// fazer click para o menu
function metodoClick(id) {
	// pego o nome do navegador
	bname=navigator.appName;
	//executa o comando abaixo apenas se o navegador for o Netscape (FF). Se não fizer isso dará erro no IE.
	if (bname=="Netscape") {
		HTMLElement.prototype.click = function() {
			var evt = this.ownerDocument.createEvent('MouseEvents');
			evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
			this.dispatchEvent(evt);
		}
	}
	//faz o click no link alvo, o IE funciona apenas com essas duas linhas.
	var x = document.getElementById(id);
    x.click();
}

//formulário contato
function ValidaForm(form){
	email = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	var MsgTit = "Os seguintes campos precisam ser preenchidos corretamente\n";
	var MsgRod = "\n-------------------------------------------------------";
	Msg = "";

	if (form.nome.value == "") { Msg += "\n Nome;"; }
	if (!email.test(form.email.value)) {Msg += "\n Email formato inválido;";}
	if (form.empresa.value == "") { Msg += "\n Empresa;"; }
	if (form.ddd.value == "") { Msg += "\n DDD;"; }
	if (form.telefone_int.value == "") { Msg += "\n Telefone;"; }
	if (form.mensagem.value == "") { Msg += "\n Mensagem;"; }
	if (Msg != "") { alert (MsgTit + Msg + MsgRod); return false;
	} else { form.submit(); }
	return true;
	
}
function ValidaFormImplementacao(form){
	var email = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	var MsgTit = "Os seguintes campos precisam ser preenchidos corretamente\n";
	var MsgRod = "\n-------------------------------------------------------";
	Msg = "";
	
	myOption = -1;
	for (i=form.lojaVirtual.length-1; i > -1; i--) {
		if (form.lojaVirtual[i].checked) {
			myOption = i; i = -1;
		}
	}
	if (myOption == -1) {
		Msg += "\n Já tenho uma loja virtual e preciso de uma plataforma mais avançada ou Ainda não tenho uma loja virtual;";
	}

	if (form.nome_contato.value == "") { Msg += "\n Nome;"; }
	if (!email.test(form.email_contato.value)) {Msg += "\n Email formato inválido;";}
	if (form.razao_social.value == "") { Msg += "\n Razão Social;"; }
	if (form.cidade.value == "") { Msg += "\n Cidade;"; }
	if (form.estado.value == "") { Msg += "\n Estado;"; }
	if (form.ddd.value == "") { Msg += "\n DDD;"; }
	if (form.telefone_int.value == "") { Msg += "\n Telefone;"; }
	if (form.nome_fantasia.value == "") { Msg += "\n Nome Fantasia;"; }
	if (Msg != "") { alert (MsgTit + Msg + MsgRod); return false;
	} else { form.submit(); }
	return true;
	
}

function mostra(div) {
	document.getElementById('opcao1').style.display = "none";
	document.getElementById('opcao2').style.display = "none";
	document.getElementById(div).style.display = "";
	return false;
}

//formulário contrato
function verificaContrato(form) {
	email = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	var MsgTit = "Os seguintes campos precisam ser preenchidos corretamente\n";
	var MsgRod = "\n-------------------------------------------------------";
	Msg = "";

	if (form.nomecontato.value == "") { Msg += "\n Seu nome completo;"; }
	if (form.fonecontato.value == "") { Msg += "\n Seu telefone;"; }
	if (!email.test(form.emailcontato.value)) {Msg += "\n Email formato inválido;";}
	if (form.razaoempresa.value == "") { Msg += "\n Razão Social;"; }
	if (form.fantasiaempresa.value == "") { Msg += "\n Nome Fantasia;"; }
	if (form.cnpjempresa.value == "") { Msg += "\n CNPJ;"; }
	if (form.foneempresa.value == "") { Msg += "\n Telefone da empresa;"; }
	if (form.enderecocobranca.value == "") { Msg += "\n Endereço;"; }
	if (form.cidadecobranca.value == "") { Msg += "\n Cidade;"; }
	if (form.ufcobranca.value == "") { Msg += "\n Estado;"; }
	if (form.cepcobranca.value == "") { Msg += "\n CEP;"; }
	if (Msg != "") { alert (MsgTit + Msg + MsgRod); return false;
	} else { form.submit(); }
	return true;	
}

function abre( width, height ) {
		window.open('','bns_captador',
		"position=center,toolbar=no,location=no,directories=no,status=yes,width="+width+",height="+height+",menubar=no,scrollbars=no,resizable=no");
}

function mudarPagina(click_java) {
	if (click_java != "") {
		metodoClick(click_java);
	}
}

function divsContato(a) {	
	var divs = document.getElementById('principal').getElementsByTagName("div");
	for(indice = 0;indice <divs.length;indice++) {
		divs[indice].className = "off";
	}
	document.getElementById(a).className = "on";
}

function mascara(src, mask) {
//f = document.getElementById(form);
    var i = src.value.length;
    var saida = mask.substring(0,1);
    var texto = mask.substring(i)
    if (texto.substring(0,1) != saida) {
         src.value += texto.substring(0,1);
       }
}

/*----------------------------------------------------------------------------->
POP UP
-------------------------------------------------------------------------------> */
function AbrirJanela(szURL, bBarras, intWidth, intHeight, szWinName) {
	var szWinOpts;
	var left = (screen.width - intWidth)/2;
	var top = (screen.height - intHeight)/2;
	szWinOpts = "position=center,toolbar=no,location=no,directories=no,";
	if((intWidth==0) || (intHeight==0)) {
		szWinOpts = szWinOpts + "status=yes,";
	}
	else {
		szWinOpts = szWinOpts + "status=yes,width=" + intWidth + ",height=" + intHeight;
	}
	szWinOpts = szWinOpts + ",top="+top+",left="+left+",menubar=no,scrollbars=";
	if(bBarras) {
		szWinOpts = szWinOpts + "yes";
	}
	else {
		szWinOpts = szWinOpts + "no";
	}
	szWinOpts = szWinOpts + ",resizable=yes";
	window.open(szURL, szWinName, szWinOpts);
}
