/* Written By Christian K. Hu */

function Center ()
{

   var xwidth = screen.availWidth ;
   var xheight = screen.availHeight ;
   var percent = 0 ;

   if ( xwidth > 1150 )
   {
      percent = (xwidth - 950) / xwidth * 50 ;
      $('bdmain').style.marginLeft = parseInt(percent) +'%' ;

      percent = (xheight - 700) / xheight * 50 ;
      $('bdmain').style.marginTop = parseInt(percent) +'%' ;

    }


 }

function MenuOver (e)  {
  var
     elmt = this.id ;

     if (elmt)
     {
     }
     else {
       elmt = e.srcElement.id ;
     }

   document.getElementById (elmt).style.backgroundImage="url(images/"+elmt+".gif)" ;
  }

function MenuOut (e)  {
  var
     elmt = this.id ;

     if (elmt)
     {
     }
     else {
       elmt = e.srcElement.id ;
     }
    document.getElementById (elmt).style.backgroundImage="" ;

  }

function wopen (nUrl)
{
  var winp =  window.open (nUrl) ;
  
  if ( winp )
  {
     winp.focus () ;

   } else ("Veuillez autoriser l'ouverture pour voir les Documents du Site Novamétrie") ;


 }


function senddate (param)
{
   window.location.href = 'getpage.php'+param ;
 }

function senddate_en (param)
{
   window.location.href = 'getpage.php'+param+'&lang=en' ;
 }


function InitMenu ()
{

 var lang = $('logo').value ;
 var lpath = '' ;


 Center () ;

 if ( lang == 'en' )
    lpath = '?lang=en' ;
 else
 {
    lang = 'fr';
    lpath = '' ;
 }

 Event.observe('wet1' ,'mouseover' ,MenuOver ) ;
 Event.observe('wet2' ,'mouseover' ,MenuOver ) ;
 Event.observe('wet3' ,'mouseover' ,MenuOver ) ;
 Event.observe('wet4' ,'mouseover' ,MenuOver ) ;

 Event.observe('wet1' ,'mouseout' ,MenuOut ) ;
 Event.observe('wet2' ,'mouseout' ,MenuOut ) ;
 Event.observe('wet3' ,'mouseout' ,MenuOut ) ;
 Event.observe('wet4' ,'mouseout' ,MenuOut ) ;


 Event.observe('logo' ,'click' ,function () { window.location.href ='index.php'+lpath ; } ) ;
 Event.observe('wet1' ,'click' ,function () { window.location.href =lang+'/etud1.html'; } ) ;
 Event.observe('wet2' ,'click' ,function () { window.location.href =lang+'/etud2.html'; } ) ;
 Event.observe('wet3' ,'click' ,function () { window.location.href =lang+'/etud3.html'; }  ) ;
 Event.observe('wet4' ,'click' ,function () { window.location.href =lang+'/etud4.html'; } ) ;
 Event.observe('seekbtn' ,'click' ,function () { 
   var str = $('searchit').value ;

   if ( str.length > 3 )
   {
      window.location.href = 'search.php?searchkey='+str+'&lang='+lang ;

    }
   else
     if ( lang == 'en' )
        alert ('Please enter a bigger word ') ;
     else
        alert ('Veuillez entrer un plus grand mot') ;

   } ) ;

 Event.observe('searchit' ,'focus' ,function() { $('searchit').value ="" ;  } ) ;
 Event.observe('searchit' ,'keydown' ,function(e) {

  var str = $('searchit').value ;
  var isTouche = false ;
  var touche=e.which;


  if ( touche == 13 ) { isTouche = true ; }

   if ( isTouche == true  ||  event.keyCode == 13 )

   {

         if ( str.length > 3 )
         {
            window.location.href = 'search.php?searchkey='+str+'&lang='+lang ;
          }
         else
           if  ( lang == 'en' )
               alert ('Please enter a bigger word') ;
           else
               alert ('Veuillez entrer un plus grand mot') ;


     }


 } ) ;




}

Event.observe( window ,'load' ,InitMenu ) ;
