var movent = 0;
var x = 2;
var cambi = 0;

window.onload = function() {
	$('imgactual').value = 1;
	setTimeout("spera(" + x + ")", 5000);

	// setTimeout("cambioImg("+x+")",3000);

	if($('galIni')){
		
		protoFlash=new ProtoFlash('galIni',{
			width: 935,
			height: 309
		});
		setTimeout("spera()", 5000);
		
		
		//setTimeout ( "flash()", 2000 );
	}
	
}
function enviarMail() {
	
	if (($('nombre').value=="") || ($('apellidos').value=="") || ($('mail').value=="") || ($('tel').value=="")) {
		alert('tiene que rellenar todos los campos obligatorios *');
		return;
	}
	var url="../xml/mail.php";
	var params="nombre="+encodeURI($('nombre').value)+"&apellidos="+encodeURI($('apellidos').value)+"&mailA="+encodeURI($('mail').value)+"&tel="+encodeURI($('tel').value)+"&dir="+encodeURI($('dir').value)+"&cp="+encodeURI($('cp').value)+"&ciudad="+encodeURI($('ciudad').value)+"&pais="+encodeURI($('pais').value)+"&noches="+encodeURI($('noches').value)+"&numhab="+encodeURI($('numhab').value)+"&dia="+encodeURI($('dia').value)+"&mes="+encodeURI($('mes').value)+"&ano="+encodeURI($('ano').value)+"&dias="+encodeURI($('dias').value)+"&mess="+encodeURI($('mess').value)+"&anos="+encodeURI($('anos').value)+"&com="+encodeURI($('com').value)+"&enviara="+encodeURI($('enviara').value);
	var ajax=new Ajax.Request ( url, {
		method: 'post',
		postBody: params,
		onLoading: function() {
					//buida($('msg'));
					//var t=document.createTextNode(unescape(iditextos[1]));
					//$('msg').style.visibility='visible';
					//$('msg').appendChild(t);
				},
		onComplete:function(reply) {
					if (reply.responseText=="Err") {
						var txt="Ha ocurrido un error.";
					} else {
						var txt="Mensaje enviado satisfactoriamente";
					}
					
					alert(txt);
					window.location="index.php";
					if (reply.responseText=="Ok") {
						
						
						
					}
			}
		});	
}

function spera() {
	$('galIni').style.display="block";
}
function map(){
	
	$('loadM').style.display="none";
	
	if (GBrowserIsCompatible()) { 
			map = new GMap2(document.getElementById("map")); 
			map.setCenter(new GLatLng(39.51738063329201, 2.4873679876327515), 13); 
			map.addControl(new GSmallMapControl()); 
			map.addControl(new GMapTypeControl()); 
			map.setMapType(G_NORMAL_MAP); 
			map.openInfoWindow(map.getCenter(), 
				"<div id='menmapa' style='margin: 0px; width: 300px; height: 133px;'><div id='iconomapa' style='float: left; margin-right: 23px;'><img src=../img/logo.jpg' style='width:200px; margin-left:10px;'></div><div style='float: left; margin-top: 10px; color: rgb(52, 71, 173); font-weight: bold; margin-left: 6px; width: 298px;'>Hotel Santa Ponsa Pins | Av del Rey Jaume I, 115, 7180 Calviā | Tel. 971 69 13 58 </div></div>"); 
			 
			
		/*	GEvent.addListener(map,"click", function(overlay,latlng) {      
		      if (latlng) {    
		        //var myHtml = "The GLatLng value is: " + map.fromLatLngToDivPixel(latlng) + " at zoom level " + map.getZoom(); 
		        var myHtml = "The GLatLng value is: " + latlng + " at zoom level " + map.getZoom(); 
		        map.openInfoWindow(latlng, myHtml); 
		      } 
	    });*/
	    
	}
}

function spera(img) {
	if (x > 5) {
		x = 1;
	}
	cambioImg(x, 0);
	x = x + 1;
	if (cambi == 0) {

		setTimeout("spera(" + x + ")", 6000);
	} else {
		cambi = 0;
		setTimeout("spera(" + x + ")", 6000);

	}

}
function cambio(x) {
	cambioImg(x);
}
function cambioImg(z, opc) {

	if (opc == 1) {
		x = z + 1;
	}

	if (movent == 0) {
		movent = 1;
		$('bt' + z).style.backgroundImage = "url('../img/tag.png')";
		$('bt' + z).style.color = "white";
		$('bt' + z).style.width = "29px";
		$('bt' + z).style.height = "22px";
		
		
		$('bt' + $('imgactual').value).style.paddingLeft = "1px";
		$('bt' + $('imgactual').value).style.width = "23px";
		$('bt' + $('imgactual').value).style.backgroundImage = "";
		$('bt' + $('imgactual').value).style.height = "";
		$('bt' + $('imgactual').value).style.color = "#3A4AAA";
		new Effect.Opacity('img' + $('imgactual').value, {
			duration : 0.8,
			from : 1.0,
			to : 0.0,
			
			
		
			
			
			afterFinish : function() {
				// $('c'+x).style.display='none';
			$('img' + $('imgactual').value).style.display = "none";
			new Effect.Appear('img' + z, {
				duration : 0.8
			});
			$('imgactual').value = z;
			movent = 0;
		}
		});
	}
}

function mostrarMapa () {
	new Effect.Appear($('contmap'), {duration:3, afterFinish:function (){
		map();
	}});
	
}
function cerrarMapa() {
	new Effect.Opacity('contmap', {
		duration : 0.8,
		from : 1.0,
		to : 0.0,
		afterFinish : function() {
		// $('c'+x).style.display='none';
		$('contmap').style.display="none";
}
});
}

