//===========
// New window
//===========

function Start(url,type,picw,pich) {
 if (type == "page") {
  OpenWin = this.open(url);
 }
 else if (type == "photo") {
  content = "width=" + picw + ",height=" + pich + ",menubars=no,scrollbars=yes,directories=no,resizable=no,statusbar=no,toolbar=no";
  OpenWin = this.open(url,"Photo",content);
 }
 else if (type == "puzzle") {
  OpenWin = this.open(url,"Puzzle","width=420,height=360,menubars=no,scrollbars=no,directories=no,resizable=no,statusbar=no,toolbar=no");
 }
}

//================
// Directory level
//================

var titre = "";
var dlevel = "";
titre = top.document.title; 

if (titre == "Agenda") {
 dlevel = "../";
}
if (titre == "News") {
 dlevel = "../";
}
if (titre == "Leclub") {
 dlevel = "../";
}
if (titre == "Fiches") {
 dlevel = "../";
}
if (titre == "Photos") {
 dlevel = "../";
}
if (titre == "Jeux") {
 dlevel = "../";
}

var url= "";
function Url(url) {
 window.location.href = dlevel + url;
}

// ====
// Menu
// ====


var text="";
text+="<style type='text/css'>";
text+="a {text-decoration: none;}";
text+=".title";
text+="{position: absolute;";
text+="width: 200px;";
text+="height: 20px;";
text+="left: 10px;";
text+="z-index: 10;";
text+="font-family: Arial;";
text+="font-size: 16px;}";
text+=".submenu";
text+="{position: absolute;";
text+="left: 25px;";
text+="width: 200px;";
text+="font-family: Arial;";
text+="font-size: 14px;";
text+="visibility: hidden;}";
text+="</style>";

text+="<DIV id='floatlayer' style='position:absolute;left:10px;top:40px'>";

text+=" <div class='title' id='title1' style='top: 0px'><a href=javascript:Url('index.htm')>Accueil</a></div>";

text+=" <div class='title' id='title2' style='top: 20px'><a href=javascript:Url('Agenda/Agenda2004.htm')>Agenda</a></div>";

text+=" <div class='title' id='title3' style='top: 40px'><a href=javascript:Url('News/News.htm')>News</a></div>";

text+=" <div class='title' id='title4' style='top: 60px'><a href='#' onclick='javascript: toggle(4,50); return false'><img name='pic4' src='./Images/closed.gif' border='0'> Le Club</a></div>";
text+=" <div class='submenu' id='submenu4' style='top: 80px'>";
text+="  <div id='Club1'><a href=javascript:Url('Leclub/Historique.htm')>Historique</a></div>";
text+="  <div id='Club2'><a href=javascript:Url('Leclub/MembresClub.htm')>Membres du club</a></div>";
text+="  <div id='Club3'><a href=javascript:Url('Leclub/Archives.htm')>Archives</a></div>";
text+=" </div>";

text+=" <div class='title' id='title5' style='top: 80px'><a href='#' onclick='javascript: toggle(5,40); return false'><img name='pic5' src='./Images/closed.gif' border='0'> Trucs & Astuces</a></div>";
text+=" <div class='submenu' id='submenu5' style='top: 100px'>";
text+="  <div id='Fiches'><a href=javascript:Url('Fiches/Fiches.htm')>Fiches</a></div>";
text+=" </div>";

text+=" <div class='title' id='title6' style='top: 100px'><a href='#' onclick='javascript: toggle(6,80); return false'><img name='pic6' src='./Images/closed.gif' border='0'> Photos</a></div>";
text+=" <div class='submenu' id='submenu6' style='top: 120px'>";
text+="  <div id='Photos1'><a href=javascript:Url('Photos/Cometes.htm')>Comètes</a></div>";
text+="  <div id='Photos2'><a href=javascript:Url('Photos/Conjonctions.htm')>Conjonctions</a></div>";
text+="  <div id='Photos3'><a href=javascript:Url('Photos/Constellations.htm')>Constellations</a></div>";
text+="  <div id='Photos4'><a href=javascript:Url('Photos/Eclipses.htm')>Eclipses</a></div>";
text+="  <div id='Photos5'><a href=javascript:Url('Photos/Planetes.htm')>Planètes</a></div>";
text+=" </div>";

text+=" <div class='title' id='title7' style='top: 120px'><a href='http://www.astroshopping.com/'>Astroshopping</a></div>";
text+=" <div class='title' id='title8' style='top: 140px'><a href=javascript:Url('Jeux/Jeux.htm')>Jeux</a></div>";
text+=" <div class='title' id='title9' style='top: 160px'><a href=javascript:Url('Liens.htm')>Liens</a></div>";

text+="</DIV>";
document.write(text);

// =======
// Submenu
// =======

var nom = 9; // Number of menus
var usePictures = 1; // use pictures?  1 = yes, 0 = no

var ttls = new Array(); // An array for the title objects
var subs = new Array(); // An array for the submenu objects
var lastn;
var lastmove;

if (document.layers) {
 visible = 'show';
 hidden = 'hide';
}
else
if (document.all) {
 visible = 'visible';
 hidden = 'hidden';
}

for (var i = 1; i <= nom; i++) {
 ttls[i] = ('title' + i);
 subs[i] = ('submenu' +i);
}

function picopen(n) {
 title = ('title' + n);
 pic = ('pic' + n);
 if (document.layers) {
  document.layers[title].document.images[pic].src = dlevel + "Images/opened.gif";
 }
 else if (document.all) {
  document.all(pic).src = dlevel + "Images/opened.gif";
 }
}
function picclose(n) {
 title = ('title' + n);
 pic = ('pic' + n);
 if (document.layers) {
  document.layers[title].document.images[pic].src = dlevel + "Images/closed.gif";
 }
 else if (document.all) {
  document.all(pic).src = dlevel + "Images/closed.gif";
 }
}

lastn = (nom + 1);
lastmove = 0;

function lasttoggle(n,move) {
 if (n <= nom) {
  menu = ('submenu' + n);
  if (document.layers) {
   submenu = document.layers[menu];
  }
  else if (document.all) {
   submenu = document.all(menu).style;
  }
  if (submenu.visibility == visible) {
   submenu.visibility = hidden;
   picclose(n); // Remove this if you don't use pictures
   for (i = (n+1); i <= nom; i++) {
    if (document.layers) {
     document.layers[ttls[i]].top -= move;
     if (document.layers("submenu"+i)) document.layers[subs[i]].top -= move;
    }
    else if (document.all) {
     document.all(ttls[i]).style.pixelTop -= move;
     if (document.all("submenu"+i)) document.all(subs[i]).style.pixelTop -= move;
    }
   }
  }
 }
}

function toggle(n,move) {
 menu = ('submenu' + n);
 if (document.layers) {
  submenu = document.layers[menu];
 }
 else if (document.all) {
  submenu = document.all(menu).style;
 }
 if (submenu.visibility == visible) {
  submenu.visibility = hidden;
  if (usePictures) picclose(n);
  for (i = (n+1); i <= nom; i++) {
   if (document.layers) {
    document.layers[ttls[i]].top -= move;
    if (document.layers("submenu"+i)) document.layers[subs[i]].top -= move;
   }
   else if (document.all) {
    document.all(ttls[i]).style.pixelTop -= move;
    if (document.all("submenu"+i)) document.all(subs[i]).style.pixelTop -= move;
   }
  }
 }
 else {
  submenu.visibility = visible;
  if (usePictures) picopen(n);
  if (lastn != n) {
   lasttoggle(lastn,lastmove);
  }
  for (i = (n+1); i <= nom; i++) {
   if (document.layers) {
    document.layers[ttls[i]].top += move;
    if (document.layers("submenu"+i)) document.layers[subs[i]].top += move;
   }
   else if (document.all) {
    document.all(ttls[i]).style.pixelTop += move;
    if (document.all("submenu"+i)) document.all(subs[i]).style.pixelTop += move;
   }
  }
 }
 lastn = n;
 lastmove = move;
}

// ====================
// Floating Menu script
// ====================

window.onerror = null;
var topMargin = 200;
var slideTime = 3000;
var ns6 = (!document.all && document.getElementById);
var ie4 = (document.all);
var ns4 = (document.layers);
function layerObject(id,left) {
if (ns6) {
this.obj = document.getElementById(id).style;
this.obj.left = left;
return this.obj;
}
else if(ie4) {
this.obj = document.all[id].style;
this.obj.left = left;
return this.obj;
}
else if(ns4) {
this.obj = document.layers[id];
this.obj.left = left;
return this.obj;
   }
}
function layerSetup() {
floatlyr = new layerObject('floatlayer', pageWidth * 0.02);
window.setInterval("main()", 10)
}
function floatObject() {
if (ns4 || ns6) {
findHt = window.innerHeight;
} else if(ie4) {
findHt = document.body.clientHeight;
   }
} 
function main() {
if (ns4) {
this.currentY = document.layers["floatlayer"].top;
this.scrollTop = window.pageYOffset;
mainTrigger();
}
else if(ns6) {
this.currentY = parseInt(document.getElementById('floatlayer').style.top);
this.scrollTop = scrollY;
mainTrigger();
} else if(ie4) {
this.currentY = floatlayer.style.pixelTop;
this.scrollTop = document.body.scrollTop;
mainTrigger();
   }
}
function mainTrigger() {
var newTargetY = this.scrollTop + this.topMargin;
if ( this.currentY != newTargetY ) {
if ( newTargetY != this.targetY ) {
this.targetY = newTargetY;
floatStart();
}
animator();
   }
}
function floatStart() {
var now = new Date();
this.A = this.targetY - this.currentY;
this.B = Math.PI / ( 2 * this.slideTime );
this.C = now.getTime();
if (Math.abs(this.A) > this.findHt) {
this.D = this.A > 0 ? this.targetY - this.findHt : this.targetY + this.findHt;
this.A = this.A > 0 ? this.findHt : -this.findHt;
}
else {
this.D = this.currentY;
   }
}
function animator() {
var now = new Date();
var newY = this.A * Math.sin( this.B * ( now.getTime() - this.C ) ) + this.D;
newY = Math.round(newY);
if (( this.A > 0 && newY > this.currentY ) || ( this.A < 0 && newY < this.currentY )) {
if ( ie4 )document.all.floatlayer.style.pixelTop = newY;
if ( ns4 )document.layers["floatlayer"].top = newY;
if ( ns6 )document.getElementById('floatlayer').style.top = newY + "px";
   }
}
function startmenu(level) {
if(ns6||ns4) {
pageWidth = innerWidth;
pageHeight = innerHeight;
printmenu();
layerSetup();
floatObject();
}
else if(ie4) {
pageWidth = document.body.clientWidth;
pageHeight = document.body.clientHeight;
layerSetup();
floatObject();
   }
}
