/**
 *
 */

if(typeof jQuery != 'undefined') {
	(function($) {
		
		$.fn.extend({
			jazzfmgallery: function(custom_settings) {
				
				// If it's not at least jquery 1.2.6 then sad times :(
				if($.fn.jquery < '1.2.6') {return;}
				// If the actual object doesn't have length, sad times :(
				if(!$(this).length){
					return;
				}
				
				// Standard settings
				var default_settings = {
					gallery_class: '.gallery-icon',
					image_class: '.attachment-thumbnail',
					colorbox: true,
					colorbox_width: 600,
					colorbox_height: 600
				};
				
				// New settings
				settings = $.extend(true, default_settings, custom_settings);
				
				// Get the current link url and replace it with the image src
				$(settings.image_class).each(function(){
					var image = $(this).attr('src');
					
					$(this).parent().attr('href', image.replace('-150x150', ''));
				});
				
				if(settings.colorbox) {
					$(settings.gallery_class + ' a').colorbox({width: settings.colorbox_width, height: settings.colorbox_height});
				}
				
			}
		});
		
	})(jQuery);
}
