// JavaScript Document
<!--

function getOffsetTop(elm){
	var mOffsetTop = elm.offsetTop;
	var mOffsetParent = elm.offsetParent;
	while(mOffsetParent){
		mOffsetTop += mOffsetParent.offsetTop;
		mOffsetParent = mOffsetParent.offsetParent;
	}
	return mOffsetTop;
}
function getOffsetLeft(elm){
	var mOffsetLeft = elm.offsetLeft;
	var mOffsetParent = elm.offsetParent;
	while(mOffsetParent){
		mOffsetLeft += mOffsetParent.offsetLeft;
		mOffsetParent = mOffsetParent.offsetParent;
	}
	return mOffsetLeft;
}
function getScrollY(){
	var scrOfY=0;
	if(typeof(window.pageYOffset)=='number'){
		//Netscape
		scrOfY=window.pageYOffset;
	}else if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){
		//DOM
		scrOfY=document.body.scrollTop;
	}else if(document.documentElement&&(document.documentElement.scrollLeft || document.documentElement.scrollTop)){
		//IE6
		scrOfY=document.documentElement.scrollTop;
	}
	return scrOfY;
}
function qh_hideElement(elmID, overDiv){
	if(document.all){
		for(i=0; i<document.all.tags(elmID).length; i++){
			obj=document.all.tags(elmID)[i];
			if(!obj||!obj.offsetParent)continue;

			// Find the element's offsetTop and offsetLeft relative to the BODY tag.
			objLeft   = obj.offsetLeft;
			objTop    = obj.offsetTop;
			objParent = obj.offsetParent;
			while(objParent.tagName.toUpperCase()!='BODY'){
				objLeft  += objParent.offsetLeft;
				objTop   += objParent.offsetTop;
				objParent = objParent.offsetParent;
			}
			objHeight=obj.offsetHeight;
			objWidth=obj.offsetWidth;
			if((overDiv.offsetLeft + overDiv.offsetWidth) <= objLeft);
			else if((overDiv.offsetTop + overDiv.offsetHeight) <= objTop);
			else if(overDiv.offsetTop >= (objTop + objHeight));
			else if(overDiv.offsetLeft >= (objLeft + objWidth));
			else{obj.style.visibility = 'hidden';}
		}
	}
}
function qh_showElement(elmID){
	if(document.all){
		for(i=0;i<document.all.tags(elmID).length;i++){
			obj=document.all.tags(elmID)[i];
				if(!obj||!obj.offsetParent)continue;
				obj.style.visibility='';
		}
	}
}

function mostra(id){
	//	alert(id);
	document.getElementById(id).style.display='';
}
function esconde(id){
	document.getElementById(id).style.display='none';
}

function fncCheckBox(id,vl){
	if(vl>0){
		$(id).checked=true;
	}else{
		$(id).checked=false;
	}
}

function mostra_conteudo_cliente (id_obj){
					if (id_obj == "cliente_sim") {
						mostra('tb_login'); 
						esconde('ficha1');
						mostra('ficha1b');
						$('passos').innerHTML = 'Passo 1/2';
						if ($("cliente_sim")) { 
						   $("cliente_sim").checked = true;
						}
						document.frmPasso1.hidden_cliente_conteudo.value = '2';
					} else {
						esconde('tb_login'); 
						mostra('ficha1'); 
						mostra('ficha1b');
						$('passos').innerHTML = 'Passo 1/3';
						if ($("cliente_nao")) { 
							$("cliente_nao").checked = true;
						}
						document.frmPasso1.hidden_cliente_conteudo.value = '1';
					}
				}
				
function fone(){
if (document.form.telefone.value.length == 0){
document.form.telefone.value = "(" + document.form.telefone.value; }
if (document.form.telefone.value.length == 3){
document.form.telefone.value = document.form.telefone.value + ") "; }
if (document.form.telefone.value.length == 9){
document.form.telefone.value = document.form.telefone.value + "-";}
}

function fone2(){
if (document.form.fax.value.length == 0){
document.form.fax.value = "(" + document.form.fax.value; }
if (document.form.fax.value.length == 3){
document.form.fax.value = document.form.fax.value + ") "; }
if (document.form.fax.value.length == 9){
document.form.fax.value = document.form.fax.value + "-";}
}

function postal(){
if (document.form.cep.value.length == 2){
document.form.cep.value = document.form.cep.value + "."; }
if (document.form.cep.value.length == 6){
document.form.cep.value = document.form.cep.value + "-"; }
}

function doc(){
if (document.form.rg.value.length == 2){
document.form.rg.value = document.form.rg.value + "."; }
if (document.form.rg.value.length == 6){
document.form.rg.value = document.form.rg.value + "."; }
if (document.form.rg.value.length == 10){
document.form.rg.value = document.form.rg.value + "-"; }
}

function doc2(){
if (document.form.cpf.value.length == 3){
document.form.cpf.value = document.form.cpf.value + "."; }
if (document.form.cpf.value.length == 7){
document.form.cpf.value = document.form.cpf.value + "."; }
if (document.form.cpf.value.length == 11){
document.form.cpf.value = document.form.cpf.value + "-"; }
}

function doc3(){
if (document.form.cnpj.value.length == 2){
document.form.cnpj.value = document.form.cnpj.value + "."; }
if (document.form.cnpj.value.length == 6){
document.form.cnpj.value = document.form.cnpj.value + "."; }
if (document.form.cnpj.value.length == 10){
document.form.cnpj.value = document.form.cnpj.value + "/"; }
if (document.form.cnpj.value.length == 15){
document.form.cnpj.value = document.form.cnpj.value + "-"; }
}

function doc4(){
if (document.form.data.value.length == 2){
document.form.data.value = document.form.data.value + "/"; }
if (document.form.data.value.length == 5){
document.form.data.value = document.form.data.value + "/";}
}

function doc5(){
if (document.form.datafinal.value.length == 2){
document.form.datafinal.value = document.form.datafinal.value + "/"; }
if (document.form.datafinal.value.length == 5){
document.form.datafinal.value = document.form.datafinal.value + "/";}
}

var vlSub=0; //GLobal
						

function somenteNumero(e,id_element){
	var key
	if(window.event) {
	// Atenter o IE
		key = e.keyCode; 
		if (( key < 47 )||( key > 58 )) {
				window.event.returnValue = null; 
				return;
		}		
	}
	else if (e.which) {
	//Atender NetScape.
			key = e.which;
			if (( key < 47 )||( key > 58 )) {
					e.preventDefault();
					return ; 
			}		
	}

}
var boolClicado = false;

function pulaCasa(vl,qtd,prox){
	var tamanho=vl.length;
	var limite=qtd;
	//alert(tamanho+'#'+qtd+'#'+prox);
		if(tamanho==limite){
			$(prox).focus();
		}
}

function abreJanela(url,nome,pars) { //v2.0
  window.open(url,nome,pars);
}

function abre_janela(width, height, nome, scrollbar) {
var top; var left;
top = ( (screen.height/2) - (height/2) )
left = ( (screen.width/2) - (width/2) )
window.open('',nome,'width='+width+',height='+height+',scrollbars='+scrollbar+',toolbar=no,location=no,status=no,menubar=no,resizable=no,left='+left+',top='+top);
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function fechar(){
	window.close();
}

function pulaCasa(vl,qtd,prox){
	var tamanho=vl.length;
	var limite=qtd;
	//alert(tamanho+'#'+qtd+'#'+prox);
		if(tamanho==limite){
			$(prox).focus();
		}
}

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_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+' precisa conter um e-mail válido.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' precisa conter números.\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+' é obrigatório\n'; }
  } if (errors) alert('Ocorreram os seguintes erros:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function resizeWindow(largura,altura){
	resizeTo(largura,altura);
	window.moveTo(largura,altura); 
}

-->