function regSubmit(){
	var surveyAction=$('#quick-reg-form').attr('action');
	//put all hidden fields into a string
	var surveyHiddenFields='';
	$.each($('#quick-reg-form input[type="hidden"]'),function(){
		surveyHiddenFields+='&'+$(this).attr('name')+'='+$(this).val();
	});
	//check which step the user is currently on
	var current=$('#quick-reg-current').val();
	//step 1 fields
	var firstName=$('#cons_first_name').val();
	var lastName=$('#cons_last_name').val();
	var email=$('#cons_email').val();
	//escape plus signs in email address
	//this allows for emails like devnull+test@convio.com to be used without the form throwing an error
	email=email.replace('+','%2B');
	
	
	
	//denySubmit is used to insure the form is submitted by a human
	//if it has any value, the submission is ignored
	var denySubmit=$('#denySubmit').val();
	if(current=='1'){
		//step 1
		hideAllErrors();
		if(firstName==''){
			firstNameError();
			$('#cons_first_name').focus();
			if(lastName=='') {
				lastNameError();
			}
			if(email.indexOf('@')==-1||email.indexOf('.')==-1)
				emailError();
		}
		else if(lastName==''){
			lastNameError();
			$('#cons_last_name').focus();
			if(email.indexOf('@')==-1||email.indexOf('.')==-1)
				emailError();
		}
		else if(email.indexOf('@')==-1||email.indexOf('.')==-1){
			emailError();
			$('#cons_email').focus();
		}
		else{
			//no errors, post the form
			var surveyFrameURL=surveyAction+
			'?printer_friendly=1'+
			surveyHiddenFields+
			'&cons_first_name='+firstName+
			'&cons_last_name='+lastName+
			'&cons_email='+email+
			'&ACTION_SUBMIT_SURVEY_RESPONSE=Submit';
			if(denySubmit!='')
				//denySubmit is not null
				surveyFrameURL+='&denySubmit='+$('#denySubmit').val();
			$('#quick-reg-success').html('<iframe src="'+surveyFrameURL+'" scrolling="no" frameborder="0" height="1" width="1"></iframe>');
			$('#quick-reg-logged-in').hide();
			$('#quick-reg-step1').hide();
			$('#quick-reg-step2').show();
			$('#quick-reg-step2').animate({opacity:1},500);
			$('#quick-reg-current').val('2');
		}
	}
	else if(current=='2'){
		var surveyInterestCheckboxes='';
		
		$.each($('#quick-reg-step2 input'),function(){
			if($(this).attr('checked'))
				surveyInterestCheckboxes+='&'+$(this).attr('name')+'='+$(this).val();
		});
		var surveyFrameURL=surveyAction+
		'?printer_friendly=1'+
		surveyHiddenFields+
		'&cons_first_name='+firstName+
		'&cons_last_name='+lastName+
		'&cons_email='+email+
		surveyInterestCheckboxes+
		'&ACTION_SUBMIT_SURVEY_RESPONSE=Submit';
		if(denySubmit!='')
			//denySubmit is not null
			surveyFrameURL+='&denySubmit='+$('#denySubmit').val();
		$('#quick-reg-success').append('<iframe src="'+surveyFrameURL+'" scrolling="no" frameborder="0" height="1" width="1"></iframe>');
		$('#quick-reg-step2').hide();
		$('#quick-reg-step3').show();
		$('#quick-reg-step3').animate({opacity:1},500);
		$('#quick-reg-current').val('3');
	}
	else if(current=='3'){
		//step 3
		var street1=$('#cons_street1').val();
		var city=$('#cons_city').val();
		var state=$('#cons_state').val();
		var zip=$('#cons_zip_code').val();
		
		hideAllErrors();
		
			//no errors, post the form
			var surveyFrameURL=surveyAction+
			'?printer_friendly=1'+
			surveyHiddenFields+
			'&cons_first_name='+firstName+
			'&cons_last_name='+lastName+
			'&cons_email='+email+
			'&cons_street1='+street1+
			'&cons_city='+city+
			'&cons_state='+state+
			'&cons_zip_code='+zip+
			'&ACTION_SUBMIT_SURVEY_RESPONSE=Submit';
			if(denySubmit!='')
				//denySubmit is not null
				surveyFrameURL+='&denySubmit='+$('#denySubmit').val();
			$('#quick-reg-success').html('<iframe src="'+surveyFrameURL+'" scrolling="no" frameborder="0" height="1" width="1"></iframe>');
		
		//document.write('surveyFrameURL is '+ surveyFrameURL);
		$('#quick-reg-step3').hide();
		$('#ACTION_SUBMIT_SURVEY_RESPONSE').hide();
		$('#quick-reg-thank-you').show();
		$('#quick-reg-thank-you').animate({opacity:1},500);
		}
	return false;
}
function firstNameError(){
	$('#error-msg-firstName').html('* Required.');
	$('#error-msg-firstName').show();
	$('#cons_first_name').addClass('quick-reg-error-field');
}
function lastNameError(){
	$('#error-msg-lastName').html('* Required');
	$('#error-msg-lastName').show();
	$('#cons_last_name').addClass('quick-reg-error-field');
}
function emailError(){
	if($('#cons_email').val()=='')
		$('#error-msg-email').html('* Required');
	else
		$('#error-msg-email').html('* Invalid E-Mail');
	$('#error-msg-email').show();
	$('#cons_email').addClass('quick-reg-error-field');
}

function hideAllErrors(){
	$('#error-msg-firstName').hide();
	$('#error-msg-lastName').hide();
	$('#error-msg-email').hide();
	$('#cons_first_name').removeClass('quick-reg-error-field');
	$('#cons_last_name').removeClass('quick-reg-error-field');
	$('#cons_email').removeClass('quick-reg-error-field');
}
function testLoggedIn(){
	var surveyAction=$('#quick-reg-form').attr('action');
	var convioDomain=surveyAction.split('/site/')[0];
	//show a loading indicator until the AJAX request is complete
	$('#quick-reg-headline').hide();
	$('#quick-reg-logged-in').html('<p style="margin:0;padding:0;"><img alt="" src="'+convioDomain+'/images/indicator.gif" /> Loading ...</p>');
	$('#ACTION_SUBMIT_SURVEY_RESPONSE').hide();
	$.getJSON(convioDomain+'/site/PageServer?pagename=jsonp_S51&pageToFetch=quickreg_loggedin&pgwrap=n&callback=?',function(data){
		$.each(data.pbResponse,function(){
			$('#quick-reg-logged-in').html(this.content);
			//set the logout link's href
			$('#quick-reg-loggedin-logoutLink').attr('href',convioDomain+'/site/UserLogin?logout=&NEXTURL='+escape(window.location.href));
			if(this.isConsLoggedIn=='true'){
				//constituent is logged in
				//change the heading to something more appropriate, and hide the submit button
				$('#quick-reg-headline').html('<p>Welcome Back</p>');
				$('#quick-reg-headline').show();
				//hide the intro text
				$('#quick-reg-step1 p.quick-reg-intro').hide();
				//pre-populate the form
				$('#cons_first_name').val($('#quick-reg-loggedin-firstName').html());
				$('#cons_last_name').val($('#quick-reg-loggedin-lastName').html());
				$('#cons_email').val($('#quick-reg-loggedin-email').html());
				//once everything is set, show the form
				$('#quick-reg-step1').show();
				$('#ACTION_SUBMIT_SURVEY_RESPONSE').show();
			}
			else{
				//not logged in
				$('#quick-reg-logged-in').html('');
				$('#quick-reg-logged-in').hide();
				$('#quick-reg-step1').show();
				$('#quick-reg-headline').show();
				$('#ACTION_SUBMIT_SURVEY_RESPONSE').show();
			}
		});
	});
}
function setQuickRegThankYou(){
	var surveyAction=$('#quick-reg-form').attr('action');
	$.getJSON(surveyAction.split('/site/')[0]+'/site/PageServer?pagename=jsonp_S51&pageToFetch=quickreg_thanks&pgwrap=n&callback=?',function(data){
		$.each(data.pbResponse,function(){
			$('#quick-reg-thank-you').html(this.content);
		});
	});
}