function IsFilled(field) {
	if (field.value == "" || field.value == null || field.value == " ")
	return false;
	else return true;
	}
function IsEmail(email) {
	if (email.value != "") {
		if (email.value.indexOf("@") != "-1" &&
			email.value.indexOf(".") != "-1")
		return true;
		else return false;
		}
	return true;
	}
function IsRadioChecked(radioFld) {
	var test = false;
	
	for(var i=0;i <= radioFld.length-1;i++) {
		//alert(radioFld[i].checked);
		if (radioFld[i].checked)
			test = true;
		}
	return test;
	}
	
function validForm (form, step, type){
	if (step == 1) {
		//check membership type
		if (IsRadioChecked(form.type)==false) {
			alert("Please select a membership type.");
			form.type[0].focus();
			return false;
			}
		}
	if (step == 2) {
		//check login and password
		if (IsFilled(form.login) == false ) {
			alert("Please provide a login ID before continuing.");
			form.login.focus();
			return false;
			}
		if ((IsFilled(form.password) == false ) || (IsFilled(form.confirmpassword) == false)) {
			alert("Please type your password into both password fields before continuing.");
			form.password.focus();
			return false;
			}
		if (form.password.value != form.confirmpassword.value) {
			alert("The password and confirm password fields must match.");
			form.password.focus();
			return false;
			}
		
		//check first and last name if not producer
		if (type != 2){
			if ((IsFilled(form.first) == false) || (IsFilled(form.last) == false)) {
				alert("First and last name are required.");
				form.first.focus();
				return false;
				}
			}
		
		//check professional exerpience if applying for professional membership
		//if (form.type[0].checked == true) {
		if (type == 1) {
			if (IsFilled(form.previousshows) == false && IsFilled(form.currentshow) == false) {
				alert("Please describe your current OR previous show(s).");
				form.currentshow.focus();
				return false;
				}
			}
		
		//check email address format if not empty
		if (IsFilled(form.email) == true) {
			if (IsEmail(form.email) == false){
				alert("Please correct the format of your email address before submitting.");
				form.email.focus();
				return false;
				}
			}
		
		
		//check Years as Professional as a number if not a producer
		if (type != 2) {
			if ((isNaN(form.years.value) == true) || (parseInt(form.years.value, 10) < 0 == true)  || (parseInt(form.years.value, 10) > 99 == true)) {
				alert("Years as a Professional must be a number between 0 and 99");
				form.years.focus();
				return false;
				}
			}
		
		//check how they heard about proskaters
		if (form.referralMethod) {		//check if this part of form exists - doesn't exist when updating profile
			if (form.referralMethod.selectedIndex < 1) {
				alert("Please tell us how you heard about Proskaters.");
				form.referralMethod.focus();
				return false;
				}
			else if (form.referralMethod.selectedIndex == 2) {
				if (IsFilled(form.referralName) == false) {
					alert("If you were referred by someone, please provide their name.");
					form.referralName.focus();
					return false;
					}
				}
			else if (form.referralMethod.selectedIndex == 3) {
				if (IsFilled(form.referralName) == false) {
					alert("If you selected Other as the method of hearing about Proskaters, please provide what that method was.");
					form.referralName.focus();
					return false;
					}
				}
			}

		}
	
	//else everything is okay - disable submit button and return true
	disableButton(form.btnSubmit);
	//return false;
	return true;
	}

function confirmDisableAdmin(name) {
	var response = confirm("Are you sure you want to remove admin rights for '" + name + "'?");
	return response;
	}
	
function confirmResetForm() {
	var response = confirm("This will undo all of your changes. Are you sure you want to reset the form to its previous state?");
	return response;
	}
	
function confirmCancelForm(strLocation) {
	var response = confirm("You are about to leave this page without submitting the form. Are you sure you want to cancel your efforts and leave this page?");
	if (response == true) 
		location.href = strLocation;
	return false;
	}
	
function disableButton(button) {
	//alert(navigator.appName + " " + navigator.appVersion);
	if(
		(navigator.appVersion.substr(0, 1) >= 4 && navigator.appName.indexOf("Microsoft") != -1)
		||
		(navigator.appVersion.substr(0, 1) >= 5 && navigator.appName.indexOf("Netscape") != -1)
		||
		(navigator.appVersion.substr(0, 1) >= 6 && navigator.appName.indexOf("Opera") != -1)
		) {
		button.disabled = true;
		}
	}
	