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 initContactForm(){

	$('#frmContact').validate();
	$('#frmOfferte').validate();

	jQuery.extend(jQuery.validator.messages, {
		required: "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: "geen geldig e-mailadres",
		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."
	});
   }

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 initMenu() {

	$("ul.sf-menu").superfish({
		animation: { opacity: 'show', height: 'show' }, // slide-down effect without fade-in 
		delay: 0.1 // 1.2 second delay on mouseout
	});

	$("ul.sf-menu").supersubs({
		minWidth: 12,   // minimum width of sub-menus in em units 
		maxWidth: 40,   // 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 
	}).superfish();  // call supersubs first, then superfish, so that subs are 
	// not display:none when measuring. Call before initialising 
	// containing tabs for same reason.
}

function runEffect() {

	//get effect type from 
	var selectedEffect = $('#effectTypes').val();

	//most effect types need no options passed by default
	var options = {};
	//check if it's scale, transfer, or size - they need options explicitly set
	if (selectedEffect == 'scale') { options = { percent: 0 }; }
	else if (selectedEffect == 'size') { options = { to: { width: 200, height: 60} }; }

	//run the effect
	$("#effect").toggle(selectedEffect, options, 500);

	setTimeout(function() { $('.togglercontent').show('fast'); }, 1000);
};

var clicked = false;

function initHotelSlide() {

	$("#button").click(function() {
		if (clicked) {
			$(this).text('meer hotels');
			$(this).removeClass('buttonclose');
		} else {
			$(this).text('verberg hotels');
			$(this).addClass('buttonclose');
		}
		clicked = !clicked;
		runEffect();
		return false;
	});	
	
}

$(document).ready(function() {

	initContentFlash();
	initPopups();
	initContactForm();
	initHyperlinks();
	//initMenu();
	initHotelSlide();

});


       
