// JavaScript Document
function bannerClick(id)
{
	$.post("/ajax_bannerclick.php", {'id':id});
}

function checkContactForm(form)
{
	var itemArray = new Array();
	itemArray.push("initials");
	itemArray.push("lastname");
	itemArray.push("company");

	checkRedForm(form, itemArray);
}

/**
 *  Formvalidator
 *  Checks if items given in itemArray are filled with a value.
 *  An extra check is given on the email and zipcode.
 *  If it is not completely filled, put a message in the item with id ingevuld.
 */
function checkRedForm(form, itemArray)
{
	var y=0;
	var somethingRed=false;

	for (y=0;y<itemArray.length;y++)
	{
		var arrayId = $('#'+itemArray[y]);
		var labelId =  $('#'+itemArray[y]+'label');
		if ( arrayId.val() == "")
		{
			labelId.css("color","#FF0000");
			somethingRed=true;
		}
		else
		{
			labelId.css("color","black");
		}
	}

	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(form.email.value))
	{
	}
	else
	{
		$('#emaillabel').css("color","#FF0000");
		somethingRed=true;
	}

	var textContent = document.getElementById('fout')
	if (somethingRed==true)
	{
		textContent.style.paddingBottom = "1em";
		textContent.innerHTML = "De velden in het rood zijn niet (correct) ingevuld."
		return;
	}
	else
	{
		$(".contactSubmit").find("a").remove()
		$(".contactSubmit").append('Bezig...');
		
		document.Request.submit();
		textContent.innerHTML = "";
	}
}

/* table sorter */
$(function() {
	$(".mailingsTable").tablesorter();
	$(".eventsTable").tablesorter();
});
