//////////////////////////////////////
function TeamCreateProfile1Validate(){

	var validForm = true;
	var errorMsg = 'Please correct the following and resubmit:\n';

	if (document.getElementById("LoginNameID").value == '' ) {
		errorMsg = errorMsg + '\n' + 'Need Login Name';
		validForm = false;
	}

	if (document.getElementById("LoginNameID").value.length < '3' || document.getElementById("LoginNameID").value.length > '12') {
		errorMsg = errorMsg + '\n' + 'Login name length must be between 3 and 12 characters.';
		validForm = false;
	}
	if (!IsAlphaNumeric(document.getElementById("LoginNameID").value)) {
		errorMsg = errorMsg + '\n' + 'Login Name may contain only letters and numbers';
		validForm = false;
	}
	if (validForm) {
		//alert( 'form passed all validation tests' );   //DEBUG
		document.getElementById("TeamCreateProfile1ID").action = 'TeamCreateProfile1a.asp';
		document.getElementById("TeamCreateProfile1ID").method = 'post';
		document.getElementById("TeamCreateProfile1ID").submit();
	}else{
		alert( errorMsg );
	}
	return false;
} // end of validate1 function
//////////////////////////////////////
function validateWorkOrderRequest(){

	var validForm = true;
	var errorMsg = 'Please correct the following and resubmit:\n';

	if (document.getElementById("Company").value == '' ) {
		errorMsg = errorMsg + '\n' + 'Need Company Name';
		validForm = false;
	}
	if (document.getElementById("BillingAddress1").value == '0' ) {
		errorMsg = errorMsg + '\n' + 'Need Billing Address';
		validForm = false;
	}
	if (document.getElementById("BillingCity").value == '' ) {
		errorMsg = errorMsg + '\n' + 'Need Billing City';
		validForm = false;
	}
	if (document.getElementById("BillingZip").value == '' ) {
		errorMsg = errorMsg + '\n' + 'Need Billing Zip Code';
		validForm = false;
	}
	if (!IsNumeric(document.getElementById("BillingZip").value)) {
		errorMsg = errorMsg + '\n' + 'Billing Zip Code contains invalid characters.';
		validForm = false;
	}
	if (document.getElementById("BillingZip").value.length != '5' ) {
		errorMsg = errorMsg + '\n' + 'Zip Code must have 5 digits.';
		validForm = false;
	}
	
	
	if (1==2){
		if (document.getElementById("InstallAddress1").value == '0' ) {
			errorMsg = errorMsg + '\n' + 'Need Install Address';
			validForm = false;
		}
		if (document.getElementById("InstallCity").value == '' ) {
			errorMsg = errorMsg + '\n' + 'Need Install City';
			validForm = false;
		}
		if (document.getElementById("InstallZip").value == '' ) {
			errorMsg = errorMsg + '\n' + 'Need Install Zip Code';
			validForm = false;
		}
		if (!IsNumeric(document.getElementById("InstallZip").value)) {
			errorMsg = errorMsg + '\n' + 'Install Zip Code contains invalid characters.';
			validForm = false;
		}
		if (document.getElementById("InstallZip").value.length != '5' ) {
			errorMsg = errorMsg + '\n' + 'Install Zip Code must have 5 digits.';
			validForm = false;
		}
	} // 1==2


	if (document.getElementById("PrimaryContactName").value == '' ) {
		errorMsg = errorMsg + '\n' + 'Need Primary Contact Name';
		validForm = false;
	}
	if (document.getElementById("Phone").value == '' ) {
		errorMsg = errorMsg + '\n' + 'Need Phone';
		validForm = false;
	}
	if (document.getElementById("PrimaryEmailAddress").value == '' ) {
		errorMsg = errorMsg + '\n' + 'Need Primary Email Address';
		validForm = false;
	}else{
		document.getElementById("email").value = document.getElementById("PrimaryEmailAddress").value;
	}

	if (document.getElementById("PhoneSystem").value == '0' ) {
		errorMsg = errorMsg + '\n' + 'Need your current Phone System';
		validForm = false;
	}

	if (document.getElementById("WorkRequested").value == '' ) {
		errorMsg = errorMsg + '\n' + 'Need a brief description of the work requested';
		validForm = false;
	}

//	if (valButton(TeamCreateProfile2.ChooseEventID) == null) {
//		errorMsg = errorMsg + '\n' + 'Please choose an event.';
//		validForm = false;
//	}
	
	if (validForm) {
		//alert( 'form passed all validation tests' );   //DEBUG
		document.getElementById("workid").action = 'http://www.creativeinternet.com/cgi-bin/mailform.asp';
		document.getElementById("workid").method = 'post';
		document.getElementById("workid").submit();
	}else{
		alert( errorMsg );
	}
	return false;
} // end of validate2 function
///////////////////////////////////////////////////
// Radio Button Validation
// copyright Stephen Chapman, 15th Nov 2004,14th Sep 2005
// you may copy this function but please keep the copyright notice with it
function valButton(btn) {
    var cnt = -1;
    for (var i=btn.length-1; i > -1; i--) {
        if (btn[i].checked) {cnt = i; i = -1;}
    }
    if (cnt > -1) return btn[cnt].value;
    else return null;
}
///////////////////////////////////////////////////
function isDigit(c)
{
  return "0123456789.".indexOf(c) == -1 ? 0 : 1
}
///////////////////////////////////////////////////
function IsNumeric(sText)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
}
///////////////////////////////////////////////////
function IsAlphaNumeric(sText)
{
   var ValidChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
   var IsValid=true;
   var Char;
   for (i = 0; i < sText.length && IsValid == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsValid = false;
         }
      }
   return IsValid;
}
///////////////////////////////////////////////////
function IsAlphabetic(sText)
{
   var ValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
   var IsValid=true;
   var Char;
   for (i = 0; i < sText.length && IsValid == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsValid = false;
         }
      }
   return IsValid;
}
///////////////////////////////////////////////////////
function coachFormValidation() {
	var validForm = true;
	var errorMsg = 'Please correct the following and resubmit:\n';
	if (document.getElementById("FirstNameID").value == '') {
		errorMsg = errorMsg + '\n' + 'Need First Name';
		validForm = false;
	}
	if (!IsAlphabetic(document.getElementById("FirstNameID").value)) {
		errorMsg = errorMsg + '\n' + 'First may contain only letters.';
		validForm = false;
	}
	if (document.getElementById("LastNameID").value == '') {
		errorMsg = errorMsg + '\n' + 'Need Last Name';
		validForm = false;
	}
	if (!IsAlphabetic(document.getElementById("LastNameID").value)) {
		errorMsg = errorMsg + '\n' + 'Last may contain only letters.';
		validForm = false;
	}
	if (document.getElementById("CoachEmailAddressID").value == '') {
		errorMsg = errorMsg + '\n' + 'Need a valid email address';
		validForm = false;
	}
	if ( (document.getElementById("CoachareaCodeID").value   == '' || 
		  document.getElementById("CoachOfficeCodeID").value == '' ||  
		  document.getElementById("CoachExtensionID").value  == '' )
		  &&
		  !(document.getElementById("CoachareaCodeID").value == '' && 
		  document.getElementById("CoachOfficeCodeID").value == '' &&  
		  document.getElementById("CoachExtensionID").value  == '' ) ) {
		errorMsg = errorMsg + '\n' + 'Incomplete home phone number';
		validForm = false;
	}
	if ( (document.getElementById("CoachCellareaCodeID").value   == '' || 
		  document.getElementById("CoachCellOfficeCodeID").value == '' ||  
		  document.getElementById("CoachCellExtensionID").value  == '' )
		  &&
		  !(document.getElementById("CoachCellareaCodeID").value == '' && 
		  document.getElementById("CoachCellOfficeCodeID").value == '' &&  
		  document.getElementById("CoachCellExtensionID").value  == '' ) ) {
		errorMsg = errorMsg + '\n' + 'Incomplete cell phone number';
		validForm = false;
	}
	if ( (document.getElementById("FaxareaCodeID").value   == '' || 
		  document.getElementById("FaxOfficeCodeID").value == '' ||  
		  document.getElementById("FaxExtensionID").value  == '' )
		  &&
		  !(document.getElementById("FaxareaCodeID").value == '' && 
		  document.getElementById("FaxOfficeCodeID").value == '' &&  
		  document.getElementById("FaxExtensionID").value  == '' ) ) {
		errorMsg = errorMsg + '\n' + 'Incomplete fax number';
		validForm = false;
	}
	if (!IsNumeric(document.getElementById("CoachareaCodeID").value)		||
		!IsNumeric(document.getElementById("CoachOfficeCodeID").value)		||
		!IsNumeric(document.getElementById("CoachExtensionID").value)		||
		!IsNumeric(document.getElementById("CoachCellareaCodeID").value)	||
		!IsNumeric(document.getElementById("CoachCellOfficeCodeID").value)	||
		!IsNumeric(document.getElementById("CoachCellExtensionID").value)	||
		!IsNumeric(document.getElementById("FaxareaCodeID").value)			||
		!IsNumeric(document.getElementById("FaxOfficeCodeID").value)		||
		!IsNumeric(document.getElementById("FaxExtensionID").value)		) {
			errorMsg = errorMsg + '\n' + 'Phone numbers may contain only numbers.';
			validForm = false;
	}
	if ( document.getElementById("CoachareaCodeID").value		== '' && 
		 document.getElementById("CoachOfficeCodeID").value		== '' && 
		 document.getElementById("CoachExtensionID").value		== '' && 
		 document.getElementById("CoachCellareaCodeID").value	== '' &&  
		 document.getElementById("CoachCellOfficeCodeID").value	== '' && 
		 document.getElementById("CoachCellExtensionID").value	== '' && 
		 document.getElementById("FaxareaCodeID").value			== '' && 
		 document.getElementById("FaxOfficeCodeID").value		== '' && 
		 document.getElementById("FaxExtensionID").value		== '' ) {
		errorMsg = errorMsg + '\n' + 'You must enter at least one phone number';
		validForm = false;
	}
	if (validForm) {
		document.getElementById("gX3r2aQs").action = "TeamCreateProfile3a.asp";
		document.getElementById("gX3r2aQs").method = "POST";
		document.getElementById("gX3r2aQs").submit();
	}else{	
		alert( errorMsg );
	}
	return false;
}
/////////////////////////////////////////////////////////

