var TEXTE_LIB={};TEXTE_LIB['acces_utilisateur']='AccÃ¨s utilisateur';TEXTE_LIB['agenda_messagerie']='Agenda & messagerie';TEXTE_LIB['annuler']='Annuler';TEXTE_LIB['aucune']='Aucune';TEXTE_LIB['champs_requis_vides']='Certains champs requis sont vides. Veuillez les complÃ©ter';TEXTE_LIB['choisir']='Choisir';TEXTE_LIB['connexion']='Connexion';TEXTE_LIB['connexion_agenda']='AccÃ¨s direct Ã  l\'agenda';TEXTE_LIB['connexion_codeuser']='Identifiant';TEXTE_LIB['connexion_en_cours']='Connexion en cours...';TEXTE_LIB['connexion_password']='Mot de passe';TEXTE_LIB['deconnexion']='DÃ©connexion';TEXTE_LIB['document_description']='Description';TEXTE_LIB['document_fichier']='Fichier';TEXTE_LIB['document_modifier']='Modifier';TEXTE_LIB['document_rubrique']='Rubrique du document';TEXTE_LIB['documents']='Documents';TEXTE_LIB['enregistrer']='Enregistrer';TEXTE_LIB['enregistrement_effectue']='Enregistrement effectuÃ©';TEXTE_LIB['enregistrement_en_cours']='Enregistrement en cours...';TEXTE_LIB['lien_ajout']='Ajouter un lien';TEXTE_LIB['lien_commentaire']='Commentaire';TEXTE_LIB['lien_libelle']='Libelle';TEXTE_LIB['lien_lien']='Adresse du lien';TEXTE_LIB['lien_rubrique']='Rubrique du lien';TEXTE_LIB['liens']='Liens prÃ©fÃ©rÃ©s';TEXTE_LIB['logo_fichier']='Image';TEXTE_LIB['logo_modifier']='Modifier mon logo';TEXTE_LIB['logo_supprime']='Supprimer le logo';TEXTE_LIB['mail_attente']='Vos Attentes';TEXTE_LIB['mail_mail']='EMail';TEXTE_LIB['mail_nom']='Nom et sociÃ©tÃ©';TEXTE_LIB['mail_recontact']='Je souhaite Ãªtre recontactÃ© le XX/XX/XX Ã  XXhXX';TEXTE_LIB['mail_tel']='TÃ©lÃ©phone';TEXTE_LIB['metadonnees_text']='Mots ClÃ©s';TEXTE_LIB['metadonnees_check']='Appliquer Ã  toutes les pages';TEXTE_LIB['page_masque']='Cette page est masquÃ©e';TEXTE_LIB['page_metadonnees']='Gestion des Mots ClÃ©s';TEXTE_LIB['page_non_masque']='Cette page n\'est pas masquÃ©e';TEXTE_LIB['pages_options']='Options d\'affichage des pages';TEXTE_LIB['profil_activite']='ActivitÃ©';TEXTE_LIB['profil_civilite']='CivilitÃ©';TEXTE_LIB['profil_email']='eMail';TEXTE_LIB['profil_genre']='Sexe';TEXTE_LIB['profil_modifier']='Modifier le profil';TEXTE_LIB['profil_nom']='Nom';TEXTE_LIB['profil_prenom']='PrÃ©nom';TEXTE_LIB['rubrique_ajout']='Ajouter une rubrique';TEXTE_LIB['rubrique_aucune']='Sans rubrique';TEXTE_LIB['rubrique_modifier']='Modifier la rubrique';TEXTE_LIB['rubrique_nom']='Nom de la rubrique';TEXTE_LIB['rubrique_parente']='Rubrique parente';TEXTE_LIB['rubriques']='Rubriques';TEXTE_LIB['services']='Services';TEXTE_LIB['site_en_construction']='Site en construction';TEXTE_LIB['telecharger']='TÃ©lÃ©charger';TEXTE_LIB['LIB_ALERT']={};TEXTE_LIB['LIB_ALERT']['cocher_lien']='Cochez les liens Ã  supprimer';TEXTE_LIB['LIB_ALERT']['cocher_rubrique']='Cochez les rubriques Ã  supprimer';TEXTE_LIB['LIB_ALERT']['document_encours']='Un document est dÃ©jÃ  en train d\'Ãªtre envoyÃ©. Veuillez attendre que ceci soit terminÃ©.';TEXTE_LIB['LIB_ALERT']['email_invalide']='L\'adresse mail fournie ne semble pas valide. Veuillez la corriger.';TEXTE_LIB['LIB_ALERT']['logo_encours']='Votre logo est dÃ©jÃ  en train d\'Ãªtre envoyÃ©. Veuillez attendre que ceci soit terminÃ©.';TEXTE_LIB['LIB_BT']={};TEXTE_LIB['LIB_BT']['agenda']='Ouvrir la Suite Logicielnet';TEXTE_LIB['LIB_BT']['connexion']='Connexion';TEXTE_LIB['LIB_BT']['contact']='Contact';TEXTE_LIB['LIB_BT']['edition']='Editer le contenu des pages';TEXTE_LIB['LIB_BT']['envoyer']='Envoyer';TEXTE_LIB['LIB_BT']['deconnexion']='Deconnexion';TEXTE_LIB['LIB_BT']['pages']='Options d\'affichage des pages';TEXTE_LIB['LIB_BT']['pages_metadonnees']='Gestion des Mots ClÃ©s';TEXTE_LIB['LIB_BT']['profil']='Modifier mon profil';TEXTE_LIB['LIB_BT']['rubriques']='Rubriques';TEXTE_LIB['LIB_BT']['scrollUp']='DÃ©filer vers le haut';TEXTE_LIB['LIB_BT']['scrollDown']='DÃ©filer vers le bas';TEXTE_LIB['LIB_BT']['webcallback']='Cliquez ici pour Ãªtre mis en relation';TEXTE_LIB['LIB_BT']['webcallback_send']='Envoyer la demande';TEXTE_LIB['LIB_CIVILITE']={};TEXTE_LIB['LIB_CIVILITE']['MME']='Mme';TEXTE_LIB['LIB_CIVILITE']['MLE']='Mlle';TEXTE_LIB['LIB_CIVILITE']['M']='M';TEXTE_LIB['LIB_CIVILITE']['M_MME']='M & Mme';TEXTE_LIB['LIB_CIVILITE']['DR']='Dr';TEXTE_LIB['LIB_CIVILITE']['PR']='Pr';TEXTE_LIB['LIB_CIVILITE']['MTRE']='Maitre';TEXTE_LIB['LIB_CIVILITE']['EFT']='Enfant';TEXTE_LIB['LIB_CIVILITE']['ADO']='Adolescent';TEXTE_LIB['LIB_CIVILITE']['SOC']='SociÃ©tÃ©';TEXTE_LIB['LIB_CIVILITE']['LAB']='Laboratoire';TEXTE_LIB['LIB_CONFIRM']={};TEXTE_LIB['LIB_CONFIRM']['documents_modifier']='Attention, la modification du document entraine la perte de l\'ancien document sauvegardÃ©. Voulez-vous continuer ?';TEXTE_LIB['LIB_CONFIRM']['documents_suppression']='Etes-vous sur de vouloir supprimer tous les documents cochÃ©s ?';TEXTE_LIB['LIB_CONFIRM']['exit']='Voulez-vous vraiment vous dÃ©connecter ?';TEXTE_LIB['LIB_CONFIRM']['liens_suppression']='Etes-vous sur de vouloir supprimer tous les liens cochÃ©s ?';TEXTE_LIB['LIB_CONFIRM']['modifications_non_enregistree_perdue']='Vous allez sortir du mode d\'Ã©dition. Toute modification non enregistrÃ©e sera perdue.Voulez-vous continuer ?';TEXTE_LIB['LIB_CONFIRM']['rubriques_suppression']='Etes-vous sur de vouloir supprimer toutes les rubriques cochÃ©es ?';TEXTE_LIB['LIB_ERROR']={};TEXTE_LIB['LIB_ERROR']['login_mdp']='L\'identifiant que vous avez entrÃ© est incorrect ou ne vous autorise pas Ã  vous connecter Ã  partir de ce site';TEXTE_LIB['LIB_ERROR']['mail_error']='Votre message n\'a pu Ãªtre transmis';TEXTE_LIB['LIB_ERROR']['popup']='Vous devez accepter les popups pour continuer';TEXTE_LIB['LIB_ERROR']['probleme_persistant']='Si le problÃ¨me persiste, contactez le support.';TEXTE_LIB['LIB_ERROR']['telechargement']='Le fichier que vous essayez de tÃ©lÃ©charger n\'est pas pou plus disponible.';TEXTE_LIB['LIB_ERROR']['tel_errone']='Le numÃ©ro de tÃ©lÃ©phone fourni est erronÃ©';TEXTE_LIB['LIB_ERROR']['transfert_fichier']='Echec du transfert de fichier';TEXTE_LIB['LIB_ERROR']['type_fichier']='Le type du fichier sÃ©lectionnÃ© ne correspond pas aux types autorisÃ©s';TEXTE_LIB['LIB_ERROR']['UPLOAD']={};TEXTE_LIB['LIB_ERROR']['UPLOAD'][1]='Le fichier excÃ¨de la taille maximale autorisÃ©e';TEXTE_LIB['LIB_ERROR']['UPLOAD'][2]='Le fichier excÃ¨de la taille maximale autorisÃ©e';TEXTE_LIB['LIB_ERROR']['UPLOAD'][3]='Le transfert du fichier a Ã©tÃ© interrompu';TEXTE_LIB['LIB_ERROR']['UPLOAD'][4]='Aucun fichier n\'a pu Ãªtre tÃ©lÃ©chargÃ©';TEXTE_LIB['LIB_ERROR']['UPLOAD'][6]='Une erreur est survenue lors du transfert de votre fichier.';TEXTE_LIB['LIB_ERROR']['UPLOAD'][7]='Une erreur est survenue lors du transfert de votre fichier.';TEXTE_LIB['LIB_ERROR']['UPLOAD'][8]='Une erreur est survenue lors du transfert de votre fichier.';TEXTE_LIB['LIB_GENRE']={};TEXTE_LIB['LIB_GENRE']['H']='Homme';TEXTE_LIB['LIB_GENRE']['F']='Femme';TEXTE_LIB['LIB_MAILS']={};TEXTE_LIB['LIB_MAILS']['accuse_reception_sujet']='[Contact] AccusÃ© de rÃ©ception';TEXTE_LIB['LIB_MAILS']['accuse_reception_message']='Bonjour,<p>Nous vous confirmons la bonne rÃ©ception du message suivant. Nous vous souhaitons de passer une excellente journÃ©e.</p>';TEXTE_LIB['LIB_MAILS']['envoi_en_cours']='Envoi en cours...';TEXTE_LIB['LIB_MAILS']['envoi_ok']='Votre message a Ã©tÃ© transmis. Nous vous souhaitons une agrÃ©able journÃ©e';TEXTE_LIB['LIB_MAILS']['nouveau_message_message']='Bonjour,<p>Vous avez reÃ§u un nouveau message.</p>';TEXTE_LIB['LIB_MAILS']['nouveau_message_sujet']='[Contact] Nouveau message';TEXTE_LIB['LIB_MAILS']['provenance']='Provenance';TEXTE_LIB['LIB_WEBCALLBACK']={};TEXTE_LIB['LIB_WEBCALLBACK']['NOM']='Votre nom';TEXTE_LIB['LIB_WEBCALLBACK']['PRENOM']='Votre prenom';TEXTE_LIB['LIB_WEBCALLBACK']['RAISON_SOCIALE']='Votre sociÃ©tÃ©';TEXTE_LIB['LIB_WEBCALLBACK']['FAX']='Votre fax';TEXTE_LIB['LIB_WEBCALLBACK']['EMAIL']='Votre adresse email';TEXTE_LIB['LIB_WEBCALLBACK']['ADRESSE']='Vodre adresse';TEXTE_LIB['LIB_WEBCALLBACK']['CODE_POSTAL']='Votre code postal';TEXTE_LIB['LIB_WEBCALLBACK']['VILLE']='Votre ville';TEXTE_LIB['LIB_WEBCALLBACK']['SITE_WEB']='Votre site web';TEXTE_LIB['LIB_WEBCALLBACK']['TELEPHONE']='Votre tÃ©lÃ©phone';TEXTE_LIB['LIB_WEBCALLBACK']['FONCTION']='Votre fonction';TEXTE_LIB['LIB_XHR_MESSAGE']={};TEXTE_LIB['LIB_XHR_MESSAGE']['CNX_LOST']='Vous n\'Ãªtes pas connectÃ© ou avez perdu la connexion. Veuillez vous reconnecter pour effectuer cette action.';var IMAGE_LIB={};IMAGE_LIB['add']='/style/orangecyan/images/plus_s.png';IMAGE_LIB['close']='/style/orangecyan/images/croix_s.png';IMAGE_LIB['barre_boutons']='/style/orangecyan/images/barredroite.png';IMAGE_LIB['default_logo']='/style/orangecyan/images/votre_logo.png';IMAGE_LIB['expand']='/style/orangecyan/images/flechedroite_s.png';IMAGE_LIB['expanded']='/style/orangecyan/images/flechebas_s.png';IMAGE_LIB['fond_input']='/style/orangecyan/images/fond_input.png';IMAGE_LIB['loader16']='/style/orangecyan/images/loader16.gif';IMAGE_LIB['loader32']='/style/orangecyan/images/loader32.gif';IMAGE_LIB['menu_fleche']='/style/orangecyan/images/flechedroite.png';IMAGE_LIB['menu_fleche_s']='/style/orangecyan/images/flechedroite_s.png';IMAGE_LIB['menu_fleche_bas']='/style/orangecyan/images/flechebas.png';IMAGE_LIB['page_masque']='/style/orangecyan/images/rond_vide_s.png';IMAGE_LIB['page_non_masque']='/style/orangecyan/images/oeil_s.png';IMAGE_LIB['rmv']='/style/orangecyan/images/moins_s.png';IMAGE_LIB['save']='/style/orangecyan/images/save.png';IMAGE_LIB['ss_menu_background']='/style/orangecyan/images/degrade_gd.png';IMAGE_LIB['LIB_BT']={};IMAGE_LIB['LIB_BT']['agenda']='/style/orangecyan/images/agenda.png';IMAGE_LIB['LIB_BT']['connexion']='/style/orangecyan/images/log_g.png';IMAGE_LIB['LIB_BT']['contact']='/style/orangecyan/images/enveloppe_g.png';IMAGE_LIB['LIB_BT']['edition']='/style/orangecyan/images/crayon.png';IMAGE_LIB['LIB_BT']['envoyer']='/style/orangecyan/images/envoyer.png';IMAGE_LIB['LIB_BT']['deconnexion']='/style/orangecyan/images/croix_g.png';IMAGE_LIB['LIB_BT']['pages']='/style/orangecyan/images/oeil.png';IMAGE_LIB['LIB_BT']['pages_metadonnees']='/style/orangecyan/images/clef.png';IMAGE_LIB['LIB_BT']['profil']='/style/orangecyan/images/bonhomme.png';IMAGE_LIB['LIB_BT']['rubriques']='/style/orangecyan/images/etoile.png';IMAGE_LIB['LIB_BT']['scrollUp']='/style/orangecyan/images/flechehaut_g.png';IMAGE_LIB['LIB_BT']['scrollDown']='/style/orangecyan/images/flechebas_g.png';IMAGE_LIB['LIB_BT']['webcallback']='/style/orangecyan/images/misenrelation.png';IMAGE_LIB['LIB_BT']['webcallback_send']='/style/orangecyan/images/misenrelation2.png';IMAGE_LIB['LIB_DOCS']={};IMAGE_LIB['LIB_DOCS']['DEFAULT']='/style/orangecyan/images/iconeautre.png';IMAGE_LIB['LIB_DOCS']['doc']='/style/orangecyan/images/iconeword.png';IMAGE_LIB['LIB_DOCS']['pdf']='/style/orangecyan/images/iconepdf.png';IMAGE_LIB['LIB_DOCS']['ppt']='/style/orangecyan/images/iconeppoint.png';IMAGE_LIB['LIB_DOCS']['xls']='/style/orangecyan/images/iconeexcell.png';/**
 * @author Laurent Thoulon
 * @version 1.0 [LT]	06/05/2008	Version initiale
 * @version 1.1 [LT]	27/08/2008	Ajout de la fonction in_array
 * @version 1.2 [LT]	25/09/2008	Ajout de nombreuses ffonctions : Utils.$, Utils.Cookie, Utils.DOM.getElementsByClass,Utils.DOM.insertAfter
 * @version 1.2b [LT]   16/10/2008	Modifications mineures
 * @version 1.3 [LT]	30/01/2009	Ajout de Utils.DOM.getElementsByTagNames et de Utils.Window
 * @version 1.4 [LT]	12/05/2009	Ajout de Utils.Form.defaultOnEmpty et de Utils.Form.emptyOnDefault
 * @version 1.5 [LT]	22/05/2009	Ajout de Utils.getExtension
 * @version 1.6 [LT]	17/06/2009	Ajout de Utils.is_int
 * @version 1.7 [HD]    25/06/2009  Ajout de Utilis.addslashes
 * @version 1.71 [LT][2009-10-12] Suppression de "for(... in ...)" sur des array
 * @version 1.72 [LT][2009-11-03] Suppression de "for(... in ...)" supplementaires
 * @version 1.73 [LT][2009-11-05] Transformation d'array associatives en object
 * @version 1.74 [LT][2009-11-05] Modifications de Form.getElements : on recupere meme les champs vides
 */

/**
 * STATIC CLASS Utils
 * Librairie offrant un certain nombre de fonctions
 * Sub-librairies :
 *  Utils.Array
 *  Utils.Cookie
 *  Utils.DOM
 *  Utils.String
 *  Utils.Window
 */

/***************/
/**** UTILS ****/
/***************/
var Utils = {
	/**
	 * Renvois tous les elements dont leur ID a ete donne en parametre
	 */
	$ : function() {
		var elements = [];
		for (var i = 0; i < arguments.length; i++) {
			var element = arguments[i];
			if (typeof element == 'string')
				element = document.getElementById(element);
			if (arguments.length == 1)
				return element;
			elements.push(element);
		}
		return elements;
	},

	/**
	 * DEPRECATED : utiliser Utils.Form.getElements(oFrm);
	 */
	getFormInfo : function(oFrm) {
		return Utils.Form.getElements(oFrm);
	},

	/**
	 * Recupere l'extension d'un nom de fichier
	 */
	getExtension : function(sFile) {
		var iExtPos = sFile.lastIndexOf('.') + 1;
		if(iExtPos != 0 && iExtPos != sFile.length) {
			return sFile.substr(iExtPos);
		}
		return false;
	},

	/**
	 * Indique si la variable envoyee est un entier
	 */
	is_int : function(vVar) {
	    if (isNaN(vVar)) {
	        return false;
	    }
	    if (parseFloat(vVar) != parseInt(vVar, 10)) {
	        return false;
	    }
	    return true;
	},

	/**
	 * Defini si un element est initialise
	 */
	isset : function(vVar) {
		return (vVar !== undefined && vVar !== null && vVar !== 'null' && vVar !== 'NULL' && vVar !== 'undefined');
	},

	/**
	 * Recharge la page avec les parametres courants
	 */
	recharge_page : function() {
		var query = window.location.search.substring(1);
		window.location.href = window.location.pathname + (query ? "?" + query : "");
	},

	replaceSpecialChars : function (string) { //BAD : should think of something else
		string = string.replace(/&/g,"**am**");
		string = string.replace(/=/g,"**eq**");
		string = string.replace(/\+/g,"**pl**");
		return string;
	},

	/**
	 * Fonctions de serialization type PHP
	 * info : http://www.xorax.info/blog/programmation/40-javascript-serialize-php.html
	 * version : 1.2 - 2007/04/23
	 *
	 * ChangeLog:
	 * ----------
	 * 1.2 : ajout du support pour la serialization d'Object php (case "O") + maj de la page de test
	 * 1.1 : fix bug dans unserialize sur boolean
	 *
	 * Description:
	 * ------------
	 * permet de decoder la chaine revoye par la fonction serialize php.
	 * ne prend pas (encore?) en compte les objects.
	 */
	serialize : function(txt) {
		switch(typeof(txt)){
			case 'string':
				return 's:'+txt.length+':"'+txt+'";';
			case 'number':
				if(txt>=0 && String(txt).indexOf('.') == -1 && txt < 65536) return 'i:'+txt+';';
				return 'd:'+txt+';';
			case 'boolean':
				return 'b:'+((txt)?'1':'0')+';';
			case 'object':
				var i=0,k,ret='';
				if(txt instanceof Array) {
					for(k=0;k<txt.length;k++){
						if(!isNaN(k)) k = Number(k);
						ret += Utils.serialize(k)+Utils.serialize(txt[k]);
						i++;
					}
				}
				else {
					for(k in txt){
						if(!isNaN(k)) k = Number(k);
						ret += Utils.serialize(k)+Utils.serialize(txt[k]);
						i++;
					}
				}
				return 'a:'+i+':{'+ret+'}';
			default:
				return 'N;';
				alert('var undefined: '+typeof(txt));return undefined;
		}
	},


	/**
	 * Envoi un ID unique a chaque appel
	 */
	uid : (function(){
		var id=0;
		return function(){
			return id++ ;
		};
	})(),

	/**
	 * Ajoute des backslashes
	 */
	addslashes : function( str){
		 return (str+'').replace(/([\\"'])/g, "\\$1").replace(/\0/g, "\\0");
	},
	unserialize : function(txt){
		var level=0,arrlen=[],del=0,fin=[],key=[],save=txt,ret;
		while(1){
			switch(txt.substr(0,1)){
				case 'N':
					del = 2;
					ret = null;
					break;
				case 'b':
					del = txt.indexOf(';')+1;
					ret = (txt.substring(2,del-1) == '1')?true:false;
					break;
				case 'i':
					del = txt.indexOf(';')+1;
					ret = Number(txt.substring(2,del-1));
					break;
				case 'd':
					del = txt.indexOf(';')+1;
					ret = Number(txt.substring(2,del-1));
					break;
				case 's':
					del = txt.substr(2,txt.substr(2).indexOf(':'));
					ret = txt.substr(1+txt.indexOf('"'),del);
					del = txt.indexOf('"')+ 1 + ret.length + 2;
					break;
				case 'a':
					del = txt.indexOf(':{')+2;
					ret = [];
					arrlen[level+1] = Number(txt.substring(txt.indexOf(':')+1, del-2))*2;
					break;
				case 'O':
					txt = txt.substr(2);
					var tmp = txt.indexOf(':"')+2;
					var nlen = Number(txt.substring(0, txt.indexOf(':')));
					name = txt.substring(tmp, tmp+nlen);
					//alert(name);
					txt = txt.substring(tmp+nlen+2);
					del = txt.indexOf(':{')+2;
					ret = new Object();
					arrlen[level+1] = Number(txt.substring(0, del-2))*2;
					break;
				case '}':
					txt = txt.substr(1);
					if(arrlen[level] != 0){alert('var missed : '+save); return undefined;};
					//alert(arrlen[level]);
					level--;
					continue;
				default:
					if(level==0) return fin;
					alert("syntax invalid(1) :\n"+save+"\nat\n"+txt+"\nlevel is at "+level);
					return undefined;
			}
			if(arrlen[level]%2 == 0){
				if(typeof(ret) == 'object'){alert('array index object no accepted : '+save);return undefined;}
				if(ret == undefined){alert('syntax invalid(2) : '+save);return undefined;}
				key[level] = ret;
			} else {
				var ev = '';
				for(var i=1;i<=level;i++){
					if(typeof(key[i]) == 'number'){
						ev += '['+key[i]+']';
					}else{
						ev += '["'+key[i]+'"]';
					}
				}
				eval('fin'+ev+'= ret;');
			}
			arrlen[level]--;//alert(arrlen[level]-1);
			if(typeof(ret) == 'object') level++;
			txt = txt.substr(del);
			continue;
		}
	},

	/**
	 * UTILS.ARRAY
	 */
	Array : {
		/**
		 * Recherche un element dans un objet Array
		 * @param needle l'element recherche
		 * @param haystack l'objet Array dans lequel on fait la recherche
		 * @return Le premier index rencontre auquel se situe l'element, false le cas echeant
		 */
		array_search : function(needle,haystack){
			var i;
			if(haystack instanceof Array) {
				for(i=0; i<haystack.length;i++){
					if(haystack[i]==needle) return i;
				}
			}
			else {
				for(i in haystack){
					if(haystack[i]==needle) return i;
				}
			}
			return false;
		},
		/**
		 * Recherche un element dans un objet Array en parcourant aussi les tableaux imbriques
		 * @param needle l'element recherche
		 * @param haystack l'objet Array dans lequel on fait la recherche
		 * @return Un tableau contenant la suite d'indexs menant au premier objet rencontre correspondanta needle
		 */
		array_search_deep : function(needle,haystack, indexs){
			if(!Utils.isset(indexs)) indexs = [];
			for(var k=0; k<haystack.length;k++){
				var tmpIndexs = indexs;
				tmpIndexs.push(k);
				if(needle == haystack[k]) return tmpIndexs;
				if(haystack[k] instanceof Array) {
					tmpIndexs = Utils.Array.array_search_deep(needle, haystack[k], tmpIndexs);
					if(tmpIndexs !== false) return tmpIndexs;
				}
			}
			return false;
		},
		/**
		 * Indique si un element est dans l'objet Array
		 * @param needle l'element recherche
		 * @param haystack l'objet Array dans lequel on fait la recherche
		 * @return Booleen
		 */
		in_array : function(needle,haystack){
			var i;
			if(haystack instanceof Array) {
				for(i=0; i<haystack.length;i++){
					if(haystack[i]==needle) return true;
				}
			}
			else {
				for(i in haystack){
					if(haystack[i]==needle) return true;
				}
			}
			return false;
		}
	},
	/**
	 * UTILS.COOKIE
	 */
	Cookie : {
		get : function(name) {
			var start = document.cookie.indexOf(name + "=");
			var len = start + name.length + 1;
			if((!start) && (name != document.cookie.substring(0, name.length)))
				return null;
			if(start == -1) return null;
			var end = document.cookie.indexOf(';', len);
			if(end == -1) end = document.cookie.length;
			return unescape(document.cookie.substring(len, end));
		},
		set : function(name, value, expires, path, domain, secure) {
			var today = new Date();
			today.setTime(today.getTime());
			if(expires)
				expires = expires * 1000 * 60 * 60 * 24;
			var expires_date = new Date(today.getTime() + (expires));
			document.cookie = name + '=' + escape(value) +
				((expires) ? ';expires='+expires_date.toGMTString() : '') + //expires.toGMTString()
				((path) ? ';path=' + path : '') +
				((domain) ? ';domain=' + domain : '') +
				((secure) ? ';secure' : '');
		},
		del : function(name, path, domain) {
			if (Utils.Cookie.get(name))
				document.cookie = name + '=' + ((path) ? ';path=' + path : '') + ((domain) ? ';domain=' + domain : '') + ';expires=Thu, 01-Jan-1970 00:00:01 GMT';
		}
	},
	/**
	 * UTILS.DOM
	 */
	DOM : {
		insertAfter : function(parent, node, referenceNode) {
			parent.insertBefore(node, referenceNode.nextSibling);
		},

		getElementsByTagNames : function(list,obj) {
			if (!obj) obj = document;
			var tagNames = list.split(',');
			var resultArray = [];
			for (var i=0;i<tagNames.length;i++) {
				var tags = obj.getElementsByTagName(tagNames[i]);
				for (var j=0;j<tags.length;j++) {
					resultArray.push(tags[j]);
				}
			}
			var testNode = resultArray[0];
			if (!testNode) return [];
			if (testNode.sourceIndex) {
				resultArray.sort(function (a,b) {
						return a.sourceIndex - b.sourceIndex;
				});
			}
			else if (testNode.compareDocumentPosition) {
				resultArray.sort(function (a,b) {
						return 3 - (a.compareDocumentPosition(b) & 6);
				});
			}
			return resultArray;
		},


		/**
		 * @param searchClass La classe que l'on recherche
		 * @param node Le noeud a partir duquel on desire chercher les elements. Si vide : document
		 * @param tag Le tagName auquel on veut restreindre la recherche. Par defaut * (tous)
		 */
		getElementsByClass : function(searchClass,node,tag) {
			var classElements = [];
			if ( node == null )
				node = document;
			if ( tag == null )
				tag = '*';
			var els = node.getElementsByTagName(tag);
			var elsLen = els.length;
			var pattern = new RegExp('(^|\\\\s)'+searchClass+'(\\\\s|$)');
			for (var i=0, j=0; i < elsLen; i++) {
				if ( pattern.test(els[i].className) ) {
					classElements[j] = els[i];
					j++;
				}
			}
			return classElements;
		},

		/**
		 * Recupere tous les descendants rencontres respectant la condition element.thing = thingValue
		 * @param element l'element duquel on part
		 * @param thingValue la valeur de thing
		 * @param thing l'attribut de l'element que l'on veut tester
		 * @param limit la nombre maximum de resultats que l'on veut
		 * @prama node ne pas prendre en compte, utilise par la fonction pour enregistrer les resultats
		 */
		getDescendentsByThing : function(element, thingValue, thing, limit, node) {
			if(!Utils.isset(limit)) limit=0;
			if(!Utils.isset(node)) node = [];
			element = Utils.$(element);
			for(var i=0;i<element.childNodes.length;i++){
				var size = node.length;
				if(element.childNodes[i][thing]){
					switch(thing) {
						case 'className':
							var classes = element.childNodes[i][thing].split(' ');
							if(Utils.Array.array_search(thingValue,classes) !== false) node.push(element.childNodes[i]);
							break;
						default :
							if(element.childNodes[i][thing].toLowerCase() == thingValue.toLowerCase()) node.push(element.childNodes[i]);
							break;
					}
				}
				if(size == node.length) {//si on n'a pas trouve d'element
					Utils.DOM.getDescendentsByThing(element.childNodes[i], thingValue, thing, limit, node);
				}
				if(limit != 0 && node.length >= limit) break;
			}
			return ((limit==1) ? node[0] : node);
		},

		/**
		 * Recupere tous les parents rencontres  respectant la condition element[thing] = thingValue
		 * @param element l'element duquel on part
		 * @param thingValue la valeur de thing
		 * @param thing l'attribut de l'element que l'on veut tester
		 * @param limit la nombre maximum de resultats que l'on veut
		 */
		getParentsByThing : function(element, thingValue, thing, limit) {
			if(!Utils.isset(limit)) limit=0;
			element = Utils.$(element);
			var node = [];
			element = element.parentNode;
			while(element.nodeName.toLowerCase() != 'html') {
				if(element[thing]) {
					switch(thing) {
						case 'className':
							var classes = element[thing].split(' ');
							if(Utils.Array.array_search(thingValue,classes) !== false) node.push(element);
							break;
						default :
							if(element[thing] == thingValue) node.push(element);
							break;
					}
				}
				if(limit != 0 && node.length >= limit) break;
				element = element.parentNode;
			}
			return ((limit==1) ? node[0] : node);
		},

		/**
		 * Parcours vers la gauche des noeuds freres a la recherche de ceux respectant la condition element[thing] = thingValue
		 * @param element l'element duquel on part
		 * @param thingValue la valeur de thing
		 * @param thing l'attribut de l'element que l'on veut tester
		 * @param limit la nombre maximum de resultats que l'on veut
		 */
		getPreviousSiblingByThing : function(element, thingValue, thing, limit) {
			if(!Utils.isset(limit)) limit=0;
			element = Utils.$(element);
			var node = [];
			element = element.previousSibling;
			while(element) {
				if(element[thing]) {
					switch(thing) {
						case 'className':
							var classes = element[thing].split(' ');
							if(Utils.Array.array_search(thingValue,classes) !== false) {node.push(element);}
							break;
						default :
							if(element[thing] == thingValue) node.push(element);
							break;
					}
				}
				if(limit != 0 && node.length >= limit) break;
				element = element.previousSibling;
			}
			return ((limit==1) ? node[0] : node);
		},

		/**
		 * Parcours vers la droite des noeuds freres a la recherche de ceux respectant la condition element[thing] = thingValue
		 * @param element l'element duquel on part
		 * @param thingValue la valeur de thing
		 * @param thing l'attribut de l'element que l'on veut tester
		 * @param limit la nombre maximum de resultats que l'on veut
		 * @prama node ne pas prendre en compte, utilise par la fonction pour enregistrer les resultats
		 */
		getNextSiblingByThing : function(element, thingValue, thing, limit) {
			if(!Utils.isset(limit)) limit=0;
			element = Utils.$(element);
			var node = [];
			element = element.nextSibling;
			while(element) {
				if(element[thing]) {
					switch(thing) {
						case 'className':
							var classes = element[thing].split(' ');
							if(Utils.Array.array_search(thingValue,classes) !== false) {node.push(element);}
							break;
						default :
							if(element[thing] == thingValue) node.push(element);
							break;
					}
				}
				if(limit != 0 && node.length >= limit) break;
				element = element.nextSibling;
			}
			return ((limit==1) ? node[0] : node);
		}
	},

	Form : {

		/**
		 * utilise pour remplir un champs avec la valeur par defaut lorsqu'il est vide
		 * @param oInput l'element en question
		 * @param bCanBeEmpty defini si l'element a le droit d'etre vide ou non
		 * @param sDefaultValue la valeur par defaut de l'element lorsque celui ci peut etre vide
		 *
		 * Par exemple un element "Nom" qui serait deja rempli lors du chargement avec "Dupont" mais ayant le droit d'etre vide aurait dans "onblur" cette fonction avec comme parametre (element,true,"Nom")
		 * Dans ce cas, des que l'on supprime le nom "Dupont" et que l'on quitte le champs, le texte "Nom" remplace "Dupont"
		 */
		defaultOnEmpty : function(oInput, bCanBeEmpty, sDefaultValue) {
			oInput.value = Utils.String.trim(oInput.value);
			if(oInput.value == "") {
				if(!bCanBeEmpty) oInput.value=oInput.defaultValue;
				else oInput.value = sDefaultValue ? sDefaultValue : "";
			}
		},

		/**
		 * Utilise pour vider un champs lorsqu'il contient la valeur par defaut (generalement dans le onfocus)
		 * @param oInput l'element en question
		 * @param sDefaultValue La valeur par defaut consideree (si vide on prend la valeur par defaut de l'element)
		 */
		emptyOnDefault : function(oInput, sDefaultValue) {
			if(!sDefaultValue) sDefaultValue = oInput.defaultValue;
			if(oInput.value == sDefaultValue) oInput.value="";
		},

		getEle : function(oFrm,sEleName) {
			for(var i=0;i < oFrm.elements.length;i++) {
				if(oFrm.elements[i].name == sEleName) return oFrm.elements[i];
			}
			return false;
		},

		getEleInd : function(oFrm,sEleName) {
			for(var i=0;i < oFrm.elements.length;i++) {
				if(oFrm.elements[i].name == sEleName) return i;
			}
			return false;
		},

		/**
		 * Renvois les informations du fomulaire sous la forme d'un tableau
		 * @param oFrm l'id, le nom du formulaire ou le formulaire lui-meme
		 */
		getElements : function(oFrm) {
			if(typeof oFrm == 'string') oFrm = Utils.$(oFrm) ? Utils.$(oFrm):document.forms[oFrm];
			if(!Utils.isset(oFrm)) return false;
			var aElements = [];
			//On recupere tous les elements du formulaire
			if(oFrm.elements) {
				for(var i = 0; i<oFrm.elements.length; i++) {
					aElements.push(oFrm.elements[i]);//on les stocks dans un tableau
				}
			}

			if(aElements.length == 0) {//si le tableau est vide : erreur
				//alert('Erreur, aucune donnees de trouvees');
				return false;
			}
			//Creation du tableau de variables
			var aVariables = [];

			for(var i=0 ; i<aElements.length ; i++){//On recupere le nom et la valeur pour les tocker dans un tableau
				if(aElements[i].name){
					var aElement = {};
					switch(aElements[i].type.toLowerCase()) {
						case 'radio':
						case 'checkbox':
							if(aElements[i].checked) {
								aElement['nom'] = aElements[i].name;
								aElement['val'] = aElements[i].value;
								aVariables.push(aElement);
							}
							break;
						case 'select-multiple':
							for(var indSel=0; indSel < aElements[i].options.length; indSel++) {
								if(aElements[i].options[indSel].selected) {
									aElement = {};
									aElement['nom'] = aElements[i].name+'[]';
									aElement['val'] = aElements[i].options[indSel].value;
									aVariables.push(aElement);
								}
							}
							break;
						default:
							aElement['nom'] = aElements[i].name;
							aElement['val'] = aElements[i].value;
							aVariables.push(aElement);
							break;
					}
				}
			}

			return aVariables;
		},

		/**
		 * permet de definir une valeur comme selectionnee.
		 * Ne prends en charge que les select actuellement.
		 */
		selectedValues : function(oInput, oValues) {
			oInput = Utils.$(oInput);
			for(var i = 0; i < oInput.options.length; i++) {
				if(oInput.options[i].value == oValues) oInput.selectedIndex = i;
			}
		}
	},

	/**
	 * UTILS.STRING
	 */
	String : {

		str_repeat : function(sString, iMultiplier ) {
			return new Array(iMultiplier+1).join(sString);
		},

		/**
		 * Supprime les espaces au debut et a la fin d'une chaine
		 */
		trim : function(myString) {
			return myString.replace(/^\s+/g,'').replace(/\s+$/g,'')
		},
		/**
		 * met la premiere lettre en majuscule
		 */
		ucfirst : function(myString) {
			var first = myString.charAt(0).toUpperCase();
			return first + myString.substr(1, myString.length-1);
		}

	},
	/**
	 * UTILS.WINDOW
	 */
	Window : {
		/**
		 * Permet de savoir si une fenetre a ete ouverte ou pas (utilise pour les bloqueurs de pop up)
		 * Ne marche pas avec Chrome
		 */
		isOpened : function(oWindow) {
			try {
				if ( oWindow == null || oWindow.closed || typeof oWindow.closed == 'undefined' )
					return false;
				if ( window.opera )
					if (!oWindow.opera)
						return false;
			} catch(err){
				return false;
			}
			return true;
		},

		/**
		 * Permet de recuperer une variable GET dans l'url
		 * @params name (string) le nom de la variable
		 */
		get : function(name) {
			var params = window.location.search.substring(1).split('#');
			if(params[0] != '') params = params[0].split('&');
			for(var i=0; i<params.length; i++) {
				var getVar = params[i].split('=');
				if(getVar[0] == name) return Utils.isset(getVar[1]) ? getVar[1]:true;
			}
			return undefined;
		},

		/**
		 * Recharge la fenetre en modifiant les parametres get
		 * @param add (string) la liste des parametres a ajouter ou a modifier, separes par un ;
		 * @param remove (string) la liste des parametres a retirer, separes par un ;
		 */
		reload : function(add, remove) {
			var newParams = {};
			if(add) {
				add = add.split(';');
				for(var i=0;i<add.length;i++) {
					var addVar = add[i].split('=');
					if(!Utils.isset(addVar[1])) addVar[1] = true;
					newParams[addVar[0]] = addVar[1];
				}
				add = newParams;
			}
			else add = {};

			if(remove) remove = remove.split(';');
			else remove = [];

			var params = window.location.search.substring(1).split('#');
			var anchor = Utils.isset(params[1]) ? '#'+params[1] : '';
			if(params[0] != '') params = params[0].split('&');
			else params = [];

			for(i=0;i<params.length;i++) {
				var getVar = params[i].split('=');
				if(Utils.Array.in_array(getVar[0],remove) || Utils.isset(add[getVar[0]])) continue;
				if(!Utils.isset(getVar[1])) getVar[1] = true;
				newParams[getVar[0]] = getVar[1];
			}

			params = '';
			for(i in newParams) {
				params += '&'+i+(newParams[i] === true ? '':'='+newParams[i]);
			}
			params = params.substr(1) + anchor;
			window.location.href = window.location.pathname + (params != '' ? '?'+params:'');
		}
	}
};/**
 * @author Laurent Thoulon
 * @version 1.0 [LT] Version initiale
 * @date 05/02/2008
 */

/**
 * Classe permettant de gerer une liste d'elements
 */
function ObjectList() {
    this.list = {};

    this.add = function(ident, obj) {
        this.list[ident] = obj;
    }

    this.get = function(ident) {
        return this.list[ident];
    }

    this.remove = function(ident) {
        delete this.list[ident];
    }

    this.exists = function(ident) {
        if(this.list[ident] != undefined && this.list[ident] != 'undefined')
            return true;
        return false;
    }
}

/**
 * Classe CallbackList
 */
function CallbackList() {
	this.list = {};

	this.add = function(ident, callback, args) {
		this.list[ident] = {};
		this.list[ident]['func'] = callback;
		this.list[ident]['args'] = args;
	}

	this.send = function(ident) {
		var func = this.list[ident]['func'];
		var args = this.list[ident]['args'];
		if(typeof func == 'string') {
			eval(func);
		}
		else func(args);
	}
}

//On declare une instance de l'objet.
var objectList = new ObjectList();/**
 * @author Laurent Thoulon
 * @version 1.0 [LT]			Version initiale
 * @version 1.1 [LT]			Integration des Fonctions externes a l'interieur de la classe
 *					  			Ajout de la methode center() qui permet de centrer l'objet
 *					  			Simplification de la methode setStyle
 *					  			Amelioration des methodes getWinWidth et getWinHeight
 * @version 1.2 [LT]			Ajout de la fonction setObject() pour permettre l'acces aux elements sans ID
 * @version 1.3 [LT] 22/08/2008	Ajout de la fonction appendText() pour inserer un noeud text
 * @version 1.4 [LT] 04/02/2009	Ajout des fonctions getObject(), resize() et resizeByStep(), adjustMinHeightTo()
 *								Correction de width() et height() afin de prendre en compte la bordure
 *								Correction de getStyle(), partie firefox, ne marchait pas toujours
 *								Correction de move() pour un X et un Y avec la valeur 0
 */

/**
 * CLASS HtmlObject
 * Classe objet permettant d'acceder a ses attributs facilement.
 * Note : all elements used by the class should be added to the objects list this way :
 * var foo = new HtmlObject('foo');
 * objectList.add('foo',foo);
 *
 * @param objName Le nom permettant d'identifier l'objet HtmlObject
 */
function HtmlObject(objName) {
	this.callbacks = new CallbackList();
	this.objId;
	this.obj;
	this.objName = objName ? objName : 'ho_'+Utils.uid();
	//nom de la variable objet ObjectList
	this.objListName = 'objectList'; //a configurer si cela change
	window.objectList.add(this.objName,this); //ajout de l'objet a la liste d'objets

	this.setId = function(newId) {
		this.objId = newId;
		return this.setObject(Utils.$(newId));
	}

	this.setObject = function(object) {
		if(object) {
			this.obj = object;
			return true;
		}
		return false;
	}

	this.getObject = function() {
		return this.obj;
	}
	
	/**
	 * @param (string, multiple) Prends autant de string en parametre que de methodes que l'on veut appeler.
	 * @return (string) Le code a evaluer pour appeler toutes les fonctions a la suite OU le code permettant d'ecceder a l'objet si aucun parametre n'est donne
	 */
	this.absThis = function() {
		var absThis = this.objListName+".get('"+this.objName+"')";
		if(arguments.length > 0) {
			var fullAbsThis = '';
			for (var i=0; i<arguments.length; ++i) {
				fullAbsThis += absThis+'.'+arguments[i]+';';
			}
			return fullAbsThis;
		}
		return absThis;
	}

	//Cre l'objet avec le tagName defini, l'id mentionne et les attributs envoyes dans un tableau associatif att => val
	this.createObject = function(tagName, id, atts) {
		this.obj = document.createElement(tagName);
		this.obj.id = id;
		for(var att in atts) {
			this.obj[att] = atts[att];
		}
	}

	//checks if the object was found
	this.check = function() {
		if(!this.obj) {
			if(this.objId)
				alert("HtmlObject Error : Object '"+this.objId+"' could not be found");
			else
				alert("HtmlObject Error : Object could not be found. Did you use setId() or setObject() ?");
			return false;
		}
		return true;
	}

	//FONCTIONS D'ACCES AUX ATTRIBUTS
	//Change one of the object attributes
	this.setAttribute = function(nameAtt, newValue) {
		if(!this.check()) return false;
		if(nameAtt.toLowerCase() == "id") {
			var msg = "The attribute 'id' cannot be changed for technical reasons."
			msg += " Please change it manualy then recreate the HtmlObject object."
			alert(msg);
			return false;
		}
		this.obj[nameAtt] = newValue;
		//alert(nameAtt+' is not defined.');
		return true;
	}

	//Change the object's class
	this.setClass = function(newClass) {
		if(!this.check()) return false;
		this.obj.className = newClass;
		return true;
	}

	//Adds a class to the element
	this.addClass = function(newClass) {
		if(!this.check()) return false;
		var classes = this.obj.className.split(' ');
		if(!Utils.Array.in_array(newClass,classes))
			classes.push(newClass);
		this.obj.className = classes.join(' ');
		return true;
	}

	//Removes a class from the element
	this.rmClass = function(oldClass) {
		if(!this.check()) return false;
		var classes = this.obj.className.split(' ');
		var i = Utils.Array.array_search(oldClass,classes)
		if(i != false) delete classes[i];
		this.obj.className = classes.join(' ');
		return true;
	}

	//Gets the desired style
	this.getStyle = function(styleProp){
		if(!this.check()) return false;
		var val = false;

		if (this.obj.currentStyle)//IE
			val = this.obj.currentStyle[styleProp];
		else if (window.getComputedStyle)//MOZILLA
			val = document.defaultView.getComputedStyle(this.obj,null)[styleProp];

		return val;
	}

	//Sets a style value.
	this.setStyle = function(sAttribute, sValue) {
		if(!this.check()) return false;
		switch(sAttribute){
			case 'opacity':
				this.obj.style.opacity = (sValue / 100);
				this.obj.style.MozOpacity = (sValue / 100);
				this.obj.style.KhtmlOpacity = (sValue / 100);
				this.obj.style.filter = "alpha(opacity=" + sValue + ")";
				break;
			default :
				try {
					this.obj.style[sAttribute] = sValue;
				}
				catch(e) {
					//alert("Style property "+sAttribute+" isn't defined");
				}
				break;
		}
		return true;
	}

	//FONCTIONS DOM
	//Empty the object
	this.empty = function(){
		if(!this.check()) return false;
		this.obj.innerHTML = "";
		return true;
	}

	//appends an element
	this.appendChild = function(child){
		if(!this.check()) return false;
		this.obj.appendChild(child);
		return true;
	}

	//appends a text element
	this.appendText = function(text){
		if(!this.check()) return false;
		this.obj.appendChild(document.createTextNode(text));
		return true;
	}

	//appends this element to the node given
	this.appendInto = function(parentNode){
		if(!this.check()) return false;
		Utils.$(parentNode).appendChild(this.obj);
		return true;
	}

	this.remove = function() {
		if(!this.check()) return false;
		if(Utils.isset(this.obj.parentNode)) this.obj.parentNode.removeChild(this.obj);
		return true;
	}

	//FONCTIONS DE CALCUL D'ATTRIBUTS
	//
	this.isScrollable = function() {
		return this.obj.scrollHeight > this.obj.clientHeight;
	}
	
	//Left absolute position of the object
	this.left = function(unite) {
		if(!this.check()) return false;
		var originalObj = this.obj;
		var posLeft = 0;
		while (this.obj.offsetParent) {
			var position = this.getStyle('position');
			if (position == 'absolute'|| position == 'relative') break;
			posLeft += this.obj.offsetLeft;
			this.obj = this.obj.offsetParent
		}
		//in case first doesn't work, this is the old method
		/*  this.obj = originalObj;
			var posLeft = this.obj.offsetLeft;
			if(document.all)//IE
				posLeft += document.documentElement.scrollLeft;
			else //OTHER
				posLeft += window.pageXOffset;
		}*/
		this.obj = originalObj;

		if(unite == '%'){
			posLeft = (posLeft/this.getWinWidth())*100;
		}

		return Math.round(posLeft);
	}

	//Top absolute position of the object
	this.top = function(unite) {
		if(!this.check()) return false;
		var originalObj = this.obj;
		var posTop = 0;
		while (this.obj.offsetParent) {
			var position = this.getStyle('position');
			if (position == 'absolute'|| position == 'relative') break;
			posTop += this.obj.offsetTop;
			this.obj = this.obj.offsetParent
		}
		//in case first doesn't work, this is the old method
		/*	this.obj = originalObj;
			var posTop = this.obj.offsetTop;
			if(document.all)//IE
				posTop += document.documentElement.scrollTop;
			else //OTHER
				posTop += window.pageYOffset;
		}*/
		this.obj = originalObj;

		if(unite == '%'){
			posTop = (posTop/this.getWinHeight())*100;
		}

		return Math.round(posTop);
	}

	//Right absolute position of the object
	this.right = function(unite) {
		if(!this.check()) return false;

		var posRight = this.getWinWidth() - (this.left() + this.width());

		if(unite == '%'){
			posRight = (posRight/this.getWinWidth())*100;
		}

		return Math.round(posRight);
	}

	//Bottom absolute position of the object
	this.bottom = function(unite) {
		if(!this.check()) return false;
		var posBottom = this.getWinHeight() - (this.top() + this.height());

		if(unite == '%'){
			posBottom = (posBottom/this.getWinHeight())*100;
		}

		return Math.round(posBottom);
	}

	//Renvois la largeur de l'objet
	this.width = function(unite, withBorder) {
		if(!this.check()) return false;
		var display = this.getStyle('display');

		var posWidth = withBorder ? this.obj.offsetWidth:this.obj.clientWidth;

		if (display == 'none' || display == null) {// Safari bug
			// Toutes les proprietes *Width et *Height retournent 0 sur les elements en display none,
			// on les active donc temporairement
			this.tempShow();
			posWidth = withBorder ? this.obj.offsetWidth:this.obj.clientWidth;
			this.tempRestore();
		}

		if(unite == '%'){
			posWidth = (posWidth/this.getWinWidth())*100;
		}
		else if(unite == 'parent'){
			posWidth = (posWidth/this.obj.parentNode.offsetWidth)*100;
		}
		return Math.round(posWidth);
	}

	//Renvois la hauteur de l'objet
	this.height = function(unite, withBorder) {
		if(!this.check()) return false;
		var display = this.getStyle('display');

		var posHeight = withBorder ? this.obj.offsetHeight:this.obj.clientHeight;

		if (display == 'none' || display == null) {// Safari bug
			// Toutes les proprietes *Width et *Height retournent 0 sur les elements en display none,
			// on les active donc temporairement
			this.tempShow();
			posHeight = withBorder ? this.obj.offsetHeight:this.obj.clientHeight;
			this.tempRestore();
		}
		if(unite == '%'){
			posHeight = (posHeight/this.getWinHeight())*100;
		}
		else if(unite == 'parent'){
			posHeight = (posHeight/this.obj.parentNode.offsetHeight)*100;
		}
		return Math.round(posHeight);
	}
	
	/**
	 * @param tiId		(string) L'identifiant de l'element auquel on veut s'ajutser
	 * @param preserve	(bool) Indique si l'on veut ou non preserver le minHeight si il est deja defini
	 */
	this.adjustMinHeightTo = function(toId, preserve) {
		if(!this.check()) return false;
		var name = 'ho_'+Utils.uid();
		var to = new HtmlObject(name);
		objectList.add(name, to);
		to.setId(toId);
		var toH = to.height();
		if(!preserve || this.getStyle('minHeight') < toH)
			this.setStyle('minHeight',toH+'px');
		return true;
	}

	//FONCTIONS DE VISIBILITE
	//Hides the object
	this.isDisplayed = function() {
		return (this.getStyle('display') != 'none');
	}

	this.hide = function() {
		if(!this.check()) return false;
		this.setStyle('display','none');
		return 'none';
	}

	//Shows the object
	this.show = function() {
		if(!this.check()) return false;
		var display;
		switch(this.obj.tagName.toUpperCase()) {
			case 'TABLE':
			case 'TR':
			case 'THEAD':
			case 'TBODY':
			case 'TFOOT':
			case 'COL':
			case 'COLGROUP':
			case 'TD':
			case 'TH':
			case 'CAPTION':
				display = '';
				break;
			case 'SELECT':
			case 'SPAN':
			case 'INPUT':
			case 'IMG':
				display = 'inline';
				break;
			default:
				display = 'block';
				break;
		}
		this.setStyle('display',display);
		return display;
	}

	//Same as hide() but uses visibility
	this.mask = function () {
		if(!this.check()) return false;
		this.setStyle('visibility','hidden');
		return true;
	}

	//Same as show() but uses visibility
	this.unmask = function () {
		if(!this.check()) return false;
		this.setStyle('visibility','visible');
		return true;
	}

	//Shows or hides the object
	this.switchView = function() {
		if(!this.check()) return false;
		if(this.isDisplayed())//hide if displayed
			return this.hide();
		else //else show
			return this.show();
	}

	//FONCTIONS DE TRANSFORMATION
	/** 
	 * Centre l'objet. Celui-ci doit etre defini en position absolue.
	 * @param typ (string) Contient h ou v en fonction de si on veut centrer horizontalement ou verticalement
	 */
	this.center = function(typ) {
		if(!this.check()) return false;
		if(!typ) typ = "hv";
		var TOP = false;
		var LEFT = false;

		if(typ.indexOf('v') != -1) {
			TOP = 50-Math.round(this.height('parent')/2);
		}
		if(typ.indexOf('h') != -1) {
			LEFT = 50-Math.round(this.width('parent')/2);
		}
		this.move(LEFT, TOP, '%');
		return true;
	}
	
	this.scrollUp = function(speed) {
		if(!this.check()) return false;
		if(!speed) speed = 1;
		this.obj.scrollTop -= speed;
		return true;
	}
	
	this.scrollDown = function(speed) {
		if(!this.check()) return false;
		if(!speed) speed = 1;
		this.obj.scrollTop += speed;
		return true;
	}

	this.move = function(X, Y, unit) {
		if(!this.check()) return false;
		unit = unit || 'px';

		if(X !== false) this.setStyle('left',X+unit);
		if(Y !== false) this.setStyle('top',Y+unit);
		return true;
	}

	//Moves the object to the desired location
	//@param x horizontal position
	//@param y vertical position
	//@param step the length of each step in percent (1 to 100)
	//@param mspd the interval of time between each step
	//@param corner the corner we want to that position (default : top-left | supported values : tr, bl, br)
	this.moveByStep = function(X, Y, step, mspd, corner) {
		if(this.getStyle('position') != 'absolute') {
			alert("Error : The position style of the object "+objId+" isn't set to absolute.");
			return false;
		}
		if(step < 1 || step > 100) {
			alert("Step out of range (1-100)");
			return false;
		}
		//Everything's alright, let's go on
		switch(corner){//Set current position
			case 'tr'://top right
				var posY = this.top();
				var posX = this.right();
				break;
			case 'bl'://bottom left
				var posY = this.bottom();
				var posX = this.left();
				break;
			case 'br'://bottom right
				var posY = this.bottom();
				var posX = this.right();
				break;
			default ://top left
				var posY = this.top();
				var posX = this.left();
				break;
		}
		//define distance to destination
		var disX = X - posX;
		var disY = Y - posY;
		//define length of one step
		var stepX = (disX * step)/100;
		var stepY = (disY * step)/100;

		var timer = 0;
		//while not positionned, move
		while(posX != X || posY != Y){
			timer += mspd;
			if(posY != Y){
				posY += stepY;//Take a step !
				disY -= stepY;//Less to go !
				if((stepY < 0 && disY > stepY) || (stepY > 0 && disY < stepY)){
					posY = Y;
					disY = 0;
				}
				switch(corner){
					case 'bl'://bottom left
					case 'br'://bottom right
						window.setTimeout(new Function(this.absThis()+".setStyle('bottom','"+posY+"px')"),timer);
						break;
					case 'tr'://top right
					default ://top left
						window.setTimeout(new Function(this.absThis()+".move(false,'"+posY+"')"),timer);
						break;
				}
			}
			if(posX != X){
				posX += stepX;//Take a step !
				disX -= stepX;//Less to go !
				if((stepX < 0 && disX > stepX) || (stepX > 0 && disX < stepX)){
					posX = X;
					disX = 0;
				}
				switch(corner){
					case 'br'://bottom right
					case 'tr'://top right
						window.setTimeout(new Function(this.absThis()+".setStyle('right','"+posX+"px')"),timer);
						break;
					case 'bl'://bottom left
					default ://top left
						window.setTimeout(new Function(this.absThis()+".move('"+posX+"', false)"),timer);
						break;
				}
			}
		}
		return true;
	}

	this.resize = function(W, H, unit) {
		if(!this.check()) return false;
		unit = unit || 'px';

		if(W !== false) this.setStyle('width',W+unit);
		if(H !== false) this.setStyle('height',H+unit);
		return true;
	}

	/**
	 * Resizes the object to the disired dimentions
	 * @param W width
	 * @param H height
	 * @param step the length of each step in percent (1 to 100)
	 * @param spd the interval of time between each step
	 */
	this.resizeByStep = function(W, H, step, spd, callback) {
		if(W === false) W = this.width();
		if(H === false) H = this.height();
		if(!step) step = 10;
		if(!spd) spd = 10;
		if(step < 1 || step > 100) {
			alert("Step is out of range (1-100)");
			return false;
		}
		//Everything's alright, let's go on

		//define distance to destination
		var posH = this.height();
		var posW = this.width();
		var disH = H - posH;
		var disW = W - posW;

		//define length of one step
		var stepH = (disH * step)/100;
		var stepW = (disW * step)/100;

		var timer = 0;
		//while not resized, resize
		while(posH != H || posW != W){
			timer += spd;
			if(posW != W){
				posW += stepW;//Take a step !
				disW -= stepW;//Less to go !
				if((stepW < 0 && disW > stepW) || (stepW > 0 && disW < stepW)){
					posW = W;
					disW = 0;
				}
				window.setTimeout(new Function(this.absThis()+".setStyle('width','"+posW+"px')"),timer);
			}
			if(posH != H){
				posH += stepH;//Take a step !
				disH -= stepH;//Less to go !
				if((stepH < 0 && disH > stepH) || (stepH > 0 && disH < stepH)){
					posH = H;
					disH = 0;
				}
				window.setTimeout(new Function(this.absThis()+".setStyle('height','"+posH+"px')"),timer);
			}
		}
		if(callback) window.setTimeout(new Function(this.absThis()+".callbacks.send('"+callback+"')"),timer+spd);
		return true;
	}

	//Make the element fade from an opacity to an other.
	this.fade = function (opacStart, opacEnd, millisec) {
		//speed for each frame
		var speed = Math.round(millisec / 100);
		var timer = 0;
		//determine the direction for the blending, if start and end are the same nothing happens
		if(opacStart > opacEnd) {
			for(i = opacStart; i >= opacEnd; i--) {
				setTimeout(new Function(this.absThis()+".setStyle('opacity'," + i + ")"),(timer * speed));
				timer++;
			}
		} else if(opacStart < opacEnd) {
			for(i = opacStart; i <= opacEnd; i++) {
				setTimeout(new Function(this.absThis()+".setStyle('opacity'," + i + ")"),(timer * speed));
				timer++;
			}
		}
	}

	//**************************//
	// Methodes d'ordre general //
	//**************************//
	//Renvois la largeur de la fenetre
	this.getWinWidth = function (){
		var wWidth = false;
		if(window.innerWidth)
			wWidth = window.innerWidth;
		else if(document.documentElement.clientWidth)
			wWidth = document.documentElement.clientWidth;
		else if(document.body.clientWidth)
			wWidth = document.body.clientWidth;

		return wWidth;
	}

	//Renvois la hauteur de la fenetre;
	this.getWinHeight = function (){
		var wHeight = false;
		if(window.innerHeight)
			wHeight = window.innerHeight;
		else if(document.documentElement.clientHeight)
			wHeight = document.documentElement.clientHeight;
		else if(document.body.clientHeight)
			wHeight = document.body.clientHeight;

		return wHeight;
	}
	//******************//
	// Methodes privees //
	//******************//
	/**
	 * Permet d'afficher temporairement un element
	 */
	this.tempShow = function() {
		this.originalVisibility = this.obj.style['visibility'];
		this.originalPosition = this.obj.style['position'];
		this.originalDisplay = this.obj.style['display'];
		this.obj.style['visibility'] = 'hidden';
		this.obj.style['position'] = 'absolute';
		this.obj.style['display'] = 'block';
	}
	/**
	 * Restitut les proprietees initiales de l'element apres avoir utilise tempShow.
	 */
	this.tempRestore = function() {
		this.obj.style['visibility'] = this.originalVisibility;
		this.obj.style['position'] = this.originalPosition;
		this.obj.style['display'] = this.originalDisplay;
	}
}

//Pour des raisons pratiques, on instancie l'objet une fois pour les "petites" manips.
var htmlObject = new HtmlObject('htmlObject');/**
 * @author Laurent Thoulon
 * @version 2.4 [LT][2010-02-01] Ajout de compatibilitÃ© Mootools
 */

/**
 * CLASS UserWindow
 * Classe permettant de creer une "fenetre" div personalisee.
 *
 * @param objName Le nom permettant d'identifier l'objet UserWindow
 */
function UserWindow(objName) {
	/*** CONSTRUCTION DE L'OBJET ***/
	this.callbacks = new CallbackList();
	//Nom de l'objet UserWindow
	this.objName = objName ? objName : 'uw_'+Utils.uid();
	//Id de l'element HTML concerne
	this.objId = this.objName+'_'+Utils.uid();
	//Creation de l'element HTML
	this.obj = (window.$ !== undefined) ? new Element('div'):document.createElement('div');
	if(this.obj.store !== undefined) this.obj.store('object',this);
	this.obj.id = this.objId;
	//Creation du sous objet htmlObject afin de beneficier de ses methodes
	this.htmlObject = new HtmlObject();
	this.htmlObject.setObject(this.obj);

	//nom de la variable objet ObjectList
	this.objListName = 'objectList'; //a configurer si cela change
	window.objectList.add(this.objName,this); //ajout de l'objet a la liste d'objets

	//Proprietes
	this.radius = 20;//a titre indicatif
	this.printed = false;
	this.shown = true;
	this.properties = {
		'type' : false,
		'bgOpacity' : 90,
		'width' : 500,
		'bt_close' : {
			'display' : 'inline',
			'text' : '',
			'action' : 'default'
		},
		'bt_save' : {
			'display' : 'inline',
			'text' : '',
			'action' : 'default'
		},
		'bt_ok' : {
			'display' : 'inline',
			'text' : 'OK',
			'action' : 'default'
		},
		'bt_cancel' : {
			'display' : 'inline',
			'text' : 'Annuler',
			'action' : 'default'
		}
	};

	//Initialisation de l'objet
/*
	<div class="uw_win">
		<div class="uw_mask"></div>
		<div class="uw_content">
			<div class="uw_head">
				<div class="uw_head_left"></div>
				<div class="uw_head_mid"></div>
				<div class="uw_head_right"></div>
			</div>
			<div class="uw_body">
				<div class="uw_body_top"></div>
				<div class="uw_body_txt"></div>
				<div class="uw_body_input"></div>
				<div class="uw_default_bts">
					<div class="uw_bt_ok"></div>
					<div class="uw_bt_cancel"></div>
				</div>
				<div class="uw_body_btm"></div>
			</div>
			<div class="uw_footer">
				<div class="uw_footer_left"></div>
				<div class="uw_footer_mid"></div>
				<div class="uw_footer_right"></div>
			</div>
			<div class="uw_bt_save"></div>
			<div class="uw_bt_close"></div>
		</div>
	</div>
*/
	this.uw = {
		'win' : this.obj,
			'mask' : document.createElement('div'),
			'content' : document.createElement('div'),
				'head' : document.createElement('div'),
					'head_left' : document.createElement('div'),
					'head_mid' : document.createElement('div'),
					'head_right' : document.createElement('div'),
				'body' : document.createElement('div'),
					'body_top' : document.createElement('div'),
					'body_txt' : document.createElement('div'),
					'body_input' : document.createElement('div'),
						'champ_prompt' : false,
					'body_btm' : document.createElement('div'),
				'footer' : document.createElement('div'),
					'footer_left' : document.createElement('div'),
					'footer_mid' : document.createElement('div'),
					'footer_right' : document.createElement('div'),
				'bt_save' : document.createElement('span'),
				'bt_close' : document.createElement('span'),
				'default_bts' : document.createElement('div'),
					'bt_ok' : document.createElement('span'),
					'bt_cancel' : document.createElement('span')
	};
	this.uw.head.appendChild(this.uw.head_left);
	this.uw.head.appendChild(this.uw.head_mid);
	this.uw.head.appendChild(this.uw.head_right);
	this.uw.default_bts.appendChild(this.uw.bt_ok);
	this.uw.default_bts.appendChild(this.uw.bt_cancel);
	this.uw.body.appendChild(this.uw.body_top);//Dummy Div : Permet d'eviter l'espace de type "margin" qui peut apparaitre entre el head et le body en fonction du texte
	this.uw.body.appendChild(this.uw.body_txt);
	this.uw.body.appendChild(this.uw.body_input);
	this.uw.body.appendChild(this.uw.body_btm);//Dummy Div : idem avec le footer.
	this.uw.footer.appendChild(this.uw.footer_left);
	this.uw.footer.appendChild(this.uw.footer_mid);
	this.uw.footer.appendChild(this.uw.footer_right);
	this.uw.content.appendChild(this.uw.head);
	this.uw.content.appendChild(this.uw.body);
	this.uw.content.appendChild(this.uw.footer);
	this.uw.content.appendChild(this.uw.bt_save);
	this.uw.content.appendChild(this.uw.bt_close);
	this.uw.content.appendChild(this.uw.default_bts);
	this.uw.win.appendChild(this.uw.content);
	this.uw.win.appendChild(this.uw.mask);

	//this.uw.mask.innerHTML = '&nbsp;';
	//affectation des classes
	for(var i in this.uw) {
		if(this.uw != false) this.uw[i].className = 'uw_'+i;
	};

	/*** METHODES ***/

	/**
	 * @param (string, multiple) Prends autant de string en parametre que de methodes que l'on veut appeler.
	 * @return (string) Le code a evaluer pour appeler toutes les fonctions a la suite OU le code permettant d'ecceder a l'objet si aucun parametre n'est donne
	 */
	this.absThis = function() {
		var absThis = this.objListName+".get('"+this.objName+"')";
		if(arguments.length > 0) {
			var fullAbsThis = '';
			for (var i=0; i<arguments.length; ++i) {
				fullAbsThis += absThis+'.'+arguments[i]+';';
			}
			return fullAbsThis;
		}
		return absThis;
	};

	this.close = function() {
		if(this.printed == true) {
			this.obj.parentNode.removeChild(this.obj);
			this.printed = false;
		}
	};

	this.hide = function() {
		if(this.shown == true) {
			this.obj.style.display = 'none';
			this.shown = false;
		}
	};

	this.show = function() {
		if(this.shown == false) {
			this.obj.style.display = 'block';
			this.shown = true;
		}
	};

	/**
	 * @param newContent (string|object) Le contenu a rajouter
	 */
	this.setContent = function (newContent, append) {
		if(!append) this.uw.body_txt.innerHTML = '';
		if(typeof newContent == 'string')
			this.uw.body_txt.innerHTML += newContent;
		else if(Utils.isset(newContent)) this.uw.body_txt.appendChild(newContent);
	};

	this.setTitle = function (newTitle) {
		this.uw.head_mid.innerHTML = newTitle;
	};
	
	this.setBgOpacity = function(newOpacity) {
		if(!newOpacity) newOpacity = this.properties.bgOpacity;
		else this.properties.bgOpacity = newOpacity;

		this.htmlObject.setObject(this.uw.mask);
		this.htmlObject.setStyle('opacity', newOpacity);
		//Retablissement
		this.htmlObject.setObject(this.obj);
	};

	this.setWidth = function(newWidth) {
		if(!newWidth) newWidth = this.properties.width;
		else this.properties.width = newWidth;

		var altWidth = newWidth-this.radius*2;
		this.htmlObject.setObject(this.uw.content);
		this.htmlObject.resize(newWidth, false);
		this.htmlObject.setObject(this.uw.head_mid);
		this.htmlObject.resize(altWidth, false);
		this.htmlObject.setObject(this.uw.footer_mid);
		this.htmlObject.resize(altWidth, false);
		this.htmlObject.setObject(this.obj);
	};

	/**
	 * @param bt (string) Le bouton que l'on veut modifier
	 * @param txt (string|object) Le texte du bouton. Peut etre une image
	 * @param act (string|function) L'action qu'effectuera le bouton. Par defaut, ferme la fenetre.
	 */
	this.setButton = function (bt, txt, act) {
		bt = 'bt_'+bt;
		if(!txt) txt = this.properties[bt].text;
		else this.properties[bt].text = txt;
		if(!act) act = this.properties[bt].action;
		else this.properties[bt].action = act;

		if(typeof txt == 'string') this.uw[bt].innerHTML = txt;
		else this.uw[bt].appendChild(txt);

		if(act == 'default') this.uw[bt].onclick = new Function(this.absThis('close()'));
		else if(typeof act == 'string') {
			this.uw[bt].onclick = new Function(act);
		}
		else this.uw[bt].onclick = act;
		this.uw[bt].style.display = this.properties[bt].display;
	};

	/**
	 * @param newType Le type de la fenetre : alert, confirm, prompt ou par defaut, vide
	 */
	this.setType = function (newType) {
		if(!Utils.isset(newType)) newType = this.properties.type;
		else this.properties.type = newType;
		
		this.htmlObject.setObject(this.uw.default_bts);
		this.htmlObject.appendInto(this.uw.content);
		this.htmlObject.setObject(this.uw.body_input);
		this.htmlObject.appendInto(this.uw.body);
		switch(newType) {
			case 'alert':
				this.setButton('close');
				this.setButton('ok');
				this.htmlObject.setObject(this.uw.body);
				this.htmlObject.setStyle('paddingBottom','10px');
				this.htmlObject.setObject(this.uw.bt_cancel);
				this.htmlObject.remove();
				this.htmlObject.setObject(this.uw.body_input);
				this.htmlObject.remove();
			break;
			case 'confirm':
				this.setButton('close');
				this.setButton('ok');
				this.setButton('cancel');
				this.htmlObject.setObject(this.uw.body);
				this.htmlObject.setStyle('paddingBottom','10px');
				this.htmlObject.setObject(this.uw.body_input);
				this.htmlObject.remove();
			break;
			case 'prompt':
				this.setButton('close');
				this.setButton('ok');
				this.setButton('cancel');
				this.htmlObject.setObject(this.uw.body);
				this.htmlObject.setStyle('paddingBottom','10px');
				this.uw.champ_prompt = document.createElement('input');
				this.uw.champ_prompt.type = 'text';
				this.uw.champ_prompt.name = 'PROMPT_TEXT';
				this.uw.body_input.appendChild(this.uw.champ_prompt);
			break;
			case 'promptalt':
				this.setButton('close');
				this.setButton('ok');
				this.setButton('cancel');
				this.htmlObject.setObject(this.uw.body);
				this.htmlObject.setStyle('paddingBottom','10px');
				this.uw.champ_prompt = document.createElement('textarea');
				this.uw.champ_prompt.name = 'PROMPT_TEXT';
				this.uw.body_input.appendChild(this.uw.champ_prompt);
			break;
			default:
				this.setButton('close');
				this.htmlObject.setObject(this.uw.default_bts);
				this.htmlObject.remove();
				this.htmlObject.setObject(this.uw.body_input);
				this.htmlObject.remove();
			break;
		}
		this.htmlObject.setObject(this.obj);
	};
	
	this.setLoading = function(on) {
		if(on !== false) {
			this.htmlObject.setObject(this.uw.body_txt);
			this.htmlObject.mask();
			this.htmlObject.setObject(this.uw.body_input);
			this.htmlObject.mask();
			this.htmlObject.setObject(this.uw.default_bts);
			this.htmlObject.mask();
			this.htmlObject.setObject(this.uw.body);
			this.htmlObject.addClass('uw_loading');
			var styleHeight = this.htmlObject.getStyle('height').replace(/px/g,"");
			if(isNaN(styleHeight)) styleHeight = 0;
			else styleHeight = parseInt(styleHeight);
			if(this.htmlObject.height() < 32 && styleHeight < 32) this.htmlObject.setStyle('height','32px');
		}
		else {
			this.htmlObject.setObject(this.uw.body_txt);
			this.htmlObject.unmask();
			this.htmlObject.setObject(this.uw.body_input);
			this.htmlObject.unmask();
			this.htmlObject.setObject(this.uw.default_bts);
			this.htmlObject.unmask();
			this.htmlObject.setObject(this.uw.body);
			this.htmlObject.rmClass('uw_loading');
		}
		
		this.htmlObject.setObject(this.obj);
	};

	this.print = function(sType, iWidth) {
		this.setWidth(iWidth);
		this.setBgOpacity();
		this.setType(sType);

		this.htmlObject.mask();
		document.body.appendChild(this.uw.win);
		this.htmlObject.setObject(this.uw.content);
		this.uw.content.style.marginLeft = -Math.floor(this.htmlObject.width()/2)+'px';
		this.htmlObject.setObject(this.obj);
		this.htmlObject.unmask();
		if(window.$ !== undefined) $(this.uw.content).makeDraggable({handle: this.uw.head});
		this.printed = true;
		return this.objId;
	};
}

function ualert(content, sTitle, iWidth) {
	if(!sTitle) sTitle = 'Notification';

	var ualert = new UserWindow('ualert_'+Utils.uid());
	ualert.setContent(content);
	ualert.setTitle(sTitle);
	ualert.print('alert', iWidth);
	return ualert;
}

function uconfirm(content, sTitle, iWidth) {
	if(!sTitle) sTitle = 'Notification';

	var uconfirm = new UserWindow('uconfirm_'+Utils.uid());
	uconfirm.setContent(content);
	uconfirm.setTitle(sTitle);
	uconfirm.print('confirm', iWidth);
	
	return uconfirm;
}

function uprompt(content, sTitle, iWidth, bTextArea) {
	if(!sTitle) sTitle = 'Notification';

	var uprompt = new UserWindow('uprompt_'+Utils.uid());
	uprompt.setContent(content);
	uprompt.setTitle(sTitle);
	uprompt.print('prompt'+(bTextArea ? 'alt':''),iWidth);
	
	return uprompt;
}

function uwin(content, sTitle, iWidth) {
	if(!sTitle) sTitle = 'Notification';

	var uwin = new UserWindow('uwin_'+Utils.uid());
	uwin.setContent(content);
	uwin.setTitle(sTitle);
	uwin.print(null,iWidth);
	
	return uwin;
}/**
 * @author Laurent Thoulon
 * @version 2.0 [LT] ajout de l'exception des input de type radio
 * @version 2.1 [LT] Transformation en Classe
 * @version 2.2 [LT] ajout du support du type checkbox
 * @version 2.3 [LT] modification au niveau de la methode de traitement des formulaires. utilise maintenant la fonction serialize
 * @version 2.4 [LT] prise en charge des select-multiple
 * @version 2.5 [LT][11/07/2008] prise en charge de requetes XPath sur l'objet XML renvoye
 * @version 2.5b [LT][17/10/2008] modifications mineurs. (prise en charge des elements dans sendForms)
 * @version 2.6 [LT][29/10/2008] Ajout de la possibilite d'avoir un callback unique qui est execute des que le document est charge
 * @version 2.7 [LT][02/02/2009] Correction mineur de la methode sendForms
 * @version 2.8 [LT][19/02/2009] Correction mineur de la methode sendForms (bis !)
 * @version 3.0 [LT][19/02/2009] Modification de certains noms de fonctions. Les reponses de types texte doivent desormais absolument etre des array serialise
 * @version 3.1 [LT][21/04/2009] Legacy compatibility
 * @version 3.2 [LT][14/05/2009] Prise en charge de ma methode GET
 * @version 3.3 [LT][09/06/2009] Corrections mineures
 * @version 3.3a [LT][03/07/2009] Corrections mineures
 * @version 3.4 [LT][2009-11-05] Correction : Array Associatif => Objet
 */

/* Fonction PHP Ã Â  utiliser
	function cleanPosUrl ($array) {
		foreach($array as $k=>$entry) {
			if(!is_array($entry)) {
				$entry = str_replace("**am**","&",$entry);
				$entry = str_replace("**pl**","+",$entry);
				$entry = str_replace("**eq**","=",$entry);
				$array[$k] = $entry;
			}
			else
				$array[$k] = cleanPosUrl($entry);
		}
		return $array;
	}
	$_POST = cleanPosUrl($_POST);*/

/**
 * Classe XmlHttp
 * Utilise la librairie Utils
 */
function XmlHttp(objName){
	this.callbacks = new CallbackList();
	this.uniqueCallback = false;
	this.pos = '';
	this.method = 'POST';
	this.objName = objName ? objName : 'xh_'+Utils.uid();
	this.xslt = false;
	this.xhr = {
		status : false,
		message : false
	};
	this.msgContainer = false;
	//nom de l'objet ObjectList
	this.objListName = 'objectList'; //a configurer si cela change
	window.objectList.add(this.objName,this); //ajout de l'objet Ã  la liste d'objets
	this.response = false;

	//METHODES
	this.alertUser = function (msg) {
		if(typeof msg != 'string') return false;
		if(htmlObject.setId(this.msgContainer)) {
			htmlObject.empty();
			htmlObject.appendText(msg);
		}
		else alert(msg);
		return true;
	}

	this.getFormInfo = function(frmId) {
		var variables = Utils.getFormInfo(frmId);

		//on echappe les caracteres speciaux &, = et +
		for(var i=0 ; i <variables.length ; i++){
			variables[i]['val'] = this.replaceSpecialChars(variables[i]['val']);
		}

		return variables;
	}
	
	this.getMsgContainer = function() {
		return this.msgContainer;
	}

	this.getText = function(tagName, id) {
		if(tagName) {
			var response = this.pos.responseText;
			var start = response.indexOf('<'+tagName);
			if(start == -1) return "";
	
			if(id) {
				start = response.indexOf("id=\""+id+"\"",start);
				if(start == -1) return "";
			}
	
			start = response.indexOf('>',start);
			if(start == -1) return "";
	
			var end = response.lastIndexOf('</'+tagName+'>');
			if(end == -1) return "";
	
			return response.slice(start+1, end);
		}
		return this.pos.responseText;
	}
	
	this.getXhrStatus = function() {
		return this.xhr.status;
	}

	this.getXML = function(tagName) {
		if(tagName) {
			var val = false;
			try{
				val = this.pos.responseXML.documentElement.getElementsByTagName(tagName)[0].childNodes[0].nodeValue;
			}
			catch(e) {
				val = false;
				//alert(e+"\ntagName="+tagName);
			}
			return val;
		}
		return this.pos.responseXML;
	}

	this.isOk = function() {
		return this.xhr.status == 'OK';
	}

	this.loadXMLPosDoc = function(url,postData) {
		this.sendHttpRequest(url,postData);
	}

	this.processPosChange = function() {
		// page loaded "complete"
		if (this.pos.readyState == 4) {
			// page is "OK"
			if (this.pos.status == 200) {
				this.xhr.status = false;
				this.xhr.message = false;
				var ident = false;
				if(this.pos.responseXML && this.pos.responseXML.documentElement){
					ident = this.getXML('callbackident');
					this.xhr.status = this.xPathQuery('//xhr/status/text()');
					if(this.xhr.status !== false) this.xhr.status = this.xhr.status[0].nodeValue;
					this.xhr.message = this.xPathQuery('//xhr/message/text()');
					try {//Pour safari : try/catch
						if(this.xhr.message !== false) this.xhr.message = this.xhr.message[0].nodeValue;
					}
					catch(e) {this.xhr.message = '';}
				}
				else if(this.pos.responseText){
					if(this.pos.responseText == '' || this.pos.responseText == 'OK'){
						this.xhr.status = 'OK';
					}
					else {
						this.response = Utils.unserialize(this.pos.responseText);
						ident = this.response['callbackident'];
						this.xhr.status = this.response['xhr']['status'];
						this.xhr.message = this.response['xhr']['message'];
					}
				}
				if(this.uniqueCallback) {
					ident = 'unique';
				}
				if(!this.isOk()) this.alertUser(this.xhr.message ? this.xhr.message:this.xhr.status);
				if(ident) this.callbacks.send(ident);
			}
			else {
				alert('Erreur '+this.pos.status +': '+this.pos.statusText);
			}
		}
	}

	this.processXSL = function() {
		var XSLDoc = this.xslt;
		var XMLDoc = this.getXML();

		if (window.XSLTProcessor) {
			var proc = new XSLTProcessor();
			proc.importStylesheet(XSLDoc);
			var newDoc = proc.transformToDocument(XMLDoc);
			newDoc = newDoc.documentElement;
		} else {
			var newDoc = XMLDoc.transformNode(XSLDoc);
			var tmpDiv = document.createElement('div');
			tmpDiv.innerHTML = newDoc;
			newDoc = tmpDiv.firstChild;
		}
		return newDoc;
	}

	this.replaceSpecialChars = function (string) {
		return Utils.replaceSpecialChars(string);
	}

	/**
	 * Envois un formulaire en POST Ã Â  du PHP.
	 * @param frmId l'id du formulaire
	 * @param page la page du script php
	 */
	this.sendForm = function(frmId, page, callback, serialize) {
		serialize = (serialize) ? true:false;
		this.sendForms(new Array(frmId), page, callback, serialize);
	}

	/**
	 * Envois plusieurs formulaires en POST Ã Â un script php PHP.
	 * @param formIdArray Tableau d'element de d'id d'element formulaire
	 * @param page la page du script php
	 */
	this.sendForms = function(formIdArray, page, callback, serialize) {
		//Creation du string de variable POST
		var postData = "";
		var toSerialize = {};
		for(var i=0; i<formIdArray.length; i++) {//toSerialize[formIdArray[i]]
			var nomForm = '';
			if(typeof formIdArray[i] == 'string')
				nomForm = formIdArray[i];
			else if(formIdArray[i].id != '')
				nomForm = formIdArray[i].id;
			else if(formIdArray[i].name != '')
				nomForm = formIdArray[i].name;
			else {
				alert("Error : can't find and appropriate name for current form. XmlHttp->sendForms(args)\n Abording operation...");
				return false;
			}
			toSerialize[nomForm] = this.getFormInfo(formIdArray[i]);
			if(!serialize) {
				for(var j=0 ; j<toSerialize[nomForm].length ; j++){
					postData += "&"+toSerialize[nomForm][j]['nom']+"="+toSerialize[nomForm][j]['val'];
				}
			}
		}
		if(serialize) {
			postData = 'serialized='+Utils.serialize(toSerialize);
		}
		else {
			postData = postData.substr(1,postData.length);//suppression du premier &
		}

		if(callback) postData += '&callbackident='+callback;//ajout du callback aux variables post
		this.sendHttpRequest(page,postData);
		return true;
	}

	this.sendHttpRequest = function(url,postData) {
		// branch for native XMLHttpRequest object
		if (window.XMLHttpRequest) {
			this.pos = new XMLHttpRequest();
		// branch for IE/Windows ActiveX version
		} else if (window.ActiveXObject) {
			try{
				this.pos = new ActiveXObject("Msxm12.XMLHTTP");
			} catch(e) {
				this.pos = new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		if (this.pos) {
			if(typeof postData == 'string')
				postData = postData.replace(String.fromCharCode(8217),"'");//remplace un ' par un '
			//On cre une fonction qui accede Ã  cet objet afin de pouvoir utiliser
			//la fonction processPosChange dans le cadre de cet objet
			this.pos.onreadystatechange = new Function(this.objListName+".get('"+this.objName+"').processPosChange()");
			switch(this.method.toUpperCase()) {
				case 'POST':
					this.pos.open("POST", url, true);
					this.pos.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
					this.pos.send(postData);
				break;
				case 'GET':
					this.pos.open("GET", url+'?'+postData, true);
					this.pos.send(null);
				break;
			}
		}
		else alert("Your browser doesn't handle XMLHttp Requests");
	}
	
	this.setUniqueCallback = function(callback, args) {
		this.callbacks.add('unique', callback, args);
		this.uniqueCallback = true;
	}

	this.setXSL = function(xsl) {
		if(xsl.indexOf('pxsl_') == -1) { // on nous donne l'adresse
			var xhr_name = 'pxsl_'+Utils.uid();
			var tempXhr = new XmlHttp(xhr_name);
			objectList.add(xhr_name,tempXhr);
			tempXhr.setUniqueCallback(this.objListName+".get('"+this.objName+"').setXSL('"+xhr_name+"')");
			tempXhr.sendHttpRequest(xsl);
		}
		else {//on nous donne l'index du resultat
			var xhr = objectList.get(xsl);
			this.xslt = xhr.getXML();
		}
	}

	this.xPathQuery = function(query) {
		var result = [];
		if(this.pos.responseXML.evaluate) {
			var evaluated = this.pos.responseXML.evaluate(query, this.pos.responseXML, null, 0, null );
			var node;
			while((node = evaluated.iterateNext())) result.push(node);
		}
		else {
			this.pos.responseXML.setProperty('SelectionLanguage', 'XPath');
			result = this.pos.responseXML.selectNodes(query);
		}
		return (result.length > 0) ? result:false;
	}
}

//Pour des raisons pratiques, on instancie l'objet une fois pour les "petites" manips.
var xmlHttp = new XmlHttp();/**
 * AJAX Iframe Method
 *
 * @author [WTK] WebToolKit http://www.webtoolkit.info/
 * @author [LT]
 * @version 1.0 [WTK] Version initiale
 * @version 1.1 [LT] Modifications diverses. Prise en charge d'une variable de réponse JS XHR
 */
 
var AIM = {
	//ATTRIBUTS
	msgContainer : false,
	//METHODES
	alertUser : function (msg) {
		if(htmlObject.setId(this.msgContainer)) {
			htmlObject.empty();
			htmlObject.appendText(msg);
		}
		else alert(msg);
	},
	
	frame : function(c) {
		var n = 'aim_f' + Utils.uid();
		var d = document.createElement('DIV');
		d.innerHTML = '<iframe style="display:none" src="about:blank" id="'+n+'" name="'+n+'" onload="AIM.loaded(\''+n+'\')"></iframe>';
		document.body.appendChild(d);
 
		var i = Utils.$(n);
		if (c && typeof(c.onComplete) == 'function') {
			i.onComplete = c.onComplete;
		}
 
		return n;
	},
 
	form : function(f, name) {
		f.setAttribute('target', name);
	},
 
	submit : function(f, c) {
		AIM.form(f, AIM.frame(c));
		if (c && typeof(c.onStart) == 'function') {
			return c.onStart();
		} else {
			return true;
		}
	},
 
	loaded : function(id) {
		var i = Utils.$(id);
		if (i.contentWindow) {
			var w = i.contentWindow;
		} else {
			var w = window.frames[id];
		}
		
		if (w.location.href == "about:blank") {
			return false;
		}
		if (typeof(i.onComplete) == 'function') {
			//Si le tableau javascript XHR est défini on le renvois
			if(Utils.isset(w.XHR)) {
				if(w.XHR['xhr']['status'] != 'OK') this.alertUser(w.XHR['xhr']['message'] ? w.XHR['xhr']['message']:w.XHR['xhr']['status']);
				i.onComplete(w.XHR);
			}
			//Sinon on renvois le contenu HTML
			else i.onComplete(w.document.body.innerHTML);
		}
		return true;
	}
}/**
 * @author [EE]
 * @author [LT]
 * @version 0.8 [EE][LT][2009-11-03]
 *
 * Gestion de l'objet webCallBack
 */
var WebCallBack = {
	exists: false,
	iLaunch : 0,
	oForm : null,
	oUw : null,
	sUrl : null,
	sIdWebCallBack : null,
	sIntro : null,
	sIdCampagne : null,
	sOpen : false,
	aChamps : null,
	xhr : new XmlHttp(),


	init: function() {
		if(WebCallBack.exists){
			if(Utils.Window.get('wcb')) {
				WebCallBack.win_open((Utils.Window.get('fixed') ? 'fixed':null));
			}
			if(WebCallBack.iLaunch > 0) {
				WebCallBack.launch(WebCallBack.iLaunch);
			}
		}
	},
	/**
	 * ImplÃ©mente les variables de configuration
	 * @param sSiteOrigin : l'origine du site utilisant l'objet webCallBack
	 */
	initConfig : function(sSiteOrigin){
		this.sUrl = Ipmed.aConfig['URL']+'php/sendCallBack.php?';
	},

	/**
	 * CrÃ©Ã© le formulaire d'appel
	 */
	create_webCallBack_form : function(sClose){
		var oInputTel,oInputNom,oInputPrenom,oInputRS,oInputPage,oDivImage;

		//<form>
		this.oForm = document.createElement('form');
		this.oForm.name = 'webCallBack_form';
		this.oForm.method = 'post';
		this.oForm.onsubmit = function(){return false;};
		this.oForm.className = 'windowed_form wcb_form';
		if(this.sIntro!=null) {
			var oDivIntro = document.createElement('div');
			oDivIntro.innerHTML = this.sIntro;
			this.oForm.appendChild(oDivIntro);
		}
			oInputPage = document.createElement('input');
			oInputPage.type = 'hidden';
			oInputPage.name = 'PAGE';
			oInputPage.value = Ipmed.sCurrentPage;
			this.oForm.appendChild(oInputPage);

			if (this.aChamps !== null){
				for (var i=0; i<this.aChamps.length; i++){
					oInputTemp = document.createElement('input');
					oInputTemp.type = 'text';
					oInputTemp.name = this.aChamps[i].NOM.toUpperCase();

					//Gestion des champs obligatoires
					if(this.aChamps[i].OBLIG){
						oInputTemp.className = 'oblig';
					}
					this.oForm.appendChild(this.create_input_container(oInputTemp, TEXTE_LIB['LIB_WEBCALLBACK'][this.aChamps[i].NOM.toUpperCase()], true));
			    }
			}
			//<input type="text" name="TELEPHONE">
			oInputTel = document.createElement('input');
			oInputTel.type = 'text';
			oInputTel.name = 'TELEPHONE';
			oInputTel.className = 'oblig';
			oInputTel.onkeypress = function(event) {
				if(event !== undefined && event.keyCode == 13) WebCallBack.send(sClose);
			};
			this.oForm.appendChild(this.create_input_container(oInputTel, TEXTE_LIB['LIB_WEBCALLBACK']['TELEPHONE'], true));

			//<div class="bt_webcallback_send"></div>
			oDivImage = document.createElement('div');
			oDivImage.className ="bt_webcallback_send";
			oDivImage.title=TEXTE_LIB['LIB_BT']['webcallback_send'];
			oDivImage.onclick = function() {WebCallBack.send(sClose);};
			this.oForm.appendChild(oDivImage);
	},

	create_input_container : function(input, label, bOverText) {
		return Ipmed.create_input_container(input, label, bOverText);
	},

	/**
	 * Envoi la requete Http
	 */
	send : function(sClose) {

		//Verifie le numÃ©ro de tÃ©lÃ©phone
		var eTelephone = Utils.Form.getEle(this.oForm,'TELEPHONE');
		eTelephone.value = Utils.String.trim(eTelephone.value);
		var sSecondChar = eTelephone.value.substr(1,1);
		if(isNaN(eTelephone.value) || eTelephone.value.length != 10 || eTelephone.value.substr(0,1)!="0" || sSecondChar=="0" || sSecondChar=="7" || sSecondChar=="8") {
			alert(TEXTE_LIB['LIB_ERROR']['tel_errone']);
		}
		else {

			// Verifie les champs obligatoires
			var formChildNodes = this.oForm.elements;
			var champsVides = false;

			for(var i = 0; i<formChildNodes.length; i++){
				var eTemp = formChildNodes[i];
				if(eTemp.type == 'text'){
					eTemp.value = Utils.String.trim(eTemp.value);
					Utils.Form.emptyOnDefault(eTemp);
					if(eTemp.className.indexOf('oblig')!=-1 && eTemp.value.length == 0) champsVides = true;
				}
			}
			if(champsVides==true)alert(TEXTE_LIB['champs_requis_vides']);
			else {
				this.oUw.setLoading();
				this.xhr.callbacks.add('WebCallBack.cb_send', (function(s) {
					return function(oArgs) {
						WebCallBack.cb_send(oArgs,s);
					}
				})(sClose));
				this.xhr.sendForm(this.oForm,this.sUrl, 'WebCallBack.cb_send');
				return true;
			}

		}
		return false;
	},

	cb_send: function(oArgs, sClose) {
		if(this.xhr['response']['WEBCALLBACK_RESPONSE'] && this.xhr['response']['WEBCALLBACK_RESPONSE'] != "OK")alert(this.xhr['response']['WEBCALLBACK_RESPONSE']);
		if(sClose != false){
			this.sOpen = false;
			this.oUw.close();
		}
		else{
			this.sOpen = false;
			this.oUw.close();
			WebCallBack.win_open('fixed');
		}

	},

	/**
	 * Lance un timer avant l'ouverture de la popup
	 */
	launch : function (time){
		setTimeout("WebCallBack.win_open('leftside')",time);
	},

	/**
	 * Ouvre la fenÃªtre
	 */
	win_open : function (positionAlternative) {
		if(this.sOpen==false){
			this.create_webCallBack_form((positionAlternative==='fixed' ? false:null));

			this.oUw = uwin(this.oForm, TEXTE_LIB['webcallback_info'], 311);
			this.sOpen = true;
			this.oUw.setButton("close",null,function(){
				WebCallBack.oUw.close();
				WebCallBack.sOpen = false;
			});

			if(positionAlternative=='leftside') {
				//RedÃ©finit l'opacitÃ© du masque
				this.oUw.setBgOpacity(1);

				//RÃ©cupÃ¨re les positions du menu
				var oMenu = $('Menu');
				var oSize = oMenu.getSize();
				var oPosition = oMenu.getPosition();
				var sTop = oPosition.y+oSize.y+10+"px";

				var iRight = oPosition.x+oSize.x-5;

				var sLeft = iRight-this.oUw.uw['content'].offsetWidth+"px";

				//Modifie la positiion de la fenÃªtre
				this.oUw.uw['content'].style.marginLeft = "0";
				this.oUw.uw['content'].style.marginTop = "0";
				this.oUw.uw['content'].style.top = sTop;
				this.oUw.uw['content'].style.left = sLeft;
			}
			if(positionAlternative=='fixed') {
				//RedÃ©finit l'opacitÃ© du masque
				this.oUw.uw['bt_close'].style.display = 'none';
				this.oUw.setBgOpacity(100);
			}
		}
	}
}/**
 * @author [LT] Laurent Thoulon
 * @author [EE] Escalle Emilien
 * @version 0.7 [LT][2009-11-03]
 *
 * Gestion des fonctions externes aux objets
 */


/**
 * Renvoie sous la forme d'un array(left,top) la position relative d'un Ã©lÃ©ment.
 * @param e : l'Ã©lement Ã  analyser.
 * @return array() : le tableau avec les valeurs correspondantes
 */
function getPosition (e){
    var left = 0;
    var top = 0;    
    
    /*Tant que l'on a un Ã©lÃ©ment parent*/
    while (e.offsetParent != undefined && e.offsetParent != null)
    {
        /*On ajoute la position de l'Ã©lÃ©ment parent*/
        left += e.offsetLeft + (e.clientLeft != null ? e.clientLeft : 0);
        top += e.offsetTop + (e.clientTop != null ? e.clientTop : 0);
        e = e.offsetParent;
    }
    return new Array(left,top);
}


function showScroll() {
	$('pageScrollUp').setStyle('visibility','visible');
	var eScrollD = $('pageScrollDown');
	eScrollD.setStyle('visibility','visible').addClass('selected');
	eScrollD.removeClass.delay(2000,eScrollD,'selected');
	eScrollD.addClass.delay(3000,eScrollD,'selected');
	eScrollD.removeClass.delay(5000,eScrollD,'selected');
}

function hideScroll() {
	$('pageScrollUp').setStyle('visibility','hidden');
	$('pageScrollDown').setStyle('visibility','hidden');
}

function winReload(add, rm) {
	if(!rm) rm = 'exit;wcb;fixed';
	else rm += ';exit;wcb;fixed';
	Utils.Window.reload(add,rm);
}

function editContent() {
	if(!Utils.isset(Utils.Window.get('cEdit')))
		winReload('cEdit');
	else if(confirm(TEXTE_LIB['LIB_CONFIRM']['modifications_non_enregistree_perdue']))
		winReload(false,'cEdit');
}


function openMenu1(elmt, menuId) {
	htmlObject.setObject(elmt);
	var y = htmlObject.top() + htmlObject.height();
	var x = htmlObject.left();

	htmlObject.setId(menuId);
	htmlObject.move(x,y);
	if(!htmlObject.isDisplayed()) {
	 	htmlObject.show();
	 	
	 	var list = htmlObject.getObject();
	 	var listitems = list.getElementsByTagName('li');
	 	for(var i=0; i<listitems.length; i++) {
	 		htmlObject.setObject(listitems[i]);
	 		htmlObject.setStyle('opacity',0);
	 	}
	 	htmlObject.setObject(list);
	 	htmlObject.unmask();
	 	for(var i=0; i<listitems.length; i++) {
	 		var objName = 'liObj'+i;
	 		var htmlObj = new HtmlObject(objName);
	 		objectList.add(objName,htmlObj);
	 		htmlObj.setObject(listitems[i]);
	 		htmlObj.fade(0,100,500);
	 	}
	}
	else {
	 	htmlObject.hide();
	}
}

function activateMenu(menuId,act) {
	//http://www.quirksmode.org/js/events_mouse.html
	htmlObject.setId(menuId);
	if(!objectList.exists(menuId+'_origH')) objectList.add(menuId+'_origH', htmlObject.height());
	var iOrigH = objectList.get(menuId+'_origH');
	switch(act) {
		case 'open':
			if(!htmlObject.isDisplayed()) {
				//htmlObject.resize(false,1);
			 	htmlObject.show();
			 	//htmlObject.resizeByStep(false,iOrigH,10,10);
			}
			break;
		case 'close' :
			if(htmlObject.isDisplayed()) {
				//htmlObject.callbacks.add('hideNresize',htmlObject.absThis('hide()','resize(false,'+iOrigH+')'));
			 	//htmlObject.resizeByStep(false,1,10,10,'hideNresize');
			 	htmlObject.hide();
			}
			break;
	}
}

function scroll(sens, bloc, iSpeed) {
	htmlObject.setId(bloc);
	//Le premier scroll fait 20px pour que le clique par clique soit plus rapide
	if(!iSpeed) iSpeed = 20;
	if(sens == 'up') {
		htmlObject.scrollUp(iSpeed);
	}
	else {
		htmlObject.scrollDown(iSpeed);
	}
	if(!objectList.exists('scrollTimer')) objectList.add('scrollTimer',window.setInterval("scroll('"+sens+"','"+bloc+"',5)",1));
}

function stopScroll() {
	window.clearInterval(objectList.get('scrollTimer'));
	objectList.remove('scrollTimer');
}/**
 * @author [LT]
 * @author [EE]
 * @version 0.5 [EE][LT][2009-10-12]
 * 
 * Gestion de l'objet Ipmed
 */

var Ipmed = {
	aConfig : null,
	isConnected : false,
	sCurrentPage : null,

	create_input_container : function(oInput, sLabel, bOverText) {
		var container = document.createElement('div');
		container.className = "input_container";
		if(typeof oInput == 'string') {
			container.innerHTML = oInput;
			oInput = container.firstChild;
			container.innerHTML = '';
		}
		if(sLabel) {
			if(bOverText) {
				oInput.onblur = function() {Utils.Form.defaultOnEmpty(this,false,sLabel);};
				oInput.onfocus = function() {Utils.Form.emptyOnDefault(this,sLabel);};
				if(oInput.defaultValue == '') oInput.defaultValue = sLabel;
				oInput.onblur();
			}
			else {
				if(oInput.id == '') oInput.id = 'input_'+Utils.uid();
				var lb = document.createElement('label');
				lb.htmlFor = oInput.id;
				lb.innerHTML = sLabel;
				container.appendChild(lb);
			}
		}
		container.appendChild(oInput);
		return container;
	},

	init : function() {
		if(this.sCurrentPage == 'l' && Utils.isset(Liens)) {
			Liens.switchRubrique();
		}
		if(this.sCurrentPage == 'd' && Utils.isset(Documents)) {
			Documents.switchRubrique();
		}
		
		if(window.WebCallBack !== undefined) {
			WebCallBack.init();
		}

		if(this.sCurrentPage == 'c' && Utils.isset(Contact)) {
			Contact.oForm = document.forms.form_contact;
			Contact.oDivMessage.setId('MessageContact');
		}
		htmlObject.setId('Page');
		if(htmlObject.isScrollable()) {
			showScroll();
		}
		else if(this.sCurrentPage == 'r' && Utils.isset(Rubriques)) {
			if(Rubriques.aListe.length > 22) {
				showScroll();
			}
		}
	}
}/**
 * @author [LT]
 * @version 0.9 [LT][2010-03-09]
 * 
 * Gestion de l'objet Connexion
 */

var Connexion = {
	//Attributs
	oUw : null,
	oForm : null,
	xhr : new XmlHttp(),
	htmlObject : new HtmlObject(),
	bPending : false,
	wConnexionAgenda : null,
	
	//Methodes	
	/**
	 * Permet d'ouvrir l'agenda ou d'executer la procedure de connexion ï¿½ ipmed
	 * @param sLogin String Le login de l'utilisateur.
	 * @param sMd5Password String Le mot de passe codï¿½ en MD5
	 * @param sApp String Le nom de l'application ï¿½ laquelle on veut se connecter
	 *
	 * Si !sLogin & sApp 	=> On ne fait rien
	 * Si !sLogin & !sApp	=> Chargement d'une popup "vide" (montre juste une animation de chargement)
	 * Si sLogin & sApp		=> Connexion dans la mï¿½me fenetre
	 * Si sLogin & !sApp	=> Connexion dans la popup "vide"
	 */
	cnx_portail : function(sLogin, sMd5Password, sApp) {
		if(!sLogin && sApp) return;
		var link,params;
		
		if(sLogin) link = Ipmed.aConfig['url_portail_logicielnet']+'?login='+sLogin+'&md5Password='+sMd5Password+'&site_origine='+Ipmed.aConfig['FULL_URL'].substring(7,Ipmed.aConfig['FULL_URL'].length-1);
		else link = 'loading.php';
		
		if(sApp) window.location.href = link+'&app='+sApp;
		else {
			if(Utils.Window.isOpened(Connexion.wConnexionAgenda)) {
				Connexion.wConnexionAgenda.location.href = link;
			}
			else {
				params = 'top='+Math.round(screen.height/2-120)+',left='+Math.round(screen.width/2-160)+',width=320,height=240,location=no,directories=no,menubar=no,resizable=yes,scrollbars=no,status=no,toolbar=no';
				Connexion.wConnexionAgenda = window.open(link,'ConnexionAgenda', params);
			}
		}
	},
	
	disconnect : function() {
		window.winReload('exit');
	},
	
	send : function() {
		var eCodeuser = Utils.Form.getEle(Connexion.oForm,'CODEUSER');
		eCodeuser.value = Utils.String.trim(eCodeuser.value).toUpperCase();
		var ePassword = Utils.Form.getEle(Connexion.oForm,'PASSWORD');
		
		if(eCodeuser.value == '' || ePassword.value == '') {
			alert(TEXTE_LIB['champs_requis_vides']);
			return false;
		}else {
			Connexion.cnx_portail(null, null, Connexion.xhr.response['direct_agenda']);
			Connexion.oUw.setLoading();
			Connexion.xhr.callbacks.add('Connexion.cb_send', function() {Connexion.cb_send()});
			Connexion.bPending = true;
			Connexion.xhr.sendForm(Connexion.oForm,Ipmed.aConfig['URL']+'php/connect.php', 'Connexion.cb_send');
			ePassword.value = '';
		}
		return true;
	},
	
	cb_send : function() {
		Connexion.bPending = false;
		if(Connexion.xhr.isOk()) {
			if(!Connexion.xhr.response['direct_agenda']) {
				if(Utils.isset(Connexion.wConnexionAgenda)) Connexion.wConnexionAgenda.close();
				Connexion.cnx_portail(Connexion.xhr.response['login'],Connexion.xhr.response['md5Password'],Ipmed.aConfig['APP_INFOS']['CODEUSER'])
			}
			else {
				Connexion.cnx_portail(Connexion.xhr.response['login'],Connexion.xhr.response['md5Password']);
				document.body.appendChild(Connexion.oForm);
				Connexion.oForm.style.display = "none";
				Connexion.oUw.close();
			}
		}
		else {
			if(Utils.isset(Connexion.wConnexionAgenda)) Connexion.wConnexionAgenda.close();
			Connexion.oUw.setLoading(false);
		}
	},
	
	win_open : function () {
		if(Connexion.oForm !== undefined) Connexion.oForm = document.getElementById("form_cnx");
		Connexion.oUw = uwin(Connexion.oForm, TEXTE_LIB['connexion'], 300);
		Connexion.oForm.style.display = "block";
		Connexion.oUw.setButton('close',null,function() {
			document.body.appendChild(Connexion.oForm);
			Connexion.oForm.style.display = "none";
			Connexion.oUw.close();
		});
		Utils.Form.getEle(Connexion.oForm,'CODEUSER').focus();
	}
}