
//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

// -----------------------------------------------------------------------------------

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function formataMoeda(campo,evt) {
   
   //para evitar caracteres alfas.
   if(((evt.keyCode < 96) || (evt.keyCode > 105)) && ((evt.keyCode < 48) || (evt.keyCode > 57)) ){
		   campo.value = campo.value.replace(String.fromCharCode(evt.keyCode).toLowerCase(),"");
   }
   str = campo.value;

   while(str.search(",") != -1)
	   str = str.replace(",","");
   
   var i = 0;

   while(i< str.length){
	   if(str.substr(i,1) == ".")
		  str = str.replace(".","");
		  i++;
   }

   part1 = str.substr(0,str.length - 2);
   while(part1.search(" ") != -1)
	   part1 = part1.replace(" ","");

	   part2 = str.substr(str.length - 2,2);
	   res = "";
	   i = part1.length;
	   sob = i % 3;
	   if((sob != 0) && (i > 2))
		  res = part1.substr(0,sob) + ".";
	   else
		  res = part1.substr(0,sob);
	   j = 1;
	   part1 = part1.substr(sob);
	   i = 0;
	   while(i < part1.length){
		  if(j == 3){
			 if(i + 1 == part1.length)
				res = res + part1.substr(i-2,3);
			 else res = res + part1.substr(i-2,3) + ".";
		  }
		  i++;
		  j = j<3?j+1:1;
	   }
	   campo.value = res + "," + part2;
	   
	   if (campo.value == ',')
			campo.value = '';

}

//---------------------------------------------------------------//
// MASK
//---------------------------------------------------------------//

function MASK(form) {
	
	$(form + ' input[@mask=telefone]').each( function() {
		
		$(this).mask("(99) 9999-9999");
	
	});

	$(form + ' input[@mask=cep]').each( function() {
		
		$(this).mask("99.999-999");
	
	});

	$(form + ' input[@mask=cpf]').each( function() {
		
		$(this).mask("999.999.999-99");
	
	});

	$(form + ' input[@mask=cnpj]').each( function() {
		
		$(this).mask("99.999.999/9999-99");
	
	});

	$(form + ' input[@mask=data]').each( function() {
		
		$(this).mask("99/99/9999");
	
	});

	$(form + ' input[@mask=moeda]').each( function() {
		
		$(this).keyup( function(event) {
			
			formataMoeda(this,event);
								
		});

	});
	
	$(form + ' input[@mask=dia_mes]').each( function() {
		
		$(this).mask("99/99");
	
	});

}

var Window = {
	
	//Abre janela
	'Open': function(url,title) {

		//Se existir um título para a janela
		if (typeof title!="undefined")
			$('#winTitle').html(title);
		
		var y = (document.all) ? document.documentElement.scrollTop : window.pageYOffset;
		
		var winW = $(document).width();
		
		var posx = ((winW - 740) / 2);
		
		$("#Win").animate({
			left:posx,top: y + 15
		}, 1000);
		
		//Se for IE
		if($.browser.msie) {
			
			//Frame da janela
			$("#frame_detalhes").show();
			$("#frame_detalhes").animate({
			left:posx,top: y + 15
			}, 1000);
			
		}
		
		idTimer = window.setInterval("window.scrollTo(0," + y + ");", 100);
		
		//Pega as propriedades da página
		var page = getPageSize();
		
		//Seta da div orverlay
		$('#block').width('100%');
		$('#block').height(page[1] + 'px');
		$("#block").fadeTo("slow", 0.6);
		$("#block").show();
		
		$('#Win-Content').load(url);
		
	},
	
	'_mudaFundo': function(){
		$('#Win-Content').css({background:'#666'});	
	},
	
	//Fecha janela
	'Close': function(){
		
		window.clearInterval(idTimer);
		
		$("#block").fadeTo("slow", 0);
		$("#block").hide();
		
		$("#Win").animate({
		left: - ($(document).width() + 600)
		}, 1000, function () {
			
			$('#Win-Content').html("");
		
		});
		
		$("#frame_detalhes").animate({
			left: - ($(document).width() * 100)
		}, 1000);
		$("#frame_detalhes").hide();
		
	},
	
	'validaIndicacao': function() {
		
		if ($('#nome_usuario').val() == "") {
			alert('Você precisa digitar seu nome! ');
			$('#nome_usuario').focus();
			return false;
		}
		
		if ($('#email_usuario').val() == "") {
			alert('Você precisa digitar seu e-mail! ');
			$('#email_usuario').focus();
			return false;
		}
		
		if ($('#email_usuario').val() != '' && $('#email_usuario').val().search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1) {
			alert('Você precisa digitar um endereço de e-mail válido! ')
			$('#email_usuario').focus();
			return false;
		}
		
		if ($('#nome_indicacao').val() == "") {
			alert('Você precisa digitar o nome de quem vai receber a indicação de imóvel! ');
			$('#nome_indicacao').focus();
			return false;
		}
		
		if ($('#email_indicacao').val() == "") {
			alert('Você precisa digitar o e-mail de quem vai receber a indicação de imóvel! ');
			$('#email_indicacao').focus();
			return false;
		}
		
		if ($('#email_indicacao').val() != '' && $('#email_indicacao').val().search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1) {
			alert('Você precisa digitar um endereço de e-mail válido! ')
			$('#email_indicacao').focus();
			return false;
		}
		
	},
	
	'validaContatoAnunciante': function() {
		
		if ($('#nome').val() == "") {
			alert('Você precisa digitar seu nome! ');
			$('#nome').focus();
			return false;
		}
		
		if ($('#email').val() == "") {
			alert('Você precisa digitar seu e-mail! ');
			$('#email').focus();
			return false;
		}
		
		if ($('#email').val() != '' && $('#email').val().search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1) {
			alert('Você precisa digitar um endereço de e-mail válido ! ')
			$('#email').focus();
			return false;
		}
		if ($('#fone').val() == "") {
			alert('Você precisa digitar um telefone para contato! ');
			$('#fone').focus();
			return false;
		}
		if ($('#obs').val() == "") {
			alert('Você precisa digitar sua mensagem! ');
			$('#obs').focus();
			return false;
		}
		
		$('#fAnunciante').reset();
	}
	
	
}


var Detalhes = {

	'show' : function() {
		
		Indicacao.hide();
		Galeria.hide();
		Anunciante.hide();
		Video.hide();
		//$("#detalhes").fadeIn("slow");
		$("#detalhes").animate({
		left: 130, top: 15
		}, 500);
		
	},
	'hide' : function() {
		
		$("#detalhes").animate({
		left: 130, top: -600
		}, 1000);
		//$("#detalhes").fadeOut("slow");
		
	}
	
}

var Indicacao = {

	'show' : function() {
		Detalhes.hide();
		Galeria.hide();
		Anunciante.hide();
		Video.hide();
		//$("#indicacao").fadeIn("slow");
		$("#indicacao").animate({
		left: 130, top: 15
		}, 500);
		
	},
	'hide' : function() {
		
		$("#indicacao").animate({
		left: 130, top: -600
		}, 1000);
		//$("#indicacao").fadeOut("slow");
		
	}
	
}

var Video = {

	'show' : function() {
		Detalhes.hide();
		Indicacao.hide();
		Galeria.hide();
		Anunciante.hide();
		//$("#anunciante").fadeIn("slow");
		$("#video").animate({
		left: 130, top: 15
		}, 500);
		
	},
	'hide' : function() {
		
		$("#video").animate({
		left: 130, top: -600
		}, 1000);
		//$("#anunciante").fadeOut("slow");
		
	}
	
}


var Galeria = {

	'show' : function() {
		Detalhes.hide();
		Indicacao.hide();
		Anunciante.hide();
		Video.hide();
		//$("#galeria").fadeIn("slow");
		$("#galeria").animate({
		left: 130, top: 15
		}, 500);
	},
	'hide' : function() {
		
		$("#galeria").animate({
		left: 130, top: -600
		}, 1000);
		//$("#galeria").fadeOut("slow");
		
	}
	
}


var Tipo = {
	
	//Carrega combo cidades para pesquisa de imóveis
	'load': function (valor){
		  
		//verifica se o browser tem suporte a ajax
		try {
			ajax = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(e) {
				try {
					ajax = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(ex) {
					try {
					   ajax = new XMLHttpRequest();
				}
				catch(exc) {
				   alert("Esse browser não tem recursos para uso do Ajax");
				   ajax = null;
				}
			}
		}
		//se tiver suporte ajax
		if(ajax) {
		 //deixa apenas o elemento 1 no option, os outros são excluídos
		 document.getElementById('cmbTipos').options.length = 1;
		 
		 idOpcao  = document.getElementById("opTipos");
		 
		 ajax.open("POST", "load-tipos.php", true);
		 ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		 
		 ajax.onreadystatechange = function() {
			//enquanto estiver processando...emite a msg de carregando
			if(ajax.readyState == 1) {
			//document.forms[0].cmbCidades
			   idOpcao.innerHTML = "Aguarde. Carregando...";   
			}
			//após ser processado - chama função processXML que vai varrer os dados
			if(ajax.readyState == 4 ) {
			   if(ajax.responseXML) {
				  processXML(ajax.responseXML,'tipo');
			   }
			   else {
				   //caso não seja um arquivo XML emite a mensagem abaixo
				   idOpcao.innerHTML = "- Selecione uma finalidade -";
			   }
			}
		 }
		 //passa o código do estado escolhido
		 var params = "finalidade=" + valor;
		 ajax.send(params);
		}
	}
}

function processXML(obj,tipo,target){
	
  //alert(tipo);
  //pega a tag cidade
  var dataArray   =   obj.getElementsByTagName(tipo);
  
  //total de elementos contidos na tag cidade
  if(dataArray.length > 0) {
	 //percorre o arquivo XML paara extrair os dados
	 for(var i = 0 ; i < dataArray.length ; i++) {
		var item = dataArray[i];
		//contéudo dos campos no arquivo XML
		var codigo    =  item.getElementsByTagName("codigo")[0].firstChild.nodeValue;
		var descricao =  item.getElementsByTagName("nome")[0].firstChild.nodeValue;
		
		if (tipo == "bairro")
			idOpcao.innerHTML = "- Todas os bairros -";
		else if (tipo == "cidade")
			idOpcao.innerHTML = "- Selecione uma cidade -";
		else if (tipo == "cidade")
			idOpcao.innerHTML = "- Todas as cidades -";
		else if (tipo == "tipo")
			idOpcao.innerHTML = "- Todos os tipos -";
		
		
		//cria um novo option dinamicamente  
		var novo = document.createElement("option");
			//atribui um ID a esse elemento
			
			if (tipo == "bairro") {
				novo.setAttribute("id", "opBairros");
			}
			else if (tipo == "cidade") {
				if (target==1)
					novo.setAttribute("id", "opCidades");
				else if (target==2)
					novo.setAttribute("id", "opCidades2");
			}
			else if (tipo == "tipo")
				novo.setAttribute("id", "opTipos");
			
			//atribui um valor
			novo.value = codigo;
			//atribui um texto
			novo.text  = descricao;
			//finalmente adiciona o novo elemento
			if (tipo == "bairro") {
				document.getElementById('cmbBairros').options.add(novo);
			}
			else if (tipo == "cidade") {
				if (target==1)
					document.getElementById('cmbCidades').options.add(novo);
				else if (target==2)
					document.getElementById('cmbCidades2').options.add(novo);
			}
			else if (tipo == "tipo")
				document.getElementById('cmbTipos').options.add(novo);
		
	 }
  }
  else {
	//caso o XML volte vazio, printa a mensagem abaixo
	if (tipo == "bairro") {
		idOpcao.innerHTML = "- Todos os bairros -";
		idOpcao.selected = true;
	}
	if (tipo == "cidade") {
		idOpcao.innerHTML = "- Todas as cidades -";
		idOpcao.selected = true;
	}
	if (tipo == "tipo") {
		idOpcao.innerHTML = "- Todas os tipos -";
		idOpcao.selected = true;
	}
  }	  
}


/**********************   VALIDAÇÃO **************/

var Anunciante = {

	'show' : function() {
		Detalhes.hide();
		Indicacao.hide();
		Galeria.hide();
		Video.hide();
		//$("#anunciante").fadeIn("slow");
		$("#anunciante").animate({
		left: 130, top: 15
		}, 500);
		
	},
	'hide' : function() {
		
		$("#anunciante").animate({
		left: 130, top: -600
		}, 1000);
		//$("#anunciante").fadeOut("slow");
		
	},
	
	'Valida': function() {
		
		if ($('#nome_contato').val() == "") {
			alert('Você precisa digitar um nome para contato! ');
			$('#nome_contato').focus();
			return false;
		}
		
		if ($('#email_contato').val() == "") {
			alert('Você precisa digitar o e-mail do contato! ');
			$('#email_contato').focus();
			return false;
		}
		
		if ($('#email_contato').val() != '' && $('#email_contato').val().search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)
		{
			alert('Você precisa digitar um endereço de e-mail válido! ')
			$('#email_contato').focus();
			return false;
		}		
		
		if ($('#fone1_contato').val() == "" && $('#fone2_contato').val() == "") {
			alert('Você precisa digitar o telefone do contato! ');
			$('#fone1_contato').focus();
			return false;
		}	
		
		if ($('#nome_usuario').val() == "") {
			alert('Você precisa digitar o nome do usuário! ');
			$('#nome_usuario').focus();
			return false;
		}
		
		if ($('#email_usuario').val() == "") {
			alert('Você precisa digitar o email de usuário que servirá para acesso ao painel de controle! ');
			$('#email_usuario').focus();
			return false;
		}
		
		if ($('#email_usuario').val() != '' && $('#email_usuario').val().search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)
		{
			alert('Você precisa digitar um endereço de e-mail válido ! ')
			$('#email_usuario').focus();
			return false;
		}	
		
		if ($('#senha').val().length < 4) {
			alert('Você precisa digitar uma senha com no mínimo 4 caracteres! ');
			$('#senha').focus();
			return false;
		}
		
		if ($('#cSenha').val().length < 4 || $('#senha').val() != $('#cSenha').val()) {
			alert('A sua confirmação de senha está diferente da senha! ');
			$('#cSenha').focus();
			return false;
		}		
		
		if ($('#nome').val() == "") {
			alert('Você precisa digitar o nome completo do anunciante!\nLembrando que este não é o nome que aparecerá no anúncio. ');
			$('#nome').focus();
			return false;
		}
		
		if ($('#nome_fantasia').val() == "") {
			alert('Você precisa digitar o nome do anunciante que aparecerá no anúncio! ');
			$('#nome_fantasia').focus();
			return false;
		}
		
		if ($('#email').val() == "") {
			alert('Você precisa digitar e-mail que aparecerá no anúncio para contato! ');
			$('#email').focus();
			return false;
		}
		
		if ($('#email').val() != '' && $('#email').val().search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)
		{
			alert('Você precisa digitar um endereço de e-mail válido! ')
			$('#email').focus();
			return false;
		}
		
		if ($('#fone1').val() == "" && $('#fone2').val() == "") {
			alert('Você precisa digitar um telefone para contato! ');
			$('#fone1').focus();
			return false;
		}

		if ($('#uf').val() == "") {
			alert('Você precisa escolher um estado! ');
			$('#uf').focus();
			return false;
		}

		if ($('#id_cidade').val() == 0) {
			alert('Você precisa escolher uma cidade! ');
			$('#id_cidade').focus();
			return false;
		}

		if ($('#id_tipo_logradouro').val() == 0) {
			alert('Você precisa escolher o logradouro! ');
			$('#id_tipo_logradouro').focus();
			return false;
		}
		
		
		if ($('#endereco').val() == "") {
			alert('Você precisa digitar o endereço! ');
			$('#endereco').focus();
			return false;
		}

		if ($('#numero').val() == "") {
			alert('Você precisa digitar o numero! ');
			$('#numero').focus();
			return false;
		}
	}	
}



var Anuncio = {
	
	'Valida': function() {
		
		if ($('#nome_contato').val() == "") {
			alert('Você precisa digitar o nome do contato! ');
			$('#nome_contato').focus();
			return false;
		}
		
		if ($('#email_contato').val() == "") {
			alert('Você precisa digitar o e-mail do contato! ');
			$('#email_contato').focus();
			return false;
		}
		
		if ($('#email_contato').val() != '' && $('#email_contato').val().search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)
		{
			alert('Você precisa digitar um endereço de e-mail válido! ')
			$('#email_contato').focus();
			return false;
		}
		
		if ($('#fone1_contato').val() == "" && $('#fone2_contato').val() == "") {
			alert('Você precisa digitar um telefone do contato! ');
			$('#fone1_contato').focus();
			return false;
		}		
		
		if ($('#nome_usuario').val() == "") {
			alert('Você precisa digitar o nome do usuário! ');
			$('#nome_usuario').focus();
			return false;
		}
		
		if ($('#email_usuario').val() == "") {
			alert('Você precisa digitar um email de usuário que servirá de acesso ao painel de controle! ');
			$('#email_usuario').focus();
			return false;
		}
		
		if ($('#email_usuario').val() != '' && $('#email_usuario').val().search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)
		{
			alert('Você precisa digitar um endereço de e-mail válido! ')
			$('#email_usuario').focus();
			return false;
		}	
		
		if ($('#senha').val().length < 4) {
			alert('Você precisa digitar uma senha com no mínimo 4 caracteres! ');
			$('#senha').focus();
			return false;
		}
		
		if ($('#cSenha').val().length < 4 || $('#senha').val() != $('#cSenha').val()) {
			alert('A sua confirmação de senha está diferente da senha! ');
			$('#cSenha').focus();
			return false;
		}		
		
		if ($('#titulo').val() == "") {
			alert('Você precisa digitar o nome que aparecerá no anúncio! ');
			$('#titulo').focus();
			return false;
		}
		
		if ($('#email').val() == "") {
			alert('Você precisa digitar o e-mail que aparecerá no anúncio! ');
			$('#email').focus();
			return false;
		}
		
		if ($('#email').val() != '' && $('#email').val().search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)
		{
			alert('Você precisa digitar um endereço de e-mail válido! ')
			$('#email').focus();
			return false;
		}
		
		if ($('#fone1').val() == "" && $('#fone2').val() == "") {
			alert('Você precisa digitar um telefone para o anúncio! ');
			$('#fone1').focus();
			return false;
		}

		if ($('#uf').val() == "") {
			alert('Você precisa escolher um estado! ');
			$('#uf').focus();
			return false;
		}

		if ($('#id_cidade').val() == 0) {
			alert('Você precisa escolher uma cidade! ');
			$('#id_cidade').focus();
			return false;
		}

		if ($('#id_tipo_logradouro').val() == 0) {
			alert('Você precisa escolher um logradouro! ');
			$('#id_tipo_logradouro').focus();
			return false;
		}
		
		
		if ($('#endereco').val() == "") {
			alert('Você precisa digitar o endereço! ');
			$('#endereco').focus();
			return false;
		}

		if ($('#numero').val() == "") {
			alert('Você precisa digitar o numero! ');
			$('#numero').focus();
			return false;
		}
		
		if ($("input:checked").length == 0)
		{
			alert('Você precisa selecionar as categorias em que o anúncio vai aparecer! ');
			return false;
		}		
	}	
}

//Login
var Login = {
	
	'Valida': function(){

		
		if ($('#email').val() == "") {
			alert('Você precisa digitar seu e-mail! ');
			$('#email').focus();
			return false;
		}
		
		if ($('#email').val() != '' && $('#email').val().search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1) {
			alert('Você precisa digitar um endereço de e-mail válido ! ')
			$('#email').focus();
			return false;
		}
	},
	
	'Valida2': function(){

		
		if ($('#email2').val() == "") {
			alert('Você precisa digitar seu e-mail! ');
			$('#email2').focus();
			return false;
		}
		
		if ($('#email2').val() != '' && $('#email2').val().search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1) {
			alert('Você precisa digitar um endereço de e-mail válido! ')
			$('#email2').focus();
			return false;
		}
	}

}



//Formulário de contato

function validaContato() {
	
	if ($('#nome').val() == "") {
		alert('Você precisa digitar seu nome! ');
		$('#nome').focus();
		return false;
	}
	
	if ($('#email').val() == "") {
		alert('Você precisa digitar seu e-mail! ');
		$('#email').focus();
		return false;
	}
	
	if ($('#email').val() != '' && $('#email').val().search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1) {
		alert('Você precisa digitar um endereço de e-mail válido ! ')
		$('#email').focus();
		return false;
	}
	if ($('#fone').val() == "") {
		alert('Você precisa digitar um telefone para contato! ');
		$('#fone').focus();
		return false;
	}
	if ($('#msg').val() == "") {
		alert('Você precisa digitar sua mensagem! ');
		$('#msg').focus();
		return false;
	}
	
}

function validaImovelSobMedida() {
	
	if ($('#nome').val() == "") {
		alert('Você precisa digitar seu nome! ');
		$('#nome').focus();
		return false;
	}
	
	if ($('#email').val() == "") {
		alert('Você precisa digitar seu e-mail! ');
		$('#email').focus();
		return false;
	}
	
	if ($('#email').val() != '' && $('#email').val().search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1) {
		alert('Você precisa digitar um endereço de e-mail válido! ')
		$('#email').focus();
		return false;
	}
	
	if ($('#fone1').val() == "" && $('#fone2').val() == "") {
		alert('Você precisa digitar um telefone para contato! ');
		$('#fone1').focus();
		return false;
	}
	
	if ($('#msg').val() == "") {
		alert('Você precisa digitar sua mensagem! ');
		$('#msg').focus();
		return false;
	}

}

//----------------------------------------------------------------------------//
//ACORDEON
//----------------------------------------------------------------------------//

var Acordeon = {
	
	'active': function(categoria) {
		
		$('#corpoAcordeon_' + categoria).toggle('slider',function(){
		
			$('#center').css('height', 'auto');
			$('#left').css('height', 'auto');
			$('#right').css('height', 'auto');
		
			var tamanho = $('#center').height() >= $('#left').height()?$('#center').height():$('#left').height();
			
			tamanho = tamanho >= $('#right').height()?tamanho:$('#right').height();
			tamanho = tamanho;
			
			//alert(tamanho);
			$('#left').css('height', tamanho);
			$('#right').css('height', tamanho);
			$('#center').css('height',tamanho);
			
		});
		
		document.getElementById('acordeonResize_' + categoria).className = (document.getElementById('acordeonResize_' + categoria).className == "acordeonResize_close") ? "acordeonResize_open" : "acordeonResize_close";	
	}
	
}

/*PARA REDIMENSIONAR AS COLUNAS*/
$(document).ready(function() {
	
	var tamanho = $('#center').height() >= $('#left').height()?$('#center').height():$('#left').height();
	
	tamanho = tamanho >= $('#right').height()?tamanho:$('#right').height();
	tamanho = tamanho;
	//alert(tamanho);
	$('#left').css('height', tamanho);
	$('#right').css('height', tamanho);
	$('#center').css('height',tamanho);
	
});

//Lista anúncios de serviços
function listaAnuncios(IDC) {
	
	window.document.location = '?IDC=' + IDC + '&IDS=' + $('#subcategoria').val() + '&uf=' + $('#uf').val() + '&cidade=' + $('#cidade').val();
	
}