﻿/****************************************************************************************************************
*                                                                                                               *
*       Dieser Quellcode ist urheberrechtlich geschützt. Das Vervielfältigen oder Abändern ist untersagt.       *
*                                                                                                               *
*                                Copyright 2007 Volker Last - vlast@gmx.de                                      *
*                                                                                                               *
****************************************************************************************************************/

window_name = 'kfz-baessler';

// Druckversion anzeigen
function printPage() {
	var printcontent = document.getElementById('id_printcontent');
	printcontent.value = encodeURIComponent(document.getElementById('id_maincontent').innerHTML);
	window.open('', 'druckfenster', 'width=800, height=700, scrollbars=1');
	document.getElementById('id_printform').submit();
}

// Bilder vorab laden
function preload(img) {
	var image = document.createElement('img');
	image.src = img;
}

// Bildwechsel
function changeImage(img_id, img_src) {
	var img = document.getElementById(img_id);
	img.src = img_src;
}

// Textgröße ändern

function setFontSize() {
	if(window.name.indexOf(window_name) == -1)
		window.name = 0+window_name;
	else {
		var content = document.getElementById('id_maincontent');
		var old_value = parseInt(content.style.fontSize.substring(0, content.style.fontSize.indexOf('px')));
		content.style.fontSize = (old_value+parseInt(window.name.substring(0, window.name.indexOf(window_name))))+'px';
		setFont(content, parseInt(window.name.substring(0, window.name.indexOf(window_name))));
	}
}

function increaseFont() {
	if(parseInt(window.name.substring(0, window.name.indexOf(window_name))) < 9) {
		var content = document.getElementById('id_maincontent');
		window.name = (parseInt(window.name.substring(0, window.name.indexOf(window_name)))+1)+window_name;
		var old_value = parseInt(content.style.fontSize.substring(0, content.style.fontSize.indexOf('px')));
		content.style.fontSize = (old_value+1)+'px';
		setFont(content, 1);
	}
}

function decreaseFont() {
	if(parseInt(window.name.substring(0, window.name.indexOf(window_name))) > -9) {
		var content = document.getElementById('id_maincontent');
		window.name = (parseInt(window.name.substring(0, window.name.indexOf(window_name)))-1)+window_name;
		var old_value = parseInt(content.style.fontSize.substring(0, content.style.fontSize.indexOf('px')));
		content.style.fontSize = (old_value-1)+'px';
		setFont(content, -1);
	}
}

function resetFont() {
	var content = document.getElementById('id_maincontent');
	var old_value = parseInt(content.style.fontSize.substring(0, content.style.fontSize.indexOf('px')));
	content.style.fontSize = (old_value-parseInt(window.name.substring(0, window.name.indexOf(window_name))))+'px';
	setFont(content, -parseInt(window.name.substring(0, window.name.indexOf(window_name))));
	window.name = 0+window_name;
}

function setFont(content, font_value) {
	var child_length = content.childNodes.length;
	for(var i = 0; i < child_length; ++i) {
		var child_node = content.childNodes[i];
		if(child_node.nodeType == 1) {
			if(child_node.tagName.toLowerCase() == 'font') {
				var old_value = child_node.style.fontSize;
				if(old_value != '') {
					old_value = parseInt(old_value.substring(0, old_value.indexOf('px')));
					child_node.style.fontSize = (old_value+font_value)+'px';
				}
			}
			if(child_node.hasChildNodes())
				setFont(child_node, font_value);
		}
		
	}
}

// Popup Bild öffnen
function showPopup(img) {
	var windowcontent = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><title>Detailansicht</title></head><body><table width=\"100%\"><tr><td height=\"20\" bgcolor=\"#004080\" align=\"right\"><a href=\"#\" onclick=\"javascript:window.close();\" style=\"font-family:Verdana, Arial, Helvetica, sans-serif; font-size:0.7em; color:#FFFFFF; text-decoration:none;\">Fenster schließen&nbsp;</a></td></tr><tr><td height=\"10\"></td></tr><tr><td align=\"center\"><img src=\"images/popup_"+img+"\" /></td></tr></table></body></html>";
	
	var popupwindow = window.open("", "popupfenster", "width=520, height=520, top=200, left=300");
	popupwindow.document.open();
	popupwindow.document.write(windowcontent);
	popupwindow.document.close();
}
