function mostraSubmenu(submenu, n) {
	document.getElementById(submenu).style.display = "inline";
	//eval("document.getElementById('"+submenu+"-cel').style.background = '#C3C2C0'");
	var td = document.getElementById("menu_box_int"); 
	//td.document.getElementsByTagName("td")[n].style.background = "#C3C2C0";
	var arr_td = td.getElementsByTagName("td")[n];
	arr_td.style.background = "#F3EAD4"
	//alert(n);
}

function escondeSubmenu(submenu, n) {
	document.getElementById(submenu).style.display = "none";
	var td = document.getElementById("menu_box_int"); 
	var arr_td = td.getElementsByTagName("td")[n];
	arr_td.style.background = "none"
}

function abreDetalhes(cod_imovel) {
	if (cod_imovel != '0') {
		window.open('pop_imovel.php?i='+cod_imovel,'pop','width=635, height=526, scrollbars=yes')
	}
}

function enviaRefImovel(ref) {
	window.opener.focus();
	window.opener.location.href = "fale.php?ref="+ref;
}

function ValidaEmail(emailad){
    var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
    var check=/@[\w\-]+\./;
    var checkend=/\.[a-zA-Z]{2,3}$/;
    if(((emailad.search(exclude) != -1)||(emailad.search(check)) == -1)||(emailad.search(checkend) == -1)){
        return false;
    }
    else {
        return true;
    }
}

function ValidaForm(){
	
	var email_form = document.getElementById('email').value;
	var nome_form = document.getElementById('nome').value;

	var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
    var check=/@[\w\-]+\./;
    var checkend=/\.[a-zA-Z]{2,3}$/;
    if(((email_form.search(exclude) != -1)||(email_form.search(check)) == -1)||(email_form.search(checkend) == -1)){
        alert("E-mail inválido!");
		  return false;
    }

	else if(nome_form == "") {
		alert("Preencha o campo Nome!");
		  return false;
	}	 
	 
	 else {
        return true;
    }
	


	//alert(email_form);
}

function limpaCampo() {
	document.getElementById("buscar").value = "";
}

// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000

// Duration of crossfade (seconds)
var crossFadeDuration = 3

// Specify the image files
var Pic = new Array() // don't touch this
// to add more images, just continue
// the pattern, adding to the array below

Pic[0] = '1.jpg'
Pic[1] = '2.jpg'
Pic[2] = '3.jpg'
Pic[3] = '4.jpg'

// =======================================
// do not edit anything below this line
// =======================================

var t
var j = 0
var p = Pic.length

var preLoad = new Array()
for (i = 0; i < p; i++){
   preLoad[i] = new Image()
   preLoad[i].src = "util/img/header_foto_" + Pic[i]
}

function runSlideShow(){
   if (document.all){
      document.images.SlideShow.style.filter="blendTrans(duration=2)"
      document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
      document.images.SlideShow.filters.blendTrans.Apply()      
   }
   document.images.SlideShow.src = preLoad[j].src
   if (document.all){
      document.images.SlideShow.filters.blendTrans.Play()
   }
   j = j + 1
   if (j > (p-1)) j=0
   t = setTimeout('runSlideShow()', slideShowSpeed)

//
//alert(Math.floor(Math.random()*5)	);
}

function mostraFoto(cod_imovel,tipo_imovel,cod_tipo,foto) {
	//alert(foto);
	parent.frmFoto.location.href="pop_foto_imovel_iframe.php?cod_imovel="+cod_imovel+"&cod_tipo="+cod_tipo+"&tipo_imovel="+tipo_imovel+"&foto="+foto;
}