// CP.JS

function Schreib(x) {
	document.getElementById('branche').value = x;
}

function info(forward) {
	alert('Diese Funktion steht nur angemeldeten Besuchern zur Verf\xFCgung!');
	if (forward != undefined) {
		window.location = 'index.php?action=' + forward;
	}
}

// Fängt alle Aktionen ab, die auf der Seite vorgenommen werden können, um vorher ein Submit
// absetzen zu können, damit alle Änderungen an den Markierungen auch wirklich ankommen
function pageSubmit(action, value) {
	var form = document.getElementById('form');
	if (action == 'do' && (value == 'export' || value == 'mark_export')) {
		var url = 'index.php?action=export&what=' + window.action + '&type=' + value;
//		var url = 'download.php?action=' + window.action + '&what=' + value;
		if (window.sessid.length > 1) url += '&SESSID=' + window.sessid;
		form.action = url;
//		form.target = 'Export';
		form.target = '';
		form.submit();
	} else if (window.action) {
		form.action = 'index.php?action=' + window.action + '&' + action + '=' + value;
		if (window.sessid.length > 1) form.action += '&SESSID=' + window.sessid;
		form.target = '';
		form.submit();
	} else {
		alert(window.action);
	}
}

function noContent() {
	alert('Es sind keine Eintr\xE4ge in der Merkliste!');
}

function printPage() {
	var url = 'print.php?action=' + window.action ;
	if (window.sessid.length > 1) url += '&SESSID=' + window.sessid;
	var win = document.open(url,'Drucken','top=20,left=20,width=700,height=600,dependent=yes,resizable=yes,scrollbars=yes');
}

function chkSchnell() {
	var sucher = '';
	var schnell_1 = document.getElementById('schnellsuche_main');
	var schnell_2 = document.getElementById('schnellsuche_home');
	if (schnell_1 && schnell_1.value.length > 0) {
		var sucher = schnell_1.value;
	} else if (schnell_2 && schnell_2.value.length > 0) {
		var sucher = schnell_2.value;
	}
	if (sucher.length == 0) {
		alert('Bitte Suchbegriff eingeben!');
		return false;
	}
	return true;
}

function clearContent(ctrl) {
	if (ctrl) ctrl.value = '';
}

function chkLogin() {
	if (window.quick_login) return true;

	var pwd = document.getElementById('password');
	if (pwd) {
		if (pwd.value.length == 0 || pwd.value == 'Password') {
			alert('Bitte Passwort eingeben!');
			return false;
		}
	}
	return true;
}
