<!--

var browserName;
var browserVersion;
var browserVersionDecimal = 0;
var browserPlatform;
var tempVersion;

if (navigator.appName.toLowerCase().indexOf("netscape") != -1)
{
    browserName = "NS";
    browserVersion = parseInt(navigator.appVersion.charAt(0));
}
else if (navigator.appName.toLowerCase().indexOf("microsoft") != -1)
{
    browserName = "MSIE";
    tempVersion = parseInt(navigator.appVersion.charAt(0));
    if (tempVersion < 4)
      browserVersion = tempVersion;
    else {
      browserVersion = parseInt(navigator.appVersion.substr((navigator.appVersion.indexOf("MSIE ") + 5),1));
      browserVersionDecimal = parseInt(navigator.appVersion.substr((navigator.appVersion.indexOf("MSIE ") + 7),1));
    }

}
else
{
    browserName = "?";
    browserVersion = parseInt(navigator.appVersion.charAt(0));
}

if ((browserName == "NS") && (browserVersion < 4))
  browserPlatform = "WINDOWS"
else
{
  if (navigator.platform.toLowerCase().indexOf("win") != -1)
      browserPlatform = "WINDOWS";
  else if (navigator.platform.toLowerCase().indexOf("mac") != -1)
      browserPlatform = "MAC";
  else
      browserPlatform = "?";
}


// -- Contador para objeto TextArea.
function LimitaCampo(campo,tam){
	var tamanho = document.form[campo].value.length;
	var tex=document.form[campo].value;
	if (tamanho>=tam) {
		document.form[campo].value=tex.substring(0,tam); 
	}
	return true;
}

// --
function SetTexto(campo,txt) { campo.innerHTML = txt ; }


function FormataDado(campo,tammax,pos,teclapres){
	var tecla = teclapres.keyCode;
	vr = document.form[campo].value;
	vr = vr.replace( "-", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length ;

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){ tam = tam - 1 ; }
			
	if ( tecla == 8 || tecla == 88 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){
	 		document.form[campo].value = vr ;}
		if ( tam > pos && tam <= tammax ){
			document.form[campo].value = vr.substr( 0, tam - pos ) + '-' + vr.substr( tam - pos, tam );}
	}
}

function FormataValor(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.form[campo].value;
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	tam = vr.length;

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }
		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){ 
	 		document.form[campo].value = vr ; }
	 	if ( (tam > 2) && (tam <= 5) ){
	 		document.form[campo].value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 6) && (tam <= 8) ){
	 		document.form[campo].value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 9) && (tam <= 11) ){
	 		document.form[campo].value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 12) && (tam <= 14) ){
	 		document.form[campo].value = vr.substr( 0, tam - 11 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 15) && (tam <= 17) ){
	 		document.form[campo].value = vr.substr( 0, tam - 14 ) + '.' + vr.substr( tam - 14, 3 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ;}
	}		
	
}

function SaltaCampo (campo,prox,tammax,teclapres){
	var tecla = teclapres.keyCode;
	vr = document.form[campo].value;
	if( tecla == 109 || tecla == 188 || tecla == 110 || tecla == 111 || tecla == 223 || tecla == 108 ){
		document.form[campo].value = vr.substr( 0, vr.length - 1 ); }
	else{
	 	vr = vr.replace( "-", "" );
	 	vr = vr.replace( "/", "" );
	 	vr = vr.replace( "/", "" );
	 	vr = vr.replace( ",", "" );
	 	vr = vr.replace( ".", "" );
	 	vr = vr.replace( ".", "" );
	 	vr = vr.replace( ".", "" );
	 	vr = vr.replace( ".", "" );
	 	tam = vr.length;	
		
	 	if (tecla != 0 && tecla != 9 && tecla != 16 ){
			if ( tam == tammax ){
				if ( document.form[prox] )
					document.form[prox].focus();
			}
		}
	}
}

function FormataData(campo,e) {
	if(browserName == "MSIE"){
		keycode = e.keyCode;	
	} else {
		keycode = e.which;
	}
	
	vr = campo.value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length + 1;

	if ( keycode != 9 && keycode != 8 ){
		if ( tam > 2 && tam < 5 )
			campo.value = vr.substr( 0, tam - 2  ) + '/' + vr.substr( tam - 2, tam );
		if ( tam >= 5 )
			campo.value = vr.substr( 0, 2 ) + '/' + vr.substr( 2, 2 ) + '/' + vr.substr( 4, 4 ); 
	}

}


function FormataHora(Campo,teclapres) {
	var tecla = teclapres.keyCode
	vr = document.form[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 < 5 )
			document.form[Campo].value = vr.substr( 0, tam - 2  ) + ':' + vr.substr( tam - 2, tam )
	}
}


function FormataCpf(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.form[campo].value;
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	tam = vr.length;

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }
		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){ 
	 		document.form[campo].value = vr ; }
	 	if ( (tam > 2) && (tam <= 5) ){
	 		document.form[campo].value = vr.substr( 0, tam - 2 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 6) && (tam <= 8) ){
	 		document.form[campo].value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 9) && (tam <= 11) ){
	 		document.form[campo].value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 12) && (tam <= 14) ){
	 		document.form[campo].value = vr.substr( 0, tam - 11 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 15) && (tam <= 17) ){
	 		document.form[campo].value = vr.substr( 0, tam - 14 ) + '.' + vr.substr( tam - 14, 3 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + '-' + vr.substr( tam - 2, tam ) ;}
	}		
}

function VerificaJava()	{
	if (navigator.javaEnabled())
		document.form.javas.value="sim"
}

function IsNumeric(pNum){

	if (pNum==''){
		return false;
	}
	for (var i = 0; i < pNum.length; i++){
		var ch = pNum.substring(i, i + 1);
		if (ch < '0' || '9' < ch){
			return false;
		}
	}
	return true;
}


function IsDecimal(pNum){

	if (pNum==''){
		return false;
	}
	
	for (var i = 0; i < pNum.length; i++){
		var ch = pNum.substring(i, i + 1);
		if ((ch < '0' || '9' < ch) && (ch != ',') && (ch != '.') && (ch != '-')){
			return false;
		}
	}
	return true;
}


function IsDate(pData){

	if(pData.length<10 || pData.length>10){

		return false;
	}

	var ano = '' + pData.substring(6,10);
	var mes = '' + pData.substring(3,5);
	var dia = '' + pData.substring(0,2);
	
	if (!IsNumeric(ano) || !IsNumeric(mes) || !IsNumeric(dia)){
		return false;
	}
			
	if(dia>'31'){
		return false;
	}
				
	if(mes>'12'){
		return false;
	}

	if(ano<='1900'){
		return false;
	}

	if(mes=='02'){
		if(ano%4!=0 && dia>'28'){
			return false;
		}
		else{
			if(dia>'29'){
				return false;
			}
		}
	}
	
	if(mes<='07'){
		if(mes%2==0 && dia>'30'){
			return false;
		}
	}
	else{
		if(mes>'09'){
			if(mes%2!=0 && dia>'30'){
				return false;
			}
		}
	}
					
	return true
}

//FUNÇÃO PARA VALIDAR UMA HORA INFORMADA
function IsHour(pHora){

	if (pHora != ''){
	
		if(pHora.length < 4 || pHora.length > 5){
			return false
		}

		var aux = pHora.indexOf(":")
		var hora = pHora.substring(0,aux)
		var min = pHora.substring(aux+1,pHora.length)
	
		if(hora > 23 || hora < 0){
			return false
		}
					
		if(min > 59 || min < 0){
			return false
		}
	}
	
	return true
}


function IsEmail(email){

	if ((email.search(/;/i) == -1) &&
	    (email.search(/,/i) == -1) &&
	    (email.indexOf("..") == -1) &&
	    (email.indexOf(".@") == -1) &&
	    (email.indexOf("@.") == -1) &&
	    (email.search(/ /i) == -1) &&
	    (email.search(/"/i) == -1) &&
	    (email.search(/'/i) == -1) &&
	    (email.indexOf("^") == -1) &&
	    (email.search(/`/i) == -1) &&
	    (email.search(/´/i) == -1) &&
	    (email.search(/~/i) == -1) &&
	    (email.search(/ç/i) == -1) &&
	    (email.length != 0) &&
	    (email.search(/@/i) >= 2) &&
	    (email.substr(0,1) != ".") &&               //Não pode começar com ponto
	    (email.substr(email.length-1) != ".") &&    //Não pode terminar com ponto
	    (email.indexOf("hotmail.com.br") == -1) &&
	    (email.indexOf("aol.com.br") == -1) &&
	    (email.indexOf("globo.com.br") == -1) &&
	    (email.indexOf(" ") == -1))
		return true;
	else
		return false; 
}

function Mid(campo,x,y){

	var res;
	if(x>0)
		x = x-1;
	if(x+y > campo.length)
		y = campo.length
	else
		y = x + y;
	res = campo.substring(x,y);
	return res;
}

	
function Left(campo,x){

	var res;
	if(x > campo.length)
		x = campo.length;
	res = campo.substring(0,x);
	return res;
}

	
function Right(campo,x){

	var res;
	if(x > campo.length){
		res = campo;
		return res;
	}
	res = campo.substring(campo.length-x,campo.length);
	return res;
}

	
function UCase(campo){

	return campo.toUpperCase()
}

	
function LCase(campo){

	return campo.toLowerCase()
}

	
function RTrim(campo){

	y=true;
	while(y==true){
		x = campo.length;
		if(Right(campo,1)==' '){
			campo = Left(campo,x-1);
			y=true;
		}
		else{
			y=false
		}
	}
	return campo;
}

	
function LTrim(campo){

	y=true;
	while(y==true){
		x = campo.length-1;
		if(Left(campo,1)==' '){
			campo = Right(campo,x);
			y=true;
		}
		else{
			y=false;
		}
	}
	return campo;
}

	
function Trim(campo){

	return RTrim(LTrim(campo));
}


//FUNÇÃO PARA OCULTAR OU TORNAR VISÍVEL UM OBJETO DE UMA PÁGINA
function ShowHide(opcao,id) {
	
	el = document.all ? document.all[id] : 
	dom ? document.getElementById(id) : 
	document.layers[id];
	els = dom ? el.style : el;

	if (dom) {
	  if (opcao == 1) els.visibility = "visible"
	  else els.visibility = "hidden"
	}
	else if (ns4){
	  if (opcao == 1) els.visibility = "show"
	  else els.visibility = "hide"
	}

}

function IsNumber() {
	if ((event.keyCode >= 48) && (event.keyCode <= 57))
		return true;
	else
		return false;
}

// Tecla Enter se comportando como Tab
function SetFocus(campo){
	if(window.event.srcElement.type == 'text' || window.event.srcElement.type == 'password'){ 
		var ele = window.event.srcElement;
		//var index = ele.sourceIndex;
		if(window.event.keyCode == 13){
			//document.all.item(index + 2).focus(); 
			if (campo.disabled == false){
				if (campo.type != 'select-one')
					campo.select()
				else
					campo.focus()
			}
			
			window.event.returnValue = false;     
		}
	} 
}

/**
* Tecla Enter se comportando como Tab
* Modificada para funcionar no IE e Firefox
*/
function enterTab(e,idCampo){
	campo = document.getElementById(idCampo);
	if (browserName == "MSIE"){
		keyCode = e.keyCode;
		typeElement = e.srcElement.type;
	} else {
		keyCode = e.which;
		typeElement = e.target.type;
	}		
	
	if(typeElement == 'text' || typeElement == 'password'){ 		
		if(keyCode == 13){			
			if (campo.disabled == false){
				if (campo.type != 'select-one')
					campo.select()
				else
					campo.focus()
			}
			
			if (browserName == "MSIE"){
				e.returnValue = false;
			} else {
				e.preventDefault();
			}
			
		}
	} 

}

// Função utilizada para validação de CPF e CNPJ
function modulo(str) {

   	soma=0;
   	ind=2;
   	for(pos=str.length-1;pos>-1;pos=pos-1) {
   		soma = soma + (parseInt(str.charAt(pos)) * ind);
   		ind++;
   		if(str.length>11) {
   			if(ind>9) ind=2;
   		}
	}
   	resto = soma - (Math.floor(soma / 11) * 11);
   	if(resto < 2) {
    	return 0
   	}
   	else {
   		return 11 - resto
   	}
}

// Função para validação do CPF
function IsCPF(valor) {

	primeiro=valor.substr(1,1);
	falso=true;
	size=valor.length;
	if (size!=11){
		return false;
	}
	size--;
	for (i=2; i<size-1; ++i){
		proximo=(valor.substr(i,1));
		if (primeiro!=proximo) {
			falso=false
		}
	}
	if (falso){
		return false;
	}
   	if(modulo(valor.substring(0,valor.length - 2)) + "" + modulo(valor.substring(0,valor.length - 1)) != valor.substring(valor.length - 2,valor.length)) {
   		return false;
   	}
   	return true
}


// Função para validação do cnpj
function IsCNPJ(valor) {

	primeiro=valor.substr(1,1);
	falso=true;
	size=valor.length;
	if (size!=14){
		return false;
	}
	size--;
	for (i=2; i<size-1; ++i){
		proximo=(valor.substr(i,1));
		if (primeiro!=proximo) {
			falso=false
		}
	}
	
	if (falso){
		return;
	}
	
   	if(modulo(valor.substring(0,valor.length - 2)) + "" + modulo(valor.substring(0,valor.length - 1)) !=valor.substring(valor.length - 2,valor.length)) {
   		return false;
   	}
   	return true
}

//======================================================
// FUNÇÃO PARA ABRIR O FORMULÁRIO DE PESQUISA DE CIDADES 
//======================================================
function PesquisaCidades(uf,nome,campo_uf,campo_nome,campo_numg)
{
   url = "pesqcidades.asp?uf=" + uf + "&nome=" + nome + "&campo_uf=" + campo_uf + "&campo_nome=" + campo_nome + "&campo_numg=" + campo_numg
   
   if(navigator.appName.indexOf("Netscape")>=0){
		window.open(url,"pesqcidades","resizable=no,scrollbars=yes,status=no,toolbar=no,location=no,menubar=no,width=450,height=190,screenX=230,screenY=250")
   } else {
		window.open(url,"pesqcidades","resizable=no,scrollbars=yes,status=no,toolbar=no,location=no,menubar=no,width=450,height=190,top=" + (window.screenTop + 130) + ",left=" + (window.screenLeft + 100))
   }
		
}	

function FechaForm(){
	if (event.keyCode == 27){
		window.close()
	}
}

function pesquisarCEP(){
	var URL = "busca_CEP.htm";
	window.open(URL,'busca_CEP','scrollbars=no,screenX=150,screenY=150,width=338,height=333');
}


//==============================================================
// FUNÇÃO PARA MONTAR AS TAB's DOS FORMULARIO
//==============================================================
function AlteraTab(tab,ntabs){

	for (i=1;i<=ntabs;i++){		
		document.getElementById('tab' + i).style.display = "none"		
		document.getElementById('imgtab' + i).style.display = "none"				
	}
	document.getElementById('tab' + tab).style.display = "block"
	document.getElementById('imgtab' + tab).style.display = "block"	
	
}


function montaTabs(vRotulos,nTabs) {

	if (vRotulos.length > 0) {
		nRotulos = vRotulos.length
		sAux=""
		for (i=0;i<vRotulos.length;i++) {
			sAux += "<div id='imgtab" + (i+1) + "' style='display:none'>" + '\n'

			sAux += "<table border=0 width=255 height=26 cellspacing=0 cellpadding=0 align=left background='images/tab_" + (i+1) + "_" + nTabs + ".jpg'>" + '\n'
			sAux += "<tr align=center>" + '\n'
			for (j=0;j<vRotulos.length;j++) {
				//TAB EM DESTAQUE
				if (i==j) {
					sAux += "<td width='" + parseInt(100/nRotulos) + "%'><a href='javascript:AlteraTab(" + (j+1) + "," + nTabs + ")' class=link-tab><b>" + vRotulos[j] + "</b></a></td>" + '\n'
				} else {
					sAux += "<td width='" + parseInt(100/nRotulos) + "%'><a href='javascript:AlteraTab(" + (j+1) + "," + nTabs + ")' class=link-tab>" + vRotulos[j] + "</a></td>"
				}
			}
			sAux += "</tr>"
			sAux += "</table>"
			sAux += "</div>"
		}
		document.write(sAux)
	}
	
}

/**
* Troca a fonte de uma 
*/
function trocaClass(id,classe){
	document.getElementById(id).className=classe;
}

/*
 * LIGHTBOX from Caio Appelt Rezende
 */

//elemento = [name][index][ [href][title] ]
function lightbox(){return this;}
lightbox.prototype.layerDiv = null;
lightbox.prototype.layerDivTitle = null;
lightbox.prototype.layerDivFrame = null;
lightbox.prototype.layerDivFrameImg = null;
lightbox.prototype.newImg = null;
lightbox.prototype.aFotos = new Array();
lightbox.prototype.layer = function(){
	if(this.layerDiv==null){
		this.layerDiv = document.createElement('div');
		this.layerDiv.id = 'lightboxLayer';
		document.body.appendChild(this.layerDiv);

		var a = document.createElement('div');
		a.id = 'lightboxDiv';
		a.onclick = lightbox.prototype.hide;
		a.style.width = parseInt(document.body.clientWidth);
		a.style.height = parseInt(document.body.clientHeight);
		this.layerDiv.appendChild(a);

		var b = document.createElement('div');
		b.id = 'lightboxDivBtnClose';
		b.onmouseout = 'this.style.color=\"black\";';
		b.onmouseover = 'this.style.color=\"white\";';
		b.onclick = lightbox.prototype.hide;
		b.style.top=parseInt(document.body.clientHeight-30);
		b.innerHTML = 'fechar';
		lightbox.prototype.layer().appendChild(b);

		this.layerDivFrame = document.createElement('div');
		this.layerDivFrame.id = 'lightboxDivFrame';
		this.layerDivFrame.onclick = lightbox.prototype.hide;
		this.layerDivFrame.style.top=100;
		lightbox.prototype.layer().appendChild(this.layerDivFrame);
	}
	return this.layerDiv;
}
lightbox.prototype.setTitle = function(title,num,vetName){
	if(this.layerDivTitle==null){
		this.layerDivTitle = document.createElement('div');
		this.layerDivTitle.id = 'lightboxDivTitle';
		lightbox.prototype.layer().appendChild(this.layerDivTitle);
	}
	if (lightbox.prototype.aFotos[vetName]){
		if (num>0 && lightbox.prototype.aFotos[vetName].length>1)
			title = "<div id='lightboxDivBtnPrevious' OnMouseOver='this.style.color=\"white\";' OnMouseOut='this.style.color=\"black\";'  OnClick='mylightbox.show(\""+(parseInt(num)-1)+"\",\""+vetName+"\");'>anterior</div>"+title;
		if (num!=lightbox.prototype.aFotos[vetName].length-1)
			title = "<div id='lightboxDivBtnNext' OnMouseOver='this.style.color=\"white\";' OnMouseOut='this.style.color=\"black\";'  OnClick='mylightbox.show(\""+(parseInt(num)+1)+"\",\""+vetName+"\");'>próximo</div>"+title;
	}
	this.layerDivTitle.innerHTML = title;
}
lightbox.prototype.setImg = function(){

	while (lightbox.prototype.layerDivFrame.hasChildNodes()){
		lightbox.prototype.layerDivFrame.removeChild(lightbox.prototype.layerDivFrame.lastChild);
	}
	lightbox.prototype.layerDivFrame.appendChild(this.newImg);
	
	this.layerDivFrame.width = this.newImg.width;
	this.layerDivFrame.height = this.newImg.height;
	this.layerDivFrame.style.left=parseInt(document.getElementsByTagName('body')[0].scrollLeft+document.body.clientWidth/2-this.newImg.width/2);
}
lightbox.prototype.show = function(num,vetName){
	document.body.style.overflow='hidden';
	lightbox.prototype.layer().style.display="block";
	lightbox.prototype.layer().style.left=document.getElementsByTagName('body')[0].scrollLeft;
	lightbox.prototype.layer().style.top=document.getElementsByTagName('body')[0].scrollTop;
	lightbox.prototype.setTitle(lightbox.prototype.aFotos[vetName][num][1],num,vetName);

	while (lightbox.prototype.layerDivFrame.hasChildNodes()){
		lightbox.prototype.layerDivFrame.removeChild(lightbox.prototype.layerDivFrame.lastChild);
	}
	var a = document.createElement('img');
	a.src = 'images/loading.gif';
	a.onclick = lightbox.prototype.hide;
	lightbox.prototype.layerDivFrame.appendChild(a);
	lightbox.prototype.layerDivFrame.style.left=parseInt(document.getElementsByTagName('body')[0].scrollLeft+document.body.clientWidth/2);
	lightbox.prototype.newImg = new Image();
	lightbox.prototype.newImg.src = lightbox.prototype.aFotos[vetName][num][0];
	
	setTimeout('lightbox.prototype.setImgComplete();',1000);
}
lightbox.prototype.setImgComplete = function(){
	if (lightbox.prototype.newImg.complete){
		lightbox.prototype.setImg();
	}else{
		setTimeout('lightbox.prototype.setImgComplete();',1000);
	}
}
lightbox.prototype.hide = function(){
	lightbox.prototype.layer().style.display="none";
	document.body.style.overflow='auto';
}
//-->
//first, tell the browsers to react to the event
if( document.captureEvents && Event.KEYUP ) {
  //remove this part if you do not need Netscape 4 to work
  document.captureEvents( Event.KEYUP );
}
/* this next line tells the browser to detect a keyup
event over the whole document and when it detects it,
it should run the event handler function 'alertkey' */
document.onkeyup = alertkey;

//now create the event handler function to process the event
function alertkey(e) {
  if( !e ) {
    //if the browser did not pass the event information to the
    //function, we will have to obtain it from the event register
    if( window.event ) {
      //Internet Explorer
      e = window.event;
    } else {
      //total failure, we have no way of referencing the event
      return;
    }
  }
  if( typeof( e.keyCode ) == 'number'  ) {
    //DOM
    e = e.keyCode;
  } else if( typeof( e.which ) == 'number' ) {
    //NS 4 compatible
    e = e.which;
  } else if( typeof( e.charCode ) == 'number'  ) {
    //also NS 6+, Mozilla 0.9+
    e = e.charCode;
  } else {
    //total failure, we have no way of obtaining the key code
    return;
  }
  if (e==37 && document.getElementById('lightboxDivBtnPrevious')){
	  setTimeout(document.getElementById('lightboxDivBtnPrevious').onclick,100);
  }if (e==39 && document.getElementById('lightboxDivBtnNext')){
	  setTimeout(document.getElementById('lightboxDivBtnNext').onclick,100);
  }
  //window.alert('The key pressed has keycode ' + e +
  //  ' and is key ' + String.fromCharCode( e ) );
}

function CleanEl( element ){
	while(document.getElementById(element).hasChildNodes()){
		document.getElementById(element).removeChild(document.getElementById(element).firstChild);
	}
}
function AddHTML( element,text, top ){
	if(document.getElementById(element)){
		var newdiv = document.createElement("div");
		if (top)
			newdiv.innerHTML = text+document.getElementById(element).innerHTML;
		else
			newdiv.innerHTML = document.getElementById(element).innerHTML+text;

		CleanEl(element);
		document.getElementById(element).appendChild(newdiv);
	}
}