//Global Variables
      var RowsInForm = 4		//How many rows will be in the order details form
      var ProductsInList = 4       //Must equal highest subscript in product list
      var SalesTaxRate = 0.07	//Set to sales tax rate in decimal. e.g. 0.0775 is 7.75%
      var TaxableState = "NJ"		//Set to name of state you charge sales tax in
      var ProdSubscript = 0		//Identifies subscript of selected product in current row.

	// Function to create a new empty array that starts at 1.

	function MakeArray(n) {	
		this.length = n
		for (var i = 1; i<= n; i++) {
			this[i] = 0	
		}		
		return this
	}

	// Function to create a new, empty array that starts at zero.

	function BuildZeroArray(n) {
		this.length = n
		for (var i = 0; i<= n; i++) {
			this[i] = 0 	
		}		
		return this
	}

	// Define a custom object named prodobj (Product Object).
	// An array of these objects will act as our product/price list.

	function prodobj(name, unitprice) {
		this.name = name
		this.unitprice = unitprice
	}

	// Define a new custom object named ordobj (Order Object).
	// Will house real numbers from order form to help with math.

	function ordobj(prodsub, qty, unitprice, extprice) {
		this.prodsub = prodsub
		this.qty = qty
		this.unitprice = unitprice
		this.extprice = extprice
	}

	//convert any non-numeric value to a zero.

	function strToZero(anyval) {
		anyval = ""+anyval
		if (anyval.substring(0,1) < "0" || anyval.substring(0,1) > "9") {
			anyval = "0"
		}
		return eval(anyval)
	}

	//update current row in order array and form.

	function updateRow(rownum){	
		var exec = 'ProdSubscript = document.ordform.prodchosen'+rownum+'.selectedIndex'
		eval (exec)
		ordData[rownum].prodsub=ProdSubscript	//get qty from the form	
		var exec='tempqty=document.ordform.qty'+rownum+'.value'
		eval (exec)
		ordData[rownum].qty = strToZero(tempqty)	//get unit price from the product price list.
		ordData[rownum].unitprice=prodlist[ProdSubscript].unitprice
		ordData[rownum].extprice = (ordData[rownum].qty) * ordData[rownum].unitprice
		var exec = 'document.ordform.unitprice'+rownum+'.value = currencyPad(ordData['+rownum+'].unitprice,10)'	
		eval (exec)
		var exec = 'document.ordform.extprice'+rownum+'.value = currencyPad(ordData['+rownum+'].extprice,10)'
		eval (exec)
		updateTotals() 			//update totals at bottom of form
	}
	
	//update the totals in the lower part of order details.

	function updateTotals() {
		var subtotal = 0
		for (var i=1; i<=RowsInForm; i++) {
			subtotal = subtotal + ordData[i].extprice
		}
		document.ordform.subtotal.value = currencyPad(subtotal,10)
		salestax = 0
		if (document.ordform.Taxable.checked) {
			salestax = SalesTaxRate * subtotal	
		}
		document.ordform.salestax.value = currencyPad(salestax,10)
		document.ordform.grandtotal.value = currencyPad(subtotal+salestax,10)
		document.fin.amount.value = currencyPad(subtotal+salestax,10)

//My excellent addition below!
browserName=navigator.appName; 
if (browserName=="Netscape") {
//Code for Netscape
		descript = document.ordform.prodchosen1.value + '(' + document.ordform.qty1.value + ') ' + document.ordform.prodchosen2.value + '(' + document.ordform.qty2.value + ') ' + document.ordform.prodchosen3.value + '(' + document.ordform.qty3.value + ') ' + document.ordform.prodchosen4.value + '(' + document.ordform.qty4.value + ') '
		document.fin.item_name.value = descript
} else {
// Internet Explorer
   var prodone = ordform.prodchosen1.options[ordform.prodchosen1.selectedIndex].text
   var prodtwo = ordform.prodchosen2.options[ordform.prodchosen2.selectedIndex].text
   var prodthree = ordform.prodchosen3.options[ordform.prodchosen3.selectedIndex].text
   var prodfour = ordform.prodchosen4.options[ordform.prodchosen4.selectedIndex].text
   var quant1 = ordform.qty1.value
   var quant2 = ordform.qty2.value
   var quant3 = ordform.qty3.value
   var quant4 = ordform.qty4.value
 		document.fin.item_name.value = prodone + "(" + quant1 + ") " + prodtwo + "(" + quant2 + ")" + prodthree + "(" + quant3 + ")" + prodfour + "(" + quant4 + ")"
//code for other browser
}}

	//copy the "Bill To" information to the "Ship To" information.

	function copyAddress() {
		document.ordform.ShipName.value = document.ordform.billName.value
		document.ordform.ShipCompany.value = document.ordform.billCompany.value
		document.ordform.ShipAdd1.value = document.ordform.billAdd1.value
		document.ordform.ShipAdd2.value = document.ordform.billAdd2.value
		document.ordform.ShipCSZ.value = document.ordform.billCSZ.value
	}

	function currencyPad(anynum,width) {
		//returns number as string in $xxx,xxx.xx format.
		anynum = "" + eval(anynum)
		//evaluate (in case an expression sent)
                intnum=0
                if (anynum >= 1) {
        	         intnum = parseInt(anynum)
                }    
		//isolate integer portion
		intstr = ""+intnum
		//add comma in thousands place.
		if (intnum >= 1000) {
			intlen = intstr.length
			temp1=parseInt(""+(intnum/1000))
			temp2=intstr.substring(intlen-3,intlen)
			intstr = temp1+","+temp2
	        }

		if (intnum >= 1000000) {
			intlen = intstr.length
			temp1=parseInt(""+(intnum/1000000))
			temp2=intstr.substring(intlen-7,intlen)
			intstr = temp1+","+temp2        
		}
		decnum = Math.abs(parseFloat(anynum)-intnum) //isolate decimal portion
		decnum = decnum * 100 // multiply decimal portion by 100.
		decstr = "" + Math.abs(Math.round(decnum))
		while (decstr.length < 2) {
			decstr="0"+decstr
		}
		retval = intstr + "." + decstr
		if (intnum < 0) {
			retval=retval.substring(1,retval.length)
			retval="("+retval+")"        
		}       
		retval = "$"+retval
		while (retval.length < width){
			retval=" "+retval
		}
		return retval
	}
