var popwin;

// PopUps aufrufen
function PopUp(src,w,h)
{
	oversize = 0;
	if(popwin) popwin.close();

	if(w > screen.width-100)
	{
		oversize = 1;
		// h = Math.round((screen.width-100)/w*h); // Verhältnis
		h = parseInt(h)+20; // Scrollbars
		w = (screen.width-100);
	}
	if(h > screen.height-150)
	{
		oversize = 1;
	    // w = Math.round((screen.height-150)/h*w); // Verhältnis
	    w = parseInt(w)+20; // Scrollbars
		h = (screen.height-150);
	}

	breite = Math.round((screen.width - w) / 2);
	hoehe = Math.round((screen.height - h) / 2);

	if(oversize == 1)
		popwin = window.open(src,"popwin","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+w+",height="+h+",top="+hoehe+",left="+breite);
	else
		popwin = window.open(src,"popwin","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width="+w+",height="+h+",top="+hoehe+",left="+breite);
}

// Klick-Vergrössern schliessen
function expandImageClose()
{
    document.body.removeChild(document.getElementById('expandImageDiv'));
	document.body.removeChild(document.getElementById('expandImageBg'));

	ie = navigator.appVersion.split("MSIE");
	version = parseFloat(ie[1]);
    if((version >= 5.5) && (version < 7) && (document.body.filters))
    {
        document.body.style.overflow = 'visible';
    }
}

// Klick-Vergrössern
function expandImage(src,w,h)
{
	// Für IE < 7 Check
	ie = navigator.appVersion.split("MSIE");
	version = parseFloat(ie[1]);
    isOldIE = (((version >= 5.5) && (version < 7) && (document.body.filters)) ? true : false);

	if(isOldIE == true) document.body.style.overflow = 'auto';

	// Falls ein Bildfenster noch geöffnet -> vorher entfernen!
	if(document.getElementById('expandImageBg')) expandImageClose();

	// Maximale Anzeigebreite und -höhe vom Body ermitteln
	maxWidth = document.body.clientWidth-100; // Max. Anzeigebreite
	maxHeight = document.body.clientHeight-100; // Max. Anzeigehöhe

	// Bildmaße ggf. verkleinern
	if(w > maxWidth)
	{
		h = Math.round(maxWidth/w*h);
		w = maxWidth;
	}
	if(h > maxHeight)
	{
	    w = Math.round(maxHeight/h*w);
		h = maxHeight;
	}

	// Dunklen Schleier erzeugen
	expandBG = document.createElement('table');
	expandBG.id = 'expandImageBg';
	expandBG.insertRow(0).insertCell(0);
	expandBG.onclick = new Function("expandImageClose();");
	if(isOldIE == true) expandBG.style.position = 'absolute'; // wegen position:fixed
	document.body.appendChild(expandBG);

	// Bildfenster erzeugen
	expandDiv = document.createElement('div');
	expandDiv.id = 'expandImageDiv';
	expandDiv.onclick = new Function("expandImageClose();");
	expandDiv.style.width = w+'px';
	expandDiv.style.marginLeft = '-'+Math.round(w/2)+'px';
	expandDiv.style.height = h+'px';
	expandDiv.style.marginTop = '-'+Math.round(h/2)+'px';
	if(isOldIE == true) expandDiv.style.position = 'absolute'; // wegen position:fixed

	// Bild anzeigen
	expandImg = document.createElement("img");
	expandImg.src = 'images/t3_blank.gif';
	expandImg.width = w;
	expandImg.height = h;
	expandImg.id = 'bigimg';
	expandDiv.appendChild(expandImg);
	document.body.appendChild(expandDiv);
	expandImg.src = src;
	// Bildanzeige nach einem kurzen Versatz - wegen Anzeigereaktion im IE6 !!!
	window.setTimeout("document.getElementById('bigimg').src = '"+src+"';",100);
}

// Formulare leeren
function ClearForm(Formular)
{
	document.forms[Formular].reset(); // Zuerst reset!
	var x = 0;
	while(document.forms[Formular].elements[x])
	{
		if(document.forms[Formular].elements[x].type == "checkbox" || document.forms[Formular].elements[x].type == "radio")
		{
			// Checkboxen + Radiobuttons werden nicht angehakt
			document.forms[Formular].elements[x].checked = false;
		}
		else if(document.forms[Formular].elements[x].type != "hidden" && document.forms[Formular].elements[x].type != "submit" && document.forms[Formular].elements[x].type != "reset" && document.forms[Formular].elements[x].type != "button")
		{
			// Alle, ausser versteckte Felder, dürfen geleert werden
			document.forms[Formular].elements[x].value = "";
		}
		x++;
	}
}

// Liefert ein Object anhand ID oder Name
function gObj(id)
{
	if(typeof document.getElementById(id) == 'object' && document.getElementById(id) != null)
	{
		return document.getElementById(id);
	}
	else if(document.getElementsByName)
	{
		var namedObjects = document.getElementsByName(id);
		if(typeof namedObjects != 'undefined' && namedObjects.length)
		{
		    return namedObjects[0];
		}
	}
}

// PNG-Bilder werden im IE 5.5 oder IE 6 halbtransparent dargestellt, ohne extra Klassen benutzen zu müssen
// vor </body> muss noch folgendes eingebunden werden:
// <script type="text/javascript">
// fixAllPNGs();
// </script>
function fixAllPNGs()
{
	ie = navigator.appVersion.split("MSIE");
	version = parseFloat(ie[1]);

    if((version >= 5.5) && (version < 7) && (document.body.filters))
    {
		for(i=0; i<document.getElementsByTagName('img').length; i++)
		{
			myImage = document.getElementsByTagName('img')[i];

			if(myImage.src.match(/\.png$/) != null)
			{
				var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
				var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
				var imgTitle = (myImage.title) ?
				             "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
				var imgStyle = "display:inline-block;" + myImage.style.cssText
				var strNewHTML = "<span " + imgID + imgClass + imgTitle
				          + " style=\"" + "width:" + myImage.width
				          + "px; height:" + myImage.height
				          + "px;" + imgStyle + ";"
				          + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
				          + "(src=\'" + myImage.src + "\', sizingMethod='image');\"></span>"
				myImage.outerHTML = strNewHTML;
				i--;
			}
		}
	}
}



