//funcao para busca de lojas
function fnBusca_Lojas(pValor)
{
	alert(pValor);

	document.location.href = pValor;

}
// Validação de Login
function verificaLogin(login){
	
	if(login.login.value.length <= 1 ) {
		alert('Atenção\nPreencha o campo LOGIN.');
		login.login.focus();
		return false;
	}
	
	if(login.senha.value.length <= 1 ) {
		alert('Atenção\nPreencha o campo SENHA.');
		login.senha.focus();
		return false;
	}
}

function verificaBusca(form){
	
	if(form.busca.value.length <= 1 ) {
		alert('Atenção\nPreencha o campo BUSCA.');
		form.busca.focus();
		return false;
	}
}

// Validação de Newsletter
function verificaNewsletter(newsletter){
	
	if(newsletter.nome.value.length <= 1 ) {
		alert('Atenção\nPreencha o campo NOME.');
		newsletter.nome.focus();
		return false;
	}
	
	if(newsletter.email.value.length <= 1 ) {
		alert('Atenção\nPreencha o campo E-MAIL.');
		newsletter.email.focus();
		return false;
	}
	
	if(newsletter.email.value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1){
		alert("Atenção!\nO campo EMAIL deve ser preenchido corretamente.");
		newsletter.email.value = ('');
		newsletter.email.focus();
		return false;
 	}
}

// Validação do Orcamento
function verificaOrcamento(form){
	if(form.nome_orcamento.value.length <= 1){
		alert('Atenção\nPreencha o campo NOME.');
		form.nome_orcamento.focus();
		return false;
	}
	if(form.email_orcamento.value.length <= 1){
		alert('Atenção\nPreencha o campo E-MAIL.');
		form.email_orcamento.focus();
		return false;
	}
	if (form.email_orcamento.value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1) {
		alert("Atenção!\nO campo EMAIL deve ser preenchido corretamente.");
		form.email_orcamento.value = ('');
		form.email_orcamento.focus();
		return false;
 	}
	if(form.telefone.value.length <= 13){
		alert('Atenção\nPreencha o campo TELEFONE.');
		form.telefone.focus();
		return false;
	}
	if(form.cidade.value.length <= 1){
		alert('Atenção\nPreencha o campo CIDADE.');
		form.cidade.focus();
		return false;
	}
	if(form.estado.value == ''){
		alert('Atenção\nPreencha o campo ESTADO.');
		form.estado.focus();
		return false;
	}
}


// Validação form de Contato
function verificaFaleConosco(form) {
	
	if(form.nome.value.length <= 1) {
		alert("O campo Nome deve estar preenchido corretamente.");
		form.nome.focus();
		return false;
	}
	
	var str_email = form.email.value;
	if (str_email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1) {
		alert("O campo E-mail deve ser preenchido corretamente");
		form.email.focus();
		return false;
	}
	
	if(form.telefone.value.length <= 13) {
		alert("O campo Telefone deve estar preenchido corretamente.");
		form.telefone.focus();
		return false;
	}
	
   	if(form.mensagem.value.length <=1) {
		alert("O campo Mensagem deve estar preenchido corretamente.");
		form.mensagem.focus();
		return false;
	}
}

// valida Comissoes Formatura
function verificaComissao(form) {
	
	if(form.nome.value.length <= 1)
  	{
   		alert("Ateção\nO campo Nome deve ser preenchido.");
   		form.nome.focus();
   		return false;
   	}
	
	if(form.convidados.value.length <= 1)
  	{
   		alert("Ateção\nO campo Número de formandos ou convidados deve ser preenchido.");
   		form.convidados.focus();
   		return false;
   	}
	
	if (form.email.value == '' )
	{
		alert("Ateção\n O campo E-MAIL deve ser preenchido.");
		form.email.focus();
		return false;
	}
	
   if (form.email.value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)
   {
	  alert("Atenção!\nO campo E-MAIL deve ser preenchido corretamente.");
	  form.email.focus();
	  return false;
   }
   
   if(form.telefone.value.length <=1 )
   {
		alert("Atenção\nO campo Telefone deve sr preenchido.");
		form.telefone.focus();
		return false
   }
   
   if(form.cidade.value.length <=1 )
   {
		alert("Atenção\nO campo Cidade deve sr preenchido.");
		comissoes_formatura.cidade.focus();
		return false
   }
}

// Validação form de Contato
function verificaAtacado(form) {
	
	if(form.nome_atacado.value.length <= 1) {
		alert("O campo Nome deve estar preenchido corretamente.");
		form.nome_atacado.focus();
		return false;
	}
	
	var str_email = form.email_atacado.value;
	if (str_email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1) {
		alert("O campo E-mail deve ser preenchido corretamente");
		form.email_atacado.focus();
		return false;
	}
	
	if(form.telefone.value.length <= 13) {
		alert("O campo Telefone deve estar preenchido corretamente.");
		form.telefone.focus();
		return false;
	}
	
   	if(form.porque.value.length <=1) {
		alert("O campo Porque deseja ser franqueado da Animafest deve estar preenchido corretamente.");
		form.porque.focus();
		return false;
	}
}

// Função de Máscara de Campos
function FormatMask(objForm, strField, sMask, evtKeyPress){
	var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;
	if(window.event){ nTecla = evtKeyPress.keyCode; }
	else if(evtKeyPress.which){ nTecla = evtKeyPress.which; }
	sValue = objForm[strField].value;
	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;
	if(nTecla != 8){
		if(sMask.charAt(i-1) == "9"){ return((nTecla > 47)&&(nTecla < 58)); }
		else{
			while(i <= mskLen){
				bolMask = ((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++;
			}
			objForm[strField].value = sCod;
			return true;
		}
	}
	else{ return true; }
}

// Favoritos
function fnFavoritos() {
	title = document.title;
	url = "http://www.animafest.com.br";
	if(window.sidebar){ window.sidebar.addPanel(title,url,""); }
    else if(window.external){ window.external.AddFavorite(url,title); }
	else if(window.opera && window.print){ return true; }
}

// Menu Drop-Down
function onOff(id) {
	visivel = document.getElementById(id).style.display;
	if(visivel == "" || visivel == "none"){ document.getElementById(id).style.display = "block" } 
	else{ document.getElementById(id).style.display = "none"; }
}

// Indique a um Amigo
var win=null;
function newWindow(mypage,myname,w,h,scroll,pos) {
	if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	win=window.open(mypage,myname,settings);
	win.focus();
}

function verificaIndique(form) {	
	if(form.nome.value==""){
		alert("O campo Seu nome deve ser preenchido corretamente.");
		form.nome.focus();
		return false;
	}
	
	var str_email = form.email.value;
    if((str_email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)||(str_email == 'Email:')) {
    	alert("O campo Seu E-mail deve ser preenchido corretamente.");
    	form.email.focus();
    	return false;
	}
	
	var str_email = form.emailamigo.value;
    if((str_email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)||(str_email == 'Email:')) {
    	alert("O campo E-mail do Destinatário deve ser preenchido corretamente.");
    	form.emailamigo.focus();
    	return false;
	}
}

// Função popup de imagem

function fnImagemPopUp( titulo , largura , altura , imagem , alt )
{
		var janela ;
		janela = window.open("",titulo,"width="+largura+",height="+altura+",scrollbars=no,toolbar=no,location=no,status=no,menubar=no,resizable=no,left=300,top=300'");
		janela.document.write('<html><head><title>'+titulo+'</title></head>');
		janela.document.write('<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');
		janela.document.write('<img src="'+ imagem + '" alt="' + alt + '" border="0" usemap="#Map"> ');
		janela.document.write('<map name="Map"><area shape="rect" coords="190,6,248,26" href="javascript:window.close();"></map>');
		janela.document.write('<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">');
}


//Ampliar Imagem
function jAmpliProd(jID,jFoto,id,titulo)
{
	window.open('j.asp?p='+jID+'&i='+jFoto+'&m='+document.getElementById(id).src,titulo,'width=700,height=540,scrollbars=yes,toolbar=no,location=no,status=no,menubar=no,resizable=no,left=5,top=5')
}

//Exibir Thumb de Imagens Menores
function jExibeThumb(thumbName,id) 
{
	var tmpImg;
	tmpImg = thumbName.src;
	thumbName.src = document.mainImg.src;
	document.mainImg.src = tmpImg;
	document.getElementById(id).value=tmpImg;
}

//Checa Formulário Referente a CEP e Frete
function checa(nform) 
{
	//Validação de Rádio Buttons
	marcado = -1
	for (i=0; i<nform.frete.length; i++) {
		if (nform.frete[i].checked) {
			marcado = i
			resposta = nform.frete[i].value
			if (resposta == "sedex" || resposta == "sedex10")
			{
				if(nform.cep.value=="")
					{
						alert("Atenção!\nO campo CEP deve ser preenchido corretamente.");
						nform.cep.focus();
						return false;
					}
			}
		}
}
	
	if (marcado == -1) {
		alert("Atenção!\nSelecione uma das opções de frete.");
		nform.frete[0].focus();
		return false;
	} 
		return true;
}

//Atualizar Quantidades De Pedidos Da Cesta de Compras
function jReload()
{
	document.formCesta.submit();
}
function fnCheca_Sedex(nform) 
{
	//validacao de radio buttons
	marcado = -1
	for (i=0; i<nform.frete.length; i++) {
		if (nform.frete[i].checked) {
			marcado = i
			resposta = nform.frete[i].value
			if (resposta == "sedex" || resposta == "sedex10")
			{
				if(nform.cep.value.length < 8)
					{
						alert("Atenção!\nFavor Preencher o CEP corretamente.");
						nform.cep.focus();
						return false;
					}
			}
		}
}
	
	if (marcado == -1) {
		alert("Atenção!\nSelecione uma das opções de frete.");
		nform.frete[0].focus();
		return false;
	} 
}

//Validação Rede Animafet

function ValidaRedeAnimafest(form) {	
	
	if(form.nome.value.length <= 1) {
		alert("O campo Nome deve estar preenchido corretamente.");
		form.nome.focus();
		return false;
	}
	
	if(form.idade.value.length <= 1) {
		alert("O campo Idade deve estar preenchido corretamente.");
		form.idade.focus();
		return false;
	}

	if(form.cpf.value.length <= 1) {
		alert("O campo CPF deve estar preenchido corretamente.");
		form.cpf.focus();
		return false;
	}

	var str_email = form.email.value;
	if (str_email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1) {
		alert("O campo E-mail deve ser preenchido corretamente");
		form.email.focus();
		return false;
	}
	
	if(form.endereco.value.length <= 1) {
		alert("O campo Endereço deve estar preenchido corretamente.");
		form.endereco.focus();
		return false;
	}
	
	if(form.numero.value.length <= 1) {
		alert("O campo Numero deve estar preenchido corretamente.");
		form.numero.focus();
		return false;
	}
	
	if(form.complemento.value.length <= 1) {
		alert("O campo Complemento deve estar preenchido corretamente.");
		form.complemento.focus();
		return false;
	}
	
	if(form.bairro.value.length <= 1) {
		alert("O campo Bairro deve estar preenchido corretamente.");
		form.bairro.focus();
		return false;
	}
	
	if(form.cep.value.length <= 1) {
		alert("O campo Cep deve estar preenchido corretamente.");
		form.cep.focus();
		return false;
	}
	
	if(form.estado.value.length <= 1) {
		alert("O campo Estado deve estar preenchido corretamente.");
		form.estado.focus();
		return false;
	}
	
	if(form.cidade.value.length <= 1) {
		alert("O campo Cidade deve estar preenchido corretamente.");
		form.cidade.focus();
		return false;
	}
  
    if(form.ddd.value.length <= 1) {
		alert("O campo DDD deve estar preenchido corretamente.");
		form.ddd.focus();
		return false;
	}
	
   	if(form.fone.value.length <= 6) {
		alert("O campo Telefone deve estar preenchido corretamente.");
		form.fone.focus();
		return false;
}

if(form.estado_civil.value.length <= 1) {
		alert("O campo Estado Civil deve estar preenchido corretamente.");
		form.estado_civil.focus();
		return false;
	}
	
	if(form.escolaridade.value.length <= 1) {
		alert("O campo Qual o grau de escolaridade? deve estar preenchido corretamente.");
		form.escolaridade.focus();
		return false;
	}
	
	if(form.academica.value.length <= 1) {
		alert("O campo Formação acadêmica deve estar preenchido corretamente.");
		form.academica.focus();
		return false;
	}
	
	if(form.situacao.value.length <= 1) {
		alert("O campo Situação empregatícia deve estar preenchido corretamente.");
		form.situacao.focus();
		return false;
	}
	
	if(form.empresa_trabalha.value.length <= 1) {
		alert("O campo Empresa em que trabalha atualmente deve estar preenchido corretamente.");
		form.empresa_trabalha.focus();
		return false;
	}
	
	if(form.cargo.value.length <= 1) {
		alert("O campo Cargo deve estar preenchido corretamente.");
		form.cargo.focus();
		return false;
	}

	if(form.tempo_empresa.value.length <= 1) {
		alert("O campo Tempo Empresa deve estar preenchido corretamente.");
		form.tempo_empresa.focus();
		return false;
	}

	
	if(form.cargo2.value.length <= 1) {
		alert("O campo Função/Cargo deve estar preenchido corretamente.");
		form.cargo2.focus();
		return false;
	}
	
	if(form.empresa_anterior.value.length <= 1) {
		alert("O campo Tempo na empresa deve estar preenchido corretamente.");
		form.empresa_anterior.focus();
		return false;
	}
	
	if(form.experiencia.value.length <= 1) {
		alert("O campo Já possui alguma experiência no varejo deve estar preenchido corretamente.");
		form.experiencia.focus();
		return false;
	}
	
	if(form.experiencia_gerencial.value.length <= 1) {
		alert("O campo Já possui alguma experiência gerencial ou administrativa deve estar preenchido corretamente.");
		form.experiencia_gerencial.focus();
		return false;
	}
	
	if(form.renda_familiar.value.length <= 1) {
		alert("O campo Renda familiar atual deve estar preenchido corretamente.");
		form.renda_familiar.focus();
		return false;
	}
	
	if(form.recursos.value.length <= 1) {
		alert("O campo Recursos disponíveis para investimento deve estar preenchido corretamente.");
		form.recursos.focus();
		return false;
	}
	
	if(form.liquidez.value.length <= 1) {
		alert("O campo Qual a liquidez destes investimentos deve estar preenchido corretamente.");
		form.liquidez.focus();
		return false;
	}
	
	if(form.de_onde.value.length <= 1) {
		alert("O campo De onde virá a renda pessoal enquanto a loja não atingir o ponto de equilíbrio deve estar preenchido corretamente.");
		form.de_onde.focus();
		return false;
	}
	
	if(form.cidade_gostaria.value.length <= 1) {
		alert("O campo Cidade onde gostaria de montar a loja deve estar preenchido corretamente.");
		form.cidade_gostaria.focus();
		return false;
	}
	
	if(form.tamanho_cidade.value.length <= 1) {
		alert("O campo Tamanho da cidade deve estar preenchido corretamente.");
		form.tamanho_cidade.focus();
		return false;
	}	
	
	if(form.evidencias.value.length <= 1) {
		alert("O campo Quais são as evidências de que a sua cidade/bairro tem potencial para a abertura de uma loja Animafest deve estar preenchido corretamente.");
		form.evidencias.focus();
		return false;
	}
	
	if(form.ponto_venda.value.length <= 1) {
		alert("O campo Já tem o ponto de venda deve estar preenchido corretamente.");
		form.ponto_venda.focus();
		return false;
	}
	
	if(form.localizacao_ponto.value.length <= 1) {
		alert("O campo Localização do ponto de venda deve estar preenchido corretamente.");
		form.localizacao_ponto.focus();
		return false;
	}
	
	if(form.dimensoes.value.length <= 1) {
		alert("O campo Dimensões do ponto de venda deve estar preenchido corretamente.");
		form.dimensoes.focus();
		return false;
	}
	
	if(form.como_conheceu.value.length <= 1) {
		alert("O campo Como conheceu a Animafest deve estar preenchido corretamente.");
		form.como_conheceu.focus();
		return false;
	}
	
	if(form.imagem_animafest.value.length <= 1) {
		alert("O campo Que imagem tem da Animafest deve estar preenchido corretamente.");
		form.imagem_animafest.focus();
		return false;
	}
	
	if(form.porque_deseja.value.length <= 1) {
		alert("O campo Por que deseja ser franqueado Animafest deve estar preenchido corretamente.");
		form.porque_deseja.focus();
		return false;
	}

	if(form.caracteristicas.value.length <= 1) {
		alert("O campo Que características te fazem acreditar que você terá êxito neste empreendimento deve estar preenchido corretamente.");
		form.caracteristicas.focus();
		return false;
	}
	
	if(form.porque_deseja.value.length <= 1) {
		alert("O campo Por que deseja ser franqueado Animafest deve estar preenchido corretamente.");
		form.porque_deseja.focus();
		return false;
	}
	
	if(form.caracteristicas.value.length <= 1) {
		alert("O campo Que características te fazem acreditar que você terá êxito neste empreendimento deve estar preenchido corretamente.");
		form.caracteristicas.focus();
		return false;
	}
}

// Abrir imagem em um Popup
function fnImagemPopUp(titulo,largura,altura,imagem,alt){
	var janela;
	janela = window.open("","janela","width="+largura+",height="+altura+",scrollbars=no,toolbar=no,location=no,status=no,menubar=no,resizable=no,left=300,top=300'");
	janela.document.write('<html><head><title>'+titulo+'</title></head>');
	janela.document.write('<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');
	janela.document.write('<img src="'+imagem+'" alt="'+alt+'" title="'+alt+'" border="0">');
	janela.document.write('</body></html>');
}
	
function fnMascara(objeto, evt, mask)
{ 
	var LetrasU = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
	var LetrasL = 'abcdefghijklmnopqrstuvwxyz';
	var Letras  = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';	
	var Numeros = '0123456789';
	var Fixos  = '().-:/ ';
	var Charset = " !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_/`abcdefghijklmnopqrstuvwxyz{|}~";

	evt = (evt) ? evt : (window.event) ? window.event : "";
	var value = objeto.value;
	if (evt) {
 	var ntecla = (evt.which) ? evt.which : evt.keyCode;
 	tecla = Charset.substr(ntecla - 32, 1);
 	if (ntecla < 32) return true;

 	var tamanho = value.length;
 	if (tamanho >= mask.length) return false;

 	var pos = mask.substr(tamanho,1);
 	while (Fixos.indexOf(pos) != -1)
	 	{
 	 		value += pos;
 	 		tamanho = value.length;
 	 		if (tamanho >= mask.length) return false;
 	 		pos = mask.substr(tamanho,1);
		}

 	switch (pos) 
		{
   			case '#' : if (Numeros.indexOf(tecla) == -1) return false; break;
   			case 'A' : if (LetrasU.indexOf(tecla) == -1) return false; break;
   			case 'a' : if (LetrasL.indexOf(tecla) == -1) return false; break;
   			case 'Z' : if (Letras.indexOf(tecla) == -1) return false; break;
   			case '*' : objeto.value = value; return true; break;
   			default : return false; break;
 		}
	}
	objeto.value = value;
	return true;
}
	
	
///////////////////////////////////////////////////////////////
//Funcao de popup
function MM_openBrWindow(theURL,winName,features) 
{
	var myWin =  window.open(theURL,winName,features);
	myWin.focus();
}
function fnFlash(str_url, int_largura, int_altura)
{
	document.writeln('<object type="application/x-shockwave-flash" data="' + str_url + '" width="' + int_largura + '" height="' + int_altura + '">');
	document.writeln('<param name="movie" value="' + str_url + '">');
	document.writeln('<param name="quality" value="high">');
	document.writeln('<param name="wmode" value="transparent">');
	document.writeln('</object>');
}

	
	
