﻿$(document).ready(function () {
    $('#scrollcontent').jScrollPane({
        showArrows:true,
        animateStep: '90'
    });
       
    $(".close").click(function () {
        $("#truecontent").stop().fadeOut(100);
        $("#contentmenu ul li .active").removeClass("active");
        Cufon.refresh();
    });
    
    var taalisopen = true
    $('#taal').click(function() {
    	if(taalisopen == true) {
            $('#taalselector').fadeIn('fast');
            taalisopen = false;            
            }
            else{ 
            $('#taalselector').fadeOut('fast');
            taalisopen = true;
        }
    }); 

    $("#contentmenu ul li a").click(function () {
        $("#contentmenu ul li .active").removeClass("active");

        var $targetLink = $(this);
        targetData = $targetLink.addClass("active").attr("href").split("&");

        rubriekID = targetData[0].split("=");
        artikelID = targetData[1].split("=");
        taal = targetData[2].split("=");
        foto = targetData[3].split("=");

        $('#truecontent').stop().fadeOut(100, function () {
            $.get("req_article.asp", { artikelid: artikelID[1], taal: taal[1], rubriekID: rubriekID[1] }, function (data) {
                $('#truecontent').html(data).stop().fadeIn(100);

                if (foto[1].length > 1 && $("#supersized img:first").attr("src") != 'uploads/achtergronden/' + foto[1]) {
                    $targetheight = $("#supersized img:first").height();
                    $targetwidth = $("#supersized img:first").width();
                    $targetoffset = $("#supersized img:first").offset();

                    $("#supersized").prepend('<img src="uploads/achtergronden/' + foto[1] + '" alt="" style="height: ' + $targetheight + 'px; width: ' + $targetwidth + 'px; left: ' + $targetoffset.left + 'px; top: ' + $targetoffset.top + 'px;" />');
                    $("#supersized img:nth-child(2)").stop().fadeTo("slow", 0, function () {
                        $(this).remove();
                    });
                }

                /*code om per rubriekID nieuwe achtergrondfoto te krijgen*/

                $(".close").click(function () {
                    $("#truecontent").stop().fadeOut(100);
                    $("#contentmenu ul li .active").removeClass("active");
                    Cufon.refresh();
                });

                Cufon.refresh();                
			    $('#scrollcontent').jScrollPane({
                    showArrows:true,
                    animateStep: '90'
                });				     
                $targetLink.removeClass("jHover");
            });
        });

        return false;
    });

    $("#contentmenu ul li a").hover(function () {
        if (!$(this).hasClass("active")) {
            $(this).addClass("jHover");
        }
    }, function () {
        $(this).removeClass("jHover");
    });

    $('#photos').cycle({
        fx: 'fade',
        speed: '200',
        continuous: 0,
        prev: '#prev',
        next: '#next',
        timeout: 0
    });
    
    $('#gallery').cycle({
        fx: 'fade',
        speed: '200',
        continuous: 0,
        prev: '#prev2',
        next: '#next2',
        timeout: 0
    });

    $('#photos ul li img').fadeTo('fast', 1);

    $('#photos ul li img').hover(function () {
        $(this).fadeTo('fast', 0.8);
    }, function () {
        $(this).fadeTo('fast', 1);
    });

    $("a.photos, .fancypic").fancybox({
        'hideOnContentClick': false,
        'zoomSpeedIn': 0,
        'zoomSpeedOut': 0,
        'overlayShow': true,
        'overlayColor': '#000',
        'overlayOpacity': 0.8,
        'padding': 0
    });
});  

