
var tmp_count = 0;

function prepareValue(el){
	tmp_count = el.value; 
    if (el.value == '0') el.value = '';
}

function validateNumber (el) {
	el.value = parseInt(el.value);
	if (isNaN(el.value)) el.value = 0;
	if (el.value<0) el.value = 0;
}

function validateInput(el){
	val = parseInt(el.value);
	if (isNaN(val)) val = 0;
	if (val < 0) val = 0;
	if ((val != el.value) && (el.value != '')) {
		val = tmp_count;
		el.value = tmp_count;
	} else tmp_count = val;
    updateCart();
    return true;  
}

function validateEmpty (id) {
    return document.getElementById(id).value.length > 0;
}

function formatFloat(n) {
	//return String(n).match(/\./)?(n+"0").match(/\d+\.\d\d/):n+".00"
    return n.toFixed(2);
}

function countDown (id) {
	var item = document.getElementById('prod_count_'+id);
	if (parseInt(item.value) > 0)
		item.value--;
}

function countUp (id) {
	document.getElementById('prod_count_'+id).value++;
}
