//*****************************************************************************
// C & G Technical Group Form Validation Script For Sankofa Connection
//*****************************************************************************

<!--
var gDate = new Date();
var gDay = gDate.getDate();
var gMon = gDate.getMonth() + 1;
var gYear = gDate.getFullYear();
var gTime = gDate.getTime();
var gHours = gDate.getHours();
var gMinutes = gDate.getMinutes();
var gSeconds = gDate.getSeconds();

//var reInteger = /^\d+$/  ;
var digits = "0123456789";
// U.S. phone numbers have 10 digits.
// They are formatted as 123 456 7890 or (123) 456-7890.
var digitsInUSPhoneNumber = 10;
// whitespace characters as defined by this sample code
var whitespace = " \t\n\r";
var numberoftimes = 0; 
function validateSubOnce (strMessage) {
	numberoftimes += 1;
	if (numberoftimes > 1) { 
		if (numberoftimes == 3) {
				strMessage = "DO NOT PRESS SUBMIT MULTIPLE TIMES!!! YOUR ACCOUNT WILL BE BILLED EACH TIME YOU PRESS SUBMIT!!! Processing may take up to one minute.";
		}
		 alert(strMessage);
		 return false; 
	}  
	return true;
} 
function isEmpty(s)
{ return ((s == null) || (s.length == 0))
}
function TrimSTR(strValue) {
	// REMOVE leading spaces.
	while (true) {
		if (strValue.indexOf(" ") == 0) {	// a leading space has been found so...
			strValue = strValue.substring(1, strValue.length)	// slice it off.
		} else {	// the first character in the string is no longer a space so...
			break	// exit the loop.
		}
	}
	// REMOVE trailing spaces.
	if (strValue.length > 0) {	// the string is not null.
		while (true) {
			if (strValue.lastIndexOf(" ") == strValue.length - 1) {	// a trailing space has been found so...
				strValue = strValue.substring(0, strValue.length - 1)	// slice it off.
			} else {	// the last character in the string is no longer a space so...
				break	// exit the loop.
			}
		}
	}
	// ASSIGN return value
	return strValue
}
function stripCharsInBag (s, bag)
{ var i;
	var returnString = "";
	for (i = 0; i < s.length; i++)
	{
	// Check that current character isn't whitespace.
		var c = s.charAt(i);
		if (bag.indexOf(c) == -1) returnString += c;
	}
	return returnString;
}
function stripCharsNotInBag (s, bag)
{ var i;
	var returnString = "";
	// Search through string's characters one by one.
	// If character is in bag, append to returnString.
	for (i = 0; i < s.length; i++)
	{
	// Check that current character isn't whitespace.
		var c = s.charAt(i);
		if (bag.indexOf(c) != -1) returnString += c;
	}
	return returnString;
}
function isInteger (s)	{
	if (isEmpty(s)) return false;
	return reInteger.test(s)
}
function stripWhitespace (s) {
	return stripCharsInBag (s, whitespace)
}
function isNumeric(objField, strLength, strMessage) {
	// INITIALIZE procedure-scope variables.
	var blnNumeric = true

	// SCAN string for non-numeric characters.
	for (var i = 0; i < objField.value.length; i++) {
		if (objField.value.length > strLength) {
			alert(strMessage);
			objField.focus();
			blnNumeric = false;
			break;
		}
		if (isEmpty(i)) {
			alert(strMessage);
			objField.focus();
			blnNumeric = false;
			break;
		}
		var strDigit = objField.value.charAt(i);
		if (strDigit < 0 || strDigit > 9) {	//non-numeric character has been found.
			alert(strMessage);
			objField.focus();
			blnNumeric = false;
			break;
		}
	}
	// ASSIGN return value.
	return blnNumeric
}
function validateTextField (objField, minLen, maxLen, strMessage) {
// Validate a Text Field
	if(objField.value == "") {
		alert(strMessage);
		objField.focus();
		return false;
	}

	if(objField.value.length < minLen || objField.value.length > maxLen) {
		alert(strMessage);
		objField.focus();
		return false;
	}
	return true;
}
function validateTextAmount (objField, minLen, maxLen, strMessage) {
// Validate a Text Field
	if(objField.value == "") {
		alert(strMessage);
		objField.focus();
		return false;
	}

	if(objField.value.length < minLen || objField.value.length > maxLen) {
		alert(strMessage);
		objField.focus();
		return false;
	}
	
	if(objField.value < 200.00) {
		alert(strMessage);
		objField.focus();
		return false;
	}
	return true;
}

function validateEmail(objField, strMessage) {
// Validates e-mail address form inputs.
	if (objField.value == "") {	// no value entered in field.
	// DISPLAY validation failure message.
		alert(strMessage);
		objField.focus();
		return false;
	}
	if (objField.value.indexOf ('@', 0) == -1 || objField.value.indexOf ('.', 0) == -1) {	// address does not contain the "@" and "." characters.
		alert(strMessage);
		objField.select();
		objField.focus();
		return false;
	}
	else {	// the address is acceptable.
		return true;
	}
}
function validatePhoneNumber(field, strLength, strMessage){
	sx = stripCharsNotInBag(field.value,digits); // Strip all non-digit chars;
	if (sx.length < strLength) {
		alert(strMessage);
		field.focus();
		return false;
	}
	return true;
}
function validateNumber(field, strLength, strMessage){
	sx = stripCharsNotInBag(field.value,digits); // Strip all non-digit chars;
	if (sx.length > strLength) {
		strMessage = 'MSG0010 - Numeric value ' + field.value + ' is too Long';
		alert(strMessage);
		field.focus();
		return false;
	}
	for (i = 0; i < field.value.length; i++) {
		var strDigit = field.value.charAt(i);
		if (strDigit == ',' || strDigit == '.') {
			continue;
		}else if (digits.indexOf(strDigit) == -1) {	//non-numeric character has been found.
				alert(strMessage);
				field.focus();
				return false;
				break;
		}
	}
	return true;
}
function validateZip(field, strMessage) {
	sx = stripWhitespace(field.value); // Strip all non-digit chars
	if(sx.length < 5) { // Postals need to be at least 5
		alert(strMessage);
		field.focus();
		return false;
	}
	return true;
}
function validateState(field, strMessage) {
	if (field.selectedindex == 0 && field.value == ''){
		alert(strMessage); 
		field.focus();
		return false;
	}
	return true;
}

function validateDropDown(objField, strMessage) {
	if (objField.options[0].selected == true && objField.value == '') {	//No Dropdown Value Selected.
		alert(strMessage);
		objField.focus();
		return false;
	}
		// Check that current character isn't whitespace.
	var c = objField.value.charAt(0);
	if ( c == '-' || c=='') {	
		alert(strMessage);
		objField.focus();
		return false;
	} 
	return true;
}
function validateAreaCode(objField, state, strMessage) {
	if (isEmpty(objField.value)) {
		alert(strMessage);
		objField.focus();
		return false;
	}else {
		if (!areacode(objField.value, state)){	         //Invalid Area Code.
			objField.focus();
			return false;
		}
	}
	return true;
}
function validateDLExpireDate(objField, strMessage) {
	//Set dates
	today=new Date();					//Current Date
	oneday=1000*60*60*24				//Get 1 day in milliseconds
	if (objField.value.indexOf('/') <= 0 || objField.value.length < 10) {
		alert(strMessage);
		objField.focus();
		return false;
	}else{
		mon=objField.value.slice(0,2);
		day=objField.value.slice(3,objField.value.length-5);
		yer=objField.value.slice(6,objField.value.length);
		dldate =new Date(yer, mon, day) //Month is 0-11 in JavaScript
		//Calculate difference btw the two dates, and convert to days
		expdate=Math.ceil((today.getTime()-dldate.getTime())/(oneday))
	}
	if (expdate > -30) {
		expdate = expdate + 30;
		alert('MSGP003 - Your Driver License Expired ' + expdate + ' Days Ago');
		objField.focus();
		return false;
	}
	return true;
}
function validateRadio(objForm, strMessage){
	for (xx=0; xx < document.FormName.elements.length; xx++){
		 if (document.FormName.elements[xx].type == 'radio' && 
			 document.FormName.elements[xx].checked == true &&
			 document.FormName.elements[xx].name == objForm)
		 return true;
	}
	alert(strMessage);
	return false;	
}

function validateFormC(objForm) {
	with(objForm) {
	// Validate Form Input
		if (hiddentotal.value == 0) return true;
		if(!confirmPassword(RegisterPwd,ConfirmPwd,'Confirm Password Does Not Match'))return false;
		if(!validateTextField(x_first_name,2,20,'Please Enter Your First Name From Credit Card')) return false;
		if(!validateTextField(x_last_name,2,20,'Please Enter Your Last Name From Credit Card')) return false;
		if(!validateTextField(x_address,5,30,'Please Enter The Credit Card Billing Statement Address')) return false;
		if(!validateTextField(x_city,3,20,'Please Enter The Credit Card Billing Statement City')) return false;
		if(!validateDropDown(x_state,'Please Select The Credit Card Billing Statement State')) return false;
		if(!validateTextField(x_zip,5,10,'Please Enter The Credit Card Billing Statement Postal Code or Province')) return false;
		
		for (xx=0; xx < document.FormName.elements.length; xx++) {
			if (document.FormName.elements[xx].type == 'radio' &&
				document.FormName.elements[xx].checked == true &&
				document.FormName.elements[xx].name == 'paymentMethod') {	
				if (document.FormName.elements[xx].value == 'creditCard') {
					if(!validateDropDown(x_card_type,'Please Select Type of Credit Card')) return false;
					if(!validateTextField(x_card_num,10,20,'Please Enter Your Credit Card Number')) return false;
					if(!validateDropDown(x_exp_month,'Please Select The Month Card Expires')) return false;
					if(!validateDropDown(x_exp_year,'Please Select The Year Card Expires')) return false;
					if(!validateTextField(x_card_code,3,4,'Please Enter CVVC Number Found On The Back Of Your Credit Card')) return false;
				}
				if (document.FormName.elements[xx].value == 'check') {
					if(!validateTextField(x_check_num,3,20,'Please Enter Check Number on The Check You Will Be Mailing To MWC')) return false;
					if(!validateTextField(x_check_routing,10,16,'Please Enter Check Routing Code On The Check You Will Be Mailing To MWC')) return false;
					if(!validateTextField(x_check_account,4,25,'Please Enter Check Account Number On The Check You Will Be Mailing To MWC')) return false;
				}
			}
		}
		
		return true;
	}
}
function validateFormS(objForm, xx) {
	with(objForm) {
	// Validate Form Input
//		var xx = document.FormName.signinButton.value;
//		var	xy = document.FormName.submitRegisterButton.value;
//		alert(xx);
		if (xx == 'b1') {
			if(!validateTextField(Username,7,120,'Please Enter The Email Address You Registered With')) return false;
			if(!validateTextField(Pwd,6,12,'Please Enter The Password You Entered During Registration')) return false;
		}
		if (xx == 'b2') {
			if(!validateTextField(Email,7,120,'Please Enter A Valid Email Address')) return false;
//			if(!validateEmail(Email ,'Please Enter A Valid Email Address')) return false;
			if(!validateTextField(CompanyName,2,60,'Please Enter Your Company Name')) return false;
			if(!validateTextField(FirstName,2,20,'Please Enter Your First Name')) return false;
			if(!validateTextField(LastName,2,20,'Please Enter Your Last Name')) return false;
			if(!validateTextField(Title,2,20,'Please Tell Us What Position You Hold In Your Company')) return false;
			if(!validateTextField(Areacode,3,3,'Invalid Area Code Entered')) return false;
			if(!validateTextField(Landcode,3,3,'Invalid Land Code Entered')) return false;
			if(!validateTextField(Phonecode,4,4,'Invalid Phone Code Entered')) return false;
			if(!validateDropDown(MailingState,'Please Select Your State')) return false;
			if(!validateTextField(Zip,5,10,'Please Enter Your Postal Code or Province')) return false;
			if(!validateDropDown(country,'Please Select Your Country Residence')) return false;
			if(!validateTextField(RegisterPwd,8,12,'Please Enter A Valid Password With Minimum Length of 8 - Containing at Least 2 Digits')) return false;
			if(!validateTextField(ConfirmPwd,8,12,'Confirmation Does Not Match Registration Password')) return false;
			if(!confirmPassword(RegisterPwd,ConfirmPwd,'Passwords Do Not Match'))return false;

		}
		return true;
	}
}

function validateFormP(objForm){
	with(objForm){
			if(!validateTextField(Email,7,120,'Please Enter A Valid Email Address')) return false;
	return true;
	}
}
function validateForm(objForm) {
	with(objForm) {
	// Validate Form Input
		if(!validateTextField(FirstName,2,20,'Please Enter Your First Name')) return false;
		if(!validateTextField(LastName,2,20,'Please Enter Your Last Name')) return false;
		if(!validateTextField(Title,2,20,'Please Tell Us What Position You Hold In Your Company')) return false;
		if(!validateTextField(Areacode,3,3,'Invalid Area Code Entered')) return false;
		if(!validateTextField(Landcode,3,3,'Invalid Land Code Entered')) return false;
		if(!validateTextField(Phonecode,4,4,'Invalid Phone Code Entered')) return false;
		if(!validateTextField(Email,7,120,'Please Enter An Email Address')) return false;
		if(!validateEmail(Email ,'Please Enter A Valid Formatted Email Address')) return false;
		if(!validateTextField(Comments,5,1000,'Please Enter A Comment/Suggestion/Instruction')) return false;

		return true;
	}
}

function confirmPassword(pwdBox1,pwdBox2,strMessage){
	if (pwdBox1.value == pwdBox2.value){
		return true;
	}
	alert(strMessage);
	pwdBox1.value = "";
	pwdBox2.value = "";
	pwdBox1.focus();
	return false;
}





function dateMark(field1, e){
	var isNN = (navigator.appName.indexOf("Netscape")!=-1);
	var keyCode = (isNN) ? e.which : e.keyCode; 
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];

	if(field1.value.length == 2 && !containsKeycode(filter,keyCode)){
		field1.value = field1.value.slice(0, field1.value.length);
		field1.value = field1.value + '/';
	}
	if(field1.value.length == 5 && !containsKeycode(filter,keyCode)){
		field1.value = field1.value.slice(0, field1.value.length);
		field1.value = field1.value + '/';
	}
	return true;
}
function ssnMark(field1, e){
	var isNN = (navigator.appName.indexOf("Netscape")!=-1);
	var keyCode = (isNN) ? e.which : e.keyCode; 
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];

	if (document.sabreForm.ssntin.options[1].selected == true) {
		if(field1.value.length == 3 && !containsKeycode(filter,keyCode)){
			field1.value = field1.value.slice(0, field1.value.length);
			field1.value = field1.value + '-';
		}
		if(field1.value.length == 6 && !containsKeycode(filter,keyCode)){
			field1.value = field1.value.slice(0, field1.value.length);
			field1.value = field1.value + '-';
		}
	}
	if (document.sabreForm.ssntin.options[2].selected == true) {
		if(field1.value.length == 2 && !containsKeycode(filter,keyCode)){
			field1.value = field1.value.slice(0, field1.value.length);
			field1.value = field1.value + '-';
		}
	}
	return true;
}
function autoTab(field1, field2, len, mark, e){
	var isNN = (navigator.appName.indexOf("Netscape")!=-1);
	var keyCode = (isNN) ? e.which : e.keyCode; 
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];

	if(field1.value.length >= len && !containsKeycode(filter,keyCode)) {
		if (mark == 2) field1.value = '(' + field1.value + ')';
		if (mark == 1) field1.value = field1.value + '-';

		field1.value = field1.value.slice(0, field1.value.length);
		field2.focus();
	}
	return true;
}
function containsKeycode(arr, ele) {
	var found = false, index = 0;
	while(!found && index < arr.length) {
		if(arr[index] == ele)
			found = true;
		else
			index++;
	}
	return found;
}
function changeAmount(form) {
	if (form.package.value == 'No Package') 
		form.x_amount.value = '200.00';
	else
		form.x_amount.value = '250.00'; 
	form.dpmonth.focus();
	
	return(formatCurrency(form.x_amount.value));
}
function formatCurrency(num)
	{
		num = num.toString().replace(/\$|\,/g,'');
		if(isNaN(num))
		   num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
		if(cents<10)
		    cents = "0" + cents;
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		    num = num.substring(0,num.length-(4*i+3))+','+
		          num.substring(num.length-(4*i+3));
  	    return (((sign)?'':'-') + '$' + num + '.' + cents);
}

function CheckChoice(objbox)
	{ 	with (objbox.form)
		{
			//Add quantity selected to registration price:
			if (objbox.checked) {
//				if (objbox.value == 'Small Business'  ||
//				    objbox.value == 'Small Business Affiliate') {
//						alert('This Membership Level Not Available At This Time!');
//						return false;
//				}
				hiddentotal.value = 0;
				hiddentotal.value = eval(objbox.price);
				x_total.value 	  = eval(objbox.price); 
				ShowMembership('divR2');
			} 
					
			//Ensure the total never goes negative:
			if (hiddentotal.value < 0) {
				alert('A Negative Total Entered - Sales Total = ' + hiddentotal.value); 
			}
			//Now, return with formatted total:
			return(formatCurrency(hiddentotal.value));
	}
}

function whichPayment(objForm) {
		for (xx=0; xx < document.FormName.elements.length; xx++) {
	
			if (document.FormName.elements[xx].type == 'radio' &&
				document.FormName.elements[xx].checked == true &&
				document.FormName.elements[xx].name == 'paymentMethod') {	
				if (document.FormName.elements[xx].value == 'check') {
					document.FormName.x_card_num.value 			= '';
					document.FormName.x_exp_month.selectedIndex = 0;
					document.FormName.x_exp_year.selectedIndex 	= 0;
					document.FormName.x_card_code.value			= '';
					document.getElementById('divChk').style.display = "block";
					document.getElementById('divCrd').style.display = "none";
					document.FormName.x_check_num.focus(); 
				}
				if (document.FormName.elements[xx].value == 'creditCard') {
					document.FormName.x_check_num.value 		= '';
					document.FormName.x_check_routing.value		= '';
					document.FormName.x_check_account.value		= '';
					document.getElementById('divChk').style.display = "none";
					document.getElementById('divCrd').style.display = "block";
					document.FormName.x_card_num.focus();
				}
			}
		}
}
function ClearDivR3() {
	document.FormName.ParentCompany.value = '';
	document.FormName.MailingAddress.value = '';
	document.FormName.MailingCity.value = '';
	document.FormName.MailingState.value = '';
	document.FormName.MailingZip.value = '';
	document.FormName.MailingState.options[0].selected = true;
	document.FormName.MailingCountry.options[0].selected = true;
	document.FormName.MailingZip.value = '';
	document.FormName.ParentAreacode.value = '';
	document.FormName.ParentPhonecode.value = '';
	document.FormName.ParentLandcode.value = '';
	document.FormName.HomeOffice.checked = false;
	document.FormName.WebAddress.value = '';
	document.FormName.BusinessProfile.value = '';
	document.FormName.EIN.value = '';
//	document.FormName.NAICS.value = '';
	document.FormName.FNKeyContact.value = '';
	document.FormName.LNKeyContact.value = '';
	document.FormName.Structure.options[0].selected = true;
	document.FormName.EstablishedDate.value = '';
//	document.FormName.Certifications.value = '';
	document.FormName.OtherCertifications.value = '';
	document.FormName.DunBradstreet.value = '';
	document.FormName.TotalEmployees.options[0].selected = true;
	document.FormName.WomenEmployees.options[0].selected = true;
	document.FormName.MinorityEmployees.options[0].selected = true;
	document.FormName.GeoMarket.options[0].selected = true;
	document.FormName.AGOA.checked = false;
	document.FormName.Reference.options[0].selected = true;
	document.FormName.OtherReference.value = '';
}

function ShowMembership(memberType){

	switch(memberType)	{
		case 'divR1':
			document.getElementById('divR1').style.display = "block";
			document.getElementById('divR2').style.display = "none";
			document.getElementById('divR3').style.display = "none";
			document.getElementById('divR4').style.display = "none";
			break;
		case 'divR2':
			document.getElementById('divR1').style.display = "none";
			document.getElementById('divR2').style.display = "block";
			document.getElementById('divR3').style.display = "none";
			document.getElementById('divR4').style.display = "none";
			document.FormName.FirstName.focus();
			break;
		case 'divR3':
			var c = false; g = false;
			if(!validateTextField(document.FormName.FirstName,2,20,'Please Enter Your First Name')) return false;
			if(!validateTextField(document.FormName.LastName,2,20,'Please Enter Your Last Name')) return false;
			if(!validateTextField(document.FormName.Title,2,20,'Please Tell Us What Position You Hold In Your Company')) return false;
			if(!validateTextField(document.FormName.Areacode,3,3,'Invalid Area Code Entered')) return false;
			if(!validateTextField(document.FormName.Landcode,3,3,'Invalid Land Code Entered')) return false;
			if(!validateTextField(document.FormName.Phonecode,4,4,'Invalid Phone Code Entered')) return false;
			if(!validateTextField(document.FormName.Email,7,120,'Please Enter A Valid Email Address')) return false;
			if(!validateEmail(document.FormName.Email,'Please Enter A Valid Email Address')) return false;
			if(!validateTextField(document.FormName.RegisterPwd,8,12,'Please Enter A Valid Password With Minimum Length of 8 - Containing at Least 2 Digits')) return false;
			if(!validateTextField(document.FormName.ConfirmPwd,8,12,'Confirmation Does Not Match Registration Password')) return false;
			if(document.FormName.ConfirmPwd.value != document.FormName.RegisterPwd.value) { alert('Confirmation Does Not Match Registration Password'); document.FormName.RegisterPwd.focus(); return false;}
			if(!validateTextField(document.FormName.CompanyName,2,60,'Please Enter Your Company Name')) return false;
			if(!validateDropDown(document.FormName.CompanySize,'Please Select The Size Of Your Company Based On Employees')) return false;
			if(!validateDropDown(document.FormName.TypeofOrganization,'Please Tell Us The Type Of Industry Your Company Represents')) return false;
			if(!validateTextField(document.FormName.Address,5,30,'Please Enter Your Locations Physical Address')) return false;
			if(!validateTextField(document.FormName.City,3,20,'Please Enter Your Locations Physical City')) return false;
			if(!validateDropDown(document.FormName.State,'Please Select Your Locations Physical State')) return false;
			if(!validateTextField(document.FormName.Zip,5,10,'Please Enter Your Locations Physical Postal Code or Province')) return false;
			if(!validateDropDown(document.FormName.Country,'Please Enter Your Locations Country')) return false;
			if(!validateDropDown(document.FormName.Race,'Please Select Your Ethnicity')) return false;
			if(!validateTextField(document.FormName.College,3,100,'Please Enter School of Higher Education Attended')) return false;

			for (xx=0; xx < document.FormName.elements.length; xx++) {
				if (document.FormName.elements[xx].type == 'radio' &&
					document.FormName.elements[xx].name == 'gender' &&
					document.FormName.elements[xx].checked == true) {
						g = true;
						break;
				}
			}
	
			if (!g) {alert('Please Select Your Gender!'); return false;	}
			
			for (xx=0; xx < document.FormName.elements.length; xx++) {
			   if (document.FormName.elements[xx].type == 'radio' &&
				   document.FormName.elements[xx].checked == true &&
				   document.FormName.elements[xx].name == 'memberlevel') {
				   		if (document.FormName.elements[xx].value == 'Small Business'  ||
						     document.FormName.elements[xx].value == 'Small Business Affiliate') {
							document.getElementById('divR1').style.display = "none";
							document.getElementById('divR2').style.display = "none";
							document.getElementById('divR3').style.display = "block";
							document.getElementById('divR4').style.display = "none";
							document.FormName.ParentCompany.focus();
						}else{
							ClearDivR3();
							document.getElementById('divR1').style.display = "none";
							document.getElementById('divR2').style.display = "none";
							document.getElementById('divR3').style.display = "none";
							document.getElementById('divR4').style.display = "block";
							document.FormName.x_first_name.focus();
						} 
				}
			}
			break;
		case 'divR4':
			document.getElementById('divR1').style.display = "none";
			document.getElementById('divR2').style.display = "none";
			document.getElementById('divR3').style.display = "none";
			document.getElementById('divR4').style.display = "block";
			document.FormName.x_first_name.focus();
			break;
	}	
}
function ShowRegistration(registerType){

	switch(registerType)	{
		case 'divR1':
			document.getElementById('divR1').style.display = "block";
			document.getElementById('divR2').style.display = "none";
			document.FormName.Username.focus();
			break;
		case 'divR2':
			document.getElementById('divR1').style.display = "none";
			document.getElementById('divR2').style.display = "block";
			document.FormName.Email.focus();
			break;
		
	}	
}

function SameAsMailing(Form) {
	if (Form.Msameas.checked == true) {
		Form.ParentCompany.value = Form.CompanyName.value;
		Form.MailingAddress.value = Form.Address.value;
		Form.MailingCity.value = Form.City.value;
		Form.MailingState.value = Form.State.value;
		Form.MailingCountry.value = Form.Country.value;
		Form.MailingZip.value = Form.Zip.value;
		Form.ParentAreacode.value = Form.Areacode.value;
		Form.ParentPhonecode.value = Form.Phonecode.value;
		Form.ParentLandcode.value = Form.Landcode.value;
	}else if (Form.Msameas.checked == false) {
		Form.ParentCompany.value = '';
		Form.MailingAddress.value = '';
		Form.MailingCity.value = '';
		Form.MailingState.options[0].selected = true;
		Form.MailingCountry.options[0].selected = true;
		Form.MailingZip.value = '';
		Form.ParentAreacode.value = '';
		Form.ParentPhonecode.value = '';
		Form.ParentLandcode.value = '';
	}
	Form.ParentCompany.focus();
}
function SameAsBilling(Form) {
	if (Form.Bsameas.checked == true) {
		Form.x_first_name.value = Form.FirstName.value;
		Form.x_last_name.value = Form.LastName.value;
		Form.x_address.value = Form.Address.value;
		Form.x_city.value = Form.City.value;
		Form.x_state.value = Form.State.value;
		Form.x_zip.value = Form.Zip.value;
	}else if (Form.Bsameas.checked == false) {
		Form.x_first_name.value = '';
		Form.x_last_name.value = '';
		Form.x_address.value = '';
		Form.x_city.value = '';
		Form.x_state.value = '';
		Form.x_state.options[0].selected = true;
		Form.x_zip.value = '';
	}
	Form.x_first_name.focus();
}

function clearbox(f) {
	var alreadychk = ''; chkname = new Array(); x=0;
	for (xx=0; xx < f.elements.length; xx++){
		 if (f.elements[xx].type == 'checkbox' && 
			 f.elements[xx].checked == true) {
			 chkname[x] = f.elements[xx].name;
			 ++x;
		}
	}
	for (xx=0; xx < chkname.length; xx++){
		 if (chkname[xx] == alreadychk) { 
	 		alert('Please Check Change -or- Delete');
			return false;	
		 } else alreadychk = chkname[xx];
	}
	return true;
}

var PrevWin = null;
function sendForm(f, action, target, page) {

	if (page) document.officeForm.page.value = page; 

	if (target != '_self') {
		PrevWin = open(action,target,'width=800,height=400,left=10,top=10,status=0,scrollbar=no,location=no,toolbar=no,resizable=no,directories=no');
		if (PrevWin && !PrevWin.closed) PrevWin.focus();
	}
	if (action) f.action = action;
	if (target) f.target = target;
	return true;
}
function deleteForm(f, action, target, page) {

	if (page == 'PlayerUpdate') {
		if(f.rType1.selectedIndex == 0) {
			alert('Please Select A Player Type'); 
			f.rType1.focus(); 
			return false;
		}
		if(f.rType1.selectedIndex == 3 && f.Captain.selectedIndex == 0) {
			alert('Please Select A Registered Captain Name For This Team Player'); 
			f.Captain.focus(); 
			return false;
		}
	}
	if (page == 'TeamsUpdate') {
		for (xx=0; xx < f.elements.length; xx++){
			var fieldname = f.elements[xx].name;
			fieldname = fieldname.substring(0, fieldname.length - 1);
			 if (f.elements[xx].type == 'checkbox' && 
				 f.elements[xx].checked == true &&
				 fieldname == 'rType') {
				 f.elements[xx].value = 'Captain';
			}
		}
	}
	
	if (page == 'TeamDelete' || page == 'PlayerDelete' || page == 'SponsorDelete') {
		var answer = confirm("Are You Sure You Want To Change/Delete This Item?")
		if (answer){
			for (xx=0; xx < f.elements.length; xx++){
				 if (f.elements[xx].type == 'checkbox' && 
					 f.elements[xx].checked == true &&
					 (f.elements[xx].value == 'ChangeCaptain' ||
					 f.elements[xx].value == 'DeleteCaptain')) {
						var captain = confirm("This Player Is A Captain. You Must Change/Delete All Players Under The Captain Before Continuing!")
						if (captain) var Continue;
						else {
							alert("Change Canceled!")
							return false;
						}
				 }
			}
		} else {
			alert("Delete Canceled!")
			return false;
		}
	}

	if (page) action = action + "?page=" + page; 

	if (target != '_self') {
		PrevWin = open(action,target,'width=800,height=400,left=10,top=10,status=0,scrollbar=no,location=no,toolbar=no,resizable=no,directories=no');
		if (PrevWin && !PrevWin.closed) PrevWin.focus();
	}
	if (action) f.action = action;
	if (target) f.target = target;
	return true;
}

function teampop(filename,Ht,Wd)
{

	if (document.FormName.Captain.options[0].selected == false && document.FormName.Teams.options[0].selected == false) {
		filename = filename + "?s=a&c=" + document.FormName.Captain.value + "&t=" + document.FormName.Teams.value;
		window.open(filename,"","height=" + Ht + ",width=" + Wd + ",status=no,toolbar=no,directories=no,menubar=no,location=no,resizable=no,scrollbars=yes, left=50,top=50");
	} else if (document.FormName.Teams.options[0].selected == true && document.FormName.Captain.options[0].selected == false) {
			alert('Players Can Be Listed Under A Specific Captain By Simply Selecting A Player Name From Individual Player List');
			filename = filename + "?s=l&t=&c=" + document.FormName.Captain.value;
			window.open(filename,"","height=" + Ht + ",width=" + Wd + ",status=no,toolbar=no,directories=no,menubar=no,location=no,resizable=no,scrollbars=yes, left=50,top=50");
	} else if (document.FormName.Teams.options[0].selected == false && document.FormName.Captain.options[0].selected == true) { 
			alert('Now Select A Captain You Would Like To Be Assigned To Play Under!');
	}
}
function winpop(filename,Ht,Wd)
{
	filename = filename + "?s=c&t=" + document.FormName.CompanyName.value;
	window.open(filename,"","height=" + Ht + ",width=" + Wd + ",status=no,toolbar=no,directories=no,menubar=no,location=no,resizable=no,scrollbars=yes, left=50,top=50");
}
function popUp(filename,Ht,Wd)
{
	window.open(filename,"","height=" + Ht + ",width=" + Wd + ",status=no,toolbar=no,directories=no,menubar=no,location=no,resizable=no,scrollbars=yes, left=50,top=50");
}



