function popup(id, a){
    if(a){
      document.getElementById(id).style.visibility='visible';
    }else{
      document.getElementById(id).style.visibility='hidden';
    }
};

function watch_count(action, id)
{
	document.count.action.value = action;
	document.count.id.value = id;
	document.count.submit();
};

function recount() {
	document.cart.action.value = 'recount';
	document.cart.submit();
}

function shipping(country) {
	if (country) {
		var shippingCost = 80;
		if (country == 'United States') {
			shippingCost = 45;
		}
		var amount = parseInt(document.getElementById('totalAmount').innerHTML);
		document.getElementById('shippingCost').innerHTML = '$'+shippingCost;
		var amShip = amount+shippingCost;
		document.getElementById('amountWithShipping').innerHTML = '$'+formatCost(amShip);
	} else {
		document.getElementById('shippingCost').innerHTML = 'choose country';
		document.getElementById('amountWithShipping').innerHTML = 'choose country';
	}
}

function formatCost(cost) {
	var str = '';
	var cost2 = String(cost);
	var len = cost2.length;
	for (i = 0; i < len; i++) {
		str += cost2.substr(i, 1);
		if ((len-i) % 3 == 1 && i != (len-1)) {
			str += ',';
		}
	}
	return str;
}

function check_order() {
	if (document.getElementById('full_name').value &&
		document.getElementById('email').value &&
		document.getElementById('address').value &&
		document.getElementById('city').value &&
		document.getElementById('zip').value &&
		document.getElementById('country').value) {
		return true;	
	}
    alert('Please fill all fields with *');
	return false;
}