function xControlMen(id,idKapa,estilos,tim){
	xCMObj= new xControlMen.create(id,idKapa,estilos,tim);
	eval('xCM'+id+'=xCMObj');
	return xCMObj;
}

xControlMen.create=function(id,idKapa,estilos,tim){
	this.arg=arguments;
	this.tiempo=0;
	this.actvFun=0;
	this.classElement=[];
	this.id='xCM'+id;

	for(var x=0;x<=this.arg[2].length;x++){
		this.classElement[x]=this.arg[2].split("/")[x];
	}
}

xControlMen.create.prototype.actvOpc=function(idTd,idHref,ev){
	var classHref=0;
	//farem un tractament especial per a la primera opcio
	//perque quan no estigui en rollover el text no quedi en gris

	if (((idTd.charAt(3)) == "1")&&(idTd.charCodeAt(4) > 58)){
		classHref=this.classElement[2];
	}
	else
	{
		classHref=this.classElement[3];
	}

	if (document.getElementById) { /* Navegadores con DOM- IE5.5,NS6*/
		if(this.actvFun==1){
			if(ev==0){
				document.getElementById(this.arg[1]).style.visibility='visible';
				document.getElementById(idTd).className=this.classElement[0];
				document.getElementById(idHref).className=this.classElement[2];
				if(this.tiempo!=0){
					clearTimeout(this.tiempo);
				}
			}else if(ev==1){
				document.getElementById(idTd).className=this.classElement[1];
				//document.getElementById(idHref).className=this.classElement[3];
				document.getElementById(idHref).className=classHref;
				this.tiempo=setTimeout(this.id+'.actvOpc("'+idTd+'","'+idHref+'",2)',this.arg[3]);
			}else{
				document.getElementById(this.arg[1]).style.visibility='hidden';
			}
		}else{
			this.actvFun=1;
			document.getElementById(this.arg[1]).style.visibility='visible';
		}
	}else if (document.all ) { /* Navegadores IE*/
		if(this.actvFun==1){
					if(ev==0){
						findObj(this.arg[1]).style.visibility='visible';
						findObj(idTd).className=this.classElement[0];
						findObj(idHref).className=this.classElement[2];
						if(this.tiempo!=0){
							clearTimeout(this.tiempo);
						}
					}else if(ev==1){
						findObj(idTd).className=this.classElement[1];
						//findObj(idHref).className=this.classElement[3];
						findObj(idHref).className=classHref;
						this.tiempo=setTimeout(this.id+'.actvOpc("'+idTd+'","'+idHref+'",2)',this.arg[3]);
					}else{
						findObj(this.arg[1]).style.visibility='hidden';
					}
				}else{
					this.actvFun=1;
					findObj(this.arg[1]).style.visibility='visible';
		}
	}
}

xControlMen.create.prototype.showOpc=function(idTd,idHref,ev){
	if (document.layers) { /* Navegadores NS4.5*/
		if(this.actvFun==1){
			if(ev==0){
				for(i=0;i<document.layers.length;i++) document.layers[i].visibility="hide";
				findObj(this.arg[1]).visibility="show";
				if(this.tiempo!=0){
					clearTimeout(this.tiempo);
				}
			}else if(ev==1){
				this.tiempo=setTimeout(this.id+'.showOpc("'+idTd+'","'+idHref+'",2)',this.arg[3]);
			}else{
				findObj(this.arg[1]).visibility="hide";
			}
		}else{
			this.actvFun=1;
			findObj(this.arg[1]).visibility="show";
		}
	}
}

function findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

//AFEGIT PER POSICIONA ELS LAYERS
var hide  = true;

function showhide(obj) {
	var x = new getObj('testP');
	hide = !hide;
	x.style.visibility = (hide) ? 'hidden' : 'visible';
	setLyr(obj,'testP');
}

function setLyr(obj,lyr,OffsX,OffsY) {
	var newX = findPosX(obj);
	var newY = findPosY(obj);
	if(OffsX==null) OffsX=0;
	if(OffsY==null) OffsY=0;
	if (lyr == 'testP') newY -= 50;
	var ObjRetorn = new getObj(lyr);
	ObjRetorn.style.left = newX+OffsX;
	ObjRetorn.style.top = newY+OffsY;
}

function findPosX(obj)
{
	var curleft = 0;
	if (document.getElementById || document.all)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (document.layers)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	var printstring = '';
	if (document.getElementById || document.all)
	{
		while (obj.offsetParent)
		{
			printstring += ' element ' + obj.tagName + ' has ' + obj.offsetTop;
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (document.layers)
		curtop += obj.y;
//	window.status = printstring;
	return curtop;
}

function getObj(name) {
 if (document.getElementById) {
	   this.obj = document.getElementById(name);
	   this.style = document.getElementById(name).style;
 } else if (document.all) {
	   this.obj = document.all[name];
	   this.style = document.all[name].style;
 } else if (document.layers) {
	   if (document.layers[name]) {
	   	this.obj = document.layers[name];
	   	this.style = document.layers[name];
	   } else {
	    this.obj = document.layers.testP.layers[name];
	    this.style = document.layers.testP.layers[name];
	   }
 }
}

// AFEGIT PER CREAR FINESTRES
var NewWindow = null;
function tancar_finestra() {
 if (NewWindow != null) {
   NewWindow.close();
   var NewWindow = null;
  }
}

function openWindow(URL,Title,Width,Height) {
 var htmlpage = " ";
 var win_opt = "toolbar=0,location=0,directories=0,status=0,menubar=0,";
 win_opt += "scrollbars=0,resizable=0,copyhistory=0,";
 win_opt += "width=" + Width + ",height=" + Height;
// Creació de la finestra
    NewWindow = window.open(URL,"Title",win_opt);
    NewWindow.creator = self;NewWindow.moveTo(20,25);
}

// AFEGIT PER CANVI D'IMATGES
/*
function opcion(indice,nomCapa,numCapa,stTD,stA,nomOp,url,naveg) {
	strCod='<tr>';
  if (document.getElementById || document.all) {
	  strCod+='<td height="16px" onmouseover=xCMpc'+numCapa+'.actvOpc("opc'+indice+nomCapa+'","opc'+indice+nomCapa+'Enc",0) onmouseout=xCMpc'+numCapa+'.actvOpc("opc'+indice+nomCapa+'","opc'+indice+nomCapa+'Enc",1)';
  	if (naveg) strCod+=' colspan="2"';
		//strCod+=' id="opc'+indice+nomCapa+'" class="'+stTD+'"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="'+stA+'" summary=""><tr><td width="5px" nowrap></td><td class="'+stA+'">';
		strCod+=' id="opc'+indice+nomCapa+'" class="textMenuOff"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="'+stA+'" summary=""><tr><td width="5px" nowrap></td><td class="'+stA+'">';
		strCod+='<a href="'+url+'" id="opc'+indice+nomCapa+'Enc" class="'+stA+'">'+nomOp+'</a>';
		strCod+='</td></tr></table></td></tr>';
    document.write(strCod);
  } else if (document.layers) {
    strCod+='<td height="16px"';
    if (naveg) strCod+=' colspan="2"';
    //strCod+=' id="opc'+indice+nomCapa+'" class="'+stTD+'"><table border="0" cellspacing="0" cellpadding="0" class="'+stA+'" summary=""><tr><td width="5px" nowrap></td><td class="'+stA+'">';
		strCod+=' id="opc'+indice+nomCapa+'" class="textMenuOff"><table border="0" cellspacing="0" cellpadding="0" class="'+stA+'" summary=""><tr><td width="5px" nowrap></td><td class="'+stA+'">';
		strCod+='<a href="'+url+'" id="opc'+indice+nomCapa+'Enc" class="'+stA+'" onmouseover=xCMpc'+numCapa+'.showOpc("opc'+indice+nomCapa+'","opc'+indice+nomCapa+'Enc",0) onmouseout=xCMpc'+numCapa+'.showOpc("opc'+indice+nomCapa+'","opc'+indice+nomCapa+'Enc",1)>'+nomOp+'</a>';
		strCod+='</td></tr></table></td></tr>';
    auxLayer=eval('document.layers.'+nomCapa+'Kapa');
    auxLayer.document.write(strCod);
  }
}
*/
function opcion(indice,nomCapa,numCapa,stTD,stA,nomOp,url,naveg,popup) {
	strCod='<tr>';
	if (popup!=null) {
		if (popup==0) popup=" "
		else popup=" target='_blank' "
	} else popup=" "
  if (document.getElementById || document.all) {
	  strCod+='<td height="16px" onmouseover=xCMpc'+numCapa+'.actvOpc("opc'+indice+nomCapa+'","opc'+indice+nomCapa+'Enc",0) onmouseout=xCMpc'+numCapa+'.actvOpc("opc'+indice+nomCapa+'","opc'+indice+nomCapa+'Enc",1)';
  	if (naveg) strCod+=' colspan="2"';
		//strCod+=' id="opc'+indice+nomCapa+'" class="'+stTD+'"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="'+stA+'" summary=""><tr><td width="5px" nowrap></td><td class="'+stA+'">';
		strCod+=' id="opc'+indice+nomCapa+'" class="textMenuOff"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="'+stA+'" summary=""><tr><td width="5px" nowrap></td><td class="'+stA+'">';
		strCod+='<a href="'+url+'"'+popup+'id="opc'+indice+nomCapa+'Enc" class="'+stA+'">'+nomOp+'</a>';
		strCod+='</td></tr></table></td></tr>';
    document.write(strCod);
  } else if (document.layers) {
    strCod+='<td height="16px"';
    if (naveg) strCod+=' colspan="2"';
    //strCod+=' id="opc'+indice+nomCapa+'" class="'+stTD+'"><table border="0" cellspacing="0" cellpadding="0" class="'+stA+'" summary=""><tr><td width="5px" nowrap></td><td class="'+stA+'">';
		strCod+=' id="opc'+indice+nomCapa+'" class="textMenuOff"><table border="0" cellspacing="0" cellpadding="0" class="'+stA+'" summary=""><tr><td width="5px" nowrap></td><td class="'+stA+'">';
		strCod+='<a href="'+url+'"'+popup+'id="opc'+indice+nomCapa+'Enc" class="'+stA+'" onmouseover=xCMpc'+numCapa+'.showOpc("opc'+indice+nomCapa+'","opc'+indice+nomCapa+'Enc",0) onmouseout=xCMpc'+numCapa+'.showOpc("opc'+indice+nomCapa+'","opc'+indice+nomCapa+'Enc",1)>'+nomOp+'</a>';
		strCod+='</td></tr></table></td></tr>';
    auxLayer=eval('document.layers.'+nomCapa+'Kapa');
    auxLayer.document.write(strCod);
  }
}

function opcion2(indice,nomCapa,numCapa,stTD,stA,nomOp,url,naveg) {
	strCod='<tr>';
  if (document.getElementById || document.all) {
	  strCod+='<td height="12px" onmouseover=xCMpc'+numCapa+'.actvOpc("opc'+indice+nomCapa+'","opc'+indice+nomCapa+'Enc",0) onmouseout=xCMpc'+numCapa+'.actvOpc("opc'+indice+nomCapa+'","opc'+indice+nomCapa+'Enc",1)';
  	if (naveg) strCod+=' colspan="2"';
		//strCod+=' id="opc'+indice+nomCapa+'" class="'+stTD+'"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="'+stA+'" summary=""><tr><td width="5px" nowrap></td><td class="'+stA+'">';
		strCod+=' id="opc'+indice+nomCapa+'" class="textMenuOff"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="'+stA+'" summary=""><tr><td width="5px" nowrap></td><td class="'+stA+'">';
		strCod+='<a href="'+url+'" id="opc'+indice+nomCapa+'Enc" class="'+stA+'">'+nomOp+'</a>';
		strCod+='</td></tr></table></td></tr>';
    document.write(strCod);
  } else if (document.layers) {
    strCod+='<td height="12px"';
    if (naveg) strCod+=' colspan="2"';
    //strCod+=' id="opc'+indice+nomCapa+'" class="'+stTD+'"><table border="0" cellspacing="0" cellpadding="0" class="'+stA+'" summary=""><tr><td width="5px" nowrap></td><td class="'+stA+'">';
		strCod+=' id="opc'+indice+nomCapa+'" class="textMenuOff"><table border="0" cellspacing="0" cellpadding="0" class="'+stA+'" summary=""><tr><td width="5px" nowrap></td><td class="'+stA+'">';
		strCod+='<a href="'+url+'" id="opc'+indice+nomCapa+'Enc" class="'+stA+'" onmouseover=xCMpc'+numCapa+'.showOpc("opc'+indice+nomCapa+'","opc'+indice+nomCapa+'Enc",0) onmouseout=xCMpc'+numCapa+'.showOpc("opc'+indice+nomCapa+'","opc'+indice+nomCapa+'Enc",1)>'+nomOp+'</a>';
		strCod+='</td></tr></table></td></tr>';
    auxLayer=eval('document.layers.'+nomCapa+'Kapa');
    auxLayer.document.write(strCod);
  }
}

function opcion3(indice,nomCapa,numCapa,stTD,stA,nomOp,url,naveg,popup) {
	strCod='<tr>';
	if (popup!=null) {
		if (popup==0) popup=" "
		else popup=" target='_blank' "
	} else popup=" "
  if (document.getElementById || document.all) {
	  strCod+='<td height="16px" onmouseover=xCMpc'+numCapa+'.actvOpc("opc'+indice+nomCapa+'","opc'+indice+nomCapa+'Enc",0) onmouseout=xCMpc'+numCapa+'.actvOpc("opc'+indice+nomCapa+'","opc'+indice+nomCapa+'Enc",1)';
  	if (naveg) strCod+=' colspan="2"';
		strCod+=' id="opc'+indice+nomCapa+'" class="'+stTD+'"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="'+stA+'" summary=""><tr><td width="5px" nowrap></td><td class="'+stA+'">';
		strCod+='<a href="'+url+'"'+popup+'id="opc'+indice+nomCapa+'Enc" class="'+stA+'">'+nomOp+'</a>';
		strCod+='</td></tr></table></td></tr>';
    document.write(strCod);
  } else if (document.layers) {
    strCod+='<td height="16px"';
    if (naveg) strCod+=' colspan="2"';
    	strCod+=' id="opc'+indice+nomCapa+'" class="'+stTD+'"><table border="0" cellspacing="0" cellpadding="0" class="'+stA+'" summary=""><tr><td width="5px" nowrap></td><td class="'+stA+'">';
		strCod+='<a href="'+url+'"'+popup+'id="opc'+indice+nomCapa+'Enc" class="'+stA+'" onmouseover=xCMpc'+numCapa+'.showOpc("opc'+indice+nomCapa+'","opc'+indice+nomCapa+'Enc",0) onmouseout=xCMpc'+numCapa+'.showOpc("opc'+indice+nomCapa+'","opc'+indice+nomCapa+'Enc",1)>'+nomOp+'</a>';
		strCod+='</td></tr></table></td></tr>';
    auxLayer=eval('document.layers.'+nomCapa+'Kapa');
    auxLayer.document.write(strCod);
  }
}

