function attachFormHandlersAjax() { 	
	if($('brochure-form')) {
		//$('brochure-form').onsubmit = function(e){
		$('brochure-form').observe('submit', function(event) {
			//alert(Event.element(e));
			Event.stop(event);
			var error = !checkForm(this);
			if(!error){
				var url = '/ltourism/sweepstakes/enter-sweeps.jsp';
				var pars = Form.serialize('brochure-form');
				var frmAjax = new Ajax.Request(url, {
					method: 'post',
					parameters: pars,
					onLoading: function() {
						$('load').style.display = 'block';
						$('submitButton').style.display = 'none';
						$('error').style.display = 'none';
					},
					onSuccess: function(transport) { // the ajax succeeded						
						$('load').style.display = 'none';						
						$('submitButton').style.display = 'block';						
						var ret = (transport.responseText).strip();						
						if(ret.startsWith('success')){ //there was success							
							$('sweepswrap').style.display = 'none';							
							$('thanks').style.display = 'block';							
							var content = ret.sub('success', ' ');
							if(!(content.strip()).empty()){
								$('thanks').insert({top:content});
								delayRedirect($$('#thanks a')[0].href);
							}
						}else{ //the form failed
							$('error').update(ret);
							$('error').style.display = 'block';
							
						}
					},
					onFailure: function(){
						$('load').style.display = 'none';
						$('error').update('There was a DB error.  Please try again later.');
						$('error').style.display = 'block';
					}
				});
			}
		});
	}
}


function delayRedirect(url){
	window.setTimeout(function(){
		redirect(url)
	}, 10000);
}

function redirect(url){
	window.location = url;
}
