/* Declare a namespace for the site */
var Site = window.Site || {};

/* Create a closure to maintain scope of the '$'
   and remain compatible with other frameworks.  */
(function($) {
	
	/*////////////
	/ Navigation /
	////////////*/ 

	
	/*//////////////
	/ jQuery Cycle /
	//////////////*/ 

	$(function() {
		$('#slideshow')
		.after('<div id="slide-nav">')
		.cycle({
			fx:'scrollLeft',
			speed:  600,
			timeout: 6000,
			pause: 1,
			pager:  '#slide-nav'
		});		

	});

	

	/*///////////////
	/ Hover effects /
	///////////////*/
	
	// $(function() {
	// 	$('.button').hover(function() {
	// 		$(this).stop().animate({backgroundColor: '#dde5f5', 'text-shadow': '0 1px 0 #ffffff'}, 200);
	// 	},
	// 	function() {
	// 		$(this).stop().animate({backgroundColor: '#b4c3d3', 'text-shadow': '0 1px 0 #dde5f5'}, 200);
	// 	});
	// });
	// $(function() {
	// 	$('header nav a:not(header nav li.active a)').hover(function() {
	// 		$(this).stop().animate({backgroundColor: '#053344'}, 200);
	// 	},
	// 	function() {
	// 		$(this).stop().animate({backgroundColor: '#08171E'}, 200);
	// 	});
	// });


	$(window).bind("load", function() {
		
	});
	
})(jQuery);

/*
$(document).ready(function() {
	//
	//
	//Navigation Fly Out
	//
	//
	$("header > nav > ul > li").hover(
		function()
		{
			$(this).parent().children("li").children("ul").clearQueue().slideUp(0);
			$(this).children("ul").css('z-index','1000').delay(50).slideDown(200);
		},
		function()
		{
			$(this).children("ul").css('z-index','10').slideUp(100);
		});
});
*/



$(function() {
	$('.border-box.photo a span').slideUp(0);
	$('.border-box.photo a').hover(
		function()
		{
			$(this).children('span').slideDown(200);
		},
		function() {
			$(this).children('span').slideUp(200);
	});		
});

// $(function() {
// 	$('html').removeClass('no-js');
// });

function format_price(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) 
	{ 
		i = 0.00; 
	}
	var minus = '';
	if(i < 0) 
	{ 
		minus = '-'; 
	}
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) 
	{ 
		s += '.00'; 
	}
	if(s.indexOf('.') == (s.length - 2)) 
	{ 
		s += '0'; 
	}
	s = minus + s;

	x = s.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? ',' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + '.' + '$2');
	}
	return x1 + x2;

	
}

function calculate_totals()
{
	$("#totals").html('');
	flt_losse_toegang_o = 325.0;
	flt_vip_tafel_o 		= 2995.0;
	flt_losse_toegang = flt_losse_toegang_o;
	flt_vip_tafel 		= flt_vip_tafel_o;
	if ($("#kortingscode").val().toUpperCase() == 'SPK11')
	{
		flt_losse_toegang = 292.5;
		flt_vip_tafel 		= 2695.5;
	}
	int_losse_toegang = $("#losse_toegang").val();
	int_vip_tafel 		= $("#vip_tafel").val();
	if (int_losse_toegang != '0' || int_vip_tafel != '0')
	{
		flt_ticket_price_o = flt_losse_toegang_o * int_losse_toegang + flt_vip_tafel_o * int_vip_tafel;
		flt_ticket_price = flt_losse_toegang * int_losse_toegang + flt_vip_tafel * int_vip_tafel;
		flt_korting = flt_ticket_price_o - flt_ticket_price;
		str_output = '<table>';
		if (int_losse_toegang)
		{
			str_output = str_output + '<tr><td width="160px">' + int_losse_toegang + ' kaarten @ ' + format_price(flt_losse_toegang_o) + '</td><td align="right">' + format_price(flt_losse_toegang_o * int_losse_toegang) + '</td></tr>';
			$("#losse_toegang_prijs").val(format_price(flt_losse_toegang * int_losse_toegang));
		}
		else
		{
			$("#losse_toegang_prijs").val("0");
		}
		
		if (int_vip_tafel != '0')
		{
			str_output = str_output + '<tr><td width="160px">' + int_vip_tafel + ' kaarten @ ' + format_price(flt_vip_tafel_o) + '</td><td align="right">' + format_price(flt_vip_tafel_o * int_vip_tafel) + '</td></tr>';
			$("#vip_tafel_prijs").val(format_price(flt_vip_tafel * int_vip_tafel));
		}
		else
		{
			$("#vip_tafel_prijs").val("0");
		}
		if (flt_korting != '0')
		{
			str_output = str_output + '<tr><td width="160px">Subtotaal:</td><td align="right">' + format_price(flt_ticket_price_o) + '</td></tr>';
			str_output = str_output + '<tr><td width="160px">Korting:</td><td align="right">' + format_price(flt_korting) + '</td></tr>';
			str_output = str_output + '<tr><td width="160px">Totaal:</td><td align="right">' + format_price(flt_ticket_price) + '</td></tr>';
		}
		else
		{
			str_output = str_output + '<tr><td width="160px">Totaal:</td><td align="right">' + format_price(flt_ticket_price) + '</td></tr>';
		}
		str_output = str_output + '</table>';
		$("#totals").html(str_output);
	}
}

$(document).ready(function() {
	$("#kortingscode").blur(function(){
		calculate_totals();
	});
	$("#losse_toegang").change(function(){
		calculate_totals();
	});
	$("#vip_tafel").change(function(){
		calculate_totals();
	});
});


