// Anzahl der Tshirts
function quantity(element,action,preis,maximum) {
	var el = document.getElementById(element);
	var el_preis = document.getElementById(element+'_preis');
	
	// Input Elemente updaten
	if (el) {
		if (action=="add") {
			if (parseInt(el.value)<maximum) {
				el.value = parseInt(el.value)+1;
				
			} else {
				alert("Es können nicht mehr als "+maximum+" Exemplare eines Artikels bestellt werden.");
			}
		} else if (action=="remove") {
			if (parseInt(el.value)>0) {
				el.value = parseInt(el.value)-1;
			}
		}
	}
	
	// Labels updaten
	if (el_preis) {
		var htmlstring = el.value*preis;
		if (el.value>0) {
			el_preis.innerHTML = htmlstring.toFixed(2)+' EUR';
		} else {
			el_preis.innerHTML = '';
		}
	}
}

// Bestellung abschicken
function bestellen(url) {
	// Bestellungen überprüfen
	if ($F('selection')=="1") {
		if (!summebestellungen()) {
			alert("Bitte mindestens einen Artikel auswählen");
			return false;
		}
	}
	
	// Felder überprüfen
	if (!$F('vorname') || !$F('nachname') || !$F('strasse') || !$F('plz') || !$F('ort') || !$F('land') || !$F('email') || !$F('telefon') || !$F('bezahlung')) {
		alert("Bitte alle Felder sorgfältig ausfüllen");
		return false;
	}
	
	// Bankeinzug
	if ($F('land') && $F('land')!="AT" && $F('bezahlung') && ($F('bezahlung')=="Bankeinzug" || $F('bezahlung')=="Kreditkarte")) {
		alert('Die Option "Bankeinzug" bzw. "Kreditkarte" ist nur für Bestellungen aus Österreich möglich');
		return false;
	}
	
	// Formular abschicken
	//$('bestellformular').submit()
	formRequestAJAX('bestellformular',url);
}

// Abo Auswahl prüfen
function checkAbo(dontalert) {
	if (!($('abo') && $F('abo'))) {
		if (!dontalert) alert("Bitte ein Abo auswählen");
		return false;
	} else {
		return true;
	}
}

// Abo Info
function aboInfo(aboid,abopr,vkostloc,vkostabr) {
	$$('div.aboinfo').each(function(e) { e.hide() });
	Effect.Pulsate('abo'+aboid, { pulses:1, duration:0.5 });
	$('abo'+aboid).show();
	$('abo').value=aboid;
	$('abopreis').value=abopr;
	$('vkostenloc').value=vkostloc;
	$('vkostenabr').value=vkostabr;
	updateShipping();
}
