//browservariables
var ns6 = (document.getElementById)? 1 : 0;
var ns4 = (document.layers)? 1 : 0;
var ie4 = (document.all)? 1 : 0;
var nsMac = (ns4 &&  navigator.platform == "MacPPC")? 1 : 0;
var ieMac = (ie4 &&  navigator.platform == "MacPPC")? 1 : 0;

//hiermit wird der JS fehler, bei noch nicht geladenen divs abgefangen
var loaded = false;

//hides the contextmenu in nearly all browsers
document.oncontextmenu = function(){return false}
if(document.layers) {
    window.captureEvents(Event.MOUSEDOWN);
    window.onmousedown = function(e){
        if(e.target==document)return false;
    }
}
else {
    document.onmousedown = function(){return false}
}

//netscape reloading in case of resizing
if (document.layers) {
	widthCheck = window.innerWidth;
	heightCheck = window.innerHeight;
	window.onResize = resizeFix;
}

function resizeFix() {
	if (widthCheck != window.innerWidth || heightCheck != window.innerHeight) {
		document.location.href = document.location.href;
	}
}

//opening the content popup
function popup(url,name,w,h,fix){
	popupWin = window.open(url, name, 'width='+ w +',height='+ h +',toolbar=0,status=0,scrollbars=1,directories=0,menubar=0,resizable='+ fix +'');
}
function popup_NoScroll(url,name,w,h,fix){
	popupWin_noScroll = window.open(url, name, 'width='+ w +',height='+ h +',toolbar=0,status=0,scrollbars=0,directories=0,menubar=0,resizable='+ fix +'');
}

//general show/hide-functions work on any client that supports <div></div>
function show(id) {
	if (loaded) {
		if (ns6) {
			eval("document.getElementById(id).style.visibility = 'visible'");
		} else {
			if (ns4) {
				document.layers[id].visibility = 'show';
			} else {
				if (ie4) {
					eval("document.all.' + id + '.style.visibility = 'visible'");
				}
			}
		}
	}
}
function hide(id) {
	if (loaded) {
		if (ns6) {
			eval("document.getElementById(id).style.visibility = 'hidden'");
		} else {
			if (ns4) {
				document.layers[id].visibility = 'hidden';
			} else {
				if (ie4) {
	        		eval("document.all.' + id + '.style.visibility = 'hidden'");
				}
			}
		}
	}
}

//layer beschreiben
function layerText(div, text) {
    if (document.layers) {
        document.layers[div].document.close();
        document.layers[div].document.write(text);
        document.layers[div].document.close();
    } else {
        if (document.all) {
            eval("document.all." + div + ".innerHTML='" + text + "'");
        } else {
            document.getElementById(div).innerHTML = text;
        }
    }
}


//general moveto funktion, works in ie, ns4, ns6
function bewegeZu(div,x,y) {
	if (document.all) {
		document.all[div].style.left = x;
		document.all[div].style.top = y;
	} else if (document.layers) {
				document.layers[div].left = x;
				document.layers[div].top = y;
			} else if (document.getElementById) {
						document.getElementById(div).style.left = x;
						document.getElementById(div).style.top = y;
					} 
}

//image preloading
function preload(imgObj,imgSrc) {
	eval(imgObj+' = new Image()');
	eval(imgObj+'.src = "'+imgSrc+'"');
}

//replace of history pages - nach laden einer seite mit abfragen, wird diese ersetzt
function pageReplace(url) {
	window.location.replace(url);
}

//redirect
function pageRedirect(url) {
	window.location.href=url;
}

//druckfunktion
function CheckBrowser() {
	var b = navigator.appName;
	if (b == "Netscape") this.b = "ns";
	else if (b == "Microsoft Internet Explorer") this.b = "ie";
	else this.b = b;
	this.version = navigator.appVersion;
	this.v   = parseInt(this.version);
	this.dom = document.getElementById ? true : false;
	this.ns  = (this.b == "ns" && this.v >= 4);
	this.ns4 = (this.b == "ns" && this.v == 4 && !this.dom);
	this.ns5 = (this.b == "ns" && this.v == 5 && this.dom);
	this.ie  = (this.b == "ie" && this.v >= 4);
	this.ie4 = (this.version.indexOf('MSIE 4') > 0 && !this.dom);
	this.ie5 = (this.version.indexOf('MSIE 5') > 0 && this.dom);
	this.min = (this.ns || this.ie);
	this.pr  = (window.print) ? true :  false;
	this.mac = (navigator.userAgent.indexOf("Mac") != -1);
}
is = new CheckBrowser();

function content_print() {
  if (is.pr) {
    self.focus();
    window.print();
  }
  else if (is.ie4 && !is.mac) {
    vbPrintPage();  
  }
  else {
    alert('Bitte benutzen Sie die Druckfunktion ihres Browsers!');  
  }
}

if (is.ie4 && !is.mac) { // IE4 (Windows)
  writeln('<OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>');
  writeln('<' + 'SCRIPT LANGUAGE="VBScript">');
  writeln('Sub window_onunload');
  writeln('  On Error Resume Next');
  writeln('  Set WB = nothing');
  writeln('End Sub');
  writeln('Sub vbPrintPage');
  writeln('  OLECMDID_PRINT = 6');
  writeln('  OLECMDEXECOPT_DONTPROMPTUSER = 2');
  writeln('  OLECMDEXECOPT_PROMPTUSER = 1');
  writeln('  On Error Resume Next');
  writeln('  WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER');
  writeln('End Sub');
  writeln('<' + '/SCRIPT>');
}
