﻿//取出COOKIE name=变量名
function fGetCookie(name) {
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0) { 
    offset = document.cookie.indexOf(search);
    if (offset != -1) { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end));
    }
  }
  return cookieValue;
}

//设置COOKIE 变量名,内容,时间(小时)
function fSetCookie(name, value, hours) {
  var expire = "";
  var domain = "; domain=aothink.com; path=/";
  if(hours != "") {
    expire = new Date((new Date()).getTime() + hours * 60 * 60 * 1000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + domain;
}

//获取URL参数
function Request_URL()
{
	var strHref = top.document.referrer;
	if (strHref=="")
	{
		strHref=this.location.href;
	}
	strHref=strHref.replace("http://","");
	var arrTmp = strHref.split("/");
	if (arrTmp[1]=="28")
	{
		return "28";
	}
	else
	{
		var arrTmp = strHref.split(".");
		return arrTmp[1];
	}
}

come_from=fGetCookie("come_from"); //取出值
if (come_from=="")
{
	come_from=Request_URL();
	fSetCookie("come_from",come_from,1);
}

//=====================

var asw_xinming=new Array();
var asw_qq=new Array();
var sort_array=new Array();

asw_xinming[0]="客服";
asw_qq[0]="415827010";

asw_xinming[1]="客服";
asw_qq[1]="467373722";


var sort_array=[0,1];
var show_xinming,show_qq,qq_list="";
sort_array.sort(function(){return Math.random()>0.5?-1:1;});

for (i=0;i<=1;i++) 
{
	show_xinming=asw_xinming[sort_array[i]];
	show_qq=asw_qq[sort_array[i]];
	qq_list+="<a href='http://wpa.qq.com/msgrd?V=1&Uin="+show_qq+"&Site="+come_from+"_"+show_xinming+"&Menu=yes' target='blank'><img SRC='http://wpa.qq.com/pa?p=1:"+show_qq+":10' alt='敦煌国际旅行社QQ服务' border='0'> "+show_xinming+"</a><BR>";
}

var showbody="<TABLE width='110' border='0' align='center' cellPadding='0' cellSpacing='0' ><TR><TD><img src='/esite/citsdh/images/top.gif' width='110' height='70' onclick='closeBanner();' /></TD></TR><TR id='qqstab1' ><TD align='center' background='/esite/citsdh/images/middle.gif'>"+qq_list+"</TD></TR><TR><TD align='center' height='35'><img src='/esite/citsdh/images/bottom.gif' width='110' height='50' onclick='qqstabBanner();' /></TD></TR></TABLE>";

	var delta=0.15
	var collection;
	var closeB=false;
	function floaters() {
		this.items	= [];
		this.addItem	= function(id,x,y,content)
				  {
					document.write('<DIV id='+id+' style="Z-INDEX: 10; POSITION: absolute;  width:80px; height:60px;left:'+(typeof(x)=='string'?eval(x):x)+';top:'+(typeof(y)=='string'?eval(y):y)+'">'+content+'</DIV>');
					var newItem				= {};
					newItem.object			= document.getElementById(id);
					newItem.x				= x;
					newItem.y				= y;

					this.items[this.items.length]		= newItem;
				  }
		this.play	= function()
				  {
					collection				= this.items
					setInterval('play()',10);
				  }
		}
		function play()
		{
			if(screen.width<=648 || closeB)
			{
				for(var i=0;i<collection.length;i++)
				{
					collection[i].object.style.display	= 'none';
				}
				return;
			}
			for(var i=0;i<collection.length;i++)
			{
				var followObj		= collection[i].object;
				var followObj_x		= (typeof(collection[i].x)=='string'?eval(collection[i].x):collection[i].x);
				var followObj_y		= (typeof(collection[i].y)=='string'?eval(collection[i].y):collection[i].y);

				if(followObj.offsetLeft!=(document.body.scrollLeft+followObj_x)) {
					var dx=(document.body.scrollLeft+followObj_x-followObj.offsetLeft)*delta;
					dx=(dx>0?1:-1)*Math.ceil(Math.abs(dx));
					followObj.style.left=followObj.offsetLeft+dx;
					}

				if(followObj.offsetTop!=(document.body.scrollTop+followObj_y)) {
					var dy=(document.body.scrollTop+followObj_y-followObj.offsetTop)*delta;
					dy=(dy>0?1:-1)*Math.ceil(Math.abs(dy));
					followObj.style.top=followObj.offsetTop+dy;
					}
				followObj.style.display	= '';
			}
		}	
		function closeBanner()
		{
			closeB=true;
			return;
		}
		function qqstabBanner()
		{
			if(document.all.qqstab1.style.display=='none')
			{
			   document.all.qqstab1.style.display=''
			}
			else 
			{
				document.all.qqstab1.style.display='none'
		    }
		}
		
	var theFloaters = new floaters();
	theFloaters.addItem('followDiv2',6,30,showbody);
	//theFloaters.addItem('followDiv1','document.body.clientWidth-130',50,showbody);
	theFloaters.play();