function clr() {
	document.getElementsByName("suche") [0].value = "";
}
	
function suchMail(min) {
	MailFenster = window.open("./mail_suche.php?min="+min, "mail","toolbar=no,status=no,scrollbars=yes,resizable=yes,width=540,height=550");
	MailFenster.focus();
}
	
function ViewArt(min) {
	//alert('Artikel = '+min);
	MeinFenster = window.open("./show_art.php?min="+min, "detail", "toolbar=no, status=no, scrollbars=yes, resizable=yes, width=740, height=600, top=40, left=40");
	MeinFenster.focus();
}
	
function helpSearch() {
	InfoFenster = window.open("./help_search.php", "info", "toolbar=no, status=no, scrollbars=yes, resizable=yes, width=540, height=400" );
	InfoFenster.focus();
}
	
function deciCorr(value) {
	if (value<=0.99) {
		newEuro = '0';
	} else {
		newEuro = parseInt(value);
	}
	newCents = parseInt((value+.0008 - newEuro)* 100);
	if (eval(newCents) <= 9) newCents='0'+newCents;
	newString = newEuro + '.' + newCents;
	return (newString);
}
 
function addItem(min, qty, price) {
	if (qty <= 0) {
		alert('Eingabefehler!\n\nBitte geben Sie eine Stückzahl ein');
		return false;
	}
	kurz = document.getElementsByName("kurz"+min) [0].value;
	if (confirm(''+qty+' x "'+ kurz +'" zu EUR '+deciCorr(price)+' zum Einkaufwagen hinzufügen')) {
		index = document.cookie.indexOf("ShopCart");
		countstart = (document.cookie.indexOf("=", index) + 1);
		countend = document.cookie.indexOf(";", index);
		if (countend == -1) {
			countend = document.cookie.length;
		}
		document.cookie="ShopCart="+document.cookie.substring(countstart, countend)+"["+min+","+deciCorr(price)+"#"+qty+"]";
	}
	inCart();
	return true;
}
 
function inCart() {
	index = document.cookie.indexOf("ShopCart");
	countstart = (document.cookie.indexOf("=", index) + 1);
	countend = document.cookie.indexOf(";", index);
	if (countend == -1) {
		countend = document.cookie.length;
	}
	fulllist = document.cookie.substring(countstart, countend);
	stueck = 0;
	for (var i = 0; i <= fulllist.length; i++) {
		if (fulllist.substring(i,i+1) == '[') {
			itemstart = i+1;
		} else if (fulllist.substring(i,i+1) == ']') {
			itemend = i;
			thequantity = fulllist.substring(itemstart, itemend);
			stueck = stueck + (eval(thequantity));
		} else if (fulllist.substring(i,i+1) == '#') {
			//theprice = fulllist.substring(itemstart, i);
			itemstart = i+1;
		}
	}
	if(stueck == 0) {
		document.getElementsByName("wagen") [0].value = 'Ihr Einkaufswagen ist leer';
	} else {
		document.getElementsByName("wagen") [0].value = 'Einkaufswagen: '+stueck+' Artikel';
	}
}

