// JavaScript Document

function func_urlLocation(cmpBuscaDefault){
	document.listaPersonalizado.submit()
}

function func_excluir(param){
	if(confirm("Dejesa excluir este registro?")==true){
		window.location=param
	}
}

function validaDefault(){
	var dc = document.form1
	if(dc.franqueado.value==""){
			alert("Preencha o campo Franqueado")
			dc.franqueado.focus()
			return false
	}
	
	if(dc.senha.value==""){
			alert("Preencha o campo Senha")
			dc.senha.focus()
			return false
	}
}


function excluirProduto(id,idProd,totalRetirado,numeroPedido){
	if(confirm("Deseja realmente excluir este registo?")==true){
		window.location="carrinho.asp?acao=excluir&id="+id+"&idProd="+idProd+"&totalRetirado="+totalRetirado+"&numeroPedido="+numeroPedido
	}
}


function funcSubmitFormEsqueci(){
	if(document.form1.emailFran.value==""){
		alert("Informe seu e-mail")
		document.form1.emailFran.focus()
	}else{
		document.form1.submit();
	}
}

function funcSubmitForm(){
	
	document.form1.submit();

}

function funcSubmitFormBusca(){
	document.formBuscaLateral.submit();	
}

function JSConfere(){
	var confere = parseInt(document.getElementById("qtdeU").value)
	if(isNaN(confere)){
		document.getElementById("qtdeU").value = 1
	}
}

function func_claAlterar(){
	dc = document.form1
	
	if(dc.cmpTitulo.value==""){
			alert("Preencha o campo Titulo")
			dc.cmpTitulo.focus()
			return false
	}
	
	if(dc.cmpClassificados.value==""){
			alert("Preencha o campo Classificados")
			dc.cmpClassificados.focus()
			return false
	}
	
	if(dc.cmpDdd.value==""){
			alert("Preencha o campo DDD")
			dc.cmpDdd.focus()
			return false
	}
	
	if(dc.cmpTelefone.value==""){
			alert("Preencha o campo Telefone")
			dc.cmpTelefone.focus()
			return false
	}
	
	if(dc.cmpNome.value==""){
			alert("Preencha o campo Nome")
			dc.cmpNome.focus()
			return false
	}
	
	dc.submit()
}


function func_categorias(cmpCategorias){
	window.location="tend_lista.asp?cmpCategorias="+cmpCategorias
}

function func_murAlterar(){
	var dc = document.form1
	
	if(dc.cmpTitulo.value==""){
		alert("Preencha o campo Titulo!")
		dc.cmpTitulo.focus()
		return false
	}
	
	if(dc.cmpPergunta.value==""){
		alert("Preencha o campo Pergunta!")
		dc.cmpPergunta.focus()
		return false
	}
	
	dc.submit();
}


function func_meusAlterar(){
	var dc = document.form1
	
	if(dc.cmpNome.value==""){
		alert("Preencha o campo Nome!")
		dc.cmpNome.focus()
		return false
	}
	
	if(dc.cmpEmail.value==""){
		alert("Preencha o campo E-mail!")
		dc.cmpEmail.focus()
		return false
	}
	
	/*if(dc.cmpLoja.value==""){
		alert("Preencha o campo Loja!")
		dc.cmpLoja.focus()
		return false
	}*/
	
	if(dc.cmpDdd.value==""){
		alert("Preencha o campo DDD!")
		dc.cmpDdd.focus()
		return false
	}
	
	if(dc.cmpTelefone.value==""){
		alert("Preencha o campo Telefone!")
		dc.cmpTelefone.focus()
		return false
	}
	
	if(dc.cmpSenha.value==""){
		alert("Preencha o campo Senha!")
		dc.cmpSenha.focus()
		return false
	}
	
	if(dc.cmpConfirmeSenha.value==""){
		alert("Preencha o campo Redigite a senha!")
		dc.cmpConfirmeSenha.focus()
		return false
	}
	
	if(dc.cmpSenha.value != dc.cmpConfirmeSenha.value){
		alert("As senhas digitadas são diferentes!")
		dc.cmpSenha.focus()
		return false
	}
	
	if(dc.cmpEndereco.value == ""){
		alert("Preencha o campo Endereço!")
		dc.cmpEndereco.focus()
		return false
	}
	
	if(dc.cmpCidade.value == ""){
		alert("Preencha o campo Cidade!")
		dc.cmpCidade.focus()
		return false
	}
	
	if(dc.cmpUF.value == ""){
		alert("Selecione um estado!")
		dc.cmpEstado.focus()
		return false
	}
	
	dc.submit();
}

function func_validaComunicacao(){
	var dc = document.form1
	
	if(dc.solicitado.value==""){
		alert("Preecha o campo Nome do Shopping")
		dc.solicitado.focus()
		return false
	}

	if(dc.telefone.value==""){
		alert("Preecha o campo Telefone Loja")
		dc.telefone.focus()
		return false
	}
	
	if(dc.pecas_comunicacao.value==""){
		alert("Peça de comunicação a ser produzida")
		dc.pecas_comunicacao.focus()
		return false
	}

	if(dc.informacoes_comunicado.value==""){
		alert("Descreva as informações que devem ser inseridas na arte")
		dc.informacoes_comunicado.focus()
		return false
	}
	
	else{
		return true	
	}
}

function func_comunicacaoIncluir(){
	
	if(func_validaComunicacao()){
		var dc = document.form1
		dc.submit();
	}
}

function func_comunicaoAlterar(){
	var dc = document.form1
	dc.submit();	
}


function mostraCampoOutros(pecas_comunicacao){
	if(pecas_comunicacao=="Outros"){
		document.getElementById("abreCampo").style.display = '';
		document.getElementById("conf").style.display = 'none';
		document.getElementById("T_outros2").style.display = '';
		document.getElementById("T_spot").style.display = 'none';
		document.getElementById("T_tv").style.display = 'none';
		document.getElementById("TEMKT").style.display = 'none';
        document.getElementById("TQtde").style.display = 'none';
	}else if(pecas_comunicacao == "Spot para rádio"){
		document.getElementById("conf").style.display = 'none';
		document.getElementById("T_spot").style.display = '';
		document.getElementById("T_outros2").style.display = 'none';
		document.getElementById("abreCampo").style.display = 'none';
		document.getElementById("T_tv").style.display = 'none';
		document.getElementById("TEMKT").style.display = 'none';
        document.getElementById("TQtde").style.display = 'none';
	}else if(pecas_comunicacao == "Vídeo para TV"){
		document.getElementById("conf").style.display = 'none';
		document.getElementById("T_spot").style.display = 'none';
		document.getElementById("T_tv").style.display = '';
		document.getElementById("T_outros2").style.display = 'none';
		document.getElementById("abreCampo").style.display = 'none';
		document.getElementById("TEMKT").style.display = 'none';
        document.getElementById("TQtde").style.display = 'none';
	}else if(pecas_comunicacao == "E-mail"){
		document.getElementById("conf").style.display = 'none';
		document.getElementById("T_spot").style.display = 'none';
		document.getElementById("T_tv").style.display = 'none';
		document.getElementById("TEMKT").style.display = '';
		document.getElementById("T_outros2").style.display = 'none';
		document.getElementById("abreCampo").style.display = 'none';
        document.getElementById("TQtde").style.display = 'none';
	}else{
		if( (pecas_comunicacao == "Catalogo")||(pecas_comunicacao == "Bloquinho")||(pecas_comunicacao == "Adesivo")||(pecas_comunicacao == "Sacola") ){
		    document.getElementById("abreCampo").style.display = 'none';
	    	document.getElementById("T_spot").style.display = 'none';
    		document.getElementById("conf").style.display = 'none';
		    document.getElementById("T_outros2").style.display = 'none';
	    	document.getElementById("T_tv").style.display = 'none';
    		document.getElementById("TEMKT").style.display = 'none';
			document.getElementById("TQtde").style.display = '';
		}else{
    		document.getElementById("abreCampo").style.display = 'none';
	    	document.getElementById("T_spot").style.display = 'none';
		    document.getElementById("conf").style.display = '';
    		document.getElementById("T_outros2").style.display = 'none';
	    	document.getElementById("T_tv").style.display = 'none';
    		document.getElementById("TEMKT").style.display = 'none';
		}
	}
	//inicio TfornCentral abrirá para todos
	if((pecas_comunicacao != "E-mail" )&&(pecas_comunicacao != "Catalogo")&&(pecas_comunicacao != "Bloquinho")&&(pecas_comunicacao != "Adesivo")&&(pecas_comunicacao != "Sacola")){
	    document.getElementById("TfornCentral").style.display='';
	}else{
		document.getElementById("TfornCentral").style.display='none';
	}
	//fim
/*              <option value="Anúncio">An&uacute;ncio Conceito</option>
			  <option value="Catalogo">Catalogo</option>
			  <option value="Mala Direta">Mala Direta</option>
			  <option value="Postal">Postal</option>
			  <option value="Bloquinho">Bloquinho</option>
			  <option value="Adesivo">Adesivo de/para</option>
			  <option value="Flyers">Flyers</option>
			  <option value="Cartaz">Cartaz de Mall</option>
			  <option value="Outdoor">Outdoor</option>
			  <option value="E-mail">E-mail MKT</option>
			  <option value="Sacola">Sacola</option>
              <option value="Tapume">Tapume</option>
              <option value="Cartão">Cartão Aniversário</option>
              <option value="Spot para rádio">Spot para rádio</option>
              <option value="Vídeo para TV">Vídeo para TV</option>
			  Anúncio Conceito
Catálogo - 1.3
Mala Direta
Postal
Bloquinho - 1.3
Adesivo de/para - 1.3
Flyers
Cartaz de Mall
Outdoor
E-mail MKT - 1.2
Sacola - 1.3
Tapume
Cartão Aniversário
Spot para rádio
Vídeo para TV*/
			  
}

function func_abreCmp(cmpFornCentral){
	var peca = document.getElementById("pecas_comunicacao").value
	if(peca!="Spot para rádio"  && peca!="Vídeo para TV"){
		if(cmpFornCentral == "Sim"){
			document.getElementById("TQtde").style.display=''
		}
	}
	if(cmpFornCentral == "Não"){
		document.getElementById("TQtde").style.display='none'
	}
}

function fun_enviarSaf(){
	var dc = document.form1
	
	if(dc.cmpNome.value==""){
		alert("Preencha o campo Nome!")
		dc.cmpNome.focus()
		return false
	}

	if(dc.cmpAssunto.value==""){
		alert("Preencha o campo Assunto!")
		dc.cmpAssunto.focus()
		return false
	}
	
	if(dc.cmpDepartamento.value==""){
		alert("Preencha o campo Departamento!")
		dc.cmpDepartamento.focus()
		return false
	}
	
	if(dc.cmpTitulo.value==""){
		alert("Preencha o campo Titulo!")
		dc.cmpTitulo.focus()
		return false
	}
	
	if(dc.cmpMensagem.value==""){
		alert("Preencha o campo Mensagem!")
		dc.cmpMensagem.focus()
		return false
	}
	
	dc.submit()
	
}

function func_enviaForm(){
	document.formBusca.submit();
}


/* AJAX */

function getBrowser() {
if (window.XMLHttpRequest) { 
	a=new XMLHttpRequest(); } //Objeto nativo (FF/Safari/Opera7.6+)
else {
  try { 
	 a=new ActiveXObject("Msxml2.XMLHTTP");  //activeX (IE5.5+/MSXML2+)
  }   
  catch(e) {
	try { 
 a=new ActiveXObject("Microsoft.XMLHTTP"); //activeX (IE5+/MSXML1)
	}   
	catch(e) { /* O navegador nÃ£o tem suporte */ 
 a=false; 
	}
  }
} 
return a;
}

/* FUNCTIONS AJAX */
function func_mostraDownload(categoria){
	//alert(categoria)
	ajax = getBrowser();
	if(ajax){
		ajax.open("GET","/comunidade/func_ajax.asp?acao=mostraDownload&categoria="+categoria, true);
		ajax.onreadystatechange = function(){
			if(ajax.readyState != 4){
				document.getElementById("divID").innerHTML = "Carregando...";
			}
			if(ajax.readyState == 4){
				if(ajax.status == 200) {
					 document.getElementById("divID").innerHTML =  ajax.responseText;
       			} else {
					document.getElementById("divID").innerHTML = "Não encontrado!"
      			}
			}
		}
		ajax.send(null);
	}
}

function func_mostraTendencias(categoria){
	//alert(categoria)
	ajax = getBrowser();
	if(ajax){
		ajax.open("GET","/comunidade/func_ajax.asp?acao=mostraTendencias&categoria="+categoria, true);
		ajax.onreadystatechange = function(){
			if(ajax.readyState != 4){
				document.getElementById("divID").innerHTML = "Carregando...";
			}
			if(ajax.readyState == 4){
				if(ajax.status == 200) {
					 document.getElementById("divID").innerHTML =  ajax.responseText;
       			} else {
					document.getElementById("divID").innerHTML = "Não encontrado!"
      			}
			}
		}
		ajax.send(null);
	}
}


function func_mostraVitrine(categoria){
	//alert(categoria)
	ajax = getBrowser();
	if(ajax){
		ajax.open("GET","/comunidade/func_ajax.asp?acao=mostraVitrine&categoria="+categoria, true);
		ajax.onreadystatechange = function(){
			if(ajax.readyState != 4){
				document.getElementById("divID").innerHTML = "Carregando...";
			}
			if(ajax.readyState == 4){
				if(ajax.status == 200) {
					 document.getElementById("divID").innerHTML =  ajax.responseText;
       			} else {
					document.getElementById("divID").innerHTML = "Não encontrado!"
      			}
			}
		}
		ajax.send(null);
	}
}



function validaFrm(){
	if(document.frmEnvia.formaPagamento[0].checked == false  && document.frmEnvia.formaPagamento[1].checked == false){
		alert("Informe um prazo de pagamento")
		return false
	}else{
		return true	
	}

}

function func_frmEnvia(){
	if(document.frmEnvia.formaPagamento[0].checked == false  && document.frmEnvia.formaPagamento[1].checked == false){
		alert("Informe um prazo de pagamento")
		return false
	}else{
		document.frmEnvia.submit();
	}
}


