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 cargafoto(id_foto)
{
	if (id_foto == null) {
		id_foto = foto_actual + 1;
		if (document.getElementById("foto" + id_foto) == null) {
			id_foto = 1;
		}
		
	}
	if (foto_actual != 0) {
		document.getElementById("foto" + foto_actual).style.visibility="hidden";
		document.getElementById("boton" + foto_actual).className ="boton";
	}
	document.getElementById("foto" + id_foto).style.visibility="visible";
	document.getElementById("boton" + id_foto).className ="botonactivo";
	foto_actual = parseInt(id_foto);
		
}

function iniciar_scroll() {
	cargafoto();
	setInterval("cargafoto()", 7000);
}

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

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

posicion_noticias = 120;
var t;
function scroll_noticias(estado){ 

if(posicion_noticias < (0 - document.getElementById('scroller').offsetHeight)){ 
	posicion_noticias = 120;
} 
	
	if (estado == 'pausa') {
		clearTimeout(t);
	} else {
		posicion_noticias-=1; 
		document.getElementById('scroller').style.top=posicion_noticias+'px'; 
		t=setTimeout( function(){ scroll_noticias('continuar') },50 );
	}
}


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         = "../images";    // 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 place(elemento)
{
	texto = elemento.options[elemento.selectedIndex].value.split('*,*');
	editor = tinyMCE.getInstanceById('horario'); 
	editor.setContent(texto[1]);  
	editor = tinyMCE.getInstanceById('lugar'); 
	editor.setContent(texto[0]);  
	editor = tinyMCE.getInstanceById('precio'); 
	editor.setContent(texto[2]);  
}