var OnlineService = function(obj, direction, top, IsStatic){//direction: left,right,float
	var base = this;
	this.a = BodyWH();
	this.obj = typeof(obj)=="string" ? d(obj) : obj;
	this.direction = direction;
	this.FloatDirection1 = "down";
	this.FloatDirection2 = "right";
	this.timer = null;
	this.top = NotIsNull(top) ? top : 130;
	this.IsStatic = NotIsNull(IsStatic) ? IsStatic : false;
	this.obj.style.display = "";
	this.obj.style.top = this.top + "px";
	this.obj.style.left = this.direction=="left" ? "1px" : (this.a[0]-this.obj.offsetWidth-1) + "px";
	this.obj.style.zIndex = 10;
	if(!this.IsStatic){
		this.timer = setInterval(function(){base.CheckFloat()}, 200);
	}
	if(direction == "float"){
		this.obj.style.top = parseInt(Rnd() * 500) + ScrollTop() + "px";
		this.obj.style.left = parseInt((Rnd() * 1000)) + "px";
		clearInterval(base.timer);
		this.timer = setInterval(function(){base.CheckFloat()}, 30);
		this.obj.onmouseover = function(){
			clearInterval(base.timer);
		}
		this.obj.onmouseout = function(){
			clearInterval(base.timer);
			base.timer = setInterval(function(){base.CheckFloat()}, 30);
		}
	}
	if(direction == "right"){
		window.onresize = function(){
			base.a = BodyWH();
			base.obj.style.left = (base.a[0]-base.obj.offsetWidth-1 + "px");
		};
	}
}
OnlineService.prototype.CheckFloat = function(){
	this.a = BodyWH();
	var n = ScrollTop() + this.top;
	var h = ScrollTop() + document.documentElement.clientHeight;
	var t = Cint(this.obj.style.top);
	var left = Cint(this.obj.style.left);
	var speed = 1;
	if(this.direction != "float"){
		this.obj.style.left = this.direction=="left" ? "1px" : (this.a[0]-this.obj.offsetWidth-1) + "px";
		if(t < n){
			speed = Math.round((n-t) / 2);
			if((n-t) > 2){
				this.obj.style.top = (t + speed) + "px";
			}
			else{
				this.obj.style.top = n + "px";
			}
		}
		else{
			speed = Math.round((t-n) / 2);
			if ((t - n) > 2) {
				this.obj.style.top = (t - speed) + "px";
			}
			else{
				this.obj.style.top = n + "px";
			}
		}
	}
	else{
		if(this.FloatDirection2 == "right"){
			if((left+this.obj.offsetWidth) < this.a[0]){
				this.obj.style.left = (left+speed)+"px";
			}
			else{
				this.FloatDirection2 = "left";
			}
		}
		else{//left
			if(left > 0){
				this.obj.style.left = (left-speed)+"px";
			}
			else{
				this.FloatDirection2 = "right";
			}
		}
		
		if(this.FloatDirection1 == "down"){
			if((t+this.obj.offsetHeight) < h && (t+this.obj.offsetHeight) < this.a[1]){
				this.obj.style.top = (t+speed)+"px";
			}
			else{
				this.FloatDirection1 = "up";
			}
		}
		else{//up
			if(t > ScrollTop()){
				this.obj.style.top = (t-speed)+"px";
			}
			else{
				this.FloatDirection1 = "down";
			}
		}
	}
}
