
function pfrota(){
	window.open("carros.php","frota","width=510,height=305,scrollbars=no,resizable=no,scrollbars=no,status=yes,titlebar=no,top=100,left=100");
}
function piti(){
	window.open("itine.php","iti","width=500,height=400,scrollbars=yes,resizable=no,scrollbars=auto,status=yes,titlebar=no,top=100,left=100");
}
function atribui(v){
	document.atrib.valor.value = v;
}
function mostra(){
	var i = document.atrib.valor.value;
	var dados=i.split("|");
	var define = "itin.php?linha="+dados[0];
	window.open(define,"buscacli","width="+dados[1]+",height=300,scrollbars=yes,resizable=no,scrollbars=auto,status=yes,titlebar=no,top=100,left=100");
}
function verifyCompatibleBrowser(){ 
    this.ver=navigator.appVersion 
    this.dom=document.getElementById?1:0 
    this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0; 
    this.ie4=(document.all && !this.dom)?1:0; 
    this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
 
    this.ns4=(document.layers && !this.dom)?1:0; 
    this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5) 
    return this 
} 
bw=new verifyCompatibleBrowser() 
 
 
var speed=50 
 
var loop, timer 
 
function ConstructObject(obj,nest){ 
    nest=(!nest) ? '':'document.'+nest+'.' 
    this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0; 
    this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0; 
    this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight 
    this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight 
    this.up=MoveAreaUp;this.down=MoveAreaDown; 
    this.MoveArea=MoveArea; this.x; this.y; 
    this.obj = obj + "Object" 
    eval(this.obj + "=this") 
    return this 
} 
function MoveArea(x,y){ 
    this.x=x;this.y=y 
    this.css.left=this.x 
    this.css.top=this.y 
} 
 
function MoveAreaDown(move){ 
	if(this.y>-this.scrollHeight+objContainer.clipHeight){ 
    this.MoveArea(0,this.y-move) 
    if(loop) setTimeout(this.obj+".down("+move+")",speed) 
	} 
} 
function MoveAreaUp(move){ 
	if(this.y<0){ 
    this.MoveArea(0,this.y-move) 
    if(loop) setTimeout(this.obj+".up("+move+")",speed) 
	} 
} 
 
function PerformScroll(speed){ 
	if(initialised){ 
		loop=true; 
		if(speed>0) objScroller.down(speed) 
		else objScroller.up(speed) 
	} 
} 
 
function CeaseScroll(){ 
    loop=false 
    if(timer) clearTimeout(timer) 
} 
var initialised; 
function InitialiseScrollableArea(){ 
    objContainer=new ConstructObject('divContainer') 
    objScroller=new ConstructObject('divContent','divContainer') 
    objScroller.MoveArea(0,0) 
    objContainer.css.visibility='visible' 
    initialised=true; 
}

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&&id.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' está incorreto.\n'; }
  } if (errors) alert('O seguintes erros foram encontrados:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function Atualiza(){
	var flag = document.frmFlag;

	if (flag.hidFlag.value == 1)
	{
	//	window.location.reload();
	}
	
	document.Situacao.CPF.focus()	
}

function Submeter(){
	var f = document.Situacao;
	var flag = document.frmFlag;

	flag.hidFlag.value = 1;

	f.submit();
}

function SaltaCampo (campo, prox, tammax, teclapres){
   var tecla = teclapres.keyCode;
   vr = campo.value;
   tam = vr.length;
   if (tecla != 0 && tecla != 10 && tecla != 24)
      if (tam == tammax)
          prox.focus();
}

var ImagemAtual = new Image();
function MudaImagem(MyImg, Imagem){
	ImagemAtual.src = Imagem;
   MyImg.src = ImagemAtual.src;
}

var ie=(((navigator.userAgent.indexOf("MSIE")>-1)||(navigator.userAgent.indexOf("Mozilla/5.0")>-1))&&navigator.userAgent.indexOf("Opera")==-1?true:false);
var ns=(navigator.userAgent.indexOf("Netscape")>-1&&navigator.userAgent.indexOf("Opera")==-1?true:false);

var ImagemAtual = new Image();
//---------------
function ajustar_cpf(input, evento)
{
         var BACKSPACE=  8; 
         var DEL=  46; 
         var FRENTE=  39; 
         var TRAS=  37;          
         var tecla= (evento.keyCode ? evento.keyCode: evento.which ? evento.which : evento.charCode)
         if (( tecla == BACKSPACE )||(tecla == DEL)||(tecla == FRENTE)||(tecla == TRAS)) {
             return true; 
             }
         if ( tecla == 13 )     return false; 

		if ((tecla<48)||(tecla>57)){
			evento.returnValue =false;
			return false;
		} else { 
			if((input.value.length==3)||(input.value.length==7)) {
			    input.value=input.value + "." ;
			}  else {
			      if(input.value.length==11) {
			           input.value=input.value + "-" ;
			         }
			}
		}
 return true;		
  		
}


//-------------------------------
function editacpf(strCampo,tam) {
    var i;
    var j;
    var nTamanho;
    var szCampo;
    j=0;
	nTamanho = strCampo.length;
	szCampo = "";
	for (i = nTamanho-1;i>=0;i--) 
	{
		if (isDigit(strCampo.charAt(i)))	{
			szCampo = strCampo.charAt(i) + szCampo;
			j++;
			if (j > tam) break;
        }
	}
	if (szCampo.length < tam) {
		for (i = szCampo.length;i<tam;i++) 
		{
			szCampo = "0" + szCampo;
		}
	}
	if (j==0) return "";
    return (szCampo.substr(0,3)+"."+szCampo.substr(3,3)+"."+szCampo.substr(6,3)+"-"+szCampo.substr(9,2));
}
//-------------------------------
function isDigit (c){   
	
	    return ((c >= "0") && (c <= "9"))
    } 
    
    //-------------------------------
function RetiraCaracteresInvalidos(strCampo,tam) {
	nTamanho = strCampo.length;
	szCampo = "";
	j=0;
	for (i = nTamanho-1;i>=0;i--) 
	{
		if (isDigit(strCampo.charAt(i)))	{
			szCampo = strCampo.charAt(i) + szCampo;
			j++;
			if (j > tam) break;
		}
	}
	if (szCampo.length < tam) {
		for (i = szCampo.length;i<tam;i++) 
		{
			szCampo = "0" + szCampo;
		}
	}
    return szCampo;
} 