function FAD(src,w,h,src2,w2,h2){
		this.src=src;
		this.src2=src2;
		this.w=w;
		this.h=h;
		this.w2=w2;
		this.h2=h2;		
		this.pos=1;
		this.padding=10;
		this.padding2=10;
		this.link="#";		
		this.type="";
		this.style="";
		this.slide=2;
		this.e=null;
		var ext=this.src.substr(this.src.lastIndexOf(".")+1).toLowerCase();
		this.type=(ext=="swf")?"flash":"";
		this.apply=function(index){
			var e=null;
			if (this.type.toLowerCase()=="flash"){
				e=getFlashObject(this.src,this.w,this.h,document.body);				
			}else{
				e=newElement("a",["href",this.link],["target","_blank"]);				
				var img=newElement("img",["src",this.src],["width",this.w],["height",this.h],["border",0]);
				if (this.src2){
					img.e=this;
					img.onmouseout=function(){
						var sl=this.e.slide;			
						this.src=this.e.src;
						this.width=this.e.w;this.height=this.e.h;
						if (sl>0)this.e.slide=4;
						this.e.setPos();
						if (sl>0)this.e.slide=sl;
					}
					img.onmouseover=function(){
						var sw=this.e.w,sh=this.e.h;
						var sl=this.e.slide;
						this.src=this.e.src2;
						this.width=this.e.w2;this.height=this.e.h2;
						this.e.w=this.e.w2;this.e.h=this.e.h2;
						if (sl>0)this.e.slide=4;
						this.e.setPos();						
						this.e.w=sw;this.e.h=sh;
						if (sl>0)this.e.slide=sl;			
					}						
				}
				e.appendChild(img);
			}
			var p=document.createElement("div");
			p.id="fad_"+index;		
			p.style.position="absolute";
			p.style.zIndex=1000+index;
			p.appendChild(e);
			document.body.appendChild(p);
			this.e=p;
			this.setPos(true);	
		}
		this.setPos=function(force){
			var top=0,left=0;
			if (this.slide>0) top +=xScrollTop();
			if (this.pos==1){
				top +=this.padding2;
				left=this.padding; 
			}else if (this.pos==2){			
				left=xClientWidth()-this.padding-this.w;
				top +=this.padding2;			
			}else if (this.pos==3){
				left=this.padding;
				top +=xClientHeight()-this.h-this.padding2;
			}else if (this.pos==4){
				left=xClientWidth()-this.padding-this.w;
				top +=xClientHeight()-this.h-this.padding2;
			}
			if (this.slide==0&&force==null)return;
			if (this.slide==1&&this.e.style.left){		 
				xSlideTo(this.e,left,top,200);
			}else{
				xMoveTo(this.e,left,top);
			}	
			
		}
	}
	function FADS(){
		this.ads=new Array(); 
	}
	FADS.prototype.add=function(ad){
		if (ad==null||ad.src==null) return;
		this.ads.push(ad);
	}
	FADS.prototype.apply=function(){
		for (var i=0;i<this.ads.length;i++){			
			this.ads[i].apply(i);
		}
	}
	FADS.prototype.resize=function(){
		for (var i=0;i<this.ads.length;i++){			
			this.ads[i].setPos();
		}		
	}
	
/*********************************************************/

var FloatLayerPosition = {leftTop :0 ,rightTop :1 , leftBottom : 2 ,rightBottom :4};

var FloatLayer = function(id , position){	
	this.autoScroll = true;
	this.tid = 0 ;
	this.position = FloatLayerPosition.leftTop || position;	
	this.enableSlide = true;
	this.padding = [10,10,10,10];
 
	if (xId(id)) this.e = xId(id);	
	else
	{
		this.__newObject = true;
		this.e = newElement("div");	
		this.e.id = id;
	}
	this.onEnterFrame = function()
	{
		if (!this.autoScroll) return;
		
		var top=0,left=0;
		
		top += xScrollTop(); 
		
		if (this.position == FloatLayerPosition.leftTop)
		{
			left = this.padding[3];			
			top += this.padding[0]; 
		}else if (this.position == FloatLayerPosition.rightTop)
		{
			left = xClientWidth()-this.padding[1]- xWidth(this.e);
			top += this.padding[0];			
		}else if (this.position == FloatLayerPosition.leftBottom)
		{
			left = this.padding[3];
			top += xClientHeight()- xHeight(this.e) - this.padding[2];			
		}else if (this.position == FloatLayerPosition.rightBottom)
		{
			left = xClientWidth() - this.padding[1] - xWidth(this.e);
			top += xClientHeight() - xHeight(this.e) - this.padding[2];				
		}
		if (this.enableSlide){		 
			xSlideTo(this.e,left,top,5);
		}else{			 
			xMoveTo(this.e,left,top);
		}			
	}
	
	this.apply = function (parent)
	{
		if ( this.__newObject == true)
		{
			
		}else
		{
			if (parent)
				xId(parent).appendChild(this.e);	
			else
				document.body.appendChild(this.e);
		}
		FloatLayer.addListener(this,this.onEnterFrame);
	}
	
	this.setStyle = function(key,value)
	{
		if (typeof(key) == "object")
		{
			for (var field in key)
			{
				this.setStyle(field,key[field]);	
			}
		}else if (typeof(key) == "string")
		{
			this.e.style[key] = value;
		}
	}
	
	this.setStyle({position:"absolute"});
	
};

FloatLayer.__listeners = new Array();
FloatLayer.__funcs = new Array();

FloatLayer.addListener = function (obj , func)
{
	FloatLayer.__listeners.push(obj);
	FloatLayer.__funcs.push(func);
}

FloatLayer.__EnterFrame = function()
{
	for (var i=0;i<FloatLayer.__listeners.length;i++)
	{
		FloatLayer.__funcs[i].apply(FloatLayer.__listeners[i]);
	}
}

setInterval("FloatLayer.__EnterFrame()",100);
