// POP UP
function popup(theURL, width, height, features) { 
	//"location=no,menubar=no,resiable=no,toolbar=no,scroollbars=yes"
	if(window.screen){
		per_ancho=(width/screen.width)*100;
		per_alto=(height/width)*100;
		win_ancho=(screen.width*per_ancho)/100;
		win_alto=(win_ancho*per_alto)/100;
		x=(screen.width-win_ancho)/2;
		y=(screen.height-win_alto)/2;
	}else{
		x=0;
		y=0;
		win_ancho=w;
		win_alto=y;
	}
	winfeatures=("top="+y+",left="+x+",width="+win_ancho+",height="+win_alto+","+features);
	window.open(theURL, 'popup', winfeatures);
}

function nada() {
   return;
}
//FLASH
function flash(versao, largura, altura, nome, modo, cor)
{
	/*
	versao = 8 .................. <- Versão do player
	largura = 200px ............. <- Largura do SWF
	altura = 200px .............. <- Altura do SWF
	id = nome ................... <- ID do arquivo
	nome = arquivo.swf .......... <- Caminho do SWF, essa opção não pode ser vazia
	modo = transparent/opaque ... <- Flash transparente ou opaco / pode ser vazia
	cor = #ffffff ............... <- Cor de fundo
	*/
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version="'+versao+',0,0,0" width="'+largura+'" height="'+altura+'">\n');
	document.write('<param name="allowScriptAccess" value="sameDomain">\n');
	document.write('<param name="movie" value="'+nome+'">\n');
	document.write('<param name="wmode" value="'+modo+'">\n');
	document.write('<param name="bgcolor" value="'+cor+'">\n');
	document.write('<embed src="'+nome+'" wmode="'+modo+'" bgcolor="'+cor+'" width="'+largura+'" height="'+altura+'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">\n');
	document.write('</object>\n');
}
// DATA - ÍNICIO
function data() {
	mdata = new Date();
	mhora = mdata.getHours();
	mminuto = mdata.getMinutes();
	msegundos = mdata.getSeconds();
	mdia = mdata.getDate();
	mdiasemana = mdata.getDay();
	mmes = mdata.getMonth();
	mano = mdata.getFullYear();
	if (mdiasemana == 0) {
		document.write("'Domingo, ");
	} else if (mdiasemana == 1) {
		document.write("Segunda-feira, ");
	} else if (mdiasemana == 2) {
		document.write("Terça-feira, ");
	} else if (mdiasemana == 3) {
		document.write("Quarta-feira, ");
	} else if (mdiasemana == 4) {
		document.write("Quinta-feira, ");
	} else if (mdiasemana == 5) {
		document.write("Sexta-feira, ");
	} else if (mdiasemana == 6) {
		document.write("Sábado, ");
	}
	document.write(+mdia+' de ');
	if (mmes == 0) {
		document.write("janeiro de ");
	} else if (mmes == 1) {
		document.write("fevereiro de ");
	} else if (mmes == 2) {
		document.write("mar&ccedil;o de ");
	} else if (mmes == 3) {
		document.write("abril de ");
	} else if (mmes == 4) {
		document.write("maio de ");
	} else if (mmes == 5) {
		document.write("junho de ");
	} else if (mmes == 6) {
		document.write("julho de ");
	} else if (mmes == 7) {
		document.write("agosto de ");
	} else if (mmes == 8) {
		document.write("setembro de ");
	} else if (mmes == 9) {
		document.write("outubro de ");
	} else if (mmes == 10) {
		document.write("novembro de ");
	} else if (mmes == 11) {
		document.write("dezembro de ");
	}
	document.write(mano);
}
// DATA - FIM
// IS NUMERIC
//onKeyPress="return(IsNumeric(this,event))"
function IsNumeric(fld, e) 
{
	var strCheck = '0123456789';
	var whichCode = (window.Event) ? e.which : e.keyCode;
	key = String.fromCharCode(whichCode);
	if (strCheck.indexOf(key) == -1) return false;
}
//LAYER
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_showHideLayers() { //v6.0
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3){
		if ((obj=MM_findObj(args[i]))!=null){
			v=args[i+2];
			if (obj.style){
				obj=obj.style;
				v=(v=='show')?'visible':(v=='hide')?'hidden':v;
			}
			if (obj.visibility=='hidden'){
				obj.visibility='visible';
			}
			else{
				obj.visibility='hidden';
			}
			
		}
	}
}


function mask(fld, e) 
{
	if(fld.value.length == 2){
		fld.value = fld.value + "/";
	}
	if(fld.value.length == 5 ){
		fld.value = fld.value + "/";
	}
	var strCheck = '0123456789';
	var whichCode = (window.Event) ? e.which : e.keyCode;
	key = String.fromCharCode(whichCode);
	if (strCheck.indexOf(key) == -1) return false;
}

//MOSTRAR E OCULTAR O BOX TELEFONE
function showTelefone(evt) {
	mouseX = evt.pageX ? evt.pageX : evt.clientX;
	mouseY = evt.pageY ? evt.pageY : evt.clientY;
	document.getElementById('telefoneBox').style.left = mouseX-60;
	document.getElementById('telefoneBox').style.top = mouseY;
	document.getElementById('telefoneBox').style.visibility = 'visible';
}
function hideTelefone() {
	document.getElementById('telefoneBox').style.visibility = 'hidden';
}
//VALIDA FORMULÁRIO FALE CONOSCO
function validaCampos2(){
	frm = document.form1;
	
	if (frm.nome.value.length==0){
		alert('Preencha o campo Nome !!');
		frm.nome.focus();
		frm.nome.select();
		return false;
	}
	if (frm.email.value.length==0){
		alert('Preencha o campo E-Mail !!');
		frm.email.focus();
		frm.email.select();
		return false;
	}
	if (frm.ddd.value.length==0){
		alert('Preencha o campo DDD !!');
		frm.ddd.focus();
		frm.ddd.select();
		return false;
	}
	if (frm.telefone.value.length==0){
		alert('Preencha o campo Telefone !!');
		frm.telefone.focus();
		frm.telefone.select();
		return false;
	}
	if (frm.comentarios.value.length==0){
		alert('Preencha o campo Comentários !!');
		frm.comentarios.focus();
		frm.comentarios.select();
		return false;
	}
}

function validaInscr(){
	frm = document.frmInscr;	
	if (frm.strNome.value.length==0){
		alert('Preencha o campo Nome !!');
		frm.strNome.focus();
		frm.strNome.select();
		return false;
	}
	if (frm.strCpf.value.length==0){
		alert('Preencha o campo CPF !!');
		frm.strCpf.focus();
		frm.strCpf.select();
		return false;
	}
	if (frm.strRg.value.length==0){
		alert('Preencha o campo RG !!');
		frm.strRg.focus();
		frm.strRg.select();
		return false;
	}
	if (frm.strEndRes.value.length==0){
		alert('Preencha o campo Endereço !!');
		frm.strEndRes.focus();
		frm.strEndRes.select();
		return false;
	}	
	if (frm.strEndResNum.value.length==0){
		alert('Preencha o campo Numero !!');
		frm.strEndResNum.focus();
		frm.strEndResNum.select();
		return false;
	}
	if (frm.strBairro.value.length==0){
		alert('Preencha o campo Bairro !!');
		frm.strBairro.focus();
		frm.strBairro.select();
		return false;
	}
	if (frm.strCidade.value.length==0){
		alert('Preencha o campo Cidade !!');
		frm.strCidade.focus();
		frm.strCidade.select();
		return false;
	}
	if (frm.strEstado.value.length==0){
		alert('Preencha o campo Estado !!');
		frm.strEstado.focus();
		frm.strEstado.select();
		return false;
	}
	if (frm.strCEP.value.length==0){
		alert('Preencha o campo CEP !!');
		frm.strCEP.focus();
		frm.strCEP.select();
		return false;
	}
	if (frm.strTelefRes.value.length==0){
		alert('Preencha o campo Telefone !!');
		frm.strTelefRes.focus();
		frm.strTelefRes.select();
		return false;
	}
	if (frm.strEmail.value.length==0){
		alert('Preencha o campo Email !!');
		frm.strEmail.focus();
		frm.strEmail.select();
		return false;
	}
	if (frm.cbCategoria.value==0){
		alert('Preencha o campo Categoria !!');
		frm.cbCategoria.focus();
		return false;
	}
	if (frm.cbPagamento.value==0){
		alert('Preencha o campo Pagamento !!');
		frm.cbPagamento.focus();
		return false;
	}
}



/*DETECTANDO A VERSÃO DO PLAYER DO FLASH*/
<!--
// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = 8;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Revision of Flash required
var requiredRevision = 0;
// the version of javascript supported
var jsVersion = 1.0;
// -----------------------------------------------------------------------------
// -->

/*
JAIR ACRESCENTEI OS SCRIPTS ABAIXO.. EU NÃO LIMPEI OS DESNECESSÁRIOS... DEPOIS
FAZEMOS ISSO SE VC QUISER.
*/

// JavaScript Document
//adiciona mascara de cnpj
function MascaraCNPJ(cnpj){
if(mascaraInteiro(cnpj)==false){
event.returnValue = false;
} 
return formataCampo(cnpj, '00.000.000/0000-00', event);
}

//adiciona mascara de cep
function MascaraCep(cep){
if(mascaraInteiro(cep)==false){
event.returnValue = false;
} 
return formataCampo(cep, '00000-000', event);
}

//adiciona mascara de data
function MascaraData(data){
if(mascaraInteiro(data)==false){
event.returnValue = false;
} 
return formataCampo(data, '00/00/0000', event);
}

//adiciona mascara de data
function MascaraData2(data){
if(mascaraInteiro(data)==false){
event.returnValue = false;
} 
return formataCampo(data, '00/0000', event);
}

//adiciona mascara ao telefone
function MascaraTelefone(tel){ 
if(mascaraInteiro(tel)==false){
event.returnValue = false;
} 
return formataCampo(tel, '(00) 0000-0000', event);
}

//adiciona mascara ao CPF
function MascaraCPF(cpf){
if(mascaraInteiro(cpf)==false){
event.returnValue = false;
} 
return formataCampo(cpf, '000.000.000-00', event);
}

//valida telefone
function ValidaTelefone(tel){
exp = /\(\d{2}\)\ \d{4}\-\d{4}/;
if(!exp.test(tel.value))
alert('Numero de Telefon Invalido!');
}


//valida CEP
function ValidaCep(cep){
exp = /\d{2}\.\d{3}\-\d{3}/;
if(!exp.test(cep.value))
alert('Numero de Cep Invalido!'); 
}

//valida data
function ValidaData(data){
exp = /\d{2}\/\d{2}\/\d{4}/;
if(!exp.test(data.value))
alert('Data Invalida!'); 
}

//valida data Mes e Ano somente
function ValidaData2(data){
exp = /\d{2}\/\d{4}/;
if(!exp.test(data.value))
alert('Data Invalida, digitar somente mês ano!'); 
}


//valida o CPF digitado
function ValidarCPF(Objcpf){
var cpf = Objcpf.value;
exp = /\.|\-/g;
cpf = cpf.toString().replace( exp, '' );
var digitoDigitado = eval(cpf.charAt(9)+cpf.charAt(10));
var soma1=0, soma2=0;
var vlr =11;

for(i=0;i<9;i++){
soma1+=eval(cpf.charAt(i)*(vlr-1));
soma2+=eval(cpf.charAt(i)*vlr);
//vlr–;
vlr--;
} 
soma1 = (((soma1*10)%11)==10 ? 0:((soma1*10)%11));
soma2=(((soma2+(2*soma1))*10)%11);

var digitoGerado=(soma1*10)+soma2;
if(digitoGerado!=digitoDigitado) 
alert('CPF Invalido!'); 
}

//valida numero inteiro com mascara
function mascaraInteiro(){
if (event.which < 48 || event.which > 57){
event.returnValue = false;
return false;
}
return true; 
}

//valida o CNPJ digitado
function ValidarCNPJ(ObjCnpj){
var cnpj = ObjCnpj.value;
var valida = new Array(6,5,4,3,2,9,8,7,6,5,4,3,2);
var dig1= new Number;
var dig2= new Number;

exp = /\.|\-|\//g;

if (cnpj == "00000000000000" || cnpj == "11111111111111" || cnpj == "22222222222222" || cnpj == "33333333333333" || cnpj == "44444444444444" || cnpj == "55555555555555" 
	|| cnpj == "66666666666666" || cnpj == "77777777777777" || cnpj == "88888888888888" || cnpj == "99999999999999")
	{erro += "Numero de CPF invalido!"}

alert("Erro no cnpj");


cnpj = cnpj.toString().replace( exp, '' );
var digito = new Number(eval(cnpj.charAt(12)+cnpj.charAt(13)));

for(i = 0; i<valida.length; i++){
dig1 += (i>0? (cnpj.charAt(i-1)*valida[i]):0); 
dig2 += cnpj.charAt(i)*valida[i]; 
}
dig1 = (((dig1%11)<2)? 0:(11-(dig1%11)));
dig2 = (((dig2%11)<2)? 0:(11-(dig2%11)));

if(((dig1*10)+dig2) != digito) 
alert('CNPJ Invalido!');

}

//formata de forma generica os campos
function formataCampo(campo, Mascara, evento) {
var boleanoMascara;

var Digitato = evento.keyCode;
exp = /\-|\.|\/|\(|\)| /g;
campoSoNumeros = campo.value.toString().replace( exp, '' );

var posicaoCampo = 0; 
var NovoValorCampo='';
var TamanhoMascara = campoSoNumeros.length;

if (Digitato != 8 ) { // backspace
for(i=0; i<= TamanhoMascara; i++) {
boleanoMascara = ((Mascara.charAt(i) == '-') || (Mascara.charAt(i) == '.')
|| (Mascara.charAt(i) == '/'))
boleanoMascara = boleanoMascara || ((Mascara.charAt(i) == '(')
|| (Mascara.charAt(i) == ')') || (Mascara.charAt(i) == ' '))
if (boleanoMascara) {
NovoValorCampo += Mascara.charAt(i);
TamanhoMascara++;
}else {
NovoValorCampo += campoSoNumeros.charAt(posicaoCampo);
posicaoCampo++;
} 
} 
campo.value = NovoValorCampo;
return true;
}else {
return true;
}
}

// END JavaScript Document

//-----------------------------------------------------
//Funcao: MascaraMoeda
//Sinopse: Mascara de preenchimento de moeda
//Parametro:
//   objTextBox : Objeto (TextBox)
//   SeparadorMilesimo : Caracter separador de milésimos
//   SeparadorDecimal : Caracter separador de decimais
//   e : Evento
//Retorno: Booleano
//-----------------------------------------------------
function MascaraMoeda(objTextBox, SeparadorMilesimo, SeparadorDecimal, e){
    var sep = 0;
    var key = '';
    var i = j = 0;
    var len = len2 = 0;
    var strCheck = '0123456789';
    var aux = aux2 = '';
    var whichCode = (window.Event) ? e.which : e.keyCode;
    if (whichCode == 13) 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;
}

// NÃO LETRAS SOMENTE NUMEROS

function IsNumTel(obj,event)
{
    var str = obj.value;
    var Tecla = event.which;
    if(Tecla == null)
        Tecla = event.keyCode;

    //se nao for número nem parentesis ou espaço
    if ( Tecla < 48 || Tecla > 59 ){
        event.returnValue = false;
	alert("Só devem ser digitados números!")
        return false;
    }
    event.returnValue = true;
    return true;
}


//FIM Formatar Data

// VALIDAÇÃO PARA AUTO-TAB

var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}


// valida formulario

function form_simples(ele){
	numero = ele.elements.length
	erro = "";
	for(i=0; i<numero; i++){
		if(ele.elements[i].alt == "yes"){
			if(ele.elements[i].name == "email" || ele.elements[i].name == "e-mail" || ele.elements[i].name == "StrEmail"){
				if(ele.elements[i].value.indexOf('@')==-1 || ele.elements[i].value.indexOf('.')==-1){
				erro = erro + "Preencha o campo '"+ ele.elements[i].name.toUpperCase() +"' corretamente. \n"
				}
			}else{
				if(ele.elements[i].value==""){
				erro = erro + "Preencha o campo '"+ ele.elements[i].name.toUpperCase() +"'. \n"
				}
			}
		}
		if(ele.elements[i].title == "yes"){
			if(ele.elements[i].value==""){
			erro = erro + "Preencha o campo '"+ ele.elements[i].name.toUpperCase() +"'. \n"
			}
		}
	}

	if(erro != ""){
		alert("Erros:\n"+erro);
		return false
	}else{
		return true
	}
}

// On focus no Formulário

function setStyle(x)
{
document.getElementById(x).style.background = "#f8f8f8";
}

function upperCase(a)
{
var x=document.getElementById(a).value;
document.getElementById(a).value=x.toUpperCase();
document.getElementById(a).style.background = "#ffffff";
}

function lowerCase(b)
{
var x=document.getElementById(b).value;
document.getElementById(b).value=x.toLowerCase();
document.getElementById(b).style.background = "#ffffff";
}

function CorCase(c)
{
var x=document.getElementById(c).value;
document.getElementById(c).style.background = "#ffffff";
}



/* mostra div conforme opção de escolha da forma de pagamento.*/
/*function divShow(obj){
	var div = document.getElementById("chequeBox");
	if (obj.value=="Cheque"){
		div.style.display="block"
	}else{
		div.style.display="none";
	}
}*/

/* mostra div conforme opção de escolha da forma de pagamento.*/
function divShow2(obj){
	var div = document.getElementById("chequeBox2");
	if (obj.value=="Boleto"){
		div.style.display="block"
	}else{
		div.style.display="none";
	}
}




