/*            ______
             /  __  \
            /  /__\  \LINCKERS©               
           /  ___    /  __________
          /  /   \   \ /  _______/
         /  /     |   |  /roups_
        /  /     /   /  /  /_  /
       /   \___ /   /  /____/ /
       \__________ /\________/
 
 *****************************************
 *  Lib_JS_2 - ver 1.2
 *  script/lib_2.js
 *  Created by McPeter - 21/04/2004
 *****************************************
 * - BLINCKERS© Groups & MonPremierSite© -
 *    http://www.blinckers-groups.com
 *    http://www.monpremiersite.com
 *****************************************
 * Fonctions JavaScript 
 *****************************************/
// fonction pour réglementation de l'attribut 'target' du W3C
function TargetBlank() { 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") anchor.target = "_blank"; 
 } 
} 

function Ident(Obj){ return (document.all)?document.all[Obj]:document.getElementById(Obj); }
function posX(Obj){ return (Obj.offsetParent)?(Obj.offsetLeft + posX(Obj.offsetParent)):(Obj.offsetLeft); }
function posY(Obj){ return (Obj.offsetParent)?(Obj.offsetTop + posY(Obj.offsetParent)):(Obj.offsetTop); }
//function posW(Obj){ return (Obj.offsetParent)?(Obj.offsetWidth + posY(Obj.offsetParent)):(Obj.offsetWidth); }
function posW(Obj){ return (Obj.offsetParent)?(Obj.offsetWidth + posX(Obj.offsetParent)):(Obj.offsetWidth); }
function posH(Obj){ return (Obj.offsetParent)?(Obj.offsetHeight + posY(Obj.offsetParent)):(Obj.offsetHeight); }

function pagePositionXY(){
	var Page=new Array();
	Page[0] = (window.innerHeight)?window.pageYOffset:((document.documentElement && document.documentElement.scrollTop)?document.documentElement.scrollTop:document.body.scrollTop);
	Page[1] = (window.innerHeight)?window.pageXOffset:((document.documentElement && document.documentElement.scrollLeft)?document.documentElement.scrollLeft:document.body.scrollLeft);
	Page[2] = (document.all) ? document.documentElement.offsetWidth : window.innerWidth;
	Page[3] = (document.all) ? document.documentElement.offsetHeight : window.innerHeight;
	return Page;
}

function putMenuTopInfos(){
	var effectIE=(document.all)?89:85;
	var heightPage=pagePositionXY();
	heightPage=heightPage[3]-effectIE;
	var heightContent=posY(Ident('footer'))-65+posH(Ident('footer'));
	heightContent=(heightContent<heightPage)?heightPage:heightContent;
	
	Ident('menuTopInfos').style.height=heightContent+'px';
}

var menu, startTop=0, oldTop=startTop;
var menu, startBottom=0, oldBottom=startBottom;
var hideMenu;

function putMenuBottom(){ // Positionnement de la barre de tâches
	topThisPage=pagePositionXY()[0];
	heightThisPage=pagePositionXY()[3];

	if(topThisPage < startTop) topThisPage=startTop; else topThisPage+=0;
	if(topThisPage==oldTop){
		(document.all)?Ident('menuBarr').style.top = topThisPage+heightThisPage-36+"px":Ident('menuBarr').style.top = topThisPage+heightThisPage-32+"px";
		(document.all)?Ident('startMenu').style.top = topThisPage+heightThisPage-432+"px":Ident('startMenu').style.top = topThisPage+heightThisPage-428+"px";
		(document.all)?Ident('startMenuShade').style.top = topThisPage+heightThisPage-422+"px":Ident('startMenuShade').style.top = topThisPage+heightThisPage-418+"px";
	}	
	Ident('menuBarr').style.visibility='visible';
	oldTop=topThisPage;
	Compt=setTimeout('putMenuBottom()',25);
}

function Start(){ // Affichage du menu Optimizer
	var startMenu=Ident('startMenu'),  startMenuShade=Ident('startMenuShade');
	startMenu.style.visibility=(startMenu.style.visibility=='visible')?'hidden':'visible';
	startMenuShade.style.visibility=(startMenuShade.style.visibility=='visible')?'hidden':'visible';
}

// Retourner quel calque est concerné par l'appel du menu parent
function findFrame(UpperMenu){ return "startMenulvl_"+UpperMenu.substr(3,1); }
function findShadow(UpperMenu){ return "startIntern_"+UpperMenu.substr(3,1); }

// Construit le contennu d'un menu
function buildMenu(UpperMenu){
	var Menu='', ViewLink='', contentMenu=new Array();	
	if(UpperMenu.substr(3,1)==1){
		switch(UpperMenu.substr(5)){
			case '0' : Menu=ThisLink[0];    break;
			case '1' : Menu=ThisLink[1];	break;
			case '2' : Menu=ThisLink[2];	break;
			case '3' : Menu=ThisLink[3];	break;
			case '4' : Menu=ThisLink[4];	break;
			case '5' : Menu=ThisLink[5];	break;
			case '6' : Menu=ThisLink[6];	break;
			default : Menu=ThisLink[0];     break;
		}
	}else if(UpperMenu.substr(3,1)==2){
		switch(UpperMenu.substr(5)){
			case '0' : Menu=ThisUnderLink[0];    break;
			case '1' : Menu=ThisUnderLink[1];	break;
			case '2' : Menu=ThisUnderLink[2];	break;
			case '3' : Menu=ThisUnderLink[3];	break;
			case '4' : Menu=ThisUnderLink[4];	break;
			default : Menu=ThisUnderLink[0];     break;
		}
	}
	for(i=1; i<Menu.length; i++){ ViewLink+=Menu[i]; }
	contentMenu[0]=Menu[0];
	contentMenu[1]=ViewLink;
	return contentMenu;
}


// Affiche les menus de premier et second niveau
function view(whoIs){
	var menuFrame=(whoIs)?findFrame(whoIs):'';					// Trouve et identifi le menu
	var shadowFrame=(whoIs)?findShadow(whoIs):'';				// Trouve et identifi l'ombre de ce menu

	if(menuFrame){												// Vérifie que le menu de second niveau est identifié
		window.clearTimeout(hideMenu);	var contentMenu=buildMenu(whoIs);	// Construit le menu
		
		if(menuFrame=="startMenulvl_2"){
			Ident(menuFrame).innerHTML=contentMenu[1];				// Insère le menu dans le calque
			Ident(menuFrame).style.width=contentMenu[0]+'px';		// Attribue la largeur du menu
			Ident(menuFrame).style.left=posW(Ident(whoIs))+6+'px';
			Ident(menuFrame).style.top=posY(Ident(whoIs))+'px';
		}else{
			Ident(menuFrame).innerHTML=contentMenu[1];				// Insère le menu dans le calque
			Ident(menuFrame).style.width=contentMenu[0]+'px';		// Attribue la largeur du menu
			if(whoIs=='lvl1-6'){
				// Positionne le menu en hauteur vers le haut
				Ident(menuFrame).style.top=posY(Ident(whoIs))-posH(Ident(menuFrame))+28+'px';
			}else{
				// Positionne le menu en hauteur vers le bas
				Ident(menuFrame).style.top=posY(Ident(whoIs))+'px';
			}
		}
		
		// Gestion de l'ombre
		Ident(shadowFrame).style.top=posY(Ident(menuFrame))+4+'px';
		Ident(shadowFrame).style.left=posX(Ident(menuFrame))+4+'px';
		Ident(shadowFrame).style.width=posW(Ident(menuFrame))+'px';
		Ident(shadowFrame).style.height=posH(Ident(menuFrame))+'px';
		
		//Ident(whoIs).style.backgroundColor='#B5B7CA';
		Ident(menuFrame).style.visibility='visible';			// Affiche le menu
		Ident(shadowFrame).style.visibility='visible';			// Affiche l'ombre
	}else{ hideMenu=setTimeout("hidde()", 500); }
}


function viewOn(){ window.clearTimeout(hideMenu); }
function hidde(){
	if(Ident('startMenulvl_1').style.visibility=="visible"){ Ident('startMenulvl_1').style.visibility="hidden"; Ident('startIntern_1').style.visibility="hidden"; }
	if(Ident('startMenulvl_2').style.visibility=="visible"){ Ident('startMenulvl_2').style.visibility="hidden"; Ident('startIntern_2').style.visibility="hidden"; }
}
function viewOff(){
	if(Ident('startMenulvl_2').style.visibility=="visible"){ Ident('startMenulvl_2').style.visibility="hidden"; Ident('startIntern_2').style.visibility="hidden"; }
}

var nav=navigator.appName.substring(0,3), ver=navigator.appVersion.substring(0,1);
function addFavorites(){
	if(nav=="Mic"&&ver>=4){
		window.external.AddFavorite('http://optimizer-xp.blinckers-groups.com', 'OptimizerXP by BLINCKERS© Groups');
	}else{
		alert("OptimizerXP by BLINCKERS© Groups\nAppuyez sur la combinaison de touches [Ctrl]+[d]\npour ajouter cette page de OptimizerXP à vos signets.");
	}
}

function Launch(){ // Activation du menu
	Today = new Date();
	Heure = Today.getHours();
	Min = Today.getMinutes();
	//Sec = Today.getSeconds();
	Jour = Today.getDay();
	JourNb = Today.getDate();
	Mois = Today.getMonth();
	Année = Today.getFullYear();
	if (Heure < 10) Heure = "0" + Heure;
	if (Min < 10) Min = "0" + Min;
	//if (Sec < 10) Sec = "0" + Sec;
	if (Jour < 10) Jour = "0" + Jour;
	if (Mois < 10) Mois = "0" + Mois;
	Horaire = Heure+' h '+Min+'<br />'+JourNb+'/'+Mois+'/'+Année;
	Ident('dateOfMoment').innerHTML=Horaire;

	putMenuTopInfos();
	putMenuBottom();
	TargetBlank();
}
window.onload = Launch;
window.onresize = Launch;
