function insertRule(ss, selector, rule, position) {
	if(ss.insertRule)
	ss.insertRule(selector + '{' + rule + '}', position);
	else if(ss.addRule)
	ss.addRule(selector, rule);
}

var FontSize = 12

function ChangeFontSize(x)
{
	var theRules = new Array();
	var ss = document.styleSheets[1];
	if (ss.cssRules)
		theRules = ss.cssRules;
	else if (ss.rules)
		theRules = ss.rules;

	FontSize += x
	insertRule(ss, '#content *', 'font-size: '+FontSize+'px;', theRules.length);
	insertRule(ss, '#start_content *', 'font-size: '+FontSize+'px;', theRules.length);
}

//Diverse Elemente bei kleiner Fenstergröße verändern
function check_resolution() {
	//array aus IDs die ausgeblendet werden sollen
	var array = new Array('functions', 'white_line', 'changefont');
	var obj;

	var bereichsbild2 = document.getElementById('bereichsbild2');
	var title = document.getElementById('title');
	var text = document.getElementById('text');
	var calcdiv = document.getElementById('calcdiv');

	if (document.body.offsetWidth < 995) {
		if(bereichsbild2) { bereichsbild2.style.right = '0px' }
		if(title) { title.style.right = '85px' }
		if(text) { text.style.right = '0px' }
		if(calcdiv) { calcdiv.style.right = '0px' }

		for(i = 0; i < array.length; i++) {
			obj = document.getElementById(array[i])
			if(obj)
				obj.style.display = 'none'
		}
	} else {
		if(bereichsbild2) { bereichsbild2.style.right = '224px' }
		if(title) { title.style.right = '309px' }
		if(text) { text.style.right = '224px' }
		if(calcdiv) { calcdiv.style.right = '224px' }

		for(i = 0; i < array.length; i++) {
			obj = document.getElementById(array[i])
			if(obj)
				obj.style.display = ''
		}
	}
}
window.onresize = window.onload = check_resolution;

function changePic(obj2, over) {
	var obj = obj2.getElementsByTagName('IMG')[0];
	var tmp_sub = 'FOLDER_' + akt_sub;

	if (obj) {
		file = obj.src;
		tmp_img= new Image();
		if (over) {
			tmp_img.src = file.replace(/2*\.gif/, '2.gif');
		} else {
			tmp_img.src = file.replace(/2+\.gif/, '.gif');
		}
		obj.src = tmp_img.src;
	}
}

function GetDate() {
	obj = document.getElementById("date");
	if (!obj)
		return;
	var jetzt = new Date();
	var Tag = jetzt.getDate();
	if (Tag < 10)
		Tag = "0" + String(Tag);
	var months = new Array("Jänner", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember");
	var Wochentag = new Array("Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag");
	var Jahr = jetzt.getYear();
	if (Jahr < 999)
		Jahr += 1900;
	obj.innerHTML = Wochentag[jetzt.getDay()] + ", <span>" + Tag + ". " + months[jetzt.getMonth()] + " " + Jahr + "</span>";
}

// flash detect
var benoetigteVersion = 6;
var flash2Installiert = false;
var flash3Installiert = false;
var flash4Installiert = false;
var flash5Installiert = false;
var flash6Installiert = false;
var flash7Installiert = false;
var hoechsteVersion = 7;
var aktuelleVersion = 0;
var richtigeVersion = false;
var browserAol = (navigator.appVersion.indexOf("AOL") != -1) ? true : false;
var browserInternetExplorer  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var betriebssystemWindows = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;

if(browserInternetExplorer && betriebssystemWindows && !browserAol) {
	document.write('<scr' + 'ipt language=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('flash2Installiert = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
	document.write('flash3Installiert = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
	document.write('flash4Installiert = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
	document.write('flash5Installiert = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');
	document.write('flash6Installiert = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');
	document.write('flash7Installiert = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');
	document.write('<\/scr' + 'ipt\> \n');
}

function detectFlash() {
	if (navigator.plugins) {
		if(navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var istVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashInfo = navigator.plugins["Shockwave Flash" + istVersion2].description;
			var flashVersion = parseInt(flashInfo.substring(16));
			flash2Installiert = flashVersion == 2;
			flash3Installiert = flashVersion == 3;
			flash4Installiert = flashVersion == 4;
			flash5Installiert = flashVersion == 5;
			flash6Installiert = flashVersion == 6;
			flash7Installiert = flashVersion == 7;
		}
	}

	for(var i = 2; i <= hoechsteVersion; i++)
		if (eval("flash" + i + "Installiert") == true)
			aktuelleVersion = i;

	if(navigator.userAgent.indexOf("WebTV") != -1) aktuelleVersion = 4;

	if(aktuelleVersion >= benoetigteVersion)
		richtigeVersion = true;
}
detectFlash();
// end flash detect

function changeDisplay(div_id, if_, then_) {
	var elem = document.getElementById(div_id);
	if (elem && elem.style.display == if_)
		elem.style.display = then_;
}

function changeVisibility(div_id, if_, then_) {
	var elem = document.getElementById(div_id);
	if (elem && elem.style.visibility == if_)
		elem.style.visibility = then_;
}

function open_sub(SM_SHORT) {
	if (akt_sub != SM_SHORT) {
		 changeDisplay(akt_sub, 'block', 'none');
		 changeDisplay(SM_SHORT, 'none', 'block');
		 akt_sub=SM_SHORT;
	}
}

function getAdr(prefix, postfix, lnkparam, lnktxt) {
	lnktxt = lnktxt.replace(/TMPL_MAIL/, prefix + '@' + postfix);
	document.write('<a ' + lnkparam + ' href="mailto:' + prefix + '@' + postfix + '">' + lnktxt);
}

/*printjob*/
function printjob() {
	if (document.all && (navigator.appVersion.indexOf("Mac") != -1)) {
		self.focus();
		alert("Drucken-Funktion unter Macintosh nicht moeglich! \nBitte verwenden Sie Datei/Drucken");
	} else {
		if (document.all && navigator.appVersion.substring(22,23)==4) {
			self.focus();
			var OLECMDID_PRINT = 6;
			var OLECMDEXECOPT_DONTPROMPTUSER = 2;
			var OLECMDEXECOPT_PROMPTUSER = 1;
			var WebBrowser = '<object id="WebBrowser1" width="0" height="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>';
			document.body.insertAdjacentHTML('beforeEnd',WebBrowser);
			WebBrowser1.ExecWB(OLECMDID_PRINT,OLECMDEXECOPT_DONTPROMPTUSER);
			WebBrowser1.outerHTML = '';
		} else{
			self.focus();
			window.print();
		}
	}
}

function Startpage(obj) {
	if (document.all) {
		obj.style.behavior='url(#default#homepage)';
		obj.setHomePage('http://');
	}
}

function Favorite() {
	if (document.all)
		window.external.AddFavorite('http://','Name');
}

function cont2pdf(ID) {
	script = "http://www.atikon.at/rechner/content2pdf.php";
	script = script + "?ID=" + ID + "&url=" + encodeURIComponent(window.location);
	window.open(script, 'm', 'scrollbars=no,height=400,width=470');
}

var popupmenuoldonload = window.onload;
window.onload = function() {
	var nav = document.getElementById('nav');
	var uls = nav.getElementsByTagName('UL');
	for(var i = 0; i < uls.length; i++)
		new xMenu1(uls[i], 0, 'mouseover');
	if(popupmenuoldonload)
		popupmenuoldonload();
}

function xMenu1(menu, mouseMargin, openEvent) {
	var isOpen = false;
	if (menu)
		xAddEventListener(menu.parentNode, openEvent, onOpen, false);

	function onOpen() {
		if (!isOpen) {
			xShow(menu);
			HideSelects(xPageX(menu), xPageY(menu), xWidth(menu), xHeight(menu));
			xAddEventListener(document, 'mousemove', onMousemove, false);
			isOpen = true;
		}
	}
	function onMousemove(ev) {
		var e = new xEvent(ev);
		contains = (xHasPoint(menu, e.pageX, e.pageY, -mouseMargin) || xHasPoint(menu.parentNode, e.pageX, e.pageY, -mouseMargin));
		if(!contains) {
			var submenus = menu.getElementsByTagName('UL');
			for(var i = 0; i < submenus.length; i++)
				if(xHasPoint(submenus[i], e.pageX, e.pageY, -mouseMargin)) {
					contains = true;
					break;
				}
		}
		if(!contains) {
			xHide(menu);
			HideSelects(0, 0, 0, 0);
			xRemoveEventListener(document, 'mousemove', onMousemove, false);
			isOpen = false;
		}
	}
}

var sel;
function HideSelects(x,y,w,h) {
	if(xIE4Up && !xMac) {
		var selx, sely, selw, selh, i
		if(!sel)
			sel = document.getElementsByTagName("SELECT");
		for(i = 0; i < sel.length; i++) {
			selx = xPageX(sel[i]);
			sely = xPageY(sel[i]);
			selw = sel[i].offsetWidth;
			selh = sel[i].offsetHeight;
			sel[i].style.visibility = (selx + selw > x && selx < x + w && sely + selh > y && sely < y + h) ? "hidden" : "visible";
		}
	}
}


function popup(url, typ, para1, width, height) {
	attrib = "";
	Y = (screen.height - width) / 2;
	X = (screen.width - height) / 2;
	X = Math.round(X);
	Y = Math.round(Y);
	if (para1 == 'CENTER') attrib += 'height=' + height + ',width=' + width + ',top=' + Y + ',left=' + X;
	if (typ == 'TYP1') attrib += ",scrollbars=no";
	if (typ == 'TYP2') attrib += ",scrollbars=yes";
	if (typ == 'TYP3') attrib += ",scrollbars=yes,menubar=yes";
	x = Math.random();
	fenster = window.open(url, 'win', attrib);
	return false;
}

// BO Popup
function hideSelectBoxes(){
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) { selects[i].style.visibility = "hidden";}

	if(!window.ie)
		document.getElementById('content').style.overflow='hidden!important';
}

function showSelectBoxes(){
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) { selects[i].style.visibility = "visible";}

	if(!window.ie)
		document.getElementById('content').style.overflow='auto';
}

var popupOldOnResize = window.onresize;
var popupOldOnLoad = window.onload;
function showPopup(id, width, height, popupinnerHTML)
{
	hideSelectBoxes();
	if(document.getElementById('popup_background')) {
		objTemp = document.getElementById('popup_background');
	}
	else
	{
		objTemp = document.createElement("div");
		objTemp.id = 'popup_background';
		objTemp.style.visibility='hidden';
		objTemp.onclick=function() { popupClose(); }
	}

	if(objTemp.style.display != 'block')
	{
		objTemp.style.display='block';

		popupBackground = document.body.appendChild(objTemp);
		$(popupBackground).effects({duration:400,onComplete:function(){      $(popupBackground).effects({}).set({'opacity':[0.5]}); showPopupContent(id, width, height, popupinnerHTML);     }}).start({'opacity':[0,0.5]});
	}
	else
	{
		$(popupBackground).effects({duration:0,onComplete:function(){      $(popupBackground).effects({}).set({'opacity':[0.5]}); showPopupContent(id, width, height, popupinnerHTML);     }}).start({'opacity':[0.5,0.5]});
	}
}

function showPopupContent(id, width, height, popupinnerHTML)
{
	if(popupinnerHTML == undefined)
		popupinnerHTML = '';

	if(document.getElementById('popup_content')) {
		objTemp = document.getElementById('popup_content');
	}
	else
	{
		objTemp = document.createElement("div");
		objTemp.id = 'popup_content';
	}

	objTemp.innerHTML= '<div id="popup_close"><a href="javascript:popupClose()"><span>X</span></a></div><div id="popup_text">' + document.getElementById(id).innerHTML + '' + popupinnerHTML + '</div>';

	if(width > 0 && height > 0) {
		objTemp.style.width=width+'px';
		objTemp.style.height=height+'px';
		objTemp.style.marginLeft='-' + Math.floor(width/2) +'px';
		objTemp.style.marginTop='-' + Math.floor(height/2) +'px';
	}

	objTemp.style.display='block';

	popupContent =  document.body.appendChild(objTemp);
}

function popupClose()
{
	popupContent = document.getElementById('popup_content');
	popupContent.style.display='none';

	popupBackground = document.getElementById('popup_background');

	$(popupBackground).effects({duration:400,onComplete:function(){      	popupBackground.style.display='none'; showSelectBoxes();    }}).start({'opacity':[0.5,0]});
}
// EO Popup (div einblenden)

