function OpenItem(iId)
{
	// Simply load it, AJAX-style
	var sDir = 'pages';
	if(GLOBAL_PAGE == 'woonvormen' || GLOBAL_PAGE == 'kerkdiensten' || GLOBAL_PAGE == 'publicaties')
		sDir = GLOBAL_PAGE;

	$.get('content/' + sDir + '/' + iId + '.html', null, function(sData) { PutPage(sData, iId); });
}

function PutPage(sData, iId)
{
	// Find the column
	var oCol = $("#col2_content");

	// Set it and change attr
	oCol.html(sData);
	oCol.attr('data-page-id', iId);
}

function SendForm(oForm)
{
	// Wrap it
	oForm = $(oForm);

	// Serialize
	var sPost = oForm.serialize();

	// Disable all inputs
	$("input,select,textarea").attr('disabled', 'disabled');

	// Post it
	$.post('send.php', sPost, SendFormCallback, 'json');

	// Don't run the normal submit
	return false;
}

function SendFormCallback(oData)
{
	// Check the status of the save
	if(oData.status)
	{
		// Swap in OK message
		OpenItem('sent');
	}
	else
	{
		alert('Er is een fout opgetreden met het versturen van uw email. Probeer het nogmaals.');

		// Enable all inputs
		$("input,select,textarea").removeAttr('disabled');
	}
}

