// (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 getMousePos(event) {
	var e=event||window.event;
	var scroll=new Array((document.documentElement&&document.documentElement.scrollLeft)||window.pageXOffset||self.pageXOffset||document.body.scrollLeft,(document.documentElement&&document.documentElement.scrollTop)||window.pageYOffset||self.pageYOffset||document.body.scrollTop);
	return new Array(e.clientX+scroll[0]-document.body.clientLeft,e.clientY+scroll[1]-document.body.clientTop);
}

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

//			if(niveau!=timeNiveau) { lesub.zIndex=ssplan++; timeNiveau=niveau; }
			lesub.zIndex=ssplan++;
			if(niveau!=timeNiveau) timeNiveau=niveau;
		}
	}
	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){ }
}

// -------------------------- 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); }

