﻿jQuery(document).ready(function() {
		jQuery('.subtabbed .first a:first').css('text-decoration','underline');
    /* fix height and padding if necessary */
    jQuery('#tabbed_4 li.abc a span').each(function() {
        var contents = jQuery(this).text();
        if (contents.length >= 20) {
            jQuery(this).parent().parent().addClass('heightfix');
        }
    });

    jQuery('#tabbed_3 li.abc a span').each(function() {
        var contents = jQuery(this).text();
        if (contents.length >= 22) {
            jQuery(this).parent().parent().addClass('heightfix');
        }
    });

    var tab = "";
    tab = jQuery("#ctl00_ContentPlaceHolder1_Label8").text();
    switch (tab) {
        case "coop":
            DoStuff(jQuery("#tabbed_3 a:eq(0)"), false);
            break;
        case "corporate":
            DoStuff(jQuery("#tabbed_3 a:eq(1)"), false);
            break;
        case "faculty":
            DoStuff(jQuery("#tabbed_3 a:eq(2)"), false);
            break;
        default:
            if ($('#tabbed_4').length == 1)
                { DoStuff(jQuery("#tabbed_4 a:eq(0)"), false) }
            else
                { DoStuff(jQuery("#tabbed_3 a:eq(0)"), false) }            
            break;
    }
    jQuery("a.subtab").click(function() {
        jQuery(".tabby div.content:not(.subtabbottom)").hide();
        jQuery("div." + jQuery(this).attr("id")).show();
        jQuery("a.subtab").css("text-decoration", "none");
        jQuery(this).css("text-decoration", "underline");
        return false;
    });

    jQuery("#tabbed_4 a, #tabbed_3 a").click(function() {
        DoStuff(jQuery(this), true);
        return false;
    });
});

function DoStuff(Elem, bool) {
    jQuery(".tabby div.content").hide();
    jQuery("div.subtabbed").hide();
    var elem1 = jQuery("#" + Elem.attr("class"));
    elem1.show();
    if (bool) { jQuery("a.subtab").css("text-decoration", "none"); elem1.find('a.subtab:first').css("text-decoration", "underline") };
    jQuery("div." + Elem.attr("class")).show();    
    if (Elem.parent().hasClass("left"))
    { Elem.parent().addClass("leftpinned"); jQuery('.abc').removeClass("centerpinned").removeClass("rightpinned") };
    if (Elem.parent().hasClass("center"))
    { jQuery('.abc').removeClass("leftpinned").removeClass("rightpinned").removeClass("centerpinned"); Elem.parent().addClass("centerpinned"); };
    if (Elem.parent().hasClass("right"))
    { Elem.parent().addClass("rightpinned"); jQuery('.abc').removeClass("centerpinned").removeClass("leftpinned") };
}
