// JavaScript Document
function chat(html){
		remote = window.open(html,'hotsite','left=10,top=10,width=600,height=420,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no')
	}

function openURL(url){
	document.location.href = url;
}
function remover_espacos(str){
	r = "";
	for(i = 0; i < str.length; i++){
		if(str.charAt(i) != ' '){
			r += str.charAt(i);
		}
	}
	return r;
}
function trocaCategoria(page,idLeilao,tipo,categoria){
	document.location.href = page+".php?idLeilao="+idLeilao+"&tipo="+tipo+"&cat="+categoria;
}

function mostraDiv(id){
	if (document.getElementById(id).style.display == 'none'){
		document.getElementById(id).style.display = 'block';
	} else {		
		document.getElementById(id).style.display = 'none';
	}
	return true;
}

function excluirContato(id, modulo){
	if (confirm('Deseja mesmo remover este contato?')){
		document.location.href = "conteudo.php?modulo="+modulo+"&acao=apagar&id="+id;
	}
}

// Verifica campos de checkbox e guarda/retira do hidden
function verificaCampo(checkbox,id){
	var hidden = document.getElementById("permissao");
	if (checkbox.checked){
		hidden.value += id+";";
	} else {
		i = hidden.value.indexOf(id+";");
		tamanho = (id+"").length;
		inicio = hidden.value.substring(0,i);
		fim = hidden.value.substring(i+tamanho + 1);
		hidden.value = inicio+fim;
	}
}
//<input name="cep" type="text" id="cep" onkeypress="return formataCampo(event,this,'#####-###');" size="10" maxlength="9" autocomplete="off">
function formataCampo(e,src,mask) {
	var _TXT = (e.which) ? e.which : e.keyCode;
	
    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 {
		// 8 = backspace, 9 = Tab, 37 = seta esquerda, 39 = seta direita, 46 = delete
		if ((_TXT != 8) && (_TXT != 9) && (_TXT != 0) && (_TXT != 37) && (_TXT != 39) && (_TXT != 46)) { return false; }
		else { return true; }
    }
}

//<input name="valor" type="text" onKeyPress="return(formataMoeda(this,12,'.',',',event))"/>
function formataMoeda(objTextBox, limite, SeparadorMilesimo, SeparadorDecimal, e){
	if (objTextBox.value.length > limite){
		objTextBox.value = objTextBox.value.substr(1,limite);
	}
	//máscara de moeda 0.000.000,00
	SeparadorMilesimo='.';
    var sep = 0;
    var key = '';
    var i = j = 0;
    var len = len2 = 0;
    var strCheck = '0123456789';
    var aux = aux2 = '';
    var whichCode = (e.which) ? e.which : e.keyCode;
    // 13=enter, 8=backspace, 9=tab as demais retornam 0(zero)
    // whichCode==0 faz com que seja possivel usar todas as teclas como delete, setas, etc    
    if ((whichCode == 13) || (whichCode == 0) || (whichCode == 9) || (whichCode == 8))
    	return true;
    key = String.fromCharCode(whichCode); // Valor para o código da Chave 
 
    if (strCheck.indexOf(key) == -1) 
    	return false; // Chave inválida
    len = objTextBox.value.length;
    for(i = 0; i < len; i++)
        if ((objTextBox.value.charAt(i) != '0') && (objTextBox.value.charAt(i) != SeparadorDecimal)) 
        	break;
    aux = '';
    for(; i < len; i++)
        if (strCheck.indexOf(objTextBox.value.charAt(i))!=-1) 
        	aux += objTextBox.value.charAt(i);
    aux += key;
    len = aux.length;
    if (len == 0) 
    	objTextBox.value = '';
    if (len == 1) 
    	objTextBox.value = '0'+ SeparadorDecimal + '0' + aux;
    if (len == 2) 
    	objTextBox.value = '0'+ SeparadorDecimal + aux;
    if (len > 2) {
        aux2 = '';
        for (j = 0, i = len - 3; i >= 0; i--) {
            if (j == 3) {
                aux2 += SeparadorMilesimo;
                j = 0;
            }
            aux2 += aux.charAt(i);
            j++;
        }
        objTextBox.value = '';
        len2 = aux2.length;
        for (i = len2 - 1; i >= 0; i--)
        	objTextBox.value += aux2.charAt(i);
        objTextBox.value += SeparadorDecimal + aux.substr(len - 2, len);
    }
    return false;
}
function numeros(campo){
	var digits="0123456789 ()-,;"
	var campo_temp 
	for (var i=0;i<campo.value.length;i++){
		campo_temp=campo.value.substring(i,i+1) 
		if (digits.indexOf(campo_temp)==-1){
			campo.value = campo.value.substring(0,i);
			break;
		}
	}
}

// JavaScript Document
function check_date(DATA) {
    var expReg = /^(([0-2]\d|[3][0-1])\/([0]\d|[1][0-2])\/[1-2][0-9]\d{2})$/;
	var msgErro = 'Formato inválido de data.';
	var vdt = new Date();
	var vdia = vdt.getDay();
	var vmes = vdt.getMonth();
	var vano = vdt.getFullYear();
	if ((DATA.value.match(expReg)) && (DATA.value!='')){
		var dia = DATA.value.substring(0,2);
		var mes = DATA.value.substring(3,5);
		var ano = DATA.value.substring(6,10);
		if((mes==04 && dia > 30) || (mes==06 && dia > 30) || (mes==9 && dia > 30) || (mes==11 && dia > 30)){
			alert("Dia incorreto !!! O mês especificado contém no máximo 30 dias.");
			DATA.focus();
			return false;
		} else{ //1
			if(ano%4!=0 && mes==2 && dia>28){
				alert("Data incorreta!! O mês especificado contém no máximo 28 dias.");
				DATA.focus();
				return false;
			} else{ //2
				if(ano%4==0 && mes==2 && dia>29){
					alert("Data incorreta!! O mês especificado contém no máximo 29 dias.");
					DATA.focus();
					return false;
				} else{ //3
					return true;
				} //3-else
			}//2-else
		}//1-else                       
	} else { //5
		alert(msgErro);
		DATA.focus();
		return false;
	} //5-else
}
function dataAtual(data){ // retorna 0 se a data é igual, -1 se for menor, +1 se for maior
	aux = data.split("/");
	var myDate=new Date(aux[1]+"/"+aux[0]+"/"+aux[2]);
	var today = new Date();
	today.setHours(0);
	today.setMinutes(0);
	today.setSeconds(0);
	today.setMilliseconds(0);
	
	if (myDate < today) {
		return -1;
	} else if (myDate > today) {
		return 1;
	} else {
		return 0;
	}
}
function validaRevenda(Form,id){
	var conteudo = remover_espacos(Form.login.value);
	
	if (conteudo.length == 0){
		alert("Informe o login desta revenda!");
		Form.login.id = 'error';
		Form.login.focus();
		return false;
	} else {
		var url = "../../scripts/ajax.php?acao=buscaLogin&id="+id+"&login="+conteudo+"&revenda=S";

		ajax = ajaxInit();
		ajax.open("GET",url,false);
		ajax.send(null);
		if (ajax.responseText > 0){
			alert("Este login já está sendo utilizado por outro usuário!");
			Form.login.id = 'error';
			Form.login.focus();
			return false;
		}
	}
	Form.login.id = '';
	
	conteudo = remover_espacos(Form.senha.value);
	
	if (conteudo.length == 0){
		alert("Informe a senha de acesso!");
		Form.senha.id = 'error';
		Form.senha.focus();
		return false;
	} else if (conteudo.length < 4) {
		alert("Esta senha deve conter pelo menos 4 caracteres!");
		Form.senha.id = 'error';
		Form.senha.focus();
		return false;
	}
	Form.senha.id = '';
	
	return true;
}

function validaEmail(Form){
	var conteudo = remover_espacos(Form.email.value);
	
	if (conteudo.length == 0){
		alert("Insira um email!");
		Form.email.focus();
		return false;
	} else {
		invalidCharsList = " #$!*()[]^<>{}\'\"";
		// define a list of invalid characters
		if (conteudo.indexOf('@',0)==-1 ||
			conteudo.indexOf('@',0)== 0 ||
			conteudo.indexOf('.',3)==-1 ||
			conteudo.lastIndexOf('.') > conteudo.length-3) {
			alert("Formato de email inválido!");
			Form.email.focus();
			return false;
		}
	
		for (i = 0; i < invalidCharsList.length; i++) {
			errorChar = invalidCharsList.charAt(i);
			if (conteudo.indexOf(errorChar,0) != -1) {
				alert("Caractere inválido!");
				Form.email.focus();
				return false;
			}
		}
	}
	Form.email.value = conteudo;
	
	return true;
}

function addLinha(index){
	var table = document.getElementById("tabPerguntas");
	
	var col0 = document.createElement("TD");
	col0.align = 'right';
	var col1 = document.createElement("TD");
	var col2 = document.createElement("TD");
	col2.align = "right";
	var col3 = document.createElement("TD");
	var col4 = document.createElement("TD");
	col4.align = "right";
	var col5 = document.createElement("TD");
	col5.align = "right";
	
	col0.innerHTML = "Opção "+(parseInt(index)+1)+":&nbsp;&nbsp;";
	
	var input = document.createElement("input");
	input.type = 'text';
	input.name = "questao"+index;
	input.id = "questao"+index;
	input.style.width = "400px";
	col1.appendChild(input);
	
	col2.innerHTML = "Posição:**";
	
	var ordem = document.createElement("input");
	ordem.type = 'text';
	ordem.name = "ordem"+index;
	ordem.id = "ordem"+index;
	ordem.style.width = "50px";
	ordem.maxLength = 3;
	col3.appendChild(ordem);
	ordem.setAttribute("onkeypress","return formataCampo(event,this,'#');");
	
	var btDel = document.createElement("input");
	btDel.type = 'button';
	btDel.value = "Remover";
	btDel.setAttribute("onClick","removerLinha("+(parseInt(index)-1)+",this.parentNode.parentNode,'add');");
	col4.appendChild(btDel);
	
	var btAdd = document.createElement("input");
	btAdd.type = 'button';
	btAdd.id = "add"+index;
	btAdd.value = "Adicionar";
	btAdd.setAttribute("onClick","this.style.display='none';addLinha("+(parseInt(index)+1)+",this);");
	col5.appendChild(btAdd);
		
	var linha = table.insertRow(-1);
	linha.id = "tr"+index;
	
	linha.appendChild(col0);
	linha.appendChild(col1);
	linha.appendChild(col2);
	linha.appendChild(col3);
	linha.appendChild(col4);
	linha.appendChild(col5);
	
	var hidden = document.getElementById("numLinhas");
	
	hidden.value += index+";";
}
function appendTable(){	
	var idAtual = $("#idAtual").val();
	var tr = document.createElement("tr");
	var td = document.createElement("td");
	var td2 = document.createElement("td");
	var td3 = document.createElement("td");
	var td4 = document.createElement("td");
	var td5 = document.createElement("td");
	var td6 = document.createElement("td");
	
	// Monta linha 1
	td.innerHTML = 'Opção '+(parseInt(idAtual)+1)+':*';
	td.className = "td80";
	td.align = "right";
	
	// Monta linha 2
	var input2 = document.createElement("input");
	input2.name = "questao"+idAtual;
	input2.id = "questao"+idAtual;
	input2.maxlength = 50;
	input2.className = "td400";
	td2.className = "td400";
	td2.appendChild(input2);
	
	// Monta linha 3
	td3.innerHTML = 'Posição:**';
	td3.className = "td60";
	td3.align = "right";
	
	// Monta linha 4
	var input4 = document.createElement("input");
	input4.name = "ordem"+idAtual;
	input4.id = "ordem"+idAtual;
	input4.maxlength = 3;
	input4.className = "td50";
	input4.value = 999;
	input4.onkeypress = function(){
		return formataCampo(event,this,'#');
	}
	td4.appendChild(input4);
	// Monta linha 5
	var input5 = document.createElement("input");
	input5.type = "button";
	input5.value = "Remover";
	input5.className = "td80";
	input5.onclick = function(){
		removerLinha(parseInt(idAtual)-1,this.parentNode.parentNode,'add');
	}
	td5.className = "td80";
	td5.appendChild(input5);
	
	// Monta linha 6
	var input6 = document.createElement("input");
	input6.type = "button";
	input6.id = "add"+idAtual;
	input6.value = "Adicionar";
	input6.className = "td80";
	input6.onclick = function(){
		this.style.display = 'none';
		appendTable();
	}
	td6.className = "td80";
	td6.align = "right";
	td6.appendChild(input6);
	
	tr.appendChild(td);
	tr.appendChild(td2);
	tr.appendChild(td3);
	tr.appendChild(td4);
	tr.appendChild(td5);
	tr.appendChild(td6);

	// Insere a nova linha na tabela
	$("#tabPerguntas").append(tr);
	// Atualiza índice
	var indices = $("#numLinhas").val();
	$("#numLinhas").val(indices+idAtual+";");
	// id da próxima linha a ser inserida
	idAtual++;
	$("#idAtual").val(idAtual);
}
function removerLinha(index, linha, tipo){
	// Antes de remover a linha, exibe o botão de adicionar anterior se este for o último da lista
	var indices = $("#numLinhas").val().split(";");
	indices.pop();
	
	var pos = -1;
	// procura pelo índice no array de índices
	for (i = 0; i < indices.length; i++){
		if (indices[i] == index){ // se achou este índice
			// Remove este índice do array
			inicio = indices.slice(0,i);
			fim = indices.slice(i+1);
			indices = inicio.concat(fim);
			// Pega valor do último índice ativo para corrigir contagem
			ultimoIndice = parseInt(indices[indices.length -1])+1;
			$("#idAtual").val(ultimoIndice);
			// Monta array novamente sem o indice removido
			$("#numLinhas").val(indices.join(";")+";");
			pos = i-1;
			break;
		}
	}
	// Caso era o último item da lista, coloca botão de adicionar na atual ultima linha 
	if (pos > -1 && pos + 1 == indices.length){
		$("#add"+indices[pos]).css('display','block');
	}
	// Remove linha da tabela
	linha.parentNode.removeChild(linha);
}
function validaEnquete(Form){
	
	var conteudo = remover_espacos(Form.pergunta.value);
	
	if (conteudo.length == 0){
		alert("Informe uma pergunta!");
		Form.pergunta.id = 'error';
		Form.pergunta.focus();
		return false;
	}
	Form.pergunta.id = '';
	conteudo = Form.numLinhas.value;
	
	var array = conteudo.split(";");
	var vazio = true;
	for(i = 0; i < array.length-1; i++){
		if ($("#questao"+i).val() != ""){
			vazio = false;
			break;
		}
	}
	if (vazio){
		alert("Informe pelo menos uma opção!");
		Form.questao0.id = 'error';
		Form.questao0.focus();
		return false;
	}
	Form.questao0.id = '';

	return true;
}
function confirmaExclusao(id,tipo,page){
	if ((tipo == "enquete") || (tipo == "solução") || (tipo == "novidade") || (tipo == "categoria") || (tipo == "pergunta")){
		var msg = "esta "+tipo;
	} else {
		var msg = "este "+tipo;
	}
	var aviso = "Deseja realmente excluir "+msg+"?";
	if (tipo == "categoria"){
		aviso += "(todo o conteúdo desta categoria será perdido!)";
	}
	
	if ((tipo == "categoria") && (confirm(aviso))){
		document.location.href = page+".php?id="+id+"&acao=removerCat";
	} else if ((tipo == "pergunta") && (confirm(aviso))){
		document.location.href = "solucoes.php?id="+id+"&acao=removerFAQ&solucao="+page;
	} else if (confirm(aviso)){
		document.location.href = page+".php?id="+id+"&acao=remover";
	} else {
		return false;
	}
}
function confirmaExclusaoArquivo(idCat,id){
	if (confirm("Deseja realmente excluir este arquivo?")){
		document.location.href = "arquivos.php?idCat="+idCat+"&id="+id+"&acao=remover";
	} else {
		return false;
	}
}
function confirmaExclusaoModulo(solucao,id){
	if (confirm("Deseja realmente excluir este módulo?")){
		document.location.href = "modulos.php?solucao="+solucao+"&id="+id+"&acao=remover";
	} else {
		return false;
	}
}
function verificaTexto(campo,limite,contador){
	var conteudo = campo.value;
	
	if (conteudo.length > limite){
		campo.value = campo.value.substr(0,limite);
	}
	document.getElementById(contador).innerHTML = (limite - conteudo.length)+" Caracteres disponíveis.";
}
function ajaxInit() {
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
	  ajax=new XMLHttpRequest();
	} else {// code for IE6, IE5
	  ajax=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return ajax;
}
function buscaEndereco(selecao){
	if (selecao.value == ""){
		return false;
	}
	var itens = new Array();
	var url = "../../scripts/ajax.php?busca=";
	// Cria novo select para substituir o antigo
	var div = document.createElement("SELECT");
	if (selecao.id == "estado"){
		div.id="cidade";
		div.name="cidade[]";
		url += "cidade";
		div.multiple="multiple";
		div.setAttribute("class","seletor");
	} else {
		div.id="bairro";
		div.name="bairro[]";
		url += "bairro";
		div.multiple="multiple";
		div.setAttribute("class","seletor");
	}
	
	var qtd = 0;
	// Gera os parâmetros (GET) a serem passados para o ajax
	for (i = 1; i < selecao.options.length; i++){
		if (selecao.options[i].selected){
			url += "&item"+qtd+"="+selecao.options[i].value;
			qtd++;
		}
	}
	
	ajax = ajaxInit();
	ajax.open("GET",url,false);
	ajax.send(null);	
	
 	var aux = document.createElement("div");
	aux.appendChild(div);
	div.innerHTML = "&nbsp;<option value=''>-- Selecione --</option>";
	div.innerHTML += ajax.responseText;
	if (selecao.id == "estado"){
		document.getElementById("linhaCidade").innerHTML = aux.innerHTML;
	} else {
		document.getElementById("linhaBairro").innerHTML = aux.innerHTML;
	}
	
	// Cria evento para o objeto criado
	if (selecao.id == "estado"){
		document.getElementById(div.id).onchange = function(){
			buscaEndereco(this);
		}
	}
}
function confirmaExclusaoItemUsuario(id,pagina){
	if (confirm("Deseja realmente excluir item?")){
		document.location.href = pagina+".php?&id="+id+"&acao=remover";
	} else {
		return false;
	}	
}
function confirmaExclusaoPonto(id,tipo){
	if (confirm("Deseja realmente excluir item?")){
		document.location.href = "pontuacao.php?usuario="+tipo+"&id="+id+"&acao=remover";
	} else {
		return false;
	}	
}

function trocaSemestre(page,semestre,id){
	part = semestre.split("/");
	var cont = "";
	if (id != ""){
		cont += "&id="+id;
	}
	
	document.location.href = page+".php?semestre="+part[0]+"&ano="+part[1]+cont;
}

function atualizaVencedor(campo,tipo){
	if (tipo == "V"){
		var url = "../../scripts/ajax.php?busca=vendedores";
	} else {
		var url = "../../scripts/ajax.php?busca=tecnicos";
	}
	
	ajax = ajaxInit();
	ajax.open("GET",url,false);
	ajax.send(null);	
	
	var div = document.getElementById("vencedor");
	div.innerHTML = "&nbsp;<select name='idVencedor'>" + 
	"<option value=''>-- Selecione --</option>" + 
	ajax.responseText + "</select>";
}
function validaCNPJ(CNPJ) {
	erro = new String;
	if (CNPJ.length < 18) erro += "É necessario preencher corretamente o número do CNPJ! \n\n";
	if ((CNPJ.charAt(2) != ".") || (CNPJ.charAt(6) != ".") || (CNPJ.charAt(10) != "/") || (CNPJ.charAt(15) != "-")){
		if (erro.length == 0) erro += "É necessário preencher corretamente o número do CNPJ! \n\n";
	}
	//substituir os caracteres que não são números
	if(document.layers && parseInt(navigator.appVersion) == 4){
		   x = CNPJ.substring(0,2);
		   x += CNPJ. substring (3,6);
		   x += CNPJ. substring (7,10);
		   x += CNPJ. substring (11,15);
		   x += CNPJ. substring (16,18);
		   CNPJ = x;
	} else {
		   CNPJ = CNPJ. replace (".","");
		   CNPJ = CNPJ. replace (".","");
		   CNPJ = CNPJ. replace ("-","");
		   CNPJ = CNPJ. replace ("/","");
	}
	var nonNumbers = /\D/;
	if (nonNumbers.test(CNPJ)) erro += "A verificação de CNPJ suporta apenas números! \n\n";
	var a = [];
	var b = new Number;
	var c = [6,5,4,3,2,9,8,7,6,5,4,3,2];
	for (i=0; i<12; i++){
	   a[i] = CNPJ.charAt(i);
	   b += a[i] * c[i+1];
	}
	if ((x = b % 11) < 2) { a[12] = 0 } else { a[12] = 11-x }
	b = 0;
	for (y=0; y<13; y++) {
		b += (a[y] * c[y]);
	}
	if ((x = b % 11) < 2) { a[13] = 0; } else { a[13] = 11-x; }
	if ((CNPJ.charAt(12) != a[12]) || (CNPJ.charAt(13) != a[13])){
		erro +="Dígito verificador com problema!";
	}
	if (erro.length > 0){
	   alert(erro);
	   return false;
	} else {
	  // alert("CNPJ valido!");
	}
	return true;
}
function validaCPF(cpf){
	var filtro = /^\d{3}.\d{3}.\d{3}-\d{2}$/i;
	if(!filtro.test(cpf)){
		window.alert("CPF inválido. Tente novamente.");
		return false;
	}
	
	cpf = remove(cpf, ".");
	cpf = remove(cpf, "-");
	
	if(cpf.length != 11 || cpf == "00000000000" || cpf == "11111111111" ||
	  	cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" ||
	 	cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" ||
	  	cpf == "88888888888" || cpf == "99999999999"){
	  	window.alert("CPF inválido. Tente novamente.");
	  	return false;
	}
	
	soma = 0;
	for(i = 0; i < 9; i++)
		soma += parseInt(cpf.charAt(i)) * (10 - i);
	resto = 11 - (soma % 11);
	if(resto == 10 || resto == 11)
		resto = 0;
	if(resto != parseInt(cpf.charAt(9))){
		window.alert("CPF inválido. Tente novamente.");
		return false;
	}
	soma = 0;
	for(i = 0; i < 10; i ++)
	 	soma += parseInt(cpf.charAt(i)) * (11 - i);
	resto = 11 - (soma % 11);
	if(resto == 10 || resto == 11)
	 	resto = 0;
	if(resto != parseInt(cpf.charAt(10))){
	 	window.alert("CPF inválido. Tente novamente.");
	 	return false;
	}
	return true;
}

function remove(str, sub) {
	i = str.indexOf(sub);
   	r = "";
   	if (i == -1) return str;
   	r += str.substring(0,i) + remove(str.substring(i + sub.length), sub);
   	return r;
}
function votar(idEnquete){
	radioObj = document.getElementById('enquete').opcao;
	var radioLength = radioObj.length;
	var valor = 0;
	if(radioLength == undefined){
		if(radioObj.checked){
			valor = radioObj.value;
		}
	}
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			valor = radioObj[i].value;
		}
	}

	
	var url = "scripts/ajax.php?acao=votacao&enquete="+idEnquete+"&voto="+valor;
	
	ajax = ajaxInit();
	ajax.open("GET",url,false);
	ajax.send(null);
 	var div = document.getElementById("conteudoEnquete");

	if (ajax.responseText == 1){
		div.innerHTML = "<p class='pIntro'>Agradecemos pela sua participação!</p>";
	}
}

function carregaRep(estado){
	var url = "scripts/ajax.php?acao=votacao&busca=representantes&estado="+estado;
	
	ajax = ajaxInit();
	ajax.open("GET",url,false);
	ajax.send(null);
 	var div = document.getElementById("listaRepresentantes");
	
	if (ajax.responseText != ''){
		div.innerHTML = ajax.responseText;
	}
}
var idAtual = null;
function slideDiv(id){
	// Se nenhuma div está aberta, abre a selecionada
	if (idAtual == null){
		var divAtual = $("#faq"+id);
		idAtual = id;
		divAtual.slideDown('slow');
	} else { // Existe uma div aberta
		if (idAtual == id){ // Se for clicado na div de mesmo id, fecha ela
			$("#faq"+id).slideUp('slow');
			idAtual = null;
		} else { // Se a div selecionada for outra, fecha a anterior e abre esta
			$("#faq"+divAtual).slideUp('slow');
			divAtual = id;
			$("#faq"+id).slideDown('slow');
		}
	}
}

function enviaMail(){
	var email = document.getElementById('email').value;
	var login = document.getElementById('login').value;
	
	if (login == ''){
		alert("Seu login de cadastro deve ser informado!");
	 	document.getElementById('login').focus();
		return false;
	}
	if (email == ''){
		alert("Seu email de cadastro deve ser informado!");
	 	document.getElementById('email').focus();
		return false;
	}
	var url = "../scripts/ajax.php?acao=recuperarSenha&email="+email+"&login="+login;
	
	ajax = ajaxInit();
	ajax.open("GET",url,false);
	ajax.send(null);
 	var div = document.getElementById("recSenha");
	
	if (ajax.responseText == 0){
		document.getElementById("mensagem").innerHTML = '<span style="font-color:#F00;">Email não encontrado. Favor informe outro email.</span>';
	} else if (ajax.responseText == 1){
		div.innerHTML = "<div style='text-align:center;'>Um lembrete foi enviado para o email fornecido.</div>";
	}
}
Shadowbox.init({
    language: 'en',
    players:  ['img', 'html', 'iframe', 'swf']
});

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
