function isNumberKey(evt){
   	var charCode = (evt.which) ? evt.which : event.keyCode
  	 if (charCode > 31 && (charCode < 48 || charCode > 57)){
      	return false;
	}
   return true;
}

function trim (zeichenkette) {
  		return zeichenkette.replace (/^\s+/, '').replace (/\s+$/, '');
}

function sendauftrag(){
	theForm	= document.forms["gravurtext"];
	theForm.action = "Steingravur-onlineshop-Autrag.php";
	/*if(theForm.checkagb.checked == 0){
		alert("Bitte bestätigen Sie unsere AGB's");
		return false;
	} else{
		theForm.submit();
	}*/
	theForm.submit();
	//
}

function sendmpay24(){
	theForm	= document.forms["gravurtext"];
	
	/*if(theForm.checkagb.checked == 0){
		alert("Bitte bestätigen Sie unsere AGB's");
		return false;
	} */

	
	/*
	http_request.open('POST', 'ajaxCall.php', true);
	http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http_request.send("contentUrl=ajaxWritebestellung.php&RegionId="+document.forms['gravurtext'].friedhofselect.value);
	PostData	= windowURL;
	PostData	= PostData + 'theForm.preisgesamtbrutto.value'+;
	 */
	
	windowName 	= "initmpay24";
	windowURL 	= 'initmpay24.php' + '?';	
	windowURL	= windowURL + 'TID=' + escape(theForm.TID.value) + '&';
	windowURL  	= windowURL + 'preisgravur=' +  escape(theForm.preisgravur.value) + '&';
	windowURL  	= windowURL + 'stueckvergolden=' +  escape(theForm.nachvergoldung.value) + '&';
	windowURL  	= windowURL + 'preisvergolden=' +  escape(theForm.preisvergolden.value) + '&';
	windowURL  	= windowURL + 'stueckfaerben=' +  escape(theForm.nachfaerben.value) + '&';
	windowURL 	= windowURL + 'preisnachfaerben=' +  escape(theForm.preisnachfaerben.value) + '&';
	windowURL  	= windowURL + 'preisexpress=' +  escape(theForm.preisexpress.value) + '&';
	windowURL  	= windowURL + 'preisnachlass=' +  escape(theForm.preisnachlass.value) + '&';
	windowURL  	= windowURL + 'fruebucherbonus=' +  escape(theForm.fruebucherbonus.value) + '&';
	windowURL  	= windowURL + 'preisgesamtnetto=' +  escape(theForm.preisgesamtnetto.value) + '&';
	windowURL  	= windowURL + 'preisgesamtsteuer=' +  escape(theForm.preisgesamtsteuer.value) + '&';
	windowURL  	= windowURL + 'preisgesamtbrutto=' +  escape(theForm.preisgesamtbrutto.value)+ '&';
	windowURL  	= windowURL + 'friedhofselect=' +  escape(theForm.friedhofselect.value)+ '&';
	windowURL  	= windowURL + 'friedhofort=' +  escape(theForm.friedhofort.value)+ '&';
	windowURL  	= windowURL + 'ptitel=' +  escape(theForm.ptitel.value)+ '&';
	windowURL  	= windowURL + 'pvorname=' +  escape(theForm.pvorname.value)+ '&';
	windowURL  	= windowURL + 'pfamilienname=' +  escape(theForm.pfamilienname.value)+ '&';
	windowURL  	= windowURL + 'pgtag=' +  escape(theForm.pgtag.value)+ '&';
	windowURL  	= windowURL + 'pgmonat=' +  escape(theForm.pgmonat.value)+ '&';
	windowURL  	= windowURL + 'pgjahr=' +  escape(theForm.pgjahr.value)+ '&';
	windowURL  	= windowURL + 'pstag=' +  escape(theForm.pstag.value)+ '&';
	windowURL  	= windowURL + 'psmonat=' +  escape(theForm.psmonat.value)+ '&';
	windowURL  	= windowURL + 'psjahr=' +  escape(theForm.psjahr.value)+ '&';
	windowURL  	= windowURL + 'zusatztext=' +  escape(theForm.zusatztext.value)+ '&';
	windowURL  	= windowURL + 'farbe=' +  escape(theForm.farbe.value)+ '&';
	windowURL  	= windowURL + 'rueckruffarbe=' +  escape(theForm.rueckruffarbe.value)+ '&';
	windowURL  	= windowURL + 'sofortservice=' +  escape(theForm.rueckruffarbe.value)+ '&';
	windowURL  	= windowURL + 'titel=' +  escape(theForm.titel.value)+ '&';
	windowURL  	= windowURL + 'vorname=' +  escape(theForm.vorname.value)+ '&';
	windowURL  	= windowURL + 'nachname=' +  escape(theForm.nachname.value)+ '&';
	windowURL  	= windowURL + 'strasse=' +  escape(theForm.strasse.value)+ '&';
	windowURL  	= windowURL + 'plz=' +  escape(theForm.plz.value)+ '&';
	windowURL  	= windowURL + 'tel=' +  escape(theForm.tel.value)+ '&';
	windowURL  	= windowURL + 'email=' +  escape(theForm.email.value)+ '&';
	windowURL  	= windowURL + 'friedhof=' +  escape(theForm.friedhof.value)+ '&';
	windowURL  	= windowURL + 'grabname=' +  escape(theForm.grabname.value)+ '&';
	windowURL  	= windowURL + 'gruppe=' +  escape(theForm.gruppe.value)+ '&';
	windowURL  	= windowURL + 'reihe=' +  escape(theForm.reihe.value)+ '&';
	windowURL  	= windowURL + 'grabnummer=' +  escape(theForm.grabnummer.value)+ '&';
	windowURL  	= windowURL + 'fotoservice=' +  escape(theForm.fotoservice.value)+ '&';
	windowURL  	= windowURL + 'gutschein=' +  escape(theForm.gutschein.value)+ '&';
	windowURL  	= windowURL + 'anmerkung=' +  escape(theForm.anmerkung.value);
	
	myWindow = window.open(windowURL, windowName, 'height=400, width=640');
	myWindow.focus();
}

function checkfriedhof(){
	if(document.forms['gravurtext'].friedhofselect.value == 'andere'){
		document.getElementById("friedhofandere").style.display = 'block';
		document.getElementById("infotextfriedhof").style.display = 'block';
		document.getElementById("bestellung").innerHTML= "4. Anfrage";
		document.getElementById("maininput").style.display = 'block';
		document.getElementById("infotextfriedhof").innerHTML= document.getElementById("infotextfriedhofAnfrage").innerHTML;
		top.faktor 		= 0;
		top.vergolden 	= 0;
		top.faerben 	= 0;
		top.express 	= 0;
	}else if (document.forms['gravurtext'].friedhofselect.value == ''){
			document.getElementById("infotextfriedhof").innerHTML= document.getElementById("infotextfriedhofLeer").innerHTML;
			
			document.getElementById("maininput").style.display = 'none';
	}else if (document.forms['gravurtext'].friedhofselect.value != ''){
		document.getElementById("friedhofandere").style.display = 'none';
		//document.getElementById("infotextfriedhof").style.display = 'none';
		document.getElementById("bestellung").innerHTML= "4. Bestellung";
		document.getElementById("infotextfriedhof").innerHTML= document.getElementById("infotextfriedhofBestellung").innerHTML;
		http_request = false;
		http_request = getHTTPRequest();
		http_request.onreadystatechange = function(){
			if (http_request.readyState == 4) {
				if (http_request.status == 200) {
					x = http_request.responseXML.documentElement.getElementsByTagName("item");
					for (i=0;i<x.length;i++){
						nodefaktor 			= x[i].getElementsByTagName('faktor').item(0);
						nodevergolden 		= x[i].getElementsByTagName('vergolden').item(0);
						nodefaerben 		= x[i].getElementsByTagName('faerben').item(0);
						nodeexpress 		= x[i].getElementsByTagName('express').item(0);
						nodeexpressaktiv 	= x[i].getElementsByTagName('expressaktiv').item(0);
						top.faktor 		= nodefaktor.firstChild.data;
						top.vergolden 	= nodevergolden.firstChild.data;
						top.faerben 	= nodefaerben.firstChild.data;
						top.express 	= nodeexpress.firstChild.data;
						expressaktiv 	= nodeexpressaktiv.firstChild.data;
						getberechnung();
						if (expressaktiv == 1){
							document.getElementById("sofortservicehidden").style.display = 'block';
						}else{
							document.getElementById("sofortservicehidden").style.display = 'none';
						}
					}
					document.getElementById("maininput").style.display = 'block';
				} else {
					alert('Bei dem Request ist ein Problem aufgetreten.');
				}
			}
		}

		http_request.open('POST', 'ajaxCall.php', true);
		http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http_request.send("contentUrl=ajaxCallRegionGet.php&RegionId="+document.forms['gravurtext'].friedhofselect.value);
		
	}
}


function getHTTPRequest(){
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
			// zu dieser Zeile siehe weiter unten
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		try {
			http_request = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {}
		}
	}
	
	if (!http_request) {
		alert('Ende :( Kann keine XMLHTTP-Instanz erzeugen');
		return false;
	}
	else{
		return http_request;
	}
}

function getberechnung(){
	form = document.forms["gravurtext"];
	calculation();
}


function array_diff (array) {
	// http://kevin.vanzonneveld.net
	// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// * example 1: array_diff(['Kevin', 'van', 'Zonneveld'], ['van', 'Zonneveld']);
	// * returns 1: ['Kevin']
	var arr_dif = [], i = 1, argc = arguments.length, argv = arguments, key, key_c, found=false, cntr=0;
	// loop through 1st array
	for ( key in array ){
		// loop over other arrays
		for (i = 1; i < argc; i++){
			// find in the compare array
			found = false;
				for (key_c in argv[i]) {
					if (argv[i][key_c] == array[key]) {
						found = true;
						break;
					}
				}
	
			if(!found){
				//arr_dif[key] = array[key];
				arr_dif[cntr] = array[key];
				cntr++;
			}
		}
	}
return arr_dif;
};


function array_push ( array ) { 
// Pushes elements onto the end of the array   
//  
// version: 810.114 
// discuss at: http://phpjs.org/functions/array_push 
// +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 
// *     example 1: array_push(['kevin','van'], 'zonneveld'); 
// *     returns 1: 3 
var i, argv = arguments, argc = argv.length; 
for (i=1; i < argc; i++){ 
	array[array.length++] = argv[i]; 
} 
return array.length; 
}

function in_array (needle, haystack, argStrict) {     
// Checks if the given value exists in the array     
//     
// version: 908.406    
// discuss at: http://phpjs.org/functions/in_array   
// +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)   
// +   improved by: vlado houba     
// *     example 1: in_array('van', ['Kevin', 'van', 'Zonneveld']);     
// *     returns 1: true   
// *     example 2: in_array('vlado', {0: 'Kevin', vlado: 'van', 1: 'Zonneveld'});    
// *     returns 2: false    
// *     example 3: in_array(1, ['1', '2', '3']);     
// *     returns 3: true    
// *     example 3: in_array(1, ['1', '2', '3'], false);     
// *     returns 3: true     
// *     example 4: in_array(1, ['1', '2', '3'], true);    
// *     returns 4: false     
var key = '', strict = !!argStrict; 
if (strict) {        
	for (key in haystack) {            
		if (haystack[key] === needle) {
			return true; 
		}
	}     
} else {
	for (key in haystack) {
		if (haystack[key] == needle) { 
				return true; 
			}
		}
	}  
	return false; 
}

function str_replace(search, replace, subject) {
    return subject.split(search).join(replace);
}



function calculation(){
	arraytocheck = [];
	array1 = [];
	pauschalefound = false;
	for (i=0; i < document.gravurtext.length;i++){
		if (trim(document.gravurtext.elements[i].value) != ''){
			array_push(arraytocheck, document.gravurtext.elements[i].name);
		}
	}

	//1 
	array1[0] = ['ptitel', 'pvorname', 'pfamilienname', 'pgtag', 'pgmonat', 'pgjahr', 'pstag', 'psmonat', 'psjahr'];
	array1[1] = arraytocheck;
	difference = array_diff (array1[0],array1[1]);
	if (difference.length == 0 && pauschalefound == false){
		var pauschalefound = true;
		var pauschale = pauschale1;
	}
	
	//2
	array1[0] = ['pvorname', 'pfamilienname', 'pgtag', 'pgmonat', 'pgjahr', 'pstag', 'psmonat', 'psjahr'];
	array1[1] = arraytocheck;
	difference = array_diff (array1[0],array1[1]);
	if (difference.length == 0 && pauschalefound == false){
		var pauschalefound = true;
		var pauschale = pauschale1;
	}
	
	//3
	array1[0] = ['pvorname', 'pfamilienname', 'pgjahr', 'psjahr'];
	array1[1] = arraytocheck;
	difference = array_diff (array1[0],array1[1]);
	if (difference.length == 0 && pauschalefound == false){
		var pauschalefound = true;
		var pauschale = pauschale1;
	}
	
	//4
	array1[0] = ['ptitel', 'pvorname', 'pgtag', 'pgmonat', 'pgjahr', 'pstag', 'psmonat', 'psjahr'];
	array1[1] = arraytocheck;
	difference = array_diff (array1[0],array1[1]);
	if (difference.length == 0 && pauschalefound == false){
		var pauschalefound = true;
		var pauschale = pauschale1;
	}
	
	//5
	array1[0] = ['pvorname', 'pgtag', 'pgmonat', 'pgjahr', 'pstag', 'psmonat', 'psjahr'];
	array1[1] = arraytocheck;
	difference = array_diff (array1[0],array1[1]);
	if (difference.length == 0 && pauschalefound == false){
		var pauschalefound = true;
		var pauschale = pauschale1;
	}
	
	//22
	array1[0] = ['pfamilienname', 'pgtag', 'pgmonat', 'pgjahr', 'pstag', 'psmonat', 'psjahr'];
	array1[1] = arraytocheck;
	difference = array_diff (array1[0],array1[1]);
	if (difference.length == 0 && pauschalefound == false){
		var pauschalefound = true;
		var pauschale = pauschale1;
	}
	//6
	array1[0] = ['ptitel', 'pvorname', 'pfamilienname'];
	array1[1] = arraytocheck;
	difference = array_diff (array1[0],array1[1]);
	if (difference.length == 0 && pauschalefound == false){
		var pauschalefound = true;
		var pauschale = pauschale1;
	}
	
	//7
	array1[0] =  ['pvorname', 'pfamilienname'];
	array1[1] = arraytocheck;
	difference = array_diff (array1[0],array1[1]);
	if (difference.length == 0 && pauschalefound == false){
		var pauschalefound = true;
		var pauschale = pauschale1;
	}
	
	//8
	array1[0] =  ['ptitel', 'pvorname', 'pgjahr', 'psjahr'];
	array1[1] = arraytocheck;
	difference = array_diff (array1[0],array1[1]);
	if (difference.length == 0 && pauschalefound == false){
		var pauschalefound = true;
		var pauschale = pauschale2;
	}
	
	//9
	array1[0] =  ['pvorname', 'pgjahr', 'psjahr'];
	array1[1] = arraytocheck;
	difference = array_diff (array1[0],array1[1]);
	if (difference.length == 0 && pauschalefound == false){
		var pauschalefound = true;
		var pauschale = pauschale2;
	}
	
	//10
	array1[0] =  ['ptitel', 'pvorname', 'psjahr'];
	array1[1] = arraytocheck;
	difference = array_diff (array1[0],array1[1]);
	if (difference.length == 0 && pauschalefound == false){
		var pauschalefound = true;
		var pauschale = pauschale2;
	}
	
	//11
	array1[0] = ['pvorname', 'psjahr'];
	array1[1] = arraytocheck;
	difference = array_diff (array1[0],array1[1]);
	if (difference.length == 0 && pauschalefound == false){
		var pauschalefound = true;
		var pauschale = pauschale2;
	}
	
	
	//12
	array1[0] = ['ptitel', 'pvorname'];
	array1[1] = arraytocheck;
	difference = array_diff (array1[0],array1[1]);
	if (difference.length == 0 && pauschalefound == false){
		var pauschalefound = true;
		var pauschale = pauschale2;
	}
	
	//13
	array1[0] =  ['pvorname'];
	array1[1] = arraytocheck;
	difference = array_diff (array1[0],array1[1]);
	if (difference.length == 0 && pauschalefound == false){
		var pauschalefound = true;
		var pauschale = pauschale2;
	}
	
	//14
	array1[0] =  ['pfamilienname'];
	array1[1] = arraytocheck;
	difference = array_diff (array1[0],array1[1]);
	if (difference.length == 0 && pauschalefound == false){
		var pauschalefound = true;
		var pauschale = pauschale2;
	}
	
	//15
	array1[0] =  ['pgtag', 'pgmonat', 'pgjahr', 'pstag', 'psmonat', 'psjahr'];
	array1[1] = arraytocheck;
	difference = array_diff (array1[0],array1[1]);
	if (difference.length == 0 && pauschalefound == false){
		var pauschalefound = true;
		var pauschale = pauschale2;
	}
	
	//16
	array1[0] =  ['pstag', 'psmonat', 'psjahr'];
	array1[1] = arraytocheck;
	difference = array_diff (array1[0],array1[1]);
	if (difference.length == 0 && pauschalefound == false){
		var pauschalefound = true;
		var pauschale = pauschale3;
	}
	
	//17
	array1[0] = ['pgjahr', 'psjahr']; 
	array1[1] = arraytocheck;
	difference = array_diff (array1[0],array1[1]);
	if (difference.length == 0 && pauschalefound == false){
		var pauschalefound = true;
		var pauschale = pauschale3;
	}
	
	//18
	array1[0] =  ['psjahr'];
	array1[1] = arraytocheck;
	difference = array_diff (array1[0],array1[1]);
	if (difference.length == 0 && pauschalefound == false){
		var pauschalefound = true;
		var pauschale = pauschale4;
	}
	
	array1[0] =  ['ptitel'];
	array1[1] = arraytocheck;
	difference = array_diff (array1[0],array1[1]);
	if (difference.length == 0 && pauschalefound == false){
		var pauschalefound = true;
		var pauschale = pauschale4;
	}
	
	//19
	array1[0] =  ['ptitel', 'pgtag', 'pgmonat', 'pstag', 'psmonat'];
	array1[1] = arraytocheck;
	difference = array_diff (array1[0],array1[1]);
	if (difference.length == 0 && pauschalefound == false){
		var pauschalefound = true;
		var pauschale = pauschale2;
	}
	
	//20
	array1[0] = ['pgtag', 'pgmonat', 'pstag', 'psmonat'];  
	array1[1] = arraytocheck;
	difference = array_diff (array1[0],array1[1]);
	if (difference.length == 0 && pauschalefound == false){
		var pauschalefound = true;
		var pauschale = pauschale3;
	}
	
	var textberechnen = trim(document.forms['gravurtext'].zusatztext.value);
	textberechnen 	= str_replace('.', '', textberechnen);
	textberechnen 	= str_replace(',', '', textberechnen);
	textberechnen 	= str_replace(' ', '', textberechnen);
	textberechnen 	= str_replace('\r\n', '', textberechnen);
	textberechnen 	= str_replace('\n', '', textberechnen);
	textberechnen 	= str_replace('\r', '', textberechnen);
	if (textberechnen.length > 0){
		if (!pauschale || pauschale < pauschale1){
			pauschale = pauschale1;
			if (textberechnen.length > 10){
				pauschale = pauschale + (textberechnen.length -10);
			}
		}else{
			pauschale = pauschale + textberechnen.length;
		}
	}
	
	preisgravur = 0;
	preisgravur = pauschale * top.faktor;
	document.forms['gravurtext'].preisgravur.value = CurrencyFormatted(preisgravur);
	 
	if (!preisgravur){
		preisgravur = 0;
	}
	
	preisexpress = 0;
	if (document.forms['gravurtext'].sofortservice.checked == true){
		preisexpress = top.express;
	}
	document.forms['gravurtext'].preisexpress.value = CurrencyFormatted(preisexpress);
	
	
	
	preisvergolden = 0;
	nachvergoldunganzahl = document.forms['gravurtext'].nachvergoldung.value;
	if (nachvergoldunganzahl > 0 ){
		preisvergolden = nachvergoldunganzahl * top.vergolden;
	}
	document.forms['gravurtext'].preisvergolden.value =	CurrencyFormatted(preisvergolden);
	
 	preisnachfaerben = 0;
	nachfaerbenanzahl = document.forms['gravurtext'].nachfaerben.value;
	if (nachfaerbenanzahl > 0 ){
		preisnachfaerben = nachfaerbenanzahl * top.faerben;
	}
	document.forms['gravurtext'].preisnachfaerben.value = CurrencyFormatted(preisnachfaerben);
	
	preisgesamtnetto = (parseFloat(preisexpress) + parseFloat(preisvergolden)  +  parseFloat(preisnachfaerben) + parseFloat(preisgravur) ) ;
	fruebucher = 0;
	//alert(document.forms['gravurtext'].fruebucher.checked);
	if (document.forms['gravurtext'].fruebucher.checked == true && parseFloat(preisgesamtnetto) > 150 ){
		
		fruebucher = 10;
		preisgesamtnetto = (parseFloat(preisexpress) + parseFloat(preisvergolden)  +  parseFloat(preisnachfaerben) + parseFloat(preisgravur) -10 ) ;
	}
	document.forms['gravurtext'].fruebucherbonus.value = fruebucher;
	
	
	document.forms['gravurtext'].preisgesamtnetto.value = CurrencyFormatted(preisgesamtnetto);
	
	preisgesamtsteuer = (preisgesamtnetto * 20)/100;
	document.forms['gravurtext'].preisgesamtsteuer.value = CurrencyFormatted(preisgesamtsteuer);
	
	preisgesamtbrutto = preisgesamtnetto + preisgesamtsteuer;
	document.forms['gravurtext'].preisgesamtbrutto.value = CurrencyFormatted(preisgesamtbrutto);
	

	
	
	drawbasket();
} 



function getgutschein(){
	form = document.forms["gravurtext"];
	var gutschein = trim(document.forms['gravurtext'].gutschein.value);

	if (in_array(trim(form.gutschein.value), top.codenr, 'false') == true){
		if (parseFloat(document.forms['gravurtext'].preisgesamtbrutto.value) > 150){
			document.forms['gravurtext'].preisnachlass.value = 10;
			document.forms['gravurtext'].preisgesamtnetto.value = (parseFloat(document.forms['gravurtext'].preisexpress.value) + parseFloat(document.forms['gravurtext'].preisvergolden.value)  +  parseFloat(document.forms['gravurtext'].preisnachfaerben.value) + parseFloat(document.forms['gravurtext'].preisgravur.value)-10 ) ;
		}
	}else{
		document.forms['gravurtext'].preisnachlass.value = 0;
		document.forms['gravurtext'].preisgesamtnetto.value = (parseFloat(document.forms['gravurtext'].preisexpress.value) + parseFloat(document.forms['gravurtext'].preisvergolden.value)  +  parseFloat(document.forms['gravurtext'].preisnachfaerben.value) + parseFloat(document.forms['gravurtext'].preisgravur.value)) ;
	}
	document.forms['gravurtext'].preisgesamtsteuer.value = (parseFloat(document.forms['gravurtext'].preisgesamtnetto.value) * 20)/100;
	document.forms['gravurtext'].preisgesamtbrutto.value = (parseFloat(document.forms['gravurtext'].preisgesamtnetto.value) + parseFloat(document.forms['gravurtext'].preisgesamtsteuer.value));
	drawbasket();
	
}



function drawbasket(){	
	output = '<table>';
	if (document.forms['gravurtext'].preisgravur.value != 0){
		output = output+'<tr><td>Gravur:</td><td align="right">'+CurrencyFormatted(document.forms['gravurtext'].preisgravur.value)+'</td></tr>';
	}
	
	if (document.forms['gravurtext'].preisvergolden.value != 0){
		output = output+'<tr><td>Nachvergoldung:</td><td align="right">'+CurrencyFormatted(document.forms['gravurtext'].preisvergolden.value)+'</td></tr>';
	}
	
	if (document.forms['gravurtext'].preisnachfaerben.value != 0){
		output = output+'<tr><td>Nachfärben:</td><td align="right">'+CurrencyFormatted(document.forms['gravurtext'].preisnachfaerben.value)+'</td></tr>';
	}
	
	if (document.forms['gravurtext'].preisexpress.value != 0){
		output = output+'<tr><td>Sofortservice:</td><td align="right">'+CurrencyFormatted(document.forms['gravurtext'].preisexpress.value)+'</td></tr>';
	}
	
	if (document.forms['gravurtext'].preisnachlass.value != 0){
		output = output+'<tr><td>Gutschein:</td><td align="right">-'+CurrencyFormatted(document.forms['gravurtext'].preisnachlass.value)+'</td></tr>';
	}
	
	if (document.forms['gravurtext'].fruebucherbonus.value != 0){
		output = output+'<tr><td>Winterbonus:</td><td align="right">-'+CurrencyFormatted(document.forms['gravurtext'].fruebucherbonus.value)+'</td></tr>';
	}
	
	if (document.forms['gravurtext'].preisgesamtnetto.value != 0){
		output = output+'<tr><td>&nbsp;</td><td>&nbsp;</td></tr>';
		output = output+'<tr class="doubleline"><td><strong>Netto:</strong></td><td align="right">'+CurrencyFormatted(document.forms['gravurtext'].preisgesamtnetto.value)+'</td></tr>';
	}
	
	
	
	if (document.forms['gravurtext'].preisgesamtsteuer.value != 0){
		output = output+'<tr><td>20% Mwst:</td><td align="right">'+CurrencyFormatted(document.forms['gravurtext'].preisgesamtsteuer.value)+'</td></tr>';
	}
	
	if (document.forms['gravurtext'].preisgesamtbrutto.value != 0){
		output = output+'<tr><td>&nbsp;</td><td>&nbsp;</td></tr>';
		output = output+'<tr><td><strong>Gesamt:</strong></td><td align="right"><strong>'+CurrencyFormatted(document.forms['gravurtext'].preisgesamtbrutto.value)+'</strong></td></tr>';
	}
	output =  output+'</table>';
	document.getElementById("rechner2").innerHTML = output;
} 

function CurrencyFormatted(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
}

function intval( mixed_var, base ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: stensi
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: intval('Kevin van Zonneveld');
    // *     returns 1: 0
    // *     example 2: intval(4.2);
    // *     returns 2: 4
    // *     example 3: intval(42, 8);
    // *     returns 3: 42
    // *     example 4: intval('09');
    // *     returns 4: 9
 
    var tmp;
 
    var type = typeof( mixed_var );
 
    if(type == 'boolean'){
        if (mixed_var == true) {
            return 1;
        } else {
            return 0;
        }
    } else if(type == 'string'){
        tmp = parseInt(mixed_var * 1, 10);
        if(isNaN(tmp) || !isFinite(tmp)){
            return 0;
        } else{
            return tmp.toString(base || 10);
        }
    } else if(type == 'number' && isFinite(mixed_var) ){
        return Math.floor(mixed_var);
    } else{
        return 0;
    }
}

function checkauftraggeber(){
	 
	form = document.forms["gravurtext"];
	error = false;
	
	if (error == false && trim(form.vorname.value) == ''){
		error = true;
		form.vorname.focus();
		alert('Bitte geben Sie Ihren Vornamen ein.');
	}
	
	if (error == false && trim(form.nachname.value) == ''){
		error = true;
		form.nachname.focus();
		alert('Bitte geben Sie Ihren Nachnamen ein.');
	}
	
	if (error == false && trim(form.strasse.value) == ''){
		error = true;
		form.strasse.focus();
		alert('Bitte geben Sie Ihre Strasse ein.');
	}
	
	
	
	if (error == false && trim(form.plz.value) == ''){
		error = true;
		form.plz.focus();
		alert('Bitte geben Sie Ihren PLz / Ort ein.');
	}
	
	if (error == false && trim(form.tel.value) == ''){
		error = true;
		form.tel.focus();
		alert('Bitte geben Sie Ihre Telefonnummer ein.');
	}
	
	
	
	if (error == false && trim(form.email.value) == ''){
		error = true;
		form.email.focus();
		alert('Bitte geben Sie Ihre e-Mail ein.');
	}
	
	if (error == false && trim(form.email.value) != ''){
		if (!checkEmail(form.email.value)){
			error = true;
			alert('Bitte geben Sie eine gültige e-mailadresse ein');
		}
	}
	
	if (error == false && trim(form.friedhof.value) == ''){
		error = true;
		form.friedhof.focus();
		alert('Bitte geben Sie den Namen des Friedhofes an.');
	}
	
	if (error == false && trim(form.grabname.value) == ''){
		error = true;
		form.grabname.focus();
		alert('Bitte geben Sie den Grabnamen ein.');
	}

	if (trim(form.gutschein.value) != ''){
		if (error == false && in_array(trim(form.gutschein.value), top.codenr, 'false') == false){
			error = true;
			form.gutschein.focus();
			alert('Bitte geben Sie eine gültige Kundennummer ein.');
		}
	}
	
	 
	
	
	if (error == true){
		return false;
	}
	
}

function checkEmail(email) {
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(email)) {
		return false;
	}else{
		return true;
	}
}

function checkagb() {
	
}


function checkgrosskunde(){
	form = document.forms["grosskunde"];
	error = false;
	
	if (error == false && trim(form.Firma.value) == ''){
		error = true;
		form.Firma.focus();
		alert('Bitte geben Sie den Firmennamen ein.');
	}
	
	if (error == false && trim(form.strasse.value) == ''){
		error = true;
		form.strasse.focus();
		alert('Bitte geben Sie den Strasse und die Hausnummer ein.');
	}
	

	
	if (error == false && trim(form.plz.value) == ''){
		error = true;
		form.plz.focus();
		alert('Bitte geben Sie Ihren PLz / Ort ein.');
	}
	
	if (error == false && trim(form.tel.value) == ''){
		error = true;
		form.tel.focus();
		alert('Bitte geben Sie Ihre Telefonnummer ein.');
	}
	
	
	
	if (error == false && trim(form.email.value) == ''){
		error = true;
		form.email.focus();
		alert('Bitte geben Sie Ihre e-Mail ein.');
	}
	
	if (error == false && trim(form.email.value) != ''){
		if (!checkEmail(form.email.value)){
			error = true;
			alert('Bitte geben Sie eine gültige e-mailadresse ein');
		}
	}
	
	if (error == false && trim(form.UID.value) == ''){
		error = true;
		form.UID.focus();
		alert('Bitte geben Sie Ihre UID ein.');
	}

	
	
	if (error == false && trim(form.vname.value) == ''){
		error = true;
		form.vname.focus();
		alert('Bitte geben Sie den Vornamen der Kontaktperson ein.');
	}

	if (error == false && trim(form.vname.value) == ''){
		error = true;
		form.vname.focus();
		alert('Bitte geben Sie den Vornamen der Kontaktperson ein.');
	}
	
	if (error == false && trim(form.nname.value) == ''){
		error = true;
		form.nname.focus();
		alert('Bitte geben Sie den Nachnamen der Kontaktperson ein.');
	}
	
	
	
	if (error == true){
		return false;
	}

}

function addbestellung(){

	alert(1);
}

