//Hover effekt på
$(function() {
    $("div#BoxContainer a img").hover(function() {
        $(this).attr("src", $(this).attr("src").split(".").join("_Hover."));  // adds -hover to the name of the image
    }, function() {
        $(this).stop(true, false); // prevents the creation of stacked actions
        $(this).attr("src", $(this).attr("src").split("_Hover.").join("."));  // removes -hover from the name of the image
    });
});

//Hent billeder inden de skal bruges
jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}

$(document).ready(function () {
    $(".SubBox").each(function () {
        var totalHeight = $(this).height();
        var headlineHeight = $("h3", this).outerHeight();

        var subPage = $(".SubPageContainer", this);

        var padding = subPage.outerHeight() - subPage.height();
        var targetHeight = totalHeight - headlineHeight - padding;

        if (subPage.height() > targetHeight)
            subPage.css('overflow', 'auto');
        else
            subPage.css('overflow', 'visible');

        subPage.height(targetHeight);
    });
});

$(window).bind('load', function() {
    $.preloadImages(
        '/Images/Default/Boxes/6-10Grade_Hover.jpg',
        '/Images/Default/Boxes/AdditionalSupport_Hover.jpg',
        '/Images/Default/Boxes/OutOfSchool_Hover.jpg');
});

$(function() {
    $("div.Container#Box a img").hover(function() {
        $(this).attr("src", $(this).attr("src").split(".").join("_Hover."));  // adds -hover to the name of the image
    }, function() {
        $(this).stop(true,false); // prevents the creation of stacked actions
        $(this).attr("src", $(this).attr("src").split("_Hover.").join("."));  // removes -hover from the name of the image
    });
});
