<!--
function submitLogin(strAction)
	{
	var strActionDesc, strNewURL, strURL;
	
	strURL = document.frmLogin.URL.value;
	
	switch(strAction)
		{
		case "LOGIN":
			strActionDesc = L_LOGIN;
			strNewURL = strURL;
			break;
		case "EDIT":
			strActionDesc = cstMyPreferences;
			
			//CHANGE URL TO EDIT PROFILE PAGE
			
			strNewURL = "/_mem_bin/membership/mypreferences.asp?jump=Profile&dest=" + escape(strURL);
			break;
		}
	
	if(loginFormValid())
		{
		document.frmLogin.URL.value = strNewURL;
		document.frmLogin.submit();
		}
	else
		{
		alert(L_PLEASESUPPLY + " " + strActionDesc + ".");
		}
	}
	
function loginFormValid()
	{
	//Verify E-mail and password are not blank
	if(trim(document.frmLogin.username.value) == "")
		{
		return false;
		}
	else if(trim(document.frmLogin.password.value) == "")
		{
		return false;
		}
		
	return true;
	}
	
function MembershipSubmit()
{		
    LogRegistrationClickToWebTrends();

	if(IsEmailFormValid(document.frmRegister) && AnsweredForCustomerQuestion())
	{
		document.frmRegister.cmdGo.disabled = true;
		document.body.style.cursor = "wait";
		if(document.frmRegister.txtDo.value == "FORCED")
		{
			exitWithSuccess = true;
		}	
		
		if (document.frmRegister.txtDo.value == "VOL")
		{
			loadCode("/_mem_bin/registration/regconfirmspotlightpg.asp");
			setTimeout("document.frmRegister.submit()", 100);
		}
		else
		{
			document.frmRegister.submit();
		}
	}
}

//////////////////////////////////////////////////////////
//LogRegistrationClickToWebTrends()
//13MAY2011 - C0007781 - PR09922 - Webtrends new reports
//Called from function MembershipSubmit()
//////////////////////////////////////////////////////////
function LogRegistrationClickToWebTrends()
{
      dcsMultiTrack("DCS.dcsuri", "/REGISTER");
      dcsMultiTrack("DCS.action", "REGISTER");
      dcsTagAut();
}


function AnsweredForCustomerQuestion()
{
	if(document.frmRegister.txtDo.value == "PREMIER" || (document.frmRegister.txtDo.value == "VOL" && document.frmRegister.chkPremier.checked))
	{
		if(document.frmRegister.rdoYes.checked || document.frmRegister.rdoNo.checked)
		{
			return true;
		}
		else
		{
			//Alert Error Message
			alert(cstCustomerQuestionReq);
			return false;
		}
	}
	else
	{
		return true;
	}
}

function ValidateMembershipSubmit(event)
{
	if(!IsEmailFormValid(document.frmRegister) || !AnsweredForCustomerQuestion())
	{
	event.returnValue = false;
	}
	else
	{
		if(document.frmRegister.txtDo.value == "FORCED")
		{
			exitWithSuccess = true;
		}	
	}
}

//Should be obsolete after Convert Anonymous...
function SubmitRegistration()
	{
	if (trim(document.frmRegister.txtEmail.value) == "")
		{
		alert(L_EMAIL + " " + L_ISREQUIRED);
		document.frmRegister.txtEmail.focus();
		return false;
		}
		
	if (!emailCheck(trim(document.frmRegister.txtEmail.value)))
		{
		document.frmRegister.txtEmail.focus();
		return false;
		}
		
	if(trim(document.frmRegister.txtEmail.value) != trim(document.frmRegister.txtEmailConfirm.value))
		{
		alert(M_EMAILNOTCONFIRMED);
		document.frmRegister.txtEmailConfirm.focus();
		return false;
		}
		
	if (!passwordValid(trim(document.frmRegister.txtPass.value), trim(document.frmRegister.txtPassConfirm.value)))
		{
		return false;
		}
		
	if (trim(document.frmRegister.txtFirstNme.value) == "")
		{
		document.frmRegister.txtFirstNme.focus();
		alert(L_FIRSTNME + " " + L_ISREQUIRED);;
		return false;
		}
		
	if (trim(document.frmRegister.txtLastNme.value) == "")
		{
		document.frmRegister.txtLastNme.focus();
		alert(L_LASTNME + " " + L_ISREQUIRED);
		return false;
		}
		
	if (trim(document.frmRegister.txtCompany.value) == "")
		{
		document.frmRegister.txtCompany.focus();
		alert(L_COMPANY + " " + L_ISREQUIRED);
		return false;
		}
		
	if (document.frmRegister.cboCtry[document.frmRegister.cboCtry.selectedIndex].value == "USA" || document.frmRegister.cboCtry[document.frmRegister.cboCtry.selectedIndex].value == "CAN")
		{
		if (trim(document.frmRegister.txtState.value) == "")
			{
			document.frmRegister.cboState.focus();
			alert(L_STATE + " " + L_ISREQUIRED + " " + L_REGSTATEVALIDATION);
			return false;
			}
		}
		
	if (trim(document.frmRegister.txtPhone.value) == "")
		{
		document.frmRegister.txtPhone.focus();
		alert(L_PHONE + " " + L_ISREQUIRED);
		return false;
		}
		
	//If got this far, then valid.  Submit Form.
	//ONLY DO IF DO=REGISTER
	if (document.frmRegister.txtDo.value == "REGISTER")
		{
		loadCode("regconfirmspotlightpg.asp");
		setTimeout("document.frmRegister.submit()", 500);
		}
	else
		{
		document.frmRegister.submit();
		}
	}
	
function loadCode(src)
	{
	if (document.getElementById)
		{
		document.getElementById('myFrame').src = src;
		}
	else if(document.all)
		{
		document.frames['myFrame'].src = src;
		}
	else if(document.layers)
		{
		document.myLayer.load(src,0);
		}
	}
	
function passwordValidHandlesMyPref(strPass, strPassConfirm, strDo)
	{

	if (strPass == "")
		{
		if(strDo == "MYPREFPREMIER" || strDo == "MYPREF") MyPrefValidationFixTabs(strDo, "TOP");
		alert(L_PWDSELFASSIGNED + " " + L_ISREQUIRED);
		document.frmRegister.txtPass.focus();
		return false;
		}
			
	if (strPass != strPassConfirm)
		{
		if(strDo == "MYPREFPREMIER" || strDo == "MYPREF") MyPrefValidationFixTabs(strDo, "TOP");
		alert(M_PWDNOTCONFIRMED);
		document.frmRegister.txtPassConfirm.focus();
		return false;
		}

	if (strPass.length < 6)
		{
		if(strDo == "MYPREFPREMIER" || strDo == "MYPREF") MyPrefValidationFixTabs(strDo, "TOP");
		alert(M_PWDLENGTHNOTVALID);
		document.frmRegister.txtPass.focus();
		return false;
		}

	//Requires number in password
	if (strPass.match(/^(.*)\d(.*)$/) == null)
		{
		alert(cstPwdMustContainNumber);
		return false;
		}
		
	return true;
	}

function passwordValid(strPass, strPassConfirm)
	{

	if (strPass == "")
		{
		alert(L_PWDSELFASSIGNED + " " + L_ISREQUIRED);
		document.frmRegister.txtPass.focus();
		return false;
		}
			
	if (strPass != strPassConfirm)
		{
		alert(M_PWDNOTCONFIRMED);
		document.frmRegister.txtPassConfirm.focus();
		return false;
		}

	if (strPass.length < 6)
		{
		alert(M_PWDLENGTHNOTVALID);
		document.frmRegister.txtPass.focus();
		return false;
		}

	if (strPass.match(/^(.*)\d(.*)$/) == null)
		{
		alert(cstPwdMustContainNumber);
		return false;
		}
		
	return true;
	}
	
function IsEmailFormValid(form)
{
	if(trim(form.txtEmail.value) == "")
	{
		alert(L_EMAIL + " " + L_ISREQUIRED);
		form.txtEmail.focus();
		return false;
	}
		
	if (!emailCheck(trim(form.txtEmail.value)))
	{
		form.txtEmail.focus();
		return false;
	}
	
	return true;
}
	
//Used to check if user clicked enter
var NS4;
NS4 = (document.layers) ? true : false;
function checkEnter(event)
{ 	
		
	if (IsEnterKey(event))
		{
		submitLogin("LOGIN");
		}
}

function filterCountryByState()
	{
	var ctry, state_value;
	
	try {  // an error may occur if the fields are hidden
		setPhoneCode();
		ctry = document.frmRegister.cboCtry[document.frmRegister.cboCtry.selectedIndex].value;
		
		FilterCountryState(document.frmRegister.cboState, ctry);
		
		state_value = document.frmRegister.txtStateCde.value;
		
		setStateDDValue(state_value);

		if (document.frmRegister.cboState.selectedIndex < 0)
			{
			document.frmRegister.cboState.selectedIndex = 0;
			document.frmRegister.txtState.value = "";
			document.frmRegister.txtStateCde.value = "";
			}
		}
		catch(er)
		{
		
		}
	}

	
function stateOnChange()
	{
	var state_dd;
	
	state_dd = document.frmRegister.cboState;
	
	if (state_dd.selectedIndex < 1)
		{
		document.frmRegister.txtState.value = "";
		document.frmRegister.txtStateCde.value = "";
		}
	else
		{
		document.frmRegister.txtStateCde.value = state_dd[state_dd.selectedIndex].value;
		document.frmRegister.txtState.value = state_dd[state_dd.selectedIndex].text;
		}
	}
	
function countryChanged()
	{
	document.frmRegister.txtState.value = "";
	document.frmRegister.txtStateCde.value = "";
		
	filterCountryByState();
	}
	
function setPhoneCode()
{
	var phonePrefix, faxPrefix;
	var i, ctry, found;
	
	found = false;
	
	phonePrefix = document.getElementById("PhoneSpan");
	faxPrefix = document.getElementById("FaxSpan");

	ctry = document.frmRegister.cboCtry[document.frmRegister.cboCtry.selectedIndex].value;
	
	for(i=0;i<arrProtocol.length;i++)
	{
		if(ctry == arrProtocol[i][0])
		{
			phonePrefix.innerText = "+" + arrProtocol[i][1];
			faxPrefix.innerText = "+" + arrProtocol[i][1];
			found = true;
			break;
		}
	}
	
	if(!found)
	{
		phonePrefix.innerText = "";
		faxPrefix.innerText = "";
	}
}
	
function SetDropDownValue(dropDown, value)
{
	var i, blnFound;
	
	blnFound = false;
	
	for(i=0;i<dropDown.length - 1;i++)
	{
		if(dropDown[i].value == value)
		{
			dropDown.selectedIndex = i;
			blnFound = true;
			break;
		}
	}
	
	if(!blnFound)
	{
		dropDown.selectedIndex = 0;
	}
}
	
function setStateDDValue(strValue)
{
	SetDropDownValue(document.frmRegister.cboState, strValue);
}
	
function FilterCountryState(dd_field, filter_by)
	{
	var dd_field, data_array
	var new_option, i;
	var match_found, last_cde;
	
	try
	{
		data_array = cs;
	}
	catch(er)
	{
		data_array = ncs;
	}
	
	match_found = false;
	last_cde = "";

	//Remove any values in the drop down
	for (i=dd_field.options.length - 1; i >= 0; i--)
			{
			dd_field.options[i] = null;
			}
	
	for(i=0;i<data_array.length;i++)
		{
		if (data_array[i][0] == filter_by)
			{
			//Added if (below comment) to remove duplicates.  
			//Data must be sorted for this to work.
			if (data_array[i][1] != last_cde)
				{
				//If this is the first match, add Select State first
				if(!match_found)
					{
					new_option = new Option("Select State", "");
					dd_field.options[dd_field.length] = new_option;
					}
				match_found = true;
				new_option = new Option(data_array[i][2], data_array[i][1]);
				dd_field.options[dd_field.length] = new_option;
				}
			
			last_cde = data_array[i][1];
			}
		else if (match_found)
			{
			break;
			}
		}
		
	//If never found a match, add a Not Applicable
	if (!match_found)
		{
		new_option = new Option("Not Applicable", "N/A");
		dd_field.options[dd_field.length] = new_option;
		}
	}
	
function CancelPaste()
	{
	event.returnValue = false;
	}
	
function SubmitPreferences(strDo)
{
	var formIsValid;
	
	var buttonClicked;
	
	formIsValid = false;
	
	buttonClicked = document.frmRegister.txtButtonClicked.value;
	
	//Do validation here
	if(strDo == "ALLOWPASS" || strDo == "ALLOWPASSPREMIER")
	{
		formIsValid = true;
		//Company
		if (trim(document.frmRegister.txtCompany.value) == "")
		{
			document.frmRegister.txtCompany.focus();
			alert(L_COMPANY + " " + L_ISREQUIRED);
			formIsValid = false;
		}
	
		//Country
		if (document.frmRegister.cboCtry[document.frmRegister.cboCtry.selectedIndex].value == "")
		{
			document.frmRegister.cboCtry.focus();
			alert(L_COUNTRY + " " + L_ISREQUIRED);
			formIsValid = false;
		}
		
	}
	else
	{
		if((strDo == "MYPREF" && !document.frmRegister.chkProtectMyPreferences.checked) || strDo == "MYPREFSWITCH")
		{
			//REASONS WHY DON'T NEED TO VALIDATE -- i.e explaination of above if stmt
			//strDo=MYPREF: then it is a self registered not premier user
			//self registered only have required fields if they protect their preferences
			//so if they aren't protecting their preferences no validation is needed.
			
			//strDo=MYPREFSWITCH: then a self registered user has decided to protect
			//their preferences.  Again - no need to validate
			
			// Updated Country is now required.
			// NOTE:  Removed Country requirement so wouldn't implement with Ebiz 525
			
			formIsValid = true;	
			
			//Country
		//	if (document.frmRegister.cboCtry[document.frmRegister.cboCtry.selectedIndex].value == "")
		//	{
		//		document.frmRegister.cboCtry.focus();
		//		alert(L_COUNTRY + " " + L_ISREQUIRED);
		//		formIsValid = false;
		//	}
		}
		else
		{
			if(buttonClicked == "UNSUBSCRIBE" || buttonClicked == "UNSUBSCRIBEITEMS")
			{
				//ONLY DO PASSWORD VALIDATION
				strDo = "MYPREF";
			}
			formIsValid = IsFormValid(strDo)
		}
	}
	
	if(formIsValid)
	{
		//The following if statement is added to add a spotlight tag when the validations are successful.
		if (document.frmRegister.txtButtonClicked.value == "SAVE" || document.frmRegister.txtButtonClicked.value == "FINISHED")
		{
			AddPreferencesSpotLightTag();
		}
		document.frmRegister.submit();
		
		if (document.frmRegister.txtButtonClicked.value == "SAVE")
		{
		    alert(cstMyPrefTitle); //Operational Request #536745RM - Finished gets redirected to Confirmation Page
		}
	}
	
}

function ChangeEmailClicked(strDo)
{
	document.frmRegister.txtChangingEmail.value = "yes";
	SubmitPreferences(strDo);
}
	
function SubmitPremierRegistration()
{
	if(IsFormValid("PREMIER"))
	{
		document.frmRegister.submit();
	}
}

function SubmitSetPassword()
{
	if(passwordValid(trim(document.frmRegister.txtPass.value), trim(document.frmRegister.txtPassConfirm.value)))
	{
		document.frmRegister.submit();
	}
}

function MyPrefValidationFixTabs(strDo, strJump)
{
	if(strDo == "MYPREFPREMIER" || strDo == "MYPREF")
	{
		JumpTo(strJump);
	}
}
	
function IsFormValid(strDo)
{
	//All required fields must be filled in
	if(strDo == "PREMIER" || strDo == "MYPREFPREMIER")
	{		
		//Last Name
		if (trim(document.frmRegister.txtLastNme.value) == "")
		{
			if(strDo == "MYPREFPREMIER") MyPrefValidationFixTabs("MYPREFPREMIER", "PROFILE");
			document.frmRegister.txtLastNme.focus();
			alert(L_LASTNME + " " + L_ISREQUIRED);
			return false;
		}
		
		//First Name
		if (trim(document.frmRegister.txtFirstNme.value) == "")
		{
			if(strDo == "MYPREFPREMIER") MyPrefValidationFixTabs("MYPREFPREMIER", "PROFILE");
			document.frmRegister.txtFirstNme.focus();
			alert(L_FIRSTNME + " " + L_ISREQUIRED);;
			return false;
		}
		
		//address me as
		if (document.frmRegister.txtAddressMeAs.value == "")
		{
			if(strDo == "MYPREFPREMIER") MyPrefValidationFixTabs("MYPREFPREMIER", "PROFILE");
			document.frmRegister.txtAddressMeAs.focus();
			alert(cstAddressMeAs + " " + L_ISREQUIRED);
			return false;
		}
		
		//Company
		if (trim(document.frmRegister.txtCompany.value) == "")
		{
			if(strDo == "MYPREFPREMIER" || strDo == "ALLOWPASSPREMIER") MyPrefValidationFixTabs("MYPREFPREMIER", "PROFILE");
			document.frmRegister.txtCompany.focus();
			alert(L_COMPANY + " " + L_ISREQUIRED);
			return false;
		}
	
		//Country
		if (document.frmRegister.cboCtry[document.frmRegister.cboCtry.selectedIndex].value == "")
		{
			if(strDo == "MYPREFPREMIER" || strDo == "ALLOWPASSPREMIER") MyPrefValidationFixTabs("MYPREFPREMIER", "PROFILE");
			document.frmRegister.cboCtry.focus();
			alert(L_COUNTRY + " " + L_ISREQUIRED);
			return false;
		}
		
		
		//my role
		if (document.frmRegister.cboSelfRole[document.frmRegister.cboSelfRole.selectedIndex].value == "")
		{
			if(strDo == "MYPREFPREMIER") MyPrefValidationFixTabs("MYPREFPREMIER", "PROFILE");
			document.frmRegister.cboSelfRole.focus();
			alert(cstMyRole + " " + L_ISREQUIRED);
			return false;
		}
		
		//my relationship
		if (document.frmRegister.cboSelfRelationship[document.frmRegister.cboSelfRelationship.selectedIndex].value == "")
		{
			if(strDo == "MYPREFPREMIER") MyPrefValidationFixTabs("MYPREFPREMIER", "PROFILE");
			document.frmRegister.cboSelfRelationship.focus();
			alert(cstMyRelationship + " " + L_ISREQUIRED);
			return false;
		}
		
		//Phone
		if (trim(document.frmRegister.txtPhone.value) == "")
		{
			if(strDo == "MYPREFPREMIER") MyPrefValidationFixTabs("MYPREFPREMIER", "PROFILE");
			document.frmRegister.txtPhone.focus();
			alert(L_PHONE + " " + L_ISREQUIRED);
			return false;
		}

		//Address
		if (trim(document.frmRegister.txtAddress.value) == "")
		{
			if(strDo == "MYPREFPREMIER") MyPrefValidationFixTabs("MYPREFPREMIER", "PROFILE");
			document.frmRegister.txtAddress.focus();
			alert(L_ADDRESS + " " + L_ISREQUIRED);
			return false;
		}
		
		//City
		if (trim(document.frmRegister.txtCity.value) == "")
		{
			if(strDo == "MYPREFPREMIER") MyPrefValidationFixTabs("MYPREFPREMIER", "PROFILE");
			document.frmRegister.txtCity.focus();
			alert(L_CITY + " " + L_ISREQUIRED);
			return false;
		}
		
		//State if country is USA or CAN
		if (document.frmRegister.cboCtry[document.frmRegister.cboCtry.selectedIndex].value == "USA" || document.frmRegister.cboCtry[document.frmRegister.cboCtry.selectedIndex].value == "CAN")
		{			
			if (trim(document.frmRegister.txtStateCde.value) == "")
			{
				if(strDo == "MYPREFPREMIER") MyPrefValidationFixTabs("MYPREFPREMIER", "PROFILE");
				document.frmRegister.cboState.focus();
				alert(L_STATE + " " + L_ISREQUIRED + " " + L_REGSTATEVALIDATION);
				return false;
			}
		}
	}
	
	//Password
	if (!passwordValidHandlesMyPref(trim(document.frmRegister.txtPass.value), trim(document.frmRegister.txtPassConfirm.value), strDo))
	{
		return false;
	}
		
	if(strDo == "PREMIER")
	{
		//if nothing checked
		if (document.frmRegister.chkServices[0].checked == false && document.frmRegister.chkServices[1].checked == false && 
			document.frmRegister.chkServices[2].checked == false && document.frmRegister.chkServices[3].checked == false &&
			document.frmRegister.chkServices[4].checked == false)
		{
			document.frmRegister.txtOrderInfoNumbers.focus();
			alert(cstREQUIREDFLDSMISSING);
			return false;	
		}
		
		//if order numbers not filled in and order app checked
		if (document.frmRegister.chkServices[0].checked || document.frmRegister.chkServices[1].checked || document.frmRegister.chkServices[3].checked || document.frmRegister.chkServices[4].checked)
		{
			if(trim(document.frmRegister.txtOrderInfoNumbers.value) == "")
			{
				document.frmRegister.txtOrderInfoNumbers.focus();
				alert(cstREQUIREDFLDSMISSING);
				return false;
			}
		}
		
		//if account bal numbers not filled in and acct bal app checked
		if (document.frmRegister.chkServices[2].checked)
		{
			if(trim(document.frmRegister.txtAcctBalNumbers.value) == "")
			{
				document.frmRegister.txtAcctBalNumbers.focus();
				alert(cstREQUIREDFLDSMISSING);
				return false;
			}
		}
		
		//Privacy Agreement
		if (document.frmRegister.PrivacyAgreementChk.checked == false)
		{
			alert(cstPrivacyNotAcceptMsg);
			return false;
		}
	}
	
	return true;
}

function ValidateCountryAndCompany(strDo)
{
		//Company
		if (trim(document.frmRegister.txtCompany.value) == "")
		{
			if(strDo == "MYPREFPREMIER" || strDo == "ALLOWPASSPREMIER") MyPrefValidationFixTabs("MYPREFPREMIER", "PROFILE");
			document.frmRegister.txtCompany.focus();
			alert(L_COMPANY + " " + L_ISREQUIRED);
			return false;
		}
	
		//Country
		if (document.frmRegister.cboCtry[document.frmRegister.cboCtry.selectedIndex].value == "")
		{
			if(strDo == "MYPREFPREMIER" || strDo == "ALLOWPASSPREMIER") MyPrefValidationFixTabs("MYPREFPREMIER", "PROFILE");
			document.frmRegister.cboCtry.focus();
			alert(L_COUNTRY + " " + L_ISREQUIRED);
			return false;
		}
		
	return true;
}

function ReturnToMyPreferences()
{
	location.href = "MyPreferences.asp"
}

function ForcedRegistrationToPremierLogin(strUrl)
{
	exitWithSuccess = true;
	callParent(strUrl, false);
}

function fillAddressMeAs()
{
	if(document.frmRegister.txtAddressMeAs.value == "")
	{
		document.frmRegister.txtAddressMeAs.value = document.frmRegister.txtFirstNme.value;
	}
}
//-->
