function setAmount(uid,cat,action,current,price){
	//SET CATS TO ZERO
	if(!eval("window.cat"+cat))eval("cat"+cat+"=0");
	current=parseInt(current);
	switch(action){
		case "inc":
			if(document.getElementById("single"+uid).value>0){
				document.getElementById("single"+uid).value=document.getElementById("overview"+uid).value=current-1;
				eval("cat"+cat+"=parseInt(cat"+cat+")-1");
				document.getElementById("bottleprice").value=(parseInt((document.getElementById("bottleprice").value)*100))/100-price;
				document.getElementById("totalbottles").value=parseInt(document.getElementById("totalbottles").value)-1;
			}
		break;
		case "dec":
			document.getElementById("single"+uid).value=document.getElementById("overview"+uid).value=current+1;
			eval("cat"+cat+"=parseInt(cat"+cat+")+1");
			document.getElementById("bottleprice").value=(parseInt((document.getElementById("bottleprice").value)*100))/100+price;
			document.getElementById("totalbottles").value=parseInt(document.getElementById("totalbottles").value)+1;
		break;
		case "prompt":
			newvalue = prompt("Geben Sie die gewünschte Anzahl ein","");
			newvalue=parseInt(newvalue);
			if(newvalue < 0 || isNaN(newvalue)){
				alert("Bitte geben Sie eine ganze Zahl ein.");
			}
			else {
				oldvalue=document.getElementById("single"+uid).value;
				document.getElementById("single"+uid).value=document.getElementById("overview"+uid).value=newvalue;
				eval("cat"+cat+"=parseInt(cat"+cat+")+newvalue");
				if(oldvalue)eval("cat"+cat+"=parseInt(cat"+cat+")-oldvalue");

				document.getElementById("bottleprice").value=(parseInt((document.getElementById("bottleprice").value)*100)/100)-oldvalue*price+newvalue*price;
				document.getElementById("totalbottles").value=parseInt(document.getElementById("totalbottles").value)+newvalue-oldvalue;
			}
		break;
		default:
			document.getElementById("single"+uid).value=document.getElementById("overview"+uid).value=current;
			eval("cat"+cat+"=parseInt(cat"+cat+")+current");
		break;
	}
	if(document.getElementById("single"+uid).value>0){
		document.getElementById("row"+uid).style.display="table-row";
		document.getElementById("total"+uid).value=number_format(document.getElementById("single"+uid).value*price,2);
	}
	else{
		document.getElementById("row"+uid).style.display="none";
	}

	document.getElementById("bottleprice").value=number_format(document.getElementById("bottleprice").value,2);

	if(eval("cat"+cat+">0"))document.getElementById("cat"+cat).style.display="none";
	else document.getElementById("cat"+cat).style.display="table-row";
}

function step(where){
//document.getElementById("bottleprice").value=0;
//document.getElementById("totalbottles").value=0;
	switch(where){
		default:
			$("#wizard").accordion("activate",where);
		break;
		case 1:
			if(document.getElementById("totalbottles").value > 5)$("#wizard").accordion("activate",where);
			else alert("Die Mindestbestellmenge beträgt 6 Flaschen");
		break;
		case 2:
			country();
			if(formCheck())$("#wizard").accordion("activate",where);
		break;
		case 3:
			
			//;
		break;
	}
}

function calcShipping(sixPackPrice,twelvePackPrice){
	totalbottles=document.getElementById("totalbottles").value;

	twelvepack=0;
	sixpack=0;
	while(totalbottles>=12){
		totalbottles=totalbottles-12;
		twelvepack++;
	}
	if (totalbottles>=6){
		totalbottles=totalbottles-6;
		sixpack=1;
	}
	if (totalbottles!=0){
		if(sixpack){
			sixpack--;
			twelvepack++;
		}
		else sixpack=1;
	}
	document.getElementById("shippingprice").value=sixpack*sixPackPrice+twelvepack*twelvePackPrice;
	document.getElementById("sland").innerHTML=document.getElementById("land").options[document.getElementById("land").selectedIndex].value;
	document.getElementById("totalprice").value=(parseInt((document.getElementById("shippingprice").value)*100)+parseInt((document.getElementById("bottleprice").value)*100))/100;
}

function country(){
	switch(document.getElementById("land").options[document.getElementById("land").selectedIndex].value){
		case 'Österreich':
		sixPackPrice=5.45;
		twelvePackPrice=7.12;
		break;
		case 'Deutschland':
		sixPackPrice=10.9;
		twelvePackPrice=13.08;
		break;
		case 'Belgien':
		sixPackPrice=13.08;
		twelvePackPrice=15.55;
		break;
		case 'Dänemark':
		sixPackPrice=14.32;
		twelvePackPrice=16.57;
		break;
		case 'Spanien':
		sixPackPrice=34.88;
		twelvePackPrice=37.14;
		break;
		case 'Frankreich':
		sixPackPrice=17.3;
		twelvePackPrice=20.49;
		break;
		case 'Großbritannien':
		sixPackPrice=16.28;
		twelvePackPrice=18.46;
		break;
		case 'Irland':
		sixPackPrice=29.07;
		twelvePackPrice=31.25;
		break;
		case 'Italien':
		sixPackPrice=19.19;
		twelvePackPrice=21.37;
		break;
		case 'Luxemburg':
		sixPackPrice=13.08;
		twelvePackPrice=15.55;
		break;	
		case 'Niederlande':
		sixPackPrice=13.08;
		twelvePackPrice=15.55;
		break;
		case 'Portugal':
		sixPackPrice=43.24;
		twelvePackPrice=45.64;
		break;
	}
	calcShipping(sixPackPrice,twelvePackPrice);
}

function formCheck(){
	var valid=true;
	var reqfields=new Array('uvorname','unachname','ustrasse','uplz','uort','utel','uemail');
	for(i=0;i<reqfields.length;i++){
		if(document.getElementById(reqfields[i]).value==""){
			valid=false;
			document.getElementById('l'+reqfields[i]).style.color='red';
		}
		else{
			document.getElementById('l'+reqfields[i]).style.color='black';
		}
		
	}

	/**/
	document.getElementById('svorname').innerHTML=document.getElementById('uvorname').value;
	document.getElementById('snachname').innerHTML=document.getElementById('unachname').value;
	if(document.getElementById('ufirma').value!='')document.getElementById('sfirma').innerHTML=' ('+document.getElementById('ufirma').value+')';
	adresse=document.getElementById('ustrasse').value+'<br />';
	adresse+=document.getElementById('uplz').value+' ';
	adresse+=document.getElementById('uort').value+'<br />';
	adresse+=document.getElementById("land").options[document.getElementById("land").selectedIndex].value
	document.getElementById('sadresse').innerHTML=adresse;
	document.getElementById('skommentar').innerHTML='Kommentar: '+document.getElementById('ukommentar').value;
	document.getElementById('semail').innerHTML=document.getElementById('uemail').value;
	document.getElementById('stel').innerHTML=document.getElementById('utel').value;
	document.getElementById('stotalprice').innerHTML=document.getElementById("totalprice").value;
	document.getElementById('ordertextstorage').value=document.getElementById("ordertext").innerHTML;

	if(valid)return true;

}




