/*
	NMS Collapse v1.0
	Created by: Steven Monetti
	Last modified: 01/23/2009
	
	
	Functionallity: It automatically hides a div tag and show an arrow simbol to toggle it open and close.
	
*/
(function($) {

$.fn.nms_iLoad = function(options) {
	
	//Options
	var defaults = {
		loader: 'jquery/NMS/img/ajax-loader.gif'
	};  
	
	var options = $.extend(defaults, options); 
	

	//Begin plugin
	return this.each(function() {
		
		// Get DIV id
		var div_id = $(this).attr('id');
		
		// Temp id
		if(div_id == '') {
			$(this).attr('id','nms-temp-iLoad-div-id');
			div_id = 'nms-temp-iLoad-div-id';
		}
		
		// Get URL for AJAX
		var URL = $(this).attr('title');
		
		// Loading gif
		$(this).html('<img src="'+options.loader+'">');
		
		// AJAX
		$.get(URL, {}, function(data) {
			
			// Replace content
			$('#'+div_id).html(data);
			
			//Erase temp id
			if(div_id == 'nms-temp-iLoad-div-id') {
				$(this).attr('id','');
			}
		});
				
	});

};


})(jQuery);
