/*Smart Page (S) Scripted by FairyFar*/
//部分来源于网络，已作修改。

var xPos = 10;
var yPos = document.body.clientHeight;
var step = 2;
var delay = 50;
var height = 0;
var Hoffset = 0;
var Woffset = 0;
var yon = 0;
var xon = 0;
var pause = true;
var interval;
float_link_div.style.top = yPos;

function hide_float_link(){
	document.getElementById("float_link_div").style.display="none";
}

function re_float_link_logo_size(){
	var old_width;
	var old_height;
	var Max_Width=250;
	for (i=0;i<document.images.length;i++){
		old_width=document.images[i].width;
		old_height=document.images[i].height;
		if (document.images[i].name=="float_link_logo" && document.all && old_width>Max_Width){
			document.images[i].style.width=Max_Width;
			//document.images[i].style.height=old_height*(Max_Width/old_width);
		}
	}
}

function changePos() {
	width = document.body.clientWidth;
	height = document.body.clientHeight;
	Hoffset = float_link_div.offsetHeight;
	Woffset = float_link_div.offsetWidth;
	float_link_div.style.left = xPos + document.body.scrollLeft;
	float_link_div.style.top = yPos + document.body.scrollTop;
	if (yon) {
		yPos = yPos + step;
	}
	else {
		yPos = yPos - step;
	}
	if (yPos < 0) {
		yon = 1;
		yPos = 0;
	}
	if (yPos >= (height - Hoffset)) {
		yon = 0;
		yPos = (height - Hoffset);
	}
	if (xon) {
		xPos = xPos + step;
	}
	else {
		xPos = xPos - step;
	}
	if (xPos < 0) {
		xon = 1;
		xPos = 0;
	}
	if (xPos >= (width - Woffset)) {
		xon = 0;
		xPos = (width - Woffset);
	}
}

function start_float_link() {
	float_link_div.visibility = "visible";
	re_float_link_logo_size();
	interval = setInterval('changePos()', delay);
}

function stop_float_link() {
	clearInterval(interval);
}

start_float_link();
