$().ready(function() {
	
	// Flash-Fallback
	
	// nur auf der Startseite
	if ($('body.welcome').length == 1) {
		if (userHasFlash) { // Wir können flashen
	
				// Fallback-Grafik verstecken
				$("div#flashheader img#flash-fallback").hide();
	
				$('#flashheader').flash({
					src: 'swf/intro.swf',
					width: 930,
					height: 186,
					id: 'flash_intro',
					name: 'flash_intro',
					swLiveConnect: true,
					allowScriptAccess: 'sameDomain',
					wmode: 'transparent',
					flashvars: {
						//noautoplay: true
					}
				},
				{
	    			update:true,
	      			version: '8'
					/*expressInstall: true,
					update:true
					version: '6.0.65',
					update: false*/
				},
				null,
				function(htmlOptions){ // Player zu alt
					$("div#flashheader img#flash-fallback").show();
					// Player-Tooltip anzeigen
					if(!readFlashFallbackCookie()) {
						$('div.flash-fallback-tooltip').css("display","block");
					}
				});
		}
		else { // Flash-Fallback
			// Player-Tooltip anzeigen
			if(!readFlashFallbackCookie()) {
				$('div.flash-fallback-tooltip').css("display","block");
			}
		}
	}

	// ------------------------------------------------------------
	// Navigation Header

	$("div#navigation2 ul li").each(function() {

		$(this).hover(function(){
			img = $(this).find('img');
			//console.log(img);
			img_path = img.attr("src");
			//$(this).attr("src", img_path.substring(0,img_path.indexOf('.png'))+'-over.png');

			img_path2 = img_path.replace(/\-over/, '');

			if (img_path == img_path2) {
				img.attr("src",img_path.replace(/(_[a-z]+)?\.png/, '-over$1.png'));
			}


		},function(){
			img.attr("src",img_path);

		});

	});

	$(".sprachswitch ul").hide();

	$(".sprachswitch").toggle(function(){
		$(".sprachswitch ul").show();
		},function(){
		$(".sprachswitch ul").hide();
	});

	external_links();

	// Höhe auslesen um die Schatten vom Content bis unten hin anzeigen zu können
	// divheight = ($("#content").height()+10)+"px";
	// $(".content-left").css({height:  divheight});
	// $(".content-right").css({height:  divheight});

	// IE6 Fix für den Seitennavigationsbackground
	 if ( $('body').is('.unternehmen') ) {
		divheight2 = ($("#content-wrapper").height())+"px";
		$("#content-wrapper").css({height:  divheight2});
	}
		
	// Produktübersicht Filter
		$("div.legende ul li").each(function() {
			$(this).click(function(){		
				locator = $(this).attr("class");
				isPadding = true;
				$("div#innercontent div h3").each(function() {
					$(this).parent("div").css("display","block");
					if (isPadding) {
						$(this).parent("div").css("padding-right", "40px");
					} else {
						$(this).parent("div").css("padding-right", "0px");
					}
					isPadding = !isPadding;
					if (($(this).attr("class") != "h3-"+locator) && ($(this).attr("class") != "h3-"+locator+" mitreg")) {
						$(this).parent("div").css("display","none");
						isPadding = !isPadding;
					}
				});
									
				// show = $("div#innercontent h3").attr("class");
				
				
			});
		});
	
	
});


// 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;
}

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;
}

