totalitems = 9;
shippingoptions = 2;
var itemcount = new Array(totalitems);
var itemname = new Array(totalitems);
var itemprice = new Array(totalitems);
var shipping = new Array(shippingoptions);
for(x=0;x<totalitems;x++){
	itemcount[x]=0;
}
var x = 0;
itemname[x] = "Ceramic Cap";
itemprice[x] = 200;
x++;
itemname[x] = "Grid MO-50";
itemprice[x] = 200;
x++;
itemname[x] = "DIP-it Samplers (1 box - 96 tips)";
itemprice[x] = 120;
x++;
itemname[x] = "Bag containing 1000 Dip-it Tips";
itemprice[x] = 870;
x++;
itemname[x] = "DIP-it Tip Holder";
itemprice[x] = 100;
x++;
itemname[x] = "Dual Tip Holder";
itemprice[x] = 50;
x++;
itemname[x] = "Multi-Tablet Carrier";
itemprice[x] = 400;
x++;
itemname[x] = "TLC Plate Module";
itemprice[x] = 400;
x++;
itemname[x] = "Base Block ET Adapter";
itemprice[x] = 300;
x++;


shipping[0] = 0;
shipping[1] = 25;
function addCart(num){
	hide('addcart'+num);
	show('incart'+num);
	itemcount[num] = 1;
	updatetotal();
}
function addOne(num){
	itemcount[num]++;
	document.getElementById('itemcount'+num).firstChild.nodeValue = itemcount[num];
	updatetotal();
}
function removeOne(num){
	itemcount[num]--;
	if(itemcount[num]>0){
		document.getElementById('itemcount'+num).firstChild.nodeValue = itemcount[num];
	}
	else{
		hide('incart'+num);
		show('addcart'+num);
	}
	updatetotal();
}
function updatetotal(){
	totalvalue = 0;
	cartitemcount = 0;
	itemnumber = 1;
	clearNode('paypal');
	addInput('paypal','cmd','_cart');
	addInput('paypal','upload','1');
	//addInput('paypal','business','fakesales@gametraderworld.com');
	addInput('paypal','business','lintvedt@ionsense.com');
	addInput('paypal','cancel_return','http://www.IonSense.com/ordercancelled.php')

	
	//DP-100 Price Break
	if(itemcount[2]>=5 && itemcount[2]<10){
		itemprice[2] = 108;
		clearNode('item2price');
		oldprice = document.createElement('span');
		oldprice.setAttribute('class','strike');
		oldprice.setAttribute('className','strike');
		oldprice.appendChild(document.createTextNode('$120'));
		newprice = document.createTextNode(' $108 ');
		savings = document.createElement('span');
		savings.setAttribute('class','savings');
		savings.setAttribute('className','savings');
		savings.appendChild(document.createTextNode('10% savings'));
		document.getElementById('item2price').appendChild(oldprice);
		document.getElementById('item2price').appendChild(newprice);
		document.getElementById('item2price').appendChild(document.createElement('br'));
		document.getElementById('item2price').appendChild(savings);
	}
	else if(itemcount[2]>=10){
		itemprice[2] = 102;
		clearNode('item2price');
		oldprice = document.createElement('span');
		oldprice.setAttribute('class','strike');
		oldprice.setAttribute('className','strike');
		oldprice.appendChild(document.createTextNode('$120'));
		newprice = document.createTextNode(' $102 ');
		savings = document.createElement('span');
		savings.setAttribute('class','savings');
		savings.setAttribute('className','savings');
		savings.appendChild(document.createTextNode('15% savings'));
		document.getElementById('item2price').appendChild(oldprice);
		document.getElementById('item2price').appendChild(newprice);
		document.getElementById('item2price').appendChild(document.createElement('br'));
		document.getElementById('item2price').appendChild(savings);
	}
	else{
		itemprice[2] = 120;
		clearNode('item2price');
		document.getElementById('item2price').appendChild(document.createTextNode('$120'));
	}

	for(x=0;x<totalitems;x++){
		totalvalue+= itemprice[x]*itemcount[x];
		cartitemcount+=itemcount[x];
		if(itemcount[x]>0){
			addInput('paypal','item_name_'+itemnumber,itemname[x]);
			addInput('paypal','amount_'+itemnumber,number_format(itemprice[x],2));
			addInput('paypal','quantity_'+itemnumber,itemcount[x]);
			addInput('paypal','custom_'+itemnumber,x);
			itemnumber++;
		}
	}
	shippingchoice = 0;
	if(cartitemcount>0){
		for(x=0;x<shippingoptions;x++){
			if(document.getElementById('shippingchoice'+x).checked){
				shippingchoice = x;
				break;
			}
		}
		addInput('paypal','shipping_1',shipping[shippingchoice]+'.00');
		totalvalue+= shipping[shippingchoice];
	}
	if(cartitemcount==1){
		document.getElementById('itemcount').firstChild.nodeValue = cartitemcount+' item';
	}
	else{
		document.getElementById('itemcount').firstChild.nodeValue = cartitemcount+' items';
	}
	document.getElementById('carttotal').firstChild.nodeValue = number_format(totalvalue,2);
	if(totalvalue>4000){
		show('paypalrequired');
	}
	else{
		hide('paypalrequired');
	}
	if(totalvalue>10000){
		hide('checkoutbutton');
		show('paymenttoohigh');
	}
	else{
		hide('paymenttoohigh');
		show('checkoutbutton');
	}
}