<!--

function TeclaMoney(obj,e)
{
	if (document.all) // Internet Explorer
		var tecla = event.keyCode;
	else if(document.layers) // Nestcape
		var tecla = e.which;
		//document.selection.createRange().text.length;
		if (tecla==44 && (obj.value.search(",") != -1 || obj.value.length == 0 || document.selection.createRange().text.length == obj.value.length)) //verifica se já tem (,) e se já tem algum número digitado
			return false;
		if ((tecla > 47 && tecla < 58) || tecla == 44) // numeros de 0 a 9 ou ,
			return true;
		else
			{
				if (tecla != 8) // backspace
					event.keyCode = 0;
					//return false;
				else
					return true;
			}
}

function fncValidaData(dia,mes,ano) {
	
	if(dia.length==1)
		return false
		
	if(mes.length==1)
		return false
	
	
	if (parseInt(mes,10) > 0 && parseInt(mes,10) <= 12)
	{
		mes = parseInt(mes,10);
		if (parseInt(ano,10) >= 0000)
		{
			if ((parseInt(ano,10) % 4) == 0)
			{
				bissexto = 1;
			}
			else
			{
				bissexto = 0;
			}
			dia = parseInt(dia,10);
			if (((mes==1 || mes==3 || mes==5 || mes==7 || mes==8 || mes==10 || mes==12) && (dia >= 1 && dia <= 31)) ||
				((mes==4 || mes==6 || mes==9 || mes==11) && (dia >= 1 && dia <= 30)) ||
				(mes==2 && dia >= 1 && dia <= (28 + bissexto)))
			{
				return   true
			}
			
				
		}
		
	}return false
}

//Funcao que valida o CNPJ
function val_cnpj(strCNPJ){
	
			numero = strCNPJ;
			dig_1 = 0;
			dig_2 = 0;
			controle_1 = 5;
			controle_2 = 6;
		    
			if (numero.length != 14)
			{
				//alert("CNPJ inválido !");						
				return false;
			}
			else
			{
				
				for ( i=0 ; i < 12 ; i++)
				{
					dig_1 = dig_1 + parseFloat(numero.substring(i, i+1) * controle_1);
					controle_1 = controle_1 - 1;
					if (i == 3)
					{
						controle_1 = 9;
					}
				}
				resto = dig_1 % 11;
				dig_1 = 11 - resto;
				if ((resto == 0) || (resto == 1))
				{
					dig_1 = 0;
				}
				for ( i=0 ; i < 12 ; i++)
				{
					dig_2 = dig_2 + parseInt(numero.substring(i, i+1) * controle_2);
					controle_2 = controle_2 - 1;
					if (i == 4)
					{
						controle_2 = 9;
					}
				}
				dig_2 = dig_2 + (2 * dig_1);
				resto = dig_2 %11;
				dig_2 = 11 - resto;
				if ((resto == 0) || (resto == 1))
				{
					dig_2 = 0;
				}
				dig_ver = (dig_1 * 10) + dig_2;
				if (dig_ver != parseFloat(numero.substring(numero.length-2, numero.length)))
				{
					//alert("CNPJ inválido !");				
					return false;
				}
			}
		    
			return true;
}

//funcao que valida CPF
function val_cpf(strCPF)
{
  dig_1 = 0;
  dig_2 = 0;
  controle_1 = 10;
  controle_2 = 11;
  lsucesso = 1;
  numero = strCPF;
  if (numero.length != 11) {
     alert("CPF inválido!");     
     return false;
  }
  else 
  {
     for ( i=0 ; i < 9 ; i++) {
        dig_1 = dig_1 + parseInt(numero.substring(i, i+1) * controle_1);
	    controle_1 = controle_1 - 1;
     }
	
	
     resto = dig_1 % 11;
     dig_1 = 11 - resto;
     if ((resto == 0) || (resto == 1)) {
	  dig_1 = 0;
     }
     for ( i=0 ; i < 9 ; i++) {
	    dig_2 = dig_2 + parseInt(numero.substring(i, i + 1) * controle_2);
        controle_2 = controle_2 - 1;
     }
     dig_2 = dig_2 + 2 * dig_1;
     resto = dig_2 % 11;
     dig_2 = 11 - resto;
     if ((resto == 0) || (resto == 1)) {
        dig_2 = 0;
     }
     dig_ver = (dig_1 * 10) + dig_2;
     if (dig_ver != parseFloat(numero.substring(numero.length-2,numero.length))) {
	    alert("CPF inválido");	    
 	    return false;
	}
  }
  return true;	
}	

function mnuOver(idCat){
 var set = document.getElementById("mnu"+idCat+"S")
 var cat = document.getElementById("mnu"+idCat)

 if(set.bgColor=="") {
  set.bgColor = "#D51111";
  cat.bgColor = "#D51111";}
 else{
  set.bgColor = "";
  cat.bgColor = "";}}
  
function insertFlash(pLagura,pAltura,pSrc,FlashVars){document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+pLagura+'" height="'+pAltura+'"><param name="movie" value="'+pSrc+'"><param name="quality" value="high"><param name="wmode" value="transparent"><param name="FlashVars" value="'+FlashVars+'"><embed src="'+pSrc+'" FlashVars="'+FlashVars+'" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+pLagura+'" height="'+pAltura+'"></embed></object>');}
function consultaPreco(CaminhoVirtual,idProduto){window.open(CaminhoVirtual+"precos.asp?idProduto="+idProduto,"consulta","width=286,height=220,scrollbars=no,statusbar=no")}

function TeclaValor(e)
{
	if (document.all) // Internet Explorer
		var tecla = event.keyCode;
	else if(document.layers) // Nestcape
		var tecla = e.which;
		if (tecla > 47 && tecla < 58) // numeros de 0 a 9
			return true;
		else
			{	
				if (tecla != 8) // backspace
					event.keyCode = 0;
					//return false;
				else
					return true;
			}
}

function changingFont(parentElement){
 with(parentElement){
  for(var i=0;i<childNodes.length;i++)
   with(childNodes[i].style){
    if(color == defaultFontColor || color == ''){
	 color = highLightedFontColor;
	 fontWeight = 'bold';}
	else{
	 color = defaultFontColor;fontWeight = 'normal'; }}}}
	 
function highLight(){
 var wE = event.srcElement.parentNode;
 if(wE.tagName == 'TR'){
  var defaultColor = wE.bgColor
  with(wE.style){
   if(backgroundColor == defaultColor || backgroundColor == ''){
    backgroundColor = highLightedColor;
    changingFont(wE);}
   else{
    backgroundColor = defaultColor;
    changingFont(wE);}}}}

function getAbsoluteLeft(aoNode){
var aoCurrentNode=aoNode;
var iLeft=0;
while(aoCurrentNode.tagName!="BODY"){
iLeft+=aoCurrentNode.offsetLeft;
aoCurrentNode=aoCurrentNode.offsetParent;
}
return iLeft
}

function getAbsoluteTop(aoNode){
var aoCurrentNode=aoNode;
var iTop=0;
while(aoCurrentNode.tagName!="BODY"){
iTop+=aoCurrentNode.offsetTop;
aoCurrentNode=aoCurrentNode.offsetParent;
}
return iTop
}

function fadeOut(elementToFade) {new Effect.FadeTo( elementToFade, 0, 500, 20);}
function fadeIn(elementToFade) {new Effect.FadeTo( elementToFade, 1, 500, 20 );}


// Funções para administração de resultados
function disableOthers(idRegistro){
var TR = '';
 for(var i=0;i<=quantRegistros;i++){
  TR = document.getElementById('tr'+i);
  if(i!=idRegistro){
   with(TR){
	if(style.backgroundColor.toUpperCase() == '#FFF1D9' || bgColor.toUpperCase() == '#FFF1D9') style.backgroundColor = '#F0F0F0';
    else style.backgroundColor = '#E2E2E2';
	disabled = true;} // End With
} // End If
}}

function enableOthers(idRegistro){
var TR = '';
 for(var i=0;i<=quantRegistros;i++){
  TR = document.getElementById('tr'+i);
  if(i!=idRegistro){
   with(TR){
	if(style.backgroundColor.toUpperCase() == '#F0F0F0' || bgColor.toUpperCase() == '#F0F0F0') style.backgroundColor = '#FFF1D9';
    else style.backgroundColor = '#FFE7BE';
	disabled = false;} // End With
} // End If
}}


function showCofirmation(idRegistro){
 imgAtualizar = document.getElementById('imgA'+idRegistro);
 imgExcluir = document.getElementById('imgE'+idRegistro);
 
 with(imgAtualizar){
  src = "../img/btnConfirmar.gif";
  width = 23 ;height = 26;
  alt = 'Confimar Alteração';
  onclick = null;
  onclick = function(){save();};}
 
 with(imgExcluir){
  src = "../img/btnCancelar.gif";
  width = 23 ;height = 26;
  alt = 'Cancelar Alteração';
  onclick = null;
  onclick = function(){cancel(idRegistro);};}}

function hideCofirmation(idRegistro){
 imgAtualizar = document.getElementById('imgA'+idRegistro);
 imgExcluir = document.getElementById('imgE'+idRegistro);
 
 with(imgAtualizar){
  src = "../img/btnAtualizar.gif";
  width = 16 ;height = 16;
  alt = 'Alterar';
  onclick = null;
  onclick = function(){alterarRegistro(idRegistro);};}
 
 with(imgExcluir){
  src = "../img/btnExcluir.gif";
  width = 16 ;height = 16;
  alt = 'Excluir';
  onclick = null;
  onclick = function(){if(alterando!=1)excluirRegistro(idRegistro);};}}

//arrErro[1] = "Email Inválido. \n";
//arrErro[2] = "CPF Inválido. \n";
//arrErro[3] = "O campo Senha deve ter no mínimo 4 e no máximo 8 caracteres. \n";
//arrErro[4] = "As duas senhas devem ser idênticas e possuir\nno mínimo 4 e no máximo 8 caracteres. \n";
//arrErro[5] = "O campo Busca deve ter no mínimo 3 caracteres.\n";
//arrErro[6] = "Preencha o campo 'Login' com no mínimo 3 e no máximo 12 caracteres. \n";
//arrErro[7] = "Preencha o campo 'Senha' com no mínimo 3 e no máximo 8 caracteres. \n";
//arrErro[8] = "Email Inválido. \n";
//arrErro[9] = "Email Inválido. \n";
//arrErro[10] = "Email Inválido. \n";
-->