var cmx_done=null;
var format_done=null;
function docmxform(){
	if (!window.jQuery) { // on passe ici apres ajax et un file upload qui se fai en iframe dans laquelle jQuery n'existe pas
		setTimeout(docmxform,1000);
		return;
	}
	// on peut arriver ici en etant sous opera, donc double test !
	if (jQuery.browser.firefox){
		cmx_done = true;
	  // Hide forms
	  var f=jQuery('form').parents('div.formulaire_spip').find('form' );
	  f.css('opacity','50%').end();
	  
	  // Processing
	  f.find( 'ol>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
	  f.css('opacity','100%').end();
	}
}
function cmxform(){
		docmxform();
		if (window.onAjaxLoad)
		  // s'ajouter dans la file des onajaxload
		  onAjaxLoad(docmxform);
}
function formate_form(){
	if (window.jQuery) {
		var formulaires = jQuery('form').parents('div.formulaire_spip').find('form').not('.styled');
		if (formulaires.length){
			jQuery(formulaires).find('input, textarea')
			  .bind('focus',function(){jQuery(this).addClass('focus');})
			  .bind('blur',function(){jQuery(this).removeClass('focus');});
			jQuery(formulaires).find('.bouton input,.bouton a,.boutons input').not('.styled').wrap('<span class="bouton-left"><span class="bouton-right"></span></span>').addClass('styled');
			jQuery(formulaires).addClass('styled');
		}
	}
}
if( document.addEventListener ) document.addEventListener( 'DOMContentLoaded', cmxform, false );
if (window.jQuery) {
	jQuery('document').ready(function(){
		formate_form();
	  onAjaxLoad(formate_form);
	});
}
