﻿// JavaScript Document

var delta = 0.1
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:100px; height:60px;right:'+(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<=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); 
		var sL = (document.compatMode == "CSS1Compat" ? document.documentElement.scrollLeft : document.body.scrollLeft);
		var sT = (document.compatMode == "CSS1Compat" ? document.documentElement.scrollTop : document.body.scrollTop);
		if(followObj.offsetLeft != (sL + followObj_x)) {
			var dx = (sL + followObj_x - followObj.offsetLeft) * delta;
			dx = (dx > 0 ? 1 : -1) * Math.ceil(Math.abs(dx));
			followObj.style.left = followObj.offsetLeft + dx;
		} 
		if(followObj.offsetTop != (sT + followObj_y)) {
			var dy = (sT + 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();
var htmlFloater;
htmlFloater = '';
htmlFloater += '<br>';
htmlFloater += '<table width="100" border="0" cellspacing="0" cellpadding="0">';
htmlFloater += '<tr>';
htmlFloater += '<td><img src="qq/qq_01.gif" width="100" height="24" /></td>';
htmlFloater += '</tr>';
htmlFloater += '<tr>';
htmlFloater += '<td height="20" background="qq/qq_05.gif"><img src="qq/qq_02.gif" width="100" height="20" /></td>';
htmlFloater += '</tr>';
htmlFloater += '<tr>';
htmlFloater += '<td height="19" background="qq/qq_05.gif"><img src="qq/qq_03.gif" width="100" height="27" /></td>';
htmlFloater += '</tr>';
htmlFloater += '<tr>';
htmlFloater += '<td height="20" background="qq/qq_05.gif">';
htmlFloater += '<table width="6%" border="0" align="center" cellpadding="0" cellspacing="0">';
htmlFloater += '<tr>';
htmlFloater += '<td width="32" height="27" align="center" class="details">';
htmlFloater += '<a target="blank" href="tencent://message/?uin=807717530&amp;Site=www.n112.com&amp;Menu=yes">';
htmlFloater += '<img border="0" src="http://wpa.qq.com/pa?p=1:807717530:7" alt="在线咨询" /></a>';
htmlFloater += '<a target="blank" href="tencent://message/?uin=908935051&amp;Site=www.n112.com&amp;Menu=yes"></a></td>';
htmlFloater += '</tr>';
htmlFloater += '<tr>';
htmlFloater += '<td width="32" height="27" align="center" class="details">';
htmlFloater += '<a target="blank" href="tencent://message/?uin=807717530&amp;Site=www.n112.com&amp;Menu=yes">';
htmlFloater += '<img border="0" src="http://wpa.qq.com/pa?p=1:807717530:7" alt="在线咨询" /';
htmlFloater += '></a>';
htmlFloater += '<a target="blank" href="tencent://message/?uin=532243200&amp;Site=www.n112.com&amp;Menu=yes"></a>';
htmlFloater += '</td>';
htmlFloater += '</tr>';
htmlFloater += '<tr>';
htmlFloater += '<td width="32" align="center" class="details"></td>';
htmlFloater += '</tr>';
htmlFloater += '</table>';
htmlFloater += '</td>';
htmlFloater += '</tr>';
htmlFloater += '<tr>';
htmlFloater += '<td><img src="qq/qq_07.gif" width="100" height="19" /></td>';
htmlFloater += '</tr>';
htmlFloater += '</table>';
theFloaters.addItem('followDiv1', screen.width-200, 66, '<br><a href="#"></a>');
theFloaters.addItem('followDiv2', screen.width-200, 366, htmlFloater); 
theFloaters.play();    
