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_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) { //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_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 carrusel() {
	var myPhotoCarousel = new CarouselJs('carruseldestacados', {speed: 45, pauseInterval: 0.5});
}

var foto_actual = 0;

function cambiafoto()
{
	if (foto_actual < 10) {
		foto_actual++;
	} else {
		foto_actual = 1;
	}
	document.getElementById("scrollimagenes").style.background = 'url(../imagenes/cabecera/'+foto_actual+'.jpg)';
		
}

function iniciar_scroll() {	
	MM_preloadImages('../imagenes/cabecera/1.jpg','../imagenes/cabecera/2.jpg','../imagenes/cabecera/3.jpg','../imagenes/cabecera/4.jpg','../imagenes/cabecera/5.jpg','../imagenes/cabecera/6.jpg','../imagenes/cabecera/7.jpg','../imagenes/cabecera/8.jpg','../imagenes/cabecera/9.jpg','../imagenes/cabecera/10.jpg');
	cambiafoto();
	setInterval("cambiafoto()", 7000);
}

function verificar(mensaje)
{
	if (confirm(mensaje))
	{
		return true;
	}
	else
	{
		return false;
	}
}

function validarcomentarios()
{
	if (document.getElementById('nombre').value.length==0 || document.getElementById('comentario').value.length==0 || document.getElementById('mail').value.length==0)
	{ 
       alert ("Todos los campos son obligatorios");
	   return false;
    } 
	
	if (document.getElementById('mail').value.length > 0)
	{
		var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/;
		if (b.test(document.getElementById('mail').value) == false)
		{
			alert("Email " + (b.test(document.getElementById('mail').value)?"":"no ") + "válido.");
			return false;
		}
	}
	
	document.getElementById('formulariocomentarios').submit();
	return true;
}

function mostrar_ocultar(id,id2)
{
	if (document.getElementById){
		var div1 = document.getElementById(id);
		var div2 = document.getElementById(id2);
		div1.style.display = 'block'; 
		div2.style.display = 'none'; 
	}
}
function ocultar(id,id2)
{
	if (document.getElementById){
		var div1 = document.getElementById(id);
		var div2 = document.getElementById(id2);
		div1.style.display = 'none'; 
		div2.style.display = 'none'; 
	}
}

function mostrar_capa (id)
{
document.getElementById(id).style.display="block";
}

function ocultar_capa (id)
{
document.getElementById(id).style.display="none";
}

function ocultar_rutas ()
{
	for (i=1; i<18;i++) {
		document.getElementById("rutaszona"+i).style.visibility="hidden";
	}
}

function mostrar_ruta (id)
{
	ocultar_rutas();
	document.getElementById("rutaszona"+id).style.visibility="visible";	
}

function configuraCalendario()
{
	// Para a&ntilde;adir festivos: (opcional)
	addHoliday( 1,  1, 0, "A&ntilde;o Nuevo");
	addHoliday(25, 12, 0, "Navidad");

	startAt        = 1;    // primer dia de la semana: 1->lunes   (por defecto), 0->domingo
	showWeekNumber = 1;    // numero de semana:        1->mostrar (por defecto), 0->ocultar
	
	imgDir         = "imagenes/";    // directorio donde se guardan las imagenes usadas por el calendario (por defecto "", el mismo donde esta popcalendar.js)

	// OJO: la imagen del bot&oacute;n para cerrar el calendario (close.gif) hay que dejarla donde est&aacute;, si no no se ve

	// Textos traducidos al español:

	gotoString  = "Ir al mes actual";
	todayString = "Hoy es";
	weekString  = "Sem";
	scrollLeftMessage  = "Pulsa para desplazar al mes anterior. Mant&eacute;n el bot&oacute;n pulsado para desplazar autom&aacute;ticamente.";
	scrollRightMessage = "Pulsa para desplazar al mes siguiente. Mant&eacute;n el bot&oacute;n pulsado para desplazar autom&aacute;ticamente.";
	selectMonthMessage = "Pulsa para seleccionar un mes.";
	selectYearMessage  = "Pulsa para seleccionar un a&ntilde;o.";
	selectDateMessage  = "Selecciona la fecha [date]."    // no modificar [date], se sustituir&aacute; por la fecha.
	monthName = new Array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
	dayName   = new Array("Lu", "Ma", "Mi", "Ju", "Vi", "Sa", "Do");
	
	// Inicializamos el calendario:
	init();
}

function escribeFechaInicio() 
{
	// Recibe la fecha del campo hidden en formato dd/mm/aaaa y separa el dia, mes y a&ntilde;o para cargar las cajas de texto separadamente:
	
	document.form1.inicio.value = document.form1.fecha_inicio.value;
	
	document.form1.fecha_fin.value = document.form1.fecha_inicio.value;

}

function escribeFechaFin()
{
	document.form1.fin.value = document.form1.fecha_fin.value;
}
function escribeFecha()
{
	document.form1.fecha.value = document.form1.fecha_fin.value;
}

function eliminar_encuesta(id)
{
	if(confirm("¿Desea eliminar la encuesta?"))
		document.location = "encuestas.php?eliminar=" + id;
}
function enviar_formulario(formulario)
{
	document.getElementById(formulario).submit();
}

function mostrar_traductor(id)
{
	if (document.getElementById(id).style.display=="block")
	{
		document.getElementById(id).style.display="none";
	}
	else
	{
		document.getElementById(id).style.display="block";
	}
}

function PopWindow(url)
{
	dir="/rutas/video.php?v=" + url;
	window.open(dir,'MyWindow','width=500,height=380,menubar=no,scrollbars=no,toolbar=no,location=no,directories=no,resizable=no,top=0,left=0');
}

function relacionado(url)
{
	window.open(url, "carga", "toolbar=no,status=no,width=600,height=700,scrollbars=yes");
}
