﻿   var count=1;
   
   // ************  for master page  ******************
//   
//  var doExitPopup = true;
//  //doExitPopup=false;
//window.onunload = function(){
//if(doExitPopup){
//                var strRoomc=0;
//               logout1(strRoomc);
//}
//}
//window.onload=function()
//{
//  
//              var strRoomc=1; 
//              logout1(strRoomc);
// }
// 
 
 
 //************************** END *******************************
 
 //*********************** For Open Chat Window *****************
 
 nextreminchatpop();
 
 
 //***************************END ******************************
 
 
 
 
var xmlHttplog;
function GetxmlHttplogObject()
        {
            var xmlHttplog=null;
            try
                {
                    // Firefox, Opera 8.0+, Safari
                    xmlHttplog=new XMLHttpRequest();
                }
            catch (e)
                {
                    // Internet Explorer
                   try
                      {
                    xmlHttplog=new ActiveXObject("Msxml2.XMLHTTP");
                       }
                   catch (e)
                     {
                    xmlHttplog=new ActiveXObject("Microsoft.XMLHTTP");
                    }
                 }
       
        return xmlHttplog;
       }
function logout1(roomc)
   {
  
    xmlHttplog=GetxmlHttplogObject();
       if (xmlHttplog==null)
          {
            alert ("Your browser does not support AJAX!");
             return;
         }          
                
              var url="/chat/chatsignout.aspx?count="+count+"&room="+roomc;          
              //alert(url)
              xmlHttplog.onreadystatechange=stateChangedlogout;
              xmlHttplog.open("GET",url,true);           
              xmlHttplog.send(null);
   }
    
    function stateChangedlogout() 
            { 
            if (xmlHttplog.readyState==4)
                { 
                  var text=xmlHttplog.responseText;                 
         
                    return xmlHttplog.responseText;
                    
  
                 }

           }
           
           
           
           
             
function GetxmlHttpforpopupObject()
        {
            var xmlHttpforpopup=null;
            try
                {
                    // Firefox, Opera 8.0+, Safari
                    xmlHttpforpopup=new XMLHttpRequest();
                }
            catch (e)
                {
                    // Internet Explorer
                   try
                      {
                    xmlHttpforpopup=new ActiveXObject("Msxml2.XMLHTTP");
                       }
                   catch (e)
                     {
                    xmlHttpforpopup=new ActiveXObject("Microsoft.XMLHTTP");
                    }
                 }
       
        return xmlHttpforpopup;
       }
       
   function reminwait()
   {
    xmlHttpforpopup=GetxmlHttpforpopupObject();
       if (xmlHttpforpopup==null)
          {
            alert ("Your browser does not support AJAX!");
             return;
         }          
                     
             // var strRoom=document.getElementById("ctl00_ctl00_MainContent_ContentPlaceHolder3_onlineuser_strRoom").value;
              //var uid=document.getElementById("ctl00_ctl00_MainContent_ContentPlaceHolder3_onlineuser_uid").value;
              var url="/livechat/remintochat.aspx?count="+count;          
            //alert(url);
             
              xmlHttpforpopup.onreadystatechange=stateChangedreminderorchatpoppu;
              xmlHttpforpopup.open("GET",url,true);           
              xmlHttpforpopup.send(null);
   }
   
    function stateChangedreminderorchatpoppu() 
            { 
            //alert("history");
            if (xmlHttpforpopup.readyState==4)
                { 
                  var text=xmlHttpforpopup.responseText;                 
           //alert(text);
                     if(text!=0)              
                     {
                      
                     doExitPopup=false;
                    // alert(text);
                    // document.getElementById("hdnflag").value="1";                     
                      
                       var text1=text.split("|");
                       //alert(text1.length);
                      if(text1.length>1)
                      {
                    
                    
                    var mine = window.open(text1[1],'_blank','toolbar=0,location=0,directories=no,status=no,menubar=0,scrollbars=yes,resizable=yes,copyhistory=no,width=490,height=300');
                     if(mine)
                        var popUpsBlocked = false
                         else
                             var popUpsBlocked = true
                              //mine.close()
                   // alert(popUpsBlocked);
                    if(popUpsBlocked)
                      alert('We have detected that your popup blocking option is activated.\n You have one request for chat.\n Please Allow Popup From ...');
                     // window.open(text1[1],'_blank','toolbar=0,location=0,directories=no,status=no,menubar=0,scrollbars=yes,resizable=yes,copyhistory=no,width=490,height=300');
                     //window.open(text1[1]);
                     }
                     //window.self.close();
                       
                      }
                    return xmlHttpforpopup.responseText;
                    
  
                 }

           }
   
        
    function nextreminchatpop()
    {
      count=parseInt(count)+1;
      reminwait();
      theTimer1=setTimeout("nextreminchatpop()", 500);
   
   }



    
function removeuserapp(str4,str)
{

  if(confirm("Chat windows already open.Do you want to open another chat windows"))
  {
     
var dt= new Date();
var my_date= dt.getDate(); 
      removeapp(str4,str);
      
       str5 = "/livechat/chatmainp.aspx?u=" + str + "&o=" + str + "&g=" + str4 + "&r=1st Room&a=&tid=" + my_date;
       
     window.open(str5,'_blank','toolbar=0,location=0,directories=no,status=no,menubar=0,scrollbars=yes,resizable=yes,copyhistory=no,width=490,height=300');
  }
  else  
   {
   return false;
     
   }
   }
   
   
   
   
   function removeapp(uid,gid)
    {
   
xmlHttpforpopupemove=GetxmlHttpforpopupemoveObject();
       if (xmlHttpforpopupemove==null)
          {
            alert ("Your browser does not support AJAX!");
             return;
         }          
                     
             // var strRoom=document.getElementById("ctl00_ctl00_MainContent_ContentPlaceHolder3_onlineuser_strRoom").value;
              //var uid=document.getElementById("ctl00_ctl00_MainContent_ContentPlaceHolder3_onlineuser_uid").value;
              var url="/livechat/removetochat.aspx?count="+count+"&uid="+uid+"&gid="+gid;          
            // alert(url);
             
              xmlHttpforpopupemove.onreadystatechange=stateChangedreminderremove;
              xmlHttpforpopupemove.open("GET",url,true);           
              xmlHttpforpopupemove.send(null);
   }
   
    function stateChangedreminderremove() 
            { 
          
            if (xmlHttpforpopupemove.readyState==4)
                { 
                  var text=xmlHttpforpopupemove.responseText;                 
        
                       
                   
                    return xmlHttpforpopupemove.responseText;
                    
  
                 }

           }
    
   
   
   function GetxmlHttpforpopupemoveObject()
        {
            var xmlHttpforpopupemove=null;
            try
                {
                    // Firefox, Opera 8.0+, Safari
                    xmlHttpforpopupemove=new XMLHttpRequest();
                }
            catch (e)
                {
                    // Internet Explorer
                   try
                      {
                    xmlHttpforpopupemove=new ActiveXObject("Msxml2.XMLHTTP");
                       }
                   catch (e)
                     {
                    xmlHttpforpopupemove=new ActiveXObject("Microsoft.XMLHTTP");
                    }
                 }
       
        return xmlHttpforpopupemove;
       }
       
   
   
    
    
    
    
    
