<!--

// Janela Rapida


function abre(url,janela,larg,alt,scroll,pos1,pos2) {
open(url,janela,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scroll+',resizable=no,copyhistory=no,top='+pos1+',left='+pos2+',screenY='+pos1+',screenX='+pos2+',width='+larg+',height='+alt);

}

// Banner Lateral direito

<!-- Original:  Randy Bennett (rbennett@thezone.net) -->
<!-- Web Site:  http://home.thezone.net/~rbennett/sitemap.htm -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function setVariables() {
if (navigator.appName == "Netscape") {

v = ".top=";
h = ".left=";
dS = "document.";
sD = "";
y = "window.pageYOffset";
// x = "window.pageXOffset";
// iW = "window.innerWidth";
iH = "window.innerHeight";
}

else {

h = ".pixelLeft=";
v = ".pixelTop=";
dS = "";
sD = ".style";
y = "document.body.scrollTop";
// x = "document.body.scrollLeft";
// iW = "document.body.clientWidth";
iH = "document.body.clientHeight";
}
xyz = 500;
// innerX = eval(iW) - 240;
innerY = eval(iH) - 310;
//innerY = 1;
object = "logo";
checkLocationA();
}
// movex = 0;
movey = 0;
// xdiff = 0;
ydiff = 0;
ystart = 0;
// xstart = 0;

function checkLocation() {
yy = eval(y);
// xx = eval(x);
ydiff = ystart - yy;
// xdiff = xstart - xx;
if ((ydiff < (-1)) || (ydiff > (1))) movey = Math.round(ydiff / 10), ystart -= movey;
// if ((xdiff < (-1)) || (xdiff > (1))) movex = Math.round(xdiff / 10), xstart -= movex;

eval(dS + object + sD + v + (ystart + innerY));
eval(dS + object + sD + h + (600));
setTimeout("checkLocation()", 10);
}

function checkLocationA() {
ystart = eval(y);    

// xstart= eval(x);
}

function switchLogo(abc) {
if (abc == "menu") {
eval(dS + object + sD + v + 0);
eval(dS + object + sD + h + (600));
object = abc;
}
else xyz = setTimeout("delayLogo()", 2000)
}

function delayLogo() {
eval(dS + object + sD + v + 0);
// eval(dS + object + sD + h + (-200));
object = 'logo';
}
//  End -->








// Popup
function GetCookie(Name) {
 var search = Name + "="
 if (document.cookie.length > 0) {
  offset = document.cookie.indexOf(search)
  if (offset != -1) {
    offset += search.length
    end = document.cookie.indexOf(";", offset)
    if (end == -1) end = document.cookie.length
    return unescape(document.cookie.substring(offset, end))
  }
 }
}
function DisplayInfo(pagina,janela,w,h,withcookie,scrolling) {
 var show
 show = 1
 if (!scrolling) { scrolling='auto' }
 if (withcookie) {
  show = !GetCookie(withcookie)
  document.cookie = withcookie+"=1;path=/;domain=.terra.com.br"
 }
 if (show) { 
  resultado = window.open(pagina,janela,'width='+w+',height='+h+',scrollbars='+scrolling+',toolbar=no,location=no,status=no,menubar=no,resizable=no,left=0,top=0')
  if ((navigator.appName != "Microsoft Internet Explorer") && (navigator.appVersion.substring(0,1) >= "3")) resultado.focus();
 }
}
// Rollover dos menus
function mOvr(src,clrOver) {
 if (!src.contains(event.fromElement)) {
  src.style.cursor = 'hand';
  src.bgColor = clrOver;
 }
}
function mOut(src,clrIn) {
 if (!src.contains(event.toElement)) {
  src.style.cursor = 'default';
  src.bgColor = clrIn;
 }
}
function mClk(src) {
 if(event.srcElement.tagName=='TD'){
  src.children.tags('A')[0].click();
 }
}
// Today's Date
var now = new Date();
var mName = now.getMonth() + 1;
var dName = now.getDay() + 1;
var dayNr = now.getDate();
var yearNr=now.getYear();
if(dName==1) Day = "Domingo";
if(dName==2) Day = "Segunda";
if(dName==3) Day = "Ter&ccedil;a";
if(dName==4) Day = "Quarta";
if(dName==5) Day = "Quinta";
if(dName==6) Day = "Sexta";
if(dName==7) Day = "S&aacute;bado";
if(mName==1) Month = "janeiro";
if(mName==2) Month = "fevereiro";
if(mName==3) Month = "março";
if(mName==4) Month = "abril";
if(mName==5) Month = "maio";
if(mName==6) Month = "junho";
if(mName==7) Month = "julho";
if(mName==8) Month = "agosto";
if(mName==9) Month = "setembro";
if(mName==10) Month = "outubro";
if(mName==11) Month = "novembro";
if(mName==12) Month = "dezembro";
if(yearNr < 2000) Year = 1900 + yearNr;
else Year = yearNr;
var todaysDate =(" " + Day + ", " + dayNr + " de " + Month + " de " + Year);


// Today's Date DD/MM/AAAA
var now2 = new Date();
var mName2 = now.getMonth() + 1;
var dayNr2 = now.getDate();
var yearNr2=now.getYear();
if(mName2==1) Month2 = "01";
if(mName2==2) Month2 = "02";
if(mName2==3) Month2 = "03";
if(mName2==4) Month2 = "04";
if(mName2==5) Month2 = "05";
if(mName2==6) Month2 = "06";
if(mName2==7) Month2 = "07";
if(mName2==8) Month2 = "08";
if(mName2==9) Month2 = "09";
if(mName2==10) Month2 = "10";
if(mName2==11) Month2 = "11";
if(mName2==12) Month2 = "12";
if(yearNr2 < 2000) Year2 = 1900 + yearNr2;
else Year2 = yearNr2;
var DDMMAAAADate =(dayNr2 + "/" + Month2 + "/" + Year2);




// Verificação de Formularios
var Validar;
function Localizar(frm) {

	if (frm.Pesquisa.value == "") {
		alert("O campo de pesquisa não pode ser nulo ! Digite um valor apropriado !");
		frm.Pesquisa.focus();
		return(false);
	}
	else {
		return(true);
	}
}

function Vazio(par1,par2,par3) {

	if (!par3 || par3=="") {
		if (!Validar) {
			alert("Este campo não pode ser nulo ! Digite um valor apropriado !");
			eval("document." + par1 + "." + par2 + ".focus()");
			Validar = true;
		}
		return(false);
	}
	else {
		Validar = false;
		return(true);
	}

}

function SoNumeros(asValor) {

	var rsValor;
	rsValor = asValor;

	for (var i=0; i<rsValor.length; i++) {
//		if (isNaN(rsValor.substring(i,i+1))) {
		if ((rsValor.charAt(i) < '0') || (rsValor.charAt(i) > '9')) {
			rsValor = rsValor.substring(0,i)+rsValor.substring(i+1,rsValor.length)
			i = i - 1;
		}
	}
	return rsValor;
}

function replaceString(oldS,newS,fullS) {

	for (var i=0; i<fullS.length; i++) {
		if (fullS.substring(i,i+oldS.length) == oldS) {
	        	fullS = fullS.substring(0,i)+newS+fullS.substring(i+oldS.length,fullS.length)
	      	}
	 }
	   	return fullS;
}

function FormataCPFCNPJ(frm,item, tipo){
	
	var rsMask
	var rsValor;
	var rsVAux;
	rsVAux  = "";
	var rsVAux;
	rsVAux  = "";
	rsValor = SoNumeros(item);

       	while (rsValor.indexOf(" ") != -1) {
			rsValor = replaceString(" ", "", rsValor);
		}
	if ((rsValor.length == 0) || (rsValor == ""))
	{
		frm.elements[tipo].value = rsValor;
		return(false);
	}

	rsValor = "00000000000000" + rsValor;

	if (tipo == "UCpf") 
	{
		rsValor = rsValor.substring(rsValor.length - 11, rsValor.length);
		rsVAux  = rsValor.substring(0, 3) + ".";
		rsValor = rsValor.substring(3, rsValor.length);
		rsVAux  = rsVAux + rsValor.substring(0, 3) + ".";
		rsValor = rsValor.substring(3, rsValor.length);
		rsVAux  = rsVAux + rsValor.substring(0, 3) + "-";
		rsValor = rsValor.substring(3, rsValor.length);
	}

	if (tipo == "Cnpj") 
	{	
		rsValor = rsValor.substring(rsValor.length - 14, rsValor.length);
		rsVAux  = rsValor.substring(0, 2) + ".";
		rsValor = rsValor.substring(2, rsValor.length);
		rsVAux  = rsVAux + rsValor.substring(0, 3) + ".";
		rsValor = rsValor.substring(3, rsValor.length);
		rsVAux  = rsVAux + rsValor.substring(0, 3) + "/";
		rsValor = rsValor.substring(3, rsValor.length);
		rsVAux  = rsVAux + rsValor.substring(0, 4) + "-";
		rsValor = rsValor.substring(4, rsValor.length);
	}
	
	if (tipo == "Pesquisa" &&   (frm.name == "Empresa" || frm.name == "Pesquisa")) 
	{	
		rsValor = rsValor.substring(rsValor.length - 14, rsValor.length);
		rsVAux  = rsValor.substring(0, 2) + ".";
		rsValor = rsValor.substring(2, rsValor.length);
		rsVAux  = rsVAux + rsValor.substring(0, 3) + ".";
		rsValor = rsValor.substring(3, rsValor.length);
		rsVAux  = rsVAux + rsValor.substring(0, 3) + "/";
		rsValor = rsValor.substring(3, rsValor.length);
		rsVAux  = rsVAux + rsValor.substring(0, 4) + "-";
		rsValor = rsValor.substring(4, rsValor.length);
	}

	rsValor = rsVAux + rsValor.substring(0, 2);

	frm.elements[tipo].value = rsValor;
	return(true);

}

function VerificaEmail(par1,par2,par3,par4){

	if ((!par3 || par3=="") && par4) {
		if (!Validar) {
			alert("Este campo não pode ser nulo ! Digite um valor apropriado !");
			eval("document." + par1 + "." + par2 + ".focus()");
			Validar = true;
		}
		return(false);
	}
	else {

		var email = par3;
		var suportado = 0;

		if (window.RegExp) {
			var tempReg = /a/;
			if (tempReg.test("a")){
			suportado = 1;
			}
		}

		if (!suportado){
			if (!(((email.indexOf(".") > 0) && (email.indexOf("@") > 0)) && ((email.lastIndexOf(".") < (email.length - 1)) && (email.lastIndexOf("@") < (email.length -1))))){
				if (par3){
					alert("Por favor confira o campo e-mail !");
					eval("document." + par1 + "." + par2 + ".focus()");
					if (par4){
						Validar = true;
					}
					return(false);
				}
			}
			if (par4){
				Validar = false;
			}
			return(true);
		}
		else{	
			var tmp1 = /(@.*@)|(\.\.)|(@\.)|(^\.)/;
			var tmp2 = /^.+@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;

			if (!(!tmp1.test(email) && tmp2.test(email))){
				if (par3){
					alert("Por favor confira o campo e-mail !");
					eval("document." + par1 + "." + par2 + ".focus()");
					if (par4){
						Validar = true;
					}
					return(false);
				}
			}
			if (par4){
				Validar = false;
			}
			return(true);
		}

	}
			
}

function Remote() {
    var remote = null
    remote = window.open('192.168.0.3/conff01.asp','promocao','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,menubar=no,width=290,height=250')
    if (remote != null) {
        remote.location.href = '192.168.0.3/conff01.asp'
    }
}

//-->

function EmpresaIndex(campo){

		if (campo.value.length==0){
		alert("Preencha o campo indicado!");
		campo.focus();
		return false;}
	
}

function initArray()
{
	this.length = initArray.arguments.length;
      for (var i = 0 ; i < 14 ; i++) 
	{
      	this[i] = " ";
      }
}

function calculaDigito( cgc_limite,  num)       
{
     cgc_soma = 0;
     cgc_ind = 1;
     cgc_peso = cgc_limite - 7 - cgc_ind;
     while(cgc_ind < cgc_limite) 
     {
         cgc_soma += num[cgc_ind - 1] * cgc_peso;
         cgc_ind++;
         if(cgc_peso == 2)
              cgc_peso = 9;
         else
              cgc_peso--;
     }
     cgc_resto = mod(cgc_soma, 11);
     if(cgc_resto == 0 || cgc_resto == 1)
           {cgc_digito = 0;}
     else
           {cgc_digito = 11 - cgc_resto;}
     return cgc_digito;
}

function mod(ini, fim)  
{
     t = ini % fim;
     return t;
}

function testaCgc(campoCgc)     
{
      var num1 = new initArray(14);
      if(campoCgc == 0) 
	{     alert("CNPJ nulo");
            return false;
	}
	if(campoCgc.length != 14)
	{
         alert("CNPJ diferente de 14 posições");
            return false; 
	}
            for (var i = 0 ; i < 14 ; i++)
		{
               num1[i] = campoCgc.substring(i, i+1); 
		}
                              
        digito13 = calculaDigito(13, num1);
        digito14 = calculaDigito(14, num1);
	if (num1[12]==(digito13) && num1[13]==(digito14)){
            return true;  }
      else {
            alert("CNPJ incorreto");
            return false;  }
  
}

function ValidaEmpresa(){
	
	var lenght = document.Usuario.length;
	for (var i=0;i<lenght;i++){
		if (document.Usuario.elements[i].name.toLowerCase() != "homepage" && document.Usuario.elements[i].name.toLowerCase() != "estado" && document.Usuario.elements[i].name.toLowerCase() != "telramal" && document.Usuario.elements[i].name.toLowerCase() != "faxramal" && document.Usuario.elements[i].name.toLowerCase() != "faxddd" && document.Usuario.elements[i].name.toLowerCase() != "fax" && document.Usuario.elements[i].name.toLowerCase() != "complemento" && document.Usuario.elements[i].name.toLowerCase() != "cargodepartamento"){
			if (document.Usuario.elements[i].value == ""){
				alert("Os campos de preenchimento obrigatório não podem ter valor nulo !");
				document.Usuario.elements[i].focus();
				return false;
			}
		}
	}
	if (document.Usuario.emailcad.value != document.Usuario.confirmacaoemailcad.value){
		alert("Os campos E-mail e Confirmação de E-mail devem ter o mesmo valor !");
		document.Usuario.emailcad.focus();
		return false;
	}
	if (document.Usuario.senha.value != document.Usuario.confirmacaosenha.value){
		alert("Os campos Senha e Confirmação de Senha devem ter o mesmo valor !");
		document.Usuario.senha.focus();
		return false;
	}

	return true;
}
function CopiaEmail(){

	document.Usuario.emailcad.value = document.Usuario.email.value;
	
}   

function Validacao(){
	
	var lenght = document.Usuario.length;
	for (var i=0;i<lenght;i++){
		if (document.Usuario.elements[i].name.toLowerCase() != "homepage" && document.Usuario.elements[i].name.toLowerCase() != "estado" && document.Usuario.elements[i].name.toLowerCase() != "telramal" && document.Usuario.elements[i].name.toLowerCase() != "faxramal" && document.Usuario.elements[i].name.toLowerCase() != "faxddd" && document.Usuario.elements[i].name.toLowerCase() != "fax" && document.Usuario.elements[i].name.toLowerCase() != "complemento" && document.Usuario.elements[i].name.toLowerCase() != "cargodepartamento"){
			if (document.Usuario.elements[i].value == ""){
				alert("Os campos de preenchimento obrigatório não podem ter valor nulo !");
				document.Usuario.elements[i].focus();
				return false;
			}
		}
	}
	if (document.Usuario.senha.value != document.Usuario.confirmacaosenha.value){
		alert("Os campos Senha e Confirmação de Senha devem ter o mesmo valor !");
		document.Usuario.senha.focus();
		return false;
	}

	return true;
}
function CopiaEmail(){

	document.Usuario.emailcad.value = document.Usuario.email.value;
	
}   

// Verifica campo em branco


function testacampo(campo)

{

if (campo.value.length == 0 )

{
   alert("Clique OK para saber qual o campo de preenchimento obrigatório.");
   campo.focus();
   return false;
}
   
   else 
      return true;
}

// Desabilita o Enter em Formulários

function desabilitaEnter() {
    var tecla = event.keyCode;
    if ((tecla == 13)) { 
    return false;
    }
    return tecla;
}