// JavaScript Document
var popUpWin=0;
var SecpopUp=0;
var PrtpopUpWin=0;
var PrtpopUpWin2=0;
var PrtpopUpWin3=0;
var ResultWin=0;
var SearchWin=0;
var MaxHeight = screen.availHeight ;
var MaxWidth = screen.availWidth ;
var MaxTop = screen.availTop ;
var MaxLeft = screen.availLeft ;

var dimensions = new Array('Search','PrintList','Basket','PrintDlg','DelDlg','AddAct','AddKW','CreateCD','DupDivX');
dimensions[0]=new Array(2);
dimensions[0][0]=782; //largeur
dimensions[0][1]=372; //moz 372 - IE 402
dimensions[1]=new Array(2);
dimensions[1][0]=700; //largeur
dimensions[1][1]=MaxHeight; //moz 372 - IE 402
dimensions[2]=new Array(2);
dimensions[2][0]=670; //largeur
dimensions[2][1]=MaxHeight; //moz 372 - IE 402
dimensions[3]=new Array(2);
dimensions[3][0]=500; //largeur
dimensions[3][1]=230; //moz 372 - IE 402
dimensions[4]=new Array(2);
dimensions[4][0]=445; //largeur
dimensions[4][1]=100; //moz 372 - IE 402
dimensions[5]=new Array(2);
dimensions[5][0]=460; //largeur
dimensions[5][1]=140; //moz 372 - IE 402
dimensions[6]=new Array(2);
dimensions[6][0]=460; //largeur
dimensions[6][1]=140; //moz 372 - IE 402
dimensions[7]=new Array(2);
dimensions[7][0]=445; //largeur
dimensions[7][1]=100; //moz 372 - IE 402
dimensions[8]=new Array(2);
dimensions[8][0]=445; //largeur
dimensions[8][1]=100; //moz 372 - IE 402*/


waitWin = 0;
function waitWindow(URLStr, width, height){
  var top=(screen.height-height)/2;
  var left=(screen.width-width)/2;
//  if (typeof(waitWin) != 'undefined') {
    if(waitWin)  {
      if(!waitWin.closed) waitWin.close();
    }
//  }
  waitWin = open(URLStr, 'waitWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function hideLoadingPage() {
  if (document.getElementById) {  // DOM3 = IE5, NS6
    document.getElementById('hidepage').style.visibility = 'hidden';
  }
    else {
      if (document.layers) {  // Netscape 4
        document.hidepage.visibility = 'hidden';
  }
    else {  // IE 4
      document.all.hidepage.style.visibility = 'hidden';
    }
  }
}
function ShowLoadingPage() {
  if (document.getElementById) {  // DOM3 = IE5, NS6
    document.getElementById('hidepage').style.visibility = 'visible';
  }
  else {
    if (document.layers) {  // Netscape 4
      document.hidepage.visibility = 'show';
    }
    else {  // IE 4
      document.all.hidepage.style.visibility = 'visible';
    }
  }
}
function hideSearchPage() {
  if (document.getElementById) {  // DOM3 = IE5, NS6
    document.getElementById('searchpage').style.visibility = 'hidden';
  }
  else {
    if (document.layers) {  // Netscape 4
      document.searchpage.visibility = 'hidden';
    }
    else {  // IE 4
      document.all.searchpage.style.visibility = 'hidden';
    }
  }
}
function ShowSearchPage() {
  if (document.getElementById) {  // DOM3 = IE5, NS6
    document.getElementById('searchpage').style.visibility = 'visible';
  }
  else {
    if (document.layers) {  // Netscape 4
      document.searchpage.visibility = 'show';
    }
    else {  // IE 4
      document.all.searchpage.style.visibility = 'visible';
    }
  }
}
//  End



// Example:
// var b = new BrowserInfo();
// alert(b.version);
function BrowserInfo(){
  this.name = navigator.appName;
  this.codename = navigator.appCodeName;
  this.version = navigator.appVersion.substring(0,4);
  this.platform = navigator.platform;
  this.javaEnabled = navigator.javaEnabled();
  this.screenWidth = screen.width;
  this.screenHeight = screen.height;
}

function PrtpopUp(URLStr){
  if(PrtpopUpWin){
    if(!PrtpopUpWin.closed) PrtpopUpWin.close();
  }
  PrtpopUpWin = open(URLStr, 'PrtpopUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=no,resizable=no,copyhistory=no,width='+MaxWidth+',height='+MaxHeight+',left='+MaxLeft+', top='+MaxTop+',screenX='+MaxLeft+',screenY='+MaxTop+'');
  PrtpopUpWin.focus();
}
function PrtpopUp2(URLStr, left, top, width, height){
  if(PrtpopUpWin2){
    if(!PrtpopUpWin2.closed) PrtpopUpWin2.close();
  }
  PrtpopUpWin2 = open(URLStr, 'PrtpopUpWin2', 'toolbar=yes,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
  PrtpopUpWin2.focus();
}
function popUpWindow(URLStr, left, top, width, height,ScrFlag){
  scr = (ScrFlag==1)? "yes" : "no";
  if(popUpWin){
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scr+',resizable=no,copyhistory=no,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
  popUpWin.focus();
}
function PrtpopUp3(URLStr, left, top, width, height){
  if(PrtpopUpWin3){
    if(!PrtpopUpWin3.closed) popUpWin.close();
  }
  PrtpopUpWin3 = open(URLStr, 'PrtpopUpWin3', 'toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
  PrtpopUpWin3.focus();
}
function SearchWindow(URLStr, left, top, width, height,ScrFlag){
  scr = (ScrFlag==1)? "yes" : "no";
  if(SearchWin){
    if(!SearchWin.closed) SearchWin.close();
  }
  SearchWin = open(URLStr, 'SearchWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scr+',resizable=no,copyhistory=no,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
  SearchWin.focus();
}
function popUpWindowMenu(URLStr, left, top, width, height){
  if(popUpWin){
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=no,resizable=no,copyhistory=no,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
  popUpWin.focus();
}
function SecPopUpWin(URLStr, left, top, width, height){
  if(SecpopUp){
    if(!SecpopUp.closed) SecpopUp.close();
  }
  SecpopUp = open(URLStr, 'SecpopUp', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
  SecpopUp.focus();
}

// Browser Window Size and Position
// copyright Stephen Chapman, 3rd Jan 2005, 8th Dec 2005
// you may copy these functions but please keep the copyright notice as well

function ScreenDetails() {
  return "\n\nscreenW : '" +screen.width +"\nscreenH :'"+screen.height+"\navailWidth :'"+screen.availWidth+"'\navailHeight : '"+screen.availHeight+"'\n";
}
function pageWidth() {
  return window.innerWidth != null? window.innerWidth: document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth:document.body != null? document.body.clientWidth:null;
}
function pageHeight() {
  return window.innerHeight != null? window.innerHeight: document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body != null? document.body.clientHeight:null;
  }
function posLeft() {
  return typeof window.pageXOffset != 'undefined' ? window.pageXOffset:document.documentElement && document.documentElement.scrollLeft? document.documentElement.scrollLeft:document.body.scrollLeft? document.body.scrollLeft:0;
  }
function posTop() {
  return typeof window.pageYOffset != 'undefined' ? window.pageYOffset:document.documentElement && document.documentElement.scrollTop? document.documentElement.scrollTop: document.body.scrollTop?document.body.scrollTop:0;
}
function WindHeight() {
  return (theNav == "MSIE") ? posBottom(): window.outerHeight;
}
function WindWidth() {
  return (theNav == "MSIE") ? window.width:window.outerWidth ;
}
function posRight() {
  return posLeft()+pageWidth();
  }
function posBottom() {
  return posTop()+pageHeight();
  }
function windLeft() {
  return (theNav == "MSIE") ? window.screenLeft:window.screenX ;
}
function windTop() {
  return (theNav == "MSIE") ? window.screenTop:window.screenY ;
}

function GetCoords(left, top, width, height, zeDest){
  wleft = windLeft();
  wtop = windTop(); 
  wHeight = WindHeight();
  wWidth = WindWidth(); 
  midHeight = wHeight/2;
  midWidth = wWidth/2;
  midWHeight = height/2;
  midWWidth = width/2;
  top = wtop + 20;
  left = wleft + 20;
 if ( (left + width) > screen.availWidth) left = screen.availWidth - width;
 if ( (top + height) > screen.availHeight)  height = screen.availHeight;
 zeDest[0] = left;
 zeDest[1] = height;
 zeDest[2] = top;
 zeDest[3] = width;
  //alert("wleft = '"+wleft+"'\nwtop :'" +wtop+ "'\nwHeight : '"+wHeight+"'\nwWidth : '"+ wWidth +"\nnLeft[0] = '"+zeDest[0]+"'\nnheight[1] :'" +zeDest[1]+ "'\nntop[2] : '"+zeDest[2]+"'\nnwidth[3] : '"+ zeDest[3] +"\n"); 
 return (zeDest)
} 

function CallScreen() {
  alert("theNav = '"+theNav+"'\n\nWinTop :'" +windTop()+ "'\nwinLeft : '"+windLeft()+"'\nbottom : '"+ (posBottom()+windTop()) +"'\nright : '"+ posRight() +"'\nWindHeight : '" + WindHeight() + "'\nWindWidth : '" + WindWidth() + "'\nIE WindWidth='"+top.window.width+"'"+ScreenDetails()+"\n"); 
} 

// Example:
// writeCookie("myCookie", "my name", 24);
// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.
function writeCookie(name, value, hours){
  var expire = "";
  if(hours != null){
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}


function SaveSelect(seld,target,theVal,theTxt){
  target.options[seld].value = theVal;
  target.options[seld].text = theTxt;}

function add2Sel(zeTarget,NewVal,NewTxt){
//  alert(zeTarget);
  target = eval(zeTarget);
//  alert(target);
  oldLength = target.length;
  nwLength = oldLength;
  target.length = nwLength;
  target[nwLength] = new Option();
  target.options[nwLength].value = NewVal;
  target.options[nwLength].text = NewTxt;
}

function trim(s){
  $i = (s.length - 1)
  while ( $i > 0 ){
    if (s.charAt($i) == " ") {
      s = s.substr(0,$i);
      $i = (s.length -1)
    } else {
      $i = 0;
    }
  }
  return s;
}

function unFill(s){
  var c="";
  switch (s) {
    case "Titre du film" : 
      s="";
      break;
    case "Nationalité" :
      s="";
      break;
    case "Titre original" :
      s="";
      break;
    case "Réalisateur" : 
      s="";
      break;
    case "Résumé" :
      s="";
      break;
    case "Nom de l'acteur" :
      s="";
      break;
    case "Genre de film" :
      s="";
      break;
    case "00/00/0000" :
      s="";
      break;
  }
  return s;
}

function maj(s){
  var ch=c="";
  s=trim(s);
  for(var i=0;i<s.length;i++){
    c=s.charAt(i)
    switch(c){
      case "à":c="a";
      break;
      case "â":c="a";
      break;
      case "ç":c="c";
      break;
      case "é":c="e";
      break;
      case "è":c="e";
      break;
      case "ê":c="e";
      break;
      case "ë":c="e";
      break;
      case "ï":c="i";
      break;
      case "î":c="i";
      break;
      case "ô":c="o";
      break;
      case "ù":c="u";
      break;
      case "û":c="u";
      break;
    }
    if((c>="a"&&c<="z")||c=="-"||c=="'"||c==" "||c==".")ch=ch+c}

  return ch;
}
// Example: obj = findObj("image1");
function findObj(theObj, theDoc){
  var p, i, foundObj;
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length){
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++)
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++)
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  return foundObj;
}

function ShowHide(id1, id2) {
  //alert(id1, id2);
  if (id1 != '') expMenu(id1,id2);
  if (id2 != '') expMenu(id2,id1);
}
function showMenu(id){
      var itm = null;
      if (document.getElementById){
             itm = document.getElementById(id);
      } else if (document.all){
             itm = document.all[id];
      } else if (document.layers){
             itm = document.layers[id];
      }
      if (!itm){
             // do nothing
      } else if (itm.style){
             if (itm.style.display == "none"){
                   itm.style.display = "";
                   return true;
             } else{
//   itm.style.display = "none";
                   return true;
             }
      } else{
             itm.visibility = "show";
             return true;
      }
} 
function hideMenu(id){
      var itm = null;
      if (document.getElementById){
             itm = document.getElementById(id);
      } else if (document.all){
             itm = document.all[id];
      } else if (document.layers){
             itm = document.layers[id];
      }
      if (!itm){
             // do nothing
      } else if (itm.style){
             if (itm.style.display == "none"){
//   itm.style.display = "";
                   return true;
             } else{
                   itm.style.display = "none";
                   return true;
             }
      }else{
             itm.visibility = "hide";
             return true;
      }
} 
function GetMenuState(id1) {
  var itm = null;
  if (document.getElementById) {
    itm = document.getElementById(id1);
  } else if (document.all){
    itm = document.all[id1];
  } else if (document.layers){
    itm = document.layers[id1];
  }
  if (!itm) {
  } else if (itm.style) {
    return itm.style.display;
  } else {
    return itm.visibility; 
  }
}

function expMenu(id,idN) {
//  alert("id : " + id + "\nidN : "+idN)
  var itm = null;
  if (document.getElementById) {
    itm = document.getElementById(id);
  } else if (document.all){
    itm = document.all[id];
  } else if (document.layers){
    itm = document.layers[id];
  }
  if (!itm) {
  } else if (itm.style) {
    if (itm.style.display == "none") {
      itm.style.display = ""; 
    } else { 
      itm.style.display = "none"; 
    }
  } else {
    itm.visibility = "show"; 
  }
}

function SetThumbnail(s,t,u){
  if (s!="") {
    pic=new Image();
    pic.src=s;
  if (theNav == "Gecko") {
      findObj(t).src = "file:///"+pic.src;
    } else {
      findObj(t).src = pic.src;
    }
    findObj(u).value=s;
  }
}
// PARAMETRAGE DU SCRIPT
var tjs_delai=30;
var tjs_max=0;
var tjs_mode=0; // 0 - calque toujours en haut de page / 1 - calque en bas

// LE RESTE NE CHANGE PAS
var tjs_hauteur=0;

function PrintCalque(left,top,width,height,contenu) {
/*  tjs_hauteur=height;
  if ((document.all)||(document.getElementById)) {
    var Z="<DIV id='printer' name='printer' style='position:absolute;left:"+left+";top:"+top+";width:"+width+";height:"+height+"'>"+contenu+"</DIV>";
  } else {
    var Z="<LAYER id='printer' name='printer' left="+left+" top="+top+" width="+width+" height="+height+">"+contenu+"</LAYER>";
  }
  document.write(Z);*/
  setTimeout("Start()",tjs_delai);
}
function Start() {
  // Toujours en haut :
  //var delta=parseInt(document.getElementById("Printer").style.top-document.body.scrollTop);
  MoveLayer("Printer",GetTop("Printer"));
  setTimeout("Start()",tjs_delai);
}
function Debug() {
  var obj=document.body
  var Z="";
  for (var i in obj) {
    Z+=i+"="+obj[i]+"\n";
  }
  alert(Z);
}
function MoveLayer(nom,top) {
  if (document.getElementById) { //IE5 et NS6
    document.getElementById(nom).style.top=top;
  }
  if ((document.all)&&(!document.getElementById)) { //IE4 seul
    document.all[nom].style.top=top;
  }
  if (document.layers) { //NS4.X seul
    document.layers[nom].top=top;
  }
}
function GetTop(nom) {
  // Partie 1 : Récupération de la position du calque et de la page
  if (document.getElementById) { //IE5 
    var pos=parseInt(document.getElementById(nom).style.top);
    var wintop=parseInt(document.body.scrollTop);
    var avail=document.body.clientHeight;
  }
  if ((document.getElementById)&&(!document.all)) { //NS6
    var pos=parseInt(document.getElementById(nom).style.top);
    var wintop=parseInt(window.pageYOffset);
    var avail=window.innerHeight;
  }
  if ((document.all)&&(!document.getElementById)) { //IE4 seul
    var pos=parseInt(document.all[nom].style.top);
    var wintop=parseInt(document.body.scrollTop);
    var avail=document.body.clientHeight;
  }
  if (document.layers) { //NS4.X seul
    var pos=parseInt(document.layers[nom].top);
    var wintop=parseInt(window.pageYOffset);
    var avail=window.innerHeight;
  }

  // Partie 2 : Traitement de la position
  if (tjs_mode==0) { // toujours en haut
    var delta=Math.ceil((pos-wintop)/3);
    if (delta>20) {delta=20;}
    if (delta<-20) {delta=-20;}
    var top=pos-delta;
  }
  if (tjs_mode==1) {// toujours en bas
    var delta=Math.ceil((pos-(wintop+avail-tjs_hauteur)));
    if (delta>tjs_max) {delta=tjs_max;}
    if (delta<-1*tjs_max) {delta=-1*tjs_max;}
    var top=pos-delta;
  }
  return top;
}
