
/* 					Javascripts f�r Mike 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.08.2004  ISC@Scandio GmbH: Zusammenfassung der bestehenden Files jslib.js und md_css.js	  		*/
/*  		07.08.2004  ISC@Scandio GmbH: Functions added: getNavigation, isExpectedFrameStructure 	 			*/
/*					 Functions deleted: ZweiFrames, link, CSS checking functions 				*/
/* 		13.02.2006  frameless Umstellung						    	         		*/
/* 		13.06.2006  Bereinigung (Framefunktionen, Browserdetection) 						    	         		*/

/* ########################################################################## */
/* Funktions�bersicht														  														*/
/* ########################################################################## */

// function track(url)
// NEU: function switchElement(el, sw)		// Direktsprung	�ber CSS statt selectbox: ersetzt quicklink()
// function quicklink(selbox)			// MIKE3: aus Topnav // nach der n�chsten Statifizierung raus

// function SucheStarten()
// function Trim(inString)
// function trim(inputString) behebt Bug im NS4.72
// function openWindow(url) 	f�r Akademie
// function BrowserDetector(ua)
// function URLEncode(myUrl)
// function URLDecode(myUrl)
// function getVIPURL(url)

//		Funktionen aus der Datei md_css.js
//	function impressum_german(){   
//	function impressum_english(){

//	function setChecked(formButton, optionValue)
//	function gotoUrl(url)
//	function xchgServer(aUrl, serverUrl)
//  function setFontSize(size){
// ***************************************************************************

///////////////////////////////////////////////////////////////////////////////
// f�r KlickTracker
///////////////////////////////////////////////////////////////////////////////
function track(url){ 
  var img = new Image();
  img.src = url;   
}

///////////////////////////////////////////////////////////////////////////////
// Schaltet Elementanzeige ein/aus (derzeit verwendet fuer direktsprung)
///////////////////////////////////////////////////////////////////////////////
function switchElement(el, sw){
	if(sw == 'on'){
		el.style.display = "block";
	}
	if(sw == 'off'){
		el.style.display = "none";
	}
}


///////////////////////////////////////////////////////////////////////////////
// Utility to select item from select-box and open in new window
// ISC: kann bald raus, wird ersetzt durch switchElement() und CSS
///////////////////////////////////////////////////////////////////////////////
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);
}

///////////////////////////////////////////////////////////////////////////////
// starts Search (is tracked by eTracker)
///////////////////////////////////////////////////////////////////////////////
function SucheStarten()
{
	var etrackerurl = "http://62.80.2.70/cnt.php?et=i9bs5E&java=j&et_easy=0&et_pagename=Suchanfrage+'";
	etrackerurl += encodeURI(document.Suchform.Suchfeld.value);
	etrackerurl += "'&et_areas=&et_ilevel=0&et_target=&et_lpage=";
	if (document.images)
	{
		document.images["se_usage"].src = etrackerurl;
	}
	parent.mainFrame.location.href ="http://www.ihk-muenchen.de/jsp/search/search.jsp?query="+document.Suchform.Suchfeld.value+"&lang=de&hitsPerPage=10&curPage=1";
}

///////////////////////////////////////////////////////////////////////////////
// Utility functions 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;
}

//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

///////////////////////////////////////////////////////////////////////////////
// �ffnet Fenster (f�r Akademie)
///////////////////////////////////////////////////////////////////////////////
function openWindow(url, attrs) {
	popUpWin = null;
	if (attrs != null){
		popUpWin = window.open(url,'demoWin',attrs);
	}else{
		popUpWin = window.open(url,'demoWin','toolbar=0,status=0,menubar=0,scrollbars=0,resizable=0,width=760,height=540');
	}
  if (navigator.appName == 'Netscape') {
	  popUpWin.focus();
  }
} // function openWindow()


// 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
// never ever add those: reserved=";/?:@&=+$," // also RFC2396

	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);
}


// Funktion f�r Linkverwaltung

function getVIPURL(url)
{
    return url;
}

/* md_css.js beginnt hier*/
function impressum_german(){
  top.location.href=/*VIPURL*/"http://edit.ihk-muenchen.de/mike/mike_edit/mike/WirUeberUns/Impressum/index.jsp";
}

function impressum_english(){
  top.location.href=/*VIPURL*/"http://edit.ihk-muenchen.de/mike/mike_edit/mike/WirUeberUns/Impressum/index.jsp";
}


  //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;
        }
      }
    }


	function xchgServer(aUrl, aServerUrl){
		if (aServerUrl == null || aServerUrl.length == 0 || aUrl == null || aUrl.length == 0){
			return aUrl;
		}
		var urllength = aServerUrl.indexOf(':')+3; // 3 is length of "://"
		var aServer = aServerUrl.substring(0, aServerUrl.indexOf('/',urllength));
		return aServer+aUrl.substring(aUrl.indexOf('/',urllength));
	}

	// Textgroesse der mittleren Spalte veraendern
	function setFontSize(size,bereich){
		var zoomBereich;
		if(bereich==null||bereich==''){
			zoomBereich = document.getElementById("contentblock");
		}
		else{
			zoomBereich = document.getElementById(bereich);
		}
		if(size =='s'){
			zoomBereich.style.fontSize = "70%";
		}
		else if(size =='m'){
			zoomBereich.style.fontSize = "100%";
		}
		else if(size =='l'){
			zoomBereich.style.fontSize = "130%";				
		}
	}
//-->	
