function testaemailB(obj) {
 if(validaemail(obj.value)) {
  //alert("Formato Valido!");
 }
 else {
  obj.focus();
  alert("Formato de Email Invalido!");
  obj.value="";
 }
}


function testaemail(form) {
 if(validaemail(form.email.value)) {
  //alert("Formato Valido!");
 }
 else {
  form.email.select();
  alert("Formato de Email Invalido!");
 }
}

// Testa um email no formato teste@testando. + com.br (3.2) ou + .com (3) ou + .br (2) //
// NÃO podem comecar com numeros. Antes da @ podem contar numeros letras, pontos e undescore //
// O Dominio pode conter caracteres e numeros porem os seus sufixos apenas caracteres // 

function validaemail(email) {
  var objRegExp  = /^[A-Za-z]([\w\.]*)@([A-Za-z0-9\.]*)\.(([A-Za-z]{3}\.[A-Za-z]{2}$)|([A-Za-z]{3}$)|([a-z]{2}$))/i ;
  return objRegExp.test(email);
}


///////////////////////////////
//	CONSTRÓI O MENU			 //
///////////////////////////////
function MenuWriter(idioma){
	ghome = "home";
	switch(idioma){
		case "1":			
			gEmpresa = "empresa";
			gProdutos = "produtos";
			gCasos = "casos de sucesso";
			gContato = "contate-nos";
			gCertif = "certificações";
			break;
		case "2":
			gEmpresa = "enterprise";
			gProdutos = "products";
			gCasos = "cases";
			gContato = "contact";
			gCertif = "certifications";
			break;	
		case "3":
			gEmpresa = "empresa";
			gProdutos = "produtos";
			gCasos = "casos de sucesso";
			gContato = "contate-nos";
			gCertif = "certificações";
			break;
	}
	//////////////
	// INÍCIO  //
	////////////
	document.write("<table  border='0' cellspacing='0' cellpadding='0' height='166'>");
	//////////////
	// LINHA 1 //
	////////////
	document.write("<tr>");
	document.write("<td width='222' class='tdmenu' onMouseOut=MM_swapImgRestore();document.getElementById('menulk1').style.textDecoration='none'; onMouseOver=MM_swapImage('menuoff1','','img/bullet_seta_menu.gif','menuon','','img/bullet_seta_menu.gif',1);document.getElementById('menulk1').style.textDecoration='underline';>");
	document.write("<a href='index.asp' class='link_menu' id='menulk1'>home</a>");
	document.write("</td>");
	document.write("<td width='6' class='tdmenu' valign='middle' style='padding-top:3px'>");
	document.write("<img src='img/spacer.gif' name='menuoff1'>");
	document.write("</td>");	
	document.write("</tr>");
	//////////////
	// LINHA 2 //
	////////////
	document.write("<tr>");
	document.write("<td width='222' class='tdmenu' onMouseOut=MM_swapImgRestore();document.getElementById('menulk2').style.textDecoration='none'; onMouseOver=MM_swapImage('menuoff2','','img/bullet_seta_menu.gif','menuon','','img/bullet_seta_menu.gif',1);document.getElementById('menulk2').style.textDecoration='underline';>");
	document.write("<a href='empresa.asp' class='link_menu' id='menulk2'>"+ gEmpresa + "</a>");
	document.write("</td>");
	document.write("<td width='6' class='tdmenu' valign='middle' style='padding-top:3px'>");
	document.write("<img src='img/spacer.gif' name='menuoff2'>");
	document.write("</td>");	
	document.write("</tr>");
	//////////////
	// LINHA 3 //
	////////////
	document.write("<tr>");
	document.write("<td width='222' class='tdmenu' onMouseOut=MM_swapImgRestore();document.getElementById('menulk3').style.textDecoration='none'; onMouseOver=MM_swapImage('menuoff3','','img/bullet_seta_menu.gif','menuon','','img/bullet_seta_menu.gif',1);document.getElementById('menulk3').style.textDecoration='underline';>");
	document.write("<a href='produtos.asp' class='link_menu' id='menulk3'>"+ gProdutos + "</a>");
	document.write("</td>");
	document.write("<td width='6' class='tdmenu' valign='middle' style='padding-top:3px'>");
	document.write("<img src='img/spacer.gif' name='menuoff3'>");
	document.write("</td>");	
	document.write("</tr>");
	//////////////
	// LINHA 4 //
	////////////
	document.write("<tr>");
	document.write("<td width='222' class='tdmenu' onMouseOut=MM_swapImgRestore();document.getElementById('menulk4').style.textDecoration='none'; onMouseOver=MM_swapImage('menuoff4','','img/bullet_seta_menu.gif','menuon','','img/bullet_seta_menu.gif',1);document.getElementById('menulk4').style.textDecoration='underline';>");
	document.write("<a href='casos.asp' class='link_menu' id='menulk4'>"+ gCasos + "</a>");
	document.write("</td>");
	document.write("<td width='6' class='tdmenu' valign='middle' style='padding-top:3px'>");
	document.write("<img src='img/spacer.gif' name='menuoff4'>");
	document.write("</td>");	
	document.write("</tr>");
	//////////////
	// LINHA 5 //
	////////////
	document.write("<tr>");
	document.write("<td width='222' class='tdmenu' onMouseOut=MM_swapImgRestore();document.getElementById('menulk5').style.textDecoration='none'; onMouseOver=MM_swapImage('menuoff5','','img/bullet_seta_menu.gif','menuon','','img/bullet_seta_menu.gif',1);document.getElementById('menulk5').style.textDecoration='underline';>");
	document.write("<a href='certificacoes.asp' class='link_menu' id='menulk5'>"+ gCertif + "</a>");
	document.write("</td>");
	document.write("<td width='6' class='tdmenu' valign='middle' style='padding-top:3px'>");
	document.write("<img src='img/spacer.gif' name='menuoff5'>");
	document.write("</td>");	
	document.write("</tr>");
	//////////////
	// LINHA 6 //
	////////////
	document.write("<tr>");
	document.write("<td width='222' class='tdmenu' onMouseOut=MM_swapImgRestore();document.getElementById('menulk6').style.textDecoration='none'; onMouseOver=MM_swapImage('menuoff6','','img/bullet_seta_menu.gif','menuon','','img/bullet_seta_menu.gif',1);document.getElementById('menulk6').style.textDecoration='underline';>");
	document.write("<a href='contato.asp' class='link_menu' id='menulk6'>"+ gContato + "</a>");
	document.write("</td>");
	document.write("<td width='6' class='tdmenu' valign='middle' style='padding-top:3px'>");
	document.write("<img src='img/spacer.gif' name='menuoff6'>");
	document.write("</td>");	
	document.write("</tr>");
	//////////////
	// FIM	   //
	////////////
	document.write("</table>");
}
//
function fnImgRed(obj,idw){
	var jwd;
	var ywd;
	if(obj.width > idw){
		//alert(obj.id + " w: " + obj.width)
		//alert(obj.id + " h: " + obj.height)
		jwd = (idw / obj.width);
		ywd = eval((obj.width/obj.height));
		obj.width = idw;
		if(eval(obj.height) > eval(obj.width)){
			ywd = ywd + 1;
			//alert("teste");
			obj.height = eval(obj.width) * (ywd);
		}
		else{
			obj.height = eval(obj.width) / (ywd);
		}
	}	
}
//
function fnWindowRes(obj){
	window.resizeTo(obj.width,obj.height);
}
//
function ChangeSrcIfr(ifr,par){
	var obj;
	switch (ifr)
	{
		case "ifrimg" :
			//parent.location.href="inclui_noticias.asp";
			//parent.location.href
			//parent.obj.src="inclui_noticias.asp?newsId=" + par		
	}	
}
//
function ExtenBan(campo){
	len=campo.value.length;
	den=campo.value.length-4;
	val=campo.value.substring(den,len)
	if(val != ""){
		if(val !=".gif" && val !=".swf"){
			alert("O Banner deve ser gif ou swf.");
			return false;
		}
	}
	return true;
}
// valida extensoes de imagem
function ExtenImg(campo){
	if(campo.value!=""&& campo.value!=undefined){
		len=campo.value.length;
		den=campo.value.length-4;
		val=campo.value.substring(den,len)
		if(val != ""){
			if(val !=".gif" && val !=".GIF" && val !=".jpg"&& val !=".jpeg" && val !=".JPG"){
				alert("A Imagem deve ser gif ou jpg.");
				return false;
			}
		}
		return true;
	}
	else{
		return true;
	}
}
function ExtenPdf(campo){
	if(campo.value!="" && campo.value!=undefined){
		len=campo.value.length;
		den=campo.value.length-4;
		val=campo.value.substring(den,len)
		if(val != ""){
			if(val !=".pdf" && val !=".PDF"){
				alert("O Arquivo deve ser pdf.");
				return false;
			}
		}
		return true;
	}
	else{
		return true;
	}
}
// valida forms
function ValidaFormReq(objform){
	ErrSum = "Você deixou de preencher os seguintes campos obrigatórios:\n";
	ErrTot = 0;
	objlen = objform.elements.length;
	for(i=0;i<objlen;i++){
		if((objform.elements[i].id.substring(0,3)=='req')&&(objform.elements[i].value=="")){
			ErrSum = ErrSum + "\n - " + objform.elements[i].id.substring(3,objform.elements[i].id.length);
			ErrTot = 1;
		}
	}
	if(ErrTot == 0){
		objform.submit();
	}
	else{
		alert(ErrSum);
	}
}
// inclusao de imagens
function fnImgInc(id,parametro,pagina){
	location.href = pagina + "?" + parametro + "=" + id
}
// redireciona a pagina
function fnRedir(page){
		location.href=page;
	}
// redireciona a pagina
function fnRedirTar(page,target){
		parent.document.getElementById(target).src=page;
	}
function fnExcCaso(userid,username,pagina){
	if (confirm("Deseja realmente excluir o caso " + username + "?")){
		location.href="exclui_casos.asp?casoId=" + userid + "&pagina=" + pagina;
	}
}
function fnExcProd(userid,username,pagina){
	if (confirm("Deseja realmente excluir o produto " + username + "?")){
		location.href="exclui_produtos.asp?prodId=" + userid + "&pagina=" + pagina;
	}
}
function fnExcImgProd(userid,prod,imagem){
	if (confirm("Deseja realmente excluir a imagem ?")){
		location.href="exclui_imagens.asp?imgId=" + userid + "&prodId=" + prod + "&imagem="+ imagem;
	}
}
function fnExcImgProd2(userid,prod,imagem){
	if (confirm("Deseja realmente excluir a imagem ?")){
		location.href="exclui_imagens_2.asp?imgId=" + userid + "&prodId=" + prod + "&imagem="+ imagem;
	}
}
// confirma exclusao
function fnExcUser(userid,username,pagina){
	if (confirm("Deseja realmente excluir o usuário " + username + "?")){
		location.href="exclui_usuarios.asp?userId=" + userid + "&pagina=" + pagina;
	}
}
function fnExcNews(newsid,titulo,ordem,pagina){
	if (confirm("Deseja realmente excluir a notícia " + titulo + "?")){
		location.href="exclui_noticias.asp?newsId=" + newsid + "&ordem=" + ordem + "&pagina=" + pagina;
	}
}
function fnExcAgen(newsid,titulo,ordem,pagina){
	if (confirm("Deseja realmente excluir o evento " + titulo + "?")){
		location.href="agenda_exclui_noticias.asp?newsId=" + newsid + "&ordem=" + ordem + "&pagina=" + pagina;
	}
}
function fnExcArtg(artgid,titulo,ordem,pagina){
	if (confirm("Deseja realmente excluir o artigo " + titulo + "?")){
		location.href="exclui_artigos.asp?artgId=" + artgid + "&ordem=" + ordem + "&pagina=" + pagina;
	}
}
function fnExcCliente(userid,cliente,pagina){
	if (confirm("Deseja realmente excluir o cliente " + cliente + "?")){
		location.href="exclui_clientes.asp?cliId=" + userid + "&pagina=" + pagina;
	}
}
function fnExcCasos(cliid,casoid,titulo,cliente,pagina){
	if (confirm("Deseja realmente excluir o caso " + titulo + "?")){
		location.href="exclui_casos.asp?casoId=" + casoid + "&cliid=" + cliid + "&cliente=" + cliente +"&pagina=" + pagina;
	}
}
function fnExcLink(linksid,titulo,pagina){
	if (confirm("Deseja realmente excluir o link " + titulo + "?")){
		location.href="exclui_links.asp?lnkid=" + linksid + "&pagina=" + pagina;
	}
}
// ordena news
function fnOrdNews (newsid,ordem,dir,pagina){
	location.href="ordena_noticias.asp?newsId=" + newsid  + "&ordem=" + ordem+ "&dir=" + dir + "&pagina=" + pagina;
}
// ordena agenda
function fnOrdAgen (newsid,ordem,dir,pagina){
	location.href="agenda_ordena_noticias.asp?newsId=" + newsid  + "&ordem=" + ordem+ "&dir=" + dir + "&pagina=" + pagina;
}
function fnOrdArtg (artgid,ordem,dir){
	location.href="ordena_artigos.asp?artgId=" + artgid  + "&ordem=" + ordem+ "&dir=" + dir;
}
// preload images
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];}}
}
////// AUTO TAB //////////////
function AutoTab(oform,campo) {

    y=getIndex(oform,campo);
//	alert(oform.elements.length);
	for (var i=0;i < oform.elements.length;i++){
	        if (oform.elements[i].name == campo){
			x=y+1;
			if (oform.elements[x].type == "text"){
				eval('document'+ "." +  oform.name + "." + 'elements' + "["  + x + "]" + "." + 'focus()');
			break; 	
	            	}			
		}
	} 
//    alert(i);
}
function getIndex(what,which) {
    for (var i=0;i < what.elements.length;i++)
        if (what.elements[i].name == which)
            return i;
    return -1;
}
////////////////////////////////////////////////////////////////////////////////////////
//FUNCOES DE CONTROLE DE VISIBILIDADE DE LAYERS
////////////////////////////////////////////////////////////////////////////////////////
function showLayer(LAYEROBJ) {
   //if (ns4) LAYEROBJ.visibility = 'show';
   //else if (dyn) 
   LAYEROBJ.style.visibility = 'visible';
   }
function hideLayer(LAYEROBJ) {
   //if (ns4) LAYEROBJ.visibility = 'hide';
   //else if (dyn) 
   LAYEROBJ.style.visibility = 'hidden';
  
  
   }


function preencheComZeros(tam,max,value,name,frm){
	if (tam == 0) return;	
	var zeros = '';
	for (var i=1;i<=(max-tam);i++){
		zeros = zeros + '0';			
	}
	var dado = (eval('document.'+frm.name+'.'+name));
	dado.value = zeros + value;
}


  
//////////////////////////////////////////////////////////////////
///formatacao de campos moeda
//////////////////////////////////////////////////////////////////
function FormataDado(campo,tammax,teclapres){
	var tecla = teclapres.keyCode;
	vr = campo.value;
	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 = tam - 1 ; }
			
	if ( tecla == 8 || tecla == 88 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){
	 		campo.value = vr ;}
	
      }
}


function FormataValor(campo,tammax,teclapres) {
	//alert(tammax);
	var tecla = teclapres.keyCode;
	vr = campo.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 = tam - 1 ; }
		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){ 
	 		campo.value = vr; }
	 	if ( (tam > 2) && (tam <= 5) ){
	 		campo.value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 6) && (tam <= 8) ){
	 		campo.value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 9) && (tam <= 11) ){
	 		campo.value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 12) && (tam <= 14) ){
	 		campo.value = vr.substr( 0, tam - 11 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 15) && (tam <= 17) ){
	 		campo.value = vr.substr( 0, tam - 14 ) + '.' + vr.substr( tam - 14, 3 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ;}
	}
		
	
}



//////////////////////////////////////////////////////////////////
///funcoes para comparar datas
//////////////////////////////////////////////////////////////////
function comparadata(campopai,campo)
{

    var data1= Date.parse(new Date(campopai.value.substring(6,10),campopai.value.substring(3,5), campopai.value.substring(0,2)));
    var data2= Date.parse(new Date(campo.value.substring(6,10),campo.value.substring(3,5), campo.value.substring(0,2)));
      // if (data2 < data1)
      // {
       //  alert("A " +  campo.name + " deve ser maior ou igual a " + campopai.name );
		 
	  // }
   
    
}
/// nao permite datas menores que a data atual
function dataok(dataatual,campo)
{
  
    var data1= Date.parse(new Date(dataatual.value.substring(6,10),dataatual.value.substring(3,5), dataatual.value.substring(0,2)));
    var data2= Date.parse(new Date(campo.value.substring(6,10),campo.value.substring(3,5), campo.value.substring(0,2)));
    
	 //  if (data2 > data1)
     //  {
     //    alert("A " +  campo.name + " deve ser menor ou igual a Data de Emissão");
		 
	 //  }
    
}
/// nao permite datas anteriores a dez anos do servidor
function datadez(dataatual,campo)
{
  
    var data1= dataatual.value.substring(6,10);
    var data2= campo.value.substring(6,10);
    //alert(data1);
    //alert(data2);
	var menorano =(data1 - 10);
	var diferenca =(data1 -  data2);
	  // if (diferenca > 10)
       //{
       //  alert("O ano mínimo para inserção de " + campo.name + " é " + menorano + " ");
		 
	  // }
    
}
/// nao permite datas anteriores a cinco anos do servidor
function datacinco(dataatual,campo)
{
  
    var data1= dataatual.value.substring(6,10);
    var data2= campo.value.substring(6,10);
    //alert(data1);
    //alert(data2);
	var menorano =(data1 - 5);
	var diferenca =(data1 -  data2);
	  // if (diferenca > 5)
      // {
      //   alert("O ano mínimo para inserção de " + campo.name + " é " + menorano + " ");
		 
	 //  }
    
}
//////////////////////////////////////////////////////////////////
///nao permite que o campo seja vazio
//////////////////////////////////////////////////////////////////
function NoBlank(campo)
{
	 //alert("ok");
	// if(campo.value==""){
	 //alert("o campo "+ campo.name.toUpperCase() +" não pode ser vazio.");
	 //}
	 
}
function FocusColorOut(campo)
{
	 campo.style.background="#ffffff";
}
/////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
///troca cor quando houver focus no input
//////////////////////////////////////////////////////////////////
function FocusColorIn(campo)
{
	 campo.style.background="#f9f9f9";
}
function FocusColorOut(campo)
{
	 campo.style.background="#ffffff";
}
/////////////////////////////////////////////////////////
//FUNCAO VALIDAR HORARIO
/////////////////////////////////////////////////////////
function IsValidTime(timeStr,campo) {
// Checks if time is in HH:MM:SS AM/PM format.
// The seconds and AM/PM are optional.

var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;

var matchArray = timeStr.match(timePat);
if (matchArray == null) {
alert("A hora está inválida. Informe no formato hh:mm.");
campo.value="";
campo.focus();
return false;
}
hour = matchArray[1];
minute = matchArray[2];
second = matchArray[4];
ampm = matchArray[6];

if (second=="") { second = null; }
if (ampm=="") { ampm = null }

if (hour < 0  || hour > 23) {
alert("Hora Inválida. Informe uma hora válida entre 0 e 23");
return false;
}
//if (hour <= 12 && ampm == null) {
//if (confirm("Please indicate which time format you are using.  OK = Standard Time, CANCEL = Military Time")) {
//alert("You must specify AM or PM.");
//return false;
//   }
//}
//if  (hour > 12 && ampm != null) {
//alert("You can't specify AM or PM for military time.");
//return false;
//}
if (minute<0 || minute > 59) {
alert ("Minuto Inválido. Informe minutos entre 0 e 59.");
return false;
}
if (second != null && (second < 0 || second > 59)) {
alert ("Segundo Inválido. Informe minutos entre 0 e 59.");
return false;
}
return false;
}
/////////////////////////////////////////////////////////
//FUNCAO PARA IMPEDIR DIGITACAO DE CARACTERES ESPECIAS
//E ESPACOS NOS CAMPOS DO FORM
/////////////////////////////////////////////////////////
// deleta espaços vazios
var mikExp = /[$\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\!\|\"\'\¨\-\´\<\>\,\.\:\;\?\/\°\º\ª\§\¢\£\³\²\¹\Á\á\À\à\Â\â\Ã\ã\É\é\È\è\Ê\ê\Í\í\Ì\ì\Ó\ó\Ò\ò\Ô\ô\Õ\õ\Ö\ö\Ú\ú\Ù\ù\Û\û\Ü\ü\Ç\ç\Ý\ý\ÿ\ ]/;
function dodacheck(val) {
var strPass = val.value;
var strLength = strPass.length;
var lchar = val.value.charAt((strLength) - 1);
    if(lchar.search(mikExp) != -1){
    var tst = val.value.substring(0, (strLength) - 1);
    val.value = tst;
    }
}
// permite espaços vazios
var mikExp2 = /[$\@\#\%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\!\|\"\'\¨\-\´\<\>\,\.\:\;\?\/\°\º\ª\§\¢\£\³\²\¹\Á\á\À\à\Â\â\Ã\ã\É\é\È\è\Ê\ê\Í\í\Ì\ì\Ó\ó\Ò\ò\Ô\ô\Õ\õ\Ö\ö\Ú\ú\Ù\ù\Û\û\Ü\ü\Ç\ç\Ý\ý\ÿ]/;
function dodasoft(val) {
var strPass = val.value;
var strLength = strPass.length;
var lchar = val.value.charAt((strLength) - 1);
    if(lchar.search(mikExp2) != -1){
    var tst = val.value.substring(0, (strLength) - 1);
    val.value = tst;
    }
}
// permite traços, para o cep
var mikExp3 = /[$\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\!\|\"\'\¨\´\<\>\,\.\:\;\?\/\°\º\ª\§\¢\£\³\²\¹\Á\á\À\à\Â\â\Ã\ã\É\é\È\è\Ê\ê\Í\í\Ì\ì\Ó\ó\Ò\ò\Ô\ô\Õ\õ\Ö\ö\Ú\ú\Ù\ù\Û\û\Ü\ü\Ç\ç\Ý\ý\ÿ\ ]/;
function dodacep(val) {
var strPass = val.value;
var strLength = strPass.length;
var lchar = val.value.charAt((strLength) - 1);
    if(lchar.search(mikExp3) != -1){
    var tst = val.value.substring(0, (strLength) - 1);
    val.value = tst;
    }
}


///////////////////////////////////////////////////////////////
//FUNCAO QUE TRANSFORMA LOWER CASE EM UPPER NOS CAMPOS
///////////////////////////////////////////////////////////////
function mudacase(campo)
{
campo.value=campo.value.toUpperCase();
}
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//PERMITE APENAS VALORES NUMERICOS NO CAMPO
//////////////////////////////////////////////////////////////////
function onlynum()
{

     if (event.keyCode < 48 || event.keyCode > 57){
		 event.returnValue = false;
	    }
	 
 }
///////////////////////////////////////////////////////////////
//PERMITE APENAS VALORES NUMERICOS NO CAMPO
//////////////////////////////////////////////////////////////////
function onlynum()
{

     if (event.keyCode < 48 || event.keyCode > 57){
		 event.returnValue = false;
	    }
	 
 }
///////////////////////////////////////////////////////////////
//NAO PERMITE  VALORES NUMERICOS NO CAMPO
//////////////////////////////////////////////////////////////////
function nopenum()
{

     if ((event.keyCode < 48 || event.keyCode < 58) && event.keyCode != 32){
		 event.returnValue = false;
	    }
	 
 }
///////////////////////////////////////////////////////////////
//FUNCAO QUE TRANSFORMA LOWER CASE EM UPPER NOS CAMPOS
///////////////////////////////////////////////////////////////
function mudacase(campo)
{
campo.value=campo.value.toUpperCase();
}

///////////////////////////////////////////////////////////////
//FUNCAO PARA COLOCAR O FOCUS NO PRIMEIRO CAMPO DO FORM
//E INICIAR TODOS OS CAMPOS DA PAGINA EXCETO O PRIMEIRO EM
//DISABLED=TRUE
///////////////////////////////////////////////////////////////
function poefoco()
{
 document.pesqpecas.codpeca1.focus();
}
///////////////////////////////////////////////////////////////
//FUNCAO PARA IMPEDIR VALORES MAIOR QUE 500 NOS CAMPOS DE QTDE
///////////////////////////////////////////////////////////////
function quinmax(campo){
    if (campo.value > 500){
	alert("Atenção: a quantidade máxima para consulta é 500.");
	campo.value="";
	campo.focus();
	}
}
/////////////////////////////////////////////////////////
//FUNCAO PARA IMPEDIR DIGITACAO DE CARACTERES ESPECIAS
//E ESPACOS NOS CAMPOS DO FORM
/////////////////////////////////////////////////////////
var mikExp = /[$\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\!\|\"\'\¨\-\´\<\>\,\.\:\;\?\/\°\º\ª\§\¢\£\³\²\¹\Á\á\À\à\Â\â\Ã\ã\É\é\È\è\Ê\ê\Í\í\Ì\ì\Ó\ó\Ò\ò\Ô\ô\Õ\õ\Ö\ö\Ú\ú\Ù\ù\Û\û\Ü\ü\Ç\ç\Ý\ý\ÿ\ ]/;
function dodacheck(val) {
var strPass = val.value;
var strLength = strPass.length;
var lchar = val.value.charAt((strLength) - 1);
    if(lchar.search(mikExp) != -1){
    var tst = val.value.substring(0, (strLength) - 1);
    val.value = tst;
    }
}
/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
//validacao de data
//antes é feita checagem de browser
/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
//
// Check browser version
var isNav4 = false, isNav5 = false, isIE4 = false
var strSeperator = "/"; 
// If you are using any Java validation on the back side you will want to use the / because 
// Java date validations do not recognize the dash as a valid date separator.
var vDateType = 3; // Global value for type of date format
//                1 = mm/dd/yyyy
//                2 = yyyy/dd/mm  (Unable to do date check at this time)
//                3 = dd/mm/yyyy
var vYearType = 4; //Set to 2 or 4 for number of digits in the year for Netscape
var vYearLength = 2; // Set to 4 if you want to force the user to enter 4 digits for the year before validating.
var err = 0; // Set the error code to a default of zero
if(navigator.appName == "Netscape") {
if (navigator.appVersion < "5") {
isNav4 = true;
isNav5 = false;
}
else
if (navigator.appVersion > "4") {
isNav4 = false;
isNav5 = true;
   }
}
else {
isIE4 = true;
}
function DateFormat(vDateName, vDateValue, e, dateCheck, dateType) {
vDateType = dateType;
//alert(vDateName + vDateValue + e + dateCheck + dateType);
// vDateName = object name
// vDateValue = value in the field being checked
// e = event
// dateCheck 
// True  = Verify that the vDateValue is a valid date
// False = Format values being entered into vDateValue only
// vDateType
// 1 = mm/dd/yyyy
// 2 = yyyy/mm/dd
// 3 = dd/mm/yyyy
//Enter a tilde sign for the first number and you can check the variable information.
if (vDateValue == "~") {
alert("AppVersion = "+navigator.appVersion+" \nNav. 4 Version = "+isNav4+" \nNav. 5 Version = "+isNav5+" \nIE Version = "+isIE4+" \nYear Type = "+vYearType+" \nDate Type = "+vDateType+" \nSeparator = "+strSeperator);
vDateName.value = "";
vDateName.focus();
return true;
}
var whichCode = (window.Event) ? e.which : e.keyCode;
// Check to see if a seperator is already present.
// bypass the date if a seperator is present and the length greater than 8
if (vDateValue.length > 8 && isNav4) {
if ((vDateValue.indexOf("-") >= 1) || (vDateValue.indexOf("/") >= 1))
return true;
}
//Eliminate all the ASCII codes that are not valid
var alphaCheck = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/-";
if (alphaCheck.indexOf(vDateValue) >= 1) {
if (isNav4) {
vDateName.value = "";
vDateName.focus();
vDateName.select();
return false;
}
else {
vDateName.value = vDateName.value.substr(0, (vDateValue.length-1));
return false;
   }
}
if (whichCode == 8) //Ignore the Netscape value for backspace. IE has no value
return false;
else {
//Create numeric string values for 0123456789/
//The codes provided include both keyboard and keypad values
var strCheck = '47,48,49,50,51,52,53,54,55,56,57,58,59,95,96,97,98,99,100,101,102,103,104,105';
if (strCheck.indexOf(whichCode) != -1) {
if (isNav4) {
if (((vDateValue.length < 6 && dateCheck) || (vDateValue.length == 7 && dateCheck)) && (vDateValue.length >=1)) {
alert("Data Inválida\nRedigite de acordo com o formato: dd/mm/aaaa");
vDateName.value = "";
vDateName.focus();
vDateName.select();
return false;
}
if (vDateValue.length == 6 && dateCheck) {
var mDay = vDateName.value.substr(2,2);
var mMonth = vDateName.value.substr(0,2);
var mYear = vDateName.value.substr(4,4)
//Turn a two digit year into a 4 digit year
if (mYear.length == 2 && vYearType == 4) {
var mToday = new Date();
//If the year is greater than 30 years from now use 19, otherwise use 20
var checkYear = mToday.getFullYear() + 30; 
var mCheckYear = '20' + mYear;
if (mCheckYear >= checkYear)
mYear = '19' + mYear;
else
mYear = '20' + mYear;
}
var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
if (!dateValid(vDateValueCheck)) {
alert("Data Inválida\nRedigite de acordo com o formato: dd/mm/aaaa");
vDateName.value = "";
vDateName.focus();
vDateName.select();
return false;
}
return true;
}
else {
// Reformat the date for validation and set date type to a 1
if (vDateValue.length >= 8  && dateCheck) {
if (vDateType == 1) // mmddyyyy
{
var mDay = vDateName.value.substr(2,2);
var mMonth = vDateName.value.substr(0,2);
var mYear = vDateName.value.substr(4,4)
vDateName.value = mMonth+strSeperator+mDay+strSeperator+mYear;
}
if (vDateType == 2) // yyyymmdd
{
var mYear = vDateName.value.substr(0,4)
var mMonth = vDateName.value.substr(4,2);
var mDay = vDateName.value.substr(6,2);
vDateName.value = mYear+strSeperator+mMonth+strSeperator+mDay;
}
if (vDateType == 3) // ddmmyyyy
{
var mMonth = vDateName.value.substr(2,2);
var mDay = vDateName.value.substr(0,2);
var mYear = vDateName.value.substr(4,4)
vDateName.value = mDay+strSeperator+mMonth+strSeperator+mYear;
}
//Create a temporary variable for storing the DateType and change
//the DateType to a 1 for validation.
var vDateTypeTemp = vDateType;
vDateType = 1;
var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
if (!dateValid(vDateValueCheck)) {
alert("Data Inválida\nRedigite de acordo com o formato: dd/mm/aaaa");
vDateType = vDateTypeTemp;
vDateName.value = "";
vDateName.focus();
vDateName.select();
return false;
}
vDateType = vDateTypeTemp;
return true;
}
else {
if (((vDateValue.length < 8 && dateCheck) || (vDateValue.length == 9 && dateCheck)) && (vDateValue.length >=1)) {
alert("Data Inválida\nRedigite de acordo com o formato: dd/mm/aaaa");
vDateName.value = "";
vDateName.focus();
vDateName.select();
return false;
         }
      }
   }
}
else {
// Non isNav Check
if (((vDateValue.length < 8 && dateCheck) || (vDateValue.length == 9 && dateCheck)) && (vDateValue.length >=1)) {
alert("Data Inválida\nRedigite de acordo com o formato: dd/mm/aaaa");
vDateName.value = "";
vDateName.focus();
return true;
}
// Reformat date to format that can be validated. mm/dd/yyyy
if (vDateValue.length >= 8 && dateCheck) {
// Additional date formats can be entered here and parsed out to
// a valid date format that the validation routine will recognize.
if (vDateType == 1) // mm/dd/yyyy
{
var mMonth = vDateName.value.substr(0,2);
var mDay = vDateName.value.substr(3,2);
var mYear = vDateName.value.substr(6,4)
}
if (vDateType == 2) // yyyy/mm/dd
{
var mYear = vDateName.value.substr(0,4)
var mMonth = vDateName.value.substr(5,2);
var mDay = vDateName.value.substr(8,2);
}
if (vDateType == 3) // dd/mm/yyyy
{
var mDay = vDateName.value.substr(0,2);
var mMonth = vDateName.value.substr(3,2);
var mYear = vDateName.value.substr(6,4)
}
if (vYearLength == 4) {
if (mYear.length < 4) {
//alert("Data Inválida\nRedigite de acordo com o formato: dd/mm/aaaa");
vDateName.value = "";
vDateName.focus();
return true;
   }
}
// Create temp. variable for storing the current vDateType
var vDateTypeTemp = vDateType;
// Change vDateType to a 1 for standard date format for validation
// Type will be changed back when validation is completed.
vDateType = 1;
// Store reformatted date to new variable for validation.
var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
if (mYear.length == 2 && vYearType == 4 && dateCheck) {
//Turn a two digit year into a 4 digit year
var mToday = new Date();
//If the year is greater than 30 years from now use 19, otherwise use 20
var checkYear = mToday.getFullYear() + 30; 
var mCheckYear = '20' + mYear;
if (mCheckYear >= checkYear)
mYear = '19' + mYear;
else
mYear = '20' + mYear;
vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
// Store the new value back to the field.  This function will
// not work with date type of 2 since the year is entered first.
if (vDateTypeTemp == 1) // mm/dd/yyyy
vDateName.value = mMonth+strSeperator+mDay+strSeperator+mYear;
if (vDateTypeTemp == 3) // dd/mm/yyyy
vDateName.value = mDay+strSeperator+mMonth+strSeperator+mYear;
} 
if (!dateValid(vDateValueCheck)) {
alert("Data Inválida\nRedigite de acordo com o formato: dd/mm/aaaa");
vDateType = vDateTypeTemp;
vDateName.value = "";
vDateName.focus();
return true;
}
vDateType = vDateTypeTemp;
return true;
}
else {
if (vDateType == 1) {
if (vDateValue.length == 2) {
vDateName.value = vDateValue+strSeperator;
}
if (vDateValue.length == 5) {
vDateName.value = vDateValue+strSeperator;
   }
}
if (vDateType == 2) {
if (vDateValue.length == 4) {
vDateName.value = vDateValue+strSeperator;
}
if (vDateValue.length == 7) {
vDateName.value = vDateValue+strSeperator;
   }
} 
if (vDateType == 3) {
if (vDateValue.length == 2) {
vDateName.value = vDateValue+strSeperator;
}
if (vDateValue.length == 5) {
vDateName.value = vDateValue+strSeperator;
   }
}
return true;
   }
}
if (vDateValue.length == 10&& dateCheck) {
if (!dateValid(vDateName)) {
// Un-comment the next line of code for debugging the dateValid() function error messages
//alert(err);  
alert("Data Inválida\nRedigite de acordo com o formato: dd/mm/aaaa");
vDateName.focus();
vDateName.select();
   }
}
return false;
}
else {
// If the value is not in the string return the string minus the last
// key entered.
if (isNav4) {
vDateName.value = "";
vDateName.focus();
vDateName.select();
return false;
}
else
{
//vDateName.value = vDateName.value.substr(0, (vDateValue.length-1));
return false;
         }
      }
   }
}
function dateValid(objName) {
var strDate;
var strDateArray;
var strDay;
var strMonth;
var strYear;
var intday;
var intMonth;
var intYear;
var booFound = false;
var datefield = objName;
var strSeparatorArray = new Array("-"," ","/",".");
var intElementNr;
// var err = 0;
var strMonthArray = new Array(12);
strMonthArray[0] = "Jan";
strMonthArray[1] = "Feb";
strMonthArray[2] = "Mar";
strMonthArray[3] = "Apr";
strMonthArray[4] = "May";
strMonthArray[5] = "Jun";
strMonthArray[6] = "Jul";
strMonthArray[7] = "Aug";
strMonthArray[8] = "Sep";
strMonthArray[9] = "Oct";
strMonthArray[10] = "Nov";
strMonthArray[11] = "Dec";
//strDate = datefield.value;
strDate = objName;
if (strDate.length < 1) {
return true;
}
for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
strDateArray = strDate.split(strSeparatorArray[intElementNr]);
if (strDateArray.length != 3) {
err = 1;
return false;
}
else {
strDay = strDateArray[0];
strMonth = strDateArray[1];
strYear = strDateArray[2];
}
booFound = true;
   }
}
if (booFound == false) {
if (strDate.length>5) {
strDay = strDate.substr(0, 2);
strMonth = strDate.substr(2, 2);
strYear = strDate.substr(4);
   }
}
//Adjustment for short years entered
if (strYear.length == 2) {
strYear = '20' + strYear;
}
strTemp = strDay;
strDay = strMonth;
strMonth = strTemp;
intday = parseInt(strDay, 10);
if (isNaN(intday)) {
err = 2;
return false;
}
intMonth = parseInt(strMonth, 10);
if (isNaN(intMonth)) {
for (i = 0;i<12;i++) {
if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {
intMonth = i+1;
strMonth = strMonthArray[i];
i = 12;
   }
}
if (isNaN(intMonth)) {
err = 3;
return false;
   }
}
intYear = parseInt(strYear, 10);
if (isNaN(intYear)) {
err = 4;
return false;
}
if (intMonth>12 || intMonth<1) {
err = 5;
return false;
}
if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
err = 6;
return false;
}
if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
err = 7;
return false;
}
if (intMonth == 2) {
if (intday < 1) {
err = 8;
return false;
}
if (LeapYear(intYear) == true) {
if (intday > 29) {
err = 9;
return false;
   }
}
else {
if (intday > 28) {
err = 10;
return false;
      }
   }
}
return true;
}
function LeapYear(intYear) {
if (intYear % 100 == 0) {
if (intYear % 400 == 0) { return true; }
}
else {
if ((intYear % 4) == 0) { return true; }
}
return false;
}
/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
//validacao de cpf
/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
function check_cpf (StrCPF,formcampo)
{
	//alert('teste');
	if (StrCPF.length >= 1) 
	{
		if(StrCPF.length < 11) {
			alert('Número do CPF Inválido !');
			formcampo.value="";
			formcampo.focus();
			return false;
		} else {
			
			if(StrCPF=='00000000000' || StrCPF=='11111111111' || StrCPF=='22222222222' || StrCPF=='33333333333' || StrCPF=='44444444444' || StrCPF=='55555555555' || StrCPF=='66666666666' || StrCPF=='77777777777' || StrCPF=='88888888888' || StrCPF=='99999999999')
			{
				alert('Número do CPF Inválido !');
				formcampo.value="";
				formcampo.focus();
				return false;
			} else {
				//alert(StrCPF);
				x = 0;
				soma = 0;
				dig1 = 0;
				dig2 = 0;
				texto = "";
				StrCPF1="";
				len = StrCPF.length;
				x = len -1;
				for (var i=0; i <= len - 3; i++)
				{
					y = StrCPF.substring(i,i+1);
					soma = soma + ( y * x);
					x = x - 1;
					texto = texto + y;
				}
				dig1 = 11 - (soma % 11);
				if (dig1 == 10) dig1=0 ;
				if (dig1 == 11) dig1=0 ;
				StrCPF1 = StrCPF.substring(0,len - 2) + dig1 ;
				x = 11; soma=0;
				for (var i=0; i <= len - 2; i++)
				{
					soma = soma + (StrCPF1.substring(i,i+1) * x);
					x = x - 1;
				}
				dig2= 11 - (soma % 11);
				if (dig2 == 10) dig2=0;
				if (dig2 == 11) dig2=0;
		
				if ((dig1 + "" + dig2) == StrCPF.substring(len,len-2))
				{
				   //alert ("Número do CPF Válido !");
				   return true;
				}
				else {
					 alert ("Número do CPF Inválido !");
					 formcampo.value="";
					 formcampo.focus();
					 return false;
				}
			}
		}
	}
}
/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
//validacao de cgc
/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
function check_cgc (StrCGC,formcampo)
{
	if(StrCGC!=""){
          var varFirstChr = StrCGC.charAt(0);
          var vlMult,vlControle,s1, s2 = "";
          var i,j,vlDgito,vlSoma = 0;
          for ( var i=0; i<=13; i++ ) {

          var c = StrCGC.charAt(i);
          if( ! (c>="0")&&(c<="9") )
            {
            alert("Número do CGC Inválido !");
            formcampo.value="";
            formcampo.focus();
            return false; }
            if( c!=varFirstChr ) { vaCharCGC = true; }
            }
            if( ! vaCharCGC ) {

            alert("Número do CGC Inválido !");
            formcampo.value="";
            formcampo.focus();
            return false ;
            }


            s1 = StrCGC.substring(0,12);
            s2 = StrCGC.substring(12,15);
            vlMult = "543298765432";
            vlControle = "";
            for ( j=1; j<3; j++ ) {

            vlSoma = 0;
            for ( i=0; i<12; i++ )
            { vlSoma += eval( s1.charAt(i) )* eval( vlMult.charAt(i) );}
            if( j == 2 ){ vlSoma += (2 * vlDgito); }
            vlDgito = ((vlSoma*10) % 11);
            if( vlDgito == 10 ){ vlDgito = 0; }
            vlControle = vlControle + vlDgito;
            vlMult = "654329876543";
            }
            if( vlControle != s2 ) {
            alert("Número do CGC Inválido !");
            formcampo.value="";
            formcampo.focus();
            return false;
            return false;
            }
            else {
            //alert("Número do CGC Válido !"); // YYY
            return true;
            }
		}
}
/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
//validacao de cep
/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
function onlycep()
{

     if ((event.keyCode < 48 || event.keyCode > 57) && event.keyCode != 45){
		 event.returnValue = false;
	    }
	 
 }
function check_cep(campo){
if (campo.value !=""){
        
		if((campo.value.length==8)&&(campo.value.substr(5, 1) != '-')) {
        midcamp1=campo.value.substr(0, 5)
		midcamp2="-"
		midcamp3=campo.value.substr(5, 3)
		campo.value=midcamp1 + midcamp2 + midcamp3
		return true
        }
		
		if(campo.value.substr(5, 1) != '-') {
        window.alert('CEP Inválido. Digite o CEP no formato: 00000-000')
        campo.value=""
		campo.focus()
        campo.select()
        return false
        }
        
        var cep2 = campo.value
        var cep3 = cep2
        var tcep = campo.value.length
        for(x = 0; x <tcep; x ++) {
        cep2 = cep3.replace(' ', '')
        cep3 = cep2
        }
        var tcep2 = cep3.length
        if (tcep2 < '9'){
        window.alert('CEP Incompleto. Digite o CEP no formato: 00000-000')
        campo.value=""
		campo.focus()
        campo.select()
        return false
        }
    }
}
//conta caracteres
function conta_caracteres(field, countfield, maxlimit) {
if (field.value.length > maxlimit) 
field.value = field.value.substring(0, maxlimit);
else 
countfield.value = maxlimit - field.value.length;
}
/;/////////////////////////////////////////////////////////////////////////
/////validacao de data
//////////////////////////////////////////////////////////////////////////
// Validação de Data
// ========= == ====

function isdate(obj)
{

if (obj.value=="")
{
return false; 
}

data = obj.value;
dia = data.substring(0,2);
mes = data.substring(3,5);
ano = data.substring(6,10);
barra1 = data.substring(2,3);
barra2 = data.substring(5,6);

hoje = new Date()
// hoje.setDate(dia);
// hoje.setMonth(mes-1);


if ((barra1 != "/") || (barra2 != "/")) {
alert("O formato da data está invalido ! Exemplo: dd/mm/aaaa");
obj.value = "";
obj.focus();
return false;
}

if ( isNaN(dia) || (dia < 1) || (dia > 31)) {
alert("A data (dia) é invalida");
obj.value = "";
obj.focus();
return false;
}

else if (isNaN(mes) || (mes < 1) || (mes > 12) ) {
alert("A data (mes) é inválida");
obj.value = "";
obj.focus();
return false;
}
else if (isNaN(ano)) {
alert("A data (ano) contem caracteres invalidos");
obj.value = "";
obj.focus();
return false;
}

else if (data.length != 10) {
alert("O formato da data esta invalido ! Exemplo: dd/mm/aaaa");
obj.value = "";
obj.focus();
return false;
}

quociente = (eval(ano) % 4);

if (quociente == 0)
biss = true;
else
biss = false;

if (ano < 1900) {
alert("Ano menor que 1900 !");
obj.value = "";
obj.focus();
return false;
}

if (mes == 2) {

if ((dia == 29) && (biss == false)) {
alert("O dia e invalido pois o ano nao e bissexto!");
obj.value = "";
obj.focus();
return false;
}
else if ((dia == 30) || (dia == 31)) {
alert("O dia e invalido para o mes de Fevereiro!");
obj.value = "";
obj.focus();
return false;
}
}

else if ((mes == 4) && (dia == 31)) {
alert("O dia e invalido para o mes de Abril!");
obj.value = "";
obj.focus();
return false;
}

else if ((mes == 6) && (dia == 31)) {
alert("O dia e invalido para o mes de Junho!");
obj.value = "";
obj.focus();
return false;
}

else if ((mes == 9) && (dia == 31)) {
alert("O dia e invalido para o mes de Setembro!");
obj.value = "";
obj.focus();
return false;
}

else if ((mes == 11) && (dia == 31)) {
alert("O dia e invalido para o mes de Novembro!");
obj.value = "";
obj.focus();
return false;
}

return true;
}
///////
function morevirg(campo){
vrvgh=campo.value.length;

	if (vrvgh==1){
		campo.value=campo.value + ",00";
		}
	if (vrvgh==2){
		campo.value=campo.value + ",00";
		}
    if (campo.value=="05"){
		campo.value="0,50";
		}
		  		
}
////break em textarea
function showLines(max, text) {
max--;
text = "" + text;
var temp = "";
var chcount = 0; 
for (var i = 0; i < text.length; i++) // for each character ... 
{   
var ch = text.substring(i, i+1); // first character
var ch2 = text.substring(i+1, i+2); // next character
if (ch == '\n') // if character is a hard return
{  
temp += ch;
chcount = 1;
}
else
{
if (chcount == max) // line has max chacters on this line
{
temp += '<br>' + ch; // go to next line
chcount = 1; // reset chcount
}
else  // Not a newline or max characters ...
{
temp += ch;
chcount++; // so add 1 to chcount
      }
   }
}
return (temp); // sends value of temp back
}
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];}}
}
MM_preloadImages('<%=GpathName%>img/botao_on.gif','<%=GpathName%>img/botao_off.gif');
///////////////////////////////
//	GENÉRICAS				 //
///////////////////////////////
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_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_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.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];}
}
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_showHideLayers() { //v3.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; }
    obj.visibility=v; }
}

