﻿/*
	Tabs Code for Vehicle Page	
*/

$( function() {
	
	$(".TabStrip").tabs();

	// Loop through each TabPage and make them all - and their parent container - the same height.
	$(".TabPage").parent().each(	
		function(i) {	
			var maxHeight = 0;
			$(this).children(".TabPage").each(
				function(j) {
					if ($(this).outerHeight() > maxHeight) maxHeight = $(this).outerHeight();
				}
			)
			$(this).children(".TabPage").height(maxHeight);
			$(this).height(maxHeight);
			
		}
	);
	
	$(".TabSectionWrapper .TabsWrapper").each(
		function(i) {
			var maxHeight = 0;
			$(this).children(".Tab").each(
				function(j) {
					if($(this).outerHeight() > maxHeight) maxHeight = $(this).outerHeight();
				}
			)
			$(this).css("min-height", maxHeight + "px");
			
			// $(this).children(".TabsWrapper").height(maxHeight);
		}
	)

	// Loop through each link on the page that has a class of 'TabTrigger' and have them change the tab page
    $(".TabTrigger").click(
        function(e) {
            $(this).parents(".TabContainer").find(".TabStrip").tabs("select", parseInt($(this).attr("class").split(" ")[2]));
            return false;
        }
    );
    
    // If there is a variable called initialTab, use it to make a tab visible 
    // Format is "selector tabNumber", e.g. "#TabStrip 2"
    if (typeof(initialTab) != "undefined") {
        $(initialTab.split(" ")[0]).tabs("select", parseInt(initialTab.split(" ")[1]));
    }
});