function nextPage() {
	var status	= parseInt($('#reg_status').val());
	var proceed	= false;
	var curpage	= '';

	switch (status) {
		case 1:
			{
				curpage = 'General';

				if ($('#name').val()=='') break;
				if ($('#email').val()=='') break;
				if ($('#password1').val()=='') break;
				if ($('#password2').val()=='') break;
				if ($('#street1').val()=='') break;
				if ($('#city').val()=='') break;
				if ($('#sother').val()=='') {
					if ($('#state').val()=='0') break;
				}
				if ($('#zip').val()=='') break;
				if ($('#country').val()=='0') break;
				if ($('#phone').val()=='') break;

				proceed = true;
			}
			break;
		case 2:
			{
				curpage = 'Details';

				if ($('#airport').val()=='0') break;

				proceed = true;
			}
			break;
		case 3:
			{
				curpage = 'Bio';

				//if ($('#bio').val()=='') break;

				proceed = true;
			}
			break;
	}

	if (!proceed) {
		alert('All required fields on the '+curpage+' page have not been filled in.');
	} else {
		status++;
		if (status>3) {
			//submit form
			return true;
		} else {
			$('#reg_status').val(status+'');
			ShowTab(status);
		}
	}
	return false;
}
function ShowTab(tab, slide) {
	var status	= parseInt($('#reg_status').val());
	var tabs	= 3;
	var t		= 0;

	if (tab>status) {
		alert('Once all of the information on the current page is filled out\nyou may click the "Next" button to continue');
		return false;
	}

	for (t=1; t<(tabs+1); t++) {
		var tabpage	= $('#page'+t);
		var tabbtn	= $('#tab'+t);

		if (t==tab) {
			if (slide) {
				tabpage.slideDown();
			} else {
				tabpage.show();
			}
			tabbtn.removeClass();
			tabbtn.addClass('tab-button-active');
		} else {
			tabpage.hide();
			tabbtn.removeClass();
			tabbtn.addClass('tab-button');
		}
	}
}
function ShowEngines() {
	if ($('#overhaul').val()=='0') {
		$('#row_comp_05').hide();
	} else {
		$('#row_comp_05').show();
	}
}
function ToggleFields() {
	var is_ind = $('#type').val();

	if (is_ind=='0') {
		$('#row_indiv_01').hide();
		$('#row_indiv_02').hide();
		$('#row_indiv_03').hide();
		$('#row_indiv_04').hide();

		$('#row_comp_01').show();
		$('#row_comp_02').show();
		$('#row_comp_03').show();
		$('#row_comp_04').show();
		ShowEngines();
	} else {
		$('#row_indiv_01').show();
		$('#row_indiv_02').show();
		$('#row_indiv_03').show();
		$('#row_indiv_04').show();

		$('#row_comp_01').hide();
		$('#row_comp_02').hide();
		$('#row_comp_03').hide();
		$('#row_comp_04').hide();
		$('#row_comp_05').hide();
	}
}
function ShowStateOther() {
	var state_id = $('#state').val();

	if (state_id=='0') {
		$('#state_other').show();
	} else {
		$('#state_other').hide();
	}
}
$(document).ready(function()
{
	if ($('#reg_status').val()=='1') {
		$('#btn_register').val('Next  >');
	}

	$('#btn_register').click(function() {
		return nextPage();
	});
	$('#overhaul').change(function() {
		ShowEngines();
	});

	$('#row_comp_05').hide(); //engines
	ShowTab(1);
	ToggleFields();
	ShowStateOther();
});
