// (c)2007-2008 Boursica.com - Tous droits réservés.

x=0; y=0;
timeID=new Array();
timeNom=new Array();
timeNiveau=0;
modifmemo=0; ssplan=10001;

function mouseMove(e) {
	x = e.clientX;
	y = e.clientY;
}

function getObj(name){
	if(document.getElementById) return document.getElementById(name).style;
	else if(document.all) return document.all[name].style;
	else if(document.layers) return document.layers[name];
	else return false;
}

function affmenu(nom,xok,yok,niveau) {
	niveau=niveau?niveau:0;
	// xok et yok : (rien ou 0)=souris automatique, nombre=position imposée, -1=non modifié
	if(timeID[niveau]) { clearTimeout(timeID[niveau]); timeID[niveau]=0; }
	if(timeNom[niveau]==nom) return;
	var n=niveau; while(timeNom[n]) { menuout2(timeNom[n],n,1); n++; } // vire tous les autres menus de niveau > ou = affichés
	var lesub = getObj(nom);

	if(nom=="memo") {
		if(!modifmemo) {
			goScript('/memo.php?act=load');
			modifmemo=1;
		}
		lesub.display="";
		document.getElementById('ssmemosaisie').focus();
	}else{
		if(document.all) {
			x=event.clientX + document.body.scrollLeft;
			y=event.clientY + document.body.scrollTop;
			width = document.body.clientWidth + document.body.scrollLeft;
			height= document.body.clientHeight + document.body.scrollTop;
		}else{
			x = x + window.pageXOffset;
			y = y + window.pageYOffset;
			width = window.innerWidth + window.pageXOffset;
			height= window.innerHeight + window.pageYOffset;
		}

		if(lesub.display=="none"){
			var large=parseInt(lesub.width);
			var haut=parseInt(lesub.height);
			var ax=x-30; if(ax<0) ax=0; else if(ax+large>width-1) ax=width-large;
			var ay=y-30; if(ay<0) ay=0; else if(ay+haut>height-1) ay=height-haut;
			if(!xok) lesub.left=ax+"px"; else if(xok>0) lesub.left=xok;
			if(!yok) lesub.top=(ay-offsetMenuY)+"px"; else if(yok>0) lesub.top=yok;
			lesub.display="";

//			if(niveau!=timeNiveau) { lesub.zIndex=ssplan++; timeNiveau=niveau; }
			lesub.zIndex=ssplan++;
			if(niveau!=timeNiveau) timeNiveau=niveau;

			if(document.all && (IEver=parseFloat(navigator.appVersion.split("MSIE")[1])) && (IEver>=5.5) && (IEver<7) && document.body.filters && (img=document.getElementById("img"+nom)))
				img.outerHTML="<span "+(img.className?"class='"+img.className+"' ":"")
					+"style=\"position:absolute;width:"+img.width+"px;height:"+img.height+"px;"
					+"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+img.src+"',sizingMethod='scale');\"></span>";
		}
	}
	timeNom[niveau]=nom;
}

function menuover(nom,niveau){
	clearTimeout(timeID[niveau?niveau:0]);
}

function menuout(nom,niveau){
	niveau=niveau?niveau:0;
	timeID[niveau]=setTimeout("menuout2('"+nom+"',"+niveau+")",1000);
}
function menuout2(nom,niveau,force){
	niveau=niveau?niveau:0;
	if((!force)&&timeNom[niveau+1]) { timeID[niveau]=setTimeout("menuout2('"+nom+"',"+niveau+")",500); return; } // cette ligne empêche l'effacement du menu parent tant qu'il y a un ssmenu
	var lesub = getObj(nom);
	lesub.display="none";
	timeID[niveau]=0;
	timeNom[niveau]="";
	if(modifmemo==2) sauvememo();
}

if(document.all) ; else document.onmousemove = mouseMove;

// ---------------------

function aff_favoris(ajout,lien,descr) {
	var obj=document.getElementById("zoneactive");
	obj.innerHTML='';
	obj.style.display='block';
	obj.style.top='99px'; obj.style.left='150px';
	obj.style.width='300px'; obj.style.height='290px';
	obj.innerHTML="<iframe src=\"/favoris-ajout.php?ajout="+ajout+"&lien="+(lien?lien:document.location)+(descr?"&descr="+descr:"")+"\" width=300 height=290 frameborder=0 scrolling=NO allowtransparency=true></iframe>";
}

// ---------------------

function aff_ident() {
	var obj=document.getElementById("zoneactive");
	obj.innerHTML='';
	obj.style.display='block';
	obj.style.top='100px'; obj.style.left='450px';
	obj.style.width='300px'; obj.style.height='330px';
	obj.innerHTML="<iframe src='/identification.php' width=300 height=330 frameborder=0 scrolling=NO allowtransparency=true></iframe>";
}
function aff_newident() {
	var obj=document.getElementById("zoneactive");
	obj.innerHTML='';
	obj.style.display='block';
	obj.style.top='100px'; obj.style.left='450px';
	obj.style.width='300px'; obj.style.height='400px';
	obj.innerHTML="<iframe src='/identification-new.php' width=300 height=400 frameborder=0 scrolling=NO allowtransparency=true></iframe>";
}

// ---------------------

function sauvememo() {
	modifmemo=1;
	goScript("/memo.php","ssmemoform");
}

// ---------------------

function bodyferme() {
	if(modifmemo==2) sauvememo();
	try{ return fermeture(); }catch(e){ }
}

// ---------------------

var tLoupeHeure;
function aff_loupe(fonction) {
	menuout2('loupe');
	if(tLoupeHeure) clearTimeout(tLoupeHeure);
	document.cookie="aff_loupe="+fonction+"; path=/";
	obj=document.getElementById("innerAlerteBas");
	switch(fonction) {
		case 'heure':
			obj.innerHTML="<big id=loupeHeure>Heure</big>";
			tLoupeHeure=setInterval('loupe_heure()',1000);
			break;
		case 'calc':
			obj.innerHTML="<big id=loupeCalc>Calculatrice (à venir)</big>";
			break;
		default:
			affiche_menu_mini();
	}
}
function loupe_heure() {
	var Maintenant=new Date();
	var jour=Maintenant.getDate();
	var moiss=new Array("Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre");
	var mois=moiss[Maintenant.getMonth()];
	var annee=Maintenant.getYear(); if(annee<2000) annee=annee+1900;
	var heure=Maintenant.getHours();
	var minutes=Maintenant.getMinutes();
	var secondes=Maintenant.getSeconds();
	document.getElementById("loupeHeure").innerHTML=jour+" "+mois+" "+annee+" - "+((heure<10)?" 0":" ")+heure+((minutes<10)?":0":":")+minutes+((secondes<10)?":0":":")+secondes;
}

// -------------------------- flux RSS

function aff_rss() {
	if((domaineDeb=document.domain.indexOf("."))==(domaineFin=document.domain.lastIndexOf("."))) domaineDeb=-1;
	window.open("/flux-rss/direct.php","direct_"+document.domain.substring(domaineDeb+1,domaineFin),"directories=no,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no,width=350,height=450").focus();
}

// -------------------------------------------- Liste de pages

btn=new Array();
function btnPgIn(obj) { if(obj.timeout) clearTimeout(obj.timeout); obj.style.height="32px"; obj.style.color="red"; }
function btnPgOut(obj) { obj.taille=32; btn[parseInt(obj.value)]=obj;  obj.timeout=setTimeout('btnPgOut2('+parseInt(obj.value)+')',100); }
function btnPgOut2(nbtn) { obj=btn[nbtn]; obj.style.color=""; if(obj.taille--<23) return; obj.style.height=obj.taille+"px"; obj.timeout=setTimeout('btnPgOut2('+nbtn+')',50); }
