function runden(wert){
wert = String(wert);
if(wert.substr(wert.indexOf(".")+1,wert.length) >=3){

	if(wert.charAt(wert.indexOf(".") + 3) >= 5){
		if(eval(wert.substr(wert.indexOf(".")+1,2)) == 99){
			return(eval(wert.substr(0,wert.indexOf("."))) + 1);
		}else{
			return(eval(wert.substr(0,wert.indexOf("."))) + "." + (eval(wert.substr(wert.indexOf(".")+1,2))+1));
		}
	}else{
		return(eval(wert.substr(0,wert.indexOf("."))) + "." + (eval(wert.substr(wert.indexOf(".")+1,2))));
	}
}else{
	return(wert);
}
}


function berechnen()
	{
			var anzahl = document.order.Anzahl.value;
			var preis = document.order.Preis.value;
			var gesamt = 0.00;
			if (anzahl <= 0)
			{anzahl = 1;}
			{preis = anzahl * 14.95;}
			{total = 5.00 + (anzahl * 14.95);}
	//x = ""+total;
	total = runden(total);
	//y = ""+preis;
	preis = runden(preis);
			document.order.Anzahl.value = anzahl;
			document.order.Preis.value = preis;
			document.order.Gesamtbetrag.value = total;
		
	}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

// OPEN WINDOW /////////////////////////////////////////////////////////////////////////

popWindow=null;
function screen4u_openWindow(theURL,winName,width,height) 
{
	agent=navigator.appVersion;
	version=parseInt(agent);
	
	if (version>=4) 
	{
		leftCorner=screen.width/8 - width/2;
		topCorner=screen.height/2 - height/2;
	}
	else
	{
		leftCorner=20;
		topCorner=20;
	}
	features=",screenX="+leftCorner+",screenY="+topCorner+",left="+leftCorner+",top="+topCorner;
	features=features+",titlebar=1,scrollbars=yes";
	
	//Mac Abfrage weil sonst nicht funktioniert	

	if ((popWindow==null) || (popWindow.closed==true))
	{
		popWindow=window.open(theURL,winName,"width="+width+",height="+height+ features);
		popWindow.focus();
	}
	else
	{
		popWindow.close();
		popWindow=window.open(theURL,winName,"width="+width+",height="+height+ features);
		popWindow.focus();
	}
}

popWindow=null;
function order_openWindow(theURL,winName,width,height) 
{
	agent=navigator.appVersion;
	version=parseInt(agent);
	
	if (version>=4) 
	{
		leftCorner=screen.width/8 - width/2;
		topCorner=screen.height/2 - height/2;
	}
	else
	{
		leftCorner=20;
		topCorner=20;
	}
	features=",screenX="+leftCorner+",screenY="+topCorner+",left="+leftCorner+",top="+topCorner;
	features=features+",titlebar=1";
	
	//Mac Abfrage weil sonst nicht funktioniert	

	if ((popWindow==null) || (popWindow.closed==true))
	{
		popWindow=window.open(theURL,winName,"width="+width+",height="+height+ features);
		popWindow.focus();
	}
	else
	{
		popWindow.close();
		popWindow=window.open(theURL,winName,"width="+width+",height="+height+ features);
		popWindow.focus();
	}
}

// FEHLERMELDUNG //

var fehler = new Image(); fehler.src = "img/error.gif";

var haveerrors = 0;
function showImage(imagename, imageurl, errors) {
document[imagename].src = imageurl;
if (!haveerrors && errors) haveerrors = errors;
}

function CheckForm() {
haveerrors = 0;
(document.order.Gesamtbetrag.value == '' || document.order.Name.value == '' || document.order.Strasse.value == '' || document.order.PLZOrt.value == '' || document.order.Telefon.value == '' || document.order.email.value == '' || document.order.AGB.checked == false)
? showImage("fehlermeldung", "img/error.gif", true)   // no semi-colon after this line!
: showImage("fehlermeldung", "img/no.gif", false); // true = errors, false = no errors

return (!haveerrors);
}
