$(document).ready(function() {
	var cssErrorClass = "error";
	var formats = {
		numeric:            /^\d+$/,
	    alphabetic:         /^[a-z]+$/i,
	    alphabetic_lower:   /^[a-z]+$/,
	    alphabetic_upper:   /^[A-Z]+$/,
	    alphanumeric:       /^[a-zA-Z\d]+$/,
	    not_empty:          /.+/,
	    standard:           /^\w+$/i,           // matches all a-z, A-Z, 0-9 and _

	    phone:              /^\+?(?:\d\d[\/\s]?)+$/,
	    email:              /^[a-z\d]+(?:[\-\.\_][a-z\d]+)*[a-z\d]+@[\w\d]+(?:[-\.][a-z\d][a-z\d\-]*[a-z\d])*[a-z\d]+\.([a-z]{2,4})$/i,

	    username:           /^[-\w_]+$/,
	    password:           /^[-\w_\$\!&%]+$/,

//	    date_short_pre:     /^(?:0?[1-9]|[12][0-9]|3[01])([-\/\.])(?:0?[1-9]|1[0-2])\1\d\d$/,
		date_short_pre:     /^((0)[1-9]|(1)[0-2])\/((0)[1-9]|(1)[0-9]|(2)[0-9]|(3)[0-1])\/([0-9]{2})$/,
	    date_short_suf:     /^\d\d([-\/\.])(?:0?[1-9]|1[0-2])\2(?:0?[1-9]|[12][0-9]|3[01])$/,

	    date_long_pre:      /^(?:0?[1-9]|1[0-2])([-\/\.])(?:0?[1-9]|[12][0-9]|3[01])\1(19|20)\d\d$/,
	    date_long_suf:      /^(19|20)\d\d([-\/\.])(?:0?[1-9]|1[0-2])\2(?:0?[1-9]|[12][0-9]|3[01])$/
	}
	
	var errMsgs = {
		numeric:            "Have to be a number",
	    alphabetic:         "Have to be alphabetic",
	    alphabetic_lower:   "Have to be on lower case.",
	    alphabetic_upper:   "Have to be in upper case.",
	    alphanumeric:       "Have to be a number",
	    not_empty:          "Can't be empty",
	    standard:           "Can't be empty",           // matches all a-z, A-Z, 0-9 and _

	    phone:              "There isn't a number format.",
	    email:              "There isn't a email format.",

	    username:           "There are invalid characters.",
	    password:           "There are invalid characters.",

//	    date_short_pre:     /^(?:0?[1-9]|[12][0-9]|3[01])([-\/\.])(?:0?[1-9]|1[0-2])\1\d\d$/,
//	    date_short_suf:     /^\d\d([-\/\.])(?:0?[1-9]|1[0-2])\2(?:0?[1-9]|[12][0-9]|3[01])$/,

//	    date_long_pre:      /^(?:0?[1-9]|[12][0-9]|3[01])([-\/\.])(?:0?[1-9]|1[0-2])\1(19|20)\d\d$/,
	    date_long_suf:      "There isn't a valid date."
	}
	
	showErrMsg = function(obj,msg){
		obj.addClass(cssErrorClass);
	}
	
	hideErrMsg = function(obj){
		obj.removeClass(cssErrorClass);
	}
	
	checkItem = function(objId,format){
		obj = $("#" + objId);
//		alert (obj.value);
//		if (msg == null){
		var msg = errMsgs[format];
//		}
		if (obj.attr("value").match( formats[format] ) == null){
			obj.addClass(cssErrorClass);
			return false;
		}else{
			obj.removeClass(cssErrorClass);
			return true;
		}
	}
	
//	sumValidator = function(){
		
//	}
});