var pathExpressInstallFile = escape("/lib/flash/expressInstall.swf");

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],
                expressInstall: pathExpressInstallFile,
                wmode: 'transparent',
                scale: 'noscale'
            })
        }
    );
}

function initSiteCatMenu() {

    $('#lstSiteCategories').change(
        function() {
            window.location = '/' + taal + '/' + $('#lstSiteCategories').val() + '/default.aspx';
        }
    );
}


function initNavigation2() {

    /*
    $(".toggle_container").each(
        function(intIndex) {
            if(intIndex != openmenuIndex-1)
                $(this).css({ display: 'block' });
        }
    );

    if (openmenuIndex < 0)
        openmenuIndex = false
    
    jQuery('#accordion').accordion({
        autoheight: false,
        header: '.trigger',
        selectedClass: 'active',
        active: openmenuIndex
    });
    */
}

function initFaq() {

    $(".faq_container").hide();

    $(".faq").toggle(function() {
        $(this).addClass("active_faq");
    }, function() {
        $(this).removeClass("active_faq");
    });

    $(".faq").click(function() {
    	$(this).next(".faq_container").slideToggle("slow,");
    	return false;
    });
}

function initPortalFlash() {

    $('#portalflash').flashembed(
    {
        src: '/lib/flash/portal.swf',
        version: [9],
        wmode: 'opaque',
        width: 950,
        height: 450
    },
    {	//dit zijn flashvars
        xmlPath: escape('/lib/xml/portal.ashx?taal=' + taal),
        lang: taal
    });
}

function initHeaderFlash() {

    $('.foto_header').flashembed(
    {
        src: '/lib/flash/header.swf',
        version: [9],
        wmode: 'opaque',
        width: 650,
        height: 114
    },
    {	//dit zijn flashvars
        xmlPath: escape('/lib/xml/headerimages.ashx?taal=' + taal + '&id=' + structuurid)
    });
}

function initForm() {
    $('.validateform').validate();
    jQuery.extend(jQuery.validator.messages, {
        required: "Dit veld is verplicht.",
        maxlength: jQuery.format("U kunt niet meer dan {0} karakters invoeren."),
        minlength: jQuery.format("U dient minimaal {0} karakters in te voeren."),
        rangelength: jQuery.format("U dient minimaal {0} en maximaal {1} karakters in te voeren."),
        email: "Een geldig emailadres is verplicht.",
        url: "Een geldig URL is verplicht.",
        date: "Een geldige datum is verplicht.",
        number: "Een geldig getal is verplicht.",
        digits: "Gebruik alleen cijfers.",
        equalTo: "Herhaal de invoer nogmaals.",
        range: jQuery.format("U dient een waarde tussen {0} en {1} in te voeren."),
        max: jQuery.format("U dient een waarde kleiner dan of gelijk aan {0} in te voeren."),
        min: jQuery.format("U dient een waarde groter dan of gelijk aan {0} in te voeren."),
        creditcard: "Een geldig creditcardnummer is verplicht."
    });
}


//global variable with slide status
var blnSlideUp = false;

function initPortalSlide() {

	$('#slide_btn a').click(function() {

		var intSpeed = 1200;
		var intClosedHeight = '0px';
		var intOpenHeight = '400px';
		var intCurrentHeight = $('#slideclip').height() + 'px'; ;

		if (blnSlideUp) {
			$('#slideclip').animate(
                { height: intClosedHeight },
                { duration: intSpeed, easing: 'easeOutQuint' }
            );
			blnSlideUp = false;
		} else {
			$('#slideclip').animate(
                { height: intOpenHeight },
                { duration: intSpeed, easing: 'easeOutQuint' }
            );
			blnSlideUp = true;
		}
		return false;
	});
}

function initFaqSiteCatMenu() {

    $('#btnShowFaq').click(
        function() {
            window.location = $('#lstFaqSiteCategories').val();
            return false;
           }
    );
}


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.");
    });
}

$(document).ready(function() {
    //Initialiseer hier je scripts
    initContentFlash();
    initPopups();
    initSiteCatMenu();
    initPortalFlash();
    initNavigation2();
    initFaq();
    initForm();
    initPortalSlide();
    initFaqSiteCatMenu();
    initHeaderFlash();
    initHyperlinks();

    if ($('body[class*=googlemaps]').length > 0) initGoogleMaps();
}
);

sfHover = function() {
	var sfEl = document.getElementById("nav");
	if (!sfEl == 'undefined') {
		var sfEls = sfEl.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);




