// JavaScript Document

jQuery.fn.equalCols = function() {
        //Array Sorter
        var sortNumber = function(a, b) { return b - a; };
        var heights = [];
        //Push each height into an array
        $(this).each(function() {
          heights.push($(this).height());
        });
        heights.sort(sortNumber);
        var maxHeight = heights[0];
        return this.each(function() {
          //Set each column to the max height
          $(this).css({ 'height': maxHeight });
        });
      };


      $(function() {

        // Main Menu Slidedown/Slideup effects and add/remove a classes to main menu item.  

        $("#mainMenu li ul").hide();
        $("#mainMenu > li").bind({ mouseenter: function() {
          $(this).children("a").addClass("activeAnchor");
          $("span", this).addClass("activeSpan");
          $("ul", this).slideDown("normal");
        },
          mouseleave: function() {
            $(this).children("a").removeClass("activeAnchor");
            $("span", this).removeClass("activeSpan");
            $("ul", this).slideUp("fast");
          }
        });

        // calculates and sets equal height of #divLeftContent and #divRightContent.
        jQuery(function($) {
          //Select the columns that need to be equal e.g
          $('div.column').equalCols();
          $('#divContentLeft,#divContentRight').equalCols();
        });

        // right aligns last item in main menu
        $("#mainMenu > li:last ul").css("right", "0");
        $("#mainMenu > li:last ul li:first").css("background-position", "left -39px");

        $("#mainMenu > li:first").css("background", "none");

        // removes background images of last anchor element from all dropdown menu items
        $("#mainMenu li").find("ul li:last a").css("background", "none");
        
        // adds a class to the first li in the dropdown menu item to display round corner at top right
        $("#mainMenu li").find("ul li:first").addClass("subMenuTop");

        // removes dotted border of last item in #ulCoursesSchedule and #ulMainCourses
        $("#ulCoursesSchedule li:last, #ulMainCourses a:last").css("border-bottom", "none");
      });           
        
     
     // Display Date //
      function getmessage() {
        var sdate
        var sday
        var smonth
        var syear
        var shour
        var sdayofweek
        var amonths = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
        var adays = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
        var sdaywelcome

        sdate = new Date()
        sday = sdate.getDate()
        sdayofweek = sdate.getDay()
        smonth = sdate.getMonth()
        syear = sdate.getFullYear()
        shour = sdate.getHours()
        sdaywelcome = adays[sdayofweek] + " " + sday + ", " + amonths[smonth] + " " + syear
        document.write(sdaywelcome)
      }
   
