//////falta por meterle el scroll y para arriba y abajo;
function menuEl(id,sX,sY,sH,sW,classS,classL,colorS,colorL,colorB,styleH,contentC0,contentC1,enlc0,enlc1,selec0,selec1,typeC)
{
 	this.id=id;
	this.posX=sX;
	this.posY=sY;
	this.width=sW;
	this.height=sH;	
	this.classSel=classS;
	this.classList=classL;
	this.colorSel=colorS;
	this.colorList=colorL;
	this.colorBorder=colorB;
	this.listHeight=sH;	
	this.selHeight=styleH;
	this.selected0=selec0;
	this.selected1=selec1;	
	this.content0=contentC0;
	this.content1=contentC1;
	this.link0=enlc0;
	this.link1=enlc1;			
	this.nat=typeC;	
	this.movingDownLimit=0;
	this.movingUpLimit=0;
	this.posSel=null;
	
	this.int1=null;
	this.int2=null;					
	this.sense=0;
	this.movementPos=0;
	this.inside=false;	

	//m_level0
	m_level0X=sX;
	m_level0Y=sY;
	m_level0Height=(this.selHeight);
	m_level0Width=(this.width);
	
	//contenedor seleccion
	m_selec1X=sX;
	m_selec1Y=(parseInt(sY)+parseInt(this.selHeight));
	m_selec1Height=(parseInt(this.selHeight));
	m_selec1Width=(parseInt(this.width));
	
	//contenedor lista
	//modCX=sX;
	//modCY=(parseInt(sY)+parseInt(this.selHeight)-1);
	
	if(IE4 || (!IE && !NS6)) {
		modCX=sX - 60;
		modCY=(parseInt(sY)+parseInt(this.selHeight)-37);
	}
	else {
		modCX=sX + 6;
		modCY=(parseInt(sY)+parseInt(this.selHeight)-41);
	}
	modCHeight=this.listHeight;
	modCWidth=this.width;

	//m_level1
	m_level1X=0;
	m_level1Y=-this.listHeight;
	m_level1Height='';
	m_level1Width=this.width;

	//up
	upSX=(this.width-20);
	upSY=15;
	upSHeight=5;
	upSWidth=9;

	//dw
	dwSX=(this.width-20);
	dwSY=(this.listHeight-20);
	dwSHeight=5;
	dwSWidth=9;
	
	if (this.nat=="top")
	{
	   this.movingDownLimit=0;	   
   	   this.movingUpLimit=-this.listHeight;
	   //alert(this.listHeight);
	}
	else if (this.nat=="bottom")
	{
   	   modCY=sY-this.listHeight;
	   m_selec1Y=(sY-this.selHeight);	   
	   m_level1Y=this.listHeight;
	   ///////cambio!!!!! necesito cambio!!!!!!!!!!
   	   this.movingUpLimit=m_level1Y-(this.content1[0].length*this.selHeight);
	   this.movingDownLimit=m_level1Y+(this.content1[0].length*this.selHeight);	   
	 }
	 
	this.table_00="<table height='"+this.selHeight+"' width='"+this.width+"' border='0' cellspacing='0' cellpadding='0'><tr><td rowspan='3' bgcolor='"+this.colorBorder+"' width='1'><img src='"+rutaEst+"images/t.gif' width='1' ></td><td bgcolor='"+this.colorBorder+"'><img src='"+rutaEst+"images/t.gif' width='1' ></td><td rowspan='3' width='1' bgcolor='"+this.colorBorder+"'><img src='"+rutaEst+"images/t.gif' width='1'></td></tr><tr><td><table bgcolor='";
	this.table_01="' cellpadding='0' cellspacing='0' border='0' width='"+(this.width-2)+"' ><tr>";
	this.table_02="</td></tr></table></td></tr><tr><td bgcolor='"+this.colorBorder+"'><img src='"+rutaEst+"images/t.gif' width='1' ></td></tr></table>";	

	// nivel 0
	buildLayer("m_level0"+this.id,"m_level0",1055,"visible");
		text0="<table width='"+this.width+"' border='0' height='"+this.selHeight+"' cellpadding='0' cellspacing='0'><tr class='"+this.classSel+"'>";
   		text0+="<td><img src='"+rutaEst+"images/separacion.gif'></td>";
		for(gg=0;gg<this.content0.length;gg++)
		{	text0+="<td align='center'><a href=javascript:"+this.link0[0]+"; onMouseOver="+this.id+".expandLevel("+gg+") onMouseOut="+this.id+".contractLevel("+gg+") class='"+this.classSel+"'>"+this.content0[gg]+"</a></td><td><img src='"+rutaEst+"images/separacion.gif'></td>"}
		text0+="</tr></table>";
 		document.write(text0);
	closeLayer();	

	//area de seleccion
	buildLayer("m_selec1"+this.id,"m_selec1",1005,"hidden");
 	 	if (this.selected0==null)
		   textS="&nbsp;"					
		else	  
		   textS=this.content1[this.selected0][this.selected1];
		textF=this.table_00+this.colorSel+this.table_01+"<td><font class='"+this.classSel+"'>&nbsp;&nbsp;"+textS+"</font>"+this.table_02;		   	
 		document.write(textF);
	closeLayer();

	//area de LISTA	
	buildLayer("modC"+this.id,"modC",1055,"visible","","","",modCWidth,modCHeight);
		for(gg=0;gg<this.content0.length;gg++)
		{
			buildLayer("m_level1"+this.id+"_"+gg,"m_level1",1055,"inherit","","","","","",this.id+".stopContractLevel("+gg+")",this.id+".contractLevel("+gg+")");
				document.write(this.table_00+this.colorList+this.table_01+"<td>");	
				for(ii=0;ii<this.content1[gg].length;ii++)
				{
					document.write("<a href=javascript:"+this.id+".selectOp("+gg+","+ii+",'true'); onMouseOver="+this.id+".stopContractLevel("+gg+")  class="+this.classList+">&nbsp;&middot;&nbsp;"+this.content1[gg][ii]+"</a>");
					if(ii!=this.content1[gg].length)
						document.write("<br>");
				}			
				document.write(this.table_02);			
			closeLayer();
		}
	closeLayer();

function startPos(op)
{changeStyle("","","modC"+this.id,"m_level1"+this.id+"_"+op,"top",m_level1Y);}

function cli(num)
{
 	clearInterval(eval("this.int"+num));
 	clearTimeout(eval("this.int"+num));
	eval("this.int"+num+"=null");
}

function expandLevel(op)
{
 		hideLayer("","","","m_selec1"+this.id);
		this.cli(2);this.cli(1);this.startPos(op);
		this.upLevel();
		if(this.nat=="top")
		{
		 	if (NS4)
			   changeStyle("","","modC"+this.id,"m_level1"+this.id+"_"+op,"top",this.movingDownLimit)
			else
				this.int1=setInterval(this.id+'.goD('+op+')',5)
		}
		else
		{
		 	if (NS4)
			   changeStyle("","","modC"+this.id,"m_level1"+this.id+"_"+op,"top",this.movingUpLimit)
			else		
				this.int1=setInterval(this.id+'.goU('+op+')',5);
		}
}

function contractLevel(op)
{
 	this.int2=setTimeout(this.id+'.contractLyrNow('+op+')',500);
}

function contractLyrNow(op)
{
		this.cli(2);
			if(this.nat=="top")
			{
			 	if (NS4)
			       changeStyle("","","modC"+this.id,"m_level1"+this.id+"_"+op,"top",this.movingUpLimit)
				else				   
					this.int1=setInterval(this.id+'.goU('+op+')',2)
			}
			else
			{
			 	if (NS4)
			   	   changeStyle("","","modC"+this.id,"m_level1"+this.id+"_"+op,"top",this.movingDownLimit)
				else
					this.int1=setInterval(this.id+'.goD('+op+')',2);
			}
		this.dwLevel();		
}

function stopContractLevel(op)
{
	this.inside=true;
	this.cli(2);
}

function goD(op)
{
	if (getStyle("","","modC"+this.id,"m_level1"+this.id+"_"+op,"top")<this.movingDownLimit)
		changeStyle("","","modC"+this.id,"m_level1"+this.id+"_"+op,"top",getStyle("","","modC"+this.id,"m_level1"+this.id+"_"+op,"top")+5);

	if (getStyle("","","modC"+this.id,"m_level1"+this.id+"_"+op,"top")>(this.movingDownLimit-1))
	{
	   	 this.cli(1);	
		 if(this.nat=="top")
		 {
		    this.sense=1;this.movementPos=0;			
		 	this.int1= setInterval(this.id+'.moveUpDown('+op+')',5);		 
		 }
		 else if((this.nat=="bottom")&&(this.selected0!=null))
		 {
		  	changeContent("","","","m_selec1"+this.id,this.table_00+this.colorSel+this.table_01+"<td><font class='"+this.classSel+"'>&nbsp;&nbsp;"+this.content1[this.selected0][this.selected1]+"</font>"+this.table_02);
			showLayer("","","","m_selec1"+this.id);		 
		 }
	}
}

function goU(op)
{
	if (getStyle("","","modC"+this.id,"m_level1"+this.id+"_"+op,"top")>this.movingUpLimit)
		changeStyle("","","modC"+this.id,"m_level1"+this.id+"_"+op,"top",getStyle("","","modC"+this.id,"m_level1"+this.id+"_"+op,"top")-5);

	if (getStyle("","","modC"+this.id,"m_level1"+this.id+"_"+op,"top")<(this.movingUpLimit+1))
	{
		this.cli(1);	
		if(this.nat=="bottom")
		{
			this.sense=-1;this.movementPos=0;				
		 	this.int1= setInterval(this.id+'.moveUpDown('+op+')',5);
		}
		else if((this.nat=="top")&&(this.selected0!=null))
		{
		  	changeContent("","","","m_selec1"+this.id,this.table_00+this.colorSel+this.table_01+"<td><font class='"+this.classSel+"'>&nbsp;&nbsp;"+this.content1[this.selected0][this.selected1]+"</font>"+this.table_02);
			showLayer("","","","m_selec1"+this.id);		 
		}		 
	}
}

function moveUpDown(op)
{
       changeStyle("","","modC"+this.id,"m_level1"+this.id+"_"+op,"top",getStyle("","","modC"+this.id,"m_level1"+this.id+"_"+op,"top")+this.sense);
	   this.movementPos++;
	   (NS6)?this.movementPos++:'';

		if (this.movementPos==10) 
		   this.sense=-this.sense
		else if (this.movementPos==20) 
		{
			this.movementPos=0;
			this.cli(1);
		}	
		
}

function selectOp(op,pos,salto)
{
 	this.contractLyrNow(op);
	changeContent("","","","m_selec1"+this.id,this.table_00+this.colorSel+this.table_01+"<td><font class='"+this.classSel+"'>&nbsp;&nbsp;"+this.content1[op][pos]+"</font>"+this.table_02);
	showLayer("","","","m_selec1"+this.id);
	this.selected0=op;
	this.selected1=pos;
	eval(this.link1[op][pos]);		
	this.posSel=pos;
	if(salto=='true')selectFunction(this.id);
}

function hide()
{ 	hideLayer("","","","m_level0"+this.id);}

function show()
{ 	showLayer("","","","m_level0"+this.id);}

function upLevel()
{
	showLayer("","","","modC"+this.id);
	changeStyle("","","","modC"+this.id,"zIndex",1500);
//	changeStyle("","","modC"+this.id,"m_level1"+this.id,"zIndex",1502);	
}
function dwLevel()
{	changeStyle("","","","modC"+this.id,"zIndex",1);}
// 	changeStyle("","","modC"+this.id,"m_level1"+this.id,"zIndex",1);}

 	this.expandLevel = expandLevel;
	this.startPos=startPos;
	this.goD=goD;
	this.goU=goU;
	this.moveUpDown=moveUpDown;
	this.contractLevel=contractLevel;
	this.contractLyrNow=contractLyrNow;
	this.stopContractLevel=stopContractLevel;
	this.selectOp=selectOp;
	this.hide=hide;
	this.show=show;
	this.cli=cli;		
	this.upLevel=upLevel;
	this.dwLevel=dwLevel;
}
