// JavaScript Document

var pestanyaActiva = "";

//Funcion para seleccionar la pestaña activa
function activarPestanya()
{
	var urlActiva = window.location.pathname;
	var regex = new RegExp("enlaces.php");
	var results = regex.exec(urlActiva);
	if(results != null)
	{
		document.getElementById("pestanya_enlaces_left").className = 'pestanya_left_selected';
		document.getElementById("pestanya_enlaces_centro").className = 'pestanya_centro_selected';
		document.getElementById("pestanya_enlaces_right").className = 'pestanya_right_sin_desplegable_selected';
		
		pestanyaActiva = "enlaces";
	}
	else
	{
		regex = new RegExp("historico.php");
		results = regex.exec(urlActiva);
		if(results != null)
		{
			document.getElementById("pestanya_historico_left").className = 'pestanya_left_selected';
			document.getElementById("pestanya_historico_centro").className = 'pestanya_centro_selected';
			document.getElementById("pestanya_historico_right").className = 'pestanya_right_selected';
			
			pestanyaActiva = "historico";
		}
		else
		{
			regex = new RegExp("ejercicios.php");
			results = regex.exec(urlActiva);
			if(results != null)
			{
				document.getElementById("pestanya_ejercicios_left").className = 'pestanya_left_selected';
				document.getElementById("pestanya_ejercicios_centro").className = 'pestanya_centro_selected';
				document.getElementById("pestanya_ejercicios_right").className = 'pestanya_right_selected';
				
				pestanyaActiva = "ejercicios";
			}
			else
			{
				regex = new RegExp("actividades.php");
				results = regex.exec(urlActiva);
				if(results != null)
				{
					document.getElementById("pestanya_ejercicios_left").className = 'pestanya_left_selected';
					document.getElementById("pestanya_ejercicios_centro").className = 'pestanya_centro_selected';
					document.getElementById("pestanya_ejercicios_right").className = 'pestanya_right_selected';
					
					pestanyaActiva = "ejercicios";
				}
				else
				{
					regex = new RegExp("artistas.php");
					results = regex.exec(urlActiva);
					if(results != null)
					{
						document.getElementById("pestanya_anecdotario_left").className = 'pestanya_left_selected';
						document.getElementById("pestanya_anecdotario_centro").className = 'pestanya_centro_selected';
						document.getElementById("pestanya_anecdotario_right").className = 'pestanya_right_selected';
						
						pestanyaActiva = "anecdotario";
					}
					else
					{
						regex = new RegExp("famosos.php");
						results = regex.exec(urlActiva);
						if(results != null)
						{
							document.getElementById("pestanya_anecdotario_left").className = 'pestanya_left_selected';
							document.getElementById("pestanya_anecdotario_centro").className = 'pestanya_centro_selected';
							document.getElementById("pestanya_anecdotario_right").className = 'pestanya_right_selected';
							
							pestanyaActiva = "anecdotario";
						}
						else
						{
							regex = new RegExp("citas.php");
							results = regex.exec(urlActiva);
							if(results != null)
							{
								document.getElementById("pestanya_anecdotario_left").className = 'pestanya_left_selected';
								document.getElementById("pestanya_anecdotario_centro").className = 'pestanya_centro_selected';
								document.getElementById("pestanya_anecdotario_right").className = 'pestanya_right_selected';
								
								pestanyaActiva = "anecdotario";
							}
							else
							{
								regex = new RegExp("lecturas_falleras.php");
								results = regex.exec(urlActiva);
								if(results != null)
								{
									document.getElementById("pestanya_anecdotario_left").className = 'pestanya_left_selected';
									document.getElementById("pestanya_anecdotario_centro").className = 'pestanya_centro_selected';
									document.getElementById("pestanya_anecdotario_right").className = 'pestanya_right_selected';
									
									pestanyaActiva = "anecdotario";
								}
								else
								{
									regex = new RegExp("origen_fiesta.php");
									results = regex.exec(urlActiva);
									if(results != null)
									{
										document.getElementById("pestanya_anecdotario_left").className = 'pestanya_left_selected';
										document.getElementById("pestanya_anecdotario_centro").className = 'pestanya_centro_selected';
										document.getElementById("pestanya_anecdotario_right").className = 'pestanya_right_selected';
										
										pestanyaActiva = "anecdotario";
									}
									else
									{
										regex = new RegExp("chicho.php");
										results = regex.exec(urlActiva);
										if(results != null)
										{
											document.getElementById("pestanya_anecdotario_left").className = 'pestanya_left_selected';
											document.getElementById("pestanya_anecdotario_centro").className = 'pestanya_centro_selected';
											document.getElementById("pestanya_anecdotario_right").className = 'pestanya_right_selected';
											
											pestanyaActiva = "anecdotario";
										}
										else
										{
											regex = new RegExp("bodas_oro.php");
											results = regex.exec(urlActiva);
											if(results != null)
											{
												document.getElementById("pestanya_anecdotario_left").className = 'pestanya_left_selected';
												document.getElementById("pestanya_anecdotario_centro").className = 'pestanya_centro_selected';
												document.getElementById("pestanya_anecdotario_right").className = 'pestanya_right_selected';
												
												pestanyaActiva = "anecdotario";
											}
											else
											{
												regex = new RegExp("merchandising.php");
												results = regex.exec(urlActiva);
												if(results != null)
												{
													document.getElementById("pestanya_anecdotario_left").className = 'pestanya_left_selected';
													document.getElementById("pestanya_anecdotario_centro").className = 'pestanya_centro_selected';
													document.getElementById("pestanya_anecdotario_right").className = 'pestanya_right_selected';
													
													pestanyaActiva = "anecdotario";
												}
												else
												{
													regex = new RegExp("local_olla.php");
													results = regex.exec(urlActiva);
													if(results != null)
													{
														document.getElementById("pestanya_anecdotario_left").className = 'pestanya_left_selected';
														document.getElementById("pestanya_anecdotario_centro").className = 'pestanya_centro_selected';
														document.getElementById("pestanya_anecdotario_right").className = 'pestanya_right_selected';
														
														pestanyaActiva = "anecdotario";
													}
													else
													{
														regex = new RegExp("tela_pilar.php");
														results = regex.exec(urlActiva);
														if(results != null)
														{
															document.getElementById("pestanya_anecdotario_left").className = 'pestanya_left_selected';
															document.getElementById("pestanya_anecdotario_centro").className = 'pestanya_centro_selected';
															document.getElementById("pestanya_anecdotario_right").className = 'pestanya_right_selected';
															
															pestanyaActiva = "anecdotario";
														}
														else
														{
															regex = new RegExp("monterrubio.php");
															results = regex.exec(urlActiva);
															if(results != null)
															{
																document.getElementById("pestanya_anecdotario_left").className = 'pestanya_left_selected';
																document.getElementById("pestanya_anecdotario_centro").className = 'pestanya_centro_selected';
																document.getElementById("pestanya_anecdotario_right").className = 'pestanya_right_selected';
																
																pestanyaActiva = "anecdotario";
															}
															else
															{
																regex = new RegExp("victor_monzon.php");
																results = regex.exec(urlActiva);
																if(results != null)
																{
																	document.getElementById("pestanya_anecdotario_left").className = 'pestanya_left_selected';
																	document.getElementById("pestanya_anecdotario_centro").className = 'pestanya_centro_selected';
																	document.getElementById("pestanya_anecdotario_right").className = 'pestanya_right_selected';
																	
																	pestanyaActiva = "anecdotario";
																}
																else
																{
																	regex = new RegExp("ofrenda.php");
																	results = regex.exec(urlActiva);
																	if(results != null)
																	{
																		document.getElementById("pestanya_anecdotario_left").className = 'pestanya_left_selected';
																		document.getElementById("pestanya_anecdotario_centro").className = 'pestanya_centro_selected';
																		document.getElementById("pestanya_anecdotario_right").className = 'pestanya_right_selected';
																		
																		pestanyaActiva = "anecdotario";
																	}
																	else
																	{
																		regex = new RegExp("presentacion.php");
																		results = regex.exec(urlActiva);
																		if(results != null)
																		{
																			document.getElementById("pestanya_anecdotario_left").className = 'pestanya_left_selected';
																			document.getElementById("pestanya_anecdotario_centro").className = 'pestanya_centro_selected';
																			document.getElementById("pestanya_anecdotario_right").className = 'pestanya_right_selected';
																			
																			pestanyaActiva = "anecdotario";
																		}
																		else
																		{
																			regex = new RegExp("paellas.php");
																			results = regex.exec(urlActiva);
																			if(results != null)
																			{
																				document.getElementById("pestanya_anecdotario_left").className = 'pestanya_left_selected';
																				document.getElementById("pestanya_anecdotario_centro").className = 'pestanya_centro_selected';
																				document.getElementById("pestanya_anecdotario_right").className = 'pestanya_right_selected';
																				
																				pestanyaActiva = "anecdotario";
																			}
																			else
																			{
																				regex = new RegExp("maquetas.php");
																				results = regex.exec(urlActiva);
																				if(results != null)
																				{
																					document.getElementById("pestanya_anecdotario_left").className = 'pestanya_left_selected';
																					document.getElementById("pestanya_anecdotario_centro").className = 'pestanya_centro_selected';
																					document.getElementById("pestanya_anecdotario_right").className = 'pestanya_right_selected';
																					
																					pestanyaActiva = "anecdotario";
																				}
																				else
																				{
																					regex = new RegExp("crema.php");
																					results = regex.exec(urlActiva);
																					if(results != null)
																					{
																						document.getElementById("pestanya_anecdotario_left").className = 'pestanya_left_selected';
																						document.getElementById("pestanya_anecdotario_centro").className = 'pestanya_centro_selected';
																						document.getElementById("pestanya_anecdotario_right").className = 'pestanya_right_selected';
																						
																						pestanyaActiva = "anecdotario";
																					}
																					else
																					{
																						regex = new RegExp("planta.php");
																						results = regex.exec(urlActiva);
																						if(results != null)
																						{
																							document.getElementById("pestanya_anecdotario_left").className = 'pestanya_left_selected';
																							document.getElementById("pestanya_anecdotario_centro").className = 'pestanya_centro_selected';
																							document.getElementById("pestanya_anecdotario_right").className = 'pestanya_right_selected';
																							
																							pestanyaActiva = "anecdotario";
																						}
																						else
																						{
																							regex = new RegExp("truc_domino.php");
																							results = regex.exec(urlActiva);
																							if(results != null)
																							{
																								document.getElementById("pestanya_anecdotario_left").className = 'pestanya_left_selected';
																								document.getElementById("pestanya_anecdotario_centro").className = 'pestanya_centro_selected';
																								document.getElementById("pestanya_anecdotario_right").className = 'pestanya_right_selected';
																								
																								pestanyaActiva = "anecdotario";
																							}
																							else
																							{
																								document.getElementById("pestanya_fp_left").className = 'pestanya_left_selected';
																								document.getElementById("pestanya_fp_centro").className = 'pestanya_centro_selected';
																								document.getElementById("pestanya_fp_right").className = 'pestanya_right_selected';
																								
																								pestanyaActiva = "fp";
																							}
																						}
																					}
																				}
																			}
																		}
																	}
																}
															}
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
}


//Funciones de capas
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
	document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

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_showHideLayers() { //v6.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')?'block':(v=='hide')?'none':v; }
	obj.display=v; }
}

function Cerrar_ec() {
	$("#ec").slideUp();
}

function Abrir_ec() {
	$("#ec").slideDown();
	document.ecForm.mi_nombre.focus();
}
		
//Función para abrir una ventana nueva
function ventanaSecundaria(URL)
{ 
	window.open(URL,"ventana1","width=620, height=550, scrollbars=yes, menubar=no, location=no, resizable=no");
} 
		
//Función para validar el formulario de Loteria
function Valida(loteriaForm)
{
	if(loteriaForm.nombre.value == '')
	{
		alert('Debes introducir tu nombre.');
		return false;
	}
	else
	{
		if(loteriaForm.apellidos.value == '')
		{
			alert('Debes introducir tus apellidos.');
			return false;
		}
		else
		{
			if(loteriaForm.direccion.value == '')
			{
				alert('Debes introducir tu dirección.');
				return false;
			}
			else
			{
				if(isNaN(loteriaForm.cp.value) == true || loteriaForm.cp.value == '')
				{
					alert('Formato de Codigo Postal incorrecto.');
					return false;
				}
				else
				{
					if(loteriaForm.poblacion.value == '')
					{
						alert('Debes introducir tu población.');
						return false;
					}
					else
					{
						if(loteriaForm.provincia.value == '')
						{
							alert('Debes introducir tu provincia.');
							return false;
						}
						else
						{
							if(isNaN(loteriaForm.telefono.value) == true || loteriaForm.telefono.value.length != 9 || loteriaForm.telefono.value == '')
							{
								alert('Debes introducir un formato de teléfono correcto.');
								return false;
							}
							else
							{
								if(isNaN(loteriaForm.ndecimos.value) == true || loteriaForm.ndecimos.value == '')
								{
									alert('Debes elegir un nº de décimos.');
									return false;
								}
								else
								{
									if(!ValidarEmail(loteriaForm.email.value))
									{
										alert('Formato de e-mail incorrecto.');
										return false;
									}
									else
									{
										if(loteriaForm.email.value != loteriaForm.reemail.value)
										{
											alert('No coinciden los dos e-mails.');
											return false;
										}
										else
										{
											if(!document.loteriaForm.mismaDirec.checked)
											{
												if(loteriaForm.edireccion.value == '')
												{
													alert('Debes introducir la dirección de entrega.');
													return false;
												}
												else
												{
													if(isNaN(loteriaForm.ecp.value) == true || loteriaForm.ecp.value == '')
													{
														alert('Formato de Codigo Postal de entrega incorrecto.');
														return false;
													}
													else
													{
														if(loteriaForm.epoblacion.value == '')
														{
															alert('Debes introducir la población de entrega.');
															return false;
														}
														else
														{
															if(loteriaForm.eprovincia.value == '')
															{
																alert('Debes introducir la provincia de entrega.');
																return false;
															}
															else
															{
																if(loteriaForm.acepto.checked)
																{
																	return true;
																}
																else
																{
																	alert('Debes aceptar las condiciones de envío.');
																	return false;
																}
															}
														}
													}
												}
											}
											else
											{
												if(loteriaForm.acepto.checked)
												{
													return true;
												}
												else
												{
													alert('Debes aceptar las condiciones de envío.');
													return false;
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
}

//Funcion para la misma direccion de envio de loteria
function loteriaMismaDirec()
{
	if(document.loteriaForm.mismaDirec.checked)
	{
		document.loteriaForm.edireccion.disabled = "disabled";
		document.loteriaForm.ecp.disabled = "disabled";
		document.loteriaForm.epoblacion.disabled = "disabled";
		document.loteriaForm.eprovincia.disabled = "disabled";
	}
	else
	{
		document.loteriaForm.edireccion.disabled = "";
		document.loteriaForm.ecp.disabled = "";
		document.loteriaForm.epoblacion.disabled = "";
		document.loteriaForm.eprovincia.disabled = "";
	}
}

//Funcion cambiar total pedido loteria
function calcularTotalPedidoLoteria(numDecimos)
{
	if(!isNaN(numDecimos) && numDecimos > 0 && numDecimos <= 100)
	{
		if(numDecimos == 1)
			document.getElementById("numDecimos").innerHTML = numDecimos + " d&eacute;cimo";
		else
			document.getElementById("numDecimos").innerHTML = numDecimos + " d&eacute;cimos";
		document.getElementById("total").innerHTML = (numDecimos*24)+3;
		document.loteriaForm.ndecimos.value = numDecimos;
	}
}

//Función para validar el formulario de Colaboracion
function ValidaColabora(colaboraForm)
{
	if(colaboraForm.nombre.value == '')
	{
		alert('Debes introducir tu nombre.');
		return false;
	}
	else
	{
		if(colaboraForm.apellidos.value == '')
		{
			alert('Debes introducir tus apellidos.');
			return false;
		}
		else
		{
			if(isNaN(colaboraForm.telefono.value) == true || colaboraForm.telefono.value.length != 9 || colaboraForm.telefono.value == '')
			{
				alert('Debes introducir un formato de teléfono correcto.');
				return false;
			}
			else
			{
				if(!ValidarEmail(loteriaForm.email.value))
				{
					alert('Formato de e-mail incorrecto.');
					return false;
				}
				else
				{
					if(colaboraForm.tipoPublicacion.value == '' || colaboraForm.tipoPublicacion.value == null)
					{
						alert('Debes elegir un tipo de publicidad.');
						return false;
					}
					else
					{
						return true;
					}
				}
			}
		}
	}
}

//Validar email
function ValidarEmail(email)
{
	var filter=/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@+([_a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]{2,200}\.[a-zA-Z]{2,6}$/;
	if (filter.test(email))
	{
		return true;
	}
	else
	{
		return false;
	}
}

//Desplegar menu compartir
function despliegaCompartir()
{
	var menu = document.getElementById("menuCompartir");
	
	if(menu.style.display == "none")
	{
		menu.style.display = "block";
	}
	else
	{
		menu.style.display = "none";
	}
} 