// JavaScript Document

function bestelCheck () {
	$("#errorMessage").hide();
	formname = arguments[0];
	var successdiv = arguments[1];

	returnValue = vArgChecker(arguments,{'border':'1px solid #090'},{'border':'1px solid #C00'},{'behoud_nummer1' : 'telefoonnummer 1','behoud_nummer2' : 'telefoonnummer 2','geboortedatum1':'geboortedag','geboortedatum2': 'geboortemaand','geboortedatum3': 'geboortejaar'});
	
	var status = returnValue.status;
	var message = returnValue.message;


	if ($("#"+formname).attr("xmlpost") && status)
	{
		$("#"+formname+" .submit").hide();
	
		$("#checkingDiv").show();
		// submit
		status = true;
	
		setTimeout(function() {
		var error_text;
			
		$.ajax({
			type: $("#"+formname).attr("method"),
			url: $("#"+formname).attr("xmlpost"),
			data : $("#"+formname).serialize(),
			dataType: "xml",
			success: function(xml) {
				$("#checkingDiv").hide();
				step = $(xml).find('step').text();	
				newid = $(xml).find('id').text();				
				$("#"+formname).fadeOut("fast",function(){
				$("#sendinfosuccessDiv").fadeIn("fast");	   
			});
			},
			error: function(data) {
					$("#checkingDiv").hide();
					$("#"+formname+" .submit").show();
		
					alerter("Er is iets foutgegaan ("+data.status+")","alerter_error");
			}
		}); //close $.ajax
							},1000);
	}else {
			$("#checkingDiv").hide();
			$("#"+formname+" .submit").show();
			alerter(message);
	};
	
	return false;
}



function alerter(txt) {
	
	vBox({html : txt});
}


function setHistory(t) {
	document.loc = t;
	document.location = "#"+t;
}


function historyCheck(){
	if 	($.vBox) return;

	var h = document.location.hash.replace("#","");

	if (document.loc != h) {
		if (h == "" || !Number(h)) {
			h=1;
		}else {
			if (typeof(subPage) == 'function') subPage(h);
		}
	}
}
