/**
 * @license
 * Logiciel RBS Change© Société RBS, 2006-2007.
 * Le logiciel ne peut être copié, corrigé, traduit ou modifié sans l'autorisation
 * préalable de l'auteur selon le Code de la Propriété Intellectuelle (http://www.celog.fr/cpi/).
 * Consulter les Dispositions Générales de droit d'exploitation.
 * Tout contrefacteur pourra faire l’objet de poursuites judiciaires par la société RBS, auteur du logiciel.
 * --
 * RBS Change™, © 2006-2007 Ready Business System.
 * This application can not be copied, changed, translated, or modified in any way without
 * prior authorization from RBS, the author of the application, according to the French Code
 * of Intellectual Property (http://www.celog.fr/cpi/). Consult the Code's General Dispositions
 * about rights of use.
 * Any use of this application without prior authorization from RBS will be subject to legal
 * prosecution to the full extent of the law.
 *
 * @copyright RBS 2006-2007
 * @date Tue May 29 15:22:02 CEST 2007
 * @author intbonjf
 *
 * Don't understand this code?
 * Everything is encapsulated into an anonymous function, so there is no global
 * functions nor variables :)
 * This is a great way to execute initialization code without the risk to override
 * other modules' JS code.
 *
 * More information here:
 * http://css.alsacreations.com/Tutoriels-JavaScript/JavaScript-organiser-son-code-en-modules
 *
 * The initForms() function is based on the code here:
 * http://www.alistapart.com/articles/prettyaccessibleforms/
 *
 * This script uses JQuery, available here:
 * http://www.jquery.com
 */
(function()
{
	function initForms()
	{
		// Hide forms
		$( 'form.cmxform' ).hide().end();

		// Processing
		$( 'form.cmxform' ).find( 'li/label' ).not( '.nocmx' ).each( function( i ){
			var labelContent = this.innerHTML;
			var labelWidth = document.defaultView.getComputedStyle( this, '' ).getPropertyValue( 'width' );
			var labelSpan = document.createElement( 'span' );
			labelSpan.style.display = 'block';
			labelSpan.style.width = labelWidth;
			labelSpan.innerHTML = labelContent;
			this.style.display = '-moz-inline-box';
			this.innerHTML = null;
			this.appendChild( labelSpan );
		} ).end();

		// Show forms
		$( 'form.cmxform' ).show().end();
	}

	// Initialize forms (required only for Firefox)
	if (document.addEventListener)
	{
		addLoadListener(initForms);
	}
}
)();
