// behebt das Flickern von Hintergrund-Bildern im IE(6)
try {
	document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

function external_links() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
	var anchor = anchors[i];
	if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
		anchor.onclick = klick;
		anchor.title = (anchor.title != "") ? anchor.title+" [öffnet in neuem Fenster]" : anchor.getAttribute("href")+" [öffnet in neuem Fenster]";
		anchor.className = (anchor.className != '') ? anchor.className+' external' : 'external';
	  }
  } 
}

function klick () {
	window.open(this.href,'_blank');
	return false;
}

window.onload = function() {
  external_links();
}

function browserCheck() 
{
	var agt = navigator.userAgent.toLowerCase();
	this.ie4 = (document.all) ? true : false;
	this.ns4 = (document.layers) ? true : false;
	this.dom2 = (document.getElementById) ? true : false;
	this.ie5 = (this.ie4 && this.dom2) ? true : false;
	this.ns6 = (!this.ie4 && this.dom2) ? true : false;
	this.opa = (agt.indexOf('opera') != -1) ? true : false;
	this.win = (agt.indexOf('win') != -1) ? true : false;
	this.mac = (agt.indexOf('mac') != -1) ? true : false;
	
	if (this.ie4 && this.win && !this.opa) 
		{
		with (document) 
			{ 
			write('<script language="VBScript" type="text/vbscript">\n');
			write('Function flashActX(flashVer)\n');
			write('\tOn Error Resume Next\n');
			write('\t\n');
			write('\tDim FlashObj\n');
			write('\tFlashObj = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & flashVer))\n');
			write('\tflashActX = FlashObj\n');
			write('End Function\n');
			write('</script>\n');
			}
		this.flashEnabled = (typeof(flashActX(4)) != 'undefined') ? true : false;
		this.flash5Enabled = (typeof(flashActX(5)) != 'undefined') ? true : false;
		this.flash6Enabled = (typeof(flashActX(6)) != 'undefined') ? true : false;
		} 
	else 
		{
		if (navigator.plugins && navigator.plugins['Shockwave Flash']) 
			{
			var flashPlugIn = 0;
			var str = navigator.plugins['Shockwave Flash'].description.split(' ');
			for (var i = 0; i < str.length; i++) 
				{
				if (!isNaN(parseInt(str[i]))) 
					{
					flashPlugIn = parseInt(str[i]);
					break;
					}
				}
			this.flashEnabled = (flashPlugIn >= 4) ? true : false;
			this.flash5Enabled = (flashPlugIn >= 5) ? true : false;
			this.flash6Enabled = (flashPlugIn >= 6) ? true : false;
			} 
		else 
			{
			this.flashEnabled = false;
			}
		}
}

function neuesFenster(formul){
	var alles = document.getElementById(formul);
	var uebstr = '';
	for(var i=0;i<alles.length;i++){
		if(alles.elements[i].type != "hidden" && alles.elements[i].type != "submit"){		
			uebstr += alles.elements[i].name;
			uebstr += "="+alles.elements[i].value+"&";
		}
	}
	uebstr = uebstr.substring(0,uebstr.lastIndexOf("&"));	
	window.open(alles.url.value+"?"+uebstr);
	return false;
}

function str_replace(search, replace, subject) {
    return subject.split(search).join(replace);
}

function slugify(text)
{
    var slug_array = text.split(" ");
    var slug = slug_array.join("-");
	return slug.toLowerCase();
}

jQuery.noConflict();

jQuery().ready(function() {
			
	/* Intro */
	if (jQuery('body').hasClass('welcome') == true) {
		jQuery('.wt-mainpic div').cycle({ 
			timeout: 2000,
			speed: 2000,
			pause:  1, 
			delay:  -2000
		});
	}

	jQuery("a.infolink").each(function() {
		var loc = jQuery(this).attr("class");
		loc = str_replace("infolink ","",loc);
		jQuery(this).mouseover(function(){	
			jQuery("#"+loc+"-text").css("display","block");
			jQuery('.wt-mainpic div').cycle('pause');
			jQuery("#"+loc+"-bild").css("display","block");
			jQuery("#"+loc+"-bild").css("opacity","1");
			jQuery("#"+loc+"-bild").css("z-index","5");
		});
		jQuery(this).mouseout(function(){
			jQuery("#"+loc+"-text").css("display","none");	
			jQuery("#"+loc+"-bild").css("display","none");
			jQuery("#"+loc+"-bild").css("opacity","0");
			jQuery("#"+loc+"-bild").css("z-index","1");		
	
			if (loc == "shd") {
				var go = "0";
			}
			else if (loc == "h21") {
				var go = "1";
			}
			else if (loc == "hdg") {
				var go = "2";
			}
			else if (loc == "shg") {
				var go = "3";
			}
			
			jQuery('.wt-mainpic div').cycle({ 
				timeout: 2000,
				speed: 2000,
				pause:  1, 
				delay:  -2000,
				startingSlide: go
			});
		});
	});
	
	
	/* Navigation */	
	jQuery("#navigation > ul > li").each(function() {
		if (!jQuery(this).hasClass("aktiv")) {
			jQuery(this).mouseover(function(){					
				jQuery(this).children("div").css("display","block");	
				jQuery(this).addClass("aktiv");
			});
			jQuery(this).mouseout(function(){					
				jQuery(this).children("div").css("display","none");
				jQuery(this).removeClass("aktiv");
			});
		}
	});
	
	
	jQuery("#navigation > ul > li.aktiv > a").click(function() {
		 jQuery(this).parent('li').toggleClass("aktiv");
		 return false;
	});
	
	/* Content Navigation */	
	jQuery("#innercontent > ul.cnavi > li").each(function() {
		
		slug = slugify(jQuery(this).children("a").html());
		jQuery(this).children("a").attr("href",jQuery(this).children("a").attr("href") + slug).attr("rel",slug);
		if('#' + jQuery(this).children("a").attr("rel") == location.hash){
			jQuery(this).children("div").css("display","block");
		}
		
		jQuery(this).click(function() {
			jQuery(this).parent("ul").children("li").children("div").css("display","none");
			jQuery(this).children("div").css("display","block");	
		});
	});
	
});
