function changePerPage(url,path) {
	
	var per_page	= $j('#pagenavPerpage :selected').val();
	
	if(per_page == 5){
		
		var url_redirect = url;
	}
	if(per_page > 5){
		
		var url_redirect = url+path+'_1-'+per_page+'.htm';
	}	
	
	window.location = url_redirect;
}

function validatePhoneNumber(value){
	jQuery(function($j){
	   $j("#"+value+"").mask("999-999 9999");
	});
}

function validateKvkNumber(value){
	jQuery(function($j){
	   $j("#"+value+"").mask("99 99 99 99");
	});
}

function validateEmail(id){
	
	var value = $j('#'+id+'').val();

	 if(isValidEmailAddress(value)){
	 	
		$j('#'+id+'').removeClass('inputfield_error');
		return true;
	 }else{
	 	
		alert("Let op!\n\nEr is geen geldig e-mail adres ingevuld!");
		$j('#'+id+'').addClass('inputfield_error');
		
		return false;
	 }  
	
}

function isValidEmailAddress(emailAddress) {
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
	
	return pattern.test(emailAddress);
}

function trim(value) {
  value = value.replace(/^\s+/,'');
  value = value.replace(/\s+$/,'');
  value = value.replace(/^\s+|\s+$/g,'');
  return value;
}

function checkNumber(textBox) {
	
	var textBox = document.getElementById(""+textBox+"");

	while (textBox.value.length > 0 && isNaN(textBox.value)) {
		
		textBox.value = textBox.value.substring(0, textBox.value.length - 1);
	}

	textBox.value = trim(textBox.value);

/*	if (textBox.value.length == 0) {
		textBox.value = 0;		

	} else {
		textBox.value = parseInt(textBox.value);
	}*/

	return textBox.value;
}

function checkNumberJquery(textBoxName) {
	
	var textBox = $j('input[name="'+textBoxName+'"]').val();

	while (textBox.length > 0 && isNaN(textBox)) {
		
		textBox = textBox.substring(0, textBox.length - 1);
		
	}
	
	textBox = trim(textBox);
	
	$j('input[name="'+textBoxName+'"]').val(textBox);
	
	//$j($j('input[name="'+textBox+'"]')).autotab({ target: 'textBox', format: 'numeric' });
}
