
var web_path="kefu/"
var guestid

 var xmlHttp = false;
   try {
     xmlHttp = new XMLHttpRequest();
   } catch (trymicrosoft) {
     try {
       xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (othermicrosoft) {
       try {
         xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
       } catch (failed) {
         xmlHttp = false;
       }  
     }
   }

 var xmlHttp_icon = false;
   try {
     xmlHttp_icon = new XMLHttpRequest();
   } catch (trymicrosoft) {
     try {
       xmlHttp_icon = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (othermicrosoft) {
       try {
         xmlHttp_icon = new ActiveXObject("Microsoft.XMLHTTP");
       } catch (failed) {
         xmlHttp_icon = false;
       }  
     }
   }

 var xmlHttp_msg = false;
   try {
     xmlHttp_msg = new XMLHttpRequest();
   } catch (trymicrosoft) {
     try {
       xmlHttp_msg = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (othermicrosoft) {
       try {
         xmlHttp_msg = new ActiveXObject("Microsoft.XMLHTTP");
       } catch (failed) {
         xmlHttp_msg = false;
       }  
     }
   }

  if (!xmlHttp) {alert("启用Ajax功能失败，您可能无法使用本站的部分功能！");}


function GetResult1() 
{
    xmlHttp.open("POST",web_path+"m_getstate.asp?listtype=guestlist_client",false);
    xmlHttp.send();
    var strResult = unescape(xmlHttp.responseText);

    var arrResult= strResult.split("###");
     ///document.write(arrResult[2]);
    for(var i =0; i<arrResult.length; i++)
    {   
        arrTmp = arrResult[i].split("@@@");
       // alert(arrTmp)
        num1 = arrTmp[0]; 
        num2 = arrTmp[1]; 
		num3 = arrTmp[2]; 
		num4 = arrTmp[3]; 
		num5 = arrTmp[4]; 
		num6 = arrTmp[5]; 
		num7 = arrTmp[6]; 
		num8 = arrTmp[7];
        if (i==0) 
		 {var str="";var str1="";
         }
        if (num2)
        {
		  if (num1=="1")
		  {
            var objname="kf_"+num6
            str="<span id="+objname+">&nbsp;&nbsp;<img src=kefu/images/icon/"+num3+".gif align=absmiddle>";
		  }
		  else
		  {
            var objname="kf_"+num6
            str="<span id="+objname+">&nbsp;&nbsp;<img src=kefu/images/icon/"+num3+"_2.gif align=absmiddle>";
		  }
          
        }

		if (num2 && num3==16)
		{
          var objname="kf_"+num6
		  if (num1=="1")
		  {
            str="<span id="+objname+">&nbsp;&nbsp;<img src=kefu/images/icon/"+num4+" align=absmiddle>";
		  }
		  else
		  {
            var objname="kf_"+num6
            str="<span id="+objname+">&nbsp;&nbsp;<img src=kefu/images/icon/"+num5+" align=absmiddle>";
		  }
          
		}

         if (num1=="1")
         { 
           
		   str=str+"&nbsp;&nbsp;<a href=javascript:void(0); onClick=window.open('/kefu/c2s.asp?userid="+num6+"','_blank','width=603,height=468,left='+(screen.availWidth-603)/2+',top='+(screen.availHeight-439)/2+',resizable=0,scrollbars=no,menubar=no,frameborder=0,status=no'); title=点击与客服人员交谈>"+num7+"</a></span>"
         }
         else
		 {
            str=str+"&nbsp;&nbsp;<a href=javascript:void(0); onClick=window.open('/kefu/guest.asp','_blank','width=603,height=439,left='+(screen.availWidth-603)/2+',top='+(screen.availHeight-439)/2+',resizable=0,scrollbars=no,menubar=no,frameborder=0,status=no'); title=客服不在线，点击留言。><font color=#666666>"+num7+"</font></a></span>"
		 }
        //var objname="kf_"+num6
        if( i<arrResult.length)
            if(i<(arrResult.length-1))
            {str2="&nbsp;&nbsp;&nbsp;&nbsp;"}else{str2=""}
         {str1=str1+str+"<br><br>"+str2}
         //  alert(str1)
        document.getElementById("kf_freezhe").innerHTML=str1;
        //document.getElementById("kf_freezhe").value=str;
		//objname.innerHTML = str;
         // document.getElementById("kf_"+num6).innerHTML =str; 
    }
} 


function GetResult2()  
{
    xmlHttp_icon.open("POST",web_path+"m_getstate.asp?listtype=guesticon_client",false);
    xmlHttp_icon.send();
    var strResult = unescape(xmlHttp_icon.responseText);
        RemoveRow();
        arrTmp = strResult.split("@@@");
        num1 = arrTmp[0]; 
        num2 = arrTmp[1]; 
		num3 = arrTmp[2]; 
		num4 = arrTmp[3]; 
		num5 = arrTmp[4]; 
        num6 = arrTmp[5]; 
        row1 = tb.insertRow();
        cell1 = row1.insertCell();
		cell1.align=num6;
		var str;
		if (num1=="在线")
		{
		   str="<a href=javascript:void(0); onClick=window.open('/kefu/c2s.asp?userid="+num2+"','_blank','width=603,height=468,left='+(screen.availWidth-603)/2+',top='+(screen.availHeight-439)/2+',resizable=1,scrollbars=no,menubar=no,frameborder=0,status=no'); title=点击与客服人员交谈><img src=kefu/images/skin/"+num3+"/icon_online.gif border=0></a>";
		}
		else
		{
		   str="<a href=javascript:void(0); onClick=window.open('/kefu/guest.asp','_blank','width=603,height=439,left='+(screen.availWidth-603)/2+',top='+(screen.availHeight-439)/2+',resizable=1,scrollbars=no,menubar=no,frameborder=0,status=no'); title=客服不在线，点击留言。><img src=kefu/images/skin/"+num3+"/icon_offline.gif border=0></a>";
		}
        cell1.innerHTML = str;

        //document.getElementById("kficon").innerHTML =str; 

}

function RemoveRow() 
{
    var iRows = tb.rows.length;
    for(var i=0; i<iRows; i++)
    {
        tb.deleteRow(0);
    }
}


function MyShow(fun_name)
{
    timer = window.setInterval(fun_name,2000);
	
}


var webchat_getinfo_everytime=5000;
var webchat_closeclientwav="N";
var webchat_closeserverwav="";
var webchat_putmsg="mid";
var webchat_puttype="auto";

 var xmlHttp_ask = false;
   try {
     xmlHttp_ask = new XMLHttpRequest();
   } catch (trymicrosoft) {
     try {
       xmlHttp_ask = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (othermicrosoft) {
       try {
         xmlHttp_ask = new ActiveXObject("Microsoft.XMLHTTP");
       } catch (failed) {
         xmlHttp_ask = false;
       }  
     }
   }

var webchat_timer_getinfo=0;
var webchat_newmsg_username="";
var wenchat_timer_popdiv=0;

function webchat_userlogin()
{
	var myurl=web_path+"kfewt_login.asp";
	var MyWebSend="mytext=data";
	xmlHttp_ask.open("POST",myurl,true);
	xmlHttp_ask.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp_ask.onreadystatechange = webchat_userlogin_callback;
	xmlHttp_ask.send(MyWebSend);
}
function webchat_userlogin_callback()
{
    var webtext;
    if (xmlHttp_ask.readyState == 4)
	 {
       if (xmlHttp_ask.status == 200)
	     {
		    webtext = xmlHttp_ask.responseText;
            var info_array=webtext.split("\r\n");
            guestid=info_array[1];

			if (webchat_puttype=="auto" && getCookie("webchat_popdiv_test")!=info_array[1]){ 
                if (info_array[2]!="offline"){
                   popmsgwin(info_array[2]);
                   setCookie("webchat_popdiv_test",info_array[1]); 
                }  
			 }

			webchat_timer_getinfo=setInterval("webchat_getinfo_update()",webchat_getinfo_everytime);
		 }
     }
}

function webchat_getinfo_update()
{
    var myurl=web_path+"kfewt_getinfo.asp";
	var MyWebSend="mytext=data";
	xmlHttp_ask.open("POST",myurl,true);
	xmlHttp_ask.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp_ask.onreadystatechange = webchat_getinfo_callback;
	xmlHttp_ask.send(MyWebSend);   
}
function webchat_getinfo_callback()
{
   if (xmlHttp_ask.readyState == 4)
   {
      if (xmlHttp_ask.status == 200)
	  {
	     var webtext;
		 webtext=xmlHttp_ask.responseText;
		 var info_array=webtext.split("\r\n");
		 if (info_array[0]=="newmsg")
		 {
		    if (webchat_timer_getinfo!=0)
			{
		     clearInterval(webchat_timer_getinfo);
			 webchat_timer_getinfo=0;
			}
			webchat_newmsg_username=info_array[1];
			if (webchat_closeserverwav=="N")
			{
			document.getElementById("webchat_sound_newmsg").play();
			}
			if (webchat_closeclientwav=="N")
			{
			document.getElementById("webchat_sound_newmsg").play();
			}

		    document.getElementById("webchat_newmsg_userspan").innerHTML=webchat_newmsg_username;
			var temp_obj=document.getElementById("webchat_newmsg_popdiv");
			temp_obj.style.display="";
			//webchat_showmsgctoc(); 
			if (webchat_putmsg=="rightdown"){ 
			   var divWidth = parseInt(temp_obj.offsetWidth,10);
			   temp_obj.style.top=parseInt(document.body.scrollTop,10) + document.body.clientHeight + 10;
			   temp_obj.style.left=document.body.clientWidth - divWidth + parseInt(document.body.scrollLeft,10);
			   if (wenchat_timer_popdiv!=0) {clearInterval(wenchat_timer_popdiv);}
			   wenchat_timer_popdiv=window.setInterval("webchat_getinfo_option()",100);
			   }
            else{ 
               temp_obj.style.top=(screen.availHeight-450)/2
               temp_obj.style.left=(screen.availWidth-250)/2
               popdivmove("webchat_newmsg_popdiv");
			   }
		 }	  
	  }
   }
}
function webchat_getinfo_option()
{ 
   var temp_obj=document.getElementById("webchat_newmsg_popdiv");
   var docHeight = document.body.clientHeight;
   var divHeight = parseInt(temp_obj.offsetHeight,10);
   if(parseInt(temp_obj.style.top,10) <= (docHeight - divHeight + parseInt(document.body.scrollTop,10)))
    {
    window.clearInterval(wenchat_timer_popdiv);
    wenchat_timer_popdiv = window.setInterval("webchat_getinfo_resizeDiv()",600);
    }
	else
	{
    temp_obj.style.top = parseInt(temp_obj.style.top,10) - 10;
	}
}
function webchat_getinfo_resizeDiv()
{
   var temp_obj=document.getElementById("webchat_newmsg_popdiv");
   var divHeight = parseInt(temp_obj.offsetHeight,10);
   var divWidth = parseInt(temp_obj.offsetWidth,10);
   var docWidth = document.body.clientWidth;
   var docHeight = document.body.clientHeight;
   temp_obj.style.top = docHeight - divHeight + parseInt(document.body.scrollTop,10);
   temp_obj.style.left = docWidth - divWidth + parseInt(document.body.scrollLeft,10);
}

function webchat_showmsgctoc(openurl) 
{
   //var myurl="s2c.asp";  
   var width=603,height=468;
   openurl=openurl+"?userid="+webchat_newmsg_username;
  /// document.write(openurl);
   //openurl=openurl+"?userid=auto";
   if (wenchat_timer_popdiv!=0) 
   {
   clearInterval(wenchat_timer_popdiv);
   wenchat_timer_popdiv=0;
   }
   document.getElementById("webchat_newmsg_popdiv").style.display="none";
   webchat_timer_getinfo=setInterval("webchat_getinfo_update()",webchat_getinfo_everytime);
   window.open(openurl,"_blank",'width=' + width + ',height=' + height + ',left='+(screen.availWidth-width)/2+',top='+(screen.availHeight-height)/2+',resizable=0,scrollbars=no,menubar=no,frameborder=0,status=no');

}

function webchat_showmsgctoc2() 
{
   if (wenchat_timer_popdiv!=0) 
   {
   clearInterval(wenchat_timer_popdiv);
   wenchat_timer_popdiv=0;
   }
   document.getElementById("webchat_newmsg_popdiv").style.display="none";
   webchat_timer_getinfo=setInterval("webchat_getinfo_update()",webchat_getinfo_everytime);
   addTab("s2callinone.asp?userid="+webchat_newmsg_username,webchat_newmsg_username);
}


function closeyq(){
document.getElementById("webchat_newmsg_popdiv").style.display="none";
    var myurl=web_path+"kfewt_saynoinvite.asp?fromuser="+escape(webchat_newmsg_username)+"&touser="+escape(guestid);
	xmlHttp_msg.open("POST",myurl,true);
	xmlHttp_msg.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp_msg.send(); 

}


function popmsgwin(username){ 
            webchat_newmsg_username=username;

			if (webchat_closeserverwav=="N")
			{
			document.getElementById("webchat_sound_newmsg").play();
			}
			if (webchat_closeclientwav=="N")
			{
			document.getElementById("webchat_sound_newmsg").play();
			}

		    document.getElementById("webchat_newmsg_userspan").innerHTML=webchat_newmsg_username;
			var temp_obj=document.getElementById("webchat_newmsg_popdiv");
			temp_obj.style.display="";
			//webchat_showmsgctoc(); 
			if (webchat_putmsg=="rightdown"){ 
			   var divWidth = parseInt(temp_obj.offsetWidth,10);
			   temp_obj.style.top=parseInt(document.body.scrollTop,10) + document.body.clientHeight + 10;
			   temp_obj.style.left=document.body.clientWidth - divWidth + parseInt(document.body.scrollLeft,10);
			   if (wenchat_timer_popdiv!=0) {clearInterval(wenchat_timer_popdiv);}
			   wenchat_timer_popdiv=window.setInterval("webchat_getinfo_option()",100);
			   }
            else{ 
               temp_obj.style.top=(screen.availHeight-450)/2
               temp_obj.style.left=(screen.availWidth-250)/2
               popdivmove("webchat_newmsg_popdiv");
			   }
}


function popdivmove(divname){ 

var temp_obj=document.getElementById(divname)
var init_pos=last_pos=temp_obj.style.posTop;
setInterval(function(){ 
var target_pos=document.body.scrollTop+init_pos; 
var step=(target_pos-last_pos)/10|0; 
temp_obj.style.posTop+=step; 
last_pos+=step; 
},1) 

}


var Mouse_Obj="none",_x,_y;
document.onmousemove=function()
{
if(Mouse_Obj!=="none")
{
document.getElementById(Mouse_Obj).style.left=_x+event.x;
document.getElementById(Mouse_Obj).style.top=_y+event.y;
event.returnValue=false;
}
}
document.onmouseup=function()
{
Mouse_Obj="none";
}
function m(o)
{
Mouse_Obj=o;
_x=parseInt(document.getElementById(Mouse_Obj).style.left)-event.x;
_y=parseInt(document.getElementById(Mouse_Obj).style.top)-event.y;
}

function setCookie(name,value) 

{
var Days = 1;
var exp = new Date();
exp.setTime(exp.getTime() + Days*24*60*60*1000);
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}


function getCookie(name) 

{
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
if(arr=document.cookie.match(reg)) return unescape(arr[2]);
else return null;
}



function delCookie(name) 

            {
            var exp = new Date();
            exp.setTime(exp.getTime() - 1);
            var cval=getCookie(name);
            if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
            }
            
            setTimeout("webchat_userlogin()",1000); 
            
            document.write('<embed src="kefu/clientmsg.wav" width="0" height="0" autostart="false" loop="false" hidden="true" id="webchat_sound_newmsg"></embed>');
            
            // 弹出框内容开始 
            document.write('<div style="position:absolute;border:0px solid #3669A3;z-index:9966;width:354px;height:158px;background:url(kefu/images/welcome.gif);filter:progid:DXImageTransform.Microsoft.Alpha(opacity=95);display:none" id="webchat_newmsg_popdiv" onmousedown="m(this.id)">');
            document.write('     <div style="position:absolute;top:6px;left:35px;width:310px;height:16px;color: #FFF;font-weight:bold;font-size:13px;">邀请对话</div>');
            document.write('	 <div style="position:absolute;top:48px;left:129px;width:211px;height:68px;color:#1268a1;font-size:13px;text-align:left;">&nbsp;&nbsp;&nbsp;&nbsp;您好！在线客服诚邀您对话！<span style="color:#FF0000;display:none" id="webchat_newmsg_userspan"></span></div>');
            document.write('	 <div style="position:absolute;top:121px;left:156px;width:185px;height:30px;"><input type="image" src="kefu/images/yes.gif" value="接受邀请" onClick=webchat_showmsgctoc("/kefu/c2s.asp"); />&nbsp;<input name="button" type="image" src="kefu/images/no.gif" onClick="closeyq();" value="看看再说" /></div>');
            document.write('</div>');
            //FloatTop();
            // 弹出框内容结束
            

document.write('<div id="kfewtFloat" style="Z-INDEX:20;right:1px;VISIBILITY:visible;WIDTH:110px;POSITION:absolute;TOP:80px;HEIGHT:300px;">');



document.write('<div id="userlist" style="display:"><table width="110" border="0" align="center" cellpadding="0" cellspacing="0">');
document.write('  <tr>');
document.write('    <td><a onclick="CloseQQ()" href="javascript:;" shape="circle" coords="91,16,12"><img src="kefu/images/skin/1/top.gif" border=0></a></td>');
document.write('  </tr>');
document.write('  <tr>');
document.write('		<td valign="top" background="kefu/images/skin/1/mid.gif">');
		
document.write('		<table width="100%" height="100%"  border="0" cellpadding="0" cellspacing="0">');
               
document.write('             <tr>');

document.write('               <td height="25" align="left" valign="middle" style="font-size: 12px; line-height: 17px">&nbsp;&nbsp;&nbsp;&nbsp;<span id="kf_freezhe"></span>');
///document.write('<img src="kefu/images/more1.gif" title="点击显示其它联系方式" onclick=change(this,v_freezhe); ><div id=v_freezhe style=DISPLAY:none;margin-top=3px><table width=80 border=0 cellpadding=0 cellspacing=1 bgcolor=#ACD6FF align=center><tr><td align=center bgcolor=#FFFFFF><a target=blank href=tencent://message/?uin=153696376&Site=http://www.kfewt.com&Menu=yes><img border=0 SRC=http://wpa.qq.com/pa?p=1:153696376:1 title=点击用QQ与我联系></a></td></tr><tr><td align=center bgcolor=#FFFFFF><a target=blank href=msnim:add?contact=freezhe@live.cn title=点击用MSN与我联系> <font size=2>MSN</font></a> </td></tr><tr><td align=center bgcolor=#FFFFFF><a target=_blank href=http://amos1.taobao.com/msg.ww?v=2&uid=freezhe&s=1 ><img border=0 src=http://amos1.taobao.com/online.ww?v=2&uid=freezhe&s=1 title=点击用淘宝旺旺与我联系></a></td></tr><tr><td align=center bgcolor=#FFFFFF><a target=_blank href=http://amos.im.alisoft.com/msg.aw?v=2&uid=freezhe&site=cnalichn&s=4 ><img border=0 src=http://amos.im.alisoft.com/online.aw?v=2&uid=freezhe&site=cnalichn&s=4 title=点击用贸易通与我联系 /></a></td></tr><tr><td align=center bgcolor=#FFFFFF> <a target=_blank href=baidu://message/?id=freezhe><img border=0 src=http://tieba.baidu.com/tb/img/hi/hiOnline.gif title=点击用百度HI与我联系 /></a> </td></tr><tr><td align=center bgcolor=#FFFFFF> <a target=_blank href=http://edit.yahoo.com/config/send_webmesg?.target=freezhe&.src=pg title=点击用雅虎通与我联系><img border=0  src=http://opi.yahoo.com/online?u=freezhe&m=g&t=0&l=cn />&nbsp;<font size=2>雅虎通</font></a> </td></tr><tr><td align=center bgcolor=#FFFFFF> <a target=_blank href=skype:freezhe?call onclick=return skypeCheck(); title=点击用SKYPE与我联系><img src=http://mystatus.skype.com/smallicon/freezhe style=border:none; >&nbsp;<font size=2>SKYPE</font></a> </td></tr></table></div></td>');
			   

document.write('</td></tr>');
document.write('		</table>');
		
document.write('		</td>');
document.write('  </tr>');
document.write('	<tr>');
document.write('		<td><img src="kefu/images/skin/1/bottom.gif"></td>');
document.write('	</tr>');
document.write('</table></div><div id=showuserlist style="float:right;display:none"><a onclick="showQQ()" href="javascript:;" shape="circle" coords="91,16,12"><img src="kefu/images/skin/1/xiao.gif" width="59" height="73" border=0></a></div>');

MyShow("GetResult1()");

document.write('</div>');

var tips; var theTop = 80/*这是默认高度,越大越往下*/; var old = theTop;

function initFloatTips() {
  tips = document.getElementById('kfewtFloat');
  moveTips();
};
function moveTips() {
  var tt=50;
  if (window.innerHeight) {
    pos = window.pageYOffset
  }
  else if (document.documentElement && document.documentElement.scrollTop) {
    pos = document.documentElement.scrollTop
  }
  else if (document.body) {
    pos = document.body.scrollTop;
  }

  pos=pos-tips.offsetTop+theTop;
  pos=tips.offsetTop+pos/10;
	
  if (pos < theTop) pos = theTop;
  if (pos != old) {
    tips.style.top = pos+"px";
    tt=10;
		//alert(tips.style.top);
  }
	
  old = pos;
  setTimeout(moveTips,tt);
}
//!]]>
initFloatTips();




  function change(imgobj,divobj)     
  {   
      var img_path=imgobj.src;  
      if (img_path.lastIndexOf("more1.gif")>0){
	    imgobj.src="kefu/images/more2.gif"; 
		imgobj.title="点击关闭其它联系方式";
	    divobj.style.display='block';
	  }
      else{
	    imgobj.src="kefu/images/more1.gif";
		imgobj.title="点击显示其它联系方式";
	    divobj.style.display='none';
	  }
  }  
  

setCookie("vcome",document.referrer);

function CloseQQ()
{
showuserlist.style.display="";
userlist.style.display="none";
return true; 
}
function showQQ()
{
showuserlist.style.display="none";
userlist.style.display="";
return true; 
}
