
	//FUNÇÕES PARA CHECKLIST
	//---------------------------------------------------------------------
	function addLoadEvent(func) {
		var oldonload = window.onload;
		
		if (typeof window.onload != "function") {
			window.onload = func;
		} else {
			window.onload = function () {
				oldonload();
				func();
			}
		}
	}
	
	addLoadEvent(function () {
		initChecklist();
	});
	
	function initChecklist() {
		if (document.all && document.getElementById) {
			// Get all unordered lists
			var lists = document.getElementsByTagName("ul");
			
			for (i = 0; i < lists.length; i++) {
				var theList = lists[i];
				
				// Only work with those having the class "checklist"
				if (theList.className.indexOf("checklist") > -1) {
					var labels = theList.getElementsByTagName("label");
					
					// Assign event handlers to labels within
					for (var j = 0; j < labels.length; j++) {
						var theLabel = labels[j];
						theLabel.onmouseover = function() { this.className += " hover"; };
						theLabel.onmouseout = function() { this.className = this.className.replace(" hover", ""); };
					}
				}
			}
		}
	}


	//FUNÇÕES PARA MASCARAS
	//---------------------------------------------------------------------
	Mascaras = {
	IsIE: navigator.appName.toLowerCase().indexOf('microsoft')!=-1,
	AZ: /[A-Z]/i,
	Acentos: /[À-ÿ]/i,
	Num: /[0-9]/,
	carregar: function(parte){
	 var Tags = ['input','textarea'];
	 if (typeof parte == "undefined") parte = document;
	 for(var z=0;z<Tags.length;z++){
	  Inputs=parte.getElementsByTagName(Tags[z]);
	  for(var i=0;i<Inputs.length;i++)
	   if(('button,image,hidden,submit,reset').indexOf(Inputs[i].type.toLowerCase())==-1)
		this.aplicar(Inputs[i]);
	 }
	},
	aplicar: function(campo){
	 tipo = campo.getAttribute('tipo');
	 if (!tipo || campo.type == "select-one") return;
	 orientacao = campo.getAttribute('orientacao');
	 mascara = campo.getAttribute('mascara');
	 if (tipo.toLowerCase() == "decimal"){
	  orientacao = "esquerda";
	  casasdecimais = campo.getAttribute('casasdecimais');
	  tamanho = campo.getAttribute('maxLength');
	  if (!tamanho || tamanho > 50)
	   tamanho = 10;
	  if (!casasdecimais)
	   casasdecimais = 2;
	  campo.setAttribute("mascara", this.geraMascaraDecimal(tamanho, casasdecimais));
	  campo.setAttribute("tipo", "numerico");
	  campo.setAttribute("orientacao", orientacao);
	 }
	 if (orientacao && orientacao.toLowerCase() == "esquerda") campo.style.textAlign = "right";
	 if (mascara) campo.setAttribute("maxLength", mascara.length);
	 if (tipo){
	  campo.onkeypress = function(e){ return Mascaras.onkeypress(e?e:event); };
	  campo.onkeyup = function(e){ Mascaras.onkeyup(e?e:event, campo) };
	 }
	 campo.setAttribute("snegativo", ((campo.value).substr(0,1) == "-" ? "s" : "n"));
	},
	onkeypress: function(e){
	 KeyCode = this.IsIE ? event.keyCode : e.which;
	 campo =  this.IsIE ? event.srcElement : e.target;
	 readonly = campo.getAttribute('readonly');
	 if (readonly) return;
	 maxlength = campo.getAttribute('maxlength');
	 pt = campo.getAttribute('pt');
	 selecao = this.selecao(campo);
	 if (selecao.length > 0 && KeyCode != 0){
	  campo.value = ""; return true;
	 }
	 if (KeyCode == 0) return true;
	 Char = String.fromCharCode(KeyCode);
	 valor = campo.value;
	 mascara = campo.getAttribute('mascara');
	 if (KeyCode != 8){
	  tipo = campo.getAttribute('tipo').toLowerCase();
	  negativo = campo.getAttribute('negativo');
	  if(negativo && KeyCode == 45){
	   snegativo = campo.getAttribute('snegativo');
	   snegativo = (snegativo == "s" ? "n" : "s");
	   campo.setAttribute("snegativo", snegativo);
	  }else{
	   valor += Char
	   if (tipo == "numerico" && Char.search(this.Num) == -1) return false;
	   if (KeyCode != 32 && tipo == "caracter" && Char.search(this.AZ) == -1 && Char.search(this.Acentos) == -1) return false;
	  }
	 }
	 if (mascara){
	  this.aplicarMascara(campo, valor);
	  return false;
	 }
	 return true;
	},
	onkeyup: function(e, campo){
	 KeyCode = this.IsIE ? event.keyCode : e.which;
	 if (KeyCode != 9 && KeyCode != 16 && KeyCode != 109){
	  valor = campo.value;
	  if (KeyCode == 8 && !this.IsIE) valor = valor.substr(0,valor.length-1);
	  this.aplicarMascara(campo, valor);
	 }
	},
	aplicarMascara: function(campo, valor){
	 mascara = campo.getAttribute('mascara');
	 if (!mascara) return;
	 negativo = campo.getAttribute('negativo');
	 snegativo = campo.getAttribute('snegativo');
	 if (negativo && valor.substr(0,1) == "-") 
	  valor = valor.substr(1,valor.length-1);
	 orientacao = campo.getAttribute('orientacao');
	 var i = 0;
	 for(i=0;i<mascara.length;i++){
	  caracter = mascara.substr(i,1);
	  if (caracter != "#") valor = valor.replace(caracter, "");
	 }
	 retorno = "";
	 if (orientacao != "esquerda"){
	  contador = 0;
	  for(i=0;i<mascara.length;i++){
	   caracter = mascara.substr(i,1);
	   if (caracter == "#"){
		retorno += valor.substr(contador,1);
		contador++;
	   }else
		retorno += caracter;
	   if(contador >= valor.length) break;
	  }
	 }else{
	  contador = valor.length-1;
	  for(i=mascara.length-1;i>=0;i--){
	   if(contador < 0) break;
	   caracter = mascara.substr(i,1);
	   if (caracter == "#"){
		retorno = valor.substr(contador,1) + retorno;
		contador--;
	   }else
		retorno = caracter + retorno;
	  }
	 }
	 if (negativo && snegativo == "s")
	  retorno = "-" + retorno;
	 campo.value = retorno;
	},
	geraMascaraDecimal: function(tam, decimais){
	 var retorno = ""; var contador = 0; var i = 0;
	 decimais = parseInt(decimais);
	 for (i=0;i<(tam-(decimais+1));i++){
	  retorno = "#" + retorno;
	  contador++;
	  if (contador == 3){
	   retorno = "." + retorno;
	   contador=0;
	  }
	 }
	 retorno = retorno + ",";
	 for (i=0;i<decimais;i++) retorno += "#";
	 return retorno;
	},
	selecao: function(campo){
	 if (this.IsIE)
	  return document.selection.createRange().text;
	 else
	  return (campo.value).substr(campo.selectionStart, (campo.selectionEnd - campo.selectionStart));
	},
	formataValor: function (valor, decimais){
	 valor = valor.split('.');
	 if (valor.length == 1) valor[1] = "";
	 for(var i=valor[1].length;i<decimais;i++)
	  valor[1] += "0"; 
	 valor[1] = valor[1].substr(0,2);
	 return (valor[0] + "." + valor[1]);
	}
	};


	//FUNÇÕES PARA IMAGENS
	//---------------------------------------------------------------------
	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_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];}
	}
	
	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;
	}


	//FUNÇÕES DE JANELA DE LAERTA
	//---------------------------------------------------------------------
	function confirma_delete(form) {
	  if (confirm("Tem certeza que deseja deletar?")) {
		document[form].submit();
	  }
	}
	
	function confirma_alteracao(form) {
	  if (confirm("Tem certeza que deseja fazer a alteração?")) {
		document[form].submit();
	  }
	}
	
	function confirma_excluir(endereco){
	if (confirm("Tem certeza que deseja excluir?")) {
	  document.location=endereco;
	  }
	}


	//FUNÇÕES PARA MUDAR DIV
	//---------------------------------------------------------------------
	function get$() {
		var elements = new Array();
		for (var i = 0; i < arguments.length; i++) {
			var element = arguments[i];
			if (typeof element == 'string')
				element = document.getElementById(element);
			if (arguments.length == 1)
				return element;
			elements.push(element);
		}
		return elements;
	}
	
	function mudarDiv(element) {
		var e = get$(element);
		if (e) {
			e.style.display = ((e.style.display != 'block') ? 'block' : 'none');
		}
	}
	
	function MostrarDiv(nomeDiv) {
	document.getElementById(nomeDiv).style.display="block";
	}
	
	function EsconderDiv(nomeDiv) {
	document.getElementById(nomeDiv).style.display="";
	}


	//FUNÇÕES PARA ABRIR JANELA
	//---------------------------------------------------------------------
	function abre_janela(width, height, nome) {
	var top; var left;
	top = ( (screen.height/2) - (height/2) )
	left = ( (screen.width/2) - (width/2) )
	window.open('',nome,'width='+width+',height='+height+',scrollbars=no,toolbar=no,location=no,status=no,menubar=no,resizable=no,left='+left+',top='+top);
	}

	//FUNÇÕES PARA VALIDAR CAMPO DE HORA
	//---------------------------------------------------------------------
	function Mascara_Hora(hora_inicio){ 
	var hora01 = ''; 
	hora01 = hora01 + hora_inicio; 
	  if (hora01.length == 2){ 
	    hora01 = hora01 + ':'; 
	    document.forms[0].hora_inicio.value = hora01; 
	  } 
	    if (hora01.length == 5){ 
	      Verifica_Hora(); 
	    } 
	  } 
	  
	function Verifica_Hora(){ 
	hrs = (document.forms[0].hora_inicio.value.substring(0,2)); 
	min = (document.forms[0].hora_inicio.value.substring(3,5)); 
				   
	estado = ""; 
	if ((hrs < 00 ) || (hrs > 23) || ( min < 00) ||( min > 59)){ 
	  estado = "errada"; 
	} 
				   
	if (document.forms[0].hora_inicio.value == "") { 
	  estado = "errada"; 
	} 
	
	if (estado == "errada") { 
	  alert("Hora inválida!"); 
	  document.forms[0].hora_inicio.focus(); 
	  } 
	} 
	
	//FUNÇÕES PARA VALIDAR CAMPO DE HORA
	//---------------------------------------------------------------------
	function Mascara_Hora2(hora_termino){ 
	var hora01 = ''; 
	hora01 = hora01 + hora_termino; 
	  if (hora01.length == 2){ 
	    hora01 = hora01 + ':'; 
	    document.forms[0].hora_termino.value = hora01; 
	  } 
	    if (hora01.length == 5){ 
	      Verifica_Hora2(); 
	    } 
	  } 
	  
	function Verifica_Hora2(){ 
	hrs = (document.forms[0].hora_termino.value.substring(0,2)); 
	min = (document.forms[0].hora_termino.value.substring(3,5)); 
				   
	estado = ""; 
	if ((hrs < 00 ) || (hrs > 23) || ( min < 00) ||( min > 59)){ 
	  estado = "errada"; 
	} 
				   
	if (document.forms[0].hora_termino.value == "") { 
	  estado = "errada"; 
	} 
	
	if (estado == "errada") { 
	  alert("Hora inválida!"); 
	  document.forms[0].hora_termino.focus(); 
	  } 
	} 


	//FUNÇÕES PARA VALIDAR FORMULÁRIO
	//---------------------------------------------------------------------
	function verifica_form(form) {
	var passed = false;
	var ok = false
	var campo
	for (i = 0; i < form.length; i++) {
	  campo = form[i].name;
	  if (form[i].getAttribute("df_verificar") == "sim") {
		if (form[i].type == "text"  | form[i].type == "textarea" | form[i].type == "select-one") {
		  if (form[i].value == "" | form[i].value == "http://") {
			form[campo].className='campo_alerta'
			form[campo].focus();
			alert("Preencha corretamente o campo em destaque!");
			return passed;
			stop;
		  }
		}
		else if (form[i].type == "radio") {
		  for (x = 0; x < form[campo].length; x++) {
			ok = false;
			if (form[campo][x].checked) {
			  ok = true;
			  break;
			}
		  }
		  if (ok == false) {
			form[campo][0].focus();
			form[campo][0].select();
			alert("Informe uma das opcões");
			return passed;
			stop;
		  }
		}
		var msg = ""
		if (form[campo].getAttribute("df_validar") == "cpf") msg = checa_cpf(form[campo].value);
		if (form[campo].getAttribute("df_validar") == "cnpj") msg = checa_cnpj(form[campo].value);
		if (form[campo].getAttribute("df_validar") == "cpf_cnpj") {
		  msg = checa_cpf(form[campo].value);
		  if (msg != "") msg = checa_cnpj(form[campo].value);
		}
		if (form[campo].getAttribute("df_validar") == "email") msg = checa_email(form[campo].value);
		if (form[campo].getAttribute("df_validar") == "numerico") msg = checa_numerico(form[campo].value);
		if (msg != "") {
		  if (form[campo].getAttribute("df_validar") == "cpf_cnpj") msg = "informe corretamente o número do CPF ou CNPJ";
		  form[campo].className='campo_alerta'
		  form[campo].focus();
		  form[campo].select();
		  alert(msg);
		  return passed;
		  stop;
		}
	  }
	}
	passed = true;
	return passed;
	}
	
	function desabilita_cor(campo) {
	campo.className='campos_formulario'
	}
	
	function checa_numerico(String) {
	var mensagem = "Este campo aceita somente números"
	var msg = "";
	if (isNaN(String)) msg = mensagem;
	return msg;
	}
	
	function checa_email(campo) {
	var mensagem = "Informe corretamente o email"
	var msg = "";
	var email = campo.match(/(\w+)@(.+)\.(\w+)$/);
	if (email == null){
	  msg = mensagem;
	  }
	return msg;
	}
	
	function mascara_data(data){ 
	var mydata = ''; 
	mydata = mydata + data; 
	if (mydata.length == 2){ 
	mydata = mydata + '/'; 
	} 
	if (mydata.length == 5){ 
	mydata = mydata + '/'; 
	} 
	return mydata; 
	} 
	
	function verifica_data(data) { 
	if (data.value != "") {
	dia = (data.value.substring(0,2));
	mes = (data.value.substring(3,5)); 
	ano = (data.value.substring(6,10)); 
	situacao = ""; 
	if ((dia < 01)||(dia < 01 || dia > 30) && (  mes == 04 || mes == 06 || mes == 09 || mes == 11 ) || dia > 31) { 
	situacao = "falsa"; 
	} 
	if (mes < 01 || mes > 12 ) { 
	situacao = "falsa"; 
	}
	if (mes == 2 && ( dia < 01 || dia > 29 || ( dia > 28 && (parseInt(ano / 4) != ano / 4)))) { 
	situacao = "falsa"; 
	} 
	if (situacao == "falsa") { 
	data.focus();
	data.select();
	alert("Data inválida!"); 
	}
	} 
	}


	//FUNÇÕES PARA FORMATAR VALORES
	//---------------------------------------------------------------------
	function FormataReal(nvalor){
	nvalor = nvalor.replace(".","");
	nvalor = nvalor.replace(",",".");
	return nvalor;
	}
	
	function FormataValor(objeto,teclapres,tammax,decimais) 
	{
		var tecla			= teclapres.keyCode;
		var tamanhoObjeto	= objeto.value.length;
		if ((tecla == 8) && (tamanhoObjeto == tammax))
		{
			tamanhoObjeto = tamanhoObjeto - 1 ;
		}
		if (( tecla == 8 || tecla == 88 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ) && ((tamanhoObjeto+1) <= tammax))
		{
			vr	= objeto.value;
			vr	= vr.replace( "/", "" );
			vr	= vr.replace( "/", "" );
			vr	= vr.replace( ",", "" );
			vr	= vr.replace( ".", "" );
			vr	= vr.replace( ".", "" );
			vr	= vr.replace( ".", "" );
			vr	= vr.replace( ".", "" );
			tam	= vr.length;
			if (tam < tammax && tecla != 8)
			{
				tam = vr.length + 1 ;
			}
			if ((tecla == 8) && (tam > 1))
			{
				tam = tam - 1 ;
				vr = objeto.value;
				vr = vr.replace( "/", "" );
				vr = vr.replace( "/", "" );
				vr = vr.replace( ",", "" );
				vr = vr.replace( ".", "" );
				vr = vr.replace( ".", "" );
				vr = vr.replace( ".", "" );
				vr = vr.replace( ".", "" );
			}
			if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 )
			{
				if (decimais > 0)
				{
					if ( (tam <= decimais) )
					{ 
						objeto.value = ("0," + vr) ;
					}
					if( (tam == (decimais + 1)) && (tecla == 8))
					{
						objeto.value = vr.substr( 0, (tam - decimais)) + ',' + vr.substr( tam - (decimais), tam ) ;	
					}
					if ( (tam > (decimais + 1)) && (tam <= (decimais + 3)) &&  ((vr.substr(0,1)) == "0"))
					{
						objeto.value = vr.substr( 1, (tam - (decimais+1))) + ',' + vr.substr( tam - (decimais), tam ) ;
					}
					if ( (tam > (decimais + 1)) && (tam <= (decimais + 3)) &&  ((vr.substr(0,1)) != "0"))
					{
						objeto.value = vr.substr( 0, tam - decimais ) + ',' + vr.substr( tam - decimais, tam ) ; 
					}
					if ( (tam >= (decimais + 4)) && (tam <= (decimais + 6)) )
					{
						objeto.value = vr.substr( 0, tam - (decimais + 3) ) + '.' + vr.substr( tam - (decimais + 3), 3 ) + ',' + vr.substr( tam - decimais, tam ) ;
					}
					if ( (tam >= (decimais + 7)) && (tam <= (decimais + 9)) )
					{
						objeto.value = vr.substr( 0, tam - (decimais + 6) ) + '.' + vr.substr( tam - (decimais + 6), 3 ) + '.' + vr.substr( tam - (decimais + 3), 3 ) + ',' + vr.substr( tam - decimais, tam ) ;
					}
					if ( (tam >= (decimais + 10)) && (tam <= (decimais + 12)) )
					{
						objeto.value = vr.substr( 0, tam - (decimais + 9) ) + '.' + vr.substr( tam - (decimais + 9), 3 ) + '.' + vr.substr( tam - (decimais + 6), 3 ) + '.' + vr.substr( tam - (decimais + 3), 3 ) + ',' + vr.substr( tam - decimais, tam ) ;
					}
					if ( (tam >= (decimais + 13)) && (tam <= (decimais + 15)) )
					{
						objeto.value = vr.substr( 0, tam - (decimais + 12) ) + '.' + vr.substr( tam - (decimais + 12), 3 ) + '.' + vr.substr( tam - (decimais + 9), 3 ) + '.' + vr.substr( tam - (decimais + 6), 3 ) + '.' + vr.substr( tam - (decimais + 3), 3 ) + ',' + vr.substr( tam - decimais, tam ) ;
					}
				}
				else if(decimais == 0)
				{
					if ( tam <= 3 )
					{ 
						objeto.value = vr ;
					}
					if ( (tam >= 4) && (tam <= 6) )
					{
						if(tecla == 8)
						{
							objeto.value = vr.substr(0, tam);
							window.event.cancelBubble = true;
							window.event.returnValue = false;
						}
						objeto.value = vr.substr(0, tam - 3) + '.' + vr.substr( tam - 3, 3 ); 
					}
					if ( (tam >= 7) && (tam <= 9) )
					{
						if(tecla == 8)
						{
							objeto.value = vr.substr(0, tam);
							window.event.cancelBubble = true;
							window.event.returnValue = false;
						}
						objeto.value = vr.substr( 0, tam - 6 ) + '.' + vr.substr( tam - 6, 3 ) + '.' + vr.substr( tam - 3, 3 ); 
					}
					if ( (tam >= 10) && (tam <= 12) )
					{
						if(tecla == 8)
						{
							objeto.value = vr.substr(0, tam);
							window.event.cancelBubble = true;
							window.event.returnValue = false;
						}
						objeto.value = vr.substr( 0, tam - 9 ) + '.' + vr.substr( tam - 9, 3 ) + '.' + vr.substr( tam - 6, 3 ) + '.' + vr.substr( tam - 3, 3 ); 
					}
	
					if ( (tam >= 13) && (tam <= 15) )
					{
						if(tecla == 8)
						{
							objeto.value = vr.substr(0, tam);
							window.event.cancelBubble = true;
							window.event.returnValue = false;
						}
						objeto.value = vr.substr( 0, tam - 12 ) + '.' + vr.substr( tam - 12, 3 ) + '.' + vr.substr( tam - 9, 3 ) + '.' + vr.substr( tam - 6, 3 ) + '.' + vr.substr( tam - 3, 3 ) ;
					}			
				}
			}
		}
		else if((window.event.keyCode != 8) && (window.event.keyCode != 9) && (window.event.keyCode != 13) && (window.event.keyCode != 35) && (window.event.keyCode != 36) && (window.event.keyCode != 46))
			{
				window.event.cancelBubble = true;
				window.event.returnValue = false;
			}
	}
