var $dialog = null; //global dialog

function checkPost(el, postid)
{
	$.post('/itemPostage.php', { id:postid, ajax:"true" }, function(data) {
		if (data.forward) { window.location = el.href; } //redirect to postage entry
		else { //set dialog html and options
			$dialog.html(data.msg)
			.dialog( "option",{
				title: 'Postage'
			}).dialog('open'); //open dialog
		}
	}, "json");
	return false;
}

function confirmOrder(el)
{
	if ($('#paypalRadio').attr('checked'))
	{
		el.value = "Processing...";
		//set dialog html and options
		$dialog.html('<p>Please be patient while we redirect you to a secure payment page</p>'
		+'<br /><p><b>DO NOT</b> click back or refresh in your browser')
		.dialog( "option",{
			closeOnEscape: false,
			open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); },
			title: 'Please wait',
			modal: true
		}).dialog('open'); //open dialog
	}
	return true;
}

$(document).ready(function() {
	$dialog = $('<div></div>').dialog({ autoOpen: false });
});
