function init_site(text)
{
	var so = new SWFObject("/swf/title.swf", "titleMovie", "450", "32", "6", "#FFFFFF");
	so.addParam("wmode", "transparent");
	so.addVariable("titleText",text);
	so.write("flashTitle");

	//alert(screen.availWidth);
	if (screen.availWidth < 1000)
	{
		document.getElementById('floatingAddress').style.marginLeft = '420px';

	}
	
	$('input[name=dag]').keyup(function () {
		if ($(this).val().length == 2)
		{
			setTimeout("$('input[name=maand]').focus();", 200);
			
		}
	});
	
	$('input[name=maand]').keyup(function () {
		if ($(this).val().length == 2)
		{
			setTimeout("$('input[name=jaar]').focus();", 200);
		}
	});
}

function aanmnb_changeBranche(selectedIndex)
{
	$('#aanmnb_hotel').hide();
	$('#aanmnb_hotel input').val('');
	$('#aanmnb_hotelrestaurant').hide();
	$('#aanmnb_hotelrestaurant input').val('');
	$('#aanmnb_restaurant').hide();
	$('#aanmnb_restaurant input').val('');
	$('#aanmnb_vakantiepark').hide();
	$('#aanmnb_vakantiepark input').val('');
	$('#aanmnb_anders').hide();
	$('#aanmnb_anders input').val('');

	document.getElementById('aantal_bedden').value = "";
	document.getElementById('aantal_couverts').value = "";

	switch (selectedIndex)
	{
		case 1:
		// Hotel
		$('#aanmnb_hotel').show();
		break;

		case 2:
		// Hotel restaurant
		$('#aanmnb_hotelrestaurant').show();
		break;

		case 3:
		// Restaurant
		$('#aanmnb_restaurant').show();
		break;

		case 4:
		// Vakantiepark
		$('#aanmnb_vakantiepark').show();
		break;

		case 8:
		// Vakantiepark
		$('#aanmnb_anders').show();
		break;
	}
}

function wijzigTekst(id,inhoud) 
{
	document.getElementById(id).innerHTML = inhoud; 
}

function updateBestelForm(_this,maximum)
{
	input_name = $(_this).attr('name');
	input_name = input_name.split('_');

	kind = input_name[2];

	ma_tvg_input = 'ma_tvg_' + kind;
	ma_balie_input = 'ma_balie_' + kind;
	vr_tvg_input = 'vr_tvg_' + kind;
	vr_balie_input = 'vr_balie_' + kind;
	value_voorraad_input = 'tot_voorraad_' + kind;

	ma_tvg = new Number($(':input[name="' + ma_tvg_input + '"]').val());
	ma_balie = new Number($(':input[name="' + ma_balie_input + '"]').val());
	vr_tvg = new Number($(':input[name="' + vr_tvg_input + '"]').val());
	vr_balie = new Number($(':input[name="' + vr_balie_input + '"]').val());
	value_voorraad = new Number($(':input[name="' + value_voorraad_input + '"]').val());

	vr_sub_input = 'vr_sub_' + kind;
	if (((isNaN(vr_tvg) == false) || (vr_tvg == '')) && ((isNaN(vr_balie) == false) || (vr_balie == '')))
	{
		if (vr_tvg < 0)
		{
			vr_tvg = Math.abs(vr_tvg);
			$(':input[name="' + vr_tvg_input + '"]').val(vr_tvg);
		}
		if (vr_balie < 0)
		{
			vr_balie = Math.abs(vr_balie);
			$(':input[name="' + vr_balie_input + '"]').val(vr_balie);
		}

		vr_sub = vr_tvg + vr_balie;
		
		// bij totalen geen check voor maxima, dit wordt gedaan bij invoeren van de aantallen
		if (input_name[0] != 'tot')
		{
 		if (vr_sub > maximum) 
 		{
 			wijzigTekst('vr_error','De ingaven van de aantallen bij <b>te verwachten gasten</b> of <b>Balieverkoop</b> is hoger dan maximaal toegestaan');
 			vr_sub = maximum;
 		} else {
 			wijzigTekst('vr_error','');
 		}
		 $(':input[name="' + vr_sub_input + '"]').val(vr_sub);
		} else
		 vr_sub = $(':input[name="' + vr_sub_input + '"]').val();
		
	} else
	$(':input[name="' + vr_sub_input + '"]').val('');

	ma_sub_input = 'ma_sub_' + kind;
	if (((isNaN(ma_tvg) == false) || (ma_tvg == '')) && ((isNaN(ma_balie) == false) || (ma_balie == '')))
	{
		if (ma_tvg < 0)
		{
			ma_tvg = Math.abs(ma_tvg);
			$(':input[name="' + ma_tvg_input + '"]').val(ma_tvg);
		}
		if (ma_balie < 0)
		{
			ma_balie = Math.abs(ma_balie);
			$(':input[name="' + ma_balie_input + '"]').val(ma_balie);
		}

		ma_sub = ma_tvg + ma_balie;
		
		// bij totalen geen check voor maxima, dit wordt gedaan bij invoeren van de aantallen
		if (input_name[0] != 'tot')
		{
		if (ma_sub > maximum) 
 		{
 			wijzigTekst('ma_error','De ingaven van de aantallen bij <b>te verwachten gasten</b> of <b>Balieverkoop</b> is hoger dan maximaal toegestaan');
 			ma_sub = maximum;
 		} else {
 			wijzigTekst('ma_error','');
 		}
		 $(':input[name="' + vr_sub_input + '"]').val(vr_sub); 		
		} else
		 ma_sub = $(':input[name="' + ma_sub_input + '"]').val();
		
		$(':input[name="' + ma_sub_input + '"]').val(ma_sub);
	} else
	$(':input[name="' + ma_sub_input + '"]').val('');

	tot_input = 'tot_bestelling_' + kind;
	if ((isNaN(vr_sub) == false) && (isNaN(ma_sub) == false) && (isNaN(value_voorraad) == false))
	{
		totaal = (Number(vr_sub) + Number(ma_sub)) - value_voorraad;
		if (totaal < 0)
		totaal = 0;
		$(':input[name="' + tot_input + '"]').val(totaal);
	} else {
		$(':input[name="' + tot_input + '"]').val('');
	}
}

function completeBestelformulier(form)
{
	emptyFieldCounter = new Number(0);
	$('fieldset[verplicht="verplicht"] input').each(function(obj){
		if (($(this).val() == ''))
		{
			emptyFieldCounter++;
			$(this).css('borderColor', 'red');
		} else
		$(this).css('borderColor', 'black');
	});

	$('input[verplicht="verplicht"]').each(function(obj){
		if (($(this).val() == ''))
		{
			emptyFieldCounter++;
			$(this).css('borderColor', 'red');
		} else
		$(this).css('borderColor', 'black');
	});

	if (emptyFieldCounter > 0)
	alert('U heeft nog ' + emptyFieldCounter + ' lege velden. Vul alle verplichte velden in. De velden die nog ingevuld dienen te worden zijn met rood gemarkeerd.')
	else
	form.submit();
}


/**
 * Wasbonmodule
 */

 function noLetters(evt)
 {
  var charCode = (evt.which) ? evt.which : evt.keyCode
  //alert(charCode);
  if (charCode > 31 && (charCode < 48 || charCode > 57) && (charCode < 96 || charCode > 105))
   return false;
  
  return true;

 }
 	
