// JavaScript Document
/*  */
urlSite = "http://www.ctsinformatica.com.br/espanol";

//armazena sempre qual objeto foi clicado
eventoClique = null;

var mouseNoDivGeral = false;

var ie = /msie/i.test(navigator.userAgent);
var ieBox = ie && (document.compatMode == null || document.compatMode == "BackCompat");
var canvasEl = ieBox ? document.body : document.documentElement;

//resolucao do pc
var wRes = screen.width; 
var hRes = screen.height;

//área da pagina no browser
var wTela = canvasEl.clientWidth || window.innerWidth;
var hTela = canvasEl.clientHeight || window.innerHeight;
/*
alert("wRes: " + wRes + "   <>   hRes:" + hRes + "\n\nwTela: " + wTela + "   <>   hTela:" + hTela);
*/

//controle do menu
var itemMenuId = null;

//controla as abas
var posicaoNormalAbas = true;
var abaId = 0;

//controle dos checkBox
var totalChecks = 12;
var arrChecked = new Array();

//controla quais interesses foram selecionados
/*
0 - nenhum
1 - fono
2 - fisio
3 - fono e fisio
*/
interesseId = 0;

/** 
nomes produtos 
AudiReport
FonoView
Avalie
Pedro na Casa Mal-Assom
Desafio dos Fonemas
VoiceReport
FisiMetrix
VoxGames
FonoFlex
VoxMetria
FonoSpeak
FonoTools
*/

var arrProdutos = new Array();
arrProdutos[0] = "AudiReport";
arrProdutos[1] = "FonoView";
arrProdutos[2] = "Avalie";
arrProdutos[3] = "Pedro na Casa Mal-Assombrada";
arrProdutos[4] = "Desafio dos Fonemas";
arrProdutos[5] = "VoiceReport";
arrProdutos[6] = "FonoTools";
arrProdutos[7] = "VoxGames";
arrProdutos[8] = "FonoFlex";
arrProdutos[9] = "VoxMetria";
arrProdutos[10] = "FonoSpeak";
arrProdutos[11] = "FisiMetrix";
arrProdutos[12] = "EarMix";

var arrProdFono = new Array();
arrProdFono[0] = "AudiReport";
arrProdFono[1] = "FonoView";
arrProdFono[2] = "Avalie";
arrProdFono[3] = "Pedro na Casa Mal-Assombrada";
arrProdFono[4] = "Desafio dos Fonemas";
arrProdFono[5] = "VoiceReport";
arrProdFono[6] = "FonoTools";
arrProdFono[7] = "VoxGames";
arrProdFono[8] = "FonoFlex";
arrProdFono[9] = "VoxMetria";
arrProdFono[10] = "FonoSpeak";
arrProdFono[11] = "EarMix";

var arrProdFisio = new Array();
arrProdFisio[0] = "FisiMetrix";

/*
produtos e categorias de fonoaudiologia
10 -> 0 - FonoSpeak
9  -> 4 - Pedro
8  -> 4 - AudiReport
7  -> 1 - VoxGames
6  -> 0 - Avalie
5  -> 1 - VoxMetria
4  -> 3 - FonoFlex
3  -> 2 - FonoTools
2  -> 1 - FonoView
1  -> 1 - VoiceReport
0  -> 0 - DesafioFonemas


0 - fala e linguagem
1 - voz
2 - distúrbios da comunicação
3 - leitura e escrita
4 - audio e pa
5 - motricidade
*/

fonoCategorias = new Array();
fonoCategorias[0] = new Array("0", "6", "10");
fonoCategorias[1] = new Array("1", "2", "5", "7");
fonoCategorias[2] = new Array("3");
fonoCategorias[3] = new Array("4");
fonoCategorias[4] = new Array("8", "9");
fonoCategorias[5] = new Array();

totalProdFono = 0;
for(i=0;i<fonoCategorias.length;i++) {
	totalProdFono += fonoCategorias[i].length;
}

/*
arrProdutos[0] = "AudiReport";
arrProdutos[1] = "FonoView";
arrProdutos[2] = "Avalie";
arrProdutos[3] = "Pedro na Casa Mal-Assombrada";
arrProdutos[4] = "Desafio dos Fonemas";
arrProdutos[5] = "VoiceReport";
arrProdutos[6] = "FonoTools";
arrProdutos[7] = "VoxGames";
arrProdutos[8] = "FonoFlex";
arrProdutos[9] = "VoxMetria";
arrProdutos[10] = "FonoSpeak";
arrProdutos[11] = "FisiMetrix";
*/
arrAtualizacoes = new Array();
arrAtualizacoes[0] = new Array("4");
arrAtualizacoes[1] = new Array("3");
arrAtualizacoes[2] = new Array("12", "11", "10");
arrAtualizacoes[3] = new Array("2");
arrAtualizacoes[4] = new Array("1");
arrAtualizacoes[5] = new Array();
arrAtualizacoes[6] = new Array("5");
arrAtualizacoes[7] = new Array("6");
arrAtualizacoes[8] = new Array("7", "15");
arrAtualizacoes[9] = new Array("9", "8");
arrAtualizacoes[10] = new Array("14", "13");
arrAtualizacoes[11] = new Array("16");
arrAtualizacoes[12] = new Array();

totalAtualizacoes = 0;
for(i=0;i<arrAtualizacoes.length;i++) {
	if(arrAtualizacoes[i].length>0) {
		totalAtualizacoes += arrAtualizacoes[i].length;
	} else {
		arrAtualizacoes[i];
	}	
}

/*
PRODUTOID
NOME
CATEGORIA
PROMOCAO
DOWNLOAD
VALOR1
VALOR2
VALOR3
VALOR4
*/

//BANCO DE COMPRA DE PRODUTOS
arrConfigProdutos = new Array();

baseCts = null;

novoCodProduto = null;
novaAba = null;

//anti spam em botoes
var primeiroClique = true;

//controle das ancoras das paginas
var ancora = null;

/** LISTA DE DOWNLOADS
eventoId - id - download
----------------//----------------//----------------
pagina de downloads

tdDown0 -  0 - Documento com Descrição dos Produtos (e-Folders)
tdDown1 -  1 - Dicas para o VoxMetria
tdDown2 -  2 - Dicas para o FonoView 
tdDown3 -  3 - Versão do VoxGames válida por 7 dias
tdDown4 -  4 - Versão do VoxMetria válida por 7 dias
tdDown5 -  5 - Versão do AudiReport válida por 15 dias
tdDown6 -  6 - Versão do FonoView válida por 7 dias
tdDown7 -  7 - Demonstrativo do FisiMetrix

----------------//----------------//----------------
pagina de atualizacoes

tabProduto8  - 8  - VoxMetria 2.8
tabProduto15 - 9  - FonoFlex 1.1
tabProduto16 - 10 - FisiMetrix 1.3

*/

function carregarSite(codProduto, aba) {
	initialize();
	//document.navigator.history = new Array();
	var itemMenuId = null;	
	//baseCts = carregarXML("basects/baseCts.xml");
	//baseFrete = carregarXML("basects/baseFrete.xml");
	mostrarAviso("cargando...", "corpo");
	if(codProduto!=null) {
		if(codProduto=="") {
			novoCodProduto = -1;
		} else {
			novoCodProduto = codProduto;
		}		
	} else {
		novoCodProduto = -1;
	}
	if(aba!=null) {
		novaAba = aba;	
	}
	
	switch(Number(novoCodProduto)) {
		case 0: {
			novaUrl = "audiReport.html";					
			break;
		}
		case 1: {
			novaUrl = "fonoView.html";					
			break;
		}
		case 2: {
			novaUrl = "avalie.html";					
			break;
		}
		case 3: {
			novaUrl = "pedroNaCasa.html";					
			break;
		}
		case 4: {
			novaUrl = "desafioFonemas.html";					
			break;
		}
		case 5: {
			novaUrl = "voiceReport.html";					
			break;
		}
		case 6: {
			novaUrl = "fonoTools.html";					
			break;
		}
		case 7: {
			novaUrl = "voxGames.html";					
			break;
		}
		case 8: {
			novaUrl = "fonoFlex.html";					
			break;
		}
		case 9: {
			novaUrl = "voxMetria.html";					
			break;
		}
		case 10: {
			novaUrl = "fonospeak.html";					
			break;
		}
		case 11: {
			novaUrl = "fisiMetrix.html";					
			break;
		}
		case 12: {
			novaUrl = "earMix.html";					
			break;
		}
		default: {
			novaUrl = -1;	
		}
	}
	
	if(novaUrl!=-1 && novaUrl!=null && String(novaUrl).length>4) {			
		if(novaAba!=null) {								
			carregaPagina(novaUrl + "{paginaProduto!" + novoCodProduto + "&" + novaAba);
			//alert("oi");
		} else {
			carregaPagina(novaUrl);
		}
	} else {
		if(window.location.hash == "" || window.location == urlSite + "/#") {
			carregaPagina("home.html");	
		} else {
			if(!ie) {			
				document.getElementById("corpo").innerHTML = tempHTML2;			
			}
		}
	}
	//carregaPagina("home.html");
	ajustarTela();
}

function deletarComponente(componente) {
	if(document.getElementById(componente)!=null) {
		var componente = document.getElementById(componente);
	}
	componente.parentNode.removeChild(componente);
}

function ajustarTela() {
	getAtributosTela();
	document.getElementById("tabMenu").style.height = hTela-145 + "px";	
}

function addEvento(objeto, evType, funcao, useCapture) {
	try {
		if(objeto.addEventListener) {
			objeto.addEventListener(evType, funcao, useCapture);
		} else if(objeto.attachEvent) {
			objeto.attachEvent("on" + evType, funcao);
		}
	} catch(e) {
		alert("Erro: " + e.message);	
	}
}

function getAtributosTela() {
	//resolucao do pc
	wRes = screen.width; 
	hRes = screen.height;
	
	//área da pagina no browser
	wTela = canvasEl.clientWidth || window.innerWidth;
	hTela = canvasEl.clientHeight || window.innerHeight;	
}

function no() {
}

function $(id){return document.getElementById(id);}

function $tag(tag){return document.getElementsByTagName(tag);}

function random(algs){return Math.random().toString().replace(/(\.|0)/g, "").substr(0, algs)}

function arredondar(valor, casas) {
	var novo = Math.round(valor*Math.pow(10,casas))/Math.pow(10,casas);
   	return(novo);
}

function itemMenuClicar(cod) {
	fecharDiv();
	primeiroClique = true;
	if(cod!=itemMenuId || cod==2) {
		marcarMenu(cod);
		switch(cod) {
			case 0: {
				carregaPagina("home.html");
				break;
			}
			case 1: {
				carregaPagina("empresa.html");
				break;
			}
			case 2: {
				carregaPagina("produtos.html");			
				break;
			}
			case 3: {
				carregaPagina("cadastro.html");
				break;
			}
			case 4: {
				carregaPagina("representantes.html");			
				break;
			}
			case 5: {
				carregaPagina("contato.html");
				break;
			}
		}
		itemMenuId = cod;		
	}
}

function desmarcarMenu(limparVar) {
	for(i=0;i<12;i++) {
		if(document.getElementById("mnu"+i)!=null)
			document.getElementById("mnu"+i).className = "tdMenuItem";
	}
	if(limparVar)
		itemMenuId = null;
}

function marcarMenu(cod) {
	desmarcarMenu();
	if(itemMenuId!=null && cod>0) {
		if(cod==2) {
			document.getElementById("mnu"+cod).className = "marcarTd2";
		} else {
			document.getElementById("mnu"+cod).className = "marcarTd";
		}
	}
}

function mouseSobreMenu(cod) {
	if(itemMenuId!=cod) {
		document.getElementById("mnu"+cod).className = "mouseSobreTd";
	} else {
		if(cod==3 || cod==4 || cod==7 || cod==10 || cod==6) {
			document.getElementById("mnu"+cod).className = "marcarTd2";
		} else {
			document.getElementById("mnu"+cod).className = "marcarTd";
		}
	}	
}

function mouseSaiForaMenu(cod) {
	if(itemMenuId!=cod) {
		document.getElementById("mnu"+cod).className = "tdMenuItem";
	} else {
		if(cod==3 || cod==4 || cod==7 || cod==10 || cod==6) {
			document.getElementById("mnu"+cod).className = "marcarTd2";
		} else {
			document.getElementById("mnu"+cod).className = "marcarTd";
		}
	}
}

function selItemPainel(cod) {
	document.getElementById(cod).className = "itemPainelSel";
}

function desSelItemPainel(cod) {
	document.getElementById(cod).className = "itemPainel";
}

function selLinguagem(linguagemId) {
	/*
		0 - português
		1 - inglês
		2 - espanhol	
	*/
	switch(linguagemId) {
		case 1: {
			alert("IE? " + ie);
		}		
	}	
}

function carregaImagem(imgSrc, alvo) {
	document.getElementById(alvo).src = imgSrc;
}

function fecharDiv() {
	document.getElementById("divGeral").style.visibility = "hidden";
	document.getElementById("telaEscura").className = "invisivel";
	document.getElementById("swfCabecalho").style.visibility = "visible";
	document.onkeypress = null;

	document.getElementsByTagName("html")[0].className = null;
}

function mostraTelaEscura() {
	
	posY = ((document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop);
	
	document.getElementById("telaEscura").className = "telaEscura1";
	document.getElementById("telaEscura").style.top = posY + "px";
	document.getElementById("telaEscura").style.left = "0px";
	document.getElementById("telaEscura").style.width = wRes + "px";
	document.getElementById("telaEscura").style.height = hRes + "px";
	document.getElementById("swfCabecalho").style.visibility = "hidden";			
	document.onkeypress = rejeitaTeclas;
	
	document.getElementsByTagName("html")[0].className = "bodyEscuro";
	scrollTo(0, posY);
}

function rejeitaTeclas(oEvent) {    

    var keyF5=116; //tecla que quer bloquear. 116 é o código da tecla F5
	var keyPageUp=33;
	var keyPageDown=34;
	var keySpace=0;

    //filtrando o evento
    var oEvent = oEvent ? oEvent : window.event;
    var tecla = (oEvent.keyCode) ? oEvent.keyCode : oEvent.which;
    
    if(oEvent.type=="keydown" && navigator.appName.indexOf('Internet Explorer')<0 ){
        //se for keydown e não for o IE, vazarei pois o keypress já foi executado
        return false;
    }    
    if(typeof(oEvent.keyCode)=='number' && oEvent.keyCode==keyF5 && oEvent.keyCode==keyPageUp && oEvent.keyCode==keyPageDown && oEvent.keyCode==keySpace) {
        if (typeof(oEvent.preventDefault)=='function'){
            oEvent.preventDefault();
        } else {
            oEvent.returnValue = false;
            oEvent.keyCode = 0;
        }
    }
    return false;
}

function testaMouse1() {
	mouseNoDivGeral = true;
}

function testaMouse2() {
	mouseNoDivGeral = false;
}	

function ampliarImagem(fonte, titulo, wImg, hImg) {	

	mostraTelaEscura();
	if(wImg=="" || wImg==null)
		wImg = 400;
	if(hImg=="" || hImg==null)
		hImg = 300;

	url = ('popImgAmpliada.html*' + titulo + "&" + fonte.src  + "&" + wImg  + "&" + hImg);
	carregarPaginaDadosEm(url, 'divGeral');
	
	document.getElementById("divGeral").className = "divGeralOn";	
	document.getElementById("divGeral").style.left = Math.floor(wTela/2 - 500/2) + "px";
	yTopo = ((document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop);
	document.getElementById("divGeral").style.top = (yTopo+Math.floor(hTela/2)-(400/2)) + "px";
	document.getElementById("divGeral").style.visibility = "visible";
}

function avancaImagem(produto) {
	switch(produto) {
		case "pedro2": {
			if(pedroImagens[0]<pedroImagens.length-1) {
				pedroImagens[0]++;
			} else {
				pedroImagens[0] = 1;	
			}
			carregaImagem(pedroImagens[pedroImagens[0]], "imgpedro2");
			document.getElementById("txtNroImg0").innerHTML = (pedroImagens[0]) + " de " + (pedroImagens.length-1);
			break;
		}
		case "earmix": {
			if(earmixImagens[0]<earmixImagens.length-1) {
				earmixImagens[0]++;
			} else {
				earmixImagens[0] = 1;	
			}
			carregaImagem(earmixImagens[earmixImagens[0]], "imgearmix");
			document.getElementById("txtNroImg1").innerHTML = (earmixImagens[0]) + " de " + (earmixImagens.length-1);
			break;
		}
	}
	
}

function voltaImagem(produto) {
	switch(produto) {
		case "pedro2": {
			if(pedroImagens[0]>1) {
				pedroImagens[0]--;
			} else {
				pedroImagens[0] = pedroImagens.length-1;	
			}
			carregaImagem(pedroImagens[pedroImagens[0]], "imgpedro2");
			document.getElementById("txtNroImg0").innerHTML = (pedroImagens[0]) + " de " + (pedroImagens.length-1);
			break;
		}
		case "earmix": {
			if(earmixImagens[0]>1) {
				earmixImagens[0]--;
			} else {
				earmixImagens[0] = earmixImagens.length-1;	
			}
			carregaImagem(earmixImagens[earmixImagens[0]], "imgearmix");
			document.getElementById("txtNroImg1").innerHTML = (earmixImagens[0]) + " de " + (earmixImagens.length-1);
			break;
		}
	}	
}

function trocaCSS(cod, classe) {
	document.getElementById(cod).className = classe;
}

function mouseSobre(cod, classe) {
	document.getElementById(cod).className = classe;
}

function mouseFora(cod, classe) {
	document.getElementById(cod).className = classe;
}

function abaClicar(cod) {
	tempL = document.getElementById("aba" + cod).parentNode.id;
	tempL = tempL.substring(5, tempL.length);
	
	if(tempL!="" && tempL!=null) {
		tempC = document.getElementById("abas" + tempL).parentNode.id;
		tempC = tempC.substring(9, tempC.length);
	} else {
		alert("bug");	
	}
	if(tempC==1) {
		alternaAbas();
	}
	marcarAba(cod);
	//carregarProdutos(cod);
	abaId = cod;
}

function marcarAba(cod) {
	//if(abaId!=null) {
		if(document.getElementById("aba"+abaId)!=null) {
			document.getElementById("aba"+abaId).className = "abaNormal";
		}
		if(cod>-1) {
			document.getElementById("aba"+cod).className = "abaSelecionada";			
		}
	//}	
}

function mouseSobreAba(cod) {
	if(abaId!=cod) {
		document.getElementById("aba"+cod).className = "abaSobre";
	} else {
		document.getElementById("aba"+cod).className = "abaSelecionada";
	}	
}

function mouseForaAba(cod) {
	if(abaId!=cod) {
		document.getElementById("aba"+cod).className = "abaNormal";
	} else {
		document.getElementById("aba"+cod).className = "abaSelecionada";
	}
}

function alternaAbas() {
	tempHTML = document.getElementById("lugarAbas0").innerHTML;
	document.getElementById("lugarAbas0").innerHTML = document.getElementById("lugarAbas1").innerHTML;
	document.getElementById("lugarAbas1").innerHTML = tempHTML;
	
	posicaoNormalAbas = !posicaoNormalAbas;
}

function marcarCheck(cod) {
	if(cod.substring(0,4)=="quad") {
		cod = cod.substring(4, cod.length);
	} 
	
	prodId = cod.substring(3, cod.length);
	if(document.getElementById(cod).className!="btnCheckBoxSel") {
		document.getElementById(cod).className = "btnCheckBoxSel";
		document.getElementById("quad" + cod).className = "quadCheckBoxSel";
		arrChecked.push(prodId);
	} else {
		document.getElementById(cod).className = "btnCheckBox";

		document.getElementById("quad" + cod).className = "quadCheckBox";
		arrChecked.removerItem(prodId);
	}
	validaCheck(arrChecked, "Produto");
}

function mouseSobreCheck(cod) {
	if(cod.substring(0,4)=="quad") {
		cod = cod.substring(4, cod.length);
	} 
	
	if(document.getElementById(cod).className!="btnCheckBoxSel") {
		document.getElementById(cod).className = "btnCheckBoxSobre";
	} else {
		document.getElementById(cod).className = "btnCheckBoxSel";
	}	
}

function mouseForaCheck(cod) {
	if(cod.substring(0,4)=="quad") {
		cod = cod.substring(4, cod.length);
	} 
	
	if(document.getElementById(cod).className!="btnCheckBoxSel") {
		document.getElementById(cod).className = "btnCheckBox";
	} else {
		document.getElementById(cod).className = "btnCheckBoxSel";
	}
}

function marcarCheckInter(cod) {
	if(cod.substring(0,4)=="quad") {
		cod = cod.substring(4, cod.length);
	}
	if(cod=="chkFono") {
		catId = 1;
	} else if("chkFisio") {
		catId = 2;
	}
	if(document.getElementById(cod).className!="btnCheckBoxSel") {
		document.getElementById(cod).className = "btnCheckBoxSel";
		document.getElementById("quad" + cod).className = "quadCheckBoxSel";
		interesseId = Number(interesseId) + Number(catId);
		
	} else {
		document.getElementById(cod).className = "btnCheckBox";
		document.getElementById("quad" + cod).className = "quadCheckBox";
		interesseId = Number(interesseId) - Number(catId);
	}	
	//montaCheckProd(interesseId, "tdProdutos");
	montaCheckProd2(interesseId, "marcarCheckProd", "tdProdutos");
}


function marcarCheckProd(cod) {
	if(cod.substring(0,4)=="quad") {
		cod = cod.substring(4, cod.length);
	}
	prodId = cod.substring(3, cod.length);
	if(document.getElementById(cod).className!="btnCheckBoxSel") {
		document.getElementById(cod).className = "btnCheckBoxSel";
		document.getElementById("quad" + cod).className = "quadCheckBoxSel";
		arrChecked.push(prodId);
	} else {
		document.getElementById(cod).className = "btnCheckBox";
		document.getElementById("quad" + cod).className = "quadCheckBox";
		arrChecked.removerItem(prodId);
	}
}

function marcarCheckAtual(cod) {
	if(cod.substring(0,4)=="quad") {
		cod = cod.substring(4, cod.length);
	}
	prodId = cod.substring(3, cod.length);
	if(document.getElementById(cod).className!="btnCheckBoxSel") {
		document.getElementById(cod).className = "btnCheckBoxSel";
		document.getElementById("quad" + cod).className = "quadCheckBoxSel";
		arrChecked.push(prodId);
	} else {
		document.getElementById(cod).className = "btnCheckBox";
		document.getElementById("quad" + cod).className = "quadCheckBox";
		arrChecked.removerItem(prodId);
	}	
	arrProdAtualSel	= new Array();
	for(i=0;i<arrChecked.length;i++) {
		for(i2=0;i2<arrAtualizacoes[arrChecked[i]].length;i2++) {
			arrProdAtualSel.push(arrAtualizacoes[arrChecked[i]][i2]);
		}
	}
	
	if(arrProdAtualSel.length>0) {
		document.getElementById("tabVisualizar").className = "tabVisivel";	
		document.getElementById("tabAviso").className = "tabInvisivel";
	} else {		
		document.getElementById("tabVisualizar").className = "tabInvisivel";
		if(arrChecked.length>0) {
			document.getElementById("tabAviso").className = "tabVisivel";
		} else {
			document.getElementById("tabAviso").className = "tabInvisivel";
		}
	}
}

function mostrarAtualizacoes() {
	mostrarCheck(false);
	carregarAtualizacoes(arrProdAtualSel);	
}

function mostrarCheck(okMostrar) {
	if(okMostrar) {
		document.getElementById("tabCheckProd").className = "tabVisivel";
		document.getElementById("tabListaAtual").className = "tabInvisivel";
	} else {
		document.getElementById("tabCheckProd").className = "tabInvisivel";
		document.getElementById("tabListaAtual").className = "tabVisivel";
	}
}

function validaCampo(nomeValor) {
	if(retirarEspacos(document.getElementById("txt" + nomeValor).value)=="") {
		document.getElementById("td" + nomeValor).className = "compFormContainerErro";
		document.getElementById("tdErro" + nomeValor).className = "tdAsteriscoErro";
		return false;
	} else {
		document.getElementById("td" + nomeValor).className = "compFormContainer";
		document.getElementById("tdErro" + nomeValor).className = "tdAsteriscoOk";
		return true;
	}	
}

function validaCEP(campoValor, campoErro) {
	if(document.getElementById(campoValor).value.length!=9) {
		document.getElementById(campoValor).parentNode.className = "compFormContainerErro";
		document.getElementById(campoErro).className = "tdAsteriscoErro";
		return false;
	} else {
		document.getElementById(campoValor).parentNode.className = "compFormContainer";
		document.getElementById(campoErro).className = "tdAsteriscoOk";		
		return true;
	}
}

function mascara(e, src, mask) {
    if(window.event) { 
		_TXT = e.keyCode; 
	} else if(e.which) { 
		_TXT = e.which; 
	}
    if(_TXT > 47 && _TXT < 58) {
 		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); 
		}
		return true; 
	} else { 
		if (_TXT != 8) { 
			return false; 
		} else { 
			return true; 
		}
    }
}

function retirarEspacos(texto) {
	texto = texto.replace(/ /gi, "");	
	return texto;
}

function validaEmail(nomeEmail) {
	document.getElementById("txt" + nomeEmail).value = retirarEspacos(document.getElementById("txt" + nomeEmail).value);
	email = document.getElementById("txt" + nomeEmail).value;
	
	if(email=="" || email.indexOf("@.")!=-1 || email.substring(email.lastIndexOf(".")+1, email.length)<1) {
		ok = false;
	} else {		
		if(email.indexOf("@")!=-1 && email.indexOf("@")==email.lastIndexOf("@")) {
			if(email.lastIndexOf("@")<email.lastIndexOf(".")-1) {
				if(email.substring(0, email.lastIndexOf("@")).length>0) {
					ok = true;
				} else {
					ok = false;	
				}
			} else {
				ok = false;
			}
		} else {
			ok = false;
		}
	}
	if(ok) {
		document.getElementById("td" + nomeEmail).className = "compFormContainer";
		document.getElementById("tdErro" + nomeEmail).className = "tdAsteriscoOk";
		return true;
	} else {
		document.getElementById("td" + nomeEmail).className = "compFormContainerErro";
		document.getElementById("tdErro" + nomeEmail).className = "tdAsteriscoErro";
		return false;
	}
}

function validaCheck(varArray, nomeValor) {
	if(varArray.length==0) {
		document.getElementById("td" + nomeValor).className = "compFormContainerErro";
		document.getElementById("tdErro" + nomeValor).className = "tdAsteriscoErro";
		return false;
	} else {
		document.getElementById("td" + nomeValor).className = "compFormContainer";
		document.getElementById("tdErro" + nomeValor).className = "tdAsteriscoOk";
		return true;
	}	
}

function limparCamposFormSuporte() {
	document.getElementById("txtNome").value = "";
	document.getElementById("txtEmail").value = "";
	document.getElementById("txtTelefone").value = "";
	document.getElementById("txtQuestao").value = "";	
	
	arrChecked = new Array();
	
	for(i=0;i<totalChecks;i++) {
		document.getElementById("chk" + i).className = "btnCheckBox";
		document.getElementById("quadchk" + i).className = "quadCheckBox";		
	}	
}

Array.prototype.removerItem = function(itemASerRemovido) {
	for(i=0;i<this.length;i++) {
		if(this[i]==itemASerRemovido) {
			this.splice(i, 1);	
		}
	}
}

function abrirPopUp(url) {	
	
	addEvento(document.getElementById("divGeral"), "mouseover", testaMouse1, true);
	addEvento(document.getElementById("divGeral"), "mouseout", testaMouse2, true);		
	
	document.onmousedown = function() {
		if(!mouseNoDivGeral) {
			fecharDiv();
			document.onmousedown = null;
		}
	}
	
	carregarPaginaDadosEm(url, 'divGeral');	
	document.getElementById("divGeral").className = "divGeralOn";
	
	document.getElementById("divGeral").style.left = (Math.floor((wRes-800)/2) + 223) + "px";
	yTopo = ((document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop);
	document.getElementById("divGeral").style.top = (yTopo+Math.floor(hTela/2)-((yTopo>50)?200:160)) + "px";
	document.getElementById("divGeral").style.visibility = "visible";
}

function executaPHP(url) {
	carregaPagina(url);
}

function reiniciaPagina() {
	//itemMenuId = null;
	//document.getElementById("mnu10").className = "tdMenuItem";
	itemMenuId = null;
	carregaPagina("home.html");	
}

function topoPagina() {
	scrollTo(0,0);
}

function getAnchorPosition(anchorname) {
	var useWindow=false;
	var coordinates=new Object();
	var x=0,y=0;
	var use_gebi=false, use_css=false, use_layers=false;
	
	if(document.getElementById){
		use_gebi=true;
	} else if(document.all){
		use_css=true;
	} else if(document.layers){
		use_layers=true;
	}
	
	if(use_gebi && document.all) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
	} else if(use_gebi) {
		var o=document.getElementById(anchorname);
		x=AnchorPosition_getPageOffsetLeft(o);
		y=AnchorPosition_getPageOffsetTop(o);
	} else if(use_css){
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
	} else if(use_layers){
		var found=0;
		for(var i=0;i<document.anchors.length;i++) {
			if(document.anchors[i].name==anchorname) {
				found=1;
				break;
			}
		} 
		if(found==0){
			coordinates.x=0;
			coordinates.y=0;
			return coordinates;
		}
		x=document.anchors[i].x;
		y=document.anchors[i].y;
	} else {
		coordinates.x=0;
		coordinates.y=0;
		return coordinates;
	}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
}
	
function getAnchorWindowPosition(anchorname) {
	var coordinates=getAnchorPosition(anchorname);
	var x=0;
	var y=0;
	if(document.getElementById) {
		if(isNaN(window.screenX)) {
			x=coordinates.x-document.body.scrollLeft+window.screenLeft;
			y=coordinates.y-document.body.scrollTop+window.screenTop;
		} else { 
			x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
			y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
		}
	} else if(document.all) {
		x=coordinates.x-document.body.scrollLeft+window.screenLeft;
		y=coordinates.y-document.body.scrollTop+window.screenTop;
	} else if(document.layers) {
		x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
		y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
	}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
}

function AnchorPosition_getPageOffsetLeft(el) {
	var ol=el.offsetLeft;
	while((el=el.offsetParent) != null) {
		ol += el.offsetLeft;
	} 
	return ol;
}

function AnchorPosition_getWindowOffsetLeft(el) {
	return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
}

function AnchorPosition_getPageOffsetTop(el) {
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null) {
		ot += el.offsetTop;
	}
	return ot;
}

function AnchorPosition_getWindowOffsetTop(el) {
	return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
}

function gotoAncora(nomeAncora) {
	//tt = document.getElementById(nomeAncora);
	//window.location.hash = nomeAncora;
	scrollTo(0, (Number(getAnchorPosition(nomeAncora).y)-25));
	//scrollBy(0, -10);	
}

/** LISTA DE DOWNLOADS
eventoId - id - download
----------------//----------------//----------------
pagina de downloads

tdDown0 -  0 - Documento com Descrição dos Produtos (e-Folders)
tdDown1 -  1 - Dicas para o VoxMetria
tdDown2 -  2 - Dicas para o FonoView 
tdDown3 -  3 - Versão do VoxGames válida por 7 dias
tdDown4 -  4 - Versão do VoxMetria válida por 7 dias
tdDown5 -  5 - Versão do AudiReport válida por 15 dias
tdDown6 -  6 - Versão do FonoView válida por 7 dias
tdDown7 -  7 - Demonstrativo do FisiMetrix

----------------//----------------//----------------
pagina de atualizacoes

tabProduto8  - 8  - VoxMetria 2.8
tabProduto15 - 9  - FonoFlex 1.1
tabProduto16 - 10 - FisiMetrix 1.3

*/

function efetuaDownload2(eventoId) {
	eventoId = Number(eventoId.substring(6, eventoId.length));
	titulo = document.getElementById("titulo" + eventoId).innerHTML;
	
	//funcaoVoltar = "javascript:carregarPaginaEm('fisiMetrix1.html', 'tdFormDown');";
	//funcaoVoltar = "javascript:paginaProduto('aba4', 'fisiMetrix1.html');";
	/*
	switch(eventoId) {
		case 1:
		case 4: url = "voxMetria4.php"; break;
		case 2:
		case 6: url = "fonoView4.php"; break;
		case 3: url = "voxGames4.html"; break;
		case 5: url = "audiReport4.php"; break;
	}
	*/
	switch(eventoId) {
		case 1:
		case 4: codP = 9; break;
		case 2:
		case 6: codP = 1; break;
		case 3: codP = 7; break;
		case 7: codP = 11; break;
	}
	//funcaoVoltar = "javascript:carregarPaginaEm('" + url + "', 'corpoProduto');"
	//funcaoVoltar = "javascript:abreProduto('" + codP + "');";	
	funcaoVoltar = "javascript:paginaProduto(" + codP + ", " + 4 + ");";
	carregarPaginaDadosEm("formDownload.html*" + titulo + "&" + eventoId + "&" + funcaoVoltar, "corpoProduto");
}

function efetuaDownloadAtual(eventoId) {
	eventoId = Number(eventoId.substring(10, eventoId.length));	
	titulo = "Atualização: " + document.getElementById("titulo" + eventoId).innerHTML;
	switch(eventoId) {
		case 15: eventoId = 9; break;
		case 16: eventoId = 10; break;
	}
	carregarPaginaDadosEm("formAtualizacao.html*" + titulo + "&" + eventoId, "corpoAtualizacoes");
}

function limparCamposFormDownload() {
	document.getElementById("txtNome").value = "";
	document.getElementById("txtEmail").value = "";
	document.getElementById("txtTelefone").value = "";
	document.getElementById("txtCidade").value = "";	
	document.getElementById("txtPais").value = "";	
	document.getElementById("txtCEP").value = "";
	document.getElementById("txtEndereco").value = "";	
	document.getElementById("txtEstado").value = "";	
	document.getElementById("txtProfissao").value = "";	
}

function validaFormDownload(idBtnEnviar) {
	if(idBtnEnviar!=null) {
		trocaCSS(idBtnEnviar, 'botaoTdSobre');	
	} else {
		ok = true;
	}	
	
	ok1 = validaCampo("Nome");
	ok2 = validaEmail("Email");
	
	ok = ok1 && ok2;
	
	if(idBtnEnviar==null) {
		if(ok) {
			enviaFormDownload();
		} else {
			alert("Os campos marcados em vermelho não estão corretamente preenchidos!");	
		}
	}
}

function enviaFormDownload() {
	
	if(primeiroClique) {

		nome = document.getElementById("txtNome").value;
		email = document.getElementById("txtEmail").value;
		telefone = document.getElementById("txtTelefone").value;
		cidade = document.getElementById("txtCidade").value;
		cep = document.getElementById("txtCEP").value;
		pais = document.getElementById("txtPais").value;
		profissao = document.getElementById("txtProfissao").value;
		estado = document.getElementById("txtEstado").value;
		endereco = document.getElementById("txtEndereco").value;
		
		nomeDownload = document.getElementById("divNomeDownload").innerHTML;	
		downloadId = document.getElementById("divDownloadId").innerHTML;
	
		htmlHead = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\"/><title>enviando email...</title></head><body>";
		
		html1Form = "<form id=\"formDownload\" name=\"formDownload\" method=\"post\" action=\"javascript:getFormDownload(document.getElementById('formDownload'), 'corpo');\" target=\"_parent\">";
		
		html2Form = "</form></body></html>";	
		
		htmlNome = "<input id=\"campoNome\" type=\"hidden\" name=\"nome\" value=\"" + nome + "\"/>";	
		htmlProfissao  = "<input id=\"campoProfissao\" type=\"hidden\" name=\"profissao\" value=\"" + profissao + "\"/>";		
		htmlEndereco = "<input id=\"campoEndereco\" type=\"hidden\" name=\"endereco\" value=\"" + endereco + "\"/>";
		htmlCidade = "<input id=\"campoCidade\" type=\"hidden\" name=\"cidade\" value=\"" + cidade + "\"/>";			
		
		htmlEstado = "<input id=\"campoEstado\" type=\"hidden\" name=\"estado\" value=\"" + estado + "\"/>";
		htmlCEP = "<input id=\"campoCEP\" type=\"hidden\" name=\"cep\" value=\"" + cep + "\"/>";			
		htmlPais = "<input id=\"campoPais\" type=\"hidden\" name=\"pais\" value=\"" + pais + "\"/>";			
		
		htmlTelefone = "<input  id=\"campoTelefone\" type=\"hidden\" name=\"telefone\" value=\"" + telefone + "\"/>";
		htmlEmail  = "<input id=\"campoEmail\" type=\"hidden\" name=\"email\" value=\"" + email + "\"/>";	
		
		htmlNomeDownload  = "<input id=\"campoDownload\" type=\"hidden\" name=\"nomeDownload\" value=\"" + nomeDownload + "\"/>";	
		htmlDownloadId  = "<input id=\"campoDownloadId\" type=\"hidden\" name=\"downloadId\" value=\"" + downloadId + "\"/>";	
		
		htmlPronto = htmlHead + html1Form + htmlNome + htmlProfissao + htmlEndereco + htmlCidade + htmlEstado + htmlCEP + htmlPais + htmlTelefone + htmlEmail + htmlNomeDownload + htmlDownloadId + html2Form;	
			
		document.getElementById("divGeral2").innerHTML = htmlPronto;	
		
		document.formDownload.submit();
		primeiroClique = false;
		mostrarAviso("enviando...", "corpo");
	}
}

function baixaArquivo(urlArq) {
	window.location = urlArq;
}

function limparCamposFormCadastro() {
	document.getElementById("txtNome").value = "";
	document.getElementById("txtEndereco").value = "";
	document.getElementById("txtBairro").value = "";
	document.getElementById("txtEmail").value = "";
	document.getElementById("txtTelefoneC").value = "";
	//document.getElementById("txtTelefoneR").value = "";
	document.getElementById("txtFax").value = "";
	document.getElementById("txtCidade").value = "";
	document.getElementById("txtPais").value = "";
	document.getElementById("txtCEP").value = "";
	document.getElementById("txtSugestao").value = "";
	document.getElementById("txtEstado").value = "";
	
	/*
	document.getElementById("chkFono").className = "btnCheckBox";
	document.getElementById("quadchkFono").className = "quadCheckBox";
	document.getElementById("chkFisio").className = "btnCheckBox";
	document.getElementById("quadchkFisio").className = "quadCheckBox";
	interesseId = 0;
	montaCheckProd(interesseId, "tdProdutos");	
	arrChecked = new Array();
	*/
}

function validaFormCadastro(idBtnEnviar) {
	if(idBtnEnviar!=null) {
		trocaCSS(idBtnEnviar, 'botaoTdSobre');	
	} else {
		ok = true;
	}	
	
	
	ok1 = validaCampo("Nome");
	ok2 = validaEmail("Email");
	
	ok = ok1 && ok2;
	
	if(idBtnEnviar==null) {
		if(ok) {
			enviaFormCadastro();
		} else {
			alert("Os campos marcados em vermelho não estão corretamente preenchidos!");	
		}
	}
}


function enviaFormCadastro() {
	
	if(primeiroClique) {
		
		nome = document.getElementById("txtNome").value;
		endereco = document.getElementById("txtEndereco").value;
		bairro = document.getElementById("txtBairro").value;		
		email = document.getElementById("txtEmail").value;
		//telefoneR = document.getElementById("txtTelefoneR").value;
		telefoneC = document.getElementById("txtTelefoneC").value;
		fax = document.getElementById("txtFax").value;
		cidade = document.getElementById("txtCidade").value;
		cep = document.getElementById("txtCEP").value;
		pais = document.getElementById("txtPais").value;
		estado = document.getElementById("txtEstado").value;		
		
		produtos = "";
		if(interesseId==0) {
			interesse = "";
		} else if(interesseId==1) {
			interesse = "Fonoaudiologia";
			for(i=0;i<arrChecked.length;i++) {
				if(i<arrChecked.length-1) {
					produtos += arrProdutos[arrChecked[i]] + ", ";
				} else {
					produtos += arrProdutos[arrChecked[i]] + ".";
				}
			}
		} else if(interesseId==2) {
			interesse = "Fisioterapia";
			for(i=0;i<arrChecked.length;i++) {
				if(i<arrChecked.length-1) {
					produtos += arrProdutos[Number(arrChecked[i]+arrProdFono.length)] + ", ";
				} else {
					produtos += arrProdutos[Number(arrChecked[i]+arrProdFono.length)] + ".";
				}
			}
		} else if(interesseId==3)	{
			interesse = "Fonoaudiologia e Fisioterapia";
			for(i=0;i<arrChecked.length;i++) {
				if(i<arrProdFono.length) {
					if(i<arrChecked.length-1) {
						produtos += arrProdutos[arrChecked[i]] + ", ";
					} else {
						produtos += arrProdutos[arrChecked[i]] + ".";
					}
				} else {
					if(i<arrChecked.length-1) {
						produtos += arrProdutos[arrChecked[i-arrProdFono.length]] + ", ";
					} else {
						produtos += arrProdutos[arrChecked[i-arrProdFono.length]] + ".";
					}
				}
			}
		}

		sugestao = document.getElementById("txtSugestao").value;		
		cont = 1;
		while(sugestao.indexOf("\n")!=-1) {			
			sugestao = sugestao.replace("\n", "<br>");		
			cont++;
		}		
		
		htmlHead = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\"/><title>enviando email...</title></head><body>";
		
		html1Form = "<form id=\"formCadastro\" name=\"formCadastro\" method=\"post\" action=\"javascript:getFormCadastro(document.getElementById('formCadastro'), 'corpo');\" target=\"_parent\">";
		
		html2Form = "</form></body></html>";			
				
		htmlNome = "<input id=\"campoNome\" type=\"hidden\" name=\"nome\" value=\"" + nome + "\"/>";	
		htmlEndereco = "<input id=\"campoEndereco\" type=\"hidden\" name=\"endereco\" value=\"" + endereco + "\"/>";
		htmlBairro = "<input id=\"campoBairro\" type=\"hidden\" name=\"bairro\" value=\"" + bairro + "\"/>";
		htmlEmail  = "<input id=\"campoEmail\" type=\"hidden\" name=\"email\" value=\"" + email + "\"/>";		
		htmlCidade = "<input id=\"campoCidade\" type=\"hidden\" name=\"cidade\" value=\"" + cidade + "\"/>";		
		htmlEstado = "<input id=\"campoEstado\" type=\"hidden\" name=\"estado\" value=\"" + estado + "\"/>";
		htmlCEP = "<input id=\"campoCEP\" type=\"hidden\" name=\"cep\" value=\"" + cep + "\"/>";			
		htmlPais = "<input id=\"campoPais\" type=\"hidden\" name=\"pais\" value=\"" + pais + "\"/>";
		//htmlTelefoneR = "<input  id=\"campoTelefoneR\" type=\"hidden\" name=\"telefoneR\" value=\"" + telefoneR + "\"/>";
		htmlTelefoneR = "";
		htmlTelefoneC = "<input  id=\"campoTelefoneC\" type=\"hidden\" name=\"telefoneC\" value=\"" + telefoneC + "\"/>";
		htmlFax = "<input id=\"campoFax\" type=\"hidden\" name=\"fax\" value=\"" + fax + "\"/>";
		htmlInteresse = "<input  id=\"campoInteresse\" type=\"hidden\" name=\"interesse\" value=\"" + interesse + "\"/>";
		htmlProdutos = "<input  id=\"campoProdutos\" type=\"hidden\" name=\"produtos\" value=\"" + produtos + "\"/>";
		htmlSugestao = "<input  id=\"campoSugestao\" type=\"hidden\" name=\"sugestao\" value=\"" + sugestao + "\"/>";
			
		htmlPronto = htmlHead + html1Form + htmlNome + htmlEndereco + htmlBairro + htmlEmail + htmlCidade + htmlEstado + htmlCEP + htmlPais + htmlTelefoneR + htmlTelefoneC + htmlFax + htmlInteresse + htmlProdutos + htmlSugestao + html2Form;	
			
		document.getElementById("divGeral2").innerHTML = htmlPronto;	
		
		document.formCadastro.submit();
		primeiroClique = false;
		mostrarAviso("enviando...", "corpo");
	}
}

function mostrarAviso(msg, lugarId) {
	topoPagina();
	document.getElementById(lugarId).innerHTML = "<center><div class=\"divCarregando\">" + msg + "</div></center>";
}

function paginaProduto(produtoId, codAba) {
	primeiroClique = true;
	switch(Number(produtoId)) {		
		case 0: {
			novaUrl = "audiReport";
			break;
		}
		case 1: {
			novaUrl = "fonoView";
			break;
		}
		case 2: {
			novaUrl = "avalie";
			break;
		}
		case 3: {
			novaUrl = "pedroNaCasa";
			break;
		}
		case 4: {
			novaUrl = "desafioFonemas";
			break;
		}
		case 5: {
			novaUrl = "voiceReport";
			break;
		}
		case 6: {
			novaUrl = "fonoTools";
			break;
		}
		case 7: {
			novaUrl = "voxGames";			
			break;
		}
		case 8: {
			novaUrl = "fonoFlex";			
			break;
		}
		case 9: {
			novaUrl = "voxMetria";
			break;
		}
		case 10: {
			novaUrl = "fonospeak";
			break;
		}
		case 11: {
			novaUrl = "fisiMetrix";
			break;
		}
		case 12: {
			novaUrl = "earMix";
			break;
		}
	}		
	if(!novaUrl) {
		reiniciaPagina();	
	} else {
		novaUrl = novaUrl + codAba + ".php?ok=1";	
		
		/*
		if(produtoId==10 && pagId==4) {
			novaUrl = novaUrl + "{carregaPagPrecosProd!" + 	11;
		} else if(produtoId==11 && pagId==3) {
			novaUrl = novaUrl + "{carregaPagPrecosFisiM";
		} else if(pagId==3) {
			novaUrl = novaUrl + "{carregaPagPrecosProd!" + 	produtoId;		
		}
		*/
		/*
		if(abaId==codAba) {
			alert("ahhh bom");
		} else {
			*/
			marcarAba(codAba);
			//alert(novaUrl);
			carregarPaginaEm(novaUrl, 'corpoProduto');
			abaId = codAba;
		//}
	}
}

/*
arrProdutos[0] = "AudiReport";
arrProdutos[1] = "FonoView";
arrProdutos[2] = "Avalie";
arrProdutos[3] = "Pedro na Casa Mal-Assombrada";
arrProdutos[4] = "Desafio dos Fonemas";
arrProdutos[5] = "VoiceReport";
arrProdutos[6] = "FonoTools";
arrProdutos[7] = "VoxGames";
arrProdutos[8] = "FonoFlex";
arrProdutos[9] = "VoxMetria";
arrProdutos[10] = "FonoSpeak";
arrProdutos[11] = "FisiMetrix";
*/

function abreProduto(produtoId) {
	abaId = null;
	switch(Number(produtoId)) {		
		case 1: {
			url = "fonoView.html";
			break;
		}
		case 7: {
			url = "voxGames.html";			
			break;
		}
		case 9: {
			url = "voxMetria.html";
			break;
		}
		case 12: {
			url = "earMix.html";
			break;
		}
		case 11: {
			url = "fisiMetrix.html";
			break;
		}
	}
	carregaPagina(url + "{paginaProduto!" + produtoId + "&1");	
}

function voltaDown(codProd) {
	carregaPagina("voxMetria.html{paginaProduto!" + codProd + "&1");
}

function abreProdutoDown(produtoId) {
	switch(produtoId) {		
		case 0: {
			url = "audiReport.html";			
			break;
		}
		case 1: {
			url = "fonoView.html";			
			break;
		}
		case 2: {
			url = "avalie.html";			
			break;
		}
		case 3: {
			url = "pedroNaCasa.html";
			break;
		}
		case 4: {
			url = "desafioFonemas.html";
			break;
		}
		case 5: {
			url = "voiceReport.html";
			break;
		}
		case 6: {
			url = "fonoTools.html";
			break;
		}
		case 7: {
			url = "voxGames.html";			
			break;
		}
		case 8: {
			url = "fonoFlex.html";			
			break;
		}
		case 9: {
			url = "voxMetria.html";
			break;
		}
		case 10: {
			url = "fonospeak.html";
			break;
		}
		case 11: {
			url = "fisiMetrix.html";
			break;
		}
		case 12: {
			url = "earMix.html";
			break;
		}
	}	
	carregaPagina(url + "{paginaProduto!" + produtoId + "&4");	
}

codProdutoComprar = null;

function comprarMaisProdutos(codProdutoComprar) {
	arrCestaCompras = new Array();
	podeContinuarCompra = true;
	contProdutos = 0;
	valorFrete = null;	
	formaEnvio = 0;	
	carregaPagina("comprarProdutos.html{adicionarProduto!" + codProdutoComprar + "&" + formaEnvio + "&1");
}

function setaValorFrete(objeto, idLugar) {
	if(objeto.value!=-1 && objeto.value!=null && objeto.value!="") {
		if(objeto.options[0].value==-1) {
			deletarComponente(objeto.options[0])
		}
		valorFrete = Number(getValorFrete(objeto.value));
		document.getElementById(idLugar).innerHTML = "R$ " + formataDinheiro(valorFrete);		
	} else {
		valorFrete = 0;
		document.getElementById(idLugar).innerHTML = "R$ 0,00";
	}
	calcularValores();
}

function calcularFreteSedex(campoValor, campoErro) {
	if(validaCEP(campoValor, campoErro)) {
		tempCEP = document.getElementById(campoValor).value.replace("-", "");
		calcularFrete(tempCEP, '85501090', '1', campoErro);
		document.getElementById(campoErro).innerHTML = document.getElementById(campoErro).innerHTML;		
	} else {
		document.getElementById(campoErro).innerHTML = "<span style=\"color:#FF4444;fonte-weight::bold;\">CEP Inválido.</span>";		
	}
}

function popUpProdutos(produtoCompraId) {
	
	mostraTelaEscura();
	
	document.getElementById("txtEstado").style.visibility = "hidden";
	

	if(produtoCompraId==null) {
		carregarPaginaDadosEm('popUpProdutos.html*' + -1 + "&" + 1 + "&" + "Adicionar" + "&" + "validaAdicaoProduto()&", 'divGeral');
	} else {
		v1 = arrCestaCompras[produtoCompraId][0];
		v2 = arrCestaCompras[produtoCompraId][2];
		v3 = "Salvar";
		v4 = "salvarModificacoesCompra()";
		
		carregarPaginaDadosEm('popUpProdutos.html*' + v1 + "&" + v2 + "&" + v3 + "&" + v4 + "&disabled=\"disabled\" style=\"background-color:#FFFFFF;border: 1px solid #AED7FF;width:300px;\"", 'divGeral');
	}
	
	document.getElementById("divGeral").className = "divPopUpProdutos";
	
	document.getElementById("divGeral").style.left = Math.floor(wTela/2 - 500/2) + "px";
	yTopo = ((document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop);
	document.getElementById("divGeral").style.top = (yTopo+Math.floor(hTela/2)-(410/2)) + "px";
	document.getElementById("divGeral").style.visibility = "visible";
}

function fechaPopUpProd() {
	document.getElementById("txtEstado").style.visibility = "visible";
	fecharDiv();
}

/*
arrProdutos[0] = "AudiReport";
arrProdutos[1] = "FonoView";
arrProdutos[2] = "Avalie";
arrProdutos[3] = "Pedro na Casa Mal-Assombrada";
arrProdutos[4] = "Desafio dos Fonemas";
arrProdutos[5] = "VoiceReport";
arrProdutos[6] = "FonoTools";
arrProdutos[7] = "VoxGames";
arrProdutos[8] = "FonoFlex";
arrProdutos[9] = "VoxMetria";
arrProdutos[10] = "FonoSpeak";
arrProdutos[11] = "FisiMetrix";
*/

function carregarProdutos(cod) {	
	if(cod==0) {
		for(i=0;i<totalProdFono;i++) {
			document.getElementById("lin"+i).className = "trVisivel";
		}	
		document.getElementById("prodDesenv").className = "tabInvisivel";
	} else {
		for(i=0;i<totalProdFono;i++) {
			document.getElementById("lin"+i).className = "tabInvisivel";
		}	
		if(fonoCategorias[cod-1].length>0) {
			document.getElementById("prodDesenv").className = "tabInvisivel";
			cont = 0;										
			for(i=0;i<totalProdFono;i++) {
				ok = false;
				for(iProd=0;iProd<fonoCategorias[cod-1].length;iProd++) {
					if(fonoCategorias[cod-1][iProd]==i) {
						document.getElementById("lin"+i).className = "trVisivel";
						ok = true;
						break;
					}
				}
			}
		} else {
			document.getElementById("prodDesenv").className = "trVisivel";
		}
	}
}

function carregarAtualizacoes(arrProdSel) {
	if(arrProdSel.length>0) {								
		for(i=1;i<=totalAtualizacoes;i++) {									
			ok = false;
			for(iProd=0;iProd<arrProdSel.length;iProd++) {	
				if(arrProdSel[iProd]==i) {
					document.getElementById("lin"+i).className = "trVisivel";
					ok = true;
					break;
				}
				
			}
			if(!ok) {		
				document.getElementById("lin"+i).className = "tabInvisivel";
			}
		}
	} else {
		if(arrChecked>0) {
			for(i=1;i<=totalAtualizacoes;i++) {
				//deletarComponente("lin"+i);
				document.getElementById("lin"+i).className = "tabInvisivel";
			}
		} else {
			//document.getElementById(idLugar).innerHTML = "";
		}
	}	
}

/*
	 0-parcelamento
	 1-forma pagamento
	 2-opcao de correio
	 3-sedex convencional (pagamento foi sedex a cobrar)
*/

function mostraAjuda(codAjuda, event) {
	ok = false;
	switch(codAjuda) {
		case 0: {
			titulo = "Parcelas";
			texto = "Se você comprar apenas um produto o valor das parcelas é calculado baseado em uma tabela para cada produto.";
			texto += "<br><br>Na compra de produtos diferentes ";
			break;
		}
		case 1: {			
			titulo = "Formas de pagamento";
			texto = "<br>";
			texto += "<strong>Depósito Bancário:</strong><br><br>";
			texto += "Realize o depósito bancário em nossa conta corrente, e depois envie o comprovante por fax. Caso o depósito seja em cheque, aguardaremos a compensação para enviar os produtos.<br><br><br>";	
			texto += "<strong>Sedex à Cobrar</strong><br><br>";
			texto += "Você terá cinco dias corridos a contar da data de emissão do aviso, para ir até a agência de Correios, fazer a retirada do produto e o pagamento da primeira parcela diretamente ao agente dos Correios.<br><br>";	
			document.getElementById("divGeral2").style.height = 240 + "px";
			ok = true;
			break;
		}
		case 2: {
			titulo = "Formas de envio";
			texto = "<br>";
			texto += "<strong>Sedex convencional</strong><br><br>";
			texto += "Sedex (Serviço de Encomenda Expressa) é um serviço da Empresa Brasileira de Correios e Telégrafos de despacho expresso de correspondências, documentos e objetos.<br>";	
			texto += "O valor do SEDEX varia de acordo com o estado ao qual será enviado o pedido.<br><br><br>";
			texto += "<strong>Encomenda (PAC)</strong><br><br>";
			texto += "Você terá cinco dias corridos a contar da data de emissão do aviso, para ir até a agência de Correios, fazer a retirada do produto e o pagamento da primeira parcela diretamente ao agente dos Correios.<br><br>";				
			document.getElementById("divGeral2").style.height = 260 + "px";
			ok = true;
			break;
		}
		case 3: {
			titulo = "Sedex";
			texto = "Se você selecionou a forma de pagamento SEDEX À COBRAR.<br>";
			texto += "A forma de envio será por SEDEX, serviço disponibilizado pelos Correios.<br><br>";
			texto += "O valor do SEDEX varia de acordo com o estado ao qual será enviado o pedido.";
			document.getElementById("divGeral2").style.height = 160 + "px";
			ok = true;			
			break;
		}
	}
	
	if(ok) {
		html = "<table style=\"border: 3px solid #B6CEE7\" width=\"100%\" height=\"100%\" align=\"center\" cellpadding=\"0\" cellspacing=\"10\"><tr><td id=\"nomeProd\" width=\"264\" height=\"20\" align=\"left\" class=\"fonte21 tdSeparadorBottom\">" + titulo + "</td></tr><tr><td id=\"desProd\" height=\"36\" align=\"left\" class=\"fonte22\">" + texto + "</td></tr></table>";
		
		document.getElementById("divGeral2").className = "divAjuda";  	
		document.getElementById("divGeral2").innerHTML = html;		
		yTopo = ((document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop);
		document.getElementById("divGeral2").style.left = (event.clientX - 475) + "px";
		document.getElementById("divGeral2").style.top = (yTopo + event.clientY - 100) + "px";
		document.getElementById("divGeral2").style.visibility = "visible";	
	}
}

function mostraHint(texto, event, larguraHint) {
	document.getElementById("divGeral2").style.height = 19 + "px";
	if(larguraHint!=null) {
		document.getElementById("divGeral2").style.width = larguraHint + "px";
	} else {
		document.getElementById("divGeral2").style.width = 250 + "px";
	}

	html = "<table align=\"center\"><tr><td class=\"fonte22\" valign=\"middle\"><center>" + texto + "</center></td></tr></table>";
			
	document.getElementById("divGeral2").className = "divHint";
	document.getElementById("divGeral2").innerHTML = html;
	
	yTopo = ((document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop);
	document.getElementById("divGeral2").style.left = (event.clientX - 30) + "px";
	document.getElementById("divGeral2").style.top = (yTopo + event.clientY + 21) + "px";
	document.getElementById("divGeral2").style.visibility = "visible";
}

function escondeAjuda() {
	try {
		document.getElementById("divGeral2").className = "tabInvisivel";	
	} catch(e) {}	
	
	if(ie) {
		versaoIE = versao.substring(versao.indexOf("MSIE")+5, versao.length);
		//alert("1: " + versaoIE);
		//versaoIE = versaoIE.substring(0, versao.indexOf(";"));
		versaoIE = versaoIE.split(";");
		versaoIE = Math.floor(Number(versaoIE[0]));
		if(versaoIE<7) {
			try {
				document.getElementById("txtEstado").style.visibility = "visible";
			} catch(e) {}
			try {
				document.getElementById("txtMesVal").style.visibility = "visible";
				document.getElementById("txtAnoVal").style.visibility = "visible";
			} catch(e) {}
		}
	}
}

function modificaValor(compId, valor, vMin, vMax) {
	num = Number(document.getElementById(compId).value);
	num += valor;	
	if(num<=vMax && num>=vMin) {
		document.getElementById(compId).value = Number(document.getElementById(compId).value) + valor;
	}
}

function iniciaSite(codProd, nroAba) {	
	var1 = encodeURI(codProd);
	var2 = encodeURI(nroAba);
	window.location = urlSite + "/redirecionar.php?var1=" + var1 + "&var2=" + var2;	
}