﻿String.prototype.trim = function () { return this.replace(/^\s+|\s+$/, ''); };

var boolScrollbarAdded = false;

$(document).ready(function () {

    $("ul.sf-menu").supersubs({
        minWidth: 12,   // minimum width of sub-menus in em units 
        maxWidth: 27,   // maximum width of sub-menus in em units 
        extraWidth: 1     // extra width can ensure lines don't sometimes turn over 
        // due to slight rounding differences and font-family 
    });

    $("ul.sf-menu").superfish({
        hoverClass: 'sfHover',          // the class applied to hovered list items 
        pathClass: 'ActiveMenuPath',       // the class you have applied to list items that lead to the current page 
        pathLevels: 1,                  // the number of levels of submenus that remain open or are restored using pathClass 
        delay: 700,                // the delay in milliseconds that the mouse can remain outside a submenu without it closing 
        animation: { opacity: 'show' },   // an object equivalent to first parameter of jQuery’s .animate() method 
        speed: 'fast',           // speed of the animation. Equivalent to second parameter of jQuery’s .animate() method 
        autoArrows: true,               // if true, arrow mark-up generated automatically = cleaner source code at expense of initialisation performance 
        dropShadows: true,               // completely disable drop shadows by setting this to false 
        disableHI: false              // set to true to disable hoverIntent detection 
        // onInit:        function(){},       // callback function fires once Superfish is initialised – 'this' is the containing ul 
        // onBeforeShow:  function(){},       // callback function fires just before reveal animation begins – 'this' is the ul about to open 
        // onShow:        function(){},       // callback function fires once reveal animation completed – 'this' is the opened ul 
        // onHide:        function(){}        // callback function fires after a sub-menu has closed – 'this' is the ul that just closed 
    });


    windowResize();
    function windowResize() {
        if ($(window).height() < 620) {
            $('#knoppenomvat').css("bottom", "4px");
            $('.TabPageContainer').css("bottom", "123px");
        } else {
            $('#knoppenomvat').css("bottom", "40px");
            $('.TabPageContainer').css("bottom", "159px");
        }
    }

    $(window).bind('resize', function () {
        windowResize();
    });


});

function CloseTabs() {

    $(".TabPageContainer").animate({ height: 0 }, 800,
        function () {
            //height weer op auto zetten
            $(".TabPageContainer").css("height", "auto").hide();
        }
    );
} //CloseTabs


lasttabname = "";
function showTab(tabname) {
    $(".TabPage").hide();


    if (lasttabname != tabname) {
        $("#" + tabname).show();
        lasttabname = tabname;
    } else {
        lasttabname = "";
    }

}

function showPlaatje(value) {
    $('#kaartjpg').attr('src', '/images/kaartje/' + value);
}


/*function startShowXXX() {
//alert('fg');
//var slideArray = [{ image: '/data/fotos/alg/id7/ft7.jpg', title: '', url: '' }, { image: '/data/fotos/alg/id5/ft5.jpg', title: '', url: '' }, { image: '/data/fotos/alg/id4/ft4.jpg', title: '', url: '' }, { image: '/data/fotos/alg/id6/ft6.jpg', title: '', url: ''}];
//alert(slideArray[0][0]);

$(function () {
$.fn.supersized.options = {
startwidth: 1280,
startheight: 850,
vertical_center: 1,
slideshow: 1,
navigation: 1,
thumbnail_navigation: 0,
transition: 0, //0-None, 1-Fade, 2-slide top, 3-slide right, 4-slide bottom, 5-slide left
pause_hover: 0,
slide_counter: 0,
slide_captions: 0,
slide_interval: 4000,
slides: slideArray

};

$('#supersized').supersized();

});


}*/



//de aanroep naar deze functie wordt 1 keer per bezoek per dag gedaan o.b.v. cookie
function ShowSplashScreen() {


    if (FlashDetect.versionAtLeast(9)) {

        // $("#splash").dialog({ width: 980, height: 450, closeText: '', modal: false, dialogClass: 'SplashScreen' });
        $("#nieuwsCont").hide();

        $("#middenStrook").hide();
        $("#strookonder").hide();
        $("#labelactueel").hide();
        $("#labelProjekt").hide();
        $("#derdestrook").hide();

        //fadeout na aantal seconden
        setTimeout(function () {

            HideSplashScreen();
        }, 14000);   /**/

    } else {

        $("#splash").hide();

    }

} //ShowSplashScreen


function hideViaFlash(theMessage) {
    //alert(theMessage);
    HideSplashScreen();
}

//verberg overlay en splash screen
function HideSplashScreen() {


    //erin gezet tbv probleem flash animatie:
    //window.location.href = '/home.aspx?id=4';
    var lightWindow = $("#splash");


    /** chrome doet iets vreemds in de fadeout **/
    chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
    if (chrome) {
        tijd = 0;
    } else {
        tijd = 0;
    }

    lightWindow.fadeOut(tijd, function () {
        // lightWindow.dialog("close"); 

        $("#nieuwsCont").show();
        $("#middenStrook").show();
        $("#strookonder").show();
        $("#labelactueel").show();
        $("#labelProjekt").show();
        $("#derdestrook").show();

        leftpos = $("#content").offset().left - 25;

        $("#labelactueel").css("margin-left", leftpos);
        $("#labelactueel").css("top", $("#content").offset().top);
        $("#labelProjekt").css("top", $("#middenStrook").offset().top + 22);
        $("#labelProjekt").css("margin-left", leftpos - 1);

        /** twitter strook **/
        $('.twitterpnl').cycle({
            cleartype: 1,
            speed: 700,
            timeout: 7000,
            pause: 1,
            fx: 'scrollLeft'
        });

        /** scrollbar **/

        if ($(".jspContainer").length == 0) { /** alleen als de scrollbar er nog niet is (HideSplashScreen wordt nl 2x aangeroepen) ) **/
            $(function () { $('.newslijn').jScrollPane(); });
        }



    });



}

/** functies voor project overzicht pagina */
function ProjectCellMouseOver(element) {
    //bepaal hover divje binnen het element
    var hoverElement = $(".ProjectIntroHover", element);
    hoverElement.stop().show().css("opacity",100); //("slow",
}
function ProjectCellMouseOut(element) {
    //bepaal hover divje binnen het element
    var hoverElement = $(".ProjectIntroHover", element);
    hoverElement.stop().fadeOut(500)
}

/*  eind functies voor project overzicht pagina */


/* functies voor slideshow-link element */

//Open lightwindow met slideshow obv client id van de hyperlink
function StartSlideshow(clientId, textClose) {

    //bepaal buitenste div als referentiekader voor de rest. 
    //dit is bewust een globale var, omdat deze gedeeld wordt met de functie "onAfter"
    outer = $(".LightWindowOuter" + clientId.toString()).stop();
    //toon het geheel in een modal lightwindow
    $(".LightWindowInner", outer).show();

    //toon navigatie controls in het geval van meer dan 2 foto's
    var nslideshowimg = $(".SlideShow > img", outer).size();
    if (nslideshowimg > 1) {
        $(".SlideShow", outer).cycle({
            fx: 'fade',
            timeout: 8000,
            speed: 750,
            prev: '.linkPrev',
            next: '.linkNext',
            after: SlideShowAfterChange,
            pause: 1
        });

        $('.navControls', outer).show();
    }
    else {
        $('.navControls', outer).hide();
    }

    $('.pause', outer).hide();

    outer.hover(
        function () {
            $(".linkNext", outer).stop().css("opacity", "1").fadeIn('slow');
            $(".linkPrev", outer).stop().css("opacity", "1").fadeIn('slow');
        },
        function () {
            $(".linkNext", outer).stop().fadeOut('slow');
            $(".linkPrev", outer).stop().fadeOut('slow');
        }
    );


    outer.dialog({ autoOpen: false,
        modal: true,
        closeText: textClose,
        width: 980,
        height: 540,
        dialogClass: 'SlideDialogLink',
        close: function () {
            //stop de slideshow
            $(".SlideShow", outer).cycle('stop');
        }
    }).dialog('open');

}
//functie voor afhandeling van het zichtbare foto nummer
function SlideShowAfterChange(curr, next, opts) {
    var caption = (opts.currSlide + 1) + ' van ' + opts.slideCount;
    $('.pager', outer).html(caption);
}

/* eind slideshow link element functies */
