﻿function changeDropDown(dropDownID, selectedValue) {

    document.getElementById("BodyContentPlaceHolder_" + dropDownID).value = selectedValue;
    setTimeout('__doPostBack(\'ctl00$BodyContentPlaceHolder$' + dropDownID + '\',\'\')', 0);
}

function loadPage() {

    highlightHeaderLink();

}

function highlightHeaderLink() {

    document.getElementById("nav1").className = "nav1";
    document.getElementById("nav2").className = "nav2";
    document.getElementById("nav3").className = "nav3";
    document.getElementById("nav4").className = "nav4";
    document.getElementById("nav5").className = "nav5";

    var pathName = window.location.pathname;
    //var pageName = pathName.substring(pathName.lastIndexOf('\\') + 1);
    var pageName = pathName.substring(pathName.lastIndexOf('/') + 1, pathName.lastIndexOf('.'));

    switch (pageName) {
        case "Index":
            document.getElementById("nav1").className += " active1";
            break;
        case "Courses":
            document.getElementById("nav2").className += " active2";
            break;
        case "Schedule":
            document.getElementById("nav3").className += " active3";
            break;
        case "Instructors":
            document.getElementById("nav4").className += " active4";
            break;
        case "Resources":
            document.getElementById("nav5").className += " active5";
            break;
        default:
            document.getElementById("nav1").className += " active1";
            break;
    }
}

function loadAdmin() {

    adminHighlightHeaderLink();

}

function adminHighlightHeaderLink() {

    document.getElementById("nav1").className = "nav1";
    document.getElementById("nav2").className = "nav2";
    document.getElementById("nav3").className = "nav3";
    document.getElementById("nav4").className = "nav4";
    document.getElementById("nav5").className = "nav5";

    var pathName = window.location.pathname;
    //var pageName = pathName.substring(pathName.lastIndexOf('\\') + 1);
    var pageName = pathName.substring(pathName.lastIndexOf('/') + 1, pathName.lastIndexOf('.'));

    switch (pageName) {
        case "EditCourses":
            document.getElementById("nav2").className += " active2";
            break;
        case "EditSchedule":
            document.getElementById("nav3").className += " active3";
            break;
        case "EditInstructors":
            document.getElementById("nav4").className += " active4";
            break;
        case "EditResources":
            document.getElementById("nav5").className += " active5";
            break;
        default:
            document.getElementById("nav1").className += " active1";
            break;
    }
}




//-----------------> Instructors.aspx <------------------

//var currentInstructorDivID;

function changeInstructor(newInstructorDivID) /* Called by the MenuMatic navigation menu */
{
    try {
        remove(currentInstructorDivID);
    }
    catch (e) {
    }
    finally {
        show(newInstructorDivID);
        currentInstructorDivID = newInstructorDivID;
    }
}

//-----------------> Courses.aspx <------------------

//var currentCourseDivID;

function changeCourse(newCourseDivID) /* Called by the MenuMatic navigation menu */
{
    try {
        remove(currentCourseDivID);
    }
    catch (e) {
    }
    finally {
        show(newCourseDivID);
        currentCourseDivID = newCourseDivID;
    }
}

//-----------------> Resources.aspx <------------------

var currentResourceDivID = 'search';

function changeResource(newResourceDivID) /* Called by the MenuMatic navigation menu */
{
    try {
        remove(currentResourceDivID);
    }
    catch (e) {
    }
    finally {
        show(newResourceDivID);
        currentResourceDivID = newResourceDivID;
    }
}

function selectDropDownItem(dropDownID, selectedValue) {
    document.getElementById(dropDownID).value = selectedValue;

    setTimeout('__doPostBack(\'' + dropDownID + '\',\'\')', 0);
}


//-----------------> Register.aspx <------------------

function AttendeesValidation(sender, args) {
    if (arguments.Value % 2 == 0) {
        arguments.IsValid = true;
    } else {
        arguments.IsValid = false;
    }
}



//----------------------------------------------------------------------------




function remove(object) {
    document.getElementById(object).style.display = "none";
}

function show(object) {
    document.getElementById(object).style.display = "inline";
}
