// global associative array
var maxQuant = new Array();
maxQuant.NIFPROEQTY =  50;
maxQuant.NIFPROFIX  =  50;
maxQuant.NIFPROMM   =  50;
maxQuant.NIFPROSPS  =  50;
maxQuant.NIFPROMPO  =  20;
maxQuant.NIFSAI     =  10;
maxQuant.NIFANREQTY =  10;
maxQuant.NIFANRFIX  =  10;
maxQuant.NIFANRMM   =  10;
maxQuant.NIFANRMPO  =  20;
maxQuant.NIFSAREQ   =  20;
maxQuant.NIFSARFIX  =  20;
maxQuant.NIFSARMM   =  20;
maxQuant.NIFSARMPO  =  20;
maxQuant.NIFNWLQ    =  50;
//maxQuant.NIFFLYMIR  =  20;
//maxQuant.NIFFLYCS   =  20;
//maxQuant.NIFFLYINV  =  20;
//maxQuant.NIFFLYBEAR =  20;
//maxQuant.NIFFLYFA   =  20;
//maxQuant.NIFFLYBOND =  20;
maxQuant.NIFCRDREF  =  50;
//maxQuant.NIFBROEQTY = 100;

maxQuant.NIFNWL     =  50;

maxQuant.NIFAPLDIR  = 100;
maxQuant.NIFAPLCRT  = 100;

// Params: t is the textbox, c is the checkbox
function incrQuantity(t,c) {
	var n = t.value * 1;
	c.checked = true;
	if(n <= 0) {
		t.value = 1;
	} else {
		if( n < maxQuant[c.value] ) {
			t.value = n + 1;
		}
	}
}

// Params: t is the textbox, c is the checkbox
function decrQuantity(t,c) {
	var n = t.value * 1;
	if(n > 0) {
		if( n == 1 ) {
			t.value = "";
			c.checked = false;
		} else {
			if( n > maxQuant[c.value] ) {
				t.value = maxQuant[c.value];
			} else {
				t.value = n - 1;
			}
		}
	}
}

// Params: t is the textbox, c is the checkbox
function checkedChangeEvent(c, t) {
	if( isChecked(c) ) {
		t.value = 1;
	} else {
		t.value = "";
	}
}

// Params: t is the textbox, c is the checkbox
function textChangeEvent(t, c) {
	if( (t.value == "") || (t.value == 0)) {
		c.checked = false;
	} else {
		c.checked = true;
	}
	var m = maxQuant[c.value];
	if( t.value >  m) {
		t.value = m;
	}
}


//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);
	}
}

function checkForm()
{
	frm = setFrmObj('litRequestForm');

	boolLitRequested = false;
	
	// find out how many pieces of literature are in the form for the next loop
	var pieces = 0;
	for( var i = 0; i < frm.elements.length; i++ ) {
		if( frm.elements[i].type == "checkbox" ) {
			pieces += 1;
		}
	}

	for( var i=1; (i <= pieces) & (! boolLitRequested); i++ ) {
		boolLitRequested = isChecked(eval("frm.lit" + i));
	}
		
	if ( isBlank(frm.fName) )
		return reportError("enter a valid First Name",frm.fName,1);

	if ( isBlank(frm.lName) )
		return reportError("enter a valid Last Name",frm.lName,1);
	
	if ( isBlank(frm.address1) )
		return reportError("enter your Address",frm.address1,1);

	if ( isBlank(frm.company) )
		return reportError("enter your Company",frm.company,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 ((!isBlank(frm.email)) && (!isValidEmail(frm.email)) )
		return reportError("enter a valid email address",frm.email,1);

	if( frm.promotion.selectedIndex < 1 )
		return reportError("select how you heard about Northern Institutional Funds.",frm.promotion,1);

// ddb - put in and took out 7/22
//
//	if( document.getElementById("promotion").selectedIndex < 1 )
//		return reportError("select how you heard about Northern Institutional Funds.",document.getElementById("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()
}

function nifDisplayPopUp(docName) {
	var rightNow = new Date();

	iUnique = rightNow.getTime();

	newWindow = window.open(docName,'NIF'+iUnique,'toolbar=no,menubar=no,resizable=yes,scrollbars=yes,width=640,height=640');
	newWindow.focus();
	return false;
}


//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 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", "614", "International Select Equity Fund")
northernFundList[7] = new northernFund("E", "617", "Technology Fund")
northernFundList[8] = new northernFund("E", "618", "Stock Index")
northernFundList[9] = new northernFund("E", "624", "Small Cap Index Fund")
northernFundList[10] = new northernFund("E", "625", "Mid Cap Growth Fund")
northernFundList[11] = new northernFund("E", "628", "Small Cap Growth Fund")
northernFundList[12] = new northernFund("E", "631", "Global Communications Fund")
northernFundList[13] = new northernFund("E", "632", "Large Cap Value Fund")
northernFundList[14] = new northernFund("E", "633", "Growth Opportunities")
northernFundList[15] = new northernFund("FI", "605", "Fixed Income Fund")
northernFundList[16] = new northernFund("FI", "606", "US Government Fund")
northernFundList[17] = new northernFund("FI", "607", "Tax Exempt Fund")
northernFundList[18] = new northernFund("FI", "608", "Intermediate Tax Exempt Fund")
northernFundList[19] = new northernFund("FI", "610", "International Fixed Income Fund")
northernFundList[20] = new northernFund("FI", "619", "Florida Intermediate Tax Exempt Fund")
northernFundList[21] = new northernFund("FI", "620", "Short-Intermediate US Government Fund")
northernFundList[22] = new northernFund("FI", "621", "California Intermediate Tax Exempt Fund")
northernFundList[23] = new northernFund("FI", "622", "Arizona Tax Exempt Bond Fund")
northernFundList[24] = new northernFund("FI", "623", "California Tax Exempt Bond Fund")
northernFundList[25] = new northernFund("FI", "626", "High Yield Municipal Fund")
northernFundList[26] = new northernFund("FI", "627", "High Yield Fixed Income Fund")
northernFundList[27] = new northernFund("MM", "611", "Money Market Fund")
northernFundList[28] = new northernFund("MM", "612", "Municipal Money Market Fund")
northernFundList[29] = new northernFund("MM", "613", "US Government Money Market Fund")
northernFundList[30] = new northernFund("MM", "615", "Government Select Money Market Fund")
northernFundList[31] = new northernFund("MM", "616", "California Municipal Money Market Fund")

