var aitindo = function() {
	return  {
		setErrorMessage: function(msg) {
			$('div.message.error').html(msg).show('slow');
		},			
		setSuccessMessage: function(msg, hideAfter) {
			$('div.message.good').html(msg).show('slow');
			
			if(hideAfter != null)
			{
				setTimeout(function(){$('div.success').hide('slow');}, hideAfter);
			}				
		}
	}		
}();

function fix_tinymce(form)
{
    $.each($('textarea', form), function() {
        $(this).val(tinyMCE.get(this.id).getContent());
    });
}

var newFieldHide = function(hash) {
  hash.w.fadeOut('2000',function() { hash.o.remove(); });
};
var newFieldShow = function(hash) {
  hash.w.fadeIn("2000");
};

function display_popup(element_id)
{
  var element = $('#' + element_id);
  var height = element.height();
  var width = element.width();
  
  element.css('margin-left', -width/2).css('margin-top', -height/2).css('top', '50%').css('left', '50%').css('position', 'fixed').css('background', '#ffffff').jqmShow();
}

// Initialize popup
$(document).ready(function() {
  $('.jqm').jqm({onHide:newFieldHide, onShow:newFieldShow, overlay: 75});
});
