
	function resetPestanyas()
		{
			var pestanyas = document.getElementById("pestFicha").childNodes;
			for (i=0; i<pestanyas.length; i++)
			{
				if (pestanyas.item(i).nodeName == "LI")
				{
					for (j=0; j<pestanyas.item(i).childNodes.length; j++)
					{
						if (pestanyas.item(i).childNodes.item(j).nodeName == "A")		
						{
							pestanyas.item(i).childNodes.item(j).className = ""
						}
					}
				}
			}
		}
		function resetTxtPestanyas()
		{
			for(i=0; i<document.getElementsByTagName("div").length; i++){
				idContenido = document.getElementsByTagName("div")[i].id;
				nombreId = idContenido.substring(0,3);
				if(nombreId == "txt"){
					document.getElementsByTagName("div")[i].style.display = "none";
				}
			}
			/*document.getElementById("txtCoberturas").style.display = "none";
			document.getElementById("txtComparacion").style.display = "none";	*/
		}
		function shComparacion(idProducto,tipoComp,estado)
		{
			if(eval("document.getElementById('"+tipoComp+"1_"+idProducto+"')"))
				eval("document.getElementById('"+tipoComp+"1_"+idProducto+"').style.display = '"+estado+"'")
			
			var tipoPoliza = eval("document.getElementById('"+tipoComp+"2_"+idProducto+"')")
			if (tipoPoliza)
			{
				eval("document.getElementById('"+tipoComp+"2_"+idProducto+"').style.display = '"+estado+"'")
			}
			var tipoPoliza2 = eval("document.getElementById('"+tipoComp+"3_"+idProducto+"')")
			if (tipoPoliza2)
			{
				eval("document.getElementById('"+tipoComp+"3_"+idProducto+"').style.display = '"+estado+"'")
			}			
		}
		function hideComparacion()
		{
			for (i=0; i<productos.length; i++)
			{
				shComparacion(productos[i],"Gen","none")
				shComparacion(productos[i],"Det","none")					
			}
		}
		function showComparacion(idProducto,tipoComp)
		{
			
			shComparacion(productos[i],tipoComp,"block")
		}
		function showHideBoton(botonID,estado)
		{
			document.getElementById(botonID).style.display = estado;
		}
		
				
		function inicioPestanya(url)
		{
			//detalleUrl = document.location.href;
			if(url.indexOf("&")>0)
				pestanya = url.substring(url.indexOf("idPestanya=")+ 11, url.indexOf("&"));
			else
				pestanya = url.substring(url.indexOf("idPestanya=")+ 11);
			
			resetPestanyas();
			resetTxtPestanyas();
							
			if(url.indexOf(pestanya)!=-1)
			{
				var encontrado = "N";
				document.getElementById(pestanya).className = "on";
				
				if(eval("document.getElementById('txt"+pestanya+"')")!=null){
					encontrado = "S";
					eval("document.getElementById('txt"+pestanya+"')").style.display = "block";
				}
				
				if(querystring!=""){
					
					if(querystring.indexOf("idPestanya")!=-1){
						var valor = querystring.substring(querystring.indexOf("idPestanya"),querystring.indexOf("&")+1);
						querystring = querystring.replace(valor,"");
					}
					
					if(url.indexOf("?")>0){
						if(document.getElementById(pestanya).href.indexOf("tarificador")<0){
							document.getElementById(pestanya).href += "&" + querystring;
						}
					}else{
						document.getElementById(pestanya).href += "?" + querystring;
					}
				}
				
				if(encontrado == "N"){
					if(querystring!=""){
						if(document.location.href.indexOf("?")>0)
							document.location.href += "&" + querystring;
						else
							document.location.href += "?" + querystring;
					}else{
						document.location.href = url;
					}
				}	
			}
			if(url.indexOf("Comparacion")!=-1) 
			{
				document.getElementById("Comparacion").className = "on";
				if(document.getElementById("txtComparacion")!=null){
					document.getElementById("txtComparacion").style.display = "block";
					
					poliza = document.getElementById("poliza2").value;
								
					showHideBoton('tablaComparaDet','none');
					hideComparacion();
				
					shComparacion(poliza,"Gen","block");
					if(document.getElementById("compGen") != null)
						document.getElementById("compGen").className = "on";
						
					if(querystring.indexOf("tarificador")!=-1){
						var uls = document.getElementsByTagName("UL");
						for(i=0; i<uls.length; i++){
							if(uls[i].className == "pestTabla"){
								uls[i].style.display = "none";
							}
						}
					}
				}
			}
		}
		
		function inicioPestanyaMasInfo(url)
		{
			if(url.indexOf("&")>0)
				pestanya = url.substring(url.indexOf("idPestanya=")+ 11, url.indexOf("&"));
			else
				pestanya = url.substring(url.indexOf("idPestanya=")+ 11);
			
			
			if(url.indexOf(pestanya)!=-1)
			{
				if(url.indexOf("padre")!=-1)
				{
					var idProducto = url.substring(url.indexOf("padre=") + 6, url.length);
					var contenidos = document.getElementsByTagName("div");
					
					
					for(i=0;i<contenidos.length; i++)
					{	
						if(contenidos[i].className == "pestProd" && contenidos[i].id=="pestProd"+idProducto)
						{
							//Sacar los hijos
							var hijos = contenidos[i].childNodes;
							for(x=0;x<hijos.length;x++)
							{
								if(hijos.item(x).nodeName == "DIV"){
									var nuevo = hijos.item(x).childNodes;
									for(h=0;h<nuevo.length;h++)
									{
										//Aquí
										if(nuevo.item(h).nodeName == "UL")
										{
											var nietos = nuevo.item(h).childNodes;
											for(z=0;z<nietos.length;z++)
											{
												if(nietos.item(z).nodeName == "LI")
												{
													var biznietos = nietos.item(z).childNodes;
													for(y=0;y<biznietos.length;y++){
														if (biznietos.item(y).nodeName == "A" && biznietos.item(y).id==pestanya){
															biznietos.item(y).className = "on";
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
				//document.getElementById(pestanya).className = "on";
			}
		}
		
		function enviarProducto(tipoDetalle)
		{
			/*var botonID = "";
			var botonIDhide = "";
			if (tipoDetalle == "Det")
			{
				botonID = "tablaComparaDet";
				botonIDhide = "tablaCompara";
				if(document.getElementById("compGen") != null)
					document.getElementById("compGen").className = "";
				if(document.getElementById("compDet") != null)
					document.getElementById("compDet").className = "on";				
			}
			else
			{
				botonID = "tablaCompara";
				botonIDhide = "tablaComparaDet";
				if(document.getElementById("compGen") != null)
					document.getElementById("compGen").className = "on";
				if(document.getElementById("compDet") != null)
					document.getElementById("compDet").className = "";				
			}*/
			var poliza = document.getElementById("poliza2").value;
			
			hideComparacion();
			/*showHideBoton(botonID,"block")
			showHideBoton(botonIDhide,"none")*/
			shComparacion(poliza,tipoDetalle,"block");
		}
		
		function cargaPestanya(){
			url = document.location.href;
			
			if(url.indexOf("faqs")>0){
				abrirFaq();
			}else{
			
				if(url.indexOf("#")<0){
					inicioPestanya(urlPrimerClick);
				}else{
					inicioPestanya(url);
				}
			}
			
		}