function openWindow(x,y){
	ancho=screen.width;
	alto=screen.height;
	my=(ancho/2)-x;
	mx=(alto/2)-y;
	ventana=window.open('','AUX','WIDTH='+x+', HEIGHT='+y+',TOP='+mx+',LEFT='+my+', SCROLLING=NO, STATUSBAR=1, MENUBARS=yes');
}
function veralbum(site,x,y){
	ancho=screen.width;
	alto=screen.height;
	my=(ancho/2)-350;
	mx=(alto/2)-300;
	
	ventanaalbum=window.open(site+'apartments/photoalbum.php?id='+x+'&ini='+y,'AUX','WIDTH=700, HEIGHT=650,TOP='+mx+',LEFT='+my+', scrollbars=NO, STATUSBAR=1, MENUBARS=yes');
}
function verbuscador(x){
	ancho=screen.width;
	alto=screen.height;
	my=(ancho/2)-200;
	mx=(alto/2)-200;
	
	ventanabus=window.open('http://www.bytargentina.com/plugin/apartments/busqueda.php?'+x,'AUX','WIDTH=470, HEIGHT=450,TOP='+mx+',LEFT='+my+', scrollbars=yes, STATUSBAR=1, MENUBARS=yes');
}

function openPageCalendardia_ing(mx,my){
	ventanacal=window.open('http://www.bytargentina.com/plugin/inc/calendario.php?FUNCION=&FORM=dispo&CAMPODIA=d_dde&CAMPOMES=m_dde&CAMPOANIO=a_dde&MODO=0','AUX','WIDTH=170, HEIGHT=150,TOP='+mx+',LEFT='+my+', scrollbars=NO, MENUBARS=NO');
}
function openPageCalendardia_sal(mx,my){
	ventanacal=window.open('http://www.bytargentina.com/plugin/inc/calendario.php?FUNCION=&FORM=dispo&CAMPODIA=d_hta&CAMPOMES=m_hta&CAMPOANIO=a_hta&MODO=0','AUX','WIDTH=170, HEIGHT=150,TOP='+mx+',LEFT='+my+', scrollbars=NO, MENUBARS=NO');
}

function openPageCalendarReserv_ing(siteaux,mx,my,conWWW)
{
	if (conWWW == 1)
	{
		site = siteaux;
	}
	else
	{
		site = siteaux.replace('www.',"");
	}
	
	ventanacal=window.open(site+'inc/calendario_reservas.php?FUNCION=&FORM=formreservas&CAMPODIA=d_dde&CAMPOMES=m_dde&CAMPOANIO=a_dde&MODO=0','AUX','WIDTH=170, HEIGHT=150,TOP='+mx+',LEFT='+my+', SCROLLING=NO, MENUBARS=NO');
}
function openPageCalendarReserv_sal(siteaux,mx,my,conWWW)
{
	if (conWWW == 1)
	{
		site = siteaux;
	}
	else
	{
		site = siteaux.replace('www.',"");
	}
	
	ventanacal=window.open(site+'inc/calendario_reservas.php?FUNCION=&FORM=formreservas&CAMPODIA=d_hta&CAMPOMES=m_hta&CAMPOANIO=a_hta&MODO=1','AUX','WIDTH=170, HEIGHT=150,TOP='+mx+',LEFT='+my+', scrollbars=NO, MENUBARS=NO');
}

function checkBrowser(){
		this.ver=navigator.appVersion
		this.dom=document.getElementById?1:0
		this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
		this.ie4=(document.all && !this.dom)?1:0;
		this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
		this.ns4=(document.layers && !this.dom)?1:0;
		this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
		window.resizeTo(150,190);
		return this
}

barrios_s=new Array()
function foco(){
		for (i=0; i<document.dispo.neighborhood_id.options.length; ++i){
			barrios_s[i]=document.dispo.neighborhood_id.options[i].selected
		}
}
function cambio(x){
	//document.getElementById('neighborhood_id').style.visibility='hidden';
	if(barrios_s[x] == true){
		document.dispo.neighborhood_id.options[x].selected = false
		barrios_s[x]=false
	}
	else{
		document.dispo.neighborhood_id.options[x].selected = true
		barrios_s[x]=true
	}

	for (i=0; i<document.dispo.neighborhood_id.options.length; ++i){
		if(barrios_s[i]==true){
			document.dispo.neighborhood_id.options[i].selected = true
		}
		else{
			document.dispo.neighborhood_id.options[i].selected = false
		}
	}
	document.dispo.neighborhood_id.options[x].selected = barrios_s[x]
	//document.getElementById('neighborhood_id').style.visibility='visible';

}
function todo(){
	cant=0;
	for (i=0; i<document.dispo.neighborhood_id.options.length; ++i){
		if(barrios_s[i]==true) cant++;
	}
	if(cant<i){ valor=true; } else { valor=false }
	for (i=0; i<document.dispo.neighborhood_id.options.length; ++i){
			document.dispo.neighborhood_id.options[i].selected = valor;
			barrios_s[i]= valor;
	}
	document.dispo.neighborhood_id.options[0].selected = valor;
}

function pestania(x){
	if(x==1) {
		document.getElementById('pestana1').className='pestanasel';
		document.getElementById('pestana2').className='pestananosel';
		document.getElementById('barrios').style.visibility='visible';
		document.getElementById('confort').style.visibility='hidden';
	}
	else {
		document.getElementById('pestana1').className='pestananosel';
		document.getElementById('pestana2').className='pestanasel';
		document.getElementById('barrios').style.visibility='hidden';
		document.getElementById('confort').style.visibility='visible';
	}
}
function checkform(formulario, lng){

   var d = new Date();
   var err=0
   var yearIn = formulario.a_dde.value
   var monthIn = formulario.m_dde.value
   var dayIn = formulario.d_dde.value
   var leap=0
   
   if ((yearIn % 4 == 0) || (yearIn % 100 == 0) || (yearIn % 400 == 0)) {
      leap = 1;
   }
   if ((monthIn == 2) && (leap == 1) && (dayIn > 29)) {
      err = 23;
   }
   if ((monthIn == 2) && (leap != 1) && (dayIn > 28)) {
      err = 24;
   }
   if ((dayIn > 31) && ((monthIn == "01") || (monthIn == "03") || (monthIn == "05") || (monthIn == "07") || (monthIn == "08") || (monthIn == "10") || (monthIn == "12"))) {
      err = 25;
   }
   if ((dayIn > 30) && ((monthIn == "04") || (monthIn == "06") || (monthIn == "09") || (monthIn == "11"))) {
      err = 26;
   }
   
   if (yearIn > d.getFullYear())
   {
		
   }
   else if (yearIn < d.getFullYear())
   {
	   err = 27;
   }	// aņos iguales
   else if (monthIn < d.getMonth()+1) 
   {
	   err = 28;
   }
   else if (monthIn > d.getMonth()+1) 
   {
	  	
   }	// son meses iguales
   else if (dayIn < d.getDate())
   {
	   err = 29;
   }

	//alert(dayIn+"-"+monthIn+"-"+yearIn); return false;

   if(err>0) {
	formulario.d_dde.style.backgroundColor = "#ff0000";
	formulario.d_dde.style.color = "#ffffff";
	formulario.m_dde.style.backgroundColor = "#ff0000";
	formulario.m_dde.style.color = "#ffffff";
   	if (lng == 'es')
		alert('Verifique la fecha de Check In');
	else
		alert('Verify your Check In date');
	formulario.d_dde.style.backgroundColor = "#ffffff";
	formulario.d_dde.style.color = "#000000";
	formulario.m_dde.style.backgroundColor = "#ffffff";
	formulario.m_dde.style.color = "#000000";
	return false;
   
   }

   err=0
   var yearOut = formulario.a_hta.value
   var monthOut = formulario.m_hta.value
   var dayOut = formulario.d_hta.value
   
   leap=0
   if ((yearOut % 4 == 0) || (yearOut % 100 == 0) || (yearOut % 400 == 0)) {
      leap = 1;
   }
   if ((monthOut == 2) && (leap == 1) && (dayOut > 29)) {
      err = 23;
   }
   if ((monthOut == 2) && (leap != 1) && (dayOut > 28)) {
      err = 24;
   }
   if ((dayOut > 31) && ((monthOut == "01") || (monthOut == "03") || (monthOut == "05") || (monthOut == "07") || (monthOut == "08") || (monthOut == "10") || (monthOut == "12"))) {
      err = 25;
   }
   if ((dayOut > 30) && ((monthOut == "04") || (monthOut == "06") || (monthOut == "09") || (monthOut == "11"))) {
      err = 26;
   }
   
   if (yearOut > d.getFullYear())
   {
	   //err = 27;
   }
   else if (yearOut < d.getFullYear())
   {
	   err = 27;
   }	// aņos iguales
   else if (monthOut < d.getMonth()+1) 
   {
	   err = 28;
   }
   else if (monthOut > d.getMonth()+1) 
   {
	  	
   }	// son meses iguales
   else if (dayOut < d.getDate())
   {
	   err = 29;
   }
  /*
  if ( (monthOut < d.getMonth()+1) && (yearOut <= d.getFullYear()) ) 
   {
	   err = 27;
   }
   if ( (dayOut < d.getDate()) && (monthOut <= d.getMonth()+1) )
   {
	   err = 27;
   }
   */
   if(err>0){
		formulario.d_hta.style.backgroundColor = "#ff0000";
		formulario.d_hta.style.color = "#ffffff";
		formulario.m_hta.style.backgroundColor = "#ff0000";
		formulario.m_hta.style.color = "#ffffff";
   		if (lng == 'es')
			alert('Verifique la fecha de Check Out');
		else
			alert('Verify your Check Out date');
		formulario.d_hta.style.backgroundColor = "#ffffff";
		formulario.d_hta.style.color = "#000000";
		formulario.m_hta.style.backgroundColor = "#ffffff";
		formulario.m_hta.style.color = "#000000";
		return false; 
	}
	
	
	// Chequea fechas entre si
   if (yearIn > yearOut)
   {
		alert('ERROR: CHECK OUT < CHECK IN');
		return false;
   }
   else if (yearIn < yearOut) {/*else son aņos iguales*/err = 0;}
   else if (monthIn > monthOut)
   {
		alert('ERROR: CHECK OUT < CHECK IN');
		return false;
   }
   else if (monthIn < monthOut) {/*else son meses iguales*/err = 0;}
   else if (dayIn > dayOut)
   {
		alert('ERROR: CHECK OUT < CHECK IN');
		return false;
   }
   else if (dayIn < dayOut) {/*else son FECHAS iguales*/err = 0;}
   else
   {	//   son iguales
	    alert('ERROR: CHECK OUT < CHECK IN');
		return false;
   }


/*
	cant=0;
	for (i=0; i<formulario.neighborhood_id.options.length; ++i){
		if(formulario.neighborhood_id.options[i].selected==true) cant++;
	}
	if(cant==i){
		for (i=0; i<formulario.neighborhood_id.options.length; ++i){
				formulario.neighborhood_id.options[i].selected = false;
		}
	}*/
}