﻿/*function inicializaCalendario(){

	document.calendar.mes.value="";

	document.calendar.ano.value="";

}*/

function preCarga() {

	if (!document.images) return;

	var ar = new Array();

	var argumentos = preload.argumentos;

	for (var i = 0; i < argumentos.length; i++) {

		ar[i] = new Image();

		ar[i].src = argumentos[i];

		alert(i);

	}

}



function devuelveHoy(){

	fecha=new Date();

	calendario(fecha);

}

function versubmenu(id){

	if(document.getElementById(id).style.display=="none")

		document.getElementById(id).style.display='block';

	else

		document.getElementById(id).style.display='none';

}



function cambiarMes(cantidad){

	hoy=new Date();

	mes=document.calendar.mes.value;

	if(mes=="")

		mes=hoy.getMonth();	

	ano=document.calendar.ano.value;

	if(ano=="")

		ano=hoy.getYear()/*+1900*/;

	if(cantidad==1)

		mes++;

	else if(cantidad==0)

		mes--;

	if(mes>11){

		mes=0;

		ano++;

	}

	if(mes<0){

		mes=11;

		ano--;

	}

	if(toString(ano).length==3){

		ano=ano+1900;

	}

	fecha=new Date(ano, mes);

	return calendario(fecha);	

}

//Calendario

function calendario(date){

	<!--//Begin

	monthnames = new Array(

	"Enero",

	"Febrero",

	"Marzo",

	"Abril",

	"Mayo",

	"Junio",

	"Julio",

	"Agosto",

	"Septiembre",

	"Octubre",

	"Noviembre",

	"Diciembre");

	var linkcount=0;

	function addlink(month, day, href) {

		var entry = new Array(3);

		entry[0] = month;

		entry[1] = day;

		entry[2] = href;

		this[linkcount++] = entry;

	}

	Array.prototype.addlink = addlink;

	linkdays = new Array();

	monthdays = new Array(12);

	monthdays[0]=31;

	monthdays[1]=28;

	monthdays[2]=31;

	monthdays[3]=30;

	monthdays[4]=31;

	monthdays[5]=30;

	monthdays[6]=31;

	monthdays[7]=31;

	monthdays[8]=30;

	monthdays[9]=31;

	monthdays[10]=30;

	monthdays[11]=31;

	todayDate=date;

	thisday=todayDate.getDay();

	thismonth=todayDate.getMonth();

	thisdate=todayDate.getDate();

	thisyear=todayDate.getYear();

	thisyear = thisyear % 100;

	thisyear = ((thisyear < 50) ? (2000 + thisyear) : (1900 + thisyear));

	if (((thisyear % 4 == 0) 

	&& !(thisyear % 100 == 0))

	||(thisyear % 400 == 0)) 

		monthdays[1]++;

	startspaces=thisdate+1;

	while (startspaces > 7) 

		startspaces-=7;

	startspaces = thisday - startspaces + 1;

	if (startspaces < 0) 

		startspaces+=7;

	document.calendar.mes.value=thismonth

	document.calendar.ano.value=thisyear

	retorno="<table border=0 align=center";

	retorno+="bordercolor='#739B73' style='font-size : 10px; color : #330099;' cellpadding='0' cellspacing='3'>";

	retorno+="<tr><td><a href='#' onclick='pintarCalendario(0);' alt='Mes anterior'><img src='images/anterior.gif' alt='Mes anterior' border='0'></a></td><td colspan='5'><center> " + monthnames[thismonth].substring(0,3) + " " + thisyear + " </center></td><td><a href='#' onclick='pintarCalendario(1);'><img src='images/siguiente.gif' alt='Mes siguiente' border='0'></a></td></tr>";

	retorno+="<tr>";	

	retorno+="<td align='center'><font color='#CC6633'>L</font></td>";

	retorno+="<td align='center'><font color='#CC6633'>M</font></td>"

	retorno+="<td align='center'><font color='#CC6633'>X</font></td>";

	retorno+="<td align='center'><font color='#CC6633'>J</font></td>";

	retorno+="<td align='center'><font color='#CC6633'>V</font></td>";

	retorno+="<td align='center'><font color='#CC6633'>S</font></td>";

	retorno+="<td align='center'><font color='#CC6633'>D</font></td>";

	retorno+="</tr>";

	retorno+="<tr>";

	for (s=0;s<startspaces;s++) {

		retorno+="<td></td>";

	}

	count=1;

	diaDeHoy=new Date();

	esteAno=diaDeHoy.getYear();

	esteAno = esteAno % 100;

	esteAno = ((esteAno < 50) ? (2000 + esteAno) : (1900 + esteAno));

	while (count <= monthdays[thismonth]) {

		for (b = startspaces;b<7;b++) {

			linktrue=false;

			retorno+="<td align='center'>";

			if (count==diaDeHoy.getDate() && thismonth==diaDeHoy.getMonth() && esteAno==thisyear) {

				retorno+="<font color='#CC6633'>";

			}

			if (count <= monthdays[thismonth]) {

				retorno+=count;

			}else {

				retorno+=" ";

			}

			if (count==diaDeHoy.getDate() && thismonth==diaDeHoy.getMonth() && thisyear==diaDeHoy.getYear()) {

				retorno+="</font>";

			}

			retorno+="</td>";

			count++;

		}

		retorno+="</tr>";

		retorno+="<tr>";

		startspaces=0;

	}

	retorno+="</table>";	

	return retorno;

}

//Menus desplegables

startList = function() {

	if (document.all&&document.getElementById) {

		navRoot = document.getElementById("nav");

		for (i=0; i<navRoot.childNodes.length; i++) {

			node = navRoot.childNodes[i];

			if (node.nodeName=="LI") {

				node.onmouseover=function() {

					this.className+=" over";

				}

				node.onmouseout=function() {

					this.className=this.className.replace(" over", "");

				}

			}

		}

	}

}

window.onload=startList;

var prefsLoaded = false;

var original= .80;

incremento = 0;

tamano = 0;



//Tamaño de la fuente

function aumentar () {	

	incremento+=.25;

	tamano = original + incremento;

	document.getElementById("cuerpo").style.fontSize = tamano + "em";

}

function reducir () {	

	incremento-=.25;

	tamano = original + incremento;

	document.getElementById("cuerpo").style.fontSize = tamano + "em";

}

function pintarCalendario(cantidad){

	document.getElementById("calendario").innerHTML=cambiarMes(cantidad);

}

function navFotos(foto){

	for(i=1; i<19; i++){

		document.getElementById("i"+i).style.visibility='hidden';

	}

	document.getElementById("i" + foto).style.visibility='visible';

}

function compruebaReserva(){

	var email=document.f2.email.value;

	var nombre=document.f2.nombre.value;

	var telefono=document.f2.telefono.value;

	var desde=document.f2.desde.value;

	var noches=document.f2.noches.value;

	if(nombre==""){

		alert('Por favor, introduzca su nombre');

	}else if(email==""){

		alert('Por favor, introduzca su email.');

	}else if (desde=="" || desde=="dd/mm/yyyy"){

		alert('Por favor, introduzca al fecha de entrada.');

	}else if (noches==""){

		alert('Por favor, introduzca el número de noches de su estancia.');

	}else if(email.indexOf('@',0)==-1 || email.indexOf('.',0)==-1){

		alert('Por favor, introduzca un email valido.');

	}else if(telefono!=null && isNaN(telefono)){

		alert('El telefono que ha introducido no es válido.');

	}else

		document.f2.submit();



}
function ofertar(){
	var email=document.faccion.email.value;
	var nombre=document.faccion.nombre.value;
	var telefono=document.faccion.telefono.value;
	var oferta=document.faccion.oferta.value;
	if(nombre==""){
		alert('Por favor, introduzca su nombre');
	}else if(email==""){
		alert('Por favor, introduzca su email.');
	}else if(email.indexOf('@',0)==-1 || email.indexOf('.',0)==-1){

		alert('Por favor, introduzca un email valido.');
	}else if(telefono!=null && isNaN(telefono)){
		alert('El teláfono que ha introducido no es válido.');
	}else if(oferta!=null && isNaN(oferta)){
		alert('La oferta que ha introducido no es válida.');
	}else
		document.faccion.submit();
}

function revisar(){

	var suemail=document.fAmigo.suemail.value;

	var sunombre=document.fAmigo.sunombre.value;

	var miemail=document.fAmigo.miemail.value;

	var minombre=document.fAmigo.minombre.value;	

	var comentario=document.fAmigo.comentario.value;

	if(suemail==""){

		alert('Por favor, introduzca el email del destinatario.');

	}else if(sunombre==""){

		alert('Por favor, introduzca el nombre del destinatirio.');

	}else if (minombre==""){

		alert('Por favor, introduzca su nombre.');

	}else if (miemail==""){

		alert('Por favor, introduzca su email.');

	}else if(miemail.indexOf('@',0)==-1 || miemail.indexOf('.',0)==-1){

		alert('Por favor, revise su email.');

	}else if(suemail.indexOf('@',0)==-1 || suemail.indexOf('.',0)==-1){

		alert('Por favor, revise el email del destinatario.');

	}else

		document.fAmigo.submit();



}

//Maps

function icono(){
		var icon = new GIcon();
		icon.image = "images/logo_arabella_sin25.png";
        //icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
        icon.iconSize = new GSize(25, 25);
        icon.shadowSize = new GSize(22, 20);
        icon.iconAnchor = new GPoint(6, 20);
		return icon;
}
function showMap(){
		var map = new GMap(document.getElementById("map"));
		map.addControl(new GSmallMapControl());		
		map.centerAndZoom(new GPoint(-4.237230, 37.479770), 8);
		createMarker(map, map.getCenter(), "Aqu&iacute; esta tu sitio, Casateli");		
    }
	function createMarker(map, point, texto) {
		var marker = new GMarker(point);
		if(texto!=""){
			var infoTabs = [new GInfoWindowTab("Casateli", texto)];			     
		}
		map.addOverlay(marker, new icono());
		marker.openInfoWindowTabsHtml(infoTabs);
      }
	
	function ir(latitud, longitud, km, sitio, zoom){
		var map = new GMap(document.getElementById("map"));
		zoom=parseInt(zoom);
		map.centerAndZoom(new GPoint(-4.237230, 37.479770), zoom);
		window.setTimeout(function() {
			map.panTo(new GLatLng(latitud, longitud));
		}, 300);
		var point2=new GLatLng(latitud, longitud);
		createMarker(map, point2, sitio + " a " + km + "Km.");
		createMarker(map, map.getCenter(), "");
	}


	function comollegar(origen){

		ciudades=new Array();

		ciudades[0]="cordoba";

		ciudades[1]="jaen";

		ciudades[2]="granada";

		ciudades[3]="malaga";

		ciudades[4]="sevilla";

		ciudades[5]="madrid";

		for(i=0;i<ciudades.length;i++){

			if(origen==ciudades[i])

				document.getElementById(ciudades[i]).style.display='block';

			else

				document.getElementById(ciudades[i]).style.display='none';

		}

	}
	function mostrarVirtuales(){
		document.getElementById('nav').style.display='block';
		document.getElementById('virtuales').style.display='none';
	}