var baners;
var ban;
var movent=false;
var num=0;

window.onload=function() {
	var fotofinca=$('fotofinca');
	if(fotofinca){
		//protoFlash=new ProtoFlash('fotofinca');
		
		protoFlash=new ProtoFlash('fotofinca', {
			interval:3,
			width: 427,
			height: 332,
			animSpeed: 2
		});
		
		
	}
	
	var fotofinca=$('imgini');
	if(fotofinca){
		//protoFlash=new ProtoFlash('fotofinca');
		
		protoFlash=new ProtoFlash('imgini', {
			interval:3,
			width: 596,
			height: 365,
			animSpeed: 2
		});

	}
	var SP=$('SP');
	if(SP){
		protoFlash=new ProtoFlash('SP', {
			interval:6,
			width: 359,
			height: 292,
			animSpeed: 2
		});
	}
	
	var SP=$('SPres');
	if(SP){
		protoFlash=new ProtoFlash('SPres', {
			interval:8,
			width: 359,
			height: 292,
			animSpeed: 2
		});
	}
	
	if($('map')){
		map();
	}
	
}

function map(){
	if (GBrowserIsCompatible()) { 
			map = new GMap2(document.getElementById("map")); 
			map.setCenter(new GLatLng(39.49961175295604, 3.0304187536239624), 17); 
			map.addControl(new GSmallMapControl()); 
			map.addControl(new GMapTypeControl()); 
			map.setMapType(G_HYBRID_MAP); 
			map.openInfoWindow(map.getCenter(), 
				"<div id='menmapa'><div id='iconomapa' style='float: left; margin-right: 23px;'><img src=../img/titulo.jpg style='width:200px;'></div><div id='titulomapa' style='color: #004178; font-weight: bold; font-size: 15px;'></div><div id='dirmapa' style='color:#004178; font-size:12px;'></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 mas(){
	if(movent==false){
		if(num<4){
			movent=true;
			new Effect.Move("visor", { mode: 'relative', x:-800, afterFinish: function(){
				movent=false;
			} });
			num++;
		}
	}
	
}
function menos(){
	if(movent==false){
		if(num>0){
			movent=true;
			new Effect.Move("visor", { mode: 'relative', x:800, afterFinish: function(){
				movent=false;
			} });
			num--;
		}
	}
	
}


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);
	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);
					
					if (reply.responseText=="Ok") {
						
						
						
					}
			}
		});	
}

function enviarMailForm() {
	if (($('nombre').value=="") || ($('apellidos').value=="") || ($('mail').value=="") || ($('tel').value=="")) {
		alert('tiene que rellenar todos los campos obligatorios *');
		return;
	}
	var url="../xml/mailForm.php";
	var params="nombre="+encodeURI($('nombre').value)+"&apellidos="+encodeURI($('apellidos').value)+"&mailA="+encodeURI($('mail').value)+"&tel="+encodeURI($('tel').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);
					
					if (reply.responseText=="Ok") {
						
						
						
					}
			}
		});	
}

function azul(x){
	$('item'+x).style.color="#999999";
}
function gris(x){
	$('item'+x).style.color="#0F6BB7";
}
function link(url){
	if(url=="casa"){
		window.location="casa.php?item=1";
	}else{
		if(url=="habitaciones"){
			window.location="habitaciones.php?item=1";
		}else{
			window.location=url+".php";
		}
	}
	
}
function linkcasa(x){
	window.location="casa.php?item="+x;
}
function linkres(x){
	if(x==1){
		window.location="restSaRapita.php";
	}
	if(x==2){
		window.location="restSiroco.php";
	}
	if(x==3){
		window.location="restPortoColom.php";
	}
	if(x==4){
		window.location="restsaplaca.php";
	}
	if(x==5){
		window.location="restCanManolo.php";
	}
	
}

function linkhab(x){
	if(x==1){
		window.location="habitacionessuiteprincipal.php";
	}
	if(x==2){
		window.location="habitacionesjunior.php";
	}
	if(x==3){
		window.location="habitacionessuite.php";
	}
	
}
