﻿$(function() {
    $("#home-feature .side-menu ul a").click(function() {
        var targetContent = $(this).attr("class");
        var currentVisible =  $("#home-feature .side-menu li.current a").attr("class");
        if($(this).parent().hasClass("current")) {        
        }
        else {
            $("#home-feature .content #"+currentVisible).slideUp("slow", function() {
                $("#home-feature #"+targetContent).slideDown("slow"); 
            });
            $("#home-feature .side-menu li").removeClass("current");  
            $(this).parent().addClass("current");
        }
        return false;  
    });
    
    // Quick Links
    $("ul.quick-links a").click(function() {
        var linkDestination = $(this).attr("href");
        $('html, body').animate({
            scrollTop: $(linkDestination).offset().top
        }, 1000);
        return false;
    });
    
    // Learning Centre hotspot links
    $(".learning-centre-diagram a").click(function() {
        var linkDestination = $(this).attr("href");
        $('html, body').animate({
            scrollTop: $(linkDestination).offset().top
        }, 1000);
        $("ol.learning-centre-list li").removeClass("current");
        $("ol.learning-centre-list li#" + linkDestination).addClass("current");
        return false;
    });
    
    $(".client-logos").scrollable({ size: 1, items: ".logo", speed: 400 });
    
    var sidebarHeight = $("#sidebar").height();
    var contentHeight = $("#content").height();
    if(sidebarHeight > contentHeight) {
        var newHeight = sidebarHeight - 3;
        $("#content .content-inner").css({ height: newHeight });
    }
});

(function ($) {
    $.fn.vAlign = function() {
	    return this.each(function(i){
	    var ah = $(this).height();
	    var ph = $(this).parent().height();
	    var mh = (ph - ah) / 2;
	    $(this).css('margin-top', mh);
	    });
    };
})(jQuery);
