﻿// Developed by Lokesh Goyal

function getXMLHTTP( ) 
{
    var XMLHTTP = null;
    if (window.ActiveXObject) 
    {
        try 
        {
            XMLHTTP = new ActiveXObject("Msxml2.XMLHTTP");
        } 
        catch (e) 
        {
            try 
            {
                XMLHTTP = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    } 
    else if (window.XMLHttpRequest) 
    {
        try 
        {
            XMLHTTP = new XMLHttpRequest( );
        } catch (e) {}
    }
    return XMLHTTP;
}
var XMLHTTP;
var imgChat;
function checkSupport()
{
    imgChat=document.getElementById("imgChat");
    if(imgChat)
    {
        try
        {
            if(!XMLHTTP)
                XMLHTTP=getXMLHTTP();
            var url="handlers/Support.ashx";
            XMLHTTP.open("POST",url,true);
            XMLHTTP.onreadystatechange=function(){
                if(XMLHTTP.readyState==4 && XMLHTTP.status==200)
                {
                    if(XMLHTTP.responseText=="-1")
                        imgChat.src="images/cl_notavailable.gif";
                    else if(XMLHTTP.responseText=="1")
                        imgChat.src="http://www.taxmann.com/taxmannchat/CuteSoft_Client/CuteChat/images/dtl_online.gif";
                    else
                        imgChat.src="http://www.taxmann.com/taxmannchat/CuteSoft_Client/CuteChat/images/dtl_offline.gif";
                } 
            };
            XMLHTTP.send(null);
         }
         catch(ex)
         {
            if(!document.getElementById("imgChat"))
            {
                var img=document.createElement("img");
                img.id="imgChat";
                document.getElementById("livesupport").appendChild(img);
            }
            img.src="images/cl_notavailable.gif";
         }
    }
    else
    {
        if(!document.getElementById("imgChat"))
        {
            var img=document.createElement("img");
            img.id="imgChat";
            document.getElementById("livesupport").appendChild(img);
        }
        img.src="images/cl_notavailable.gif";
    }
}

window.setInterval("checkSupport()",100000);
