 /* Copyright (c) On Technology Australia Pty Ltd - All Rights Reserved.
 *
 * This source may be used only by registered customers of the "eziMerchant®" range
 * of products. Use of this code by unregistered parties is an offence that will be prosecuted.
 *  Modified heavily by Hendrik Thijssens -CDAS  User 7122 as updated 1/2/2012
 * * 
 */ 
// cookie cart columns
var colProductID = 0;
var colQuantity = 1;
var colCustomFields = 2;
// product columns
var colProductPrice = 0;
var colFreightLocal = 1;
var colFreightDomestic = 2;
var colFreightInternational = 3;
var colProductWeight = 4;
var colTaxLocal = 5;
var colTaxDomestic = 6;
var colTaxInternational = 7;
// product info columns
var colProductCode = 0;
var colProductDesc = 1; 
var colCustomFieldKeys = 2;

// data structure
var arrCookie = document.cookie.split("; "); // in case there is more than one cookie
var arrItem;
var arrLine;
var bProcessCart = false;

// * Added by hjt 2/11/2007
    
	 var varOnLine = true;   //<<======================== to identify which of the two Websites is used
	 var varDataInputMode = true;
	 var varCheckOutNow = false;
     var colBasicRate = 0;
     var colVariableRate = 1;
     varPrompt = " ";
     var varWeight = 0;

     var varDiscount = 0;
     var TradeDiscount = 0;
     var TradeDiscountNumber = 0;
     var DeliveryNumber = 0;
	 var varQuantity = 0;
     var varVariableWeight = 0;
     var varTotalWeight = 0;
     var varTotalLength = 0;
     var varLocalDeliveryCost = 0;
     var varLongHaulCost = 0;
     var varInsurance = 8.00;
     var varAdminFee = 11.00;
     var varAddOn = 1.18;

     var varConfirm = true;
 
     var extraShelfNumber = 0;
     var cabWidth = 0;
	 var extraShelfCost = parseFloat(0);
	 
	 var varCheckShoppingList = 0;
	 var varSuffix = "";
	 varURL = document.title;

     var varQtyCheck = 0;	 
	 var varFieldValue = " ";	 
     var varCustomFieldValue = 0;
     var  varCustomFieldName = "This is the fieldname "
     var varIndex = 0;
	 
	 var varFieldCheck = 0;
	 var old_iLineIdx = 0;
	 var  iLineIdx = 0;
	 var varPriceFactor = 1;
	 var varStyle = 0;
	 var varProdStyle = " ";
	 var varProductCode = " ";
	 var newProductCode = " ";
	 var varShortCode = " ";
	 var varLengthShortCode = 2;
	 var varSubFieldIndex = 0;
	 var varErrors = 0;
	 var varBypass = 0;
	 var BypassCheckProductRange = false;
	 var PanelKBQuestion = false;

	 var FinalCheck = false;
	 var varStyleNeeded = 0;      //        checkIfStyleNeeded(iProdID)       
	 var varDeleteLine = false;
	 var varOrderCost = 0;
	 var varLHWidth = 0;
	 var varRHWidth = 0;
	 var varDoorSize = 0;	 
	 var varZone = " ";
	 
	 var ProductDoorStyle1 = "Nil";
	 var ProductDoorStyle2 = "Nil";
	 var ProductDoorStyle3 = "Nil";
	 var ProductOpenStyle1 = "Nil";
	 var ProductOpenStyle2 = "Nil";
	 var ProductOpenStyle3 = "Nil";
	 var ProductPanelStyle1 = "Nil";
	 var ProductPanelStyle2 = "Nil";
	 var ProductPanelStyle3 = "Nil";
	 var ProductKickStyle1 = "Nil";
	 var ProductKickStyle2 = "Nil";
	 var ProductKickStyle3 = "Nil";
	 
	 var varDoorStyle1 = "Nil";
	 var varDoorStyle2 = "Nil";
	 var varDoorStyle3 = "Nil";
	 var varPanelStyle1 = "Nil";
	 var varPanelStyle2 = "Nil";
	 var varPanelStyle3 = "Nil";
	 var varKickStyle1 = "Nil";
	 var varKickStyle2 = "Nil";
	 var varKickStyle3 = "Nil";
	 var varOpenStyle1 = "Nil";
	 var varOpenStyle2 = "Nil";
	 var varOpenStyle3 = "Nil";
	 var varStyleStyle = " ";
	 	 
	 var varCustomFieldNames = "";
	 var varCustomFieldValues = "";
	 var varLHDepth = 0;
	 var varOrderTotals = false;
	 var varProductType = "Unde";
	 var varProductDesc = "Unknown";
	 var varWardRobe1 = "000";
	 var varWardRobe2 = "000";
	 var varWardRobe3 = "000";
	 var varWardRobe4 = "000";
	 var varWardRobe5 = "000";
	 var varWardRobe6 = "000";
 	 var varWardRobe7 = "000";
	 var varWardRobe8 = "000";
	 var varWardRobe9 = "000";
	 var varWardRobe10 = "000";
	 var varWardRobe11 = "000";
	 var varWardRobe12 = "000";
	 var varWardRobe13 = "000";
	 var varWardRobe14 = "000";
	 var varWardRobe15 = "000";
	 var varWardRobe16 = "000";
	 var varWardRobe17 = "000";
	 var varWardRobe18 = "000";
	 var varWardRobe19 = "000";
	 var varWardRobe20 = "000";
	 var varWardRobe21 = "000";
	 var varWardRobe22 = "000";
	 var varWardRobe23 = "000";
	 var varWardRobe24 = "000";
	 
	 var varRoomWall = "00"
	 var RoomWall = "";
	 var Section = "";
	  
	 var varWardRobeHeight1 = 0;
	 var varWardRobeHeight2 = 0;
	 var varWardRobeHeight3 = 0;
	 var varWardRobeHeight4 = 0;
	 var varWardRobeHeight5 = 0;
	 var varWardRobeHeight6 = 0;
 	 var varWardRobeHeight7 = 0;
	 var varWardRobeHeight8 = 0;
	 var varWardRobeHeight9 = 0;
	 var varWardRobeHeight10 = 0;
	 var varWardRobeHeight11 = 0;
	 var varWardRobeHeight12 = 0;
	 var varWardRobeHeight13 = 0;
	 var varWardRobeHeight14 = 0;
	 var varWardRobeHeight15 = 0;
	 var varWardRobeHeight16 = 0;
	 var varWardRobeHeight17 = 0;
	 var varWardRobeHeight18 = 0;
 	 var varWardRobeHeight19 = 0;
	 var varWardRobeHeight20 = 0;
	 var varWardRobeHeight21 = 0;
	 var varWardRobeHeight22 = 0;
	 var varWardRobeHeight23 = 0;
	 var varWardRobeHeight24 = 0;	 
	 
	 var varWardRobeDepth1 = 0;
	 var varWardRobeDepth2 = 0;
	 var varWardRobeDepth3 = 0;
	 var varWardRobeDepth4 = 0;
	 var varWardRobeDepth5 = 0;
	 var varWardRobeDepth6 = 0;
 	 var varWardRobeDepth7 = 0;
	 var varWardRobeDepth8 = 0;
	 var varWardRobeDepth9 = 0;
	 var varWardRobeDepth10 = 0;
	 var varWardRobeDepth11 = 0;
	 var varWardRobeDepth12 = 0;
	 var varWardRobeDepth13 = 0;
	 var varWardRobeDepth14 = 0;
	 var varWardRobeDepth15 = 0;
	 var varWardRobeDepth16 = 0;
	 var varWardRobeDepth17 = 0;
	 var varWardRobeDepth18 = 0;
 	 var varWardRobeDepth19 = 0;
	 var varWardRobeDepth20 = 0;
	 var varWardRobeDepth21 = 0;
	 var varWardRobeDepth22 = 0;
	 var varWardRobeDepth23 = 0;
	 var varWardRobeDepth24 = 0;
	 
  var varWardRobeShape1 = false;
  var varWardRobeShape2 = false;
  var varWardRobeShape3 = false;
  var varWardRobeShape4 = false;
  var varWardRobeShape5 = false;
  var varWardRobeShape6 = false;
  var varWardRobeShape7 = false;
  var varWardRobeShape8 = false;
  var varWardRobeShape9 = false;
  var varWardRobeShape10 = false;
  var varWardRobeShape11 = false;
  var varWardRobeShape12 = false;
  var varWardRobeShape13 = false;
  var varWardRobeShape14 = false;
  var varWardRobeShape15 = false;
  var varWardRobeShape16 = false;
  var varWardRobeShape17 = false;
  var varWardRobeShape17 = false;
  var varWardRobeShape19 = false;
  var varWardRobeShape20 = false;
  var varWardRobeShape21 = false;
  var varWardRobeShape22 = false;
  var varWardRobeShape23 = false;
  var varWardRobeShape24 = false;
  
   wardrobe = new Array("ZZZ","ZZZ","ZZZ","ZZZ","ZZZ","ZZZ","ZZZ","ZZZ","ZZZ","ZZZ","ZZZ","ZZZ","ZZZ","ZZZ","ZZZ","ZZZ","ZZZ","ZZZ","ZZZ","ZZZ","ZZZ","ZZZ","ZZZ","ZZZ");
   sections = new Array("A","B","C","D","E","F","G","H","I");
  var X = 0;  // used in checking the Wardrobe Sections
  var Y = 0; 
  var WRShelfQuantity = 0;
  var WRShelfCost = 64.50;	
	 	 
	 RoomWallSection = "000";
	 
	 var varRW1 = "NIL";
	 var varRW2 = "NIL";
	 var varRW3 = "NIL";
	 var varRW4 = "NIL";
	 var varRW5 = "NIL";
	 var varRW6 = "NIL";
	 var varRW7 = "NIL";
	 var varRW8 = "NIL";
	 var varRWError = "";
	 var varSection = " ";
	 var varLastWR = " ";
	 var varLastSection = " ";
	 
	 var varNewRoom = " ";
	 var varNewWall = " ";
	 var varNewBench = "";
	 var varNewSection = " ";
	 var varBenchTop1 = "";
     var varBenchTop2 = "";
	 var varBenchTop3 = "";
	 var varBenchTop4 = "";
	 var varBenchTop5 = "";
	 var varBenchTop6 = "";
 	 var varBenchTop7 = "";
	 var varBenchTop8 = "";
	 var varBenchTop9 = "";
	 var varBenchTop10 = "";
	 var varLeftEnd1 = 0;
	 var varLeftEnd2 = 0;
	 var varLeftEnd3 = 0;
	 var varLeftEnd4 = 0;
	 var varLeftEnd5 = 0;
	 var varLeftEnd6 = 0;
	 var varLeftEnd7 = 0;
	 var varLeftEnd8 = 0;
	 var varLeftEnd9 = 0;
	 var varLeftEnd10 = 0;
	 var varRightEnd1 = 0;
	 var varRightEnd2 = 0;
	 var varRightEnd3 = 0;
	 var varRightEnd4 = 0;
	 var varRightEnd5 = 0;
	 var varRightEnd6 = 0;
	 var varRightEnd7 = 0;
	 var varRightEnd8 = 0;
	 var varRightEnd9 = 0;
	 var varRightEnd10 = 0;
	 
	 var varBenchCost = 0;

	 var varBTNumber = 0;
	 var varMaleJoin = 0;
	 var varFemaleJoin = 0;

	 var varButtJoin = 0;
	 var varEndJoin = 0;
	 var varJoinTotal = 0;
	 var varCarcass = false;
	 var varDoor = false;
	 var varCabinet = false;
	 var varBenchtop = false;
	 var varWardrobe = false;
	 var varPanel = false;
	 var varOpenUnit = false;
	 var varStyleSpec= false;
	 var varDelivery = false;
	 var varDiscountRequest = false;
	 var varKickboard = false;
	 var varFiller = false;
	 var varHandles = false;
	 var varHardware = false;
	 var varConfirmDelivery = false;
	 var varOrderStatus = false;
	 var varInvalidProduct = false;
	 var varConfirm = false;
	 var TotalOrderCheck = false;
	 var varFatalError = false;
	 var varErrorType = 0;
	 var varErrorType2 = 0;
	 var iProdIDLast = 0;
	 
	 var varStatistics = false;
	 var FloorUnits = 0;
	 var WallUnits = 0;
	 var OpenUnits = 0;
	 var Panels = 0;
	 var Kickboards = 0;
	 var Benchtops = 0;
	 var Wardrobes = 0;
	 var Bulkheads = 0;
	 var Fillers = 0;
	 var ExtraDoors = 0;
	 var CarcassUnits = 0;
	 var ModularUnits = 0;
	 var Handles = 0;
	 var Hardware = 0;
// for benchtop calculations
     var Ll = 0;  // length of side
	 var Ww = 0;  // Width od side
	 var Ee = 0;  // Single or Double Postform
	 var varBenchWeight = 0 ;  // calculated weight of one Side
	 var BenchWeight = 0 ;  // Total weight of a benchtop product.
	 var CalculatedBenchtopCost = 0;
	 
	 var varBenchtopProcessed = false; 
	 var varLeftSideProcessed = false;
	 var varRightSideProcessed = false;
	 
	 var varLl = 0;  //Lenth of side 1
	 var varW1 = 0;  // Width of Side 1
	 var varE1 = 0;  //Edging of Side 1
	 var varBenchW1 = 0;  // Weight of Side 1
	 var varW2 = 0;  // Width of Side 2
	 var varE2 = 0;  //Edging of Side 2
	 var varBenchW2 = 0;  // Weight of Side 2
	 var varL3 = 0;  //Lenth of side 3
	 var varW3 = 0;  // Width of Side 3
	 var varE3 = 0;  //Edging of Side 3
	 var varBenchW3 = 0;  // Weight of Side 3
	 var BenchCost = 0;  //calculated benchCost
	 var BenchCost1 = 0;  // Side 1 cost
	 var BenchCost2= 0;  // Side 2 cost
	 var BenchCost3 = 0;  // Side 3 cost
	 var varBenchtopStyle = false;
	
	 var varEndFinishNumber = 0;
	 var varEndNumber = 0;
	 var BenchLength = 0;  // checking on the maximum length of a benchTop
	 var BenchWeightLshapeA = 0; // weight of Lshape Bench A
	 var BenchWeightLshapeB = 0; // weight of Lshape Bench B
	 var BenchWeightUshapeA = 0; // weight of U-shape Bench A
	 
	 var varMinimum = false;  // used to set a 'Special request field for delivery
	 var varKickboardCheck = false;
	 var varPanelCheck = false;
	 var varCarcassProcessed = false;
	 var varPreviousBaseHeight = 0;  //To check that current Base Cabinet Height = Previous one 
	 var varFullProductStyle = "A different Style"; 
	 var varProductChangeFlag = false;
	 var varDescription1 = " but you have not yet provided a Colour choice - do you want to do that now?"; 
// for calculation of Proportional Cost (changing curPrice)

	 var varNewPrice = 0;
	 var varMeasurements = " ";
	 arrDimensions = new Array(5);
	 var varHeight = 0;
	 var varWidth = 0;
	 var varDepth = 0;
	 var varLHWidth = 0;
	 var varRHWidth = 0;
	 var varLHDepth = 0;
	 var varRHDepth = 0;
	 var varCurrentOrderPrice = 0;
	 var productCode= " ";
	 var customName = " ";
	 var customValue = " ";
	 var realPID = 0;
	 var varDimension1 = 750;  // default values for Height that is used to build a newProductCode
	 var varDimension2 = 600; // deault Width
	 var varShelfSize = 36; // default shelf size
	 var varSpecialRequest = "";
	 var varChar = " ";
	 var varSpecial = "";
	 
	 var X1 = 0; //used in checking the ABCstring
	 var ABCstring = "ABCDEFGHIJK";
	 var varLastcode = "A";
	 var varNextcode = "A";
	 var varOutlet = "ACT - Mitchell 2902";
	 var varAdminCost = 0;
	 var Insurance = 0;
	 var DoNotallowEdit = false;
	 var varMaxHeight = 0;
	 var varHeightCode = 0;
	 var addThirtyPercent = false;
	 var varFirstTime = true;
 	 var varOutletSet = false;
	 var OutLet = false;
	 var varNoPanel = false;
	 var varNoKick = false;
	   
	 var SaveCookie = false;	 
	 if (arrCookie == null || arrCookie == "") SaveCookie = false;
	 var CookieID = "lines";

	 var CookieRetentionDefault = 60;
	 var CookieRetention = 60;  //to set deleted items

	 var newwindow1;
	 var prodname = "prodname";
	 var newwindow;
     var newwindow1;
	 var varListAll = false;
   	 var varLimitLines = false; 
	 var currentLine = 0;


 
	  // END of Variables put in by HJT
//==================================================================

private_CartLoad(); 
//alert(" 458 arrCookie= " + arrCookie + " varLimitLines = " + varLimitLines );

function poptastic(url)
{
  if (newwindow) newwindow.close();
  if (newwindow1) newwindow1.close();
  newwindow = window.open(url,"pop1","height=300,width=600,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=no,status=no");
  if (window.focus){newwindow.focus()}
}
function poptastic1(url)
{
  if (newwindow) newwindow.close();
  if (newwindow1) newwindow1.close();
  newwindow1 = window.open(url,"pop2","height=250,width=1100,left=10,top=1000,resizable=yes,scrollbars=yes,toolbar=no,status=no");
//  if (window.focus){newwindow1.focus()}
}


// delete current Cookie
function deleteCookie()
{
varLimitLines = false;
 arrLine = new Array();
 CookieRetention = 0;
 private_UpdateLines();
 CookieRetention = CookieRetentionDefault;

}
	
//---------------------------------------------//  this function is to delete the complete order details
function deleteAll()
{
varLimitLines = false;

varConfirm=window.confirm("You have asked to [REMOVE] Projects. Please CONFIRM - to REMOVE all data click [OK] - to KEEP all entries click [CANCEL].");
	if (varConfirm == true)
	{
varConfirm=window.confirm("To DELETE ALL Projects data [for example : to overcome a Systems Problem} - click [OK] - to just REMOVE the current Project details click [Cancel].");
      if (varConfirm == false) 
	  {
	    deleteCookie();
         alert(" Just your current Project data has been Removed - Now (re-)start your new Project specifications");
    	   window.location.replace("category38_1.htm");
      }
	  else
      {
	     for(var ii = 0; ii <arrCookie.length; ii++)
         {
            if (arrCookie[ii] != "undefined" && arrCookie[ii].length > 5)
			{
	            CookieID = arrCookie[ii].substr(0, 5);
		        deleteCookie(); 
		    }
	     }	   
	      window.location.replace("category38_1.htm");
         alert("All Projects stored have been deleted - Now [re-]start your new Project specifications");
      }
    }
		
} 

//==================================================================
//   Checking Input values only ( "?" or Null value, or " "), or exceeding MAX values
//  NOTE: this function is processed for EVERY Field on the Input Record!!	 
function checkInput(strFieldVal, i, iLineIdx, iProdID)
{ 
   if (iLineIdx > 0) iLineIdx = iLineIdx - 1;
	    varCustomFieldCount = getLineSubCount(iLineIdx, colCustomFields);
		customName = getCustomField(getProductInfo(iProdID)[colCustomFieldKeys][i-1]);
		varCustomFieldNameCode = getProductInfo(iProdID)[colCustomFieldKeys][i - 1];
    
  // check on blank fields             
	  var firstChar = strFieldVal.substring(0,1);		
	  if (varCustomFieldNameCode >  530 && varCustomFieldNameCode < 553) ;
	  else if (firstChar == "?" || (strFieldVal == " " && varCustomFieldNameCode != 10) || (strFieldVal < " " && varCustomFieldNameCode != 10 ))								  
	  {
			      varFieldCheck = 1;
window.alert("The prompt for: [" + customName + "] in your last Product Specification has an invalid value, shown as: [" + strFieldVal + "]  - or has been changed to [blank cell] . ----- For a VALID  Specification you MUST correctly fill in each cell value. --- To return back to the Product PROMPT  click [OK] ");
	  }			  	          	  

 // Now we check at the end of the normal input if there were any errors or other changes
    if (varProductCode == "Outlet" && OutLet == true && i == 1) {
	  varConfirm=window.confirm("You entered new Project details - there is a CURRENT Project already. If you merely wanted to change some of the Project data details then the Current Project line item will be REPLACED when you click [CANCEL] now -  BUT - If you want to START A NEW RFQ then click [OK] and the current RFQ data will be stored and a new Project will be started." );  
		  
		   if (varConfirm == true) {
		      OutLet = false;
		      storeCurrentCookie();		  
		   }
		   else 
		   {    
		      deleteLine(currentLine);
           }				 
	 }
	
// Firstly if STYLE record was entered
   	varProductCode = getProductInfo(iProdID)[colProductCode];	
    if (varProductCode.substring(0,7) == "2 Style" && i == 1) {
		  if (BypassCheckProductRange == false) {
		    checkProductRange();			
               return varFieldCheck;
           }
	}
 
		
//  Secondly when a DELIVERY is entered.
  // For Customer to arrange Freighting 
    if (varProductCode.substring(0,16) == "zPickUpBoxReqd/1" && i == 1) {
	     varConfirm=window.confirm("***NOTE: For this choice the factory will box the product components, awaiting your Freight Comany - BUT you will not be eligable for the 5% Pickup Discount - please confirm [OK] or change[CANCEL] your Delivery choice.");
                      if (varConfirm == false) {					 
					        varFieldCheck = 1;
					        return varFieldCheck;
					  }
	}			  

        if ((varProductCode.substring(0,2) == "zP" && i == 1) || (varProductCode.substring(0,2) == "zD" && i == 1)) {
		  if (BypassCheckProductRange == false) {
		   checkDiscountandProducts();			
           return varFieldCheck;
           }
		}        

       iProdIDLast = 0;
       varPriceFactor = 1;

	   varProductCode = getProductInfo(iProdID)[colProductCode];
	   varShortCode = varProductCode.substring(0,3);
	   varProdName = getProductInfo(iProdID)[colProductDesc];
	   varStyle = varProdName.indexOf("HMR W");
	   if (varStyle > 0) varProdStyle = "Carca";

       varCustomFieldNameCode = getProductInfo(iProdID)[colCustomFieldKeys][i-1];
// check for Product Style data	   
       if (varCustomFieldNameCode > 594 && varCustomFieldNameCode < 600){
	     varProdStyle = strFieldVal.substring(0,5);	
	     if (varProdStyle == "Lamin" || varProdStyle == "Unfin") varPriceFactor = 1;
	     else if (varProdStyle == "Belmo" || varProdStyle == "Unfin") varPriceFactor = 2;
	     else if (varProdStyle == "Byron" || varProdStyle == "Alban") varPriceFactor = 4;
	     else if (varProdStyle == "Avoca") varPriceFactor = 7;	

       }
	   varProductType = checkProductType(iProdID,varStatistics,i);
//  
//  Here we check for MAX Height, Max Width and/or Max Depth (or RH-Width) values for a range of Products
//
  if (varProductType != "Deli" && varProductType != "Disc" && varProductType != "Styl" && varProductType != "Hand" && varProductType != "Hard") 
  {
          varFieldValue = parseInt(strFieldVal);		  
 			  if (i == 1) {			  
			    varCustomFieldNameCode = getProductInfo(iProdID)[colCustomFieldKeys][i - 1];
				varProductCode = getProductInfo(iProdID)[colProductCode];
				varShortCode = varProductCode.substring(0,3);
				varFiveCode = varProductCode.substring(0,5);			  
                varMaxHeight = getMaxHeight(varCustomFieldNameCode);

				  if (varMaxHeight > 0 && varMaxHeight < varFieldValue) {
   window.alert("****You cannot exceed the HEIGHT (or Length) range for this Product***, please amend the height specified or select a different Product Range - also you could put a REQUEST for Quotation in the [Special Request] box and we will provide a quotation for this special case***");
                      varFieldCheck = 1;
			          return varFieldCheck;	
				  }
// For Underbench Oven WITH Drawer check if height < 750
                  if (varProductCode.substring(0,4) == "UBOD" && varFieldValue < 750) {
window.alert("*** Sorry, but for an Underbench Oven WITH DRAWER the minimum Height is 750 mm***, please amend the Height or choose a different Underbench Oven product");
                   varFieldCheck = 1;
			          return varFieldCheck;	
				  }				  				  
				  
//Check for Floor Cabinet Height being the same as the previous height, for FIRST Field Value				  
				  if (varProductCode.substring(0,1) == "B" && varProductCode.substring(0,2) != "BT") {
				    if (varPreviousBaseHeight > 0 && varPreviousBaseHeight != varFieldValue) {
varConfirm=window.confirm("This Floor Unit has a different HEIGHT from a previous Floor unit specified - please confirm [OK] or change[CANCEL]");
                      if (varConfirm == false) {					 
					        varFieldCheck = 1;
			                return varFieldCheck;
					  }			  
                    }				  			  					
		         }				  			  					
		      }
			  
              if (i == 2) {			   			  
			    varCustomFieldNameCode = getProductInfo(iProdID)[colCustomFieldKeys][i - 1];			  
                varMaxWidth = getMaxWidth(varCustomFieldNameCode);
				if (varFieldValue > 0) varLHWidth = varFieldValue;
				  if (varMaxWidth > 0 && varMaxWidth < varFieldValue) {
   window.alert("****You cannot exceed the WIDTH range for this Product***, please amend the width specified or select a different Product - if that is not available then use the maximum Width and put a REQUEST for Quotation in the [Special Request] box and we will provide a quotation for this special case***");
                      varFieldCheck = 1;
			          return varFieldCheck;
				  }			  					
		      }		  
	  	
		if (i == 3) {
		      if (varProductType != "Ward" && varShortCode != "WOD" && varShortCode != "WOM") {			    			  
			    varCustomFieldNameCode = getProductInfo(iProdID)[colCustomFieldKeys][i - 1];			  
                varMaxWidth = getMaxWidth(varCustomFieldNameCode);
                  if (varFieldValue > 0) varRHWidth = varFieldValue;
				  if (varMaxWidth > 0 && varMaxWidth < varFieldValue) {
   window.alert("****You cannot exceed the Depth (or RH-WIDTH range) for this Product***, please amend the field value specified or select a different Product Range - also you could put a REQUEST for Quotation in the [Special Request] box and we will provide a quotation for this special case***");
                      varFieldCheck = 1;
			          return varFieldCheck;
				  }
			   }			  					
		}
			  
		if (i == 4) {			   			  
			    varCustomFieldNameCode = getProductInfo(iProdID)[colCustomFieldKeys][i - 1];
				  if (varProductType != "Ward" && varShortCode != "WOD" && varShortCode != "WOM" ) { 			  
                      varMaxWidth = getMaxWidth(varCustomFieldNameCode);
				      if (varMaxWidth > 0 && varMaxWidth < varFieldValue) {
   window.alert("****You cannot exceed the MAXIMUM DEPTH for this Product***, please amend the field value specified or select a different Product Range - also you could put a REQUEST for Quotation in the [Special Request] box and we will provide a quotation for this special case***");
                      varFieldCheck = 1;
			          return varFieldCheck;
				     }			  
				   if (varFieldValue > 0) varLHDepth = varFieldValue;
				 }
				 else {
			           varMaxHeight = getMaxHeight(varCustomFieldNameCode);
				       if (varMaxHeight > 0 && varMaxHeight < varFieldValue) {
					      if (varProductType == "Ward") {
						     window.alert("****You cannot exceed the HEIGHT range for this Product***, please amend the value specified or select a different Product Range - also you could put a REQUEST for Quotation in the [Special Request] box and we will provide a quotation for this special case***");
                    		  varFieldCheck = 1;
			        		  return varFieldCheck;	
				    	   }
						   else {
						  
   window.alert("****You cannot exceed the maximum DEPTH for this Product***, please amend the value specified or select a different Product Range - also you could put a REQUEST for Quotation in the [Special Request] box and we will provide a quotation for this special case***");
                    		  varFieldCheck = 1;
			        		  return varFieldCheck;	
				      	 }
					   }			  
				 }
	    }
		
		if (i == 5 && varLHDepth > 0 && varProductType != "Ward") {
// window.alert("varProductType= " + varProductType  + " varLHDepth= " + varLHDepth + " i= " + i );			   			  
			    varCustomFieldNameCode = getProductInfo(iProdID)[colCustomFieldKeys][i - 1];			  
              if (varProductType != "Ward" && varProductType != "Benc" && varShortCode != "WOD" && varShortCode != "WOM" && varShortCode != "BOA" && varShortCode != "WDO" && varShortCode != "cWO" && varShortCode != "cPD" && varShortCode != "cBO" && varShortCode != "cWD") {
				varMaxWidth = getMaxWidth(varCustomFieldNameCode);
				if (varFieldValue > 0) {
				      if (varMaxWidth > 0 && varMaxWidth < varFieldValue) {
   window.alert("****You cannot exceed the MAXIMUM DEPTH for this Product***, please amend the field value specified or select a different Product Range - also you could put a REQUEST for Quotation in the [Special Request] box and we will provide a quotation for this special case***");
                      varFieldCheck = 1;
			          return varFieldCheck;
				     }			  				
					varRHDepth = varFieldValue;
//Exclude 'BOOMERANG' cabinet or a Diagonal cabinet and Diagonal Pantries
                  if (varProductType != "Hybr" && varShortCode != "BD-" && varShortCode != "WD-" && varShortCode != "BB4" && varShortCode != "WB4")  {
				  
				   if (varShortCode != "PD-" && varShortCode != "WEC" && varShortCode != "WR" && varShortCode != "cPD" && varShortCode != "cWD" && varShortCode != "cBD") {
				     varBiFoldWidth = varLHWidth - varRHDepth;
					  if (varBiFoldWidth < 220) {
	   window.alert(" From the measurements that you had entered the [LEFT] Bi-fold Door is only [" + varBiFoldWidth + " ]mm Wide. The minimum size is [220]mm. You must increase the [Left] Width or/and decrease the [Right] Depth to achieve a bigger door size. Click the Info button in this product when you return to this product for more information about how to work out door sizes");
                      varFieldCheck = 1;
			          return varFieldCheck;
				      } 
					} 
					
					if (varShortCode != "PD-" && varShortCode != "WEC" && varShortCode != "WR" && varShortCode != "cPD" && varShortCode != "cWD" && varShortCode != "cBD") {
				    	varBiFoldWidth = varRHWidth - varLHDepth;
					  if (varBiFoldWidth < 220) {
	  window.alert(" From the measurements that you had entered the [RIGHT] Bi-fold Door is only [" + varBiFoldWidth + " ]mm Wide. The minimum size is [220]mm. You must increase the [Right] Width or/and decrease the [Left] Depth to achieve a bigger door size. Click the Info button in this product when you return to this product for more information about how to work out door sizes");
                      varFieldCheck = 1;
			          return varFieldCheck;
				      } 
					 }
					 			  
                   if (varShortCode != "PD-" && varShortCode != "WEC" && varShortCode != "WR" && varShortCode != "cPD" && varShortCode != "cWD" && varShortCode != "cBD" && varShortCode != "TBA") {
				    varBiFoldWidth = varLHWidth - varRHDepth + varRHWidth - varLHDepth;					
					  if (varBiFoldWidth > 650) {
varConfirm=window.confirm("From the measurements that you have entered the combined Left and Right Bi-fold door size is [" + varBiFoldWidth + "]mm in combined Width. The hinge supplier will not warrant anything above 650mm because of dropping and sagging due to the excessive weight. To overcome this you will need to reduce the cabinet size to achieve a smaller combined door size. Click the [Info button] when returning to this product for more information about how to work out door sizes.----- Click [OK] to force your current size (thus voiding your warrantee for this cabinet) OR Click [CANCEL] to return to this product to re-adjust sizes or learn more about sizes");  
                        if (varConfirm == false) {					 
					        varFieldCheck = 1;
			                return varFieldCheck;
				        } else {
						   varErrorType2 = 1;
						  }
					  }
					}
					
					if (varShortCode != "PD-" && varShortCode != "WEC" && varShortCode != "WR" && varShortCode != "cPD" && varShortCode != "cWD" && varShortCode != "cBD" && varShortCode != "TBA") {  				  
					    if (varBiFoldWidth < 450){
varConfirm=window.confirm(" The Bi-Fold Door for this cabinet =  " + varBiFoldWidth + "  mm and this is very small , you could reconsider the cabinet dimensions by clicking [CANCEL] or ignore the warning by clicking [O.K.]. "	); 
	                    if (varConfirm == false) {					 
					        varFieldCheck = 1;
			                return varFieldCheck;
						 }			  					  
					  }
					}
					
                   if (varShortCode == "PD-" || varShortCode == "WD-" ) {
                    varBiFoldWidth = Math.ceil(Math.sqrt(Math.pow(varLHWidth - varRHDepth,2)+ Math.pow(varRHWidth - varLHDepth,2)));	
window.alert("Your Door Width has been calculated as about " + varBiFoldWidth + "mm");
					  if (varBiFoldWidth < 400){
varConfirm=window.confirm(" The Diagonal Door for this cabinet =  " + varBiFoldWidth + "  mm and this is very small , you could reconsider the cabinet dimensions by clicking [CANCEL] or ignore the warning by clicking [O.K.]. "	); 
	                    if (varConfirm == false) {					 
					        varFieldCheck = 1;
			                return varFieldCheck;
						 }			  					  
					  }
					}

                if (varFiveCode == "PD-D1") {
				   if (varBiFoldWidth > 650) {
varConfirm=window.confirm("From the measurements that you have entered the Door size is [" + varBiFoldWidth + "]mm in Width The hinge supplier will not warrant anything above 650mm because of dropping and sagging due to the excessive weight. To overcome this you will need to reduce the cabinet size to achieve a smaller combined door size. ----- Click [OK] to force your current size (thus voiding your warrantee for this cabinet) OR Click [CANCEL] to return to this product to re-adjust sizes or learn more about sizes");  
                        if (varConfirm == false) {					 
					        varFieldCheck = 1;
			                return varFieldCheck;
				        } else {
						   varErrorType2 = 1;
						  }
					}
				}
				
                if (varFiveCode == "PD-D2") {
				   if (varBiFoldWidth > 1300) {
varConfirm=window.confirm("From the measurements that you have entered the Door size is [" + varBiFoldWidth + "]mm in width. The hinge supplier will not warrant anything above 650mm because of dropping and sagging due to the excessive weight. To overcome this you will need to reduce the cabinet size to achieve a smaller combined door size. ----- Click [OK] to force your current size (thus voiding your warrantee for this cabinet) OR Click [CANCEL] to return to this product to re-adjust sizes or learn more about sizes");  
                        if (varConfirm == false) {					 
					        varFieldCheck = 1;
			                return varFieldCheck;
				        } else {
						   varErrorType2 = 1;
						  }
					  }				
			    }
			   
					}
				  } 					      
			     }                     
		   }
		   
            if (i == 5 && varProductType == "Ward") {			   			  
			    varCustomFieldNameCode = getProductInfo(iProdID)[colCustomFieldKeys][i - 1];			  
//			    window.alert("Field Code name= " + varCustomFieldNameCode + " i= " + i);
                varMaxWidth = getMaxWidth(varCustomFieldNameCode);
				if (varMaxWidth > 0 && varMaxWidth < varFieldValue) {
   window.alert("****You cannot exceed the WIDTH range for this Product***, please amend the width specified or select a different Product Range - also you could put a REQUEST for Quotation in the [Special Request] box and we will provide a quotation for this special case***");
                      varFieldCheck = 1;
			          return varFieldCheck;
				  }
				if (varFieldValue > 0) varLHWidth = varFieldValue;				  			  					
		      }

	         if (i == 6 && varProductType == "Ward") {			    			  
			    varCustomFieldNameCode = getProductInfo(iProdID)[colCustomFieldKeys][i - 1];			  
                varMaxWidth = getMaxWidth(varCustomFieldNameCode);
				    if (varMaxWidth > 0 && varMaxWidth < varFieldValue) {
   window.alert("****You cannot exceed the  maximum DEPTH for this Product***, please amend the field value specified or select a different Product Range - also you could put a REQUEST for Quotation in the [Special Request] box and we will provide a quotation for this special case***");
                      varFieldCheck = 1;
			          return varFieldCheck;
				    }
                  if (varFieldValue > 0) varRHWidth = varFieldValue;								  					
		      }
  }

// Checking on WardRobe to prevent duplicate identifications or Section not starting with A							 
   if (varProductType ==  "Ward")  {						   
	 if (i == 1) varNewRoom = strFieldVal;
	 if (i == 2) varNewWall = strFieldVal;						
	 if (i == 3) {
		varNewSection = strFieldVal;
		varRoomWall = varNewRoom + varNewWall;							
		var varPosition = varNewRoom + varNewWall + varNewSection;
		if (varPosition == varWardRobe1 || varPosition == varWardRobe2 || varPosition == varWardRobe3 || varPosition == varWardRobe4 || varPosition == varWardRobe5 || varPosition == varWardRobe6 || varPosition == varWardRobe7 || varPosition == varWardRobe8 || varPosition == varWardRobe9 || varPosition == varWardRobe10 || varPosition == varWardRobe11 || varPosition == varWardRobe12 || varPosition == varWardRobe13 || varPosition == varWardRobe14 || varPosition == varWardRobe15 || varPosition == varWardRobe16 || varPosition == varWardRobe17 || varPosition == varWardRobe18 || varPosition == varWardRobe19 || varPosition == varWardRobe20 || varPosition == varWardRobe21 || varPosition == varWardRobe22 || varPosition == varWardRobe23 || varPosition == varWardRobe24) {
window.alert("Please supply a unique ROOM, ROBE or SECTION code for this Wardrobe. There is already a  Wardrobe in your Shopping Cart with the same Room Name, Robe and Section Number. see [VIEWCART] ");	   
                            varFieldCheck = 1;
			                return varFieldCheck;
	   }
	   
	   if (varRoomWall != varWardRobe1.substring(0,12) && varRoomWall != varWardRobe2.substring(0,12) && varRoomWall != varWardRobe3.substring(0,12) && varRoomWall != varWardRobe4.substring(0,12) && varRoomWall != varWardRobe5.substring(0,12) && varRoomWall != varWardRobe6.substring(0,12) && varRoomWall != varWardRobe7.substring(0,12) && varRoomWall != varWardRobe8.substring(0,12) && varRoomWall != varWardRobe9.substring(0,12) && varRoomWall != varWardRobe10.substring(0,12) && varRoomWall != varWardRobe11.substring(0,12) && varRoomWall != varWardRobe12.substring(0,12) && varRoomWall != varWardRobe13.substring(0,12) && varRoomWall != varWardRobe14.substring(0,12) && varRoomWall != varWardRobe15.substring(0,12) && varRoomWall != varWardRobe16.substring(0,12) && varRoomWall != varWardRobe17.substring(0,12) && varRoomWall != varWardRobe18.substring(0,12) && varRoomWall != varWardRobe19.substring(0,12) && varRoomWall != varWardRobe20.substring(0,12) && varRoomWall != varWardRobe21.substring(0,12) && varRoomWall != varWardRobe22.substring(0,12) && varRoomWall != varWardRobe23.substring(0,12) && strFieldVal != "A") {
window.alert("The first SECTION code for a new ROOM/ROBE specification MUST be [A] -- following Sections must be consequetively coded from the Left to Right, e.g.: [A, B, C...] ----Please amend this specification");	  	   
							varFieldCheck = 1;
			                return varFieldCheck;	   
	   }	   	   
  }
 } 
  
 // Check that a Wardrobe SECTION has the same Height and Depth and Shape as OTHER SECTIONs with the same ROOM and WALL code
   if (varProductType ==  "Ward" && i == 4)  {
      var varWRH = false;
   if (varRoomWall == varWardRobe1.substring(0,12) && varFieldValue !=  varWardRobeHeight1) varWRH = true;
   if (varRoomWall == varWardRobe2.substring(0,12) && varFieldValue !=  varWardRobeHeight2) varWRH = true;
   if (varRoomWall == varWardRobe3.substring(0,12) && varFieldValue !=  varWardRobeHeight3) varWRH = true;
   if (varRoomWall == varWardRobe4.substring(0,12) && varFieldValue !=  varWardRobeHeight4) varWRH = true;
   if (varRoomWall == varWardRobe5.substring(0,12) && varFieldValue !=  varWardRobeHeight5) varWRH = true;
   if (varRoomWall == varWardRobe6.substring(0,12) && varFieldValue !=  varWardRobeHeight6) varWRH = true;
   if (varRoomWall == varWardRobe7.substring(0,12) && varFieldValue !=  varWardRobeHeight7) varWRH = true;
   if (varRoomWall == varWardRobe8.substring(0,12) && varFieldValue !=  varWardRobeHeight8) varWRH = true;
   if (varRoomWall == varWardRobe9.substring(0,12) && varFieldValue !=  varWardRobeHeight9) varWRH = true;
   if (varRoomWall == varWardRobe10.substring(0,12) && varFieldValue !=  varWardRobeHeight10) varWRH = true;
   if (varRoomWall == varWardRobe11.substring(0,12) && varFieldValue !=  varWardRobeHeight11) varWRH = true;
   if (varRoomWall == varWardRobe12.substring(0,12) && varFieldValue !=  varWardRobeHeight12) varWRH = true;
   if (varRoomWall == varWardRobe13.substring(0,12) && varFieldValue !=  varWardRobeHeight13) varWRH = true;
   if (varRoomWall == varWardRobe14.substring(0,12) && varFieldValue !=  varWardRobeHeight14) varWRH = true;
   if (varRoomWall == varWardRobe15.substring(0,12) && varFieldValue !=  varWardRobeHeight15) varWRH = true;
   if (varRoomWall == varWardRobe16.substring(0,12) && varFieldValue !=  varWardRobeHeight16) varWRH = true;
   if (varRoomWall == varWardRobe17.substring(0,12) && varFieldValue !=  varWardRobeHeight17) varWRH = true;
   if (varRoomWall == varWardRobe18.substring(0,12) && varFieldValue !=  varWardRobeHeight18) varWRH = true; 	 
   if (varRoomWall == varWardRobe19.substring(0,12) && varFieldValue !=  varWardRobeHeight19) varWRH = true;
   if (varRoomWall == varWardRobe20.substring(0,12) && varFieldValue !=  varWardRobeHeight20) varWRH = true;
   if (varRoomWall == varWardRobe21.substring(0,12) && varFieldValue !=  varWardRobeHeight21) varWRH = true;
   if (varRoomWall == varWardRobe22.substring(0,12) && varFieldValue !=  varWardRobeHeight22) varWRH = true;
   if (varRoomWall == varWardRobe23.substring(0,12) && varFieldValue !=  varWardRobeHeight23) varWRH = true;
   if (varRoomWall == varWardRobe24.substring(0,12) && varFieldValue !=  varWardRobeHeight24) varWRH = true;

	 if (varWRH == true) {
window.alert("Error: You have tried to ADD another section to an existing BANK of robes - but you have entered a different HEIGHT value? Please correct either Height value OR change the Wall Number");
 							varFieldCheck = 1;
			                return varFieldCheck;	 
     }
  }

   if (varProductType ==  "Ward" && i == 6) {
      varWRD = false;
    if (varRoomWall == varWardRobe1.substring(0,12) && varFieldValue !=  varWardRobeDepth1) varWRD = true;
	if (varRoomWall == varWardRobe2.substring(0,12) && varFieldValue !=  varWardRobeDepth2) varWRD = true;
	if (varRoomWall == varWardRobe3.substring(0,12) && varFieldValue !=  varWardRobeDepth3) varWRD = true;
	if (varRoomWall == varWardRobe4.substring(0,12) && varFieldValue !=  varWardRobeDepth4) varWRD = true;
	if (varRoomWall == varWardRobe5.substring(0,12) && varFieldValue !=  varWardRobeDepth5) varWRD = true;
	if (varRoomWall == varWardRobe6.substring(0,12) && varFieldValue !=  varWardRobeDepth6) varWRD = true;
	if (varRoomWall == varWardRobe7.substring(0,12) && varFieldValue !=  varWardRobeDepth7) varWRD = true;
	if (varRoomWall == varWardRobe8.substring(0,12) && varFieldValue !=  varWardRobeDepth8) varWRD = true;
	if (varRoomWall == varWardRobe9.substring(0,12) && varFieldValue !=  varWardRobeDepth9) varWRD = true;
	if (varRoomWall == varWardRobe10.substring(0,12) && varFieldValue !=  varWardRobeDepth10) varWRD = true;
	if (varRoomWall == varWardRobe11.substring(0,12) && varFieldValue !=  varWardRobeDepth11) varWRD = true;
    if (varRoomWall == varWardRobe12.substring(0,12) && varFieldValue !=  varWardRobeDepth12) varWRD = true;
	if (varRoomWall == varWardRobe13.substring(0,12) && varFieldValue !=  varWardRobeDepth13) varWRD = true;
	if (varRoomWall == varWardRobe14.substring(0,12) && varFieldValue !=  varWardRobeDepth14) varWRD = true;
	if (varRoomWall == varWardRobe15.substring(0,12) && varFieldValue !=  varWardRobeDepth15) varWRD = true;
	if (varRoomWall == varWardRobe16.substring(0,12) && varFieldValue !=  varWardRobeDepth16) varWRD = true;
	if (varRoomWall == varWardRobe17.substring(0,12) && varFieldValue !=  varWardRobeDepth17) varWRD = true;
	if (varRoomWall == varWardRobe18.substring(0,12) && varFieldValue !=  varWardRobeDepth18) varWRD = true;
	if (varRoomWall == varWardRobe19.substring(0,12) && varFieldValue !=  varWardRobeDepth19) varWRD = true;
	if (varRoomWall == varWardRobe20.substring(0,12) && varFieldValue !=  varWardRobeDepth20) varWRD = true;
	if (varRoomWall == varWardRobe21.substring(0,12) && varFieldValue !=  varWardRobeDepth21) varWRD = true;
	if (varRoomWall == varWardRobe22.substring(0,12) && varFieldValue !=  varWardRobeDepth22) varWRD = true;	 
	if (varRoomWall == varWardRobe23.substring(0,12) && varFieldValue !=  varWardRobeDepth23) varWRD = true;
	if (varRoomWall == varWardRobe24.substring(0,12) && varFieldValue !=  varWardRobeDepth24) varWRD = true;

	 if (varWRD == true) {
window.alert("Error: You have tried to ADD another section to an existing BANK of robes - but you have entered a different DEPTH value? Please correct either Depth value OR change the Wall Number");
 							varFieldCheck = 1;
			                return varFieldCheck;	 
     }
   }   
   if (varProductType ==  "Ward" && i == 7) {
      var varWRS = false;
    if (varRoomWall == varWardRobe1.substring(0,12) && strFieldVal !=  varWardRobeShape1) varWRS = true;
	if (varRoomWall == varWardRobe2.substring(0,12) && strFieldVal !=  varWardRobeShape2) varWRS = true;
	if (varRoomWall == varWardRobe3.substring(0,12) && strFieldVal !=  varWardRobeShape3) varWRS = true;
	if (varRoomWall == varWardRobe4.substring(0,12) && strFieldVal !=  varWardRobeShape4) varWRS = true;
	if (varRoomWall == varWardRobe5.substring(0,12) && strFieldVal !=  varWardRobeShape5) varWRS = true;
	if (varRoomWall == varWardRobe6.substring(0,12) && strFieldVal !=  varWardRobeShape6) varWRS = true;
	if (varRoomWall == varWardRobe7.substring(0,12) && strFieldVal !=  varWardRobeShape7) varWRS = true;
	if (varRoomWall == varWardRobe8.substring(0,12) && strFieldVal !=  varWardRobeShape8) varWRS = true;
	if (varRoomWall == varWardRobe9.substring(0,12) && strFieldVal !=  varWardRobeShape9) varWRS = true;
	if (varRoomWall == varWardRobe10.substring(0,12) && strFieldVal !=  varWardRobeShape10) varWRS = true;
	if (varRoomWall == varWardRobe11.substring(0,12) && strFieldVal !=  varWardRobeShape11) varWRS = true;
    if (varRoomWall == varWardRobe12.substring(0,12) && strFieldVal !=  varWardRobeShape12) varWRS = true;
	if (varRoomWall == varWardRobe13.substring(0,12) && strFieldVal !=  varWardRobeShape13) varWRS = true;
	if (varRoomWall == varWardRobe14.substring(0,12) && strFieldVal !=  varWardRobeShape14) varWRS = true;
	if (varRoomWall == varWardRobe15.substring(0,12) && strFieldVal !=  varWardRobeShape15) varWRS = true;
	if (varRoomWall == varWardRobe16.substring(0,12) && strFieldVal !=  varWardRobeShape16) varWRS = true;
	if (varRoomWall == varWardRobe17.substring(0,12) && strFieldVal !=  varWardRobeShape17) varWRS = true;
	if (varRoomWall == varWardRobe18.substring(0,12) && strFieldVal !=  varWardRobeShape18) varWRS = true;
	if (varRoomWall == varWardRobe19.substring(0,12) && strFieldVal !=  varWardRobeShape19) varWRS = true;
	if (varRoomWall == varWardRobe20.substring(0,12) && strFieldVal !=  varWardRobeShape20) varWRS = true;
	if (varRoomWall == varWardRobe21.substring(0,12) && strFieldVal !=  varWardRobeShape21) varWRS = true;
	if (varRoomWall == varWardRobe22.substring(0,12) && strFieldVal !=  varWardRobeShape22) varWRS = true;	 
	if (varRoomWall == varWardRobe23.substring(0,12) && strFieldVal !=  varWardRobeShape23) varWRS = true;
	if (varRoomWall == varWardRobe24.substring(0,12) && strFieldVal !=  varWardRobeShape24) varWRS = true;

	 if (varWRS == true) {
window.alert("Error: You have tried to ADD another section to an existing BANK of robes - but you have entered a different Angle of Top Shelf? Please correct the Angle setting");
//alert("line 849- strFieldVal= "  + strFieldVal + " varWardRobeShape1= " + varWardRobeShape1 + " varWardRobeShape2= " + varWardRobeShape2);
 							varFieldCheck = 1;
			                return varFieldCheck;	
     }
   }   
     
//  Set flag to show LEFT END finishing has been recorded
 if (varProductType == "Benc" ) {
      varProductCode = getProductInfo(iProdID)[colProductCode];
      var varLongCode = varProductCode.substring(0,4);
	  varShortCode = varProductCode.substring(0,3);
	
  if (varLongCode == "BTEL" || varLongCode == "BTLM" || varLongCode == "BTLF" || varLongCode == "BTBL")
 	       varLeftSideProcessed = true ;
  else     varLeftSideProcessed = false;
 }   
   
// Check on Unique Numbers for Benchtops
  if (varProductType == "Benc" ) {
               if ((varShortCode == "BTS" || varShortCode == "BTD" || varShortCode == "BTL" || varShortCode == "BTU") && i == 3) {
			       varBenchtopProcessed = true;
			   }
   }
   		
  if (varProductType == "Benc" ) {
		      if (iProdID > 215 && iProdID < 220 && i == 7) {
			       varBenchtopProcessed = true;
				   varNewBench = strFieldVal;
			   }			   
			   else if ((iProdID > 220 && iProdID < 224) && i == 9) {
			       varBenchtopProcessed = true;
				   varNewBench = strFieldVal;
			   }			   
			   else if (iProdID == 220 && i == 10) {
			       varBenchtopProcessed = true;
				   varNewBench = strFieldVal;
			   }			   
	}

 if (varProductType == "Disc" && i==1) window.alert("The Discount has been calculated and is added at the bottom of your Shopping List");
 
 	varProductCode = getProductInfo(iProdID)[colProductCode];
	if (varProductCode.substring(0,18) == "2 Style Laminate/Y" && i ==2) window.alert("You will be given a QUOTE for the extra cost for this YOUR CHOICE Brand/Material selection, this will be at least $385 for the Order");
				
   if (varProductType == "Carc" && i == 1)  {
    if (varCarcassProcessed == false) {
varConfirm=window.confirm("This selection is for a CARCASS-ONLY product, that means Doors, Drawer-Fronts, Drawer Slides, Hinges and Adjustable Feet are NOT INCLUDED - please confirm [OK] or change[CANCEL]");
                      if (varConfirm == false) {					 
					        varFieldCheck = 1;
			                return varFieldCheck;
					  }
	 }
   }
		  
 return varFieldCheck;
 }

 //
 //  Find the maximum Height for a Custom Field Height specification, using SubfieldCode value
 //
 function getMaxHeight(varHeightCode)
  {
  switch(varHeightCode)
  {
case 1: return 500;
case 112: return 1000;
case 166: return 600;
case 219: return 2150;
case 220: return 2350;
case 334: return 750;
case 344: return 1200;
case 352: return 500;
case 386: return 200;
case 388: return 400;
case 390: return 600;
case 434: return 2350;
case 493: return 2100;
case 505: return 1000;
case 507: return 1500;
case 508: return 2100;
case 509: return 2500;
case 510: return 3000;
case 511: return 3550;
case 567: return 1200;
case 573: return 1200;
case 578: return 2350;
case 580: return 850;
case 581: return 2350;
case 583: return 900;
case 585: return 1800;
case 601: return 1000;
case 611: return 1000;
}
return 0;
} 
//  End of Maximum Height Custom Field Code Table 
//
// Find the Maximum Width ( or LH Width or RH Width, or Depth) for a Custom Field width specification
//

 function getMaxWidth(varWidthCode)
  {
  switch(varWidthCode)
  {
case 7:  return 750;
case 150:  return 300;
case 153:  return 620;
case 154:  return 700;
case 155:  return 800;
case 156:  return 900;
case 164:  return 400;
case 167:  return 700;
case 168:  return 700;
case 171:  return 1000;
case 172:  return 1000;
case 229:  return 600;
case 233:  return 900;
case 307:  return 800;
case 318:  return 600;
case 342:  return 500;
case 350:  return 900;
case 351:  return 900;
case 427:  return 500;
case 498:  return 400;
case 499:  return 600;
case 506:  return 900;
case 520:  return 595;
case 521:  return 1000;
case 540:  return 750;
case 568:  return 600;
case 570:  return 1200;
case 571:  return 900;
case 572:  return 1200;
case 574:  return 900;
case 575:  return 1200;
case 577:  return 1150;
case 582:  return 1200;
case 584:  return 600;
case 586:  return 850;
case 587:  return 850;
case 590:  return 595;
case 591:  return 595;
case 592:  return 1800;
case 593:  return 1200;
case 602:  return 700;
case 629:  return 1150;
case 638:  return 800;
}
return 0;
}  
//  End of Maximum Width Custom Field Code Table
//	 

// to calculate extra charges for shelf(s) - depending on Width X Depth  and for Softclose Drawers
function extraShelfCalc(i, iProdID)
{	   
// get the posted custom fields
     var varQty = 1;
	 var varSoftClose = false;
	    shelfCost = 0
	 var SoftCloseCost = 0
		extraShelfCost = 0;
		varPriceFactor = 1;
	    varCustomFieldCount = getLineSubCount(i, colCustomFields);
	    varProductCode = getProductInfo(iProdID)[colProductCode];
	    varShortCode = varProductCode.substring(0,3);
	    varProdName = getProductInfo(iProdID)[colProductDesc];
	    varStyle = varProdName.indexOf("HMR W");
	    if (varStyle > 0) varProdStyle = "Carca";

		if (varCustomFieldCount > 0)
		{		      			  				 		
		      for (var varIndex = 0; varIndex < varCustomFieldCount; varIndex++)
              {        
				   varCustomFieldNameCode = getProductInfo(iProdID)[colCustomFieldKeys][varIndex];
				   varCustomFieldValue = getLineSubItem(i, colCustomFields, varIndex);
// check for Product Style data	   
                   if ((varCustomFieldNameCode > 594 && varCustomFieldNameCode < 600) || varCustomFieldNameCode == 605){
	                 varProdStyle = varCustomFieldValue.substring(0,5);	
	                 if (varProdStyle == "Belmo" || varProdStyle == "Unfin") varPriceFactor = 2;
	                 else if (varProdStyle == "Byron" || varProdStyle == "Alban") varPriceFactor = 4;
	                 else if (varProdStyle == "Avoca") varPriceFactor = 7;	
                   }
				   	   		
			       if (varCustomFieldNameCode == 333) {
				        if (varShortCode == "P-D" || varShortCode == "PD-" || varShortCode == "PC-") 
						     varQty = varCustomFieldValue - 5;   // original Cabinet cost included five shelves
						else varQty = varCustomFieldValue - 1;  // original Cabinet cost included one shelf
						shelfCost = Math.floor(2.75 + (varShelfSize / 10000) * .18 + .50) ;					
				   }
				   if (varCustomFieldNameCode == 634 && varCustomFieldValue == "Yes" ) varSoftClose = true; 
	   
// If the cabinet is an Open Unit AND NOT just made of melamine then we charge more for extra Shelves
// the the normal Qty * Price REMEMBER that the original Cabinets price was based on 1Shelf included (5) for Pantries
//	  
			  if (varShortCode == "BO-" || varShortCode == "BOA" || varShortCode == "WO-" || varShortCode == "WDO")
					   		 shelfCost = shelfCost * varPriceFactor;
			  if (varProductCode.substring(0,8) == "BDrw-MT2" && varSoftClose == true) SoftCloseCost = 132.74;
			  else if (varProductCode.substring(0,8) == "BDrw-MT3" && varSoftClose == true) SoftCloseCost = 199.11;
			  else if (varProductCode.substring(0,8) == "BDrw-MT4" && varSoftClose == true) SoftCloseCost = 265.40;
			  else if (varProductCode.substring(0,8) == "BDrw-MT5" && varSoftClose == true) SoftCloseCost = 331.85;
			  else if ((varProductCode.substring(0,2) == "WO" || varProductCode.substring(0,8) == "BCD2Drw2")&& varSoftClose == true) SoftCloseCost = 132.74; //Wall Oven  Combo
			  else if (varProductCode.substring(0,3) == "BCD" && varSoftClose == true) SoftCloseCost = 66.37;        // Combo 1 Drawer
           }			  			 
			  extraShelfCost = Math.round((((varQty  * shelfCost) + SoftCloseCost) * 100) /100)  ;		                 	           	  
       }	 
   return extraShelfCost;
 }
// end of hjt function 4/11/2007
//===========================================================
//	Creates a new array with X elements, with the supplied argument value or default
//
function nA()
{
	var myProductArray = new Array(0,0,0,0,0,0,0,0);
	for (var x = 0; x < arguments.length; x++) 
	{
		myProductArray[x] = arguments[x];
	}
	return myProductArray;
}

// getProductPrice

function getProductPrice(curSymbol, thousandsSeparator, decPlaces, decSeparator, truncateDec, blnSymbolAtFront, pid, local, domestic, international, defaultRegion, blnIncludeTax)
{
	var curPrice;

 	var region = defaultRegion.toString();	
 	if (getItem("region") != "") region = getItem("region");
 	if (region != "0" && region != "1" && region != "2") region = "1";	

	if (!blnIncludeTax) region = "99";
    region = "1";   //  forece to Domestic Pricing hjt 19/01/2010
	switch(region)
	{
	case "0":
		curPrice = getProduct(pid)[colProductPrice] * (1 + getProduct(pid)[colTaxLocal]);		
		break;
	case "1":
		curPrice = getProduct(pid)[colProductPrice] * (1 + getProduct(pid)[colTaxDomestic]);		
		break;
	case "2": 
		curPrice = getProduct(pid)[colProductPrice] * (1 + getProduct(pid)[colTaxInternational]);		
		break;
	case "99":
		curPrice = getProduct(pid)[colProductPrice];
		break;
	}

	return formatCurrency(curSymbol, thousandsSeparator, decPlaces, decSeparator, truncateDec, blnSymbolAtFront, curPrice);
}

function getPriceInfo(pid,local, domestic, international, defaultRegion, blnIncludeTax)
{
	var strTaxString;
	var curPrice;
	
	var region = defaultRegion.toString();	
	if (getItem("region") != "") region = getItem("region");
	if (region != "0" && region != "1" && region != "2") region = "1";	

	if (!blnIncludeTax) region = "99";
    region = "1";   //  forece to Domestic Pricing hjt 19/01/2010
	switch(region)
	{
	case "0":
		curPrice = getProduct(pid)[colProductPrice] * (1 + getProduct(pid)[colTaxLocal]);		
		if (curPrice != getProduct(pid)[colProductPrice])
			strTaxString = local;
		else
			strTaxString = "";
		break;
	case "1":
		curPrice = getProduct(pid)[colProductPrice] * (1 + getProduct(pid)[colTaxDomestic]);		
		if (curPrice != getProduct(pid)[colProductPrice])
			strTaxString = domestic;
		else
			strTaxString = "";
		break;
	case "2": 
		curPrice = getProduct(pid)[colProductPrice] * (1 + getProduct(pid)[colTaxInternational]);		
		if (curPrice != getProduct(pid)[colProductPrice])
			strTaxString = international;
		else
			strTaxString = "";
		break;
	case "99":
		curPrice = getProduct(pid)[colProductPrice];
		strTaxString = "";
		break;
	}
	return strTaxString;
}
 
// * addProductToCart(frm)
// * adds the product represented by the HTML form - frm. This includes custom fields.
// * If the product being added is identical (including custom fields) the quantity of
// * the item in the cart is added to the amount being added through the form.
// *
// * input - 
// * frm: a HTML form object that contains a qty and pid element along with any
// *		custom fields that are required.


function addProductToCart(frm, strAddMessage, strErrMsg, strFileName)
{
//   add  by hjt 4/11/2007
//
      varDataInputMode = true;
	  if (varFieldCheck == 0)
	     {
		    iLineIdx = getLineCount();
		    old_iLineIdx = iLineIdx;
	     }
	  else
	    {
	      iLineIdx = old_iLineIdx;
		  varFieldCheck = 0;
	    } 
		
//  end of substitution hjt 4/11/2007			
//  var iLineIdx = getLineCount();  // this line was substituted with the above code

	var iProdID = parseInt(frm.elements["pid"].value);
	var fltQty = parseInt(frm.elements["qty"].value);
    varQtyCheck = fltQty;

	if ((fltQty.toString() == "NaN") ||
			(fltQty - frm.elements["qty"].value != 0) || (fltQty <= 0))
	{

		if (typeof(document.all) != "undefined")
		{ 
  		  if (strFileName != ""){
		    showModalDialog(strFileName, "", "dialogHeight: 145px; dialogWidth: 256px; dialogTop: px; dialogLeft: px; center: Yes; help: No; resizable: No; status: No; scroll: No;edge: raised");
 		  }
		}
		else
		{
  		  if (strErrMsg != ""){
			alert(strErrMsg);
		  } 
		}
		frm.elements["qty"].focus();
		frm.elements["qty"].select();
		return false;
	}
// =========================================================================================
//  add (insert) by hjt in December 2007   Get Global values from preceding Input Lines
       if (CalculateOrderTotals() == true) varOrderTotals = true;   
	   varProductType = checkProductType(iProdID,varStatistics,i);	   	      
	   if (varDelivery == true) {
	    if (varProductType != "Disc" && varProductType != "Hand" && varProductType != "Hard" && varProductType != "Styl" && varProductType != "Outl") {
window.alert(" Sorry - This Product can not be added UNTIL the Delivery product that you have in your Shopping Cart is Removed. The Delivery product has to be the very last Product Ordered as it works out the Total Weight. Please [REMOVE] the Delivery Item.");
				   window.location = "viewcart.htm";
				   varFieldCheck = 1;
				   return false;
	     }
		} 			  	   	   
	   
// end of add by hjt
// =======================================================================================	
	// get the posted custom fields
	var arrCustomField = new Array(0);
	for (var i = 0; i <frm.elements.length; i++)
	{
		if (frm.elements[i].name == "cf")
		{
			var strFieldVal = "";
			if (frm.elements[i].type.substr(0, 6) == "select")
			{
				strFieldVal = frm.elements[i].options[frm.elements[i].selectedIndex].value;
			}
			else if (frm.elements[i].type.substr(0, 6) == "checkb")
			{
				if (frm.elements[i].checked == false)
				{
					strFieldVal = "No"
				} else {
					strFieldVal = "Yes"			
				}

			}
			else
			{
				strFieldVal = frm.elements[i].value;
			}
//===================================================			
//  add by hjt 9/11/2007   to check simple input fields.  
varProductCode = getProductInfo(iProdID)[colProductCode];
varCustomFieldNameCode = getProductInfo(iProdID)[colCustomFieldKeys][i - 1];

if (varCustomFieldNameCode == 364) {
	 if  (varProductCode.substring(0,3) == "BTS" || varProductCode.substring(0,3) == "BTD" 
	   || varProductCode.substring(0,3) == "BTL" || varProductCode.substring(0,3) == "BTU") {
      if (varLastcode == "") strFieldVal = "A";
	  else strFieldVal = varNextcode; 
	 } 
	if  (varProductCode.substring(0,3) == "BTE" ) strFieldVal  = varLastcode; 
 }								
    	varFieldCheck = checkInput(strFieldVal, i, iLineIdx, iProdID); 				
		if (varFieldCheck == 1 ) {
		    return false;
		}		
		
		if (varErrorType2 == 1 && frm.elements.length - 2 == i) {
				    strFieldVal = "**Cabinet Warranty revoked due to exessive door width**" + strFieldVal;
					varErrorType2 = 0;
		}
		
// Process Colour/Profile record(s) 
//
		varProductCode = getProductInfo(iProdID)[colProductCode];
		 if (varProductCode.substring(0,1) == "1" || varProductCode.substring(0,1) == "2") {
		  if (BypassCheckProductRange == false) {
		   if (frm.elements.length - 2 == i) {
		       strFieldVal = "*C* " + strFieldVal;
		   }
		  }
		   varStyleStyle = varProductCode.substring(8,13);
		   if (frm.elements.length - 3 == i) {
		       if (strFieldVal.substring(0,12) == "All Cabinets") {
			      if (varDoorStyle1 != "Nil") {
window.alert("You have already recorded a Colour for Doors & Drawer fronts - please choose another 'Applies to' or [REMOVE] a previous Colour selection");
						varFieldCheck = 1;
	                    return false;
				  }
			      if (varPanelStyle1 != "Nil") {
window.alert("You have already recorded a Colour for Panels - please choose another 'Applies to' or [REMOVE] a previous Colour selection");
						varFieldCheck = 1;
	                    return false;										  
				  }
			      if (varKickStyle1 != "Nil") {
window.alert("You have already recorded a Colour for Kickboards - please choose another 'Applies to' or [REMOVE] a previous Colour selection");
						varFieldCheck = 1;
	                    return false;										  
				  }
			      if (varOpenStyle1 != "Nil") {
window.alert("You have already recorded a Colour for Open Units - please choose another 'Applies to' or [REMOVE] a previous Colour selection");
						varFieldCheck = 1;
	                    return false;										  
				  }			 				  
			   }
		       if (strFieldVal.substring(0,5) == "Doors") {			   
			      if (varDoorStyle1 != "Nil") {
window.alert("You have already recorded a Colour for Doors & Drawer fronts - please choose another 'Applies to' or [REMOVE] a previous Colour selection");
						varFieldCheck = 1;
	                    return false;										  
				  }			 				  
			   }
			   			   
		       if (strFieldVal.substring(0,11) == "Panels only") {
			      if (varPanelStyle1 != "Nil") {
window.alert("You have already recorded a Colour for Panels - please choose another 'Applies to' or [REMOVE] a previous Colour selection");
						varFieldCheck = 1;
	                    return false;										  
				  }			 				  
			   }
		       if (strFieldVal.substring(0,15) == "Kickboards only") {
			      if (varKickStyle1 != "Nil") {
window.alert("You have already recorded a Colour for KICKBOARDS - please choose another 'Applies to' or [REMOVE] a previous Colour selection");
						varFieldCheck = 1;
	                    return false;										  
				  }			 				  
			   }			   			   		   
		       if (strFieldVal.substring(0,4) == "Open") {
			      if (varOpenStyle1 != "Nil") {
window.alert("You have already recorded a Colour for OPEN UNITS - please choose another 'Applies to' or [REMOVE] a previous Colour selection");
						varFieldCheck = 1;
	                    return false;										  
				  }			 				  
			   }			   			   			   		   
		   }
        if (varProductCode.substring(8,12) == "GLOS" && frm.elements.length - 3 == i) 
		alert("The price for [" + strFieldVal + "] products that now have a GLOSS finish will be recalculated on your 'Shopping List'");	
		}
		

 // Process 'Project" record
 
        if (iProdID == 65 && frm.elements.length - 3 == i){	
			strFieldVal = DateModified;
	     }

// Process DELIVERY 'Product' 
//
        if (iProdID == 3 && i == 3 )  varSpecial = "*F* Freight Calculated" + strFieldVal;
		if (iProdID == 4 && i == 4 )  varSpecial = "*F* Freight Calculated" + strFieldVal;
		
	    if (iProdID == 2 && i == 3 && varOnLine == true) strFieldVal = "*D* Pickup Discount applies, but may be offset by proportion of the Setup/Admin cost " + strFieldVal;
		if (iProdID == 1 && i == 3 && varOnLine == true) strFieldVal = "*A proportion of the Setup/Admin cost may apply" + strFieldVal;

//   Also Validate fields (except "Special Requests") and remove any extraneous characters
       if (frm.elements.length - 2 != i)  {      				
		 varStrFieldVal = parseInt(strFieldVal);
		if (varStrFieldVal > 0 &&  varProductType != "Styl") strFieldVal = varStrFieldVal;
	   }
									
// calculate and add the weight. length and other statistics into the Delivery Option 'product'	
			    if (iProdID < 5) {
				
				     if (i == 1) {
					             varStatistics = true;
					             CalculateOrderWeight();
// Here we estimate the Weight of the packing case
					    if (iProdID == 1 || iProdID == 4 ) varTotalWeight = Math.round(varTotalWeight * 1.28);                          
 	                                             arrCustomField[arrCustomField.length] = varTotalWeight;
                     }
 			         if (i == 2)                 arrCustomField[arrCustomField.length] = varTotalLength;
					 
					 if (i == 3 && iProdID != 4) arrCustomField[arrCustomField.length] = FloorUnits;
					 if (i == 4 && iProdID != 4) arrCustomField[arrCustomField.length] = WallUnits;
					 if (i == 5 && iProdID != 4) arrCustomField[arrCustomField.length] = OpenUnits;
					 if (i == 6 && iProdID != 4) arrCustomField[arrCustomField.length] = Benchtops;
					 if (i == 7 && iProdID != 4) arrCustomField[arrCustomField.length] = Wardrobes;
					 if (i == 8 && iProdID != 4) arrCustomField[arrCustomField.length] = Panels;
					 if (i == 9 && iProdID != 4) arrCustomField[arrCustomField.length] = Kickboards;
					 if (i == 10 && iProdID != 4) arrCustomField[arrCustomField.length] = Fillers;
					 if (i == 11 && iProdID != 4) arrCustomField[arrCustomField.length] = ExtraDoors;
					 if (i == 12 && iProdID != 4) arrCustomField[arrCustomField.length] = CarcassUnits;
					 if (i == 13 && iProdID != 4) arrCustomField[arrCustomField.length] = Handles;
					 if (i == 14 && iProdID != 4) arrCustomField[arrCustomField.length] = Hardware;
					 if (i == 15 && iProdID != 4) arrCustomField[arrCustomField.length] = varSpecial;
					 if (i == 16 && iProdID != 4) arrCustomField[arrCustomField.length] = strFieldVal;

					 if (i == 3 && iProdID == 4) arrCustomField[arrCustomField.length] = strFieldVal;			 					 					 
					 if (i == 4 && iProdID == 4) arrCustomField[arrCustomField.length] = strFieldVal;  
					 if (i == 4 && iProdID == 4) arrCustomField[arrCustomField.length] = FloorUnits;
					 if (i == 6 && iProdID == 4) arrCustomField[arrCustomField.length] = WallUnits;
					 if (i == 7 && iProdID == 4) arrCustomField[arrCustomField.length] = OpenUnits;
					 if (i == 8 && iProdID == 4) arrCustomField[arrCustomField.length] = Benchtops;					 
					 if (i == 9 && iProdID == 4) arrCustomField[arrCustomField.length] = Wardrobes;
					 if (i == 10 && iProdID == 4) arrCustomField[arrCustomField.length] = Panels;
					 if (i == 11 && iProdID == 4) arrCustomField[arrCustomField.length] = Kickboards;
					 if (i == 12 && iProdID == 4) arrCustomField[arrCustomField.length] = Fillers;
					 if (i == 13 && iProdID == 4) arrCustomField[arrCustomField.length] = ExtraDoors;
					 if (i == 14 && iProdID == 4) arrCustomField[arrCustomField.length] = CarcassUnits;
					 if (i == 15 && iProdID == 4) arrCustomField[arrCustomField.length] = Handles;
					 if (i == 16 && iProdID == 4) arrCustomField[arrCustomField.length] = Hardware;
					 if (i == 17 && iProdID == 4) arrCustomField[arrCustomField.length] = varSpecial;
	 				 if (i == 18 && iProdID == 4) arrCustomField[arrCustomField.length] = strFieldVal;

//alert("line 1484 i= " + i + " strFieldVal= " + strFieldVal);					
					 
			    }
				else arrCustomField[arrCustomField.length] = strFieldVal; 
// end of current 'Modification' by hjt

//=======================================================================================================						
		}
	}
		
	for(var i = 0; i <iLineIdx; i++)  //checking for same product as stored previously
	{
		if (getLineItem(i, colProductID) == iProdID)
		{	
			if (arrCustomField.length != getLineSubCount(i, colCustomFields)) continue;		

			for(var iCustomField = 0; iCustomField <arrCustomField.length; iCustomField++)
			{
				if (getLineSubItem(i, colCustomFields, iCustomField) != arrCustomField[iCustomField]) break;
								
			}
		
			if (iCustomField == arrCustomField.length)
			{	
				setLineItem(i, colQuantity, fltQty + parseFloat(getLineItem(i, colQuantity)));

				break;
			}
		}
	}

	if (i == iLineIdx)  // store current product in cookie arrays
	{
		// process line
		setLineItem(iLineIdx, colProductID, iProdID);
		setLineItem(iLineIdx, colQuantity, fltQty);
	
		// process custom fields
		for(var iCustomField = 0; iCustomField <arrCustomField.length; iCustomField++)
		{
			setLineSubItem(iLineIdx, colCustomFields, iCustomField, arrCustomField[iCustomField]);
		}
	}

// Add by HJT 22/10/2008 =======================================================

  if (varBenchtopProcessed == true) {
     if (varShortCode == "BTS" || varShortCode =="BTD") 
    window.alert("The Benchtop details and calculated costs have been recorded - now please specify the LEFT END finish requirements - even if this is UNFINISHED - as we like to have positive confirmation.");
	 else
   window.alert("The Benchtop details have been processed and a Cost Price has been calculated, for 'L' and 'U' shapes this includes the costs for the JOINS  -- now please specify the LEFT END and RIGHT END finish requirements - even if this is UNFINISHED, then all three items will be shown on the Shoppimg List (see View Cart).");

	return true;
   }
   
  if (varLeftSideProcessed == true) {
    window.alert("LEFT END finish details have been recorded - now please specify the RIGHT END finish requirements - even if this is UNFINISHED - as we like to have positive confirmation.");

	varLeftSideProcessed == false;
	return true;
   }
//  end add ================================================================

	if (typeof(strAddMessage) == "undefined" && varBenchtopProcessed == false)
	{
		window.location = "viewcart.htm";
		return true;
	}
	else if (strAddMessage != "")
	{
		alert(strAddMessage);
		return false;
	}
	
	
//  add (Insert) by hjt 4/11/2007  ===========================================================
   
   if (varDeleteLine) deleteLine(0);
 	   if (varFieldCheck == 1) return false;
   }
// end of addProductToCart(frm, strAddMessage, strErrMsg, strFileName) function
//================================================================================
// recalcCart
function recalcCart(line, item, strErrMsg, strFileName)
{
	if (item.value != item.defaultValue)
	{
		var fltQty = parseInt(item.value);

		if ((fltQty.toString() != "NaN") &&
			(fltQty - item.value == 0))
		{
			if (fltQty <= 0)
				deleteLine(line);
			else
				setLineItem(line, colQuantity, fltQty);
	
			window.location.href = 'viewcart.htm';
		}
		else
		{			
			if (typeof(document.all) != "undefined") 
			{
			  if (strFileName != ""){
				showModalDialog(strFileName, "", "dialogHeight: 145px; dialogWidth: 256px; dialogTop: px; dialogLeft: px; center: Yes; help: No; resizable: No; status: No; scroll: No;edge: raised");

				item.focus();
				item.select();			
			  }
			}
			else
			{
			  if (strErrMsg != ""){
				alert(strErrMsg);
				item.focus();
				item.select();			
			   }
			}
		}
	}
}

//* getCart(curSymbol, thousandsSeparator, decPlaces, decSeparator, blnSymbolAtFront, showExTax, showIncTax, showTaxPercent, showTaxAmount, defaultRegion)
// *
// * gets an HTML table that represents the reflects the current state of a shopping cart
// * 
// * input -
// * curSymbol:	the symbol used to represent currency
// * decPlaces:	the number of decimal places to display when writing currency
// * blnSymbolAtFront: whether to put the currency symbol at the front or at the back of the currency
// * showExTax:	show the ex tax column in the cart
// * showIncTax:	show the inc tax column in the cart
// * showTaxPercent: show the tax percent column in the cart
// * showTaxAmount: show the tax amount in the cart
// * defaultRegion: the default merchant to customer relationship in which to show prices (0 - local, 1 - domestic, 2 - international)


function getCart(curSymbol, thousandsSeparator, decPlaces, decSeparator,  truncateDec, blnSymbolAtFront, 

showExTax, showIncTax, showTaxPercent, showTaxAmount, defaultRegion, headerFont, headerSize, 

headerBackgnd, headerForegnd, headerText, cartFontOdd, cartFontSizeOdd, cartBackgndOdd,cartForegndOdd, 

cartFontEven, cartFontSizeEven, cartBackgndEven, cartForegndEven, totTaxLabel, totLabel, removeText, emptyCart, 

verStr, imagepath, strErrMsg, strFileName,NotRegMsg)

{
//alert("1647 did we get here");
 document.cookie = 'deleteme' + escape('nothing')  //this creates an EXTRA cookie just in case there was no data
 

 if (document.cookie == "") //but if cookie still 'blank' then give a message
  {
	strCart="<table border=\"1\" cellspacing=\"0\" width=\"80%\" bgcolor=\"#FFFFFF\" bordercolor=\"#808080\" cellpadding=\"6\"><tr><td width=\"100%\">";
	strCart +="<p align=\"center\"><font face=\"Tahoma\"><b>We're Sorry</b></font></td>";
	strCart +="</tr><tr><td width=\"100%\"><font face=\"Tahoma\" size=\"2\"><br>";
	strCart +="It appears your browser is set to refuse cookies. Our online Quotation ";
	strCart +="system requires that you have cookies enabled on your browser so your specifications and our Pricing can be stored in complete Privacy on your PC. </font>";
	strCart +="<p><font face=\"Tahoma\" size=\"2\">If you don't know how to enable this ";
	strCart +="feature we have provided instructions on enabling cookies for various ";
	strCart +="browsers at <a href=\"http://www.ezimerchant.com/linkin/shopping_cart.asp?link=CookiesNotEnabled\">www.ezimerchant.com</a>";
	strCart +="</font></p><p>&nbsp;</td></tr></table>";
	return strCart;

  }
	var strCart = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"2\">";

	var iColSpan = 4 + 
		(showExTax ? 1 : 0) + 
		(showTaxPercent ? 1 : 0) + 
		(showTaxAmount ? 1 : 0) + 
		(showIncTax ? 1 : 0);

	var curTaxTotal = 0;
	var curSubTotal = 0;

 	var region = defaultRegion.toString();	
 	if (getItem("region") != "") region = getItem("region");
 	if (region != "0" && region != "1" && region != "2") region = "1";
    region = "1";   //  force to Domestic Pricing hjt 19/01/2010	
	var lineCount = getLineCount();

	if (lineCount == 0)
	{	
		strCart += "<tr bgcolor=\"" + cartBackgndEven + "\"><td colspan=" + (iColSpan + 1) + " align=center valign=center nowrap><font face=\"" + cartFontOdd + "\" color=\"" + cartForegndEven + "\" size=\"" + cartFontSizeOdd + "\">" + emptyCart + "</font></td></tr>";
	}
	else
	{	
		strCart += "<tr id=\"heading\" bgcolor=" + headerBackgnd + ">";
		strCart += "<th nowrap valign=\"bottom\"><font face=\""+ headerFont + "\" color=\"" + headerForegnd + "\" size=" + headerSize +"><b>" + headerText[0] + "</b></font></th>";
		strCart += "<th valign=\"bottom\"><font face=\"" + headerFont +"\" color=\"" + headerForegnd + "\" size=" + headerSize + "><b>" + headerText[1] + "</b></font></th>";
		strCart += "<th valign=\"bottom\"><font face=\""+ headerFont +"\" color=\"" + headerForegnd + "\" size=" + headerSize + "><b>" + headerText[2] + "</b></font></th>";
		strCart += showExTax ? "<th valign=\"bottom\"><font face=\""+ headerFont +"\" color=\"" + headerForegnd + "\" size=" + headerSize + "><b>" + headerText[3] + "</b></font></th>" : "";
		strCart += showTaxPercent ? "<th valign=\"bottom\"><font face=\""+ headerFont +"\" color=\"" + headerForegnd + "\" size=" + headerSize + "><b>" + headerText[4] + "</b></font></th>" : "";
		strCart += showTaxAmount ? "<th valign=\"bottom\"><font face=\""+ headerFont +"\" color=\"" + headerForegnd +"\" size=" + headerSize + "><b>" + headerText[5] + "</b></font></th>" : "";
		strCart += showIncTax ? "<th valign=\"bottom\"><font face=\""+ headerFont +"\" color=\"" + headerForegnd + "\" size=" + headerSize + "><b>" + headerText[6] + "</b></font></th>" : "";
		strCart += "<th valign=\"bottom\"><font face=\""+ headerFont +"\" color=\"" + headerForegnd + "\" size=" + headerSize + "><b>" + headerText[7] + "</b></font></th>";
		strCart += "<th>&nbsp;</th></tr>";
//==============================================================
// insert by hjt 2/12/2009
// Check if there is  "OUTLET" data and initialise the varOutlet variable, also store any StyleSpec
 var lineCount = getLineCount();
 varSuffix = "";
 if (lineCount != 0)
 { 		
	for(var i = 0; i <lineCount; i++)
	{						
		var iProdID = parseInt(getLineItem(i, colProductID));
		varProductCode = getProductInfo(iProdID)[colProductCode]
		varCustomFieldNameCode = getProductInfo(iProdID)[colCustomFieldKeys][0];
        if (varProductCode.substring(0,1) == "2" || varProductCode.substring(0,1) == "z") {
	      varStyleSpec = true;
		  checkStyleInput(i,iProdID)
	    }
		if (varProductCode.substring(0,3) == "zP-") varNoPanel = true;
		if (varProductCode.substring(0,3) == "zK-") varNoKick = true;
                      // this is to prevent multiple prompts for missing Panel or Kickboard
	    if (varProductCode.substring(0,6) == "Outlet") {
		    varOutlet = getLineSubItem(i, colCustomFields, 1);
			OutLet = true;
		}
		if (addThirtyPercent == true && varFirstTime == true) varFirstTime = false;   
		if (varProductCode.substring(0,18) == "2 Style Laminate/X" || varProductCode.substring(0,18) == "2 Style Laminate/Z") addThirtyPercent = true; 		      	
	}
	if (OutLet == false && varURL.substring(0,5) != "START") {
		 alert("Your Current PRODUCT selection has been stored, but you have not yet supplied a selected Manufacturing Outlet [in 'START - Request for Quotation'] - please do that now before continuing.");
		 Outlet = true;
		 location.replace("category38_1.htm");
	}
 }
//=======================end inser by jjt 2/12/2009==========================			   
		for(var i = 0; i <lineCount; i++)
		{
		  var iProdID = parseInt(getLineItem(i, colProductID));
		  var fltQty = parseFloat(getLineItem(i, colQuantity));  
		  		  	
	   if (varLimitLines == true && iProdID == 65) currentLine = i;  // currentLine   is used in 'START-...' in case we want to REMOVE the Project line 		
       if (varLimitLines == true && iProdID != 65) continue;    // hjt  29/01/2012

//=========================Adition by hjt  November 2009 ================================== 
//  swap PID for a different Style-Price calculation using a new Product Code that is assembled from parts of the Old Product code
           varProductType = checkProductType(iProdID,varStatistics,i);
  		   varNewPID=changeStyle(iProdID,i);
// ========================================================				
			if (getProduct(iProdID) == null) continue;
			if (getProductInfo(iProdID) == null) continue;
			switch(region)
			{
			case "0":
				l_taxRate = parseFloat(getProduct(iProdID)[colTaxLocal]);
				break;			
			case "1":
				l_taxRate = parseFloat(getProduct(iProdID)[colTaxDomestic]);
				break;
			case "2":
				l_taxRate = parseFloat(getProduct(iProdID)[colTaxInternational]);
				break;
			}
//================================================
//add by HJT
          if (varNewPID != iProdID)
			var curPrice = parseFloat(getProduct(varNewPID)[colProductPrice]); 			
		  else curPrice = parseFloat(getProduct(iProdID)[colProductPrice]); 
//alert("line 1656 -check new product curPrice= " + curPrice + " iProdID=  " +  iProdID + "varNewPID= " + varNewPID);
//
//----------------------------------------------------------------------------------
// add (insert) by hjt on 30/11/2007
//
// calculate Price for Variable Size products 

	varProductCode = getProductInfo(iProdID)[colProductCode];
	varProdName = getProductInfo(iProdID)[colProductDesc];
	varProductType = checkProductType(iProdID,varStatistics,i);
	prodname = insertGloss(varProdName);
//alert("1840 prodname= " + prodname);	  	
	if (varOnLine == true) {
	  if (varProductCode.indexOf("/Y") > 0 && varProductCode.substring(0,1) != "2")  curPrice=PriceandWeightCalc(i);
	  if (varProductCode.substring(0,3) == "UBO" && varProductCode.indexOf("-") > 0)  curPrice = CalculateProportionalDiscount(curPrice,iProdID,i,lineCount,varNewPID);	  
	  if (varProductCode.substring(0,2) == "BT" || varProductCode.substring(0,2) == "WR" || varProductCode.substring(0,3) == "WOM" 
	  || varProductCode.substring(0,3) == "WOD" || varProductCode.substring(0,3) == "RH-" )
	               curPrice = CalculateProportionalDiscount(curPrice,iProdID,i,lineCount,varNewPID);
	}
	// add 25% to cost for GLOSS Laminate or 50% for Panels/Kickboards/Open-cabinets 
	if (varProductType == "Door" && varDoorStyle1 == "GLOSS" )  curPrice = curPrice * 150/100;
	if (varProductType == "Kick" && varKickStyle1 == "GLOSS" ) {
	                    curPrice = curPrice * 150/100;
     }
	 
	if (varProductType == "Open" && varOpenStyle1 == "GLOSS" ) curPrice = curPrice * 150/100;
	if (varProductType == "Pane" && varPanelStyle1 == "GLOSS" ) curPrice = curPrice * 150/100;
	
	if (varProductType == "Kit-" && varDoorStyle1 == "GLOSS" ) curPrice = curPrice * 125/100;
	if (varProductType == "Hybr" && varDoorStyle1 == "GLOSS" ) curPrice = curPrice * 125/100;
//alert("1674 - varProductType= " + varProductType + " varDoorStyle1= " + varDoorStyle1 + " varOpenStyle1= " + varOpenStyle1);
	
    if (varProductType != "Disc" && varProductType != "Hand" && varProductType != "Hard" && varProductType != "Styl" && varProductType != "Deli") {
	        extraShelfCalc(i, iProdID);        
			curPrice = curPrice + extraShelfCost;
			extraShelfCost = 0;
    }
// add 30% to cost of Kickboards in Aluminium or Black

     if (varProductCode.substring(0,4) == "Kick" && addThirtyPercent == true && varFirstTime == true) {
	 window.alert("The Kickboard(s) cost has been recalculated based on your choice of Aluminium or Black colour");
	 varFirstTime = false;
	 } 
	 if (varProductCode.substring(0,4) == "Kick" && addThirtyPercent == true)  curPrice = Math.round(curPrice * 130 /100); 
				
// check on Product Types and set 'indicators' 
//     checkProductType(iProdID,varStatistics,i)
	 
// Calculate U-Shape  or L-Shape bench
     if (iProdID < 224 && iProdID > 215 )  curPrice = BenchtopParameters(i, iProdID);
	 
	  varCurrentOrderPrice = varCurrentOrderPrice + parseFloat(curPrice * fltQty);   		 	 
			  
//calculate Freight cost and add in Admin charge proportionally for order cost < $800 (incl GST) unless Hardware only
      CalculateOrderWeight() 
	  var varAdminCost = Math.round(54.545 - varCurrentOrderPrice / 727.20 * 54.545);
//alert("1779 varAdminCost= " + varAdminCost + " varCurrentOrderPrice= " + varCurrentOrderPrice + " varTotalLength= " + varTotalLength);
	  if (varAdminCost < 2 || varTotalLength == 0) varAdminCost = 0;
	  if (varAdminCost > 0 && iProdID < 5) 
	alert("$" + varAdminCost + " (excl. GST) has been added to the Delivery Cost (or deducted from your Discount) for Orders <$800 in value, to cover a proportion of the $60 Setup/Admin costs incurred.");
		   	
			  if (iProdID == 1) {
   			     curPrice = 0;
				 if (varCurrentOrderPrice < 727.21) curPrice = curPrice + varAdminCost;  
			  }		  		
			  if (iProdID == 2) {
				  curPrice = Math.round(curPrice - (varCurrentOrderPrice * 5 ) / 100);
				  if (varCurrentOrderPrice <  727.21) curPrice = curPrice + varAdminCost;					 
			  }		  			       	   
              else if (iProdID == 3) {
				    if (CalculateOrderWeight() == true) {				  	 				 
			            varLocalDeliveryCost = Math.round(varTotalWeight * 3.5) / 10;
						if (varTotalLength > 2350) {
						    varLocalDeliveryCost = varLocalDeliveryCost + 50.00;
	alert("An extra charge of $50 has been added to the estimated cost of delivery as one of the components exceeds 2350mm in length and this may result in extra charges by the Carrier");
	
	                    }						
						 if (varLocalDeliveryCost < 70.00) {
							  varLocalDeliveryCost = 70.00;
window.alert("A MINIMUM freight cost of $70.00 (excl. GST) has been applied for this Order");
                          }									 								   
				     curPrice = varLocalDeliveryCost;
					 if (varCurrentOrderPrice <  727.21) curPrice = curPrice + varAdminCost;							 
				    }
			 }	  	   		  				  	
             else if (iProdID == 4) {
				   if (CalculateOrderWeight() == true) {
					varTotalWeight = Math.round(varTotalWeight * 1.28);
					varZone = getLineSubItem(i, colCustomFields, 2);
					if (getLineSubItem(i, colCustomFields, 3) == "Yes") varInsured = "Yes";   				
					else varInsured = "No";					   		
     			    varLongHaulCost = Math.round(CalculateLongHaul(varZone) * 100) / 100;
                    if (varTotalLength > 2350) {
						    varLocalDeliveryCost = varLocalDeliveryCost + 50.00;
	alert("An extra charge of $50 has been added to the estimated cost of delivery as one of the components exceeds 2350mm in length and this may result in extra charges by the Carrier");
	                 }
					if (varLongHaulCost < 85.00) {
						varLongHaulCost = 85.00;
					    alert("A MINIMUM freight cost of $85.00 (excl GST) has been applied for this Order");
					}
					if (varInsured == "Yes") {
					  Insurance = Math.ceil(varCurrentOrderPrice * .105) ; 
					  varLongHaulCost = varLongHaulCost + Insurance;
	alert(" Insurance cost of " + Insurance + " (excl. GST) has been added to the ESTIMATED cost of Delivery");
	                }
									  										
					if (varTotalLength > 2350) {
						varLongHaulCost = varLongHaulCost + 50.00;
	alert("An extra charge of $50 (excl. GST) has been added to the estimated cost of delivery as one of the components exceeds 2350mm in length and this may result in extra charges by the Carrier");
	                }
					
					curPrice = varLongHaulCost;
					if (varCurrentOrderPrice < 727.21) curPrice = curPrice + varAdminCost;  
	             }
    	     }  
			 
//
//* end modification by hjt on 30/o1/2008
//											
			var curTaxAmount = curPrice * l_taxRate;
			var curPriceIncTax = curPrice + curTaxAmount;
			var curPriceSubTotal;
			if (truncateDec) {
 			  curPriceSubTotal = Math.floor(fltQty * curPriceIncTax * Math.pow(10, decPlaces)) / Math.pow(10, decPlaces);
			}else {
 			  curPriceSubTotal = Math.round(fltQty * curPriceIncTax * Math.pow(10, decPlaces)) / Math.pow(10, decPlaces);
			}
			
//=================================================================			
			strCart += "<tr bgcolor=\"" + ((i % 2) == 0 ? cartBackgndEven : cartBackgndOdd) + "\">" +
						"<td><input type=text size=4 name=\"quantity\" value=\"" + fltQty + "\" onblur=\"recalcCart(" + i + ", this, '" + strErrMsg + "', '" + strFileName + "');\" onkeypress=\"if (event.which == 0 || event.keyCode == 13) recalcCart(" + i + ", this);\"></td>" +
//						"<td><font face=\"" + ((i % 2) == 0 ? cartFontEven : cartFontOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\">" + getProductInfo(iProdID)[colProductDesc] + "</font></td>" +

						"<td><font face=\"" + ((i % 2) == 0 ? cartFontEven : cartFontOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\">" + prodname + "</font></td>" +

//=========================================================================						
//						"<td><font face=\"" + ((i % 2) == 0 ? cartFontEven : cartFontOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\">" + getProductInfo(iProdID)[colProductCode] + "</font></td>";
						"<td><font face=\"" + ((i % 2) == 0 ? cartFontEven : cartFontOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\">" + newProductCode + "</font></td>";
//==========================================================================						
						
			strCart += showExTax ? "<td align=\"right\"><font face=\"" + ((i % 2) == 0 ? cartFontEven : cartFontOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\">" + formatCurrency(curSymbol, thousandsSeparator, decPlaces, decSeparator, truncateDec, blnSymbolAtFront, curPrice) + "</font></td>" : "";
			strCart += showTaxPercent ? "<td><font face=\"" + ((i % 2) == 0 ? cartFontEven : cartFontOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\">" + l_taxRate * 100 + "%</td>" : "";
			strCart += showTaxAmount ? "<td align=\"right\"><font face=\"" + ((i % 2) == 0 ? cartFontEven : cartFontOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd) + "\"  color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\">" + formatCurrency(curSymbol, thousandsSeparator,decPlaces, decSeparator, truncateDec, blnSymbolAtFront, curTaxAmount) + "</td>" : "";
			strCart += showIncTax ? "<td align=\"right\"><font face=\"" + ((i % 2) == 0 ? cartFontEven : cartFontOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\">" + formatCurrency(curSymbol, thousandsSeparator,decPlaces, decSeparator, truncateDec, blnSymbolAtFront, curPriceIncTax) + "</td>" : "";
			strCart += "<td align=\"right\"><font face=\"" + ((i % 2) == 0 ? cartFontEven : cartFontOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\">" + formatCurrency(curSymbol, thousandsSeparator,decPlaces, decSeparator, truncateDec, blnSymbolAtFront, curPriceSubTotal) + "</td>";
			
 strCart += "<td><a href=\"javascript: deleteLine(" + i + "); window.location = 'viewcart.htm';\"><img src=\"" + imagepath + "/cartremove.gif\" border=0 title=\"" + removeText + "\"></a>";
 	
			// hidden fields sent to server per orderline					
			strCart += "<input type=hidden name=\"prodweight\" value=\"" + FormatSeparator(getProduct(iProdID)[colProductWeight],decSeparator) + "\">";
			strCart += "<input type=hidden name=\"localtax\" value=\"" + getProduct(iProdID)[colTaxLocal] + "\">";
			strCart += "<input type=hidden name=\"domestictax\" value=\"" + getProduct(iProdID)[colTaxDomestic] + "\">";
			strCart += "<input type=hidden name=\"internationaltax\" value=\"" + getProduct(iProdID)[colTaxInternational] + "\">";
			strCart += "<input type=hidden name=\"localdelivery\" value=\"" + getProduct(iProdID)[colFreightLocal] + "\">";
			strCart += "<input type=hidden name=\"interstatedelivery\" value=\"" + getProduct(iProdID)[colFreightDomestic] + "\">";
			strCart += "<input type=hidden name=\"internationaldelivery\" value=\"" + getProduct(iProdID)[colFreightInternational] + "\">";
			strCart += "<input type=hidden name=\"unitprice\" value=\"" +  FormatSeparator(curPrice,decSeparator) + "\">";
//			strCart += "<input type=hidden name=\"prodname\" value=\"" + safeString(getProductInfo(iProdID)[colProductDesc]) + "\">";
				
            strCart += "<input type=hidden name=\"prodname\" value=\"" + prodname + "\">";
			
//			strCart += "<input type=hidden name=\"prodcode\" value=\"" + safeString(getProductInfo(iProdID)[colProductCode]) + "\">";
            strCart += "<input type=hidden name=\"prodcode\" value=\"" + newProductCode + "\">";
// process custom fields into hidden fields to be sent to server
			var strCustomFieldNames = "";
			var strCustomFieldValues = "";
			var iCustomFieldCount = getLineSubCount(i, colCustomFields);

			if (iCustomFieldCount > 0)
			{
				for(var iCustomField = 0; iCustomField <iCustomFieldCount; iCustomField++)
				{
					if (iCustomField > 0)
					{
						strCustomFieldNames += "|";
						strCustomFieldValues += "|";
					}		

					strCustomFieldNames += escape(getCustomField(getProductInfo(iProdID)[colCustomFieldKeys][iCustomField]));
					varCustomFieldNameCode = getProductInfo(iProdID)[colCustomFieldKeys][iCustomField];
					
// and just in case a 'last Minute Edit has removed one or more products we recalculate the totals					              
					if (varCustomFieldNameCode == 514 || varCustomFieldNameCode == 519) {
					    varStatistics = true;
					    CalculateOrderWeight();
						varStatistics = false;
					     if (varCustomFieldNameCode == 514 ) strCustomFieldValues += varTotalWeight;
					     if (varCustomFieldNameCode == 519 ) strCustomFieldValues += Math.round(varTotalWeight * 1.28);
					}
					else if (varCustomFieldNameCode == 517 ) strCustomFieldValues += varTotalLength;
					else if (varCustomFieldNameCode == 531 ) strCustomFieldValues += FloorUnits;
					else if (varCustomFieldNameCode == 532 ) strCustomFieldValues += WallUnits;
					else if (varCustomFieldNameCode == 533 ) strCustomFieldValues += OpenUnits;
					else if (varCustomFieldNameCode == 534 ) strCustomFieldValues += Wardrobes;
					else if (varCustomFieldNameCode == 535 ) strCustomFieldValues += Panels;
					else if (varCustomFieldNameCode == 536 ) strCustomFieldValues += Kickboards;
					else if (varCustomFieldNameCode == 537 ) strCustomFieldValues += ExtraDoors;
					else if (varCustomFieldNameCode == 538 ) strCustomFieldValues += Benchtops;
					else if (varCustomFieldNameCode == 539 ) strCustomFieldValues += CarcassUnits;
					else if (varCustomFieldNameCode == 552 ) strCustomFieldValues += Handles;
					else if (varCustomFieldNameCode == 553 ) strCustomFieldValues += Hardware;
// special check on text in "Special Requests"					
					else if (varCustomFieldNameCode == 10 || varCustomFieldNameCode == 617) { 
					   varSpecialRequest = escape(getLineSubItem(i, colCustomFields, iCustomField));
					   if (varSpecialRequest != "" ) varSpecialRequest = checkSpecialCharacters(varSpecialRequest);
					   strCustomFieldValues += varSpecialRequest;
					}					
														
				    else strCustomFieldValues += escape(getLineSubItem(i, colCustomFields, iCustomField));					  									
				}
			}
			strCart += "<input type=hidden name=\"customfieldname\" value=\"" + strCustomFieldNames + "\">";
			strCart += "<input type=hidden name=\"customfieldvalue\" value=\"" + strCustomFieldValues + "\">";

			strCart += "</td></tr>";
						
			if (iCustomFieldCount > 0)
			{
				strCart += "<tr bgcolor=\"" + ((i % 2) == 0 ? cartBackgndEven : cartBackgndOdd) + "\"><td>&nbsp;</td><td colspan=\"" + iColSpan + "\"><table>";
				for(var iCustomField = 0; iCustomField <getLineSubCount(i, colCustomFields); iCustomField++)
				{
					strCart += "<tr><td width=\"45%\" align=\"left\"><font face=\"" + ((i % 2) == 0 ? cartFontEven : cartFontOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\"><b><i>" + getCustomField(getProductInfo(iProdID)[colCustomFieldKeys][iCustomField]) + ":</i></b></font></td>"
					
//  added code hjt====================================================================					
					 customName = getCustomField(getProductInfo(iProdID)[colCustomFieldKeys][iCustomField]);
					 customValue = getLineSubItem(i, colCustomFields, iCustomField);
                     productCode = newProductCode;
					 varCustomFieldNameCode = getProductInfo(iProdID)[colCustomFieldKeys][iCustomField];					 

// and just in case a 'last Minute Edit has removed one or more products we reclculate the totals					              
					
				    if (varCustomFieldNameCode == 514 ) customValue = varTotalWeight;
					else if (varCustomFieldNameCode == 519 ) customValue = Math.round(varTotalWeight * 1.28);
					else if (varCustomFieldNameCode == 517 ) customValue = varTotalLength;
					else if (varCustomFieldNameCode == 531 ) customValue = FloorUnits;
					else if (varCustomFieldNameCode == 532 ) customValue = WallUnits;
					else if (varCustomFieldNameCode == 533 ) customValue = OpenUnits;
					else if (varCustomFieldNameCode == 534 ) customValue = Wardrobes;
					else if (varCustomFieldNameCode == 535 ) customValue = Panels;
					else if (varCustomFieldNameCode == 536 ) customValue = Kickboards;
					else if (varCustomFieldNameCode == 537 ) customValue = ExtraDoors;
					else if (varCustomFieldNameCode == 538 ) customValue = Benchtops;
					else if (varCustomFieldNameCode == 539 ) customValue = CarcassUnits;
					else if (varCustomFieldNameCode == 552 ) customValue = Handles;
					else if (varCustomFieldNameCode == 553 ) customValue = Hardware;
					else if (varCustomFieldNameCode == 10 ) customValue = getLineSubItem(i, colCustomFields, iCustomField);
					else if (varCustomFieldNameCode == 637 && iProdID == 2 && varAdminCost > 0) customValue = "*D* Pickup Discount is offset by Setup/Admin cost $" + varAdminCost + " (excl. GST)";
					else if (varCustomFieldNameCode == 637 && iProdID == 2 && varAdminCost == 0)  customValue = "*D* Pickup Discount calculated";
					else if (varCustomFieldNameCode == 637 && iProdID == 1 && varAdminCost > 0)  customValue = "*F* Self Shipping cost is free but a proportional Setup/Admin cost is included of $" + varAdminCost + " (excl. GST)" ;
					else if (varCustomFieldNameCode == 637 && iProdID == 1 && varAdminCost == 0)  customValue = "*F* Self Shipping cost." ;
					else if (varCustomFieldNameCode == 637 && iProdID == 3 && varAdminCost == 0 && Insurance == 0) customValue = "*F* Freight Calculated." ;
					else if (varCustomFieldNameCode == 637 && iProdID == 3 && varAdminCost != 0) customValue = "*F* Freight Calculated includes a proportion of Setup cost of $" + varAdminCost + " (excl. GST)";
					else if (varCustomFieldNameCode == 637 && iProdID == 4  && varAdminCost == 0 && Insurance == 0)  customValue = "*F* Freight Calculated";
					else if (varCustomFieldNameCode == 637 && iProdID == 4 && varAdminCost == 0 && Insurance != 0) customValue = "*F* Freight Calculated includes insurance cost of $" + Insurance + " (excl. GST)"; 
					else if (varCustomFieldNameCode == 637 && iProdID == 4 && varAdminCost != 0 && Insurance == 0) customValue = "*F* Freight Calculated includes a proportion of Setup cost of $" + varAdminCost + " (excl. GST)";   
					else if (varCustomFieldNameCode == 637 && iProdID == 4 && varAdminCost != 0 && Insurance != 0) customValue = "*F* Freight Calculated includes a proportion of Setup cost of $" + varAdminCost + " (excl. GST)" + " Insurance of $" + Insurance + " (excl. GST)";
					else if (varCustomFieldNameCode == 636 && iProdID == 4) {
					 var tempvar= customValue;
					 if (tempvar.substring(0,3) == "Yes")  varPrompt="Alternative= [No]"; 
					 if (tempvar.substring(0,3) == "No")  varPrompt="Alternative= [Yes]"; 
					}	

                    if (customName == null) customName = "--------------------";					
					if (iProdID > 4){
					 var tempvar= customValue;
					      if (tempvar.substring(0,3) == "Yes")  varPrompt="Alternative= [No]";
					 else if (tempvar.substring(0,2) == "No")  varPrompt="Alternative= [Yes]";					 
					 else if (tempvar.substring(0,4) == "Left")  varPrompt="Alternative= [Right], or [None]";
					 else if (tempvar.substring(0,4) == "None")  varPrompt="Alternative= [Right], or [Left]";
					 else if (tempvar.substring(0,5) == "Right")  varPrompt="Alternative= [Left], or [None]";
					 else if (tempvar.substring(0,5) == "Fixed")  varPrompt="Alternative= [Adjustable]";
					 else if (tempvar.substring(0,10) == "Adjustable")  varPrompt="Alternative= [Fixed]";
					 else if (tempvar.substring(0,5) == "Right")  varPrompt="Alternative= [Left], or [None}";
					 else if (customName.substring(0,5) == "Front") varPrompt="Alternatives= [Bullnose Edge], [D-round Edge] or [Square]";
					 else if (customName.substring(0,10) =="Hinge Hole") varPrompt="Alternatives= [Cup + Outriggers], [Cup only] or [Not Applicable]";
					 else if (customName.substring(0,4) == "Rear") varPrompt="Alternatives= [Unfinished], or [As for Front edge]";
					 else if (customName.substring(0,4) == "SECT")  varPrompt="Alternatives= [A] - [H]";
					 else if (tempvar.substring(0,4) >= 0)  varPrompt="Amend: [Number]";
					 
					 else varPrompt=" ";
                   }
			       if (varURL.substring(0,9) != "View Cart" || productCode.substring(0,1) == "2" || productCode.substring(0,1) == "8" || productCode.substring(0,2) == "zz" || customName.substring(0,6) == "Unique" || customName.substring(0,4) == "Room" || customName.substring(0,4) == "Wall" ||  customName.substring(0,4) == "Ward" || iProdID < 5 || iProdID == 65)
				        DoNotallowEdit = true;
				   else DoNotallowEdit = false; 
				   if (varCustomFieldNameCode == 636 || varCustomFieldNameCode == 10) DoNotallowEdit = false; 
				   
				   if (DoNotallowEdit == true) {
			   
					strCart += "<td align=\"left\"><font face=\"" + ((i % 2) == 0 ? cartFontEven : cartFontOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd) + "\"  color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\">" + customValue + "</font></td>";
   			      } else {
						
						if (customName.substring(0,16) == "Special requests") 
 						  strCart += "<td align=\"left\"><input type=text size=50 name=\"newInput\" value=\"" + getLineSubItem(i, colCustomFields, iCustomField) +  "\" onblur=\"editCart(" + i + ", this, '" + colCustomFields + "', '" + iCustomField + "' ,'" + productCode + "', '" + customName + "','" + customValue + "','" + varCustomFieldNameCode + "');\" onkeypress=\"if (event.which == 0 || event.keyCode == 13) editCart(" + i + ", this);\"></td>" ;
                         else {						  				   		
  	                     strCart += "<td width=\"5%\" align=\"left\"><input type=text size=20 name=\"newInput\" value=\"" + tempvar + "\" onblur=\"editCart(" + i + ", this, '" + colCustomFields + "', '" + iCustomField + "' ,'" + productCode + "', '" + customName + "','" + customValue + "','" + varCustomFieldNameCode + "');\" onkeypress=\"if (event.which == 0 || event.keyCode == 13) editCart(" + i + ", this) ;\"> " ;
                          strCart += "</td>";
						  strCart += "<td width=\"70%\" align=\"right\">";
						  strCart += varPrompt;		 
						 
						 strCart += "</td>";
//						 	alert(item.value + " " + productCode + " " + customName + " " + customValue);
						}		
 				  }				      
			    }
	//alert("2027 - prodname= " + safeString(getProductInfo(iProdID)[colProductDesc])  + " prodcode= " + newProductCode + " strCustomFieldNames= "  + strCustomFieldNames + " strCustomFieldValues= " + strCustomFieldValues);	
															
//======================================================================================= hjt end changes				
//"\" onblur=\"recalcCart(" + i + ", this, '" + strErrMsg + "', '" + strFileName + "');\"				
							
				strCart += "</table></td></tr>";
			}
	
			if (truncateDec) {
  			  curTaxTotal += Math.floor(fltQty * curTaxAmount * Math.pow(10, decPlaces)) / Math.pow(10, decPlaces); 	
			}else {
  			  curTaxTotal += Math.round(fltQty * curTaxAmount * Math.pow(10, decPlaces)) / Math.pow(10, decPlaces);
			}
	
			curSubTotal += curPriceSubTotal;
		}
		
		iUseBackgnd = lineCount + 1;
		if (curTaxTotal > 0)
		{
			strCart += "<tr><td colspan=\"" + (iColSpan - 1) + "\" align=right>" +
					"<font face=\"" + ((i % 2) == 0 ? cartFontEven : cartFontOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd) + "\"  color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\">" +
					"<b>" + totLabel + " (" +  totTaxLabel + " " + formatCurrency(curSymbol, thousandsSeparator,decPlaces, decSeparator, truncateDec, blnSymbolAtFront, curTaxTotal) + "):</b>" + 
					"</font>" +
					"</td>" +
					"<td align=\"right\" bgcolor=\"" + ((iUseBackgnd % 2) ? cartBackgndEven : cartBackgndOdd) + "\">" +
					"<font face=\"" + ((i % 2) == 0 ? cartFontEven : cartFontOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\">" +
					"<b>" + formatCurrency(curSymbol, thousandsSeparator,decPlaces, decSeparator, truncateDec, blnSymbolAtFront, curSubTotal) + "</b>" +
					"</font>" +
					"</td>" +
				"</tr>";
//------------------------------------------------------------------------------------
// add (insert)  by hjt 29/11/2007
 varOrderCost = curSubTotal;

 
// end of add-in   --------------------------------------------------------------------				
						
		}
		else
		{
			strCart += "<tr><td colspan=\"" + (iColSpan - 1) + "\" align=right><font face=\"" + ((i % 2) == 0 ? cartFontEven : cartFontOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd) + "\"  color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\"><b><i>" + totLabel + ":</i></b></font></td><td align=\"right\" bgcolor=\"" + ((iUseBackgnd % 2) ? cartBackgndEven : cartBackgndOdd) + "\"><font face=\"" + ((i % 2) == 0 ? cartFontEven : cartFontOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\"><b>" + formatCurrency(curSymbol, thousandsSeparator,decPlaces, decSeparator, truncateDec, blnSymbolAtFront, curSubTotal) + "</b></font></td></tr>";		
		}

		strCart += "<tr><td colspan=\"" + (iColSpan + 1) + "\" align=right>";
		strCart += "<input type=hidden name=\"productcount\" value=\"" + getLineCount() + "\">";
		strCart += "<input type=hidden name=\"version\" value=\"" + verStr + "\">";
		strCart += "</td></tr>";

		strCart += "<tr><td colspan=\"9\" align=right>";
// add by HJT 01282008   -----------------------------------------------------------------------
// to allow validation of total Order details before submitting the Order to the Server
// the CheckShoppingList() function will change the window.location to viewcart-2.htm if the Order checks out.
   
   varNewPID = iProdID
		
  if (varURL.substring(0,9) == "View Cart") {
  
        strCart += "<br><font color='green' size=4>When all Product, Colour and Delivery details are supplied <br> - then please check your data for consistency by clicking: </font> <a href=\"#\" onclick=\"CheckShoppingList()\"><img src=\"" + imagepath + "/CheckShoppingList_on.gif\" vspace=3 border=\"3\" name=\"recalcBtn\"></a>";

  }
  if (varURL.substring(0,10) == "viewcart-2") { 
    if (NotRegMsg !="") {
		strCart += "<br> <a href=\"javascript: bProcessCart = false;alert('" + NotRegMsg+ "');\"><img src=\"" + imagepath + "/cartcheckout.gif\" border=\"0\"></a>";
    } else {
		strCart += "<br><font color='green' size='5'>Your Shopping List has been validated - please continue:<a href=\"javascript: bProcessCart = true; document.forms['ordercart'].submit();\"><img src=\"" + imagepath + "/cartcheckout.gif\" border=\"0\"></a>";
      }
  }
 varOutletSet= false;
 varLimitLines = false;   
// end of modifications by HJT 30/1/2008 ----------------------------------------------------------
		strCart += "</td></tr>";
	}
	strCart += "</table>";
	strCart += "<input type=hidden name=\"requestedaction\" value=\"CreateNewOrder\">";

if (varURL.substring(0,10) == "viewcart-3" && varProductCode.substring(0,6) == "Outlet" ) alert("Now that you have selected a Manufacturing Outlet - please CLICK again on the [Get Price] button of your last Product selection");

return strCart;

}

// * formatCurrency(curSymbol, thousandsSeparator, decPlaces, decSeparator,  truncateDec, blnSymbolAtFront, curValue)
// *
// * takes a currency value and decorates it with currency formatting
// *
// * curSymbol:	the actual symbol used to indicate this is currency
// * decPlaces:	the number of decimals to display to the right of the separator
// * decSeparator: the symbol used to separate the whole from the fractional portion of the currency
// * blnSymbolAtFront: whether to put the currency symbol at the front or back
 //* curValue:	the actual money value to display


function formatCurrency(curSymbol, thousandsSeparator, decPlaces, decSeparator, truncateDec, blnSymbolAtFront, curValue)
{
	var strCurrency;
	if (truncateDec) {
	  strCurrency = Math.floor(parseFloat(curValue) * Math.pow(10, decPlaces));
	}else {
	  strCurrency = Math.round(parseFloat(curValue) * Math.pow(10, decPlaces));
	}

	strCurrency = strCurrency.toString();

	while (strCurrency.length <= decPlaces) strCurrency = "0" + strCurrency;

	var decValue = 	strCurrency.substr(strCurrency.length - decPlaces, strCurrency.length);			

	strCurrency = strCurrency.substr(0, strCurrency.length - decPlaces);
	var s;

	if (strCurrency.length > 3) {
	        s = strCurrency.substr(strCurrency.length-3, 3);

		for (var i = 4; i <= strCurrency.length; i++){
        	   if (((i - 4) % 3) == 0){
	              s = strCurrency.substr(strCurrency.length - i,1) + thousandsSeparator + s;
		    } 
		    else{
		      s = strCurrency.substr(strCurrency.length - i,1) + s;
		    }
	
		}
	} else {
	  s = strCurrency;
	}

	if (decPlaces != 0) {
   	  strCurrency =  s + decSeparator + decValue;
	}else{
   	  strCurrency =  s;
	}

	return blnSymbolAtFront ? curSymbol + strCurrency : strCurrency + curSymbol;	

}

// * safeString(str)
// *
// * takes a str and returns another safe to put into a value attribute on an input tag
// *
// * input -
// * str:		the string that is dirty


function safeString(str)
{
	if (str.constructor != String) 
		str = new String(str);
	return str.replace(/\"/g, "&quot;");
}

// * setRegion(region)
// *
// * takes the region specified and persists it for the current user
// * this allows prices to shown in the region relative to the merchant appropriately
// * input -
// * region:	0 for a local (interstate) sale
// *			1 for a domestic (national) sale
// *			2 for an international sale

function setRegion(region)
{
	setItem("region", region);
	
	// File condition to cater for problem with IE7
	if (window.location.protocol == "file:")
	{
		window.location = "file://" + window.location.pathname;
	}
	else
	{
		window.location = window.location.pathname;
	}
	return false;
}

function getRegion(defaultregion)
{
   var region = defaultregion.toString();	
   if (getItem("region") != "") region = getItem("region");
   if (region != "0" && region != "1" && region != "2") region = "1";	
    region = "1";   //  forece to Domestic Pricing hjt 19/01/2010
  return region;
}

function getLocalButton(defaultregion, OnlyInCart)
{

  if (OnlyInCart) {
    var lineCount = getLineCount();
    if (lineCount == 0){
      return  "";
    }
  }
     
  var strBtn = "<a href=\"javascript:setRegion(0);\">";
  strBtn += getRegion(defaultregion) == 0 ? "<img border=\"0\" src=\"images/cartlocal_on.gif\"></a>" : "<img border=\"0\" src=\"images/cartlocal_off.gif\"></a>";
  return strBtn;

}

function getDomesticButton(defaultregion, OnlyInCart)
{
  if (OnlyInCart) {
    var lineCount = getLineCount();
    if (lineCount == 0){
      return  "";
    }
  }
  var strBtn = "<a href=\"javascript:setRegion(1);\">";
  strBtn += getRegion(defaultregion) == 1 ? "<img border=\"0\" src=\"images/cartdomestic_on.gif\"></a>" : "<img border=\"0\" src=\"images/cartdomestic_off.gif\"></a>";
  return strBtn;

}

function getInternationalButton(defaultregion, OnlyInCart)
{
  if (OnlyInCart) {
    var lineCount = getLineCount();
    if (lineCount == 0){
      return  "";
    }
  }
  var strBtn = "<a href=\"javascript:setRegion(2);\">";
  strBtn += getRegion(defaultregion) == 2 ? "<img border=\"0\" src=\"images/cartinternational_on.gif\"></a>" : "<img border=\"0\" src=\"images/cartinternational_off.gif\"></a>";
  return strBtn;

}

function getItem(key)
{
	var idx = private_getItemIndex(key);

	if (idx == -1)
	{
		return "";
	}
	
	return unescape(arrItem[idx][1]);
}

function setItem(key, value)
{	
	var idx = private_getItemIndex(key);

	if (idx == -1) idx = arrItem.length;

	arrItem[idx] = new Array(key, escape(value));

	return private_UpdateItems();
}

function getLineItem(line, key)
{
	var idx = private_getLineItemIndex(line, key);

	if (idx == -1)
	{
		return "";
	}

	return unescape(arrLine[line][idx]);
}

function setLineItem(line, key, value)
{
	var idx = private_getLineItemIndex(line, key);
	if (idx == -1)
	{
		if (typeof(arrLine) == "undefined")
		{
			arrLine = new Array();
		}
		if (typeof(arrLine[line]) == "undefined")
		{		     
			arrLine[line] = new Array(0);
		}
		idx = key;
	}

	if (typeof(value) == "string")
	{
		arrLine[line][idx] = escape(value);
	   if (typeof(arrLine[line][idx]) == "undefined") arrLine = escape(value);
	}
	else
	{
	   if (typeof(arrLine) == "undefined") arrLine = escape(value);   // hjt 26/12/2010
	   else arrLine[line][idx] = value;
	}

	return private_UpdateLines();
}

function deleteLine(line)
{
	var arrLineTmp = new Array(0);

	if (arrLine.length > line)
	{
		for(var i = 0; i <line; i++)
		{
			arrLineTmp[i] = arrLine[i];
		}
		for(var i = line + 1; i <arrLine.length; i++)
		{
			arrLineTmp[i - 1] = arrLine[i];
		}
	}
	
	arrLine = arrLineTmp;
	
	private_UpdateLines();
}

function getLineSubItem(line, key1, key2)
{
	var idx = private_getLineItemIndex(line, key1);

	if (idx == -1)
	{
		return "";
	}

	if (typeof(arrLine[line][idx]) == "string")
	{
		return unescape(arrLine[line][idx]);
	}

	arrSubLine = arrLine[line][idx];

	if (typeof(arrSubLine) == "undefined" || arrSubLine == null)
	{
		return "";
	}
	
	return unescape(arrSubLine[key2]);
}

function setLineSubItem(line, key1, key2, value)
{

	var idx = private_getLineItemIndex(line, key1);

	var arrSubLine = null;

	if (idx == -1)
	{
		arrSubLine = new Array(0);
		arrSubLine[key2] = escape(value);
	}
	else
	{
		arrSubLine = arrLine[line][idx];
		if (typeof(arrSubLine) == "undefined")
		{
			arrSubLine = new Array(0);			
		}
		
		arrSubLine[key2] = escape(value);
		if (typeof(value) == "string" && typeof(arrSubLine[key2]) == "undefined") arrSubLine = value;       //hjt 26/12/2010
	}

	setLineItem(line, key1, arrSubLine);
}

function getLineCount()
{
	if (typeof(arrLine) == "undefined")
		return 0;
	else
		return arrLine.length;
}

function getLineSubCount(line, key)
{
	if (typeof(arrLine[line]) == "undefined")
	{
		return 0;
	}

	if (typeof(arrLine[line][key]) == "string")
	{
		return 1;
	}

	if (typeof(arrLine[line][key]) == "undefined" ||
		typeof(arrLine[line][key]) != "object")
	{
		return 0;
	}
	
	return arrLine[line][key].length;
}

function private_UpdateItems()   //deleted 0n 4/2/2012 deemed obsolete
{
	return true;
}


function private_UpdateLines()
{
	var strLines;
	var arrLineTmp = new Array(0);
	var yy = 0;
	
	for(var i = 0; i <arrLine.length; i++)
	{
//alert("2455 arrLine=  " + arrLine[i] + " arrLine.length= " + arrLine.length + " i= " + i);		
		if (typeof(arrLine[i]) == "undefined")    continue;
		 arrLineTmp[yy] = arrLine[i].join("&"); //change 12/01/22
		 yy = yy + 1;
	}
 
	    strLines = CookieID + "=" + arrLineTmp.join("#");

	  if (strLines.length > 4096) return false;
	  var dtExpiry = new Date();
	  dtExpiry.setDate(dtExpiry.getDate() + CookieRetention); // added as a variable	
	document.cookie = strLines + "; expires=" + dtExpiry.toGMTString() + ";";
//alert("2467 at end - strLines= " + strLines + " i= " + i);
	return true;

}

function private_getItemIndex(key)
{
	if (typeof(arrItem) == "undefined") return -1;

	for(var i = 0; i <arrItem.length; i++)
	{
		if (arrItem[i][0] == key) return i;
	}

	return -1;
}

function private_getLineItemIndex(line, key)
{
	if (typeof(arrLine) == "undefined") return -1;
	if (typeof(arrLine[line]) == "undefined") return -1;
	if (typeof(arrLine[line][key]) == "undefined") return -1;

	return key;
}


function private_CartLoad()
{

//alert(" CookieID= " + CookieID + " arrrCookie= " + arrCookie + " varLimitLines = " + varLimitLines);
	if (arrCookie == null || arrCookie == "" || arrCookie == "delet")
	{
		arrCookie = new Array(0);
	}
  if (varListAll == false ) {
	for(var i = 0; i <arrCookie.length; i++)
	{
		if (arrCookie[i].substr(0, 5) == CookieID )
		{
			arrLine = arrCookie[i].substr(6, arrCookie[i].length - 6).split("#");
//alert("2508 collected new arrLine data= " + arrLine);
		}
	}
  }

	if (arrLine == null || arrLine == "" )
	{
		arrLine = new Array(0);
	} 
	
	for(var i = 0; i <arrLine.length; i++)
	{
     if (arrLine[i] == "" || arrLine[i] == null) continue; 		
	 else {
	 	arrLine[i] = arrLine[i].split("&");
         }	
		for (var iField = 0; iField <arrLine[i].length; iField++)
		{
			var arrSubItems = arrLine[i][iField].split(",");
			
			if (arrSubItems != null && arrSubItems != "")
			{
				if (arrSubItems.length == 1) continue;

				arrLine[i][iField] = arrSubItems;
			}
		}				
	}
	
}

function FormatSeparator(strValue,decSeparator)
{
	var re = /\./;
	var newValue = strValue.toString();
	newValue = newValue.replace(re, decSeparator);
	return newValue;
}


// additional code added by hjt December 2007
// for Delivery calculations and to Check that Order-Lines still have the correct Style Identification

function CalculateOrderTotals()
{
    TotalOrderCheck = true;
    varOrderCost = 0;
	extraShelfCost = 0;
	varPrice = 0;
	varWeight = 0;
	varVariableWeight = 0;
	varTotalWeight = 0;
	varQuantity = 0;
	CalculatedBenchtopCost = 0;
    PanelStyle = "Nil";

	varWardRobe1 = "000";
	varWardRobe2 = "000";
	varWardRobe3 = "000";
	varWardRobe4 = "000";
	varWardRobe5 = "000";
	varWardRobe6 = "000";
	varWardRobe7 = "000";
	varWardRobe8 = "000";
	varWardRobe9 = "000";
	varWardRobe10 = "000";
	varWardRobe11 = "000";
	varWardRobe12 = "000";
	varWardRobe13 = "000";
	varWardRobe14 = "000";
	varWardRobe15 = "000";
	varWardRobe16 = "000";
	varWardRobe17 = "000";
	varWardRobe18 = "000";
	varWardRobe19 = "000";
	varWardRobe20 = "000";
	varWardRobe21 = "000";
	varWardRobe22 = "000";
	varWardRobe23 = "000";
	varWardRobe24 = "000";
	
	varWardRobeHeight1 = 0;
	varWardRobeHeight2 = 0;
	varWardRobeHeight3 = 0;
	varWardRobeHeight4 = 0;
	varWardRobeHeight5 = 0;
	varWardRobeHeight6 = 0;
    varWardRobeHeight7 = 0;
    varWardRobeHeight8 = 0;
	varWardRobeHeight9 = 0;
	varWardRobeHeight10 = 0;
	varWardRobeHeight11 = 0;
	varWardRobeHeight12 = 0;
	varWardRobeHeight13 = 0;
	varWardRobeHeight14 = 0;
	varWardRobeHeight15 = 0;
	varWardRobeHeight16 = 0;
	varWardRobeHeight17 = 0;
	varWardRobeHeight18 = 0;
    varWardRobeHeight19 = 0;
    varWardRobeHeight20 = 0;
	varWardRobeHeight21 = 0;
	varWardRobeHeight22 = 0;
	varWardRobeHeight23 = 0;
	varWardRobeHeight24 = 0;	 
	 
 varWardRobeDepth1 = 0;
 varWardRobeDepth2 = 0;
 varWardRobeDepth3 = 0;
 varWardRobeDepth4 = 0;
 varWardRobeDepth5 = 0;
 varWardRobeDepth6 = 0;
 varWardRobeDepth7 = 0;
 varWardRobeDepth8 = 0;
 varWardRobeDepth9 = 0;
 varWardRobeDepth10 = 0;
 varWardRobeDepth11 = 0;
 varWardRobeDepth12 = 0;
 varWardRobeDepth13 = 0;
 varWardRobeDepth14 = 0;
 varWardRobeDepth15 = 0;
 varWardRobeDepth16 = 0;
 varWardRobeDepth17 = 0;
 varWardRobeDepth17 = 0;
 varWardRobeDepth19 = 0;
 varWardRobeDepth20 = 0;
 varWardRobeDepth21 = 0;
 varWardRobeDepth22 = 0;
 varWardRobeDepth23 = 0;
 varWardRobeDepth24 = 0;
 
 varWardRobeShape1 = false;
 varWardRobeShape2 = false;
 varWardRobeShape3 = false;
 varWardRobeShape4 = false;
 varWardRobeShape5 = false;
 varWardRobeShape6 = false;
 varWardRobeShape7 = false;
 varWardRobeShape8 = false;
 varWardRobeShape9 = false;
 varWardRobeShape10 = false;
 varWardRobeShape11 = false;
 varWardRobeShape12 = false;
 varWardRobeShape13 = false;
 varWardRobeShape14 = false;
 varWardRobeShape15 = false;
 varWardRobeShape16 = false;
 varWardRobeShape17 = false;
 varWardRobeShape17 = false;
 varWardRobeShape19 = false;
 varWardRobeShape20 = false;
 varWardRobeShape21 = false;
 varWardRobeShape22 = false;
 varWardRobeShape23 = false;
 varWardRobeShape24 = false;	 
 varRW1 = "NIL";
 varRW2 = "NIL";
 varRW3 = "NIL";
 varRW4 = "NIL";
 varRW5 = "NIL";
 varRW6 = "NIL";
 varRW7 = "NIL";
 varRW8 = "NIL";
 varRWError = "";
 varSection = " ";
 varLastWR = " ";
 varLastSection = " ";
 for (var ii = 0; ii<24; ii++)
   {wardrobe[ii] = "ZZZ";
   }
	  
	varBenchTop1 = "";
	varBenchTop2 = "";
	varBenchTop3 = "";
    varBenchTop4 = "";
	varBenchTop5 = "";
	varBenchTop6 = "";
	varBenchTop7 = "";
	varBenchTop8 = "";
	varBenchTop9 = "";
	varBenchTop10 = "";
	varBTNumber = 0;
	varMaleJoin = 0;
	varFemaleJoin = 0;	
	varButtJoin = 0;
	varEndJoin = 0;  
	varTotalJoin = 0;
	varInvalidProduct = false;
	varProductType = "Unde";
	
	FloorUnits = 0;
	WallUnits = 0;
	OpenUnits = 0;
	Panels = 0;
	Kickboards = 0;
	Benchtops = 0;
	Wardrobes = 0;
	Bulkheads = 0;
	Filler = 0;
	ExtraDoors = 0;
	CarcassUnits = 0;
	ModularUnits = 0;
	Handles = 0;
	Hardware = 0;
	varMinimum = false;
	varStatistics = false;
// for benchtop calculations
    Ll = 0;  // length of side
	Ww = 0;  // Width od side
	Ee = 0;  // Single or Double Postform
	varBenchWeight = 0 ;  // calculated weight of one Side
    BenchWeight = 0 ;  // Total weight of a benchtop product.	 	 
    varLl = 0;  //Lenth of side 1
	varW1 = 0;  // Width of Side 1
	varE1 = 0;  //Edging of Side 1
	varBenchW1 = 0;  // Weight of Side 1
	varL2 = 0;  //Lenth of side 2
	varW2 = 0;  // Width of Side 2
	varE2 = 0;  //Edging of Side 2
	varBenchW2 = 0;  // Weight of Side 2
	varL3 = 0;  //Lenth of side 3
	varW3 = 0;  // Width of Side 3
	varE3 = 0;  //Edging of Side 3
	varBenchW3 = 0;  // Weight of Side 3
	BenchCost = 0;  //calculated benchCost
	BenchCost1 = 0;  // Side 1 cost
	BenchCost2= 0;  // Side 2 cost
	BenchCost3 = 0;  // Side 3 cost
	BenchLength = 0;
	varBenchtopStyle = false;
	varEndFinishNumber = 0;
	varEndNumber = 0;
	varFatalError = false;
	varPreviousBaseHeight = 0;  //To check that current Base Cabinet Height = Previous one 
	
	varDoorStyle1 = "Nil";
    varDoorStyle2 = "Nil";
	varDoorStyle3 = "Nil";
	varPanelStyle1 = "Nil";
	varPanelStyle2 = "Nil";
	varPanelStyle3 = "Nil";
	varKickStyle1 = "Nil";
	varKickStyle2 = "Nil";
	varKickStyle3 = "Nil";
	varOpenStyle1 = "Nil";
	varOpenStyle2 = "Nil";
	varOpenStyle3 = "Nil";
	
	varFullProductStyle = "A different Style"; 
	varCarcassProcessed = false;		
			
    var lineCount = getLineCount();
// firstly we check on the Style records that were recorded and build up an array of recorded Styles:
//      and at the same time we check for [**Bypass Input Check] order lines
 if (lineCount != 0)
 {	
	for(var i = 0; i <lineCount; i++)
	{
		var iProdID = parseInt(getLineItem(i, colProductID));
//=========================Adition by hjt  November 2009 ================================== 
//  swap PID for a different Style-Price calculation BUT DO NOT CHANGE DATA INPUT!!!!  -- 
		varNewPID=changeStyle(iProdID,i);
// ========================================================		

 			checkStyleInput(i, iProdID);
								
            var iCustomFieldCount = getLineSubCount(i, colCustomFields); 	        
			if (iCustomFieldCount > 0)  {						
	          for(var iCustomField = 0; iCustomField <iCustomFieldCount; iCustomField++)
	          {
			      var varCustomFieldValue = getLineSubItem(i, colCustomFields, iCustomField);					
			       varThree = varCustomFieldValue.substring(0,3);
				  if (varThree == "*D*" || varThree == "*F*" || varThree == "*C*") {   
// this means that  Product Range checking was done when either Delivery or Style records were processed
				       BypassCheckProductRange = true;
				  }
// hjt 11/9/22 get the last Unique bench identifyer used and set the next one
                  var varCustomFieldNameCode = getProductInfo(iProdID)[colCustomFieldKeys][iCustomField];
                  if (varCustomFieldNameCode == 364) {
				     if  (varProductCode.substring(0,3) == "BTS"  || varProductCode.substring(0,3) == "BTD"
					  || varProductCode.substring(0,3) == "BTL" || varProductCode.substring(0,3) == "BTU") {
				      X1 = ABCstring.indexOf(varCustomFieldValue);
					  varLastcode = varCustomFieldValue;
					  varNextcode = ABCstring.substring(X1 + 1,X1 + 2);				   
				  } }
//				  				  	  
			  }
			}
       if (varProductCode.substring(0,3) == "zP-") varNoPanel = true;
	   if (varProductCode.substring(0,3) == "zK-") varNoKick = true;
    }
 }

// now we collect data on actual Product items
 if (lineCount != 0)
 {	
	for(var i = 0; i <lineCount; i++)
	{
		var iProdID = parseInt(getLineItem(i, colProductID));		
		iQty = parseFloat(getLineItem(i, colQuantity));
//		varPrice = parseFloat(getProduct(varNewPID)[colProductPrice]);
		varWeight = parseFloat(getProduct(iProdID)[colProductWeight]);
			
// check that any previous Product ordered still conforms to the Style specifications
       varProdStyle = getProductStyle(iProdID,i);
//alert("line 2614 - varProdStyle= " + varProdStyle + " i= " + i);
   
	   varProductType = checkProductType(iProdID,varStatistics,i);	   
	   if (varProductType == "Deli")  
	    {	varDelivery = true;
			PanelKBQuestion = true;
		}	   
	   
//	   set Base Cabinet Height
	 			varProductCode = getProductInfo(iProdID)[colProductCode];
				if (varProductCode.substring(0,1) == "B") {
				  var iCustomFieldCnt = getLineSubCount(i, colCustomFields); 
                  if (iCustomFieldCnt > 0)  {			
	                  varPreviousBaseHeight = getLineSubItem(i, colCustomFields, 0);			   			   
			      } 				
				}

// get details on WardRobe identifications:
           var iCustomFieldCount = getLineSubCount(i, colCustomFields); 
           if (iCustomFieldCount > 0 && varProductType ==  "Ward")  {			
	          for (var iCustomField = 0; iCustomField <iCustomFieldCount; iCustomField++)
	          {
			   varCustomFieldValues = getLineSubItem(i, colCustomFields, iCustomField);
			   			   
			      if (iCustomField == 0) var varRoom = varCustomFieldValues;
				  else {
					   if (iCustomField == 1) var varWall = varCustomFieldValues;
				       else {
						    if (iCustomField == 2) {
							    var varSection = varCustomFieldValues;							
							    var varPosition = varRoom + varWall + varSection;
 								var varWRHeight = getLineSubItem(i, colCustomFields,3);
 								var varWRDepth = getLineSubItem(i, colCustomFields, 5);
								var varWRShape = getLineSubItem(i, colCustomFields, 6);								 
							    if (varWardRobe1 == "000") 	{ 
								    wardrobe[0] = varPosition;
								    varWardRobe1 = varPosition;
									varWardRobeHeight1 = varWRHeight;
									varWardRobeDepth1 = varWRDepth;
									varWardRobeShape1 = varWRShape;																		
								}							
								else if (varWardRobe2 == "000") {
								    wardrobe[1] = varPosition;
									varWardRobe2 = varPosition;
									varWardRobeHeight2 = varWRHeight;
									varWardRobeDepth2 = varWRDepth;
									varWardRobeShape2 = varWRShape;
								}
							  	else if (varWardRobe3 == "000") {
									wardrobe[2] = varPosition;
									varWardRobe3 = varPosition;
									varWardRobeHeight3 = varWRHeight;
									varWardRobeDepth3 = varWRDepth;
									varWardRobeShape3 = varWRShape;
								}
							    else if (varWardRobe4 == "000") {
									wardrobe[3] = varPosition;
									varWardRobe4 = varPosition;
									varWardRobeHeight4 = varWRHeight;
									varWardRobeDepth4 = varWRDepth;
									varWardRobeShape4 = varWRShape;
								}
							    else if (varWardRobe5 == "000") {
									wardrobe[4] = varPosition;
									varWardRobe5 = varPosition;
									varWardRobeHeight5 = varWRHeight;
									varWardRobeDepth5 = varWRDepth;
									varWardRobeShape5 = varWRShape;
								}
								else if (varWardRobe6 == "000") {
									wardrobe[5] = varPosition;
									varWardRobe6 = varPosition;
									varWardRobeHeight6 = varWRHeight;
									varWardRobeDepth6 = varWRDepth;
									varWardRobeShape6 = varWRShape;
								}
								else if (varWardRobe7 == "000") {
									wardrobe[6] = varPosition;
									varWardRobe7 = varPosition;
									varWardRobeHeight7 = varWRHeight;
									varWardRobeDepth7 = varWRDepth;
									varWardRobeShape7 = varWRShape;
								}
								else if (varWardRobe8 == "000") {
									wardrobe[7] = varPosition;
									varWardRobe8 = varPosition;
									varWardRobeHeight8 = varWRHeight;
									varWardRobeDepth8 = varWRDepth;
									varWardRobeShape8 = varWRShape;
								}
								else if (varWardRobe9 == "000") {
									wardrobe[8] = varPosition;
									varWardRobe9 = varPosition;
									varWardRobeHeight9 = varWRHeight;
									varWardRobeDepth9 = varWRDepth;
									varWardRobeShape9 = varWRShape;
								}
								else if (varWardRobe10 == "000") {
									wardrobe[9] = varPosition;
									varWardRobe10 = varPosition;
									varWardRobeHeight10 = varWRHeight;
									varWardRobeDepth10 = varWRDepth;
									varWardRobeShape10 = varWRShape;
								}
								else if (varWardRobe11 == "000") {
									wardrobe[10] = varPosition;
									varWardRobe11 = varPosition;
									varWardRobeHeight11 = varWRHeight;
									varWardRobeDepth11 = varWRDepth;
									varWardRobeShape11 = varWRShape;
								}
								else if (varWardRobe12 == "000") {
									wardrobe[11] = varPosition;
									varWardRobe12 = varPosition;
									varWardRobeHeight12 = varWRHeight;
									varWardRobeDepth12 = varWRDepth;
									varWardRobeShape12 = varWRShape;
								}
								else if (varWardRobe13 == "000") {
									wardrobe[12] = varPosition;
									varWardRobe13 = varPosition;
									varWardRobeHeight13 = varWRHeight;
									varWardRobeDepth13 = varWRDepth;
									varWardRobeShape13 = varWRShape;
								}
								else if (varWardRobe14 == "000") {
									wardrobe[13] = varPosition;
									varWardRobe14 = varPosition;
									varWardRobeHeight14 = varWRHeight;
									varWardRobeDepth14 = varWRDepth;
									varWardRobeShape14 = varWRShape;
								}
							  	else if (varWardRobe15 == "000") {
									wardrobe[14] = varPosition;
									varWardRobe15 = varPosition;
									varWardRobeHeight15 = varWRHeight;
									varWardRobeDepth15 = varWRDepth;
									varWardRobeShape15 = varWRShape;
								}
							    else if (varWardRobe16 == "000") {
									wardrobe[15] = varPosition;
									varWardRobe16 = varPosition;
									varWardRobeHeight16 = varWRHeight;
									varWardRobeDepth16 = varWRDepth;
									varWardRobeShape16 = varWRShape;
								}
							    else if (varWardRobe17 == "000") {
									wardrobe[16] = varPosition;
									varWardRobe17 = varPosition;
									varWardRobeHeight17 = varWRHeight;
									varWardRobeDepth17 = varWRDepth;
									varWardRobeShape17 = varWRShape;
								}
								else if (varWardRobe18 == "000") {
									wardrobe[17] = varPosition;
									varWardRobe18 = varPosition;
									varWardRobeHeight18 = varWRHeight;
									varWardRobeDepth18 = varWRDepth;
									varWardRobeShape18 = varWRShape;
								}
								else if (varWardRobe19 == "000") {
									wardrobe[18] = varPosition;
									varWardRobe19 = varPosition;
									varWardRobeHeight19 = varWRHeight;
									varWardRobeDepth19 = varWRDepth;
									varWardRobeShape19 = varWRShape;
								}
								else if (varWardRobe20 == "000") {
									wardrobe[19] = varPosition;
									varWardRobe20 = varPosition;
									varWardRobeHeight20 = varWRHeight;
									varWardRobeDepth20 = varWRDepth;
									varWardRobeShape20 = varWRShape;
								}
								else if (varWardRobe21 == "000") {
									wardrobe[20] = varPosition;
									varWardRobe21 = varPosition;
									varWardRobeHeight21 = varWRHeight;
									varWardRobeDepth21 = varWRDepth;
									varWardRobeShape21 = varWRShape;
								}
								else if (varWardRobe22 == "000") {
									wardrobe[21] = varPosition;
									varWardRobe22 = varPosition;
									varWardRobeHeight22 = varWRHeight;
									varWardRobeDepth22 = varWRDepth;
									varWardRobeShape22 = varWRShape;
								}
								else if (varWardRobe23 == "000") {
									wardrobe[22] = varPosition;
									varWardRobe23 = varPosition;
									varWardRobeHeight23 = varWRHeight;
									varWardRobeDepth23 = varWRDepth;
									varWardRobeShape23 = varWRShape;
								}
								else if (varWardRobe24 == "000") {
									wardrobe[23] = varPosition;
									varWardRobe24 = varPosition;
									varWardRobeHeight24 = varWRHeight;
									varWardRobeDepth24 = varWRDepth;
									varWardRobeShape24 = varWRShape;
								}	
// window.alert("Height= " + varWRHeight + " Depth= " + varWRDepth + " varWRShape=) " + varWRShape) ;																			            
							}							
					 }					 
				   }	 
					 
			    }
			  }																
								
				if ( varProductType ==  "Ward")  {
					if (iQty > 1) {
window.alert("The WARDROBE Quantity in the View-Cart Shopping List is greater than '1' -- it must Only be '1'. Our Production System can not deal with duplicate Room/Wall and Sections. Please change the Qty to '1' and then Enter another Unique Wardrobe specification if you require multiple wardrobe inserts.");
                  varErrorType = varErrorType + 1;
				  location.replace("viewcart.htm");
                    }
			}
			if (varProductType ==  "Disc") {
			varDiscountRequest = true;
			 PanelKBQuestion = true;
			 if (iQty > 1) {
window.alert("The Discount Quantity in the View-Cart Shopping List is greater than '1' -- it must Only be '1'. Only ONE Discount is allowed at the time. Please change the Qty to '1' or REMOVE the Discount entry completely and resubmit a new one." );
                  varErrorType = varErrorType + 1;
				  location.replace("viewcart.htm");
                    }
			}			  			 
			 
			if ( varProductType ==  "Styl" && varProductCode.substring(0,7) != "8 Style")  {
			  PanelKBQuestion = true;
				if (iQty > 1) {
window.alert("One of your STYLE specifications has been duplicated as it has a QUANTITY > '1' - each STYLE product must be for a UNIQUE set of components - please [CHANGE] the Quantity to '1' and make another Style specification if needed");
                  varErrorType = varErrorType + 1;
				   location.replace("viewcart.htm");
                }
			}
							 
            if (varProductType ==  "Benc")  {
			    
				if (iQty > 1) {
window.alert("Ooooppps - There is a QUANTITY greater than [1] for one of your Benchtop products in your VIEW CART - The QUANTITY can only ever be [1] here. - Click [OK] to go to the View Cart so you can correct this to [1]");
                  varErrorType = varErrorType + 1;
				   location.replace("viewcart.htm");
                }
				varProductCode = getProductInfo(iProdID)[colProductCode];
				varShortCode = varProductCode.substring(0,3);
				varLongCode = varProductCode.substring(0,4);
				if (varShortCode == "BTS" || varShortCode == "BTD" || varShortCode == "BTU") varBTNumber = varBTNumber + 1;
				if (varLongCode == "BTLA" || varLongCode == "BTLB" || varLongCode == "BTLC" || varLongCode == "BTLD") varBTNumber = varBTNumber + 1;
				if (varLongCode == "BTEL" || varLongCode == "BTER") varEndNumber = varEndNumber + 1;
				if (varLongCode == "BTLM" || varLongCode == "BTLF" || varLongCode == "BTBL" || varLongCode == "BTRM" || varLongCode == "BTRF" || varLongCode == "BTBR") {
				     varJoinTotal = varJoinTotal + 1;					 
				     varProdName = getProductInfo(iProdID)[colProductDesc];
					   if (varProdName.indexOf("Male") > 0) varMaleJoin = varMaleJoin + 1;
					   else if (varProdName.indexOf("Female") > 0) varFemaleJoin = varFemaleJoin + 1;
					   else if (varProdName.indexOf("Butt") > 0) varButtJoin = varButtJoin + 1;
					   else varEndJoin = varEndJoin + 1;
                }
								
              var iCustomFieldCount = getLineSubCount(i, colCustomFields); 			
// end of if (lineCount != 0) AND for(var i = 0; i <lineCount; i++)				  							       													
       }
	   }    
  TotalOrderCheck = false; 
  
  
// to prevent additional Carcass Selected Messages  
    if (varProductType ==  "Carc")  varCarcassProcessed = true; 
    return true;	   	       													
   }
  else {
    TotalOrderCheck = false;
    return false;
  }			    			
}

// fundtion to calculate Total Weight, Total Order Cost and checkout WardRobe details
function CalculateOrderWeight()
{
    varOrderCost = 0;
	extraShelfCost = 0;
	varWeight = 0;
	varVariableWeight = 0;
	varTotalWeight = 0;
	BenchWeightLshapeA = 0; // weight of Lshape Bench A
	BenchWeightLshapeB = 0; // weight of Lshape Bench B
	BenchWeightUshapeA = 0; // weight of U-shape Bench A
	CalculatedBenchtopCost = 0;
			
    var lineCount = getLineCount();

 if (lineCount != 0)
 { 		
	for(var i = 0; i <lineCount; i++)
	{						
			var iProdID = parseInt(getLineItem(i, colProductID));			
							
			iQty = parseFloat(getLineItem(i, colQuantity));
			varQuantity = iQty			
			varProductType = checkProductType(iProdID,varStatistics,i);
			varProductCode = getProductInfo(iProdID)[colProductCode];
			varProdName = getProductInfo(iProdID)[colProductDesc];
			varWeight = parseFloat(getProduct(iProdID)[colProductWeight]);
			if (varWeight == 0  && varProductCode.substring(0,1) != "2" && varProductCode.substring(0,1) != "3" && varProductCode.substring(0,1) != "z" && varProductCode.substring(0,4) != "BTEL" && varProductCode.substring(0,4) != "BTER" && varProductCode.substring(0,4) != "Outl" && varProductCode.substring(0,3) != "WOM")  PriceandWeightCalc(i);  // calculated weight   			
					
			varTotalWeight = Math.round(varTotalWeight + (varWeight * iQty) + (varVariableWeight * iQty));
//alert("3014 varTotalWeight= " + varTotalWeight + " varWeight= " + varWeight + " varVariableWeight= " + varVariableWeight + " varProductCode= " + varProductCode);
             varVariableWeight = 0;
//  ascertain longest size (either Height or Width) from Order details
             var iCustomFieldCount = getLineSubCount(i, colCustomFields); 
			 
             if (iCustomFieldCount > 0) {			
	          for(var iCustomField = 0; iCustomField <iCustomFieldCount; iCustomField++)
	          {
			   varCustomFieldValues = parseInt(getLineSubItem(i, colCustomFields, iCustomField));
               if (varProductType == "Kit-" || varProductType == "Door" || varProductType == "Pane" || varProductType == "Open" || varProductType == "Kick" || varProductType == "Hybr")  {
			    if (varProductCode.indexOf("Y")> 0) {
			      if (iCustomField <= 2) {				  
				     if (varCustomFieldValues > varTotalLength) varTotalLength = varCustomFieldValues;
				  }
				}
				else if (varProdName.indexOf("720") > 0 && varTotalLength < 720) varTotalLength = 720;
				else if (varProdName.indexOf("800") > 0 && varTotalLength < 800) varTotalLength = 800;
				else if (varProdName.indexOf("880") > 0 && varTotalLength < 880) varTotalLength = 880;
				else if (varProdName.indexOf("900") > 0 && varTotalLength < 900) varTotalLength = 900;
				else if (varProdName.indexOf("912") > 0 && varTotalLength < 912) varTotalLength = 912;
				else if (varProdName.indexOf("1000") > 0 && varTotalLength < 1000) varTotalLength = 1000;
				else if (varProdName.indexOf("1935") > 0 && varTotalLength < 1935) varTotalLength = 1935;
				else if (varProdName.indexOf("2127") > 0 && varTotalLength < 2127) varTotalLength = 2127;
				else if (varProdName.indexOf("2150") > 0 && varTotalLength < 2150) varTotalLength = 2150;
				else if (varProdName.indexOf("2350") > 0 && varTotalLength < 2350) varTotalLength = 2350;
				else if  (varTotalLength < 720) varTotalLength = 700;
			   }

			   	
	           if (varProductType ==  "Ward") {
					   if (iCustomField <= 5) {
					       if (varCustomFieldValues > varTotalLength) varTotalLength = varCustomFieldValues;
					   }
			   } 
			   
	           if (varProductType ==  "Benc") {					   
					   if (iCustomField == 0 && iProdID > 215 && iProdID < 224) {
					      BenchtopParameters(i, iProdID);
					      varTotalWeight = Math.round(varTotalWeight + BenchWeightUshapeA + BenchWeightLshapeA + BenchWeightLshapeB);
						  if (BenchLength > varTotalLength) varTotalLength = BenchLength;				  
                       }
					   else if (iCustomField <= 2 && (iProdID < 216 || iProdID > 223)) {
					     if (varCustomFieldValues > varTotalLength) varTotalLength = varCustomFieldValues;
					   }
			   } 			   			   			   
//
			  }
			 }
			 							       													
          }
	  return true;   			
   }
   else return false;

}

// Calculation of Long Haul Costs via TOLL with extra Discount for Queensland
//
function   CalculateLongHaul(varZone)
{

 arrayZoneCosts = getZoneCost(varZone);
 varBasicRate = arrayZoneCosts[colBasicRate];
 varVariableRate = arrayZoneCosts[colVariableRate];
 

  varLongHaulCost = Math.round(varInsurance + varAdminFee + (varVariableRate * varTotalWeight + varBasicRate) * varAddOn);
  
 if(varZone.substring(0,3) == "QLD") {
    if (varCurrentOrderPrice < 1500) varSubsidyRate = 0.05 * varCurrentOrderPrice;
	else varSubsidyRate = 0.10 * varCurrentOrderPrice; 
//window.alert("varZone= " + varZone.substring(0,3) + " varVariableRate= " + varVariableRate + 

   varLongHaulCost = Math.round(varLongHaulCost - varSubsidyRate);
  }

  
return varLongHaulCost;
}

function getZoneCost(zoneName)
{

switch(zoneName)
	{

case  "NSW Central NSW": return nD(16.34,1.01);
case  "NSW Hunter Region NSW": return nD(16.34,0.9);
case  "NSW Newcastle": return nD(16.34,0.79);
case  "NSW North Coast NSW": return nD(16.34,1.13);
case  "NSW Riverina NSW": return nD(16.34,0.52);
case  "NSW South Coast NSW": return nD(16.34,0.87);
case  "NSW Sydney": return nD(16.34,0.41);
case  "NSW Western NSW": return nD(16.34,1.22);
case  "NSW Wollongong": return nD(16.34,0.75);
case  "NSW Albury/Wodonga": return nD(16.34,0.28);
case  "NT Alice Springs": return nD(19.71,1.18);
case  "NT Darwin": return nD(19.71,1.7);
case  "NT Northern Territory": return nD(34.81,3.15);
case  "QLD Brisbane": return nD(16.34,0.90);
case  "QLD Brisbane Outside CBD": return nD(16.34,1.30);
case  "QLD Cairns": return nD(16.34,2.00);
case  "QLD Cape York": return nD(31.01,6.44);
case  "QLD Central Coast QLD": return nD(16.34,2.09);
case  "QLD Mackay": return nD(16.34,1.50);
case  "QLD Northern Coast QLD": return nD(19.71,2.24);
case  "QLD Rockhampton": return nD(16.34,1.40);
case  "QLD South East QLD": return nD(16.34,1.30);
case  "QLD South East QLD (Outer)": return nD(19.71,1.40);
case  "QLD Townsville": return nD(16.34,1.63);
case  "QLD Western QLD": return nD(31.01,2.72);
case  "SA Adelaide": return nD(16.34,0.57);
case  "SA Mt. Gambier": return nD(16.34,0.99);
case  "SA North West SA": return nD(16.34,1.57);
case  "SA South East SA": return nD(16.34,0.31);
case  "TAS Hobart": return nD(16.34,2.22);
case  "TAS Launceston": return nD(16.34,1.82);
case  "TAS Tasmania (Rest)": return nD(23.63,2.81);
case  "VIC Inner VIC Country": return nD(19.71,0.94);
case  "VIC Melbourne": return nD(16.34,0.5);
case  "VIC Outer VIC Country": return nD(16.34,0.75);
case  "WA Broome": return nD(26.87,4.02);
case  "WA Central WA": return nD(20.49,2.16);
case  "WA Northern WA": return nD(26.87,6.07);
case  "WA Perth": return nD(16.34,0.6);
case  "WA Southern WA": return nD(16.34,0.69);
}

return nD(0.0,0.00);
}


// *	Creates a new array with X elements, with the supplied argument value or default
// *
function nD()
{
	var arrayZoneCosts = new Array(0,0);
	for (var x = 0; x < arguments.length; x++) 
	{
		arrayZoneCosts[x] = arguments[x];
	}
	return arrayZoneCosts;
}

// determine the Style Name of a Product

 function getProductStyle(iProdID,i)
 {
   varProdStyle = "Lamin";   // default value
	varProductCode = getProductInfo(iProdID)[colProductCode];
	varProdName = getProductInfo(iProdID)[colProductDesc];	
	var iCustomFieldCount = getLineSubCount(i, colCustomFields); 	        
			if (iCustomFieldCount > 0)  {						
	          for (var iCustomField = 0; iCustomField <iCustomFieldCount; iCustomField++)
	          {	
			    var varCustomFieldNameCode = getProductInfo(iProdID)[colCustomFieldKeys][iCustomField];
				var varCustomFieldValue = getLineSubItem(i, colCustomFields, iCustomField);
//alert("line 3184 - varCustomFieldNameCode= " + varCustomFieldNameCode + " varCustomFieldValue= " + varCustomFieldValue);
									   
                if ((varCustomFieldNameCode > 594 && varCustomFieldNameCode < 600) || varCustomFieldNameCode == 605)
	               varProdStyle = varCustomFieldValue.substring(0,5);
	            var varStyle = varProdName.indexOf("HMR W");
			    if (varStyle > 0) varProdStyle = "Carca";
				if (varProductCode.substring(0,2) == "WR") varProdStyle = "Carca";
				if (varProductCode.substring(0,9) == "Panel-HMR") varProdStyle = "Carca";				
			  }
			}
			if (varDataInputMode == false) {
			  if (varSuffix == "a") varProdStyle = "Belmo";
			  
			  else if (varSuffix == "e") varProdStyle = "Unfin";
			  else if (varSuffix == "z")  varProdStyle = "Lamin";
			  else if (varProductCode.substring(0,9) == "Panel-HMR") varProdStyle = "Carca";
			  else varProdStyle = "Lamin";			  
			}
//alert("line 3206 -varProdStyle= " + varProdStyle + " i= " + i + " varSuffix= " + varSuffix);						  						  					                			
	return varProdStyle;
}

//  Here we accumulate the various STYLE inputs when ever they have been made. ????

function checkStyleInput(i,iProdID)
{
     var varProdCode  = "Nil";		
	varProductCode = getProductInfo(iProdID)[colProductCode];
	varProdCode = varProductCode.substring(8,13);
	var iCustomFieldCount = getLineSubCount(i, colCustomFields);
	        
	  if (iCustomFieldCount > 0)  {		
        if (varProductCode.substring(0,1) == "2" || varProductCode.substring(0,1) == "1") {			
 	          for(var iCustomField = 0; iCustomField <iCustomFieldCount; iCustomField++)
 	          {
 			   varCustomFieldValues = getLineSubItem(i, colCustomFields, iCustomField);
 			   if (varCustomFieldValues.substring(0,12) == "All Cabinets") {
    		     if (varDoorStyle1 == "Nil") varDoorStyle1 = varProdCode; 
			     else if (varDoorStyle2 == "Nil" && varProdCode != varDoorStyle1) varDoorStyle2 = varProdCode;
			     else if (varDoorStyle3 == "Nil" && varProdCode != varDoorStyle1 && varProdCode != varDoorStyle2) varDoorStyle3 = varProdCode;
				 				 				
				 if (varPanelStyle1 == "Nil") varPanelStyle1 = varProdCode;
    		     else if (varPanelStyle2 == "Nil" && varProdCode != varPanelStyle1) varPanelStyle2 = varProdCode;
				 else if (varPanelStyle3 == "Nil" && varProdCode != varPanelStyle1 && varProdCode!= varPanelStyle2) varPanelStyle3 = varProdCode;
				 				  
				 if (varOpenStyle1 == "Nil") varOpenStyle1 = varProdCode;
				 else if (varOpenStyle2 == "Nil" && varProdCode != varOpenStyle1) varOpenStyle2 = varProdCode;
				 else if (varOpenStyle3 == "Nil" && varProdCode != varOpenStyle1 && varProdCode != varOpenStyle2) varOpenStyle3 = varProdCode;
						 
				 if (varKickStyle1 == "Nil") varKickStyle1 = varProdCode;
				 else if (varKickStyle2 == "Nil" && varProdCode != varKickStyle1) varKickStyle2 = varProdCode;
				 else if (varKickStyle3 == "Nil" && varProdCode != varKickStyle1 && varProdCode != varKickStyle2) varKickStyle3 = varProdCode;				 				 						
               }
			 
 			   if (varCustomFieldValues.substring(0,5) == "Doors") {
    		     if (varDoorStyle1 == "Nil") varDoorStyle1 = varProdCode; 
			     else if (varDoorStyle2 == "Nil" && varProdCode != varDoorStyle1) varDoorStyle2 = varProdCode;
			     else if (varDoorStyle3 == "Nil" && varProdCode != varDoorStyle1 && varProdCode != varDoorStyle2) varDoorStyle3 = varProdCode;
				 				 				 								
               }			 

			  if (varCustomFieldValues.substring(0,11) == "Panels only") {
    		     if (varPanelStyle1 == "Nil") varPanelStyle1 = varProdCode;
    		     else if (varPanelStyle2 == "Nil" && varProdCode != varPanelStyle1) varPanelStyle2 = varProdCode;
				 else if (varPanelStyle3 == "Nil" && varProdCode != varPanelStyle1 && varProdCode != varPanelStyle2) varPanelStyle3 = varProdCode;				 								
              }			 			 
			 
			  if (varCustomFieldValues.substring(0,15) == "Kickboards only") {			 
				 if (varKickStyle1 == "Nil") varKickStyle1 = varProdCode;
				 else if (varKickStyle2 == "Nil" && varProdCode != varKickStyle1) varKickStyle2 = varProdCode;
				 else if (varKickStyle3 == "Nil" && varProdCode != varKickStyle1 && varProdCode != varKickStyle2) varKickStyle3 = varProdCode;				 						
              }
			  
			  if (varCustomFieldValues.substring(0,4) == "Open") {
				 if (varOpenStyle1 == "Nil") varOpenStyle1 = varProdCode;
				 else if (varOpenStyle2 == "Nil" && varProdCode != varOpenStyle1) varOpenStyle2 = varProdCode;
				 else if (varOpenStyle3 == "Nil" && varProdCode != varOpenStyle1 && varProdCode != varOpenStyle2) varOpenStyle3 = varProdCode;			  }			  			 
 		} 
	   }   
	 } 		 			   						   			   								  					
}


//  this function determines Product Type (Cabinet, Doors, Panels, Wardrobe insert, Benchtop etc.)
// also it (again) determines Product Style and creates a Product Style matrix
//   and also accumulates Product-type totals for display in the DELIVERY product

function checkProductType(iProdID,varStatistics,i)
{
var varHeight = 750;  //default values
var varWidth = 600;
var varRange = "base";
// window.alert("iProdIDLast= " + iProdIDLast + " " + iProdID);
if (iProdID != iProdIDLast || varStatistics == true) {
  varProductCode = getProductInfo(iProdID)[colProductCode];
  varProductDesc = getProductInfo(iProdID)[colProductDesc];
     
  if (varProductCode.substring(0,1) == "c"){
      varProductType = "Carc";
      varCarcass = true;
	  if(varStatistics == true) CarcassUnits = CarcassUnits + varQuantity;
   }
  else {
     if (varProductCode.substring(0,2) == "BT") {
	   varProductType = "Benc";
	   varBenchtop = true;
	   if(varStatistics == true && (varProductCode.substring(0,3) == "BTS" || varProductCode.substring(0,3) == "BTD" || varProductCode.substring(0,3) == "BTU" || varProductCode.substring(0,4) == "BTLA" || varProductCode.substring(0,4) == "BTLB" || varProductCode.substring(0,4) == "BTLC" || varProductCode.substring(0,4) == "BTLD")) Benchtops = Benchtops + varQuantity;
	 }  
	else {
	  if (varProductCode.substring(0,2) == "WR" || varProductCode.substring(0,2) == "RV" ) {
	     varProductType = "Ward";
	     varWardrobe = true;
		 if(varStatistics == true) Wardrobes = Wardrobes + varQuantity;
		 if (varProductCode.substring(0,4) == "WRCS" || varProductCode.substring(0,2) == "RV") varProductType = "Hybr";
		 if (varProductCode.substring(0,4) != "WRCS") {
		 	varHeight = parseInt(getLineSubItem(i, colCustomFields, 3));
			varWidth = parseInt(getLineSubItem(i, colCustomFields, 4));
			varDimension1 = 2000;
		    if (varWidth < 301) varDimension2 = 300;
			else if (varWidth < 601) varDimension2 = 600;
			else varDimension2 = 1000;
			
			if (varProductCode.substring(0,4) == "WRD2" || varProductCode.substring(0,4) == "WRD3" || varProductCode.substring(0,4) == "WRD4" || varProductCode.substring(0,4) == "WRD5") {
				if (varWidth < 401) varDimension2 = 400;
				else if (varWidth < 601) varDimension2 = 600;
				else varDimension2 = 900;
		    }
         }
		 if (varProductCode.substring(0,4) == "WRCS") {
		   	varHeight = parseInt(getLineSubItem(i, colCustomFields, 0));
			varWidth  = parseInt(getLineSubItem(i, colCustomFields, 1));
				if (varHeight < 2000) varDimension1 = 2000;
				else  varDimension1 = 2350;
           if (varWidth < 901) varDimension2 = 900;
		   else varDimension2 = 1000;
		 }
	  }
	  else {
	     if (varProductCode.substring(0,4) == "Kick") {
		    varProductType = "Kick";
		    varKickboard = true;
			if(varStatistics == true) Kickboards = Kickboards + varQuantity;
			varHeight = parseInt(getLineSubItem(i, colCustomFields, 0));
			varWidth = parseInt(getLineSubItem(i, colCustomFields, 1));
	
		    varDimension1 = 200;	
			if (varWidth < 751) varDimension2 = 750;
			else if (varWidth < 901) varDimension2 = 900;
			else if (varWidth < 1051) varDimension2 = 1050;
			else if (varWidth < 1201) varDimension2 = 1200;
			else if (varWidth < 1501) varDimension2 = 1500;
			else if (varWidth < 1801) varDimension2 = 1800;
			else if (varWidth < 2101) varDimension2 = 2100;
			else  varDimension2 = 2350;
			
			getProductStyle(iProdID,i);
			if (varProdStyle != "Nil") {
			   if (ProductKickStyle1 == "Nil") ProductKickStyle1 = varProdStyle;
			   else if(ProductKickStyle2 == "Nil" && varProdStyle != ProductKickStyle1) ProductKickStyle2 = varProdStyle;
			   else if(ProductKickStyle3 == "Nil" && varProdStyle != ProductKickStyle1 && varProdStyle != ProductKickStyle2) ProductKickStyle3 = varProdStyle;
			} 
		  }
		 else { 
		   if (varProductCode.substring(0,4) == "Door") {
		       varProductType = "Door";
		       varDoor = true;
			   if(varStatistics == true) ExtraDoors = ExtraDoors + varQuantity;
			   varHeight = parseInt(getLineSubItem(i, colCustomFields, 0));
			   varWidth = parseInt(getLineSubItem(i, colCustomFields, 1)); 
	
			   if (varHeight < 401) varDimension1 = 400;
			   else if (varHeight < 601)  varDimension1 = 600;
			   else if (varHeight < 751)  varDimension1 = 750;
			   else if (varHeight < 901)  varDimension1 = 900;
			   else if (varHeight < 1201) varDimension1 = 1200;
			   else if (varHeight < 1451) varDimension1 = 1450;
			   else if (varHeight < 1801) varDimension1 = 1800;
	           else if (varHeight < 2101) varDimension1 = 2100;
			   else  varDimension1 = 2350;
	
			   if (varWidth < 301) varDimension2 = 300;
	           else if (varWidth < 401) varDimension2 = 400;
	           else if (varWidth < 501) varDimension2 = 500;
	           else  varDimension2 = 600;
			   
			   getProductStyle(iProdID,i);
			   if (varProdStyle != "Nil") {
				 if (ProductDoorStyle1 == "Nil") ProductDoorStyle1 = varProdStyle;
				 else if(ProductDoorStyle2 == "Nil" && varProdStyle != ProductDoorStyle1) ProductDoorStyle2 = varProdStyle;
				 else if(ProductDoorStyle3 == "Nil" && varProdStyle != ProductDoorStyle1 && varProdStyle != ProductDoorStyle2) ProductDoorStyle3 = varProdStyle;
				} 
		   }
		   else {
		     if (varProductCode.substring(0,4) == "Pane") {
			    varProductType = "Pane";
			    varPanel = true;
				getProductStyle(iProdID,i);
				varHeight = parseInt(getLineSubItem(i, colCustomFields, 0));
				varWidth = parseInt(getLineSubItem(i, colCustomFields, 1));

				if (varHeight < 201) varDimension1 = 200;
				else if (varHeight < 401)  varDimension1 = 400;
				else if (varHeight < 601)  varDimension1 = 600;
				else if (varHeight < 751)  varDimension1 = 750;
				else if (varHeight < 901) varDimension1 = 900;
				else if (varHeight < 1201) varDimension1 = 1200;
				else if (varHeight < 1451) varDimension1 = 1500;
				else if (varHeight < 1801) varDimension1 = 1850;
				else if (varHeight < 2101) varDimension1 = 2100;
				else if (varHeight < 2251) varDimension1 = 2250;
				else  varDimension1 = 2350;
	
				if (varWidth < 301) varDimension2 = 300;
				else if (varWidth < 401) varDimension2 = 400;
				else if (varWidth < 501) varDimension2 = 500;
				else if (varWidth < 601) varDimension2 = 600;
				else if (varWidth < 751) varDimension2 = 750;
				else if (varWidth < 901) varDimension2 = 900;
				else if (varWidth < 1051) varDimension2 = 1050;
				else  varDimension2 = 1200;
				if (varProdStyle != "Nil") {
					if (ProductPanelStyle1 == "Nil") ProductPanelStyle1 = varProdStyle;
				    else if(ProductPanelStyle2 == "Nil" && varProdStyle != ProductPanelStyle1) ProductPanelStyle2 = varProdStyle;
				  	else if(ProductPanelStyle3 == "Nil" && varProdStyle != ProductPanelStyle1 && varProdStyle != ProductPanelStyle2) ProductPanelStyle3 = varProdStyle;
				}
				if(varStatistics == true) Panels = Panels + varQuantity;
			  }
			 else {
			   if (varProductCode.substring(0,4) == "Hand") {
			       varProductType = "Hand";
			       varHandles = true;
				   if(varStatistics == true) Handles = Handles + varQuantity;
			    }
				
				else {
			       if (varProductCode.substring(0,4) == "Hard") {
			          varProductType = "Hard";
			          varHardware = true;
				      if(varStatistics == true) Hardware = Hardware + varQuantity;
			       }
				
			      else  {
			        if (varProductDesc.indexOf("Open") > 0) {
					    varProductType = "Open";
					    varOpenUnit = true;
						getProductStyle(iProdID,i);
									 varHeight = parseInt(getLineSubItem(i, colCustomFields, 0));
									 varWidth = parseInt(getLineSubItem(i, colCustomFields, 1)); 
	
								    if (varProductCode.substring(0,3) == "MW/" )  varDimension1 = 500;
									else if (varProductCode.substring(0,3) == "BO-" && varHeight < 751) varDimension1 = 750;
									else if (varProductCode.substring(0,3) == "BO-" && varHeight < 1001) varDimension1 = 900;
									else if ((varProductCode.substring(0,3) == "BOA" || varProductCode.substring(0,3) == "WO-" 
									|| varProductCode.substring(0,3) == "WDO") && varHeight < 751) varDimension1 = 750;
									else if ((varProductCode.substring(0,3) == "BOA" || varProductCode.substring(0,3) == "WO-" 
									|| varProductCode.substring(0,3) == "WDO") && varHeight < 901) varDimension1 = 900;										 
									else if ((varProductCode.substring(0,3) == "BOA" || varProductCode.substring(0,3) == "WO-" 
									|| varProductCode.substring(0,3) == "WDO") && varHeight < 1201) varDimension1 = 1200;
									else if (varHeight < 751)  varDimension1 = 500;													 
									else  varDimension1 = 900;
	
									if (varWidth < 401) varDimension2 = 400;
									else if (varWidth < 501) varDimension2 = 500;
									else if (varWidth < 601) varDimension2 = 600;
									else if (varWidth < 701) varDimension2 = 700;
									else if (varWidth < 801) varDimension2 = 800;
									else if (varWidth < 901) varDimension2 = 900;
									else if (varWidth < 1001) varDimension2 = 1000;
									else if (varWidth < 1101) varDimension2 = 1100;
									else  varDimension2 = 1200;
									 if (varProdStyle != "Nil") {
				   						if (ProductOpenStyle1 == "Nil") ProductOpenStyle1 = varProdStyle;
				  					    else if(ProductOpenStyle2 == "Nil" && varProdStyle != ProductOpenStyle1) ProductOpenStyle2 = varProdStyle;
				  						else if(ProductOpenStyle3 == "Nil" && varProdStyle != ProductOpenStyle1 && varProdStyle != ProductOpenStyle2) ProductOpenStyle3 = varProdStyle;
									 }						
						if(varStatistics == true) OpenUnits = OpenUnits + varQuantity;
					}
					else {
					   if (varProductCode.substring(0,1) == "1" || varProductCode.substring(0,1) == "2" 
					   || varProductCode.substring(0,1) == "3"  || varProductCode.substring(0,1) == "8" || varProductCode.substring(0,1) == "0")
					   {
					       varProductType = "Styl";
                           varStyle = true;
						   if (varProductCode.substring(0,1) == "3") varBenchtopStyle = true;
					   }
					   else {
					    if (varProductCode.substring(0,2) == "zz") {
						    varProductType = "Disc";
						}
						else {
						  if (varProductCode.substring(0,2) == "zP" || varProductCode.substring(0,2) == "zD" || varProductCode.substring(0,2) == "zK" 
						   || varProductCode.substring(0,6) == "Outlet") {
						      varProductType = "Deli";
							  if (varProductCode.substring(0,6) == "Outlet") varProductType = "Outl";
							  if (varProductCode.substring(0,3) == "zP-") varProductType = "Outl";
							  if (varProductCode.substring(0,3) == "zK-") varProductType = "Outl";
						  }
						  
						  else {
	     						if (varProductCode.substring(0,4) == "Fill") {
		                          varProductType = "Door";
		                          varFiller = true;
								  varHeight = parseInt(getLineSubItem(i, colCustomFields, 0));
								  varWidth = parseInt(getLineSubItem(i, colCustomFields, 1)); 
	
								if (varHeight < 751) varDimension1 = 750;
								else if (varHeight < 1201) varDimension1 = 1200;
								else if (varHeight < 1801) varDimension1 = 1800;
								else  varDimension1 = 2350;
	
 								varDimension2 = 100;
								 getProductStyle(iProdID,i);
									 if (varProdStyle != "Nil") {
				   						if (ProductDoorStyle1 == "Nil") ProductDoorStyle1 = varProdStyle;
				  					    else if(ProductDoorStyle2 == "Nil" && varProdStyle != ProductDoorStyle1) ProductDoorStyle2 = varProdStyle;
				  						else if(ProductDoorStyle3 == "Nil" && varProdStyle != ProductDoorStyle1 && varProdStyle != ProductDoorStyle2) ProductDoorStyle3 = varProdStyle;
									 }
			                      if(varStatistics == true) Fillers = Fillers + varQuantity;
		                        }
						  
				                else {
						             varProductType = "Kit-";
//alert("line 3322 - varProdStyle= " + varProdStyle);									 
								     varCabinet = true;        // check for WallUnits  now but excluding OpenUnits
									 getProductStyle(iProdID,i);
									 varHeight = parseInt(getLineSubItem(i, colCustomFields, 0));
									 varWidth = parseInt(getLineSubItem(i, colCustomFields, 1));
									 var varWidthRH = varWidth;
									 if (varProductCode.substring(0,3) == "BC-" || varProductCode.substring(0,3) == "WC-"|| varProductCode.substring(0,3) == "BB4" || varProductCode.substring(0,3) == "WB4") 
										varWidthRH = parseInt(getLineSubItem(i, colCustomFields, 2));
	            					 if (varWidthRH > varWidth) varWidth = varWidthRH;
													 								 
	                                 if (varProductCode.substring(0,3) == "B-D" || varProductCode.substring(0,3) == "BDr" || varProductCode.substring(0,3) == "BD-" || 
									  varProductCode.substring(0,3) == "BC-" || varProductCode.substring(0,3) == "BCA" || varProductCode.substring(0,3) == "BB4" || varProductCode.substring(0,3) == "BCD" 
									  || varProductCode.substring(0,3) == "UBO" || varProductCode.substring(0,3) == "BO-" || varProductCode.substring(0,3) == "BOA"
									  || varProductCode.substring(0,3) == "BDr") varRange = "base";
									 else if (varProductCode.substring(0,3) == "W-D" || varProductCode.substring(0,3) == "WC-" ||  
									   varProductCode.substring(0,3) == "WO-" || varProductCode.substring(0,3) == "WD-" || varProductCode.substring(0,3) == "WDO" 
									   || varProductCode.substring(0,3) == "WB4" || varProductCode.substring(0,3) == "BDr" || varProductCode.substring(0,3) == "cWC" 
									   || varProductCode.substring(0,3) == "RH-")    varRange = "wall";
									 
									 else if (varProductCode.substring(0,3) == "WOM" || varProductCode.substring(0,3) == "WOD") 
									 		varRange = "oven";
									 else if (varProductCode.substring(0,3) == "P-D" || varProductCode.substring(0,3) == "PC-" || 
									   varProductCode.substring(0,3) == "PD-" || varProductCode.substring(0,1) == "L") varRange = "pant";
									 else varRange = "unkn";
									 
									 if (varProductCode.substring(0,3) == "UBO") varDimension1 = 800;
									 else if ((varRange == "base" || varRange == "wall") && varHeight < 751) varDimension1 = 750;
									 else if(varRange == "base" && varHeight > 750) varDimension1 = 900;
									 else if(varRange == "wall" && varHeight < 751) varDimension1 = 750;
									 else if(varRange == "wall" && varHeight < 901 && varProductCode.substring(0,3) != "WD-") 
									      varDimension1 = 900;												 
									 else if(varRange == "wall" && varHeight > 900 && varProductCode.substring(0,3) != "RH-") 
									      varDimension1 = 1200;
									 else if((varRange == "pant" || varRange == "oven") && varHeight < 2151) varDimension1 = 2150;
									 else if((varRange == "pant" || varRange == "oven") && varHeight > 2150) varDimension1 = 2350;
									 else varDimension1 = 750;
	
									 if ((varProductCode.substring(0,3) == "BC-" || varProductCode.substring(0,3) == "BCA" 
									      || varProductCode.substring(0,3) == "WC-" || varProductCode.substring(0,3) == "WD-" 
										  || varProductCode.substring(0,3) == "BB4" || varProductCode.substring(0,3) == "WB4" 
										  || varProductCode.substring(0,3) == "RH-" || varRange == "oven") && varWidth < 601) 
										           varDimension2 = 600;					 						 
 									 else if ((varProductCode.substring(0,3) == "BC-" || varProductCode.substring(0,3) == "BCA" 
									 	|| varProductCode.substring(0,3) == "WC-" || varProductCode.substring(0,3) == "RH-")
										 && varWidth < 701)  varDimension2 = 700;
									 else if (varRange == "oven" && varWidth > 700) varDimension2 = 700;	 									 						 
 									 else if ((varProductCode.substring(0,3) == "BC-" || varProductCode.substring(0,3) == "WCA" 
									 || varProductCode.substring(0,3) == "WC-" || varProductCode.substring(0,3) == "RH-" 
									 || varProductCode.substring(0,1) == "L")  && varWidth > 700)              varDimension2 = 900;
									 else if (varProductCode.substring(0,4) == "BCD1"  && varWidth < 401)       varDimension2 = 400;
									 else if (varProductCode.substring(0,4) == "BCD1"  && varWidth > 500)       varDimension2 = 500;
									 else if (varProductCode.substring(0,8) == "BCD2Drw1" && varWidth > 801) varDimension2 = 900;									 						 
									 else if (varProductCode.substring(0,3) == "WD-") varDimension2 = 600;
									 else if (varProductCode.substring(0,3) == "PD-") varDimension2 = 1000;
									 else if (varProductCode.substring(0,3) == "UBO" && varWidth > 801) varDimension2 = 900;
									 else if (varWidth > 600 && varRange == "oven") varDimension2 = 700;						 															 
															 															 
									 else if (varWidth < 301 && varRange != "pant" && varRange != "micr") varDimension2 = 300;
									 else if (varWidth < 401 && varRange != "pant" && varRange != "micr") varDimension2 = 400;
									 else if (varWidth < 501 && varRange != "micr") varDimension2 = 500;
									 else if (varWidth < 601) varDimension2 = 600;
									 else if (varWidth < 701) varDimension2 = 700;
									 else if (varWidth < 801) varDimension2 = 800;
									 else if (varWidth < 901) varDimension2 = 900;
									 else if (varWidth > 900 && varRange == "pant") varDimension2 = 900;
									 else if (varWidth < 1001) varDimension2 = 1000;
									 else if (varWidth < 1101) varDimension2 = 1100;									 	 								 
									 else if (varWidth < 1201) varDimension2 = 1200;
									 else  varDimension2 = 900;
									 
//alert("line 3526 varDimension2= " + varDimension2 + " varDimension1= " + varDimension1);									 
									 
									 									 									 
									 if (varProdStyle != "Nil") {
				   						if (ProductDoorStyle1 == "Nil") ProductDoorStyle1 = varProdStyle;
				  					    else if(ProductDoorStyle2 == "Nil" && varProdStyle != ProductDoorStyle1) ProductDoorStyle2 = varProdStyle;
				  						else if(ProductDoorStyle3 == "Nil" && varProdStyle != ProductDoorStyle1 && varProdStyle != ProductDoorStyle2)
										                    ProductDoorStyle3 = varProdStyle;																				
									 }
						             if(varProductCode.substring(0,1) == "W" || varProductCode.substring(0,1) == "R" || varProductCode.substring(0,1) == "M") {
									     if(varStatistics == true) WallUnits = WallUnits + varQuantity;
									 } 
									   else  if(varStatistics == true) FloorUnits = FloorUnits + varQuantity;					
						     	}	
						      }
                           }						 
					    }
					  }
			        }    
				 }				 			   
			   }
		   }
		 }
	  }
	}
  } 
 }
					 
 iProdIDLast =iProdID
//alert("line 3596 varDimension1 = " + varDimension1 + " varDimension2 = " + varDimension2 + " varHeight= " + varHeight + " varWidth= " + varWidth + "varProductCode= " + varProductCode + " varRange=  " + varRange);
  return varProductType;
}



// Checking of Total Order after pressing "t" button in "ViewCart"
function CheckShoppingList()
{ 
  varCheckShoppingList = 1;
  CalculateOrderTotals()  
  CalculateOrderWeight()
  
  if(varInvalidProduct == true || varErrorType > 0) {
     window.alert(" You still have an invalid Product specification in your Shopping Cart and you CAN NOT proceed past [Checkout] to SUBMIT this Order. Please [REMOVE] it and then RE-ENTER its details");
	 return;
  }
//Check WardRobes that each unique ROOM/WALL  has one Section [A] and [A] is followed by [B], [C] etc
  sortedwardrobe = wardrobe.sort();
  
//  alert("line 3615 sorted wardrobe data= " + sortedwardrobe[0] + "," + sortedwardrobe[1] + "," + sortedwardrobe[2] + "," + sortedwardrobe[3] + "," + sortedwardrobe[4] + "," + sortedwardrobe[5] + "," + sortedwardrobe[6] + "," + sortedwardrobe[7] + "," + sortedwardrobe[8] + sortedwardrobe[9] + sortedwardrobe[10]  + sortedwardrobe[11]  + sortedwardrobe[12]  + sortedwardrobe[13] + sortedwardrobe[14]);
 if (sortedwardrobe[0].substring(0,3) != "ZZZ" ) {
  X = 0;
  Y = 0;
// check that the first Sorted Wardrobe entry has a Section = "A"
 if (sortedwardrobe[0].substring(12,13) != sections[0]) {
    wardrobeError(sortedwardrobe[X].substring(12,13),sections[Y]);
		location.replace("viewcart.htm");
		             return;
 }  

  for ( X = 1; X< 24; X++) {
	if (sortedwardrobe[X].substring(0,3) == "ZZZ") break; 
      if (sortedwardrobe[X].substring(0,12) == sortedwardrobe[X-1].substring(0,12)) {
          if (Y != "H") Y = Y + 1;
          if (sortedwardrobe[X].substring(12,13) != sections[Y]) {
			wardrobeError(sortedwardrobe[X].substring(0,12),sections[Y]);
				location.replace("viewcart.htm");
		             return;
          } 
      }
      else {
          Y = 0;
	      if (sortedwardrobe[X].substring(12,13) != sections[Y]) {
			wardrobeError(sortedwardrobe[X].substring(0,12),sections[Y]);
				location.replace("viewcart.htm");
		             return;
	      } 
    }
   
    }
 }
        if (varButtJoin != 0 && varButtJoin != 2 && varButtJoin != 4) {
window.alert(" There are normally two sides to a BUTT join but you specified only an uneven number, Each actual Benchtop MUST have BOTH of these products with the SAME [Unique Bench Identifyer] - i.e [A] or [B] etc. as that Benchtop. Click [OK] to go back to the View Cart to find which Benchtop is missing one or both of the END Finish products and then ADD in the correct END Finish from the Benchtop section")
				     varFieldCheck = 1;
	                 location.replace("viewcart.htm");
		             return;	
             } 
	 	 	 
	          if (varMaleJoin != varFemaleJoin) {
window.alert(" You specified " + varMaleJoin + " MALE joins and " + varFemaleJoin + " FEMALE joins - we need one of each for a proper join - Each actual Benchtop MUST have BOTH of these products with the SAME [Unique Bench Identifyer] - i.e [A] or [B] etc. as that Benchtop. Click [OK] to go back to the View Cart to find which Benchtop is missing one of the END Finish products and then ADD in the correct END Finish from the Benchtop section");	 
	                 location.replace("viewcart.htm");
		             return;	
	          }
			  
			  if (varBTNumber > 0) {
			   varEndFinishNumber = varBTNumber * 2 - varMaleJoin - varFemaleJoin - varButtJoin - varEndNumber;
//window.alert("varBTNumber= " + varBTNumber + " varMaleJoin= " + varMaleJoin + " varFemaleJoin= " + varFemaleJoin + " varButtJoin= " + varButtJoin + " varEndNumber= " + varEndNumber);	
			   if (varEndFinishNumber > 0) {
	window.alert(" You missed specifying the finishing for " + varEndFinishNumber + " of the short END side(s)for the Bench Top(s) shown on the Shopping List (see Viewcart) - Each actual Benchtop MUST have BOTH of these products with the SAME [Unique Bench Identifyer] - i.e [A] or [B] etc. as that Benchtop. Click [OK] to go back to the View Cart to find which Benchtop is missing one of the END Finish products and then ADD in the correct END Finish from the Benchtop section");
	                 location.replace("viewcart.htm");
					varFieldCheck = 1;
		             return;
			   }	
              }
			  
              if (varBTNumber > 0 && varEndFinishNumber < 0) {
 window.alert(" Somehow you specified " + varEndFinishNumber * -1 + " too many End Machining operations ---- Please review your Shopping List (in Viewcart) and remove the duplicates"); 
 					varFieldCheck = 1;
		             return;               	
              }			  			  			  			  			  	
  			  

     if (varBenchtop == true && varBenchtopStyle == false ) {
      varConfirm=window.confirm(" You now need to add a Colour for your Bench top Laminate - If you don't know as yet then just select 'TBA' when in the selection area.---Click [OK] to now go to the 'Benchtop LAMINATE' page to do this or [CANCEL] to add more products first");
	    if (varConfirm == true) {
	      varFieldCheck = 1;
         location.replace("category32_1.htm");
		  return;
	    }
		varFatalError = true;
	}	
 
     if (varNoPanel == false && varCabinet == true ) {
	    if (varPanel == false) {
window.alert("You did not specify any Coloured 'seen' End or SIDE PANELS  - this may be an oversight or intentional. At this stage of processing we like to be certain so you will be transferred to the Panels page to add Specifications or [No Panel Requird]");
	      varFieldCheck = 1;
	     location.replace("category1000011_1.htm");
		 return;
	    }	
	}
	  
    if (varNoKick == false && varCabinet == true ) {
		  if (varKickboard == false) {
window.alert("You did not specify any Kickboards - this may be an oversight or intentional. At this stage of processing we like to be certain so you will be transferred to the Kickboards page to add Specifications or [No Kickboard Required]");
	      varFieldCheck = 1;
	     location.replace("category1002111_1.htm");
		 return;
	    }	
	}

			if (varDoorStyle1 == "Nil" && varPanelStyle1 == "Nil" && varOpenStyle1 == "Nil" && varKickStyle1 == "Nil" && (varCabinet == true || varPanel == true)) {
varConfirm=window.confirm("A COLOUR/PROFILE scheme MUST be supplied to cover your Cabinets and Panels --- Click [OK] to go to COLOUR & Profiles ----- otherwise Click [CANCEL] to add additional products");

                 if (varConfirm == true) { 
	                 varFieldCheck = 1;
	                 location.replace("category259_1.htm");
		             return;
	             }
				 varFatalError = true;
           }
  		   
		   			
//window.alert("3819 Check on Product Styles - ProductDoorStyle1= " + ProductDoorStyle1  + " ProductKickStyle1= " + ProductKickStyle1 + " varDoorStyles= " + varDoorStyle1 + " " + " varKickStyle1= " + varKickStyle1 + " varOpenStyle1= " + varOpenStyle1);

// Check on Match of ProductStyles to Style Records

      if (ProductDoorStyle1 != "Nil" && varDoorStyle1 == "Nil") {  
varConfirm=window.confirm("You have listed one or more products with DOORS or DRAWER FRONTS  " + varDescription1);
				 if (varConfirm == true) { 
	                 varFieldCheck = 1;
	                 location.replace("category259_1.htm");
		             return;
	             }
				 varFatalError = true;
     }
	
      if (ProductPanelStyle1 != "Nil" && ProductPanelStyle1 != "Carca" && varPanelStyle1 == "Nil") {
//	 varFullProductStyle = transformProductStyle(ProductPanelStyle1);
varConfirm=window.confirm("You have listed one or more PANEL products " + varDescription1);
				 if (varConfirm == true) { 
	                 varFieldCheck = 1;
	                 location.replace("category259_1.htm");
		             return;
	             }
				 varFatalError = true;
     }
	

     if (ProductKickStyle1 != "Nil" && varKickStyle1 == "Nil") {

varConfirm=window.confirm("You have listed one or more KICKBOARDS " + varDescription1);
				 if (varConfirm == true) { 
	                 varFieldCheck = 1;
	                 location.replace("category259_1.htm");
		             return;
	             }
				 varFatalError = true;
     }
		
     if (ProductOpenStyle1 != "Nil" && varOpenStyle1 == "Nil") {
varConfirm=window.confirm("You have listed one or more OPEN UNITS  " + varDescription1);
				 if (varConfirm == true) { 
	                 varFieldCheck = 1;
	                 location.replace("category259_1.htm");
		             return;
	             }
				 varFatalError = true;
     }

 if (varDelivery == false) {
 varConfirm=window.confirm("You have not yet entered a Delivery Option, this MUST be supplied - as the last Order Line. --- Click [O.K] to go to 'DELIVERY' ---Click [CANCEL] to add additional products first.");
   if (varConfirm ==true) {
      FinalCheck = true;
	   varFieldCheck = 1;
     location.replace("category9001_1.htm");
	 return;
   }
 }
 
 if (varDelivery == true && varFatalError == false) varOrderStatus = true;
 else varOrderStatus == false;
 
 if (varOrderStatus == true) {
  window.alert("Your Request for final Quotation has been validated and you can now proceed to the CHECKOUT ");
         location.replace("viewcart-2.htm"); 
 }
 else {
 window.alert("Your Request for Quotation (or Shopping List) IS NOT COMPLETE YET - Please Validate once more and follow the suggestions to add additional specifications"); 
	            return;
 }
}


function CheckoutMessage()
{
window.alert("Proceeding to Checkout can only be done after [Check Shopping List] has advised that you can proceed ---- Please click on 'Check Shopping List] now");
}

function checkProductRange()
{

  if(varInvalidProduct == true || varErrorType > 0) {
     window.alert(" You still have an invalid Product specification in your Shopping Cart and you CAN NOT proceed past [Checkout] to SUBMIT this Order. Please [REMOVE] it and then RE-ENTER its details");
	 return;
  }

 if (BypassCheckProductRange == false) {
  
  if (varBTNumber > 1 & varJoinTotal == 0) {
varConfirm=window.confirm("You have ordered " + varBTNumber + " benchtops but you did not specify any MACHINING for possible JOINs - if this is an oversight then Click [OK} to add the required Machining details as well for that Benchtop Unique Identifier Code - [A], [B] etc.; ---Click [CANCEL] if there is no requirement for to JOIN any of the Benchtops - or if you want to Review your Viewcart entries first");
          if (varConfirm == true) {
	         location.replace("category1002104_1.htm");
			 varFieldCheck = 1;
        	             return;
	      }	
   }
	 	 	 
	          if (varButtJoin != 0 && varButtJoin != 2 && varButtJoin != 4) {
varConfirm=window.confirm(" There are normally two sides to a BUTT join but you specified only an uneven number - please review your specification and Click [OK} to ADD new Order lines if required; otherwise Click [Cancel].")
                  if (varConfirm == true) {
	                 location.replace("category1002104_1.htm");
					 varFieldCheck = 1;
		             return;
	              }	
              } 
	          if (varMaleJoin != varFemaleJoin) {
varConfirm=window.confirm(" You specified " + varMaleJoin + " MALE joins and " + varFemaleJoin + " FEMALE joins - Each actual Benchtop MUST have TWO of these products with the SAME [Unique Bench Identifyer] - i.e [A] or [B] etc. as that Benchtop. Click [OK] to go back to the View Cart to find which Benchtop is missing one or both of the END Finish products and then ADD in the correct END Finish from the Benchtop section");	 
                 if (varConfirm == true) {
	                 location.replace("category1002104_1.htm");
		             return;
	              }	
	          }
 
  if (varCabinet == true && varNoPanel == false) {
    if (varPanel != true) {
window.alert("You did not specify any Coloured 'seen' End or SIDE PANELS  - this may be an oversight or intentional. At this stage of processing we like to be certain so you will be transferred to the Panels page to add Specifications or [No Panel Requird]");
	      varFieldCheck = 1;
	     location.replace("category1000011_1.htm");
		 return;
	    }	
	}

  if ((varCabinet == true || varCarcass == true) && varNoKick == false) {
    if (varKickboard != true ) {
window.alert("You did not specify any Kickboards - this may be an oversight or intentional. At this stage of processing we like to be certain so you will be transferred to the Kickboard page to add Specifications or [No Kickboard Required]");
	      varFieldCheck = 1;
	     location.replace("category1002111_1.htm");
		 return;
	    }	
	}
  
 } 

}

function checkDiscountandProducts()
{
 CalculateOrderTotals()
  CalculateOrderWeight()
  			  
  checkProductRange();

}
//  collect the benchtop parameters
function BenchtopParameters(i, iProdID) {

     if (iProdID > 219 && iProdID < 224) {
         varLl = parseInt(getLineSubItem(i, colCustomFields, 0));
		 varL2 = parseInt(getLineSubItem(i, colCustomFields, 1));
		 varL3 = parseInt(getLineSubItem(i, colCustomFields, 2));
		 varW1 = parseInt(getLineSubItem(i, colCustomFields, 3));
		 varW2 = parseInt(getLineSubItem(i, colCustomFields, 4));
		 varW3 = parseInt(getLineSubItem(i, colCustomFields, 5));
		 
		 if(iProdID == 220) {
		 	varE1 = getLineSubItem(i, colCustomFields, 7);
			varE3 = getLineSubItem(i, colCustomFields, 8);
		 
		 	varE1 = varE1.substring(0,1);
		 	varE2 = "U";
		 	varE3 = varE3.substring(0,1);
		 	varLx = varL2 - varW1 ;
		 	varL2 = varLx - varW3 ;
		}
		if(iProdID == 221) {
		 	varE1 = getLineSubItem(i, colCustomFields, 7);		 
		 	varE1 = varE1.substring(0,1);
		 	varE2 = "U";
		 	varE3 = "U";
		 	varL2 = varL2 - varW1 ;
			varL3 = varL3 - varW2 ;
		}
		if(iProdID == 222) {
			varE3 = getLineSubItem(i, colCustomFields, 7);		 
		 	varE1 = "U";
		 	varE2 = "U";
		 	varE3 = varE3.substring(0,1);
		 	varLl = varLl - varW2 ;
		 	varL2 = varL2 - varW3 ;
		}
		if(iProdID == 223) {	 
		 	varE1 = "U";
		 	varE2 = getLineSubItem(i, colCustomFields, 7);
			varE2= varE2.substring(0,1);
		 	varE3 = "U";
		 	varLl = varLl - varW2 ;
		 	varL3 = varL3 - varW2 ;
		}
				 		 
		 BenchCost1 = calculateBenchCost(varLl, varW1, varE1) ;
		 BenchCost2 = calculateBenchCost(varL2, varW2, varE2) ;
		 BenchCost3 = calculateBenchCost(varL3, varW3, varE3) ;
		 
		 curPrice = BenchCost1 + BenchCost2 + BenchCost3 + 231.00;
		 if (varLl > 3550) curPrice = curPrice + 80.00;
		 if (varL2 > 3550) curPrice = curPrice + 80.00;
		 if (varL3 > 3550) curPrice = curPrice + 80.00;
		 
		 CalculatedBenchtopCost = CalculatedBenchtopCost + curPrice;
//window.alert("line 3043 - CalculatedBenchtopCost= " + CalculatedBenchtopCost + " curPrice= " + curPrice);
		 
		 if (varLl > varL2) BenchLength = varLl ;
		 else BenchLength = varL2;		 
		 if (BenchLength < varL3) BenchLength = varL3 ;
		 
		 	varBench1Weight = calculateBenchWeight(varLl, varW1, varE1);
			varBench2Weight = calculateBenchWeight(varL2, varW2, varE2);
			varBench3Weight = calculateBenchWeight(varL3, varW3, varE3);
			
			BenchWeightUshapeA = varBench1Weight + varBench2Weight + varBench3Weight;		
// window.alert(" 2988 bench1W= " + varBench1Weight + "bench2W= " + varBench2Weight + "bench3W= " + varBench3Weight);			
		 		 
		 return curPrice;		
     }
	 
//  calculate for L-Shape benchtops	 
	 if (iProdID > 215 && iProdID < 220) {
         varLl = parseInt(getLineSubItem(i, colCustomFields, 0));
		 varL2 = parseInt(getLineSubItem(i, colCustomFields, 1));
		 varW1 = parseInt(getLineSubItem(i, colCustomFields, 2));
		 varW2 = parseInt(getLineSubItem(i, colCustomFields, 3));
		 varIdentifyer = parseInt(getLineSubItem(i, colCustomFields, 6));
		 
		 if(iProdID == 216) {
		  	varE1 = getLineSubItem(i, colCustomFields, 5);		 
		 	varE1 = varE1.substring(0,1);
		 	varE2 = "U";
		 	varL2 = varL2 - varW1 ;		 
		}
		if(iProdID == 217) {
			varE1 = "U";
		   	varE2 = getLineSubItem(i, colCustomFields, 5)
		 	varE2 = varE2.substring(0,1);
		 	varLl = varLl - varW2 ;
		}
		if(iProdID == 218) {
			varE2 = getLineSubItem(i, colCustomFields, 5);		 
		 	varE1 = "U";
		 	varE2 = varE2.substring(0,1);
		 	varLl = varLl - varW2 ;
		}
		if(iProdID == 219) {	 
		 	varE1 = getLineSubItem(i, colCustomFields, 5);
			varE1 = varE1.substring(0,1);
		 	varE2 = "U";
		 	varL2 = varL2 - varW1 ;
		}
				 		 
		 BenchCost1 = calculateBenchCost(varLl, varW1, varE1) ;	 
		 BenchCost2 = calculateBenchCost(varL2, varW2, varE2) ;
		 
		 curPrice = BenchCost1 + BenchCost2 + 116.00;
		 if (varLl > 3550) curPrice = curPrice + 80.00;
		 if (varL2 > 3550) curPrice = curPrice + 80.00;
		 
		 if (varLl > varL2) BenchLength = varLl ;
		 else BenchLength = varL2;
// window.alert(" 3093 BenchCost1= " + BenchCost1 + " BenchCost2 = " + BenchCost2 + " BenchCost3= " + BenchCost3 + " varLl= " + varLl + " varL2 = " + varL2 + " varL3 =  " + varL3);

		 CalculatedBenchtopCost = CalculatedBenchtopCost + curPrice;
//window.alert("line 4077 - CalculatedBenchtopCost= " + CalculatedBenchtopCost + " curPrice= " + curPrice);		 
		 
		 	varBench1Weight = calculateBenchWeight(varLl, varW1, varE1);
			varBench2Weight = calculateBenchWeight(varL2, varW2, varE2);			
			if (varIdentifyer == "A") BenchWeightLshapeA = varBench1Weight + varBench2Weight;
			else BenchWeightLshapeB = varBench1Weight + varBench2Weight; 					
//  window.alert(" 4083 benchWeight - " + BenchWeightLshapeA + " bench1W= " + varBench1Weight + " bench2W= " + varBench2Weight );
		 return curPrice;		
     }
}

function calculateBenchCost(Ll, Ww, Ee)
{
if (Ll > 3500) Ll = 3500;
if      (Ee == "U" && Ww < 601)  BenchCost = Math.ceil(Ll / 500) * 47.000;
else if (Ee == "U" && Ww < 901)  BenchCost = Math.ceil(Ll / 500) * 67.00;
else if (Ee == "U" && Ww < 1201) BenchCost = Math.ceil(Ll / 500) * 101.00;
else if (Ee == "A" && Ww < 601)  BenchCost = Math.ceil(Ll / 500) * 55.00;
else if (Ee == "A" && Ww < 901)  BenchCost = Math.ceil(Ll / 500) * 73.00;
else if (Ee == "A" && Ww < 1201) BenchCost = Math.ceil(Ll / 500) * 105.00;
//add 30% increase 11/9/2011
BenchCost = Math.ceil(BenchCost * 1.3);
//alert("line 3686 cost = " + BenchCost + " length=  " + Math.ceil(Ll  / 100) + " Width= " + Ww + " Ee= " + Ee); 
	  
return BenchCost;
}

function calculateBenchWeight(Ll, Ww, Ee){
			if (Ww  < 601 && varE1 == "U") varBenchWeight = (Ll * 13.8) / 1000 ;
			else if (Ww  < 601 && Ee == "A") varBenchWeight = (Ll * 14.0) / 1000 ;
			else if (Ww  < 901 && Ee == "U") varBenchWeight = (Ll * 20.6) / 1000 ;
			else if (Ww  < 901 && Ee == "A") varBenchWeight = (Ll * 21.0) / 1000;
			else if (Ee == "U") varBenchWeight = (Ll * 27.6) / 1000 ;
			else if (Ee == "A") varBenchWeight = (Ll * 28.0) / 1000 ;
					
			return varBenchWeight ;
}


function PriceandWeightCalc(i)
{     
	    curPrice = 0.0;
		getInputDimensions(i);
		varVariableWeight = 0;
		varWeight= 0;
	
// Base Cabinets Your Dimension	
   if (varProductCode.substring(0,12) == "B-D1-S1/Y241"){
      curPrice = Math.round(0.124716553 * varHeight * varWidth * varDepth / 1000000 + 87.75);
	  varWeight = 0.59 * varHeight * varWidth * varDepth / 10000000 + 10.00;
   }
   if (varProductCode.substring(0,12) == "B-D2-S1/Y242")  {
      curPrice = Math.round(0.161565 * varHeight * varWidth * varDepth / 1000000 + 105);
	  varWeight = 0.59 * varHeight * varWidth * varDepth / 10000000 + 10.00;
   }
// Floor Open Units BO-S1/Y1	
   if (varProductCode.substring(0,8) == "BO-S1/Y1"){
      curPrice = Math.round(0.2315 * varHeight * varWidth * varDepth / 1000000 + 108.00);
	  varWeight = 0.4853 * varHeight * varWidth * varDepth / 10000000 + 12.55;
   }   
   // Floor Open Diagonal Units BOA-S1/Y	
   if (varProductCode.substring(0,8) == "BOA-S1/Y"){
      curPrice = Math.round(0.0877 * varHeight * varWidth * varDepth / 1000000 + 117.90);
	  varWeight = 0.4853 * varHeight * varWidth * varDepth / 10000000 + 12.55;
   }   
// Drawers Your Dimension       
    if (varProductCode.substring(0,10) == "BDrw-MT2/Y") {
    curPrice = Math.round(0.104 * varWidth + (varHeight - 750) * 0.04 + 157);
      varWeight = 0.039 * varWidth + (varHeight - 750) * 0.04 + 14.00;
	}
   if (varProductCode.substring(0,10) == "BDrw-MT3/Y") {
     curPrice = Math.round(0.124 * varWidth + (varHeight - 750) * 0.06 + 207.00);
 	   varWeight = 0.05 * varWidth + (varHeight - 750) * 0.06 + 12.00;
   }
   if (varProductCode.substring(0,10) == "BDrw-MT4/Y") {
     curPrice = Math.round(0.142 * varWidth + (varHeight - 750) * 0.12 + 245.00);
	  varWeight = 0.06 * varWidth + (varHeight - 750) * 0.06 + 13.00;
   }
   if (varProductCode.substring(0,10) == "BDrw-MT5/Y") {
     curPrice = Math.round(0.160 * varWidth + (varHeight - 750) * 0.14 + 255.00);
	 varWeight = 0.06 * varWidth + (varHeight - 750) * 0.06 + 14.00;
   }
 // Corner Cabinets Your Dimesion BC-D1-S1/Y  
   if (varProductCode.substring(0,10) == "BC-D1-S1/Y") {     
	 curPrice = Math.round(1.073 * (varHeight * varLHWidth * varLHDepth + varHeight * varRHWidth * varRHDepth)/ 10000000 + 222);
	   varWeight = Math.round(0.425 * (varHeight * varLHWidth * varLHDepth + varHeight * varRHWidth * varRHDepth)/ 10000000) + 18.5;
   }  
	 if (varProductCode.substring(0,11) == "BCA-D1-S1/Y") {
	 curPrice = Math.round(1.073 * (varHeight * varLHWidth * varLHDepth + varHeight * varRHWidth * varRHDepth)/ 10000000 + 235);
	  varWeight = Math.round(0.425 * (varHeight * varLHWidth * varLHDepth + varHeight * varRHWidth * varRHDepth)/ 10000000) + 18.5;
   }   
// Diagonals BD-D1-S1/Y
  if (varProductCode.substring(0,10) == "BD-D1-S1/Y") {
	 curPrice = Math.round(1.4 * (varHeight * varLHWidth * varLHDepth + varHeight * varRHWidth * varRHDepth)/ 10000000 + 114.26);
	 varWeight = Math.round(0.292 * (varHeight * varLHWidth * varLHDepth + varHeight * varRHWidth * varRHDepth)/ 10000000 + 16.5);
  }
// Combo units BCD1Drw1/Y  
     if (varProductCode.substring(0,10) == "BCD1Drw1/Y") {
     curPrice = Math.round(0.2889 * varHeight * varWidth * varDepth / 1000000 + 118.55);
	 varWeight = Math.round(0.0843 * varHeight * varWidth * varDepth / 1000000 + 11.5);
     }
    if (varProductCode.substring(0,10) == "BCD2Drw1/Y") {
     curPrice = Math.round(0.245 * varHeight * varWidth * varDepth / 1000000 + 146);
	 varWeight = Math.round(0.0829 * varHeight * varWidth * varDepth / 1000000 + 12.7);
    }
    if (varProductCode.substring(0,10) == "BCD2Drw2/Y") {
     curPrice = Math.round(0.2868 * varHeight * varWidth * varDepth / 1000000 + 175);
	  varWeight = Math.round(0.0799 * varHeight * varWidth * varDepth / 1000000 + 13.9);
    }
// Wall Units W-D1-S1/Y 
if (varProductCode.substring(0,9) == "W-D1-S1/Y" && varHeight > 900) {
     curPrice = Math.round(0.3769 * varHeight * varWidth * varDepth / 1000000 + 64.10);
	 varWeight = Math.round(0.076 * varHeight * varWidth * varDepth / 1000000 + 8.4);
   }
   if (varProductCode.substring(0,9) == "W-D2-S1/Y" && varHeight > 900) {
     curPrice = Math.round(0.36114 * varHeight * varWidth * varDepth / 1000000 + 83.85);
	   varWeight = Math.round(0.07 * varHeight * varWidth * varDepth / 1000000 + 10.0);
   }
   if (varProductCode.substring(0,9) == "W-D1-S1/Y" && varHeight < 901) {
     curPrice = Math.round(0.4134 * varHeight * varWidth * varDepth / 1000000 + 59.20);
	 varWeight = Math.round(0.0806 * varHeight * varWidth * varDepth / 1000000 + 7.00);
   }
   if (varProductCode.substring(0,9) == "W-D2-S1/Y" && varHeight < 901) {
     curPrice = Math.round(0.3588 * varHeight * varWidth * varDepth / 1000000 + 83);
	  varWeight = Math.round(0.0762 * varHeight * varWidth * varDepth / 1000000 + 8.45);
   }   
   
 // Wall Units Frame Doors W-F1-S1/Y 
   if (varProductCode.substring(0,9) == "W-F1-S1/Y" && varHeight > 900) {
     curPrice = Math.round(0.218 * varHeight * varWidth * varDepth / 1000000 + 86.55);
	varWeight = Math.round(0.076 * varHeight * varWidth * varDepth / 1000000 + 2.4);
   }
   if (varProductCode.substring(0,9) == "W-F2-S1/Y" && varHeight > 900) {
     curPrice = Math.round(0.2089 * varHeight * varWidth * varDepth / 1000000 + 114.55);
	varWeight = Math.round(0.07 * varHeight * varWidth * varDepth / 1000000 + 40.0);
   }
   if (varProductCode.substring(0,9) == "W-F1-S1/Y" && varHeight < 901) {
     curPrice = Math.round(0.235 * varHeight * varWidth * varDepth / 1000000 + 81.55);
	varWeight = Math.round(0.0806 * varHeight * varWidth * varDepth / 1000000 + 1.00);
   }
  if (varProductCode.substring(0,9) == "W-F2-S1/Y" && varHeight < 901) {
     curPrice = Math.round(0.21905 * varHeight * varWidth * varDepth / 1000000 + 112.55);
	varWeight = Math.round(0.0762 * varHeight * varWidth * varDepth / 1000000 + 2.45);
   }
   
 // Corner Wall Cabinets Your Dimesion WC-D1-S1/Y  
   if (varProductCode.substring(0,10) == "WC-D1-S1/Y") {
	 curPrice = Math.round(0.1883* (varHeight * varLHWidth * varLHDepth + varHeight * varRHWidth * varRHDepth)/ 1000000 + 189.50);
	 varWeight = Math.round(0.054127 * (varHeight * varLHWidth * varLHDepth + varHeight * varRHWidth * varRHDepth)/ 1000000 + 5.55);
   }
// Wall Diagonals WD-D1-S1/Y
   if (varProductCode.substring(0,10) == "WD-D1-S1/Y") {
	 curPrice = Math.round(0.1353 * (varHeight * varLHWidth * varRHWidth)/ 1000000 + 116);
		 varWeight = Math.round(0.0546 * (varHeight * varLHWidth * varRHWidth)/ 1000000 + 12.5);
   }
 // Wall Units Open WO-S1/Y 
   if (varProductCode.substring(0,7) == "WO-S1/Y") {
     curPrice = Math.round(0.2617 * varHeight * varWidth * varDepth / 1000000 + 89.55);
	varWeight = Math.round(0.0576 * varHeight * varWidth * varDepth / 1000000 + 9.75);
   }
  
 // Wall Diagonals Open WDO-S1/Y
   if (varProductCode.substring(0,8) == "WDO-S1/Y") {
	 curPrice = Math.round(0.309677 * (varHeight * varLHWidth * varRHWidth)/ 1000000 + 61.55);
		 varWeight = Math.round(0.0615 * (varHeight * varLHWidth * varRHWidth)/ 1000000 + 9.5);
   }  
// Wall 135 degree Booma unit WB45-D1-S1/Y  
    if (varProductCode.substring(0,12) == "WB45-D1-S1/Y" ) {
	 curPrice = Math.round(0.3866 * (varHeight * varLHWidth * varLHDepth + varHeight * varRHWidth * varRHDepth)/ 1000000 + 146.33);
	 varWeight = Math.round(0.56 * (varHeight * varLHWidth * varLHDepth + varHeight * varRHWidth * varRHDepth)/ 10000000) + 26.5;
//alert("4242 - varWeight= " + varWeight + " curPrice= " + curPrice + " " + varHeight + " " + varLHWidth + " " + varRHWidth + " " + varLHDepth + " " + varRHDepth);
	 } 
	   
 // Floor 135 degree Booma unit BB45-D1-S1/Y  
    if (varProductCode.substring(0,12) == "BB45-D1-S1/Y" ) {
	 curPrice = Math.round(1.073 * (varHeight * varLHWidth * varLHDepth + varHeight * varRHWidth * varRHDepth)/ 10000000 + 250.55);
	 varWeight = Math.round(0.425 * (varHeight * varLHWidth * varLHDepth + varHeight * varRHWidth * varRHDepth)/ 10000000) + 18.5;
	 }
// Pantry or general storage One Door P-D1-S5/Y
	if (varProductCode.substring(0,9) == "P-D1-S5/Y" && varDepth > 450) {
     curPrice = Math.round(0.22 * varHeight * varWidth * varDepth / 1000000 +120.95);
     varWeight = Math.round(0.06818 * varHeight * varWidth * varDepth / 1000000 + 20.75);
// alert("4254 varWeight= " + varWeight + " varHeight= " + varHeight + " varWidth= " + varWidth + " varDepth= " + varDepth + " curPrice= " + curPrice);
    }

	if (varProductCode.substring(0,9) == "P-D2-S5/Y" && varDepth > 450) {
     curPrice = Math.round(0.176 * varHeight * varWidth * varDepth / 1000000 + 169.85);
	 varWeight = Math.round(0.06347 * varHeight * varWidth * varDepth / 1000000 + 26.25);  
	}
	if (varProductCode.substring(0,9) == "P-D1-S5/Y" && varDepth < 451) {
     curPrice = Math.round(0.251 * varHeight * varWidth * varDepth / 1000000 + 121.30);
     varWeight = Math.round(0.06818 * varHeight * varWidth * varDepth / 1000000 + 20.75);
    }
	if (varProductCode.substring(0,9) == "P-D2-S5/Y"  && varDepth < 451) {
     curPrice = Math.round(0.231 * varHeight * varWidth * varDepth / 1000000 + 156.45);
	 varWeight = Math.round(0.06347 * varHeight * varWidth * varDepth / 1000000 + 26.25); 
	}
// Corner Pantry One Door PC-D1-S5/Y
	if (varProductCode.substring(0,10) == "PC-D1-S5/Y") {
	 curPrice = Math.round(0.036 * (varHeight * varLHWidth * varLHDepth + varHeight * varRHWidth * varRHDepth)/ 1000000 + 664.10);
	  varWeight = Math.round(0.0342592593 * (varHeight * varLHWidth * varLHDepth + varHeight * varRHWidth * varRHDepth)/ 1000000 + 57.35);	 
	 }	 
// Corner Walkin Pantry One Door PD-D1-S5/Y
	if (varProductCode.substring(0,10) == "PD-D1-S5/Y") {
	 curPrice = Math.round(0.125 * (varHeight * varLHWidth * varLHDepth + varHeight * varRHWidth * varRHDepth)/ 1000000 + 166.25);
	     varWeight  = Math.round(0.0375 * (varHeight * varLHWidth * varLHDepth + varHeight * varRHWidth * varRHDepth)/ 1000000 + 40);

	 }	 	 
// Corner Walkin Pantry Two Door PD-D2-S5/Y
	if (varProductCode.substring(0,10) == "PD-D2-S5/Y") {
	   curPrice = Math.round(0.073 * (varHeight * varLHWidth * varLHDepth + varHeight * varRHWidth * varRHDepth)/ 1000000 + 315.85);
		 varWeight = Math.round(0.029167 * (varHeight * varLHWidth * varLHDepth + varHeight * varRHWidth * varRHDepth)/ 1000000 + 64);
	 }
	 
// Panels  "Panel/Y"
	if (varProductCode.substring(0,7) == "Panel/Y") {
	   curPrice = Math.round(0.05654 * (varHeight * varWidth) / 1000 + 10.50);
		 varWeight  = Math.round(0.01116 * (varHeight * varWidth)/ 1000 + 1); 
	 }
// Kickboards  "Kick/Y"
	if (varProductCode.substring(0,6) == "Kick/Y") {
	   curPrice = Math.round(0.05 * (varHeight * varWidth) / 1000 + 5.50);
		 varWeight  = Math.round(0.01116 * (varHeight * varWidth)/ 1000 + 1 ); 
	 }	 
// Filler  "Filler/Y"
	if (varProductCode.substring(0,8) == "Filler/Y") {
	   curPrice = Math.round(0.075 * (varHeight * varWidth) / 1000 + 7.4);
		 varWeight  = Math.round(0.01116 * (varHeight * varWidth)/ 1000 + 1 ); 
	 }	 	 
// just Doors  "Door/Y"
	if (varProductCode.substring(0,6) == "Door/Y") {
	   curPrice = Math.round(0.0538129 * (varHeight * varWidth) / 1000 + 18);
		 varWeight  = Math.round(0.01116 * (varHeight * varWidth)/ 1000 + 1 ); 
	 }
	
   if (varWeight > 0) varVariableWeight =  varWeight;	 
   varWeight = 0;
//as of 2011-Oct
curPrice = Math.round((curPrice * 103) / 100);  
		  	 	 
 return curPrice;
}

// -------------------------------------

//function to determine PID to be used depending on Style required and specified Height and Width
// Recalculate Costs after a GLOBAL change in Style Finish
// OBSOLETE processing in C-ONLINE
function changeStyle(iProdID,i)
{
 realPID = iProdID;
 varNewPID = iProdID;
//alert("4312 iProdID= " + iProdID);
 varProductCode = getProductInfo(iProdID)[colProductCode];
 newProductCode = varProductCode;
 if ((varProductCode.substring(0,1) != "2" && varProductCode.substring(0,1) != "3"  && varProductCode.substring(0,1) != "8" & varProductCode.substring(0,1) != "0" && varProductCode.substring(0,1) != "z" && varProductCode.substring(0,2) != "Ha" && varProductCode.substring(0,2) != "BT"  && varProductCode.substring(0,3) != "TBA" && varProductCode.substring(0,1) != "c" && varProductCode.substring(0,3) != "Out")|| varProductCode.indexOf("/Q") == 0) { 
	var varLength = varProductCode.length;
	var varSlash = varProductCode.indexOf("/");
	var varRoot = varProductCode.substring(0,varSlash + 1);
	var varLastChar = ""	        

	newProductCode = varRoot + varDimension1 + "-" + varDimension2 + varLastChar; 		  
    varNewPID=changePID(newProductCode);   // find the new PID based on the newProductCode 

    if(varNewPID == 0)  varNewPID = realPID;
 }
//alert("line 4369 varRoot= " + varRoot + " varLastChar= " + varLastChar + " newProductCode= " + newProductCode +  " varNewPID= " + varNewPID + " i= " + i);
   return varNewPID;
}
// ----------------------------------------------------------------------------------------	 
function changePID(varNewPID)
{
// varNewPID initially contains the ProductCode.
// change ProductCode to Root + Suffix - 
//window.alert("varNewPID=  " + varNewPID);

  switch(varNewPID)
    {
      case 'WRS/2000-600' : return  25758;
	  case 'WOMD2/2150-600' : return 18441;
	  case 'WOMD4/2150-600' : return 18442;
	  case 'WOD2/2150-600' : return 18443;
	  case 'WOD4/2150-600' : return 18444;
	  case 'WOMD2/2150-700' : return 18445;
	  case 'WOMD4/2150-700' : return 18446;
	  case 'WOD2/2150-700' : return 18447;
	  case 'WOD4/2350-700' : return 18448;
	  case 'WOMD2/2350-600' : return 18561;
	  case 'WOMD4/2350-600' : return 18562;
	  case 'WOD2/2350-600' : return 18563;
	  case 'WOD4/2350-600' : return 18564;
	  case 'WOMD2/2350-700' : return 18565;
	  case 'WOMD4/2350-700' : return 18566;
	  case 'WOD2/2350-700' : return 18567;
	  case 'WOD4/2350-700' : return 18568;  
	  case 'RH-D2-S1/750-600' : return 19071;
	  case 'RH-D2-S1/750-700' : return 19072;
	  case 'RH-D2-S1/750-900' : return 19158;
	  case 'RH-D2-S1/900-600' : return 19113;
	  case 'RH-D2-S1/900-700' : return 19114;
	  case 'RH-D2-S1/900-900' : return 19172;
	  
    }
    return 0; 
}     

function CalculateProportionalDiscount(curPrice,iProdID,i,lineCount,varNewPID)

// We assume that: for Base and Wall Cabinets - based on Carcass-only pricing
//					Depth variation save $5.00 per 100mm in Carcass costs;
//                  Width variations save $4.00 per 100mm in Carcass cost 
//                  Height variations save $9.00 per 100mm  
//  Drawers:     Height or Width $12 per 100mm, Depth at $5.00
//   Doors etc.  Vinyl - no saving as prices set in ranges by the Supplier
//                Laminate Doors etc. %5.00 per 100mm Height and $4.00 per 100mm Width

// With iProdID we find Product Code for the standard item. We then Modify the Product code for the nearest HeightxWidth dimension and the appropriate
//  Suffix (Style finish code) 
// We use the new ProductCode to find the appropriate PID code, and use that to find the Stored Price. This Price is then modified in the ratio 
//   HxW/eightxwidth 
//                   But not for Benchtops, Hardware etc    
{ 
  var varOldPrice = curPrice;
  var varStart = 0;
  var varCarcassSaving = 0;
  var varDoorSaving = 0;
  var varBenchSaving = 0;
  varNewPrice = varOldPrice;

   
  getProductStyle(iProdID,i);

//  When processing BenchTop STYLE record
 if (newProductCode.substring(0,1) == "3") {
   if (varBenchCost < 181.82) varNewPrice = 72.73;
   else if (varBenchCost > 454.55) varNewPrice = 0;
   else varNewPrice = Math.round(72.73 - ((varBenchCost - 181.82) * 0.267));
   if (i == lineCount - 1)
 alert("To cover the Overheads on small Benchtop acquisitions ($80 for Orders under $200 in value, and $0.00 for orders greater than $500) - this Benchtop Value being $" + varBenchCost + " (excl. GST) we have charged $" + varNewPrice  + " excl. GST") ;
  }
  else if(newProductCode.substring(0,1) == "2")  varStart = 0; 
  else varStart = newProductCode.indexOf("/");
  var varLength = newProductCode.length;
//------------------------------------------------------  
  if  (varStart > 0) varMeasurements = newProductCode.substring(varStart + 1, varLength)
  
  arrDimensions = varMeasurements.split("-");
//window.alert("line 4374 " + arrDimensions[0] + "," + arrDimensions[1] + " varProdStyle= " + varProdStyle + " newProductCode= " + newProductCode);
  var varH = parseInt(arrDimensions[0]);
  var varW = parseInt(arrDimensions[1]);
  if (newProductCode.substring(0,3) == "B-D") varD = 700;
  else if (newProductCode.substring(0,3) == "W-D" || newProductCode.substring(0,4) == "WB45" || newProductCode.substring(0,2) == "WC" || newProductCode.substring(0,2) == "WB" || newProductCode.substring(0,3) == "WDO"  || newProductCode.substring(0,3) == "RH-" || newProductCode.substring(0,3) == "MW/") varD =500;
  else if (newProductCode.substring(0,2) == "WR")  varD = 595;
  else if (newProductCode.substring(0,4) == "BD-D") varD = 350;
  else varD = 600;
  if (newProductCode.substring(0,4) == "BB45" || newProductCode.substring(0,4) == "WB45"|| newProductCode.substring(0,4) == "BD-D" || newProductCode.substring(0,4) == "BC-D") var varDoorWidth = 600;
  else if (newProductCode.substring(0,3) == "PD-") varDoorWidth = 566
  else if (newProductCode.substring(0,4) == "PC-D") varDoorWidth = 600;  // Assumed Standard Door size 
  else varDoorWidth = varW;
//  alert("4385 varDoorWidth=" + varDoorWidth);
  getInputDimensions(i);
  
 if (newProductCode.substring(0,4) == "BDrw" || newProductCode.substring(0,4) == "cBDr" || newProductCode.substring(0,3) == "BCD")   
   varCarcassSaving = (varH - varHeight) / 100 * 6.00 + (varW - varWidth) / 100 * 11.00 + (varD - varDepth) / 100 * 11.00;
   // items deleted here =====================================================
 
	
  // Items deleted from COD - program  above=========================================================================	
 else if (newProductCode.substring(0,3) == "cP-") varCarcassSaving = (varH - varHeight) / 100 * 11.00 + (varW - varWidth) / 100 * 12.00 + (varD - varDepth) / 100 * 13.00; 
 
 else if (newProductCode.substring(0,4) == "WRFH") varCarcassSaving = (varH - varHeight) / 100 * 1.00 + (varW - varWidth) / 100 * 2.00 + (varD - varDepth) / 100 * 5.00;  
 else if (newProductCode.substring(0,4) == "WRDH") varCarcassSaving = (varH - varHeight) / 100 * 1.00 + (varW - varWidth) / 100 * 3.00 + (varD - varDepth) / 100 * 8.00; 
 else if (newProductCode.substring(0,3) == "WRS") varCarcassSaving = (varH - varHeight) / 100 * 4.00 + (varW - varWidth) / 100 * 7.00 + (varD - varDepth) / 100 * 18.00; 
 else if (newProductCode.substring(0,5) == "WRFHS") varCarcassSaving = (varH - varHeight) / 100 * 2.00 + (varW - varWidth) / 100 * 3.00 + (varD - varDepth) / 100 * 12.00;
 else if (newProductCode.substring(0,4) == "WRD2") varCarcassSaving = (varH - varHeight) / 100 * 4.00 + (varW - varWidth) / 100 * 12.00 + (varD - varDepth) / 100 * 28.00;
 else if (newProductCode.substring(0,4) == "WRD3") varCarcassSaving = (varH - varHeight) / 100 * 4.00 + (varW - varWidth) / 100 * 14.00 + (varD - varDepth) / 100 * 32.00;
 else if (newProductCode.substring(0,4) == "WRD4") varCarcassSaving = (varH - varHeight) / 100 * 4.00 + (varW - varWidth) / 100 * 15.00 + (varD - varDepth) / 100 * 35.00;
 else if (newProductCode.substring(0,4) == "WRD5") varCarcassSaving = (varH - varHeight) / 100 * 4.00 + (varW - varWidth) / 100 * 16.00 + (varD - varDepth) / 100 * 40.00;
 else if (newProductCode.substring(0,4) == "WECS") varCarcassSaving = (varH - varHeight) / 100 * 9.00 + (varW - varLHWidth) / 100 * 6.00 + (varW - varRHWidth) / 100 * 6.00 + (varD - varLHDepth) / 100 * 7.00 + (varD - varRHDepth) / 100 * 7.00 ;
 else if (newProductCode.substring(0,4) == "WRCS") varCarcassSaving = (varH - varHeight) / 100 * 3.00 + (varW - varLHWidth) / 100 * 3.00 + (varW - varRHWidth) / 100 * 3.00 + (varD - varLHDepth) / 100 * 8.00 + (varD - varRHDepth) / 100 * 8.00 - WRShelfQuantity * WRShelfCost ; 
 
 else if (newProductCode.substring(0,2) == "RV") varCarcassSaving = (2000 - varHeight) / 100 * 1.00 + (595 - varWidth) / 100 * 2.00;
 
 else if (newProductCode.substring(0,4) == "Pane" || newProductCode.substring(0,4) == "Door" || newProductCode.substring(0,4) == "Kick" || newProductCode.substring(0,4) == "Fill" || newProductCode.substring(0,2) == "BT" || newProductCode.substring(0,1) == "2" || newProductCode.substring(0,1) == "L") { 
 		varCarcassSaving = 0;
	    varDoorSize =  varWidth;
   }     	    
 else varCarcassSaving = (varH - varHeight) / 100 * 5.00 + (varW - varWidth) / 100 * 4.00 + (varD - varDepth) / 100 * 4.00;
	    
//alert(" line 4477 varDoorWidth= " + varDoorWidth + " varDoorSize= " + varDoorSize + " varH=  " + varH + " varHeight= " + varHeight + " " + " varW= " + varW + " " + varProdStyle + " varCarcassSaving= " + varCarcassSaving);
varDoorSaving = 0;  

 if      (varProdStyle == "Lamin") varDoorSaving = Math.round(((varH * varDoorWidth) - (varHeight * varDoorSize)) / 1000 * 0.055);
 else if (varProdStyle == "Unfin") varDoorSaving = Math.round(((varH * varDoorWidth) - (varHeight * varDoorSize)) / 1000 * .11);

 else if (varProdStyle = "Carca")  varDoorSaving = ((varH * varDoorWidth) - (varHeight * varDoorSize)) / 1000 * 0.03;
//alert(" line 4477 - varDoorSaving= " + varDoorSaving + " varProdStyle= " + varProdStyle + " varH= " + varH + "  varDoorWidth= " + varDoorWidth + " varHeight= " + varHeight + " varDoorSize= " + varDoorSize );

 if (newProductCode.substring(0,4) == "BO-S" || newProductCode.substring(0,4) == "WO-S" || newProductCode.substring(0,4) == "BOA-" || newProductCode.substring(0,4) == "WDO-" 
   || newProductCode.substring(0,4) == "BB45" || newProductCode.substring(0,4) == "BB45" || newProductCode.substring(0,3) == "MW/" || newProductCode.substring(0,2) == "WR" 
   || newProductCode.substring(0,2) == "WE"  || newProductCode.substring(0,2) == "BT" || newProductCode.substring(0,1) == "c" || newProductCode.substring(0,2) == "RV"
   || newProductCode.substring(0,1) == "L" || newProductCode.substring(0,3) == "UBO")  varDoorSaving = 0; 
	
 if (newProductCode.substring(0,3) == "WOD" || newProductCode.substring(0,3) == "WOM") varDoorSaving = varDoorSaving / 2;  
 if (newProductCode.substring(0,3) == "MW/") varCarcassSaving = varCarcassSaving / 2; 
 
 if (newProductCode.substring(0,3) == "BTS" || newProductCode.substring(0,3) == "BTD") {
   if (varHeight > 3500) varHeight = 3500;	
 	if (varWidth < 601 && newProductCode.substring(0,3) == "BTS")  varBenchSaving = Math.round((varHeight / 500) * 61.3);
	else if (varWidth < 901 && newProductCode.substring(0,3) == "BTS")  varBenchSaving = Math.round((varHeight / 500) * 89.3);
	else if (varWidth < 1201 && newProductCode.substring(0,3) == "BTS") varBenchSaving = Math.round((varHeight / 500) * 134.0);
	else if (varWidth < 601 && newProductCode.substring(0,3) == "BTD")  varBenchSaving = Math.round((varHeight / 500) * 72.9);
	else if (varWidth < 901 && newProductCode.substring(0,3) == "BTD") varBenchSaving = Math.round((varHeight / 500) * 95.5);
	else if (varWidth < 1201 && newProductCode.substring(0,3) == "BTD") varBenchSaving = Math.round((varHeight / 500) * 140.0);

	varNewPrice =  varBenchSaving;
	varBenchCost = varBenchCost + varNewPrice; 	
 }

 
 if (newProductCode.substring(0,2) != "BT" && newProductCode.substring(0,1) != "3" && newProductCode.substring(0,1) != "2" && newProductCode.substring(0,11) != "DoorGlass/Y3")  {
 	  varNewPrice = Math.round(varOldPrice - varCarcassSaving - varDoorSaving);
	  
// Frame Doors  "DoorGlass/Y*"
	if (newProductCode.substring(0,11) == "DoorGlass/Y") {
	   var varNumber = varProductCode.substring(11,12)	    
	   varNewPrice = Math.round(0.15 * (varHeight * varWidth) / 1000);
	     if (varNumber == 1) varNewPrice = Math.round(0.15 * (varHeight * varWidth) / 1000 + 75.0);
		 if (varNumber == 2) varNewPrice = Math.round(0.15 * (varHeight * varWidth) / 1000 + 127.5);
		 if (varNumber == 3) varNewPrice = Math.round(0.15 * (varHeight * varWidth) / 1000+ 169.6);				 
	  
		varWeight  = Math.round(0.02 * (varHeight * varWidth)/ 1000 + 0.2 ); 
	}

//alert("4517 line- " + varH + " " + varHeight + " " + varW + " " + varWidth + " " + varD + " " + varDepth + " " + curPrice + " ProductChangeFlag= " + varProductChangeFlag +  " varCarcassSaving= " + varCarcassSaving + " varDoorSaving= " + varDoorSaving + " varProdStyle= " + varProdStyle + " " + newProductCode); 

}
 varProductChangeFlag == false;
  return varNewPrice;
}
//----------------------------------------------------------------------
function getInputDimensions(i)
{
	var iCustomFieldCount = getLineSubCount(i, colCustomFields);
    if (varProductCode.substring(0,1) != "2" && varProductCode.substring(0,1) != "3" && varProductCode.substring(0,1) != "z" && varProductCode.substring(0,1) != "H" && varProductCode.substring(0,2) != "WR" && varProductCode.substring(0,6) != "Outlet") { 
        varHeight = getLineSubItem(i, colCustomFields, 0);
	    varWidth = getLineSubItem(i, colCustomFields, 1);
	    varDepth = getLineSubItem(i, colCustomFields, 2); 
		varDoorSize = varWidth;	
		varShelfSize = varWidth * varDepth;
		if (varProductCode.substring(0,4) == "Fill" || varProductCode.substring(0,4) == "Door" ||varProductCode.substring(0,4) == "Kick") 
		   varDepth = 0;		
    } 
	if (varProductCode.substring(0,3) == "WC-" || varProductCode.substring(0,3) == "WD-" || varProductCode.substring(0,3) == "WDO" || varProductCode.substring(0,3) == "WB4" || varProductCode.substring(0,3) == "PD-" || varProductCode.substring(0,3) == "PC-" || varProductCode.substring(0,3) == "BC-" || varProductCode.substring(0,3) == "BD-" || varProductCode.substring(0,3) == "BB4" || varProductCode.substring(0,3) == "BCA") {
	 varHeight = getLineSubItem(i, colCustomFields, 0);
	 varLHWidth = parseInt(getLineSubItem(i, colCustomFields, 1));
	 varRHWidth = parseInt(getLineSubItem(i, colCustomFields, 2));
	 varLHDepth = parseInt(getLineSubItem(i, colCustomFields, 3));
	 varRHDepth = parseInt(getLineSubItem(i, colCustomFields, 4));
	 varDoorSize = (varLHWidth + varRHWidth)- (varLHDepth + varRHDepth);
	 varShelfSize = varLHWidth * varRHDepth + varRHWidth * varLHDepth;
//alert("4571 -varRHDepth= " + varRHDepth + " iCustomFieldCount= " + iCustomFieldCount + " varLHDepth= " + varLHDepth + " varProductCode= " + varProductCode + " i= " + i);
	}

// items deleted from COD  ==================================================	

 // end of items deleted from COD ======================================================
	if (varProductCode.substring(0,2) == "WR" && varProductCode.substring(0,4) != "WRCS") {
		varHeight = getLineSubItem(i, colCustomFields, 3);
	    varWidth  = getLineSubItem(i, colCustomFields, 4);
	    varDepth  = getLineSubItem(i, colCustomFields, 5); 
		varShelfSize = varWidth * varDepth;
		varDoorSize = 0;
	}
	if (varProductCode.substring(0,4) == "WRCS") {
	 varHeight = getLineSubItem(i, colCustomFields, 0);
	 varLHWidth = parseInt(getLineSubItem(i, colCustomFields, 1));
	 varRHWidth = parseInt(getLineSubItem(i, colCustomFields, 2));
	 varLHDepth = parseInt(getLineSubItem(i, colCustomFields, 3));
	 varRHDepth = parseInt(getLineSubItem(i, colCustomFields, 4));
	 WRShelfQuantity = parseInt(getLineSubItem(i, colCustomFields, 6));
	 WRShelfCost = 64.50;
	 if (varLHWidth < 901 && varRHWidth < 901) WRShelfCost = 57.20; 
		varDoorSize = 0;
	}
	if (varProductCode.substring(0,4) == "BD-D" || varProductCode.substring(0,4) == "WD-D" || varProductCode.substring(0,4) == "BB45" || varProductCode.substring(0,4) == "WB45" || varProductCode.substring(0,4) == "cBD-" || varProductCode.substring(0,4) == "cWD-") varDoorSize = 600;
	if (varProductCode.substring(0,3) == "PD-" ) varDoorSize = Math.ceil(Math.sqrt(Math.pow(varLHWidth - varRHDepth,2)+ Math.pow(varRHWidth - varLHDepth,2)));
//alert("line 4475 varHeight= " + varHeight + " varProductCode= " + varProductCode + " varRHHWidth= " + varRHWidth + "varRHDepth= " + varRHDepth + " varDoorSize =" + varDoorSize + " WRShelfCost= " + WRShelfCost);
}
//============================================
// Procedure to Acccept changes from the View Cart screen when the User OVERWRITE the listed Custom fields
function editCart(line, item, colCustomFields, iCustomField, productCode, customName, customValue, varCustomFieldNameCode)
{
		if (item.value != "NaN") {	
	        var varFieldCode = parseInt(varCustomFieldNameCode);
			
			if ((item.value.substring(0,1) == "n" || item.value.substring(0,1) == "y" || item.value.substring(0,1) == "a" || item.value.substring(0,1) == "b" || item.value.substring(0,1) == "l" || item.value.substring(0,1) == "f" || item.value.substring(0,1) == "r" || item.value.substring(0,1) == "l" || item.value.substring(0,1) == "b" || item.value.substring(0,1) == "c" || item.value.substring(0,1) == "d" || item.value.substring(0,1) == "s") && productCode.substring(0,1) != "3")
				{	 
					 var varFirstChar = item.value.substring(0,1);
					 var varFirstChar2 = varFirstChar.toUpperCase();
					 var newitemValue = varFirstChar2 + item.value.substring(1,item.value.length);
					 setLineSubItem(line, colCustomFields, iCustomField, newitemValue);
					 item.value = newitemValue;		
				}
			else if (customName.substring(0,6) == "Height") {
			         varMaxHeight = getMaxHeight(varFieldCode);
//alert(" 4597 customname= " + customName + " customValue= " + customValue + " item.value= " + item.value + " varCustomFieldNameCode= " + varCustomFieldNameCode + " varMaxHeight= " + varMaxHeight);
				      if (varMaxHeight > 0 && varMaxHeight < item.value) 
   window.alert("****You cannot exceed the HEIGHT (or Length) range for this Product***, please amend the height specified or select a different Product Range - also you could put a REQUEST for Quotation in the [Special Request] box and we will provide a quotation for this special case***");
                     else { setLineSubItem(line, colCustomFields, iCustomField, item.value);
					      window.location.href = 'viewcart.htm';
					  }
					  
            }
			else if (customName.substring(0,5) == "Width") {
			        varMaxWidth = getMaxWidth(varFieldCode);				 
                    if (varMaxWidth > 0 && varMaxWidth < item.value)
   window.alert("****You cannot exceed the MAXIMUM WIDTH for this Product***, please amend the field value specified or select a different Product Range - also you could put a REQUEST for Quotation in the [Special Request] box and we will provide a quotation for this special case***");								        	
			        else { setLineSubItem(line, colCustomFields, iCustomField, item.value);
			               window.location.href = 'viewcart.htm';
				    }
			}
			else if (customName.substring(0,4) == "LH W") {
			        varMaxWidth = getMaxWidth(varFieldCode);				 
                    if (varMaxWidth > 0 && varMaxWidth < item.value)
   window.alert("****You cannot exceed the MAXIMUM LH WIDTH for this Product***, please amend the field value specified or select a different Product Range - also you could put a REQUEST for Quotation in the [Special Request] box and we will provide a quotation for this special case***");								        	
			        else { setLineSubItem(line, colCustomFields, iCustomField, item.value);
			               window.location.href = 'viewcart.htm';
				    }
			}
			else if (customName.substring(0,4) == "RH W") {
			        varMaxWidth = getMaxWidth(varFieldCode);				 
                    if (varMaxWidth > 0 && varMaxWidth < item.value)
   window.alert("****You cannot exceed the MAXIMUM RH WIDTH for this Product***, please amend the field value specified or select a different Product Range - also you could put a REQUEST for Quotation in the [Special Request] box and we will provide a quotation for this special case***");								        	
			        else { setLineSubItem(line, colCustomFields, iCustomField, item.value);
			               window.location.href = 'viewcart.htm';
				    }
			}
			
			else {  setLineSubItem(line, colCustomFields, iCustomField, item.value);
			              window.location.href = 'viewcart.htm';
			}		
				
	if (customName.substring(0,4) == "SECT") {
	       if (item.value != "A" && item.value != "B" && item.value != "C" && item.value != "D" && item.value != "E" && item.value != "F" && item.value != "G" && item.value != "H") 
		    alert("The only values allowed here are [A] - [H] ..... please correct");  }
  }
}
//==============================
function wardrobeError(varRWError,varSection)
{
window,alert("The Wardrobe Insert specifications for [" + varRWError + " ] is missing a SECTION code [" + varSection + "]. Please Insert a Section [" + varSection + "] or recode the other SECTIONS for that Wardrobe to make a complete sequence like: [A],[B]....[H].");
varFatalError = true;
varFieldCheck = 1;
X = 0;
Y = 0;	                
}
// =================================== 

function BypassChecking()
{
 location.replace("\category36_1.htm"); 
}
//============================
function checkSpecialCharacters(varSpecialRequest)
{
var varX = 0;
var varY = 1;
var varSRL = varSpecialRequest.length;
 for(varX = 0; varX <varSRL; varX++)
 {					
    if (varSpecialRequest.substring(varX,varY + 2) == "%3B") varSpecialRequest = replaceChar(varSpecialRequest,".",varX);
	if (varSpecialRequest.substring(varX,varY + 2) == "%2C") varSpecialRequest = replaceChar(varSpecialRequest,".",varX);
	if (varSpecialRequest.substring(varX,varY) == "-") varSpecialRequest = replaceChar(varSpecialRequest,"_",varX);
	if (varSpecialRequest.substring(varX,varY + 2) == "%3D") varSpecialRequest = replaceChar(varSpecialRequest,"EQUALS",varX);
	varY = varY + 1

  }
  return varSpecialRequest;
}

function replaceChar(varSpecialRequest,varChar,varX)
{ 
 var varSRL = varSpecialRequest.length;
 var varNew = "";
  if (varChar == "_" ) varNew = varSpecialRequest.substring(0,varX) + varChar + varSpecialRequest.substring(varX + 1,varSRL);
  else    varNew = varSpecialRequest.substring(0,varX) + varChar + varSpecialRequest.substring(varX + 3,varSRL);
// alert("4695 varX= " + varX + " varChar= " + varChar + " " + varNew); 
  varSpecialRequest = varNew;
  return varSpecialRequest;
}
// Insert "GLOSS" into Product Name - when appropriate
function insertGloss(prodname)
{
  if (prodname.indexOf("Laminate") > 0) {
    var length = prodname.length; 
    var start = prodname.indexOf("Laminate");
	var rest = prodname.substring(start + 8, length);
	var newProd = prodname.substring(0, start + 8) + " GLOSS " + rest;

    if (varProductType == "Door" && varDoorStyle1 == "GLOSS" ) prodname = newProd;
	else if (varProductType == "Kick" && varKickStyle1 == "GLOSS" )   prodname = newProd;
	else if (varProductType == "Open" && varOpenStyle1 == "GLOSS" ) prodname = newProd;
	else if (varProductType == "Pane" && varPanelStyle1 == "GLOSS" ) prodname = newProd;	
	else if (varProductType == "Kit-" && varDoorStyle1 == "GLOSS" ) prodname = newProd;
	else if (varProductType == "Hybr" && varDoorStyle1 == "GLOSS" ) prodname = newProd;
 }	
 return prodname;
}

//  ===============

