function NumbersOnly(str){var checkNum = "0123456789";var retStr = "";for(i=0; i < str.length; i++){ch = str.charAt(i);for(j=0; j < checkNum.length; j++){if(ch == checkNum.charAt(j)){retStr = retStr + ch; break;}}}return (retStr);}
function SelectByValue(lst, v){var MyIndex = -1;for(var i=0;i<lst.options.length;i++){if(lst.options[i].value == v){lst.selectedIndex = i;break;}}}

function frmRegister_Reset(){
	var theForm = document.frmRegister;
	for ( var i = 0 ; i < theForm.elements.length ; i ++ ){
		e = theForm.elements[i];
		if( e.className == 'FormError' )
			SetColor( e );
	}
	theForm.cmbState.options.length = 1;
	theForm.cmbState.options[0].value = 'B';
	theForm.cmbState.options[0].text = 'Select Country';
}

function frmRegister_OnSubmit(){
	var theForm = document.frmRegister;
	var b_Bad = false;
	var sMsg = '';
	if( theForm.txtPhone.value != '' ) {
		theForm.txtPhone.value = NumbersOnly( theForm.txtPhone.value );
	}
	if( theForm.txtExt.value != '' ) {
		theForm.txtExt.value = NumbersOnly( theForm.txtExt.value );
	}
	if( theForm.txtFax.value != '' ) {
		theForm.txtFax.value = NumbersOnly( theForm.txtFax.value );
	}
	if( theForm.txtZip.value != '' ) {
		theForm.txtZip.value = NumbersOnly( theForm.txtZip.value );
	}
	if( theForm.txtFName.value == '' ) {
		sMsg += 'Please enter your First Name.\n';
		SetColor( theForm.txtFName, 'FormError' );
	} else if( theForm.txtFName.value.length > 60 ) {
		sMsg += 'The First Name field can only be up to 60 characters.\n';
		SetColor( theForm.txtFName, 'FormError' );
	} else {
		SetColor( theForm.txtFName );
	}
	if( theForm.txtLName.value == '' ) {
		sMsg += 'Please enter your Last Name.\n';
		SetColor( theForm.txtLName, 'FormError' );
	} else if( theForm.txtLName.value.length > 60 ) {
		sMsg += 'The Last Name field can only be up to 30 characters.\n';
		SetColor( theForm.txtLName, 'FormError' );
	} else {
		SetColor( theForm.txtLName );
	}

	if( theForm.txtEMail.value == '' ) {
		sMsg += 'Please enter your E-Mail Address.\n';
		SetColor( theForm.txtEMail, 'FormError' );
	} else if( theForm.txtEMail.value.length > 256 ) {
		sMsg += 'The E-Mail Address field can only be up to 256 characters.\n';
		SetColor( theForm.txtEMail, 'FormError' );
	} else {
		if( theForm.txtEMail.value != theForm.txtEMailConf.value ) {
			sMsg += 'Your E-Mail addresses do not match.\n';
			SetColor( theForm.txtEMail, 'FormError' );
			SetColor( theForm.txtEMailConf, 'FormError' );
		} else if( theForm.txtEMail.value.length > 256 ) {
			sMsg += 'The E-Mail Address field can only be up to 256 characters.\n';
			SetColor( theForm.txtEMail, 'FormError' );
			SetColor( theForm.txtEMailConf, 'FormError' );
		} else {
			SetColor( theForm.txtEMail );
			SetColor( theForm.txtEMailConf );
		}
	}

	if( theForm.txtPass.value == '' ) {
		sMsg += 'Please enter a desired Password.\n';
		SetColor( theForm.txtPass, 'FormError' );
	} else {
		if( theForm.txtPass.value != theForm.txtPassConf.value ) {
			sMsg += 'Your desired Passwords do not match.\n';
			SetColor( theForm.txtPass, 'FormError' );
			SetColor( theForm.txtPassConf, 'FormError' );
		} else {
			SetColor( theForm.txtPass );
			SetColor( theForm.txtPassConf );
		}
	}


	if( theForm.txtTitle.value == '' ) {
		sMsg += 'Please enter your Title.\n';
		SetColor( theForm.txtTitle, 'FormError' );
	} else if( theForm.txtTitle.value.length > 60 ) {
		sMsg += 'The E-Mail Address field can only be up to 60 characters.\n';
		SetColor( theForm.txtTitle, 'FormError' );
	} else {
		SetColor( theForm.txtTitle );
	}
	if( theForm.txtCompany.value == '' ) {
		sMsg += 'Please enter your Company\'s Name.\n';
		SetColor( theForm.txtCompany, 'FormError' );
	} else if( theForm.txtCompany.value.length > 100 ) {
		sMsg += 'The Company field can only be up to 100 characters.\n';
		SetColor( theForm.txtCompany, 'FormError' );
	} else {
		SetColor( theForm.txtCompany );
	}
	if( theForm.cmbJobFunction.selectedIndex <= 0 ) {
		sMsg += 'Please select a Company Type.\n';
		SetColor( theForm.cmbJobFunction, 'FormError' );
	} else {
		SetColor( theForm.cmbJobFunction );
	}
	if( theForm.cmbMarketSegment.selectedIndex <= 0 ) {
		sMsg += 'Please select a Market Segment.\n';
		SetColor( theForm.cmbMarketSegment, 'FormError' );
	} else {
		SetColor( theForm.cmbMarketSegment );
	}
	if( theForm.txtPhone.value.length > 30 ) {
		sMsg += 'The Phone Number field can only be up to 30 characters.\n';
		SetColor( theForm.txtPhone, 'FormError' );
	}
	if( theForm.txtFax.value.length > 30 ) {
		sMsg += 'The Fax Number field can only be up to 30 characters.\n';
		SetColor( theForm.txtFax, 'FormError' );
	}
	if( theForm.txtWeb.value.length > 512 ) {
		sMsg += 'The Website field can only be up to 512 characters.\n';
		SetColor( theForm.txtWeb, 'FormError' );
	}
	if( theForm.txtAddress1.value == '' ) {
		sMsg += 'Please enter your Address.\n';
		SetColor( theForm.txtAddress1, 'FormError' );
	} else if( theForm.txtAddress1.value.length > 100 ) {
		sMsg += 'The Address field can only be up to 100 characters.\n';
		SetColor( theForm.txtAddress1, 'FormError' );
	} else {
		SetColor( theForm.txtAddress1 );
	}
	if( theForm.txtAddress2.value.length > 512 ) {
		sMsg += 'The Second Address field can only be up to 512 characters.\n';
		SetColor( theForm.txtAddress2, 'FormError' );
	}
	if( theForm.txtCity.value == '' ) {
		sMsg += 'Please enter your City.\n';
		SetColor( theForm.txtCity, 'FormError' );
	} else if( theForm.txtCity.value.length > 60 ) {
		sMsg += 'The City field can only be up to 60 characters.\n';
		SetColor( theForm.txtCity, 'FormError' );
	} else {
		SetColor( theForm.txtCity );
	}
	if( theForm.cmbCountry.selectedIndex <= 0 ) {
		sMsg += 'Please select a Country.\n';
		SetColor( theForm.cmbCountry, 'FormError' );
	} else {
		SetColor( theForm.cmbCountry );
	}
	if( theForm.cmbState.options[theForm.cmbState.selectedIndex].value == 'B' ) {
		sMsg += 'Please select a State.\n';
		SetColor( theForm.cmbState, 'FormError' );
	} else {
		SetColor( theForm.cmbState );
	}
	if( theForm.txtZip.value.length > 20 ) {
		sMsg += 'The Zip Code field can only be up to 20 characters.\n';
		SetColor( theForm.txtZip, 'FormError' );
	}
	if( sMsg != '' ){
		alert('Please fix the following problems:\n\n' + sMsg);
		return (false);
	}
	return true;
}

function frmLogin_OnSubmit(){
	var theForm = document.frmLogin;
	var sMsg = '';
	if( theForm.txtEMail.value == '' ) {
		sMsg += 'Please enter your E-Mail Address.\n';
		SetColor( theForm.txtEMail, 'FormError' );
	} else {
		SetColor( theForm.txtEMail );
	}	
	if( theForm.txtPass.value == '' ) {
		sMsg += 'Please enter your Password.\n';
		SetColor( theForm.txtPass, 'FormError' );
	} else {
		SetColor( theForm.txtPass );
	}	
	if( sMsg != '' ){
		alert('Please fix the following problems:\n\n' + sMsg);
		return false;
	}
	return true;
}

var eStyle
function SetColor( e, sStyle ) {
	if( sStyle != null ){
		e.className = sStyle;
	} else {
		e.className = '';
	}
}