function initPopups() {

    $.fn.nyroModal.settings.regexImg = '[^\.]\.(jpg|jpeg|png|tiff|gif|bmp)\s*$|image.aspx';
    $.fn.nyroModal.settings.minWidth = 0;
    $.fn.nyroModal.settings.minHeight = 0;

}

function initContentFlash() {
    $('.contentflash').each(
        function() {
            var strId = $(this).attr('id');
            var strParams = $(this).find('a').attr('rel').split('|');

            $('#' + strId).flashembed(
            {
                src: strParams[0],
                version: [strParams[1]],
                width: strParams[2],
                height: strParams[3],
                wmode: 'transparent',
                scale: 'noscale'
            })
        }
    );
    
    $('#flash').flashembed(
    {
        src: '/lib/flash/headerflash.swf',
        version: [9, 115],    
        wmode: 'transparent',
        scale: 'noscale'
    },
    {
        xmlPath: '/lib/xml/slideshow.xml?r=' + Math.random().toString()
    })
}

function initHyperlinks() {
    $("a[rel=external]").each(function() {
        $(this).click(function() { window.open($(this).attr("href")); return false; });
        if ($(this).attr("title") == "") $(this).attr("title", "Deze link wordt in een nieuw venster geopend.")
        else $(this).attr("title", "'" + $(this).attr("title") + "' wordt in een nieuw venster geopend.");
    });
}

function initContactForm(){
    
    $('#frmContact').validate();
}

$(document).ready(function() {

    //Initialiseer hier je scripts
    initContentFlash();
    initHyperlinks();
    initPopups();
    initContactForm();
});

sfHover = function() {
    var sfEls = document.getElementById("nav").getElementsByTagName("LI");
    for (var i = 0; i < sfEls.length; i++) {
        sfEls[i].onmouseover = function() {
            this.className += " sfhover";
        }
        sfEls[i].onmouseout = function() {
            this.className = this.className.replace(new RegExp(" sfhover\\b"), "");
        }
    }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


var hoverEnd = false;

function checkMenu() {
    if (hoverEnd == true) {
        $("#nav li ul:visible").fadeOut("fast");
    };
};

$(function() {

    $("#nav li").hover(
          function() {

              $(this).find('ul:first').fadeIn('fast');

          },
          function() {
              $(this).find('ul').fadeOut('fast');


          }
        );
    $("#nav li ul").hover(
          function() {
              hoverEnd = false;
          },
          function() {
              hoverEnd = true;
          }
        );



    $("#nav li:first").addClass('top');
    $("#utils li:last").addClass('last');
    $("#nav li ul li:first").addClass('top');
    $("#nav li ul li ul li").addClass('top');

    $('#frmContact').validate();

    /* $('#flash-img').flashembed(
    {
    src: '/lib/flash/slideshow.swf',
    version: [9, 115],
    wmode: 'transparent',
    scale: 'noscale'
    },
    {
    xmlUrl: '/lib/xml/slideshow.xml?r=' + Math.random().toString()
    })
    */
    //setInterval("checkMenu()", 3000)



    jQuery.validator.addMethod("telefoon", function(telefoon, element) {
        return this.optional(element) || telefoon.match(/[0-9]{10}/);
    }, "Ongeldig nummer.");

    jQuery.validator.addMethod("postcode", function(postcode, element) {
        return this.optional(element) || postcode.match(/[1-9][0-9]{3} ?[a-zA-Z]{2}/);
    }, "Ongeldige postcode.");

});
