﻿Cufon.replace("#menu li a", { fontFamily: "ArialRoundedMTBold" });
Cufon.replace("#eyecatchertitle h2", { fontFamily: "BellGothicBold" });
Cufon.replace(".submenueyecatcher div:not(span)", { fontFamily: "BellGothicBlack" });
Cufon.replace("#submenu a", { fontFamily: "BellMT" });
Cufon.replace("#submenucontainer h3, .articletitle, .articletitle2, .articlegallerycontainer h3, .submenueyecatcher div span", { fontFamily: "BellGothicBlack" });

jQuery(function ($) {
    $.supersized({
        //Background image
        slides: [{ image: 'http://www.bikesolutions.be/images/achtergrond.jpg'}]
    });
});

$(document).ready(function () {
    var $activeMenuItem = $("#menu li.active");
    $("#menu li").hover(function () {
        if (!$(this).hasClass("active")) {
            $activeMenuItem.removeClass("active");
        }
    }, function () {
        if (!$(this).hasClass("active")) {
            $activeMenuItem.addClass("active");
        }
    });

    var $activeSubMenuItem = $("#submenu li.active");
    $("#submenu li").hover(function () {
        if (!$(this).hasClass("active")) {
            $activeSubMenuItem.removeClass("active");
            Cufon.refresh("#submenu a");
        }
    }, function () {
        if (!$(this).hasClass("active")) {
            $activeSubMenuItem.addClass("active");
            Cufon.refresh("#submenu a");
        }
    });

    $(".buttonbehavior").css({ 'cursor': 'pointer' }).click(function () {
        window.location = $("a:first", this).attr("href");
    });

    $("#eyecatchers").before("<div id=\"eyecatchersnav\"></div>").cycle({
        random: true,
        pager: '#eyecatchersnav',
        pagerAnchorBuilder: function (index, el) {
            return '<a href="#"></a>';
        },
        before: onBeforeCycleSlide
    });

    function onBeforeCycleSlide(currSlideElement, nextSlideElement) {
        var $newTitle = $(nextSlideElement).attr("rel");

        $("#eyecatchertitle").animate({ bottom: "-" + $("#eyecatchertitle").outerHeight() + "px" }, 400, function () {
            $("#eyecatchertitle h2").text($newTitle);
            Cufon.refresh("#eyecatchertitle h2");
            $("#eyecatchertitle").animate({ bottom: 0 }, 400);
        });
    }

    $(".articlegalleryinnercontainer a").fancybox({
        centerOnScroll: true,
        padding: 2,
        titlePosition: "inside",
        overlayOpacity: 0.8,
        overlayColor: "#000000"
    });

    $(".articlegallery").easyscroller();

    $(".articlegalleryNext, .articlegalleryPrev").hover(function () {
        $(".inside", this).css({ "background-position": "bottom left" });
    }, function () {
        $(".inside", this).css({ "background-position": "top left" });
    });
});

$(window).load(function () {
    $(".submenueyecatcher div").each(function () {
        $(this).css({ 'margin-top': '-' + (($(this).height() - 5) / 2) + 'px' });
    });    
});
