<!--
flag=1;
var noexitad;
var shasha;
	
if ('' != "")   /* noexitad will almost always be set to 0 */
	noexitad = 1;
else
	noexitad = 0;

/*********** this is onUnload and opens the new window ************************/
function go() 
{
// there isn't anything here...
}

function Verify(strField)
{
	if (!strField.checked)
		{
		alert("Please read the disclaimer and check the box to continue!");
		strField.focus();
		return false;
		}
	return true;
}
	
function Join() 
{
	//document.frmOrder.boxNoRunaround.value = 2;
	/* window.location.href = "Affiliate/SignUp.asp?ac=<%=tempAffiliateID%>" */
	window.open("Affiliate/SignUp.asp?ac=1239","SignUP");
}

function CheckZipCode(strZipCode,strCountry)
{
	if( strCountry.value == "US" )
	{
		if( CheckRegularExpression(document.frmOrder.boxZip,/(^\d{5}$)|(^\d{5}-\d{4}$)/,"Zip code is invalid.") == false )
			return false;
	}
	else if( strCountry.value == "CA"  )
	{
		if( CheckRegularExpression(document.frmOrder.boxZip,/[a-zA-Z]\d[a-zA-Z] \d[a-zA-Z]\d$/,"Postal Code is invalid. ex: X0X 0X0") == false )
			return false;
	}
	else if( strCountry.value == "UK"  )
	{
		if( CheckRegularExpression(document.frmOrder.boxZip,/[A-Z]{1,2}\d[A-Z\d]? \d[ABD-HJLNP-UW-Z]{2}$/,"Zip code is invalid.") == false )
			return false;
	}
	return true;
}

function ValidDatePhone(intAreaCode,intExchange,intPNumber,intPhone,strPhoneField)
{
	if( (strPhoneField == "1") || (strPhoneField == "2" && intAreaCode.value != "") ) 
	{
		var strAreaCode = new String(intAreaCode.value)
		if( CheckRegularExpression(intAreaCode,/\d{3}$/,"Phone number is invalid.") &&
			CheckRegularExpression(intExchange,/\d{3}$/,"Phone number is invalid.") &&
			CheckRegularExpression(intPNumber,/\d{4}$/,"Phone number is invalid.") &&
			CheckForRepeatingChar(intAreaCode,"Area Code is invalid."))
		{
			if( strAreaCode.charAt(0) != "0" && strAreaCode.charAt(0) != "1" && 
				intExchange.value != "000" && intExchange.value != "111" && 
				intExchange.value != "555" )
			{
				intPhone.value = intAreaCode.value + '-' + intExchange.value + '-' + intPNumber.value;
			}
			else
			{
				alert("Phone number is invalid.");
				intAreaCode.focus();
				return false;
			}
		}
		else
		{
			return false;
		}
	}
	return true;
}

function CheckSameness(strField1,strField2,strMessage)
{
	if(strField1.value != strField2.value)
	{
		alert(strMessage);
		strField1.focus();
		return false;
	}
	return true;
}
	
function CheckForRepeatingChar(strField,strMessage)
{
	var strText = new String(strField.value);
	var strTemp = new String();
	var intTimesEqual = 0;
	var blnValid = true;
	//Check for character repeating more then 2 times
	for(var x=0; x < strText.length && blnValid; ++x)
	{
		if(strText.charAt(x) == strTemp)
		{
			++intTimesEqual;
		}
		else
		{
			strTemp = strText.charAt(x);
			intTimesEqual = 1;
		}
		if(intTimesEqual > 2)
			blnValid = false;
	}
	
	if (!blnValid)
	{
		alert(strMessage);
		strField.focus();
		return false;
	}
	return true;
}

function CheckForPatterns(strField,strMessage)
{
	var strText = new String(strField.value);
	var strTemp = new String();
	var intTimesEqual = 0;
	var blnValid = true;
	
	//Check for character repeating more then 2 times
	for(var x=0; x < strText.length && blnValid; ++x)
	{
		if(strText.charAt(x) == strTemp)
		{
			++intTimesEqual;
		}
		else
		{
			strTemp = strText.charAt(x);
			intTimesEqual = 1;
		}
		if(intTimesEqual > 2)
			blnValid = false;
	}
		
	strTemp = "";
	intTimesEqual = 0;
	//Check for pattern repeating more then 1 time
	for(var z=0; z < strText.length && blnValid; ++z)
	{
		for(var x=z; x < strText.length && blnValid; ++x)
		{
			if(strText.charAt(x) == strTemp.charAt(0) && 1 < strTemp.length)
			{
				for(var i=0; i < strTemp.length && blnValid;++i)
				{
					if(strTemp.charAt(i) == strText.charAt(x + i))
						++intTimesEqual;
					else
					{
						intTimesEqual = 0;
						i = strTemp.length + 1;
						strTemp = "";
					}
				}
				//found a matching pattern if intTimesEqual is greater then 0
				if(intTimesEqual > 1)
					blnValid = false;
			}
			else
			{
				strTemp = strTemp.concat(strText.charAt(x));
				intTimesEqual = 0;
			}
		}
		strTemp = "";
		intTimesEqual = 0;
	}
		
	if (!blnValid)
	{
		alert(strMessage);
		strField.focus();
		return false;
	}
	return true;
}

function CheckRegularExpression(strField,Pattern,strMessage)
{
  //alert("Checking: "+strField.name + " : " + strField.value);
	if(navigator.userAgent.indexOf('Mac') > 0)
	{
		if(strField.value == "")
		{
			alert(strMessage);
			strField.focus();
			return false;
		}
	}
	else
	{
		var re = new RegExp(Pattern);

		if(!re.test(trim(strField.value)))
		{
			alert(strMessage);
			strField.focus();
			return false;
		}
	}
	return true;
}

function checkFilledIn(strField, strMessage)
  {
  alert("Checking Filled In"); 
  compField = trim(strField.value);
  if (compField == "")
    {
    alert(strMessage);
		strField.focus();
		return false;
    }
  return true;
  } // end function

function trim(strText)
{ 
    // this will get rid of leading spaces 
    while (strText.substring(0,1) == ' ') 
        strText = strText.substring(1, strText.length);

    // this will get rid of trailing spaces 
    while (strText.substring(strText.length-1,strText.length) == ' ')
        strText = strText.substring(0, strText.length-1);

   return strText;
}

function CheckGender()
{
	if(!document.frmOrder.rGender[0].checked && !document.frmOrder.rGender[1].checked)
	{
		alert("Please select gender.");
		document.frmOrder.rGender[0].focus();
		return false;
	}
	return true;
}

function CheckDidInPast()
{
	if(!document.frmOrder.selQuestion5[0].checked && !document.frmOrder.selQuestion5[1].checked)
	{
		alert("Question 5 is required.");
		document.frmOrder.selQuestion5[0].focus();
		return false;
	}
	return true;
}

function CheckHasDebt()
{
	if(!document.frmOrder.selQuestion6[0].checked && !document.frmOrder.selQuestion6[1].checked)
	{
		alert("Question 6 is required.");
		document.frmOrder.selQuestion6[0].focus();
		return false;
	}
	return true;
}

function CheckTime(bypasscheck) 
{
	if(bypasscheck != 'y')
	{
		/* Grab Client Time */
		var ct = new Date();
		var tCheck = ct.getTimezoneOffset();
		var GoodToGo = 0;
		if ((tCheck <= 600) && (tCheck >= 120)) 
		{
			GoodToGo = 1;
		}
		if (eval(GoodToGo) == 0) 
		{
			// parent.location='Sorry.asp';
		}
		return true;
	}
}
	
function JumpBox(tempMaxLength,e,tempCurrBox,tempNextBox) 
{
	var tempCurrValueLength = tempCurrBox.value;
	tempCurrValueLength = tempCurrValueLength.length;
	var charCode = e.keyCode
	if ((eval(charCode) != 9) && (eval(charCode) != 16)) 
	{
		if (tempCurrValueLength >= eval(tempMaxLength)) 
		{
			if (isNaN(tempCurrBox.value)) 
			{
				alert("Please enter a valid number.");
				tempCurrBox.value = "";
				document.frmOrder.hidCurrentLength.value = 1;
				tempCurrBox.focus();
			}
			else 
			{
				tempNextBox.focus();
			}
			document.frmOrder.hidCurrentLength.value = 1;
		}
		else 
		{
			document.frmOrder.hidCurrentLength.value = tempCurrValueLength;
		}
	}
	return true;
}
//-->

