// JavaScript Document

buscacanalbrujula();

var dom = document.getElementById ? true:false;
var nn4 = document.layers ? true:false;
var ie4 = document.all ? true:false;
var nn = document.layers ? true:false;
var ie = document.all ? true:false;

var rutaweb=location.pathname 
var carp=''

function countLetter (string, letter) {
  var n = 0;  var p = 0;
  while ((p = string.indexOf(letter, p) + 1) != 0)
    n++;
  return n;
}


if (location.href.indexOf('_www')>-1) { // SI ESTE ARCHIVO ESTA EN LOCAL
	posref=location.href.indexOf("_www")
	posref=eval(posref+5);
	rutaweb=location.href.substring(0,posref)+'particulares/'
	carpeta=location.href.substring(posref,location.href.length)
	if (carpeta.indexOf("/")>-1) auxnivel=countLetter(carpeta,'/')
	if (carpeta.indexOf("\\")>-1) auxnivel=countLetter(carpeta,'\\')
	if (!auxnivel) nivel=0;
	else nivel=auxnivel;
	
	for (var j = 1; j < nivel; ++j) {
		carp+='../'
	}
	
} else { // SI ESTE ARCHIVO ESTA EN UN SERVIDOR
	carp='http://'+location.host;
	rutaweb='';
						
}



								
ruta=rutaweb+carp;

var storedValue ;
var menumm='';
var menummon='';
var primernivelactivo=-1;
var segundonivelactivo=-1;
var tercernivelactivo=-1;
var ultimaopcioncargada=-1;
var menuabierto=0
var opcionforzada1;
var opcionforzada2;
var primernivelabierto=-1

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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 MM_openBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}
function MM_findObj(n, d) { //v4.01
  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);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


function MM_setTextOfLayer(objName,x,newText) { //v4.01
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
	if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
	obj.visibility=v; }
}

function imprimir(){
  cadena=document.location.href;
  nombre=('imp-'+cadena.slice(cadena.lastIndexOf('/')+1));
  imp=window.open(nombre,'imprimir','resizable=no,scrollbars=yes,toolbar=no,location=no,menu=no,Width=580,Height=350,');
}

function showContent(capitadiv,modo) {
	var body = document.getElementById(capitadiv);
	if (body.style.display == "none"){
		body.style.display = "block";

	} else {
		body.style.display = "none";

	}
}

function ancladin(capitadiv,ancla) {
	showContent(''+capitadiv,0);
	if (ancla!='') self.location.href=''+ancla
}


function item(nombre, parent, text, depth,clink) {
        this.nombre = nombre 
	    this.parent = parent 
        this.text = text 
        this.depth = depth 
		this.clink = clink 
}

function setStates() {
        var storedValue = menumm

        if (!storedValue) {
                for (var i = 0; i < arbol.length; ++i) {
                        if (arbol[i].level == 3)
                                arbol[i].state = true
                        else
                                arbol[i].state = false
                }
        } else {
                for (var i = 0; i < arbol.length; ++i) {
                        if (storedValue.charAt(i) == '1') {
	                      
                                arbol[i].state = true
                        } else {
                                arbol[i].state = false
                        }
                }
        }
}

function setImages() {

        for (var i = 0; i < arbol.length; ++i) {
                if (arbol[i].state)
                       
						if (arbol[i].parent) {
     
                                if (arbol[i].level==1) arbol[i].pic = ' <IMG SRC="'+ruta_imagenes+'movistar_es_ico-menu-item.gif" BORDER=0>'
                                if (arbol[i].level==2) arbol[i].pic = ' <IMG SRC="'+ruta_imagenes+'movistar_es_ico-menu-secc4.gif" BORDER=0>'
                        }
        }
}
function forzar(num) {
	
	if (arbol[num].state!=1) {
		
		toggle(num)
	}
	
}



function toggle(num) {
	
	 if (isNaN(num)) {

		for (var i = 0; i < arbol.length; ++i) {
			if (arbol[i].name==num) {
				num=i;
				break;
			}
		}
	  }

	if (!isNaN(num)) {
		
					
					
					
					if ((arbol[num].level==0) && (ultimaopcioncargada!=num) ){

						for (var i = 0; i < arbol.length; ++i) {
							if (arbol[i].level == 0)
								arbol[i].state = true
							else
								arbol[i].state = false;
						}

					}

					
				
					
					for (var i = num + 1; i < arbol.length && arbol[i].level >= arbol[num].level + 1; ++i) {
							if (arbol[i].level == arbol[num].level + 1) {
								arbol[i].state = !arbol[i].state;
							} else {
								if (opcionforzada1!=num) arbol[i].state=false;
							}
					}
				
				
					
			
					if ((arbol[num].level==0) && (primernivelactivo>-1) && (ultimaopcioncargada!=num) ) {
						
						for (var i = primernivelactivo + 1; i < arbol.length && arbol[i].level >= arbol[primernivelactivo].level + 1; ++i) {
									arbol[i].state=false;
						}	
					
					}


					if (menuabierto!=1){


						if ((arbol[num].level==1) && (segundonivelactivo>-1) && (segundonivelactivo!=num)) {
							for (var i = segundonivelactivo + 1; i < arbol.length && arbol[i].level >= arbol[segundonivelactivo].level + 1; ++i) {


										if (opcionforzada1!=i) arbol[i].state=false;

							}	

						}

					}
					
			
			
					
					if ((arbol[num].level==2) && (tercernivelactivo>-1) && (tercernivelactivo!=num)) {
							for (var i = tercernivelactivo + 1; i < arbol.length && arbol[i].level >= arbol[tercernivelactivo].level + 1; ++i) {

								arbol[i].state=false;

							}	

					}
					
					
					if (arbol[num].level==0)  { 
						primernivelactivo=num;
						segundonivelactivo=-1;
						tercernivelactivo=-1;
					} else {
						if (arbol[num].level==1)  segundonivelactivo=num

					} 

					if (arbol[num].level==2)  tercernivelactivo=num

					ultimaopcioncargada=num
					
	
	  }
        setStorage(num)
        creararbol();
        pintamenu();
		//if (primernivelactivo>0) alert('primernivelactivo:'+eval('arbol['+primernivelactivo+'].text'))

		//if (segundonivelactivo>0) alert('segundonivelactivo:'+eval('arbol['+segundonivelactivo+'].text'))
		//if (ultimaopcioncargada>0) alert('ultimaopcioncargada:'+eval('arbol['+ultimaopcioncargada+'].text'))
						

}

///////////////////////////////////////////////////////////////////////
//
//       Despliega el menú lateral tantas veces como sea necesario
//		 para que aparezca seleccionado el canal que se le mete
//		 como parámetro.
//
///////////////////////////////////////////////////////////////////////
function multiple_toggle(canal) {

		//if (document.location.pathname.indexOf("0,")>-1){

				var indice_canal=0;
				
					for (var i = 0; i < arbol.length; ++i) {
					
						if (arbol[i].name==canal) {
							
							indice_canal=i;
							break;
						}
					}
				
			
			
				
				if (indice_canal!=-1) { 		
				
					//Si la opcion es de primer nivel (level=0) 
					if (arbol[indice_canal].level==0) toggle(indice_canal);

					//Si la opcion es de segundo nivel (level=1)
					
					if (arbol[indice_canal].level==1)  {
						multiple_toggle(arbol[indice_canal].parentname);
						toggle(indice_canal);
					}

					//Si la opcion es de tercer nivel (level=2)
					if (arbol[indice_canal].level==2) {
						multiple_toggle(arbol[indice_canal].parentname);
						toggle(indice_canal);
					}

					//Si la opcion es de cuarto nivel (level=3)
					if (arbol[indice_canal].level==3) {
						multiple_toggle(arbol[indice_canal].parentname);
						toggle(indice_canal);
					} 
					//Si la opcion es de cuarto nivel (level=4)
					if (arbol[indice_canal].level==4) {
						multiple_toggle(arbol[indice_canal].parentname);
						toggle(indice_canal);
					} 
					if (arbol[indice_canal].level==5) {
						multiple_toggle(arbol[indice_canal].parentname);
						toggle(indice_canal);
					} 
					if (arbol[indice_canal].level==6) {
						multiple_toggle(arbol[indice_canal].parentname);
						toggle(indice_canal);
					} 							
					
				}
	
		//}

}



function multiple_togglepormapeo(canal,micanalrastro) {

		//if ((canal!=undefined) && (canal!='undefined')) {
		
		
		//alert('multiple_togglepormapeo del canal '+micanalrastro)
		
		
		var indice_canal=0;
		if (micanalrastro>-1) {
			//alert('micanalrastro:'+micanalrastro)
			indice_canal=micanalrastro
		} else {
			//alert('no hay micanalrastro y busco por '+canal)	
			for (var i = 0; i < arbol.length; ++i) {
			
				if (arbol[i].name==canal) {
					//alert('encontrado canal:'+i)
					indice_canal=i;
					break;
				}
			}
		}
	
		
		
	if (indice_canal!=-1) { 		
		/*
			//Si la opcion es de primer nivel (level=0) 
			if (arbol[indice_canal].level==0) toggle(indice_canal);
*/
			//Si la opcion es de segundo nivel (level=1)
			if (arbol[indice_canal].level==1) {
			
				multiple_togglepormapeo(arbol[indice_canal].parentname);
				toggle(indice_canal);
			}

			//Si la opcion es de tercer nivel (level=2)
			if (arbol[indice_canal].level==2) {
				multiple_togglepormapeo(arbol[indice_canal].parentname);
				toggle(indice_canal);
			}

			//Si la opcion es de cuarto nivel (level=3)
			if (arbol[indice_canal].level==3) {
				multiple_togglepormapeo(arbol[indice_canal].parentname);
				toggle(indice_canal);
			} 
			//Si la opcion es de cuarto nivel (level=4)
			if (arbol[indice_canal].level==4) {
				multiple_togglepormapeo(arbol[indice_canal].parentname);
				toggle(indice_canal);
			} 
			//Si la opcion es de cuarto nivel (level=5)
			if (arbol[indice_canal].level==5) {
				multiple_togglepormapeo(arbol[indice_canal].parentname);
				toggle(indice_canal);
			} 	
						//Si la opcion es de cuarto nivel (level=6)
			if (arbol[indice_canal].level==6) {
				multiple_togglepormapeo(arbol[indice_canal].parentname);
				toggle(indice_canal);
			} 	
			
		}
	
	

}


///////////////////////////////////////////////////////////////////////
//
//       Despliega el menú lateral tantas veces como sea necesario
//		 para que aparezca seleccionado el canal que se le mete
//		 como parámetro.
//
///////////////////////////////////////////////////////////////////////
function obtenerCanal() {

	
	//if (document.location.pathname.indexOf("0,")>0) {
		for(var i=0; i<arbol.length; i++) {
			if (arbol[i].url==document.location.pathname) {
				
				return arbol[i].name;
			}
		}
	//} 
	
	
}

function pintamenu(){
	
	actual= menummon
	
	gestion=0
	
	textohtml=''
	//textohtml+='<table width="194" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">'
	//textohtml+='<tr><td height="5" colspan="3" class="itemmenu"><img src="img/movistar_es_espacio3.gif" width="5" height="5"></td></tr></table>'
	
	//textohtml+='<table width="204" border="0" cellspacing="0" cellpadding="0"><tr><td colspan="5"><a href="#"><img src="img/movistar_es_cabecerarecarga.gif"  border=0 alt=""></a></td></tr></table>'
	//textohtml+='<table width="204" border="0" cellspacing="0" cellpadding="0"><tr><td width="1" bgcolor="#FFFFFF"><img src="'+ruta_imagenes+'movistar_es_espacio3.gif" width="1" height="11"></td><td width="204">'
	
	textohtml+='<table width="204" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">'

	//if (idcanalbuscado>0) alert('arbol[1].description:'+arbol[1].description)
	for (var i = 1; i < arbol.length; ++i) {
	
		
		 //EXcepciones para roaming
		 
		 
		 if ((arbol[i].description!="MENUGESTION") && (arbol[i].description!="ESPACIO")) {
		 
				if (arbol[i].state){
			
					//Excepciones para Empresas >> Dispositivos y Moviles
					if (arbol[i].description=='Mail movistar Empresa') {
						arbol[i].url ="/empresas/servicios/correomovil/mailempresas/terminales";
						window.status = arbol[i].level;
					}
					
					if (arbol[i].description=='Mail movistar Profesional') {
						arbol[i].url ="/empresas/servicios/correomovil/mailprofesional/terminales";
						arbol[i].level = 3;
					} 
					
					if ((arbol[i].description.indexOf("<img")>-1) || (arbol[i].mouseoverimage.length>1)){
						cestilo='itemmenu'; 
						if (arbol[i].description.indexOf("<img")>-1) {
							textohtml+='<tr><td bgcolor="#FFFFFF"><img src="'+ruta_imagenes+'movistar_es_iconar1.gif" width="12" height="16"></td><td colspan="2"  width="250"><a href="javascript:toggle(' + i + ')"  alt="'+arbol[i].nombre+'" >'+arbol[i].description+'</a></td></tr>';
						}
						//if (arbol[i].mouseoverimage.length>1) textohtml+='<tr><td bgcolor="#FFFFFF"><img src="'+ruta_imagenes+'movistar_es_iconar1.gif" width="12" height="16"></td><td colspan="2"  width="250"><a href="javascript:toggle(' + i + ')"  alt="'+arbol[i].nombre+'" ><img src="/vgn/images/portal/site_66994/channel/'+ruta_imagenes+arbol[i].mouseoverimage+'" border="0"></a></td></tr>';
					} else {
						
						texxxto=''
						cestilo='itemmenu'; 
						
						// Excepciones de recarga
						if ((arbol[i].description=='Recarga de Tarjeta') || (arbol[i].description=='Siempre Saldo') || (arbol[i].description=='Soluciones') || (arbol[i].description=='Servicios')|| (arbol[i].description=='Internacional')) {
						
							if (arbol[i].description=='Recarga de Tarjeta') {
							
								textohtml+='<tr><td bgcolor="#FFFFFF" colspan="3" width="250"><a href="javascript:toggle(' + i + ')"  alt="'+arbol[i].description+'" ><img src="/staticFiles/cda/movistar_es_cabecerarecarga.gif" alt="Recarga de Tarjeta" border="0"/></a></td></tr>';
							}
							
						
							
							if (arbol[i].description=='Siempre Saldo') {
								
								textohtml+='<tr><td bgcolor="#FFFFFF" colspan="3"   width="250"><a href="javascript:toggle(' + i + ')"  alt="Soluciones sin saldo" ><img src="/staticFiles/cda/movistar_es_cabecerarecargasinsaldo.gif" alt="Soluciones sin saldo" border="0"/></a></td></tr>';
							}
							
							
							if (arbol[i].description=='Soluciones') {
								window.status='Soluciones'													
								textohtml+='<tr><td bgcolor="#FFFFFF" colspan="3" width="250"><a href="/empresas/servicios"  alt="Soluciones" ><img src="/staticFiles/cda/movistar_es_solucionesazul.gif" alt="Soluciones" border="0"/></a></td></tr>';
							}
							
							if (arbol[i].description=='Servicios') {
																												
								textohtml+='<tr><td bgcolor="#FFFFFF" colspan="3" width="250"><a href="/empresas/servicios"  alt="Servicios" ><img src="/staticFiles/cda/movistar_es_serviciosazul.gif" alt="Servicios" border="0"/></a></td></tr>';
							}
						//Excepciones de Roaming

						if (arbol[i].description=='Internacional') {
							textohtml+='<tr><td bgcolor="#FFFFFF" colspan="3" width="250"><a href="http://www.movistar.es/particulares/servicios/hablacualquierpais/roaming"  alt="Internacional" ><img src="/staticFiles/cda/movistar_es_internacional.gif" alt="Internacional" border="0"/></a></td></tr>';
												
						}			
							
	
												
						} else {
						
						
							if (arbol[i].level==1)  {


									if (arbol[i].description != "Resumen de Tarifas") {
								textohtml+='<tr><td bgcolor="#FFFFFF"><img src="'+ruta_imagenes+'movistar_es_icogris.gif" width="12" height="1"></td><td  colspan="2" align="left"><img src="'+ruta_imagenes+'movistar_es_icogris.gif" width="181" height="1"></td></tr>'										
									}
							}
					
								if ( ((actual==i) || (opcionforzada1==i) || (opcionforzada2==i)) && (primernivelactivo>-1) && (arbol[0].state==1)) {
									//Usamos esto para eliminar la opcion "Resumen de Tarifas"
									if ((arbol[i].level==1) && (arbol[i].description != "Resumen de Tarifas") && (arbol[i].description != "Resumen de tarifas")) { cestilo='itemmenu'; textohtml+='<tr><td width="12" bgcolor="#D6D5DA"><img src="'+ruta_imagenes+'movistar_es_iconar1on.gif" width="12" height="16"></td><td colspan="2" bgcolor="#D6D5DA" class="itemmenu" width="250">'}
									if (arbol[i].level==2) { cestilo='itemmenunivel3'; textohtml+='<tr><td width="12" class="fijoa10">&nbsp;</td><td width="16"><img src="'+ruta_imagenes+'movistar_es_iconivel2.gif" width="14" height="13"></td><td width="250" height="16" class="itemmenunivel3">'}
									if (arbol[i].level==3) { cestilo='itemmenunivel3'; textohtml+='<tr><td class="fijoa10">&nbsp;</td><td class="fijoa10">&nbsp;</td><td height="14"  class="'+cestilo+'"><img src="'+ruta_imagenes+'movistar_es_espacio3.gif" width="5" height="1" border="0"><img src="'+ruta_imagenes+'movistar_es_iconivel3.gif" border=0 align="absmiddle">'}
									if (arbol[i].level==4) { cestilo='itemmenunivel3'; textohtml+='<tr><td class="fijoa10">&nbsp;</td><td class="fijoa10">&nbsp;</td><td height="14"  class="'+cestilo+'"><img src="'+ruta_imagenes+'movistar_es_espacio3.gif" width="15" height="1" border="0"><img src="'+ruta_imagenes+'movistar_es_iconivel3.gif" border=0 align="absmiddle">'}
									if (arbol[i].level==5) { cestilo='itemmenunivel3'; textohtml+='<tr><td class="fijoa10">&nbsp;</td><td class="fijoa10">&nbsp;</td><td height="14"  class="'+cestilo+'"><img src="'+ruta_imagenes+'movistar_es_espacio3.gif" width="15" height="1" border="0"><img src="'+ruta_imagenes+'movistar_es_iconivel3.gif" border=0 align="absmiddle">'}			
									if (arbol[i].level==6) { cestilo='itemmenunivel3'; textohtml+='<tr><td class="fijoa10">&nbsp;</td><td class="fijoa10">&nbsp;</td><td height="14"  class="'+cestilo+'"><img src="'+ruta_imagenes+'movistar_es_espacio3.gif" width="15" height="1" border="0"><img src="'+ruta_imagenes+'movistar_es_iconivel3.gif" border=0 align="absmiddle">'}	
									if ((arbol[i].description != "Resumen de Tarifas") && (arbol[i].description != "Resumen de tarifas")) {texxxto= '<span class="'+cestilo+'"><b>'+arbol[i].description+'</b></span>'}
									
											
								} else {
				
									//Usamos esto para eliminar la opcion "Resumen de Tarifas"
									if ((arbol[i].level==1) && (arbol[i].description != "Resumen de Tarifas") && (arbol[i].description != "Resumen de tarifas")) { cestilo='itemmenu'; textohtml+='<tr><td width="12" height="16"><img src="'+ruta_imagenes+'movistar_es_iconar1.gif" width="12" height="16"></td><td height="16" width="250" colspan="2" class="itemmenu">'}
									if (arbol[i].level==2) { cestilo='itemmenunivel2'; textohtml+='<tr><td width="12" class="fijoa10">&nbsp;</td><td width="16"><img src="'+ruta_imagenes+'movistar_es_iconivel2.gif" width="14" height="13"></td><td width="250" height="16" class="itemmenunivel2">'}
									if (arbol[i].level==3) { cestilo='itemmenunivel3b'; textohtml+='<tr><td class="fijoa10">&nbsp;</td><td class="fijoa10">&nbsp;</td><td height="14"><img src="'+ruta_imagenes+'movistar_es_espacio3.gif" width="5" height="1" border="0"><img src="'+ruta_imagenes+'movistar_es_iconivel3b.gif" hspace="0" width="7" height="16" border="0" align="absmiddle" class="'+cestilo+'">'}
									if (arbol[i].level==4) { cestilo='itemmenunivel3b'; textohtml+='<tr><td class="fijoa10">&nbsp;</td><td class="fijoa10">&nbsp;</td><td height="14"><img src="'+ruta_imagenes+'movistar_es_espacio3.gif" width="15" height="1" border="0"><img src="'+ruta_imagenes+'movistar_es_iconivel3b.gif" hspace="0" width="7" height="16" border="0" align="absmiddle" class="'+cestilo+'">'}
									if (arbol[i].level==5) { cestilo='itemmenunivel3b'; textohtml+='<tr><td class="fijoa10">&nbsp;</td><td class="fijoa10">&nbsp;</td><td height="14"><img src="'+ruta_imagenes+'movistar_es_espacio3.gif" width="15" height="1" border="0"><img src="'+ruta_imagenes+'movistar_es_iconivel3b.gif" hspace="0" width="7" height="16" border="0" align="absmiddle" class="'+cestilo+'">'}
									
									if (arbol[i].level==6) { cestilo='itemmenunivel3b'; textohtml+='<tr><td class="fijoa10">&nbsp;</td><td class="fijoa10">&nbsp;</td><td height="14"><img src="'+ruta_imagenes+'movistar_es_espacio3.gif" width="15" height="1" border="0"><img src="'+ruta_imagenes+'movistar_es_iconivel3b.gif" hspace="0" width="7" height="16" border="0" align="absmiddle" class="'+cestilo+'">'}
									
									
									
											
									if ((i==segundonivelactivo) ) {
										texxxto= '<span class="'+cestilo+'"><b>'+arbol[i].description+'</b></span>'
									
									//Usamos esto para eliminar la opcion "Resumen de Tarifas"
									} else if ((arbol[i].description != "Resumen de Tarifas") && (arbol[i].description != "Resumen de tarifas")) {
										texxxto= '<span class="'+cestilo+'">'+arbol[i].description+'</span>'
										
									}
									
							
								}
								
							}
						
						
						
					
						/************************************* TODOS LINKAN *************************************/
						if (arbol[i].url!='#') {
							if (arbol[i].url.indexOf('script')>-1){ 
							
								textohtml+='<a href="javascript:;" onclick="'+arbol[i].url+'" title="'+arbol[i].description+'"  class="'+cestilo+'">'+texxxto+'</a></td></tr>'
							} else {
								
								if (arbol[i].url.indexOf('http')>-1){ 
									textohtml+='<a href="'+arbol[i].url+'" target="_blank" title="'+arbol[i].description+'"  class="'+cestilo+'">'+texxxto+'</a></td></tr>'								
								} else {
									textohtml+='<a href="'+carp+arbol[i].url+'" title="'+arbol[i].description+'"  class="'+cestilo+'">'+texxxto+'</a></td></tr>'
								}
							}
							
						} else {
							textohtml+='<a href="javascript:toggle(' + i + ')"  title="'+arbol[i].description+'"  class="'+cestilo+'">'+texxxto+'</a></td></tr>'		
							
						}
						/**************************************** FIN TODOS LINKAN *****************************/
						
						/***************************** SOLO LINKAN LOS HIJOS FINALES ************************** 
						// ====> Si lleva link
						if (((arbol[i+1].name).indexOf(arbol[i].name))==-1) {
						//if (mapaOpcion[i].url!='') {
								
							// ====> Si el link lleva javascript asociado
							if (arbol[i].url.indexOf('script')>-1){ 
								
							textohtml+='<a href="javascript:;" onclick="'+arbol[i].url+'" title="'+arbol[i].description+'" >'+texxxto+'</a></td></tr>'
							// ====> Si el link no lleva javascript asociado (simple link)
							} else {
								// ====> Si el link es externo (fuera del servidor)
								if (arbol[i].url.indexOf('http')>-1){ 
									if (arbol[i].url.indexOf('canalcliente')<0){ 
										textohtml+='<a href="'+arbol[i].url+'" target="_self"  title="'+arbol[i].description+'" >'+texxxto+'</a></td></tr>'								
									}else{
										textohtml+='<a href="'+arbol[i].url+'" target="_self"  title="'+arbol[i].description+'" >'+texxxto+'</a></td></tr>'								
									}
								// ====> Si el link es interno (dentro del servidor)
								} else {
									textohtml+='<a href="'+carp+''+arbol[i].url+'" title="'+arbol[i].description+'" class="'+cestilo+'" onmouseover="if(document.all) {this.style.textDecoration=\'underline\'};" onmouseout="if(document.all) {this.style.textDecoration=\'none\'};">'+arbol[i].description+'</a></td></tr>'
										
								}
							}
							
						// ====> Si no tiene q linkar a ningún sitio, tiene subopciones 
						//	(se hace toggle: desplegar o colapsar, según sea su estado)
						} else {
								textohtml+='<a href="javascript:toggle(' + i + ')"  title="'+arbol[i].description+'" >'+texxxto+'</a></td></tr>'		
								
						}
						/***************************** FIN SOLO LINKAN LOS HIJOS FINALES ***************************/
						
					}///////
					
					
				} 
			   }
	
	}

	
	textohtml+='<tr><td  colspan="3" height="4" align="center"><img src="'+ruta_imagenes+'movistar_es_icogris.gif" width="204" height="1"></td></tr>'

	//textohtml+='</table></td><td width="1" bgcolor="#FFFFFF"><img src="'+ruta_imagenes+'movistar_es_espacio3.gif" width="1" height="16"></td></tr>'
	textohtml+='<tr><td colspan="4"><img src="'+ruta_imagenes+'movistar_es_espacio3.gif" width="204" height="11"></td><td><img src="'+ruta_imagenes+'movistar_es_espacio3.gif" width="1" height="1"></td></tr></table><br>'
	window.status=obtenerCanal();
	valecanal=obtenerCanal();
	
//	Particulares
	/*if(arbol[1].description=='Tipos de Tarjeta'){
	textohtml+='<table width="204" border="0" cellspacing="0" cellpadding="0"><tr><td>';
	textohtml+='<a href="javascript:MM_openBrWindow(\'/asesores/index.html\',\'Asesor\',\'scrollbars=no\',\'710\',\'560\',\'true\')">';
	textohtml+='<img src="/staticFiles/cda/movistar_es_asesorvirtual.jpg" alt="Asesor Virtual" id="asesortarifas" width="179" height="71" vspace="10" border="0" />';
	textohtml+='</a>';
	textohtml+='</td></tr></table>';
	}*/
	
//	Empresas	
	/*if(arbol[1].description=='Tipos de Contratos'){
	textohtml+='<table width="204" border="0" cellspacing="0" cellpadding="0"><tr><td>';
	textohtml+='<a href="javascript:MM_openBrWindow(\'http://www.movistar.es/asesores/empresas/index.html\',\'asesordecontratos\',\'scrollbars=no\',\'700\',\'450\',\'true\')">';
	textohtml+='<img src="/staticFiles/cda/movistar_es_asesorvirtual.jpg" alt="Asesor Virtual" id="asesortarifas" width="179" height="71" vspace="10" border="0" />';
	textohtml+='</a>';
	textohtml+='</td></tr></table>';
	}*/
	
//	Autonomos
	//if(arbol[1].description=='Contrato Autónomos'){
	/*if(arbol[1].parentname=='Autonomos:Tarifas y Contratos'){
	textohtml+='<table width="204" border="0" cellspacing="0" cellpadding="0"><tr><td>';
	textohtml+='<a href="javascript:MM_openBrWindow(\'http://www.movistar.es/asesores/autonomos/index.html\',\'asesordecontratos\',\'scrollbars=no\',\'700\',\'450\',\'true\')">';
	textohtml+='<img src="/staticFiles/cda/movistar_es_asesorvirtual.jpg" alt="Asesor Virtual" id="asesortarifas" width="179" height="71" vspace="10" border="0" />';
	textohtml+='</a>';
	textohtml+='</td></tr></table>';
	}
	
	
	if(arbol[1].description=='Siempre Saldo'){
		textohtml+='<table width="204" border="0" cellspacing="0" cellpadding="0"><tr><td>';
		textohtml+='<img src="/staticFiles/cda/movistar_es_dest_asesorempresas.gif" alt="Asesor de Tarifas" width="133" height="239" vspace="10" border="0" usemap="#segundo" title="Asesor de Tarifas"/>';
		textohtml+='</td></tr></table>';
		textohtml+='<map name="segundo" id="segundo"> ';
		textohtml+='<area shape="rect" coords="15,88,115,102" href="http://www.movistar.es/empresas/tarifasycontratos/tarifas/index">';
		textohtml+='<area shape="rect" coords="15,113,115,127" href="javascript:;" onClick="MM_openBrWindow(\'http://www.movistar.es/asesores/empresas/index.html\',\'asesordecontratos\',\'scrollbars=no\',\'700\',\'450\',\'true\')">';
		textohtml+='</map>';
	}*/
	
	
			
	MM_setTextOfLayer("capa_menu_lateral",0,textohtml);
	
}




function setStorage(numero) {
        var text = ""
        for (var i = 0; i < arbol.length; ++i) {
                text += (arbol[i].state) ? "1" : "0"
        }
     menumm= text
	menummon=numero
		
}
 


var nWidth=0;
var nHeight=0;
var nBodyW=0;
var nBodyH=0;




function buscar(mifrm){  
  var texque=mifrm.txtbuscar.value	
  if (texque=="" || null){  
    alert("Introducir texto a buscar.")
    mifrm.txtbuscar.focus
  }else{  
    //var url="../"+carp+"buscador/index.htm?claves="+(texque)
	var url="http://www.movistar.es/buscador/index.htm?claves="+escape(texque)
 
    var idv=window.open (url, "buscador", "scrollbars=yes,status=yes,width=790,height=560,screenX=0,screenY=0")

    idv.focus()
  }  

}


var comilla;

function escribefechahora(){
	
	var fecha_actual = new Date(); hora = fecha_actual.getHours(); minuto = fecha_actual.getMinutes();  if (minuto<10)  minuto='0'+minuto; 
	htmlfecha='<span class="hora">'+hora+':'+minuto+'&nbsp;</span>';
	var nombres_dias = new Array("Domingo", "Lunes", "Martes", "Mi&eacute;rcoles", "Jueves", "Viernes", "S&aacute;bado"); var nombres_meses = new Array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");var fecha_actual = new Date();dia_mes = fecha_actual.getDate();dia_semana = fecha_actual.getDay();mes = fecha_actual.getMonth() + 1;anio = fecha_actual.getFullYear();lafecha= nombres_dias[dia_semana] + ", <b>" + dia_mes + "</b> de " + nombres_meses[mes - 1]; 
	htmlfecha+='<span class="grisfecha">'+lafecha.toLowerCase()+'</span>'
	return htmlfecha
	
}




function creararbol() {
	arbol=OpcionesMenuLateral(seccion);
	
  
	pintamenu();
	
}


///////////////////////////FUNCIONES AUXILIARES PARA TARIFAS Y CONTRATOS NUEVAS TARIFAS
function anegrita (){
	for (var i=1;i<=14;++i){
		enlac = "link"+i;
		document.getElementById(enlac).style.fontWeight="normal";
		}
	}

//Los elementos se meteran en un array y se hará un FOR en vez de todas estas sentencias
function muestratarifa1 (tarifa){
	if (tarifa == "tarjeta"){
		document.getElementById('copy1').style.display="none";
		document.getElementById('tarifemp').style.display="none";
		document.getElementById('tarifcontra').style.display="none";
		document.getElementById('tariftarje').style.display="block";
		
	} else {
		if (tarifa == "contrato"){
			document.getElementById('copy1').style.display="none";
			document.getElementById('tarifemp').style.display="none";
			document.getElementById('tariftarje').style.display="none";
			document.getElementById('tarifcontra').style.display="block";} 
		else {
			document.getElementById('copy1').style.display="none";
			document.getElementById('tarifcontra').style.display="none";
			document.getElementById('tariftarje').style.display="none";
			document.getElementById('tarifemp').style.display="block";
		}
	}
}

//TARJETA
function muestratarifa2 (tarifa){
	anegrita();
	if (tarifa == "nacional"){
		document.getElementById('link1').style.fontWeight="bold";
		document.getElementById('contenidos').src="/tarifasnuevas/tarjeta_tarifas-nacionales.html";
	}
	if (tarifa == "internacional"){
		document.getElementById('link2').style.fontWeight="bold";
		document.getElementById('contenidos').src="/tarifasnuevas/tarjeta_tarifas-internacionales.html";
	}
	if (tarifa == "tarifasroaming"){
		document.getElementById('link3').style.fontWeight="bold";
		document.getElementById('contenidos').src="/tarifasnuevas/tarjeta_tarifas-roaming.html";
	}
	if (tarifa == "servicios"){
		document.getElementById('link4').style.fontWeight="bold";
		document.getElementById('contenidos').src="/tarifasnuevas/tarjeta_tarifas-servicios.html";
	}

}

//CONTRATO
function muestratarifa3 (tarifa){
	anegrita();
	if (tarifa == "nacional"){
		document.getElementById('link5').style.fontWeight="bold";
		document.getElementById('contenidos').src="/tarifasnuevas/contrato_nacionales.html";
	}
	if (tarifa == "internacional"){
		document.getElementById('link6').style.fontWeight="bold";
		document.getElementById('contenidos').src="/tarifasnuevas/contrato_internacionales.html";
	}
	if (tarifa == "tarifasroaming"){
		document.getElementById('link7').style.fontWeight="bold";
		document.getElementById('contenidos').src="/tarifasnuevas/contrato_roaming.html";
	}
	if (tarifa == "servicios"){
		document.getElementById('link8').style.fontWeight="bold";
		document.getElementById('contenidos').src="/tarifasnuevas/contrato_servicios.html";
	}
	if (tarifa == "movistarcombi"){
		document.getElementById('link9').style.fontWeight="bold";
		document.getElementById('contenidos').src="/tarifasnuevas/contrato_otros_ servicios.html";
	}	

}

//EMPRESAS
function muestratarifa4 (tarifa){
	anegrita();
	if (tarifa == "nacional"){
		document.getElementById('link10').style.fontWeight="bold";
		document.getElementById('contenidos').src="/tarifasnuevas/empresas_nacionales.html";
	}
	if (tarifa == "internacional"){
		document.getElementById('link11').style.fontWeight="bold";
		document.getElementById('contenidos').src="/tarifasnuevas/empresas_internacionales.html";
	}
	if (tarifa == "tarifasroaming"){
		document.getElementById('link12').style.fontWeight="bold";
		document.getElementById('contenidos').src="/tarifasnuevas/empresas_roaming.html";
	}
	if (tarifa == "servicios"){
		document.getElementById('link13').style.fontWeight="bold";
		document.getElementById('contenidos').src="/tarifasnuevas/empresas_servicios.html";
	}
	if (tarifa == "movistarcombi"){
		document.getElementById('link14').style.fontWeight="bold";
		document.getElementById('contenidos').src="/tarifasnuevas/empresas_otros.html";
	}

}

function escribeframe()
{

document.write('<iframe src="#" id="contenidos" name="contenidos" width="540" frameborder="0" scrolling="no" height="0" style="overflow:auto" onload="resize_iframe()"></iframe>');
}

moz=document.getElementById&&!document.all;
mozHeightOffset=20;

//Cambia dinamicamente el tamaño del iframe
function resize_iframe(){
document.getElementById("contenidos").height=100 // required for Moz bug, value can be "", null, or integer
document.getElementById("contenidos").height=window.frames["contenidos"].document.body.scrollHeight+(moz?mozHeightOffset:0)
}


