var online= new Array();
var urlroot = "http://im.bizapp.qq.com:8000/";
var urlroot1= "http://www.shui.org/js/kefu/";
var tOut = -1;
var drag = false;
var g_safeNode = null;
lastScrollY = 0;
var kfguin="800030030";
var ws = '';
var companyname;
var welcomeword;
var type="0";

if(kfguin)
{
  rightDivHtml = '<div id="rightDiv" style="position:absolute; top:160px; right:1px;">';

  rightDivHtml += kf_getPopupRightDivHtml(kfguin,ws);
  
  rightDivHtml += '</div>';
  
  document.write(rightDivHtml);
  
  if(type==1 && kf_getCookie('hasshown')==0)
  {
  	  companyname = companyname.substr(0,15);	   	  
      welcomeword = kf_processWelcomeword(welcomeword);
  	  
  	  kfguin = kf_getSafeHTML(kfguin);
  	  companyname = kf_getSafeHTML(companyname);
  	  
  	  welcomeword = welcomeword.replace(/<brT>/g,'\r\n');
  	  welcomeword = kf_getSafeHTML(welcomeword);
  	  welcomeword = welcomeword.replace(/\r/g, "").replace(/\n/g, "<BR>");
  
      window.setTimeout("kf_sleepShow()",10000);
      //kf_sleepShow();
  }
  window.setTimeout("kf_moveWithScroll()",1);
  //window.setInterval("wpa_count()",10000);
}

function kf_getSafeHTML(s)
{
	var html = "";
	var safeNode = g_safeNode;
	
	if(!safeNode)
	{
		safeNode = document.createElement("TEXTAREA");
	}

	if(safeNode)
	{
		safeNode.innerText = s;
		html = safeNode.innerHTML;
		safeNode.innerText = "";
		
		g_safeNode = safeNode;
	}
	
	return html;
}

function kf_moveWithScroll() 
{ 
	if(typeof window.pageYOffset != 'undefined') { 
		nowY = window.pageYOffset; 
	}else if(typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') { 
		nowY = document.documentElement.scrollTop; 
	}else if(typeof document.body != 'undefined') { 
		nowY = document.body.scrollTop; 
	}  

	percent = .1*(nowY - lastScrollY);
	if(percent > 0) 
	{
		percent=Math.ceil(percent);
	}else{
		percent=Math.floor(percent);
	}

	document.getElementById("rightDiv").style.top = parseInt(document.getElementById("rightDiv").style.top) + percent+"px";
	if(document.getElementById("kfpopupDiv"))
	{
		document.getElementById("kfpopupDiv").style.top = parseInt(document.getElementById("kfpopupDiv").style.top) + percent+"px";
	}
	lastScrollY = lastScrollY + percent;
	tOut = window.setTimeout("kf_moveWithScroll()",1);
}

function kf_hide() 
{
	if(tOut!=-1)
	{
		clearTimeout(tOut);   
		tOut=-1;
	}
	document.getElementById("rightDiv").style.visibility = "hidden";
}

function kf_hidekfpopup()
{
	if(tOut!=-1)
	{
		clearTimeout(tOut);   
		tOut=-1;
	}
	document.getElementById("kfpopupDiv").style.visibility = "hidden";
	tOut=window.setTimeout("kf_moveWithScroll()",1);
}

function kf_getPopupRightDivHtml(kfguin,reference)
{	
	var temp = "";
	temp += '<div class="wpa_popup" style="width:90px; height:170px;">';
	temp += '<div style="width:8px; height:170px; float:left; background:url('+urlroot1+'bg_1.gif);"></div>';
	temp += '<div style="float:left; width:74px; height:170px; background:url('+urlroot1+'middle.jpg); background-position: center;">';
	temp += '<div ><h1 style="line-height:17px; font-size:14px; color:#FFF; margin:0px; padding:10px 0 13px 8px; display:block;">&nbsp;</h1></div>';
	temp += '<div style="height:27px; padding:3px 0 0 0px; clear:both;"><div style="width:74px; height:22px; float:left; "><a href="http://chat.53kf.com/company.php?arg=yijiawater&style=4" target="_blank"><img  src="http://chat.53kf.com/kfimg.php?arg=yijiawater&style=4" border=0 width=74></a></div></div>';
	temp += '<div style="height:27px; padding:3px 0 0 0px; clear:both;"><div style="width:74px; height:22px; float:left; "><a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=800030030&site=qq&menu=yes"><img border="0" src="http://wpa.qq.com/pa?p=2:800030030:41" border=0 width=74></a></div></div>';
	temp += '<div style="height:27px; padding:3px 0 0 0px; clear:both;"><div style="width:74px; height:22px; float:left; "><img border="0" src="http://amos1.taobao.com/online.ww?v=2&uid=westnet&s=1" alt="点击这里给我发消息" onclick="javascript:window.open(\'http://amos1.taobao.com/msg.ww?v=2&uid=westnet&s=1\',\'alim\',\'\')"  class="pointer" align="absmiddle"  width=74 /></div></div>';
	temp += '<div style="clear:both;"></div></div>';
	temp += '<div style="width:8px; height:170px; float:left; background:url('+urlroot1+'bg_1.gif) right;"></div></div>';
	return temp;
}

