/* JavaScript AjaxFunctions Libary */
/* Scripted by Valtos Copyright NySoft 2008 */

/*#########Ajax Functions##########*/
function savenote(anr) {
	setAttrValue('notestatus','src','images/loading.gif');
	var objElement = document.getElementById("note").value;
	AjaxLiveImplementation('savenotes.php','?anr=' + anr + '&note=' + escape(objElement));
}
function AjaxLiveImplementation(adress,additional) {
	http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
        }
	} 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;
	}
	http_request.onreadystatechange = checkReturn;
	http_request.open('GET', adress + additional, true);
	http_request.send(null);
}
function checkReturn() {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			if(http_request.responseText == "true") {
				setAttrValue('notestatus','src','images/ok.png');
			} else {
				setAttrValue('notestatus','src','images/Error.gif');
				alert("Fehler beim speichern! \n Rückgabe:" + http_request.responseText);
			}
		} else {
			alert('Bei dem Request ist ein Problem aufgetreten.');
		}
	}
}
function removecarfromlist(fnr,parentel) {
	check = confirm('Sind Sie sicher das Sie dieses Fahrzeug löschen wollen?');
	if(check) {
		removeElementChildTag(parentel,fnr);
		simpleAjaxImplementation('index.php?fileid=partnerfahrzeuge&mode=remove','&fnr=' + fnr);
	}
}
function simpleAjaxImplementation(adress,additional) {
	http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
        }
	} 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;
	}
	http_request.onreadystatechange = checkReturn;
	http_request.open('GET', adress + additional, true);
	http_request.send(null);
}
function removecar() {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
		} else {
			alert('Bei dem Request ist ein Problem aufgetreten.');
		}
	}
}
function confirmJump(question,adress) {
	check = confirm(question);
	if(check) {
		document.location = adress;	
	}
}
function confirmJumpAction(question,jumpAdress,actionAdress) {
	check = confirm(question);
	if(check) {
		simpleAjaxImplementation(actionAdress,jumpAdress);
	}
}
function confirmJumpActionPrompt(question,jumpAdress,actionAdress) {
	check = confirm(question);
	if(check) {
		var eingabe = window.prompt("Bitte geben Sie Ihren aktuellen Kassenbestand ein.","");
		if(eingabe != "") {
		simpleAjaxImplementation(actionAdress + "&kasbes=" + eingabe.replace(/,/,'.'),jumpAdress);
		} else { alert("Ohne Kassenbestandseingabe kein beenden der Aktion moeglich!"); }
	}
}
/*######Ajax Functions Ende########*/