/*
// jQuery fancyTabControl
//
// Version 1.0
// Based off of jQuery Multi Select by
// Cory S.N. LaViska
// A Beautiful Site (http://abeautifulsite.net/)
// 06 April 2008
// Visit http://abeautifulsite.net/notebook.php?article=62 for more information
//
// Andre LeBlanc
// Liquid Multimedia (http://www.liquidmm.com)
// 03 September 2008
// E-Mail andre@liquidmm.com for more information
//
// Usage: $('#control_id').fancyTabControl( options, callback )
//
// Options:  selectAll          - whether or not to display the Select All option; true/false, default = true
//           selectAllText      - text to display for selecting/unselecting all options simultaneously
//           noneSelected       - text to display when there are no selected items in the list
//           oneOrMoreSelected  - text to display when there are one or more selected items in the list
//                                (note: you can use % as a placeholder for the number of items selected).
//                                Use * to show a comma separated list of all selected; default = '% selected'
//
// Dependencies:  jQuery 1.2 or higher (http://jquery.com/)
//                the jQuery Dimensions plugin (http://plugins.jquery.com/project/dimensions)
//
// Licensing & Terms of Use
// 
// jQuery File Tree is licensed under a Creative Commons License and is copyrighted (C)2008 by Cory S.N. LaViska.
// For details, visit http://creativecommons.org/licenses/by/3.0/us/
//	
*/
if(jQuery) (function($){
	
	$.extend($.fn, {
		fancyTabControl: function(o, callback) {
			// Default options
			if( !o ) var o = {};
			
			
			// Initialize each fancyTabControl
			$(this).each( function() {
				var container = this;
				
				// Events
				$(container).find("div.tab").click( function() {
					$(this).parent().find('div.tab').removeClass("selected");
					$(this).addClass("selected");
					var idx = $(container).find("div.tab").index(this);
					$(container).find("div.tab_contents.selected").removeClass("selected");
					$($(container).find("div.tab_contents")[idx]).addClass("selected");
					if ($(this).hasClass('refresh')) { 
						window.location = $(this).find('a')[0].href;
					}
					if ($(this).hasClass('map')) {
					    gmap_load();					
					}
					return false;
				}).focus( function() {
					// So it can be styled with CSS
					$(this).addClass('focus');
				}).blur( function() {
					// So it can be styled with CSS
					$(this).removeClass('focus');
				});
				$(container).find('div.tab.selected.map').each(function() {gmap_load();});
				
			});
			
		}
		
	});
	
})(jQuery);