//------------------------------------------------------------
// JavaScript-Datei: funktionen.js
//------------------------------------------------------------
// Autor:   Johannes Mueller
// Kontakt: www.mueller24.info/kontakt.php
//
// last modified: 11.04.2006
//------------------------------------------------------------
// Funktionen:
//   Adr(accountVerkehrt, subdomainVerkehrt, topdomainVerkehrt, modus)
//   DeutschesDatum(datum)
//   Go(url)
//   GoOpener(url)
//   PopUp(url, breite, hoehe, skalierbar)
//   PopUpBild(url, bildbreite, bildhoehe, bildtitel)
//   SeiteVerlassen()
//   VerhindereFrameDarstellung()
//------------------------------------------------------------


//------------------------------------------------------------
// Globale Variablen fuer alle Seiten
//------------------------------------------------------------

var popUpFenster;


//------------------------------------------------------------
// Funktionen
//------------------------------------------------------------

function PopUp(url, breite, hoehe, skalierbar)
{
	var eigenschaften, spezial;

	if (popUpFenster)
		if (!popUpFenster.closed)
			popUpFenster.close();

	if ((breite > 0) && (hoehe > 0))
	{
		if (skalierbar)
			spezial = "resizable=yes,scrollbars=yes,dependent=no";
		else
			spezial = "resizable=no,scrollbars=no,dependent=yes";

		eigenschaften =
		"width=" + breite + ",height=" + hoehe + "," +
		"left=0,top=0,menubar=no,toolbar=no,location=no,status=no," +
		spezial;

		popUpFenster = window.open(url, "_blank", eigenschaften);
		popUpFenster.focus();
	}
	
	// popUpFenster.moveTo(0,0) funktioniert im IE nicht
	// bei einem Verweis auf eine fremde Web-Seite
}


function SeiteVerlassen()
{
	if (popUpFenster)
		if (!popUpFenster.closed)
			popUpFenster.close();
}


function GoOpener(url)
{
	if (opener)
	{
		if (!opener.closed)
		{
			opener.top.focus();
			opener.top.location.href = url;
		}
		else
			window.open(url, "_blank");
	}
	else
		window.open(url, "_blank");

	if (!window.closed)
		window.setTimeout("window.close()", 500);
}




function PopUpBild(url, bildbreite, bildhoehe, bildtitel)
{
	var fensterbreite, fensterhoehe, fenstertitel, farbe, css_datei;

	linie     = "#E0E0E0 2px solid";
	css_datei = "layout.css";

	if (bildbreite > 180)	fensterbreite = bildbreite + 30;
	else			fensterbreite = 210;

	if (bildtitel)		fensterhoehe  = bildhoehe  + 115;
	else			fensterhoehe  = bildhoehe  + 75;

	if (bildtitel)		fenstertitel = "Bild: " + bildtitel.replace(/<BR>/g," ");
	else			fenstertitel = "Bild: " + url;

	PopUp("about:blank", fensterbreite, fensterhoehe, false);

	popUpFenster.document.open("text/html");
	popUpFenster.document.writeln("<HTML><HEAD>");
	popUpFenster.document.writeln("<TITLE>" + fenstertitel + "</TITLE>");
	popUpFenster.document.writeln("<LINK REL=STYLESHEET TYPE=\"text/css\" HREF=\"/inc/css-layout.css\">");
	popUpFenster.document.writeln("</HEAD><BODY>");

	popUpFenster.document.writeln("<TABLE CELLPADDING=5 CELLSPACING=0 BORDER=0 WIDTH=100% ALIGN=CENTER>");
	if (bildtitel)
		popUpFenster.document.writeln("<TR ALIGN=CENTER><TD STYLE=\"border-bottom:" + linie + "\">" + bildtitel + "</TD></TR>");

	popUpFenster.document.write("<TR ALIGN=CENTER><TD>");
	popUpFenster.document.write("<IMG SRC=\"" + url + "\" BORDER=0 VSPACE=10>");
	popUpFenster.document.writeln("</TD></TR>");

	popUpFenster.document.writeln("<TR ALIGN=CENTER><TD STYLE=\"border-top:" + linie + "; font-size:8pt;\">");
	popUpFenster.document.writeln("<IMG SRC=\"/bild/symbol-drucken.gif\" WIDTH=12 HEIGHT=12 BORDER=0 HSPACE=2>");
	popUpFenster.document.writeln("<A HREF=\"javascript:window.print()\">Drucken</A> |");
	popUpFenster.document.writeln("<IMG SRC=\"/bild/symbol-schliessen.gif\" WIDTH=12 HEIGHT=9 BORDER=0 HSPACE=2>");
	popUpFenster.document.writeln("<A HREF=\"javascript:window.close()\">Fenster schlie&szlig;en</A>");
	popUpFenster.document.writeln("</TD></TR></TABLE>");

	popUpFenster.document.writeln("</BODY></HTML>");
	popUpFenster.document.close();
}


function Go(url)
{
	if (url)
	{
		if (popUpFenster)
			if (popUpFenster.closed == false)
				popUpFenster.close();

		if (url.indexOf("http") == 0)
		{
			popUpFenster = window.open(url, "_blank");
			popUpFenster.focus();
		}
		else
			window.location.href = url;
	}
}


function DeutschesDatum(datum)
{
	var datumstring = "";

	datumstring =	(datum.getDate()<10 ? "0" : "") +  datum.getDate()	+ "." +
			(datum.getMonth()<9 ? "0" : "") + (datum.getMonth()+1)	+ "." +
			datum.getFullYear();
	return (datumstring);
}



function VerhindereFrameDarstellung()
{
	if (top.location.href != self.location.href)
		top.location.href = self.location.href;
}




function Adr(accountVerkehrt, subdomainVerkehrt, topdomainVerkehrt, modus)
{
	var i, begrenzung1, begrenzung2;
	var linkwortVerkehrt = ":otliam";
	var zielfenster = window;

	switch (modus)
	{
		case 0:
			begrenzung1 = "";
			begrenzung2 = "";
			break;
		case 1:
			begrenzung1 = "&lt;";
			begrenzung2 = "&gt;";
			break;
		case 10:
			begrenzung1 = "<IMG SRC=\"/bild/symbol-brief.gif\" WIDTH=13 HEIGHT=9 BORDER=0> ";
			begrenzung2 = "";
			break;
		case 100:
			begrenzung1 = "";
			begrenzung2 = "";
			if (un)
				zielfenster = un;
			else
				return;
			break;
		default:
			begrenzung1 = "";
			begrenzung2 = "";
			break;
	}

	zielfenster.document.write(begrenzung1);

	zielfenster.document.write("<A HREF=\"");
	for (i=linkwortVerkehrt.length-1; i>=0; i--)
		zielfenster.document.write(linkwortVerkehrt.charAt(i));
	for (i=accountVerkehrt.length-1; i>=0; i--)
		zielfenster.document.write(accountVerkehrt.charAt(i));
	zielfenster.document.write("&#64;");
	for (i=subdomainVerkehrt.length-1; i>=0; i--)
		zielfenster.document.write(subdomainVerkehrt.charAt(i));
	zielfenster.document.write("&#46;");
	for (i=topdomainVerkehrt.length-1; i>=0; i--)
		zielfenster.document.write(topdomainVerkehrt.charAt(i));
	zielfenster.document.write("\">");

	for (i=accountVerkehrt.length-1; i>=0; i--)
		zielfenster.document.write(accountVerkehrt.charAt(i));
	zielfenster.document.write("&#64;");
	for (i=subdomainVerkehrt.length-1; i>=0; i--)
		zielfenster.document.write(subdomainVerkehrt.charAt(i));
	zielfenster.document.write("&#46;");
	for (i=topdomainVerkehrt.length-1; i>=0; i--)
		zielfenster.document.write(topdomainVerkehrt.charAt(i));

	zielfenster.document.write("</A>");

	zielfenster.document.writeln(begrenzung2);
}
