function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function checkFieldsAvaliacao() {
missinginfo = "";
if (
		document.getElementById('1').checked == false &&
		document.getElementById('2').checked == false &&
		document.getElementById('3').checked == false
		){
		missinginfo += "\n     -  Selecione uma das opções";
}

if (missinginfo != "") {
missinginfo ="Os campos listados abaixo são obrigatórios:\n" +
missinginfo +
"\n\nFavor selecionar e clicar em \"Responder\"";
alert(missinginfo);
return false;
}
else return true;
}

function checkFieldsTreinamento() {
missinginfo = "";
if (document.treinamento.NomeCompleto.value == "") {
missinginfo += "\n     -  Nome Completo";
}

if (document.treinamento.EmpresaRevenda.value == "") {
missinginfo += "\n     -  Empresa/Revenda";
}

if (document.treinamento.Telefone.value == "") {
missinginfo += "\n     -  Telefone";
}

if ((document.treinamento.Email.value == "") ||
(document.treinamento.Email.value.indexOf('@') == -1) ||
(document.treinamento.Email.value.indexOf('.') == -1)) {
missinginfo += "\n     -  E-mail";
}

if (document.treinamento.Data.value == "") {
missinginfo += "\n     -  Data treinamento";
}
if (missinginfo != "") {
missinginfo ="Os campos listados abaixo são obrigatórios:\n" +
missinginfo +
"\n\nFavor preencher e clicar em \"Enviar\"";
alert(missinginfo);
return false;
}
else return true;
}

function checkFieldsModTreinamento() {
	missinginfo = "";
	if (document.inscricao.empresa.value == "") {
		missinginfo += "\n     -  Empresa";
	}
	if (document.inscricao.cnpj.value == "") {
		missinginfo += "\n     -  CNPJ";
	}
	if (document.inscricao.ie.value == "") {
		missinginfo += "\n     -  IE";
	}
	if (document.inscricao.endereco.value == "") {
		missinginfo += "\n     -  Endereço";
	}
	if (document.inscricao.cidade.value == "") {
		missinginfo += "\n     -  Cidade";
	}
	if (document.inscricao.cep.value == "") {
		missinginfo += "\n     -  CEP";
	}
	if (document.inscricao.participante.value == "") {
		missinginfo += "\n     -  Nome Participante";
	}
	if (document.inscricao.email.value == "") {
		missinginfo += "\n     -  E-mail";
	}
	if (document.inscricao.telefones.value == "") {
		missinginfo += "\n     -  Telefones";
	}
	if (missinginfo != "") {
		missinginfo = "Os campos listados abaixo são obrigatórios:\n" +
		missinginfo + "\n\nFavor preencher e clicar em 'Inscrever-se'";
		alert(missinginfo);
		return false;
	} else {
		return true;
	}
}

function checkFieldsServicos() {
missinginfo = "";
if (document.servicos.Empresa.value == "") {
missinginfo += "\n     -  Empresa";
}

if (document.servicos.CNPJ.value == "") {
missinginfo += "\n     -  CNPJ";
}

if (document.servicos.Endereco.value == "") {
missinginfo += "\n     -  Endereço de Faturamento";
}
if (document.servicos.Cidade.value == "") {
missinginfo += "\n     -  Cidade";
}

if (document.servicos.telefone.value == "") {
missinginfo += "\n     -  Telefone";
}
if ((document.servicos.Email.value == "") ||
(document.servicos.Email.value.indexOf('@') == -1) ||
(document.servicos.Email.value.indexOf('.') == -1)) {
missinginfo += "\n     -  E-mail";
}


if (missinginfo != "") {
missinginfo ="Os campos listados abaixo são obrigatórios:\n" +
missinginfo +
"\n\nFavor preencher e clicar em \"Enviar\"";
alert(missinginfo);
return false;
}
else return true;
}

function checkFieldsAreaTestes() {
missinginfo = "";
if (document.areatestes.Nome.value == "") {
missinginfo += "\n     -  Nome";
}

if (document.areatestes.Sobrenome.value == "") {
missinginfo += "\n     -  Sobrenome";
}

if (document.areatestes.Empresa.value == "") {
missinginfo += "\n     -  Empresa";
}

if (document.areatestes.Telefone.value == "") {
missinginfo += "\n     -  Telefone";
}

if ((document.areatestes.Email.value == "") ||
(document.areatestes.Email.value.indexOf('@') == -1) ||
(document.areatestes.Email.value.indexOf('.') == -1)) {
missinginfo += "\n     -  E-mail";
}

if (missinginfo != "") {
missinginfo ="Os campos listados abaixo são obrigatórios:\n" +
missinginfo +
"\n\nFavor preencher e clicar em \"Enviar\"";
alert(missinginfo);
return false;
}
else return true;
}

function checkFieldsProdutos() {
missinginfo = "";

if (document.produtos.empresa.value == "") {
missinginfo += "\n     -  Empresa";
}

if (document.produtos.contato.value == "") {
missinginfo += "\n     -  Contato";
}

if (document.produtos.telefone.value == "") {
missinginfo += "\n     -  Telefone";
}

if ((document.produtos.email.value == "") ||
(document.produtos.email.value.indexOf('@') == -1) ||
(document.produtos.email.value.indexOf('.') == -1)) {
missinginfo += "\n     -  E-mail";
}

if (document.produtos.modelocentral.value == "") {
missinginfo += "\n     -  Modelo/marca da central PABX ";
}

if (document.produtos.qtderamais.value == "") {
missinginfo += "\n     -  Quantidade de ramais";
}

if (document.produtos.qtdecentrais.value == "") {
missinginfo += "\n     -  Quantidade de centrais a serem tarifadas";
}

if (document.produtos.tipobilhetagem.value == "") {
missinginfo += "\n     -  Tipo de saída de bilhetagem";
}

if (missinginfo != "") {
missinginfo ="Os campos listados abaixo são obrigatórios:\n" +
missinginfo +
"\n\nFavor preencher e clicar em \"Enviar\"";
alert(missinginfo);
return false;
}
else return true;
}

function checkFieldsCadastro() {
	missinginfo = "";

	if (document.customCad.firstname.value == "") {
		missinginfo += "\n     -  Nome";
	}
	if (document.customCad.lastname.value == "") {
		missinginfo += "\n     -  Sobrenome";
	}
	if ((document.customCad.email.value == "") || (document.customCad.email.value.indexOf('@') == -1) ||  (document.customCad.email.value.indexOf('.') == -1)) {
		missinginfo += "\n     -  E-mail";
	}
	if (document.customCad.user.value == "") {
		missinginfo += "\n     -  Usuário";
	}
	if (document.customCad.pwd1.value == "" || document.customCad.pwd2.value == "") {
		missinginfo += "\n     -  Ambas as senhas devem ser preenchidas";
	} else if (document.customCad.pwd1.value != document.customCad.pwd2.value){
		missinginfo += "\n     -  As senhas informadas não são iguais";
	}
	if (document.customCad.custom4.value == "") {
		missinginfo += "\n     -  Empresa";
	}
	if (document.customCad.occupation.value == "") {
		missinginfo += "\n     -  Cargo";
	}
	if (document.customCad.address.value == "") {
		missinginfo += "\n     -  Endereço";
	}
	if (document.customCad.city.value == "") {
		missinginfo += "\n     -  Cidade";
	}
	if (document.customCad.postal.value == "") {
		missinginfo += "\n     -  CEP";
	}
	if (document.customCad.custom2.value == "") {
		missinginfo += "\n     -  País";
	}
	if (missinginfo != "") {
		missinginfo ="Os campos listados abaixo são obrigatórios:\n" +
		missinginfo +
		"\n\nFavor preencher e clicar em \"Cadastrar\"";
		alert(missinginfo);
		return false;
	}
		else return true;
	}

function CheckStatus(){
	if(document.getElementById('newsletter').checked==true){
		document.getElementById('interesses').style.display='none';
	} else {
		document.getElementById('interesses').style.display='block';
	}

}

/***
* Descrição.: formata um campo do formulário de
* acordo com a máscara informada...
* Parâmetros: - objForm (o Objeto Form)
* - strField (string contendo o nome
* do textbox)
* - sMask (mascara que define o
* formato que o dado será apresentado,
* usando o algarismo "9" para
* definir números e o símbolo "!" para
* qualquer caracter...
* - evtKeyPress (evento)
* Uso.......: <input type="textbox"
* name="xxx".....
* onkeypress="return txtBoxFormat(document.rcfDownload, 'str_cep', '99999-999', event);">
* Observação: As máscaras podem ser representadas como os exemplos abaixo:
* CEP -> 99.999-999
* CPF -> 999.999.999-99
* CNPJ -> 99.999.999/9999-99
* Data -> 99/99/9999
* Tel Resid -> (99) 999-9999
* Tel Cel -> (99) 9999-9999
* Processo -> 99.999999999/999-99
* C/C -> 999999-!
* E por aí vai...
***/

function txtBoxFormat(objForm, strField, sMask, evtKeyPress) {
	var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;
	//dumpObject(evtKeyPress.keyCode);
	if(document.all) { // Internet Explorer
		var nTecla = evtKeyPress.keyCode; }
	else if(document.layers) { // Nestcape
		var nTecla = evtKeyPress.wich;
	}

	//alert(nTecla);
	objForm[strField].maxLength=sMask.length;
	sValue = objForm[strField].value;

	// Limpa todos os caracteres de formatação que
	// já estiverem no campo.
	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;

	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;

	if (nTecla != 8) { // backspace
		if (sMask.charAt(i-1) == "9") { // apenas números...
			return ((nTecla > 47) && (nTecla < 58)); } // números de 0 a 9
		else { // qualquer caracter...
			return true;
		}
	} else {
		return true;
	}
}

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{	// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 	// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();
