
var prices = new Array();

function updatePrice(t) {
	
	if (typeof(prices) == "undefined" || prices == null) {
		prices = new Array();
	}
	
	var price = 0.00;
	
	if (t < 20) {
		price = <?php echo $firstPrice;?>;
	} else if (t > 19 && t < 100) {
		price = <?php echo $secondPrice;?>;
	} else if (t > 99) {
		price = <?php echo $thirdPrice;?>;
	}
	document.getElementById('example_quantity').innerHTML = t;
	document.getElementById('example_price').innerHTML = price;
	document.getElementById('real_quantity').value = t;	
	document.getElementById('real_price').value = price;
	document.getElementById('user_price').innerHTML = t * price;
}

function updateShipping(t) {
	var shipping = 2.00;
	if (t > 5 && t < 100)
		shipping = 4.95;
	if (t >= 100)
		shipping = 0.0;
	document.getElementById('real_shipping').value = shipping;
	document.getElementById('user_shipping').innerHTML = shipping;

}

function updateQuantity() {
	var t = document.getElementById('user_quantity').value;
	t = t.replace(/[^0-9]/g, '');	
	if (t == '') {
		document.getElementById('user_quantity').value = 0;
		document.getElementById('real_quantity').value = 0;			
	}
	
	document.getElementById('user_quantity').value = t;
	updatePrice(t);
	updateShipping(t);
}

