// JavaScript Document

/* images survolées */
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; 
  document.MM_sr=new Array; 
  for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){
	   document.MM_sr[j++]=x; 
	   if(!x.oSrc) x.oSrc=x.src; 
	   		x.src=a[i+2];
   }
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}


/* fonction pour afficher les sous menus */
/**
 * showSubMenu : affiche ou cache les sous-menus du menu principal
 * @param id : attribut 'id' de l'élément à montrer/cacher (tous les sous-menus ont le même)
 */
function showSubMenu(id){
	/* On ferme tous les autres menus */
	/* On affiche le menu à ouvrir */
	var e = document.getElementById(id)
	if (e.style.display == 'none') {
		e.style.display = 'block'
	} 
	else {
		e.style.display = 'none'
	}
}



/*
SimpleJS ver 0.1 beta
----------------------
SimpleJS is developed by Christophe "Dyo" Lefevre (http://bleebot.com/)
*/

function $parcourirImage(id){
	var e = document.getElementById(id)
	if (e.disabled == true) {
		e.disabled = false;
		e.value = '';
	} 
	else {
		e.disabled = true;
	}
}


/* $toggle (ma version simple) */
function $toggleBase(id){
	var e = document.getElementById(id)
	if (e.style.display == 'none') {
		e.style.display = 'block'
	} 
	else {
		e.style.display = 'none'
	}
}



function $(id){
	return document.getElementById(id);
}

function STO(_24,_25){
	return window.setTimeout(_24,_25);
}

function $toggle(id){
	if(act_height(id) == 0){
		$blinddown(id);
	} 
	else {
		$blindup(id);
	}
}

function act_height(id){
	height = $(id).clientHeight;
	if(height == 0){
		height = $(id).offsetHeight;
	}
	return height;
}

function act_width(id){
	width = $(id).clientWidth;
	if(width == 0){
		width = $(id).offsetWidth;
	}
	return width;
}

function max_height(id){
	var ids = $(id).style;
	ids.overflow = "hidden";
	if(act_height(id) != 0){
		return act_height(id);
	} 
	else {
		origdisp  = ids.display;
		origheight = ids.height;
		origpos = ids.position;
		origvis = ids.visibility;
		ids.visibility = "hidden";
		ids.height = "";
		ids.display = "block";
		ids.position = "absolute";
		height = act_height(id);
		ids.display = origdisp;
		ids.height = origheight;
		ids.position = origpos;
		ids.visibility = origvis;
		//alert("taille = " + height)
		return height;
	}
}

function $blindup(id,_2f){
	if(!_2f){
		_2f = 200;
	}
	acth = act_height(id);
	maxh = max_height(id);
	if(acth == maxh){
		$(id).style.display = "block";
		var _30;
		_30=Math.ceil(_2f/acth);
		
		for(i=0 ; i <= acth ; i++){
			newh = acth-i;
			STO("$('" + id + "').style.height = '" + newh + "px'",_30*i);
		}
	}
}

function $blinddown(id,_32){
	if(!_32){
		_32 = 200;
	}
	acth = act_height(id);
	if(acth == 0){
		maxh = max_height(id);
		$(id).style.display = "block";
		$(id).style.height = "0px";
		var _33;
		_33 = Math.ceil(_32/maxh);
		
		for(i=1 ; i <= maxh ; i++){
			STO("$('" + id + "').style.height = '" + i + "px'", _33*i);
		}
	}
}

/**
 * afficheZero : affiche un zero devant les chiffres < 10
 */
function afficheZero(Value) {
  return (Value > 9) ? "" + Value : "0" + Value;
}


/**
 * afficheDate : affiche la date du jour
 */
function afficheDate(){
	AfficheDate = new Date;
	jour = AfficheDate.getDay();
	numJour = afficheZero(AfficheDate.getDate());
	mois = afficheZero(AfficheDate.getMonth()+1);
	annee = AfficheDate.getFullYear();
	
	TabJour = new Array("Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi");
	TabMois = new Array("janvier","f&eacute;vrier","mars","avril","mai","juin","juillet","aout","septembre","octobre","novembre","dé&eacute;embre");
	
	messageDate = numJour + "/" + mois + "/" + annee;
	return messageDate;
}



/**
 * afficheHeure : affiche l'heure en temps réel
 */
function afficheHeure() {
	AfficheDateHeure = new Date;
	h = afficheZero(AfficheDateHeure.getHours());
	m = afficheZero(AfficheDateHeure.getMinutes());
	s = afficheZero(AfficheDateHeure.getSeconds());
	messageHeure = h + ":" + m + ":" + s;
	if(document.getElementById('heure')){
		document.getElementById('heure').innerHTML = messageHeure;
	}
}
setInterval("afficheHeure()", 1000);	/* A ne pas enlever ! */


  function afficheId(baliseId,ongletId,nomImage)
  {
     if (document.getElementById && document.getElementById(baliseId) != null)
    {
    var tag = document.getElementById(baliseId);
    tag.style.visibility='visible';
    tag.style.display='block';
    
  	var ongletLien = document.getElementById(ongletId).getElementsByTagName('a')[0];
   	ongletLien.style.backgroundImage = 'url(images/equipes/onglets/onglet_selectionne_'+nomImage+'.jpg)';
   	ongletLien.onmouseover = function() {};
   	ongletLien.onmouseout = function() {}; 
    }
  }

function cacheId(baliseId,ongletId,nomImage)
  {
  if (document.getElementById && document.getElementById(baliseId) != null)
    {
    var tag = document.getElementById(baliseId);
    tag.style.visibility='hidden';
    tag.style.display='none';
    
    var ongletLien = document.getElementById(ongletId).getElementsByTagName('a')[0];
    ongletLien.style.backgroundImage = 'url(images/equipes/onglets/onglet_rien_'+nomImage+'.jpg)';
  	ongletLien.onmouseout = function() { this.style.background = 'url(images/equipes/onglets/onglet_rien_'+nomImage+'.jpg)';};  	
  	ongletLien.onmouseover = function() { this.style.background = 'url(images/equipes/onglets/onglet_survole_'+nomImage+'.jpg)';};
  	}
  }
 

function afficheEquipe(){
afficheId("equipe","ongletEquipe","equipe");
cacheId("resultatPh1","ongletResultatPh1","ph1");
cacheId("resultatPh2","ongletResultatPh2","ph2");
}

function afficheResultatPh1(){
cacheId("equipe","ongletEquipe","equipe");
afficheId("resultatPh1","ongletResultatPh1","ph1");
cacheId("resultatPh2","ongletResultatPh2","ph2");
}

function afficheResultatPh2(){
cacheId("equipe","ongletEquipe","equipe");
cacheId("resultatPh1","ongletResultatPh1","ph1");
afficheId("resultatPh2","ongletResultatPh2","ph2");
}


preload=function(o,img_src,w,h){
	var img = new Image();
	img.onload=function(){
	o=onload=null;
	if(w)o.width=w;
	if(h)o.height=h;
	o.src=img.src
	};
	img.src=img_src;
}

