﻿
$(document).ready(function() {
    //Attach the global navigation items (Departments/eTools)
    GlobalNavInit();

    AddWebPartClasses()

    //Rotate Alerts If Present
    RotateAlerts();

    if ($('#IsInEditMode').length == 0) {
        WebPartTabsInit('.TabZone1', true);
        WebPartTabsInit('.TabZone2', true);
        WebPartTabsInit('.TabZone3', true);
        WebPartTabsInit('.TabZone10', true);
    }

    wrapItems('.DocumentsContainer', 'class', 'LibraryDocuments');

    //Start Featured News SlideShow
    FeaturedNewsInit();

    RecentDocAnimationsInit();

    LimitThemes();
});

function AddWebPartClasses() {
    //Add Class To WebPart Zone   
    AddWebPartClass('.WPAlert', 'WPAlertSpace');
    AddWebPartClass('.LeftLink1', 'LeftLink1Space');
    AddWebPartClass('.MiddleLink2', 'MiddleLink2Space');
    AddWebPartClass('.RightLink3', 'RightLink3Space');

    AddWebPartClass('.WPZone1', 'WPZone1Space');
    AddWebPartClass('.WPZone2', 'WPZone2Space');
    AddWebPartClass('.WPZone3', 'WPZone3Space');
    AddWebPartClass('.WPZone4', 'WPZone4Space');
    AddWebPartClass('.WPZone5', 'WPZone5Space');
    AddWebPartClass('.WPZone6', 'WPZone6Space');
    AddWebPartClass('.WPZone7', 'WPZone7Space');
    AddWebPartClass('.WPZone8', 'WPZone8Space');
    AddWebPartClass('.WPZone9', 'WPZone9Space');
}

function LimitThemes() {
    if (document.title == "Site Theme") {
        var srcList = $("select[title*='Select a Theme']");
        if (srcList.length > 0) {
            srcList.css('display', 'none');
            var cpylist = srcList.clone();
            srcList.parent().append(cpylist);

            cpylist.children("option[value$='thbelltown.gif']:not(:selected)").remove();
            cpylist.children("option[value$='thbreezetwo.gif']:not(:selected)").remove();
            cpylist.children("option[value$='thcardinal.gif']:not(:selected)").remove();
            cpylist.children("option[value$='thcitrus.gif']:not(:selected)").remove();
            cpylist.children("option[value$='thclassic.gif']:not(:selected)").remove();
            cpylist.children("option[value$='thnone.gif']:not(:selected)").remove();
            cpylist.children("option[value$='thgranite.gif']:not(:selected)").remove();
            cpylist.children("option[value$='thjet.gif']:not(:selected)").remove();
            cpylist.children("option[value$='thlacquer.gif']:not(:selected)").remove();
            cpylist.children("option[value$='thlichen.gif']:not(:selected)").remove();
            cpylist.children("option[value$='thobsidian.gif']:not(:selected)").remove();
            cpylist.children("option[value$='thpetal.gif']:not(:selected)").remove();
            cpylist.children("option[value$='thplastic.gif']:not(:selected)").remove();
            cpylist.children("option[value$='threflector.gif']:not(:selected)").remove();
            cpylist.children("option[value$='thsimple.gif']:not(:selected)").remove();
            cpylist.children("option[value$='thverdant.gif']:not(:selected)").remove();
            cpylist.children("option[value$='thvintage.gif']:not(:selected)").remove();
            cpylist.children("option[value$='thwheat.gif']:not(:selected)").remove();
            cpylist.css('display', 'block').attr('id', 'ThemeSelect2').attr('name', 'ThemeSelect2');

            cpylist.change(function() {
                var selected = $(this).children(':selected');
                if(selected.length > 0)
                    srcList.children("option[value='" + selected.attr('value') + "']:contains('" + selected.html() + "')").attr("selected", true);
            });
        }
    }
}
 
