var lstCustoms	= new Array();
var lstTables	= new Array();

		
function Extract()
{
	lstCustoms	= strCustoms.split( ";" );
	lstTables	= strTables.split( ";" );
	
	for (indCustom=1; indCustom<=parseInt( lstCustoms[0] ); indCustom++)
	{
		lstCustoms[indCustom] = lstCustoms[indCustom].split( ":" );
	}
	
	for (indTable=1; indTable<=parseInt( lstTables[0] ); indTable++)
	{
		lstTables[indTable] = lstTables[indTable].split( "," );
		
		if (parseInt( lstTables[indTable][1] ) <= lstCustoms[0])// && parseInt( lstTables[indTable][2] ) > 1)
		{
			for (indX=0; indX<lstTables[indTable][2]; indX++)
				lstTables[indTable][4 + indX] = lstTables[indTable][4 + indX].split( ":" );
			
			if (parseInt( lstTables[indTable][1] ))
				for (indY=0; indY<lstTables[indTable][3]; indY++)
					lstTables[indTable][4 + parseInt( lstTables[indTable][2] ) + indY] = lstTables[indTable][4 + parseInt( lstTables[indTable][2] ) + indY].split( ":" );
		}
	}
}


function EvaluateTableField( field )
{
	field = field==null ? "0.00" : field.toString();
	
	var results;
	
	if (results = field.match( /^C(\d)=T(\d)$/ ))
	{
		var selCustom	= eval( "document.frmProduct.selCustom" + results[1] );
		var lstTable	= lstTables[results[2]];
		var index		= selCustom!=null ? selCustom.selectedIndex - 1 : -1;
		
		if (index < 0)
			return "";
		
		return EvaluateTableField( lstTable[4 + parseInt( lstTable[2] ) + parseInt( lstTable[3] ) + index] );
	}
	else if (results = field.match( /^C(\d):C(\d)=T(\d)$/ ))
	{
		var selCustomX	= eval( "document.frmProduct.selCustom" + results[1] );
		var selCustomY	= eval( "document.frmProduct.selCustom" + results[2] );
		var lstTable	= lstTables[results[3]];
		var indX		= selCustomX!=null ? selCustomX.selectedIndex - 1 : -1;
		var indY		= selCustomY!=null ? selCustomY.selectedIndex - 1 : -1;
		
		if (indX < 0 || indY < 0)
			return "";
		
		return EvaluateTableField( lstTable[4 + parseInt( lstTable[2] ) + parseInt( lstTable[3] ) + indY * parseInt( lstTables[indTable][2] ) + indX] );
	}
	else if (field.substr(0,1) == "x")
		return "fltPermutation *= parseFloat( " + field.substring( 1, field.length ) + " );";
	else
		return "fltTotal += parseFloat( " + field + " );";
}

function Refresh()
{
	fltTotal       = parseFloat( 0.00 );
	fltPermutation = parseFloat( 1.00 );	
	var price_error = false;
	
	for (indTable=1; indTable<=parseInt( lstTables[0] ); indTable++)
	{
		indNamesX	= 4;
		indNamesY	= indNamesX + parseInt( lstTables[indTable][2] );
		indData		= indNamesY + parseInt( lstTables[indTable][3] );
		
		if (!parseInt( lstTables[indTable][0] ) && !parseInt( lstTables[indTable][1] ))
			continue;
		
		if (parseInt( lstTables[indTable][1] ) > parseInt( lstCustoms[0] ))
		{
			if (lstTables[indTable][4].length)
				indX = parseInt( eval( "document.frmProduct.selCustom" + lstTables[indTable][4] + ".selectedIndex" ) ) - 1;
			else
				indX = 0;
			
			if (parseInt( lstTables[indTable][3] ) > 1)
				indY = parseInt( eval( "document.frmProduct.selCustom" + lstTables[indTable][4 + parseInt( lstTables[indTable][2] )] + ".selectedIndex" ) ) - 1;
			else
				indY = 0;
			
			// ISO : THIS IS UGLY //
			if (lstCustoms[parseInt( lstTables[indTable][0] )][0] == "Custom Range");
			else
			{
				txtCustom		= eval( "document.frmProduct.txtCustom"		+ lstTables[indTable][0] );
				txtCustomView	= eval( "document.frmProduct.txtCustomView"	+ lstTables[indTable][0] );
				
				var value = parseFloat( txtCustom.value );
				var min = eval( "document.frmProduct.hidCustomMin" + lstTables[indTable][0] + ".value" );
				min = min==null ? 0 : min;
				var max = eval( "document.frmProduct.hidCustomMax" + lstTables[indTable][0] + ".value" );
				max = max==null ? 0 : max;
				
				if ((txtCustom != null) && txtCustom.value.length)
				{
					if (!isNaN( txtCustom.value ) && (value >= min && value <= max))
					{
						if (txtCustomView != null) {
							var format = eval( "document.frmProduct.hidCustomFormat" + lstTables[indTable][0] + ".value" );
							if (format == "tenth") {
								value = parseInt( value * 10 ).toString();
								while (value.length < 3) {
									value = '0'+ value;
								}
							}
							else if (format == "nenth") {
								value = parseInt( value * 10 ).toString();
								while (value.length < 2) {
									value = '0'+ value;
								}
								value = 'N'+ value;
							}
							else if (format == "length") {
								value = parseInt( value ).toString();
								while (value.length < 3) {
									value = '0'+ value;
								}
							}
							txtCustomView.value = value;
						}
						
						EvaluateTableField( lstTables[indTable][indY * parseInt( lstTables[indTable][2] ) + indX + indData] );
						
						var field = lstTables[indTable][indY * parseInt( lstTables[indTable][2] ) + indX + indData]
						field = field==null ? "0.00" : field.toString();
						
						if (field.substr(0,1) == "x")
							fltTotal += (indX < 0) || (indY < 0) ? 0.00 : parseFloat( txtCustom.value ) * parseFloat( field.substring( 1, field.length ) );
						else
							fltTotal += (indX < 0) || (indY < 0) ? 0.00 : parseFloat( txtCustom.value ) * parseFloat( field );
							
						//fltTotal += (indX < 0) || (indY < 0) ? 0.00 : parseFloat( txtCustom.value ) * parseFloat( lstTables[indTable][indY * parseInt( lstTables[indTable][2] ) + indX + indData] );
						
						if (txtCustomView != null) {
							txtCustomView.style.color = "#333333";
						}
					}
					else {
						price_error = true;
						if (txtCustomView != null) {
							txtCustomView.value = "ERR";
							txtCustomView.style.color = "#ff0000";
						}
					}
				}
				else {
					if (txtCustomView != null)
						txtCustomView.value = "---";
				}
			}
		}
		else
		{
			if (parseInt( lstTables[indTable][2] ) <= 1)
			{
				eval( EvaluateTableField( lstTables[indTable][indData] ));
				
				/*var field = lstTables[indTable][indData].toString();
				
				if (field.substr(0,1) == "x")
					fltPermutation *= parseFloat( field.substring( 1, field.length ) );
				else
					fltTotal += parseFloat( field );*/
					
				//fltTotal += parseFloat( lstTables[indTable][indData] );	
			}
			else
			{
				selCustomX		= eval( "document.frmProduct.selCustom"		+ lstTables[indTable][0] );
				txtCustomViewX	= eval( "document.frmProduct.txtCustomView"	+ lstTables[indTable][0] );
				
				if (selCustomX != null)
					indX = selCustomX.selectedIndex - 1;
				else
					indX = -1;
				
				// ISO : THIS IS UGLY //
				if ((parseInt( lstTables[indTable][0] ) < lstCustoms[0]) && (lstCustoms[parseInt( lstTables[indTable][0] ) + 1][0] == "Custom Range"))
				{
					var objSpanC, objSpanF, objSpanNA, objSpanView, objSpanViewNA;
					var strUnits = "";
					
					if (document.all)
					{
						objSpanC		= document.all["spanCustomC"		+ (parseInt(lstTables[indTable][0]) + 1)];
						objSpanF		= document.all["spanCustomF"		+ (parseInt(lstTables[indTable][0]) + 1)];
						objSpanNA		= document.all["spanCustomNA"		+ (parseInt(lstTables[indTable][0]) + 1)];
					}
					else if(document.getElementById)
					{
						objSpanC		= document.getElementById( "spanCustomC"		+ (parseInt(lstTables[indTable][0]) + 1) );
						objSpanF		= document.getElementById( "spanCustomF"		+ (parseInt(lstTables[indTable][0]) + 1) );
						objSpanNA		= document.getElementById( "spanCustomNA"		+ (parseInt(lstTables[indTable][0]) + 1) );
					}
					
					txtCustomView	= eval( "document.frmProduct.txtCustomView"		+ (parseInt(lstTables[indTable][0]) + 1) );
					
					if (indX >= 0)
					{
						if (lstTables[indTable][4+indX][0] == "YC")
						{
							strUnits					= "C";
							objSpanC.style.display		= "inline";
							objSpanF.style.display		= "none";
							objSpanNA.style.display		= "none";
							txtCustomView.style.display	= "inline";
							txtCustomViewX.style.display	= "none";
						}
						else if (lstTables[indTable][4+indX][0] == "YF")
						{
							strUnits					= "F";
							objSpanC.style.display		= "none";
							objSpanF.style.display		= "inline";
							objSpanNA.style.display		= "none";
							txtCustomView.style.display	= "inline";
							txtCustomViewX.style.display	= "none";
						}
						else
						{
							strUnits					= "";
							objSpanC.style.display		= "none";
							objSpanF.style.display		= "none";
							objSpanNA.style.display		= "inline";
							txtCustomView.style.display	= "none";
							txtCustomViewX.style.display	= "inline";
						}
					}
					else
					{
						strUnits					= "";
						objSpanC.style.display		= "none";
						objSpanF.style.display		= "none";
						objSpanNA.style.display		= "inline";
						txtCustomView.style.display	= "none";
						txtCustomViewX.style.display	= "inline";
					}
					
					if (strUnits.length)
					{
						txtCustomFrom	= eval( "document.frmProduct.txtCustomFrom"		+ strUnits + (parseInt(lstTables[indTable][0]) + 1) );
						txtCustomTo		= eval( "document.frmProduct.txtCustomTo"		+ strUnits + (parseInt(lstTables[indTable][0]) + 1) );
						txtCustomFromC	= eval( "document.frmProduct.txtCustomFromC"	+ (parseInt(lstTables[indTable][0]) + 1) );
						txtCustomToC	= eval( "document.frmProduct.txtCustomToC"		+ (parseInt(lstTables[indTable][0]) + 1) );
						txtCustomFromF	= eval( "document.frmProduct.txtCustomFromF"	+ (parseInt(lstTables[indTable][0]) + 1) );
						txtCustomToF	= eval( "document.frmProduct.txtCustomToF"		+ (parseInt(lstTables[indTable][0]) + 1) );
						
						if ((txtCustomFromC != null) && (txtCustomToC != null) && (txtCustomFromF != null) && (txtCustomToF != null))
						{
							if (strUnits == "C")
							{
								txtCustomFromF.value	= Math.round( CelsiusToFahrenheit( txtCustomFromC.value ) );
								txtCustomToF.value		= Math.round( CelsiusToFahrenheit( txtCustomToC.value ) );
							}
							else if (strUnits == "F")
							{
								txtCustomFromC.value	= Math.round( FahrenheitToCelsius( txtCustomFromF.value ) );
								txtCustomToC.value		= Math.round( FahrenheitToCelsius( txtCustomToF.value ) );
							}
						}
						
						if ((txtCustomView != null) && (txtCustomFrom != null) && (txtCustomTo != null))
						{
							txtCustomView.value  = "[" + (((txtCustomFrom != null) && txtCustomFrom.value.length && !isNaN( txtCustomFrom.value )) ? txtCustomFrom.value : "---") + " / ";
							txtCustomView.value += (((txtCustomTo != null) && txtCustomTo.value.length && !isNaN( txtCustomTo.value )) ? txtCustomTo.value : "---") + " " + strUnits + "]";
						}
					}
					else
						if (txtCustomView != null)
							txtCustomView.value = "-----------";
				}
				
				if (indX >= 0)
				{
					if (txtCustomViewX != null)
						txtCustomViewX.value = selCustomX.options[selCustomX.selectedIndex].text.split( " : " )[0];
					
					if (parseInt( lstTables[indTable][1] ))
					{
						selCustomY		= eval( "document.frmProduct.selCustom"		+ lstTables[indTable][1] );
						txtCustomViewY	= eval( "document.frmProduct.txtCustomView"	+ lstTables[indTable][1] );
						
						if (selCustomY != null)
							indY = selCustomY.selectedIndex - 1;
						else
							indY = -1;
						
						if (indY >=0)
						{
							if (txtCustomViewY != null)
								txtCustomViewY.value = selCustomY.options[selCustomY.selectedIndex].text.split( " : " )[0];
							
							eval( EvaluateTableField( lstTables[indTable][indY * parseInt( lstTables[indTable][2] ) + indX + indData] ) );
							
							/*var field = lstTables[indTable][indY * parseInt( lstTables[indTable][2] ) + indX + indData].toString();
							
							if (field.substr(0,1) == "x")
								fltPermutation *= parseFloat( field.substring( 1, field.length ) );
							else
								fltTotal += parseFloat( field );*/
							
							//fltTotal += parseFloat( lstTables[indTable][indY * parseInt( lstTables[indTable][2] ) + indX + indData] );
						}
						else
							if (txtCustomViewY != null)
								txtCustomViewY.value = "---";
					}
					else
					{
						eval( EvaluateTableField( lstTables[indTable][indX + indData] ) );
						
						/*var field = lstTables[indTable][indX + indData].toString();
						
						if (field.substr(0,1) == "x")
							fltPermutation *= parseFloat( field.substring( 1, field.length ) );
						else
							fltTotal += parseFloat( field );*/
						
						//fltTotal += parseFloat( lstTables[indTable][indX + indData] );
					}
				}
				else
					if (txtCustomViewX != null)
						txtCustomViewX.value = "---";
			}
		}
	}
		
	var fltTotal_ita	= ((fltTotal * g_fltCurrency_ita)	+ fltPrice_ita) * fltPermutation;
	var fltTotal_usa	= ((fltTotal * g_fltCurrency_usa)	+ fltPrice_usa) * fltPermutation;
	var fltTotal_can	= ((fltTotal * g_fltCurrency_can)	+ fltPrice_can) * fltPermutation;
		fltTotal		= ((fltTotal * g_fltCurrency)		+ fltPrice    ) * fltPermutation;
	
	if (g_blnRefresh)
	{
		if (price_error) {
			window.document.frmProduct.hidTotal_ita.value	= RoundPrice( 0	);
			window.document.frmProduct.hidTotal_usa.value	= RoundPrice( 0	);
			window.document.frmProduct.hidTotal_can.value	= RoundPrice( 0	);
			window.document.frmProduct.txtTotal.value	= "ERROR";
			window.document.frmProduct.txtTotal.style.color = "#ff0000";
		}
		else {
			window.document.frmProduct.hidTotal_ita.value	= RoundPrice( fltTotal_ita	);
			window.document.frmProduct.hidTotal_usa.value	= RoundPrice( fltTotal_usa	);
			window.document.frmProduct.hidTotal_can.value	= RoundPrice( fltTotal_can	);
			window.document.frmProduct.txtTotal.value	= RoundPrice( fltTotal		);
			window.document.frmProduct.txtTotal.style.color = "#333333";
		}
		
		var txtQuantity = window.document.frmProduct.txtQuantity;
		
		if (price_error) {
			window.document.frmProduct.hidNetTotal.value	= RoundPrice( 0 );
			window.document.frmProduct.txtNetTotal.value	= "ERROR";
			window.document.frmProduct.txtNetTotal.style.color = "#ff0000";
		}
		else if (txtQuantity.value.length && !isNaN( txtQuantity.value ) && (parseInt( txtQuantity.value ) > 0)) {
			window.document.frmProduct.hidNetTotal.value	= RoundPrice( fltTotal * parseFloat( document.frmProduct.txtQuantity.value ) );
			window.document.frmProduct.txtNetTotal.value	= RoundPrice( fltTotal * parseFloat( document.frmProduct.txtQuantity.value ) );
			window.document.frmProduct.txtNetTotal.style.color = "#333333";
		}
		else {
			window.document.frmProduct.hidNetTotal.value	= RoundPrice( 0 );
			window.document.frmProduct.txtNetTotal.value	= "-----";
			window.document.frmProduct.txtNetTotal.style.color = "#cccccc";
		}
	}
	
	return( true );
}

function Validate_getCustomizationIndex( offsets, customization )
{
	var index = customization;
	for (var i=0; i<offsets.length; i++) {
		if (customization > offsets[i]) {
			index--;
		}
	}
	return index;
}
function Validate( _frmTarget )
{
	var offsets = [1];
	
	for (indTable=1; indTable<=parseInt( lstTables[0] ); indTable++)
	{
		indData =  4 + parseInt( lstTables[indTable][2] ) + parseInt( lstTables[indTable][3] );
		
		if (parseInt( lstTables[indTable][1] ) > parseInt( lstCustoms[0] ))
		{
			txtCustom		= eval( "document.frmProduct.txtCustom"		+ lstTables[indTable][0] );
			hidCustomMin	= eval( "document.frmProduct.hidCustomMin"	+ parseInt(lstTables[indTable][0]) );
			hidCustomMax	= eval( "document.frmProduct.hidCustomMax"	+ parseInt(lstTables[indTable][0]) );
			
			intMin = (hidCustomMin == null) ? -99999 : hidCustomMin.value;
			intMax = (hidCustomMax == null) ?  99999 : hidCustomMax.value;
			
			if (txtCustom != null)
			{
				if (!txtCustom.value.length || isNaN( txtCustom.value ) || (parseInt( txtCustom.value ) < intMin) || (parseInt( txtCustom.value ) > intMax))
				{
					alert( "Customization #" + Validate_getCustomizationIndex( offsets, parseInt(lstTables[indTable][0]) ) + " value is invalid" );
					txtCustom.focus();
					return( false );
				}
			}
		}
		else
		{
			if (parseInt( lstTables[indTable][2] ) > 1)
			{
				selCustomX		= eval( "document.frmProduct.selCustom"		+ lstTables[indTable][0] );
				selCustomY		= eval( "document.frmProduct.selCustom"		+ lstTables[indTable][1] );
				
				if (selCustomX != null)
				{
					if (selCustomX.selectedIndex < 1)
					{
						alert( "Customization #" + Validate_getCustomizationIndex( offsets, parseInt(lstTables[indTable][0]) ) + " has no selection" );
						selCustomX.focus();
						return( false );
					}
					
					indX = selCustomX.selectedIndex - 1;
				}
				else
					indX = -1;
				
				if (selCustomY != null)
				{
					if (selCustomY.selectedIndex < 1)
					{
						alert( "Customization #" + Validate_getCustomizationIndex( offsets, parseInt(lstTables[indTable][1]) ) + " has no selection" );
						selCustomY.focus();
						return( false );
					}
				}
				
				// ISO : THIS IS UGLY //
				if ((parseInt( lstTables[indTable][0] ) < lstCustoms[0]) && (lstCustoms[parseInt( lstTables[indTable][0] ) + 1][0] == "Custom Range") && (indX >= 0))
				{
					offsets[offsets.length] = parseInt(lstTables[indTable][0]);
					
					var strUnits = "";
					
					if (lstTables[indTable][4+indX][0] == "YC")
						strUnits = "C";
					else if (lstTables[indTable][4+indX][0] == "YF")
						strUnits = "F";
					
					if (strUnits.length)
					{
						txtCustomFrom	= eval( "document.frmProduct.txtCustomFrom"	+ strUnits + (parseInt(lstTables[indTable][0]) + 1) );
						txtCustomTo		= eval( "document.frmProduct.txtCustomTo"	+ strUnits + (parseInt(lstTables[indTable][0]) + 1) );
						hidCustomMin	= eval( "document.frmProduct.hidCustomMin"	+ strUnits + (parseInt(lstTables[indTable][0]) + 1) );
						hidCustomMax	= eval( "document.frmProduct.hidCustomMax"	+ strUnits + (parseInt(lstTables[indTable][0]) + 1) );
						
						intMin = (hidCustomMin == null) ? -99999 : hidCustomMin.value;
						intMax = (hidCustomMax == null) ?  99999 : hidCustomMax.value;
						
						if (txtCustomFrom != null)
						{
							if (!txtCustomFrom.value.length || isNaN( txtCustomFrom.value ) || (parseInt( txtCustomFrom.value ) < intMin) || (parseInt( txtCustomFrom.value ) > intMax) || (parseInt( txtCustomFrom.value ) > parseInt( txtCustomTo.value )))
							{
								alert( "Customization #" + Validate_getCustomizationIndex( offsets, parseInt(lstTables[indTable][0]) ) + " minimum value is invalid" );
								txtCustomFrom.focus();
								return( false );
							}
						}
						
						if (txtCustomTo != null)
						{
							if (!txtCustomTo.value.length || isNaN( txtCustomTo.value ) || (parseInt( txtCustomTo.value ) > intMax) || (parseInt( txtCustomTo.value ) < intMin) || (parseInt( txtCustomTo.value ) < parseInt( txtCustomFrom.value )))
							{
								alert( "Customization #" + Validate_getCustomizationIndex( offsets, parseInt(lstTables[indTable][0]) ) + " maximum value is invalid" );
								txtCustomTo.focus();
								return( false );
							}
						}
					}
				}
			}
		}
	}
	
	var txtQuantity = _frmTarget.txtQuantity;
	
	if ((txtQuantity != null) && (!txtQuantity.value.length || isNaN( txtQuantity.value ) || (parseInt( txtQuantity.value ) < 1)))
	{
		alert( "Quantity is invalid" );
		txtQuantity.focus();
		return( false );
	}
	
	return( true );
}

function Compile( _objOutput )
{
	lstTweak = new Array( window.document.frmProduct.txtTotal.value );
	
	for (indCustom=1; indCustom<=parseInt( lstCustoms[0] ); indCustom++)
	{
		for (indTable=1; indTable<=parseInt( lstTables[0] ); indTable++)
		{
			if (parseInt( lstTables[indTable][0] ) == indCustom)
			{
				indAxis		= 0;
				indNames	= 4;
				break;
			}
			else if (parseInt( lstTables[indTable][1] ) == indCustom)
			{
				indAxis		= 1;
				indNames	= 4 + parseInt( lstTables[indTable][2] );
				break;
			}
		}
		
		if (indTable > parseInt( lstTables[0] ))
			;//lstTweak[lstTweak.length] = "";
		else
		{
			if (parseInt( lstTables[indTable][1] ) > parseInt( lstCustoms[0] ))
			{
				// ISO : THIS IS UGLY //
				if (lstCustoms[parseInt( lstTables[indTable][0] )][0] == "Custom Range")
				{
					objSelect = eval( "document.frmProduct.selCustom" + (parseInt(lstTables[indTable][0])-1) );
					
					if (objSelect.selectedIndex > 0)
						strValue = objSelect.options[objSelect.selectedIndex].text.substring( 0, 2 );
					else
						strValue = "";
					
					if (strValue == "YC")
						lstTweak[lstTweak.length] = eval( "document.frmProduct.txtCustomFromC" + lstTables[indTable][0] + ".value" ) + "/" + eval( "document.frmProduct.txtCustomToC" + lstTables[indTable][0] + ".value" ) + "/C";
					else if (strValue == "YF")
						lstTweak[lstTweak.length] = eval( "document.frmProduct.txtCustomFromF" + lstTables[indTable][0] + ".value" ) + "/" + eval( "document.frmProduct.txtCustomToF" + lstTables[indTable][0] + ".value" ) + "/F";
					else
						lstTweak[lstTweak.length] = "";
				}
				else
					lstTweak[lstTweak.length] =  eval( "document.frmProduct.txtCustom" + indCustom + ".value" );
			}
			else
			{
				if (parseInt( lstTables[indTable][2 + indAxis] ) <= 1)
					lstTweak[lstTweak.length] = "";
				else
				{
					lstTweak[lstTweak.length] = eval( "document.frmProduct.selCustom" + indCustom + ".selectedIndex" ) - 1;
				}
			}
		}
	}
	
	if (_objOutput != null)
		_objOutput.value = lstTweak.join( "@" );
	else
		return( lstTweak.join( "@" ) );
}

function Serialize( _objOutput )
{
	lstSerial = new Array();
	
	for (indCustom=1; indCustom<=parseInt( lstCustoms[0] ); indCustom++)
	{
		for (indTable=1; indTable<=parseInt( lstTables[0] ); indTable++)
		{
			if (parseInt( lstTables[indTable][0] ) == indCustom)
			{
				indAxis		= 0;
				indNames	= 4;
				break;
			}
			else if (parseInt( lstTables[indTable][1] ) == indCustom)
			{
				indAxis		= 1;
				indNames	= 4 + parseInt( lstTables[indTable][2] );
				break;
			}
		}
		
		if (indTable > parseInt( lstTables[0] ))
			;//lstSerial[lstSerial.length] = "";
		else
		{	
			if (parseInt( lstTables[indTable][1] ) > parseInt(lstCustoms[0] ))
			{
				// ISO : THIS IS UGLY //
				if (lstCustoms[parseInt( lstTables[indTable][0] )][0] == "Custom Range")
				{
					objSelect = eval( "document.frmProduct.selCustom" + (parseInt(lstTables[indTable][0])-1) );
					
					if (objSelect.selectedIndex > 0)
						strValue = objSelect.options[objSelect.selectedIndex].text.substring( 0, 2 );
					else
						strValue = "";
						
					if (strValue == "YC")
						lstSerial[lstSerial.length] = "[" + eval( "document.frmProduct.txtCustomFromC" + lstTables[indTable][0] + ".value" ) + "/" + eval( "document.frmProduct.txtCustomToC" + lstTables[indTable][0] + ".value" ) + "C]";
					else if (strValue == "YF")
						lstSerial[lstSerial.length] = "[" + eval( "document.frmProduct.txtCustomFromF" + lstTables[indTable][0] + ".value" ) + "/" + eval( "document.frmProduct.txtCustomToF" + lstTables[indTable][0] + ".value" ) + "F]";
				}
				else
				{
					var value = eval( "document.frmProduct.txtCustom" + indCustom + ".value" );
					var format = eval( "document.frmProduct.hidCustomFormat" + indCustom + ".value" );
					if (format == "tenth") {
						value = parseInt( parseFloat( value ) * 10 ).toString();
						while (value.length < 3) {
							value = '0'+ value;
						}
					}
					lstSerial[lstSerial.length] = value;
				}
			}
			else
			{
				if (parseInt( lstTables[indTable][2 + indAxis] ) <= 1)
					lstSerial[lstSerial.length] = lstTables[indTable][indNames][0];
				else
				{
					var indSelected = eval( "document.frmProduct.selCustom" + indCustom + ".selectedIndex" ) - 1;
					var strSelectedValue = indSelected < 0 ? "n/a" : lstTables[indTable][indNames + indSelected][0];
					
					if ((parseInt( lstTables[indTable][0] ) < lstCustoms[0]) && (lstCustoms[parseInt( lstTables[indTable][0] ) + 1][0] == "Custom Range") && ((strSelectedValue=="YC") || (strSelectedValue=="YF")))
						;
					else
						lstSerial[lstSerial.length] = strSelectedValue
				}
			}
		}
	}
	
	if (_objOutput != null)
		_objOutput.value = lstSerial.join( "@" );
	else
		return( lstSerial.join( "@" ) );
}

function SetEvents()
{
	for (indCustom=1; indCustom<=parseInt( lstCustoms[0] ); indCustom++)
	{
		txtCustom		= eval( "document.frmProduct.txtCustom"			+ indCustom );
		txtCustomFromC	= eval( "document.frmProduct.txtCustomFromC"	+ indCustom );
		txtCustomToC	= eval( "document.frmProduct.txtCustomToC"		+ indCustom );
		txtCustomFromF	= eval( "document.frmProduct.txtCustomFromF"	+ indCustom );
		txtCustomToF	= eval( "document.frmProduct.txtCustomToF"		+ indCustom );
		txtCustomView	= eval( "document.frmProduct.txtCustomView"		+ indCustom );
		
		if (txtCustom != null)
		{
			txtCustom.onkeydown		= function() { Refresh(); }
			txtCustom.onkeypress	= function() { Refresh(); }
			txtCustom.onkeyup		= function() { Refresh(); }
		}
		
		if (txtCustomFromC != null)
		{
			txtCustomFromC.onkeydown	= function() { Refresh(); }
			txtCustomFromC.onkeypress	= function() { Refresh(); }
			txtCustomFromC.onkeyup		= function() { Refresh(); }
		}
		
		if (txtCustomToC != null)
		{
			txtCustomToC.onkeydown	= function() { Refresh(); }
			txtCustomToC.onkeypress	= function() { Refresh(); }
			txtCustomToC.onkeyup	= function() { Refresh(); }
		}
		
		if (txtCustomFromF != null)
		{
			txtCustomFromF.onkeydown	= function() { Refresh(); }
			txtCustomFromF.onkeypress	= function() { Refresh(); }
			txtCustomFromF.onkeyup		= function() { Refresh(); }
		}
		
		if (txtCustomToF != null)
		{
			txtCustomToF.onkeydown	= function() { Refresh(); }
			txtCustomToF.onkeypress	= function() { Refresh(); }
			txtCustomToF.onkeyup	= function() { Refresh(); }
		}
		
		if (txtCustomView != null)
		{
			txtCustomView.onkeydown		= function() { return( false ); }
			txtCustomView.onkeypress	= function() { return( false ); }
			txtCustomView.onkeyup		= function() { return( false ); }
		}
	}
	
	if (window.document.frmProduct.txtTotal != null)
	{
		window.document.frmProduct.txtTotal.onchange	= function() { this.value = this.form.hidTotal.value; return( false ); }
		window.document.frmProduct.txtTotal.onkeydown	= function() { this.value = this.form.hidTotal.value; return( false ); }
		window.document.frmProduct.txtTotal.onkeypress	= function() { this.value = this.form.hidTotal.value; return( false ); }
		window.document.frmProduct.txtTotal.onkeyup		= function() { this.value = this.form.hidTotal.value; return( false ); }
	}
	
	if (window.document.frmProduct.txtNetTotal != null)
	{
		window.document.frmProduct.txtNetTotal.onchange		= function() { this.value = this.form.hidNetTotal.value; return( false ); }
		window.document.frmProduct.txtNetTotal.onkeydown	= function() { this.value = this.form.hidNetTotal.value; return( false ); }
		window.document.frmProduct.txtNetTotal.onkeypress	= function() { this.value = this.form.hidNetTotal.value; return( false ); }
		window.document.frmProduct.txtNetTotal.onkeyup		= function() { this.value = this.form.hidNetTotal.value; return( false ); }
	}
	
	if (window.document.frmProduct.txtQuantity != null)
	{
		window.document.frmProduct.txtQuantity.onchange		= function() { Refresh(); }
		window.document.frmProduct.txtQuantity.onkeydown	= function() { window.setTimeout( "window.document.frmProduct.txtQuantity.onchange()", 1 ); }
		window.document.frmProduct.txtQuantity.onkeypress	= function() { window.setTimeout( "window.document.frmProduct.txtQuantity.onchange()", 1 ); }
		window.document.frmProduct.txtQuantity.onkeyup		= function() { window.setTimeout( "window.document.frmProduct.txtQuantity.onchange()", 1 ); }
	}
}

function SetLayerStyle( strID, strStyle, varValue )
{
	if (document.all)
		pLayer = document.all[strID];
	else if (document.getElementById)
		pLayer = document.getElementById( strID );
	
	if (pLayer)
		eval( "pLayer.style." + strStyle + "=" + (isNaN(varValue)?"'":"") + varValue + (isNaN(varValue)?"'":"") );
}

function CelsiusToFahrenheit( _fltDegrees ) { return( (parseFloat( _fltDegrees ) * 1.8) + 32.0 ); }
function FahrenheitToCelsius( _fltDegrees ) { return( (parseFloat( _fltDegrees ) - 32.0) / 1.8 ); }

function SetCustomization()
{
	for (var i=0; i<parseInt( lstCustoms[0] ); i++)
	{
		var indCustom      = i + 1;
		var selCustom      = eval( "document.frmProduct.selCustom"      + indCustom );
		var txtCustom      = eval( "document.frmProduct.txtCustom"      + indCustom );
		var txtCustomFromC = eval( "document.frmProduct.txtCustomFromC" + indCustom );
		var txtCustomToF   = eval( "document.frmProduct.txtCustomToC"   + indCustom );
		var txtCustomFromF = eval( "document.frmProduct.txtCustomFromF" + indCustom );
		var txtCustomToF   = eval( "document.frmProduct.txtCustomToF"   + indCustom );
		
		if (arguments[i] == null)
			continue;
		
		if (selCustom)
			selCustom.selectedIndex = parseInt( arguments[i] );
		
		else if (txtCustom)
			txtCustom.value = arguments[i].toString();
		
		else if (txtCustomFromC && txtCustomToC && txtCustomFromF && txtCustomToF)
		{
			var argument         = arguments[i].toString().split( "," );
			txtCustomFromC.value = argument[0];
			txtCustomToC.value   = argument[1];
			txtCustomFromF.value = argument[2];
			txtCustomToF.value   = argument[3];
		}
	}
	
	Refresh();
}

function LockCustomization()
{
	for (var i=0; i<parseInt( lstCustoms[0] ); i++)
	{
		var indCustom      = i + 1;
		var selCustom      = eval( "document.frmProduct.selCustom"      + indCustom );
		var txtCustom      = eval( "document.frmProduct.txtCustom"      + indCustom );
		var txtCustomFromC = eval( "document.frmProduct.txtCustomFromC" + indCustom );
		var txtCustomToF   = eval( "document.frmProduct.txtCustomToC"   + indCustom );
		var txtCustomFromF = eval( "document.frmProduct.txtCustomFromF" + indCustom );
		var txtCustomToF   = eval( "document.frmProduct.txtCustomToF"   + indCustom );
		
		if (selCustom)
			selCustom.disabled = arguments[i] ? true : false;
		
		else if (txtCustom)
			txtCustom.disabled = arguments[i] ? true : false;
		
		else if (txtCustomFromC && txtCustomToC && txtCustomFromF && txtCustomToF)
		{
			var disable = arguments[i] ? true : false;
			txtCustomFromC.disabled = disable;
			txtCustomToC.disabled   = disable;
			txtCustomFromF.disabled = disable;
			txtCustomToF.disabled   = disable;
		}
	}
}

function InitializeCustomizations()
{
	//	virtual function -AKA- dummy callback function to be re-declared during execution //
}