/* All Jquery code has to be wrapped in a (document).ready function() */
jQuery(document).ready(function(){
	var href;
	/*jQuery("li.on").addClass("current");	*/
	jQuery("div.on").show();
	jQuery("ul li a.tabLinkMod").click(function(){			
		href = jQuery(this).attr("href");
		hideAllExcept(href);
		/*jQuery(this).parent().parent().addClass("current");*/
		return false;		
	});	
	
	/* function hides all divs except the one with the ID that's declared in the href */
	function hideAllExcept(el) { 			
		jQuery("ul.anchors li").removeClass("current");
		jQuery('div.fragment').hide();
		jQuery(el).show();						    
	}
});


jQuery(document).ready(function(){
	
	// resize to compressed version if more than 4 tabs
	if (jQuery('#tabNavigation li').length == 5) {
		jQuery('#tabNavigation').addClass('five');
	} else if (jQuery('#tabNavigation li').length == 6) {
		jQuery('#tabNavigation').addClass('six');
	}

	selectTab(jQuery("#tabNavigation li.active a").get(0));

	jQuery("#tabNavigation a").click(function(){			
		selectTab(this);
		return false;		
	});	

	function selectTab(tab) {
		jQuery("#tabNavigation a").each(function(i) {
			if (this == tab) {
				hideAllExcept(i);
				return;
			}
		});
	}
	
	function hideAllExcept(index) {
		jQuery('#tabNavigation a').each(function(i) {
			if (i == index)	{
				jQuery(this).children('img').eq(0).hide();
				jQuery(this).children('img').eq(1).show();
			} else {
				jQuery(this).children('img').eq(0).show();
				jQuery(this).children('img').eq(1).hide();
			}
		});

		jQuery('#tabNavigation li').removeClass('active');
		jQuery('#tabContent div').hide();
		jQuery('#tabNavigation li').eq(index).addClass('active');
		jQuery('#tabContent div').eq(index).show();
	}
});