$(document).ready(function()
{
	$('#loginform').ajaxForm({
		dataType: 'json',
		beforeSubmit: function(){
			$('#disable').show();
			$('#ajaxloader').show();
			$('#disable').click(function(){
				closeError();
			});
		},

		success: function(json){
			if(json.type == 'success'){
				$('#disable').hide();
				$('#ajaxloader').hide();
				
				window.location.href.href = json.pagina;
				
			} else {
				displayError(json.message.title, json.message.text);
			}
		}

	});
	$(document).pngFix(); 
	/*
	 * als je tablesorter wilt gebruiken
	 * uncomment dit hieronder
	 *
	 * en voeg deze div toe onder de table
	 * <div id="pager">
	<form action="">
		<img src="{IMAGES_PATH}first.png" style="float:left;" class="first" alt="" />
		<img src="{IMAGES_PATH}prev.png" style="float:left;" class="prev" alt="" />
		<input type="text" style="float:left; margin-left:8px;" disabled="disabled" size="10" class="pagedisplay" alt="" />
		<img src="{IMAGES_PATH}next.png" style="float:left;" class="next" alt="" />
		<img src="{IMAGES_PATH}last.png" style="float:left;" class="last" alt="" />

		<select style="float:left; margin-left:8px;" class="pagesize">
			<option selected="selected"  value="10">10</option>
			<option value="20">20</option>
			<option value="30">30</option>
			<option  value="40">40</option>
		</select>
	</form>
</div>
	 */

	/*
	$("table")
		.tablesorter({widthFixed: true, widgets: ['zebra']})
		.tablesorterPager({container: $("#pager")});
	*/
});

function displayError(title, text){
	$('#disable').show();
	$('#error_title').html(title);
	$('#error_tekst').html(text);
	$('#ajaxloader').hide();
	$('#errordiv').show();
}

function closeError(){
	$('#disable').hide();
	$('#errordiv').hide();
}

function loadUrl(url){
	window.location.href.href = url;
}

function filterload(url){
	var woonplaats = $("#woonplaats").val();
	var product = $("#product").val();
	if(product == 'alles' && woonplaats == 'alles'){
		url += '.html';
	} else if(product == 'alles' && woonplaats != 'alles') {
		url += '/' + woonplaats + '.html';
	} else if(product != 'alles' && woonplaats == 'alles') {
		url += '/' + product + '.html';
	} else {
		url += '/' + product + '/' + woonplaats + '.html';
	}
	window.location.href = url
}