﻿
/// FLIPPING BETWEEN ADVERTISERS ON IN4CHAT
/// =======================================     
var FlippingAdvertisers;
function AdvertisersFlip()
{
    try
    {    
        var parentDiv = document.getElementById("AdvertisersDivs");
                       
        var DivToDisplay;
        
        if (strAdvertisers != null && parentDiv.childNodes.length==0 && window.navigator.userAgent.indexOf("Firefox")==-1)
        {                        
            document.getElementById("AdvertisersDivs").innerHTML = strAdvertisers;
        }
        
        
        for (i=0; i<parentDiv.childNodes.length; i++ )
        {
            if (parentDiv.childNodes[i].style.zIndex == "10")
            {
                parentDiv.childNodes[i].style.zIndex = "-10";
                if (i==(parentDiv.childNodes.length-1))
                { 
                    if (strAdvertisers != null && window.navigator.userAgent.indexOf("Firefox")==-1)
                    {
                        document.getElementById("AdvertisersDivs").innerHTML = strAdvertisers;
                    }
                    DivToDisplay = parentDiv.childNodes[0];
                }
                else
                { 
                    if (parentDiv.childNodes[i+1]) 
                    {
                        DivToDisplay = parentDiv.childNodes[i+1]; 
                    }
                }
                
                if (DivToDisplay)
                    { DivToDisplay.style.zIndex = "10"; }
                i = parentDiv.childNodes.length;
            }
        }
        
        FlippingAdvertisers = window.setTimeout(AdvertisersFlip, 4000);
    }
    catch (e)
    {
        FlippingAdvertisers = window.setTimeout(AdvertisersFlip, 4000);
        window.status = "in4me";
    }
}
FlippingAdvertisers = window.setTimeout(AdvertisersFlip, 4000);



/// IN4CHAT REFRESH
/// ===============             
var FirstLoop = true;
var strCampaigns = null;
var strAdvertisers = null;

function RefreshIn4Chat()
{
    xmlHttpRefreshIn4Chat = ajaxObject();
    xmlHttpRefreshIn4Chat.onreadystatechange=function()
            {
                if(xmlHttpRefreshIn4Chat.readyState==4)
                { 
                     try
                     {                            
                        strCampaigns = xmlHttpRefreshIn4Chat.responseText.split("==========")[0];
                         
                        strAdvertisers = xmlHttpRefreshIn4Chat.responseText.split("==========")[1];                            
                        if (strAdvertisers != null)
                        {                            
                            document.getElementById("HiddenRefreshedAdvertisers").innerHTML = strAdvertisers;
                        }
                           
                     }
                     catch (e)
                     {                                    
                        //alert("");
                        RefreshIn4ChatTimeOut = window.setTimeout(RefreshIn4Chat, 5000);  
                     }
                     RefreshIn4ChatTimeOut = window.setTimeout(RefreshIn4Chat, 5000);  
                }
            }
                                      
    xmlHttpRefreshIn4Chat.open("GET", SiteURL + "CodeBehind/in4Chat.aspx?trick=" + Date() , true);
    
    xmlHttpRefreshIn4Chat.send(null);                        

}

function RefreshCampaigns()
{//IE only                
    if (window.navigator.userAgent.indexOf("Firefox")==-1)
    {
        if (FirstLoop)
        {
            FirstLoop = false;
        }
        else
        {
            if (strAdvertisers != null) //strAdvertisers!!!
            {
                document.getElementById("CampaignsMarquee").innerHTML =  strCampaigns;                           
            }
        }
    }
}
 
if (window.navigator.userAgent.indexOf("Firefox")==-1)
{//IE only
    window.onbeforeunload = DefaultClearTimeOuts;
    var RefreshIn4ChatTimeOut = window.setTimeout(RefreshIn4Chat, 5000);
}

function DefaultClearTimeOuts()
{
    try
    {
        window.clearTimeout(RefreshIn4ChatTimeOut);
    }
    catch (e)
    {
    }       
}

/// BOTTOM SMS MESSAGE
/// ==================
function ForSMSRegister()
{
    document.getElementById("ForSMSRegisterSpan").style.visibility = "visible";
    return false;
}