var externalWin=null;
var externalWinLoaded=false;
var winOpener=null;
var laPage;
var url;
var name;
var toolbar = 'no';
var abvLocation = 'no';
var directories = 'no';
var status = 'no';
var menubar = 'no';
var scrollbars = 'no';
var resizable = 'no';
var copyhistory = 'no';
var dependent = 'no';
var laLargeur;
var laHauteur;

var w, h, x, y;

if (document.layers) 
{
  window.captureEvents(Event.ONFOCUS);
}
window.onFocus=focusHandler;

function focusHandler(e){
  if(externalWin != null) 
  {
    if (externalWin.closed == false) 
    {
      externalWin.focus();
      return false;
    }
    else 
    {
      if (winOpener) 
      {
        winOpener.externalWinClosed();
      }
      externalWin = null;
      externalWinLoaded = false;
      top.unLockClick();
    }
  }
  return true;
}

function small()      { initWindow('0.40'); }
function normal()     { initWindow('0.75'); }
function fullScreen() { initWindow('1');    }

function initWindow (aString)
{
  var laLargeurDispo;
  var laHauteurDispo;

  //Pour Internet Explorer
  if ( document.all ) {

    laLargeurDispo = screen.availWidth - 10;
    laHauteurDispo = screen.availHeight - 70;
  }
  else {

    laLargeurDispo = screen.availWidth;
    laHauteurDispo = screen.availHeight;
  }

//alert("initWindow : Résolution utile : x : " + screen.availWidth + " : y : " + screen.availHeight);

  /* if ( laLargeurDispo > 1000 ) 
  {
    laLargeurDispo = 1014;
    laHauteurDispo = 635;
  } */

  laLargeur = laLargeurDispo * eval( parseFloat('1') );
  laHauteur = laHauteurDispo * eval( parseFloat('1') );

//alert("initWindow : laLargeur : "+ laLargeur + " : laHauteur : "+ laHauteur +" .");

  w = Math.round( laLargeur * eval( parseFloat( aString ) ) );
  h = Math.round( laHauteur * eval( parseFloat( aString ) ) );

  x = Math.round( ( laLargeur - w ) / 2 );
  y = Math.round( ( laHauteur - h ) / 4 );

//alert("initWindow : x : " + x + " : y : " + y + " : w : " + w + " : h : " + h + " .");
}

function initWithWH ( aLargeur , anHauteur ) 
{
  var laLargeurDispo;
  var laHauteurDispo;

  //Pour Internet Explorer
  if ( document.all ) {

    laLargeurDispo = screen.availWidth - 10;
    laHauteurDispo = screen.availHeight - 70;
  }
  else {

    laLargeurDispo = screen.availWidth;
    laHauteurDispo = screen.availHeight;
  }

  laLargeur = laLargeurDispo * eval( parseFloat('1') );
  laHauteur = laHauteurDispo * eval( parseFloat('1') );

//alert("initWithWH : laLargeur : "+ laLargeur + " : laHauteur : "+ laHauteur +" .");

  w = aLargeur;
  h = anHauteur;

  x = Math.round( ( laLargeur - w ) / 2 );
  y = Math.round( ( laHauteur - h ) / 4 );

//alert("initWithWH : x : " + x + " : y : " + y + " : w : " + w + " : h : " + h + " .");
}

function windowForNoteInfo (url, name) 
{
  small();
  resizable = 'no';
  scrollBar = 0;
  name = 'NoteInfo';
  laPage = nouvelleWindow( name, url, 0, scrollBar, 0, 0);
  return false;
}

function windowForRessource (url, name) 
{
  normal();
  resizable = 'yes';
  scrollBar = 1;
  name = 'Ressource';

  laPage = nouvelleWindow( name, url, 1, scrollBar, 0, 0);
  return false;
}

function windowForVideo (url, name) 
{
  normal();
  resizable = 'yes';
  scrollBar = 1;
  name = 'Ressource';

  laPage = nouvelleWindow( name, url, 1, scrollBar, 0, 0);
  return false;
}

function windowForRequeteur (url, name) 
{
  normal();
  resizable = 'yes';
  scrollBar = 1;
  name = 'Ressource';

  laPage = nouvelleWindow( name, url, 1, scrollBar, 0, 0);
  return false;
}



function windowForListeNoteInformation (url, name) 
{
  resizable = 'yes';
  scrollBar = 1;

  w = 1000;
  h = 850;
  x = 1;
  y = 1;

  laPage = nouvelleWindow( name, url, 1, scrollBar, 0, 0);
  return false;
}

function windowForNoteInformation (url, name) 
{
  resizable = 'yes';
  scrollBar = 1;

  w = 770;
  h = 850;
  x = 1;
  y = 1;

  laPage = nouvelleWindow( name, url, 1, scrollBar, 0, 0);
  return false;
}

function windowForNoteInformationAleph (url, name) 
{
  resizable = 'yes';
  scrollBar = 1;

  w = 1400;
  h = 900;
  x = 1;
  y = 1;

  laPage = nouvelleWindow( name, url, 1, scrollBar, 0, 0);
  return false;
}

function windowForVideo (url, name) 
{
  resizable = 'yes';
  scrollBar = 0;

  w = 750;
  h = 600;
  x = 1;
  y = 1;

  laPage = nouvelleWindow( name, url, 1, scrollBar, 0, 0);
  return false;
}

function windowForNoteInformationRessource (url, name) 
{
  resizable = 'yes';
  scrollBar = 1;

  w = 450;
  h = 400;
  x = 1;
  y = 1;

  laPage = nouvelleWindow( name, url, 1, scrollBar, 0, 0);
  return false;
}

function windowForListeUti (url, name) 
{
  resizable = 'yes';
  scrollBar = 1;

  w = 600;
  h = 700;
  x = 1;
  y = 1;

  laPage = nouvelleWindow( name, url, 1, scrollBar, 0, 0);
  return false;
}

function windowForAnalyseNoteInformation (url, name) 
{
  resizable = 'yes';
  scrollBar = 1;

  w = 800;
  h = 900;
  x = 10;
  y = 10;

  laPage = nouvelleWindow( name, url, 1, scrollBar, 0, 0);
  return false;
}

function windowForFicheCommande (url, name) 
{
  resizable = 'yes';
  scrollBar = 1;

  w = 700;
  h = 500;
  x = 0;
  y = 0;

  laPage = nouvelleWindow( name, url, 1, scrollBar, 0, 0);
  return false;
}

function windowForQuizz(url, name) 
{
  resizable = 'no';
  scrollBar = 0;

  w = 300;
  h = 220;
  x = 30;
  y = 30;

  laPage = nouvelleWindow( name, url, 0, scrollBar, 0, 0);
  return false;
}

function windowForToDoListe(url, name) 
{
  var laLargeurDispo = screen.width;
  var laHauteurDispo = screen.height;

  if ( laLargeurDispo > 1000 ) 
  {
    laLargeurDispo = 1014;
    laHauteurDispo = 635;
  }

  laLargeur = laLargeurDispo * eval(parseFloat('1'));
  laHauteur = laHauteurDispo * eval(parseFloat('1'));

  w = 300;
  h = 250;

  x = Math.round( ( laLargeur - h ) / 2 );
  y = Math.round( ( laHauteur - h ) / 2 );

// Pour positionner la popup sous le posit
  y = 320;

  resizable = 'no';
  scrollBar = 0;

  laPage = nouvelleWindow( name, url, 0, scrollBar, 0, 0);
  return false;
}

function windowForAS (name, url) 
{
  var laLargeurDispo = screen.width;
  var laHauteurDispo = screen.height;

  if ( laLargeurDispo > 1000 ) 
  {
    if (laLargeurDispo > 1200) {
        laLargeurDispo = 1190;
        laHauteurDispo = 635;
    }
    else {
        laLargeurDispo = 1014;
        laHauteurDispo = 635;
    }
  }

  laLargeur = laLargeurDispo * eval(parseFloat('1'));
  laHauteur = laHauteurDispo * eval(parseFloat('1'));

  w = 740;
  h = 260;

  x = Math.round( laLargeur  - w );
  y = Math.round( ( laHauteur - h ) / 4 );
  resizable = 'no';
  scrollBar = 0;

  laPage = nouvelleWindow( name, url, 0, scrollBar, 0, 0);
  return laPage;
}


function windowForMessagerie(url, name) 
{
  fullScreen();
  resizable = 'no';
  scrollBar = 1;
  name = 'Application';

  w = 950;
  h = 600;
  x = Math.round( ( laLargeur  - w ) / 2 );
  y = 0;

  if (! name) name = 'newWindow';
  laPage = nouvelleWindow( name, url, 1, scrollBar, 1, 1);
  return false;
}

function windowForWOApplication(url, name) 
{

//alert("windowForWOApplication : x : "+x+" : y : "+y+ " : w : "+w+" : h : "+h+" .");

  fullScreen();
  resizable = 'yes';

  x = 0;
  y = 0;

//alert("windowForWOApplication : x : "+x+" : y : "+y+ " : w : "+w+" : h : "+h+" .");

  if ( name == null ) name = 'newWindow';
  laPage = nouvelleWindow( name, url, 1, 1, 0, 0);
  return false;
}

function windowForDirectAction(url, name) 
{
  fullScreen();
  resizable = 'no';
  scrollBar = 1;
  name = 'Application';

  w = 850;
  h = 600;
  x = 0;
  y = 0;

  if (! name) name = 'newWindow';
  laPage = nouvelleWindow( name, url, 1, scrollBar, 0, 0);
  return false;
}

function windowForExecutable(url , name) 
{
  return windowForExecutable(url) ;
}

function windowForExecutable(url) 
{
  fullScreen();
  resizable = 'yes';
  scrollBar = 1;
  name = 'Executable';

  if (! name) name = 'newWindow';
  laPage = nouvelleWindow( name, url, 1, scrollBar, 0, 1);
  return false;
}

function smallWindow( url, name, statusBar, scrollBar , toolbar, menuBar ) 
{
  small();
  resizable = 'yes';
  scrollBar = 1;
  if (! name) name = 'newWindow';
  laPage = nouvelleWindow( name, url, statusBar, scrollBar , toolbar, menuBar );
  return false;
}

function fullWindow( url, name, statusBar, scrollBar , toolbar, menuBar ) 
{
  fullScreen();
  resizable = 'yes';
  scrollBar = 1;
  if (! name) name = 'newWindow';
  laPage = nouvelleWindow( name, url, statusBar, scrollBar , toolbar, menuBar );
  return false;
}

function nouvelleWindow( name, url, statusBar, scrollBar , toolbar, menuBar ) 
{
  var nouvelleWindow;

  if (!scrollBar) scrollBar ='no'; else scrollBar ='yes';
  if (!toolbar)   toolbar='no';    else toolbar='yes';
  if (!statusBar) statusBar='no';  else statusBar='yes';
  if (!menuBar)   menuBar ='no';   else menuBar ='yes';

  // Pour Internet Explorer
  if ( document.all )
  {
   nouvelleWindow = window.open(url, name, 'toolbar='+toolbar+', location=no, directories=no, status='+ statusBar +', menubar='+ menuBar +', scrollbars='+ scrollBar +', resizable='+resizable+', copyhistory=no, left='+x+', top='+y+', width='+w+', height='+h+', dependent=yes, channelmode=0' );

  }
  else
  {
    nouvelleWindow = window.open(url, name,'toolbar='+toolbar+',location=no,directories=no,status='+statusBar+',menubar='+menuBar+',scrollbars='+scrollBar+',resizable='+resizable+',copyhistory=no,screenX='+x+',screenY='+y+',outerWidth='+w+',outerHeight='+h+',z-lock=yes,dependent=no');
  }


  if ( nouvelleWindow )
  {
  try {
    nouvelleWindow.focus();
  }
  catch(e) {
  }
  }

  return nouvelleWindow;
}

function displayWindow( url, sender, height, width, statusBar)
{
  resizable = 'no';
  if ( sender ) 
  {
    winOpener = sender;
  }
  
  if ( ( externalWinLoaded == false ) || ( externalWin.closed == true ) ) 
  {
    if (!height) height = ( screen.availHeight / 2 );
    if (!width)  width  = ( screen.availWidth  / 2 );
    top.lockClick();
    externalWin = newWindow('externalWin',url, statusBar,Math.abs((screen.width - width)/2),Math.abs((screen.height - height)/2), width, height);
    externalWinLoaded = true;
  }
  
  if ( externalWin ) 
  {
    externalWin.focus()
  }
  return externalWin;
}

function newWindow( name, url, statusBar, x, y, w, h)
{
  return nouvelleWindow( name, url, statusBar, 0, 0, 0 ) 
}

function gotoPrevoyance( anUrl ) 
{

  fullScreen();

  //alert( ' width = ' + w + ' height = ' + h );

  self.open(anUrl,'_new','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,left=0,top=0,width='+ w +',height='+ h +',dependent=yes,channelmode=0');
  //self.open(anUrl,'_new','fullscreen,scrollbars,status');
}

function retailler(x,y) {
this.resizeTo(x,y);

this.onresize = putFrameInit; 
onscroll= putFrameInit; 
this.onmousewheel = putFrameInit;
}

function GetDomOffset( Obj, Prop ) {
  var iVal = 0;
  while (Obj && Obj.tagName != 'BODY') {
    eval('iVal += Obj.' + Prop + ';');
    Obj = Obj.offsetParent;
  }
  return iVal;
}
function putFrameInit() { 
this.onresize = putFrameInit; 
onscroll= putFrameInit; 
this.onmousewheel = putFrameInit;

  putFrame(document.getElementById('MenufixeBottom'),'MenufixeBottom');
}

function putFrame(anDiv,anId) { 

  var d = document.getElementById(anId);
  var f = document.getElementById("iframeAide"); 
  var addBool = false;
  var decalageTop = 0;
  var decalageLeft = 0;

   if ( f == null )
   {
     f = document.createElement("iframe");

     f.setAttribute("id","iframeAide");
     f.id = "iframeAide";
     f.src = "javascript:'<html></html>'";
     f.style.border="none";    
     f.setAttribute("frameborder","0"); 
     f.setAttribute("scrolling","no");

     addBool = true;
   }


   var ntop = GetDomOffset(anDiv,'offsetTop') + decalageTop;
   var nleft = GetDomOffset(anDiv,'offsetLeft') + decalageLeft;

   //anDiv.style.zIndex = '999';

   with(f.style) { 
     position   = "absolute"; 
     width      = d.offsetWidth+"px"; 
     height     = d.offsetHeight+"px";
     top        = ntop +"px"; 
     left       = nleft +"px"; 
     zIndex     = "1"; 
     filter = "alpha(opacity=0)";
   } 

   if ( addBool )
     document.body.appendChild(f);

   f.style.display = 'block';

}
