String.prototype.checkFor=function(ctr){
	var pattern;
	switch(ctr){
		case 'email':
			pattern = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
			return pattern.test(this);
		
		case 'time':
			pattern = /^[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}$/;
			return pattern.test(this);
		
		case 'num':
			pattern = /^[0-9]+$/;
			return pattern.test(this);

		case 'float':
			pattern = /^\d+((\.\d+)|(\d*))$/;		
			return pattern.test(this);

		case 'ip':
			pattern = /^((([0-1]?[0-9]{1,2})|(2([0-4][0-9]|5[0-5])))\.(([0-1]?[0-9]{1,2})|(2([0-4][0-9]|5[0-5])))\.(([0-1]?[0-9]{1,2})|(2([0-4][0-9]|5[0-5])))\.(([0-1]?[0-9]{1,2})|(2([0-4][0-9]|5[0-5])))|([0-9]{1,10}))$/;
			return pattern.test(this);
		
		case 'date':
			pattern = /^((([0-9]{0,3}[1-9]|[0-9]{0,2}[1-9][0-9]|[0-9]?[1-9][0-9]{2}|[1-9][0-9]{3})[-\/](((0?[13578]|1[02]))[-\/](0?[1-9]|[12][0-9]|3[01])|((0?[469]|11)[-\/](0?[1-9]|[12][0-9]|30))|(0?2)[-\/](0?[1-9]|[1][0-9]|2[0-8])))|((([0-9]{0,2})(0[48]|[2468][048]|[13579][26])|((0?[48]|[2468][048]|[3579][26])00))[-\/]0?2[-\/]29))$/;
			return pattern.test(this);

		case 'postcode':
			pattern = /^[0-9]{3}\-[0-9]{4}/;
			return pattern.test(this);

		default: 
			return false;
	}	
}

String.prototype.trim = function(){
	return this.replace(/(^\s*)|(\s*$)/g, '');
}

String.prototype.empty = function(){
	if(this.trim() == '') return true; else return false;
}

String.prototype.strlen = function(){
	var len = 0;
	for (var i = 0; i < this.length; i++) {
		if (this.charCodeAt(i) > 255) len += 2; else len ++;
	}
	return len;
}