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("select_color"))
		color = document.getElementById("select_color").value;
	else
		color = "";
		
	var color2;
	if(document.getElementById("select_color2"))
		color2 = document.getElementById("select_color2").value;
	else
		color2 = "";
		
	var size;
	if(document.getElementById("select_size"))
		size = document.getElementById("select_size").value;
	else
		size = "";
		
	var height;
	if(document.getElementById("select_height"))
		height = document.getElementById("select_height").value;
	else
		height = "";
	
	//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.location = 'index.php?action=buy&mid='+item+'&amount='+amount+'&color='+color+'&color2='+color2+'&size='+size+'&height='+height+'&p=_cart';
}

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";
	}
}