function addLoadEvent(func)
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function')
	{
		window.onload = func;
	}
	else
	{
		window.onload = function()
		{
			oldonload();
			func();
		}
	}
}

addLoadEvent(function()
{
	document.AHUxRef.elements["Manufacturer"].selectedIndex = 0;
})

function optionDetails(CompDesc, linkHref, linkText) {
	// Details object
	this.CompDesc = CompDesc;
	this.linkHref = linkHref;
	this.linkText = linkText;
}
//Here is important section number 1. All arrDetails[] numbers must be unique.  The competitor's model number displayed below 
//in green text (i.e. 'CHY or BHY') must match exactly the SECOND set of competitor's option text in important section number 2 below. 
arrDetails = new Array();
//Carrier Models
arrDetails[0] = new optionDetails('42BHC', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=307202#2000000014', 'Model H Horizontal Belt Drive Blower Coil');
arrDetails[1] = new optionDetails('42BVC', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=307202#2000000014', 'Model V Vertical Belt Drive Blower Coil');
arrDetails[2] = new optionDetails('39L', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=181803#2000000004','Model MQL Indoor Air Handling Unit');

//First Company Models (continue arrDetails[] numbering list from above)
arrDetails[10] = new optionDetails('SHW or SHX BCU', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=307202#2000000014', 'Model H Horizontal Belt Drive Blower Coil');
arrDetails[11] = new optionDetails('SVW or SVX BCU', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=307202#2000000014', 'Model V Vertical Belt Drive Blower Coil');
arrDetails[12] = new optionDetails('SHW or SHX AHU', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=181803#2000000004','Model MQL Indoor Air Handling Unit,<br> Horizontal Arrangement');
arrDetails[13] = new optionDetails('SVW or SVX AHU', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=181803#2000000004','Model MQL Indoor Air Handling Unit,<br> Vertical Arrangement');

//IEC Models (continue arrDetails[] numbering list from above)
arrDetails[20] = new optionDetails('HBC', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=307202#2000000014', 'Model H Horizontal Belt Drive Blower Coil');
arrDetails[21] = new optionDetails('VBY', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=307202#2000000014', 'Model V Vertical Belt Drive Blower Coil');

//Johnson Controls Models (continue arrDetails[] numbering list from above)
arrDetails[30] = new optionDetails('AHI or AHM', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=307202#2000000014', 'Model H Horizontal Belt Drive Blower Coil');
arrDetails[31] = new optionDetails('AVI or AVM', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=307202#2000000014', 'Model V Vertical Belt Drive Blower Coil');
arrDetails[32] = new optionDetails('ACB', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=307202#2000000013', 'Model VB Vertical Reduced Footprint Belt Drive<br> Blower Coil, Bottom Return');
arrDetails[33] = new optionDetails('ACR or ACM', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=307202#2000000013', 'Model VR Vertical Reduced Footprint Belt Drive<br> Blower Coil, Rear Return');
arrDetails[34] = new optionDetails('AMI', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=181803#2000000004','Model MQL Indoor Air Handling Unit');

//Lennox Models (continue arrDetails[] numbering list from above)
arrDetails[40] = new optionDetails('CB Series', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=307203', 'CDV Vertical High Performance Direct Drive FCU');

//Magic Aire Models
arrDetails[50] = new optionDetails('HBAW or HBAX', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=307202#2000000014','Model H Horizontal Belt Drive Blower Coil');
arrDetails[51] = new optionDetails('HBAW or HBAX F&B', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=181803#2000000004','Model MQL Indoor Air Handling Unit,<br> Horizontal Arrangement');
arrDetails[52] = new optionDetails('BVW or BVX', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=307202#2000000014','Model V Vertical Belt Drive Blower Coil');
arrDetails[53] = new optionDetails('BMW or BMX', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=181803#2000000004','Model MQL Indoor Air Handling Unit');

//McQuay Models
arrDetails[60] = new optionDetails('Destiny and FCZC', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=307202#2000000014','Models H and V Horizontal and Vertical<br> Belt Drive Blower Coil Units');
arrDetails[61] = new optionDetails('Destiny', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=181803#2000000004','Model MQL Indoor Air Handling Unit');

//Titus Models
arrDetails[70] = new optionDetails('HAB', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=307202#2000000014', 'Model H Horizontal Belt Drive Blower Coil');
arrDetails[71] = new optionDetails('VAB', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=307202#2000000014', 'Model V Vertical Belt Drive Blower Coil');
arrDetails[72] = new optionDetails('MAB', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=181803#2000000004','Model MQL Indoor Air Handling Unit');

//Trane Models
arrDetails[80] = new optionDetails('BCHC', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=307202#2000000014', 'Model H Horizontal Belt Drive Blower Coil');
arrDetails[81] = new optionDetails('BCVC', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=307202#2000000014', 'Model V Vertical Belt Drive Blower Coil');
arrDetails[82] = new optionDetails('LPC or MCCB', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=181803#2000000004','Model MQL Indoor Air Handling Unit');

//Williams Models
arrDetails[90] = new optionDetails('AH BCU', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=307202#2000000014', 'Model H Horizontal Belt Drive Blower Coil');
arrDetails[91] = new optionDetails('AV BCU', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=307202#2000000014', 'Model V Vertical Belt Drive Blower Coil');
arrDetails[92] = new optionDetails('AH AHU', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=181803#2000000004','Model MQL Indoor Air Handling Unit,<br> Horizontal Arrangement');
arrDetails[93] = new optionDetails('AV AHU', 'http://www.enviro-tec.com/eCatalog/products.asp?ID=181803#2000000004','Model MQL Indoor Air Handling Unit,<br> Vertical Arrangement');

function getRef(obj)
{
	if(typeof obj == "string")
		obj = document.getElementById(obj);
	return obj;
}
	
function getDetails(elem)
{
	var blnClear = true;
	
	if (elem.selectedIndex > -1)
	{
		for (var i = 0; i < arrDetails.length; i++)
		{
			oDetail = arrDetails[i];
			if (oDetail != null)
			{
				if (oDetail.CompDesc == elem.options[elem.selectedIndex].value)
				{	
					getRef("DetailAnchor").href = oDetail.linkHref;
					getRef("DetailAnchor").innerHTML = oDetail.linkText;
					blnClear = false;
					break;
				}
			}
			
		}
	}
	if (blnClear)
	{
		getRef("DetailAnchor").href = document.location.href;
		getRef("DetailAnchor").innerHTML = '';
	}
}

function makeSelected(elem, linkedElem)
{
	var olinkedElem = document.AHUxRef.elements[linkedElem];
	
	// Clear existing items
	for (var i = olinkedElem.options.length; i >= 0; i--){
		olinkedElem.options[i] = null;

	}
	
	if (elem.options[elem.selectedIndex].value==''){
		olinkedElem.options[olinkedElem.options.length] = new Option('Select Model','');
	}

//Here is important section 2, defining competitor's models.  The SECOND set of green text below must match the optionDetails text above exactly.
//The FIRST set of competitor's text is what displays in the "Select Model" drop-down menu on the web page; can say whatever.	
	if (elem.options[elem.selectedIndex].value=='Carrier'){
		olinkedElem.options[olinkedElem.options.length] = new Option('42BHC','42BHC');
		olinkedElem.options[olinkedElem.options.length] = new Option('42BVC','42BVC');
		olinkedElem.options[olinkedElem.options.length] = new Option('39L up to 8500 CFM','39L');
		
	}
	
	if (elem.options[elem.selectedIndex].value=='First Co.'){
		olinkedElem.options[olinkedElem.options.length] = new Option('SHW or SHX up to 4000 CFM','SHW or SHX BCU');
		olinkedElem.options[olinkedElem.options.length] = new Option('SVW or SVX up to 4000 CFM','SVW or SVX BCU');
		olinkedElem.options[olinkedElem.options.length] = new Option('SHW or SHX up to 8500 CFM','SHW or SHX AHU');
		olinkedElem.options[olinkedElem.options.length] = new Option('SVW or SVX up to 8500 CFM','SVW or SVX AHU');
		
	}
	
	if (elem.options[elem.selectedIndex].value=='IEC'){
		olinkedElem.options[olinkedElem.options.length] = new Option('HBC','HBC');
		olinkedElem.options[olinkedElem.options.length] = new Option('VBY','VBY');
		
	}
	
	if (elem.options[elem.selectedIndex].value=='JCI'){
		olinkedElem.options[olinkedElem.options.length] = new Option('AHI or AHM','AHI or AHM');
		olinkedElem.options[olinkedElem.options.length] = new Option('AVI or AVM','AVI or AVM');
		olinkedElem.options[olinkedElem.options.length] = new Option('ACB','ACB');
		olinkedElem.options[olinkedElem.options.length] = new Option('ACR or ACM','ACR or ACM');
		olinkedElem.options[olinkedElem.options.length] = new Option('AMI','AMI');
		
	}
	
	if (elem.options[elem.selectedIndex].value=='Lennox'){
		olinkedElem.options[olinkedElem.options.length] = new Option('CB Series AHU','CB Series');
		
	}


	if (elem.options[elem.selectedIndex].value=='Magic Aire'){
		olinkedElem.options[olinkedElem.options.length] = new Option('HBAW or HBAX (Horizontal)','HBAW or HBAX');
		olinkedElem.options[olinkedElem.options.length] = new Option('HBAW or HBAX with Face & Bypass Dampers','HBAW or HBAX F&B');
		olinkedElem.options[olinkedElem.options.length] = new Option('BVW or BVX (Vertical)','BVW or BVX');
		olinkedElem.options[olinkedElem.options.length] = new Option('BMW or BMX up to 8500 CFM','BMW or BMX');
		
	}
	
	if (elem.options[elem.selectedIndex].value=='McQuay'){
		olinkedElem.options[olinkedElem.options.length] = new Option('Destiny or FCZC up to 4000 CFM','Destiny and FCZC');
		olinkedElem.options[olinkedElem.options.length] = new Option('Destiny up to 8500 CFM','Destiny');
		
	}
	
	if (elem.options[elem.selectedIndex].value=='Titus'){
		olinkedElem.options[olinkedElem.options.length] = new Option('HAB','HAB');
		olinkedElem.options[olinkedElem.options.length] = new Option('VAB','VAB');
		olinkedElem.options[olinkedElem.options.length] = new Option('MAB','MAB');
		
	}

	if (elem.options[elem.selectedIndex].value=='Trane'){
		olinkedElem.options[olinkedElem.options.length] = new Option('BCHC up to 4000 CFM','BCHC');
		olinkedElem.options[olinkedElem.options.length] = new Option('BCVC up to 4000 CFM','BCVC');
		olinkedElem.options[olinkedElem.options.length] = new Option('LPC or MCCB up to 8500 CFM','LPC or MCCB');
		
	}
	
	if (elem.options[elem.selectedIndex].value=='Williams'){
		olinkedElem.options[olinkedElem.options.length] = new Option('AH up to 4000 CFM','AH BCU');
		olinkedElem.options[olinkedElem.options.length] = new Option('AV up to 4000 CFM','AV BCU');
		olinkedElem.options[olinkedElem.options.length] = new Option('AH up to 8500 CFM','AH AHU');
		olinkedElem.options[olinkedElem.options.length] = new Option('AV up to 8500 CFM','AV AHU');
		
	}
	
	getDetails(document.AHUxRef.elements[linkedElem]);
}