// global vars
var literatureRequested = new Array()
var i = 0 

//Trims blank spaces to the left of the value entered
function trimString(formObj){
   var str = formObj.value + "z"
   var ch = ""

   for (var x = 0; x < str.length; x++){
      ch = str.substring(x, x + 1)
      if (ch != " "){
         formObj.value = str.substring(x, str.length - 1)
         break
      }
   }
}

function setFrmObj(formname) {
	if (document.layers) {
		return eval("document.main.document."+formname);
	} else {
		return eval("document."+formname);
	}
}

// for (i=1; (i < 24) & (! boolLitRequested); i++) {boolLitRequested = isChecked(eval("frm.lit" + i)); this number is one more than the number of literature request kits (23).  
var numKits = 31; // was 27

function checkForm()
{
	frm = setFrmObj('litRequestForm');

	boolLitRequested = false;
	for (i=1; (i < numKits) & (! boolLitRequested); i++) {
		boolLitRequested = isChecked(eval("frm.lit" + i));
	}

	if ( isBlank(frm.fName) )
		return reportError("enter your First Name",frm.fName,1);

	if ( isBlank(frm.lName) )
		return reportError("enter your Last Name",frm.lName,1);
	
	if ( isBlank(frm.address1) )
		return reportError("enter your Address",frm.address1,1);

	if ( isBlank(frm.city) )
		return reportError("enter your City",frm.city,1);

	if ( isSelected(frm.state,-1) || isSelected(frm.state,0) )
		return reportError("select your State",frm.state,1);
	
	if (! isValidZip(frm.zip) )
		return reportError("enter a valid Zip Code",frm.zip,1);

	if ( (! isValidPhoneSimple(frm.phone1)) && (! isBlank(frm.phone1)) && (frm.phone1.value != '###-###-####') )
		return reportError("enter a valid primary phone number in the form ###-###-####",frm.phone1,1);

	if ( (! isValidPhoneSimple(frm.phone2)) && (! isBlank(frm.phone2)) )
		return reportError("enter a valid secondary phone number in the form ###-###-####",frm.phone2,1);

	if ( isRadioChecked(frm.receiveUpdates,0) && (! isValidEmail(frm.email) ) ) 
		return reportError("enter a valid email address",frm.email,1);

	if ( isChecked(frm.contactInfo[0]) && isSelected(frm.callBackInfo,0) )
		return reportError("select the best time to call you back",frm.callBackInfo,1);

	if ( ! isRadioChecked(frm.isCurrentInvestor,-1) ) 
		return reportError("indicate whether you are a current Northern Funds investor",frm.isCurrentInvestor[0],1);
	
	if ( isSelected(frm.investmentAmount,0) ) 
		return reportError("indicate a desired investment amount",frm.investmentAmount,1);
	
	if ( ! isRadioChecked(frm.receiveUpdates,-1) ) 
		return reportError("indicate whether you would like to receive \nperiodic e-mail updates about Northern Funds",frm.receiveUpdates[0],1);

	if ( isSelected(frm.promotion,0) ) 
		return reportError("select how you heard about Northern Funds",frm.promotion,1);

	if (!boolLitRequested) 
		return reportError("select at least one piece of literature.",frm.lit1,1);

	document.litRequestForm.submit()

	return false;
}

function removeAll(formObj)
{
var dropdown = formObj

	for (i = dropdown.length-1; i > 0; i--)
	{
		//dropdown.options[i] = null;
		dropdown.options[i].text = "";
		dropdown.options[i].value = "";
		dropdown.options[i] = null;
	}
}

//Loops through the northernFundsList Array with the passed parameters
// and fills the appropriate funds dropdown list
function fillDropDown(fundType, dropDownName)
{

	var dropdown = dropDownName
	var fundType = fundType
	var j = 1

	// remove the current fund list
	removeAll(dropdown)

	// fill the funds dropdown
	for (var i=1; i<=northernFundList.length-1; i++)
	{
		if (northernFundList[i].fundType == fundType)
		{
			dropdown.options[j] = new Option(northernFundList[i].fundName, northernFundList[i].fundID);
			j++
    	}
   	}

	dropdown.selectedIndex = 0
	dropdown.focus()
}

//Create Array Object
var northernFundList = new Array()

//northernFund Object Constructor
function northernFund(fundType, fundID, fundName)
{
   this.fundType = fundType;
   this.fundID = fundID;
   this.fundName = fundName;
}

//Create northernFund objects
northernFundList[1] = new northernFund("E", "601", "Growth Equity Fund")
northernFundList[2] = new northernFund("E", "602", "Income Equity Fund")
northernFundList[3] = new northernFund("E", "603", "Small Cap Value Fund")
northernFundList[4] = new northernFund("E", "604", "Select Equity Fund")
northernFundList[5] = new northernFund("E", "609", "International Growth Equity Fund")
northernFundList[6] = new northernFund("E", "617", "Technology Fund")
northernFundList[7] = new northernFund("E", "618", "Stock Index Fund")
northernFundList[8] = new northernFund("E", "624", "Small Cap Index Fund")
northernFundList[9] = new northernFund("E", "625", "Mid Cap Growth Fund")
northernFundList[10] = new northernFund("E", "628", "Small Cap Growth Fund")
northernFundList[11] = new northernFund("E", "632", "Large Cap Value Fund")
northernFundList[12] = new northernFund("E", "633", "Growth Opportunities Fund")
northernFundList[13] = new northernFund("FI", "605", "Fixed Income Fund")
northernFundList[14] = new northernFund("FI", "606", "U.S. Government Fund")
northernFundList[15] = new northernFund("FI", "607", "Tax Exempt Fund")
northernFundList[16] = new northernFund("FI", "608", "Intermediate Tax Exempt Fund")
northernFundList[17] = new northernFund("FI", "610", "Global Fixed Income Fund")
northernFundList[18] = new northernFund("FI", "619", "Florida Intermediate Tax Exempt Fund")
northernFundList[19] = new northernFund("FI", "620", "Short-Intermediate US Government Fund")
northernFundList[20] = new northernFund("FI", "621", "California Intermediate Tax Exempt Fund")
northernFundList[21] = new northernFund("FI", "622", "Arizona Tax Exempt Bond Fund")
northernFundList[22] = new northernFund("FI", "623", "California Tax Exempt Bond Fund")
northernFundList[23] = new northernFund("FI", "626", "High Yield Municipal Fund")
northernFundList[24] = new northernFund("FI", "627", "High Yield Fixed Income Fund")
northernFundList[25] = new northernFund("MM", "611", "Money Market Fund")
northernFundList[26] = new northernFund("MM", "612", "Municipal Money Market Fund")
northernFundList[27] = new northernFund("MM", "613", "U.S. Government Money Market Fund")
northernFundList[28] = new northernFund("MM", "615", "U.S. Government Select Fund")
northernFundList[29] = new northernFund("MM", "616", "California Municipal Money Market Fund")
