// JavaScript Document
function isEmailAddr(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

function checkformcontact(MyFORM)
{
	if (form.nombre.value=="")
  {
  	alert( "Por favor ingrese su nombre y apellido." );
	 	form.nombre.focus();
   	return false;
  }
  
  if (form.telefono.value=="")
	{
  	alert( "Por favor ingrese un número de teléfono." );
	 	form.telefono.focus();
   	return false;
  }
  
  if (form.email.value != "") 
  {
  	if (!isEmailAddr(form.email.value))
  	{		
			alert("Por favor ingrese un E-mail valido." );
			form.email.focus();
			return false;
		}
  }
  else
  {
  	alert("Por favor ingrese una dirección de E-mail." );
		form.email.focus();
		return false;	
  }
	return true;  
}


	
function AgregarServicio(value, id, status)
{
	if(status == true)
	{
		document.getElementById(id).value  = value;
	}
}

function MostrarSuperficies(idCategoria)
{
	if( idCategoria == 11 )
	{
		//Seteamos el rango de superficie para Campos (Ha) 
		document.getElementById('superficieCampos').style.display  = 'block';
		document.getElementById('selectCampos').disabled = false;
		
		document.getElementById('superficieGral').style.display  = 'none';
		document.getElementById('selectSupGral').disabled = true;
	}
	else
	{
		//Seteamos el rango de superficie para Otras Categorias (M2) 
		document.getElementById('superficieGral').style.display  = 'block';
		document.getElementById('selectSupGral').disabled = false;
		
		document.getElementById('superficieCampos').style.display  = 'none';
		document.getElementById('selectCampos').disabled = true;
	}	
}	

function MostrarDivCalendario(idOperacion)
{
	if( idOperacion == 2 )
	{
		//Mostramos el calendario
		document.getElementById('divCalendario').style.display  = 'block';	
		document.getElementById('divCalendario2').style.display = 'block';
	}
	else
	{
		//No mostramos el calendario
		document.getElementById('divCalendario').style.display  = 'none';
		document.getElementById('divCalendario2').style.display = 'none';	
		MostrarFechaIn('');
		MostrarFechaOut('');
	}
	
	if( idOperacion == 1 || idOperacion == 2)
	{
		//Seteamos el rango de precios para Alquiler y Alquiler Temporario 
		document.getElementById('precioAlquileres').style.display  = 'block';
		document.getElementById('selectAlquileres').disabled = false;
		
		document.getElementById('precioGral').style.display  = 'none';
		document.getElementById('selectGral').disabled = true;
		
		document.getElementById('precioVenta').style.display  = 'none';
		document.getElementById('selectVenta').disabled = true;
		
	}
	else if( idOperacion == 3 || idOperacion == 4 )
	{
		document.getElementById('precioVenta').style.display  = 'block';
		document.getElementById('selectVenta').disabled = false;
		
		document.getElementById('precioGral').style.display  = 'none';
		document.getElementById('selectGral').disabled = true;
	
		document.getElementById('precioAlquileres').style.display  = 'none';
		document.getElementById('selectAlquileres').disabled = true;		
	}
	else
	{
		document.getElementById('precioVenta').style.display  = 'none';
		document.getElementById('selectVenta').disabled = true;
	
		document.getElementById('precioAlquileres').style.display  = 'none';
		document.getElementById('selectAlquileres').disabled = true;
		
		document.getElementById('precioGral').style.display  = 'block';
		document.getElementById('selectGral').disabled = false;
	}				
}

function playSound() {
  document.all.sound.src = "audio/botones_over.WAV";
}

function Calendario(InOut)
{
	urlFechaCalendario = 'calendario'+InOut+'.php';
	popup(urlFechaCalendario, 'Calendario', 235, 260);
}

function MostrarFechaIn(fecha)
{
	document.getElementById('fechaIngreso').value = fecha;
	if( fecha != '')
	{
		document.getElementById('fechaIngreso').style.display = 'block';
	}
	else
	{
		document.getElementById('fechaIngreso').style.display = 'none';
	}		
}

function MostrarFechaOut(fecha)
{
	document.getElementById('fechaEgreso').value = fecha;
	if( fecha != '')
	{
		document.getElementById('fechaEgreso').style.display = 'block';
	}
	else
	{
		document.getElementById('fechaEgreso').style.display = 'none';
	}		
}
	
	
function TouryFoto(obj)
{
	if( obj.name == 'contour' )
	{
		if( obj.checked == true )
		{
			document.getElementById('PropCTour').value 							= 1;
		}
		else
		{
			document.getElementById('PropCTour').value 							= 0;
		}			
	}
	if( obj.name == 'confoto' )
	{
		if( obj.checked == true )
		{
			document.getElementById('PropCFoto').value 							= 1;
		}
		else
		{
			document.getElementById('PropCFoto').value 							= 0;
		}
	}	
}

function BuscarPropiedad(accion)
{
	document.getElementById('accion').value = accion;
	document.frmProp.submit();
}

function VerPropiedad(idDpto)
{
	URL = 'editproperty.php?idDpto='+idDpto;
	popup(URL, 'EdicionPropiedad', 573, 780);
}

function popup(URL, name, Height, width)
{
	vars = 'height='+Height+',width='+width;
	newwindow=window.open(URL, name, vars);
	if (window.focus) {newwindow.focus()}
	return false;
}

function BuscarAvanzada()
{
	if( document.getElementById('divOpcAvanzadas').style.display == "none" )
	{
		document.getElementById('divOpcAvanzadas').style.display				= "block";
	}
	else
	{
		document.getElementById('divOpcAvanzadas').style.display				= "none";
	}			
}

function CargarImagen(path)
{ 
	document.getElementById('imagen_ppal').src  = path;
}
