//////////////////////////////////////////////////////////////////////////////////
//////////////////// MANEJA CARPETAS Y FALDONES      /////////////////////////////
//////////////////////////////////////////////////////////////////////////////////

function ponerNormal(estilo){

// pone todas las pestañas sin seleccionar

	MM_swapImage('carp','','/esp/ecom/pc/pweb/bin/img/home1.gif');
	for (i=2;i<numcarpetas+1;i++){		
		document.getElementById(i).className=estilo;		
		document.getElementById("l"+i).className="lnkPestayas";
	}
}

function ocultarFaldones(){

// oculta todos los contenidos de los faldones

	for (i=0; i<numcarpetas+1; i++){	
		document.getElementById("nav2_"+i).className="faldonN";
	}
}

function cambiaCarpeta(capa,subm,subact){		
// capa: identificador de la carpeta
// subm: 0 si no se muestra el submenú, 1 si queremos que se muestre
// subact: número del elemento del submenú que va a estar activado, si se manda cero no se marca ninguno
	var estilo=carpetasAct[capa].color;	
	var numsub=0;		
	if (subm!=0)
		numsub=carpetasAct[capa].numElem;			
	ponerNormal("divNormal");
	document.getElementById(capa).className="divSelect"+estilo;	
	if (capa < numcarpetas){
		document.getElementById(capa+1).className="siguiente";			
		document.getElementById("l"+(capa+1)).className="siguiente";
	}
	var estilofaldon;
	if (estilo=="Rosa")
		document.getElementById("l"+capa).className="lnkPestayasNA";				
	else
		document.getElementById("l"+capa).className="lnkPestayasA";	
	estilofaldon="lnk"+estilo;	
	document.getElementById("l"+capa).blur();
	ocultarFaldones();	
	if (numsub==0)
		document.getElementById("nav2_0").className="faldon"+estilo;		
	else{		
		document.getElementById("nav2_"+capa).className="faldon"+estilo;
		for (i=1;i<numsub+1;i++)			
			document.getElementById("s"+capa+"_"+i).className=estilofaldon;			
		if (subact!=0){	
//Actualizar cada vez que se modifique un producto de una carpeta
			if (subact=='10')subact='7';
			if (subact=='11')subact='8'; 
				document.getElementById("s"+capa+"_"+subact).className=estilofaldon+"A";					
		}
	}
}

function ponerNormalSub(estilo,ids,num){

// estilo: estilo del link de los elementos del submenu
// ids: perfijo del identificador del elemento del submenú
// num: numero de elementos que tiene el submenú (con el prefijo forma el identificador)
	
	for (i=1;i<num+1;i++){			
		document.getElementById(ids+i).className=estilo;
	}
}

function cargaPagina(id,num,estilo){	

// id: identificador del elemento del submenú
// num: numero de elementos que tiene el submenú
// estilo: estilo del link	
	
	var pos = id.indexOf("_");	
	ponerNormalSub(estilo,id.substring(0,pos+1),num);	
	document.getElementById(id).className=document.getElementById(id).className+"A";						
	document.getElementById(id).blur();
}


//////////////////////////////////////////////////////////////////////////////////
//////////////////// ESCRIBE CONTENIDO de  carpetas  /////////////////////////////
//////////////////////////////////////////////////////////////////////////////////

//Abre un enlace en el frame Contenido
function abreContenido(contLnk) {
  cont="parent.contenido.location.href='"+contLnk+"'";
  eval (cont);
}


function menuNav2Inicio(){
	document.write('<div id="faldon">');
}

function menuNav2Fin(){
	document.write('</div>');
}

function menuNav2(ndiv,col) {	
	// escribe el faldón con sus elementos	    
  var txt=eval('nav2_'+ndiv+'_txt');      
  var link=eval('nav2_'+ndiv+'_lnk');  
  var size=txt.length;
  var col2 = carpetasAct[ndiv].color;
  var lnk="lnk"+col2;  
  var nav2Main,nav2Ini,nav2Fin;
    
  var nav2Main='';
    
  nav2Ini='<div style="padding-left:0px;" id="nav2_'+ndiv+'" class="faldon'+col+'">';
  nav2Ini+='<table style=\'margin-left:-3px;\'><tr style=\'line-Height:11px;\'>';
  for (i=1;i<txt.length+1;i++) { //Escribe los elementos del submenú (los textos y sus enlaces)   	 	
    nav2Main+='<td align=center style=\'white-space:nowrap;\'><span id="idfaldon"><a href="#" id="s'+ndiv+'_'+i+'" class="'+lnk+'" onClick="cargaPagina(\'s'+ndiv+'_'+i+'\','+txt.length+',\''+lnk+'\'); '+link[i-1]+'">'+txt[i-1]+'</a></span></td>';
  }    
	nav2Fin='</tr></table></div>';
  document.write(nav2Ini+nav2Main+nav2Fin);
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.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=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}	

function cambia() {
	document.carp.src="/esp/ecom/pc/pweb/bin/img/home1.gif";
}