// JavaScript Document
function ClassEffect2(layer,id,limit)
{
		this.canvas = document.getElementById(layer);
		this.layer=document.getElementById(layer).style;
		this.plus=15;
		this.time=1;
		this.limit=limit;
		this.id = id;
		this.ante = '';
		this._OPACITY_ = limit;
		this.navig = ObjGen.navign._NAV;
		this.active = false;
		this.type = '+';
		this.execFun=null;
		this.preImage = null;
		this.onClick = null;
		this.innerHTML = null;
		this.layerHTML = null;
		this.OBJscroll = null;

		
		this.setValue = function (value)
		{
			if (value>100)
				value=100; 
			else
			if (value<0)
				value=0;
			if (this.navig==1)
				this.layer.filter = 'alpha(opacity='+(value)+')';					
			else
				this.layer.opacity = value/100;			
			this._OPACITY_ = value;
		}
		
		this.opacity = function ()
		{	
		
			this._OPACITY_ =  eval(this._OPACITY_ + this.type + this.plus);

			if (this._OPACITY_<=(this.limit+this.plus) && this.execFun!=null)
					{					
					this.execFun();					
					}	
			
			if (this._OPACITY_<=(this.limit+this.plus) && this.innerHTML!=null)
					{
					document.getElementById((this.layerHTML!=null)?(this.layerHTML):(this.canvas.id)).innerHTML = this.innerHTML;										
					this.innerHTML=null;										
					}				
			
			this.setValue(this._OPACITY_);
			
			if ((this._OPACITY_>this.limit && this.type=='-')||(this._OPACITY_<100 && this.type=='+'))
					setTimeout('OBJ_TIT['+this.id+'].opacity()',1);
			else
					{
					this.active = false;
					
					if (this._OPACITY_<=this.limit)
						{//this.layer.visibility='hidden';
						this._OPACITY_ = this.limit;
						this.layer.display='none';
						this.type ='+';
						}	
					else
					if (this.execFun !=null)
						{
							this.execFun();		
						}
					}
			
		}
				
		
		this.start = function()
		{
			if (this.navig==0)
					{
						//this.layer.visibility='hidden';
						this.layer.display='none';
						if (this.execFun!=null)
								{
									//this.layer.visibility='visible';
									this.layer.display='block';
									this.execFun();
								}
					}
			else
			if (this.active==false)
					{
						//this.layer.visibility='visible';
						this.layer.display='block';
						this.setValue(this._OPACITY_);
						this.active=true;	
						this.opacity();
					}
		}

		this.showScroll = function (id)
		{
				if (this.OBJscroll == null)
				{
					try
					{this.OBJscroll = new ClassScroll(this.canvas.id,this.id);}
					catch (err)
					{this.OBJscroll = null;}			
				}
				if (this.OBJscroll!=null)
				{
				this.OBJscroll.lay_txt=document.getElementById(id);
				
				this.OBJscroll.lay_txt.style.marginTop = '1px';
				
				this.OBJscroll.Slayer.display='none';
				//alert(this.OBJscroll.lay_txt.offsetHeight+'dd'+this.OBJscroll.Nlayer.offsetHeight);
				if (parseInt(this.OBJscroll.lay_txt.offsetHeight)>parseInt(this.OBJscroll.Nlayer.offsetHeight)+10)
						this.OBJscroll.Slayer.display='block';
				}
		}

		this.setEffect1 = function(pos,id,action)
		{
			
			if (this.type=='+' && this._OPACITY_>1)
				this.type='-';
			
			if (id!='')
			{
				this.execFun = function (){
				if (this.ante!='')
						document.getElementById(this.ante).style.display='none';
				document.getElementById(id).style.display='block';
				this.ante=id;
				this.showScroll(id);
				this.type ='+';
				};
			}
			else
				{
				this.execFun=null;
				}
		this.start();				
		}
		
		this.preLoadImage = function(image)
		{
			if (this.preImage==null)
					{
						this.preImage = new Image();
						this.preImage.src = image;
						
					}
					
			if (this.preImage.complete==true)
					{												
						this.canvas.innerHTML = "";
						setTimeout('OBJ_TIT['+this.id+'].setValue(0);OBJ_TIT['+this.id+'].canvas.innerHTML="<img style=\''+((this.onClick==null)?(''):('cursor:pointer'))+'\' onclick='+this.onClick+' src=\''+this.preImage.src+'\'>";OBJ_TIT['+this.id+'].setEffect1('+this.id+',"","");OBJ_TIT['+this.id+'].preImage=null;OBJ_TIT['+this.id+'].onClick=null',1000);
					}
			else
					setTimeout('OBJ_TIT['+this.id+'].preLoadImage(null)',1);
		}
}

function encima(id,type)
{
	OBJ_TIT[id].type=type;
	OBJ_TIT[id].start();
}

