//////////////////////////////////////////////////////////////////////////
// TITLE:		DPI Selector Calculations								//
// PURPOSE:		Validate User Input and select product based on input	//
//																		//
// FUNCTIONS:	keycheck - checks for 'Enter' key and validates			//
//				ridethrough -- calculates ride through time				//
//				prodsort - sorts product list on time					//
//				makemodel - create model objects						//
//				set_v - validates the voltage setting					//
//				set_i - validates the current setting					//
//				set_pf - validates the power factor setting				//
//				set_t - validates the time setting						//
//				calculate - calculates recommendation based on inputs	//
//				updbyp - calculates bypass switch						//
//																		//
// VERSION:		1.00													//
// DATE:		June 28, 2003											//
//																		//
//				© Copyright Measurlogic 2003							//
//																		//
//////////////////////////////////////////////////////////////////////////

// Definition of primary variables
var
	v,			// Voltage entered
	i,			// Current entered
	pf,			// Power factor entered
	t,			// Desired ride through time entered
	v_model,	// Voltage model, can be 120 or 230
	v_ok,		// Set if voltage is in valid range
	i_ok,		// Set if current is in valid range
	pf_ok,		// Set if power factor is in valid range
	t_ok		// Set if desired ride through time in valid range

// Interface with HTML objects
var v120,		// Point to 120V model voltage range description for feedback
	v230,		// Point to 230V range voltage range description for feedback
	i120,		// Point to 120V model current range description for feedback
	i230,		// Point to 230V model current range description for feedback
	pfr,		// Point to power factor range description for feedback
	tr,			// Point to desired ride through time range description for feedback
	v_inp,		// Point to voltage input
	i_inp,		// Point to current input
	pf_inp,		// Point to power factor input
	t_inp,		// Point to desired ride through time input
	out1,		// Point to lowest recommendation model
	out2,		// Point to primary recommendation model
	out3,		// Point to upper recommendation model
	out1t,		// Point to lowest recommendation calculated time
	out2t,		// Point to primary recommendation calculated time
	out3t		// Point to upper recommendation calculated time

// Operation variables
var
	products	// Stores information about the products

// Persistant Information
var
	myCookie,	// Points to the document cookie
	vCookie,	// voltage Cookie data
	iCookie,	// current Cookie data
	pCookie,	// power factor Cookie data
	tCookie		// ride through time Cookie data

// Initialization code

	// Point to HTML components
	v120 = window.document.all("v120");	
	v230 = window.document.all("v230");
	i120 = window.document.all("i120");
	i230 = window.document.all("i230");
	pfr = window.document.all("pfrange");
	tr = window.document.all("trange");
	
	out1 = window.document.all("out1");
	out2 = window.document.all("out2");
	out3 = window.document.all("out3");

	out1t = window.document.all("out1t");
	out2t = window.document.all("out2t");
	out3t = window.document.all("out3t");
	
	v_inp = window.document.all("V");
	i_inp = window.document.all("I");
	pf_inp = window.document.all("PF");
	t_inp = window.document.all("T");
	
	// Create the product information
	products = new Array();
	
	// Models set up with parameters	Model,	Energy,	Current, Time, VModel, Preferred, pdf file
	// where
	//		Model - is the model number / identifier
	//		Energy - is the energy rating of the model
	//		Current - is the current rating of the model
	//		Time - is a location for calculating ride through time 
	//		VModel - is the voltage that identifies the model (120 or 230)
	//		Preferred - set to true if this is a preferred model (used in sorting)
	//		pdf file - name of the pdf file describing this model
	
	// 120V model products
	products["S2512"] = new makemodel("DPI52S25-12", 0.0066, 2.11, 0, 120, true, "user1");
	products["S5012"] = new makemodel("DPI52S50-12", 0.0132, 4.21, 0, 120, true, "user1");
	products["S9512"] = new makemodel("DPI52S95J-12", 0.0132, 4.21, 0, 120, false, "user4");
	products["L1k12"] = new makemodel("DPI52L1k-12", 0.022, 8.41, 0, 120, true, "user2");
	products["S19012"] = new makemodel("DPI52S190J-12", 0.0264, 4.21, 0, 120, false, "user4");
	products["L23812"] = new makemodel("DPI52L238J-12", 0.033, 8.41, 0, 120, false, "user5");
	products["L2k12"] = new makemodel("DPI52L2k-12", 0.044, 16.71, 0, 120, true, "user2");
	products["L3k12"] = new makemodel("DPI52L3k-12", 0.066, 16.71, 0, 120, true, "user2");
	products["L47512"] = new makemodel("DPI52L475J-12", 0.066, 16.71, 0, 120, false, "user5");
	products["L71312"] = new makemodel("DPI52L713J-12", 0.099, 25.01, 0, 120, false, "user5");
	products["L95012"] = new makemodel("DPI52L950J-12", 0.132, 25.01, 0, 120, false, "user5");
	products["L118812"] = new makemodel("DPI52L1188J-12", 0.165, 25.01, 0, 120, false, "user5");
	products["L163312"] = new makemodel("DPI52L1663J-12", 0.231, 25.01, 0, 120, false, "user5");
	products["L237612"] = new makemodel("DPI52L2376J-12", 0.33, 25.01, 0, 120, false, "user5");
	
	// 208/230V model products
	products["S2523"] = new makemodel("DPI52S25-23", 0.00204, 1.11, 0, 230, true, "user1");
	products["S5023"] = new makemodel("DPI52S50-23", 0.00408, 2.21, 0, 230, true, "user1");
	products["S10823"] = new makemodel("DPI52S108J-23", 0.00408, 2.21, 0, 230, false, "user4");
	products["S21623"] = new makemodel("DPI52S216J-23", 0.00816, 2.71, 0, 230, false, "user4");
	products["L1k523"] = new makemodel("DPI52L1k5-23", 0.01, 6.51, 0, 230, true, "user2");
	products["L26523"] = new makemodel("DPI52L265J-23", 0.01, 6.51, 0, 230, false, "user5");
	products["L3k23"] = new makemodel("DPI52L3k-23", 0.02, 13.01, 0, 230, true, "user2");
	products["L52923"] = new makemodel("DPI52L529J-23", 0.02, 13.01, 0, 230, false, "user5");
	products["L4k523"] = new makemodel("DPI52L4k5-23", 0.03, 20.01, 0, 230, true, "user2");
	products["L79423"] = new makemodel("DPI52L794J-23", 0.03, 20.01, 0, 230, false, "user5");
	products["L58723"] = new makemodel("DPI52L1587J-23", 0.06, 20.01, 0, 230, false, "user5");
	products["L238123"] = new makemodel("DPI52L2381J-23", 0.09, 20.01, 0, 230, false, "user5");
	products["L317423"] = new makemodel("DPI52L3174J-23", 0.12, 20.01, 0, 230, false, "user5");
	products["L396823"] = new makemodel(" DPI52L3968J-23", 0.15, 20.01, 0, 230, false, "user5");

	// Initialize the variables for the example and calculate it

	v = 0;
	i = 0;
	p = 0;
	t = 0;
	
	myCookie = document.cookie.split("; ");
	//alert("length = " + myCookie.length);
	for (var j=0; j < myCookie.length; j++)
	{
		// a name/value pair (a crumb) is separated by an equal sign
		var aCrumb
		
		aCrumb = myCookie[j].split("=");
		
		//alert("counter = " + j + ", " + aCrumb[0] + ", " + aCrumb[1]);
		//alert("Test Voltage, '" + aCrumb[0] + "'");
		if ("Voltage" == aCrumb[0]) 
		{
			//alert("Set Voltage = " + aCrumb[1]);
			v = aCrumb[1];
		}	
		
		//alert("Test Current, '" + aCrumb[0] + "'");
		if (aCrumb[0] == "Current") 
		{
			//alert("Set Current = " + aCrumb[1]);
			i = aCrumb[1];
		}
		
		//alert("Test Power Factor, '" + aCrumb[0] + "'");
		if ("Power Factor" == aCrumb[0]) 
		{
			//alert("Set Power Factor = " + aCrumb[1]);
			pf = aCrumb[1];
		}
		
		//alert("Test Ride Through Time, '" + aCrumb[0] + "'");
		if ("Ride Through Time" == aCrumb[0]) 
		{
			//alert("Set Ride Through Time = " + aCrumb[1]);
			t = aCrumb[1];
		}
		
	}
	
	//alert ("Voltage = " + v);
	//alert ("Current = " + i);
	//alert ("Power Factor = " + pf);
	//alert ("Ride Through Time = " + t);

	if (v==0)
		v = 118;
	
	if (i==0)
		i = 0.1;
	
	if (p==0)
		pf = 0.75;
		
	if (t==0)
		t = 1.0;

	//alert ("Voltage = " + v);
	//alert ("Current = " + i);
	//alert ("Power Factor = " + pf);
	//alert ("Ride Through Time = " + t);
	set_v (v);

	//alert ("Voltage = " + v);
	//alert ("Current = " + i);
	//alert ("Power Factor = " + pf);
	//alert ("Ride Through Time = " + t);
	set_i (i);

	//alert ("Voltage = " + v);
	//alert ("Current = " + i);
	//alert ("Power Factor = " + pf);
	//alert ("Ride Through Time = " + t);
	set_pf (pf);

	//alert ("Voltage = " + v);
	//alert ("Current = " + i);
	//alert ("Power Factor = " + pf);
	//alert ("Ride Through Time = " + t);
	set_t (t);
	
	calculate();
	
// Check the key on the input boxes
// If it is 'Enter', then validate the box content
function keycheck(item)
{
	// Check for 'Enter' key
	if (window.event.keyCode == 13)
	{
		// If voltage entry box
		if (item == v_inp)
		{
			// validate voltage
			set_v(item.value);
		}

		// If current entry box
		if (item == i_inp)
		{
			// validate current
			set_i(item.value);
		}

		// If power factor entry box
		if (item == pf_inp)
		{
			// validate power factor
			set_pf(item.value);
		}

		// If time entry box
		if (item == t_inp)
		{
			// validate time
			set_t(item.value);
		}
	}
	else
	{
		//If voltage, current, power factor or time entry box then erase the recommendations
		if ((item == v_inp) ||
			(item == i_inp) ||
			(item == pf_inp) ||
			(item == t_inp))
		{
			// Erase recommendations
			out1.innerHTML = "";
			out1t.innerHTML = "";
			out2.innerHTML = "";
			out2t.innerHTML = "";
			out3.innerHTML = "";
			out3t.innerHTML = "";
			out1c.checked = false;
			out2c.checked = false;
			out3c.checked = false;
			byp10c.checked = false;
			byp40c.checked = false;
		}
	}
}

// Method rt of Product
// Calculate the ride through time based on voltage, current and powerfactor
function ridethrough( v, i, pf)
{
var rt	// rider through time 
	// calculate ride trough time
	rt = ((Math.pow(v*Math.sqrt(2)-5, 2) - Math.pow((v*0.9+5),2))*0.5 * this.energy)/(i*v*pf+12+i*5);
	// Set the model time to the ride through time
	this.time = rt;
	return (rt);
}

// Implements the sort function of the candidates
// Used to sort two products by time
// The sort returns -1 if first is lower than second
//			returns 0 if they are equal
//			returns 1 if first is higher than second
function prodsort(a, b)
{
var
	retval
	
	// If the first procut's time is less than the second return -1
	if (a.time < b.time) 
	{
		retval = -1;
	}
	else
	{
		// If the prouct times are equal
		if (a.time == b.time)
		{
			// if a is a preferred product, return 1
			if (a.preferred)
			{
				retval = 1;
			}
			// else return 0
			else
			{
				retval = 0;
			}
		}
		else
		{
			// if a's time is greater than b's time return 1	
			if (a.time > b.time)
			{
				retval = 1;
			}
		}
	}
	return (retval);	
}

// Object creation for the makemodel objects (Products)
function makemodel(Model, Energy, Current, Time, Nominal, Preferred, pdf)
{
	this.model = Model;				// Assign model description
	this.energy = Energy;			// Assign energy value
	this.current = Current;			// Assign model current
	this.time = Time;				// Assign initial model time - used in calculation
	this.nominal = Nominal;			// Assign nominal voltage (voltage model)
	this.preferred = Preferred;		// Preferred model or not
	this.pdf = pdf;					// pdf file name for this model
	this.rt = ridethrough;			// ridethrough function used as method to calculate time
	
}	

// Validate the voltage input
function set_v(v_in)
{
	// If the voltage is set to a number
	if (isFinite(v_in))
	{
		// Create a number from the input text
		v = new Number(v_in);
		// Format the number and place it back in the input box
		v_inp.value = v.toFixed(1);
		
		// if the voltage is in the range 95 to 132 inclusive
		if ((v_in >= 95) & (v_in <= 132))
		{
			// set the model and show the 120V range settings in light green, bold font
			// show the 230V range settings in black
			// set v_ok indicating voltage is valid
			v_model = 120;
			v120.className="selector-selected";
			v230.className="selector-normal";
			v_ok=true;
		}
		else
		{
			// if the voltage is in the range 185 to 240 inclusive
			if ((v_in >= 185) & (v_in <= 240))
			{
				// set the model and show the 120V range settings in black
				// show the 230V range settings in light green, bold font
				// set v_ok indicating voltage is valid
				v_model = 230;
			    v120.className="selector-normal";
			    v230.className="selector-selected";
				v_ok=true;
			}
			else
			{
				// incorrect voltage entered
				// set the model to 0 and the 120V and 230V range settings to red font
				// set v_ok false indicating voltage is not valid
			    v120.className="selector-error";
			    v230.className="selector-error";
				v_model = 0;
				v_ok=false;
			}
		}
	}
	else
	{
		// Not a number so
		// Set the model to 0 and the 120V and 230V range settings to red font
        v120.className="selector-error";
		v230.className="selector-error";
		v_model = 0;
		v_ok=false;
	}
	// Force validation of the current
	set_i(i);
	// Cause calculation
	calculate();
}

// Validate the current input
function set_i(i_in)
{
	// if the current is a number
	if (isFinite(i_in))
	{
		// Create a number from the input text
		i = new Number(i_in);
		// Format the number and put it back in the input box
		i_inp.value = i.toFixed(1);
		
		// If the current is greater than 0.1A
		if (i_in >= 0.1)
		{
			// if the current is less than 20A then both model types are OK
			if (i_in <= 20)
			{
				// set that this is a valid current
				i_ok = true;
				
				// set the colours for the corrent model range
				switch (v_model)
				{
					// if model is 120V, then 
					// set 120V model color to lightgreen and bold
					// set 230V model color to black
					case 120:
			            i120.className="selector-selected";
			            i230.className="selector-normal";
						//calculate();
						break;
					// if model is 230V, then set c
					// set 120V model color to black
					// set 230V model color to lightgreen and bold
					case 230:
			            i120.className="selector-normal";
			            i230.className="selector-selected";
						//calculate();
						break;
					// model is not 120V or 230V so
					// set 120V range to lightgreen and bold
					// set 230V range to lightgreen and bold
					// because the current range is correct for either model
					default:
			            i120.className="selector-selected";
			            i230.className="selector-selected";
				}
			}
			else
			// current is > 0.1A  but not <= 20A
			{
				// if current is <= 25A
				if (i_in <= 25)
				{
					// determine range settings to colour from model
					switch (v_model)
					{
						// 120V model set i_ok true
						// set 120V model range to lightgreen and bold
						// set 230V model range to black
						case 120:
							i_ok = true;
			                i120.className="selector-selected";
			                i230.className="selector-normal";
							//calculate();
							break;

						// 230V model set i_ok true
						// set 120V model range to black
						// set 230V model range to red - not a valid current for 230V
						case 230:
							i_ok = false;
			                i120.className="selector-normal";
			                i230.className="selector-error";
							break;
						
						// set i_ok true because it could be a valid current
						// set 120V model range to lightgreen bold because it is valid for 120V models
						// set 230V model range to red - not a valid current for 230V
						default:
							i_ok = true;
			                i120.className="selector-selected";
			                i230.className="selector-error";
							break;
					}
				}
				else
				// current is > 25A
				{
					switch (v_model)
					{
						// set i_ok false
						// set 120V model red and 230V model black (120V model selected)
						case 120:
							i_ok = false;
			                i120.className="selector-error";
			                i230.className="selector-normal";
							break;

						// set i_ok false
						// set 120V model black and 230V model red (230V model selected)
						case 230:
							i_ok = false;
			                i120.className="selector-normal";
			                i230.className="selector-error";
							break;

						// set i_ok false
						// set 120V model red and 230V model red (no model selected)
						default:
							i_ok = false;
			                i120.className="selector-error";
			                i230.className="selector-error";
							break;
					}
				}
			}
		}
		else
		// current is less than 0.1A
		{
			switch (v_model)
			{
				// set i_ok false
				// set 120V model red and 230V model black (120V model selected)
				case 120:
					i_ok = false;
		            i120.className="selector-error";
		            i230.className="selector-normal";
					break;
					
				// set i_ok false
				// set 120V model black and 230V model red (230V model selected)
				case 230:
					i_ok = false;
		            i120.className="selector-normal";
		            i230.className="selector-error";
					break;
					
				// set i_ok false
				// set 120V model red and 230V model red (no model selected)
				default:
					i_ok = false;
		            i120.className="selector-error";
		            i230.className="selector-error";
					break;
			}
		}
	}
	else
	// not a number entered
	{
		// set i_ok false
		// set 120V model red and 230V model red (not a valid number)
		i_ok = false;
        i120.className="selector-error";
        i230.className="selector-error";
	}					
	// Force calculation
	calculate();
}

// Validate the power factor entered
function set_pf(pf_in)
{
	// if the power factor entered is a number
	if (isFinite(pf_in))
	{
		// Create a number from the power factor entered
		pf = new Number(pf_in);
		// Format the number and store it back in the power factor box
		pf_inp.value = pf.toFixed(2);
		
		// if the power factor is between 0 and 1
		if (pf >= 0 & pf <= 1)
		{
			// Set the power factor range to lightgreen and bold
			pf_ok = true;
			pfr.className="selector-selected";
			//calculate();
		}
		else
		// power factor is not between 0 and 1
		{
			// set the power factor range to red
			pf_ok = false;
			pfr.className="selector-error";
		}
	}
	else
	// power factor entered is not a number
	{
		// not a good power factor
		// set power factor range to red
		pf_ok = false;
		pfr.className="selector-error";
	}
	// force calculate
	calculate()
}

// Validate the desired ride through time
function set_t(t_in)
{
	// if the desired ride through time setting is a number
	if (isFinite(t_in))
	{
		// create a number for the time entered
		t = new Number(t_in);
		// format the time and store it back in the box
		t_inp.value = t.toFixed(2);
		
		// if the time is between 0.1 and 10.0 inclusive
		if (t_in >= 0.1 & t_in <= 10.0)
		{
			// set the time range font to lightgreen and bold
			tr.className="selector-selected";
			t_ok = true;
		}
		else
		// time entered is out of range
		{
			// set the time range font to red
			tr.className="selector-error";
			t_ok = false;
		}
	}
	// force calculate
	calculate();
}

// Calculate the time for each model and select recommended models
function calculate(theinput)
{
var rt;				// ride through time calculated
var r1, r2, r3;
var candidates;		// stores only valid candidate products
var index;			// used to index the candidates array
var rtemp;

	// Create a new product array that will only contain valid candidates
	candidates = new Array();

	// only calculate if the paramters entered are OK
	if (v_ok & i_ok & pf_ok & t_ok)
	{
		var
			d, y, c
		
		d = new Date();
		y = d.getYear() + 1;
		d.setYear(y);
		
		//c = "Voltage=" + v + ";" +
		//	"Current=" + i + ";" +
		//	"Power Factor=" + pf + ";" +
		//	"Ride Through Time=" + t + ";expires=" + d.toGMTString();
			
		//document.cookie = c;
		//alert ("Writing cookie");
		document.cookie = "Voltage=" + escape(v) + ";expires=" + d.toGMTString();
		document.cookie = "Current=" + escape(i) + ";expires=" + d.toGMTString();
		document.cookie = "Power Factor=" + escape(pf) + ";expires=" + d.toGMTString();
		document.cookie = "Ride Through Time=" + escape(t) + ";expires=" + d.toGMTString();
		
		//var aCookie = document.cookie.split("; ");
		//for (var ii=0; ii < aCookie.length; ii++)
		//{
			// a name/value pair (a crumb) is separated by an equal sign
		//	var aCrumb = aCookie[ii].split("=");
		//	alert("Pair is; " + aCrumb[0] + "=" + aCrumb[1]);
		//}
		//alert("End Writing Cookie");

		
		
		// for each model in the products array
		for (model in products)
		{
			// calculate the ride through time for this model
			rt = products[model].rt(v, i, pf); 
		}
		
		// set the candidate index to 0
		index = 0;
		// for each model in the products array
		for (model in products)
		{
			// if the current for the model is acceptable and 
			// the voltage model matches the selected model
			if ((products[model].current >= i) & (products[model].nominal == v_model))
			{
				// add the candidate to the candidates array from the products array
				candidates[index] = products[model];
				index++;		// increment the index to the candidantes
			}
		}
		
		// sort the candidates array using the prodsort method
		candidates.sort(prodsort);
		
		// find the first candidate that exceeds the desired time
		for (index=0; index<candidates.length; index++)
		{
			if (candidates[index].time >= t)
			{
				break;
			}
		}
		
		// if the found candidate is not the first candidate then
		if (index > 0)
		{
			// recommendations are from one before found candidate to one after found candidate
			r1 = candidates[index - 1];
			r2 = candidates[index];
			
			// if one after found candidate exists, use it
			if (candidates[index+1] != undefined)
			{
				r3 = candidates[index + 1];
			}
			else
			{
				r3 = undefined;
			}
		}
		else
		// found candidate is the first candidate
		{
			// there is no lower candidate so recommend this candidate
			r1 = undefined;
			r2 = candidates[index];
			r3 = candidates[index+1];
		}
		
		// if both of the lower candidates are found
		if ((r1 != undefined) & (r2 != undefined))
		{
			// if their times are the same recommend the preferred unit
			if (r1.time == r2.time)
			{
				// if r2 is not preferred and r1 is preferred switch these rows
				if ((r2.preferred == false) & (r1.preferred == true))
				{
					rtemp = r1;
					r1 = r2;
					r2 = rtemp;
				}
			}
		}
		
		// if both of the upper candidates are found
		if ((r2 != undefined) & (r3 != undefined))
		{
			// if their times are the same, recommend the preferred unit
			if (r2.time == r3.time)
			{
				// if r2 is not preferred and r3 is preferred then swith these rows
				if ((r2.preferred == false) & (r3.preferred == true))
				{
					rtemp = r2;
					r2 = r3;
					r3 = rtemp;
				}
			}
		}
		
		// if lower candidate is defined	
		if (r1 != undefined)
		{
			// write out the values and make them visible
			out1.innerHTML = "<A href='../pdf/dpi/" + r1.pdf + ".pdf'>" + r1.model;
			out1t.innerHTML = Math.round(r1.time*100)/100 + " s";
			out1c.visible = true;
		}
		else
		// lower candidate is not defined
		{
			// erase the values and make them invisible
			out1.innerHTML = "";
			out1t.innerHTML = "";
			out1c.visible = false;
			out1c.visible = false;
		}
		
		// if recommended candidate is defined
		if (r2 != undefined)
		{
			// write out the values and make the visible
			out2.innerHTML = "<A href='../pdf/dpi/" + r2.pdf + ".pdf'>" + r2.model;
			out2t.innerHTML = Math.round(r2.time*100)/100 + " s";
			out2c.checked = true;
			
			// if the current for the recommended model is below 10A, recommend the 10A bypass switch
			if (r2.current <= 10)
			{
				byp10c.checked = true;
				byp40c.checked = false;
			}
			else
			// else recommend the 40A bypass switch
			{
				byp10c.checked = false;
				byp40c.checked = true;
			}
		}
		else
		// the recommended candidate is not defined so erase the values
		{
			out2.innerHTML = "";
			out2t.innerHTML = "";
		}
		
		// if the upper candidate is defined
		if (r3 != undefined)
		{
			// write out the values for this candidate
			out3.innerHTML = "<A href='../pdf/dpi/" + r3.pdf + ".pdf'>" + r3.model;
			out3t.innerHTML = Math.round(r3.time*100)/100 + " s";
		}
		else
		// the upper candidate is not defined
		{
			// erase the values 
			out3.innerHTML = "";
			out3t.innerHTML = "";
		}
		
	}
	else
	// parameters are not Ok so erase the values for all candidates
	{
		out1.innerHTML = "";
		out1t.innerHTML = "";
		out2.innerHTML = "";
		out2t.innerHTML = "";
		out3.innerHTML = "";
		out3t.innerHTML = "";
	}
	// force checking of the update bypass switch (used for more complicated selection)
	updbyp();	
}

// Update the bypass switch recommendation
function updbyp()
{
var
	m,		// points to model in the product array
	model	// model text information
	
	// disable both recommendations
	byp10c.checked = false;
	byp40c.checked = false;
	model = "";		// set the model to nothing
	
	// if the current entered is greater than 9.5 amps
	if(i > 9.5)
	{
		// recommend the 40A bypass switch
		byp40c.checked = true;
	}
	else
	// the current is below 9.5A
	{
		if (i <= 9.5)
		{
			// recommend the 10A bypass switch
			byp10c.checked = true;
		}
	}

// this section is commented out
// it could be used to make the bypass recommendation based on the parameters of the model recommended
/*	
	if (out1c.checked == true)
	{
		model = out1.innerText;
		for (m in products)
		{
			if (products[m].model == model)
			{
				if (products[m].current <= 10)
				{
					byp10c.checked = true;
				}
				else
				{
					byp40c.checked = true;
				}
			}
		}
	}
	if (out2c.checked == true)
	{
		model = out2.innerText;
		for (m in products)
		{
			if (products[m].model == model)
			{
				if (products[m].current <= 10)
				{
					byp10c.checked = true;
				}
				else
				{
					byp40c.checked = true;
				}
			}
		}
	}
	if (out3c.checked == true)
	{
		model = out3.innerText;
		for (m in products)
		{
			if (products[m].model == model)
			{
				if (products[m].current <= 10)
				{
					byp10c.checked = true;
				}
				else
				{
					byp40c.checked = true;
				}
			}
		}
	}
*/
}
//////////////////////////////////////////////////////////////////////////
//				© Copyright Measurlogic 2003							//
//////////////////////////////////////////////////////////////////////////
