//FUNCOES DO SITE
/*
function initMenu() {

	$('#menu_new ul').hide();
	$('#menu_new ul:first').show();
	$('#menu_new li a').click(function() {
	
		var checkElement = $(this).next();
		if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
			return false;
		}

		if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
		
			$('#menu_new ul:visible').slideUp('normal');
			checkElement.slideDown('normal');
			
			return false;
		}
	});
}

$(document).ready(function() {

	initMenu();
});
*/
/*function verificar()
{
	var testando = String(String(document.location).substr(11,String(document.location).length)).split("/");
	if(!(testando[5] == ""))
	{
				document.getElementById('departamentos'+testando[5]).style.display="block";
	}
}
*/
function status_site()
{
	window.defaultStatus = " ...........:: SHOPPING CENTER NET ::........... ";
	window.status = " ...........:: SHOPPING CENTER NET ::........... ";
}
function menu_vertical(val_obj)
{
	if(document.getElementById(val_obj).style.display == "none")
	{
		document.getElementById(val_obj).style.display="block";
	}
	else if(document.getElementById(val_obj).style.display == "block")
	{
		document.getElementById(val_obj).style.display="none";
	}
}
function search(form, site_url) {
	
	var key = form.key.value;
	var tipo_midia = form.tipo_midia.options[form.tipo_midia.selectedIndex].value;
	var dp = form.id_departamento.options[form.id_departamento.selectedIndex].value;
	
	var url = site_url+"site/search/"+escape(key)+"/"+tipo_midia+"/"+dp;
	
	document.location = url;
	
	return false;
}

function search_pa(form, site_url) {
			
	var key = form.key.value!='' ? form.key.value : 'null';
	
	if (key == 'null') {
	
		alert('Chave de busca obrigatoria.');
		return false;
	}
		
	var cat = form.id_categoria.options[form.id_categoria.selectedIndex].value !='' ? form.id_categoria.options[form.id_categoria.selectedIndex].value : 'null';
	var cidade = form.id_cidade.options[form.id_cidade.selectedIndex].value !='' ? form.id_cidade.options[form.id_cidade.selectedIndex].value : 'null';
	
	//var url = site_url+"site/searchPA/"+$.base64.encode(key)+"/"+cat+"/"+cidade;
	var url = site_url+"site/searchPA/"+escape(key)+"/"+cat+"/"+cidade+'/'+(cat&&cidade?'1':'0');
	
	document.location = url;
	
	return false;
}

function validarCPF(cpf){   
    
   if(cpf.length != 11 || cpf == "00000000000" || cpf == "11111111111" ||
	  cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" ||
	  cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" ||
	  cpf == "88888888888" || cpf == "99999999999"){
	  //window.alert("CPF inv�lido. Tente novamente.");
	  return false;
   }

   soma = 0;
   for(i = 0; i < 9; i++)
   	 soma += parseInt(cpf.charAt(i)) * (10 - i);
   resto = 11 - (soma % 11);
   if(resto == 10 || resto == 11)
	 resto = 0;
   if(resto != parseInt(cpf.charAt(9))){
	 //window.alert("CPF inv�lido. Tente novamente.");
	 return false;
   }
   soma = 0;
   for(i = 0; i < 10; i ++)
	 soma += parseInt(cpf.charAt(i)) * (11 - i);
   resto = 11 - (soma % 11);
   if(resto == 10 || resto == 11)
	 resto = 0;
   if(resto != parseInt(cpf.charAt(10))){
     //window.alert("CPF inv�lido. Tente novamente.");
	 return false;
   }
   return true;
 }
 
 function validate_profile(form) {
 
 	if (form.nome.value.search(/^ *?$/) != -1) {	
	
		alert("Preencha o campo 'nome'.");
		
		form.nome.focus();
		
		return false;
	}
	
	if (form.cpf.value.search(/^ *?$/) != -1) {	
	
		alert("Preencha o campo 'cpf'.");
		
		form.cpf.focus();
		
		return false;
	}
	
	if (form.email.value.search(/^ *?$/) != -1) {	
	
		alert("Preencha o campo 'email'.");
		
		form.email.focus();
		
		return false;
	}
	
	if (form.endereco.value.search(/^ *?$/) != -1) {	
	
		alert("Preencha o campo 'endereco'.");
		
		form.endereco.focus();
		
		return false;
	}
	
	if (form.bairro.value.search(/^ *?$/) != -1) {	
	
		alert("Preencha o campo 'bairro'.");
		
		form.bairro.focus();
		
		return false;
	}
	
	if (form.cep.value.search(/^ *?$/) != -1) {	
	
		alert("Preencha o campo 'CEP'.");
		
		form.cep.focus();
		
		return false;
	}
	
	if (form.cidade.value.search(/^ *?$/) != -1) {	
	
		alert("Preencha o campo 'cidade'.");
		
		form.cidade.focus();
		
		return false;
	}
	
	if (!form.id_profile && form.senha.value.search(/^ *?$/) != -1) {	
	
		alert("Preencha o campo 'senha'.");
		
		form.senha.focus();
		
		return false;
	}
	
	if (!form.id_profile && form.confirme.value.search(/^ *?$/) != -1) {	
	
		alert("Voce deve confirme a senha");
		
		form.confirme.focus();
		
		return false;
	}
	
	if (!validarCPF(form.cpf.value)) {
	
		alert("CPF invalido.");
		
		form.cpf.focus();
		
		return false;
	}
	
	if (form.email.value.search(/@/) == -1) {
	
		alert("Formato do 'email' incorreto.");
		
		form.email.focus();
		
		return false;
	}
	
	if (form.senha.value != form.confirme.value) {
	
		alert("As senhas nao conferem.");
		
		form.senha.value = "";
		form.confirme.value = "";
		
		form.senha.focus();
		
		return false;
	}
	
	return true;
}

function validate_forgot(form) {
 

	
	if (form.email.value.search(/^ *?$/) != -1) {	
	
		alert("Preencha o campo 'email'.");
		
		form.email.focus();
		
		return false;
	}

	
	if (form.email.value.search(/@/) == -1) {
	
		alert("Formato do 'email' incorreto.");
		
		form.email.focus();
		
		return false;
	}
	
	return true;
}

function validate_login(form) {
 

	
	if (form.email.value.search(/^ *?$/) != -1) {	
	
		alert("Preencha o campo 'email'.");
		
		form.email.focus();
		
		return false;
	}
	
	if (form.senha.value.search(/^ *?$/) != -1) {	
	
		alert("Preencha o campo 'senha'.");
		
		form.senha.focus();
		
		return false;
	}

	
	if (form.email.value.search(/@/) == -1) {
	
		alert("Formato do 'email' incorreto.");
		
		form.email.focus();
		
		return false;
	}
	
	return true;
}