﻿$j(document).ready(function() {
    //CASEHOVER
    $j('#CaseGrid .CaseItem, .Hover .Image').hover(function() {
        var item = $j(this);
        //var height = item.height();
        //var imgHeight = item.find('img').height();
        item.append('<div class="Overlay"></div>');
        //$j('.OverlayContent').height(imgHeight ? imgHeight : 140);
        //item.height(height);
        var overlay = item.find('.Overlay');
        overlay.wrap('<a href="' + item.closest('.Box').find('.ReadMore').attr('href') + '" />');

        overlay.stop().fadeIn('fast', function() {
            item.find('.Teaser').stop().show();
            item.find('.ReadMore').stop().show();
        });
    }, function() {
        var item = $j(this);
        item.find('.Teaser').stop().hide()
        item.find('.ReadMore').stop().hide();
        item.find('.Overlay').stop().remove();
    });

    //CASE SET QUERYSTRING
    var url = window.location;
    $j("#CaseGrid select").change(function() {
        var value = $j(this).find('option:selected').val();
        if (url.search.length >= 0) {
            var newUrl = url.href.replace(url.href, "?type=" + value);
            window.location = newUrl;
        }
    });

    //SLIDEBOX
    var boxes = $j(".SlideBox");

    boxes.find("h3").click(function() {
        var title = $j(this);
        if (title.hasClass("Selected")) {
            title.siblings(".Intro").slideUp();
            title.removeClass("Selected");
        }
        else {
            title.siblings(".Intro").slideDown();
            title.addClass("Selected");
        }
    });
});

//FLASH VIDEOPLAYER RESIZE
function flashRequestSizeChange(height) {
    $j("#FlashContent").stop(true, true).animate({ "height": height }, "fast", "linear");
}

function introHasEnded() {
    //console.log("slut");
}
