/*
	Assec 2002 ixPP  1.0  ( acesso )
 // 	
 // 
 //
 //       Coder  ppires@assec.pt
 //       file ixmenu.js( da  pagina principal)

*/
 function escreve_cookie(nome,valor,expires,path,domain,secure) {

 if  (!valor)
    eval('var t='+nome); 
    else t= valor;
 
 
 document.cookie =  
     nome + "=" + escape (t) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") + 
    ((path) ? "; path=" + path : "") + 
    ((domain) ? "; domain=" + "assec.pt" : "") + 
    ((secure) ? "; secure" : "");
    
    }
    
var stoppesquisa;
 stoppesquisa = 0;
 
function  WriteCookie(name,value,expires,path,domain,secure){
     escreve_cookie(name,value,expires,path,domain,secure);
     }
    
    
//window.captureEvents(event.RESIZE);   
window.onresize=ixredimensiona;
 function ixredimensiona(){
  posicionaIMGTopo();
     
       }
    
      
window.onscroll=ixscroll;
 function ixscroll(){
 // posicionaIMGTopo();
     
       }

function  viewn(){
    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 ixfuncao(value,expires,path,domain,secure) { 

       
 document.cookie = "mix=" + ""+ 
         "; expires=0" +
         ";" + 
         ";  " + 
         ""; 
  document.cookie = "tix=" + ""+ 
         "; expires=0" +
         ";" + 
         ";  " + 
         "";      
       
     ixpos(value,0,0,'',expires,path,domain,secure,'')  
    }

    
    
    
function ixpos(cix,pos,ppos,tix,expires,path,domain,secure,mix){
     
  //escreve_cookie('cix',cix);   
    
    document.cookie = "cix" + "=" + escape (cix) + 
       ((expires) ? "; expires=" + expires.toGMTString() : "") + 
       ((path) ? "; path=" + path : "") + 
        ((domain) ? "; domain=" + Predinegocios.pt : "") + 
       ((secure) ? "; secure" : ""); 

    document.cookie = "pos" + "=" + escape (pos) + 
    ((expires) ? "; expires=" + expires.toGMTString() : "") + 
    ((path) ? "; path=" + path : "") + 
    ((domain) ? "; domain=" + Predinegocios.pt : "") + 
    ((secure) ? "; secure" : "");
        
    document.cookie = "ixf" + "=" + escape (ixf) + 
    ((expires) ? "; expires=" + expires.toGMTString() : "") + 
    ((path) ? "; path=" + path : "") + 
    ((domain) ? "; domain=" + Predinegocios.pt : "") + 
    ((secure) ? "; secure" : "");
 
 document.cookie =
     ((tix) ? "tix" + "=" + escape (tix): "") + 
    ((expires) ? "; expires=" + expires.toGMTString() : "") + 
    ((path) ? "; path=" + path : "") + 
    ((domain) ? "; domain=" + Predinegocios.pt : "") + 
    ((secure) ? "; secure" : "");

 document.cookie = "ppos" + "=" + escape (ppos) + 
    ((expires) ? "; expires=" + expires.toGMTString() : "") + 
    ((path) ? "; path=" + path : "") + 
    ((domain) ? "; domain=" + Predinegocios.pt : "") + 
    ((secure) ? "; secure" : "");

document.cookie =  
    ((mix) ? "mix" + "=" + escape (mix): "") + 
    ((expires) ? "; expires=" + expires.toGMTString() : "") + 
    ((path) ? "; path=" + path : "") + 
    ((domain) ? "; domain=" + Predinegocios.pt : "") + 
    ((secure) ? "; secure" : "");
    


        for (i=1; i< 8 ;i++){
        
               eval(" escreve_cookie('Pmenu'+i)");
               }
        
        escreve_cookie('Pxmenu4');  
        escreve_cookie('Pxmenu5');
        escreve_cookie('Pxmenu6'); 
        
    
    var v =  viewn();    
        
    if ( document.cookie == ''){      
            location= "main.php?cix="+escape(cix)+"&email="+escape(email)
                     +"&pos="+escape(pos)+ "&ppos="+escape(ppos)+ "&tix="
                     +escape(tix)+ "&mix="+escape(mix);
            }
       else location="main.php?v="+v; 
     
    }
    



 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 > 770)
              posx= (parseInt(document.body.clientWidth ) -770)/2;
  
           }
      else {
                // posiciona  left
           if (window.innerWidth > 770)
              posx= (parseInt(window.innerWidth) -770)/2 -10; 
       
            }
              
 
   

     // posicionar top
        var posy= 0;
        if (document.all)  
            posy=  ( parseInt(document.body.clientHeight  )     - parseInt( l.LayerCorpo.clientHeight)   - parseInt( l.LayerTopo.clientHeight)  - parseInt( l.Layerbottom.clientHeight)   )/2 -2  ;
         
         else
             posy = 0;     
      
        if (posy < 0  ) posy = 0;
       

        window.posx = posx;
        window.posy = posy;
        
      // posiciona top de  botton
       if (document.all){
               var  vposy= parseInt(l.LayerCorpo.clientHeight)+ posy +109;
                }
          else  var  vposy= parseInt( document.getElementById('LayerCorpo').offsetHeight) + parseInt( document.getElementById('LayerCorpo').style.top) + posy-2 ;
            
 
    
      PosicionaLayer( l.LayerTopo,posx+0,posy+0); 
    
       
    
      PosicionaLayer( l.LayerCorpo,posx,posy+114);
      
    
      PosicionaLayer( l.Layerbottom,posx,vposy);
 
      PosicionaLayer( l.Layercontactos ,posx,vposy-47);
 
     if (!document.all) vposy -=10;   
      PosicionaLayer( l.LayerLstDestaques,posx+166, vposy+5 );
   
    
    if (document.all){
               var  Principaly= parseInt(l.LayerMenuPrincipal.offsetHeight) ;
                }
          else  var  Principaly= parseInt( document.getElementById('LayerMenuPrincipal').offsetHeight) ;;

    
     if (! document.all)   posy -= 11; 
     var i = 2;
      Principaly += 112;
     var acumulado = posy; 
   
     if (! document.all)   acumulado -= 11; 
     
     PosicionaLayer( l.LayerMenuPrincipal,posx+2,posy+117); 
     if (eval( l.LayerMenuPrincipal2)  )  
         PosicionaLayer( l.LayerMenuPrincipal2,posx+2,acumulado);  
   
    acumulado += Principaly +2;
   
 while ( eval('l.LayerMenuPrincipal'+i )) {
          if (! eval('l.LayerMenuPrincipal'+(i-1) ) ) { Principaly= 2 ; }
          else {
        if (document.all)
                   Principaly= parseInt( document.getElementById('LayerMenuPrincipal'+(i-1)).clientHeight);
          else 
            Principaly=  parseInt( document.getElementById('LayerMenuPrincipal'+(i-1)).offsetHeight) ;
          }
          
         PosicionaLayer( eval('l.LayerMenuPrincipal'+i) ,posx+2, (acumulado + Principaly)); 
         acumulado += Principaly -1;
         if (! document.all)   acumulado -= 11;
         i++; 
        
        }    
     
      crescerlencol(); 
     
      };
      
      
      
      
function mostraP(mix,p1,p2,p3){
   //    alert (Pmenu4+'-'+Pmenu5+'-'+Pmenu6);
    document.cookie = "pesquisa=" + ""+ 
         "; expires=0" +
         ";" + 
         ";  " + 
         ""; 
   
 
//   alert (Pmenu4+'-'+Pmenu5+'-'+Pmenu6);
   
   
   ixpos(0,0,0,0,0,0,0,0,mix)
    };
 // ixpos(cix,pos,ppos,tix,expires,path,domain,secure,mix)  
function mostraL(valor){
     ixpos(1313131,0,0,valor,0,0,0,0,'');
    };
    
function ixposPesquisa(cix,pos,ppos,tix,pesquisa,path,domain,secure,expires){
         
   document.cookie = "pesquisa=" + escape (pesquisa)+ 
    ((expires) ? "; expires=" + expires.toGMTString() : "") + 
    ((path) ? "; path=" + path : "") + 
    ((domain) ? "; domain=" + Predinegocios.pt : "") + 
    ((secure) ? "; secure" : ""); 
    
    ixpos(cix,ppos,ppos,tix);
    
  };
  

//    
function    busca(pesquisa){
                       
    document.cookie = "pesquisa=" + escape (pesquisa)+ "; expires=" +  "0"+
         "; path=" +  "" + 
         "; domain=" +  "" + 
         "; secure" + "";  

       
  if ( document.cookie == ''){      
            var now=new Date()
  
            var v =  viewn();   
 
            location= "main.php?pesquisa="+escape(pesquisa);
            }
       else  ixpos(0,0,0,0);
     
    };
       
       
       

         
//          
function pesquisa(valor){

       
 // if ( document.cookie == ''){      
            var now=new Date()
  
            var v =  viewn();   
 
            location= "main.php?sortpesquisa="+escape(valor);
        //    }
       //else  ixpos(0,0,0,0);
       
        }      


function AlteraMenu(pmenu){
     var  l= new Object ;

 /////
  
   for (i=1; i < 8 ;i++){
              if (i == 5 ) continue;
			  if (i == pmenu ) continue;
              if (i != 1)
                      l  = document.getElementById('CLayerMenuPrincipal'+i); 
                else  l  = document.getElementById('CLayerMenuPrincipal');
                
              l.style.display = 'none'; 
              eval("window.Pmenu"+i+"=0");
              }   
  
 ////     
   if (pmenu != '1')
   l  = document.getElementById('CLayerMenuPrincipal'+pmenu); 
     else   l  = document.getElementById('CLayerMenuPrincipal');

   if   (!(l.style.display  == 'none')  ){
          l.style.display = 'none'; 
          eval("window.Pmenu"+pmenu+"=0");
          }
   else {
          l.style.display = 'block'; 
           eval("window.Pmenu"+pmenu+"=1");
          }
                
                
   posicionaIMGTopo();
     
   crescerlencol();

   posicionaIMGTopo();
   
         }
         
         
         

function AbreFecha(pm,ps,deph){
    var  l= new Object ;
 
  if (document.all){ l =  document.all;  }
       else {
         l =  document;
          };  
  
   for (i=0; i <  99; i++){  
      var l =  document.getElementById('ixmenuid_'+pm+'_'+ i)  ;
      if (!( eval( l  )) ) break; 
       //   eval("document.all.ixmenuid_"+parseInt(pm)+"_"+ parseInt(i)+".style.display= 'block'");   
       // if ( eval(document.getElementById('ixmenuid_'+parseInt(pm)+"_"+ parseInt(i)) ) ) break;
      document.getElementById('ixmenuid_'+pm+'_'+ i).style.display= 'block';
    
   }
      
  

    AlteraMenu('1');  
    AlteraMenu('1');  
   }

         
function ixpfuncao(value,p1,p2,p3,mode,expires,path,domain,secure) { 

    Pxmenu4=p1;
    Pxmenu5=p2;
    Pxmenu6=p3;
  //  if (mode == 3 )  Pmenu1=1;
           
    ixpos('',0,0,value,expires,path,domain,secure,'');
              
}       


function ixpf(value,mode){
 
 if (mode != '' ) {
         eval('Pmenu'+mode+'=1'); 
         AlteraMenu(mode);  
        }

  ixfuncao(value);
}
 

function crescerlencol(){
   var  l= new Object ;

   l  = document.getElementById('LayerMenuPrincipal8'); 
   var  HPrincipal4 = parseInt(l.offsetHeight);
   var  Principal4= HPrincipal4 +parseInt(document.getElementById('LayerMenuPrincipal8').style.top) ;  
     
   var  PosDestaqeues = parseInt( document.getElementById('LayerCorpo').offsetHeight ) + parseInt( document.getElementById('LayerCorpo').style.top) -47;
   
   
    
  if ( (Principal4 +10) >  PosDestaqeues  )  
        document.getElementById('crescer').style.height = ( parseInt(document.getElementById('crescer').style.height) +  Principal4 - PosDestaqeues +4)  ;
      else{ 
          document.getElementById('crescer').style.height = 0   ;
      //      else   document.getElementById('crescer').style.height = document.getElementById('crescer').style.height + 53  ;
         }     
}
 
 