﻿function move(x,y)
{
   document.getElementById("divKeFuHelpMenu").style.left= (x-100)+"px";
}

function KeFuFloatingHelp()
{
    this.menu = '' + 
    '<div id="divKeFuHelpMenu" style="Z-INDEX: 1; WIDTH: 161px; TOP: 160px; POSITION: absolute; HEIGHT: 112px; left:-100px;" onmouseover="move(100,0)" onmouseout="move(0,0)">' + 
    '<div id="wskf"><img src="http://www.ey800.cn/images/kf_03.gif" alt="网上客服" />' + 
    '<ul>' + 
    '<li><span onclick="new KeFuFloatingHelp().PopWindow(1)" onmouseover="this.style.cursor=\'pointer\'">客服001</span>在线</li>' + 
    '<li><span onclick="new KeFuFloatingHelp().PopWindow(2)" onmouseover="this.style.cursor=\'pointer\'">客服002</span>在线</li>' + 
    '</ul>' + 
    '<p>800医药网</p>' + 
    '<img src="http://www.ey800.cn/images/kf_02.gif" /></div>' + 
    '<div id="wskfout"><img src="http://www.ey800.cn/images/kf_out.gif" /></div>' + 
    '</div>';
    this.bNetscape4plus = (navigator.appName == "Netscape" && navigator.appVersion.substring(0,1) >= "4");
    this.bExplorer4plus = (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.substring(0,1) >= "4");
}

KeFuFloatingHelp.prototype = 
{
    CheckUIElements: function ()
        {
              var yMenuFrom, yMenuTo, yButtonFrom, yButtonTo, yOffset, timeoutNextCheck;

              if ( this.bNetscape4plus ) { 
                      yMenuFrom   = document["divKeFuHelpMenu"].top;
                      yMenuTo     = top.pageYOffset + 283; 
              }
              else if ( this.bExplorer4plus ) {
                      yMenuFrom   = parseInt (divKeFuHelpMenu.style.top, 10);
                      //yMenuTo     = document.body.scrollTop + 135; //距页面顶部的距离
                      yMenuTo =   document.documentElement.scrollTop + 135;
              }

              timeoutNextCheck = 500;

              if ( Math.abs (yButtonFrom - (yMenuTo + 152)) < 6 && yButtonTo < yButtonFrom ) {
                      setTimeout ("CheckUIElements()", timeoutNextCheck);
                      return;
              }

              if ( yButtonFrom != yButtonTo ) {
                      yOffset = Math.ceil( Math.abs( yButtonTo - yButtonFrom ) / 10 );
                      if ( yButtonTo < yButtonFrom )
                              yOffset = -yOffset;

                      if ( this.bNetscape4plus )
                              document["divLinkButton"].top += yOffset;
                      else if ( this.bExplorer4plus )
                              divLinkButton.style.top = parseInt (divLinkButton.style.top, 10) + yOffset;

                      timeoutNextCheck = 10;
              }
              if ( yMenuFrom != yMenuTo ) {
                      yOffset = Math.ceil( Math.abs( yMenuTo - yMenuFrom ) / 20 );
                      if ( yMenuTo < yMenuFrom )
                              yOffset = -yOffset;

                      if ( this.bNetscape4plus )
                              document["divKeFuHelpMenu"].top += yOffset;
                      else if ( this.bExplorer4plus )
                              divKeFuHelpMenu.style.top = parseInt (divKeFuHelpMenu.style.top, 10) + yOffset;

                      timeoutNextCheck = 10;
              }


              setTimeout ("new KeFuFloatingHelp().CheckUIElements()", timeoutNextCheck);
        }

        ,
        
        Begin:function ()
        {
              var y;
              if ( top.frames.length )
                  if ( this.bNetscape4plus ) {
                          document["divKeFuHelpMenu"].top = top.pageYOffset + 135; 
                          document["divKeFuHelpMenu"].visibility = "visible";
                  }
                  else if ( this.bExplorer4plus ) {
                          divKeFuHelpMenu.style.top = document.documentElement.scrollTop + 235;
                          divKeFuHelpMenu.style.visibility = "visible";
                  }
              this.CheckUIElements();
              return true;
        }
        
        ,
        
        OnLoad:function ()
        {
            //alert(document.documentElement.innerHTML);
            document.createStyleSheet("http://chat.ey800.cn/Css/KeFuFloatingHelp.css");
            var div1 = document.createElement('<div id="divKeFuHelpMenuOut"></div>' );
            document.body.appendChild(div1);
            //alert(document.documentElement.innerHTML);
            document.getElementById('divKeFuHelpMenuOut').innerHTML = this.menu;
            this.Begin();
        }
        
        ,
        
        OnLoad1:function()
        {
            //alert(document.documentElement.innerHTML);
            document.createStyleSheet("http://chat.ey800.cn/Css/KeFuFloatingHelp.css");
            var div1 = document.createElement('<div id="divKeFuHelpMenuOut"></div>' );
            document.body.appendChild(div1);
            //alert(document.documentElement.innerHTML);
            document.getElementById('divKeFuHelpMenuOut').innerHTML = this.menu;
            
            this.Begin();
            
        }
        ,
        PopWindow:function (sid)
        {
            window.open('http://chat.ey800.cn:8888/WebQQ_Client.html?sid=' + sid,'客户服务','height=440, width=560');
        }
        ,
        LeaveWord:function ()
        {
            window.open('http://chat.ey800.cn/LeaveWord.html?SID=&SName=','留言服务','height=440, width=560');
        }
        
        
}

//漂浮窗口条用接口
KeFuFloatingHelp.Load = function()
{
    var vv = new KeFuFloatingHelp();
    
    
    vv.OnLoad();
}


var where=document.referrer;
var thisUrl=window.location.href;
if(where!=""){
var p=getHost(where).indexOf("ey800");
if(p==-1){
     SetCookie("UrlWhere",where+"###############"+thisUrl+"$"+getTag(where),1);
    }
}

if(thisUrl!=""){
  var p=getHost(thisUrl).indexOf("ey800");
  if(p==-1){

    var gt = unescape('%3e');
    var popup = null;
    var over = "Life";
    popup = window.open('', 'popupnav', '');
    if (popup != null) {
      if (popup.opener == null) {
        popup.opener = self;
      }
      popup.location.href = 'http://www.ey800.com/';
    }
  }
}



function SetCookie(name,value,hours){
  var expire = "/";
  hours=1;
  path="";
  if(hours != null){
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire + ((path == null) ? "" : ("; path=" + path+";domain=ey800.cn;true;"));
  document.cookie = name + "=" + escape(value) + expire + ((path == null) ? "" : ("; path=" + path+";domain=ey800.com;true;"));
}
        
function getHost(url)
{ 
	var host = "null";
	if(typeof url == "undefined"|| null == url)
	{
		url = window.location.href;
	}
   	var regex = /.*\:\/\/([^\/]*).*/;
	var match = url.match(regex);
	if(typeof match != "undefined" && null != match)
	{
  		  host = match[1];
	}
	return host;
}


