/*
 * Group of java script methods userd to create the
 *
 */

/**
 * Cancelling the Proccessing of the order.
 */
function purchaseCheckIn()
{
	if(window.confirm('Are you sure to cancel processing this order?'))
	{
		document.formCheckin.submit();
	}
	return false;
}

function replaceCancelOrder()
{
	setTimeout(function()
	{
		purchaseCancel();
	},
	300	
	);	
}

/**
 * 
 */
function processCancelPurchase()
{
	// if(window.confirm('Are you sure to cancel this order?'))
	// {
	
		var options = {
				beforeSubmit:function()
				{
					$('#jqmForm').jqmHide();
					$('#ajaxIndicator').jqmShow();
					
					alert('before');
					
				}, 
				type:'POST',
				url:configInfo.site_url + 'ajax/process_cancel_order.php',
				dataType:  'json', 
				error:function()
				{
					// $('#ajaxIndicator').jqmHide();					
					// showError('There has been an unexpected error while processing the request.');
					alert('There has been an unexpected error while processing the request.');
					//replaceCancelOrder();				
				},
				success:function(json)
				{
					
					 if(json.error != '')
					 {
						 $('#ajaxIndicator').jqmHide();
						 showError(json.error);	
						 replaceCancelOrder();
					 }else
					 {
						document.location.href = json.url;
					 }
					
					
				}
		};
	
		$('#fromCancelOrder').ajaxSubmit(options);			
		
	// }else
	// {
		// return false;
	// }
	
}

/**
 *
 */
function purchaseCancel()
{
	$('#jqmForm').jqmShow();
}
