$(function () {
  var fname = 'form.mophform, form.mophform2';
  var getStyle = function(i) {
    return i.currentStyle || document.defaultView.getComputedStyle(i, '');
  };

  // Hide forms
  $(fname).hide().end();
  
  // Processing
  $(fname).find( 'label' ).not( '.nocmx' ).each(function (i) {
    var labelContent = this.innerHTML;
    var labelWidth = getStyle(this).width;
    var labelSpan = document.createElement('span');
    labelSpan.style.display = 'block';
    if (labelWidth != '0px') labelSpan.style.width = labelWidth;
    labelSpan.innerHTML = labelContent;

    if ($.browser.mozilla) this.style.display = '-moz-inline-box';
    if ($.browser.opera) this.style.display = '-moz-inline-box';
    if ($.browser.safari) this.style.display = '-moz-inline-box';
    this.innerHTML = '';
    this.appendChild(labelSpan);
    
    var labelpx = labelWidth;
    if (labelWidth.match(/^(\d+)(px)?$/)) {
        labelpx = RegExp.$1;
    }
    $(this).parent().parent().find('.mophform-text').each(function (txt) {
      var style = getStyle(this);
      $(this).css({
        position: "relative",
        top: "-1.8em",
        left: labelWidth,
        width: (405 - 10 - labelpx) + "px",
        "margin-bottom": "-1.5em"
      });
    });
    
  } ).end();
  
  // Show forms
  $(fname).show().end();
});
