/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
*
*	© 2000-2002 Steve Mapúa
*	All Rights Reserved
*	Steve.Mapua@GlobalTelesis.com
*
*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
function GetSelectedOption(MyForm)
{
	for(var i = 0;i < 3; i++)
	{
		if(MyForm.goto_page[i].checked)
		{
			MyForm.OriginatingOption.value = i;
			break;
		}
	}
}
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function GetSelectedOptionEx(MyForm)
{
	for(var i = 0;i < 3; i++)
	{
		if(MyForm.goto_page[i].checked)
		{
			MyForm.OriginatingOption.value = i;
			break;
		}
	}
	if(MyForm.hid_button_state.value == 1)
		MyForm.hid_semaphor.value = 1;
}
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function ValidateSearchForm(MyForm)
{
	with(MyForm)
	{
		if(Email.value.length > 0)
		{
			var szTest   = new String(Email.value);
			var szDomain = new String();
			var nAtPos   = new Number();
			var nDotPos  = new Number();

			//yourname@yourdomain.com
			nAtPos  = 0;
			nDotPos = 0;

			nAtPos  = szTest.indexOf("@");
			if(nAtPos > 1)
			{
				nDotPos = szTest.indexOf(".",nAtPos);
				if(nDotPos > 1)
				{
					szDomain = szTest.substr(nDotPos + 1);

					if(szDomain.length)
					{
						hid_Email.value = Email.value;
						MyForm.submit();
						return true
					}
				}
			}
		};

		alert('Please enter a valid email address');
		Email.focus();

	}
	return false;
}
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function ValidateForm(MyForm)
{
	var szTest = new String();
	var szSubTest = new String();
	var szErrMsg = new String();
	var nCnt = new Number();
	var bFocusSet = new Boolean();

	nCnt      = 1;
	bFocusSet = false;
	szTest    = "";
	szSubTest = "";
	szErrMsg  = "";

	with(MyForm)
	{
		szTest = name_first.value;
		if(!szTest.length)
		{
			szErrMsg = nCnt + ". First Name\n";
			bFocusSet = true;
			name_first.focus();
			nCnt++
		}

		szTest = name_middle.value;

		szTest = name_last.value;
		if(!szTest.length)
		{
			szErrMsg += nCnt + ". Last Name\n";
			if(!bFocusSet)
			{
				bFocusSet = true;
				name_last.focus();
			}
			nCnt++
		}

		szTest = Address1.value;
		if(szTest.length)
		{
			szTest = City.value;
			if(!szTest.length)
			{
				szErrMsg += nCnt + ". Your City\n";
				if(!bFocusSet)
				{
					bFocusSet = true;
					City.focus();
				}
				nCnt++
			}
			szTest = State.value;
			if(!szTest.length)
			{
				szErrMsg += nCnt + ". Your State\n";
				if(!bFocusSet)
				{
					bFocusSet = true;
					State.focus();
				}
				nCnt++
			}

			szTest = Zip.value;
			if(!szTest.length)
			{
				szErrMsg += nCnt + ". Your Postal Code\n";
				if(!bFocusSet)
				{
					bFocusSet = true;
					Zip.focus();
				}
				nCnt++
			}

			szTest = Country.value;
			if(!szTest.length)
			{
				szErrMsg += nCnt + ". Your Country\n";
				if(!bFocusSet)
				{
					bFocusSet = true;
					Country.focus();
				}
				nCnt++
			}
		}

		szSubTest = DayAreaCode.value;
		szTest = DayPhone.value;
		if(szTest.length && !szSubTest.length)
		{
			szErrMsg += nCnt + ". Day Phone Area Code\n";
			if(!bFocusSet)
			{
				bFocusSet = true;
				DayAreaCode.focus();
			}
			nCnt++
		}

		szSubTest = NiteAreaCode.value;
		szTest = NitePhone.value;
		if(szTest.length && !szSubTest.length)
		{
			szErrMsg += nCnt + ". Night Phone Area Code\n";
			if(!bFocusSet)
			{
				bFocusSet = true;
				NiteAreaCode.focus();
			}
			nCnt++
		}

		szTest = EMail.value;
		if(!szTest.length)
		{
			szErrMsg += nCnt + ". Email Address\n";
			if(!bFocusSet)
			{
				bFocusSet = true;
				EMail.focus();
			}
			nCnt++
		}

		if(nCnt > 1)
		{
			alert("Please fill out the following:\n\n" + szErrMsg);
			return false;
		}
	}

	return true;

}
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
