
/** -- file:/egipe/Applications/coreBindings/soca.js -- */
/**
* 	Soca script : Simple and Object-oriented Cross-browser API Javascript 
* 	Copyright (C) 2007 Gaesys - www.gaesys.com
* 	licensed under GPL (GPL-license.txt) license.
* 	
*	Ce script est requis pour l'importation des autres modules. il est minimal,
*	Et ne crèe que les objets les plus basiques possibles.
*
* 	@author: Julien Poveda
* 	@author: Stéphane Seyer
*/


/*====================================================================================
	Objet soca et log
====================================================================================*/
function BaseLog () {
	this.waitingMessages = [];
	this.log = function (aMessage) {
		if (window.console) {
			if (arguments.length == 1) {
				_console.showWaitingMessages ();
			}
			window.console.log(aMessage);
		}
		else if (window.egClient) {
			if (arguments.length == 1) {
				_console.showWaitingMessages ();
			}
			window.egClient.log(aMessage);
		} 
		else {
			_console.waitingMessages.push(aMessage);
		}
	};
	this.showWaitingMessages = function () {
		if (_console.waitingMessages.length !=0)
		{
			for (var i=0; i<_console.waitingMessages.length; i++) {
				this.log(_console.waitingMessages[i],true);
			}
		}
	};
}
var _console = new BaseLog();
var _log = _console.log;
/*====================================================================================
	Namespaces et Imports
====================================================================================*/
function Namespace (aNamespace) {
	var parts = aNamespace.split(".");
	var currentObjectForLevel = window;
	for (var i=0; i<parts.length; i++) {
		if (!(parts[i] in currentObjectForLevel) || (typeof currentObjectForLevel[parts[i]] != "object"))	{
			currentObjectForLevel = new NamespaceObject (currentObjectForLevel, parts[i]);
		}
		else {
			currentObjectForLevel = currentObjectForLevel[parts[i]];
		}
	}
	return currentObjectForLevel;
}

function NamespaceObject (aParentObject,aName) {
	this.name = ((aParentObject.name && !aParentObject.top)?aParentObject.name+"."+aName:aName);
	
	aParentObject[aName] = this;
	
	this.add = function () {
		var aString = false, aClassOrPrototype = false;
		if (arguments.length == 2)
		{
			aString = arguments[0];
			aClassOrPrototype = arguments[1];
		} else {
			aClassOrPrototype = arguments[0];
		}
		
		if (aClassOrPrototype.prototype) {
			aClassOrPrototype.prototype._namespace = this.name;
			aClassOrPrototype.prototype._className = aString;
			if (!aString) {
				aString = aClassOrPrototype.prototype._className;
			}
		} else {
			aClassOrPrototype._className = aString;
			aClassOrPrototype._namespace = this.name;
		}
		this[aString] = aClassOrPrototype;
		
	};
}

function Import (aNamespace) {
	var dHead = document.getElementsByTagName("head")[0];
	var sNode = document.createElement("script");
	sNode.id = aNamespace;
	sNode.setAttribute("src", "/services/getJs.php?package="+aNamespace);
	dHead.appendChild(sNode);
}


/** -- file:/egipe/Applications/coreBindings/com.egipe.soca/core/core.js -- */
Namespace ("com.egipe.soca.core");
/*====================================================================================
	Pseudo constants
====================================================================================*/
com.egipe.soca.NO_ELEMENT = 0;
com.egipe.soca.ELEMENT_ORPHAN = 1;
com.egipe.soca.ELEMENT_INSERT = 2;
com.egipe.soca.XHTMLNS = "http://www.w3.org/1999/xhtml";

/*====================================================================================
	New Objects (méthodes non attachable à un objet natif)
====================================================================================*/
/*
 * HTML Parser By John Resig (ejohn.org)
 * Original code by Erik Arvidsson, Mozilla Public License
 * http://erik.eae.net/simplehtmlparser/simplehtmlparser.js
 *
 * // Use like so:
 * HTMLParser(htmlString, {
 *     start: function(tag, attrs, unary) {},
 *     end: function(tag) {},
 *     chars: function(text) {},
 *     comment: function(text) {}
 * });
 *
 * // or to get an XML string:
 * HTMLtoXML(htmlString);
 *
 * // or to get an XML DOM Document
 * HTMLtoDOM(htmlString);
 *
 * // or to inject into an existing document/DOM node
 * HTMLtoDOM(htmlString, document);
 * HTMLtoDOM(htmlString, document.body);
 *
 */

(function(){

	// Regular Expressions for parsing tags and attributes
	var startTag = /^<(\w+)((?:\s+\w+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/,
		endTag = /^<\/(\w+)[^>]*>/,
		attr = /(\w+)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g;
		
	// Empty Elements - HTML 4.01
	var empty = makeMap("area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed");

	// Block Elements - HTML 4.01
	var block = makeMap("address,applet,blockquote,button,center,dd,del,dir,div,dl,dt,fieldset,form,frameset,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,p,pre,script,span,table,tbody,td,tfoot,th,thead,tr,ul");

	// Inline Elements - HTML 4.01
	var inline = makeMap("a,abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,strike,strong,sub,sup,textarea,tt,u,var");

	// Elements that you can, intentionally, leave open
	// (and which close themselves)
	var closeSelf = makeMap("");//"colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr");

	// Attributes that have their values filled in disabled="disabled"
	var fillAttrs = makeMap("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected");

	// Special Elements (can contain anything)
	var special = makeMap("script,span,style");

	var HTMLParser = this.HTMLParser = function( html, handler ) {
		var index, chars, match, stack = [], last = html;
		stack.last = function(){
			return this[ this.length - 1 ];
		};

		while ( html ) {
			chars = true;

			// Make sure we're not in a script or style element
			if ( !stack.last() || !special[ stack.last() ] ) {

				// Comment
				if ( html.indexOf("<!--") == 0 ) {
					index = html.indexOf("-->");
	
					if ( index >= 0 ) {
						if ( handler.comment )
							handler.comment( html.substring( 4, index ) );
						html = html.substring( index + 3 );
						chars = false;
					}
	
				// end tag
				} else if ( html.indexOf("</") == 0 ) {
					match = html.match( endTag );
	
					if ( match ) {
						html = html.substring( match[0].length );
						match[0].replace( endTag, parseEndTag );
						chars = false;
					}
	
				// start tag
				} else if ( html.indexOf("<") == 0 ) {
					match = html.match( startTag );
	
					if ( match ) {
						html = html.substring( match[0].length );
						match[0].replace( startTag, parseStartTag );
						chars = false;
					}
				}

				if ( chars ) {
					index = html.indexOf("<");
					
					var text = index < 0 ? html : html.substring( 0, index );
					html = index < 0 ? "" : html.substring( index );
					
					if ( handler.chars )
						handler.chars( text );
				}

			} else {
				html = html.replace(new RegExp("(.*)<\/" + stack.last() + "[^>]*>"), function(all, text){
					text = text.replace(/<!--(.*?)-->/g, "$1").replace(/<!\[CDATA\[(.*?)]]>/g, "$1");

					if ( handler.chars )
						handler.chars( text );

					return "";
				});

				parseEndTag( "", stack.last() );
			}

			if ( html == last )
				throw "Parse Error: " + html;
			last = html;
		}
		
		// Clean up any remaining tags
		parseEndTag();

		function parseStartTag( tag, tagName, rest, unary ) {
			if ( block[ tagName ] ) {
				while ( stack.last() && inline[ stack.last() ] ) {
					parseEndTag( "", stack.last() );
				}
			}

			if ( closeSelf[ tagName ] && stack.last() == tagName ) {
				parseEndTag( "", tagName );
			}

			unary = empty[ tagName ] || !!unary;

			if ( !unary )
				stack.push( tagName );
			
			if ( handler.start ) {
				
				var attrs = [];

				rest.replace(attr, function(match, name) {
					var value = arguments[2] ? arguments[2] :
						arguments[3] ? arguments[3] :
						arguments[4] ? arguments[4] :
						fillAttrs[name] ? name : "";
					
					attrs.push({
						name: name,
						value: value,
						escaped: value.replace(/(^|[^\\])"/g, '$1\\\"') //"
					});
				});
					
				if ( handler.start )
					handler.start( tagName, attrs, unary );
			}
		}

		function parseEndTag( tag, tagName ) {
			// If no tag name is provided, clean shop
			var pos;
			if ( !tagName )
				pos = 0;
				
			// Find the closest opened tag of the same type
			else
			{
				for (pos = stack.length - 1; pos >= 0; pos-- )
				{
					if ( stack[ pos ] == tagName )
						break;
				}
			}
			if ( pos >= 0 ) {
				// Close all the open elements, up the stack
				for ( var i = stack.length - 1; i >= pos; i-- ) {
					if ( handler.end )
						handler.end( stack[ i ] );
				}
				
				// Remove the open elements from the stack
				stack.length = pos;
			}
		}
	};
	
	this.HTMLtoXML = function( html ) {
		var results = "";
		
		HTMLParser(html, {
			start: function( tag, attrs, unary ) {
				results += "<" + tag.toLowerCase();
		
				for ( var i = 0; i < attrs.length; i++ )
					results += " " + attrs[i].name + '="' + attrs[i].escaped + '"';
		
				results += (unary ? "/" : "") + ">";
			},
			end: function( tag ) {
				results += "</" + tag.toLowerCase() + ">";
			},
			chars: function( text ) {
				results += text;
			},
			comment: function( text ) {
				results += "<!--" + text + "-->";
			}
		});
		
		return results;
	};
	
	this.HTMLtoDOM = function( html, doc ) {
		// There can be only one of these elements
		var one = makeMap("html,head,body,title");
		
		// Enforce a structure for the document
		var structure = {
			link: "head",
			base: "head"
		};
	
		if ( !doc ) {
			if ( typeof DOMDocument != "undefined" )
				doc = new DOMDocument();
			else if ( typeof document != "undefined" && document.implementation && document.implementation.createDocument )
				doc = document.implementation.createDocument("", "", null);
			else if ( typeof ActiveX != "undefined" )
				doc = new ActiveXObject("Msxml.DOMDocument");
			
		} else
			doc = doc.ownerDocument ||
				doc.getOwnerDocument && doc.getOwnerDocument() ||
				doc;
		
		var elems = [],
			documentElement = doc.documentElement ||
				doc.getDocumentElement && doc.getDocumentElement();
				
		// If we're dealing with an empty document then we
		// need to pre-populate it with the HTML document structure
		if ( !documentElement && doc.createElement ) (function(){
			var html = doc.createElement("html");
			var head = doc.createElement("head");
			head.appendChild( doc.createElement("title") );
			html.appendChild( head );
			html.appendChild( doc.createElement("body") );
			doc.appendChild( html );
		})();
		
		// Find all the unique elements
		if ( doc.getElementsByTagName ) 
		{
			for ( var i in one )
				one[ i ] = doc.getElementsByTagName( i )[0];
		}
		// If we're working with a document, inject contents into
		// the body element
		var curParentNode = one.body;
		
		HTMLParser( html, {
			start: function( tagName, attrs, unary ) {
				// If it's a pre-built element, then we can ignore
				// its construction
				if ( one[ tagName ] ) {
					curParentNode = one[ tagName ];
					return;
				}
			
				var elem = doc.createElement( tagName );
				
				for ( var attr in attrs )
					elem.setAttribute( attrs[ attr ].name, attrs[ attr ].value );
				
				if ( structure[ tagName ] && typeof one[ structure[ tagName ] ] != "boolean" )
					one[ structure[ tagName ] ].appendChild( elem );
				
				else if ( curParentNode && curParentNode.appendChild )
					curParentNode.appendChild( elem );
					
				if ( !unary ) {
					elems.push( elem );
					curParentNode = elem;
				}
			},
			end: function( tag ) {
				elems.length -= 1;
				
				// Init the new parentNode
				curParentNode = elems[ elems.length - 1 ];
			},
			chars: function( text ) {
				curParentNode.appendChild( doc.createTextNode( text ) );
			},
			comment: function( text ) {
				// create comment node
			}
		});
		
		return doc;
	};

	function makeMap(str){
		var obj = {}, items = str.split(",");
		for ( var i = 0; i < items.length; i++ )
			obj[ items[i] ] = true;
		return obj;
	}
})();

/*------------------------------------------------------------------------------------
	Utils (Statique)
-------------------------------------------------------------------------------------*/
com.egipe.soca.core.add ("Utils", (function () {
	var Utils = {};
	var entitiesNames =

		// Base HTML entities.
		//'nbsp,gt,lt,quot,' +

		// Latin-1 Entities
		'iexcl,cent,pound,curren,yen,brvbar,sect,uml,copy,ordf,laquo,' +
		'not,shy,reg,macr,deg,plusmn,sup2,sup3,acute,micro,para,middot,' +
		'cedil,sup1,ordm,raquo,frac14,frac12,frac34,iquest,times,divide,' +

		// Symbols
		'fnof,bull,hellip,prime,Prime,oline,frasl,weierp,image,real,trade,' +
		'alefsym,larr,uarr,rarr,darr,harr,crarr,lArr,uArr,rArr,dArr,hArr,' +
		'forall,part,exist,empty,nabla,isin,notin,ni,prod,sum,minus,lowast,' +
		'radic,prop,infin,ang,and,or,cap,cup,int,there4,sim,cong,asymp,ne,' +
		'equiv,le,ge,sub,sup,nsub,sube,supe,oplus,otimes,perp,sdot,lceil,' +
		'rceil,lfloor,rfloor,lang,rang,loz,spades,clubs,hearts,diams,' +

		// Other Special Characters
		'circ,tilde,ensp,emsp,thinsp,zwnj,zwj,lrm,rlm,ndash,mdash,lsquo,' +
		'rsquo,sbquo,ldquo,rdquo,bdquo,dagger,Dagger,permil,lsaquo,rsaquo,' +
		'euro,' +

		// Latin Letters Entities
		'Agrave,Aacute,Acirc,Atilde,Auml,Aring,AElig,Ccedil,Egrave,Eacute,' +
		'Ecirc,Euml,Igrave,Iacute,Icirc,Iuml,ETH,Ntilde,Ograve,Oacute,Ocirc,' +
		'Otilde,Ouml,Oslash,Ugrave,Uacute,Ucirc,Uuml,Yacute,THORN,szlig,' +
		'agrave,aacute,acirc,atilde,auml,aring,aelig,ccedil,egrave,eacute,' +
		'ecirc,euml,igrave,iacute,icirc,iuml,eth,ntilde,ograve,oacute,ocirc,' +
		'otilde,ouml,oslash,ugrave,uacute,ucirc,uuml,yacute,thorn,yuml,' +
		'OElig,oelig,Scaron,scaron,Yuml,' +

		// Greek Letters Entities.
		
		'Alpha,Beta,Gamma,Delta,Epsilon,Zeta,Eta,Theta,Iota,Kappa,Lambda,Mu,' +
		'Nu,Xi,Omicron,Pi,Rho,Sigma,Tau,Upsilon,Phi,Chi,Psi,Omega,alpha,' +
		'beta,gamma,delta,epsilon,zeta,eta,theta,iota,kappa,lambda,mu,nu,xi,' +
		'omicron,pi,rho,sigmaf,sigma,tau,upsilon,phi,chi,psi,omega,thetasym,' +
		'upsih,piv';

	var entitiesBaseValues = ' ><"';
	var entitiesValues = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿×÷ƒ•…′″‾⁄℘ℑℜ™ℵ←↑→↓↔↵⇐⇑⇒⇓⇔∀∂∃∅∇∈∉∋∏∑−∗√∝∞∠∧∨∩∪∫∴∼≅≈≠≡≤≥⊂⊃⊄⊆⊇⊕⊗⊥⋅⌈⌉⌊⌋〈〉◊♠♣♥♦ˆ˜' +
								'       ' + // Espaces pour les sections 'ensp,emsp,thinsp,zwnj,zwj,lrm,rlm'
								'–—‘’‚“”„†‡‰‹›€ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿŒœŠšŸΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϑϒϖ';
	var names = entitiesNames.split(',');
	var entities = {};
	for (var i=0; i<names.length; i++) {
		entities[names[i]] = entitiesValues.charAt(i);
	}
	Utils.parseString = function (aString)
	{
		if (document.implementation)
		{
			var doctype = document.implementation.createDocumentType("html", "-//W3C//DTD HTML 4.01//EN", "http://www.w3.org/TR/html4/strict.dtd"); 
			var aDoc = document.implementation.createDocument ('', 'html', doctype);
			var aBody = aDoc.documentElement.appendChild(aDoc.createElement("body"));
			aBody.innerHTML = aString;
		
			var serializer = new XMLSerializer();
			var content = HTMLtoXML(serializer.serializeToString( aBody ));
			return content.substr(6, content.length-13);
		}
		else {
			return aString;
		}
	};
	Utils.getEntityValue = function (aName) 
	{
		if (aName[0]=="&") {
			aName = aName.substr(1,aName.length-2);
		}
		if (aName in entities) {
			return entities[aName];
		}
		return false;
	};
	Utils.getType = function (mixed) 
	{
		if (!Utils.isDef(mixed)) {
			return false;
		}
		var mType = typeof mixed;
		if ((mType == "object") && ("nodeType" in mixed)) {
			try {
				switch (mixed.nodeType) {
					case 1: 
						return 'element';
					case 9:
						return 'document';
					case 3: 
						return (/\S/).test(mixed.nodeValue) ? 'textnode' : 'whitespace';
					default:
						return "node type ".mixed.nodeType;
						break;
				}
			} catch (e) {
				return "error_element";
			}
			
		}
		if (mType == "object" || mType == "function") {
			switch (mixed.constructor) {
				case Array: 
					return "array";
				case RegExp: 
					return "regexp";
				case Function: 
					return "function";
				case String: 
					return "string";
				case Number: 
					return "number";
				default:
					break;
			}
			if ("self" in mixed) {
				return "window";
			}
			if (typeof mixed.length == "number") {
				if (mixed.item) {
					return "collection";
				}
				if (mixed.callee) {
					return 'arguments';
				}
			}
			
		}
		
		return mType;
	};
	Utils.isDef = function (obj) {
		return (obj != undefined);
	};
	Utils.getArguments = function (argsObj) {
		var aType = Utils.getType(argsObj[0]);
		if (argsObj.length && Utils.getType(argsObj[0]) == "arguments") {
			return argsObj[0];
		}
		else {
			return argsObj;
		}
	};
	/*------------------------------------------------------------------------------------
		Retourne l'objet instancié correspondant au noeud donné
	------------------------------------------------------------------------------------*/
	Utils.getObjectByElement = function (anElementOrId /*, aClassHandler */) {
		try {
			var aType = Utils.getType(anElementOrId);
			var aDomElement = anElementOrId;
			if (aType == "string") {
				aDomElement = document.getElementById(anElementOrId);
			}
			if (aDomElement) {
//					_log(Utils.isDef(aDomElement.jsobject));
//					if (Utils.isDef(aDomElement.jsobject)) {
//						_log(aDomElement.jsobject._instanceOf(com.egipe.soca.core.Element));
//						if (aDomElement.jsobject._instanceOf(com.egipe.soca.core.Element)) {
//							_log(aDomElement.jsobject._className);
//						}
//					}
				if ((!Utils.isDef(aDomElement.jsobject))|| (!aDomElement.jsobject._instanceOf(com.egipe.soca.core.Element))) {
					var classHandler = (arguments.length == 2 && arguments[1])?arguments[1]:com.egipe.soca.core.HTMLElement;
					var anObj =  new classHandler (aDomElement);
					return anObj;
				}
				else if (Utils.isDef(aDomElement.jsobject)) {
					return aDomElement.jsobject;
				}
				return aDomElement;
			}
			else {
				return false;
				//throw (new DomException(anElementOrId+" ne correspond ni à une ID ni à un DomElement"));
			}
		}
		catch (e) {
			_log("$ ("+anElementOrId+" ["+aType+"], "+classHandler+") | "+e.message+"; "+e.lineNumber+" "+e.stack);
		}
		return false;
	}; 
	/*------------------------------------------------------------------------------------
		Retourne la collection d'objets instanciés selon le selecteur
	------------------------------------------------------------------------------------*/
	Utils.getObjectsBySelector = function (aSelector /*, aClassHandler, aRefNode */) {
		var classHandler = (arguments.length >= 2)?arguments[1]:com.egipe.soca.base.Element;
		var refNode = (arguments.length == 3)?arguments[2]:document;
		var aColl = document.getElementsBySelector(aSelector, refNode);
		var aCollOfJsObject = [];
		for (var i=0; i<aColl.length;i++)
		{
			aCollOfJsObject.push($(aColl[i],classHandler));
		}
		return aCollOfJsObject;
	}; 
	
	return Utils;
})());
	
/*------------------------------------------------------------------------------------
	URI
-------------------------------------------------------------------------------------*/
com.egipe.soca.core.add ("URI", (function () {
	function URI () 
	{
		this.names = ["source","protocol","authority","domain","port","path","directoryPath","fileName","query","anchor"];
		this.expression = new RegExp("^(?:([^:/?#.]+):)?(?://)?(([^:/?#]*)(?::(\\d*))?)?((/(?:[^?#](?![^?#/]*\\.[^?#/.]+(?:[\\?#]|$)))*/?)?([^?#/]*))?(?:\\?([^#]*))?(?:#(.*))?");
		this.set((arguments.length == 1)?arguments[0]:document.location.href);
	}
	URI.prototype.set = function (aString)
	{
		this.asciiSpec = aString;
		var uriParts = this.expression.exec(aString);
		var self = this;
		uriParts.foreach(this._setPart, this);
		
		// Always end directoryPath with a trailing backslash if a path was present in the source URI		// Note that a trailing backslash is NOT automatically inserted within or appended to the "path" key		if(this.directoryPath.length > 0) {			this.directoryPath = this.directoryPath.replace(/\/?$/, "/");		}	};
	URI.prototype._setPart = function (aPart,anIndex)
	{
		this[this.names[anIndex]] = aPart;
	};
	URI.prototype.encode = function () 
	{
	    return this.asciiSpec.encode();
	};
	return URI;
})());

/*------------------------------------------------------------------------------------
	Shortcuts
-------------------------------------------------------------------------------------*/
	
var $ = com.egipe.soca.core.Utils.getObjectByElement;
var $$ = com.egipe.soca.core.Utils.getObjectsBySelector;
var Utils = com.egipe.soca.core.Utils;

/** -- file:/egipe/Applications/coreBindings/com.egipe.soca/core/native.js -- */
/*====================================================================================
	Object 
====================================================================================*/
/**
	Add specified object properties and methods off to [this] object
	[someObject] should be declared before calling this method.
*/

function o (anObject) {
	if (typeof anObject.foreach == "undefined")
	{
		anObject.foreach = function (aFunction /*, cThis */)
		{
			if (typeof aFunction != "function") {
				throw new TypeError(); 
			}
			var aReturn = true;
			var cThis = (arguments.length==2)?arguments[1]:this;
			for (var prop in this) {
				if (prop[0] != "_" && prop != "foreach") {
					aReturn &= aFunction.apply(cThis, [this[prop],prop]);
				}
			}
			return aReturn;
		};
		anObject._add = function (someObject) 
		{
			for (var prop in someObject) {
				this[prop] = someObject[prop];
			}
		};
		anObject._instanceOf = function (someHandler) 
		{
			if (Utils.getType(this) == "object")
			{
				if ("_parents" in this && "indexOf" in this._parents) {
					if (this._parents.indexOf(someHandler) != -1) {
						return true;
					}
				}
				return this instanceof someHandler;
			}
			return false;
		};
		anObject._serialize = function () 
		{
			var serializedString = "";
			switch (Utils.getType(this))
			{
				case "number":
					serializedString = this;
					break;
				case "string":
					serializedString = "'"+this+"'";
					break;
				case "object":
					for (var prop in this)
					{
						if (Utils.getType(this[prop]) != "function") {
							serializedString += "'"+prop+"':"+this[prop]._serialize()+",";
						}	
					}
					serializedString = "{"+serializedString.substr(0,serializedString.length-1)+"}";
					break;
				case "array":
					for (var i=0; i<this.length; i++)
					{
						serializedString += this[i]._serialize()+",";
					}
					serializedString = "["+serializedString.substr(0,serializedString.length-1)+"]";
					break;
				default:
					serializedString = this;
					break;
			}
			return serializedString;
		};
	}
	return anObject;
}


/*====================================================================================
	Array 
====================================================================================*/
if (!"indexOf" in Array)
{
	Array.prototype.indexOf = function (aKey)
	{
		if (aKey in this) {
			return true;
		} 
		return false;
	};
}
	
Array.prototype.foreach = function (aFunction /*, cThis */)
{
	if (typeof aFunction != "function") {
		throw new TypeError(); 
	}
	var aReturn = true;
	var cThis = arguments[1];
	for (var i=0; i<this.length; i++) {
		if (i in this) {
			aReturn &= aFunction.apply(cThis, [this[i],i]);
		}
	}
	return aReturn;
};
Array.prototype.merge = function (anArray)
{
	anArray.foreach(this._push, this);
};
Array.prototype._push = function (aValue, anIndex)
{
	this.push(aValue);
};

/*====================================================================================
	Function 
====================================================================================*/
/**
	Pseudo class inherance
*/
Function.prototype.extendsClass = function (classHandler) 
{
  	this.implementsClass(classHandler);
	// add parents class (inherance order)
	this.prototype._parents = [];
	if ('_parents' in classHandler.prototype) {
		this.prototype._parents.merge(classHandler.prototype._parents);
	}
	this.prototype._parents.push(classHandler);
	
	// Add parent method
	this.prototype._parent = function () 
	{ 
		var _child = this;
		var _classHandler = classHandler;
		var _methodName = false;
		
		/* Non Standard : à vérifier sur IE et Opéra */
		/* Récupère le constructeur courrant qui appelle la fonction parent */
		if ("caller" in this._parent)
		{
			var parentCaller = this._parent.caller;
			if (parentCaller && '_parents' in parentCaller.prototype) {
				_classHandler = parentCaller.prototype._parents[parentCaller.prototype._parents.length-1];
			} 
		}
		/* fin non standard */
		
		if (arguments.length==1)
		{
			if (typeof(arguments[0]) == "string") {
				_methodName = arguments[0];
			} else {
				_classHandler = arguments[0];
			}
		} else if (arguments.length==2) {
			_classHandler = arguments[0];
			_methodName = arguments[1];
		}
		if (_methodName) {
			return function () { return _classHandler.prototype[_methodName].apply(_child, com.egipe.soca.core.Utils.getArguments(arguments)); };
		}
		else {
			return function () { _classHandler.apply(_child, com.egipe.soca.core.Utils.getArguments(arguments)); };
		}
	};

};

Function.prototype.implementsClass = function (classHandler) 
{
	var curNamespace = this.prototype._namespace;
	o(this.prototype)._add(classHandler.prototype);
	if (!this.prototype._className) {
  		this.prototype._className = this.toString().match(/function\s*(\w+)/)[1];
	}
};

/**
	Return a function which call this function in context of this object
*/
Function.prototype.bind = function (anObject) 
{	var __method = this;
	return function() {
		return __method.apply(anObject, arguments);
	};
};

/*====================================================================================
	String 
====================================================================================*/
String.prototype.trim = function () 
{
	return this.replace(/^\s+/, "").replace(/\s+$/, "");
};
String.prototype.encode = function () 
{
	return escape(this).replace(/\+/g, '%2B').replace(/\"/g,'%22').replace(/\'/g, '%27').replace(/\//g,'%2F');
};
/*====================================================================================
	Date 
====================================================================================*/
Date.prototype._toString = Date.prototype.toString;
Date.prototype.locale = {
	fr:{pattern:/^([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})/,capture:['day','month','year'],format:'%D/%L/%Y'},
	iso:{pattern:/^([0-9]{4})\-([0-9]{1,2})\-([0-9]{1,2})/,capture:['year','month','day'],format:'%Y-%L-%D'}
};
Date.prototype.toString = function () 
{
	var self=this;
	var hasYear = (this.getYear()!=-1);
	var p = function p(s) {
		return (s.toString().length==1)?'0'+s:s;
	};
	if (arguments.length==1)
	{
		return arguments[0].replace (
			/%([DdLlYyHhMmSs])/g,
			function()
			{
				switch(arguments[1])
				{
					// Day
					case "D":
						return hasYear?p(self.getDate()):'00';
					case "d":
						return hasYear?self.getDate():'0';
					// Month
					case "L":
						return hasYear?p((self.getMonth()+1)):'00';
					case "l":
						return hasYear?self.getMonth()+1:'0';
					// Year
					case "Y":
						return hasYear?self.getFullYear():'0000';
					case "y":
						return hasYear?self.getFullYear().toString().substring(2,4):'00';
					// Hour
					case "H":
						return p(self.getHours());
					case "h":
						return self.getHours();
					// Minute
					case "M":
						return p(self.getMinutes());
					case "m":
						return self.getMinutes();
					// Second
					case "S":
						return p(self.getSeconds());
					case "s":
						return self.getSeconds();
					default:
						return "";
				}
				return "";
			}
		);
	}
	else {
		return this._toString();
	}
};
Date.prototype.setLocaleDate = function (aString) 
{
	var lang = 'iso';
	if (arguments.length==2 && arguments[1] in this.locale) {
		lang = arguments[1];
	}
	var cDate = {'length':0};
	var parts = this.locale[lang].pattern.exec(aString);
	if (parts)
	{
		for (var i=1; i<parts.length;i++) {
			cDate[this.locale[lang].capture[i-1]] = parts[i];
			cDate.length++;		
		}
		if (cDate.length == 3)
		{
			this.setYear(cDate.year);
			this.setMonth(cDate.month-1);
			this.setDate(cDate.day);
			return true;
		}
	}
	return false;
	
};
Date.prototype.getLocaleDate = function () 
{
	var lang = 'iso';
	if (arguments.length==1 && arguments[0] in this.locale) {
		lang = arguments[0];
	}
	if (this.toString("%Y%h%m%s") == '0000000') {
		return "";
	}
	return this.toString(this.locale[lang].format+' %H:%M:%S');
};

/** -- file:/egipe/Applications/coreBindings/com.egipe.soca/core/htmlElement.js -- */
Namespace ("com.egipe.soca.core.interfaces");
/*------------------------------------------------------------------------------------
	CLASSE _BaseHTMLElement
	Classe Abstraite, implementes les methodes des elements HTML 
-------------------------------------------------------------------------------------*/
com.egipe.soca.core.interfaces.add("HTMLElement", (function(){
	
	function HTMLElement () {}
	HTMLElement.prototype = {
		addEventListener : function (eventType, funcHandler, traverse) {
			if (!this.htmlElement.addEventListener) {
				this.htmlElement.addEventListener = window.addEventListener;
			}
			this.htmlElement.addEventListener(eventType, funcHandler, traverse);
		},
		
		hasAttribute : function (attName) {
			if ("hasAttribute" in this.htmlElement) {
				return this.htmlElement.hasAttribute(attName);
			} else {
				return !!this.htmlElement.getAttribute(attName);
			}
		},
		getAttribute : function (attName) {
			return this.htmlElement.getAttribute(attName);
		},
		setAttribute : function (attName, attValue) {
			if (attName == "class")
			{
				this.htmlElement.className = attValue;
			}
			else
			{
				this.htmlElement.setAttribute(attName, attValue);
				if (attName == "id") {
					this.uid = attValue;
				}
			}
		},
		removeAttribute : function (attName) {
			if (attName != "id") {
				this.htmlElement.removeAttribute(attName);
			}
		},
		appendChild : function (someDomNode) {
			return this.htmlElement.appendChild(someDomNode);
		},
		focus : function () {
			return this.htmlElement.focus();
		},
		getElementsByClassName : function (aClassName) {
			return document.getElementsByClassName (aClassName, this.htmlElement);
		},
		getElementsByTagName : function (aTagName) {
			return this.htmlElement.getElementsByTagName (aTagName);
		},
		getElementsBySelector : function (aSelector) {
			return document.getElementsBySelector (aSelector, this.htmlElement);
		}
	};
	
	return HTMLElement;
})());

/** -- file:/egipe/Applications/coreBindings/com.egipe.soca/core/events.js -- */
Namespace ("com.egipe.soca.core");
/*------------------------------------------------------------------------------------
	CLASSE CrossBrowserEvent
	Permet d'unifier pour tous les navigateurs la gestion des événements.
-------------------------------------------------------------------------------------*/
com.egipe.soca.core.add("Event", (function(){

	function Event (evt)
	{
		this.eventHandler = window.event?window.event:evt;
		this.target = window.event?this.eventHandler.srcElement:this.eventHandler.target;
		this.type = this.eventHandler.type;
		if (this.target.nodeType && this.target.nodeType != 1 && this.target.nodeType != 9)
		{
			node = this.target;
			while (node.nodeType != 1) {
				node = node.parentNode;
			}
			this.target = node;
		}
	}
	
	Event.prototype.clearEvent = function () {
		if (window.event) {
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		}
		else
		{
			this.eventHandler.stopPropagation();
			this.eventHandler.preventDefault();
		}
		return false;
	};
	
	return Event;
})());

/** -- file:/egipe/Applications/coreBindings/com.egipe.soca/core/elements.js -- */
Namespace ("com.egipe.soca.core");
com.egipe.objectsCounter = 0;
com.egipe.soca.core.add ("Exception", (function(){
	
	Exception.extendsClass (ReferenceError);
	function Exception (aMessage) 
	{
		this.message = aMessage;
	}
	Exception.NO_DOM_ELEMENT = 0;
	
	return Exception;
})());

/*====================================================================================
	Prototype des objets de base
====================================================================================*/
com.egipe.soca.core.add("Object", (function(){

	function Object () {}
	Object.prototype._className = "BaseObject";
	
	return Object;
})());

/*------------------------------------------------------------------------------------
	CLASSE BaseObjectWithPersistence
	Objet de base avec persistance des attributs
-------------------------------------------------------------------------------------*/
com.egipe.soca.core.add("ObjectWithPersistence", (function(){

	ObjectWithPersistence.extendsClass(com.egipe.soca.core.Object);
	function ObjectWithPersistence () {}
	ObjectWithPersistence.prototype.setPersistentAttribute = function (attName, attValue)
	{
		var curDomain = window.location.hostname;		var curPath = window.location.pathname;
		var storeGlobal = arguments.length != 2?true:false;
		attValue = attValue._serialize();
		if ("uid" in this) {
			attName = this.uid+"__"+attName;
		}
		
		if (window.globalStorage)
		{
			window.globalStorage[curDomain][curPath+"|"+attName] = attValue;
		}
		else
		{
			var now = new Date();			var expires = new Date (now.getFullYear()+1, now.getMonth(), now.getDate());
			curPath = storeGlobal?"/":curPath;
			var secure = false;			document.cookie=name+"="+escape(value)+				((expires==null) ? "" : ("; expires="+expires.toGMTString()))+				((curPath==null) ? "" : ("; path="+curPath))+				((curDomain==null) ? "" : ("; domain="+curDomain))+				((secure==true) ? "; secure" : "");
		}
	};
	ObjectWithPersistence.prototype.getPersistentAttribute = function (attName)
	{
		var curDomain = window.location.hostname;		var curPath = window.location.pathname;
		if ("uid" in this) {
			attName = this.uid+"__"+attName;
		}
		var attVal = false;
		
		if (window.globalStorage)
		{
			if (curPath+"|"+attName in	window.globalStorage[curDomain]) {
				attVal = window.globalStorage[curDomain][curPath+"|"+attName];
				if (attVal.value.indexOf("object Object") != -1)
				{
					delete window.globalStorage[curDomain][curPath+"|"+attName];
					return false;
				}
				else {	
					eval("var attObject = "+attVal+";");
					return attObject;
				}
			}
		}
		else {
			var arg=attName+"=";			var alen=arg.length;			var clen=document.cookie.length;			var i=0;
			while (i<clen) {				var j=i+alen;				if (document.cookie.substring(i, j)==arg) {		 			var endstr=document.cookie.indexOf (";", j);					if (endstr==-1) {			    		endstr=document.cookie.length;
					}
					attVal = unescape(document.cookie.substring(j, endstr));
					eval("var attObject = "+attVal+";");
					return attObject;
				}
		      i = document.cookie.indexOf(" ",i)+1;
		      if (i==0) {
		      	break;
		      }
		   }
		}		return false;	};
	return ObjectWithPersistence;
})());

/*====================================================================================
	Prototype des elements de base
====================================================================================*/
com.egipe.soca.core.add("Element", (function(){

	Element.extendsClass(com.egipe.soca.core.ObjectWithPersistence);
	function Element (mixed)
	{
		this._currentTimeout = false;
		this._eventHandlers = [];
		this.parentObject = false;
		this.htmlElement = false;
		this.isNewElement = false;
		o(this);
		if ((Utils.getType(mixed) == "array" || Utils.getType(mixed) == "arguments") && mixed.length != 0) {
			mixed = mixed[0];
		}
		/* Bug spécifique à opéra 19/11/2008
			mixed est un objet, et mixed[0] comprend bien le domElement concerné
		*/
		if ((Utils.getType(mixed) == "array" || Utils.getType(mixed) == "arguments") && mixed.length != 0) {
			mixed = mixed[0];
		}
//		var mType = Utils.getType(mixed[0]);
//		if (mType == "element" || mType == "document" || mType == "window" )
//		{
//			mixed = mixed[0];
//		}
		/* Fin bug */
		if (arguments.length==2) {
			this._attachDomElement (mixed,arguments[1]);
		}
		else {
			this._attachDomElement (mixed);
		}
		
		if ("_appendObject" in this)	{
			this._appendObject();
		}
	}
	/** 
		(private) Reçoit une chaine (élément à créer) ou un élément DOM déjà existant ou null (createHTMLElement présent) 
	**/
	Element.prototype._getClassNameRegexp = function (aClassName) {
		return new RegExp ("(?:^("+aClassName+")$)|(?:^("+aClassName+" ).*)|(?:.*( "+aClassName+")$)|(?:.*( "+aClassName+") .*)");
	};
	/** 
		(private) Reçoit une chaine (élément à créer) ou un élément DOM déjà existant ou null (createHTMLElement présent) 
	**/
	Element.prototype._attachDomElement = function (domOrString) {
		try {
			var aType = Utils.getType(domOrString);
			if (aType == "string") {
				if (arguments.length==2) {
					this.htmlElement = document.createElementNS(arguments[1], domOrString);
				}
				else {
					this.htmlElement = document.createElement(domOrString);
				}
				this.isNewElement = true;
				try {
					this.htmlElement.className = this._className;
				} catch (e) {}
			}
			else if (aType == "element" || aType == "window" || aType == "document") {	
				this.htmlElement = domOrString;
				this._onAttach(true);
			}
			else if ("createHtmlElement" in this) {
				this.htmlElement = this.createHtmlElement();
				this.isNewElement = true;
			}
			if (this.htmlElement)
			{
				this.htmlElement.jsobject = this;
				this._attachEvents();
			}
		}
		catch (e) {	
			_log(domOrString+" | "+e.message); 
		}
	};
	/**
		(private) Attache les événements adéquats (selon qu'ils existe des méthode dont le nom est 
		formé selon le masque /(.*)Event$/
	**/
	Element.prototype._attachEvents = function () {
		var evt = false;
		var prop;
		for (prop in this) {
			evt = prop.match(/(.*)Event$/);
			if (evt != null && evt [1] != "dispatch" && evt [1] != "attach") {
				if ("addEventListener" in this)	{
					this.addEventListener (evt [1], this._onevent, true);
				} else {
					window.addEventListener(evt [1], this._onevent, true);
				}
				this._eventHandlers.push(evt [1]);
			}
		}
	};
	
	/**
		(indirect) Centralise la gestion des événement. Appelle la méthode liée à l'événement (nommée event.type + "Event")
		dans le context du premier jsobjet dans les ancètres du noeud qui génère l'événement 
	**/
	Element.prototype._onevent = function (evt) {
		try 
		{
			var cbEvent = new com.egipe.soca.core.Event(evt);
			var cnode = cbEvent.target;
			while (typeof(cnode.jsobject) !== "object" || !("htmlElement" in cnode.jsobject)) {
				cnode = cnode.parentNode;
			}
			if ((cbEvent.type+"Event" in cnode.jsobject)) {	
				return cnode.jsobject[cbEvent.type+"Event"](cbEvent);
			}
			else if (("parentObject" in cnode.jsobject) && (cbEvent.type+"Event" in cnode.jsobject.parentObject)) {
				return cnode.jsobject.parentObject[cbEvent.type+"Event"](cbEvent);
			}
		}
		catch (e) {	
			_log(evt.target+" "+evt.type+" "+e.lineNumber+" | "+e.message); 
		}
		return true;
	};
	
	/**
		(indirect) gère l'événement d'attachement du noeud;
	**/
	Element.prototype._onAttach = function () {
		if (this.htmlElement) {
			if (this.htmlElement.parentNode) {
				var currentNode = this.htmlElement.parentNode;
				while (Utils.getType(currentNode) == "element" && (typeof(currentNode.jsobject) !== "object" || !("htmlElement" in currentNode.jsobject))) {
					currentNode = currentNode.parentNode;
				}
				this.parentObject = currentNode.jsobject;
			}
			if ("onAttach" in this) {
				this.onAttach();
			}
		}
	};
	/**
		(public) Retourne l'état parmis 	ELEMENT_ORPHAN|ELEMENT_INSERT|ELEMENT_INSTANCIATE
	**/
	Element.prototype.state = function () {
		var currentState = com.egipe.soca.NO_ELEMENT;
		if (this.htmlElement) {	
			currentState &= com.egipe.soca.ELEMENT_ORPHAN; 
			if (this.htmlElement.parentNode) {
				currentState &= com.egipe.soca.ELEMENT_INSERT; 
			}
		}
		return currentState;	
	};
	
	/**
		(public) Envoie l'evenement de type aType
	**/
	Element.prototype.dispatchEvent = function (aType) {
		var evt = document.createEvent("HTMLEvents");
		evt.initEvent(aType,true,false);
		this.htmlElement.dispatchEvent(evt);
	};
	/**
		(public) Attache un événement
	**/
	Element.prototype.attachEvent = function (aType, anHandler) {
		var self = this;
		if (this[aType+"Event"]) {
			this[aType+"Event"] = function (evt) { self[aType+"Event"](evt); anHandler (evt); };
		} else {
			this[aType+"Event"] = anHandler;
			this.addEventListener(aType, this._onevent, true);
			this._eventHandlers.push(aType);	
		}
	};

	return Element;
})());


/*------------------------------------------------------------------------------------
	classe BaseElement
	Element de base, étend les objets avec persistence (possibilité de conserver des paramètres)
	Etend l'objet HTML de base
-------------------------------------------------------------------------------------*/
com.egipe.soca.core.add("HTMLElement", (function(){

	HTMLElement.extendsClass(com.egipe.soca.core.Element);
	HTMLElement.implementsClass(com.egipe.soca.core.interfaces.HTMLElement);

	function HTMLElement ()
	{
		this._parent()(arguments);
		if (this.hasAttribute("id"))	{
			this.uid = this.getAttribute("id");
		} 
		else {
			this.setAttribute("id", "obj"+((com.egipe.objectsCounter)++));
		}
	}
	/**
		(public) Retourne si l'élément a bien la classe donnée
	**/
	HTMLElement.prototype.hasClass = function (aClassName) {
		return this.getClass().match(this._getClassNameRegexp(aClassName));
	};
	/**
		(public) Retourne si l'élément a bien la classe donnée
	**/
	HTMLElement.prototype.getClass = function () {
		try {
			return this.htmlElement.className;
		} catch (e) {
			return this.htmlElement.getAttribute("class");
		}
	};
	/**
		(public) Ajoute une classe à l'élément
	**/
	HTMLElement.prototype.addClass = function (aClassName) {
		if (!this.hasClass(aClassName)) {
			try {
				this.htmlElement.className += ((this.htmlElement.className.length!=0)?" ":"")+aClassName;
			} catch (e) {
				this.htmlElement.setAttribute("class",aClassName);
			}
		}
	};
	/**
		(public) Retire une classe à l'élément
	**/
	HTMLElement.prototype.removeClass = function (aClassName) {
		if (this.hasClass(aClassName)) {
			
			var parts = this._getClassNameRegexp(aClassName).exec(this.getClass());
			for (var i=1; i<parts.length;i++) {
				if (parts[i] && parts[i].length != 0) {
					try {
						var cName = this.htmlElement.className;
						this.htmlElement.className = cName.replace(parts[i], "");
					} catch (e) {
						var c = this.htmlElement.getAttribute("class");
						this.htmlElement.setAttribute("class",c.replace(parts[i], ""));
					}
					break;
				}
			}
		}
	};
	/**
		(public) Remplace une class par une autre;
	**/
	HTMLElement.prototype.changeClass = function (oldClassName, newClassName) {
		if (this.hasClass(oldClassName)) {
			this.htmlElement.className = this.htmlElement.className.replace(oldClassName, newClassName);		
		}	
	};
	HTMLElement.prototype.keypress = function (aKeyCode,aCharCode) {
		var evt = document.createEvent("KeyboardEvent");
		evt.initKeyEvent("keypress",true,true,window,false,false,false,false,aKeyCode,aCharCode);
		this.htmlElement.dispatchEvent(evt);
	};
	
	/**
		(public) Retourne le module attaché à cet élément, ou le module de base s'il existe, ou false
	**/
	HTMLElement.prototype.getModule = function () {
		if (this._namespace) {
			return com.egipe.getModule(this._namespace);
		} else if (com.egipe.getModule("com.egipe.soca.base")) {
			return com.egipe.getModule("com.egipe.soca.base");
		}
		return false;
	};
	/**
		(public) Détruit l'objet (destruction du noeud html)
	**/
	HTMLElement.prototype.destruct = function (evt) {
		try {
			this.htmlElement.parentNode.removeChild(this.htmlElement);
		} catch (e) {}
	};
	/**
		(public) Retourne les noeuds enfants (uniquement les DomElement)
	**/
	HTMLElement.prototype.getChildren = function () {
		var items = this.htmlElement.childNodes;
		var len = items.length;
		var i = 0;
		var children = [];
		if (len != 0)
		{			do	{
				if (items[i].nodeType == 1) {
					children.push(items[i]);
				}
			}			while (++i < len);
		}		return children;
	};
	/**
		(public) Retourne les déscendants de l'élément selon un selecteur
	**/
	HTMLElement.prototype.getDescendants = function (selector) {
		return this.getElementsBySelector(selector, this.htmlElement);
	};
	
	/**
		(public) Indique si l'élément contient un noeud donné
	**/
	HTMLElement.prototype.contains = function (relatedElement) {
		if ("compareDocumentPosition" in this.htmlElement) {
			return !!(this.htmlElement.compareDocumentPosition(relatedElement) & 16);
		} else if ("contains" in this.htmlElement) {
			return this.htmlElement.contains(relatedElement);
		}
		return true;
	};
	/**
		(public) ajoute un élément enfant dans l'élément
	**/
	HTMLElement.prototype.appendElement = function (someTagName) {
		return this.htmlElement.appendChild(document.createElement(someTagName));
	};
	/**
		(public) ajoute un élément enfant dans l'élément
	**/
	HTMLElement.prototype.append = function (someElement) {
		this.htmlElement.appendChild(someElement.htmlElement);
		someElement._onAttach ();
		return someElement;
	};
	/**
		(public) atache l'élément au noeud donné
	**/
	HTMLElement.prototype.insertIn = function (someDomNode) {
		someDomNode.appendChild(this.htmlElement);
		this._onAttach();
	};
	/**
		(public) atache l'élément avant un noeud donné
	**/
	HTMLElement.prototype.insertBefore = function (someDomNode) {
		someDomNode.parentNode.insertBefore(this.htmlElement, someDomNode);
		this._onAttach();
	};
	/**
		(public) atache l'élément après un noeud donné
	**/
	HTMLElement.prototype.insertAfter = function (someDomNode) {
		if (someDomNode.nextSibling) {
			someDomNode.parentNode.insertBefore(this.htmlElement, someDomNode.nextSibling);
		}
		else {
			someDomNode.parentNode.appendChild(this.htmlElement);
		}
		this._onAttach();
	};
	/* Gestion des timeout */
	HTMLElement.prototype.setTimeout = function (cmethod, interval /*, arguments */) {
		this.clearTimeout();
		var self = this;
		var cmd;
		if (arguments.length == 3)
			cmd = function () { return self[cmethod](arguments[2]); };
		else 
			cmd = function () { return self[cmethod](); };
		
		//var cmdString = "if (document.getElementById('"+ this.uid +"')) {document.getElementById('"+ this.uid +"').jsobject."+cmethod+"();}";
		this._currentTimeout = window.setTimeout(cmd, interval);
	};
	HTMLElement.prototype.clearTimeout = function () {
		if (this._currentTimeout) {
			window.clearTimeout(this._currentTimeout);
		}
	};
	/* Manipulation des styles */
	HTMLElement.prototype.setStyle = function (astyle, avalue) {
		this.htmlElement.style[astyle] = avalue;
	};
	HTMLElement.prototype.setStyles = function (Rule) {
		document.addRule("#"+this.uid+" "+Rule);
	};
	HTMLElement.prototype.setPartBackground = function (skin, position,radius,gradientHeight) {
		var cUri = "/services/getImagePart.php?image=images/rounded/"+skin+".png&radius="+radius+"&gradheight="+gradientHeight+"&part="+position;
		var positions = position.split("_");
		var hpos = positions[0];
		var vpos = positions[1];
		
		this.htmlElement.style.backgroundImage = "url('"+cUri+"')";
		this.htmlElement.style.backgroundPosition = hpos+" "+vpos;
		this.htmlElement.style.backgroundRepeat = "no-repeat";
		if (hpos=="center")	{
			this.htmlElement.style.backgroundRepeat = "repeat-y";
		}
		if (vpos=="center")	{
			this.htmlElement.style.backgroundRepeat = "repeat-x";
		}
		
	};
	HTMLElement.prototype.setContent = function (aContent) {
		this.htmlElement.innerHTML = aContent;
	};
	HTMLElement.prototype.getContent = function () {
		return this.htmlElement.innerHTML;
	};
	
	HTMLElement.prototype.display = function () {
		this.htmlElement.style.display = "block";
	};
	HTMLElement.prototype.hide = function () {
		this.htmlElement.style.display = "none";
	};
	HTMLElement.prototype.isActive = function () {
		return this.htmlElement.style.display != "none";
	};
	
	HTMLElement.prototype.setVisible = function () {
		this.htmlElement.style.visibility = "visible";
	};
	HTMLElement.prototype.setHidden = function () {
		this.htmlElement.style.visibility = "hidden";
	};
	HTMLElement.prototype.getOffsetTop = function () {
		var oTop = this.htmlElement.offsetTop;
		var cNode = this.htmlElement;
		while (cNode.tagName.toLowerCase() != "body")
		{
			cNode = cNode.parentNode;
			oTop += cNode.offsetTop;
		}
		return oTop;
	};

	return HTMLElement;
})());

/*------------------------------------------------------------------------------------
	CLASSE ElementWithTarget
-------------------------------------------------------------------------------------*/
com.egipe.soca.core.add("ElementWithTarget", (function(){

	function ElementWithTarget (targetObject, targetMethod) {
		this.targetObject = targetObject;
		this.targetMethod = targetMethod;
	}
	ElementWithTarget.prototype.execMethod = function () {
		if (this.targetMethod in this.targetObject) {
			return this.targetObject[this.targetMethod](this);
		} else {
			_log("Method "+this.targetMethod+" of "+this.targetObject._className+" unknown");
		}
		return fakse;
	};
	
	return ElementWithTarget;
})());

/*------------------------------------------------------------------------------------
	CLASSE RegisterObject
-------------------------------------------------------------------------------------*/
com.egipe.soca.core.add("RegisterObject", (function(){

	function RegisterObject () {}
	RegisterObject.prototype._appendObject = function () {
		if (!(this._className in this.getModule().registredObjects)) {
			this.getModule().registredObjects[this._className] = [];
		}
		this.getModule().registredObjects[this._className].push(this);
	};

	return RegisterObject;
})());
/*------------------------------------------------------------------------------------
	CLASSE BaseRequestElement
	Element de Base avec gestion des requêtes HTTP.
-------------------------------------------------------------------------------------*/
com.egipe.soca.core.add("ElementWithRequestor", (function(){

	ElementWithRequestor.extendsClass(com.egipe.soca.core.HTMLElement);
	function ElementWithRequestor ()
	{
		this._parent()(arguments);
		this.xmlResponse = false;
		this.textResponse = false;
		this.currentUrl = false;
		this.currentParamaters = false;
		this.currentData = null;
		this.currentMethod = "GET";
		this.inProgress = false;
		this.isRefreshOnce = false;
	}
	
	ElementWithRequestor.prototype._getHTTPObject = function (tt) {
	     var http_request = false;	   	    if (window.XMLHttpRequest)	    {
			     try			     {			         http_request = new XMLHttpRequest();			     }			     catch (e)			     {			         http_request = false;			     }
	    }	    else	    {	        try	        {	            http_request = new ActiveXObject("Msxml2.XMLHTTP");	        }	        catch (e)	        {	            try	            {	                http_request = new ActiveXObject("Microsoft.XMLHTTP");	            }	            catch (e)	            {	                http_request = false;	            }	        }	    }	    return http_request;	};
	ElementWithRequestor.prototype._SendHTTPRequest = function (rurl, method, data) 
	{
		if (!this.xmlReqObject) {
	   	this.xmlReqObject = this._getHTTPObject();
		}
	   	var target;			if (this.xmlReqObject)
		{
			try 
			{
				if (this.xmlReqObject.status !== 0) {
					this.xmlReqObject.abort();
				}
			}
			catch (e) {}
			
			this.inProgress = true;
			this.currentUrl = rurl;
			this.currentMethod = method;
			this.currentData = data;
		
			if ("addThrobber" in this) {
				this.addThrobber();
			}
			if (method == "PUT") {
				this.xmlReqObject.open(method, rurl, true); 
				//this.xmlReqObject.setRequestHeader("Content-type", "text/plain");
			}
			else {
				this.xmlReqObject.open(method, rurl); 
			}
			if (method == "POST") {
				if (arguments.length != 4)
				{
					// Arguments 4 indique un envoi binaire
					this.xmlReqObject.setRequestHeader("Content-type","application/x-www-form-urlencoded");
				}
				this.xmlReqObject.setRequestHeader("Content-length",data.length);
			}
			if (arguments.length==4 && arguments[3]) {
				this.xmlReqObject.setRequestHeader('X-Referer', arguments[3]);
			}
			
			if (arguments.length==5 && arguments[4]) {
				this.xmlReqObject.setRequestHeader('If-Modified-Since', arguments[4]);
				//this.xmlReqObject.channel.loadFlags |= Components.interfaces.nsIRequest.LOAD_BYPASS_CACHE; 
			}
			
			target = this.htmlElement;
			this.xmlReqObject.onreadystatechange = function () {
				var xmlreq = target.jsobject.xmlReqObject;
				if (xmlreq.readyState == 4)
				{
					if (xmlreq.status == 200 || xmlreq.status == 204)
					{
						if (xmlreq.responseXML && xmlreq.responseXML.documentElement.tagName != "parsererror" && xmlreq.responseXML.documentElement.childNodes.length !== 0) {
							target.jsobject.xmlResponse = xmlreq.responseXML;
						}
						else {
							target.jsobject.xmlResponse = false;
						}
						target.jsobject.textResponse = xmlreq.responseText;
						target.jsobject.inProgress = false;
					}
					else
					{
						target.jsobject.xmlResponse = false;
						target.jsobject.textResponse = "Erreur "+xmlreq.status+" url : "+target.jsobject.currentUrl;
					}
					target.jsobject.doRequest();
			  	}
			};
			if (method == "PUT") {
				this.xmlReqObject.sendAsBinary(data); 
			}
			else {
				this.xmlReqObject.send(data); 
			}
		}
	};
	ElementWithRequestor.prototype._SendGETRequest = function (rurl) 
	{
		if (arguments.length==3) {
			this._SendHTTPRequest (rurl, "GET", null, arguments[1], arguments[2]);
		}
		else if (arguments.length==2) {
			this._SendHTTPRequest (rurl, "GET", null, arguments[1]);
		}
		else {
			this._SendHTTPRequest (rurl, "GET", null);
		}
	};
	ElementWithRequestor.prototype._getParentJsObject = function (node)
	{
		while (node.tagName.toLowerCase() != "body" && !node.jsobject.HTMLElement){
			node = node.parentNode;
		}
		return node;
	};
	ElementWithRequestor.prototype.refresh = function ()
	{
		if (arguments.length != 0) {
			this.currentUrl = arguments[0];
		}
		if (this.currentUrl)
		{
			if ("content" in this) {
				this.content.innerHTML = "";
			}
			else {
				this.htmlElement.innerHTML = "";
			}
			this.isRefreshOnce = true;
			var curl = this.currentUrl;
			if ("currentParameters" in this && this.currentParameters.length != 0)
			{
				curl = curl+"&"+this.currentParameters.substr(1);
			}
			this._SendHTTPRequest (curl, this.currentMethod, this.currentData);
		}
	};
	
	ElementWithRequestor.prototype.doRequest = function () 
	{
		this.inProgress = false;
	};

	return ElementWithRequestor;
})());

/** -- file:/egipe/Applications/coreBindings/com.egipe.soca/core/dom.js -- */
Namespace ("com.egipe.soca.core");
/*====================================================================================
	Dom created object extensions (IE has'nt native DomObject)
	Conditional DOM Extension
====================================================================================*/
/*------------------------------------------------------------------------------------
	_window 
-------------------------------------------------------------------------------------*/
com.egipe.soca.core.add("_window", (function(){

	_window.extendsClass(com.egipe.soca.core.Element);
	function _window () 
	{
		this._parent()(window);
		this.uid = "window";
		this.document = new com.egipe.soca.core._document ();
		
		this.addCapabilities ();
		
		if (!window.addEventListener) {
			window.addEventListener = this._addEventListener;
		}
		window.getInnerSize = this.getInnerSize;
		
	}
	_window.prototype.addCapabilities = function()  
	{
		if (window.ActiveXObject) {
			window.navigator.ie = window.XMLHttpRequest ? 'ie7' : 'ie6';
		}
		else if (document.childNodes && !document.all && !navigator.taintEnabled) {
			window.navigator.webkit = window.xpath ? 'webkit420' : 'webkit419';
		}
		else if (document.getBoxObjectFor != null) {
			window.navigator.gecko = true;
		}
	};
	_window.prototype._addEventListener = function(anEventType, anHandler, hasCapture)  
	{
		if (this.attachEvent) { 
			this.attachEvent('on' + anEventType, anHandler); 
		}	};
	_window.prototype.getInnerSize = function () 
	{		var winWidth = 0, winHeight = 0;
		if( typeof( window.innerWidth ) == 'number' ) {
			// Non IE6			winWidth = window.innerWidth;			winHeight = window.innerHeight;		} 
		else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'			winWidth = document.documentElement.clientWidth;			winHeight = document.documentElement.clientHeight;		} 
		else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {			//IE 4 compatible			winWidth = document.body.clientWidth;			winHeight = document.body.clientHeight;		}
		return {"width":winWidth,"height":winHeight};	};
	return _window;
})());

/*------------------------------------------------------------------------------------
	_document 
-------------------------------------------------------------------------------------*/
com.egipe.soca.core.add("_document", (function(){

	_document.extendsClass(com.egipe.soca.core.Element);
	function _document () 
	{
		this._parent()(document);
		this.uid = "document";
		this.parentObject = window.jsobject;
		this.includedFiles = [];
		this.currentSheet = false;
		this.initialWrite = document.write;
		
		document.xpath = !!(document.evaluate);
		if (!document.importNode || window.webkit) {			document.importNode = this.importNode;		}
		if (!document.all) {
			document.write = this.write;
		}
		
		if (!document.getElementsBySelector) {
			document.getElementsBySelector = this.getElementsBySelector;
		}
		
		if (document.getElementsByClassName) {
			document._getElementsByClassName = document.getElementsByClassName;
		}
		document.getElementsByClassName = this.getElementsByClassName;
		
		document.include = this.include;
		document.addRule = this.addRule;
		 
		this.initStyles();
	}
	_document.prototype.initStyles = function () {
		if (!document.styleSheets.length && document.head) {
			document.head.appendChild(document.createElement("style"));
		}
		if (!window.navigator.webkit)	{
			this.currentSheet = document.styleSheets[0];
		}
	};
	_document.prototype.addRule = function (rule) {
		var style = false;
		var aRule = false;
		try {
			if(document.styleSheets)
			{
				if (!window.navigator.webkit)
				{
				 	var a   = $(this).currentSheet;
			 		var arr = rule.replace(/}.*/,'').split('{');
			 		if	(a.insertRule) {
			 			aRule = a.cssRules.length;
			 			a.insertRule(rule,aRule);
			 		}
			 		else if(a.addRule)
			 		{
			  			var arr2 = arr[0].split(/,/);
			  			for(var i=0;i<arr2.length;i++) {
			  				aRule = a.addRule(arr2[i],arr[1]);
			  			}
			  		}
		 		}
		 		else
		 		{
		 			style = document.head.getElementsByTagName("style").item(0);
		 			if (!style)
		 			{
		 				style = document.head.appendChild(document.createElement("style"));
		 			}
					style.appendChild(document.createTextNode(rule));
		 		}
		 	}
		}
		catch (e) {}
		return aRule;
	};
	
	_document.prototype.importNode = function(aNode, appendChid) 
	{
		var imported;
		var attrs;		if (node.nodeType == 1)  {
			imported = document.createElement(aNode.nodeName);			attrs = aNode.attributes;			for (i = attrs.length - 1; i >= 0; i--) {				imported.setAttribute(attrs[i].name, attrs[i].value);
			}			if (aNode.style && aNode.style.cssText) {
				imported.style.cssText = node.style.cssText;
			}		} 
		else if (aNode.nodeType == 3) {
			imported = document.createTextNode(aNode.nodeValue);
		}		if(appendChid && aNode.hasChildNodes()) {		   var oChild = aNode.firstChild;		   do {				imported.appendChild(document.importNode(oChild, true));				oChild = oChild.nextSibling;			} while (oChild);		}		return imported;	};
	
	_document.prototype.write = function (aString) 
	{
	    // Watch for writing out closing tags, we just ignore these (as we auto-generate our own)	    if ( aString.match(/^<\//) ) {
	    	return;
	    }		    // Make sure & are formatted properly, but Opera messes this up and just ignores it	    if ( !navigator.opera ) {	        aString = aString.replace(/&(?![#a-z0-9]+;)/g, "&amp;");
	    }		    // Watch for when no closing tag is provided (Only does one element, quite weak)	    aString = aString.replace(/<([a-z]+)(.*[^\/])>$/, "<$1$2></$1>");	       	    // Mozilla assumes that everything in XHTML innerHTML is actually XHTML - Opera and Safari assume that it's XML	    if ( !navigator.gecko ) {	        aString = aString.replace(/(<[a-z]+)/g, "$1 xmlns='http://www.w3.org/1999/xhtml'");
	    }
	    
	    /* PATCH  Erreur CKEditor**/
	  	 aString = aString.replace(/<\/script><\/script>/,"</script>");
	  	 /* PATCH */	       	    // The HTML needs to be within a XHTML element
	    var div = document.createElementNS("http://www.w3.org/1999/xhtml","div");	    div.innerHTML = aString;
	       	    /* PATCH  Erreur CKEditor**/
	    if ( aString.match(/<\/script>/) )
	    {
	    		document.getElementsByTagName("head").item(0).appendChild(div.firstChild);
	    }
	    else
		 /* PATCH */	    
		 {
			 // Find the last element in the document			 var pos;			    			 // Opera and Safari treat getElementsByTagName("*") accurately always including the last element on the page			 if ( !navigator.gecko ) {			     pos = document.getElementsByTagName("*");			     pos = pos[pos.length - 1];			            			 } 
			 // Mozilla does not, we have to traverse manually			 else {			     pos = document;			     while ( pos.lastChild && pos.lastChild.nodeType == 1 ) {			         pos = pos.lastChild;
			     }			 }			    			 // Add all the nodes in that position			 var nodes = div.childNodes;			 while ( nodes.length ) {			     pos.parentNode.appendChild( nodes[0] );
			 }
		}	};
	_document.prototype.include = function (filename)	
	{
		for (var i=0; i < $(this).includedFiles.length; i++) {
			if ($(this).includedFiles[i] == filename) {
				return false;
			}
		}
		var script = document.createElementNS(com.egipe.soca.XHTMLNS, "script");
		script.setAttribute("type", "text/javascript");
		script.setAttribute("src", filename);
		document.getElementsByTagName("head")[0].appendChild(script);
		$(this).includedFiles.push (filename);
		return true;
	};
	_document.prototype.getElementsBySelector = function (simpleSelector) 
	{
		/*
		p | .toto | #someid | p.essais
		avec [someatt=somevalue] ou non
		*/

		try {
			var tagName = false;
			var parts_before = simpleSelector.match(/([a-zA-Z]*)([.|#]*)([a-zA-Z]*)/);
			if (parts_before[1].length != 0) {
				tagName = parts_before[1];
				if (parts_before[2].length != 0) {
					simpleSelector = simpleSelector.substr(tagName.length);
				}
			}
			var parts = simpleSelector.match(/^([.|#]?)([a-zA-Z]*)(\[(.*)=(.*)\])?/), tempColl = [], collection = [], refNode = document;
			var typeSelector = parts[1], stringSelector = parts [2];
			var attributeSelector = Utils.isDef(parts[4])?parts[4].substr(1):false;
			var valueSelector = Utils.isDef(parts[5])?parts[5]:false;

			if (arguments.length == 2) {
				refNode = arguments[1];
			}


				switch (typeSelector) 
				{
					case "#":
						// stringSelector is an id
						if (document.getElementById(stringSelector)) {
							tempColl.push(document.getElementById(stringSelector));	
						}
						break;
					case ".":
						// stringSelector is a class
						tempColl = document.getElementsByClassName(stringSelector, refNode, tagName);
						break;
					case "":
						// stringSelector is a tagName
						tempColl = refNode.getElementsByTagName(stringSelector);
						break;
					default:
						break;
				}
				for (var i=0; i<tempColl.length; i++)
				{
					if (attributeSelector) {
						if (tempColl[i].hasAttribute(attributeSelector) && tempColl[i].getAttribute(attributeSelector) == valueSelector) {
							collection.push(tempColl[i]);
						}
					}
					else {
						collection.push(tempColl[i]);
					}
				}
			return collection;
		}
		catch (e) {
			_log(simpleSelector+" | "+e.message); 
		}
		return false;
	};
	_document.prototype.getElementsByClassName = function (cName)
	{
		var i=0;
		var coll = [];
		var tagName = false;
		var refNode = document;
		if (arguments.length == 2) {
			refNode = arguments[1];
		}
		if (arguments.length == 3 && arguments[2]) {
			tagName = arguments[2];
		}
		if (!document.all)
		{
			var hColl = false;
			if ("_getElementsByClassName" in refNode) {
				hColl = refNode._getElementsByClassName(cName);
			} else {
				hColl = refNode.getElementsByClassName(cName);
			}
			
			for(i=0;i<hColl.length;i++)
			{
				if (!tagName || tagName == hColl.item(i).tagName) {
					coll.push(hColl.item(i));
				}
			}
		}
		else
		{
			var elements;
			elements = refNode.getElementsByTagName("*");
			var rExp = new RegExp ("(^"+cName+"$)|(^"+cName+" .*)|(.* "+cName+"$)|(.* "+cName+" .*)");
			for (i=0; i<elements.length; i++)
			{
				try {
					
					if (elements[i].className.match(rExp) && (!tagName || tagName == elements[i].tagName)) {
						coll.push(elements[i]);
					}
				}
				catch (e)
				{
					alert(e);
				}
			}
		}
		return coll;
	};

	return _document;
})());



/** -- file:/egipe/Applications/coreBindings/com.egipe.soca/core/module.js -- */
Namespace ("com.egipe.soca.core");
/*------------------------------------------------------------------------------------
	CLASSE Module
	Module avec chargement des comportements et règles CSS
-------------------------------------------------------------------------------------*/
com.egipe.soca.core.add("Module", (function(){
	
	Module.extendsClass(com.egipe.soca.core.Object);
	function Module ()
	{
		this._currentTimeout = false;
		this.instanciatesBehaviors = new Object ();
		this.registredObjects = new Object ();
		this.isLoaded = false;
		this.isDisabled = false;
		this.isAsync = false;
		o(this);
		var instanceName = this._namespace;
		
		if (!com.egipe.instanciatesModules) 
		{
			com.egipe.instanciatesModules = {};
			com.egipe.getModule = function (aString) {
				if (aString in com.egipe.instanciatesModules) {
					return com.egipe.instanciatesModules[aString];
				}
				return false;
			};
		}
		com.egipe.instanciatesModules[instanceName] = this;
		if ("initBehavior" in this) {
			window.addEventListener(
				"load", 
				function () { 
					if (!com.egipe.instanciatesModules[instanceName].isDisabled) { com.egipe.instanciatesModules[instanceName].initBehavior(); } 
					if (!com.egipe.instanciatesModules[instanceName].isAsync) { com.egipe.instanciatesModules[instanceName].isLoaded = true; } 
				}, 
				false);
		}
		else {
			this.isLoaded = true;
		}
		if ("onpageshow" in this) {
			window.addEventListener(
				"pageshow", 
				function () { 
					_log("show :"+instanceName);
					com.egipe.instanciatesModules[instanceName].onpageshow();
				}, 
				false);
		}
		if ("onpagehide" in this) {
			window.addEventListener(
				"pagehide", 
				function () { 
					_log("hide :"+instanceName);
					com.egipe.instanciatesModules[instanceName].onpagehide();
				}, 
				false);
		}
	
		if ("addCssRules" in this) {
			this.addCssRules();
		}
		if ("resize" in this) {
			window.addEventListener("resize", function () { com.egipe.instanciatesModules[instanceName].resize(); }, false);
		}
		if ("scroll" in this) {
			window.addEventListener("scroll", function () { com.egipe.instanciatesModules[instanceName].scroll(); }, false);
		}
		if ("destruct" in this) {
			window.addEventListener("beforeunload", function (evt) { com.egipe.instanciatesModules[instanceName].destruct(evt); }, false);
		}
	}
	Module.prototype.getObjectsByClassName = function (cName) {
		if (cName in this.registredObjects) {
			return this.registredObjects[cName];
		}
		return [];
	};
	Module.prototype.setTimeout = function (cmethod, interval) {
		this.clearTimeout();
		var instance = com.egipe.instanciatesModules[this._namespace];
		//var cmdString = "window['"+this._className+"Instance']."+cmethod+"();";
		var cmd = function () { return instance[cmethod](); };
		//var cmdString = "if (document.getElementById('"+ this.uid +"')) {document.getElementById('"+ this.uid +"').jsobject."+cmethod+"();}";
		this._currentTimeout = window.setTimeout(cmd, interval);
	};
	Module.prototype.clearTimeout = function () {
		if (this._currentTimeout) {
			window.clearTimeout(this._currentTimeout);
		}
	};
	Module.prototype._getCName = function (fHandler)
	{
		return fHandler.toString().match(/function\s*(\w+)/)[1];
	};
	
	return Module;

})());
// Fin de chargement du module
com.egipe.soca.core.isComplete = true;

/** -- file:/egipe/Applications/coreBindings/com.egipe.soca/base/base.js -- */
Namespace ("com.egipe.soca.base");
/*------------------------------------------------------------------------------------
	Module Base
	Vérifie le chargement des modules
-------------------------------------------------------------------------------------*/
com.egipe.soca.base.add("Module", (function(){

	Module.extendsClass(com.egipe.soca.core.Module);
	function Module () 
	{
		this._parent()();
		$(window, com.egipe.soca.core._window);
		this.setTimeout("checkModules", 100);
	}
	Module.prototype.checkModules = function () 
	{
		if (com.egipe.instanciatesModules.length == 0) {
			this.setTimeout("checkModules",100);
		}
		if (o(com.egipe.instanciatesModules).foreach(this.checkModule, this))
		{
			this.isAllLoaded = true;
		}
		else {
			this.setTimeout("checkModules",100);
		}
	};
	Module.prototype.checkModule = function (aModule) 
	{
		if (aModule.isLoaded) {
			if ("isFinalized" in aModule && !aModule.isFinalized) {
				aModule.finalize();
				aModule.isFinalized = true;
			}
			return true;
		}
		return false;
	};
	return Module;
})());

new com.egipe.soca.base.Module ();

/* Element natif de base */
/*------------------------------------------------------------------------------------
	CLASSE Canvas
-------------------------------------------------------------------------------------*/
com.egipe.soca.base.add("Canvas", (function(){
	
	Canvas.extendsClass(com.egipe.soca.core.HTMLElement);
	function Canvas (w,h)
	{
		this._parent()("canvas");
		this.context = false;
		if (this.htmlElement.getContext) {
			this.context = this.htmlElement.getContext('2d');
		}
		this.width = w;
		this.height = h;
		this.htmlElement.width = w;
		this.htmlElement.height = h;
	}
	Canvas.prototype.getImageData = function (x, y, w, h) {
		var d = this.context.getImageData(x, y, w, h);
		return d.data;
	};
	Canvas.prototype.putImageData = function (odata, x, y) {
		return this.context.putImageData(odata, x, y);
	};
	Canvas.prototype.drawImage = function (i, x, y, w, h) {
		this.context.clearRect(x, y, w, h);
		this.context.drawImage(i,x, y, w, h);
	};
	Canvas.prototype.desaturate = function () {
		if (this.context)
		{
			var oDataSrc = this.getImageData(0, 0, this.width, this.height);
			var oDataDst = this.getImageData(0, 0, this.width, this.height);
			var x, y, iOffsetY, iBrightness;
			y = this.height;
			do {
				iOffsetY = (y-1)*this.width*4;
				x = this.width;
				do {
					iOffset = iOffsetY + (x-1)*4;
					iBrightness = Math.round(oDataSrc[iOffset]*0.3 + oDataSrc[iOffset+1]*0.59 + oDataSrc[iOffset+2]*0.11);
		
					oDataDst[iOffset] = iBrightness;
					oDataDst[iOffset+1] = iBrightness;
					oDataDst[iOffset+2] = iBrightness;
					oDataDst[iOffset+3] = oDataSrc[iOffset+3];
		
				} while (--x);
			} while (--y);
			this.putImageData(oDataDst,0,0);
		}
	};
	
	return Canvas;
})());
/*------------------------------------------------------------------------------------
	CLASSE Image
-------------------------------------------------------------------------------------*/
com.egipe.soca.base.add("Image", (function(){

	Image.extendsClass(com.egipe.soca.core.HTMLElement);
	function Image (/* imgUrl, width, height */)
	{
		this._parent()("img");
		if (arguments.length > 0) {
			this.setAttribute("src", arguments[0]);
		}
		if (arguments.length == 3) {
			this.htmlElement.width = arguments[1];
			this.htmlElement.height = arguments[2];
		}	
	}
	Image.prototype.loadEvent = function () {
		this.width = this.htmlElement.width;
		this.height = this.htmlElement.height;
	};
	return Image;
})());




/* Comportement de base des elements HTML */
/*------------------------------------------------------------------------------------
	CLASSE Button
	Trois état : normal, désactivé, enclanché
-------------------------------------------------------------------------------------*/
com.egipe.soca.base.add("Button", (function(){

	Button.extendsClass(com.egipe.soca.core.HTMLElement);
	Button.extendsClass(com.egipe.soca.core.ElementWithTarget);
	
	function Button (targetObject, targetMethod, imageSrc)
	{
		this._parent(com.egipe.soca.core.HTMLElement)("div");
		this._parent(com.egipe.soca.core.ElementWithTarget)(targetObject, targetMethod);
		
		this.isEnabled = true;
		this.isToogled = false;
		
		this.image = this.appendChild(new Image());
		this.canvas = false;

		if (arguments.length == 4)
		{
			var self = this;
			this.image.style.display = "none";
			this.image.onload = function () { self.createCanvas (this);};
		}
		this.image.setAttribute("src", imageSrc);
	}
	Button.prototype.clickEvent = function (evt) {
		if (this.isToogled || (!this.isToogled && this.isEnabled)) {
			return this.execMethod();
		}
		return false;
	};
	Button.prototype.enable = function () {
		this.isEnabled = true;
		this.htmlElement.style.opacity = 1;
		if (this.canvas)
		{
			this.canvas.display();
			this.canvasDisabled.hide();
		}
	};
	Button.prototype.disable = function () {
		this.isEnabled = false;
		this.htmlElement.style.opacity = 0.6;
		if (this.canvas)
		{
			this.canvas.hide();
			this.canvasDisabled.display();
		}
	};
	Button.prototype.createCanvas = function (anImage) {
		this.canvas = this.canvas?this.canvas:this.append(new com.egipe.soca.base.Canvas(anImage.width, anImage.height));
		this.canvas.drawImage(anImage,0,0,anImage.width, anImage.height);
		
		this.canvasDisabled = this.canvasDisabled?this.canvasDisabled:this.append(new com.egipe.soca.base.Canvas(anImage.width, anImage.height));
		this.canvasDisabled.drawImage(anImage,0,0,anImage.width, anImage.height);
//		this.canvasDisabled.desaturate();
		this.canvasDisabled.hide();
	};
	
	return Button;
})());
/*------------------------------------------------------------------------------------
	CLASSE BaseList
-------------------------------------------------------------------------------------*/
com.egipe.soca.base.add("List", (function(){

	List.extendsClass(com.egipe.soca.core.HTMLElement);
	function List ()
	{
		this._parent()("ul");
		this.items = new Array ();
	}
	List.prototype.insertItem = function (label) {
		var item = new com.egipe.soca.base.ListItem();
		this.items.push (item);
		item.setLabel(label);
		item.insertIn(this.htmlElement);
		return item;
	};
	
	return List;
})());
/*------------------------------------------------------------------------------------
	CLASSE BaseItem
-------------------------------------------------------------------------------------*/
com.egipe.soca.base.add("ListItem", (function(){
	
	ListItem.extendsClass(com.egipe.soca.core.HTMLElement);
	function ListItem ()
	{
		this._parent()("li");
		this.activeElement = this.htmlElement.appendChild(document.createElement("a"));
	}
	ListItem.prototype.setLabel = function (label) {
		this.activeElement.innerHTML = "";
		this.activeElement.appendChild(document.createTextNode(label));
	};
	
	return ListItem;
})());
/*------------------------------------------------------------------------------------
	CLASSE BaseScroller
-------------------------------------------------------------------------------------*/
com.egipe.soca.base.add("Scroller", (function(){

	Scroller.extendsClass(com.egipe.soca.core.HTMLElement);
	function Scroller (targetObject, scrollStep, className)
	{
		this._parent()("div");
		this.htmlElement.className = className;
		this.targetObject = targetObject;
		this.originalStep = scrollStep;
		if (this.originalStep < 0) {
			this.htmlElement.appendChild(document.createTextNode("«"));
		}
		else {
			this.htmlElement.appendChild(document.createTextNode("»"));
		}
		this.maxTime = 200;
	}
	Scroller.prototype.mouseoverEvent = function (cbevent) {
		this.targetObject.noscroll = true;
		this.setTimeout("scrollTarget", this.maxTime);
	};
	Scroller.prototype.scrollTarget = function (cbevent) {
		this.targetObject.scrollStep(this.originalStep);
		this.setTimeout("scrollTarget", this.maxTime);
		if (this.maxTime > 10) {
			this.maxTime = this.maxTime-10;
		}
	};
	Scroller.prototype.mouseoutEvent = function (cbevent) {
		this.clearTimeout();
		this.maxTime = 200;
		this.targetObject.noscroll = false;
	};
	
	return Scroller;
})());
/*------------------------------------------------------------------------------------
	CLASSE BaseLinkButton
-------------------------------------------------------------------------------------*/
com.egipe.soca.base.add("LinkButton", (function(){

	LinkButton.extendsClass(com.egipe.soca.core.HTMLElement);
	function LinkButton (targetObject, targetMethod, atext)
	{
		this._parent()("a");
		var className = false;
		if (arguments.length == 4) {
			className = arguments[3];
		}
		this.targetObject = targetObject;
		this.targetMethod = targetMethod;
		this.htmlElement.setAttribute("href", "#");
		if (className)
		{
			this.htmlElement.className = className;
			this.setStyles("{background : url(/skin/tasks/"+className+".png) no-repeat top left;}");
		}
		this.htmlElement.appendChild(document.createTextNode(atext));
	}
	LinkButton.prototype.clickEvent = function (cbevent) {
		cbevent.clearEvent();
		return this.targetObject[this.targetMethod](this);
	};
	LinkButton.prototype.enable = function () {
		if (!document.all) {			this.htmlElement.style.opacity = 1;
		}		this.htmlElement.style.color = "#000";	};	LinkButton.prototype.disable = function () {		if (!document.all) {			this.htmlElement.style.opacity = 0.5;
		}		this.htmlElement.style.color = "#999";	};
	
	return LinkButton;
})());
/*------------------------------------------------------------------------------------
	CLASSE BaseImage
-------------------------------------------------------------------------------------*/
com.egipe.soca.base.add("Image", (function(){

	Image.extendsClass(com.egipe.soca.core.HTMLElement);
	function Image ()
	{
		this._parent()("img");
		this.htmlElement.className = "mimg";
		this.tempImage;
	}
	Image.prototype.loadEvent = function (event) {
	
		var wImg = this.tempImage.width;
		var hImg = this.tempImage.height;
	
		var wMax = getWinInnerSize().width-50;
		var hMax = getWinInnerSize().height-120;
		if ("viewElement" in this)
		{
			wMax = this.viewElement.htmlElement.clientWidth-50;
			hMax = hImg;
		}
		var wFinal;
		var hFinal;
		var ratio = 1;
		if (wImg > wMax && hImg > hMax) {
			if (wMax/wImg < hMax/hImg) {
				ratio = wMax/wImg;
			}
			else {
				ratio = hMax/hImg;
			}
		}
		else if (wImg > wMax) {
			ratio = wMax/wImg;
		}
		else if (hImg > hMax) {
			ratio = hMax/hImg;
		}
		this.htmlElement.width = Math.round(wImg*ratio);
		this.htmlElement.height = Math.round(hImg*ratio);
		var dLeft = Math.round((getWinInnerSize().width - this.htmlElement.width - 10)/2);
		var dTop = document.documentElement.scrollTop+document.body.scrollTop + Math.round((getWinInnerSize().height - this.htmlElement.height - 60)/2);
		if ("dialog" in this)
		{
			this.dialog.htmlElement.style.left = dLeft+"px";
			this.dialog.htmlElement.style.top = dTop+"px";
			this.dialog.setVisible();
		}
	};
	Image.prototype.setImage = function (imgSrc) {
		this.tempImage = new Image ();
		this.tempImage.src = imgSrc;
		this.htmlElement.src = imgSrc;
	};
	
	return Image;
})());
/*------------------------------------------------------------------------------------
	CLASSE BaseFrame
	Boite de dialogue javascript
	oButton			Boutton lié à l'ouverture (lien)
	oTitle			Titre de la boite de dialogue
	[content]		Noeud XML de contenu
-------------------------------------------------------------------------------------*/
com.egipe.soca.base.add("Frame", (function(){

	Frame.extendsClass (com.egipe.soca.core.ElementWithRequestor);
	function Frame (oButton, oTitle) {
	
		this.destroyOnClose = true; 				// Indique si la fenêtre est détruite à la fermeture
		this.mainContent = false;					// Noeud de contenu de la boîte
		if ("htmlElement" in oButton) {
			this.clickElement = oButton;
		}
		else {
			this.clickElement = $(oButton);		// Object de l'élément cliqué
		}
		this.redirectLink = true;
		
		var args = "div";
		var mainContent = false;
		// Le troisième parmètre est le contenu de la boîte						
		if (arguments.length >= 3) {
			args = arguments[2];
			
			mainContent = arguments[2].firstChild;
			if (mainContent.nodeType != 1) {
				mainContent = mainContent.nextSibling;
			}
			
		}
	
		// Création de la boite de dialogue
		this._parent()(args);
		if (mainContent) {
			if (mainContent.hasAttribute("id")) {
				mainContent.removeAttribute("id");	
			}
			this.mainContent = this.append(new com.egipe.soca.core.HTMLElement("div"));
			this.mainContent.appendChild(mainContent);
		}
		
		// Ajout de la div de contenu 
		this.currentUrl = "";
		if (!this.mainContent) {
			this.mainContent = this.append(new com.egipe.soca.core.HTMLElement("div"));
			if (this.clickElement.imageElement)
			{
				this.setHidden();
				this.currentImage = new BaseImage ();
				this.currentImage.dialog = this;
				if (document.all)
				{
					this.currentImage.htmlElement.detachEvent("onload", com.egipe.soca.core.HTMLElement.prototype.onevent);
					this.currentImage.htmlElement.setAttribute("height", "480px");
					this.currentImage.htmlElement.setAttribute("width", "640px");
					this.currentImage.setImage(this.clickElement.imageElement.src.replace(".140.105",".640.480"));
					this.setVisible();
				}
				else {
					this.currentImage.setImage(this.clickElement.imageElement.src.replace(".140.105",".100"));
				}
				this.currentImage.insertIn(this.htmlElement);
	
				if ("tasksElement" in this.clickElement) {
					this.htmlElement.appendChild(this.clickElement.tasksElement.cloneNode(true));
				}
			}
			else if (this.clickElement.htmlElement.hasAttribute("href"))
			{
				if (this.clickElement.htmlElement.getAttribute("href") != "#") {
					this.currentUrl = this.clickElement.htmlElement.getAttribute("href");
					this._SendGETRequest (this.currentUrl+"&output=htmlContent", this.htmlElement);
				}
			}
		}
		this.currentOpacity = 1;
		this.currentStep = 0.25;
		this.realContent = this.mainContent;
	}
	Frame.prototype._SendGETRequest = function (currentUrl, currentElement)
	{
		if ("realContent" in this)
		{
			this.realContent.setHidden();
			this.realContent.htmlElement.innerHTML = "";
		}
		else {
			this.mainContent.setHidden();
			this.mainContent.htmlElement.innerHTML = "";
		}
		this._parent(com.egipe.soca.core.ElementWithRequestor,"_SendGETRequest")(currentUrl+"&timestamp="+(new Date ().getTime()), currentElement);
	};
	Frame.prototype.loadView = function (currentUrl)
	{
		this.currentUrl = currentUrl;
		this.redirectLink = true;
		this.open();
		this._SendGETRequest (this.currentUrl+"&output=body", this.htmlElement);
	};
	Frame.prototype.doRequest = function ()
	{
		var xmlDocument = this.xmlResponse;
		var rootNode;
		try {
			if (xmlDocument.getElementById("real_content")) {
				rootNode = xmlDocument.getElementById("real_content");
			}
			else if (xmlDocument.documentElement.getElementsByTagName("body").length !== 0) {
				rootNode = xmlDocument.documentElement.getElementsByTagName("body").item(0);
			}
			else if (xmlDocument.documentElement.getElementsByTagName("form").length !== 0) {
				rootNode = xmlDocument.documentElement.getElementsByTagName("form").item(0);
			}
			else if (xmlDocument.documentElement.getElementsByTagName("div").length !== 0) {
				rootNode = xmlDocument.documentElement.getElementsByTagName("div").item(0);
			}
			else {
				rootNode = xmlDocument.documentElement.getElementsByTagName("ul").item(0);
			}
			var childs = rootNode.childNodes;
			var rChilds = [];
			var full = false;
			for (var i = 0; i< childs.length; i++)
			{
				if (childs.item(i).nodeType == "1")
				{
					rChilds.push(childs.item(i));
					full = true;
				}
			}
			if (full)
			{
				var mainTarget = this.realContent.htmlElement;
				mainTarget.innerHTML = "";
	    		var node = document.importNode(rootNode, true);
	    		if (node.tagName == "body") {
	   			for (i=0;i<rChilds.length;i++) {
		    			mainTarget.appendChild(rChilds[i]);
	    			}
	    		}
	    		else {
	  				node = mainTarget.appendChild(node);
	    		}
	    		mainTarget.appendChild(document.createElement("hr"));
	  			if (com.egipe.getModule("com.egipe.soca.form")) {
	   				com.egipe.getModule("com.egipe.soca.form").applyBehavior(mainTarget);
	  			}
	  			
	  			if (this.redirectLink)
	  			{
					var cAnchors = mainTarget.getElementsByTagName("a");
					for (i = 0; i < cAnchors.length; i++)
					{
						var curl = cAnchors.item(i).getAttribute("href");
						//if (curl.substr(curl.length-1) != "/")
						//	cAnchors.item(i).setAttribute("href", "/#"+curl)
						cAnchors.item(i).onclick = this.refresh;
						cAnchors.item(i).jsobject = this;
					}
					var cForms = mainTarget.getElementsByTagName("form");
					for (i = 0; i < cForms.length; i++)
					{
						cForms.item(i).onsubmit = this.post;
						cForms.item(i).jsobject = this;
					}
	  			}
				this.setVisible();
				this.mainContent.setVisible();
				if ("realContent" in this)
				{
					this.realContent.setVisible();
				}
	
	    	}
		}
		catch (e) {
			if (this.textResponse.length) {
				var currentInfos = eval("("+this.textResponse+")");
				var para = this.realContent.append(new com.egipe.soca.core.HTMLElement("p"));
				para.setAttribute("class","fvalid");
				para.setContent("("+currentInfos.form+") "+currentInfos["return"]);
				this.setVisible();
				this.mainContent.setVisible();
				this.realContent.setVisible();
				if (com.egipe.getModule("com.egipe.soca.basic"))	{
					com.egipe.getModule("com.egipe.soca.basic").pinfos.getInfos();
				}
				this.setTimeout("close", 3000);
			}
			else {
				_log("An exception occurred in the script. Error name: " + e.name + ". Error message: " + e.message);
			}
		}
	};
	Frame.prototype.post = function (evt) {
		var cbevent = new com.egipe.soca.core.Event (evt);
		var clickButton = evt.explicitOriginalTarget;
		cbevent.clearEvent();
		var cForm = cbevent.target;
		var cFields = cForm.elements;
		var qparts = [];
		for (var i=0;i<cFields.length;i++)
		{
			if ((cFields[i].tagName != "button" || cFields[i] == clickButton) && Utils.isDef(cFields[i].name) && cFields[i].name.length !=0) {
				qparts.push(cFields[i].name.encode()+"="+cFields[i].value.encode());
			}
		}
		qparts.push("isRequest=true");
		var formData = qparts.join("&");
		this.jsobject.realContent.setHidden();
		this.jsobject.realContent.htmlElement.innerHTML = "";
		this.jsobject._SendHTTPRequest (this.action, "POST",formData);
		
		return false;
	};
	Frame.prototype.refresh = function (evt) {
		var tAnchor;
		var cbevent = new com.egipe.soca.core.Event (evt);
		cbevent.clearEvent();
		switch (cbevent.target.tagName.toLowerCase())
		{
			case "div":
			case "h3":
				tAnchor = cbevent.target.parentNode;
				break;
			case "object":
			case "img":
				if (cbevent.target.parentNode.tagName == "a")
				{
					tAnchor = cbevent.target.parentNode;
				}
				else
				{
					tAnchor = cbevent.target.parentNode.parentNode;
				}
				break;
			case "a":
				tAnchor = cbevent.target;
				break;
			default:
				alert ("Dialog : impossible de trouver le lien href");
				break;
		}
		if (tAnchor.getAttribute("href").indexOf("#") != -1)
		{
			var cHeaders = tAnchor.parentNode.getElementsByTagName("h3");
			if (tAnchor.parentNode.className == "cicon") {
				cHeaders = tAnchor.parentNode.parentNode.getElementsByTagName("h3");
			}
			
			var oTitle = "";
			if (cHeaders.length) {
				oTitle = cHeaders.item(0).textContent;
			}
			tAnchor.jsobject.clickElement.updateRelatedElement(tAnchor.getAttribute("href").substr(tAnchor.getAttribute("href").indexOf("#")+1), oTitle);
			tAnchor.jsobject.close();
		}	
		else {
			tAnchor.jsobject._SendGETRequest (tAnchor.getAttribute("href")+"&output=body", tAnchor.jsobject.htmlElement);
		}
	};
	Frame.prototype.open = function () {
		this.display();
	};
	
	Frame.prototype.close = function (closeButton) {
		this.setHidden();
		this.setTimeout("remoteClose",100);
	};
	Frame.prototype.remoteClose = function () {
		this.hide();
		this.setVisible();
	};
	
	return Frame;
})());
/*------------------------------------------------------------------------------------
	CLASSE BaseFrameAnchor
-------------------------------------------------------------------------------------*/
com.egipe.soca.base.add("FrameAnchor", (function(){

	FrameAnchor.extendsClass(com.egipe.soca.core.HTMLElement);
	function FrameAnchor () 
	{
		
	}
	
	return FrameAnchor;
})());
/*------------------------------------------------------------------------------------
	CLASSE Overlay
-------------------------------------------------------------------------------------*/
com.egipe.soca.base.add("Overlay", (function(){

	Overlay.extendsClass(com.egipe.soca.core.HTMLElement);
	function Overlay ()
	{
		this._parent()("div");
		this.opacity = 0;
		
		this.hide();
		this.setStyles("{"+
			"z-index : 8000;"+
			"position : absolute;"+
			"top : 0;"+
			"left : 0;"+
			"width: 100%;"+
			"background-color : #FFF;"+
			"opacity : 0;"+
			"}");
		this.insertIn(document.getElementsByTagName("body").item(0));
	}
	Overlay.prototype.bind = function (curObject , openMethod, closeMethod)
	{
		this.currentElement = curObject;
		this.currentElement._initialOpen = this.currentElement[openMethod];
		this.currentElement[openMethod] = function () {
			this.setHidden();
			this._initialOpen();
			com.egipe.getModule("com.egipe.soca.basic").overlay.showElement(this);
		};
		this.currentElement._initialClose = this.currentElement[closeMethod];
		this.currentElement[closeMethod] = function () {
			this._initialClose();
			com.egipe.getModule("com.egipe.soca.basic").overlay.setTimeout("decreaseOpacity", 5);
		};
		
	};
	Overlay.prototype.showElement = function (curObject)
	{
		this.currentElement = curObject;
		this.setStyle("height", document.body.clientHeight+"px");
	
		this.setTimeout("increaseOpacity", 5);
	};
	Overlay.prototype.increaseOpacity = function ()
	{
		this.display();
		this.opacity = this.opacity+2;
		this.htmlElement.style.opacity = this.opacity/10;
		if (this.opacity < 6)	{
			this.setTimeout("increaseOpacity", 5);
		}
		else {
			this.clearTimeout();
			this.currentElement.setVisible ();
		}
	};
	Overlay.prototype.decreaseOpacity = function ()
	{
		this.opacity = this.opacity-2;
		if (this.opacity > 0) {
			this.htmlElement.style.opacity = this.opacity/10;
			this.setTimeout("decreaseOpacity", 5);
		}
		else {
			this.opacity = 0;
			this.clearTimeout();
			this.hide();
		}
	};
	
	return Overlay;
})());
/*------------------------------------------------------------------------------------
	CLASSE BasicDialog
-------------------------------------------------------------------------------------*/
com.egipe.soca.base.add("Dialog", (function(){

	Dialog.extendsClass (com.egipe.soca.core.RegisterObject);
	Dialog.extendsClass (com.egipe.soca.base.Frame);
	
	function Dialog (oButton, oTitle) {
		if (arguments.length >= 3 && arguments[2])	{
			this._parent()(oButton, oTitle, arguments[2]);
		}
		else {
			this._parent()(oButton, oTitle);
		}
		if (this.getModule().overlay) {
			this.getModule().overlay.bind(this, "open", "close");
		}
		var initialContent = this.mainContent.htmlElement.innerHTML;
		this.mainContent.htmlElement.innerHTML = "";	
		this.skins = {"green":"bbd5b0","yellow":"f9d631","red":"cba9a9"};
		var radius = 35;
		var gHeight = 280;
		var margin = 80;
		var skin = "green";
		if (arguments.length == 4)	{
			skin = arguments[3];
		}
		var cTop = 100;
		
		this.mainContent.setAttribute("class","bpopup");
		
		
		var sizes = getInnerSize();
		
		
		var cWidth = Math.floor(sizes.width-(margin*2));
		var cHeight = Math.floor(sizes.height-(cTop*2));
		

		
		
		
		this.mainContent.setStyle("top",cTop+"px");
		this.mainContent.setStyle("left",margin+"px");
		this.mainContent.setStyle("width",cWidth+"px");
		this.mainContent.setStyle("height",cHeight+"px");
	
		/* En tête ******************/
		this.header = this.mainContent.append(new com.egipe.soca.core.HTMLElement("div"));
		this.header.addClass("header");
		this.title = this.header.append(new com.egipe.soca.core.HTMLElement("h2"));
		this.title.htmlElement.appendChild(document.createTextNode(oTitle));
		this.closeButton = this.header.append(new com.egipe.soca.base.Button(this, "close", "/skin/images/dialog/close.png"));
		this.closeButton.setStyles("{ position:absolute; top:5px; right:5px;}");
		this.realContent = this.mainContent.append(new com.egipe.soca.core.HTMLElement("div"));
		this.realContent.addClass("mc");

		//this.mainContent = this.realContent;
		this.realContent.htmlElement.innerHTML = initialContent;	
		this.htmlElement.style.zIndex = -1;
		this.display();
	}
	Dialog.prototype.setTop = function (){
		var cTop = 80;
		this.mainContent.setStyle("top",(cTop+document.documentElement.scrollTop)+"px");
	};
	Dialog.prototype.close = function () {
		this.htmlElement.style.zIndex = -1;
	};
	Dialog.prototype.open = function (){
		var sizes = getInnerSize();
		var radius = 35;
		var gHeight = 280;
		var margin = 80;
		var cTop = 80;
		var cWidth = Math.floor(sizes.width-(margin*2));
		var cHeight = Math.floor(sizes.height-(cTop*2));
		if (cHeight<gHeight) {
			cHeight = gHeight;
		}
		this.setStyle("top",0);
		this.setStyle("left",0);
		this.setStyle("width",sizes.width+"px");
		this.setStyle("height",sizes.height+"px");
		this.htmlElement.style.zIndex = 20001;
		this.mainContent.setStyle("top",(cTop+document.documentElement.scrollTop)+"px");
		this.mainContent.setStyle("width",cWidth+"px");
		this.mainContent.setStyle("height",cHeight+"px");
		this.realContent.setStyle("height",(cHeight-60)+"px");
	};
	Dialog.prototype.reveal = function (){
	};
	
	

	return Dialog;
})());

com.egipe.soca.base.isComplete = true;

/** -- file:/egipe/Applications/siteBase/com.egipe.soca/site/site.js -- */
Namespace ("com.egipe.soca.site");
/*------------------------------------------------------------------------------------
	Module Base
	Vérifie le chargement des modules
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("Module", (function(){

	// Modules et extensions
	Module.extendsClass(com.egipe.soca.base.Module);
	function Module () 
	{
		this._parent()();
		this.currentMaxImage = false;
	}
	
	Module.prototype.initBehavior = function ()
	{
		if (!document.all) {
			this.pinfos = new com.egipe.soca.site.PageSiteInfos();
		}
		
//		if (window.top === window) {
//			$$("body.rplayer", com.egipe.soca.site.RemotePlayer);
//		}

		$$(".thumb",	com.egipe.soca.site.ThumbElement);

		$$(".thumbview", com.egipe.soca.site.ThumbnailViewElement);
		$$(".mainmenu", com.egipe.soca.site.MainmenuElement);
		$$(".fslide", com.egipe.soca.site.SliderElement);
		$$(".slide", com.egipe.soca.site.ScollerElement);
		$$(".zedit", com.egipe.soca.site.EditableZone);
		$$(".photos", com.egipe.soca.site.Photos);
		$$(".amail", com.egipe.soca.site.MailtoLink);
		$$(".asubmit", com.egipe.soca.site.AutoSumitForm);
		$$(".colapse", com.egipe.soca.site.ColapsableElement);
		$$(".help", com.egipe.soca.site.HelpElement);
		$$(".mgalerie",  com.egipe.soca.site.GalerieElement);
		$$(".tabsCont",	com.egipe.soca.site.TabsElement);
		$$(".player",	com.egipe.soca.site.PlayerElement);
		$$(".rlink", com.egipe.soca.site.RemoteLink);
		$$(".external",	com.egipe.soca.site.ExternalLink);
		$$(".match", com.egipe.soca.site.FeuilleMatch);
		$$(".atabs", com.egipe.soca.site.AnotherTabs);
//		$$(".sudoku", com.egipe.soca.site.Sudoku);
//		$$(".smenu", com.egipe.soca.site.vmenuElement);
	};
	
	Module.prototype.attach = function (egCLient)
	{
		this.isAttach = true;
		this.remoteAttach ();
	};
	Module.prototype.remoteAttach = function ()
	{
		if (this.pinfos) {
			this.pinfos.getInfos();
		} else {
			this.setTimeout("remoteAttach", 100);
		}
	};
	
	Module.prototype.addCssRules = function ()
	{
		document.addRule(".photos li a img,.photos div img { visibility : hidden; } ");
		document.addRule(".help { z-index : 1; visibility : hidden; position : absolute; border : 2px solid #3c80b1; width : 920px; margin-bottom : 13px !important; opacity : 0.9;} ");
		document.addRule(".help img { position : absolute; bottom : -15px; left : 250px; border : none; background:transparent;} ");

		document.addRule(".bpopup { padding-right : 35px; position : absolute; opacity : 0.94;}");
		document.addRule(".Tooltip {min-width : 150px; position : absolute; display : none; z-index : 8000; padding : 0.3em;}");
		document.addRule(".Tooltip p { margin : 0; padding : 0;}");
		document.addRule(".closeButton {float : right; opacity : 0.5;}");
		document.addRule(".titlebar:hover > img {opacity : 1;}");
		document.addRule(".thumbview {position: relative;}");
		document.addRule(".toclose {position: absolute;}");
		
//		document.addRule(" .sudoku {border-top : 2px solid #999;border-left : 2px solid #999; } ");
//		document.addRule(" .sudoku td {border-right : 1px solid #AAA;border-bottom : 1px solid #AAA; } ");
//		document.addRule(" .sudoku input {border:none; font-size : 120%;text-align : center; height:1.2em;width:1.2em;} ");
//		document.addRule(" .sudoku .tcol {border-right : 2px solid #999;} ");
//		document.addRule(" .sudoku .tline {border-bottom : 2px solid #999; } ");
	};
	return Module;
})());
	
com.egipe.clientModule = new com.egipe.soca.site.Module ();
/*------------------------------------------------------------------------------------
	CLASSE RemoteLink
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("RemoteLink", (function(){
	RemoteLink.extendsClass(com.egipe.soca.core.ElementWithRequestor);
	function RemoteLink ()
	{
		this._parent()(arguments);

		var frame = document.createElement("iframe");	
		this._SendGETRequest (this.getAttribute("href")+"?module=page::default");
	}
	RemoteLink.prototype.doRequest = function ()
	{
		
		if (this.xmlResponse) 
		{
			this.addClass('siteOk');
		}	
		else {
			this.addClass('siteKo');
		}
		this.isFinished = true;
		return true;
	};
	return RemoteLink;
})());

/*------------------------------------------------------------------------------------
	CLASSE RemotePlayer
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("RemotePlayer", (function(){
	RemotePlayer.extendsClass(com.egipe.soca.core.HTMLElement);
	function RemotePlayer ()
	{
		this._parent()(arguments);
		this.hide();
		this.htmlElement.parentNode.removeChild(this.htmlElement);
		var frameSet = document.documentElement.appendChild(document.createElement("frameset"));	
		frameSet.setAttribute("framespacing", "1");
		frameSet.setAttribute("rows", "78,*");
			
		var topFrame = frameSet.appendChild(document.createElement("frame"));
		topFrame.setAttribute("id", "top");
		var botFrame = frameSet.appendChild(document.createElement("frame"));
		botFrame.setAttribute("id", "bottom");
		document.getElementById("bottom").contentDocument.location.href = document.location.href;
	}
	return RemotePlayer;
})());
/*------------------------------------------------------------------------------------
	CLASSE AnotherTabs
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("AnotherTabs", (function(){
	AnotherTabs.extendsClass(com.egipe.soca.core.HTMLElement);
	function AnotherTabs ()
	{
		this._parent()(arguments);
		
		// Récupération des contents
		this.contents = $$(".atab" , com.egipe.soca.site.AnotherTabContent, this.htmlElement);
		
		// Création des tabs
		this.tabs = $(document.createElement("ul"));
		this.tabs.addClass("rtabs");
		this.tabs.insertBefore(this.htmlElement);
		var that = this;
		var ind = 0;
		
		this.htmlElement.getElementsByTagName("h3").foreach(function(aTitle) { 
			_log (aTitle.textContent); 
			if (aTitle.textContent)	{
				var aTab = that.tabs.append($(document.createElement("li"), com.egipe.soca.site.AnotherTab));
				that.contents[ind].attachButton(aTab, ind++);
				aTab.addTitle(aTitle.textContent);
			}
		});
		
		this.setCurrentTab(0);
	}
	AnotherTabs.prototype.setCurrentTab = function (anIndex)
	{
		this.contents.foreach(function(aContent) { aContent.hide(); aContent.button.removeClass("current"); } );
		this.contents[anIndex].display();
		this.contents[anIndex].button.addClass("current");
	};	
	return AnotherTabs;
})());
/*------------------------------------------------------------------------------------
	CLASSE AnotherTabContent
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("AnotherTabContent", (function(){
	AnotherTabContent.extendsClass(com.egipe.soca.core.HTMLElement);
	function AnotherTabContent ()
	{
		this._parent()(arguments);
	}
	AnotherTabContent.prototype.attachButton = function (aButton, anIndex)
	{
		this.button = aButton;
		this.index = anIndex;
		aButton.content = this;
		aButton.index = anIndex;
	};	
	return AnotherTabContent;
})());
/*------------------------------------------------------------------------------------
	CLASSE AnotherTab
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("AnotherTab", (function(){
	AnotherTab.extendsClass(com.egipe.soca.core.HTMLElement);
	function AnotherTab ()
	{
		this._parent()(arguments);
	}
	AnotherTab.prototype.addTitle = function (aTitle)
	{
		this.htmlElement.appendChild(document.createTextNode(aTitle));
	};	
	AnotherTab.prototype.clickEvent = function (anEvent)
	{
		this.content.parentObject.setCurrentTab(this.index);
	};	
	return AnotherTab;
})());

/*------------------------------------------------------------------------------------
	CLASSE FeuilleMatch
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("FeuilleMatch", (function(){
	FeuilleMatch.extendsClass(com.egipe.soca.core.HTMLElement);
	function FeuilleMatch ()
	{
		this._parent()(arguments);
		this.equipes = $$("a" , com.egipe.soca.core.HTMLElement,document.getElementById("f_equipes"));
		this.joueurs = $$(".infos" , com.egipe.soca.site.Joueur, this.htmlElement);
		this.listes = $$(".lj" , com.egipe.soca.site.ListEquipe, this.htmlElement);
	}
	FeuilleMatch.prototype.getJoueurs = function (jid)
	{
		for (var i=0; i<this.joueurs.length; i++)
		{
			if (this.joueurs[i].getAttribute("href").indexOf("#"+jid) != -1)
			{
				return this.joueurs[i];
			}
		}
		return false;
	};	
	
	return FeuilleMatch;
})());
/*------------------------------------------------------------------------------------
	CLASSE ListEquipe
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("ListEquipe", (function(){
	ListEquipe.extendsClass(com.egipe.soca.core.HTMLElement);
	function ListEquipe ()
	{
		this._parent()(arguments);
		this.items = $$("li" , com.egipe.soca.site.ItemEquipe, this.htmlElement);
		
	}
	
	return ListEquipe;
})());
/*------------------------------------------------------------------------------------
	CLASSE ItemEquipe
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("ItemEquipe", (function(){
	ItemEquipe.extendsClass(com.egipe.soca.core.HTMLElement);
	function ItemEquipe ()
	{
		this._parent()(arguments);
		this.joueur = this.parentObject.parentObject.getJoueurs(this.getAttribute("id"));
		this.joueur.setItem(this);
	}
	ItemEquipe.prototype.mouseoverEvent = function (event)
	{
		event.clearEvent();
		this.joueur.tooltip.display ();
		return false;
	};	
	ItemEquipe.prototype.mouseoutEvent = function (event)
	{
		event.clearEvent();
		this.joueur.tooltip.hide ();
		return false;
	};	
	
	return ItemEquipe;
})());
/*------------------------------------------------------------------------------------
	CLASSE Joueur
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("Joueur", (function(){
	Joueur.extendsClass(com.egipe.soca.core.HTMLElement);
	function Joueur ()
	{
		this._parent()(arguments);
		
		this.postes = ["Pilier (gauche)","Talonneur","Pilier (droit)","Deuxième ligne (gauche)","Deuxième ligne (droite)",
		"Troisième ligne aile (gauche)","Troisième ligne aile (droite)","Troisième ligne central","Demi de mêlée","Demi d'ouverture","Ailier (gauche)",
		"Centre (gauche)","Centre (droit)","Ailier (droit)","Arrière"];		
		
		this.tooltip = $(document.createElement("div"));
		this.tooltip.hide();
		this.tooltip.insertIn(document.getElementById("f_terrain"));

		this.tooltip.setAttribute("class", "atip");
		this.num = this.tooltip.append($(document.createElement("p")));
		this.num.setAttribute("class","numero");
		this.poste = this.tooltip.append($(document.createElement("p")));
		this.poste.setAttribute("class","poste");
		this.title = this.tooltip.append($(document.createElement("p")));
		this.tooltip.setStyle("position", "absolute");
		this.tooltip.setStyle("top", (this.htmlElement.offsetTop-10)+"px");
		this.tooltip.setStyle("left", (this.htmlElement.offsetLeft+15)+"px");
	}
	Joueur.prototype.setItem = function (anItem)
	{
		var cAnchors = anItem.htmlElement.getElementsByTagName("a");
		var num = this.getAttribute("href").substr(this.getAttribute("href").indexOf("#")+2);
		this.poste.setContent(this.postes[num-1]);
		this.num.setContent(num);
		if (cAnchors.length)
		{
			this.title.setContent($(cAnchors[0]).getContent());
		}

	};	
	Joueur.prototype.mouseoverEvent = function (event)
	{
		event.clearEvent();
		this.tooltip.display ();
		return false;
	};	
	Joueur.prototype.mouseoutEvent = function (event)
	{
		event.clearEvent();
		this.tooltip.hide ();
		return false;
	};	
	
	
	return Joueur;
})());

/*------------------------------------------------------------------------------------
	CLASSE PagesInfos
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("PageSiteInfos", (function(){

	PageSiteInfos.extendsClass(com.egipe.soca.core.ElementWithRequestor);
	
	function PageSiteInfos ()
	{
		this._parent()("div");
		this.button = new com.egipe.soca.base.Button(this, "openDialog", "/skin/images/global/nloading-blue.gif");
		this.button.insertIn(this.htmlElement);
		this.button.htmlElement.style.position = "absolute";
		this.button.htmlElement.style.top = "3px";
		this.button.htmlElement.style.right = "5px";
		this.button.hide();
		this.button.setAttribute("height", "16px");
		this.button.setAttribute("width", "16px");
		this.button.image.setAttribute("height", "16px");
		this.button.image.setAttribute("width", "16px");
		this.insertIn(document.body);
	}
	PageSiteInfos.prototype.getInfos = function ()
	{
		this.hasErrors = false;
		this.isFinished = false;
		this.debugPopup = false;
		this.button.image.setAttribute("src", "/skin/images/global/nloading-blue.gif");
		this.button.display();
		var curUrl = window.location.href;
		if (arguments.length == 1) {
			curUrl = arguments[0];
		}	
		var timestamp = new Date ().getTime();
		if (curUrl.indexOf("?") != -1) {
			this._SendGETRequest (curUrl+"&json=tasks_errors&timestamp="+timestamp, this.htmlElement);
		}
		else {
			this._SendGETRequest (curUrl+"?json=tasks_errors&timestamp="+timestamp, this.htmlElement);
		}
	};
	
	PageSiteInfos.prototype.openDialog = function ()
	{
		if (this.debugPopup) {
		 	this.debugPopup.open ();
		}
	};
	
	PageSiteInfos.prototype.doRequest = function ()
	{
		
		if (this.textResponse) 
		{
			var currentInfos = eval("("+this.textResponse+")");
			var srcImage = "";
			var msg = "";
		
			if (com.egipe.client)
			{
				var lastModDoc = document.lastModified;
				var lDate = lastModDoc.substr(0,10).split("/");
				var lTime = lastModDoc.substr(11);
				var lIso = lDate[2]+"-"+lDate[0]+"-"+lDate[1]+" "+lTime;
				com.egipe.tasks = currentInfos.tasks;
			}
		
			if(currentInfos.errors.message.length!=0)
			{
				msg = currentInfos.errors.message+" ";
			}
			
		
			
			switch (currentInfos.errors.ctype)
			{	
				case "exclamation":
					srcImage = "/skin/tasks/exclamation.png";
					if (this.getModule().soundManager) {
						this.getModule().soundManager.play("error");
					}
					break;
				case "error":
					srcImage = "/skin/tasks/warning.png";
					break;
				case "information":
					srcImage = "/skin/tasks/information.png";
					break;
				case "notice":
					srcImage = "/skin/tasks/error.png";
					break;
				case "none":
					srcImage = "/skin/tasks/accept.png";
					break;
				default:
					srcImage = "/skin/tasks/error.png";
					break;
			}
			if (com.egipe.client) {
				if (!msg.length) {
					msg += "Page correctement chargée";
				}
				com.egipe.client.updateFeature("sidebar");
			}
			if (msg.length && "attachTooltip" in this.button) {
				this.button.attachTooltip (msg);
			}
			this.button.hide();
			this.button.image.setAttribute("src", srcImage);
			if (currentInfos.errors.report.length != 0)
			{
				this.displayErrors(currentInfos.errors);
			}
	
		}	
		else {
			this.button.attachTooltip ("Erreur de chargement des infos de pages !!");
			this.button.image.setAttribute("src", "/skin/tasks/warning.png");
		}
		this.button.display();
		this.isFinished = true;
		return true;
	};
	PageSiteInfos.prototype.displayErrors = function (oErrors)
	{
		var container = false;
		var showInPopup = ((new com.egipe.soca.core.URI()).path != "/showrproc");
		if (showInPopup) {
			this.debugPopup = new com.egipe.soca.base.Dialog(this.htmlElement, oErrors.message,false,"red");
			this.debugPopup.destroyOnClose = false;
			this.debugPopup.close();
			this.debugPopup.insertIn(document.body);
			this.debugPopup.realContent.setAttribute("class","pconsole");
			container = this.debugPopup.realContent;
		} 
		else {
			container = $("real_content");
		}
	
		var curDiv = false;
		var curCont = false;
		var curReport = false;
		var curSpan = false;
		var curErr = false;
		for (var i=0; i<oErrors.report.length;i++)
		{
			curDiv = container.append(new com.egipe.soca.core.HTMLElement("div"));
			curDiv.setAttribute("class","page");
			curDiv.htmlElement.appendChild(document.createTextNode(oErrors.report[i].label));
			curDiv = container.append(new com.egipe.soca.core.HTMLElement("div"));
			for (var j=0; j<oErrors.report[i].content.length;j++)
			{
				curErr = oErrors.report[i].content[j];
				curCont = curDiv.append(new com.egipe.soca.core.HTMLElement("div"));
				curCont.setAttribute("class","mconsole "+curErr.type);
				
				curSpan = curCont.htmlElement.appendChild(document.createElement("span"));
				curSpan.appendChild(document.createTextNode(curErr.msg));
				curSpan.setAttribute("class","msg");
				
				curSpan = curCont.htmlElement.appendChild(document.createElement("span"));
				curSpan.appendChild(document.createTextNode(curErr.url+" "+curErr.line));
				curSpan.setAttribute("class","file");
				
				if (curErr.content.length != 0)
				{
					curCont = curDiv.append(new com.egipe.soca.core.HTMLElement("div"));
					curCont.setAttribute("class","mcontent");
					curCont.htmlElement.innerHTML = "<div>"+curErr.content+"</div>";
				}
			}
		}
		
	};
	
	return PageSiteInfos;
})());
/*------------------------------------------------------------------------------------
	CLASSE ExternalLink
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("ExternalLink", (function(){
	ExternalLink.extendsClass(com.egipe.soca.core.HTMLElement);
	function ExternalLink ()
	{
		this._parent()(arguments);
		this.curl = this.getAttribute("href");
	}
	ExternalLink.prototype.clickEvent = function (event)
	{
		event.clearEvent();
		window.open(this.curl, "external");
		return false;
	};	
	
	return ExternalLink;
})());
/*------------------------------------------------------------------------------------
	CLASSE PlayerElement
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("PlayerElement", (function(){
	PlayerElement.extendsClass(com.egipe.soca.core.HTMLElement);
	function PlayerElement ()
	{
		this._parent()(arguments);

		this.flashPlayer = document.all?document.getElementById("fobject"):document.getElementsByName("fobject").item(0);

		// récupération du parametre "movie" de l'objet (IE) 
		this.objectParam = false;
		var cParams = this.htmlElement.getElementsByTagName("param");
		for (var i=0; i<cParams.length; i++) {
			if (cParams[i].name == "movie")
			{
				this.objectParam = cParams[i];
			}
		}
		var self = this;
		// récupération du "title"
		this.vtitle = false;
		var cHeaders = this.htmlElement.getElementsByTagName("h3");
		if (cHeaders.length) {
			this.vtitle = $(cHeaders[0]);
		}
		// récupération du "object"
		this.mobject = false;
		var cObjects = this.htmlElement.getElementsByTagName("object");
		if (cObjects.length) {
			this.mobject = cObjects[0];
		}
		// récupération du "embed" (autres)
		this.membed = false;
		var cEmbeds = this.htmlElement.getElementsByTagName("embed");
		if (cEmbeds.length) {
			this.membed = cEmbeds[0];
		}
		
		// récupération des "dates"
		this.months = $$(".cm", com.egipe.soca.core.HTMLElement, this.htmlElement);
		this.days = $$(".cd", com.egipe.soca.core.HTMLElement, this.htmlElement);

		// Chargement des bouttons
		this.buttons = $$(".pbutton", com.egipe.soca.site.PlayerButton, this.htmlElement);
		for (i=0; i < this.buttons.length; i++)
		{
			this.buttons[i].index = i;
		}
		this.mobject.style.visibility = "hidden";
		if (this.membed)
		{
			this.membed.style.visibility = "hidden";
		}
		this.loadInProgress = true;
		this.autoPlay = false;
		this.setTimeout("endLoad", 100);
		this.currentVideo = 0;
	}
	PlayerElement.prototype.displayVideo = function (vIndex)
	{
		if (this.membed || this.objectParam)
		{
			if (this.currentVideo != vIndex)
			{
				this.buttons[this.currentVideo].removeClass("current");
				this.buttons[vIndex].addClass("current");
				this.vtitle.setContent(this.buttons[vIndex].vTitle);
				this.months[0].setContent(this.buttons[vIndex].vMonth);
				this.days[0].setContent(this.buttons[vIndex].vDay);
				if (this.membed)
				{
					this.membed.style.visibility = "hidden";
					this.membed.setAttribute("src", this.buttons[vIndex].vUrl+'&autoPlay=1');
				}
				else {
					this.mobject.LoadMovie(0, this.buttons[vIndex].vUrl);
					this.mobject.Play();
				}
				this.currentVideo = vIndex;
				this.loadInProgress = true;
				this.setTimeout("endLoad", 500);
			}
		}
		else {
			alert("Erreur de chargement de la video");
		}
	
	};
	PlayerElement.prototype.endLoad = function (vIndex)
	{
		if ("PercentLoaded" in this.flashPlayer)
		{
			if (this.flashPlayer.PercentLoaded() < 100)
			{
				this.setTimeout("endLoad", 100);
				return false;
			}
		}
		this.mobject.style.visibility = "visible";
		if (this.membed)
		{
			this.membed.style.visibility = "visible";
		}
		this.loadInProgress = false;
		return true;
	};

	return PlayerElement;
})());
/*------------------------------------------------------------------------------------
	CLASSE PlayerElement
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("PlayerButton", (function(){
	PlayerButton.extendsClass(com.egipe.soca.core.HTMLElement);
	function PlayerButton ()
	{
		this._parent()(arguments);
		this.index = 0;
		this.vUrl = this.getAttribute("href");
		var parts = this.getAttribute("title").trim().split("|");
		this.vTitle = parts[1].trim();
		var dates = parts[0].split(" ");
		this.vMonth = dates[1].trim();
		this.vDay = dates[0].trim();
	}
	PlayerButton.prototype.clickEvent = function (event)
	{
		event.clearEvent();
		this.parentObject.displayVideo(this.index);
		return false;
	};

	return PlayerButton;
})());
/*------------------------------------------------------------------------------------
	CLASSE TabsElement
	Tabs avec structure 
	<div class="tabsCont">
		<ul>
			<li><a>Item 1</a></li>
			<li><a>Item 2</a></li>
			...
		</ul>
		<div class="cont">
			<element1/>
			<element2/>
			...
		</div>
	</div>
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("TabsElement", (function(){

	TabsElement.extendsClass(com.egipe.soca.core.HTMLElement);
	function TabsElement ()
	{
		this._parent()(arguments);
		
		this.tabs = new Array ();
		this.containers = new Array ();
		
		var currentChild = false;
		var currentTab = false;
		var currentContainer = false;
		var tcont = false;
		var ccont = false;
		var maxHeight = 0;
		
		// Vérification de la structure
		if (this.htmlElement.getElementsByTagName("ul").length != 0)
		{
			tcont = this.htmlElement.getElementsByTagName("ul").item(0);
		}
		if (this.htmlElement.getElementsByTagName("div").length != 0 && this.htmlElement.getElementsByTagName("div").item(0).className == "cont")
		{
			ccont = this.htmlElement.getElementsByTagName("div").item(0);
		}
		
		// Construction des collections
		if (tcont && ccont)
		{
			for (var i=0; i < tcont.childNodes.length; i++)
			{
				currentChild = tcont.childNodes.item(i);
				if (currentChild.nodeType == 1)
				{
					currentTab = this.tabs.push(currentChild);	
					currentChild.onclick = this.tabclk;
				}
				
			}
			for (var j=0; j < ccont.childNodes.length; j++)
			{
				currentChild = ccont.childNodes.item(j);
				if (currentChild.nodeType == 1)
				{
					currentContainer = this.containers.push(currentChild);
					if (currentChild.clientHeight > maxHeight) {
						maxHeight = currentChild.clientHeight;
					}
					currentContainer.jsobject = this;
					this.tabs[this.containers.length-1].jsobject = currentContainer;
				}
				
			}
			
			for (i=0; i < this.containers.length; i++)
			{
				this.containers[i].style.height = maxHeight+"px";
			}
			
		}
	}
	TabsElement.prototype.activateTab = function (cont)
	{
		for (var i=0; i < this.containers.length; i++)
		{
			if (this.tabs[i].className.indexOf("curtab") != -1)
			{
				this.containers[i].className = "";
				this.tabs[i].className = "";
			}
			if (this.tabs[i] == cont)
			{
				this.containers[i].className = "curcont";
				this.tabs[i].className = "curtab";
			}
		}
	};
	
	TabsElement.prototype.tabclk = function (evt)
	{
		var event = new com.egipe.soca.core.Event(evt);
		var tabMgr = false;
		var curTab = false;
		if (event.target.tagName.toLowerCase() == "li") {
		 	tabMgr = event.target.parentNode.parentNode.jsobject;
		 	curTab = event.target;
		}
		else if (event.target.tagName.toLowerCase() == "a") {
		 	tabMgr = event.target.parentNode.parentNode.parentNode.jsobject;
		 	curTab = event.target.parentNode;
		}
		if (tabMgr) {
			tabMgr.activateTab(curTab);
		}
		event.clearEvent ();
	};
	return TabsElement;
})());

/*------------------------------------------------------------------------------------
	CLASSE GalerieElement
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("GalerieElement", (function(){
	GalerieElement.extendsClass(com.egipe.soca.core.HTMLElement);
	function GalerieElement ()
	{
		this._parent()(arguments);
		this.containers = this.htmlElement.getElementsByTagName("img");
		this.titles = this.htmlElement.getElementsByTagName("span");
		this.currentIndex = 1;
		this.nbImages = this.containers.length;
		this.setTimeout("showNextImage", 6000);
	}
	GalerieElement.prototype.showNextImage = function ()
	{
		// Cache l'image active
		if (this.currentIndex != 0)
		{
			this.containers.item(this.currentIndex).parentNode.style.display = "none";
		}
		this.currentIndex += 1;
		/// Retour au début si on est à la fin
		if (this.currentIndex+1 > this.nbImages)
		{
			this.currentIndex = 1;
		}
		// Active la nouvelle image
		var currentContainer = this.containers.item(this.currentIndex);
		if (!currentContainer.src) {
			currentContainer.src = currentContainer.getAttribute("alt");
		}
		this.containers.item(this.currentIndex).parentNode.style.display = "block";
		this.setTimeout("showNextImage", 2000);
	};

	return GalerieElement;
})());
/*------------------------------------------------------------------------------------
	CLASSE ThumbElement
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("ThumbElement", (function(){
	ThumbElement.extendsClass(com.egipe.soca.core.HTMLElement);
	function ThumbElement ()
	{
		this._parent()(arguments);
		this.tbElement = new com.egipe.soca.site.ThumbBigElement(this);
	}
	ThumbElement.prototype.clickEvent= function ()
	{
		if (this.getModule().currentMaxImage) {
			this.getModule().currentMaxImage.hideImage ();
		}
		this.tbElement.showImage();
		this.getModule().currentMaxImage = this.tbElement;
	};

	return ThumbElement;
})());
/*------------------------------------------------------------------------------------
	CLASSE ThumbElement
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("ThumbBigElement", (function(){
	ThumbBigElement.extendsClass(com.egipe.soca.core.HTMLElement);
	function ThumbBigElement (thumb)
	{
		this._parent()("div");
		this.setAttribute("class", "timage");
		var tsrc = thumb.getAttribute("src");
		this.mainImage = $(new Image ());
		this.origin = thumb;
		var imgHeight = thumb.htmlElement.height;
		var imgWidth = thumb.htmlElement.width;
		var fimgHeight = 2*imgHeight;
		var fimgWidth = 2*imgWidth;
		
		
		this.mainImage.htmlElement.src = tsrc.replace("."+imgWidth+"."+imgHeight,"."+fimgWidth+"."+fimgHeight);
		this.mainImage.setAttribute("width", imgWidth+"px");
		this.mainImage.setAttribute("height", imgHeight+"px");
		this.iwidth = imgWidth;
		this.iheight = imgHeight;
		this.step = 10;
		this.append(this.mainImage);
		this.hide();
		this.opacity = 100;
		this.insertIn(document.body);
		// Emplacement du thumbnail
		var offParent = thumb.htmlElement;
		var oTop = 0;
		var oLeft = 0;
		while (offParent.tagName.toLowerCase() !="body" && offParent.tagName.toLowerCase() !="html")
		{
			oTop += offParent.offsetTop;
			oLeft += offParent.offsetLeft;
			offParent = offParent.offsetParent;
		}
		
		
		this.itop = oTop;
		this.ileft = oLeft;
		this.mainImage.setStyle("position", "absolute");
	}
	ThumbBigElement.prototype.showImage = function ()
	{
		this.display();
		this.setTimeout("maximize", 50);
	};
	ThumbBigElement.prototype.maximize = function ()
	{
		var imgHeight = this.origin.htmlElement.height;
		var imgWidth = this.origin.htmlElement.width;

		if (this.opacity != 100)
		{
			this.opacity = 100;
			this.setStyle("opacity", 1);
		}
		if (this.iheight < 2*imgHeight)
		{
			this.iheight += Math.round((2*imgHeight)/this.step); 
			this.iwidth += Math.round((2*imgWidth)/this.step); 
			this.mainImage.setAttribute("width", this.iwidth+"px");
			this.mainImage.setAttribute("height", this.iheight+"px");
			this.mainImage.setStyle("top", (this.itop-((this.iheight-imgHeight)/2))+"px");
			var curleft = this.ileft-((this.iwidth-imgWidth)/2);
			if (curleft<0) {
				curleft = 0;
			}	
			this.mainImage.setStyle("left", curleft+"px");
			this.setTimeout("maximize", 50);
		}
	};
	ThumbBigElement.prototype.clickEvent = function ()
	{
		this.hideImage();
	};
	ThumbBigElement.prototype.hideImage = function ()
	{
		var imgHeight = this.origin.htmlElement.height;
		var imgWidth = this.origin.htmlElement.width;
		if (this.opacity > 0)
		{
			this.opacity -= 10;
			this.setStyle("opacity", Math.round(this.opacity/10)/10);
			this.setTimeout("hideImage", 50);
		}
		else
		{
			this.hide();
			this.mainImage.setAttribute("width", imgWidth+"px");
			this.mainImage.setAttribute("height", imgHeight+"px");
			this.setStyle("opacity", 1);
			this.mainImage.setStyle("top", this.itop+"px");
			this.mainImage.setStyle("left", this.ileft+"px");
			this.iwidth = imgWidth;
			this.iheight = imgHeight;
			this.opacity = 100;
		}
	};

	return ThumbBigElement;
})());
/*------------------------------------------------------------------------------------
	CLASSE MailtoLink
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("HelpElement", (function(){
	HelpElement.extendsClass(com.egipe.soca.core.HTMLElement);
	function HelpElement ()
	{
		if (!document.all)
		{
			this._parent()(arguments);
			this.arrow = this.append($(document.createElement("img")));
			this.arrow.setAttribute("height","15px");
			this.arrow.setAttribute("width","33px");
			this.arrow.setAttribute("src","/images/help.gif");
			this.arrow.setAttribute("class","harrow");
			this.input = false;
			var inputs = this.htmlElement.nextSibling.getElementsByTagName("input");
			if (inputs.length != 0)
			{
				this.input = $(inputs[0], com.egipe.soca.site.HInputElement);
				this.input.setHelp(this);
			}
			else {
				inputs = this.htmlElement.nextSibling.getElementsByTagName("textarea");
				if (inputs.length != 0)
				{
					this.input = $(inputs[0], com.egipe.soca.site.HInputElement);
					this.input.setHelp(this);
				}
				else {
					inputs = this.htmlElement.nextSibling.getElementsByTagName("select");
					if (inputs.length != 0)
					{
						this.input = $(inputs[0], com.egipe.soca.site.HInputElement);
						this.input.setHelp(this);
					}
				}
			}			
		}
		
	}
	return HelpElement;
})());
/*------------------------------------------------------------------------------------
	CLASSE MailtoLink
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("HInputElement", (function(){
	HInputElement.extendsClass(com.egipe.soca.core.HTMLElement);
	function HInputElement ()
	{
		this._parent()(arguments);
		this.help = false;
	}
	HInputElement.prototype.setHelp = function (helpContainer)
	{
		this.help = helpContainer;
		this.help.htmlElement.style.top = (this.htmlElement.offsetTop - (this.help.htmlElement.offsetHeight+26))+ "px";
		this.help.hide();
		this.help.setVisible();
	};
	HInputElement.prototype.focusEvent = function (event)
	{
		if (this.help)
		{
			this.help.display();
		}
	};
	HInputElement.prototype.blurEvent = function (event)
	{
		if (this.help)
		{
			this.help.hide();
		}
	};
	return HInputElement;
})());
/*------------------------------------------------------------------------------------
	CLASSE MailtoLink
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("ColapsableElement", (function(){
	ColapsableElement.extendsClass(com.egipe.soca.core.HTMLElement);
	function ColapsableElement ()
	{
		this._parent()(arguments);
		this.hide();
		this.strongs = this.htmlElement.getElementsByTagName("strong");
		this.colPara = new com.egipe.soca.site.ColapsableButton(this);
		this.colPara.insertBefore(this.htmlElement);
		
		var content = "";
		for (var i=0; i<this.strongs.length; i++)
		{
			content += this.strongs[i].innerHTML;
			if (i!=this.strongs.length-1) {
				content += ", ";
			} 
		}
		content += "...";
		this.colPara.setContent(content);
	}
	return ColapsableElement;
})());
/*------------------------------------------------------------------------------------
	CLASSE MailtoLink
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("ColapsableButton", (function(){
	ColapsableButton.extendsClass(com.egipe.soca.core.HTMLElement);
	function ColapsableButton (elementToShow)
	{
		this._parent()("a");
		this.addClass("ccolapse");
		this.setAttribute("title", "voir les détails");
		this.relatedElement = elementToShow;
	}
	ColapsableButton.prototype.clickEvent = function (event)
	{
		this.hide();
		this.relatedElement.display();
		return event.clearEvent();
	};
	return ColapsableButton;
})());
/*------------------------------------------------------------------------------------
	CLASSE MailtoLink
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("AutoSumitForm", (function(){
	AutoSumitForm.extendsClass(com.egipe.soca.core.HTMLElement);
	var site = com.egipe.soca.site;
	function AutoSumitForm ()
	{
		this._parent()(arguments);
		var cSelects = this.htmlElement.getElementsByTagName("select");
		var self = this.htmlElement;
		for (var i=0; i<cSelects.length; i++)
		{
			cSelects[i].onchange = function () { this.form.rsubmit.click(); };
		}
	}
	return AutoSumitForm;
})());
/*------------------------------------------------------------------------------------
	CLASSE MailtoLink
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("MailtoLink", (function(){
	MailtoLink.extendsClass(com.egipe.soca.core.HTMLElement);
	var site = com.egipe.soca.site;
	function MailtoLink ()
	{
		this._parent()(arguments);
		var pemail;
		if ("textContent" in this.htmlElement) {
			pemail = this.htmlElement.textContent.replace(" (at) ","@");
			this.htmlElement.textContent = pemail;
		} else {
			pemail = this.htmlElement.innerText.replace(" (at) ","@");
			this.htmlElement.innerText = pemail;
		}
		var femail = "mailto:"+pemail;
		if (this.hasAttribute("title")) {
			femail += "?subject="+this.getAttribute("title");
		}
		this.clink = femail;
	}
	MailtoLink.prototype.clickEvent = function (evt)
	{
		document.location.href = this.clink;
		return evt.clearEvent();
	};
	
	return MailtoLink;
})());

/*------------------------------------------------------------------------------------
	CLASSE Photos
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("Photos", (function(){
	Photos.extendsClass(com.egipe.soca.core.HTMLElement);
	var site = com.egipe.soca.site;
	function Photos ()
	{
		this._parent()(arguments);
		var imgs = this.htmlElement.getElementsByTagName("img");
		var self = this;
		this.mainImage = $(imgs[0]);
		imgs[0].onload = function () { self.mainImage.setVisible(); };
		this.images = {};
		this.currentIndex = 0;
		for (var i = 1; i<imgs.length; i++)
		{
			this.images[i-1] = $(imgs.item(i), com.egipe.soca.site.Photo);
			this.images[i-1].main = this;
			this.images[i-1]._index = i-1;
			
		}
		this.setMainImage(0);
	}
	Photos.prototype.setMainImage = function (anIndex)
	{
		this.images[this.currentIndex].anchor.removeClass("selected");
		var curImage = this.images[anIndex];
		var curUrl = curImage.getAttribute("src");
		this.mainImage.setAttribute("src", curUrl.replace('64.48','640.480'));
		curImage.anchor.addClass("selected");
		this.currentIndex = anIndex;
	};
	return Photos;
})());
/*------------------------------------------------------------------------------------
	CLASSE Photo
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("Photo", (function(){
	Photo.extendsClass(com.egipe.soca.core.HTMLElement);
	function Photo ()
	{
		this._parent()(arguments);
		this.anchor = $(this.htmlElement.parentNode);
		this.image = new Image ();
		this.image.src = this.getAttribute("src").replace('64.48','640.480');
		var self = this;
		this.image.onload = function () { self.activate (); };
	}
	Photo.prototype.activate = function ()
	{
		this.setVisible();
	};
	Photo.prototype.clickEvent = function (evt)
	{
		this.main.setMainImage(this._index);
		evt.clearEvent();
	};
	Photo.prototype.mouseoverEvent = function (evt)
	{
		this.main.setMainImage(this._index);
		evt.clearEvent();
	};
	Photo.prototype.mouseoutEvent = function (evt)
	{
		this.main.setMainImage(this._index);
		evt.clearEvent();
	};
	return Photo;
})());
/*------------------------------------------------------------------------------------
	CLASSE ThumbnailViewElement
	Element de type block en autoscroll
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("ThumbnailViewElement", (function(){
	ThumbnailViewElement.extendsClass(com.egipe.soca.core.HTMLElement);
	function ThumbnailViewElement ()
	{
		this._parent()(arguments);
		this.thumbnails = new Array ();
		this.currentThumbnailIndex = 0;
		this.paused = false;
		this.noscroll = false;
	
		// Div pour le scroll
		var cDivs = this.htmlElement.getElementsByTagName("div");
		var initialContainer = cDivs.item(0);
	
		// Ajout des scroller pour le navigateur
		this.overflow = document.createElement("div");
		this.overflow.style.overflow = "hidden";
		this.scrollLeft = new com.egipe.soca.base.Scroller (this, -5, "sleft");
		this.scrollRight = new com.egipe.soca.base.Scroller (this, 5, "sright");
		this.scrollLeft.hide();
		this.scrollRight.hide();
		this.scrollLeft.insertIn(this.htmlElement);
		this.scrollRight.insertIn(this.htmlElement);
		this.htmlElement.appendChild (this.overflow);
		// Div contenant les images
		this.container = this.overflow.appendChild(initialContainer);
		this.container.style.overflow = "hidden";
	
		// Ajout des thumbnails
		var oAnchors = this.htmlElement.getElementsByTagName("a");
		var currentThumbnail = false;
		for (var i=0; i<oAnchors.length; i++)
		{
			if (oAnchors.item(i).getElementsByTagName("img").length == 1)
			{
				currentThumbnail = new com.egipe.soca.site.ThumbnailElement (oAnchors.item(i));
				currentThumbnail.thumbnailView = this;
				currentThumbnail.viewIndex = this.thumbnails.length;
				this.thumbnails.push(currentThumbnail);
			}
		}

		// Ajout de la toolbar
		this.createToolbar ();
	
		// Ajout de la Div pour le diaporama;
		this.createDiapoContainer ();
	
		this.setDiaporamaView ();
	
	}
	ThumbnailViewElement.prototype.createToolbar = function () 
	{
		this.toolbar = this.htmlElement.insertBefore (document.createElement("div"), this.htmlElement.firstChild);
		this.toolbar.className = "diaptoolbar";
		this.standardViewButton = new com.egipe.soca.base.LinkButton(this, "setStandardView", "Standard", "application_view_2columns");
		this.standardViewButton.hide();
		this.diaporamaViewButton = new com.egipe.soca.base.LinkButton(this, "setDiaporamaView", "Diaporama", "application_view_gallery");
		this.navigatorViewButton = new com.egipe.soca.base.LinkButton(this, "setNavigatorView", "Navigation", "application_view_tile");
		this.navigatorViewButton.insertIn(this.toolbar);
		this.diaporamaViewButton.insertIn(this.toolbar);
		this.standardViewButton.insertIn(this.toolbar);
		this.toolbar.appendChild(document.createElement("hr"));
	};
	ThumbnailViewElement.prototype.createDiapoContainer = function () 
	{
	
		this.diapoContainer = this.htmlElement.appendChild (document.createElement("div"));
		this.diapoContainer.className = "diapocont";
		// Toolbar 
		var dtool = this.diapoContainer.appendChild (document.createElement("div"));
		dtool.className = "diaptools";
		var bNext = new com.egipe.soca.base.LinkButton (this, "goNext", "Suivant", "control_fastforward_blue");
		var bPrevious = new com.egipe.soca.base.LinkButton (this, "goPrevious", "Précédent", "control_rewind_blue");
		var bPause = new com.egipe.soca.base.LinkButton (this, "startPause", "Pause", "control_pause_blue");
		var bClose = new com.egipe.soca.base.LinkButton (this, "close", "Fermer", "cross");
		bPrevious.insertIn(dtool);
		bPause.insertIn(dtool);
		bNext.insertIn(dtool);
		bClose.insertIn(dtool);
		// Image viewer
		this.viewer = new com.egipe.soca.base.Image();
		this.viewer.viewElement = this;
		this.viewer.insertIn(this.diapoContainer);
		this.diapoContainer.style.display = "none";
	};
	ThumbnailViewElement.prototype.setStandardView = function () 
	{
		this.currentView = 0;
		this.clearTimeout();
		this.overflow.className = "onav";
		this.overflow.scrollLeft = 0;
		this.scrollLeft.hide();
		this.scrollRight.hide();
	
		this.diapoContainer.style.display = "none";
		this.navigatorViewButton.disable();
		this.diaporamaViewButton.disable();
		this.standardViewButton.enable();

		this.container.className = "standardView";
		this.container.style.width = "auto";
		this.container.style.height = "auto";
	};

	ThumbnailViewElement.prototype.setNavigatorView = function () 
	{
		this.currentView = 1;
		this.clearTimeout();
		this.overflow.className = "onav";
		this.overflow.scrollLeft = 0;
		this.scrollLeft.hide();
		this.scrollRight.hide();
	
		this.navigatorViewButton.enable();
		this.diaporamaViewButton.disable();
		this.standardViewButton.disable();
	
		this.diapoContainer.style.display = "none";

		this.container.className = "thumbs";
		this.container.style.width = "auto";
		this.container.style.height = "auto";

	};
	ThumbnailViewElement.prototype.setDiaporamaView = function () 
	{
		this.currentView = 2;
		this.scrollLeft.display();
		this.scrollRight.display();
	
		this.navigatorViewButton.disable();
		this.diaporamaViewButton.enable();
		this.standardViewButton.disable();
	
		this.diapoContainer.style.display = "block";
		this.diapoContainer.className = "diapcont";
	
		this.container.className = "diaporamaView";
		this.container.style.width = (this.thumbnails.length*161)+"px";
		this.container.style.height = "115px";
	
		this.overflow.className = "odiap";

		this.nextThumbnail();
	};
	ThumbnailViewElement.prototype.nextThumbnail = function () 
	{
		this.clearTimeout();
		if (arguments.length != 0) {
			this.currentThumbnailIndex = arguments[0];
		}
		if (document.all)
		{
			this.viewer.htmlElement.detachEvent("onload", BaseElement.prototype.onevent);
			this.viewer.htmlElement.setAttribute("height", "480px");
			this.viewer.htmlElement.setAttribute("width", "640px");
		}
		this.viewer.setImage(this.thumbnails[this.currentThumbnailIndex].imageElement.src.replace(".140.105",".640.480"));
	
		this.thumbnails[this.currentThumbnailIndex].getFocus();
		this.currentThumbnailIndex++;
		if (this.currentThumbnailIndex >= this.thumbnails.length) {
			this.currentThumbnailIndex = 0;
		}
		if (!this.paused) {
			this.setTimeout("nextThumbnail", 5000);
		}
	};
	ThumbnailViewElement.prototype.showThumbnail = function (cTIndex) 
	{
		this.clearTimeout();
		this.currentThumbnailIndex = cTIndex;
		if (document.all)
		{
			this.viewer.htmlElement.detachEvent("onload", this._onevent);
			this.viewer.htmlElement.setAttribute("height", "480px");
			this.viewer.htmlElement.setAttribute("width", "640px");
		}
		this.viewer.setImage(this.thumbnails[this.currentThumbnailIndex].imageElement.src.replace(".140.105",".640.480"));
		this.diapoContainer.className = "diapcont toclose";
		this.diapoContainer.style.display = "block";
		this.diapoContainer.style.top = (this.thumbnails[this.currentThumbnailIndex].imageElement.offsetTop-3)+"px";
	};
	ThumbnailViewElement.prototype.goNext = function () 
	{
		this.clearTimeout();
		if (this.currentThumbnailIndex >= this.thumbnails.length) {
			this.currentThumbnailIndex = 0;
		}
		this.nextThumbnail ();
	};
	ThumbnailViewElement.prototype.goPrevious = function () 
	{
		this.clearTimeout();
		this.currentThumbnailIndex = this.currentThumbnailIndex-2;
		if (this.currentThumbnailIndex < 0) {
			this.currentThumbnailIndex = this.thumbnails.length+this.currentThumbnailIndex;
		}
		this.nextThumbnail ();
	};
	ThumbnailViewElement.prototype.startPause = function (aBut) 
	{
		if (this.paused)
		{
			aBut.htmlElement.textContent = "Pause";
			this.paused = false;
			this.nextThumbnail ();
		}
		else 
		{
			aBut.htmlElement.textContent = "Reprendre";
			this.paused = true;
			this.clearTimeout();
		}
	};
	ThumbnailViewElement.prototype.close = function () 
	{
		this.diapoContainer.style.display = "none";
		this.diapoContainer.className = "diapcont";
	};
	ThumbnailViewElement.prototype.scrollStep = function (indice) 
	{
		this.overflow.scrollLeft = this.overflow.scrollLeft + indice;
	};
	return ThumbnailViewElement;
})());

/*------------------------------------------------------------------------------------
	CLASSE ThumbnailElement
	Element de type block en autoscroll
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("ThumbnailElement", (function(){
	ThumbnailElement.extendsClass(com.egipe.soca.core.HTMLElement);
	function ThumbnailElement ()
	{
		this._parent()(arguments);
		var cImgs = this.htmlElement.getElementsByTagName("img");
		this.imageElement = cImgs.item(0);
		var cUls = this.htmlElement.parentNode.getElementsByTagName("ul");
		if (cUls.length != 0) {
			this.tasksElement = cUls.item(0);
		}
	//	cvi_instant.add( this.imageElement, { tilt: "none", shadow: 33, color: "#fff", noshade: false } );
	}
	ThumbnailElement.prototype.clickEvent = function (event) 
	{
		var oTitle;
		var currentView = 1;
		if ("thumbnailView" in this) {
			currentView = this.thumbnailView.currentView+0;
		}
		event.clearEvent();
		if (currentView == 2) {
			this.thumbnailView.nextThumbnail(this.viewIndex);
		}
		else {
			this.thumbnailView.showThumbnail (this.viewIndex);
		}
		return false;
	};
	ThumbnailElement.prototype.getFocus = function () 
	{
		var cThumb = document.getElementById ("curThumb");
		if (cThumb) {
			cThumb.removeAttribute ("id");
		}
		this.htmlElement.setAttribute("id", "curThumb");	
	
		if (!this.thumbnailView.noscroll)
		{
			if ((this.htmlElement.offsetLeft+149) > (this.thumbnailView.overflow.scrollLeft + this.thumbnailView.overflow.clientWidth)) {
				this.thumbnailView.overflow.scrollLeft = this.htmlElement.offsetLeft+149;
			}
			if (this.htmlElement.offsetLeft < this.thumbnailView.overflow.scrollLeft) {
				this.thumbnailView.overflow.scrollLeft = this.htmlElement.offsetLeft-30;
			}
			if ((this.htmlElement.offsetLeft+149) < this.thumbnailView.overflow.clientWidth) {
				this.thumbnailView.overflow.scrollLeft = 0;
			}
			if ((this.htmlElement.offsetLeft+150) == (this.thumbnailView.thumbnails.length*149)) {
				this.thumbnailView.overflow.scrollLeft = this.thumbnailView.thumbnails.length*149;
			}
		}
	};
	ThumbnailElement.prototype.mouseoverEvent = function (cbevent) {
		this.thumbnailView.noscroll = true;
	};
	ThumbnailElement.prototype.mouseoutEvent = function (cbevent) {
		this.thumbnailView.noscroll = false;
	};
	return ThumbnailElement;
})());


/*------------------------------------------------------------------------------------
	CLASSE Sudoku
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("Sudoku", (function(){
	Sudoku.extendsClass(com.egipe.soca.core.HTMLElement);
	var site = com.egipe.soca.site;
	function Sudoku ()
	{
		this._parent()(arguments);
		this.rows = [];
		this.cols = [];
		this.groups = [];
		this.setAttribute("cellspacing",0);
		this.setAttribute("cellpadding",0);
		for (var i=0;i<9;i++) {
			this.cols.push(new site.SudokuGroup ("col",i));
			this.groups.push(new site.SudokuGroup ("group",i));
		}
		var curGroup;
		for (i=0;i<9;i++) {
			this.rows.push(this.append(new site.SudokuGroup ("row",i)));
		}
		
	}
	return Sudoku;
})());
/*------------------------------------------------------------------------------------
	CLASSE SudokuGroup
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("SudokuGroup", (function(){
	SudokuGroup.extendsClass(com.egipe.soca.core.HTMLElement);
	var site = com.egipe.soca.site;
	function SudokuGroup (aType,anIndex)
	{
		this.cells = [];
		this.type = aType;
		this.index = anIndex;
		if (this.type=="row") {
			this._parent()("tr");			
		}
	}
	SudokuGroup.prototype.onAttach = function ()
	{
		var curCell;
		for (var i=0;i<9;i++) 
		{
			curCell = this.append(new site.SudokuCell([this.index,i]));
			this.addCell(curCell);
		}
	};
	SudokuGroup.prototype.addCell = function (aSudokuCell)
	{
		this.cells.push(aSudokuCell);
	};
	return SudokuGroup;
})());
/*------------------------------------------------------------------------------------
	CLASSE SudokuTable
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("SudokuCell", (function(){
	SudokuCell.extendsClass(com.egipe.soca.core.HTMLElement);
	function SudokuCell (anArray)
	{
		this._parent()("td");
		this.rowIndex = anArray[0];
		this.colIndex = anArray[1];
		if ((this.colIndex+1)%3==0) {
			this.addClass("tcol");
		}
		if ((this.rowIndex+1)%3==0) {
			this.addClass("tline");
		}
		
		this.input = this.append($(document.createElement("input")));
		this.input.setAttribute("type","text");
		this.input.setAttribute("size","1");
		this.groupIndex = (Math.ceil((this.rowIndex+1)/3)+(Math.ceil((this.colIndex+1)/3)-1)*3)-1;
	}
	SudokuCell.prototype.onAttach = function ()
	{
		_log(this.groupIndex);
		this.parentObject.parentObject.cols[this.colIndex].addCell(this);		
		this.parentObject.parentObject.groups[this.groupIndex].addCell(this);	
	};	
	return SudokuCell;
})());
/*------------------------------------------------------------------------------------
	CLASSE vmenuElement
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("EditableZone", (function(){

	EditableZone.extendsClass(com.egipe.soca.core.HTMLElement);
	function EditableZone ()
	{
		this._parent()(arguments);
		this.para = this.getElementsByTagName("p")[0];
		this.input = this.append($(document.createElement("textarea")));
		this.input.setHidden();
	}
	EditableZone.prototype.clickEvent = function ()
	{
		this.input.setVisible();
		this.input.value = this.input.htmlElement.value.replace("<br/>","\n");
	};
	EditableZone.prototype.mouseoutEvent = function ()
	{
		if (this.input.isActive())
		{
			this.para.innerHTML = this.input.htmlElement.value.replace(new RegExp( "\\n", "g" ),"<br/>");
			this.input.setHidden();
		}
	};
	
	return EditableZone;
})());
/*------------------------------------------------------------------------------------
	CLASSE vmenuElement
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("vmenuElement", (function(){

	vmenuElement.extendsClass(com.egipe.soca.core.HTMLElement);
	function vmenuElement ()
	{
		this._parent()(arguments);
		this.countItem = 2;
		this.showAll = false;
		this.title = $(this.getElementsByTagName("h3").item(0), com.egipe.soca.core.HTMLElement);
		this.container = $(this.getElementsByTagName("ul").item(0), com.egipe.soca.core.HTMLElement);
		this.items = $$("li", com.egipe.soca.site.vmenuItemElement, this.htmlElement);
		this.hideItems();
	}
	vmenuElement.prototype.hideItems = function ()
	{
		if (this.items.length>this.countItem)
		{
			this.removeClass("more_all");
			this.addClass("more");
			for (var i=this.countItem; i<this.items.length; i++)
			{
				this.items[i].hide();
			}
			this.showAll = false;
		}
	};
	vmenuElement.prototype.showItems = function ()
	{
		if (this.items.length>this.countItem && !this.showAll)
		{
			this.removeClass("more");
			this.addClass("more_all");
			for (var i=this.countItem; i<this.items.length; i++)
			{
				this.items[i].display();
			}
			this.showAll = true;
		}
	};
	vmenuElement.prototype.mouseoverEvent = function ()
	{
		this.showItems();
	};
	vmenuElement.prototype.mouseoutEvent = function (evt)
	{
		if (!this.contains(evt.eventHandler.relatedTarget))
		{
			this.hideItems();
		}
	};
	
	return vmenuElement;
})());

/*------------------------------------------------------------------------------------
	CLASSE vmenuElement
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("vmenuItemElement", (function(){

	vmenuItemElement.extendsClass(com.egipe.soca.core.HTMLElement);
	function vmenuItemElement ()
	{
		this._parent()(arguments);
	}
	vmenuItemElement.prototype.mouseoverEvent = function ()
	{
		this.parentObject.parentObject.showItems();
	};
	
	return vmenuItemElement;
})());

/*------------------------------------------------------------------------------------
	CLASSE ScollerElement
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("ScollerElement", (function(){

	ScollerElement.extendsClass(com.egipe.soca.core.HTMLElement);
	function ScollerElement ()
	{
		this._parent()(arguments);
		this.interval = 50;
		this.container = $(this.getElementsByTagName("ul").item(0), com.egipe.soca.core.HTMLElement);
		this.slides = $$("img", com.egipe.soca.site.ImageScrollElement, this.htmlElement); 
		this.navs = $$(".nav", com.egipe.soca.site.NavigScrollElement, this.htmlElement); 
		this.scrollIndice = 1;
		this.scrollStep = 1;
		this.scrollScale = 1;
		this.setTimeout("scroll",this.interval);
	}
	ScollerElement.prototype.scroll = function ()
	{
		if ( (this.scrollIndice < (90*(this.slides.length-7))) && ((this.scrollIndice+(this.scrollStep*this.scrollScale))>0)) {
			this.scrollIndice += this.scrollStep*this.scrollScale;
			this.container.setStyle("marginLeft", "-"+this.scrollIndice+"px");
			this.setTimeout("scroll",this.interval);
		} 
		else 
		{
			this.scrollStep = -this.scrollStep;
			this.scrollIndice += this.scrollStep*this.scrollScale;
			if (!this.navs[0].isOver && !this.navs[1].isOver)
			{
				this.setTimeout("scroll",this.interval);
			}
		}
	};
	ScollerElement.prototype.mouseoverEvent = function ()
	{
		this.clearTimeout();
	};
	ScollerElement.prototype.mouseoutEvent = function ()
	{
		this.scrollScale = 1;
		this.setTimeout("scroll",this.interval);
	};
	
	return ScollerElement;
})());

/*------------------------------------------------------------------------------------
	CLASSE ScollerElement
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("ImageScrollElement", (function(){

	ImageScrollElement.extendsClass(com.egipe.soca.core.HTMLElement);
	function ImageScrollElement ()
	{
		this._parent()(arguments);
	}
	ImageScrollElement.prototype.mouseoverEvent = function ()
	{
		this.parentObject.parentObject.mouseoverEvent();
	};
	ImageScrollElement.prototype.mouseoutEvent = function ()
	{
		this.parentObject.parentObject.mouseoutEvent();
	};
	
	return ImageScrollElement;
})());
/*------------------------------------------------------------------------------------
	CLASSE ScollerElement
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("NavigScrollElement", (function(){

	NavigScrollElement.extendsClass(com.egipe.soca.core.HTMLElement);
	function NavigScrollElement ()
	{
		this._parent()(arguments);
		this.isOver = false;
	}
	NavigScrollElement.prototype.mouseoverEvent = function ()
	{
		if (!this.isOver)
		{
			this.isOver = true;
			if (this.hasClass("back")) {
				this.parentObject.scrollStep = -1;
			}
			else {
				this.parentObject.scrollStep = 1;
			}
			this.setTimeout("accelerate",200);
		}
	};
	NavigScrollElement.prototype.accelerate = function ()
	{
		if (this.parentObject.scrollScale < 9)
		{
			this.parentObject.scrollScale += 1;
		}
		if (this.isOver) {
			this.setTimeout("accelerate",200);
		}
	};
	NavigScrollElement.prototype.mouseoutEvent = function ()
	{
		this.isOver = false;
		this.clearTimeout();
		this.parentObject.mouseoutEvent();
	};
	
	return NavigScrollElement;
})());
	
/*------------------------------------------------------------------------------------
	CLASSE SliderElement
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("SliderElement", (function(){

	SliderElement.extendsClass(com.egipe.soca.core.HTMLElement);
	function SliderElement ()
	{
		this._parent()(arguments);
		this.interval = 3000;
		this.slides = $$("div", com.egipe.soca.site.SlideElement, this.htmlElement); 
		this.currentSlide = this.slides.length-1;
		this.setTimeout("startNextSlide",this.interval);
	}
	SliderElement.prototype.startNextSlide = function ()
	{
		if (this.currentSlide>0)
		{
			this.slides[this.currentSlide].decreaseOpacity();
		} 
		else 
		{
			this.slides[this.slides.length-1].increaseOpacity();
		}
	};
	SliderElement.prototype.endNextSlide = function ()
	{
		this.currentSlide = this.currentSlide-1;
		this.clearTimeout();
		this.setTimeout("startNextSlide",this.interval);
	};
	SliderElement.prototype.restart = function ()
	{
		for (var i=0; i<this.slides.length; i++)
		{
			this.slides[i].setOpacity(10);
		}
		this.currentSlide = this.slides.length-1;
		this.clearTimeout();
		this.setTimeout("startNextSlide",this.interval);
	};
	
	return SliderElement;
})());

/*------------------------------------------------------------------------------------
	CLASSE SlideElement
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("SlideElement", (function(){

	SlideElement.extendsClass(com.egipe.soca.core.HTMLElement);
	function SlideElement ()
	{
		this._parent()(arguments);
		this.opacity = 10;
	}
	SlideElement.prototype.setOpacity = function (aNumber)
	{
		this.opacity = aNumber;
		if (document.all) {
			this.setStyle("filter","alpha(opacity="+(this.opacity*10)+")");
		}
		else {
			this.setStyle("opacity",this.opacity/10);
		}
	};
	SlideElement.prototype.decreaseOpacity = function ()
	{
		if (this.opacity>0) {
			this.setOpacity(--this.opacity);
			this.setTimeout("decreaseOpacity", 100);
		} else {
			this.clearTimeout();
			this.parentObject.endNextSlide();
		}
		
	};
	SlideElement.prototype.increaseOpacity = function ()
	{
		if (this.opacity<10) {
			this.setOpacity(++this.opacity);
			this.setTimeout("increaseOpacity", 100);
		} else {
			this.clearTimeout();
			this.parentObject.restart();
		}
		
	};
	
	return SlideElement;
})());

/*------------------------------------------------------------------------------------
	CLASSE MainmenuElement
	Gère un diaporama de photos
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("MainmenuElement", (function(){

	MainmenuElement.extendsClass(com.egipe.soca.core.HTMLElement);
	function MainmenuElement ()
	{
		this._parent()(arguments);
		var oUls = this.htmlElement.parentNode.getElementsByTagName("ul");
		// Construction des sous-menus
		this.submenus = [];
		for (var i=0; i<oUls.length; i++) 
		{
			if (oUls.item(i).className.indexOf("submenu") != -1)
			{
				var newmenu = new com.egipe.soca.site.SubmenuElement(oUls.item(i));
				newmenu.mainmenu = this;
				this.submenus.push(newmenu);
			}
		}
		// Attachement de sous menus au menu principal, ajout du hover
		var oLis = this.htmlElement.getElementsByTagName("li");
		this.mainitems = [];
		this.currentMenu = 0;
		for (i=0; i<oLis.length; i++) 
		{
			if (oLis.item(i).className == "current")
			{
				this.currentMenu = i;
			}
			var newitem = new com.egipe.soca.site.MainitemElement(oLis.item(i));
			newitem.submenu = this.submenus[i];
			newitem.submenu.mainitem = newitem;
			newitem.mainmenu = this;
			this.mainitems.push(newitem);
		}
		this.hideSubmenus();
		this.showCurrent();
	}
	MainmenuElement.prototype.hideSubmenus = function (currentMenu)
	{
		for (var i=0; i<this.submenus.length; i++)
		{
			if (this.submenus[i] !== currentMenu)
			{
				this.submenus[i].hide();
			}
		}
		for (i=0; i<this.mainitems.length; i++)
		{
			this.mainitems[i].setAttribute("class", "");
		}
	};
	MainmenuElement.prototype.showCurrent = function ()
	{
		this.hideSubmenus();
	//	this.submenus[this.currentMenu].display();
		this.mainitems[this.currentMenu].setAttribute("class", "current");
	};
	return MainmenuElement;
})());

/*------------------------------------------------------------------------------------
	CLASSE MainmenuElement
	Gère un diaporama de photos
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("MainitemElement", (function(){

	MainitemElement.extendsClass(com.egipe.soca.core.HTMLElement);
	function MainitemElement ()
	{
		this._parent()(arguments);
		this.submenu = false;
		this.mainmenu = false;
	}
	MainitemElement.prototype.mouseoverEvent = function (evt)
	{
		this.mainmenu.hideSubmenus(this.submenu);
		this.setAttribute("class", "current");
		var oleft = 0;
		if (this.htmlElement.offsetLeft!=0) {
			oleft =	this.htmlElement.offsetLeft-1;
		}
			
		this.submenu.htmlElement.style.left = oleft+"px";
		this.submenu.display();
	};
	MainitemElement.prototype.mouseoutEvent = function (evt)
	{
		var destNode = evt.eventHandler.relatedTarget; 
	
		if (!this.contains(destNode) && evt.originalTarget != this.htmlElement && !this.submenu.contains(destNode))
		{
			this.clearTimeout();
			this.mainmenu.showCurrent();
		}
	};
	
	return MainitemElement;
})());

/*------------------------------------------------------------------------------------
	CLASSE SubmenuElement
	Gère un diaporama de photos
-------------------------------------------------------------------------------------*/
com.egipe.soca.site.add("SubmenuElement", (function(){

	SubmenuElement.extendsClass(com.egipe.soca.core.HTMLElement);
	function SubmenuElement ()
	{
		this._parent()(arguments);
		this.mainmenu = false;
		this.mainitem = false;
		this.ison = false;
	}
	SubmenuElement.prototype.mouseoverEvent = function (evt)
	{
		this.ison = true;
		this.mainmenu.hideSubmenus(this);
		this.mainitem.setAttribute("class", "current");
		this.display();
	};
	
	SubmenuElement.prototype.mouseoutEvent = function (evt)
	{
		var destNode = evt.eventHandler.relatedTarget; 
		if (!destNode) {
			destNode = evt.eventHandler.toElement;
		}
		
		if (this.ison && !this.contains(destNode))
		{
			this.hide();
			this.ison = false;
			this.mainitem.mouseoutEvent(evt);
		}
		return evt.clearEvent();
	};
	
	return SubmenuElement;
})());
	
