$(document).ready(function()
{
	$("a[rel='lightbox']").colorbox({});
	
	$("#aantal").change(function()
	{
		changeBedrag();
	});
	$("#aantalDiner").change(function()
	{
		changeBedrag();
	});
	changeBedrag();
	$(".companyName").click(function()
	{
		$(this).next('div').slideToggle();
	});
	
	$(".workshopName").click(function()
	{
		$(this).next('div').slideToggle();
	});
	
	$(".openCloseAll").click(function()
	{
		$html = $(this).html();
		if ($html == 'Alles openen')
		{ 
			$('.companyContent').slideDown();
			$('.workshopContent').slideDown();
			$(".openCloseAll").html('Alles sluiten');
		}
		else
		{
			$('.companyContent').slideUp();
			$('.workshopContent').slideUp();
			$(".openCloseAll").html('Alles openen');
		}
		
		return false;
	});
	
	
	$('.morning td:not(.empty):not(.volgeboekt), .afternoon td:not(.empty):not(.volgeboekt), .evening td:not(.empty):not(.volgeboekt)').mouseover(function()
	{
		$(this).toggleClass('mouseOver');
		$id = $(this).attr('id');
		
		$.get("loadWorkshopText.php?id=" + $id, function(html) {
			$('#omschrijvingWorkshop').html(html);
		});
		
	});
	
	$('.morning td:not(.empty):not(.volgeboekt), .afternoon td:not(.empty):not(.volgeboekt), .evening td:not(.empty):not(.volgeboekt)').mouseout(function()
	{
		$(this).toggleClass('mouseOver');
	});
	
	$('.morning td:not(.empty):not(.volgeboekt), .afternoon td:not(.empty):not(.volgeboekt), .evening td:not(.empty):not(.volgeboekt)').click(function()
	{
		$timeZone = $(this).parents('tr:first').attr('class');
		if ($(this).hasClass("tweeUur"))
		{
			$('.' + $timeZone).children('td').removeClass('selected');
			$('.' + $timeZone).children('td').children('input').attr('value', '0');
		}
		else if ($(this).hasClass("eenUur"))
		{
			$(this).parents('tr:first').children('td.eenUur').removeClass('selected');
			$('.' + $timeZone).children('td.tweeUur').removeClass('selected');
			
			$(this).parents('tr:first').children('td.eenUur').children('input').attr('value', '0');
			$('.' + $timeZone).children('td.tweeUur').children('input').attr('value', '0');
		}
		$(this).children('input').attr('value', '1');
		$(this).addClass('selected');
	});
		
});

function validateProgramma()
{
	return confirm("http://www.BrightWhiteDay.nl\nUw dagprogramma keuze wordt definitief gemaakt.\nWijzigen van uw dagprogramma is hier niet meer mogelijk.");
}

function changeBedrag()
{
	$valueKaart = $("#aantal").attr('value');
	$valueDiner = $("#aantalDiner").attr('value');
	$bedragKaart = $("#bedragKaart").attr('value');
	$bedragDiner = $("#bedragDiner").attr('value');
	var $bedrag = (($valueKaart * $bedragKaart) + ($valueDiner * $bedragDiner)).toFixed(2);
	$("#bedrag").html($bedrag);
}

function openWindow(url, wname, width, height) {  
	window.open(url, wname, "height=" + height + ",width=" + width + "location = 0, status = 1, resizable = 0, scrollbars=1, toolbar = 0");  
	return true;
}
