// JavaScript Document
//created by Marcone Ferreira Ramos 02/11/2011
//contact development@marconeramos.com
(function($){
jQuery.fn.bmformbehaviors=function(bmretrieve,thesubmit){
//gives a name to the element
var element=this;
//calls the function bellow, applyBehavior
applyBehavior();
//starts the function
function applyBehavior(){
	//gets the value sent
	var elval=bmretrieve;
	//splits the value sent
	var str=elval.split("!::");
	//if the button is not disabled, it will automaticlly disable it.
	/*if ($(thesubmit).is(':disabled')==false) { 
		$(thesubmit).attr('disabled', 'disabled');
	} */
	//start the case
		switch(str[0]) {
			//if the str returns error means that if the element is disabled, it has to enable it again
			case 'error': 
				 if ($(thesubmit).is(':disabled')==true) { 
					$(thesubmit).removeAttr("disabled");
				 };
			break;
			// if the str is ok, that menas that the form is not necessary anymore. so it disappears
			case 'ok': 
					$(element).fadeOut(3000);
			break;
		}
}
};
})(jQuery);
