function FloatingModule()
{
		this.myie=document.all;
		this.right_edge=0;//=this.myie&&!window.opera? isiebody().clientWidth-imagewidth: window.innerWidth-imagewidth;
		this.expandState = 0;
		
		
		this.ie = document.all ? 1 : 0;
		this.ns = document.layers ? 1 : 0;
		
		this.master = new Object("element");
		this.master.curLeft =this.right_edge;
		this.master.curTop = 10;
		this.master.gapLeft = 0;
		this.master.gapTop = 0;
		this.master.timer = null;
		this.isleft=1;
		this.myController="";
		this.myFormID="";
}



FloatingModule.prototype.Init=function(moduleid,strWidth,imagewidth,isLeft,myfid,top,alwaysfloating)
{
		this.isleft=isLeft;
		this.myController="Floating"+moduleid;
		this.myFormID=myfid;
		this.imageWidth=imagewidth;
		this.myie=document.all;
		this.alwaysfloating=alwaysfloating;

		this.expandState = 0;
		this.top=top;
		 
		this.strWidth=strWidth;
		
		//this.right_edge=this.myie&&!window.opera? this.isiebody().clientWidth-imagewidth: window.innerWidth-imagewidth;
		
		this.right_edge=this.isiebody().clientWidth-imagewidth;
		
		if( this.isleft==1) 
		{
           this.strleft = 0;
           this.strhleft = - strWidth;
         }
        else
        {
           this.strleft = this.right_edge- strWidth;
           this.strhleft = this.right_edge;
         }
        
        this.containerwidth= strWidth + imagewidth;
       	document.getElementById(this.myFormID).style.left = this.strhleft + "px";
	
		document.getElementById(this.myFormID).style.top = this.top + "px";
		document.getElementById(this.myFormID).style.width =this.containerwidth + "px";
	
		if (document.compatMode && document.compatMode!="BackCompat" && !isIE6())
	         document.getElementById(this.myFormID).style.position="fixed" ;
		else
		     document.getElementById(this.myFormID).style.position="absolute" ;
		document.getElementById(this.myFormID).style.zIndex="99999" ;
	
		this.ie = document.all ? 1 : 0;
		this.ns = document.layers ? 1 : 0;
		
		
		this.master = new Object("element");
	    
		this.master.curLeft =this.strhleft;
				    
		this.master.curTop = this.top;
		this.master.gapLeft = 0;
		this.master.gapTop = 0;
		this.master.timer = null;
		
	   
	    setInterval(this.myController+'.FixY()', 100);
	    
        if(this.alwaysfloating==0)
        {
            this.expandState = 0;
		    this.setPace(this.myFormID, this.strhleft, this.top, 20); 
		}
		else
		{
		    this.expandState = 1;
		    this.setPace(this.myFormID, this.strleft, this.top, 20); 
		}
	}
		
		
	FloatingModule.prototype.moveAlong=function(layerName, paceLeft, paceTop, fromLeft, fromTop)
	{
			clearTimeout(this.master.timer)
			if(this.master.curLeft != fromLeft)
			{
				if((Math.max(this.master.curLeft, fromLeft) - Math.min(this.master.curLeft, fromLeft)) < paceLeft){this.master.curLeft = fromLeft}
				else if(this.master.curLeft < fromLeft){this.master.curLeft = this.master.curLeft + paceLeft}
					else if(this.master.curLeft > fromLeft){this.master.curLeft = this.master.curLeft - paceLeft}
				if(this.ie){document.getElementById(layerName).style.left = this.master.curLeft}
				else{document.getElementById(layerName).style.left = this.master.curLeft + "px"}
			}
			 if(document.compatMode && document.compatMode!="BackCompat" && !isIE6())
			 {
			 
			 }
			 else
			 {
			    if(this.master.curTop != fromTop)
			    {
				    if((Math.max(this.master.curTop, fromTop) - Math.min(this.master.curTop, fromTop)) < paceTop){this.master.curTop = fromTop}
				    else if(this.master.curTop < fromTop){this.master.curTop = this.master.curTop + paceTop}
					    else if(this.master.curTop > fromTop){this.master.curTop = this.master.curTop - paceTop}
				    if(this.ie){document.getElementById(layerName).style.top = this.master.curTop}
				    else{document.getElementById(layerName).style.top = this.master.curTop + "px"}
			     }
			 }
			 this.master.timer=setTimeout(this.myController+'.moveAlong("'+layerName+'",'+paceLeft+','+paceTop+','+fromLeft+','+fromTop+')',30)
		}

		FloatingModule.prototype.setPace=function(layerName, fromLeft, fromTop, motionSpeed)
		{
			this.master.gapLeft = (Math.max(this.master.curLeft, fromLeft) - Math.min(this.master.curLeft, fromLeft))/motionSpeed
			this.master.gapTop = (Math.max(this.master.curTop, fromTop) - Math.min(this.master.curTop, fromTop))/motionSpeed
			this.moveAlong(layerName, this.master.gapLeft, this.master.gapTop, fromLeft, fromTop)
		}
		
		FloatingModule.prototype.FixY=function(){
	
	       
            this.right_edge=this.isiebody().clientWidth-this.imageWidth;
		    if( this.isleft!=1&&this.strhleft!=this.right_edge) 
		    {
                                 
                 this.strhleft = this.right_edge;
                 this.strleft = this.right_edge- this.strWidth;
                 
                 if(this.expandState == 0)
                      this.setPace(this.myFormID, this.strhleft,this.isiebody().scrollTop+this.top,20);	
                 else
                      this.setPace(this.myFormID, this.strleft,this.isiebody().scrollTop+this.top,20);		
                
				 return;
             }
                
                
       		var lf;
			if(this.expandState == 0)
			{
			    lf= this.strhleft; 
			}
			else
			{
			    lf= this.strleft; 
			}
			
			
			if(Math.abs(this.master.curTop - this.isiebody().scrollTop - this.top)>=1)
			     this.setPace(this.myFormID, lf,this.isiebody().scrollTop+this.top,20);	
			
		}
		
		FloatingModule.prototype.isiebody=function(){
			return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
		}
		
		FloatingModule.prototype.expand=function(){
		    var tp;
		    if (document.body.scrollTop>0) 
		    	tp=document.body.scrollTop+this.top;
		    else
		    	tp=document.documentElement.scrollTop+this.top;
			if(this.expandState == 0){this.setPace(this.myFormID, this.strleft, tp, 20); 
			this.expandState = 1;}
			else{this.setPace(this.myFormID, this.strhleft, tp, 20); 
			this.expandState = 0;}
		}
		
		function isIE6(){
            var browser=navigator.appName 
            var b_version=navigator.appVersion 
            var version=b_version.split(";"); 
            var trim_Version=version[1].replace(/[ ]/g,""); 
            //alert(trim_Version);
            if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE6.0") 
                return true;
            else
                return false;
		}


