 /* 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 ast updated 12/3/2010
 * * 
 */ 
// 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 structs
var arrCookie = document.cookie.split("; ");
var arrItem;
var arrLine;
var bProcessCart = false;
/*
 * Added by hjt 2/11/2007
 */    
 
 // data structure for ZONE Delivery Costs
//
	 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 varPrice = 0;
     var varWeight = 0;

     var varDiscount = 0;
     var TradeDiscount = 0;
     var TradeDiscountNumber = 0;
     var DeliveryNumber = 0;
	 var varQuantity = 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 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 varShortCode = " ";
	 var varLengthShortCode = 2;
 	 var varConfirmation = true;
	 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;
	 	 
	 RoomWallSection = "000";
	 
	 var varRW1 = "NIL";
	 var varRW2 = "NIL";
	 var varRW3 = "NIL";
	 var varRW4 = "NIL";
	 var varRW5 = "NIL";
	 var varRW6 = "NIL";
	 var varRWError = "";
	 
	 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 varL1 = 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 varL2 = 0;  //Lenth of side 2
	 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/Profile choice - do you want to do that now?"; 
// for calculation of Proportional Cost (changing curPrice)

	 var varNewPrice = 0;
	 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 = " ";
	
// END of Variables put in by HJT
	 	  
//	 
	 var SaveCookie = false;
	 
	 if (arrCookie == null || arrCookie == "") SaveCookie = false;

	 	 
//
//   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 (varConfirmation == true) 
	{
     if (iLineIdx > 0) iLineIdx = iLineIdx - 1;
	    varCustomFieldCount = getLineSubCount(iLineIdx, colCustomFields);
		
  		if (varCustomFieldCount > 0)
		{
            for (varIndex = 0; varIndex < varCustomFieldCount; varIndex++)
            { 
			  varCustomFieldValue = getLineSubItem(iLineIdx, colCustomFields, varIndex);
			   varFirstChar = varCustomFieldValue.substring(0,1);
			   if (varFirstChar == "*") {
			       varThree = varCustomFieldValue.substring(0,3);
// This check was bypassed in May 2008  hjt				   
//			       if (varThree == "**B") {
//	               varBypass = 1;
//	               varConfirmation = false;
//	              }

				}			 
	         }	 
	    }
	 
    if (varBypass == 1) {
	  varFieldCheck = 0;
	  window.alert("Input Field checking is bypassed for this Product Specification");
	}	
   else {
  // find the 'Special requests' field in the first line item  
  	  customName = getCustomField(getProductInfo(iProdID)[colCustomFieldKeys][i-1]);
  	  varCustomFieldNameCode = getProductInfo(iProdID)[colCustomFieldKeys][i - 1];             
	  var firstChar = strFieldVal.substring(0,1);
	  if (firstChar == "?" || (strFieldVal == " " && varCustomFieldNameCode != 10 && varCustomFieldNameCode != 243)
		                   || (strFieldVal < " " && varCustomFieldNameCode != 10 && varCustomFieldNameCode != 243))								  
	  {
			      varFieldCheck = 1;
//			      varErrors = varErrors + 1;
//				  if (varErrors < 2 ) 
//				  {
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 Product Specification you MUST correctly fill in each cell value. --- To return back to the Product to fix the missing value/s click [OK] ");
//		          }
//		          if (varConfirmation == false) {
//				      varFieldCheck = 0;
//			      }
//				  else varBypass = 0;
                 return varFieldCheck;
			  }			  	
        }           	  
	
 }  
 // Now we check at the end of the normal input if there were any errors
// 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;
           }
	}
 
 // Firstly when DISCOUNT is entered
    if (varProductCode.substring(0,2) == "zz" && i == 1 ) {
		    if (varDiscountRequest == true) {
			  varFieldCheck = 1;
varConfirm=window.confirm("***You have already specified a Discount - Click [OK] to REMOVE the previous entry from the VIEWCART list, or [CANCEL] your current DISCOUNT choice and pick another Specification.");
                      if (varConfirm == true) location.replace("viewcart.htm");
			}
		    	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;
	   
       getProductStyle(iProdID);
	   varProductType = checkProductType(iProdID,varStatistics);

//  
//  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 != "WRC" && 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 != "WRC" && 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 != "WRC" && varShortCode != "cPD" && varShortCode != "cWD" && varShortCode != "cBD") {
				    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 != "WRC" && varShortCode != "cPD" && varShortCode != "cWD" && varShortCode != "cBD") {  				  
					    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, WALL or SECTION code for this Wardrobe. There is already a  Wardrobe in your Shopping Cart with the same Room Name, Wall 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/WALL specification MUST be [A] -- following Sections must be consequetively coded from the Left to Right, e.g.: [A, B, C...] or [A,C, E...]----Please amend this specification");	  	   
							varFieldCheck = 1;
			                return varFieldCheck;	   
	   }	   	   
  }
 }   
 // Check that a Wardrobe SECTION has the same Height and Depth 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;	 
     }
   }   
 
//  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 == "BTLT")
 	       varLeftSideProcessed = true ;
  else     varLeftSideProcessed = false;
 }


// Check on Unique Numbers for Benchtops
  if (varProductType == "Benc" ) {
               if ((varShortCode == "BTS" || varShortCode == "BTD") && i == 3) {
			       varBenchtopProcessed = true;
				   varNewBench = strFieldVal;
			   }
   }
   		
  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 == "Benc" ) {			
			if (varNewBench != "") {  			   			   			   
			   if (varNewBench == varBenchTop1 || varNewBench == varBenchTop2 || varNewBench == varBenchTop3 || varNewBench == varBenchTop4 || varNewBench == varBenchTop5 || varNewBench == varBenchTop6 || varNewBench == varBenchTop7 || varNewBench == varBenchTop8 || varNewBench == varBenchTop9 || varNewBench == varBenchTop10 ) 
			   {
window.alert(" Please supply a unique Bench COMPONENT Identifyer - the current Codes have already been used");
                       varNewBench = ""  ;                  
					   varFieldCheck = 1;
			           return varFieldCheck;
			   } 
			}   
     }
	
						  		   	  			  	  		  
  if ((varLongCode == "BTEL" || varLongCode == "BTLM" || varLongCode == "BTLF" || varLongCode == "BTBL" || varLongCode == "BTER" || varLongCode == "BTRM" || varLongCode == "BTRF" || varLongCode == "BTBR" ) && i == 1 ) {
		 varNewJoin = strFieldVal;				   
		 if (varNewJoin == varBenchTop1 || varNewJoin == varBenchTop2 || varNewJoin == varBenchTop3 || varNewJoin == varBenchTop4 || varNewJoin == varBenchTop5 || varNewJoin == varBenchTop6 || varNewJoin == varBenchTop7 || varNewJoin == varBenchTop8 || varNewJoin == varBenchTop9 || varNewJoin == varBenchTop10) 
			  varFieldCheck = 0;
		 else {		 
window.alert(" Error - There is no Bench Top on your 'Shopping List- see: [VIEW CART] label above' that matches the 'Unique Bench Identifyer' you selected - Please correct before trying to add this Product. ");  
		       varFieldCheck = 1;
			   return varFieldCheck;
		 }
	 if	(varLongCode == "BTEL" || varLongCode == "BTLM" || varLongCode == "BTLF" || varLongCode == "BTBL") {
	   if (varNewJoin == varLeftEnd1 || varNewJoin == varLeftEnd2 || varNewJoin == varLeftEnd3 || varNewJoin == varLeftEnd4 || varNewJoin == varLeftEnd5 || varNewJoin == varLeftEnd6 || varNewJoin == varLeftEnd7 || varNewJoin == varLeftEnd8 || varNewJoin == varLeftEnd9 || varNewJoin == varLeftEnd10) {
window.alert(" Error - This UNIQUE IDENTIFYER [" + varNewJoin + "] has already been specified earlier for a LEFT END Finish - see also: [VIEW CART] label above' - Please correct before adding this Left End Finish specification again. ");  
		       varFieldCheck = 1;
			   return varFieldCheck;
		 }
	  }	   
	 if	(varLongCode == "BTER" || varLongCode == "BTRM" || varLongCode == "BTRF" || varLongCode == "BTBR") {
	   if (varNewJoin == varRightEnd1 || varNewJoin == varRightEnd2 || varNewJoin == varRightEnd3 || varNewJoin == varRightEnd4 || varNewJoin == varRightEnd5 || varNewJoin == varRightEnd6 || varNewJoin == varRightEnd7 || varNewJoin == varRightEnd8 || varNewJoin == varRightEnd9 || varNewJoin == varRightEnd10) {
window.alert(" Error - This UNIQUE IDENTIFYER [" + varNewJoin + "] has already been specified earlier for a RIGHT END Finish - see also: [VIEW CART] label above' - Please correct before adding this Right Hand Finish specification again. ");  
		       varFieldCheck = 1;
			   return varFieldCheck;
		 }
	  }	 	   	   						  
  }  

 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 110: return 600;
case 111: return 750;
case 112: return 900;
case 113: return 1050;
case 114: return 1200;
case 115: return 1350;
case 166: return 600;
case 219: return 2150;
case 220: return 2350;
case 334: return 750;
case 343: return 1200;
case 344: return 1200;
case 352: return 500;
case 379: return 2100;
case 386: return 200;
case 388: return 400;
case 390: return 600;
case 392: return 1450;
case 393: return 1800;
case 396: return 750;
case 397: return 900;
case 398: return 1200;
case 399: return 1500;
case 400: return 1800;
case 401: return 2100;
case 402: return 2350;
case 434: return 2350;
case 435: return 2150;
case 446: return 1050;
case 466: return 600;
case 493: return 2000;
case 505: return 1000;
case 507: return 1500;
case 508: return 2000;
case 509: return 2500;
case 510: return 3000;
case 511: return 3550;
case 567: return 1200;
case 573: return 1200;
case 580: return 850;
case 583: return 900;
case 585: return 1800;
}
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 150:  return 300;
case 151:  return 400;
case 152:  return 500;
case 153:  return 600;
case 154:  return 700;
case 155:  return 800;
case 156:  return 900;
case 157:  return 1000;
case 164:  return 400;
case 202:  return 300;
case 229:  return 600;
case 233:  return 900;
case 307:  return 700;
case 311:  return 400;
case 318:  return 600;
case 350:  return 900;
case 351:  return 900;
case 382:  return 750;
case 383:  return 900;
case 384:  return 1050;
case 385:  return 1200;
case 403:  return 1000;
case 404:  return 1100;
case 405:  return 1200;
case 427:  return 500;
case 164:  return 400;
case 498:  return 400;
case 499:  return 600;
case 506:  return 900;
case 512:  return 1200;
case 513:  return 500;
case 520:  return 595;
case 521:  return 100;
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 576:  return 900;
case 577:  return 1200;
case 584:  return 600;
case 586:  return 850;
case 587:  return 850;
case 588:  return 445;
case 589:  return 445;
case 590:  return 595;
case 591:  return 595;
}
return 0;
}  
//  End of Maximum Width Custom Field Code Table
//	 
// Pricing for Shelfs depending on Width
//

function getShelfCost(varWidthTruncated)
  {
  switch(varWidthTruncated)
  {
    case 2:	return 5.00;
	case 3:	return 6.50;
	case 4:	return 7.50;
	case 5:	return 8.50;
	case 6:	return 10.00;
	case 7:	return 11.00;
	case 8:	return 12.50;
	case 9:	return 13.00;
	case 10: return 14.00;
	case 11: return 15.50; 
	case 12: return 17.00; 
	case 36: return 20.00;
	case 49: return 22.00;
	case 64: return 25.00;
	case 81: return 26.00; 
	case 100: return 28.00; 
	case 121: return 34.00;
}
return 0.00;
}  

//  Find the custom field that has 'Extra Shelf(s) required? ', if Value >0 then add cost
// of shelf(s) * (Qty to Product Price calculayed earlier 
// to calculate extra charges for extra Shelf - depending on Width
// Find the custom field that has 'Extra Shelf(s) required? ', if Value >0 then add cost
// of shelf(s) * (1+Tax rate) to Product Price calculayed earlier 
	
function extraShelfCalc(i, iProdID)
{	   
// get the posted custom fields
		extraShelfCost = 0;
	    varCustomFieldCount = getLineSubCount(i, colCustomFields);

		if (varCustomFieldCount > 0)
		{
		      varStyle = getProductStyle(iProdID);		      			  
			  varCustomFieldName = getCustomField(getProductInfo(iProdID)[colCustomFieldKeys][1]);
			  if (varCustomFieldName != null) {
    		        var shortName = varCustomFieldName.substring(0,5);
			  }
  			  else shortName = "  ";
		      varCustomFieldValue = getLineSubItem(i, colCustomFields, 1); 

              varWidth1 = parseInt(varCustomFieldValue);
		      varWidthTruncated = Math.floor((varWidth1 + 98) / 100)
			  if (shortName == "LH Wi")  //Here we deal with a Corner or Diagonal cabinet shelf
			  {
			     if (varShortCode == "BCA" || varShortCode == "WC-"  || varShortCode == "PC-" || varShortCode =="BB4" || varShortCode =="WB4" || varShortCode =="BC-" || varShortCode =="PD-") 
				 {
				   varWidthTruncated = varWidthTruncated * varWidthTruncated;
				 }
			  } 	 		  
			     shelfCost = getShelfCost(varWidthTruncated);
				 		
		         for (var varIndex = 0; varIndex < varCustomFieldCount; varIndex++)
                 {        
                   varCustomFieldName = getCustomField(getProductInfo(iProdID)[colCustomFieldKeys][varIndex]);
			       if (varCustomFieldName != null) {
			           var varFieldName = varCustomFieldName.substring(0,5);
			       }
			       else varFieldName = " ";
			           varCustomFieldValue = getLineSubItem(i, colCustomFields, varIndex);

// 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
//	  	   		
			      if (varFieldName == "Extra")
			      {		     
                       varFactor=parseInt(varPriceFactor);
				       extraShelfNumber = parseInt(varCustomFieldValue);
                       varQty = extraShelfNumber * 1;
	                   if (varShortCode == "BO-" || varShortCode == "BOA") varQty = extraShelfNumber * varFactor;
                       if (varShortCode == "WO-" || varShortCode == "WDO") varQty = extraShelfNumber * varFactor;
			           extraShelfCost = (varQty  * shelfCost);
                       break;
			       }			      
//  hang on to these three brackets
                 }               	           	  
   }	 
   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;
	// check the quantity

	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);	   	      
	   if (varDelivery == true) {
	    if (varProductType != "Disc" && varProductType != "Hand" && varProductType != "Hard" && varProductType != "Styl") {
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.  				
    	varFieldCheck = checkInput(strFieldVal, i, iLineIdx, iProdID); 				
		if (varFieldCheck == 1) {
		    return false;
		}		
// now we check if we have the last field (Special Request) so we can modify this as an
//  record that Error checking is to be bypassed for all further Data input - and also
// that ProductRange checking can be bypassed			
		
		if (varConfirmation == false && frm.elements.length - 2 == i) {
				    strFieldVal = "**Bypass input check**" + strFieldVal;
					varBypass = 1;
		}
		
		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 (varStyleStyle == varDoorStyle1 || varStyleStyle == varDoorStyle2 || varStyleStyle == varDoorStyle3) {
window.alert("You have already recorded this STYLE for Doors & Drawer fronts - please choose another Style or omit this input");
						varFieldCheck = 1;
	                    return false;
				  }
			      if (varStyleStyle == varPanelStyle1 || varStyleStyle == varPanelStyle2 || varStyleStyle == varPanelStyle3) {
window.alert("You have already recorded this STYLE for Panels - please choose another Style or omit this input");
						varFieldCheck = 1;
	                    return false;										  
				  }
			      if (varStyleStyle == varKickStyle1 || varStyleStyle == varKickStyle2 || varStyleStyle == varKickStyle3) {
window.alert("You have already recorded this STYLE for KICKBOARDS - please choose another Style or omit this input");
						varFieldCheck = 1;
	                    return false;										  
				  }
			      if (varStyleStyle == varOpenStyle1 || varStyleStyle == varOpenStyle2 || varStyleStyle == varOpenStyle3) {
window.alert("You have already recorded this STYLE for OPEN UNITS - please choose another Style or omit this input");
						varFieldCheck = 1;
	                    return false;										  
				  }				 				  
			   }
		       if (strFieldVal.substring(0,5) == "Doors") {			   
			      if (varStyleStyle == varDoorStyle1 || varStyleStyle == varDoorStyle2 || varStyleStyle == varDoorStyle3) {
window.alert("You have already recorded this STYLE for DOORS and DRAWER fronts - please choose another Style or omit this input");
						varFieldCheck = 1;
	                    return false;										  
				  }			 				  
			   }
			   			   
		       if (strFieldVal.substring(0,11) == "Panels only") {
			      if (varStyleStyle == varPanelStyle1 || varStyleStyle == varPanelStyle2 || varStyleStyle == varPanelStyle3) {
window.alert("You have already recorded this STYLE for PANELS - please choose another Style or omit this input");
						varFieldCheck = 1;
	                    return false;										  
				  }			 				  
			   }
		       if (strFieldVal.substring(0,15) == "Kickboards only") {
			      if (varStyleStyle == varKickStyle1 || varStyleStyle == varKickStyle2 || varStyleStyle == varKickStyle3) {
window.alert("You have already recorded this STYLE for KICKBOARDS - please choose another Style or omit this input");
						varFieldCheck = 1;
	                    return false;										  
				  }			 				  
			   }			   			   		   
		       if (strFieldVal.substring(0,15) == "Open Units only") {
			      if (varStyleStyle == varOpenStyle1 || varStyleStyle == varOpenStyle2 || varStyleStyle == varOpenStyle3) {
window.alert("You have already recorded this STYLE for OPEN UNITS - please choose another Style or omit this input");
						varFieldCheck = 1;
	                    return false;										  
				  }			 				  
			   }			   			   			   		   
		   }	
		}
		
		
// Process Discount 'Product' 
//
        if (iProdID == 26043 || iProdID == 26045) {
		   if (frm.elements.length - 2 == i) {
		       strFieldVal = "*D* Discount processed " + strFieldVal;
		    }	
		}
		
// Process DELIVERY 'Product' 
//
        if (iProdID == 3 && i == 3 )  strFieldVal = "*F* Freight Calculated" + strFieldVal;
		if (iProdID == 4 && i == 4 )  strFieldVal = "*F* Freight Calculated" + strFieldVal;
		
	    if (iProdID == 2 && i == 3) {
		  if (varOnLine == false) strFieldVal = "*D* Pickup Discount applied" + strFieldVal;
          if (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) 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) arrCustomField[arrCustomField.length] = strFieldVal;
					 
					 if (i == 4 && iProdID != 4) arrCustomField[arrCustomField.length] = FloorUnits;
					 if (i == 5 && iProdID != 4) arrCustomField[arrCustomField.length] = WallUnits;
					 if (i == 6 && iProdID != 4) arrCustomField[arrCustomField.length] = OpenUnits;
					 if (i == 7 && iProdID != 4) arrCustomField[arrCustomField.length] = Benchtops;
					 if (i == 8 && iProdID != 4) arrCustomField[arrCustomField.length] = Wardrobes;
					 if (i == 9 && iProdID != 4) arrCustomField[arrCustomField.length] = Panels;
					 if (i == 10 && iProdID != 4) arrCustomField[arrCustomField.length] = Kickboards;
					 if (i == 11 && iProdID != 4) arrCustomField[arrCustomField.length] = Fillers;
					 if (i == 12 && iProdID != 4) arrCustomField[arrCustomField.length] = ExtraDoors;
					 if (i == 13 && iProdID != 4) arrCustomField[arrCustomField.length] = CarcassUnits;
					 if (i == 14 && iProdID != 4) arrCustomField[arrCustomField.length] = Handles;
					 if (i == 15 && iProdID != 4) arrCustomField[arrCustomField.length] = Hardware;
					 			 					 
                     if (i == 4 && iProdID == 4) arrCustomField[arrCustomField.length] = strFieldVal;					 
					 if (i == 5 && 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;
					 
			    }
				else arrCustomField[arrCustomField.length] = strFieldVal; 
// end of current 'Modification' by hjt
//=======================================================================================================						
		}
	}
	
// add by hjt 6/12/2009
// ==============================================\
// check for Repricing 'product" it a new one is submitted and get rid of the old one	
	for(var i = 0; i <iLineIdx; i++)
	{
		if (getLineItem(i, colProductID) == iProdID && iProdID == 6)
		{
				   deleteLine(i);
				   iLineIdx = iLineIdx - 1;
				   break;  
		} 
	}	
// c=================================================================	
	for(var i = 0; i <iLineIdx; i++)
	{
		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)
	{
		// 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 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  -- 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  ===========================================================
//  checkFieldValue(iLineIdx, iProdID);    
   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)

{

 document.cookie = 'deleteme' + escape('nothing')
  if (document.cookie == "") 
  {
	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 purchasing ";
	strCart +="system requires that you have cookies enabled on your browser. </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";   //  forece 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 a ProductCode = '8 Style'  record and get its Style Description
 var lineCount = getLineCount();
 if (lineCount != 0)
 { 		
	for(var i = 0; i <lineCount; i++)
	{						
		var iProdID = parseInt(getLineItem(i, colProductID));
		varProductCode = getProductInfo(iProdID)[colProductCode]
		if (varProductCode.substring(0,7) == "8 Style") {
			varCustomFieldValues = getLineSubItem(i, colCustomFields, 1);           	
		varDataInputMode = false;
     	     if (varCustomFieldValues.substring(0,5) == "BELMO" ) varSuffix = "a"; 
	 		 if (varCustomFieldValues.substring(0,5) == "BYRON" ) varSuffix = "b";  
	 		 if (varCustomFieldValues.substring(0,5) == "ALBAN" ) varSuffix = "c";  
	 		 if (varCustomFieldValues.substring(0,5) == "AVOCA" ) varSuffix = "d";
			 if (varCustomFieldValues.substring(0,5) == "UNFIN" ) varSuffix = "e";
			 if (varCustomFieldValues.substring(0,5) == "LAMIN" ) varSuffix = "";    
	 		 if (varCustomFieldValues.substring(0,5) == "RESET" ) varSuffix = "x";  
	    }			
	}
 }
//=======================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));
//=========================Adition by hjt  November 2009 ================================== 
//  swap PID for a different Style-Price calculation
   iProdID=changeStyle(iProdID);
// ========================================================			
	
			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;
			}
	
			var curPrice = parseFloat(getProduct(iProdID)[colProductPrice]);
//
//----------------------------------------------------------------------------------
// add (insert) by hjt on 30/11/2007
//
// calculate Price for Variable Size products 

	varProductCode = getProductInfo(iProdID)[colProductCode];
	if (varProductCode.indexOf("/Y") > 0) {
	 if (varProductCode.substring(0,1) != "2")  curPrice=PriceandWeightCalc(i) ;
	}
	if (varOnLine == false && curPrice > 10.00) curPrice = CalculateProportionalDiscount(curPrice,iProdID,i,lineCount);
	        extraShelfCalc(i, iProdID);          
			curPrice = curPrice + extraShelfCost;
			extraShelfCost = 0;
			
// check on Product Types and set 'indicators' 
     checkProductType(iProdID,varStatistics)
  
// Calculate U-Shape  or L-Shape bench
     if (iProdID < 224 && iProdID > 215 )  curPrice = BenchtopParameters(i, iProdID)		 	 
			  
//calculate Freight cost and for Cab-on-Line add in Admin charge proportionally for order cost < $800 (incl GST)
             var varAdminCost = Math.round(54.545 - varCurrentOrderPrice / 727.20 * 54.545);
			 if (varAdminCost < 2) varAdminCost = 0;
			 if (varOnLine == true && varAdminCost > 0 && iProdID < 5) 
			 	alert("$" + varAdminCost + " 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 (varOnLine == true && varCurrentOrderPrice < 727.21) curPrice = curPrice + varAdminCost;  
			  }		  		
			  if (iProdID == 2) {
			      curPrice = 0;
				  curPrice = Math.round(curPrice - (varCurrentOrderPrice * 5 ) / 100);
				  if (varOnLine == true && varCurrentOrderPrice <  727.21) curPrice = curPrice + varAdminCost;					 
			  }		  			       	   
              else if (iProdID == 3) {
				    if (CalculateOrderWeight() == true) {				  	 				 
			            varLocalDeliveryCost = Math.round(varTotalWeight * 3.5) / 10;
						 if (varLocalDeliveryCost < 70.00) {
							  varLocalDeliveryCost = 70.00;
window.alert("A MINIMUM freight cost has been applied for this Order");
                          }									 								   
				     curPrice = varLocalDeliveryCost;
					 if (varOnLine == true && varCurrentOrderPrice <  727.21) curPrice = curPrice + varAdminCost;							 
				    }
			 }	  	   		  				  	
  	         else if (iProdID == 4) {
				   if (CalculateOrderWeight() == true) {
					varTotalWeight = Math.round(varTotalWeight * 1.28);
					varZone = getLineSubItem(i, colCustomFields, 2); 	   		
     			    varLongHaulCost = Math.round(CalculateLongHaul(varZone) * 100) / 100;
					if (varMinimum == true)  window.alert("A MINIMUM freight cost has been applied for this Order");
					curPrice = varLongHaulCost;
					if (varOnLine == true && varCurrentOrderPrice < 727.21) curPrice = curPrice + varAdminCost;  
	              }
    	     }  
// Calculate Discounts
       varCurrentOrderPrice = varCurrentOrderPrice + parseFloat(curPrice * fltQty);
     
     if (varProductCode.substring(0,3) == "zzD") {
			  TradeDiscount = 0;			  					 
//  calculate the Order Cost up to this point excluding any Delivery COSTS	     
//			 if (CalculateOrderWeight() == true) {
	    if ((varCurrentOrderPrice - varLocalDeliveryCost - varLongHaulCost) * 1.1 > 1199) {
		  if (iProdID == 26043)  TradeDiscount = ((varCurrentOrderPrice - varLocalDeliveryCost - varLongHaulCost) * 5 ) / 100;
		  else if (iProdID == 26045) TradeDiscount = ((varCurrentOrderPrice - varLocalDeliveryCost - varLongHaulCost) * 10 ) / 100;
//window.alert("varCurrentOrderPrice= " + varCurrentOrderPrice + " " + varLocalDeliveryCost + " " + varLongHaulCost);
		  }
				TradeDiscountNumber = TradeDiscountNumber + 1;
			 	curPrice = curPrice - TradeDiscount;		
    }
     
//
//* 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) + "\" color=\"" + ((i % 2) == 0 ? cartForegndEven : cartForegndOdd)  + "\" size=\"" + ((i % 2) == 0 ? cartFontSizeEven : cartFontSizeOdd) + "\">" + getProductInfo(iProdID)[colProductCode] + "</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) + "\">";
// change to ---curPrice--- here  hjt 2008
			strCart += "<input type=hidden name=\"prodname\" value=\"" + safeString(getProductInfo(iProdID)[colProductDesc]) + "\">";
			strCart += "<input type=hidden name=\"prodcode\" value=\"" + safeString(getProductInfo(iProdID)[colProductCode]) + "\">";

			// 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]));
					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=\"40%\" 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>"
					
					 customName = getCustomField(getProductInfo(iProdID)[colCustomFieldKeys][iCustomField]);
					 customValue = getLineSubItem(i, colCustomFields, iCustomField);
					 productCode = getProductInfo(iProdID)[colProductCode];
					 var tempvar= getLineSubItem(i, colCustomFields, iCustomField);
					      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 (tempvar.substring(0,5) == 0)  varPrompt="Amend: Number";
					 
					 else varPrompt=" ";
					 
					 if (tempvar.substring(0,1) == "n" || tempvar.substring(0,1) == "y" || tempvar.substring(0,1) == "a" | tempvar.substring(0,1) == "f" || tempvar.substring(0,1) == "r" || tempvar.substring(0,1) == "l" || tempvar.substring(0,1) == "b" || tempvar.substring(0,1) == "c" || tempvar.substring(0,1) == "d" || tempvar.substring(0,1) == "s")
					 alert("The last Edit you made was not quite correct - Please change the first character to UPPER CASE");
			       if (varURL.substring(0,9) != "View Cart" || productCode.substring(0,1) == "2" || productCode.substring(0,1) == "8" || productCode.substring(0,1) == "z" || customName.substring(0,6) == "Unique" || customName.substring(0,4) == "Room" || customName.substring(0,4) == "Wall" || customName.substring(0,4) == "SECT") {
			   
					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) + "\">" + getLineSubItem(i, colCustomFields, iCustomField) + "</font></td>";
   			      } else {
						
						if (customName.substring(0,16) == "Special requests") 
 						  strCart += "<td align=\"left\"><input type=text size=80 name=\"newInput\" value=\"" + getLineSubItem(i, colCustomFields, iCustomField) +  "\" onblur=\"editCart(" + i + ", this, '" + colCustomFields + "', '" + iCustomField + "' ,'" + productCode + "', '" + customName + "','" + customValue + "');\" onkeypress=\"if (event.which == 0 || event.keyCode == 13) editCart(" + i + ", this);\"></td>" ;
                         else {
						  
						  				   		
  	                     strCart += "<td width=\"5%\" align=\"left\"><input type=text size=15 name=\"newInput\" value=\"" + tempvar + "\" onblur=\"editCart(" + i + ", this, '" + colCustomFields + "', '" + iCustomField + "' ,'" + productCode + "', '" + customName + "','" + customValue + "');\" onkeypress=\"if (event.which == 0 || event.keyCode == 13) editCart(" + i + ", this) ;\"> " ;
                          strCart += "</td>";
						  strCart += "<td width=\"35%\" align=\"left\">";
						  strCart += varPrompt;		 
						 
						 strCart += "</td>";
//						 	alert(item.value + " " + productCode + " " + customName + " " + customValue);
						}		
 				  }				      
			    }			
//				
//"\" 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.

		
  if (varURL.substring(0,9) == "View Cart") {
  
        strCart += "<br><font color='green' size=4>When all products and Corrections, Discount / 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>";
		
//		strCart += "<br><font color='blue' size='2'>After Advice that your Shopping List has been correctly validated - </font> <a href=\"#\" // onclick=\"CheckoutMessage()\"><img src=\"" + imagepath + "/cartcheckout.gif\" border=\"0\"></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>";
    }
 }   
// end of modifications by HJT 30/1/2008 ----------------------------------------------------------
		strCart += "</td></tr>";
	}
	strCart += "</table>";
	strCart += "<input type=hidden name=\"requestedaction\" value=\"CreateNewOrder\">";
return strCart;
}

/* formatCurrency(curSymbol, thousandsSeparator, decPlaces, decSeparator,  truncateDec, blnSymbolAtFront, curValue)
 *
 * takes a currency value and decorates it with currency formatting
 *
 * input -
 * 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);
	}
	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);
	}

	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()
{
	var arrItemTmp = new Array(arrItem.length);
	
// change Cookie storage to 14 days
// hjt 10/4/2008
	  	 var dtExpiry = new Date();
		 dtExpiry.setDate(dtExpiry.getDate() + 14);	

// end replace the once line "document.cookie = strLines

	var strItems;
	for(var i = 0; i <arrItem.length; i++)
	{
		arrItemTmp[i] = arrItem[i].join("=");
	}
	strItems = "items=" + arrItemTmp.join("&");

	document.cookie = strItems + "; expires=" + dtExpiry.toGMTString() + ";";

	return true;
}

function private_UpdateLines()
{
	var strLines;

	var arrLineTmp = new Array(arrLine.length);
	
	for(var i = 0; i <arrLine.length; i++)
	{
		arrLineTmp[i] = arrLine[i].join("&");
	}
	strLines = "lines=" + arrLineTmp.join("#");

	if (strLines.length > 4096) return false;
// change Cookie storage to 14 days
// hjt 29/3/2008
	  	 var dtExpiry = new Date();
		 dtExpiry.setDate(dtExpiry.getDate() + 14);	

		document.cookie = strLines + "; expires=" + dtExpiry.toGMTString() + ";";
// end replace the once line "document.cookie = strLines

	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()
{
	if (arrCookie == null || arrCookie == "")
	{
		arrCookie = new Array(0);
	}
	for(var i = 0; i <arrCookie.length; i++)
	{
		if (arrCookie[i].substr(0, 5) == "items")
		{
			arrItem = arrCookie[i].substr(6, arrCookie[i].length - 6).split("&");
		}
		if (arrCookie[i].substr(0, 5) == "lines")
		{
			arrLine = arrCookie[i].substr(6, arrCookie[i].length - 6).split("#");
		}
	}
	if (arrItem == null || arrItem == "")
	{
		arrItem = new Array(0);
	}
	for(var i = 0; i <arrItem.length; i++)
	{
		arrItem[i] = arrItem[i].split("=");
	}
	if (arrLine == null || arrLine == "")
	{
		arrLine = new Array(0);
	}
	for(var i = 0; i <arrLine.length; i++)
	{
		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;
}


private_CartLoad();

// 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;
	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;	 
 varRW1 = "NIL";
 varRW2 = "NIL";
 varRW3 = "NIL";
 varRW4 = "NIL";
 varRW5 = "NIL";
 varRW6 = "NIL";
 varRWError = "";
	  
	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.	 	 
    varL1 = 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"; 
	varStyleSpec = false;
	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!!!!
     iProdID=changeStyle(iProdID);
// ========================================================		

//        getProductStyle(iProdID);
//	   varProductType = checkProductType(iProdID,varStatistics);
 			checkStyleInput(i, iProdID);
								
            var iCustomFieldCount = getLineSubCount(i, colCustomFields); 	        
			if (iCustomFieldCount > 0)  {						
	          for(var iCustomField = 0; iCustomField <iCustomFieldCount; iCustomField++)
	          {
			  var varCustomFieldValue = getLineSubItem(i, colCustomFields, iCustomField);
					
			   varFirstChar = varCustomFieldValue.substring(0,1);
			   if (varFirstChar == "*") {
			       varThree = varCustomFieldValue.substring(0,3);
			       if (varThree == "**B") {   // this means the Customer swithched off Input Validation
				       varErrorType = 1;
	                }
				  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;
				  }
			   }	  
			  }
			}

    }
 }

// now we collect data on actual Product items
 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 if the Customer has clicked the right button This function is called in 4 places NOT USED on INPUT
   iProdID=changeStyle(iProdID);
// ========================================================		
		iQty = parseFloat(getLineItem(i, colQuantity));
		varPrice = parseFloat(getProduct(iProdID)[colProductPrice]);
		varWeight = parseFloat(getProduct(iProdID)[colProductWeight]);
			
// check that any previous Product ordered still conforms to the Style specifications
       varProdStyle = getProductStyle(iProdID);
   
	   varProductType = checkProductType(iProdID,varStatistics);	   
	   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);  
							    if (varWardRobe1 == "000") 	{ 
								    varWardRobe1 = varPosition;
									varWardRobeHeight1 = varWRHeight;
									varWardRobeDepth1 = varWRDepth;
								}							
								else if (varWardRobe2 == "000") {
									varWardRobe2 = varPosition;
									varWardRobeHeight2 = varWRHeight;
									varWardRobeDepth2 = varWRDepth;
								}
							  	else if (varWardRobe3 == "000") {
									varWardRobe3 = varPosition;
									varWardRobeHeight3 = varWRHeight;
									varWardRobeDepth3 = varWRDepth;
								}
							    else if (varWardRobe4 == "000") {
									varWardRobe4 = varPosition;
									varWardRobeHeight4 = varWRHeight;
									varWardRobeDepth4 = varWRDepth;
								}
							    else if (varWardRobe5 == "000") {
									varWardRobe5 = varPosition;
									varWardRobeHeight5 = varWRHeight;
									varWardRobeDepth5 = varWRDepth;
								}
								else if (varWardRobe6 == "000") {
									varWardRobe6 = varPosition;
									varWardRobeHeight6 = varWRHeight;
									varWardRobeDepth6 = varWRDepth;
								}
								else if (varWardRobe7 == "000") {
									varWardRobe7 = varPosition;
									varWardRobeHeight7 = varWRHeight;
									varWardRobeDepth7 = varWRDepth;
								}
								else if (varWardRobe8 == "000") {
									varWardRobe8 = varPosition;
									varWardRobeHeight8 = varWRHeight;
									varWardRobeDepth8 = varWRDepth;
								}
								else if (varWardRobe9 == "000") {
									varWardRobe9 = varPosition;
									varWardRobeHeight9 = varWRHeight;
									varWardRobeDepth9 = varWRDepth;
								}
								else if (varWardRobe10 == "000") {
									varWardRobe10 = varPosition;
									varWardRobeHeight10 = varWRHeight;
									varWardRobeDepth10 = varWRDepth;
								}
								else if (varWardRobe11 == "000") {
									varWardRobe11 = varPosition;
									varWardRobeHeight11 = varWRHeight;
									varWardRobeDepth11 = varWRDepth;
								}
								else if (varWardRobe12 == "000") {
									varWardRobe12 = varPosition;
									varWardRobeHeight12 = varWRHeight;
									varWardRobeDepth12 = varWRDepth;
								}
								else if (varWardRobe13 == "000") {
									varWardRobe13 = varPosition;
									varWardRobeHeight13 = varWRHeight;
									varWardRobeDepth13 = varWRDepth;
								}
								else if (varWardRobe14 == "000") {
									varWardRobe14 = varPosition;
									varWardRobeHeight14 = varWRHeight;
									varWardRobeDepth14 = varWRDepth;
								}
							  	else if (varWardRobe15 == "000") {
									varWardRobe15 = varPosition;
									varWardRobeHeight15 = varWRHeight;
									varWardRobeDepth15 = varWRDepth;
								}
							    else if (varWardRobe16 == "000") {
									varWardRobe16 = varPosition;
									varWardRobeHeight16 = varWRHeight;
									varWardRobeDepth16 = varWRDepth;
								}
							    else if (varWardRobe17 == "000") {
									varWardRobe17 = varPosition;
									varWardRobeHeight17 = varWRHeight;
									varWardRobeDepth17 = varWRDepth;
								}
								else if (varWardRobe18 == "000") {
									varWardRobe18 = varPosition;
									varWardRobeHeight18 = varWRHeight;
									varWardRobeDepth18 = varWRDepth;
								}
								else if (varWardRobe19 == "000") {
									varWardRobe19 = varPosition;
									varWardRobeHeight19 = varWRHeight;
									varWardRobeDepth19 = varWRDepth;
								}
								else if (varWardRobe20 == "000") {
									varWardRobe20 = varPosition;
									varWardRobeHeight20 = varWRHeight;
									varWardRobeDepth20 = varWRDepth;
								}
								else if (varWardRobe21 == "000") {
									varWardRobe21 = varPosition;
									varWardRobeHeight21 = varWRHeight;
									varWardRobeDepth21 = varWRDepth;
								}
								else if (varWardRobe22 == "000") {
									varWardRobe22 = varPosition;
									varWardRobeHeight22 = varWRHeight;
									varWardRobeDepth22 = varWRDepth;
								}
								else if (varWardRobe23 == "000") {
									varWardRobe23 = varPosition;
									varWardRobeHeight23 = varWRHeight;
									varWardRobeDepth23 = varWRDepth;
								}
								else if (varWardRobe24 == "000") {
									varWardRobe24 = varPosition;
									varWardRobeHeight24 = varWRHeight;
									varWardRobeDepth24 = varWRDepth;
								}																
								
// window.alert("Height= " + varWRHeight + " Depth= " + varWRDepth);																					            
							}
					 }
				   }	 
					 
			    }
			  }
				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); 			
	          for(var iCustomField = 0; iCustomField <iCustomFieldCount; iCustomField++)
	          {
			   varCustomFieldValues = getLineSubItem(i, colCustomFields, iCustomField);			   
				  if ((varShortCode == "BTS" || varShortCode == "BTD") && iCustomField == 2) {
				     if (varCustomFieldValues == "A") varBenchTop1 = "A";
					 else if (varCustomFieldValues == "B") varBenchTop2 = "B";
					 else if (varCustomFieldValues == "C") varBenchTop3 = "C";
					 else if (varCustomFieldValues == "D") varBenchTop4 = "D";
					 else if (varCustomFieldValues == "E") varBenchTop5 = "E";
					 else if (varCustomFieldValues == "F") varBenchTop6 = "F";					 
					 else if (varCustomFieldValues == "G") varBenchTop7 = "G";
					 else if (varCustomFieldValues == "H") varBenchTop8 = "H";
					 else if (varCustomFieldValues == "I") varBenchTop9 = "I";				 
					 else if (varCustomFieldValues == "J") varBenchTop10 = "J";
			      }
//window.alert("i= " + i + " iCustomField= " + iCustomField + " varCustomFieldValues= " + varCustomFieldValues + " varBenchTop1= " + varBenchTop1);				  
				  
				  if (iProdID > 215 && iProdID < 220 ) {
				     if (iCustomField == 6 && varCustomFieldValues == "A") varBenchTop1 = "A";
					 else if (iCustomField == 6 && varCustomFieldValues == "B") varBenchTop2 = "B";
					 else if (iCustomField == 6 && varCustomFieldValues == "C") varBenchTop3 = "C";
					 else if (iCustomField == 6 && varCustomFieldValues == "D") varBenchTop4 = "D";				  
					 else if (iCustomField == 6 && varCustomFieldValues == "C") varBenchTop5 = "E";
					 else if (iCustomField == 6 && varCustomFieldValues == "C") varBenchTop6 = "F";
					 else if (iCustomField == 6 && varCustomFieldValues == "C") varBenchTop7 = "G";
					 else if (iCustomField == 6 && varCustomFieldValues == "C") varBenchTop8 = "H";
					 else if (iCustomField == 6 && varCustomFieldValues == "C") varBenchTop9 = "I";
					 else if (iCustomField == 6 && varCustomFieldValues == "C") varBenchTop10 = "J";				  				  	
         		  } 
				  if (iProdID == 220)  {
				     if (iCustomField == 9 && varCustomFieldValues == "A") varBenchTop1 = "A";
					 else if (iCustomField == 9 && varCustomFieldValues == "B") varBenchTop2 = "B";
					 else if (iCustomField == 9 && varCustomFieldValues == "C") varBenchTop3 = "C";
					 else if (iCustomField == 9 && varCustomFieldValues == "D") varBenchTop4 = "D";				  
					 else if (iCustomField == 9 && varCustomFieldValues == "E") varBenchTop5 = "E";
					 else if (iCustomField == 9 && varCustomFieldValues == "F") varBenchTop6 = "F";				  
					 else if (iCustomField == 9 && varCustomFieldValues == "G") varBenchTop7 = "G";
					 else if (iCustomField == 9 && varCustomFieldValues == "H") varBenchTop8 = "H";
					 else if (iCustomField == 9 && varCustomFieldValues == "I") varBenchTop9 = "I";
					 else if (iCustomField == 9 && varCustomFieldValues == "J") varBenchTop10 = "J";				  				  	
        		  } 
				  if (iProdID == 221 || iProdID == 222 || iProdID == 223) {
				     if (iCustomField == 8 && varCustomFieldValues == "A") varBenchTop1 = "A";
					 else if (iCustomField == 8 && varCustomFieldValues == "B") varBenchTop2 = "B";
					 else if (iCustomField == 8 && varCustomFieldValues == "C") varBenchTop3 = "C";
					 else if (iCustomField == 8 && varCustomFieldValues == "D") varBenchTop4 = "D";				  
					 else if (iCustomField == 8 && varCustomFieldValues == "E") varBenchTop5 = "E";
					 else if (iCustomField == 8 && varCustomFieldValues == "F") varBenchTop6 = "F";				  
					 else if (iCustomField == 8 && varCustomFieldValues == "G") varBenchTop7 = "G";
					 else if (iCustomField == 8 && varCustomFieldValues == "H") varBenchTop8 = "H";
					 else if (iCustomField == 8 && varCustomFieldValues == "I") varBenchTop9 = "I";
					 else if (iCustomField == 8 && varCustomFieldValues == "J") varBenchTop10 = "J";				  				  	
        		  } 
				  if (varLongCode == "BTEL" || varLongCode == "BTLM" || varLongCode == "BTLF" || varLongCode == "BTBL") {
				     if (iCustomField == 0 	    && varCustomFieldValues == "A") varLeftEnd1 = "A";
					 else if (iCustomField == 0 && varCustomFieldValues == "B") varLeftEnd2 = "B";
					 else if (iCustomField == 0 && varCustomFieldValues == "C") varLeftEnd3 = "C";
					 else if (iCustomField == 0 && varCustomFieldValues == "D") varLeftEnd4 = "D";				  
					 else if (iCustomField == 0 && varCustomFieldValues == "E") varLeftEnd5 = "E";
					 else if (iCustomField == 0 && varCustomFieldValues == "F") varLeftEnd6 = "F";				  
					 else if (iCustomField == 0 && varCustomFieldValues == "G") varLeftEnd7 = "G";
					 else if (iCustomField == 0 && varCustomFieldValues == "H") varLeftEnd8 = "H";
					 else if (iCustomField == 0 && varCustomFieldValues == "I") varLeftEnd9 = "I";
					 else if (iCustomField == 0 && varCustomFieldValues == "J") varLeftEnd10 = "J";				  				  	
        		  } 
				  if (varLongCode == "BTER" || varLongCode == "BTRM" || varLongCode == "BTRF" || varLongCode == "BTBR") {
				     if (iCustomField == 0 	    && varCustomFieldValues == "A") varRightEnd1 = "A";
					 else if (iCustomField == 0 && varCustomFieldValues == "B") varRightEnd2 = "B";
					 else if (iCustomField == 0 && varCustomFieldValues == "C") varRightEnd3 = "C";
					 else if (iCustomField == 0 && varCustomFieldValues == "D") varRightEnd4 = "D";				  
					 else if (iCustomField == 0 && varCustomFieldValues == "E") varRightEnd5 = "E";
					 else if (iCustomField == 0 && varCustomFieldValues == "F") varRightEnd6 = "F";				  
					 else if (iCustomField == 0 && varCustomFieldValues == "G") varRightEnd7 = "G";
					 else if (iCustomField == 0 && varCustomFieldValues == "H") varRightEnd8 = "H";
					 else if (iCustomField == 0 && varCustomFieldValues == "I") varRightEnd9 = "I";
					 else if (iCustomField == 0 && varCustomFieldValues == "J") varRightEnd10 = "J";				  				  	
        		  } 			 			 			 				 				 
			 }
// 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;
	varPrice = 0;
	varWeight = 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));
//=========================Adition by hjt  November 2009 ================================== 
//  swap PID for a different Style-Price calculation if the Customer has clicked the right button
   iProdID=changeStyle(iProdID);
// ========================================================			
							
			iQty = parseFloat(getLineItem(i, colQuantity));
			varPrice = parseFloat(getProduct(iProdID)[colProductPrice]);
			varWeight = parseFloat(getProduct(iProdID)[colProductWeight]);
			varQuantity = iQty			
			varProductType = checkProductType(iProdID,varStatistics);
			varProductCode = getProductInfo(iProdID)[colProductCode];
	         if (varProductCode.indexOf("/Y") > 0) {	
	            varPrice = PriceandWeightCalc(i) ;
             }
        			
//            extraShelfCalc(i, iProdID);    
//			varPrice = varPrice + extraShelfCost;
						
//			varOrderCost = varOrderCost + (varPrice  * iQty);
			varTotalWeight = Math.round(varTotalWeight + (varWeight * iQty));

//  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++)
	          {
//		       varCustomFieldNames = getCustomField(getProductInfo(iProdID)[colCustomFieldKeys][iCustomField]);
//		       varFieldName = varCustomFieldNames.substring(0,5);

			   varCustomFieldValues = parseInt(getLineSubItem(i, colCustomFields, iCustomField));
              if (varProductType == "Kit-" || varProductType == "Door" || varProductType == "Pane" || varProductType == "Open" || varProductType == "Kick" || varProductType == "Hybr") {
			    if (iCustomField <= 2) {				  
				     if (varCustomFieldValues > varTotalLength) varTotalLength = varCustomFieldValues;
				}
			   }
			   	
	           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;
					   }
			   } 			   			   			   
//
			  }
			 }
			 							       													
          }
// add in the Benchtop weight
   
	  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= " + varLongHaulCost + " varSubsidyRate= " + varSubsidyRate);
   varLongHaulCost = Math.round(varLongHaulCost - varSubsidyRate);
  }

 if (varLongHaulCost < 85.00) {
             varLongHaulCost = 85.00;
			 varMinimum = true;
 }
  
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)
 {
    varProductCode = getProductInfo(iProdID)[colProductCode];
	varShortCode = varProductCode.substring(0,3);
	varProdName = getProductInfo(iProdID)[colProductDesc];
			  
			  varStyle = varProdName.indexOf("Melamine");			  
			  if (varStyle > 0) {
				 varProdStyle = "Lamin";
				 varPriceFactor = 1;
			  }
			  else  {
				  varStyle = varProdName.indexOf("Belmo");
				  if (varStyle > 0) {
				   varProdStyle = "Belmo";
				   varPriceFactor = 2;
			      }			     
                  else  {
					 varStyle = varProdName.indexOf("Byron");
				     if (varStyle > 0) {
					   varProdStyle = "Byron";
				       varPriceFactor = 4;
			         }
					 else  {
				        varStyle = varProdName.indexOf("Alban");
				        if (varStyle > 0) {
					      varProdStyle = "Alban";
				          varPriceFactor = 4;
			            }						
					    else  {
				              varStyle = varProdName.indexOf("Avoca");
				              if (varStyle > 0) {
					            varProdStyle = "Avoca";
				                varPriceFactor = 7;
			                  }				  
					          else  {
				                    varStyle = varProdName.indexOf("Unfinished");
				                    if (varStyle > 0) {
					                   varProdStyle = "Unfin";
				                       varPriceFactor = 1;
								   }
								   else  {
				                    varStyle = varProdName.indexOf("HMR W");
				                    if (varStyle > 0) {
					                   varProdStyle = "Carca";
				                       varPriceFactor = 1;
								   }								  							  
							       else  {
						                varProdStyle = "Lamin";
				                        varPriceFactor = 1;
                                   }
								 }
							 }
                        }
                     }
                  }
				}
//	if (varProductCode(0,1) == "1" || varProductCode(0,1) == "2") varProdStyle = "Styl";									  					                			
	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 (varOpenStyle1 == "Nil") varOpenStyle1 = varProdCode;
				 else if (varOpenStyle2 == "Nil" && varProdCode != varOpenStyle1) varOpenStyle2 = varProdCode;
				 else if (varOpenStyle3 == "Nil" && varProdCode != varOpenStyle1 && varProdCode != varOpenStyle2) varOpenStyle3 = 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,15) == "Open Units only") {
				 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)
{

// 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"   // Hybrid type Like Wardrobe, but no Room/Wall?Section
	  }
	  else {
	     if (varProductCode.substring(0,4) == "Kick") {
		    varProductType = "Kick";
		    varKickboard = true;
			if(varStatistics == true) Kickboards = Kickboards + varQuantity;
			getProductStyle(iProdID);
			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;
			   getProductStyle(iProdID);
				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);
				 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);
									 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")
					   {
					       varProductType = "Styl";
                           varStyle = true;
						   if (varProductCode.substring(0,1) < "3") varStyleSpec = true;
						   if (varProductCode.substring(0,1) == "3") varBenchtopStyle = true;
					   }
					   else {
					    if (varProductCode.substring(0,2) == "zz") {
						    varProductType = "Disc";
//						    varDiscountRequest = true;
							varStyleSpec = true;
						}
						else {
						  if (varProductCode.substring(0,2) == "zP" || varProductCode.substring(0,2) == "zD") {
						      varProductType = "Deli";
							  varStyleSpec = true;
//						      varDelivery = true;
						  }
						  
						  else {
	     						if (varProductCode.substring(0,4) == "Fill") {
		                          varProductType = "Pane";
		                          varFiller = true;
								  getProductStyle(iProdID);
									 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) Fillers = Fillers + varQuantity;
		                        }
						  
				                else {
						             varProductType = "Kit-";
								     varCabinet = true;        // check for WallUnits  now but excluding OpenUnits
									 getProductStyle(iProdID);
									 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;
										
// window.alert("line 3009 - ProductDoorStyle1= " + ProductDoorStyle1 + " ProductDoorStyle2= " + ProductDoorStyle2 + " ProductDoorStyle3= " + ProductDoorStyle3 + " ProductKickStyle1= " + ProductKickStyle1);
										
										
									 }
						             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
  return varProductType;
}



// Checking of Total Order after pressing "CheckShoppingList" 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;
  }
// On request I have bypassed the REJECTION MODE for Unchecked order items - they are now processed  
//  if (varErrorType == 1) {
//     window.alert("You elected to BYPASS Input Data VALIDATION for some or all Products and this List of Items can not be processed through the [CHECKOUT] - to make a Valid Order please [REMOVE] the items marked as *Bypassed Input validation**");
//      return; 
//  }
  
//  if (varErrorType == 2) {
//    window.alert("TBA");
//	 return;  
//  }

// window.alert("BypassCheckProductRange= " + BypassCheckProductRange + " varStyleSpec = " + varStyleSpec + " varCabinet = " + varCabinet + " varOrderCost= " + varOrderCost );
  	 
// if (BypassCheckProductRange == false) {
			  	 	 
//Check WardRobes that each unique ROOM/WALL  has one Section [A]
  checkA(varWardRobe1);
  checkA(varWardRobe2);
  checkA(varWardRobe3);
  checkA(varWardRobe4);
  checkA(varWardRobe5);
  checkA(varWardRobe6);
  checkA(varWardRobe7);
  checkA(varWardRobe8);
  checkA(varWardRobe9);
  checkA(varWardRobe10);
  checkA(varWardRobe11);
  checkA(varWardRobe12);
 							 
//window.alert("line 3167 varRW1 = " + varRW1 + " varRW2= " + varRW2 + " varRW3= " + varRW3 + " varRW4= " + varRW4 + " varRW5= " + varRW5 + " varRW6= " + varRW6);
								   
if (varRW1 != "NIL" && varRW1.substring(12,13) != "A") varRWError = varRW1.substring(0,12);
if (varRW2 != "NIL" && varRW2.substring(12,13) != "A") varRWError = varRW2.substring(0,12);
if (varRW3 != "NIL" && varRW3.substring(12,13) != "A") varRWError = varRW3.substring(0,12);
if (varRW4 != "NIL" && varRW4.substring(12,13) != "A") varRWError = varRW4.substring(0,12);
if (varRW5 != "NIL" && varRW5.substring(12,13) != "A") varRWError = varRW5.substring(0,12);
if (varRW6 != "NIL" && varRW6.substring(12,13) != "A") varRWError = varRW6.substring(0,12);

if (varRWError > " ") {
window,alert("The Wardrobe Insert specifications for " + varRWError + "  should have started with the Left most SECTION being coded with an [A], but there is no [A] section recorded. Please Insert an [A] Section  for this location, even if you have to [REMOVE] an existing Section");
varFatalError = true;
}


        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;               	
              }			  			  			  			  			  	
  			  
			  	
//    checkProductRange()

     if (varBenchtop == true && varBenchtopStyle == false ) {
      varConfirm=window.confirm("You have not yet specified your Bench top Laminate Brand and Colour.----Click [OK] to to go to the 'Benchtop LAMINATE' page to specify or [CANCEL] to ignore this message for the time being and continue");
	    if (varConfirm == true) {
	      varFieldCheck = 1;
		  if (varOnLine == true) location.replace("category32_1.htm");
	      if (varOnLine == false) location.replace("category406_1.htm");		 return;
	    }
	  }	
 
     if (varStyleSpec == false && varCabinet == true ) {
	     if (varPanel == false) {
varConfirm=window.confirm("You did not order any End (or SIDE) PANELS (see SINGLE PARTS ) - this may be an oversight or intentional.----Click [OK] to to go to the Panels page to order some or [CANCEL] to ignore this message and continue");
	    if (varConfirm == true) {
	      varFieldCheck = 1;
	     location.replace("category1005432_1.htm");
		 return;
	    }
	  }	
	}
	  
    if (varStyleSpec == false && varCabinet == true ) {
		  if (varKickboard == false) {
varConfirm=window.confirm("You did not order any KICKBOARDS (see SINGLE PARTS) - this may be an oversight or intentional. ---- Click [OK] to to go to the Panels page to order some or [CANCEL] to ignore this message and continue");	
	        if (varConfirm == true) {
	            varFieldCheck = 1; 
	            location.replace("category1002111_1.htm");
		        return;
	        }
         }
	}

//window.alert("line 3290 varCabinets= " + varCabinet + "varPanel= " + varPanel);

			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("3304 Check on Product Styles - ProductDoorStyle1= " + ProductDoorStyle1 + " ProductDoorStyle2= " + ProductDoorStyle2 + " ProductDoorStyle3= " + ProductDoorStyle3 + " ProductKickStyle1= " + ProductKickStyle1 + " varDoorStyles= " + varDoorStyle1 + " " + varDoorStyle2 + " varKickStyle1= " + varKickStyle1 + " varKickStyle2= " + varKickStyle2);

// Check on Match of ProductStyles to Style Records
      if (ProductDoorStyle1 != "Nil" && (ProductDoorStyle1 != varDoorStyle1 && ProductDoorStyle1 != varDoorStyle2 && ProductDoorStyle1 != varDoorStyle3)) {
	 varFullProductStyle = transformProductStyle(ProductDoorStyle1);
varConfirm=window.confirm("You have listed one or more products with DOORS or DRAWER FRONTS in the " + varFullProductStyle + varDescription1);
				 if (varConfirm == true) { 
	                 varFieldCheck = 1;
	                 location.replace("category259_1.htm");
		             return;
	             }
				 varFatalError = true;
     }
	
     if (ProductDoorStyle2 != "Nil" && (ProductDoorStyle2 != varDoorStyle1 && ProductDoorStyle2 != varDoorStyle2 && ProductDoorStyle2 != varDoorStyle3)) {
	  varFullProductStyle = transformProductStyle(ProductDoorStyle2);
varConfirm=window.confirm("You have listed another product with DOORS or DRAWER FRONTS in the " +varFullProductStyle + varDescription1);
				 if (varConfirm == true) { 
	                 varFieldCheck = 1;
	                 location.replace("category259_1.htm");
		             return;
	             }
				 varFatalError = true;
    }  
     
	 if (ProductDoorStyle3 != "Nil" && (ProductDoorStyle3 != varDoorStyle1 && ProductDoorStyle3 != varDoorStyle2 && ProductDoorStyle3 != varDoorStyle3)) {
	 	  varFullProductStyle = transformProductStyle(ProductDoorStyle3);
varConfirm=window.confirm("You have listed one or more products with DOORS or DRAWER FRONTS in the " + varFullProductStyle + varDescription1);
 				 if (varConfirm == true) { 
	                 varFieldCheck = 1;
	                 location.replace("category259_1.htm");
		             return;
	             }
				 varFatalError = true;
     }                 	  		   		                  	  

      if (ProductPanelStyle1 != "Nil" && (ProductPanelStyle1 != varPanelStyle1 && ProductPanelStyle1 != varPanelStyle2 && ProductPanelStyle1 != varPanelStyle3)) {
	 varFullProductStyle = transformProductStyle(ProductPanelStyle1);
varConfirm=window.confirm("You have listed one or more PANELS in the " + varFullProductStyle + varDescription1);
				 if (varConfirm == true) { 
	                 varFieldCheck = 1;
	                 location.replace("category259_1.htm");
		             return;
	             }
				 varFatalError = true;
     }
	
     if (ProductPanelStyle2 != "Nil" && (ProductPanelStyle2 != varPanelStyle1 && ProductPanelStyle2 != varPanelStyle2 && ProductPanelStyle2 != varPanelStyle3)) {
	  varFullProductStyle = transformProductStyle(ProductPanelStyle2);
varConfirm=window.confirm("You have listed one or more PANELS in the " + varFullProductStyle + varDescription1);
				 if (varConfirm == true) { 
	                 varFieldCheck = 1;
	                 location.replace("category259_1.htm");
		             return;
	             }
				 varFatalError = true;
    }  
     
	 if (ProductPanelStyle3 != "Nil" && (ProductPanelStyle3 != varPanelStyle1 && ProductPanelStyle3 != varPanelStyle2 && ProductPanelStyle3 != varPanelStyle3)) {
	 	  varFullProductStyle = transformProductStyle(ProductPanelStyle3);
varConfirm=window.confirm("You have listed one or more PANELS in the " + varFullProductStyle + varDescription1);
 				 if (varConfirm == true) { 
	                 varFieldCheck = 1;
	                 location.replace("category259_1.htm");
		             return;
	             }
				 varFatalError = true;
     }                 	 
	
     if (ProductKickStyle1 != "Nil" && (ProductKickStyle1 != varKickStyle1 && ProductKickStyle1 != varKickStyle2 && ProductKickStyle1 != varKickStyle3)) {
	 varFullProductStyle = transformProductStyle(ProductKickStyle1);
varConfirm=window.confirm("You have listed one or more KICKBOARDS in the " + varFullProductStyle + varDescription1);
				 if (varConfirm == true) { 
	                 varFieldCheck = 1;
	                 location.replace("category259_1.htm");
		             return;
	             }
				 varFatalError = true;
     }
	
     if (ProductKickStyle2 != "Nil" && (ProductKickStyle2 != varKickStyle1 && ProductKickStyle2 != varKickStyle2 && ProductKickStyle2 != varKickStyle3)) {
	  varFullProductStyle = transformProductStyle(ProductKickStyle2);
varConfirm=window.confirm("You have listed one or more KICKBOARDS in the " + varFullProductStyle + varDescription1);
				 if (varConfirm == true) { 
	                 varFieldCheck = 1;
	                 location.replace("category259_1.htm");
		             return;
	             }
				 varFatalError = true;
    }  
     
	 if (ProductKickStyle3 != "Nil" && (ProductKickStyle3 != varKickStyle1 && ProductKickStyle3 != varKickStyle2 && ProductKickStyle3 != varKickStyle3)) {
	 	  varFullProductStyle = transformProductStyle(ProductKickStyle3);
varConfirm=window.confirm("You have listed one or more KICKBOARDS in the " + varFullProductStyle + varDescription1);
 				 if (varConfirm == true) { 
	                 varFieldCheck = 1;
	                 location.replace("category259_1.htm");
		             return;
	             }
				 varFatalError = true;
     }                 	 
				
		
     if (ProductOpenStyle1 != "Nil" && (ProductOpenStyle1 != varOpenStyle1 && ProductOpenStyle1 != varOpenStyle2 && ProductOpenStyle1 != varOpenStyle3)) {
	 varFullProductStyle = transformProductStyle(ProductOpenStyle1);
varConfirm=window.confirm("You have listed one or more OPEN UNITS in the " + varFullProductStyle + varDescription1);
				 if (varConfirm == true) { 
	                 varFieldCheck = 1;
	                 location.replace("category259_1.htm");
		             return;
	             }
				 varFatalError = true;
     }
	
     if (ProductOpenStyle2 != "Nil" && (ProductOpenStyle2 != varOpenStyle1 && ProductOpenStyle2 != varOpenStyle2 && ProductOpenStyle2 != varOpenStyle3)) {
	  varFullProductStyle = transformProductStyle(ProductOpenStyle2);
varConfirm=window.confirm("You have listed one or more OPEN UNITS in the " + varFullProductStyle + varDescription1);
				 if (varConfirm == true) { 
	                 varFieldCheck = 1;
	                 location.replace("category259_1.htm");
		             return;
	             }
				 varFatalError = true;
    }  
     
	 if (ProductOpenStyle3 != "Nil" && (ProductOpenStyle3 != varOpenStyle1 && ProductOpenStyle3 != varOpenStyle2 && ProductOpenStyle3 != varOpenStyle3)) {
	 	  varFullProductStyle = transformProductStyle(ProductOpenStyle3);
varConfirm=window.confirm("You have listed one or more OPEN UNITS in the " + varFullProductStyle + varDescription1);
 				 if (varConfirm == true) { 
	                 varFieldCheck = 1;
	                 location.replace("category259_1.htm");
		             return;
	             }
				 varFatalError = true;
     }                 	 
     varStyleSpec = true;   // this is set to prevent multiple checks on Panels & Kickboards								
					  
	 if (varDiscountRequest == false && ((varCurrentOrderPrice - varLocalDeliveryCost - varLongHaulCost) * 1.1  > 1080) && varOnLine == false) {
varConfirm=window.confirm("You have not applied for any discount. --- Click [OK] to go to the Discount page, (see Discounts ) -----Click [CANCEL] to continue");
       if (varConfirm == true) { 
	      varFieldCheck = 1;
	     location.replace("category1005632_1.htm");
		 return;
	   }
	 } 			  
 
 
// if  (TradeDiscountNumber > 1) {
// window.alert("You have applied for more than one Discounts - only one applies in any situation - please [REMOVE] one of these.");
//     location.replace("viewcart.htm");
//	 return; 
// }
  
// redo the validation process before deciding the Delivery process
     if (varStyleSpec == false && varCabinet == true ) {
window.alert("Please redo the Validation process when additional entries have been made, for example:  Colour/Profiles");
        return;
     }
 
 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;
  if (varOrderStatus == true) {
  window.alert("The Shopping List has been validated and you can now proceed to the CHECKOUT ");
         location.replace("viewcart-2.htm"); 
  }
  else {
 window.alert("The Shopping List IS NOT COMPLETE YET - Please Validate once more and follow the suggestions"); 
	            return;
  }
}

// change the five-character Style code to a full description
function transformProductStyle(varFullProductStyle)
{

  if (varFullProductStyle == "Lamin") varFullProductStyle = "MELAMINE (LAMINATE) style";
  else if (varFullProductStyle == "Belmo") varFullProductStyle = "Vinyl - BELMONT style";
  else if (varFullProductStyle == "Byron") varFullProductStyle = "Vinyl - BYRON BAY style";
  else if (varFullProductStyle == "Alban") varFullProductStyle = "Polyurethane - ALBANY style";
  else if (varFullProductStyle == "Avoca") varFullProductStyle = "Polyurethane - AVOCA style";
  else if (varFullProductStyle == "Unfin") varFullProductStyle = "Unfinished 18mm MR-MDF";


 return varFullProductStyle;
}


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) {
    if (varPanel != true && varPanelCheck == false && PanelKBQuestion == false) {
     varConfirm = window.confirm("You did not order any End (or SIDE) PANELS (see SINGLE PARTS) - this may be an oversight or intentional - click [OK] to ADD a Panel - [Cancel] to ignore as Panels are not required.");
	  if (varConfirm == true) {
	     location.replace("category1005432_1.htm");
		 varFieldCheck = 1;
		 return;
	  }
	  else varPanelCheck = true;	
    }
  }

  if (varCabinet == true || varCarcass == true) {
    if (varKickboard != true && varKickboardCheck == false && PanelKBQuestion == false) {
varConfirm = window.confirm("You did not order any KICKBOARDS (see SINGLE PARTS) - this may be an oversight or intentional---- Click [OK] to to go to the Panels page to order some or [CANCEL] to ignore this message and continue");	
      if (varConfirm == true) { 
          varFieldCheck = 1;
            location.replace("category1002111_1.htm");
		 return;
      }
	  	  else varKickboardCheck = true;
    }
  }
  
 } 

}

function checkDiscountandProducts()
{
 CalculateOrderTotals()
  CalculateOrderWeight()

  if (varDiscountRequest == false && ((varCurrentOrderPrice - varLocalDeliveryCost - varLongHaulCost) * 1.1  > 1080) && varOnLine == false) {   
varConfirm=window.confirm("You have not yet applied for any discount. ---Click [OK] to go to the Discount page, see DISCOUNTS -----Click [CANCEL] to continue");
       if (varConfirm == true) { 
	      varFieldCheck = 1;
	     location.replace("category1005632_1.htm");
		 return;
	   }
  } 
  			  
  checkProductRange();

}
//  collect the benchtop parameters
function BenchtopParameters(i, iProdID) {

     if (iProdID > 219 && iProdID < 224) {
         varL1 = 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);
		 	varL1 = varL1 - varW2 ;
		 	varL2 = varL2 - varW3 ;
		}
		if(iProdID == 223) {	 
		 	varE1 = "U";
		 	varE2 = getLineSubItem(i, colCustomFields, 7);
			varE2= varE2.substring(0,1);
		 	varE3 = "U";
		 	varL1 = varL1 - varW2 ;
		 	varL3 = varL3 - varW2 ;
		}
				 		 
		 BenchCost1 = calculateBenchCost(varL1, varW1, varE1) ;
		 BenchCost2 = calculateBenchCost(varL2, varW2, varE2) ;
		 BenchCost3 = calculateBenchCost(varL3, varW3, varE3) ;
		 
		 curPrice = BenchCost1 + BenchCost2 + BenchCost3 + 231.00;
		 if (varL1 > 2350) curPrice = curPrice + 80.00;
		 if (varL2 > 2350) curPrice = curPrice + 80.00;
		 if (varL3 > 2350) curPrice = curPrice + 80.00;
		 
		 CalculatedBenchtopCost = CalculatedBenchtopCost + curPrice;
//window.alert("line 3043 - CalculatedBenchtopCost= " + CalculatedBenchtopCost + " curPrice= " + curPrice);
		 
		 if (varL1 > varL2) BenchLength = varL1 ;
		 else BenchLength = varL2;		 
		 if (BenchLength < varL3) BenchLength = varL3 ;
		 
		 	varBench1Weight = calculateBenchWeight(varL1, 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) {
         varL1 = 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);
		 	varL1 = varL1 - varW2 ;
		}
		if(iProdID == 218) {
			varE2 = getLineSubItem(i, colCustomFields, 5);		 
		 	varE1 = "U";
		 	varE2 = varE2.substring(0,1);
		 	varL1 = varL1 - varW2 ;
		}
		if(iProdID == 219) {	 
		 	varE1 = getLineSubItem(i, colCustomFields, 5);
			varE1 = varE1.substring(0,1);
		 	varE2 = "U";
		 	varL2 = varL2 - varW1 ;
		}
				 		 
		 BenchCost1 = calculateBenchCost(varL1, varW1, varE1) ;	 
		 BenchCost2 = calculateBenchCost(varL2, varW2, varE2) ;
		 
		 curPrice = BenchCost1 + BenchCost2 + 116.00;
		 if (varL1 > 2350) curPrice = curPrice + 80.00;
		 if (varL2 > 2350) curPrice = curPrice + 80.00;
		 
		 if (varL1 > varL2) BenchLength = varL1 ;
		 else BenchLength = varL2;
// window.alert(" 3093 BenchCost1= " + BenchCost1 + " BenchCost2 = " + BenchCost2 + " BenchCost3= " + BenchCost3 + " varL1= " + varL1 + " varL2 = " + varL2 + " varL3 =  " + varL3);

		 CalculatedBenchtopCost = CalculatedBenchtopCost + curPrice;
//window.alert("line 3102 - CalculatedBenchtopCost= " + CalculatedBenchtopCost + " curPrice= " + curPrice);		 
		 
		 	varBench1Weight = calculateBenchWeight(varL1, varW1, varE1);
			varBench2Weight = calculateBenchWeight(varL2, varW2, varE2);			
			if (varIdentifyer == "A") BenchWeightLshapeA = varBench1Weight + varBench2Weight;
			else BenchWeightLshapeB = varBench1Weight + varBench2Weight; 					
//  window.alert(" 2988 benchWeight - " + BenchWeightLshapeA + " bench1W= " + varBench1Weight + " bench2W= " + varBench2Weight );
		 return curPrice;		
     }
}

function calculateBenchCost(Ll, Ww, Ee)
{
if      (Ee == "U" && Ww < 601)  BenchCost = Math.ceil(Ll  / 10) * 1.000;
else if (Ee == "U" && Ww < 901)  BenchCost = Math.ceil(Ll  / 10) * 1.450;
else if (Ee == "U" && Ww < 1201) BenchCost = Math.ceil(Ll  / 10) * 2.175;
else if (Ee == "A" && Ww < 601)  BenchCost = Math.ceil(Ll  / 10) * 1.175;
else if (Ee == "A" && Ww < 901)  BenchCost = Math.ceil(Ll  / 10) * 1.545;
else if (Ee == "A" && Ww < 1201) BenchCost = Math.ceil(Ll  / 10) * 2.270;
//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);
	
// Base Cabinets Your Dimension	
   if (varProductCode.substring(0,12) == "B-D1-S1/Y241"){
      curPrice = Math.round(0.17687 * varHeight * varWidth * varDepth / 1000000 + 75.55);
	  varWeight = 0.59 * varHeight * varWidth * varDepth / 10000000 + 10.00;
   }
   if (varProductCode.substring(0,12) == "B-D2-S1/Y242")  {
      curPrice = Math.round(0.13605 * varHeight * varWidth * varDepth / 1000000 + 116.55);
	    varWeight = 0.5935 * varHeight * varWidth * varDepth / 10000000 + 10.1;
   }
// Floor Open Uniys BO-S1/Y1	
   if (varProductCode.substring(0,8) == "BO-S1/Y1"){
      curPrice = Math.round(0.229 * varHeight * varWidth * varDepth / 1000000 + 80.55);
	  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 + 156.55);
      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 + 203.55);
 	   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 + 238.55);
	  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 + 250.55);
	 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" || varProductCode.substring(0,11) == "BCA-D1-S1/Y") {     
	 curPrice = Math.round(1.073 * (varHeight * varLHWidth * varLHDepth + varHeight * varRHWidth * varRHDepth)/ 10000000 + 206.55);
	   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 + 218.55);
	  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.13 * (varHeight * varLHWidth * varLHDepth + varHeight * varRHWidth * varRHDepth)/ 10000000 + 134.55);
	 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 + 141.55);
	 varWeight = Math.round(0.0829 * varHeight * varWidth * varDepth / 1000000 + 12.7);
    }
    if (varProductCode.substring(0,10) == "BCD2Drw2/Y") {
     curPrice = Math.round(0.3033 * varHeight * varWidth * varDepth / 1000000 + 153.55);
	  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.218 * varHeight * varWidth * varDepth / 1000000 + 76.55);
	 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.2089 * varHeight * varWidth * varDepth / 1000000 + 94.55);
	   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.235 * varHeight * varWidth * varDepth / 1000000 + 71.55);
	 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.21905 * varHeight * varWidth * varDepth / 1000000 + 92.55);
	  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.16667 * (varHeight * varLHWidth * varLHDepth + varHeight * varRHWidth * varRHDepth)/ 1000000 + 204.00);
	 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 + 120.55);
		 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(2.519 * (varHeight * varLHWidth * varLHDepth + varHeight * varRHWidth * varRHDepth)/ 10000000 + 150.55);
	 varWeight = Math.round(0.56 * (varHeight * varLHWidth * varLHDepth + varHeight * varRHWidth * varRHDepth)/ 10000000) + 26.5;
	 } 
	   
 // 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") {
     curPrice = Math.round(0.06818 * varHeight * varWidth * varDepth / 1000000 + 197.55);
     varWeight = Math.round(0.06818 * varHeight * varWidth * varDepth / 1000000 + 20.75);
    }
// Pantry or general storage Two Door P-D1-S5/Y
	if (varProductCode.substring(0,9) == "P-D2-S5/Y") {
     curPrice = Math.round(0.154 * varHeight * varWidth * varDepth / 1000000 + 192.55);
	   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.148148148 * (varHeight * varLHWidth * varLHDepth + varHeight * varRHWidth * varRHDepth)/ 1000000 + 325.55);
	  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.10416667 * (varHeight * varLHWidth * varLHDepth + varHeight * varRHWidth * varRHDepth)/ 1000000 + 177.55);
		 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") {
	   if (varHeight < 2151) curPrice = Math.round(0.03083333 * (varHeight * varLHWidth * varLHDepth + varHeight * varRHWidth * varRHDepth)/ 1000000 + 386);
       if (varHeight > 2150) curPrice = Math.round(0.03083333 * (varHeight * varLHWidth * varLHDepth + varHeight * varRHWidth * varRHDepth)/ 1000000 + 452); 
		 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 ); 
	 }	
// Frame Doors  "DoorGlass/Y*"
	if (varProductCode.substring(0,11) == "DoorGlass/Y") {
	   var varNumber = varProductCode.substring(11,12)	   
	  if (varProductCode.substring(12,13) == "a") {
	   curPrice = Math.round(0.21574 * (varHeight * varWidth) / 1000);
	     if (varNumber == 1 || varNumber == 4 || varNumber == 7 || varNumber == "x" ) curPrice = curPrice + 75.0;
		 else if (varNumber == 2 || varNumber == 5 || varNumber == 8 || varNumber == "y" ) curPrice = curPrice + 127.5;
		 else if (varNumber == 3 || varNumber == 6 || varNumber == 9 || varNumber == "z" ) curPrice = curPrice + 169.6;
	  }
      else if (varProductCode.substring(12,13) == "b") {
			   curPrice = Math.round(0.272 * (varHeight * varWidth) / 1000);
				 if (varNumber == 1 || varNumber == 4 || varNumber == 7 || varNumber == "x" ) curPrice = curPrice + 83.80;
				 else if (varNumber == 2 || varNumber == 5 || varNumber == 8 || varNumber == "y" ) curPrice = curPrice + 136.5;
				 else if (varNumber == 3 || varNumber == 6 || varNumber == 9 || varNumber == "z" ) curPrice = curPrice + 178.5;
	  }
 	  else if (varProductCode.substring(12,13) == "c") {
				 if (varNumber == 1 || varNumber == 4 || varNumber == 7 || varNumber == "x" )  
				   curPrice = Math.round(0.3636 * (varHeight * varWidth) / 1000 + 52.0);
				 else if (varNumber == 2 || varNumber == 5 || varNumber == 8 || varNumber == "y" ) 
				    curPrice = Math.round(0.3854 * (varHeight * varWidth) / 1000 + 109.5);
				 else if (varNumber == 3 || varNumber == 6 || varNumber == 9 || varNumber == "z" ) 
				    curPrice = Math.round(0.3883 * (varHeight * varWidth) / 1000 + 155);
	  }
	  else if (varProductCode.substring(12,13) == "d") {
				 if (varNumber == 1 || varNumber == 4 || varNumber == 7 || varNumber == "x" ) 
				   curPrice = Math.round(0.404 * (varHeight * varWidth) / 1000 + 83.8);				
				 else if (varNumber == 2 || varNumber == 5 || varNumber == 8 || varNumber == "y" )
				    curPrice = Math.round(0.449 * (varHeight * varWidth) / 1000 + 108.3);
				 else if (varNumber == 3 || varNumber == 6 || varNumber == 9 || varNumber == "z" ) 
				    curPrice = Math.round(0.4521 * (varHeight * varWidth) / 1000 + 153.7);
	  }
	  else if (varProductCode.substring(12,13) == "e") {			 
		 curPrice = Math.round(0.15 * (varHeight * varWidth) / 1000);
	     if (varNumber == 1 || varNumber == 4 || varNumber == 7 || varNumber == "x" ) curPrice = curPrice + 75.0;
		 if (varNumber == 2 || varNumber == 5 || varNumber == 8 || varNumber == "y" ) curPrice = curPrice + 127.5;
		 if (varNumber == 3 || varNumber == 6 || varNumber == 9 || varNumber == "z" ) curPrice = curPrice + 169.6;				 
//deduct 5% for Cabinets-online Website		 
//		 if (varOnLine == true) curPrice = Math.round(curPrice * 0.95 + 0.5);
		} varWeight  = Math.round(0.02 * (varHeight * varWidth)/ 1000 + 0.2 ); 
   }		  	 
//window.alert("The Price (excluding GST) for this Product will be " + curPrice + " and will be listed on the Shopping List " + varWeight );	 
	 
	 return curPrice;
}
//function to Check on Sections a for WardRobes
function checkA(RoomWallSection) 
{
 if (RoomWallSection != "000") {  
     RoomWall = RoomWallSection.substring(0,12);
     Section = RoomWallSection.substring(12,13); 
     if (RoomWall == varRW1.substring(0,12)) {
	   if (Section == "A") varRW1 = RoomWallSection;
	   return;
	 }
	 if (RoomWall == varRW2.substring(0,12)) {
	   if (Section == "A") varRW2 = RoomWallSection;
	   return;
	 }
	 if (RoomWall == varRW3.substring(0,12)) {
	   if (Section == "A") varRW3 = RoomWallSection;
	   return;
	 }	 
	 if (RoomWall == varRW4.substring(0,12)) {
	   if (Section == "A") varRW4 = RoomWallSection;
	   return;
	 }
	 if (RoomWall == varRW5.substring(0,12)) {
	   if (Section == "A") varRW5 = RoomWallSection;
	   return;
	 }	 		 
	 if (RoomWall == varRW6.substring(0,12)) {
	   if (Section == "A") varRW6 = RoomWallSection;
	   return;
	 }	 		 

   if (varRW1 == "NIL") {
       varRW1 = RoomWallSection;
	   return
   }
   if (varRW2 == "NIL") {
       varRW2 = RoomWallSection;
	   return
   } 
   if (varRW3 == "NIL") {
       varRW3 = RoomWallSection;
	   return
   }
   if (varRW4 == "NIL") {
       varRW4 = RoomWallSection;
	   return
   }  
   if (varRW5 == "NIL") {
       varRW5 = RoomWallSection;
	   return
   }   
   if (varRW6 == "NIL") {
       varRW6 = RoomWallSection;
	   return
   }   	 	 	 		
 }
  return
} 

// -------------------------------------------------------------------------------------------------//  this function is to delete the complete order details
function deleteAll()
{
varConfirm=window.confirm("You have asked to [REMOVE ALL] entries on your Shopping Cart. Please CONFIRM - to REMOVE ALL click [OK] - to KEEP all entries click [CANCEL].");
 if (varConfirm == true) {
	var arrLineTmp = new Array(0);	
	arrLine = arrLineTmp;	
	private_UpdateLines();
	 window.location = "viewcart.htm";
 }
}
// -------------------------------------

//function to Recalculate Costs after a GLOBAL change in Style Finish
function changeStyle(iProdID)
{
 var realPID = iProdID;
 varNewPID = iProdID;

 if (varOnLine == false && varDataInputMode == false && varSuffix != "x") { 
 	var varProductCode = getProductInfo(iProdID)[colProductCode];
//window.alert(" varDataInputMode= " + varDataInputMode);
     	 varNewPID=changePID(varProductCode);
     	 if(varNewPID == 0)  varNewPID = realPID;
 }
return varNewPID;
}
// ----------------------------------------------------------------------------------------	 
function changePID(varNewPID)
{
// varNewPID initially contains the ProductCode.
// change ProductCode to Root + Suffix - NOTE the Suffix is stored in a special file attached to the various versions of "Viewcart"
//window.alert("varNewPID=  " + varNewPID);
	var varLength = varNewPID.length;
	var varRoot = varNewPID;
	var varLastChar = "";
	 varProductChangeFlag = true;
	varLastChar = varNewPID.substring(varLength - 1, varLength);

if (varLastChar == "a" || varLastChar == "b" || varLastChar == "c" || varLastChar == "d" || varLastChar == "e" ) varRoot = varNewPID.substring(0, varLength - 1);
varNewPID = varRoot + varSuffix; 
//window.alert("varNewPID=  " + varNewPID);
  switch(varNewPID)
  {
case    "BB45-D1-S1/17785":  return  17785

case    "WO-S1/20929d":  return  25285

  }
   return 0;
}     

function CalculateProportionalDiscount(curPrice,iProdID,i,lineCount)
// CANIBALISED as not required in Cabinets o-Line  hjt 04/04/2010    
{
  var varOldPrice = curPrice;
  var varStart = 0;
  var varCarcassSaving = 0;
  var varDoorSaving = 0;
  var varBenchSaving = 0;
  varNewPrice = varOldPrice;
  
}

//----------------------------------------------------------------------
function getInputDimensions(i)
{
    if (varProductCode.substring(0,1) != "2" && varProductCode.substring(0,1) != "3" && varProductCode.substring(0,1) != "z" && varProductCode.substring(0,1) != "H") { 
		var iCustomFieldCount = getLineSubCount(i, colCustomFields);
        varHeight = getLineSubItem(i, colCustomFields, 0);
	    varWidth = getLineSubItem(i, colCustomFields, 1);
	    varDepth = getLineSubItem(i, colCustomFields, 2); 
		varDoorSize = varWidth;
    } 
	if (iCustomFieldCount > 7 && varProductCode.substring(0,4) != "Door" && varProductCode.substring(0,4) != "RH-D" && varProductCode.substring(0,2) != "WO" && varProductCode.substring(0,3) != "BCD") {
	 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)
	}
 	if (varProductCode.substring(0,4) == "cBC-" || varProductCode.substring(0,4) == "cBCA" || varProductCode.substring(0,4) == "cWC-" || varProductCode.substring(0,4) == "cBD-" || varProductCode.substring(0,4) == "cWD-" || varProductCode.substring(0,3) == "cPC" || varProductCode.substring(0,3) == "cPD" || varProductCode.substring(0,3) == "cWC" ) {
	 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)
	}
	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); 
		varDoorSize = 0;
	}
	if (varProductCode.substring(0,4) == "WRCS") {
	 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 = 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;
// window.alert(" varHeight= " + varHeight + "varWidth= " + varWidth + "varDepth= " + varDepth + " varDoorSize =" + varDoorSize);
}

// 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)
{
		if (item.value != "NaN") {
// alert(productCode + " " + customName + ":" + customValue + " new value: " + item.value);
		    setLineSubItem(line, colCustomFields, iCustomField, item.value);		
			window.location.href = 'viewcart.htm';
		}
}