order_total =0;  
item_num = 1;
present_item = 1;
items_ordered = 0;
total_item_quan = 0;
total_item_price =0;
total_item_weight =0;
shipping_cost =0;
sales_tax =0;
maxarray = 50;
var st_astr = '<html><body bgcolor=#ffffff>';
var en_astr = '</body></html>';
var CustomCode = "";
var ship_fname = "";
var ship_lname = "";
var ship_email = "";
var ship_addy1 = "";
var ship_addy2 = "";
var ship_phon1 = "";
var ship_phon2 = "";
var ship_phon3 = "";
var ship_city  = "";
var ship_state = "";
var ship_zip   = "";

function product(code,price,desc,quan,url){
  this.price = 0;
  this.code = code;
  this.price = price;
  this.desc = desc;
  this.quan = quan;
  this.url = url;
  return this;
}

function CustProd(func,codes,prices,descrip,url){
  CustomCode = codes;
  custdiv=document.getElementById("Custmzr");

  custfrm=document.getElementById("Cstmzr");  
  custfrm.src="CustomPane.htm";

  custdiv.style.visibility="visible";
  custdiv.style.zIndex=100;
}

function additem(codes,prices,descrip,url){
  // adds another item to a variable length array
  // remember to do it via new product()

  loc = check_if_in(codes);
  //present_item = item_num
  //last_item = item_num;

  if (loc != -1){
    // update existing item
    olditem =  itemlist[loc].quan;
    itemlist[loc] = new product(codes,prices,descrip,olditem + 1,url);
  }
  else{ // new item
    olditem =  itemlist[item_num].quan;
    itemlist[item_num] = new product(codes,prices,descrip,olditem + 1,url);
    items_ordered = item_num;
    item_num = item_num + 1;
  }
  remove_nil_items(itemlist);

  cartdiv=parent.document.getElementById("artCart");
  if(item_num>0){
    cartdiv.style.visibility="visible";
    var xtot = all_order_totals();
    total_item_quan = all_order_quant(); 
    var xpop = top.frames['Cart'].location = "CartPop.htm";
  }

  custdiv=parent.document.getElementById("Custmzr");
  custdiv.style.visibility = "hidden";
}

var shiparray =  new parent.createArray(10);

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 all_order_quant(){
  item_count = 0;
  if (item_num > 0){
    for (i=1;i<item_num;i++){
	item_count = item_count + itemlist[i].quan;
    }
  }
  return item_count;
}

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_this_page(){
  var i = 0; 
  var k = 0; 
  for (i = 0;i < parent.main.document.form1.elements.length;i++){
    for (k=1;k<=items_ordered;k++){
      if ((itemlist[k].code ==  parent.main.document.form1.elements[i].name) && (k<=items_ordered) && (i<=parent.main.document.form1.elements.length))
        parent.main.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;
}

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;
}

var itemlist = new createArray(50);
var temp_array = new createArray(50);

function initialize_arrays(arraysa){
  for (i = 1;i < maxarray;i++){
    arraysa[i] = new product('',0,'',0,'')
  }
}

function updatemain_order(){
  parent.frames[1].document.close();
  // parent.frames[1].document.open();
  parent.frames[1].location = "order.html";
  parent.frames[1].document.close();
}

function updatenav_nav(){
  parent.frames[0].document.close();
  // parent.frames[0].document.open();
  parent.frames[0].location = "navigate.htm";
  parent.frames[0].document.close();
}

function check_if_in(code_check){ // this works
  var i = 1;
  loc = 0;
// line 47
  while ((i < item_num) && (itemlist[i].code != code_check)) i = i + 1;
  if (itemlist[i].code == code_check)
    loc = i;
  else
    loc = -1;
//alert('loc is ' + loc);
  return loc;
}

function subitem(codes,prices,descrip,url){
  loc = check_if_in(codes);
  if ((loc != -1) && (itemlist[loc].quan > 0)) {
    // update existing item
    olditem =  itemlist[loc].quan;
    //alert(' loc is before oldvalue ' + loc);
    //alert('olditem is ' + olditem);
    itemlist[loc] = new product(codes,prices,descrip,olditem - 1,url);
  }
  //updatepage(codes) 

  if(item_num>0){
    cartdiv=document.getElementById("artCart");
    cartdiv.style.display="block";
    var xtot = all_order_totals();
    total_item_quan = all_order_quant(); 
    xpop = top.frames['Cart'].location = "CartPop.htm";
  }
  else{
    cartdiv=parent.document.getElementById("artCart");
    cartdiv.style.display="none";
  }
}

function ViewCart(){
  var currentfr=this.parent.document.getElementById('ABody');
  currentfr.height = 2200;
  var xcrt = top.frames['ABody'].location = "YourCart.htm";
  var xban = top.frames['CBanner'].location = "CartBanner.htm#topper";
}

function ViewPPal(){
  var currentfr=this.parent.document.getElementById('ABody');
  currentfr.height = 1100;
  var xban = top.frames['CBanner'].location = "CartBanner.htm#topper";
}

initialize_arrays(itemlist);
initialize_arrays(temp_array);

function check_window(){
  if (self == mainbody){
    document.write('<head><META HTTP-EQUIV="Refresh" CONTENT="15; URL=index.html"></head><body><center><h1>Warning!</h1><br><font color=#ff000><b>This is inside a multiple frame window.<br>The scripts may not work correctly!!!!,</font><BR>We are jumping you directly to our <a href="index.htm" target=_top>Main page</a> in 15 seconds.</center>');
    self.location = "index.htm";
    parent.document.close();
  }
}

index = 0;
	
function format(val, post)
{
    var decpoint;
    var begin;
    var end;
    var valstr;
	var temp_char;

    valstr = "" + val;
	//alert('valstr = ' + valstr);
    decpoint = valstr.indexOf(".")
    if (decpoint != -1) {
	    //alert('decpoint = ' + decpoint);
        begin = valstr.substring(0,decpoint);
        end = valstr.substring(decpoint+1,valstr.length);
		//alert('begin = ' + begin + '\nend= ' + end);
    }
    else {
        begin = valstr;
        end = "";
    } 
	if (end.length < post)
	 {while (end.length < post)
	    {
        end += "0";
        }
	 }
     
	end = end.substring(0,post);
	//alert('begin = ' + begin + '\nend= ' + end);
    return (begin+"."+end);
}

function orderSubmit(type) 
{
  if (type == 'order'){
    if ( ! ( checkRequired() )){
		// checkCardNumber();            ENTRY HERE
             document.order.form_action.value = type;
             document.order.submit();
             return true;
			 
        }
        else {
            return false;
			
        }
    }
}

var infowin = null;

function disableSameFlag() {
    document.order.same_flag.checked = false;
}

function UpdateShip(){
  ship_fname = document.order.first_name.value;
  ship_lname = document.order.last_name.value;
  ship_email = document.order.email.value;
  ship_addy1 = document.order.address1.value;
  ship_addy2 = document.order.address2.value;
  ship_phon1 = document.order.night_phone_a.value;
  ship_phon2 = document.order.night_phone_b.value;
  ship_phon3 = document.order.night_phone_c.value;
  ship_city  = document.order.city.value;
  ship_state = document.order.state.value;
  ship_zip   = document.order.zip.value;
}

function checkRequired() {
  if (document.order.zip.value < 1000 ||
      document.order.zip.value >99999 ||
	document.order.first_name.value == "First Name" ||
	document.order.first_name.value == "" ||
	document.order.last_name.value == "Last Name" ||
	document.order.last_name.value == "" ||
	document.order.email.value == "" ||
	document.order.night_phone_a.value == "" ||
	document.order.night_phone_b.value == "" ||
	document.order.night_phone_c.value == "" ||
	document.order.city.value == "" ||
	document.order.state.value == "" ||
	document.order.address1.value == "") { 
    alert('You have not completed all required fields:\n' +
          'Please complete the Contact Information fields');
    return true;
  }
  else {
    return false;
  }
}

<!-- Cookie Functions -->

function getCookie (name) {
  var dcookie = document.cookie; 
  var cname = name + "=";
  var clen = dcookie.length;
  var cbegin = 0;
  while (cbegin < clen) {
    var vbegin = cbegin + cname.length;
    if (dcookie.substring(cbegin, vbegin) == cname) { 
	var vend = dcookie.indexOf (";", vbegin);
      if (vend == -1) vend = clen;
      return unescape(dcookie.substring(vbegin, vend));
    }
    cbegin = dcookie.indexOf(" ", cbegin) + 1;
    if (cbegin == 0) break;
  }
  return null;
}

function setCookie (name, value, expires) {
  if (!expires) expires = new Date();
  document.cookie = name + "=" + escape (value) + "; expires=" + expires.toGMTString() +  "; path=/";
}

function delCookie (name) {
  var expireNow = new Date();
  document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT" +  "; path=/";
}

function getCookieArray(name){
  var i = 0;
  while (getCookie(name + i) != null) {
    shiparray[i + 1] = getCookie(name + i);
    i++;
    shiparray.length = i; 
  }
}

var expdate = new Date();
 
expdate.setTime (expdate.getTime() +  (24 * 60 * 60 * 1000 * 365)); 

function setCookieArray(name){
  temp_length = setCookieArray.arguments.length - 1;
  for (var i = 0; i < temp_length; i++) {
    data = setCookieArray.arguments[i + 1];
    setCookie (name + i, data, expdate);
  }        
}

function go_with_cookie(){
  setCookieArray('gifttails',
  parent.ship_details.f_namea,
  parent.ship_details.l_namea,
  parent.ship_details.email,
  parent.ship_details.ad_onea,
  parent.ship_details.ad_twoa,
  parent.ship_details.citya,
  parent.ship_details.statea,
  parent.ship_details.countrya,
  parent.ship_details.zipa);
}

function get_that_cookie(){
  var i;
  getCookieArray('gifttails');
  //alert('shiparray.length = '+ shiparray.length);
  for (i=0;i<shiparray.length+1;i++){
    if (shiparray[i]){
      //alert('ship_array[' + i + '] ='+ shiparray[i]);
      ship_details[i]  = shiparray[i];
	//alert('ship_details[' + i + '] ='+ ship_details[i]);
    }
    else{
      // to initiate array values
	ship_details[i] = ''
    }
  }
	
  parent.ship_details.f_namea = ship_details[1];
  parent.ship_details.l_namea = ship_details[2];
  parent.ship_details.email = ship_details[3];
  parent.ship_details.ad_onea = ship_details[4];
  parent.ship_details.ad_twoa = ship_details[5];
  parent.ship_details.citya = ship_details[6];
  parent.ship_details.statea = ship_details[7];
  parent.ship_details.countrya = ship_details[8];
  parent.ship_details.zipa = ship_details[9];
	
  //alert('shiparray length= ' + shiparray.length + '\nshiparray[1] = ' + shiparray[1] + '\nshiparray[2] = ' + shiparray[2] + '\nshiparray[3] = ' + shiparray[3] + '\nshiparray[4] = ' + shiparray[4] + '\nshiparray[5] = ' + shiparray[5] + '\nshiparray[6] = ' + shiparray[6] + '\nshiparray[7] = ' + shiparray[7] + '\nshiparray[8] = ' + shiparray[8]);
}