
function changeMark(input_id, checkbox_id, checkbox_img, checkbox_img_checked)
{
	var input_elem = document.getElementById(input_id);
	var checkbox_elem = document.getElementById(checkbox_id);
	if (input_elem.value == "") {
		input_elem.value = 'mark';
		checkbox_elem.src = checkbox_img_checked;
	} else {
		input_elem.value = '';
		checkbox_elem.src = checkbox_img;
	}
}

function markALL(from_pos, to_pos, checkbox_img_checked)
{
	from_pos = parseInt(from_pos);
	to_pos = parseInt(to_pos);
	for (i = from_pos; i <= to_pos; i++) {
		var input_elem = document.getElementById('mark' + i);
		if (input_elem != null) {
			var checkbox_elem = document.getElementById('checkbox_img_' + i);
			input_elem.value = 'mark';
			checkbox_elem.src = checkbox_img_checked;
		}
	}
}

function demarkALL(from_pos, to_pos, checkbox_img)
{
	from_pos = parseInt(from_pos);
	to_pos = parseInt(to_pos);
	for (i = from_pos; i <= to_pos; i++) {
		var input_elem = document.getElementById('mark' + i);
		if (input_elem != null) {
			var checkbox_elem = document.getElementById('checkbox_img_' + i);
			input_elem.value = '';
			checkbox_elem.src = checkbox_img;
		}
	}
}

function doPrint(from_pos, to_pos)
{
	from_pos = parseInt(from_pos);
	to_pos = parseInt(to_pos);
	var mark_cnt = 0;
	for (i = from_pos; i <= to_pos; i++) {
		var input_elem = document.getElementById('mark' + i);
		if (input_elem != null) {
			if (input_elem.value == 'mark') {
				mark_cnt++;
			}
		}
	}
	if (mark_cnt == 0) {
		alert("Markieren Sie bitte eines oder mehrere Dokumente!");
		return;
	}
/* OPS: funktioniert nicht wegen Steuerdokument
	if (mark_cnt > (to_pos - from_pos)) {
		if (!confirm("Möchten Sie wirklich alle Dokumente drucken?")) {
			return;
		}
	}
*/
	var form = document.getElementById('treffer_liste'); 
	form.submit();
}

function openWindow(url, name, width, height, posX, posY)
{
  var popWindow=window.open(url,name,'left='+posX+',top='+posY+',width='+width+',height='+height+',scrollbars=yes,menubar=no,status=yes,resizable=yes')
  return popWindow;
}

function showOriginal(url, width, height)
{
	var posX = (screen.width - width) / 2;
	var posY = (screen.height - height) / 2;
	var win_width = width + 40;
	var win_height = height + 30;
	var win = openWindow(url, 'original', win_width, win_height, posX, posY);
}
