// ONSUBMIT VALIDATION FUNCTIONS
function validateResOffice(form) {
	a=0

	// OnSubmit functions for Resolution Office

	// If no Applicant name is entered, make them do it
	if (form.Applicant.value.length == 0) {
		alert("Please enter your name in 'SSAGT Applicant' field");
		a=a+1
		}

	// If no E-Mail is entered, make them do it
	if (form.App_Email.value.length == 0) {
		alert("Please enter your SSAGT Email address in 'SSAGT Applicant E-Mail' field\n\nThis is necessary so that you can receive automatic correspondence on the progress of your request.");
		a=a+1
	}
	if (form.email.value.length == 0) {
		alert("Please enter your Email address in 'SSAGT Applicant E-Mail' field\n\nThis is necessary so that you can receive automatic correspondence on the progress of your request.");
		a=a+1
	}

	// If no Region is selected, make them do it.
	if (form.Region[0].checked != "1" && form.Region[1].checked != "1" && form.Region[2].checked != "1" ) {
		alert("Please select your Region in the 'Region' field");
		a=a+1;
	}

	// If no Client is entered
	if (form.Client.value.length == 0) {
		alert("Please specify the Client Company in the 'Client' field for whom you are escalating this BMR work unit");
		a=a+1
	}

	// If Escalation is not approved, do not allow escalation
	if (form.Approve_Reject[0].checked != "1") {
		alert("You need to first indicate that this has been approved before it can be escalated.");
		a=a+1
	}

	// If no R&D professional is indicated, do not allow escalation
	if (form.RD_Pro.selectedIndex == 0) {
		alert("You forgot to indicate to whom this should be escalated.");
		a=a+1
	}

	// If no Officer is entered
	if (form.Res_Pro.selectedIndex == 0) {
		alert("You forgot to indicate who you are!\n\nPlease select your name in the 'Resolution Office Professional' dropdown list above.");
	}

}

function validateEnroll(form) {
	a=0

	// OnSubmit functions for Enrollment Form

	// If no EMAIL ADDRESS/LOGIN ID REQUESTED is selected, make them do it.
	if (form.Login_Requested.value.length == 0) {
		alert("EMAIL ADDRESS/LOGIN ID REQUESTED field cannot be blank!\n\nThis is necessary to process your email authorization.");
		a=a+1
	}

	// If no First Name is entered, make them do it
	if (form.firstname.value.length == 0) {
		alert("Please enter your First Name.");
		a=a+1
	}

	// If no Last Name is entered, make them do it
	if (form.lastname.value.length == 0) {
		alert("Please enter your Last Name.");
		a=a+1
	}
	
	//If no Job Title is entered, make them do it
	if (form.title.value.length == 0) {
		alert("Please enter your Job Title.");
		a=a+1
	}
	// If no Company is selected, make them do it.
	if (form.company.value.length == 0) {
		alert("Please specify the name of your Company.");
		a=a+1
	}

	// If no Site Location is selected, make them do it.
	if (form.site.value.length == 0) {
		alert("Please specify your Site Location.");
		a=a+1
	}

	// If no Phone is selected, make them do it.
	if (form.phone.value.length == 0) {
		alert("Please specify your Phone number.");
		a=a+1
	}

	// If no Contact Type is indicated, make them enter it.
	if (form.Contact_Type.selectedIndex == 0) {
		alert("Please specify your Relationship to SSA GT.");
		a=a+1
	}

	// If no Product Line is indicated, make them enter it.
	if (form.product_line.selectedIndex == 0) {
		alert("Please specify your Product Line:\n\nBPCS including BPCS Extension Products, Max International Products, or interBiz Products");
		a=a+1
	}

	// If no Support Center Region is indicated, make them enter it.
	if (form.Region.selectedIndex == 0) {
		alert("Please specify your Support Center Region.");
		a=a+1
	}

	// If no Phone is selected, make them do it.
	if (form.primary_contact.value.length == 0) {
		alert("Please specify your company's Primary Contact.\n\nThis information is necessary to process your email authorization.");
		a=a+1
	}

	// If no Primary Contact Phone or Email, make them enter it.
	if (form.primary_contact_phone.value.length == 0 && form.primary_contact_email.value.length == 0) {
		alert("Please specify either your Primary Contact's phone number or email address.\n\nThis information is necessary to process your email authorization.");
		a=a+1
	}

	// If any errors are detected do not submit
	if (a != 0)
		a=0;

	// If everything is ok send string and clear form
	else {
		form.submit()
		//document.userReset.click();
	}
}


function validateFeedback(form) {
	a=0

	// OnSubmit functions for Feedback Form
	if (form.Question.value.length == 0) {
		alert("You forgot to enter your question!");
		a=a+1
		}

	// If no Applicant name is entered, make them do it
	if (form.Requestor.value.length == 0) {
		alert("You must enter your name");
		a=a+1
		}

	// If no Location is entered, make them do it
	if (form.Location.value.length == 0) {
		alert("You must enter your company name!\n\nThe site location is also preferred.");
		a=a+1
	}

	// If no E-Mail is entered, make them do it
	if (form.Email.value.length == 0) {
		alert("Please enter your Email address!\n\nWe cannot provide you with a response without it!");
		a=a+1
		}

	// If any errors are detected do not submit
	if (a != 0)
		a=0;

	// If everything is ok send string and clear form
	else {
		form.submit()
		//document.userReset.click();
	}
}

// ONBLUR CLEAN DATA FUNCTIONS

// If E-Mail is entered, check for valid format
function validateEmail(theField) {
	if (theField.value.length != 0) {
		var email = (theField.value.indexOf('@') != -1) && (theField.value.indexOf('.') != -1);
		if(email == false) {
			alert("Please enter a valid email address.  It needs to contain an '@' and a '.' - such as 'jsmith@ssax.com'");
			theField.focus();
			theField.value = "";
		}
		return email;
	}
}
