	function gId(id){return document.getElementById(id);}


var oteONGLET_HEIGHT=15;
var oteTEASER_HEIGHT=284;
var oteNB_FICHE=4;
var oteSCROLL_D=3; //pas du scroll permanent
var oteSCROLL_T=3; //ms scroll permanent
var oteONGLET_DEFAUT='1';
var oteMODE_RANDOM=0;
oteONGLET_HEIGHT+=1;//marge sous onglet
var oteESPACE=3;
var oteTMP_DEFIL=4000;
function oteObjFiche(num, open, position, top, destin, timeOut, onglet1, onglet2, loaded, texte){
this.num=num; //num de classement
this.open=open; //fenetre est visible (1=oui, 0=non)
this.position=position; //pos de l'onglet (2=en mouvement, 1=en haut, 0=en bas)
this.top=top; //ordonnée actuelle de l'onglet
this.destin=destin; //ordonnée de destination
this.timeOut=timeOut;
this.onglet1=onglet1;
this.onglet2=onglet2;
this.loaded=loaded;
this.texte=texte;
}
var oteObjFiche1=new oteObjFiche(1, '0', 1, 0, '0', '0', 'http://www.peyman.org/forum/templates/xeon/images/accueil-menu-c.gif', 'http://www.peyman.org/forum/templates/xeon/images/accueil-menu.gif', '0', '');
oteTabSrc1={"iran":"http:\/\/www.peyman.org\/forum\/templates\/xeon\/images\/lencart.gif"};

var oteObjFiche2=new oteObjFiche(2, '0', 1, 0, '0', '0', 'http://www.peyman.org/forum/templates/xeon/images/presentation-menu-c.gif', 'http://www.peyman.org/forum/templates/xeon/images/presentation-menu.gif', '0', '');
oteTabSrc2={"iran":"http:\/\/www.peyman.org\/forum\/templates\/xeon\/images\/spacer.gif"};

var oteObjFiche3=new oteObjFiche(3, '0', 1, 0, '0', '0', 'http://www.peyman.org/forum/templates/xeon/images/statistiques-menu-c.gif', 'http://www.peyman.org/forum/templates/xeon/images/statistiques-menu.gif', '0', '');
oteTabSrc3={"iran":"http:\/\/www.peyman.org\/forum\/templates\/xeon\/images\/spacer.gif"};

var oteObjFiche4=new oteObjFiche(4, '0', 1, 0, '0', '0', 'http://www.peyman.org/forum/templates/xeon/images/charte-menu-c.gif', 'http://www.peyman.org/forum/templates/xeon/images/charte-menu.gif', '0', '');
oteTabSrc4={"iran":"http:\/\/www.peyman.org\/forum\/templates\/xeon\/images\/spacer.gif"};

//fonction determinant le placement
function otePlacement (affiche){
var i;
var obj;
var fiche;
for (i=1; i<=oteNB_FICHE; i++){
	obj=eval("oteObjFiche" + i);
	//on verifie si il est en haut ou en bas
	if (i <= affiche){
	obj.open=0;
	obj.destin=((i - 1) * oteONGLET_HEIGHT);
	if (i == affiche){
	obj.open=1;
	}	
	} else{
	obj.open=0;
	obj.destin=((i - 1) * oteONGLET_HEIGHT) + oteTEASER_HEIGHT + oteESPACE;	
	}	
}
}
//fonction de defilement
function oteScroll(sens, objId)
	{
	var obj;
	obj=eval("oteObjFiche" + objId);
	if (sens=='bas')
		{
		if (obj.position != 0)
			{
			obj.top=obj.top + oteSCROLL_D;
			if (obj.top < obj.destin)
				{
				fiche=gId("oteFiche" + objId);
				if (fiche)
					{fiche.style.top=obj.top + 'px';}
				obj.position=2;
				obj.timeOut=setTimeout('oteScroll("bas", '+ objId +')', oteSCROLL_T);
				}
			else
				{
				obj.top=obj.destin;
				fiche=gId("oteFiche" + objId);
				if (fiche)
					{fiche.style.top=obj.top + 'px';}
				obj.position=0;
				}
			}
		}
	else if (sens=='haut')
		{
		if (obj.position != 1)
			{
			obj.top=obj.top - oteSCROLL_D;	
			if (obj.top > obj.destin)
				{	
				fiche=gId("oteFiche" + objId);
				if (fiche)
					{fiche.style.top=obj.top + 'px';}
				obj.position=2;
				obj.timeOut=setTimeout('oteScroll("haut", '+ objId +')', oteSCROLL_T);
				}
			else
				{
				obj.top=obj.destin;
				fiche=gId("oteFiche" + objId);
				if (fiche)
					{fiche.style.top=obj.top + 'px';}
				obj.position=1;
				}
			}
		}
	}
//choix des onglets à bouger en fonction des pos actuelles
function oteQuiBougeOu (idObj)
	{
	var i;
	var obj;
	obj=eval("oteObjFiche" + idObj);
	if (obj.position == 1)
		{
		for (i=obj.num; i<=oteNB_FICHE; i++)
			{oteScroll('bas', i);}
		}
	if (obj.position == 0)
		{
		for (i=1; i<=obj.num; i++)
			{oteScroll('haut', i);}	
		}
	}
//charge l'image d'onglet
function oteLoadOng(nomObj, src, idObj)
	{
	var obj;
	obj=gId(nomObj + idObj);
	if (obj)
		{obj.src=src;}	
	}
//change toutes les images d'onglet et cache les selects
function oteFormatImg()
	{
	var obj;
	var elem;
	var i;
	for (i=1; i<=oteNB_FICHE; i++)
		{
		obj=eval("oteObjFiche" + i);
		elem=gId("oteTitre" + i);
		if (elem)
			{elem.src=obj.onglet2;}
		oteHiddeSelect(i, 'none');
		}	
	}
//rend les selects invisibles
function oteHiddeSelect(elemID, visib)
	{
 	var div=gId('oteCorp' + elemID);
 	if (div)
		{selects=div.getElementsByTagName('select');}
 	var selectsNb=selects.length;
 	for (var i=0; i < selectsNb; i++)
		{
		thisSelect=selects[i];
		thisSelect.style.display=visib;
		}
	}
//on vérifie que tous les onglets ont fini de bouger
function oteAffSelec(objId)
	{
	var obj;
	var immo=1;
	var i;
	for (i=1; i<=oteNB_FICHE; i++)
		{
		obj=eval("oteObjFiche" + i);
		if (obj.position == 2)
			{immo=0;}
		}
	if (immo == 1)
		{oteHiddeSelect(objId, 'inline');}
	else
		{hideS=setTimeout('oteAffSelec(' + objId + ')', 100);}
	}

//charge les images du teaser
function oteLoadImg(idObj)
	{
	var obj=eval("oteObjFiche" + idObj);
	var elem=gId("oteCorp" + idObj);
	var tab=eval("oteTabSrc" + idObj);
	if (elem)
		{
		var nodeArray = elem.getElementsByTagName('img');
		var nodeNb = nodeArray.length;
		var node;
		for (var i = 0; i<nodeNb;i++)
			{
			node=nodeArray[i];
			node.src=tab[node.getAttribute('alt')];
			}
			obj.loaded=1;
		}	
	}
//action du clic sur un onglet
function oteOnClic(actionId, auto)
	{
	var obj;
	obj=eval("oteObjFiche" + actionId);
	if ((obj.open != 1) && (obj.position != 2))
		{
		if (obj.loaded!=1)
			{
			var elem=gId('oteCorp' + actionId);
			if (elem)
				{elem.style.display="block";}
			oteLoadImg(actionId);
			}
		otePlacement (actionId);
		oteFormatImg();
		oteLoadOng('oteTitre', obj.onglet1, actionId);
		hideS=setTimeout('oteAffSelec(' + actionId + ')', 200);
		oteQuiBougeOu (actionId);
		}
	}
function oteDefOngl()
	{
	if (oteMODE_RANDOM==1)
		{
		var alea;
		alea=parseInt(Math.random() * oteNB_FICHE, 10);
		alea++;
		oteOnClic(alea, 1);
		}
	else
		{
		if (oteONGLET_DEFAUT!='')
			{
			oteOnClic(oteONGLET_DEFAUT, 1);
			}
		else
			{
			oteOnClic('1', 1);
			}
		}
	}