﻿
var delta=0.15
var collection;
function floaters() {
this.items = [];
this.addItem = function(id,x,y,content)
{
	document.write("<div id="+id+" style='Z-INDEX: 10; POSITION: absolute; width:120px;'><div style='width:120px; text-align:left;'><div><img src='images/bg_t.gif' /></div><div style=' background-image:url(images/bk_mid.gif); background-repeat:repeat-y;'><div style='margin-left:8px;width:100px; overflow:hidden;'>" + content + "</div></div><div><img src='images/bg_f.gif' /></div></div></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<=800)
	{
		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.documentElement.scrollTop+followObj_y)) 
		{
			var dy=(document.documentElement.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 = '';
	}
} 
//var theFloaters = new floaters();
//theFloaters.addItem('followDiv1','document.body.clientWidth-145',350,'<div style=\"margin:5px 0px 10px 10px;\"><img src=\"images/12_online.gif\" style=\"cursor:pointer;margin:5px 0px;\" onclick=\"openQQ(928719881);\"/><img src=\"images/12_online.gif\" style=\"cursor:pointer;margin:5px 0px;\" onclick=\"openQQ(1020346717);\"/></div>');
////theFloaters.addItem('followDiv2',8,100,''); 
//theFloaters.play(); 

//Open QQ
function openQQ(qqcode)
{
	var qqwindow=window.open('tencent://message/?Menu=yes&uin='+qqcode+'&Site=&Service=200');
	
	setTimeout(function(){qqwindow.close()},2000);

}

function floatQQ(obj)
{
    var array=new Array();
    array=obj.split('-');
    var txt="";
    for(var i = 0;i<array.length-1;i++)
    {
        txt += '<img src=\"images/6_online2.gif\" style=\"cursor:pointer;margin:5px 0px;\" onclick=\"openQQ(' + array[i] + ');\"/>';
    }
    var theFloaters = new floaters();
    theFloaters.addItem('followDiv1','document.body.clientWidth-136',(375-0)-35*(array.length-1),'<div style=\"margin:5px 0px; text-align:center;\"><div style="color:#000000; line-height:150%;">免费服务热线<br/>020-38893055</div>' + txt +  '</div>');
    theFloaters.play(); 
}