/*
	Assec 2002 ixPP  1.0  ( acesso )
 // 	
 // 
 //
 //       Coder  ppires@assec.pt
 //       file ixmenu.js( da  pagina principal)

*/

  if (document.images){ 
  
     //   pic1 = new Image(100,100);
    //    pic1.src= "images/img_top.jpg";
        
     //   pic2 = new Image(100,100);
     //   pic2.src= "images/img_top1.jpg";
        
     //   pic3 = new Image(100,100);
    //    pic3.src= "images/img_top2.jpg";

        }

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 ixfuncao2(value,expires,path,domain,secure) {


     ixpos2(value,0,0,"",expires,path,domain,secure,"")
    }

function ixpos2(cix,pos,ppos,tix,expires,path,domain,secure,mix,email,lingua){

        zix = cix;

        valor = location.href.split('?');

        location.href=valor[0]+ '?cix='+escape(cix)
                +( (email) ? '&email='+escape(email) : '')
                +"&pos="+escape(pos)+ "&ppos="+escape(ppos)+ "&tix="
                +escape(tix)+ "&mix="+escape(mix)
                +"&mono_lang="+ escape(lingua)
                +"&v="+escape(fviewn());
      }

	  
function ixfuncao(value,expires,path,domain,secure) { 
   /*document.cookie = "cix" + "=" + escape (value) + 
    ((expires) ? "; expires=" + expires.toGMTString() : "") + 
    ((path) ? "; path=" + path : "") + 
    ((domain) ? "; domain=" + rude.pt : "") + 
    ((secure) ? "; secure" : "");
    
  
    if ( document.cookie == ''){     
            location= "?cix="+escape(value);
            }
       else location=document.location;*/
     
     ixpos(value,0,0,"",expires,path,domain,secure,"")  
    }

function ixpos(cix,pos,ppos,tix,expires,path,domain,secure,mix,email){
     
/*
    
   document.cookie = "cix" + "=" + escape (cix) + 
    ((expires) ? "; expires=" + expires.toGMTString() : "") + 
    ((path) ? "; path=" + path : "") + 
    ((domain) ? "; domain=" + jf-britelo.pt : "") + 
    ((secure) ? "; secure" : "");

    document.cookie = "pos" + "=" + escape (pos) + 
    ((expires) ? "; expires=" + expires.toGMTString() : "") + 
    ((path) ? "; path=" + path : "") + 
    ((domain) ? "; domain=" + jf-britelo.pt : "") + 
    ((secure) ? "; secure" : "");
        
    /*document.cookie = "ixf" + "=" + escape (ixf) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") + 
    ((path) ? "; path=" + path : "") + 
    ((domain) ? "; domain=" + jf-britelo.pt : "") + 
    ((secure) ? "; secure" : "");*/
 /*
 document.cookie = "tix" + "=" + escape (tix) + 
   
    ((expires) ? "; expires=" + expires.toGMTString() : "") + 
    ((path) ? "; path=" + path : "") + 
    ((domain) ? "; domain=" + jf-britelo.pt : "") + 
    ((secure) ? "; secure" : "");

 document.cookie = "ppos" + "=" + escape (ppos) + 
    ((expires) ? "; expires=" + expires.toGMTString() : "") + 
    ((path) ? "; path=" + path : "") + 
    ((domain) ? "; domain=" + jf-britelo.pt : "") + 
    ((secure) ? "; secure" : "");

document.cookie =   "mix=" + escape (mix) + 
    ((expires) ? "; expires=" + expires.toGMTString() : "") + 
    ((path) ? "; path=" + path : "") + 
    ((domain) ? "; domain=" + jf-britelo.pt : "") + 
    ((secure) ? "; secure" : "");
*/
    var v=fviewn();
  /*  if (cix.substring(0,5) == 'MFoto')
            tpp='MFOTO';
         else  tpp='fototeca';
  */
 
        location= "./?cix="+escape(cix)+( (email) ? "&email="+escape(email) : "")
                     +"&pos="+escape(pos)+ "&ppos="+escape(ppos)+ "&tix="
                     +escape(tix)+ "&mix="+escape(mix)+"&v="+v;
      }
    

    
//window.captureEvents(event.RESIZE);   
window.onresize=ixredimensiona;
 function ixredimensiona(){
//  posicionaIMGTopo();
     
       }
    
      
window.onscroll=ixscroll;
 function ixscroll(){
 // posicionaIMGTopo();
     
       }


/// funcoes  do menu
function IxshowMenu(menu, x, y, child) {
       this.xi=0;
       
        if ( menu == null  ) return;
       var e = e || window.Event || window.event;
      // var posY =   window.pageY  || e.clientY;     
       
         if (document.all) {
                var pos =document.all.Layer2.offsetTop+1 ;

                }
          else {
                var pos = document.Layer2.offsetTop+1 ;
                }
                  
     
     // var  pos =  parseInt(posY)  +7  + document.body.scrollTop; 
       pos = pos+y;
 
     
       var xi =x+  (parseInt( document.body.clientWidth)-775)/2   ;
       if ( document.body.clientWidth < 775)
              xi =x;
       
               //      x =  x - parseInt((parseInt( document.body.clientWidth)-775)/2); 
        
           
     // MENUPOS.innerHTML = "  x-"+x+"    w-"+ document.body.clientWidth+"   xi- "+xi+"   valoer-"+ ((parseInt( document.body.clientWidth)-775)/2)+x; 
        showMenu(menu, xi, pos );
             
        
        }



function LeftShowMenu(leftmenu,posicao){
   this.leftmenu = leftmenu;
   this.posicao = posicao ;
   
  
   if (! posicao ) return;
    
   if (! leftmenu ) return;
//     alert('chegou2');
   var e = e || window.Event || window.event;
   var posY = e.pageY || e.clientY; 
 
   var lagura = 0;
   if  (posicao== 1)  lagura = 357;
   if  (posicao== 2)  lagura = 417;
   if  (posicao== 3)  lagura = 470;
   if  (posicao== 4)  lagura = 540;
   if  (posicao== 5)  lagura = 630;
   if  (posicao== 6)  lagura = 712;
   
  if ( this.leftmenu == null  ) return;
  
  var pos = (parseInt(document.body.clientWidth ) -780)/2+lagura  - parseInt(this.leftmenu.menuItemWidth)  ;
   
   if ( document.body.clientWidth < 780)
        pos = lagura - parseInt(this.leftmenu.menuItemWidth); 
  leftmenu.childMenuDirection = "left";
  

  
  

 // var posicaoY =document.all.Layer2.offsetTop+1; 
        if (document.all) {
                var posicaoY =document.all.SuperContentor.offsetTop+1 ;

                }
          else {
                var posicaoY = document.SuperContentor.offsetTop+1 ;
                };

  
   //if  (posicao== 1) 
   posicaoY = posicaoY+24;
 /*  if  (posicao== 2)  posicaoY = posicaoY+20;
   if  (posicao== 3)  posicaoY = posicaoY+39;
   if  (posicao== 4)  posicaoY = posicaoY+48;
   if  (posicao== 5)  posicaoY = posicaoY+37;  */
   
 showMenu(this.leftmenu, pos ,posicaoY);
  
  
    for (var i=0; i < this.leftmenu.childMenus.length; i++) {
      
            this.leftmenu.childMenus[i].childMenuDirection = "left";
        }
}

function showMenuButton(buttonmenu,x){
       this.buttonmenu = buttonmenu;
       this.x= x;

      var e = e || window.Event || window.event;
    //  var posY = e.clientY || e.pageY;
        var posY =document.all.imageButton.offsetTop+15;
     
        
       x = x+ (parseInt(document.body.clientWidth ) -775)/2;
       if ( document.body.clientWidth < 775)
                x= x-(parseInt(document.body.clientWidth ) -775)/2;
                
       
        if ( this.buttonmenu == null  ) return;
        
    //   var posicao =  parseInt(posY)  -15 -  parseInt(this.buttonmenu.items.length)*20 + document.body.scrollTop;
          var posicao =  parseInt(posY)  -15 -  parseInt(this.buttonmenu.items.length)*20 ;
       
      showMenu(buttonmenu,x,posicao);
      
  }

 function PosicionaLayer(layer,pposx,pposy){
     this.pposx = pposx;
     this.pposy = pposy;
    
      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.visibility= "visible";
      
        }
                  
}
         
  
 function posicionaIMGTopo(){
     var  l= new Object ;
     var posx= 0;
     var posy= 0;
     
     if (document.all){ l =  document.all;  }
       else {
         l =  document;
          };
     
     if (document.all) {
       // posiciona  left
           if ( document.body.clientWidth > 785)
              posx= (parseInt(document.body.clientWidth ) -785)/2;
  
           }
      else {
                // posiciona  left
           if ( document.body.offsetWidth > 785)
              posx= (parseInt(document.body.offsetWidth ) -785)/2;
       
            }
              
     
   
      // posicionar top
      var posy= 0;
      if (document.all)  {
        
             posy= (parseInt( document.body.offsetHeight) - parseInt( l.SuperContentor.clientHeight  )    )/2 -2  ;
      }
         else
                  posy= (parseInt(document.height) - parseInt( l.SuperContentor.clip.height)    )/2 -2  ;
       
      
       // if (posy < 0  ) 
       posy = 0;
      
      //  if (document.all){ }
      //        else  posy = 0;

        window.posx = posx;
        window.posy = posy;
        
      // posiciona top de  botton
   
          
      PosicionaLayer( l.LayerCorpo,posx,posy);
     // PosicionaLayer( l.LayerTopo,0+0,0+0);
      PosicionaLayer( l.SuperContentor,posx,posy);
    
   //  if ( window.ActiveMenu )  hideActiveMenus(window.ActiveMenu);
};
      
      
      
      
function mostraP(mix){
   ixpos(0,0,0,0,0,0,0,0,mix)
    };
    

function ixposPesquisa(cix,pos,ppos,tix,pesquisado,path,domain,secure,expires){
         
  /* document.cookie = "pesquisa=" + escape (pesquisa)+ 
    ((expires) ? "; expires=" + expires.toGMTString() : "") + 
    ((path) ? "; path=" + path : "") + 
    ((domain) ? "; domain=" + "jf-britelo.pt" : "") + 
    ((secure) ? "; secure" : ""); 
    
    ixpos(cix,ppos,ppos,tix);*/
     
     document.cookie = "cix=" + escape ('busca')+ "; expires=" +  "";
    
     document.cookie = "pesquisa=" +escape(pesquisado)+ "; expires=" +  "";
     
     document.cookie = "ppos=" +escape(ppos)+ "; expires=" +  "";
       

    var v=fviewn();
    
    
    if ( document.cookie == ''){      
     
            location= "main.php?cix=busca&pesquisa="+pesquisado;
            }
       else location="main.php?v="+v; 
        
  };
  

    
function    busca(pesquisado){
    
/*     document.cookie = "cix=" + escape ('busca')+ "; expires=" +  "";
    
     document.cookie = "pesquisa=" +pesquisado+ "; expires=" +  "";
          
*/
  var v=fviewn();
    
  location= "main.php?cix=busca&pesquisa="+pesquisado+"&v="+v;

}


       
       
 var lastmenu = '0';
     
 function AlteraMenu(pmenu){
     if (pmenu =='') return;
     var  l= new Object ;
     
     l = eval( 'document.all.'+pmenu);
    
   
    
     if   (!(l.style.display  == 'none')  )
                l.style.display = 'none'; 
              else {
                    l.style.display = 'block'; 
                     lastmenu = pmenu;
                     }
                     
     posicionaIMGTopo();
   
     pcontentorresized();
   
     }
     
     
  function ixmp(value,pos,value2,expires,path,domain,secure){
      
        ixpos(value,pos,value2,"",expires,path,domain,secure,"");  
        }
  
  
  
  
  
 function escreve_cookie(nome,valor,expires,path,domain,secure) {



    
   document.cookie =
     nome + "=" + escape (valor) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + "assec.pt" : "") +
    ((secure) ? "; secure" : "");

  }

 function ixIMGMax(imgname){
        fixIMGMax(imgname,0)
   }
   
 function fixIMGMax(imgname,top){

     if (imgname.substring(11) == '0.gif.lp') return;
     document.getElementById('ixgMax') .style.visibility= "hidden";
     document.getElementById('ixImg').src = 'db/imagens/0.gif';
     document.getElementById('ixImg').src = imgname;
     document.getElementById('ixgMax').style.top = top;
     document.getElementById('ixgMax') .style.visibility= "visible";
   //  alert(top);
    }

 function ixIMGOff(){
       document.getElementById('ixgMax') .style.visibility= "hidden";
        document.getElementById('ixImg').src = 'db/imagens/0.gif';
       }
       
 function u_checkver() {
    return true;
  }

  

