function externalLink(obj){	
	obj.target = "_blank";	 
}

function moveNavigation(moveTo){
   pageNro = document.getElementById("actual");
   switch(moveTo){
      case "next":
        pageNro.value = pageNro.value*1+1;
      break;
      case "back":
        pageNro.value = pageNro.value*1-1;
      break;
     }
   document.getElementById("listado").submit();     
  }



function doSearch(){
	
  form = document.listado;
	
  if(document.getElementById('pags')){
     document.getElementById('pags').value = "";
    }
  if(document.getElementById('actual')){
     document.getElementById('actual').value = "";
    }
   document.getElementById('listado').submit();
}


function exportarConsultas(){
	
  form = document.listado;
	
  url = 'exportar_consultas.php?';
  url += 'origen='+form.origen.value+'&cod='+form.cod.value+'&orden='+form.orden.value;
  window.location = url;
}

function versionImprimible(){
		
	form = document.listado;
	
	form.target = '_blank';
	form.action = 'impresion.php';
	form.submit();
	
	form.target = '';
	form.action = '';
}

function mostrar_pdf(){
	$('.cb_pdf').each(function(i,e){
		e.checked = false;
	})
	window.location = 'generar_pdf.php?type=pdf';
}
function click_pdf(id){		
	$.get('select_pdf.php?id='+id+'&checked='+$('#pdf_'+id)[0].checked,{},function(){
		
	});	
}

function cambiarOrdenListado(url){
	
	window.location = url+'orden='+$('#orden').val();
	
}

function MM_openBrWindow(ref, name, options){
   window.open(ref, 'zoom', options);
  }
  
function setPriceRange(tipo){
   elementPrice = document.getElementById("b26dd018cac0dd997ba96451c63445bc");

   if(((tipo==2 || tipo==3) && elementPrice.childNodes.item(1).value=="X <= 1000") || ((tipo=="" || tipo==1) && elementPrice.childNodes.item(1).value=="X <= 100000")){
      return true;
     }
   
   while(elementPrice.hasChildNodes()){
      elementPrice.removeChild(elementPrice.childNodes.item(elementPrice.childNodes.length-1))
     }

   if(tipo==1 || tipo==""){
     newOption = document.createElement("option");
     newOption.value = "";
     newOption.innerHTML = "Indistinto";
     elementPrice.appendChild(newOption);

     newOption = document.createElement("option");
     newOption.value = "X <= 100000";
     newOption.innerHTML = "Hasta U$D 100.000";
     elementPrice.appendChild(newOption);

     newOption = document.createElement("option");
     newOption.value = "X > 100000 AND X <= 200000";
     newOption.innerHTML = "De U$D 100.000 a 200.000";
     elementPrice.appendChild(newOption);
     
     newOption = document.createElement("option");
     newOption.value = "X > 200000 AND X <= 300000";
     newOption.innerHTML = "De U$D 200.000 a 300.000";
     elementPrice.appendChild(newOption);

     newOption = document.createElement("option");
     newOption.value = "X > 300000 AND X <= 400000";
     newOption.innerHTML = "De U$D 300.000 a 400.000";
     elementPrice.appendChild(newOption);

     newOption = document.createElement("option");
     newOption.value = "X > 400000 AND X <= 500000";
     newOption.innerHTML = "De U$D 400.000 a 500.000";
     elementPrice.appendChild(newOption);

     newOption = document.createElement("option");
     newOption.value = "X > 500000";
     newOption.innerHTML = "Mayor a U$D 500.000";
     elementPrice.appendChild(newOption);
     }
   if(tipo==2 || tipo==3){
     newOption = document.createElement("option");
     newOption.value = "";
     newOption.innerHTML = "Indistinto";
     elementPrice.appendChild(newOption);
        
     newOption = document.createElement("option");
     newOption.value = "X <= 1000";
     newOption.innerHTML = "Hasta U$D 1000";
     elementPrice.appendChild(newOption);

     newOption = document.createElement("option");
     newOption.value = "X > 1000 AND X <= 2000";
     newOption.innerHTML = "De U$D 1.000 a 2.000";
     elementPrice.appendChild(newOption);
     
     newOption = document.createElement("option");
     newOption.value = "X > 2000 AND X <= 3000";
     newOption.innerHTML = "De U$D 2.000 a 3.000";
     elementPrice.appendChild(newOption);

     newOption = document.createElement("option");
     newOption.value = "X > 3000 AND X <= 4000";
     newOption.innerHTML = "De U$D 3.000 a 4.000";
     elementPrice.appendChild(newOption);

     newOption = document.createElement("option");
     newOption.value = "X > 4000 AND X <= 5000";
     newOption.innerHTML = "De U$D 4.000 a 5.000";
     elementPrice.appendChild(newOption);

     newOption = document.createElement("option");
     newOption.value = "X > 5000";
     newOption.innerHTML = "Mayor a U$D 5.000";
     elementPrice.appendChild(newOption);
     }
  }
function setBarrioCerrado(elementZona){
   if(elementZona.text=="Barrio cerrado"){
      document.getElementById("divBarrio").style.display="block";
     }else{
           document.getElementById("divBarrio").style.display="none";
           document.getElementById("selBarrio").selectedIndex=0;
          }
  }


function enviarMail(){

  var msn = "";

  var deboEnviar = false;

  if(document.contactar.nombre.value==""){

     msn = "Nombre\n";

    }

  if(document.contactar.apellido.value==""){

     msn = msn + "Apellido\n";

    }

  if(document.contactar.email.value==""){

     msn = msn + "E-mail\n";

    }

  
  $.ajax({
	  type: 'POST',
	  url: '/SecureImage/Validar',
	  dataType: 'json',
	  data: {captcha_code: $('#captcha_code').val()},
	  success: function(data){
		  if(data.resultado != true){
			  msn = msn + "El codigo de confirmacion es incorrecto.";		  
		  }else{
			  $('#auth').val(data.auth);
		  }
		  
		  if(msn==""){
		     document.contactar.submit();
		  }else{

		     alert("LOS SIGUIENTES DATOS SON OBLIGATORIOS:\n"+msn)
		     document.getElementById('securecaptchaimg').src = '/SecureImage/SecureImageShow/sid/' + Math.random().toString();
		     $('#captcha_code').val('');
		  }
		  
	  } 
  });
  
  

}


function enviarResultados(){

	  var msn = "";

	  var deboEnviar = false;

	  if(document.contactar.nombre.value==""){

	     msn = "Nombre\n";

	    }

	  if(document.contactar.apellido.value==""){

	     msn = msn + "Apellido\n";

	    }

	  if(document.contactar.email.value==""){

	     msn = msn + "E-mail\n";

	    }

	  if(msn==""){

		 /*$(':input[name=operacion]').val($('#244a1dc9a994fbd14b28b28e1ee18e46')[0].options[$('#244a1dc9a994fbd14b28b28e1ee18e46')[0].selectedIndex].text);
		 $(':input[name=edificacion]').val($('#fac0ddaf0de1be74b20504915f18b200')[0].options[$('#fac0ddaf0de1be74b20504915f18b200')[0].selectedIndex].text);
		 $(':input[name=zona]').val($('#b4ffde0bdbba1d640d5449c4690297d7')[0].options[$('#b4ffde0bdbba1d640d5449c4690297d7')[0].selectedIndex].text);
		 if($('#f3ac356b2fcec4f636da58ca78e8b72b')[0].options.length>0){
			 $(':input[name=barrio]').val($('#f3ac356b2fcec4f636da58ca78e8b72b')[0].options[$('#f3ac356b2fcec4f636da58ca78e8b72b')[0].selectedIndex].text);
		 }
		 $(':input[name=precio]').val($('#b26dd018cac0dd997ba96451c63445bc')[0].options[$('#b26dd018cac0dd997ba96451c63445bc')[0].selectedIndex].text);
		*/
		  $(':input[name=operacion]').val($('#244a1dc9a994fbd14b28b28e1ee18e46').val());
		  $(':input[name=edificacion]').val($('#fac0ddaf0de1be74b20504915f18b200').val());
		  $(':input[name=zona]').val($('#cboZona').val());
		  if($('#cboBarrios')[0].options.length>0){
			 $(':input[name=barrio]').val($('#cboBarrios').val());
		  }
		  $(':input[name=precio]').val($('#b26dd018cac0dd997ba96451c63445bc')[0].options[$('#b26dd018cac0dd997ba96451c63445bc')[0].selectedIndex].text);
			
	     document.contactar.submit();

	    }else{

	          alert("LOS SIGUIENTES DATOS SON OBLIGATORIOS:\n"+msn)

	         }

	}


function enviarAmigo(){

	  var msn = "";

	  var deboEnviar = false;

	  if(document.contactar.destino.value==""){

	     msn = "E-mail destinatario\n";

	    }

	  if(document.contactar.nombre.value==""){

	     msn = msn + "Nombre remitente\n";

	    }

	  if(document.contactar.email.value==""){

	     msn = msn + "E-mail remitente\n";

	    }

	  if(msn==""){

	     document.contactar.submit();

	    }else{

	          alert("LOS SIGUIENTES DATOS SON OBLIGATORIOS:\n"+msn)

	         }

	}
