$(document).ready(function () {


    //FOTOVERGROTING OP ZOEKRESULTATENPAGINA
    if ($('.zoekthumb')) {
        $('.zoekthumb').each(function () {
                vSrc = $(this).attr('src').replace('MyThumbnail', '__Source');
                $(this).wrap('<a rel="group2" href="' + vSrc + '" />');
        });
        $('.zoekthumb').parent().fancybox({ 'width': 'auto', 'height': 'auto', 'autoDimensions': true, 'transitionIn': 'fade', 'transitionOut': 'fade', 'speedIn': 500, 'speedOut': 500, 'overlayShow': true, 'hideOnContentClick': true, 'overlayOpacity': 0.65, 'overlayColor': '#000000', 'showNavArrows': false, 'titleShow': false });
    }
    if ($('.zoekthumb2')) {
        $('.zoekthumb2').each(function () {
                vSrc = $(this).attr('src');
                $(this).wrap('<a rel="group2" href="' + vSrc + '" />');
        });
        $('.zoekthumb2').parent().fancybox({ 'width': '500', '500': 'false', 'autoDimensions': false, 'transitionIn': 'fade', 'transitionOut': 'fade', 'speedIn': 500, 'speedOut': 500, 'overlayShow': true, 'hideOnContentClick': true, 'overlayOpacity': 0.65, 'overlayColor': '#000000', 'showNavArrows': false, 'titleShow': false });
    }


    function loadfancybox(target, lightbfx, lightdur, lightit) { // options > http://fancybox.net/api
        target.fancybox({
            'transitionIn': lightbfx,
            'transitionOut': lightbfx,
            'speedIn': lightdur,
            'speedOut': lightdur,
            'overlayShow': true,
            'hideOnContentClick': true,
            'overlayOpacity': 0.85,
            'overlayColor': '#000000',
            'showNavArrows': false,
            'titleShow': lightit
        });
    }


    if ($('#display_rules').length > 0) {
        var marleft = 0;
        $(window).load(function () {
            var wrapwidth = 600;
            var imgswidth = $('#display_imgs #wrap').width() + 100;
            //console.log($('#display_imgs #wrap').width());
            //console.log($('#display_imgs #wrap').actual('outerWidth'));
            var movemargin = imgswidth - wrapwidth;
            $('#display_imgs').css('width', '610px');
            $('#display_main').css('height', '610px');
            $('#display_imgs #wrap').css({ 'width': '600px', 'overflow': 'hidden' });
            var mover = $('#imgswrap');
            $('#display_imgs #wrap').show();
            if (movemargin > 0) {
                $('#a_right').click(function () {
                    if (movemargin < wrapwidth) {
                        mover.animate({ 'margin-left': marleft - movemargin });
                        marleft = marleft - movemargin;
                    } else {
                        mover.animate({ 'margin-left': marleft - (wrapwidth - 100) });
                        marleft = marleft - (wrapwidth - 100);
                    }
                    checkarrows(marleft);
                    return false;
                });
                $('#a_left').click(function () {
                    if (movemargin < wrapwidth) {
                        mover.animate({ 'margin-left': marleft + movemargin });
                        marleft = marleft + movemargin;
                    } else {
                        mover.animate({ 'margin-left': marleft + (wrapwidth - 100) });
                        marleft = marleft + (wrapwidth - 100);
                    }
                    checkarrows(marleft);
                    return false;
                });
            }
            function checkarrows(marleft) {
                //alert(marleft);
                if (marleft >= 0) { $('#a_left').fadeOut() } else { $('#a_left').fadeIn() }
                if (marleft <= -imgswidth + 100 + wrapwidth) { $('#a_right').fadeOut() } else { $('#a_right').fadeIn() }
            }

            $('#imgswrap a').click(function () {
                //			if($('#display_main img').attr('new') != $(this).attr('href')){
                //			$('#display_main img').attr('new',$(this).attr('href'));
                //			$('#display_main img').fadeOut(function(){
                //					$(this).attr('src',$(this).attr('new'))
                //				});
                //			$('#display_main img').load(function(){
                //				$(this).fadeIn();
                //				});
                //			}
                $('#display_main img').attr('src', $(this).attr('href'));
                return false
            });
            checkarrows(marleft);
        });
    }

});

$(document).ready(function () { $("a").bind("focus", function () { if (this.blur) this.blur(); }); });

$.fn.extend({ actual: function (a, j) { var b, c, g, f, e, i, d, h; if (!this[a]) { throw '$.actual => The jQuery method "' + a + '" you called is not exist'; } g = $.extend({ absolute: false, clone: false }, j); c = this; d = g.clone === true ? function () { c = c.filter(":first").clone().css({ position: "absolute", top: -1000 }).appendTo("body"); } : function () { b = c.parents().andSelf().filter(":hidden"); f = g.absolute === true ? { position: "absolute", visibility: "hidden", display: "block"} : { visibility: "hidden", display: "block" }; e = []; b.each(function () { var l = {}, k; for (k in f) { l[k] = this.style[k]; this.style[k] = f[k]; } e.push(l); }); }; h = g.clone === true ? function () { c.remove(); } : function () { b.each(function (l) { var m = e[l], k; for (k in f) { this.style[k] = m[k]; } }); }; d(); i = c[a](); h(); return i; } });
