/*
	Created by: Jonathan Arp
	Date: 09/04/2009
	Version: .9.0

 	fadon is plugin that allows you to have a portion  of you display fade out when elements are clicked
 	this is recommended for form submissions in particularil
 	
 	the funciton takes 2 arguments
 	
 	container: the div or other element that you have to have fade out
 	params: currently two parameters are available. the opacity and the message
 	
 	opacity -- between 0 - 1 for the level of opacity
 	message -- if you want to change the message of your submit button, add this parameter
 	           your message will display in the submit button on click

 	You would call this from the host page with the following:
 
 	$("input[type='submit']").fadeon(
		"body", 
		{
		opacity:.3,
		message:'Yo Wait'
		}
		);
 	
*/

jQuery.fn.fadeon = function(container, params){
	
	// if no parameters are passed in, create params object and set opacity default to 30%
	if(params == null){
		params = new Object();
		params.opacity = .3;		
	}
	
	$(this).each(function(){
		$(this).click(function() {  	
			// fade container to specificd opacity	   		
			$(container).fadeTo('slow', params.opacity);
			// update the submit button is a submit button and a message is passed in the params			
			if($(this).attr('type') == 'submit'  && params.message !== 'undefined'){	
				$(this).attr('value', params.message);				
				}
		   });
		});
}

// for later
//$('<div class="loader-box"></div>').insertBefore( $('#crumbs') )
