/*
	forces Constraint Validation API

	helpers for the HTML5 constraint validation API

*/

if ( jQuery !== "undefined" ) {
(function( $ ){
	"use strict";

	// where one radio button is required, ensure all are required
	// this ensures each one in the group reports the same .validity.valueMissing properties
	(function() {
		var names = {};

		$( ":radio[required]" ).each(function() {

			if ( names[ this.name ] !== true ) {
				$( ":radio[name=" + this.name + "]" ).attr( "required", "required" );
				names[ this.name ] = true;
			}

		});
	}());


	// INPUT validity API not implemented in browser
	if ( typeof $( "<input>" )[0].validity !== "object" ) {

		// http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#valid-e-mail-address
		// 1*( atext / "." ) "@" ldh-str 1*( "." ldh-str )
		var REXP_EMAIL = /^[A-Za-z0-9!#$%&'*+\-\/=\?\^_`\{\|\}~\.]+@[A-Za-z0-9\-]+\.[A-Za-z0-9\-]+$/,

			invalidCount = 0,

			validityState = function( typeMismatch, valueMissing ) {
				var valid = ! typeMismatch && ! valueMissing;
				if ( valid === false ) {
					invalidCount = invalidCount + 1;
				}
				return {
					typeMismatch: typeMismatch,
					valueMissing: valueMissing,
					valid: valid
				};
			}
		;


		// check for blank required fields on submit
		$( "form" ).live( "submit", function() {

			var form = $( this );

			// check required fields
			form.find( ":text, select, textarea" ).each(function() {

				var $this = $( this ),

					isBlank = $this.attr( "required" ) && ! this.value,

					invalidEmail = this.getAttribute( "type" ) === "email" && !! this.value && ! REXP_EMAIL.test( this.value )
				;

				this.validity = validityState( invalidEmail, isBlank );

				if ( !this.validity.valid ) {
					// invalid event
					$this.trigger( $.Event( "invalid" ));
				}

			});

			// check required radio button groups
			(function() {
				
				var names = {};

				form.find( ":radio[required]" ).each(function() {

					if ( names[ this.name ] !== true ) {
						
						var group = form.find( ":radio[name=" + this.name + "]" ),
							isBlank = group.filter( ":checked" ).length === 0;

						group.each(function() {
							this.validity = validityState( false, isBlank );
						});

						names[ this.name ] = true;
					}
				});

			}());

			// suppress submit if invalid fields exist
			if ( invalidCount > 0 ) {
				
				event.stopImmediatePropagation();
				event.preventDefault();
				return false;
			}

		});

	}


}( jQuery ));
}

@@ -1375,32 +1375,39 @@
 bmit%22, function(
+ event 
 ) %7B%0D%0A%0D%0A%09%09%09var fo

include event parameter in submit event