var BROWNSER_NAVIGATOR 	= navigator.appName


function validaCampos(){
	dados = document.contact_agent;
	if (dados.name.value == ""){
		alert("O campo nome deve ser preenchido!");
		dados.name.focus();
		return false;
	}
	
	parte1 = dados.email.value.indexOf("@");
	parte2 = dados.email.value.indexOf(".");
	parte3 = dados.email.value.length;
		if (!(parte1 >= 1 && parte2 >= 6 && parte3 >= 9)) {
		alert ("O campo " + dados.email.name + " deve ser conter um e-mail válido!");
		dados.email.focus();
		return false;
	}
	 
	if (dados.telephone.value == ""){
		alert("O campo telefone deve ser preenchido!");
		dados.telephone.focus();
		return false;
	} 
	   
	if (dados.subject.value == ""){
		alert("O campo assunto deve ser preenchido!");
		dados.subject.focus();
		return false;
	}
	if (dados.message.value == ""){
		alert("O campo mensagem deve ser preenchido!");
		dados.message.focus();
		return false;
	}
	dados.submit();
}

function SetImage(cod){
	var img = "img/fotos/" + cod + "_g.jpg";
	var objImg = document.getElementById("imgPrincipal");
		objImg.src = img;
	
}

function validaCadastro(){
	if (document.formCadastroImovel.titulo.value == ""){
		alert('O campo Título não pode estar vazio')
		document.formCadastroImovel.titulo.focus();
		return false;
	}
	
	if (document.formCadastroImovel.tipo.value == 0){
		alert('Selecione algum Tipo')
		document.formCadastroImovel.tipo.focus();
		return false;
	}
	
	if (document.formCadastroImovel.typeimovel.value == 0){
		alert('Selecione algum Tipo de imóvel')
		document.formCadastroImovel.typeimovel.focus();
		return false;
	}
	
	if (document.formCadastroImovel.operacao.value == ""){
		alert('O campo Operação não pode estar vazio')
		document.formCadastroImovel.operacao.focus();
		return false;
	}
	
	if (document.formCadastroImovel.preco.value == ""){
		alert('O campo Preço não pode estar vazio')
		document.formCadastroImovel.preco.focus();
		return false;
	}
	
	if (document.formCadastroImovel.descricao.value == ""){
		alert('O campo Descrição não pode estar vazio')
		document.formCadastroImovel.descricao.focus();
		return false;
	}
	
	if (document.formCadastroImovel.regiao.value == 0){
		alert('O campo Região não pode estar vazio')
		document.formCadastroImovel.regiao.focus();
		return false;
	}
	
	if (document.formCadastroImovel.cidade.value == ""){
		alert('O campo Cidade não pode estar vazio')
		document.formCadastroImovel.cidade.focus();
		return false;
	}
	
	if (document.formCadastroImovel.bairro.value == ""){
		alert('O campo Bairro não pode estar vazio')
		document.formCadastroImovel.bairro.focus();
		return false;
	}
	
	if (document.formCadastroImovel.endereco.value == ""){
		alert('O campo Endereço não pode estar vazio')
		document.formCadastroImovel.endereco.focus();
		return false;
	}
	
	if (document.formCadastroImovel.localizacao.value == ""){
		alert('O campo Localização não pode estar vazio')
		document.formCadastroImovel.localizacao.focus();
		return false;
	}
	
	
	if (document.formCadastroImovel.nome.value == ""){
		alert('O campo nome não pode estar vazio')
		document.formCadastroImovel.nome.focus();
		return false;
	}
	if (document.formCadastroImovel.email.value == ""){
		alert('O campo e-mail não pode estar vazio')
		document.formCadastroImovel.email.focus();
		return false;
	}
	
	if (document.formCadastroImovel.telefone.value == ""){
		alert('O campo Telefone não pode estar vazio')
		document.formCadastroImovel.telefone.focus();
		return false;
	}

	
	document.formCadastroImovel.submit()
}

function valida(){
	if(document.ref.listingID.value == ""){
		alert('O campo código referência não pode estar vazio')
		document.ref.listingID.focus();
		return false
	}
	document.ref.submit();
}
function Tecla(e){
	if (document.all) // Internet Explorer
		var tecla = event.keyCode;
	else if(document.layers) // Nestcape
		var tecla = e.which;
		if (tecla > 47 && tecla < 58) // numeros de 0 a 9
			return true;
		else
			{
				if (tecla != 8) // backspace
					event.keyCode = 0;
					//return false;
				else
					return true;
			}
}

function writeInicioBlocoDestaque()
{
	if (BROWNSER_NAVIGATOR !==  "Netscape"){
		document.write('<div class="bloco_destaque">');
	}
	else{
		document.write('<div class="bloco_destaque" style="margin-left:6px; width:257px; margin-right:0px">');
	}

}

function writeFimBlocoDestaque()
{
	document.write('</div>');
}



var message = 'Direitos de imagem reservados';
/**
 * Other functions
*/
var ie  = document.all && !document.getElementById;
var dom = document.getElementById;
var ns  = document.layers;



function clickIe()
{
    if (document.all)
    {
        alert(message);
        return false;
    }
}
function clickNs(e)
{
    if (ns || (dom && !document.all))
    {
        if (e.which == 2 || e.which == 3)
        {
            alert(message);
            return false;
        }
    }
}
function protege(imagem)
{
    if (dom && !document.all)
    {
        document.captureEvents(Event.MOUSEDOWN);
        if (document.images)
        {
            imagem.onmousedown = clickNs;
        }
    }
    else
    {
        if (document.images)
        {
            document.onmouseup   = clickNs;
            imagem.oncontextmenu = clickIe;
        }
    }
}



