// IE Browser-Detection
function getIEVersionNumber() {
	var ua = navigator.userAgent;
	var MSIEOffset = ua.indexOf("MSIE ");
	if (MSIEOffset == -1) {
		return 0;
	} else {
		return parseFloat(ua.substring(MSIEOffset + 5, ua.indexOf(";", MSIEOffset)));
	}
}

//var ie55 = getIEVersionNumber() >= 5.5;


function popup(mylink, winname,w,h) {
	var breit = (w)? "width=" + (w + 40) : "width=700";
	var hoch = (h)? "height=" + (h + 40) : "height=500";

	if (!window.focus) return true;
	var href;
	if (typeof(mylink) == 'string')
		href=mylink;
	else
		href=mylink.href;
	window.open(href, winname, breit + ',' + hoch + ',scrollbars=yes, resizable=yes, menubar=yes').focus();
	return false;
}
var newWin;
function imgPopUp(cont, winname,w,h) {
	var width = (w)? (w) : 700;
	var height = (h)? (h) : 500;


	width += 70;
	height += 135;
	var left = parseInt((screen.availWidth/2) - (width/2));
	var top = parseInt((screen.availHeight/2) - (height/2));
	var param = "width=" + width +  ", height=" + height + ", left=" + left + ", top=" + top;

		newWin = window.open("", winname, param + ',scrollbars=no, resizable=yes, menubar=no');
		newWin.resizeTo(width, height);
		setTimeout("putInWindow('" + cont + "')", 50);
		newWin.focus();

	return false;
}
function putInWindow(cont) {
	var newCont = "<html><head><title>Zoomansicht</title></head>";
	newCont += "<style type='text/css'>a img {border: solid 1px #000;} a:hover img {border: solid 1px #fff;}</style>"
	newCont += "<body style='background: #A5AAB0;margin: 0; padding: 30px 30px 45px 30px; height: 100%'>"
	newCont += "<div style='position: absolute; z-index: 1; font: 11px Verdana, sans-serif; color:#8A8A8A; margin-top: 30%; text-align: center;'>Bild wird geladen...</div>"
	newCont += "<div style='position: relative; z-index: 100;'><a href='#' onclick='self.close();'><img src='"+ cont + "'></a></div>";
	newCont += "<div style='position: relative; z-index: 100;padding-top: 10px;  text-align: center; color: #606060; font-size: 11px; font-family: Arial, Helvetica, sans-serif;'>Zum Schließen bitte auf das Bild klicken</div>";
	newCont += "</body></html>";
	newWin.document.write(newCont);
	newWin.document.close();
}

function checkChangeForm() {
	if(window.top.topFrame.changeForm == true) {
		if (confirm("Es wurden anscheinend Änderungen am Formular durchgeführt.\n Klicken Sie Abbrechen um die Änderungen speichern zu können.\n Klicken Sie OK wenn Sie die Änderungen nicht speichern möchten")) {
			return true;
		} else {
			return false;
		}
	}
	return false;
}


function openHide(id) {
	obj = document.getElementById(id);
	obj.style.display = (obj.style.display == "block")? "none" : "block";
}
function openScrollWin(url, winName, width, height)
{

 	if (width == null) { width = 600;}
 	if (height == null) { height = 440; }

	var Win = window.open(url, winName,'width='+ width + ',height=' + height + ',resizable=1,scrollbars=1,menubar=1,status=0');

    var z = parseFloat(navigator.appVersion);
    if (navigator.appName.substring(0,8) == "Netscape" || z >= 4) {
    	Win.focus();
	}
}

//Cookies
function getExpDate(days, hours, minutes)
{
    var expDate = new Date();
    if (typeof days == "number" && typeof hours == "number" && typeof minutes == "number")
	{
        expDate.setDate(expDate.getDate() + parseInt(days));
        expDate.setHours(expDate.getHours() + parseInt(hours));
        expDate.setMinutes(expDate.getMinutes() + parseInt(minutes));
    }
	return expDate.toUTCString();
}
// utility function called by getCookie()
function getCookieVal(offset)
{
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
	{
        endstr = document.cookie.length;
    }
    return decodeURI(document.cookie.substring(offset, endstr));
}
// primary function to retrieve cookie by name
function getCookie(name)
{
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen)
	{
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
		{
            return getCookieVal(j);
        }
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return "";
}
// store cookie value with optional details as needed
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie = name + "=" + encodeURI(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}
// remove the cookie by setting ancient expiration date
function deleteCookie(name,path,domain)
{
    if (getCookie(name))
	{
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}