// -------------
// -- OBJECTS --
// -------------
function CProductList()
{
	this.pdt = new Array();

	this.Add = AddProduct;
	this.Get = GetProduct;
}
function CProduct(name, tds, rfs)
{
	this.Name = name;
	this.TDS = tds;
	this.RFS = rfs;
}
function AddProduct(index, name, tds, rfs)
{
	this.pdt[index] = new CProduct(name, tds, rfs);
}
function GetProduct(index)
{
	return this.pdt[index];
}
var allapp = new Array();
function CAppList(index, name)
{
	this.Index = index;
	this.Name = name;
	
	this.app = new Array();
	this.h = new Array();
	this.r = new Array();
	
	this.Add = AddApp;
	this.Get = GetApp;
	this.New = NewApp;
	
	this.H = AddHighlyRecommended;
	this.R = AddRecommended;
	this.NewH = NewH;
	this.NewR = NewR;
}
function AddApp(parentid, index, name)
{
	allapp[index] = new CAppList(index, name);
	if (parentid != 0)
	{
		allapp[parentid].New(allapp[index]);
	}
	else
	{
		this.New(allapp[index]);
	}
}
function NewApp(object)
{
	this.app[this.app.length] = object;
}
function GetApp(index)
{
	return this.app[index];
}
function NewH(object)
{
	this.h[this.h.length] = object;
}
function NewR(object)
{
	this.r[this.r.length] = object;
}
function AddHighlyRecommended(appid, pdtid)
{
	allapp[appid].NewH(allpdt.Get(pdtid));
}
function AddRecommended(appid, pdtid)
{
	allapp[appid].NewR(allpdt.Get(pdtid));
}
// -------------
// -- DISPLAY --
// -------------
function init()
{
	var select = document.getElementById("select1");
	initList(select, app);
}
function initList(select, appList)
{
	while (select.length>0)
		select[0] = null; 
	for(var i=0; i<appList.app.length; i++)
	{
		select[select.length] = new Option(appList.app[i].Name, appList.app[i].Index);
	}
	select[0].text = "--- " + select[0].text + " ---";
}
function select(obj, nextselect)
{
	if (nextselect < 3)
		document.getElementById("selecttr3").style.display = "none";

	var select = document.getElementById("select" + nextselect);
	var selecttr = document.getElementById("selecttr" + nextselect);
	var selecttd = document.getElementById("selecttd" + nextselect);
	var appindex = eval(obj[obj.selectedIndex].value);
	
	var selectedApp = allapp[appindex];
	if (selecttr)
	{
		if (appindex == 0 || !selectedApp || selectedApp.app.length == 0)
		{
			selecttr.style.display = "none";
		}
		else if (selectedApp.app.length > 0)
		{
			initList(select, allapp[appindex]);
			selecttd.innerHTML = allapp[appindex].app[0].Name;
			selecttr.style.display = "";
		}
	}
	hasresults = false;
	display("highly", selectedApp.h);
	display("recommended", selectedApp.r);
	
//	var resume = document.getElementById("resume");
//	var search = document.getElementById("search");
	if (hasresults)
	{
//		resume.style.display = "";
//		search.innerHTML = "";
		
		if (!nextselect) nextselect = 4;
		for (var i=1; i<nextselect; i++)
		{
			select = document.getElementById("select" + i);
//			search.innerHTML += ((i > 1)? " &gt;&gt; " : "") + select[select.selectedIndex].text;
		}
	}
//	else
//	{
//		resume.style.display = "none";
//	}
}
var hasresults = false;
function display(listname, pdtlist)
{
	var table = document.getElementById(listname);
	if (pdtlist.length > 0)
	{
		document.getElementById(listname + "tr0").style.display = "none";
		document.getElementById(listname + "tr1").style.display = "none";
		
		for (var i=0; i<pdtlist.length; i++)
		{
			document.getElementById(listname + "td" + i).innerHTML = pdtlist[i].Name;
			document.getElementById(listname + "tds" + i).href = pdtlist[i].TDS;
			//document.getElementById(listname + "rfs" + i).href = pdtlist[i].RFS;
			document.getElementById(listname + "tr" + i).style.display = "";
		}
		table.style.display = "";
		hasresults = true;
	}
	else
	{
		table.style.display = "none";
	}
}
function tds(obj)
{
	login(obj, 600, 500, false, true);
}
function rfs(obj)
{
	window.open(obj);
}
// -------------
// --  LISTS  --
// -------------
var allpdt = new CProductList();
allpdt.Add(0, "<a href='/common/pc/product/displayproduct.aspx?id=19343' target='_blank'>DuPont&trade; Ti-Pure&reg; R-706</a>", "/common/pc/product/displayproduct.aspx?id=19343", "/tc/TiO2/rfs.aspx?pcc=19343");
allpdt.Add(1, "<a href='/common/pc/product/displayproduct.aspx?id=19344' target='_blank'>DuPont&trade; Ti-Pure&reg; R-900</a>", "/common/pc/product/displayproduct.aspx?id=19344", "/tc/TiO2/rfs.aspx?pcc=19344");
allpdt.Add(2, "<a href='/common/pc/product/displayproduct.aspx?id=20559' target='_blank'>DuPont&trade; Ti-Pure&reg; R-902+</a>", "/common/pc/product/displayproduct.aspx?id=20559", "/tc/TiO2/rfs.aspx?pcc=20559");
allpdt.Add(3, "<a href='/common/pc/product/displayproduct.aspx?id=19346' target='_blank'>DuPont&trade; Ti-Pure&reg; R-931</a>", "/common/pc/product/displayproduct.aspx?id=19346", "/tc/TiO2/rfs.aspx?pcc=19346");
allpdt.Add(4, "<a href='/common/pc/product/displayproduct.aspx?id=19347' target='_blank'>DuPont&trade; Ti-Pure&reg; R-960</a>", "/common/pc/product/displayproduct.aspx?id=19347", "/tc/TiO2/rfs.aspx?pcc=19347");
allpdt.Add(5, "<a href='/common/pc/product/displayproduct.aspx?id=19341' target='_blank'>DuPont&trade; Ti-Select&reg; TS-6200</a>", "/common/pc/product/displayproduct.aspx?id=19341", "/tc/TiO2/rfs.aspx?pcc=19341");

var app = new CAppList();
app.Add(0, 0, "Application");
app.Add(0, 1, "Architectural");
	app.Add(1, 35, "Please further specify");
	app.Add(1, 4, "Interior");
		app.Add(4, 36, "Surface aspect");
		app.Add(4, 19, "Gloss");
			app.H(19, 1);
			app.R(19, 0);
		app.Add(4, 20, "Semi-gloss/Satin");
			app.H(20, 2);
			app.R(20, 0);
		app.Add(4, 21, "Flat");
			app.H(21, 3);
			app.R(21, 2);
	app.Add(1, 5, "Exterior");
		app.Add(5, 37, "Surface aspect");
		app.Add(5, 22, "Gloss");
			app.H(22, 0);
			app.R(22, 2);
		app.Add(5, 23, "Semi-gloss/Satin");
			app.H(23, 2);
			app.R(23, 0);
		app.Add(5, 24, "Flat");
			app.H(24, 2);
			app.R(24, 3);
app.Add(0, 2, "OEM");
	app.Add(2, 38, "Market");
	app.Add(2, 13, "Automotive");
		app.Add(13, 42, "Please further specify");
		app.Add(13, 31, "E-coat");
			app.H(31, 1);
		app.Add(13, 32, "Primer");
			app.H(32, 1);
			app.R(32, 2);
		app.Add(13, 33, "Basecoats");
			app.H(33, 5);
			app.R(33, 4);
			app.R(33, 0);
		app.Add(13, 34, "Plastics");
			app.H(34, 5);
			app.R(34, 4);
			app.R(34, 0);
	app.Add(2, 44, "Can/Packaging");
			app.H(44, 1);
			app.R(44, 2);
			app.R(44, 0);
	app.Add(2, 7, "Coil");
		app.Add(7, 40, "Please further specify");
		app.Add(7, 27, "Durable");
			app.H(27, 5);
			app.R(27, 4);
			app.R(27, 0);
		app.Add(7, 28, "Non-durable");
			app.H(28, 2);
			app.R(28, 1);
	app.Add(2, 11, "E-coat");
			app.H(11, 1);
			app.R(11, 2);
	app.Add(2, 6, "General / Metal");
		app.H(6, 2);
		app.R(6, 0);
	app.Add(2, 10, "Plastics");
			app.H(10, 2);
			app.R(10, 0);
			app.R(10, 5);
	app.Add(2, 9, "Powder");
		app.Add(9, 41, "Please further specify");
		app.Add(9, 29, "Durable");
			app.H(29, 0);
			app.R(29, 2);
			app.R(29, 5);
		app.Add(9, 30, "Non-durable");
			app.H(30, 1);
			app.R(30, 0);
			app.R(30, 2);
	app.Add(2, 12, "Primer");
			app.H(12, 1);
			app.R(12, 2);
			app.R(12, 0);
	app.Add(2, 8, "Wood");
			app.H(8, 2);
			app.R(8, 0);
			app.R(8, 1);
app.Add(0, 3, "Special Purpose");
	app.Add(3, 43, "Please further specify");
	app.Add(3, 16, "Aerospace");
			app.H(16, 5);
			app.R(16, 0);
			app.R(16, 4);
	app.Add(3, 15, "Automotive Refinish");
			app.H(15, 5);
			app.R(15, 0);
			app.R(15, 4);
	app.Add(3, 14, "Dispersions");
			app.H(14, 0);
			app.R(14, 2);
	app.Add(3, 17, "Marine");
			app.H(17, 0);
			app.R(17, 4);
			app.R(17, 5);
	app.Add(3, 18, "Traffic");
			app.H(18, 1);
			app.R(18, 2);
app.Add(0, 39, "Ink");
	app.R(39, 1);
	app.R(39, 3);
	app.R(39, 4);
