/*
	Assec 2002 ixPP  1.0  ( acesso )
 // 	
 // 
 //
 //       Coder  ppires@assec.pt
 //       file ixmenu.js( da  pagina principal)

*/
 document.write('<script language=\"javascript\" type=\"text/javascript\" src=\"db/funcoes/js/ixmain.js\"><\/script>')

    
//window.captureEvents(event.RESIZE);   
window.onresize=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 (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';
*/
      
   if (document.all){ 
         layer.style.width= w;
         layer.style.height= h;
         }
      else 
          layer.display= modo;
      
}




 function arranca(){
	 
     posicionaIMGTopo();
    document.getElementById('layerzmain').style.visibility= "visible";
    document.getElementById('swfzmenu').style.visibility= "visible"; 

    }
    
    
 function PosicionaLayer(layer,pposx,pposy){
     this.pposx = pposx;
     this.pposy = pposy;
    
      if (!layer) return;
     
     layer.style.left=pposx+"px"; 
      layer.style.top=pposy+"px"; 
	 
      if (document.all) {
        layer.style.left=pposx+"px"; 
        layer.style.top=pposy+"px"; 
        layer.style.visibility= "visible";

        }
      else {
           layer.left = this.pposx;
          layer.top  = this.pposy;
          layer.style.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 ;
		var posx = 0;
		var posy = 0;


		if (document.all){ 
			l =  document.all;  }
		else {
			l =  document;
		};

		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 > 600 )  posy = ( altura - 600)/2
 
 

		if (posy < 0  ) posy = 0;
		if (posx < 0  ) posx = 0;

		window.posx = posx;
		window.posy = posy;



	 	setIZStyle( getObj('layerswf'),'position:absolute; left:'+posx+'px; top:'+posy+'px; ');
		setIZStyle( getObj('layerzmain'),'position:absolute; left:'+parseInt(posx+196)+'px; top:'+parseInt(posy+131)+'px; visibility: visible;');
		
		setIZStyle( getObj('Layerfundo'),'position:absolute; left:'+0+'px; top:'+0+'px; width:100%; height:100%;');
		
		setIZStyle( getObj('divBottom'),'position:absolute; left:'+parseInt(posx)+'px; top:'+parseInt(posy+600)+'px; width:900px; height:'+ parseInt(altura-600-posy) +'px; visibility: visible;');
	};



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;
}


	var ultObj;
	function getObj(valor){
		var ultObj= document.getElementById( valor );
		return  ultObj;
		}
		


function setIZStyle(obj,nomes,valores) {
     
	if ( !obj ) return;
	 
	if ( isString(nomes) ){
		if ( !document.all ){
			obj.setAttribute('style',nomes);	
			return;
			}
		
	    tmp = nomes.split(';');
		 
		if ( isArray(tmp) )
		for (i=0; i < tmp.length; i++){
		    if ( tmp[i] == undefined  || tmp[i] == '' ) continue;
			var tmpa = tmp[i].split(':');
			if ( isArray(tmpa) )
				if ( tmpa[0] != undefined 
					&& tmpa[1] != undefined 
					&& tmpa[0] != '' 
					&& tmpa[1] != '' 
					)  obj.style.setAttribute(tmpa[0].replace(/ /,""),  tmpa[1].replace(/ /,"")); 
					   
			} 
		 
		return;
		} 

	if ( nomes == null || valores == null) return;
	if ( !document.all){ 
			var estilo= '';
			for(var i=0 ; i	< nomes.length; i++)
				estilo = estilo + nomes[i]+':'+valores[i]+'; ';
			obj.setAttribute('style',estilo);		
			}
		else
			for(var i=0 ; i	< nomes.length; i++)
				obj.style.setAttribute(nomes[i],valores[i]);
			
	}
	 


function sp (){

  var l = document.getElementById('limpressor'+plingua);
  if ( l ) 
    l.style.display = 'none';

  }
 function nosp (){
  var l = document.getElementById('limpressor'+plingua);
  if ( l ) l.style.display = 'block';

  }

 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();
        return;
        }
		
  function lstcompleta(){
 
	ixfuncao('busco%',0)
	}	
	
 function  busca(valor,lingua){
     zmain.busca(valor)
     posicionaIMGTopo();
    }

	function isObject(a) {
    return (a && typeof a == 'object') || isFunction(a);
}
  function isArray(a) {
    return isObject(a) && a.constructor == Array;
}
    function zprint(){
	
    /**	zmain.zix = zix;
     zmain.zprint(); */
	 imprimeConteudo();
    }


 function mostraCaminho(caminho){
  var l = document.getElementById('llocalizacao');
  if ( !l ) return;
  
  l.innerHTML = caminho;  
  l.style.display = 'block';
 }

function escondeCaminho() {
	var l = document.getElementById('llocalizacao');
	if ( !l ) return;

	l.style.display = 'none';
} 
 
function isString(a) {
    return typeof a == 'string';
}
  
 function reload() { 
  window.location.reload();
 }


function links(){
      ixfuncao(127);
	 
 }

 

 function clienteSWF() {  
	var so = new SWFObject("menu.swf", "zmenu", "900", "600", "6", "#ffffff"); 
	so.addParam("WMODE", "transparent");
	so.addParam("swliveconnect", "true");
	so.addParam("menu", "false");
 
	so.write("swfzmenu");
	
	if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
		document.write('<script language=\"VBScript\"\> \n');
		document.write('On Error Resume Next\n');
		document.write('Sub zmenu_FSCommand(ByVal command, ByVal args)\n');
		document.write('	Call zmenu_DoFSCommand(command, args)\n');
		document.write('End Sub\n');
		document.write('</script\>\n');
	}
	
}
 
 
  function imprimeConteudo(){
   
	aposx = parseInt(window.posx+55);
	bposx = 83;
 
	var PainelImprimirP =  new ObjPainelIframe('','Imprime','position:absolute; left:13px; top:195px; width:775px; height:470px;  ');
	PainelImprimirP.cxStyle = 'z-index:999; position:absolute; top:43px; left:'+aposx+'px; width:770px; height:515px; color:#5F5F5F; font-size:18;font-weight: bolder; background-color:#FFFFFF;';
	var l = PainelImprimirP.render(); 
	setIZStyle(PainelImprimirP.bok,'position:absolute; top:0px; left:'+bposx+'px; width:70px; ') 
	PainelImprimirP.pFrame.id = 'iframePrint';
 
	var  inHTML = '';
	if (document.all)
		inHTML = document.zmain.document.getElementById("LayerConteudo").innerHTML ;
	else inHTML = window.frames['zmain'].document.getElementById("LayerConteudo").innerHTML ;
	
	if  ( inHTML == '' ) return;
	var htmlinicial = '<html>\n<head>\n<link rel="stylesheet" href="./includes/stylesheet.css" TYPE="text/css">\n\n<LINK rel="stylesheet" type"text/css" href="includes/print.css" media="print">\n</head>\n<body  bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" style="border:0;">\n';
 
	var janelaPreview = PainelImprimirP.pFrame.contentWindow;
	janelaPreview.document.write(htmlinicial+inHTML+'<input type="text" id="zero"  style="width:0; height:0;" /></body></html>');
 
	 
	var bprint = CriaBotao( l,null,'Imprimir','position:absolute; top:6px; left:690px; ');
	
	 bprint.onclick = function () { 	
		if ( !document.all ){  //	painelMsg(' imprimindo '); 
			janelaPreview.focus(); janelaPreview.print(); }
		else { window.frames['iframePrint'].zero.focus();  print();}
		}
	 CriaImagem(l,'','db/imagens/0.gif','position: absolute; top:32px; left:0; width:759px; height:480px; z-index:9;')
    PainelImprimirP.bok.onclick = function () { fechaCaixa(); }

	}


