//    Copyright (C) 1998   Zhong Yang  oops@beida.com V1.2
//
//    This program is free software; you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation; either version 2 of the License, or
//    any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program; if not, write to the Free Software
//    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                  

function addto (form) { //add to cart but stay on the same page
  var entry=form;
  var a=0;
  boundry = new Array(entry.elements.length);
  boundry[0]=0;
   for(x=1;x<entry.elements.length;x++){
	if(entry.elements[0].name==entry.elements[x].name)
         {
           a++;
           boundry[a]=x;
         }
   }   

j=0;
for(i=0;i<=a;i++) {
  j=boundry[i];
// check to see if you are using <select>
if(isNaN(entry.elements[j+1].length)){
     var description=entry.elements[j+1].value;
  } else {
     var opindex=entry.elements[j+1].selectedIndex;
     var description=entry.elements[j+1].options[opindex].text;
  }
  var ind=j+2;
  while(entry.elements[ind].name==entry.elements[ind-1].name)
  {
     opindex=entry.elements[ind].selectedIndex;
     description = description+" "+entry.elements[ind].options[opindex].text;
     ind++;
  }
  store_name=entry.elements[ind].value;
  product_name=entry.elements[ind].name;
  quantity=entry.elements[j].value;
  price=entry.elements[j+1].name;

  var num=parseInt(entry.elements[j].value)
  if(!isNaN(num) && num>=0 )
  {
  document.cookie ="oops"+store_name+"+"+description
+ "+" + product_name + "=" + quantity +
"+" + document.referrer  +"+"+ price + 
"; path=/"+"";
   }       
 }
}

function  addtocart(form,page){ //add to cart and go to a new page
addto(form)
location.href="/"+ page;		// AS 7/31/2000: added forward slash
}

function setform(form,page){
var formname=form;
formname.method='GET';
formname.action=page;
}
