/* Requires StringUtils.js */

function isEmptyString(strString)	{
	return Trim(strString) == "";
}

function isInt(strString)	{
	var strValidChars = "0123456789";
	var strChar;
	var blnResult = true;
	
	//test strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++)
	{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
		{
			blnResult = false;
		}
	}
	return blnResult;
}

function isDecimal(strString){
	var strValidChars = "0123456789.,";
	var strChar;
	var blnResult = true;
  
	for (i = 0; i < strString.length && blnResult == true; i++){
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1) {
			blnResult = false;
		}
	}
	return blnResult;
}

function isRef(strString)	{
	var strValidChars = "0123456789/";
	var strChar;
	var blnResult = true;
	
	//test strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++)
	{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
		{
			blnResult = false;
		}
	}
	return blnResult;
}

function virtualKeyPressed(field, event, extraCods) {
	//extraCods: lista de caracteres q são aceites
	var intCharCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	
	strCods = new String("48,49,50,51,52,53,54,55,56,57");
	
	if(extraCods != "" && extraCods != undefined){
		arrCods = extraCods.split(",");		
		for(i=0; i!=arrCods.length; i++){
			strCods += "," + (arrCods[i].charCodeAt(0));
		}
	}	
	
	if(strCods.indexOf(intCharCode) == -1){
		event.returnValue = false;
	}
}

function isData(ano, mes, dia, txt){
	if(ano.value.length != 0 || mes.value.length != 0 || dia.value.length != 0){
		if(ano.value.length < 4 || !(isInt(ano.value))) {
			alert("O ano de " + txt + " tem de ser preenchido com valores numéricos. \nPreencha, por favor o ano de " + txt + "  correctamente.");
			ano.focus();
			return false;
		}	

		var data_actual = new Date();
	    var ano_actual = 1900 + data_actual.getYear();

		if(ano.value < 1900 || ano.value > ano_actual){
			alert("Por favor, preencha o ano de " + txt + " correctamente.");
			ano.focus();
			return false;
		}

		if(mes.value == 0 || mes.value.length == 0 || !(isInt(mes.value))) {
			alert("O mês de " + txt + " tem de ser preenchido com valores numéricos. \nPreencha, por favor a o mes de " + txt + " correctamente.");
			mes.focus();
			return false;
		}
		
		if(mes.value > 12){
			alert("Por favor, preencha o mês de " + txt + " correctamente.");
			mes.focus();
			return false;
		}
		
		if(dia.value == 0 || dia.value.length == 0 || !(isInt(dia.value))) {
			alert("O dia de " + txt + " tem de ser preenchido com valores numéricos. \nPreencha, por favor a o dia de " + txt + " correctamente.");
			dia.focus();
			return false;
		}
		
		if(mes.value == "01" || mes.value == "1" || mes.value == "03" || mes.value == "3" || mes.value == "05" || mes.value == "5" || mes.value == "07" || mes.value == "7" || mes.value == "08" || mes.value == "8" || mes.value == "10" || mes.value == "12"){
			if(dia.value > 31){
				alert("Por favor, preencha o dia de " + txt + " correctamente.");
				dia.focus();
				return false;
			}
		} 
		
		if(mes.value == "02" || mes.value == "2" ){
			if(dia.value > 29){
				alert("Por favor, preencha o dia de " + txt + " correctamente.");
				dia.focus();
				return false;
			}	
		} 	

		if(mes.value == "04" || mes.value == "4" || mes.value == "06" || mes.value == "6" || mes.value == "09" || mes.value == "9" || mes.value == "11"){
			if(dia.value > 30){
				alert("Por favor, preencha o dia de " + txt + " correctamente.");
				dia.focus();
				return false;
			}
		} 
	}
	return true;
}

function isEndereco(cod4, cod3, loc){

	if((cod4.value.length != 0) && ((cod4.value.length < 4) || !(isInt(cod4.value)))) {
		alert("O campo Código postal tem de ser preenchido com valores numéricos. \nPreencha, por favor a o código postal correctamente.");
		cod4.focus();
		return false;
	}
 	
	if(((cod3.value.length != 0) && (cod3.value.length < 3))  || !(isInt(cod3.value))) {
		alert("O campo Código postal tem de ser preenchido com valores numéricos. \nPreencha, por favor a o código postal correctamente.");
		cod3.focus();
		return false;
	}

	if(cod4.value.length != 0 && loc.value.length == 0){
		alert("Por favor, preencha a Localidade.");
		loc.focus();
		return false;
	}
	
	if(cod4.value.length == 0 && loc.value.length != 0){
		alert("Por favor, preencha o Código Postal.");
		cod4.focus();
		return false;
	}
	
	return true;
}

function isPhoneNumber(strString){
	var strValidChars = "0123456789/ ";
	var strChar;
	var blnResult = true;
	
	//test strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++)
	{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
		{
			blnResult = false;
		}
	}
	return blnResult;
}

function checkSearchParams(){
	boolErro = false;
	
	boolPesq = false;
	try{
		boolPesq = document.getElementById('pesq').value == "true";
	}catch(e){}

	try{
		document.getElementById('referencia').value="";
	}catch(e){}		
	
	document.getElementById('distrito_concelho_error').style.height = "0px";
	document.getElementById('distrito_concelho_error').style.lineHeight = "0px";
	document.getElementById('distrito_concelho_error').style.fontSize = "0px";
	document.getElementById('distrito_concelho_error').innerHTML = "";        
	document.getElementById('distrito_concelho_id').className = "pesquisa";

	/*document.getElementById('tipo_error').style.height = "0px";
	document.getElementById('tipo_error').style.lineHeight = "0px";
	document.getElementById('tipo_error').style.fontSize = "0px";
	document.getElementById('tipo_error').innerHTML = "";        
	document.getElementById('tipo_id').className = "pesquisa";*/

	/*document.getElementById('operacao_error').style.height = "0px";        
	document.getElementById('operacao_error').style.lineHeight = "0px";
	document.getElementById('operacao_error').style.fontSize = "0px";
	document.getElementById('operacao_error').innerHTML = "";        
	document.getElementById('operacao').className = "pesquisa";*/

	//Quando é feito uma pesquisa as oportunidades ou caixa arrendamento os campos distrito_concelho_id e o tipo_id não são obrigatórios
//	if(document.getElementById('operacao').options[document.getElementById('operacao').selectedIndex].value != 4 && document.getElementById('operacao').options[document.getElementById('operacao').selectedIndex].value != 5) {
	/*	if(document.getElementById('distrito_concelho_id').selectedIndex == 0) {
			if(boolPesq){
				document.getElementById('distrito_concelho_error').style.paddingTop = "2px";
				document.getElementById('distrito_concelho_error').style.height = "15px";
				document.getElementById('distrito_concelho_error').style.lineHeight = "11px";
				document.getElementById('distrito_concelho_error').style.fontSize = "10px";
				document.getElementById('distrito_concelho_error').innerHTML = "* Por favor, escolha um distrito ou um concelho.";        
				document.getElementById('distrito_concelho_id').className = "pesquisa_erro";
			}
			boolErro = true;
	    }
	*/    
	    /*if(document.getElementById('tipo_id').selectedIndex == 0) {
	    	if(boolPesq){
	    		document.getElementById('tipo_error').style.paddingTop = "2px";
		  		document.getElementById('tipo_error').style.height = "15px";
		  		document.getElementById('tipo_error').style.lineHeight = "11px";
		  		document.getElementById('tipo_error').style.fontSize = "10px";
		   		document.getElementById('tipo_error').innerHTML = "* Por favor, escolha um tipo de imóvel.";        
				document.getElementById('tipo_id').className = "pesquisa_erro";
			}
			boolErro =  true;
	    }*/
//	}

	/*if(document.getElementById('operacao').selectedIndex == 0) {
		if(boolPesq){
			document.getElementById('operacao_error').style.paddingTop = "2px";
			document.getElementById('operacao_error').style.height = "15px";   
			document.getElementById('operacao_error').style.lineHeight = "11px";
			document.getElementById('operacao_error').style.fontSize = "10px";
	   		document.getElementById('operacao_error').innerHTML = "* Por favor, escolha um tipo de negócio.";        
			document.getElementById('operacao').className = "pesquisa_erro";
		}
		boolErro = true;		
    }*/
	
	/*
	if(document.getElementById('operacao').options[document.getElementById('operacao').selectedIndex].value == 5) {
		checkOperacao();
	}
 */
	if(boolErro){
		return false;
	}
  	return true;
 	
}


function checkSearchParamsFIIAH(){
	boolErro = false;
	
	boolPesq = false;
	try{
		boolPesq = document.getElementById('pesq').value == "true";
	}catch(e){}

	try{
		document.getElementById('referencia').value="";
	}catch(e){}		
	
	document.getElementById('distrito_concelho_error').style.height = "0px";
	document.getElementById('distrito_concelho_error').style.lineHeight = "0px";
	document.getElementById('distrito_concelho_error').style.fontSize = "0px";
	document.getElementById('distrito_concelho_error').innerHTML = "";        
	document.getElementById('distrito_concelho_id').className = "pesquisa";

/*
	if(document.getElementById('distrito_concelho_id').selectedIndex == 0) {
			if(boolPesq){
				document.getElementById('distrito_concelho_error').style.paddingTop = "2px";
				document.getElementById('distrito_concelho_error').style.height = "15px";
				document.getElementById('distrito_concelho_error').style.lineHeight = "11px";
				document.getElementById('distrito_concelho_error').style.fontSize = "10px";
				document.getElementById('distrito_concelho_error').innerHTML = "* Por favor, escolha um distrito ou um concelho.";        
				document.getElementById('distrito_concelho_id').className = "pesquisa_erro";
			}
			boolErro = true;
	    }

	if(boolErro){
		return false;
	}
	
*/
  	return true;
 	
}

function checkSearchParamsEmpreend(){
	boolErro = false;
	
	boolPesq = false;
	try{
		boolPesq = document.getElementById('pesq').value == "true";
	}catch(e){}
	
	document.getElementById('distrito_concelho_error').style.height = "0px";
	document.getElementById('distrito_concelho_error').style.lineHeight = "0px";
	document.getElementById('distrito_concelho_error').style.fontSize = "0px";
	document.getElementById('distrito_concelho_error').innerHTML = "";        
	document.getElementById('distrito_concelho_id').className = "pesquisa";

	//Quando é feita uma pesquisa por nome o campo distrito_concelho_id não é obrigatório
	strNomeEmpreend = document.getElementById('nome').value;
	/*if(Trim(strNomeEmpreend).length == 0 || strNomeEmpreend == "Nome Empreendimento") {		
		if(document.getElementById('distrito_concelho_id').selectedIndex == 0) {
			if(boolPesq){
				document.getElementById('distrito_concelho_error').style.paddingTop = "2px";
				document.getElementById('distrito_concelho_error').style.height = "30px";
				document.getElementById('distrito_concelho_error').style.lineHeight = "11px";
				document.getElementById('distrito_concelho_error').style.fontSize = "10px";
				document.getElementById('distrito_concelho_error').innerHTML = "Por favor, escolha um distrito / concelho ou indique o nome do empreendimento que procura.";        
				document.getElementById('distrito_concelho_id').className = "pesquisa_erro";
			}
			boolErro = true;
	    }	    
	}
*/	
	if(boolErro){
		return false;
	}
	
	if (strNomeEmpreend == "Nome Empreendimento") document.getElementById('nome').value = '';
  	return true;
  	
}

function checkSearchRef(){
	boolErro = false;
	
	boolPesq = false;
	try{
		boolPesq = document.getElementById('pesq').value == "true";
	}catch(e){}
	
	document.getElementById('referencia_error').style.height = "0px";
	document.getElementById('referencia_error').style.lineHeight = "0px";
	document.getElementById('referencia_error').style.fontSize = "0px";
	document.getElementById('referencia_error').innerHTML = "";        
	document.getElementById('referencia').className = "pesquisa";
	
	if(isEmptyString(document.getElementById('referencia').value)) {
		document.getElementById('referencia_error').style.paddingTop = "2px";
		document.getElementById('referencia_error').style.lineHeight = "11px";
		document.getElementById('referencia_error').style.fontSize = "10px";
		document.getElementById('referencia_error').style.height = "15px";        
		document.getElementById('referencia_error').innerHTML = "* Por favor, preencha o campo Ref. Caixa Imobiliário.";        
		document.getElementById('referencia').className = "pesquisa_erro";
		boolErro = true;
    }
	
	if (!isEmptyString(document.getElementById('referencia').value) && document.getElementById('referencia').value.length < 8){
		document.getElementById('referencia_error').style.paddingTop = "2px";
		document.getElementById('referencia_error').style.lineHeight = "11px";
		document.getElementById('referencia_error').style.fontSize = "10px";
		document.getElementById('referencia_error').style.height = "25px";        
		document.getElementById('referencia_error').innerHTML = "* Por favor, preencha o campo com pelo menos 8 caracteres";        
		document.getElementById('referencia').className = "pesquisa_erro";
		boolErro = true;
	}
	
	if  (!isRef(document.getElementById('referencia').value)) {
		document.getElementById('referencia_error').style.paddingTop = "2px";
		document.getElementById('referencia_error').style.lineHeight = "11px";
		document.getElementById('referencia_error').style.fontSize = "10px";
		document.getElementById('referencia_error').style.height = "25px";        
		document.getElementById('referencia_error').innerHTML = "* Por favor, preencha o campo apenas com valores numéricos e/ou \"/\"";        
		document.getElementById('referencia').className = "pesquisa_erro";
		boolErro = true;
	}
 
	if(boolErro){
		return false;
	}
  	return true;
 	
}

function onChangeRef(){
	if(!isEmptyString(document.getElementById('referencia').value)){
		limparPesquisa();
	}
}

function limparPesquisa(){
	try{
		if(document.getElementById("distrito_concelho_id").disabled == false){
			document.getElementById("distrito_concelho_id").value = 0;
		}
	}catch(e){}

	try{
		if(document.getElementById("freguesia_id").disabled == false){
			document.getElementById("freguesia_id").value = 0; 
		}
	}catch(e){}

	try{
		if(document.getElementById("tipo_id").disabled == false){
			document.getElementById("tipo_id").value = 0;
		}
	}catch(e){}

	try{
		if(document.getElementById("tipologia_id").disabled == false){
			document.getElementById("tipologia_id").value = 0;
		}
	}catch(e){}	
	
	try{
		if(document.getElementById("operacao").disabled == false){
			document.getElementById("operacao").value = 0;
		}
	}catch(e){}	
	
	try{
		if(document.getElementById("area").disabled == false){
			document.getElementById("area").value = 0;
		}
	}catch(e){}	
	
	try{
		if(document.getElementById("preco").disabled == false){
			document.getElementById("preco").value = 0;
		}
	}catch(e){}	
}


function checkPedidosParams(){
	boolErro = false;
		
	reg = /^[\w-]+(\.[\w-]+)*@(([\w-]{2,63}\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
	
	document.getElementById('nome_error').style.height = "0px";        
	document.getElementById('nome_error').style.lineHeight = "0px";
	document.getElementById('nome_error').style.fontSize = "0px";
	document.getElementById('nome_error').innerHTML = "";        
	document.getElementById('nome').className = "font11";

	document.getElementById('telefone_error').style.height = "0px";        
	document.getElementById('telefone_error').style.lineHeight = "0px";
	document.getElementById('telefone_error').style.fontSize = "0px";
	document.getElementById('telefone_error').innerHTML = "";        
	document.getElementById('telefone').className = "font11";

	document.getElementById('email_error').style.height = "0px";        
	document.getElementById('email_error').style.lineHeight = "0px";
	document.getElementById('email_error').style.fontSize = "0px";
	document.getElementById('email_error').innerHTML = "";        
	document.getElementById('email').className = "font11";
	
	if(document.getElementById('intranet').value == "true"){	
		document.getElementById('nr_empregado_error').style.height = "0px";        
		document.getElementById('nr_empregado_error').style.lineHeight = "0px";
		document.getElementById('nr_empregado_error').style.fontSize = "0px";
		document.getElementById('nr_empregado_error').innerHTML = "";        
		document.getElementById('nr_empregado').className = "font11";
	
		document.getElementById('cod_agencia_error').style.height = "0px";        
		document.getElementById('cod_agencia_error').style.lineHeight = "0px";
		document.getElementById('cod_agencia_error').style.fontSize = "0px";
		document.getElementById('cod_agencia_error').innerHTML = "";        
		document.getElementById('cod_agencia').className = "font11";

		document.getElementById('ag_telefone_error').style.height = "0px";        
		document.getElementById('ag_telefone_error').style.lineHeight = "0px";
		document.getElementById('ag_telefone_error').style.fontSize = "0px";
		document.getElementById('ag_telefone_error').innerHTML = "";        
		document.getElementById('telefone_empregado').className = "font11";
	
		document.getElementById('nif_nipc_error').style.height = "0px";        
		document.getElementById('nif_nipc_error').style.lineHeight = "0px";
		document.getElementById('nif_nipc_error').style.fontSize = "0px";
		document.getElementById('nif_nipc_error').innerHTML = "";        
		document.getElementById('nif_nipc').className = "font11";
	}	
	
	if(document.getElementById('intranet').value == "true"){
		if(isEmptyString(document.getElementById('nr_empregado').value)) {
			document.getElementById('nr_empregado_error').style.paddingTop = "2px";
			document.getElementById('nr_empregado_error').style.lineHeight = "11px";
			document.getElementById('nr_empregado_error').style.fontSize = "10px";
			document.getElementById('nr_empregado_error').style.height = "15px";        
			document.getElementById('nr_empregado_error').innerHTML = "* Por favor, preencha o campo  Nr de Empregado.";        
			document.getElementById('nr_empregado').className = "pesquisa_erro";
			boolErro = true;
 	 }
 	 if(isEmptyString(document.getElementById('cod_agencia').value)) {
			document.getElementById('cod_agencia_error').style.paddingTop = "2px";
			document.getElementById('cod_agencia_error').style.lineHeight = "11px";
			document.getElementById('cod_agencia_error').style.fontSize = "10px";
			document.getElementById('cod_agencia_error').style.height = "15px";        
			document.getElementById('cod_agencia_error').innerHTML = "* Por favor, preencha o campo Cod. Agência.";        
			document.getElementById('cod_agencia').className = "pesquisa_erro";
			boolErro = true;
 	 }
 	 if(Trim(document.getElementById('telefone_empregado').value).length < 9 || !(isInt(document.getElementById('telefone_empregado').value))) {
		document.getElementById('ag_telefone_error').style.paddingTop = "2px";
		document.getElementById('ag_telefone_error').style.lineHeight = "11px";
		document.getElementById('ag_telefone_error').style.fontSize = "10px";
   	document.getElementById('ag_telefone_error').style.height = "15px";        
		document.getElementById('ag_telefone_error').innerHTML = "* O campo Telefone deve ser preenchido com valores numéricos. Por favor, preencha correctamente o campo Telefone.";        
		document.getElementById('telefone_empregado').className = "pesquisa_erro";
		boolErro = true;
	}
 	 if(isEmptyString(document.getElementById('telefone_empregado').value)) {
			document.getElementById('ag_telefone_error').style.paddingTop = "2px";
			document.getElementById('ag_telefone_error').style.lineHeight = "11px";
			document.getElementById('ag_telefone_error').style.fontSize = "10px";
			document.getElementById('ag_telefone_error').style.height = "15px";        
			document.getElementById('ag_telefone_error').innerHTML = "* Por favor, preencha o campo Telefone.";        
			document.getElementById('telefone_empregado').className = "pesquisa_erro";
			boolErro = true;
 	 }
  }

	if(isEmptyString(document.getElementById('nome').value)) {
		document.getElementById('nome_error').style.paddingTop = "2px";
		document.getElementById('nome_error').style.lineHeight = "11px";
		document.getElementById('nome_error').style.fontSize = "10px";
		document.getElementById('nome_error').style.height = "15px";        
		document.getElementById('nome_error').innerHTML = "* Por favor, preencha o campo Nome.";        
		document.getElementById('nome').className = "pesquisa_erro";
		boolErro = true;
  }
  
  if(document.getElementById('intranet').value == "true"){		
 	 if(isEmptyString(document.getElementById('nif_nipc').value)) {
			document.getElementById('nif_nipc_error').style.paddingTop = "2px";
			document.getElementById('nif_nipc_error').style.lineHeight = "11px";
			document.getElementById('nif_nipc_error').style.fontSize = "10px";
			document.getElementById('nif_nipc_error').style.height = "15px";        
			document.getElementById('nif_nipc_error').innerHTML = "* Por favor, preencha o campo NIF/NIPC.";        
			document.getElementById('nif_nipc').className = "pesquisa_erro";
			boolErro = true;
 	 }
 	} 

	if(Trim(document.getElementById('telefone').value).length < 9 || !(isInt(document.getElementById('telefone').value))) {
		document.getElementById('telefone_error').style.paddingTop = "2px";
		document.getElementById('telefone_error').style.lineHeight = "11px";
		document.getElementById('telefone_error').style.fontSize = "10px";
   		document.getElementById('telefone_error').style.height = "15px";        
		document.getElementById('telefone_error').innerHTML = "* O campo telefone deve ser preenchido com valores numéricos. Por favor, preencha correctamente o campo Telefone.";        
		document.getElementById('telefone').className = "pesquisa_erro";
		boolErro = true;
	}

	if(isEmptyString(document.getElementById('telefone').value)) {
		document.getElementById('telefone_error').style.paddingTop = "2px";
		document.getElementById('telefone_error').style.lineHeight = "11px";
		document.getElementById('telefone_error').style.fontSize = "10px";
  	document.getElementById('telefone_error').style.height = "15px";        
		document.getElementById('telefone_error').innerHTML = "* Por favor, preencha o telefone.";        
		document.getElementById('telefone').className = "pesquisa_erro";
		boolErro = true;
  }

	if(!isEmptyString(document.getElementById('email').value) && !reg.test(document.getElementById('email').value)){
		document.getElementById('email_error').style.paddingTop = "2px";
		document.getElementById('email_error').style.lineHeight = "11px";
		document.getElementById('email_error').style.fontSize = "10px";
		document.getElementById('email_error').style.height = "15px";        
		document.getElementById('email_error').innerHTML = "* Por favor, preencha o campo Email correctamente. ex: antonio@imocaixa.pt";        
		document.getElementById('email').className = "pesquisa_erro";
		boolErro = true;
	}

	if(boolErro){
		return false;
	}else
  	return true;
}

function checkEnvioAmigoParams(){
	boolErro = false;
		
	reg = /^[\w-]+(\.[\w-]+)*@(([\w-]{2,63}\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
	
	document.getElementById('env_nome_error').style.height = "0px";        
	document.getElementById('env_nome_error').style.lineHeight = "0px";
	document.getElementById('env_nome_error').style.fontSize = "0px";
	document.getElementById('env_nome_error').innerHTML = "";        
	document.getElementById('env_nome').className = "font11";

	document.getElementById('env_email_error').style.height = "0px";        
	document.getElementById('env_email_error').style.lineHeight = "0px";
	document.getElementById('env_email_error').style.fontSize = "0px";
	document.getElementById('env_email_error').innerHTML = "";        
	document.getElementById('env_email').className = "font11";
	
	if(isEmptyString(document.getElementById('env_nome').value)) {
		document.getElementById('env_nome_error').style.paddingTop = "2px";
		document.getElementById('env_nome_error').style.lineHeight = "11px";
		document.getElementById('env_nome_error').style.fontSize = "10px";
		document.getElementById('env_nome_error').style.height = "15px";        
		document.getElementById('env_nome_error').innerHTML = "* Por favor, preencha o seu nome.";        
		document.getElementById('env_nome').className = "pesquisa_erro";
		boolErro = true;
    }

	if(isEmptyString(document.getElementById('env_email').value) || !reg.test(document.getElementById('env_email').value)){
		document.getElementById('env_email_error').style.paddingTop = "2px";
		document.getElementById('env_email_error').style.lineHeight = "11px";
		document.getElementById('env_email_error').style.fontSize = "10px";
		document.getElementById('env_email_error').style.height = "15px";        
		document.getElementById('env_email_error').innerHTML = "* Por favor, preencha o campo Email correctamente. ex: antonio@imocaixa.pt";        
		document.getElementById('env_email').className = "pesquisa_erro";
		boolErro = true;
	}

	if(boolErro){
		return false;
	}
  	return true;
}

function isRadioChecked(radioObjName) {
	radioObj = document.getElementsByName(radioObjName);
	
	if(!radioObj) return "";
	
	var radioLength = radioObj.length;
	if(radioLength == undefined && radioObj.checked) return true;
	
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) return true;
	}
	
	return false;
}

function getRadioCheckedValue(radioObjName) {
	radioObj = document.getElementsByName(radioObjName);

	if(!radioObj) return "";
	
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
			
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	
	return "";
}

//Envio Amigo
function envioSent() {
	document.getElementById("divButtonRecomendar").style.visibility = "hidden";

	document.getElementById("divEnvFeedback").innerHTML = 
	"<br/><center>A sua recomendação foi enviada com sucesso.</center>";	
}

function envioError() {		
	document.getElementById("divEnvFeedback").innerHTML = 
		"<center>Lamentamos mas não foi possível enviar a sua recomendação!<br/>" +
		"Por favor aguarde um momento e tente novamente.</center><br/>" + document.getElementById("divFeedback").innerHTML;
}	
/*
function checkOperacao() {
	var pesqTodos = false;
	try{
		if (document.getElementById("pesq_todos").value == "true")
			pesqTodos = true;
	}catch(e){}	
	
	if(document.getElementById('operacao').options[document.getElementById('operacao').selectedIndex].value == 5) {
		if (pesqTodos != true)
			document.getElementById('pesq_imoveis').action = '/comprar-alugar/caixa-arrendamento.jsp';
		else
			document.getElementById('pesq_imoveis').action = '/comprar-alugar/todos-caixa-arrendamento.jsp';					
	}else{
		if (pesqTodos != true)
			document.getElementById('pesq_imoveis').action = '/comprar-alugar/resultados-pesquisa-imobiliaria.jsp';
		else
			document.getElementById('pesq_imoveis').action = '/comprar-alugar/todos-resultados-pesquisa-imobiliaria.jsp';;					

		
	}
  }
  */

