function buy_item(item,amount,amount2) {
	if(amount%amount2 == 0) {
		; //OK
	}
	else {
		amountopr = amount2*Math.ceil(amount/amount2);
		alert("Nie je možné objednať "+amount+"ks (balené po "+amount2+").\nDávam preto do košíka "+amountopr+"ks.");
		amount = amountopr;
	}
	
	var color;
	if(document.getElementById("color_value"))
		color = document.getElementById("color_value").innerHTML;
	else
		color = "";
		
	var size;
	if(document.getElementById("select_size"))
		size = document.getElementById("select_size").value;
	else
		size = "";
	
	//window.open('buy.php?mid='+item+'&amount='+amount+'&color='+color+'&size='+size,'editWindow','resizable=no,scrollbars=no,status=yes,width=730,height=550,menubar=no');
	
	window.open('buy.php?mid='+item+'&amount='+amount+'&color='+color+'&size='+size,'editWindow','resizable=no,scrollbars=no,status=yes,width=730,height=550,menubar=no');
}

function toggle_basket_div() {
	var div = document.getElementById("basket_div");
	if(div.style.display=="none")
		div.style.display="block";
	else
		div.style.display="none";
}

function color_thumb_change(sel) {
	
	document.getElementById("color_value").innerHTML = document.getElementById("color_"+sel.value).innerHTML;

	for(var i=0; i!=-1; i++) {
		var img = document.getElementById("color_thumb_"+i);
		if(!img) break;
		
		if(i==sel.value)
			img.style.display="inline";
		else
			img.style.display="none";
	}
}