/**
* JavaScript-Funktionsbibliothek fuer http://www.thueringen.de
*
* © 2005-2008 <i-D> internet + Design GmbH & Co. KG
* Erfurter Str. 35
* 99423 Weimar
* Deutschland
* Fon:     03643 7785 0
* Fax:     03643 7785 29
* E-Mail:  office@i-d.de
* Web:     http://www.i.d.de/
*/

var loc = location.href.toLowerCase();
if (loc.indexOf("http://mobile")==-1) {
	var hp = new Array(/thueringen\.de\/de\/content\.html$/,
						/thueringen\.de\/de\/?$/,
						/thueringen\.de\/?$/,
						/thueringen\.de\/content\.html$/);
	for (var i=0;i<hp.length;i++) {
		if	(hp[i].test(loc)) {
			if (screen.width < "800" ) {
				window.location.href='http://mobile.thueringen.de/';
			} 
		}
	}
}	



if (!d) var d = document;
var load_handlers = new Array();

// -----------------------------------------------------------------------------

// zum Auffinden von maskierten E-Mail-Adressen
// geklammerte Elemente werden als Gruppe im Ergebnis der RegExp-Suche behandelt...
//var EMAIL_PATTERN  = /([a-zA-Z0-9\._-]+)(\[at\])([a-zA-Z0-9\._-]+)(\[punkt\])([a-zA-Z]+)/i;
var EMAIL_PATTERN  = /([a-zA-Z0-9\._-]+)([\{|\[]at[\}|\]])([a-zA-Z0-9\._-]+)([\{|\[]punkt[\}|}\]])([a-zA-Z]+)/i;
// ... und werden durch die folgende Werte ersetzt;
// leeres Feld bedeutet, das der urspruengliche Wert erhalten bleibt
// ACHTUNG: in Feld 0 steht immer das komplette Ergebnis; die Indizierung der
// geklammerten Ergebnisse beginnt also mit 1 (eins)!
var EMAIL_REPLACES = new Array (5);
EMAIL_REPLACES[2] = '@';
EMAIL_REPLACES[4] = '.';

// -----------------------------------------------------------------------------

/**
* Frameblocker
*
* @author Niels Bobogk <niels@i-d.de>
*/
if (top != self) top.location = self.location;

// -----------------------------------------------------------------------------

/**
* JavaScript-Include
*
* @return void
* @author Niels Bobogk <niels@i-d.de>
*/
function include(path) {
	if (!d.createElement) {
		return;
	}
	var s = d.createElement('script');
	if (s) {
		try {
			s.setAttribute('type', 'text/javascript');
			s.setAttribute('src', path);
			s.setAttribute('charset', 'iso-8859-1');
			var head = d.getElementsByTagName('head')[0];
			if (head) {			
				head.appendChild(s);
			}
		} catch (e) {
			return (e);	
		}
	}
}

// -----------------------------------------------------------------------------

/**
* generiert einen Textlink zum Oeffnen des Druckdialogs des Browsers;
* wird deshalb nur angezeigt, wenn JS aktiviert ist
*
* @return void
* @author Niels Bobogk <niels@i-d.de>
*/
function printlink() {
	if (print) { 
		d.open();
		d.write("<a href=\"java" + "script:print();\" title=\"&Ouml;ffnet das Dialogfenster &raquo;Drucken&laquo; Ihres Browsers\" class=\"iconPrinter\">Drucken<\/a>");//<\/li>");
		d.close(); 
	}	
}

// -----------------------------------------------------------------------------

/**
* für Flexmodul popup_fixwin
* Öffnet ein Bild in gegebenen Maßen im neuen Browaserfenster
*
* @return void
* @author Dirk Hildebrandt <hille@i-d.de>
*/
function picwin(pfad, winname, options) {
	var win = window.open(pfad, winname, options);
}

// -----------------------------------------------------------------------------

/**
* für TLVWA id_openwin
* öffnet fenster mit text.
*
* @return void
* @author Dirk Hildebrandt (hille@i-d.de)
*/
function id_openw(pfad, winname, options) {
	var win = window.open(pfad, winname, options);
}

// -----------------------------------------------------------------------------


/**
* ersetzt maskierte Mail-Adressen sowohl in Textknoten als auch in
* mailto-Links
*
* @author Niels Bobogk <niels@i-d.de>
* @return void
*/
function decodeEMail() {
	// zunaechst alle mailto-Links bearbeiten
	var a = d.links;
	var matches, newEMail;

	// href aller mailto-links ersetzen
	for (var i = 0; i < a.length; i++) {
		if(a[i].href.indexOf('mailto')>-1) {
		a[i].href = a[i].href.replace(/\[punkt\]/i,".");
		a[i].href = decodeURI(a[i].href);
			
		a[i].href = a[i].href.replace(/%7B/i,"{");
		a[i].href = a[i].href.replace(/%7D/i,"}");
		
		matches = EMAIL_PATTERN.exec(a[i].href);
		if (matches != null) {
			a[i].href = a[i].href.replace(EMAIL_PATTERN, replaceMaskedEMail(matches));
			if (navigator.appName.indexOf("Internet Explorer") != -1) {
				EMAIL_PATTERN.lastIndex = 0;
			}
		};
		
		a[i].href = a[i].href.replace(/%7Bpunkt%7D/i,".");
		a[i].href = a[i].href.replace(/%7Bat%7D/i,"@");
}
	}	
	// alle Textknoten filtern
	decodeEMailInText(d.body);
}

// -----------------------------------------------------------------------------

/**
* durchsucht rekursiv die Textknoten ab einer bestimmten Stelle nach
* maskierten E-Mailadressen
*
* @author Niels Bobogk <niels@i-d.de>
* @param object node: Startknoten (z.B. 'document.body')
* @return void
*/
function decodeEMailInText(nodeCurr) {
	for (var i = 0; i < nodeCurr.childNodes.length; i++) {
		decodeEMailInText(nodeCurr.childNodes[i]);	
	}
	// Textknoten?
	if (nodeCurr.nodeType == 3) {
		var matches = EMAIL_PATTERN.exec(nodeCurr.nodeValue);
		if (matches != null) {
			nodeCurr.nodeValue = nodeCurr.nodeValue.replace(EMAIL_PATTERN, replaceMaskedEMail(matches));
		};	
	}
}

// -----------------------------------------------------------------------------

/**
* maskierte E-Mail-Adresse umwandeln
*
* @param match auf maskierte E-Mail-Adresse
* @return string
*/
function replaceMaskedEMail(matches) {
	var newEMail = '';
	
	try {		
		if (matches != null) {		
			// Indizierung der Gruppen beginnt ab Feld 1 !
			for (var i = 1; i < matches.length; i++) {
				// urspruenglichen Wert behalten
				if (EMAIL_REPLACES[i] == null || EMAIL_REPLACES[i] == '') {
					newEMail += matches[i];
				}
				// Wert ersetzen
				else {
					newEMail += EMAIL_REPLACES[i];
				}
			}
		}
	} 
	catch (e) {
		newEMail = "FEHLER: " + e;	
	}
	return 	newEMail;
}

// -----------------------------------------------------------------------------

/**
* falls Prototype nicht geladen wurde, wird in einer Zeitschleife gewartet,
* bis die erforderlichen Funktionen zur Verfuegung stehen
*
* @return void
*/
function waitPrototype() {
	if (typeof Prototype != 'undefined') {
		window.clearTimeout(d.to);
		// Opera führt schon eher aus, daher so:
		Prototype.Browser.Opera ? Event.observe(window, 'load', decodeEMail) : decodeEMail();			
	} else {
		d.to = window.setTimeout('waitPrototype()', 1000);
	}
}

// -----------------------------------------------------------------------------


function init() {
	decodeEMail();
	for (var i = 0; i < load_handlers.length; i++) {
		eval(load_handlers[i]);
	}
}

// -----------------------------------------------------------------------------

if (typeof Prototype == 'undefined') {
	// Aufruf der Include-Funktion. Ist das Erste Feld ein leerer String '', dann wird immer included
	// entweder so mit Prototype:
	// include('/de/js/prototype-1.5.1.2.js');
	// waitPrototype();
	// oder so ohne:
	window.onload = init;	
} else {
	Event.observe(window, 'load', init);	
}



//----------------------------------------------------------------------
// Flexmodul: Textbox mit 3 Tabs 


function switchTab(flex,id){
  for (a=1; a<=3; a++){
    var aktuell = document.getElementById("textboxTab-"+flex+"-"+a);
    if (a == '1'){
      if (a == id){
        aktuell.className = "textboxTitel first textboxAktiv";
        document.getElementById('textboxContent-'+flex+'-'+a).style.display="block";
      }
      else {
        aktuell.className = "textboxTitel first";
        document.getElementById("textboxContent-"+flex+"-"+a).style.display="none";
      }
    }
    else {
      if (a==id) {
        aktuell.className = "textboxTitel textboxAktiv secondThird";
        document.getElementById('textboxContent-'+flex+'-'+a).style.display="block";
      }
      else {
        aktuell.className = "textboxTitel secondThird";
        document.getElementById("textboxContent-"+flex+"-"+a).style.display="none";
      }
    }
  }
}


/**
*   file:           idTools-0.2.1.js
*
*   function:       Require
*   begin:          feb.2009
*   copyright:      © 2009 <i-D> internet + Design GmbH & Co. KG
*                   Erfurter Str. 35
*                   99423 Weimar
*                   Deutschland
*                   Fon:     03643 7785 0
*                   Fax:     03643 7785 29
*                   E-Mail:  office@i-d.de
*                   Web:     http://www.i.d.de/
*   author:         Michael Waack <m.waack@i-d.de>
*
*		0.1							Require(filename|modulname)[regex]
*										addEvent(window, 'load', function)
*										addStyle(filename)
*		0.2							viewport.height() ! Funktion, da jedesmal neu berechnet wird falls Browserfenster geändert wurde
*										viewport.width()
*										Cookie.get(name) 
*													.set(name, value(string), daysToExpire)
*													.erase(name) 
*
*		0.2.1		Wichtiges Update: (2009-06-03)
*					idTools.cfg.js hinzugefügt. Enthält die Konfigurierten Module
*					__libPath muss nicht mehr gesetzt werden
*/



var idTools = function() {
/* PRIVATE */
		// version
		var __version = '0.2.1';
		
		/* CONFIG_REQUIRE */
		var __libPath;// = "/js/lib/";												// Pfad zu den Bibliotheken
		
		/* UPDATE 2009-06-03: 
		*		bibliothekenpfad wird dynamisch gebaut
		*		configurationsfile wird gelesen
		*/
		
		var scrDummy = document.getElementsByTagName('script');
		for (i=0;i<scrDummy.length;i++) {
//			if (scrDummy[i].src !== undefined && (scrDummy[i].src.match(/\?idTools\.v=/g) || scrDummy[i].src.match(/idTools.+\.js/g) || scrDummy[i].src.match(/thueringen.+\.js/g))) { // idTools.v=
			if (scrDummy[i].src !== undefined && (scrDummy[i].src.match(/thueringen/g) || scrDummy[i].src.match(/\?idTools\.v=/g) || scrDummy[i].src.match(/idTools.+\.js/g))) { // idTools.v=
				
				__libPath = scrDummy[i].src.substr(0,scrDummy[i].src.lastIndexOf('/'));
				// Config einlesen
				__loadModul(__libPath + '/idTools.cfg.js');
				__libPath +=  '/lib/'; // fest defnierter Pfad!
				break;
			}
		}

	
		var __xReq;							// zum einlesen der Module
		var __modulIndex = null;			// Index im Array des aktuellen Moduls
		var __modulName = null;				// Name des Aktuellen Moduls
		var __RequireReady = new Array();	// Speichert Ladezustand der Module
		
/* --------------------------------------- */
/* Interne Funktionen zum laden der Module */
	function __loadModul(item)
	{
		__modulIndex = item;
		__xReq = __createXMLHttpRequest();	
	  //__xReq.onreadystatechange = __handleStateChange;
	  if (typeof(__modul) != 'undefined') {
	  	__xReq.open('GET', __libPath + __modul[item][0], false); 
	  	__modulName = __libPath + __modul[item][0];
	}
	  else {
	  	__xReq.open('GET', item, false); 
	  	__modulName = item;
	}
	  __xReq.send(null);
		if (__xReq.readyState == 4){
			exec(__xReq.responseText);
			if (typeof(__modul[item]) != 'undefined')
				__modul[item][2] = 1;
		}
	}
	function exec(script) {
//		try {
		( window.execScript ) ? window.execScript( script ) : window.eval( script );
//		if (navigator.userAgent.match(/Firefox/i)) console.log('done loading ' + __modulName);
//		}
//		catch (err) {
//			if (navigator.userAgent.match(/Firefox/i)) {
//				console.log(err);
//				console.log('error loading ' + __modulName);
//			}
//		}
	}

/* --------------------------------------------------------------- */
/*		xmlRequest erstellen                                         */
/* --------------------------------------------------------------- */
	function __createXMLHttpRequest() {
	  var req = null;
  	try {
    	req = new ActiveXObject("MSXML2.XMLHTTP");
	  }
  	catch (err_MSXML2) {
    	try {
	      req = new ActiveXObject("Microsoft.XMLHTTP");
  	  }
    	catch (err_Microsoft) {
      	if (typeof XMLHttpRequest != "undefined") 
        	req = new XMLHttpRequest;
	    }
  	}
  	return req;
	}
		
	
/* ################################################################ */
/* Public */

return {
	version : __version,

/* --------------------------------------------------------------- */
/*		Ermittelt sichtbare höhe/breite des aktuellen Browsers	   */
/* --------------------------------------------------------------- */

	viewport : function () {
		var viewportwidth;
		var viewportheight;
		function __viewportRender(){
		 if (typeof window.innerWidth != 'undefined')
		 {
		      viewportwidth = window.innerWidth,
		      viewportheight = window.innerHeight
		 }
		 else if (typeof document.documentElement != 'undefined'
		     && typeof document.documentElement.clientWidth !=
		     'undefined' && document.documentElement.clientWidth != 0)
		 {
		       viewportwidth = document.documentElement.clientWidth,
		       viewportheight = document.documentElement.clientHeight
		 }
		 else
		 {
		       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
		       viewportheight = document.getElementsByTagName('body')[0].clientHeight
		 }
		}	
		 return {
		 	height : function() { __viewportRender(); return viewportheight; },
		 	width : function() { __viewportRender(); return viewportwidth; }
		 	
			}			
	}(),
	
/* --------------------------------------------------------------- */
/*		Lädt Module nach sofern noch nicht geladen                  */
/* --------------------------------------------------------------- */
	Require : function (modul)
	{
		var i = 0;
		__modulName = modul;
		__RequireReady[__modulName] = false;
		for (i=0;i<__modul.length;i++)
		{
			if (__modul[i][0].match(modul))
			{
				if(__modul[i][2]==1)
					return;
				if(!__modul[i][1])
				{
					__loadModul(i);
					return;
				}
			}
		}
		// Modul nicht in config, datei einlesen
		__modul.push (new Array(modul,true,0));
		__loadModul(__modul.length-1);
		__modul[i][2]=1;
		
	},

/* Fügt eine Event zum angegebenen Object hinzu (z.B. __addEvent(window, 'load', function); */
	addEvent : function (obj, evType, fn)
	{ 
		if (obj.addEventListener){ 
	   obj.addEventListener(evType, fn, false); 
  	 return true; 
 		} else if (obj.attachEvent){ 
   		var r = obj.attachEvent("on"+evType, fn); 
	   	return r; 
 		} else { 
   		return false; 
 		} 
	},
	addStyle : function (styleFile,styleType) 
	{
		var st = document.createElement("link");
		st.setAttribute("href",styleFile);
		if (styleType === undefined) styleType = "screen";
		st.setAttribute("media",styleType);
		st.setAttribute("type","text/css");
		st.setAttribute("rel","stylesheet");
		
		document.getElementsByTagName("head")[0].appendChild(st);
		//document.write('<link href="/de/css/slideshow/slideshow-js.css" rel="stylesheet" media="screen" type="text/css" />');
	},
	Trim: function (strValue)
	{
		return strValue.replace (/^\s+/, '').replace (/\s+$/, '');
	},
Cookie : function ()
		{ 
			return {
  set: function(name, value, daysToExpire) {  
    var expire = '';  
    if (daysToExpire != undefined) {  
      var d = new Date();  
      d.setTime(d.getTime() + (86400000 * parseFloat(daysToExpire)));  
      expire = '; expires=' + d.toGMTString();  
    }  
    return (document.cookie = escape(name) + '=' + escape(value || '') + expire);  
  },  
  get: function(name) { 
  	var keyEquals = name+"="; 
  	var value = false;
		document.cookie.split(';').invoke('strip').each(function(s){
    	if (s.startsWith(keyEquals)) {
					value = unescape(s.substring(keyEquals.length, s.length));
          throw $break;
       }
  		});
    return value;  
  },  
  erase: function(name) {  
    var cookie = idTools.Cookie.get(name) || true;  
    idTools.Cookie.set(name, '', -1);  
    return cookie;  
  },  
  accept: function() {  
    if (typeof navigator.cookieEnabled == 'boolean') {  
      return navigator.cookieEnabled;  
    }  
    idTools.Cookie.set('_test', '1');  
    return (idTools.Cookie.erase('_test') === '1');  
  } 				
				
				
				
			}
		}()	
	
	

};}();

if (location.href.indexOf('/landtag/')>0) {
	/* idTools.Require ("../../../js/lib/scripty2/2.0.0_b1/dist/release/prototype.s2.js");
	idTools.Require ("lytebox.js");
	idTools.addStyle("/css/screen/uc/Lytebox.css"); */
} else {
	idTools.Require ("highslide/highslide.js");
}


