﻿function MyFloatDiv(){
	this.MaxWidth=980;
	this.hPosition="left";
	this.x=20;
	this.y=140;
	this.IsRoll=false;
	this.Id="";
	this.newName="";
	this.Interval=null;
	this.Show=function(){
		var obj=this.GetDivBox();
		var objdisplay=true;
		ScreenWidth=document.documentElement.scrollWidth;
		if(ScreenWidth>=this.MaxWidth && obj!=null){
			return true;
			}
		else{return false;}
		}
	this.GetDivBox=function(){
		if(arguments.length>0){return document.getElementById(arguments[0]);}
		else{return document.getElementById(this.Id);}
		}
	this.ChangePosition=function(){
		var obj;
		if(arguments.length>0){
			obj=this.GetDivBox(arguments[0]);
			}
		else{
			obj=this.GetDivBox();
			}
		if(this.Show()){
			var nowTop=document.documentElement.scrollTop;
			obj.style.display="";
			if(this.IsRoll){
				if(this.hPosition=="left"){
					obj.style.left=this.x+"px";
					obj.style.top=(nowTop+this.y)+"px";
					}
				else{
					obj.style.right=this.x+"px"
					obj.style.top=(nowTop+this.y)+"px";
					}
				}
				else{
				if(this.hPosition=="left"){
					obj.style.left=this.x+"px";
					obj.style.top=this.y+"px";
					}
				else{
					obj.style.right=this.x+"px"
					obj.style.top=this.y+"px";
					}	
				}
			}
		else{
			if(arguments.length>0){
				obj=this.GetDivBox(arguments[0]);
				}
			else{
				obj=this.GetDivBox();
				}
			obj.style.display="none";
			}
		}
	this.Start=function(){
		var obj=this.GetDivBox();
		if(this.Show()){
			obj.style.display="";
			obj.style.position="absolute";
			obj.innerHTML+="<div class=\"control\"><a onclick=\""+this.newName+".Close('"+this.Id+"');\">关闭</a></div>";
			var nowTop=document.documentElement.scrollTop;
			if(this.hPosition=="left"){
				obj.style.left=this.x+"px";
				obj.style.top=(nowTop+this.y)+"px";
				}
			else{
				obj.style.right=this.x+"px"
				obj.style.top=(nowTop+this.y)+"px";
				}
			this.Interval=window.setInterval(""+this.newName+".ChangePosition('"+this.Id+"')",80);
			}
		else{
			obj.style.display="none";
			}
		}
	this.Close=function(){
		var obj;
		if(arguments.length>0){
			obj=this.GetDivBox(arguments[0]);
			}
		else{
			obj=this.GetDivBox();
			}
		obj.style.display="none";
		window.clearInterval(this.Interval);
		}
	}