// JavaScript Document
var $foo = jQuery.noConflict();
    jQuery(document).ready(function() {
        $foo('.project').mouseenter(function(e) {
            $foo(this).children('a').children('span').fadeIn(200);
        }).mouseleave(function(e) {
            $foo(this).children('a').children('span').fadeOut(200);
        });
    });
	
	
	//plugin
jQuery.fn.topLink = function(settings) {
	settings = jQuery.extend({
		min: 1,
		fadeSpeed: 200
	}, settings);
	return this.each(function() {
		//listen for scroll
		var el = $foo(this);
		el.hide(); //in case the user forgot
		$foo(window).scroll(function() {
			if($foo(window).scrollTop() >= settings.min)
			{
				el.fadeIn(settings.fadeSpeed);
			}
			else
			{
				el.fadeOut(settings.fadeSpeed);
			}
		});
	});
};

//usage w/ smoothscroll
jQuery(document).ready(function() {
	//set the link
	$foo('#top-link').topLink({
		min: 400,
		fadeSpeed: 500
	});
	//smoothscroll
	$foo('#top-link').click(function(e) {
		e.preventDefault();
		$foo.scrollTo(0,300);
	});
});



// SRIPTS GEDOOR

function validaFrmIndicaAmigo(form){
	if(form.txtSeuNome.value==""){
		$foo("#form_alert div").show();
		$foo("#form_alert div").html("Por favor, informe <span>seu nome</span>!");
		form.txtSeuNome.focus();
		return false;
	}
	if(form.txtSeuEmail.value==""){
		$foo("#form_alert div").show();
		$foo("#form_alert div").html("Por favor, informe <span>seu email</span>!");
		form.txtSeuEmail.focus();
		return false;
	}else{
		if(!validaEmail(form.txtSeuEmail.value)){
		$foo("#form_alert div").show();
			$foo("#form_alert div").html("Aten&ccedil;&atilde;o, <span>seu email deve ser v&aacute;lido</span>!");
			form.txtSeuEmail.focus();
			return false;
		}
	}
	if(form.txtNomeAmigo.value==""){
		$foo("#form_alert div").show();
		$foo("#form_alert div").html("Por favor, informe o <span>nome do seu amigo</span>!");
		form.txtNomeAmigo.focus();
		return false;
	}
	if(form.txtEmailAmigo.value==""){
		$foo("#form_alert div").show();
		$foo("#form_alert div").html("Por favor, informe o <span>email do seu amigo</span>!");
		form.txtEmailAmigo.focus();
		return false;
	}else{
		if(!validaEmail(form.txtEmailAmigo.value)){
			$foo("#form_alert div").html("Aten&ccedil;&atilde;o, <span>o email do seu amigo deve ser v&aacute;lido</span>!");
			form.txtEmailAmigo.focus();
			return false;
		}
	}
	$foo("#form_alert div").load('ctrlImplementa.php?'+$foo("#frmIndicaAmigo").formSerialize());
}

function popup(url, width, height, rola){						
	if (rola==""){
		rola="yes"
	}
	window.open(url,"_blank","resizable=no,toolbar=no,status=no,top=" + (window.screen.height - height)/2 + ",left=" + (window.screen.width - width)/2 + ",menubar=no,scrollbars=" + rola + ",width=" + width + ",height=" + height);
}


function validaFrmContatoHotsite(form) {
	
	$foo('#resposta').show();
	$foo('#resposta').css('color','red');
	$foo('#resposta').css('font-size','13px');
	$foo('#resposta').css('margin-left','75px')
	
	if(form.nome.value==""){

		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo NOME!";

		form.nome.focus();

		return false;

	}
		if(form.ddd.value==""){

		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo DDD!";

		form.ddd.focus();

		return false;

	}
		if(form.tele.value==""){

		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo TELEFONE!";

		form.tele.focus();

		return false;

	}
		if(form.email.value==""){

		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo EMAIL!";

		form.email.focus();

		return false;

	}
		if(form.mensagem.value==""){

		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo MENSAGEM!";

		form.mensagem.focus();

		return false;

	}

}
function validaFrmContato(form){
	
	$foo('#resposta').show();
	$foo('#resposta').css('color','red');
	$foo('#resposta').css('font-size','13px');
	$foo('#resposta').css('margin-bottom','25px')
	
	if(form.txtNome.value=="Digite seu Nome ..." || form.txtNome.value==""){

		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo NOME!";

		form.txtNome.focus();

		return false;

	}

	if(form.txtEmail.value=="Digite seu Email ..." || form.txtEmail.value=="" ){

		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo EMAIL!";

		form.txtEmail.focus();

		return false;

	}else{

		if(!validaEmail(form.txtEmail.value)){

			document.getElementById("resposta").innerHTML = "Por favor, informe um EMAIL V&Aacute;LIDO!";

			form.txtEmail.focus();

			return false;

		}

	}

	if(form.txtFone.value=="Digite seu Telefone ..." || form.txtFone.value=="" ){

		document.getElementById("resposta").innerHTML = "Por favor, selecione o Telefone!";

		form.txtFone.focus();

		return false;

	}

	if(form.txtMensagem.value==""){

		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo MENSAGEM!";

		return false;

	}

	$foo("#resposta").load('ctrlImplementa.php?'+$foo("#contact-form").formSerialize());

}



function montaFlash(destino, flavez, width, height, trans, scale){

	var myFlash =
	'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'" id="'+flavez+'" align="middle">'+
	'<param name="allowScriptAccess" value="sameDomain" />'+
	'<param name="movie" value="'+flavez+'.swf" />'+
	'<param name="wmode" value="transparent" />'+
	'<param name="scale" value="noscale" />'+
	'<param name="quality" value="high" />'+
	'<param name="allowFullScreen" value="true" />'+
	'<embed src="'+flavez+'.swf" allowFullScreen="true" wmode="transparent" quality="high" width="'+width+'" height="'+height+'" name="empresas" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'+
	'</object>'
	;
	document.getElementById(destino).innerHTML = myFlash;
}

function validaFrmTrabalhe(form){	
	scrollTo(0,315);
	document.getElementById("resposta").style.display = "block";
	if(form.txtNome.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo NOME!";
		form.txtNome.focus();
		return false;
	}
	if(form.txtDataNas.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo DATA DE NASCIMENTO!";
		form.txtDataNas.focus();
		return false;
	}
	if((form.fone.value=="") && (form.celular.value=="")){
		document.getElementById("resposta").innerHTML = "Por favor, preencha ao menos um TELEFONE!";
		form.fone.focus();
		return false;
	}
	if(form.email.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo EMAIL!";
		form.email.focus();
		return false;
	}else{
		if(!validaEmail(form.email.value)){
			document.getElementById("resposta").innerHTML = "Por favor, informe um EMAIL V&Aacute;LIDO!";
			form.email.focus();
			return false;
		}
	}		
	if(form.txtCidade.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo CIDADE!";
		form.txtCidade.focus();
		return false;
	}
	if(form.anexo.value==""){
		document.getElementById("resposta").style.display = "none";
		scrollTo(0,1200);
		alert('Favor anexar seu currículo!');
		form.anexo.focus();
		return false;
	}
	if(form.mensagem.value==""){
		document.getElementById("resposta").style.display = "none";
		document.getElementById("msg").style.display = "block";
		document.getElementById("msg").innerHTML = "Vamos lá, fale um pouco de VOCÊ!";
		scrollTo(0,1200);
		form.mensagem.focus();
		return false;
	}
	document.getElementById("resposta").style.display = "none";	
}
function Data(evento,objeto){
        var keypress=(window.event)?event.keyCode:evento.which;
        campo = eval (objeto);
        if (campo.value == '00/00/0000')
        {
                campo.value=""
        }

        caracteres = '0123456789';
        separacao1 = '/';
        conjunto1 = 2;
        conjunto2 = 5;
        if ((caracteres.search(String.fromCharCode (keypress))!=-1) && campo.value.length < (10))
        {
                if (campo.value.length == conjunto1 )
                campo.value = campo.value + separacao1;
                else if (campo.value.length == conjunto2)
                campo.value = campo.value + separacao1;
        }
        else
                event.returnValue = false;
}

//MÁSCARA DE VALORES
function txtBoxFormat(objeto, sMask, evtKeyPress) {
    var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;


	if(document.all) { // Internet Explorer
		nTecla = evtKeyPress.keyCode;
	} else if(document.layers) { // Nestcape
		nTecla = evtKeyPress.which;
	} else {
		nTecla = evtKeyPress.which;
		if (nTecla == 8 || nTecla == 0) {
			return true;
		}
	}

    sValue = objeto.value;

    // Limpa todos os caracteres de formatação que
    // já estiverem no campo.
    sValue = sValue.toString().replace( "-", "" );
    sValue = sValue.toString().replace( "-", "" );
    sValue = sValue.toString().replace( ".", "" );
    sValue = sValue.toString().replace( ".", "" );
    sValue = sValue.toString().replace( "/", "" );
    sValue = sValue.toString().replace( "/", "" );
    sValue = sValue.toString().replace( ":", "" );
    sValue = sValue.toString().replace( ":", "" );
    sValue = sValue.toString().replace( "(", "" );
    sValue = sValue.toString().replace( "(", "" );
    sValue = sValue.toString().replace( ")", "" );
    sValue = sValue.toString().replace( ")", "" );
    sValue = sValue.toString().replace( " ", "" );
    sValue = sValue.toString().replace( " ", "" );
    fldLen = sValue.length;
    mskLen = sMask.length;

    i = 0;
    nCount = 0;
    sCod = "";
    mskLen = fldLen;

    while (i <= mskLen) {
      bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ":"))
      bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))

      if (bolMask) {
        sCod += sMask.charAt(i);
        mskLen++;
	  }else{
        sCod += sValue.charAt(nCount);
        nCount++;
      }
      i++;
    }

    objeto.value = sCod;

	if (nTecla != 8) { // backspace ou tab
		if(sMask.charAt(i-1) == "9"){ // apenas números...
			return ((nTecla > 47) && (nTecla < 58));
		}else{ // qualquer caracter...
			return true;
		} 
	}else{
		return true;
	}
}

//escreve o flash na div desejada para que nao precise clicar nele antes de usa-lo

function montaFlashParams(width, height, arquivo, params, destino){

	var parametro = false;

	

	if(params != null || params != "" || params != "none"){

		parametro = true;

	}

	

	var myFlash =

	'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'" id="'+arquivo+'" align="middle">'+

	'<param name="allowScriptAccess" value="sameDomain" />'+

	'<param name="movie" value="swf/'+arquivo+'.swf';if(parametro){ myFlash += '?'+params;} myFlash += '" />'+

	'<param name="wmode" value="transparent" />'+

	'<param name="scale" value="scale" />'+

	'<param name="quality" value="high" />'+

	'<param name="bgcolor" value="#ffffff" />'+

	'<embed src="swf/'+arquivo+'.swf'; if(parametro){ myFlash += '?'+params;} myFlash += '" wmode="transparent" quality="high" width="'+width+'" height="'+height+'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'+

	'</object>'

	;

	document.getElementById(destino).innerHTML = myFlash;

}

function redimensionaInternas() {
	var ie = /msie/i.test(navigator.userAgent);
	var ieBox = ie && (document.compatMode == null || document.compatMode == "BackCompat");

	var w, h; // Contem o width e o height da janela
	var canvasEl = ieBox ? document.body : document.documentElement;
	w = window.innerWidth || canvasEl.clientWidth;
	h = window.innerHeight || canvasEl.clientHeight;
	//alert("width: "+w+", height:"+h);
	if(h<610){
		montaFlash('global','swf/intro','100%','610');
	}else{
		montaFlash('global','swf/intro','100%','100%');
	}
}

function Abre(url, width, height, rola)	{						
	if (rola==""){rola="yes"}
	window.open(url,"_blank","resizable=no,toolbar=no,status=no,top=" + (window.screen.height - height)/2 + ",left=" + (window.screen.width - width)/2 + ",menubar=no,scrollbars=" + rola + ",width=" + width + ",height=" + height);
}

function checaEncontrou(nform) {
        //validacao de radio buttons sem saber quantos sao
        marcado = -1
        for (i=0; i<nform.resp.length; i++) {
                if (nform.resp[i].checked) {
                        marcado = i
                        resposta = nform.resp[i].value
                }
        }
        
        if (marcado == -1) {
                alert("Selecione uma resposta.");
                nform.resp[0].focus();
                return false;
        } else { 
                if(resposta=="sim") {
					alert("Obrigado por sua resposta!");	
				}
				else {
					location.href="sob_medida.php";
				}
        } 
                return true;
}

function checaVender(nform) {
        //validacao de radio buttons sem saber quantos sao
        marcado2 = -1
        for (i=0; i<nform.resp2.length; i++) {
                if (nform.resp2[i].checked) {
                        marcado2 = i
                        resposta2 = nform.resp2[i].value
                }
        }
        
        if (marcado2 == -1) {
                alert("Selecione uma resposta.");
                nform.resp2[0].focus();
                return false;
        } else { 
                if(resposta2=="vender") {
					location.href="quero_vender.php";	
				}
				else {
					location.href="quero_alugar.php";	
				}
        } 
                return true;
}

//cadastra o email informado no newsletter

function cadNews(email){
	if(email=="Digite seu email!" || email==""){
		alert("Informe seu e-mail");
	}else{
		if(!validaEmail(email)){
			alert("E-mail invalido!");
		}else{
			$foo("#iframeSubmitForm").load("ctrlImplementa.php?acao=addNews&email="+email);
			alert('Email cadastrado com sucesso.');
			document.getElementById('frmCadNewsletter').reset(); 
		}

	}

}


function validaFrmSeuImovelQV(form){
	scrollTo(0,0);
	document.getElementById("resposta").style.display = "block";
	if(form.txtTipo.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, selecione o TIPO DE IM&Oacute;VEL!";
		form.txtTipo.focus();
		return false;
	}
	if(form.txtFinalidade.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, selecione a FINALIDADE!";
		form.txtFinalidade.focus();
		return false;
	}
	if(form.txtImovel.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, selecione o IM&Oacute;VEL!";
		form.txtImovel.focus();
		return false;
	}
	if(form.txtSituacao.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, selecione a SITUA&Ccedil;&Atilde;O!";
		form.txtSituacao.focus();
		return false;
	}
	if(form.txtEnderecoIm.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo ENDERE&Ccedil;O DO IM&Oacute;VEL!";
		form.txtEnderecoIm.focus();
		return false;
	}
	if(form.txtCidadeIm.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo CIDADE DO IM&Oacute;VEL!";
		form.txtCidadeIm.focus();
		return false;
	}
	if(form.txtEstadoIm.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo ESTADO DO IM&Oacute;VEL!";
		form.txtEstadoIm.focus();
		return false;
	}
	if(form.txtNome.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo NOME!";
		form.txtNome.focus();
		return false;
	}
	if(form.txtDDD.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo DDD!";
		form.txtDDD.focus();
		return false;
	}
	if(form.txtFone.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo FONE!";
		form.txtFone.focus();
		return false;
	}
	if(form.txtEmail.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo EMAIL!";
		form.txtEmail.focus();
		return false;
	}else{
		if(!validaEmail(form.txtEmail.value)){
			document.getElementById("resposta").innerHTML = "Por favor, informe um EMAIL V&Aacute;LIDO!";
			form.txtEmail.focus();
			return false;
		}
	}

	$foo("#resposta").load('ctrlImplementa.php?'+$foo("#frmSeuImovelQV").formSerialize());
}
function validaFrmSeuImovelQA(form){
	scrollTo(0,0);
	document.getElementById("resposta").style.display = "block";
	if(form.txtTipo.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, selecione o TIPO DE IM&Oacute;VEL!";
		form.txtTipo.focus();
		return false;
	}
	if(form.txtFinalidade.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, selecione a FINALIDADE!";
		form.txtFinalidade.focus();
		return false;
	}
	if(form.txtEnderecoIm.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo ENDERE&Ccedil;O DO IM&Oacute;VEL!";
		form.txtEnderecoIm.focus();
		return false;
	}
	if(form.txtCidadeIm.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo CIDADE DO IM&Oacute;VEL!";
		form.txtCidadeIm.focus();
		return false;
	}
	if(form.txtEstadoIm.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo ESTADO DO IM&Oacute;VEL!";
		form.txtEstadoIm.focus();
		return false;
	}
	if(form.txtNome.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo NOME!";
		form.txtNome.focus();
		return false;
	}
	if(form.txtDDD.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo DDD!";
		form.txtDDD.focus();
		return false;
	}
	if(form.txtFone.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo FONE!";
		form.txtFone.focus();
		return false;
	}
	if(form.txtEmail.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo EMAIL!";
		form.txtEmail.focus();
		return false;
	}else{
		if(!validaEmail(form.txtEmail.value)){
			document.getElementById("resposta").innerHTML = "Por favor, informe um EMAIL V&Aacute;LIDO!";
			form.txtEmail.focus();
			return false;
		}
	}
	$foo("#resposta").load('ctrlImplementa.php?'+$foo("#frmSeuImovelQA").formSerialize());
}
function validaFrmSobMedidaQA(form){
	scrollTo(0,0);
	document.getElementById("resposta").style.display = "block";
	if(form.txtTipo.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, selecione o TIPO DE IM&Oacute;VEL!";
		form.txtTipo.focus();
		return false;
	}
	if(form.txtFinalidade.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, selecione a FINALIDADE!";
		form.txtFinalidade.focus();
		return false;
	}
	if(form.txtCidadeIm.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo CIDADE DO IM&Oacute;VEL!";
		form.txtCidadeIm.focus();
		return false;
	}
	if(form.txtEstadoIm.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo ESTADO DO IM&Oacute;VEL!";
		form.txtEstadoIm.focus();
		return false;
	}
	if(form.txtBairroIm.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo BAIRROS DESEJADOS DO IM&Oacute;VEL!";
		form.txtBairroIm.focus();
		return false;
	}
	if(form.txtNome.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo NOME!";
		form.txtNome.focus();
		return false;
	}
	if(form.txtDDD.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo DDD!";
		form.txtDDD.focus();
		return false;
	}
	if(form.txtFone.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo FONE!";
		form.txtFone.focus();
		return false;
	}
	if(form.txtEmail.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo EMAIL!";
		form.txtEmail.focus();
		return false;
	}else{
		if(!validaEmail(form.txtEmail.value)){
			document.getElementById("resposta").innerHTML = "Por favor, informe um EMAIL V&Aacute;LIDO!";
			form.txtEmail.focus();
			return false;
		}
	}
	$foo("#resposta").load('ctrlImplementa.php?'+$foo("#frmSobMedidaQA").formSerialize());
}
function validaFrmSobMedidaQC(form){	
	scrollTo(0,0);
	document.getElementById("resposta").style.display = "block";
	if(form.txtTipo.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, selecione o TIPO DE IM&Oacute;VEL!";
		form.txtTipo.focus();
		return false;
	}
	if(form.txtFinalidade.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, selecione a FINALIDADE!";
		form.txtFinalidade.focus();
		return false;
	}
	if(form.txtObjetivo.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, selecione o OBJETIVO!";
		form.txtObjetivo.focus();
		return false;
	}
	if(form.txtCidadeIm.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo CIDADE DO IM&Oacute;VEL!";
		form.txtCidadeIm.focus();
		return false;
	}
	if(form.txtEstadoIm.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo ESTADO DO IM&Oacute;VEL!";
		form.txtEstadoIm.focus();
		return false;
	}
	if(form.txtBairroIm.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo BAIRROS DESEJADOS DO IM&Oacute;VEL!";
		form.txtBairroIm.focus();
		return false;
	}
	if(form.txtNome.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo NOME!";
		form.txtNome.focus();
		return false;
	}
	if(form.txtDDD.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo DDD!";
		form.txtDDD.focus();
		return false;
	}
	if(form.txtFone.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo FONE!";
		form.txtFone.focus();
		return false;
	}
	if(form.txtEmail.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo EMAIL!";
		form.txtEmail.focus();
		return false;
	}else{
		if(!validaEmail(form.txtEmail.value)){
			document.getElementById("resposta").innerHTML = "Por favor, informe um EMAIL V&Aacute;LIDO!";
			form.txtEmail.focus();
			return false;
		}
	}
	$foo("#resposta").load('ctrlImplementa.php?'+$foo("#frmSobMedidaQC").formSerialize());
}
function moeda(z){  
	v = z.value;
	v=v.replace(/\D/g,"")  //permite digitar apenas números
	v=v.replace(/[0-9]{15}/,"")   //limita pra máximo 999.999.999,99
	v=v.replace(/(\d{1})(\d{11})$foo/,"$foo1.$foo2")  //coloca ponto antes dos últimos 8 digitos
	v=v.replace(/(\d{1})(\d{8})$foo/,"$foo1.$foo2")  //coloca ponto antes dos últimos 8 digitos
	v=v.replace(/(\d{1})(\d{5})$foo/,"$foo1.$foo2")  //coloca ponto antes dos últimos 5 digitos
	v=v.replace(/(\d{1})(\d{1,2})$foo/,"$foo1,$foo2")    //coloca virgula antes dos últimos 2 digitos
	z.value = v;
}
function abreHighslide(url, largura, altura, tipo){
	var link = document.createElement("a");
	link.setAttribute("href",url);
	
	if(!tipo){
		tipo = 'ajax';
	}

	hs.htmlExpand(link, {objectType:tipo, width:largura, height:altura, dimmingOpacity: 0.5, outlineType: 'glossy-dark', useControls: false, wrapperClassName: 'draggable-header no-footer'});
}
function abreHighslide2(url, largura, altura, tipo){
	var link = document.createElement("a");
	link.setAttribute("href",url);
	
	if(!tipo){
		tipo = 'ajax';
	}
	
	hs.htmlExpand(link, {objectType:tipo, width:largura, height:altura, dimmingOpacity: 0.5, outlineType: 'glossy-dark', useControls: false, wrapperClassName: 'draggable-header no-footer'}); 
	
}

function carregaDestaques(categorias){

	$foo(".chamadaDest").removeClass("atual");

	if(categorias=="17,24,25"){

		$foo("#chamada17").addClass("atual");

	}else if(categorias=="26,29,30,31,39,40,44"){

		$foo("#chamada26").addClass("atual");

	}else{

		$foo("#chamada"+categorias).addClass("atual");

	}

	$foo("#loadImoveis").load("ctrlImplementa.php?acao=destaques_home&atualizar=true&id_categoria="+categorias,destaques);

}



function carregaDestaques2(div, categorias){

	$foo("#"+div+" #loadImoveis").load("ctrlImplementa.php?acao=destaques_home&atualizar=true&id_categoria="+categorias,destaques);

}



var destWidth = new Array();

var qtdImovel = new Array();

var idAtual;



function destaques(){

	var i = 1;

	$foo(".cx_imoveis_geral").each(function(){

											

		var id = $foo(this).attr("id");							

		qtdImovel[i] = $foo("#"+id+" .imoveis_container div > dl").length;

		destWidth[i] = qtdImovel[i]*447;
//		destWidth[i] = qtdImovel[i]*431;  //Andar 2 em 2

		$foo("#"+id+" .imoveis_container div").css("width",destWidth[i]);

		

		//alert("qtd:"+qtdImovel[i]+"  i:"+i +"  this:"+$foo(this).attr("id"));

		

		if(qtdImovel[i]<=2){

			$foo("#"+id+" img.avancar").attr("src", "img/setaDir_dis.png");

			$foo("#"+id+" .btn_dir a").attr("href","javascript:;");
			$foo("#"+id+" .btn_dir a").attr("onclick","");
			
			$foo("#"+id+" .btn_dir img").css("border","none");

			$foo("#"+id+" img.voltar").attr("src", "img/setaEsq_dis.png");

			$foo("#"+id+" .btn_esq a").attr("onclick","");
			$foo("#"+id+" .btn_esq a").attr("href","javascript:;");
			$foo("#"+id+" .btn_esq img").css("border","none");

		}else{

			$foo("#"+id+" img.avancar").attr("src", "img/setaDir.png");

			$foo("#"+id+" .btn_dir a").attr("href","javascript:avancar('"+id+"');");

			$foo("#"+id+" img.voltar").attr("src", "img/setaEsq.png");

			$foo("#"+id+" .btn_esq a").attr("href","javascript:;");


		}

		i++;

	});

	

	$foo(".preloader").css("display","none");

	$foo(".imoveis_container").css("display","block");

	

}



function avancar(id){

	

	idAtual = id;

	

	var i = 1;

	var j = 1;

	$foo(".cx_imoveis_geral").each(function(){

		if(idAtual != $foo(this).attr("id")){

			i++;

		}else{

			j = i;

		}

	});

	

	var margin = $foo("#"+idAtual+" .imoveis_container div").css("marginLeft").replace("px","");

	var pontoRef = (destWidth[j]-894)*(-1);

	var sobra = destWidth[j]%5;

	

	$foo("#"+idAtual+" .btn_dir a").attr("href","javascript:;");
	

	if(parseInt(margin-894)<pontoRef){
		//alert('if');
		//move = (5-sobra)*163;

		move = pontoRef-parseInt(margin);

		moveImoveis(move, margin);

	}else{
		moveImoveis(-894, margin);

	}

}



function moveImoveis(num, margin){

	//alert("num:"+num+"  margin:"+margin);

	$foo("#"+idAtual+" .imoveis_container div").animate({ 

        marginLeft: parseInt(margin)+num+"px"

	}, 500, "swing", verifica );

}





function voltar(id){

	

	idAtual = id;

	

	var i = 1;

	var j = 1;

	$foo(".cx_imoveis_geral").each(function(){

		if(idAtual != $foo(this).attr("id")){

			i++;

		}else{

			j = i;

		}

	});

	

	var margin = $foo("#"+idAtual+" .imoveis_container div").css("marginLeft").replace("px","");

	var sobra = destWidth[j]%5;

	

	$foo("#"+idAtual+" .btn_esq a").attr("href","javascript:;");

	if(margin > -894){

		//move = (5-sobra)*163;

		move = parseInt(margin);

		moveImoveis(-move, margin);

	}else{

		moveImoveis(894, margin);

	}

	

}





function verifica(){

	var i = 1;

	var j = 1;

	$foo(".cx_imoveis_geral").each(function(){

		if(idAtual != $foo(this).attr("id")){

			i++;

		}else{

			j = i;

		}

	});

	

	

	var margin = $foo("#"+idAtual+" .imoveis_container div").css("marginLeft").replace("px","");

	var pontoRef = (destWidth[j]-894)*(-1);

	

	if(margin==0 && destWidth[j]>894){

		$foo("#"+idAtual+" img.voltar").attr("src", "img/setaEsq.png");

		$foo("#"+idAtual+" .btn_dir a").attr("href","javascript:avancar('"+idAtual+"');");

	}else if(margin==pontoRef && destWidth[j]>894){

		$foo("#"+idAtual+" img.avancar").attr("src", "img/setaDir.png");

		$foo("#"+idAtual+" .btn_esq a").attr("href","javascript:voltar('"+idAtual+"');");

	}else{

		$foo("#"+idAtual+" img.avancar").attr("src", "img/setaDir.png");

		$foo("#"+idAtual+" .btn_dir a").attr("href","javascript:avancar('"+idAtual+"');");

		$foo("#"+idAtual+" img.voltar").attr("src", "img/setaEsq.png");

		$foo("#"+idAtual+" .btn_esq a").attr("href","javascript:voltar('"+idAtual+"');");

	}	

}


function limparPadrao(campo) {
	if (campo.value == campo.defaultValue) {
		campo.value = "";
    }
}
function escreverPadrao(campo) {
	if (campo.value == "") {
		campo.value = campo.defaultValue;
	}
}
function goBack() {
	if(navigator.appName=='Microsoft Internet Explorer') {
		history.go(-1);
	}else{
		history.go(-2);
	}
}

function validaFrmCanalLo(form){

	scrollTo(0,0);

	document.getElementById("resposta").style.display = "block";
	var solicitante = 0;			
	if ($foo("input[type=radio][name=txSolicitante]:checked").val()) {
			var solicitante = 1;			
	}
	if(solicitante==0){

		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo SOLICITANTE!";

		form.txSolicitante[0].focus();

		return false;

	}
	
	if(form.txtNome.value==""){

		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo NOME!";

		form.txtNome.focus();

		return false;

	}

	if(form.txtEmail.value==""){

		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo EMAIL!";

		form.txtEmail.focus();

		return false;

	}else{

		if(!validaEmail(form.txtEmail.value)){

			document.getElementById("resposta").innerHTML = "Por favor, informe um EMAIL V&Aacute;LIDO!";

			form.txtEmail.focus();

			return false;

		}

	}	

	if(form.txtFone.value==""){

		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo TELEFONE!";

		form.txtFone.focus();

		return false;

	}
	if(form.txtCidade.value==""){

		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo CIDADE!";

		form.txtCidade.focus();

		return false;

	}
		if(form.txtEstado.value==""){

		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo ESTADO!";

		form.txtEstado.focus();

		return false;

	}
	if(form.txtAssunto.value==""){

		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo ASSUNTO!";

		form.txtAssunto.focus();

		return false;

	}

	if(form.txtMensagem.value==""){

		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo MENSAGEM!";

		form.txtMensagem.focus();

		return false;

	}

	$foo("#resposta").load('ctrlImplementa.php?'+$foo("#frmCanalLo").formSerialize());

}

function validaEmail(email){
	ER = new RegExp("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]{2,64}(\.[a-z0-9-]{2,64})*\.[a-z]{2,4}$foo");
	if (ER.test(email)){
		return true;
	}else{
		return false;
	}
}


function verifica(){

	var i = 1;

	var j = 1;

	$foo(".cx_imoveis_geral").each(function(){

		if(idAtual != $foo(this).attr("id")){

			i++;

		}else{

			j = i;

		}

	});

	

	

	var margin = $foo("#"+idAtual+" .imoveis_container div").css("marginLeft").replace("px","");

	var pontoRef = (destWidth[j]-894)*(-1);

	

	if(margin==0 && destWidth[j]>894){
		$foo("#"+idAtual+" img.avancar").attr("src", "img/setaDir.png");
		
		//disable
		$foo("#"+idAtual+" img.voltar").attr("src", "img/setaEsq_dis.png");

		$foo("#"+idAtual+" .btn_dir a").attr("href","javascript:avancar('"+idAtual+"');");

	}else if(margin==pontoRef && destWidth[j]>894){
		//disable
		$foo("#"+idAtual+" img.avancar").attr("src", "img/setaDir_dis.png");
		//enable
		$foo("#"+idAtual+" img.voltar").attr("src", "img/setaEsq.png");
		
	
		$foo("#"+idAtual+" .btn_esq a").attr("href","javascript:voltar('"+idAtual+"');");

	}else{

		$foo("#"+idAtual+" img.avancar").attr("src", "img/setaDir.png");

		$foo("#"+idAtual+" .btn_dir a").attr("href","javascript:avancar('"+idAtual+"');");

		$foo("#"+idAtual+" img.voltar").attr("src", "img/setaEsq.png");

		$foo("#"+idAtual+" .btn_esq a").attr("href","javascript:voltar('"+idAtual+"');");

	}	


}
function mudaVideo(url,titulo,descricao){
	$foo("#carregaVideoInt").load("ctrlImplementa.php?acao=video&url="+url+"&titulo="+titulo+"&descricao="+descricao);
}

function validaFrmParceiroCorretor(form){
	scrollTo(0,0);
	document.getElementById("resposta").style.display = "block";
	if(form.nome.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo NOME!";
		form.nome.focus();
		return false;
	}
	if(form.email.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo EMAIL!";
		form.email.focus();
		return false;
	}else{
		if(!validaEmail(form.email.value)){
			document.getElementById("resposta").innerHTML = "Por favor, informe um EMAIL V&Aacute;LIDO!";
			form.email.focus();
			return false;
		}
	}	
	
	if(form.fone.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo TELEFONE!";
		form.fone.focus();
		return false;
	}
	if(form.checkgerente.checked==false && form.checktabelas.checked==false && form.checkimagens.checked==false){
		document.getElementById("resposta").innerHTML = "Por favor, selecione pelo menos um tipo de assunto";	
		return false;
	}

	if(form.mensagem.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo MENSAGEM!";
		form.mensagem.focus();
		return false;
	}
	$foo("#resposta").load('ctrlImplementa.php?'+$foo("#frmParceiroCorretor").formSerialize());
}

