function objetus1() {
    	var objetus1 = false; 
		try {
    		objetus1 = new ActiveXObject("Msxml2.XMLHTTP");
  		} 
		catch (e) {
  					try {
    					objetus1= new ActiveXObject("Microsoft.XMLHTTP");
   					} 
					catch (E) {
   						objetus1= false;
   					}
   	 	}
   		if (!objetus1 && typeof XMLHttpRequest!='undefined') {
   		objetus1 = new XMLHttpRequest();
   		}
   		return objetus1
   	 }
   function appointment(codigo, cod){
   			_objetus1=objetus1();
   			_parametros="codigo="+cod;
			_URL_="proceso.php";
			
			_objetus1.open("GET",_URL_+'?'+_parametros,true);
		   	_objetus1.onreadystatechange=function() {
				if (_objetus1.readyState == 4){
					   target="appointment";
   			           document.getElementById(target).innerHTML = _objetus1.responseText;
   			}
   	}
   _objetus1.send('');
}


function cambio(codi){
	document.getElementById("s"+codi).src="images/selected.jpg";
	
}

var divs= new Array("detalles","fotos","area","mapa","videos","masinfo");

function cambiaDiv(divm){
	for(n in divs){
		if(divs[n]==divm){
			$("#div"+divs[n]).fadeIn();	
		} else {
			$("#div"+divs[n]).hide();	
		}
	}
	try{
		if(divm=="videos"){
			$f("player","flowplayer-3.1.1.swf",{clip:{url:"http://www.bonninsanso.com/"+video,autoPlay:true,autoBuffering: true}});
		} else {
			$f().stop();	
		}
	} catch(e){}
}


function cambiaFoto(foto){
	$("#afotom").attr("href","http://www.bonninsanso.com/"+foto);
	$("#fotom").attr("src","http://www.bonninsanso.com/"+foto);
}

function mail(texto){

	var mailres = true;            
	var cadena = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890@._-";
    
	var arroba = texto.indexOf("@",0);
	if ((texto.lastIndexOf("@")) != arroba) arroba = -1;
    
	var punto = texto.lastIndexOf(".");
                
	for (var contador = 0 ; contador < texto.length ; contador++){
		if (cadena.indexOf(texto.substr(contador, 1),0) == -1){
			mailres = false;
			break;
		}
	}

    if ((arroba > 1) && (arroba + 1 < punto) && (punto + 1 < (texto.length)) && (mailres == true) && (texto.indexOf("..",0) == -1)){
		mailres = true;
    }else{
		mailres = false;
	}           
	return mailres;
}

function sendform(){
	var nom=$("#fnom").val();
	var em=$("#femail").val();
	var te=$("#ftel").val();


	if(nom!=""){
		if(em!=""){
			if(mail(em)==false){
				alert("El email introducido no es correcto.");
				return false;
			}
		}
		if(em!="" && te!=""){
			return true;
		}else {
			if(em!="" || te!=""){
				return confirm("No ha introducido todos los datos de contacto, żdesea enviar de todos modos?");
			}else{
				alert("Debe introducir un e-mail o un telefono para poder contactar con usted.");
				return false;
			}
		}
	}else {
		alert("Debe introducir un nombre y apellidos.");
		return false;
	}
		
}

function borrarForm(){
	$("#fnom").value="";
	$("#ftel").value="";
	$("#femail").value="";
	$("#fcomen").text="";
}