﻿var kf_success=1; var kftype=2;
    // has defined <!DOCTYPE... > 
    function hasdoctype()
    {
      var ret=false;
      try
      {
        if(document.compatMode=="BackCompat")
          ret=false;
        else if (document.compatMode=="CSS1Compat")
          ret=true;
        else
          ret=true;
      }
      catch(e){ ret=false }
      return ret;
    }

    // ie8 =  IE8_Partner_Build [2008-12-11] 
    function detectBrowser()
    { 
      var ret="ie6"; // default 
      var user_agent = navigator.userAgent; 
      if(user_agent.indexOf("compatible")>-1)
      {
        if(user_agent.indexOf("MSIE 6.0") > -1)
          ret="ie6"
        else if(user_agent.indexOf("MSIE 7.0") > -1)
          ret="ie7";
        else if(user_agent.indexOf("MSIE 8.0") > -1)
          ret="ie8";
      }
      else if(user_agent.indexOf("Gecko") > -1)
        ret="firefox";

      return ret;
    }
    
    // 间距小于步进，则移动间距的距离 
    function smoothMove(start,end)
    {
      var step=(end-start)*0.2;
			posi=start+step;
      if(step>0)
      {
        if(posi>end)
          posi=end;
      }
      else
      {
        if(posi<end)
          posi=end;
      }
      return posi;
    }

    var hasdoctype=hasdoctype();
    var browser=detectBrowser();

		function _createIconDivMain()
					{
						if(document.getElementById(this.config["iconDiv"])==null)
            {
              var id=this.config["id"];
              setTimeout('kf_icons['+id+'].createIconDivMain()',500);
              return ;
            }
						if(document.getElementById(this.config["iconDiv"]).innerHTML.indexOf('.gif')!=-1 
							|| document.getElementById(this.config["iconDiv"]).innerHTML.indexOf('.jpg')!=-1 
							|| document.getElementById(this.config["iconDiv"]).innerHTML.indexOf('.swf')!=-1) 
						{
							return ;
						}
						if (this.config["isonline"]==1) 
							imgsrc=this.config["img_on"];
						else 
							imgsrc=this.config["img_off"];
						var html="";
//						if (this.config["iframe_flag"]==1)
//						{   
//							html += "<iframe   style='position:absolute;z-index:7998;width:0px;height:0px;top:0px;left:0px;' frameborder='0' ></iframe>";
//						} 
						//var kf="<img onclick=\"setIsinvited();kf_icons["+this.config["id"]+"].wopen('"+this.setParameter()+"')\" src=\""+imgsrc+"\" style='cursor:pointer'>"; 
var kf = "<div id=\"kfshow\" style=\"display:none\"><table width=\"143\" height=\"242\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
kf += "  <tr>";
kf += "    <td valign=\"top\" background=\"\/images\/kf001.gif\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
kf += "      <tr><td>&nbsp;<\/td><\/tr>";
kf += "      <tr><td height=\"68\" align=\"center\"><a href=\"http:\/\/sighttp.qq.com\/cgi-bin\/check?sigkey=f27e6ac22a9f312c6687aaf2b56faafb9ceb82c649a15331d539b6bd8b9541b4\"; target=_blank; onclick=\"var tempSrc=\'http:\/\/sighttp.qq.com\/wpa.js?rantime=\'+Math.random()+\'&sigkey=f27e6ac22a9f312c6687aaf2b56faafb9ceb82c649a15331d539b6bd8b9541b4\';var oldscript=document.getElementById(\'testJs\');var newscript=document.createElement(\'script\');newscript.setAttribute(\'type\',\'text\/javascript\'); newscript.setAttribute(\'id\', \'testJs\');newscript.setAttribute(\'src\',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;\"><img border=\"0\" SRC=\'http:\/\/wpa.qq.com\/pa?p=1:1411668318:7\' alt=\"点击这里给我发消息\"><\/a><br\/>在线客服1<\/td><\/tr>";
kf += "      <tr><td height=\"68\" align=\"center\"><a  href=\"http:\/\/sighttp.qq.com\/cgi-bin\/check?sigkey=93e8de109ea7d2a2fdd958f959fa027e872d3e737925dbf479392a80e828d6df\"; target=_blank; onclick=\"var tempSrc=\'http:\/\/sighttp.qq.com\/wpa.js?rantime=\'+Math.random()+\'&sigkey=93e8de109ea7d2a2fdd958f959fa027e872d3e737925dbf479392a80e828d6df\';var oldscript=document.getElementById(\'testJs\');var newscript=document.createElement(\'script\');newscript.setAttribute(\'type\',\'text\/javascript\'); newscript.setAttribute(\'id\', \'testJs\');newscript.setAttribute(\'src\',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;\"><img border=\"0\" SRC=\'http:\/\/wpa.qq.com\/pa?p=1:1183776148:1\' alt=\"点击这里给我发消息\"><\/a><br\/>在线客服2<\/td><\/tr>";

kf += "      <tr><td height=\"50\" align=\"center\">咨询电话：<br\/>0755-&nbsp;&nbsp;&nbsp;<br\/>25012501<br\/>13088845488&nbsp;<\/td><\/tr>";
kf += "      <tr><td>&nbsp;<\/td><\/tr>";
kf += "    <\/table><\/td>";
kf += "    <td width=\"23\"><a href=\"javascript:void(0)\" onclick=\"ShowKf(false);\"><img src=\"\/images\/kf002.gif\" width=\"23\" height=\"242\" border=\"0\" \/><\/a><\/td>";
kf += "  <\/tr>";
kf += "<\/table><\/div>";
kf += "<div id=\"kfhidd\" style=\"display:block\"><table width=\"42\" height=\"242\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
kf += "  <tr><td><a href=\"javascript:void(0)\" onclick=\"ShowKf(true);\"><img src=\"\/images\/kf01.gif\" width=\"42\" height=\"241\" border=\"0\" \/><\/a><\/td>";
kf += "  <\/tr>";
kf += "<\/table><\/div";

//						if (this.config["record_url"]!="" && this.config["isonline"]==0)
//						{
//							kf="<a href=\""+this.config["record_url"]+"\" target='_blank'><img border=0 src=\""+imgsrc+"\" style='cursor:pointer'></a>"; 
//						}
						html += "<DIV id='"+this.config["iconDivMain"]+"' style='z-index:7999;display:"+this.display+";left: "+this.left+"px; top: "+this.top+"px;width:"+this.config["width"]+"px;height:"+this.config["height"]+"px; overflow:hidden;POSITION: absolute;text-align:left'>"+kf+"</div>";

						document.getElementById(this.config["iconDiv"]).innerHTML=html;
						this.iconDivMain=document.getElementById(this.config["iconDivMain"]);

					}  //to avoid the no 

  if (typeof(kf_icons)=="undefined")
  {
    var kf_icons=new Array();
    function hishow(id,img_url)
    {
      var divname="hsdiv"+id;
      if(document.getElementById(divname).style.display=="")
      {
        document.getElementById(divname).style.display="none";
        document.getElementById("arrow"+id).src="http://chat.53kf.com/"+img_url+"arrow2.gif";
      }
      else
      {
        document.getElementById(divname).style.display="";
        document.getElementById("arrow"+id).src="http://chat.53kf.com/"+img_url+"arrow.gif";
      }
    }

    function kfIcon()
    { 
      this.config=new Array();
      this.left=-200;//图标需要到达的 left 
      this.top=0;
      this.width=0;//图标宽度 
      this.height=0;//图标宽度 
      this.offsetLeft=0;//距离左侧宽度，包括滚动过的距离 
      this.scrolledX=0;//图标水平滚动条滚动过的距离 
      this.scrolledY=0;
      this.issmooth=false;//是否平滑移动 
      this.loopmillisecond=40;//图标循环定位的毫秒，数值越大越慢，对CPU影响越小 
      this.Xstep=4;//水平步进基数,数字越大越平滑，也越慢 
      this.Ystep=4;
      this.pageW=0;//页面总宽度 
      this.pageH=0;
      this.display="";//是否显示图标,值 "none"|"" 
      this.iconDiv=null;
      this.iconDivMain=null;
      this.autoScrollTimer=null;

      this.init=_init;
      this.autoScroll=scroll;
      this.createIconDivMain=_createIconDivMain;//
      this.setParameter=_setParameter;//在 createIconDivMain 中调用 
      this.wopen=_wopen;//同上 
      this.closeIcon=_closeIcon; //同上 
      this.hidden=_hidden; //同上 
    };

    function scroll()
    {
      //this.createIconDivMain();
     //if(document.getElementById("Xstep"))   
      //this.Xstep=document.getElementById("Xstep").value;
     //if(document.getElementById("Ystep"))   
      //this.Ystep=document.getElementById("Ystep").value;
      //alert("scroll");
      try
      {
        this.offsetLeft=this.iconDivMain.offsetLeft;
        this.width=parseInt(this.iconDivMain.style.width.replace("px",""));
        this.height=parseInt(this.iconDivMain.style.width.replace("px",""));
      }
      catch(e)
      {
        this.iconDivMain=document.getElementById(this.config["iconDivMain"]);
        return ; 
      }

      this.scrollbarW=20;// scrollbar width in ie6,ie7,ie8 = 20px
      this.scrolledY = document.body.scrollTop;
      this.scrolledX = document.body.scrollLeft;
      if(this.scrolledY==0)
        this.scrolledY = document.documentElement.scrollTop;
      if(this.scrolledX==0)
        this.scrolledX = document.documentElement.scrollLeft;

      if(browser=="ie6")
      {   
        this.pageH = document.documentElement.offsetHeight;
        this.pageW = document.documentElement.offsetWidth;
      }
      else if(browser=="ie7")
      {
        this.pageH = document.documentElement.offsetHeight;
        if(hasdoctype)
          this.pageW = document.documentElement.offsetWidth+21;
        else
          this.pageW = document.documentElement.offsetWidth;
      }
      else if(browser=="ie8")
      {
        this.pageH = document.documentElement.offsetHeight;
        this.pageW = document.documentElement.offsetWidth;
      }
      else if(browser=="firefox")
      {
        this.pageH = window.innerHeight;
        // 21=17+4 
        // 17 for document.documentElement.clientWidth in firefox 3
        // 4 for document.documentElement.scrollLeft in firefox 3 differently from ie6,ie7
        //
        this.pageW = document.documentElement.clientWidth+21; 
      }
      else
      {   
        this.pageH = document.documentElement.offsetHeight;
        this.pageW = document.documentElement.offsetWidth;
      }

      if(this.top!=(this.scrolledY+this.config["offsetH"]))
      {
        this.top=this.scrolledY+this.config["offsetH"];
      }

      if(this.config["showmodel"]==1)
      {
        if(this.left!=(this.scrolledX+this.pageW))
        {
          var iconDivWidth=this.scrolledX+this.config["offsetW"]-this.offsetLeft;
          iconDivWidth=(iconDivWidth>0?1:-1)*Math.ceil(Math.abs(iconDivWidth));
          this.left=this.offsetLeft+iconDivWidth;
        }
      }
      else
      {
        if(this.left!=(this.scrolledX+this.pageW-this.width-this.config["offsetW"]-this.scrollbarW))
        {
          var iconDivWidth=this.scrolledX+this.pageW-this.width-this.config["offsetW"]-this.scrollbarW-this.offsetLeft;
          iconDivWidth=(iconDivWidth>0?1:-1)*Math.ceil(Math.abs(iconDivWidth));
          this.left=this.offsetLeft+iconDivWidth;
        }
      }
      //set kf_icon postiotn
      //超出窗口边界，直接移动到窗口边界再平滑移动 
      var left=parseInt(this.iconDivMain.style.left.replace("px",""));
      var top=parseInt(this.iconDivMain.style.top.replace("px",""));
      //var shallMove=false;
      if(this.issmooth==true)
      {
        if(left!=this.left)
        {
          if(left<(this.scrolledX-this.width))
            left=this.scrolledX-this.width;
          if(left>this.scrolledX+this.pageW)
            left=this.scrolledX+this.pageW;
          left=smoothMove(left,this.left);
          //shallMove=true;
        }
        if(top!=this.top)
        {
          if(top<(this.scrolledY-this.height))
            top=this.scrolledY-this.height;
          if(top>this.scrolledY+this.pageH)
            top=this.scrolledY+this.pageH;
          top=smoothMove(top,this.top);
          //shallMove=true;
        }
      }
      else if(this.issmooth==false)
      {
        left=this.left;
        top=this.top; 
        this.issmooth=true;
      }
      this.iconDivMain.style.left=left+"px";
      this.iconDivMain.style.top=top+"px";

      //if(shallMove == true)
        //clearInterval(this.autoScrollTimer);
    }
    
    function _wopen(com) 
    {
      if (this.config["is_zdyurl"]==1)
        window.open(this.config["zdyurl"],"_blank","height="+473+",width="+703+",top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=yes,scrollbars=no,location=no,titlebar=no");
      else  
        window.open(this.config["server_path"]+"/webCompany.php?arg="+this.config["arg"]+com,"_blank","height="+473+",width="+703+",top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=yes,scrollbars=no,location=no,titlebar=no");
    };

    function _setParameter()
    {
      var params="";
      params+=this.config["style_id"];
      params+=this.config["language"];
      params+=this.config["onurl"]; 
      params+=this.config["lytype"];
      params+=this.config["lyurl"];
      params+=this.config["copartner"];
      params+=this.config["username"];
      params+=this.config["userinfo"];
      params+=this.config["charset"];	
      params+=this.config["introurl"];
      params+=this.config["kf"];
      params+=this.config["referer"];
      params+=this.config["keyword"];
      params+=this.config["company_tpl"];
			params+=this.config["brief"];
			params+=this.config["logo"];
			params+=this.config["question"];
      return params;
    };
    function _hidden()
    {
      this.display="none";
      document.getElementById(this.config["iconDivMain"]).style.display="none";
      try
      {
        clearInterval(kf_icons[this.config["kf_icon_id"]].autoScrollTimer);
      }
      catch(e){}
    };
	
	function ShowKf(isShow)
	{
		 if (isShow) {
            document.getElementById('kfshow').style.display='block';
            document.getElementById('kfhidd').style.display='none';
        }
        else {
            document.getElementById('kfshow').style.display = 'none';
            document.getElementById('kfhidd').style.display = 'block';
		}
	}

    function _closeIcon()
    {
      if (1==1 || 63933955==600603 || 63933955==61393572 || 63933955==1413303 || 63933955==61389920 || 63933955==61420906 || 63933955==61578368)
        return "<img onclick='kf_icons["+this.config["id"]+"].hidden()' style='position:absolute; right:7px;top:4px; cursor:hand;' src='http://www25.53kf.com/img/kflogo/close.gif'/>";
      return "";
    };

    function _init()
    {
      document.write('<div id="'+this.config["iconDiv"]+'" ></div>');
      this.iconDiv=document.getElementById(this.config["iconDiv"]);
      this.createIconDivMain();
    };
 
  }

  if(typeof(kf_icon_id)=="undefined")
    kf_icon_id=1;
  else
    kf_icon_id++;
  kf_icons[kf_icon_id]=new kfIcon();
  kf_icons[kf_icon_id].config["id"]=kf_icon_id;
  kf_icons[kf_icon_id].config["iframe_flag"]="0";
  kf_icons[kf_icon_id].config["style_id"]="&style=1";
  kf_icons[kf_icon_id].config["isonline"]="1";
  kf_icons[kf_icon_id].config["img_on"]="/images/kf02.gif";
  kf_icons[kf_icon_id].config["img_off"]="/images/kf02.gif";
  kf_icons[kf_icon_id].config["height"]="242";
  kf_icons[kf_icon_id].config["width"]="143";
  kf_icons[kf_icon_id].config["showmodel"]=parseInt("1");
  kf_icons[kf_icon_id].config["offsetW"]=parseInt("5");
  kf_icons[kf_icon_id].config["offsetH"]=parseInt("200");
  kf_icons[kf_icon_id].config["iconDivMain"]="iconDivMain"+kf_icon_id;
  kf_icons[kf_icon_id].config["iconDiv"]="iconDiv"+kf_icon_id;

  kf_icons[kf_icon_id].init();
  eval('kf_icons['+kf_icon_id+'].autoScrollTimer=window.setInterval("kf_icons['+kf_icon_id+'].autoScroll()", '+kf_icons[kf_icon_id].loopmillisecond+');');
