/**
 *  formHelper.js
 *  Helper behaviour for WDR's various forms
 *  Requires prototype.js 1.5.0
 */



//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Check document is loaded
Event.observe(window, 'load', function() {

	// Find the forms that all this applies to
	var theForm = $A($(	'subscribeForm',
						'freeTrialForm',
						'DKpurchaseForm',
						'askForm',
						'userProfileForm'
	)).detect(function(node) {
		return node != undefined;
	} );
	
	if (theForm != null) {
	
		// Focus first element
		theForm.focusFirstElement();
	
		// Add reset button and attach behaviour
		new Insertion.After('submitButton', ' <input type="submit" class="inputSubmit" id="clearForm" name="clearForm" value="Reset">');
		$('clearForm').observe('click', function(e) {
			Event.stop(e)		// Don't actually submit the form
			theForm.reset();
		} );
	}
} );
