<!-- hide

order_total =0;  
item_num = 1;
present_item = 1;
items_ordered = 0;
total_item_price =0;
maxarray = 50;

this.invcompany= ''
this.invaddress1= ''
this.invaddress2= ''
this.invtown= ''
this.invcounty= ''
this.invcountry= ''
this.invpostcode=''
this.delcompany= ''
this.deladdress1= ''
this.deladdress2= ''
this.deltown= ''
this.delcounty= ''
this.delcountry= ''
this.delpostcode= ''
this.sameflag = false
this.contactname=''
this.dept= ''
this.custordernumber=''
this.email= ''
this.phone=''
this.fax=''
this.paymentmethod=''
this.comments= ''


function item_tot_price(i)
{
 total_item_price = eval((itemlist[i].price * itemlist[i].quan));
 return total_item_price;
}


function all_order_totals()
{order_total = 0;
if (item_num > 0)
 {  
for (i =1;i < item_num;i++)
 {order_total = order_total + item_tot_price(i)}
   
 } return order_total;
}


function remove_nil_items(inputlist)
{var i = 0; 
 var j = 1; 
  for (i=1;i<item_num;i++)
   {if (itemlist[i].quan != 0)
    {temp_array[j]=itemlist[i]
     items_ordered =j 
     j=j+1
     } 
   } 
  itemlist = temp_array
  item_num = items_ordered + 1
}


function update_page()
{
var i = 0; 
var k = 0;
 {for (i = 0;i < parent.viewer.document.form1.elements.length;i++)
  {for (k=1;k<=items_ordered;k++)
   {
if ((itemlist[k].code ==  parent.viewer.document.form1.elements[i].name) && (k<=items_ordered) && (i<=parent.viewer.document.form1.elements.length))
         parent.viewer.document.form1.elements[i].value = itemlist[k].quan
   }
  }
 }   
}

function item_quan(code)
{
var loc = check_if_in(code)
if (loc > 0)
 var quantities = itemlist[loc].quan
else
 var quantities = 0;
return quantities
//alert("qty" + quantities);
}

function createArray(n)
//n		size of array
//init	what you want all values initialized to
{               this.length = n
		var i = 0
		for (i = 1 ; i < n ; i++) 
			this[i] = null;	
                return this
}


function product(code,desc,url,price,quan)
{ this.price = 0
  this.code = code
  this.desc = desc
  this.url = url
  this.price = price
  this.quan = quan
 return this;
}

var itemlist = new createArray(50);
var temp_array = new createArray(50);

function initialize_arrays(arraysa)
{
for (i = 0;i < maxarray;i++)
{
arraysa[i] = new product('','','',0,0)
}

}

function check_if_in(code_check) // this works
{
var i = 0
loc = 0;
while ((i < item_num) && (itemlist[i].code != code_check))
  i = i + 1;
   if (itemlist[i].code == code_check)
    loc = i
   else
    loc = -1;
return loc;
}


function additem(codes,desc,url,prices)
{
loc = check_if_in(codes)
if (loc != -1){
olditem =  itemlist[loc].quan
//alert('loc is ' + loc);
//alert('olditem is ' + olditem);
itemlist[loc] = new product(codes,desc,url,prices,olditem + 1)
}
else  {
// new item
olditem =  itemlist[item_num].quan;
itemlist[item_num] = new product(codes,desc,url,prices,olditem + 1);
items_ordered = item_num
item_num = item_num + 1
     }
 //   remove_nil_items(itemlist) 
 }


function subitem(codes,desc,url,prices)
{
loc = check_if_in(codes)
if ((loc != -1) && (itemlist[loc].quan > 0)) {
  olditem = itemlist[loc].quan
//alert('subloc is ' + loc);
//alert('subolditem is ' + olditem);
  itemlist[loc] = new product(codes,desc,url,prices,olditem - 1)}
}

initialize_arrays(itemlist)
initialize_arrays(temp_array)


<!--  end hide -->