// JavaScript Document

	function move_cima(x) { x.style.color='#D62418'; }
	function move_fora(x) { x.style.color= '#738A94'; }
	
	
	
	function showLayer( idLayer ){
		document.getElementById(idLayer).style.visibility = 'visible';
		document.getElementById(idLayer + '2').style.visibility = 'visible';
	}
	
	function hideLayer( idLayer ){
		document.getElementById(idLayer).style.visibility = 'hidden';
		document.getElementById(idLayer + '2').style.visibility = 'hidden';
	}
	
	

		
	// essa recarrega uma página.  Não está sendo usada,mas deixei para estudo
	function abreF5(s){
		location.reload(s);
	}
	
	// essa abre a página atualizando. é melhor que window.open, pois não carrega de novo
	function abre(s){
	 	document.location = s;
	 }
	
	// essa carrega passando parametro "cod"
	 function edt(variavel){
	 	window.open( "form_cliente.php?cod=" + variavel,"_top", "" );
	 }
	 	
	// carrega passando o endereço e o "cod"
	function abre_param(dcm,vari){
	 	window.open( dcm + "?cod=" + vari,"_top", "" );
	 }
	 
	 
	function openPopup( URL, p_width, p_height ){
		winWidth = p_width;
		winHeight = p_height;
		winLeft = (screen.availWidth/2)-(winWidth/2);
		winTop = (screen.availHeight/2)-(winHeight/2) - 23;
		
		features = "top=" + winTop + ",left=" + winLeft + ",Width=" + winWidth + ",Height=" + winHeight + ",resizable=no,status=no,toolbar=no,scrollbars=yes";
		popupWin = window.open( URL, "_blank", features );
		return popupWin;
	}
	 	

	
	var removeClick = new Date();
	var editaClick = new Date();
	
	
	function valida_logon(){
		//validar nome
		d = document.logon;
		if (d.usu.value == ""){
			alert("Não é permitido deixar campos em branco!\nTente novamente.");
			d.usu.focus();
			return false;
		}

		//validar endereco
		if (d.senha.value == ""){
			alert("Não é permitido deixar campos em branco!\nTente novamente.");
			d.senha.focus();
			return false;
		}						
		
		return true;
	}
	
	
	function FormataCNPJ(Campo, teclapres){

   	if(window.event){
    var tecla = teclapres.keyCode;
   	}else  tecla = teclapres.which;
   	var vr = new String(Campo.value);
   	vr = vr.replace(".", "");
   	vr = vr.replace(".", "");
   	vr = vr.replace("/", "");
   	vr = vr.replace("-", "");

   	tam = vr.length + 1;
   	if (tecla != 9 && tecla != 8){
      if (tam > 2 && tam < 6)
         Campo.value = vr.substr(0, 2) + '.' + vr.substr(2, tam);
      if (tam >= 6 && tam < 9)
         Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,tam-5);
      if (tam >= 9 && tam < 13)
         Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,tam-8);
      if (tam >= 13 && tam < 15)
         Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,4)+ '-' + vr.substr(12,tam-12);
      }
}
		
function FormataCEP(Campo, teclapres){
   	if(window.event){
    var tecla = teclapres.keyCode;
   	}else  tecla = teclapres.which;
   	var vr = new String(Campo.value);
   	vr = vr.replace("-", "");
   	tam = vr.length + 1;   
   	if (tecla != 9 && tecla != 8){
      if( tam > 5 )
         Campo.value = vr.substr(0, 5) + '-' + vr.substr(5, tam);
         
      }
}
		
function FormataDATA(Campo, teclapres){
   	if(window.event){
    var tecla = teclapres.keyCode;
   	}else  tecla = teclapres.which;
   	var vr = new String(Campo.value);
   	vr = vr.replace("/", "");
   	vr = vr.replace("/", "");
   	tam = vr.length + 1;  
   	if (tecla != 9 && tecla != 8){
      if( tam > 2 & tam < 4)
         Campo.value = vr.substr(0, 2) + '/' + vr.substr(2, tam);    
       if (tam >= 5 && tam <6)
         Campo.value = vr.substr(0,2) + '/' + vr.substr(2,3) + '/' + vr.substr(5,tam-5);    
	  }
		  
}	
	


function FormataHora(Campo, teclapres){
   	if(window.event){
    	var tecla = teclapres.keyCode;
   	}else  
		tecla = teclapres.which;
   	
	var vr = new String(Campo.value);
   	vr = vr.replace(":", "");
   	vr = vr.replace(":", "");
   	tam = vr.length + 1;  
   	if (tecla != 9 && tecla != 8){
      if( tam > 2 & tam < 4)
         Campo.value = vr.substr(0, 2) + ':' + vr.substr(2, tam);        
	}
	
	
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_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_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_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];
	   }
   }
}	
	
	
	
	
	
	
	
	
	
	
}



