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_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_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 validaEnviadatos(){
	
	if (document.formcontacto.name.value==""){
		alert("y tu Nombre? \nand your Name?");
		document.formcontacto.name.focus();
		return false;
	}
	
	email=document.formcontacto.email.value;
	if(email==""){
		alert("Debes escribir tu email para recibir tus datos.");
		document.formcontacto.email.focus();
		return false;
	}
	else{
		var atSign = Number(String([email]).indexOf("@"));
		var closeDot = Number(String([email]).indexOf(".", atSign));
		if (String([email]).indexOf("@") == -1 || String([email]).indexOf(".") == -1) {
			document.formcontacto.email.focus();
			alert("Email invalido.");
			return false;
		}else if (closeDot-atSign<=1){
			alert("Email invalido.");
			document.formcontacto.email.focus();
			return false;
		}
	}
	
	if (document.formcontacto.phone.value==""){
		alert("y tu Telefono? \nand your Phone?");
		document.formcontacto.phone.focus();
		return false;
	}
	
}

function validaReserva(){
	
	if (document.fromreserva.name.value==""){
		alert("y tu Nombre? \nand your Name?");
		document.fromreserva.name.focus();
		return false;
	}
	
	email=document.fromreserva.email.value;
	if(email==""){
		alert("Debes escribir tu email para recibir tus datos.");
		document.fromreserva.email.focus();
		return false;
	}
	else{
		var atSign = Number(String([email]).indexOf("@"));
		var closeDot = Number(String([email]).indexOf(".", atSign));
		if (String([email]).indexOf("@") == -1 || String([email]).indexOf(".") == -1) {
			document.fromreserva.email.focus();
			alert("Email invalido.");
			return false;
		}else if (closeDot-atSign<=1){
			alert("Email invalido.");
			document.fromreserva.email.focus();
			return false;
		}
	}
	
	if (document.fromreserva.phone.value==""){
		alert("y tu Telefono? \nand your Phone?");
		document.fromreserva.phone.focus();
		return false;
	}
	
	if (document.fromreserva.fllegada.value==""){
		alert("Fecha de llegada? \nArrival date?");
		document.fromreserva.fllegada.focus();
		return false;
	}
	
	if (document.fromreserva.fsalida.value==""){
		alert("Fecha de salida? \nDeparture date?");
		document.fromreserva.fsalida.focus();
		return false;
	}
	if (document.fromreserva.personas.value==""){
		alert("Cuantas personas? \nHow many people?");
		document.fromreserva.personas.focus();
		return false;
	}
	if (document.fromreserva.habitaciones.value==""){
		alert("Cuantas Habitaciones? \nHow many Rooms?");
		document.fromreserva.habitaciones.focus();
		return false;
	}
	
}

function validaDisponib(){
	
	if (document.formdisponib.name.value==""){
		alert("y tu Nombre? \nand your Name?");
		document.formdisponib.name.focus();
		return false;
	}
	
	email=document.formdisponib.email.value;
	if(email==""){
		alert("Debes escribir tu email para recibir tus datos.");
		document.formdisponib.email.focus();
		return false;
	}
	else{
		var atSign = Number(String([email]).indexOf("@"));
		var closeDot = Number(String([email]).indexOf(".", atSign));
		if (String([email]).indexOf("@") == -1 || String([email]).indexOf(".") == -1) {
			document.formdisponib.email.focus();
			alert("Email invalido.");
			return false;
		}else if (closeDot-atSign<=1){
			alert("Email invalido.");
			document.formdisponib.email.focus();
			return false;
		}
	}
	
	
	if (document.formdisponib.fllegada.value==""){
		alert("Fecha de llegada? \nArrival date?");
		document.formdisponib.fllegada.focus();
		return false;
	}
	
	if (document.formdisponib.fsalida.value==""){
		alert("Fecha de salida? \nDeparture date?");
		document.formdisponib.fsalida.focus();
		return false;
	}
	
}


function popUp(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
if(myWidth=="" || myHeight==""){
		myWidth=680;
		myHeight=509;
	}
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}



if ((screen.width == 640) && (screen.height == 480)) 
alert ("ATENCIÓN!!\r\rLa resolución de pantalla que Ud. utiliza actualmente no le permitirá ver bien este sitio.\r\rPor favor, cambie la resolución a 800x600 o más.\r\r\rGracias.")

var homes= new Array ()

homes[0] = 'http://www.studenthousingchile.com/images/galeria/grandes/4.jpg'
homes[1] = 'http://www.studenthousingchile.com/images/galeria/grandes/5.jpg'
homes[2] = 'http://www.studenthousingchile.com/images/galeria/grandes/6.jpg'
homes[3] = 'http://www.studenthousingchile.com/images/galeria/grandes/7.jpg'
homes[4] = 'http://www.studenthousingchile.com/images/galeria/grandes/8.jpg'
homes[5] = 'http://www.studenthousingchile.com/images/galeria/grandes/12.jpg'
homes[6] = 'http://www.studenthousingchile.com/images/galeria/grandes/15.jpg'

var j = 0
var p = homes.length;
var preBuffer = new Array ()
for  (i = 0; i < p; i++){
   preBuffer[i] = new Image ()
   preBuffer[i].src = homes[i]
}
var whichImage = Math.round (Math.random ()* (p-1));
function showImage (){
document.write ('<img src="'+homes[whichImage]+'">');
}
