var arrCategory, arrApplication;

/*
 * This function is called when a user chooses an option from
 * a dropdown. Either the next sequential dowpdown is populated, 
 * or the user is redirected to a product page.
 */
function finder_action(sel) {
	var popArr = null;
	var popSel = null;
	var ix;
	
	switch (sel.name) {
		case "selMarket":
			popArr = arrCategory;
			popSel = document.frmProductFinder.selCategory;
			ix = sel.selectedIndex;
			break;
			
		case "selCategory":
			ix = sel[sel.selectedIndex].value;
			break;
			
		default: 
			return; // error - jump out / do nothing
	}
	
	if (isNaN(ix)) document.location.href=ix;
	else {
		for (m=popSel.options.length-1; m>0; m--) popSel.options[m]=null;
		for (i=0; i<popArr[ix].length; i++) popSel.options[i]=new Option(popArr[ix][i].text, popArr[ix][i].value);
		popSel.options[0].selected=true;
	}
}

/*
 * This function builds the data arrays used to populate the dropdowns.
 */
function initializeData() {
	var i, len, sel;
	
	document.frmProductFinder.selMarket.selectedIndex=0;
	document.frmProductFinder.selCategory.selectedIndex=0;
	
	/*
	 * Market dropdown
	 */
	var sel = document.frmProductFinder.selMarket;
	sel.options[1]=new Option("Architectural Coatings","");
	sel.options[2]=new Option("Industrial Coatings","");
	sel.options[3]=new Option("Pressure Sensitive Adhesives","");
	sel.options[4]=new Option("Sealants & Construction","");
	sel.options[5]=new Option("Specialty Coatings","");
	sel.options[6]=new Option("Thickeners","");
	sel.options[7]=new Option("Traffic Coatings","");
	
	/*
	 * Categories
	 */
	len = document.frmProductFinder.selMarket.options.length;
	arrCategory = new Array(len);
	for (i=0; i<len; i++) arrCategory[i] = new Array();
	arrCategory[0][0] = new Option("Select:","0");
	
	// Architectural Coatings
	arrCategory[1][0]=new Option("Select:","0");
	arrCategory[1][1]=new Option("Interior/Exterior Wall & Trim","wall.htm");
	// Industrial
	arrCategory[2][0]=new Option("Select: ","0");
	arrCategory[2][1]=new Option("Coatings","industrial/coatings.htm");
	// Adhesives
	arrCategory[3][0]=new Option("Select:","0");
	arrCategory[3][1]=new Option("Adhesives","adhesive.htm");

	// Sealants & Construction
	arrCategory[4][0]=new Option("Select:","0");
	arrCategory[4][1]=new Option("Concrete Admix & EIFS","sealant/concrete.htm");
	arrCategory[4][2]=new Option("Dust Control","sealant/dust.htm");
	arrCategory[4][3]=new Option("Sealants","sealant/sealants.htm");
	arrCategory[4][4]=new Option("Tape Joints","sealant/tape.htm");
	arrCategory[4][5]=new Option("Tile Adhesives","sealant/tile.htm");
	// Specialty Coatings
	arrCategory[5][0]=new Option("Select:","0");
	arrCategory[5][1]=new Option("Direct to Metal","specialty/metal.htm");
	arrCategory[5][2]=new Option("Elastomeric Roof & Wall","specialty/elastomeric.htm");
	arrCategory[5][3]=new Option("Floor & Deck","specialty/floor.htm");
	arrCategory[5][4]=new Option("Primers","specialty/primer.htm");
	arrCategory[5][5]=new Option("Sports Surfaces","specialty/sports.htm");
	// Thickeners
	arrCategory[6][0]=new Option("Select:","0");
	arrCategory[6][1]=new Option("Thickeners","thickeners.htm");
	// Traffic
	arrCategory[7][0]=new Option("Select:","0");
	arrCategory[7][1]=new Option("Coatings","traffic.htm");
	
}
