// Funções especiais	
function tabnavSelected(id){
	var obj = document.getElementById(id);
	var ger = document.getElementById("ger");
	var nut = document.getElementById("nut");
	var art = document.getElementById("art");
	
	ger.style.background = "#CCCCCC";
	nut.style.background = "#CCCCCC";
	art.style.background = "#CCCCCC";
	
	obj.style.background = "#FEFAE9";	
}

function ajustaConteudo(tamanho){
	var obj = document.getElementById("conteudo");
	
	obj.style.height = tamanho;	
}

function txtBoxFormat(objForm, strField, sMask, evtKeyPress) {
     var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;

     if(document.all) { // Internet Explorer
       nTecla = evtKeyPress.keyCode; }
     else { // Mozilla
       nTecla = evtKeyPress.which;
     }


     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 if (nTecla == 8){
	 nCount=nCount--;
       }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;
     }
}

function validaDetalhes()
{
	var erro=false;
	var mensagem="Você deve preencher antes: \n";
	if(document.int.corr_senha.value != document.int.conf_senha.value){
		mensagem="Senha não confere! \n";
		erro=true;
	}
		
	if(erro) alert(mensagem);
	return !(erro);
}

//Função que envia o formulário
function enviarForm(url, campos, destino) {
	var elemento = document.getElementById(destino); //Atribui à variável 'elemento' o elemento que irá receber a página postada
	objetoXML(); //Executa a função objetoXML()
	if (!xmlhttp) { //Se o objeto de 'xmlhttp' não estiver true
		elemento.innerHTML = 'Impossível iniciar o objeto XMLHttpRequest.'; //Insere no 'elemento' o texto atribuído
		return;
	} else { //Senão
		elemento.innerHTML = 'Carregando...'; //Insere no 'elemento' o texto atribuído
	}
	xmlhttp.onreadystatechange = function () {
    	if (xmlhttp.readyState == 4 || xmlhttp.readyState == 0) { //Se a requisição estiver completada
    		if (xmlhttp.status == 200) { //Se o status da requisição estiver OK
    			elemento.innerHTML = xmlhttp.responseText; //Insere no 'elemento' a página postada
    		} else { //Senão
    			elemento.innerHMTL = 'Página não encontrada!'; //Insere no 'elemento' o texto atribuído
    		}
    	}
	}
	xmlhttp.open('POST', url+'?'+campos, true); //Abre a página que receberá os campos do formulário
	xmlhttp.send(campos); //Envia o formulário com dados da variável 'campos' (passado por parâmetro)
}

function setarContato() {	
		campos = "nome="+encodeURI(document.getElementById('inome').value);
		campos += "&telefone="+encodeURI(document.getElementById('itelefone').value);
		campos += "&email="+encodeURI(document.getElementById('iemail').value);
		campos += "&cep="+encodeURI(document.getElementById('icep').value);
		campos += "&assunto="+encodeURI(document.getElementById('iassunto').value);
		campos += "&contato="+encodeURI(document.getElementById('icontato').value);
}

function setarDisponivel() {	
		campos = "nome="+encodeURI(document.getElementById('inome').value);
		campos += "&email="+encodeURI(document.getElementById('iemail').value);
		campos += "&item="+encodeURI(document.getElementById('iitem').value);
}

function setarNews() {	
		campos = "nome="+encodeURI(document.getElementById('inomeNews').value);
		campos += "&email="+encodeURI(document.getElementById('iemailNews').value);
}

function setarPesquisa() {	
		campos = "icampo="+encodeURI(document.getElementById('icampo').value);
		campos += "&tp=pesq";
		campos += "&pesq=Palavra pesquisada: "+encodeURI(document.getElementById('icampo').value);
		campos += "&pgini=0";
}

function setarInscricao() {	
		campos = "nome="+encodeURI(document.getElementById('nome').value);
		campos += "&email="+encodeURI(document.getElementById('email').value);
		campos += "&profissao="+encodeURI(document.getElementById('profissao').value);
		campos += "&outros="+encodeURI(document.getElementById('outros').value);
		campos += "&cidade="+encodeURI(document.getElementById('cidade').value);
		campos += "&telefone="+encodeURI(document.getElementById('email').telefone);
		campos += "&celular="+encodeURI(document.getElementById('celular').celular);
}

function setarCorrida() {	
		campos = "nome="+encodeURI(document.getElementById('nome').value);
		campos += "&email="+encodeURI(document.getElementById('email').value);
		campos += "&endereco="+encodeURI(document.getElementById('endereco').value);
		campos += "&bairro="+encodeURI(document.getElementById('bairro').value);
		campos += "&cep="+encodeURI(document.getElementById('cep').value);
		campos += "&cidade="+encodeURI(document.getElementById('cidade').value);
		campos += "&estado="+encodeURI(document.getElementById('estado').value);
		campos += "&pais="+encodeURI(document.getElementById('pais').value);
		campos += "&telefone="+encodeURI(document.getElementById('cidade').value);
		campos += "&nascimento="+encodeURI(document.getElementById('nascimento').value);
		campos += "&idade="+encodeURI(document.getElementById('idade').value);
		campos += "&sexo="+encodeURI(document.getElementById('sexo').value);
}

function setarCarrinho() {	
		campos = "tamanho="+encodeURI(document.getElementById('tamanho').value);
		campos += "&saborcor="+encodeURI(document.getElementById('saborcor').value);
		campos += "&prodId="+encodeURI(document.getElementById('prodId').value);
		campos += "&quantidade="+encodeURI(document.getElementById('quantidade').value);
}
