/* 					Javascripts f�r Basis Website							  */

/* Beschreibung:	alle Javascriptfunktionen sollen in einem zentralen File  */
/* 					gehalten werden. Die vorliegende Version enth�lt alle     */
/*					Funktionen, die f�r die Vorlagen ben�tigt werden		  */
/*																			  */
/* Ge�ndert am:		06:11:2003 Zusammenfassung der bestehenden Files		  */
/*						jslib.js und md_css.js									  */
/* Autor:			ISC@Scandio GmbH 										  */
/* Ge�ndert am:		22.01.2004 */
/*						Functions added: getNavigation, isExpectedFrameStructure */
/*						Functions deleted: ZweiFrames, link, CSS checking functions */
/* Autor:			ISC@Scandio GmbH 	*/

/* ########################################################################## */
/* Funktions�bersicht														  */
/* ########################################################################## */
// function quicklink (selbox)
// function quicklink2 (selbox)
// function getVIPURL(url)
// function gotoUrl(url)
// function setChecked(formButton, optionValue)
// function Trim(inString)
// function URLEncode(myUrl)
// function URLDecode(myUrl)
// function trim(inputString)
// NEU: function getConditionTag(bd) 	ISC 05.11.2003 : Stylesheet Bedingungen
// NEU: function printAktDate()	 			ISC 08.11.2003 : awp



///////////////////////////////////////////////////////////////////////////////
// aus Vorlage navigation_top
///////////////////////////////////////////////////////////////////////////////
function quicklink (selbox){
	var selindex = selbox.selectedIndex;
	var sellink = selbox.options[selindex].value;
	var seltarget = selbox.options[selindex].id;
	selbox.selectedIndex = 0;
	window.open(sellink, seltarget);
}

///////////////////////////////////////////////////////////////////////////////
// L�nderauswahlbox
///////////////////////////////////////////////////////////////////////////////
function quicklink2 (selbox) {
	var selindex = selbox.selectedIndex;
	var sellink = selbox.options[selindex].value;
	// erster Eintrag nicht w�hlbar
	if (selindex > 0) {
		parent.location.href = sellink;
	}
}

///////////////////////////////////////////////////////////////////////////////
// Funktion f�r Linkverwaltung
function getVIPURL(url) {
    return url;
}

///////////////////////////////////////////////////////////////////////////////
//link aufruf
function gotoUrl(url) {
    location.href = url;
}

///////////////////////////////////////////////////////////////////////////////
function setChecked(formButton, optionValue) {
	fField = eval('document.'+formButton);

    for(var i = 0; i < fField.length; i++) {
    	if(fField[i].value == optionValue) {
        	fField[i].checked = true;
          	i = fField.length;
        }
   	}
}

///////////////////////////////////////////////////////////////////////////////
// Utility function to trim spaces from both ends of a string
///////////////////////////////////////////////////////////////////////////////
function Trim(inString) {
  var retVal = "";
  var start = 0;
  while ((start < inString.length) && (inString.charAt(start) == ' ')) {
    ++start;
  }
  var end = inString.length;
  while ((end > 0) && (inString.charAt(end - 1) == ' ')) {
    --end;
  }
  retVal = inString.substring(start, end);
  return retVal;
}


// Encode eine URL. Muss f�r die Kompatibilit�t mit JavaScript 1.2
// bzw. mit Netscape 4.7x implementiert werden
function URLEncode(myUrl)
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetci
					"abcdefghijklmnopqrstuvwxyz" +
					"-_!~*()&/?:";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = myUrl;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" + ch + "' cannot be encoded using standard URL encoding.\n" +
				        "(URL encoding only supports 8-bit characters.)\n" +
						"A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	return encoded;
}

///////////////////////////////////////////////////////////////////////////////
function URLDecode(myUrl) {
   // Replace + with ' '
   // Replace %xx with equivalent character
   var encoded = myUrl;
   var plaintext = "";
   var i = 0;
   while (i < (encoded.length-2)) {
       var ch = encoded.charAt(i);
	   if (ch == "+") {
	       plaintext += " ";
		   i++;
	   } else if (ch == "%" && encoded.charAt(i+1) != "%") {
	       plaintext += unescape( encoded.substr(i,3) );
		   i += 3;
		} else {
		   plaintext += ch;
		   i++;
		}
	} // while
	if (i < encoded.length) {
	    plaintext += encoded.substr(i,encoded.length-i);
	}
   return unescape(plaintext);
}
///////////////////////////////////////////////////////////////////////////////
//Da im NS4.78 die Funktion Trim nicht vorhanden ist, hier eine Implementierung
///////////////////////////////////////////////////////////////////////////////
function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function


///////////////////////////////////////////////////////////////////////////////
// getConditionTag() liefert "IE", "NS", "IEV4", "IEV6", "NSV4", "NSV6" oder "unknown"
// zur Unterscheidung der versch. Browser und Versionen
///////////////////////////////////////////////////////////////////////////////
function getConditionTag(bd) {
	var retVal = "unknown";
	if (bd.browser == "IE" ){
		retVal = "IE";
		if ( bd.version < 5 ){
			retVal = retVal + "V4";				// IE Version kleiner 5.x
		}
		if (bd.version >= 5 ){
			retVal = retVal + "V6";				// IE ab Version 5
		}
	}
	if (bd.browser == "Netscape" ){
		retVal = "NS";
		if ( bd.version < 5 ){
			retVal = retVal + "V4";				// NS Version kleiner 6.x
		}
		if (bd.version >= 5 ){
			retVal = retVal + "V6";				// NS ab Version 6
		}
	}
	return retVal;
}

///////////////////////////////////////////////////////////////////////////////
// Schreibt das Tagesdatum im Format TT.MMM.JJJJ
///////////////////////////////////////////////////////////////////////////////
function printAktDate() {
		var now = new Date();
		var yr = now.getYear();
		if ( yr< 2000) {
			yr+=1900;
		}

		var mName = now.getMonth() + 1;
		var dName = now.getDay() + 1;
		var dayNr = ((now.getDate()<10) ? "0" : "")+ now.getDate();

		if(dName==1) Day = "Sonntag";
		if(dName==2) Day = "Montag";
		if(dName==3) Day = "Dienstag";
		if(dName==4) Day = "Mittwoch";
		if(dName==5) Day = "Donnerstag";
		if(dName==6) Day = "Freitag";
		if(dName==7) Day = "Sonnabend";

		if(mName==1) Month="JANUAR";
		if(mName==2) Month="FEBRUAR";
		if(mName==3) Month="M&Auml;RZ";
		if(mName==4) Month="APRIL";
		if(mName==5) Month="MAI";
		if(mName==6) Month="JUNI";
		if(mName==7) Month="JULI";
		if(mName==8) Month="AUGUST";
		if(mName==9) Month="SEPTEMBER";
		if(mName==10) Month="OKTOBER";
		if(mName==11) Month="NOVEMBER";
		if(mName==12) Month="DEZEMBER";

		// String to display current date.
		var todaysDate =(" " + dayNr + ". " + Month + " " + yr + "<BR>");

		// Write date to page.
		document.open();
//document.write('<FONT COLOR="#000000" SIZE="1" face="arial, helvetica">'+todaysDate+'</FONT>');
		document.write(todaysDate);
} // function printAktDate()

function showBild(url){
	var strWindowProps = "top=0, left=0, width=1000, height =600, scrollbars=yes, dependent=yes,resizable=yes";
	var strFensterName  = "BildGross";
	window.open(url,strFensterName,strWindowProps);
}

////////////////////////// Statistik //////////////////////////////////////////
sfHover = function() {
	var sfEls = document.getElementById("linkList").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}


////////////////////////// end jslib.js ///////////////////////////////////////

