/**
 * This function save the checkout information into an order
 * Afterwards is determined if and which payment connector should be called
 */
function saveCheckout(orderstatus){

	$.ajax({
		url: "functions/checkout_functions.php",
		dataType: "json",
   		data: { status: orderstatus },
   		cache: false,
		success: function(json){

			//alert(json)
			/*
				json.type: if a payment connectof is called do we need to show a page or a dialog (connector specific)
				json.url: the path to the dialog or page
				json.call: an optional javascript file which will is executed after the page/dialog is shown
				(f.e. to submit a form in a dialog)
			*/

			if(orderstatus != 'release'){
				// the order has the 'ordered status or
				window.location.href = "/site.php?formid=checkout_payment_form";
			} else {
				if(json.type=="dialog"){
					json.dialogurl = json.url;
					json.id = json.module;
					generateDialog(json);
				} else if(json.type=="page"){
					window.location.href = "/site.php?module="+json.module+"&pageid="+json.pageid;
				}
			
			}
				
		},
		error: function(){
			updateDialog("A Problem Ocured.");
		},
		timeout: function(){
			updateDialog("Time Out");
		}
	
	
	});
	
	/*
	//Add errors to the javascript console for debugging
	$(document).ajaxError(function(){
	    if (window.console && window.console.error) {
	        console.error(arguments);
	    }
	});
	*/
	
}
