// JavaScript Document


$(document).ready(function(){
	$('form:not(.boxes)').jValidate(); // use default config - see below

	$('form.boxes').jValidate({  // use a custom config
			errorTag: "div"
		});
}); 



(function($) { // do not touch this line
	
	
	/* jValidate preferences */
	var jv_config = {
		errorTag: "span", // which tag do you want to use for error container. it must be one that opens and closes (div,span,p,b)
		errorClass: "jvm", // this is the css class name given to the tag above
		errorLocation: "afterEnd", // only accepts beforeBegin or afterEnd (either before or after the input element) or none
		//note: if you choose "none" for the above attribute, you must create the error yourself and give the element an ID consisting of the option below + the name of the form + the name of the field to validate.
		errorIDPrefix: "jvm", // prefix of the id of the element above that will attach to the name or id of the form element. don't use spaces or special characters. unfortunately, this is the only option that cannot be applied individually to each element
		startGone: false, //couldn't think of another name for this, but if true, it will apply "display:none", otherwise, the element is just invisible.
		useBR: "none", // accepts before, after, both or none; This will add a new line (<br />) before and/or after the above element.
		submitClass: 'jv_submit', // apply this class inside any form to let this element submit the form.
		resetClass: 'jv_reset', // apply this class inside any form to let this element reset the form.
		resetConfirm: false, // if true, it will prompt user to confirm if they click a reset button.
		highlightColor: '#FFFF99', //default color should be:  #FFFF99
		endColor: '#FFFFFF', //this is what you generally want to set to the background color behind the form elements.
		extMessage: true // if true, and you have accept attribute on file input, it tells user what extensions are accepted.
	};
	/*  note: can apply any of the custom options above by including {optionname: 'value'} in the element's class.  */
	
	
	//setup validators like: name of validator, default message, /regular expression/ !don't forget the / in front and the / in back!!!!
	var jv_custom_validators = {
		number: {
			className: "jv_number",
			defaultMessage: "This field must have a numerical value.",
			regExp: /^[-]?\d+(\.\d+)?$/
		},
		digits: {
			className: "jv_digits",
			defaultMessage: "This field can only contain numbers.",
			regExp: /^[-]?\d+(\.\d+)?$/
		},
		maxlength: {
			className: "jv_maxlength",
			defaultMessage: "This field is limited to $1 characters."
		},
		func: {
			className: "jv_function",
			func: "alertBox"
		},
		email: {
			className: "jv_email",
			defaultMessage: "This field must contain a valid email address.",
			regExp: /^([a-zA-Z0-9_\.\-])+(\+[a-zA-Z0-9]+)*\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/
		},
		uscanzip: {
			className: "jv_uscanzip",
			defaultMessage: "This field must contain a valid US or Canada zip code.",
			regExp: /^((\d{5}([- ])\d{4})|(\d{5})|([AaBbCcEeGgHhJjKkLlMmNnPpRrSsTtVvXxYy]\d[A-Za-z]\s?\d[A-Za-z]\d))$/
		},
		usstate: {
			className: "jv_usstate",
			defaultMessage: "This field must contain a valid 2 letter US state code.",
			regExp: /^(A[LKSZRAEP]|C[AOT]|D[EC]|F[LM]|G[ANU]|HI|I[ADLN]|K[SY]|LA|M[ADEHINOPST]|N[CDEHJMVY]|O[HKR]|P[ARW]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY])$/
		},
		usphone: {
			className: "jv_usphone",
			defaultMessage: "This field must contain a valid US phone number with area code.",
			regExp: /^([0-9]( |-|.)?)?(\(?[0-9]{3}\)?|[0-9]{3})( |-|.)?([0-9]{3}( |-|.)?[0-9]{4}|[a-zA-Z0-9]{7})$/
		},
		creditcard: {
			className: "jv_creditcard",
			defaultMessage: "This field must contain a valid credit card number.",
			regExp: /^((4\d{3})|(5[1-5]\d{2})|(6011))([- ])?\d{4}([- ])?\d{4}([- ])?\d{4}|3[4,7]\d{13}$/
		},
		ssn: {
			className: "jv_ssn",
			defaultMessage: "This field must contain a valid social security number.",
			regExp: /(^|\s)(00[1-9]|0[1-9]0|0[1-9][1-9]|[1-6]\d{2}|7[0-6]\d|77[0-2])(-?|[\. ])([1-9]0|0[1-9]|[1-9][1-9])\3(\d{3}[1-9]|[1-9]\d{3}|\d[1-9]\d{2}|\d{2}[1-9]\d)($|\s|[;:,!\.\?])/
		},
		alpha: {
			className: "jv_alpha",
			defaultMessage: "This field must contain only letters.",
			regExp: /^[a-zA-z\s]+$/
		},
		alphanum: {
			className: "jv_alphanum",
			defaultMessage: "This field must contain only letters or numbers.",
			regExp: /^[a-zA-Z0-9]+$/
		}
	};
	
	
	/* only change the default message, do not change the className */
	var jv_validators = {
		required: {
			className: "jv_required",
			defaultMessage: "This field is required."
		},
		notfirst: {
			className: "jv_notfirst",
			defaultMessage: "Select something other than the first item."
		},
		filetypes: {
			defaultMessage: "This field accepts the following file types:"
		},
		ajax: {
			className: "jv_ajax",
			defaultMessage: "This value should change based on ajax request result.",
			url:'jsv_ajax.php'
		}
	};
	
	
	
	
	
	
	/* do not edit anything below */
	
	
	/* begin jValidate */

	
	$.fn.jValidate = function(jvars) {
		
		var o = $.extend($.fn.jValidate.d, jvars);
		var v = $.extend($.fn.jValidate.jv_v);
		var cv = $.extend($.fn.jValidate.jvc_v);
		
		/*
		$(this).bind('submit', function(){
//			alert($(this).attr('id'));
//			alert(v.required['className']);
			alert('coming soon...');
			return false;
		});
		*/
		
	}; // end jValidate
	
	// setup defaults and validators
	$.fn.jValidate.d = jv_config;
	$.fn.jValidate.jv_v = jv_validators;
	$.fn.jValidate.jvc_v = jv_custom_validators;
	
	
})(jQuery); // do not touch this line