/*
'================================================================================
'NAME:			IndependentArtsFormValidate.js
'DESCRIPTION:	Functions for _Information_form.asp.
'--------------------------------------------------------------------------------
'DATE		AUTHOR			REQUEST #	DESCRIPTION
'05/11/2005	John Lamberton	449			Create
'09/26/2007	Cathy Hubin		993			Form was submitting in error because of the
'										code that checked for IE, NS, etc. 
'										Also added check for whether or not the
'										sponsor number exists
'================================================================================
*/
function SponsorRadio(f) {

	if (f.chkSponsor[1].checked){ //This is the yes in chkSponsor	
		//if user clicks the radio button indicating they are a sponsor 
		//and they are not logged in, create the txtSponsorNumber field
		//and prompt them for their sponsor number
		if ( strSponsorNumber.length <= 0 )
		{
			writeLayer("SponsorNumber",' - Sponsor Number &nbsp;&nbsp;<input type="text" size="15" name="txtSponsorNumber" value="' + strSponsorNumber + '" />');
			writeLayer("SponsorError","(6 or 7 digit number<br />if handy)");
		}
	} else {
		writeLayer ('SponsorNumber', '&nbsp;');
		writeLayer ('SponsorError', '&nbsp;');
	}

}

function submitForm() {
	if (ValidateForm(document.frmIndependentArtist)) document.frmIndependentArtist.submit();
}

function ValidateForm(f) {

	var blnSponsorChecked = false;
	
	ValidateHaveErrors = false;
	
	ValidateNonBlank(f.txtName,"NameError");	
	ValidateNonBlank(f.txtBusinessGroup,"BusinessGroupError");	
	ValidateAnEmailRequired(f.txtEmailAddress,"EmailAddressError");	
	ShowTheErrorMessage("SponsorError", "", false);
	for (i = 0; i < f.chkSponsor.length; i++) {
		if ( f.chkSponsor[i].checked ) {
			blnSponsorChecked = true;
			if (f.chkSponsor[i].value == "yes") ValidateSponsorNumber(f.txtSponsorNumber,"SponsorError",false);
		}
	}
	if (! blnSponsorChecked) ShowTheErrorMessage("SponsorError", "Select", true); 

	//alert(1);return false;
	
	window.location.hash = '#FormTop';
	if (ValidateHaveErrors) alert("Your form is incomplete.\nPlease review your information.");
	return (!ValidateHaveErrors);
}
