// JavaScript Document
//Passage de variable Javascript -> FLASH
function sendToFlash(nom_obj,chemin,prop,val,propriete){
	//proporiete true : prop d'un objet
	var myswf = obj(nom_obj);
	if(is_charge(myswf)){
		if(prop.value!="" && val.value!=""){
			if(propriete){
				myswf.TSetProperty(chemin, prop, val);
			}else{
				myswf.SetVariable("/"+chemin+":"+prop,val)
				//myswf.TGotoFrame("/",1);
			}
		}else{
			alert("Valeur incorrect");
		}
	}
}
function is_charge(objet){
var movie = objet;
	if(movie.PercentLoaded()){ return true; }
	return false;
}
function fTGotoFrame(objet,cible){
var movie = objet;
	if(is_charge(movie)){
		 if(cible=="/"){
		 	movie.TGotoFrame("/",3+precharge);
		 }else{
		 	 movie.TGotoFrame("/",2+precharge);
			 movie.TGotoFrame("/",2);
		 }
	 }
}

//normalisation du target
function setTarget() {
if ( document.getElementsByTagName ) {
var x = document.getElementsByTagName('a');
for ( var i = 0; i < x.length; i++ ) {
if ( x[i].className.indexOf('external') == -1 ) continue;
navigator.appName == 'Microsoft Internet Explorer'
? x[i].setAttribute('onclick', function anonymous() { window.open(this.href);return false; })
: x[i].setAttribute('onclick', 'window.open(this.href);return false;');
}
}
}
if(document.all)
{
 window.attachEvent("onload", setTarget);
}
else
{
 window.addEventListener("load", setTarget, true);
}
function LibJour(ma_date) 
{ 
  texp = ma_date.split('/');
  eri=0;
  jj= texp[0];
  mm = texp[1];
  aa = texp[2];
  if(!aa){eri=1;aa = 2008;}
  ret = LibJourVrai(jj,mm,aa);
  if(eri==1){ ret = ret.replace(/2008/g,''); }
  return ret;
} 
function LibJourVrai(jj,mm,aa) 
{ 
	une_date=jj+'/'+mm+'/'+aa;
	navvers = navigator.appVersion.substring(0,1);
	if (navvers > 3)
	   navok = true;
	else
	   navok = false;
	
	if(une_date=='')
	{
		//Date messagerie
		today = new Date();
	}else{
		mois = une_date.split('/')[1]-1;
		if(mois==-1){ mois = 0; }
		today = new Date(une_date.split('/')[2],mois,une_date.split('/')[0]);
	}
	jour = today.getDay();
	numero = today.getDate();
	if (numero<10)
	   numero = "0"+numero;
	mois = today.getMonth();
	if (navok)
	   annee = today.getFullYear();
	else
	   annee = today.getYear();

	TabJour = new Array("Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi");
	TabMois = new Array("janvier","février","mars","avril","mai","juin","juillet","aout","septembre","octobre","novembre","décembre");
	messageDate = TabJour[jour] + " " + numero + " " + TabMois[mois] + " " + annee;
  return messageDate; 
} 
function ouvrirFermerTr(id){
	handler = document.getElementById(id);
	if(handler.className.indexOf('cacher_tr') != -1 ){
		if(window.getComputedStyle){ // Mozilla Firefox & cie
			handler.className = handler.className.replace("cacher_tr","afficher_tr");
		}else{ // Microsoft Internet Explorer
			handler.className = handler.className.replace("cacher_tr","afficher_tr_ie");
		}
	}else{
		if(handler.className.indexOf('afficher_tr_ie') != -1 ){
			handler.className = handler.className.replace("afficher_tr_ie","cacher_tr");
		}
		if(handler.className.indexOf('afficher_tr') != -1 ){
			handler.className = handler.className.replace("afficher_tr","cacher_tr");
		}
	}
}
//Page indisponible
function nonDispo(){
	alert('Cette page sera bientôt disponible');	
}
//normalisation du target
function setTarget() {
if ( document.getElementsByTagName ) {
var x = document.getElementsByTagName('a');
for ( var i = 0; i < x.length; i++ ) {
if ( x[i].className.indexOf('external') == -1 ) continue;
navigator.appName == 'Microsoft Internet Explorer'
? x[i].setAttribute('onclick', function anonymous() { window.open(this.href);return false; })
: x[i].setAttribute('onclick', 'window.open(this.href);return false;');
}
}
}
if(document.all)
{
 window.attachEvent("onload", setTarget);
}
else
{
 window.addEventListener("load", setTarget, true);
}
/* Enlever click droit */
function disableRightClick(e)
{
	try{
  if(!document.rightClickDisabled)
  {
    if(document.layers) 
    {
      document.captureEvents(Event.MOUSEDOWN);
      document.onmousedown = disableRightClick;
    }
    else document.oncontextmenu = disableRightClick;
    return document.rightClickDisabled = true;
  }
  if(document.layers || (document.getElementById && !document.all))
  {
    if (e.which==2||e.which==3)
    {
      return false;
    }
  }
  else
  {
    return false;
  }
	}catch(ex){}
}
disableRightClick();

/* changement des images du menu */
function menuDyn(){ 
	 for(i = 0; i < document.images.length; ++i)
 	 { 
		if(document.images[i].src.search('/b_')>0){
			//affecter l'image du menu
			document.images[i].style.cursor="pointer";
			document.images[i].onmouseover=function() { this.src= this.src.replace('/b_','/bs_'); };
			document.images[i].onmouseout=function() {  this.src= this.src.replace('/bs_','/b_'); };
			tmpimg= new Image();
			tmpimg.src=document.images[i].src.replace('/b_','/bs_');	
		}
	 }
}
function greatSize(chaine){
	ret = chaine;
	try{
		ret = chaine.substring(0,chaine.length-2);
	}catch(e){}
	return ret;
}
function getStyle(el,styleProp)
{
	if (el.currentStyle)
		var y = el.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(el,null).getPropertyValue(styleProp);
	if(document.all && styleProp== 'height'){ return el.offsetHeight; }else{ 	return y; }
	
}
/* affichage des flashs */

/*****************************************************************************
* BackToTheHtml Command
*///**************************************************************************
function BackToTheHtml(node)
{
	if(node == null)
		this.node = document; 
	else
		this.node = node; 
};
BackToTheHtml.prototype.node = null;

BackToTheHtml.prototype.execute = function()
{
	this.activateObject();
}

BackToTheHtml.prototype.activateObject = function(domObject)
{
	var aDomObject = this.node.getElementsByTagName('object');
	var activationObject;
	for(var i=0; i<aDomObject.length; i++)
		if
		(
			aDomObject[i].getAttributeNode('BackToTheHtml') == null
			&&
			(activationObject = this.getActivationObject(aDomObject[i])) != null
		)
			activationObject.execute();
};

BackToTheHtml.prototype.getActivationObject = function(domObject)
{
	var classid = domObject.classid.toUpperCase().substr('clsid:'.length);
	var mimeType = domObject.type.toLowerCase();

	switch(true)
	{
		case 
			classid == 'D27CDB6E-AE6D-11CF-96B8-444553540000' 
			||
			mimeType == 'application/x-shockwave-flash'
		:
			return new ActivateObjectFlash(domObject);

		default :
			return null;
	}
};

BackToTheHtml.uniqueID = function(prefix)
{
	var sPrefix;
	if(prefix == null)
		sPrefix = 'uniqueId';
	else
		sPrefix = prefix;
		
	var i=0;
	while(document.getElementById(sPrefix + (i++)))
		;
	return sPrefix + (i-1);
};

BackToTheHtml.isParentOf = function(parent,child)
{
	var found = false;
	for(var i=0; i<parent.childNodes.length; i++)
		if(parent.childNodes[i] == child)
			return true;
		else
			found = arguments.callee(parent.childNodes[i],child);

	return found;
}

/*****************************************************************************
* ActivateObject Command
*///**************************************************************************
function ActivateObject(domObject)
{
	this.domObject = domObject;
}

ActivateObject.prototype.domObject = null;
ActivateObject.prototype.classid = null;
ActivateObject.prototype.aHtmlAttribute = ['accessKey','align','alt','archive','border','code','codeBase','codeType','declare','dir','height','hideFocus','hspace','lang','language','name','standby','tabIndex','title','useMap','vspace','width'];
ActivateObject.prototype.aObjectProperty = null;

ActivateObject.prototype.execute = function()
{
	this.xndObjectId = BackToTheHtml.uniqueID();
	this.setTextHtml();
	this.writeObject();

	this.xndObject = document.getElementById(this.xndObjectId);
	this.setSpecialProperties();
	this.removeOriginalObject();
}

ActivateObject.prototype.setTextHtml = function()
{
	var str = '';
	str += '<object BackToTheHtml ' + '\n';
	str += ' classid="clsid:' + this.classid + '" ' + '\n';

	//Add HTML attributes to the <object> tag
	for(var i=0; i<this.aHtmlAttribute.length; i++)
	{
		var name = this.aHtmlAttribute[i];
		if(typeof this.domObject[name] != 'undefined' && this.domObject[name].toString() != '')
			str += '\t' + name + '="' + this.domObject[name].toString() + '" ' + '\n';
	}

	str += 'id="' + this.xndObjectId + '" ' + '\n';
	str += '>';

	for(var i=0; i<this.aObjectProperty.length; i++)
	{
		var name = this.aObjectProperty[i];
		if(typeof this.domObject[name] != 'undefined' && this.domObject[name].toString() != '' )
			str += '\t<param name="' + name + '" value="' + this.domObject[name].toString() + '"></param>' + '\n';
	}
	str += '</object>';

	this.textHtml = str;
};

ActivateObject.prototype.writeObject = function()
{
	this.domObject.insertAdjacentHTML("afterEnd",this.textHtml);
};

ActivateObject.prototype.setSpecialProperties = function()
{
	if(typeof this.domObject.className != 'undefined' && this.domObject.className.toString() != '')
		this.xndObject.className = this.domObject.className

	if(typeof this.domObject.style.cssText != 'undefined' && this.domObject.style.cssText.toString() != '')
		this.xndObject.style.cssText = this.domObject.style.cssText;

	if(typeof this.domObject.SWRemote != 'undefined' && this.domObject.SWRemote.toString() != '')
		this.xndObject.FlashVars = this.domObject.SWRemote;

	if(typeof this.domObject.codebase == 'undefined' || this.domObject.codebase.toString() == '')
		this.xndObject.codebase = 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,24,0';

	if(typeof this.domObject.id != 'undefined' && this.domObject.id.toString() != '')
		this.xndObject.id = this.domObject.id;

};

ActivateObject.prototype.removeOriginalObject = function()
{
	this.domObject.parentNode.removeChild(this.domObject);
};

/*****************************************************************************
* ActivateObjectFlash Command
*///**************************************************************************
function ActivateObjectFlash(domObject)
{
	ActivateObject.call(this,domObject);
}
ActivateObjectFlash.prototype = new ActivateObject;
ActivateObjectFlash.prototype.aObjectProperty = ['FrameNum','Playing','Quality','Quality2','Scalemode','Scale','AlignMode','SAlign','BackgroundColor','BGColor','Loop','Movie','WMode','Base','DeviceFont','EmbedMovie','SWRemote','FlashVars','AllowScriptAccess'];
ActivateObjectFlash.prototype.classid = 'D27CDB6E-AE6D-11CF-96B8-444553540000';


/*****************************************************************************
* Script initialisation
*///**************************************************************************
if(typeof ActiveXObject != 'undefined' && typeof Function.call != 'undefined')
{
	var styleId = BackToTheHtml.uniqueID();
	document.write('<style id="' + styleId + '" ></style>');
	var domStyle = document.getElementById(styleId);

	var isHead = false;
	var aHead = document.getElementsByTagName('head');
	for(var i=0; i<aHead.length; i++)
		if(BackToTheHtml.isParentOf(aHead[i],domStyle))
			isHead = true;

	if(isHead)
	{
		document.write('<style type="text/css">OBJECT{visibility:hidden;}</style>');
		document.onreadystatechange = function()
		{
			if(document.readyState == 'complete')
			{
				new BackToTheHtml().execute();
				document.styleSheets[document.styleSheets.length-1].addRule("OBJECT","visibility:visible;");
				//alert('head');
				//alert(document.body.innerHTML);
			}
		}
	}
	else
	{
		new BackToTheHtml().execute();
		//alert('body');
		//alert(document.body.innerHTML);
	}
	
	domStyle.parentNode.removeChild(domStyle);
}
/* GESTION LISTE TEMPLATE */
function afficherListe(div_template,dataset){
	//dataset est un array multi-dimention de niveau 3    dataset[element[property]]
	html="";
	divliste = document.getElementById(div_template);
	template = divliste.innerHTML;
	for(i=1;i<dataset.length;i++){
		//nouvel élément
		tp=template;
		element = dataset[i];
		for(j=0;j<element.length;j++){
			property = element[j][0];
			value = element[j][1];
			if( property.search('date')!=-1 && value!=""){
				value = LibJour(value);
				if(element[j][1].search('Du ')!=-1) value = "Du "+LibJour(element[j][1].substr(2,element[j][1].length-2));
				if(element[j][1].search('Le ')!=-1) value = "Le "+LibJour(element[j][1].substr(2,element[j][1].length-2));
				if(element[j][1].search('au ')!=-1) value = "au "+LibJour(element[j][1].substr(2,element[j][1].length-2));
			}
			if( property.search('image')!=-1 && value==''){value = 'spacer.gif';}
			reg=new RegExp(property, "g");
			tp = tp.replace(reg,value.replace(/\'/g,"'"));
		}
		if(tp!=template){html+=tp;}
	}
	if(html==""){ html = '<br /><div class="texte-description" style="padding-left:13px;"></div>'; }
	divliste.innerHTML=html;
	divliste.style.visibility="visible";
}
/**/
<!-- DEBUT DE CONTROLE D'EMAIL -->
function checkEmail(emailAddr) {
	// Cette fonction vérifie la bon format d'une adresse e-mail.
	// Comme :
	// user@domain.com ou user.perso@domain.com
	
	var i;
	
	// Recherche de @
	i = emailAddr.indexOf("@");
	if (i == -1) {
		return false;
	}
	
	// Séparation du nom de l'utilisateur et du nom de domaine.
	var username = emailAddr.substring(0, i);
	var domain = emailAddr.substring(i + 1, emailAddr.length)

	// Recherche des espaces au début du nom de l'utilisateur.
	i = 0;
	while ((username.substring(i, i + 1) == " ") && (i < username.length)) {
		i++;
	}
	// Les enleve s'il en trouve.
	if (i > 0) {
		username = username.substring(i, username.length);
	}

	// Recherche d'espaces a la fin du nom de domaine.
	i = domain.length - 1;
	while ((domain.substring(i, i + 1) == " ") && (i >= 0)) {
		i--;
	}
	// Les enleve s'il en trouve.
	if (i < (domain.length - 1)) {
		domain = domain.substring(0, i + 1);
	}

	// Vérifie que le nom de l'utilisateur et du domaine ne soit pas vide.
	if ((username == "") || (domain == "")) {
		return false;
	}
	
	// Vérifie s'il n'y a pas de caracteres interdits dans le nom de l'utilisateur.
	var ch;
	for (i = 0; i < username.length; i++) {
		ch = (username.substring(i, i + 1)).toLowerCase();
		if (!(((ch >= "a") && (ch <= "z")) || 
			((ch >= "0") && (ch <= "9")) ||
			(ch == "_") || (ch == "-") || (ch == "."))) {
				return false;
		}
	}
	
	// Vérifie s'il n'y a pas de caracteres interdits dans le nom de domaine
	for (i = 0; i < domain.length; i++) {
		ch = (domain.substring(i, i + 1)).toLowerCase();
		if (!(((ch >= "a") && (ch <= "z")) || 
			((ch >= "0") && (ch <= "9")) ||
			(ch == "_") || (ch == "-") || (ch == "."))) {
				return false;
		}
	}
var aSuffix = new Array("com","net","int","aero","biz","museum","name","info","coop","pro","eu","edu","org","gov","mil","bj","dz","de","ad","be","ca","bf","bi","cm","cf","cg","cd","ci","dj","fr","ga","gp","gf","lu","mg","ml","ma","mq","mr","mc","nc","pf","re","pm","sn","ch","td","tf","tn");
	var bFoundSuffix = false;
	i = 0;
	while (i < aSuffix.length) {
		if (("." + aSuffix[i]) == domain.substring(domain.length - aSuffix[i].length - 1, domain.length)) {
			return true;
		}
		i++;
	}
	// Si le nom de domaine est inconnu  : return false
	return false;
	
}	
function emailOK(emailAddr) {
	if (!(checkEmail(emailAddr))) {return false;}else{ return true; }
}function obj(i){
	return document.getElementById(i);	
}
function evt(handler,value,envsubmit){
	obj('postback').innerHTML=obj('postback').innerHTML+"<input type='hidden' id='"+handler+"' name='"+handler+"' value='"+value+"'>";
	if(envsubmit){obj('postback').submit();}
}
function erreur(i){
	obj('erreur').innerHTML=obj('erreur').innerHTML+i+"<br/>";
}
function compareDate(pDateDebut,pDateFin) { 
day1 = pDateDebut.substring(0,2);
month1 = pDateDebut.substring(3,5);
year1 = pDateDebut.substring(6,10);
day2 = pDateFin.substring(0,2);
month2 = pDateFin.substring(3,5);
year2 = pDateFin.substring(6,10);

d = new Date(year1, month1-1, day1);
e = new Date(year2, month2-1, day2);
diff = e.getTime()-d.getTime();
var ret=true;
if(diff<0){ ret=false;}
return ret; 
}