/*
	Assec 2002 ixPP  1.0  ( acesso )
 // 	
 // 
 //
 //       Coder  ppires@assec.pt
 //       file ixmenu.js( da  pagina principal)

*/

    
//window.captureEvents(event.RESIZE);   
window.onresize=ixredimensiona;
window.onload=ixredimensiona;


    
      
//window.onscroll=ixscroll;
function ixscroll(){
	// posicionaIMGTopo();
	return true;
}


function LayerVis(layer,modo){
	if (!layer) return;
   
 /* 
   if ((modo=='') or (modo == 'true')) var visivel = 'visible';
     else var  visivel = 'none';
*/
	if ( !modo ) modo =  'visible';

	if (document.all) 
		layer.style.display= modo;
	else 
		layer.display= modo;
}


function LayerWH(layer,w,h){
   if (!layer) return;
   
 /* 
   if ((modo=='') or (modo == 'true')) var visivel = 'visible';
     else var  visivel = 'none';
*/
   modo =  'visible';
 
   if (document.all){ 
		layer.style.width= w;
		layer.style.height= h;
	} else 
		layer.display= modo;
}




function arranca(){
	posicionaIMGTopo();
	document.getElementById('lmain').style.visibility = "visible";
	document.getElementById('swfMenu').style.visibility = "visible";
	document.getElementById('legenda').style.visibility = "visible";
}
    
    
function PosicionaLayer(layer, pposx, pposy){
	this.pposx = pposx;
	this.pposy = pposy;

	if (!layer) return;


	if (document.all) {
		layer.style.left = pposx+"px"; 
		layer.style.top  = pposy+"px"; 
		layer.style.visibility = "visible";
	} else {
		layer.setAttribute('style', 'left: '+pposx+'; top: '+pposy+'; visibility: visible;');		
		/* layer.left = this.pposx;
		layer.top  = this.pposy;
		layer.visibility= "visible";*/
	}  
}

function GetHeight(layer){
	if (!layer) return 0;
	if (document.all) {
		if (false && layer.style.pixelHeight)
			return (layer.style.pixelHeight);
		else
			return (layer.clientHeight);
	}
	else {
		if (false && layer.style.pixelHeight)
			return (layer.style.pixelHeight);
		else
			return (layer.clientHeight);
	}
	return (-1);
}       

function posicionaIMGTopo(){
	var  l= new Object ;
	if (document.all){ 
		l =  document.all;  
	} else {
		l =  document;
	};
		  
	var posx= 0;
	var posy= 0;	 

	var largura =  parseInt(document.body.clientWidth) || parseInt(document.documentElement.clientWidth ); 	 
	if (largura > 900)  posx= (largura -900)/2;
				 
	var altura =  parseInt(document.body.clientHeight) || parseInt(document.documentElement.clientHeight );   
	if (altura > 585 )  posy = ( altura- 585)/2

	if (posy < 1 ) posy = 0;
	if (posx < 1  ) posx = 0;
	
 
	window.posx = posx;
	window.posy = posy;
	
//	PosicionaLayer(l.lmain, posx, posy);
//	PosicionaLayer(l.layerzmain , posx+2, posy+180);
 
	PosicionaLayer( document.getElementById('lacssi') , posx+529, posy+14); 
	PosicionaLayer( document.getElementById('legenda') , posx+736, posy+580); 
	PosicionaLayer( document.getElementById('swfMenu') , posx, posy); 
	if ( posy > 82){
		PosicionaLayer( document.getElementById('fundoestrealas') , posx+695,posy - 89 ); 
		PosicionaLayer( document.getElementById('legenda') , posx+736, posy+590);
		}
	 else  {
		PosicionaLayer( document.getElementById('fundoestrealas') , posx+692,posy-42); 
		PosicionaLayer( document.getElementById('legenda') , posx+736, posy+582); 
		}
	//pcontentorresized();
};

         
         
function ixredimensiona(){
	posicionaIMGTopo();
	return  true;
}



function  fviewn(){
	var now=new Date()

	v=(now.getSeconds())*10000 + (now.getMinutes())*1000 +
		(now.getDate())*100 + (now.getMonth())*100+(now.getHours()) ;
	v=v+1;
	return v;
}


function sp (){
	var l = document.getElementById('limpressor'+plingua);
	if ( l ) 
		l.style.display = 'block';
}
  
function nosp (){
	var l = document.getElementById('limpressor'+plingua);
	if ( l ) l.style.display = 'none';
}

function  ixfuncao(valor,lingua){
	plingua = lingua;

	if ( valor != 0 )
		sp();
	else 
		nosp();

	zix = valor;
	if ( !zmain.ixlpfuncao ){
		burl = location.href ;
		zmain.location.href=burl+ 'main.php?cix='+escape(valor)
			+"&lang="+ escape(lingua)
			+'&v='+ fviewn();
		return;
	}
	zmain.ixlpfuncao(valor,lingua);
	posicionaIMGTopo();
	pcontentorresized()
	return;
}

function  busca(valor,lingua){
	zmain.busca(valor)
	posicionaIMGTopo();
}


function zprint(){
	zmain.zprint();
}



function mostraCaminho(){}


function ixcol(valor){
	var l = document.getElementById('layerbarra');
    if  (!l) return;
	   
	var cor= '01';
	switch(valor){
	       
		case '2':
			cor= '03';
			break; 
		case '3':
			cor= '02';
			break; 
		case '4':
			cor= '04';
			break; 
		case '5':
			cor= '05';
			break; 	
		}
	
 	 l.style.background = 'url(\'./images/bkg_direita_'+cor+'.gif\') ';
 
	}

	 
var img1 = './images/bkg_direita_01.gif';
var img2 = './images/bkg_direita_02.gif';
var img3 = './images/bkg_direita_03.gif';
var img4 = './images/bkg_direita_04.gif';
var img5 = './images/bkg_direita_05.gif';
 
 
 //////////////////////////////////////
var tempo = 200;

var Stopdown= 0;
var Stopup= 0;

var posxpp= 0;
var posxppinc = 50;

var scrollParado = 0;

 
function LayerScr(){
	return QLayerScr('zmain');
}


function LayerNAV(){
	return QLayerScr( 'LayerNAV');
}



function QLayerScr(name){

  var  lm= new Object ;

       lm  = document.getElementById(name);

  return lm;
}


function PGoUp() {
 
       if (Stopup) return;
       IxFGoUp();
       setTimeout("  PGoUp()",tempo);

}

function PGoDown() {
		if (scrollParado) return;
        if (Stopdown) return;
        IxFGoDown();
      setTimeout("  PGoDown()",tempo);
}

function IxFGoUp(){
    lm=  LayerScr();
    if (document.all){
        posxpp -=  posxppinc;
        if ( posxpp <  posxppinc ) posxpp= 0;
        zmain.window.scroll(0, posxpp);
    }
     else {
     if ( !(lm.top) ) lm.top=0;

           if (lm.style.position != 'absolute')
                lm.style.position = 'absolute';

           lm.top = lm.top -50;
          }
};


function  IxFGoDown(){

    lm=  LayerScr();
    if (document.all) {
        posxpp +=  posxppinc;
        zmain.window.scroll(0, posxpp);

    }
      else {



           }
}


function FStopdown() {
    Stopdown = 1;   
}

function FStopup() {
    Stopup = 1;
}

function FGodown() {
    Stopdown = 0;
    PGoDown();
}



function FGoUp() {
    Stopup = 0;
    PGoUp();
}

///////////////////////
function SGoDown() {
  if (scrollParado) return;
  
    Stopdown = 0;
     IxFGoDown();
}



 function SGoUp() {
   if (scrollParado) return;
    Stopup = 0;
    IxFGoUp();
    }
//////////////////////////

  function pcontentorresized(){
	var  lm= new Object ;
	var  ln= new Object ;

//alert( zmain.LayerConteudo.scrollHeight);
	lm=  LayerScr();
	ln = LayerNAV();
  
    var barazl  = document.getElementById('barritaazule');

	var mAltura = 0;
    if ( !(document.all) ) {
	   
		var bzl =  frames['zmain'].document.getElementById('LayerConteudo');
		mAltura =   bzl.scrollHeight;
        }
		else  mAltura =   zmain.LayerConteudo.scrollHeight;

 
     //alert(zmain.LayerConteudo.scrollHeight+'+');
	 
      if (   mAltura > 390 ){

          ln.style.visibility="visible";
		  barazl.style.visibility="visible";
		  scrollParado = 0;
          }
         else {
			ln.style.visibility="hidden";
			barazl.style.visibility="hidden";
			scrollParado = 1;
			}


       }

    
	
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
	
 // click na tecla 'A'
 // coder: ppires@assec.pt

 var  espera =  false;
 var  activo =  false;
 var  mostra =  false;
 
 var eSiga = null;
 var eActivo = null;	
 var eActivoF = null;	
 
function  actAviso(){
	 
	eSiga = setTimeout('sigaA()',3000); 	
	espera =  true;			
      
	setTimeout(' abre()',500); 
	return true;
	}	
	
 function sigaA() { 
      
	fecha();
	clearTimeout(eSiga); 
     
	espera = false;	
     	
	activo = true	
	return true;
	} 

	
 function abre(){
    if (!espera ) return true;
 	var q=  document.getElementById('lacss');  if (!q) return  true;
	q.style.visibility = 'visible';
	}
 function  fecha(){
    clearTimeout(eSiga); 
    var p=  document.getElementById('lacss'); if (!p) return  true;
	p.style.visibility = 'hidden';
	}
	
function kix(e){

	if( window.event)  keynum = event.keyCode;
		else if ( e.which)  keynum = e.which;
     
	if (keynum == 97   ){ 
		if (!espera) return  actAviso();
		 else 
			if ( activo) {	
				activo=false;
				clearTimeout(eSiga);
				
				setTimeout( " open('simples','wa0') ",50);
				setTimeout( " espera = false ",100);
				fecha();
				return true;
				}
		}
		else  {
			espera =  false;
			clearTimeout(eSiga);
			fecha();
			}
    
 	return true;	 
	}
 

 
 function kixOff(){
    espera = false;
	activo = false;
    clearTimeout(eSiga);
 
	fecha();
	 
	return true;
	}	
	

////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////





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];}}
}

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];}
}
