$().ready(function() {

	external_links();
	popup_links();

	// behebt das Flickern von Hintergrund-Bildern im IE(6)
	try {
	  document.execCommand("BackgroundImageCache", false, true);
	} catch(err) {}

	// Produktdetailseiten-Animation
	$('div#content2-3 a.details').each(function(){
		$(this).bind("click",false,showProductDetails);
	});
	
	// Vertikale Navigation des Menüs anzeigen
	$("#scrolling_up_id").toggle();
	$("#scrolling_down_id").toggle();

	// Scroll-Leisten des Menüs verstecken
	$("#container1").css("overflow","hidden");

});

function showProductDetails() {
//alert("spd")
	$("div#content1-3").slideUp("slow",function(){;
			$("div#content2-3").animate(
				{
					right: 271
				},
				"slow",
				function () {
					$("td.spalte_lu a").html($("td.spalte_lu a").html().replace(details,zurueck));
					$("td.spalte_lu b:first").html("&lt;&lt;");
					$("div#content-details").show();
					$('div#content2-3 a.details').unbind("click");
					$('div#content2-3 a.details').bind("click",false,hideProductDetails);
				}
			);
		});
	return false;
}

function hideProductDetails() {
//alert("hpd")
	$("div#content-details").slideUp(function() {

		$("div#content2-3").animate(
			{
				right: 0
			},
			"slow",
			function() {
				
				$("div#content1-3").slideDown();
				$("td.spalte_lu a").html($("td.spalte_lu a").html().replace(zurueck,details));
				$("td.spalte_lu b:first").html("&gt;&gt;");
				$('div#content2-3 a.details').unbind("click");
				$('div#content2-3 a.details').bind("click",false,showProductDetails);

			}
		);

	});
	return false;
}

function getElementsByClassName(classname,tag) {
	if(!tag) tag = "*";
	var anchs =		document.getElementsByTagName(tag);
	var total_anchs = anchs.length;
	var regexp = new RegExp('\\b' + classname + '\\b');
	var class_items = new Array()

	for(var i=0;i<total_anchs;i++) {
		var this_item = anchs[i];
		if(regexp.test(this_item.className)) {
		 class_items.push(this_item.id);
		}
	}
	return class_items;
}

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 popup_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") == "popup") {
			anchor.onclick=function() {
				popup_window(this.href+'?popup=true'); return false;
			}
			anchor.title = (anchor.title != "") ? anchor.title+" [öffnet in Popup-Fenster]" : anchor.getAttribute("href")+" [öffnet in Popup-Fenster]";
			anchor.className = (anchor.className != '') ? anchor.className+' popup' : 'popup';
		}
	}
}

function popup_window(url) {
	window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=560,height=600,screenX=150,screenY=150,top=150,left=150');
}

function popup_closelink() {
	document.writeln('<p class="closelink">');
	document.writeln('  <a href="#" onClick=\'window.close();\' title="Popup-Fenster schließen">Fenster schließen</a>');
	document.writeln('</p>');
}

function non(id) {
	document.getElementById(id).style.display="block";
	document.getElementById(id).style.backgroundColor="#ffffff";
	document.getElementById(id).style.zIndex="999";
}

function noff(id) {
	document.getElementById(id).style.display="none";
	document.getElementById(id).style.backgroundColor="transparent";
	document.getElementById(id).style.zIndex="1";
}

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