// JavaScript Document

var tempoTooltip = ""
function tooltip(obj, x, y){
	/*texto = obj.getAttribute("legenda");
	if(texto!='') {
		obj.setAttribute("onmouseout","escondeElemento('div-tooltip'); window.clearTimeout(tempoTooltip);document.getElementById('"+obj.id+"').focus();");
	
		if(document.getElementById('div-tooltip')) {
			document.body.removeChild(document.getElementById('div-tooltip'));
			window.clearTimeout(tempoTooltip);
		}
		janela = document.createElement("div");
		janela.setAttribute("id","div-tooltip");
		
		tabela = "<table width='100%' height='100%' cellpadding='0' cellspacing='0'>";
		tabela+= "<tr><td class='c1r1'></td><td class='c2r1'></td><td class='c3r1'></td></tr>";
		tabela+= "<tr><td class='c1r2'></td><td class='c2r2'>"+texto+"</td><td class='c3r2'></td></tr>";
		tabela+= "<tr><td class='c1r3'></td><td class='c2r3'></td><td class='c3r3'></td></tr>";
		tabela+="</table>";

		
		janela.innerHTML = tabela;
		var antesDeu = document.getElementsByTagName("div")[0];
		document.body.insertBefore(janela, antesDeu);	
		janela.style.marginLeft = (x+5)+"px";
		janela.style.marginTop = (y+5)+"px";
		janela.focus();	

		obj.style.display = '';
		obj.focus();
		return false;
	}*/
}

function posicaoX(event){
	if(navigator.appName == "Microsoft Internet Explorer"){
		x = event.clientX + document.documentElement.scrollLeft;
		y = event.clientY + document.documentElement.scrollTop;
	}else{
		x = event.clientX + window.pageXOffset;
		y = event.clientY + window.pageYOffset;
	}
	return x;
}

function posicaoY(event){
	if(navigator.appName == "Microsoft Internet Explorer"){
		x = event.clientX + document.documentElement.scrollLeft;
		y = event.clientY + document.documentElement.scrollTop;
	}else{
		x = event.clientX + window.pageXOffset;
		y = event.clientY + window.pageYOffset;
	}
	return y;
}

function getValue(obj) {
	return document.getElementById(obj).value;
}

function setValue(obj,valor) {
	document.getElementById(obj).value=valor;
}

function getInnerHTML(obj) {
	return document.getElementById(obj).innerHTML;
}

function setInnerHTML(obj,valor) {
	document.getElementById(obj).innerHTML=valor;
}

function getAtributo(obj,atributo) {
	return document.getElementById(obj).getAttribute(atributo);
}

function setAtributo(obj,valor) {
	document.getElementById(obj).setAttribute(atributo,valor);
}


function ValidaForm(formulario){
	erro=0;
    for(x=0; x<document.forms[formulario].length; x++){
    	if(document.forms[formulario].elements[x].getAttribute("obrigatorio")==1){
    		if(document.forms[formulario].elements[x].value=="" || document.forms[formulario].elements[x].value==document.forms[formulario].elements[x].getAttribute("valorpadrao")){
    			erro++;
    		}
    	}
    }
    if(erro>0){
    	alert("Favor preencher todos os campos corretamente.")
    	return false;
    }else{
    	document.forms[formulario].submit();
    	return true;
    }
}

function desceElemento(elemento){
	//document.getElementById(elemento).style.display = '';
	new Effect.SlideDown(elemento);
}

function sobeElemento(elemento){
	new Effect.SlideUp(elemento);
	//window.setTimeout("document.getElementById('"+elemento+"').style.display = 'none';",1000);
}

function mostraElemento(elemento){
	document.getElementById(elemento).style.display = '';
	new Effect.Appear(elemento,{duration:1, from:0, to:1.0});
}

function escondeElemento(elemento){
	new Effect.Appear(elemento,{duration:1, from:1.0, to:0});
	window.setTimeout("document.getElementById('"+elemento+"').style.display = 'none';",1000);
}

function mostraValorPesquisa(valor){
	if(valor.indexOf('dat')>=0){
		document.getElementById('inputValor').value='';
		document.getElementById('inputValor').onkeyup=new Function("mascaradata(this.value, this)");
	}else{
		document.getElementById('inputValor').onkeyup="";
		document.getElementById('inputValor').value='';
	}
}

function mostraConteudo(aux){
	document.getElementById('conteudo-1').style.display='none';
	document.getElementById('conteudo-2').style.display='none';
	document.getElementById('conteudo-3').style.display='none';
	document.getElementById('conteudo-4').style.display='none';
	document.getElementById('conteudo-'+aux).style.display='';
	
	document.getElementById('botao-1').className='';
	document.getElementById('botao-2').className='';
	document.getElementById('botao-3').className='';
	document.getElementById('botao-4').className='';
	document.getElementById('botao-'+aux).className='this';
}

function mudabanner(img){
	document.getElementById('imgbanner').src = 'central/banner/img/'+img;
}


function comprar_front(idproduto, valor){
    var ajaxUC = ajaxInit();
	ajaxUC.open("GET", "central/func/comprar.php?idproduto="+idproduto+"&valor="+valor,true);
	ajaxUC.onreadystatechange = function() {
		if(ajaxUC.readyState == 4) {
			if(ajaxUC.status == 200) {
				var valor = ajaxUC.responseText;
                //carrinho();                
            }else{
                alert(ajaxUC.responseText);
            }
		}
	}
	ajaxUC.send(null);
}

function cadastrarEmail(){
	var email = document.getElementById('email-newsletter').value;
    var ajaxUC = ajaxInit();
	ajaxUC.open("GET", "central/func/newsletter.php?email="+email,true);
	ajaxUC.onreadystatechange = function() {
		if(ajaxUC.readyState == 4) {
			if(ajaxUC.status == 200) {
				var valor = ajaxUC.responseText;
                document.getElementById('email-newsletter').value = '';
				alert('Obrigado por se inscrever no nosso Newsletter !!');
            }else{
                alert(ajaxUC.responseText);
            }
		}
	}
	ajaxUC.send(null);

}

var atualPaginaBanner = 1;
var totalPaginaBanner = 5;

function paginaBanner(acao){
	nome = "banner_lista";
	anterior = atualPaginaBanner-1;
	proxima = atualPaginaBanner+1;
	if(acao=='anterior'){
		if(anterior>0){
			atualPaginaBanner--;
			aux = "" + 678;
			new Effect.Move(nome, { x: aux, y: 0, mode: 'relative' });
		}else{
			atualPaginaBanner=totalPaginaBanner;
			aux = "" + (678*totalPaginaBanner);
			new Effect.Move(nome, { x: aux, y: 0, mode: 'relative' });
		}
	}else{
		if(proxima <= totalPaginaBanner) {
			atualPaginaBanner++;
			aux = "-" + 678;
			new Effect.Move(nome, { x: aux, y: 0, mode: 'relative' });
		}else{
			atualPaginaBanner=1;
			aux = "" + (678*(totalPaginaBanner-1));
			new Effect.Move(nome, { x: aux, y: 0, mode: 'relative' });			
		}
	}
}


function bannerRoda(pos){
	window.clearInterval(IntervaloBanner);
	nome = "banner_lista";
	if(pos>atualPaginaBanner){
		aux = "-" + (678*(pos-atualPaginaBanner));
		new Effect.Move(nome, { x: aux, y: 0, mode: 'relative' });
	}else{
		aux = "" + (678*(atualPaginaBanner-pos));
		new Effect.Move(nome, { x: aux, y: 0, mode: 'relative' });
	}
	atualPaginaBanner=pos;

}

function mudaCampoTabela(tabela, campo, id, valor){
	
	document.getElementById("ativo"+id).style.background = 'yellow';
   var ajaxUC = ajaxInit();
	ajaxUC.open("GET", "../includes/func_muda_campo.php?tabela="+tabela+"&campo="+campo+"&valor="+valor+"&id="+id,true);
	ajaxUC.onreadystatechange = function() {
		if(ajaxUC.readyState == 4) {
			if(ajaxUC.status == 200) {
				document.getElementById("ativo"+id).style.background = 'blue';
         }else{
         	document.getElementById("ativo"+id).style.background = 'red';
            alert('Ocorreu um erro.');
         }
		}
	}
	ajaxUC.send(null);

}


function maisFlores(){
    var ajaxUC = ajaxInit();
	ajaxUC.open("GET", "central/func/flor.php",true);
	ajaxUC.onreadystatechange = function() {
		if(ajaxUC.readyState == 4) {
			if(ajaxUC.status == 200) {
				var valor = ajaxUC.responseText;
				//arr = valor.split('|');
				//document.getElementById('foto-flor').style.background = arr[0];
				//document.getElementById('TextoDescricaoFlores').innerHTML = arr[1];
				document.getElementById('flores').innerHTML = valor;
				correctPNG();
				window.setTimeout("maisFlores()", 10000);
            }else{
                alert(ajaxUC.responseText);
            }
		}
	}
	ajaxUC.send(null);

}



/////////////////////


function comprar(idproduto, valor){
    var ajaxUC = ajaxInit();
	ajaxUC.open("GET", "../func/comprar.php?idproduto="+idproduto+"&valor="+valor,true);
	ajaxUC.onreadystatechange = function() {
		if(ajaxUC.readyState == 4) {
			if(ajaxUC.status == 200) {
				var valor = ajaxUC.responseText;
                carrinho();                
            }else{
                alert(ajaxUC.responseText);
            }
		}
	}
	ajaxUC.send(null);

}

function carrinho(){
    var ajaxUC = ajaxInit();
	ajaxUC.open("GET", "../func/carrinho.php",true);
	ajaxUC.onreadystatechange = function() {
		if(ajaxUC.readyState == 4) {
			if(ajaxUC.status == 200) {
				var valor = ajaxUC.responseText;
				document.getElementById('carrinho').innerHTML=valor;
                var valorfinal = document.getElementById('valorfinal');
                if(valorfinal!='undefined'){
                   totalCarrinho();
                }else{
                    alert(valorfinal);
                }
                
			}else{
                alert(ajaxUC.responseText);
            }
		}
	}
	ajaxUC.send(null);
}

function totalCarrinho(){
    var ajaxUC = ajaxInit();
	ajaxUC.open("GET", "../func/carrinho_total.php",true);
	ajaxUC.onreadystatechange = function() {
		if(ajaxUC.readyState == 4) {
			if(ajaxUC.status == 200) {
				var taxa = document.getElementById('taxaentrega').value;
				taxa = taxa.replace(',','.');
				if(taxa==''){taxa=0}
				var valor = ajaxUC.responseText;
				valor = valor.replace(',','.');
				total = (eval(valor) + eval(taxa)) + '';
				total = total.replace('.',',');
				document.getElementById('valorfinal').value = total;
			}else{
                alert(ajaxUC.responseText);
            }
		}
	}
	ajaxUC.send(null);
}

function excluirCarrinho(id){
    var ajaxUC = ajaxInit();
	ajaxUC.open("GET", "../func/carrinho_excluir.php?id="+id,true);
	ajaxUC.onreadystatechange = function() {
		if(ajaxUC.readyState == 4) {
			if(ajaxUC.status == 200) {
				carrinho();
			}else{
                alert(ajaxUC.responseText);
            }
		}
	}
	ajaxUC.send(null);
}

function AddOpcao(combo, valor, strDescricao){
	var novaOpcao = new Option(strDescricao, valor);
	combo.options[combo.length] = novaOpcao;
	combo.options[combo.length].selected = true;
}

function DelOpcao(combo, strIndice){
	combo.options.remove(strIndice);
}

function editaLinha(idobj, tabela, id, campo, tipo){
	var obj = document.getElementById(idobj);
	var valor = obj.innerHTML;
	var mascara = "";
	if(tipo=='datetime'){
		mascara = " onkeyup=\"mascaradata(this.value, this)\"";
	}
	obj.innerHTML = "<input id=\""+idobj+campo+"ED\" type=\"text\" value=\""+valor+"\" antigo=\""+valor+"\" name=\"campo\" class=\"inputText\" style=\"width: 90%\" onblur=\"atualizaLinha('"+idobj+"', this.value, '"+tabela+"', "+id+", '"+campo+"', '"+tipo+"')\" onkeypress=\"if(event.keyCode == '13'){atualizaLinha('"+idobj+"', this.value, '"+tabela+"', "+id+", '"+campo+"', '"+tipo+"')}else if(event.keyCode=='27'){cancelaLinha('"+idobj+"', this.getAttribute('antigo'))}\" "+mascara+">";
	objaux = document.getElementById(idobj+campo+"ED");
	objaux.focus();
}

function cancelaLinha(idobj, valor){
	obj = document.getElementById(idobj);
	obj.innerHTML = "CANCELADO";
	window.setTimeout("document.getElementById('"+idobj+"').innerHTML='"+valor+"'", 2000);
}

function atualizaLinha(idobj, valor, tabela, id, campo, tipo){
	obj = document.getElementById(idobj);
	url = "../includes/atualiza_campo.php?id="+id+"&tabela="+tabela+"&campo="+campo+"&valor="+valor+"&tipo="+tipo;
	var ajaxUC = ajaxInit();
	ajaxUC.open("GET", url,true);
	ajaxUC.onreadystatechange = function() {
		if(ajaxUC.readyState == 4) {
			if(ajaxUC.status == 200) {
				document.getElementById(idobj).style.color = 'blue';
				obj.innerHTML="ATUALIZADO";
				window.setTimeout("document.getElementById('"+idobj+"').innerHTML='"+valor+"'; document.getElementById('"+idobj+"').style.fontWeight = 'normal'; document.getElementById('"+idobj+"').style.color = 'black';",2000);
				
			}else{
				document.getElementById(idobj).style.color = 'red';
				obj.innerHTML="ERRO";
				window.setTimeout("document.getElementById('"+idobj+"').innerHTML='"+valor+"'; document.getElementById('"+idobj+"').style.fontWeight = 'normal'; document.getElementById('"+idobj+"').style.color = 'black';",2000);				
			}
		}
	}
	ajaxUC.send(null);
}


function enviarCadastro(){
	//inputs = document.forms[0].elements;
	inputs = document.getElementsByTagName("input");
	erro=0;
	nome = "";
	tam = inputs.length;
	if(tam>20){
		tam=21;
	}
	cont=0;
	for(x=0; x<=tam-1; x++){
		aux = inputs[x];
		if(aux.getAttribute('obrigatorio')=="sim"){
			if(aux.value==''){
				erro=1;
				cont++;
				nome += cont+".)  "+aux.getAttribute('name')+"\n";
			}
		}
	}
	
	if(erro==1){
		alert("Preencher os campos obrigatarios abaixo: \n\n" + nome);
	}else{
		document.forms[0].submit();
	}
}

function abcPesquisa(valor){
	document.getElementById("inputInicio").value = 1;
	document.getElementById("inputValor").value = valor;
	document.forms[0].submit();	
}

function funcListaParceiro(idevento){
	var ajaxUC = ajaxInit();
	ajaxUC.open("GET", "../classes/parceiro_listaevento.php?idevento="+idevento,true);
	ajaxUC.onreadystatechange = function() {
		if(ajaxUC.readyState == 4) {
			if(ajaxUC.status == 200) {
				var valor = ajaxUC.responseText;
				document.getElementById('parceirolista').innerHTML = valor;

			}
		}
	}
	ajaxUC.send(null);
}

function mascaradata(S,campo){
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++){
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=8) {
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 4 ){if (Digitos.indexOf(digito)>=0){temp = "/"+ S.charAt(0) + S.charAt(1) + S.charAt(2) + S.charAt(3)}}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"/"+ S.charAt(1) + S.charAt(2) + S.charAt(3) + S.charAt(4)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = "/"+ S.charAt(0) + S.charAt(1) +"/"+ S.charAt(2) + S.charAt(3) + S.charAt(4) + S.charAt(5)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"/"+ S.charAt(1) + S.charAt(2) +"/"+ S.charAt(3) + S.charAt(4) + S.charAt(5)+ S.charAt(6)}}
			if (numero == 8 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"/"+ S.charAt(2) + S.charAt(3) +"/"+ S.charAt(4) + S.charAt(5) + S.charAt(6)+ S.charAt(7)}}
		}
	}
    campo.value = temp;
}

function mascaradatahora(S,campo){
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++){
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=14) {
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"/"+ S.charAt(1) + S.charAt(2) + S.charAt(3) + S.charAt(4)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = "/"+ S.charAt(0) + S.charAt(1) +"/"+ S.charAt(2) + S.charAt(3) + S.charAt(4) + S.charAt(5)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"/"+ S.charAt(1) + S.charAt(2) +"/"+ S.charAt(3) + S.charAt(4) + S.charAt(5)+ S.charAt(6)}}
			if (numero == 8 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"/"+ S.charAt(2) + S.charAt(3) +"/"+ S.charAt(4) + S.charAt(5) + S.charAt(6)+ S.charAt(7)}}
			if (numero == 9 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) +" "+ S.charAt(3) + S.charAt(4) + ":" + S.charAt(5) + S.charAt(6) + ":" + S.charAt(7)+ S.charAt(8)}}
			if (numero == 10 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) + S.charAt(3) +" "+ S.charAt(4) + S.charAt(5) + ":" + S.charAt(6) + S.charAt(7) + ":" + S.charAt(8)+ S.charAt(9)}}
			if (numero == 11 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + "/" + S.charAt(1) + S.charAt(2) + S.charAt(3) + S.charAt(4) + " " + S.charAt(5) + S.charAt(6) + ":" + S.charAt(7) + S.charAt(8) + ":" + S.charAt(9)+ S.charAt(10)}}
			if (numero == 12 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "/" + S.charAt(2) + S.charAt(3) + S.charAt(4) + S.charAt(5) + " " + S.charAt(6) + S.charAt(7) + ":" + S.charAt(8) + S.charAt(9) + ":" + S.charAt(10)+ S.charAt(11)}}
			if (numero == 13 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + "/" + S.charAt(1) + S.charAt(2) + "/" + S.charAt(3) + S.charAt(4) + S.charAt(5) + S.charAt(6) + " " + S.charAt(7) + S.charAt(8) + ":" + S.charAt(9) + S.charAt(10) + ":" + S.charAt(11)+ S.charAt(12)}}
			if (numero == 14 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "/" + S.charAt(2) + S.charAt(3) + "/" + S.charAt(4) + S.charAt(5) + S.charAt(6) + S.charAt(7) + " "+ S.charAt(8) + S.charAt(9) + ":" + S.charAt(10) + S.charAt(11) + ":" + S.charAt(12)+ S.charAt(13)}}
		}
	}
    campo.value = temp;
}

function mascarahora(S,campo){
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++){
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=5) {
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 3 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + ":" + S.charAt(1)+ S.charAt(2)}}
			if (numero == 4 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + ":" + S.charAt(2)+ S.charAt(3)}}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + ":" + S.charAt(1) + S.charAt(2) + ":" + S.charAt(3)+ S.charAt(4)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + ":" + S.charAt(2) + S.charAt(3) + ":" + S.charAt(4)+ S.charAt(5)}}
		}
	}
    campo.value = temp;
}

function mascaracep(S,campo){
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++){
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=6) {
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 3 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + "-" + S.charAt(1) + S.charAt(2) + S.charAt(3)}}
			if (numero == 4 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "-" + S.charAt(2) + S.charAt(3) + S.charAt(4)}}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) + "-" + S.charAt(3) + S.charAt(4) + S.charAt(5)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + "." + S.charAt(1) + S.charAt(2) + S.charAt(3) + "-" + S.charAt(4) + S.charAt(5) + S.charAt(6)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "." + S.charAt(2) + S.charAt(3) + S.charAt(4) + "-" + S.charAt(5) + S.charAt(6) + S.charAt(7)}}
		}
	}
//	document.formulario.CGC.value = temp;
    campo.value = temp;
}

function Money_2_Java(num){
	novo_num = num;
	for(z=0;novo_num.lastIndexOf(".")>-1;z++){
		ult_ponto = novo_num.lastIndexOf(".");
		novo_num = novo_num.substring(0,ult_ponto) + novo_num.substring(ult_ponto+1,novo_num.length);
	}
	ult_virg = novo_num.lastIndexOf(",");
	if (ult_virg > -1){
		novo_num = novo_num.substring(0,ult_virg) + "." + novo_num.substring(ult_virg+1,novo_num.length);
	}
	return novo_num
}

function NumJava_2_Money(num){
	virg = false;
	novo_num = "";
	num = "" + num
	if (num.lastIndexOf(".") == -1){
		virg = true;
		ponto = 0
	}
	for(i=0;i<num.length;i++){
		if(num.substring(num.length-i-1,num.length-i) == "."){
			if (!virg){
				virg = true;
				ponto = 0;
				novo_num = "," + novo_num;
			}
		}else{
			if(virg){
				if (ponto == 3 && num.substring(num.length-i-1,num.length-i) != "-"){
					ponto = 0
					novo_num = "." + novo_num
				}
				ponto = ponto + 1
			}
			novo_num = num.substring(num.length-i-1,num.length-i) + novo_num;
		}
	}
	if (novo_num.lastIndexOf(",") == -1){
		novo_num = novo_num + ",00";
	}else if(novo_num.lastIndexOf(",") == novo_num.length - 2){
		novo_num = novo_num + "0";
//	}else{
//		novo_num = novo_num.substring(0,novo_num.lastIndexOf(",")) + novo_num.substring(novo_num.lastIndexOf(",") + 1,2);
	}
	return novo_num
}

function mascarafone(S,campo){
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++){
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=10) {
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"-"+ S.charAt(1) + S.charAt(2) + S.charAt(3) + S.charAt(4)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"-"+ S.charAt(2) + S.charAt(3) + S.charAt(4) + S.charAt(5)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) +"-"+ S.charAt(3) + S.charAt(4) + S.charAt(5)+ S.charAt(6)}}
			if (numero == 8 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) + S.charAt(3) +"-"+ S.charAt(4) + S.charAt(5) + S.charAt(6) + S.charAt(7)}}
			if (numero == 9 ){if (Digitos.indexOf(digito)>=0){temp = "(" + S.charAt(0) + ") " + S.charAt(1) + S.charAt(2) + S.charAt(3) + S.charAt(4) +"-"+ S.charAt(5) + S.charAt(6) + S.charAt(7)+ S.charAt(8)}}
			if (numero == 10 ){if (Digitos.indexOf(digito)>=0){temp = "(" + S.charAt(0) + S.charAt(1) + ") " + S.charAt(2) + S.charAt(3) + S.charAt(4) + S.charAt(5) +"-"+ S.charAt(6) + S.charAt(7) + S.charAt(8)+ S.charAt(9)}}
		}
	}
//	document.formulario.CGC.value = temp;
    campo.value = temp;
}

function mascaranumero(S,campo){
	var Digitos = "0123456789";
	S = limpa_string(Money_2_Java(S));
	ini_z = false
	sem_zero = ""
	for (var i=0; i<S.length; i++){
		if (ini_z == true || S.charAt(i) != "0"){
			ini_z = true;
			sem_zero = sem_zero + S.charAt(i);
		}
	}
	S = sem_zero;
	a_virg = "";
	numero = 0;
   	for (var i=0; i<S.length - 2; i++){
	  	numero = numero + 1;
	  	digito = S.charAt(i);
		if (Digitos.indexOf(digito)>=0){a_virg = a_virg + digito}
	}

 	if (S.length == 1){
		temp = "0.0" + S;
		temp = NumJava_2_Money(temp);
	}else if (S.length == 2){
		temp = "0." + S;
		temp = NumJava_2_Money(temp);
	}else if (S.length > 2){
		temp = a_virg + "." + S.charAt(S.length-2) + S.charAt(S.length-1);
		temp = NumJava_2_Money(temp);
	}else{
		temp = S;
	}
	if (eval(Money_2_Java(temp)) == 0){temp = "";}
	if(temp=="")
	{temp = "0,00"}
    campo.value = temp;
}

function mascarapeso(S,campo){
	var Digitos = "0123456789";
	S = limpa_string(Money_2_Java(S));
	ini_z = false
	sem_zero = ""
	for (var i=0; i<S.length; i++){
		if (ini_z == true || S.charAt(i) != "0"){
			ini_z = true;
			sem_zero = sem_zero + S.charAt(i);
		}
	}
	S = sem_zero;
	a_virg = "";
	numero = 0;
   	for (var i=0; i<S.length - 3; i++){
	  	numero = numero + 1;
	  	digito = S.charAt(i);
		if (Digitos.indexOf(digito)>=0){a_virg = a_virg + digito}
	}
	if (S.length == 1){
		temp = "0.00" + S
		temp = NumJava_2_Money(temp);
	}else if (S.length == 2){
		temp = "0.0" + S
		temp = NumJava_2_Money(temp);
	}else if (S.length == 3){
		temp = "0." + S
		temp = NumJava_2_Money(temp);
	}else if (S.length > 3){
		temp = a_virg + "." + S.charAt(S.length-3) + S.charAt(S.length-2) + S.charAt(S.length-1);
		temp = NumJava_2_Money(temp);
	}else{
		temp = S;
	}
	if (eval(Money_2_Java(temp)) == 0){temp = "";}
	if(temp=="")
	{temp = "0.00"}
    campo.value = temp;
}

function mascaranumero2(S,campo){
	var Digitos = "0123456789";
	S = limpa_string(Money_2_Java(S));
	ini_z = false
	sem_zero = ""
	for (var i=0; i<S.length; i++){
		if (ini_z == true || S.charAt(i) != "0"){
			ini_z = true;
			sem_zero = sem_zero + S.charAt(i);
		}
	}
	S = sem_zero;
	a_virg = "";
	numero = 0;
   	for (var i=0; i<S.length - 2; i++){
	  	numero = numero + 1;
	  	digito = S.charAt(i);
		if (Digitos.indexOf(digito)>=0){a_virg = a_virg + digito}
	}
	temp = S;
	if (eval(Money_2_Java(temp)) == 0){temp = "";}
    campo.value = temp;
}

function mascaracpfcnpj(S,campo){
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++){
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=13) {
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 2 ){temp = "-" + S.substring(S.length-2,S.length)}
			if (numero == 3 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"-"+ S.charAt(1) + S.charAt(2)}}
			if (numero == 4 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "-" + S.charAt(2) + S.charAt(3)}}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = "."+S.charAt(0) + S.charAt(1) + S.charAt(2) + "-" + S.charAt(3) + S.charAt(4)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"."+ S.charAt(1) + S.charAt(2) + S.charAt(3) + "-" + S.charAt(4) + S.charAt(5)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"."+ S.charAt(2) + S.charAt(3) + S.charAt(4) + "-" + S.charAt(5)+ S.charAt(6)}}
			if (numero == 8 ){if (Digitos.indexOf(digito)>=0){temp = "."+S.charAt(0) + S.charAt(1) + S.charAt(2) +"."+ S.charAt(3) + S.charAt(4) + S.charAt(5) + "-" + S.charAt(6)+ S.charAt(7)}}
			if (numero == 9 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"."+ S.charAt(1) + S.charAt(2) + S.charAt(3) +"."+ S.charAt(4) + S.charAt(5) + S.charAt(6) + "-" + S.charAt(7)+ S.charAt(8)}}
			if (numero == 10){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"."+ S.charAt(2) + S.charAt(3) + S.charAt(4) +"."+ S.charAt(5) + S.charAt(6) + S.charAt(7) + "-" + S.charAt(8)+ S.charAt(9)}}
			if (numero == 11){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) +"."+ S.charAt(3) + S.charAt(4) + S.charAt(5) +"."+ S.charAt(6) + S.charAt(7) + S.charAt(8) + "-" + S.charAt(9) + S.charAt(10)}}
			if (numero == 12){if (Digitos.indexOf(digito)>=0){temp = "." + S.charAt(0) + S.charAt(1) + S.charAt(2) + "." + S.charAt(3) + S.charAt(4) + S.charAt(5) + "/" +  S.charAt(6) + S.charAt(7) + S.charAt(8) + S.charAt(9) + "-" + S.charAt(10) + S.charAt(11)}}
			if (numero == 13){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + "." +  S.charAt(1) + S.charAt(2) + S.charAt(3) +"."+ S.charAt(4) + S.charAt(5) + S.charAt(6) +"/"+ S.charAt(7) + S.charAt(8) + S.charAt(9) + S.charAt(10) +"-"+ S.charAt(11) + S.charAt(12)}}
			if (numero == 14){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "." + S.charAt(2) + S.charAt(3) + S.charAt(4) + "." + S.charAt(5) + S.charAt(6) + S.charAt(7) + "/" + S.charAt(8) + S.charAt(9) + S.charAt(10) + S.charAt(11) +"-"+ S.charAt(12) + S.charAt(13)}}
		}
	}
//	document.formulario.CGC.value = temp;
    campo.value = temp;
}

function mascaracnpjcol(S,campo){
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++){
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=11) {
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 2 ){temp = "-" + S.substring(S.length-2,S.length)}
			if (numero == 3 ){if (Digitos.indexOf(digito)>=0){temp = "." + S.charAt(0) + S.charAt(1) + S.charAt(2)}}
			if (numero == 4 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"."+ S.charAt(1) + S.charAt(2) + S.charAt(3)}}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"."+ S.charAt(2) + S.charAt(3) + S.charAt(4)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = "."+S.charAt(0) + S.charAt(1) + S.charAt(2) +"."+ S.charAt(3) + S.charAt(4) + S.charAt(5)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"."+ S.charAt(1) + S.charAt(2) + S.charAt(3) +"."+ S.charAt(4) + S.charAt(5) + S.charAt(6)}}
			if (numero == 8){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"."+ S.charAt(2) + S.charAt(3) + S.charAt(4) +"."+ S.charAt(5) + S.charAt(6) + S.charAt(7)}}
			if (numero == 9){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) +"."+ S.charAt(3) + S.charAt(4) + S.charAt(5) +"."+ S.charAt(6) + S.charAt(7) + S.charAt(8)}}
			if (numero == 10){if (Digitos.indexOf(digito)>=0){temp = "." + S.charAt(0) + S.charAt(1) + S.charAt(2) + "." + S.charAt(3) + S.charAt(4) + S.charAt(5) + "/" +  S.charAt(6) + S.charAt(7) + S.charAt(8) + S.charAt(9)}}
			if (numero == 11){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + "." +  S.charAt(1) + S.charAt(2) + S.charAt(3) +"."+ S.charAt(4) + S.charAt(5) + S.charAt(6) +"/"+ S.charAt(7) + S.charAt(8) + S.charAt(9) + S.charAt(10)}}
			if (numero == 12){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "." + S.charAt(2) + S.charAt(3) + S.charAt(4) + "." + S.charAt(5) + S.charAt(6) + S.charAt(7) + "/" + S.charAt(8) + S.charAt(9) + S.charAt(10) + S.charAt(11)}}
		}
	}
//	document.formulario.CGC.value = temp;
    campo.value = temp;
}

function limpa_string(S){
	// Deixa so' os digitos no numero
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
   	for (var i=0; i<S.length; i++){
      digito = S.charAt(i);
      if (Digitos.indexOf(digito)>=0){temp=temp+digito}
   	}
   return temp
}

function limpa_string_virg(S){
	// Deixa so' os digitos no numero
	var Digitos = "0123456789,.";
	var temp = "";
	var digito = "";
   	for (var i=0; i<S.length; i++){
	      digito = S.charAt(i);
	      if (Digitos.indexOf(digito)>=0){temp=temp+digito}
   	}
   return temp;
}

function valida_CPF(s){
	var i;
	s = limpa_string(s);
	var c = s.substr(0,9);
	var dv = s.substr(9,2);
	var d1 = 0;
	for (i = 0; i < 9; i++){
		d1 += c.charAt(i)*(10-i);
	}
        if (d1 == 0) return false;
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1){
		return false;
	}

	d1 *= 2;
	for (i = 0; i < 9; i++){
		d1 += c.charAt(i)*(11-i);
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1){
		return false;
	}
   return true;
}
function valida_CGC(s){
	var i;
	s = limpa_string(s);
	var c = s.substr(0,12);
	var dv = s.substr(12,2);

	var d1 = 0;
	for (i = 0; i < 12; i++){
		d1 += c.charAt(11-i)*(2+(i % 8));
	}
        if (d1 == 0) return false;
        d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1){
		return false;
	}

	d1 *= 2;
	for (i = 0; i < 12; i++){
		d1 += c.charAt(11-i)*(2+((i+1) % 8));
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1){
		return false;
	}
        return true;
}
function ltrim(string){
	inicio = false;
	nova_string = "";
	for (x=0;x<string.length;x++){
		if (string.charAt(x) != " "){
			inicio = true;
			nova_string = nova_string + string.charAt(x);
		}else if(inicio){
			nova_string = nova_string + string.charAt(x);
		}
	}
	return nova_string
}

var IntervaloBanner;

window.onload = function() {
	IntervaloBanner = window.setInterval("paginaBanner('proximo')",10000);	
}