jQuery(document).ready(function(){
   jQuery(".wLayout input#password").keyup(function(){
   
   maxlimit = 10 ;
   	value = jQuery(this).val();
   
   if (value.length > maxlimit){
	 		value = value.substring(0, maxlimit);
	 		jQuery(this).val(value);
	 		alert("Nur 10 Zeichen sind zulässig");
	 }
      
  
	 });
 });

/*
	JavaScript-Funktionen
*/

// Event-Hilfsfunktionen Funktionen
function addEvent(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;
	}
}

function getGetTarget(evt) {
	if(evt.srcElement) return evt.srcElement;
	else return evt.target;
}

// beim Laden initialiesieren
window.onload = init;
timerHauptmenu = null;

// initialisieren:
function init() {
	// Mouseoverfunktionen dem Hauptmenue hinzufuegen
	var idprodukt = document.getElementById("produkt");
	if(idprodukt) {
		var imgs = idprodukt.getElementsByTagName("IMG");
		for(j=0;j<imgs.length;j++) {
			var img = imgs[j];
			if(img.src.indexOf("jpg") == -1) img.parentNode.removeChild(img);
		}
	}
	
	
	menu = document.getElementById("hauptmenu");
	if(menu) {
		lis = menu.getElementsByTagName("LI");
		for(j=0;j<lis.length;j++) {
			if(lis[j].parentNode.parentNode == menu) {
				addEvent(lis[j], "mouseover", highliteHauptmenu);
				addEvent(lis[j], "mouseout", setTimerFolgemenue);
			} else {
				addEvent(lis[j], "mouseover", highliteSubmenueButton);
				addEvent(lis[j], "mouseout", downliteSubmenuButton);
			}
			addEvent(lis[j], "click", goToChildHref);
		}
	}

	favLink = document.getElementById("favoriteLink");
	if(favLink) addEvent(favLink, "click", add_favourite);

	pagerNumSelect = document.getElementById("pagerNumSelect");
	if(pagerNumSelect) {
		addEvent(pagerNumSelect, "change", submitMyForm);
	}

	quickfinder = document.getElementById("quickfinder");
	if(quickfinder) {
		addEvent(quickfinder, "change", submitMyForm);
	}
	zbh = document.getElementById("zubehoer");
	if(zbh) {
		as = zbh.getElementsByTagName("A");

		if(as.length > 3) {
			for(j=0;j<as.length;j++) {
				addEvent(as[j], "click", showHideZubehoer);
			}
		} else {
			for(j=0;j<as.length;j++) {
				showHideZubehoer(as[j]);
			}
			return false;
		}
	}
	resizeContent();

	if(typeof(FLVPlayer.init) == "function") {
		FLVPlayer.init();
	}

}
function submitMyForm(evt) {
	obj = getGetTarget(evt);
	obj.form.submit();
}
function showHideZubehoer(evt) {
	// console.log("good");
	// alert("");
	if(evt.tagName == "A") obj = evt;
	else obj = getGetTarget(evt);
	if(obj) {
		if(obj.className == "") {
			obj.className = "offen";
			setSiblingsByClassName(obj.parentNode.parentNode,"hidden","_hidden");
			/* var ch = jQuery("#inhaltMitte").height();
			var nch = ch + 325; // content height + absolute positioned header + mainnav
			var wh = getWindowHeight();
			var newtop = (wh - nch)+"px"; */
			//setFooter();
		} else {
			obj.className = "";
			setSiblingsByClassName(obj.parentNode.parentNode,"_hidden","hidden");
			/* var ch = jQuery("#inhaltMitte").height();
			var nch = ch + 325; // content height + absolute positioned header + mainnav
			var wh = getWindowHeight();
			var newtop = (wh - nch)+"px"; */
			//setFooter();
		}
	}
	return false;
}
function setSiblingsByClassName(cur, className, newClassName) {
	while(cur.nextSibling) {
//		alert(cur.nextSibling.innerHTML)
		if(cur.nextSibling.className != className) {
		} else {
			cur.nextSibling.className = newClassName;
			break;
		}
		cur = cur.nextSibling;
	}
}
function trIsOpenerLink(obj) {
	if(obj) {
		return obj.getElementsByTagName("A").length > 0;
	} else return false;
}
function highliteSubmenueButton(evt) {
	obj = getButton(getGetTarget(evt));
	if(obj.className) {
		obj.className = obj.className.replace("normal", "over");
	}
}
function downliteSubmenuButton(evt) {
	obj = getButton(getGetTarget(evt));
	if(obj) {
		if(obj.className) {
			obj.className = obj.className.replace("over","normal");
		}
	}
}
function getButton(obj) {
	if(obj) {
		if(obj.nodeName == "LI") return obj;
		else {
			if(obj.parentNode.nodeName == "LI") return obj.parentNode;
			else return null;
		}
	}
}
// Timer-Funktionen
function setTimerFolgemenue() {
	clearTimeout(timerHauptmenu);
	timerHauptmenu = setTimeout("downliteHauptmenu()", 1000);
}

/* Mouseover-Funktionen */

// ?ndert die Klasse des feuernden Elements
// Klappmen? anzeigen
function highliteHauptmenu(evt) {
	clearTimeout(timerHauptmenu);
	obj = getGetTarget(evt);
	aTag = null;
	if (obj.nodeName == "LI") {
		aTag = obj.getElementsByTagName("A")[0];
	} else {
		if(obj.nodeName == "A") aTag = obj;
	}
	if(aTag) {
		aTag.className = obj.className.replace("normal", "over");
		ul = aTag.parentNode.getElementsByTagName("UL")[0];
		if(ul) {
			ul.className = ul.className.replace("normal", "over");
			downliteHauptmenuBut(aTag.parentNode);
		}
	}
	hideSelectionsInElement("inhaltRechts");
	hideSelectionsInElement("inhaltMitte");
}
function hideSelectionsInElement(id) {
	if(document.getElementById(id)) {
		sel = document.getElementById(id).getElementsByTagName("SELECT");
		if(sel) {
			for(i=0;i<sel.length;i++) {
				sel[i].style.display = "none";
			}
		}
	}
}

// Diese funktion setzt alle Hauptmenupunkte zur?ck
function downliteHauptmenu(notMe) {
	lis = document.getElementById("hauptmenu").getElementsByTagName("li");
	for(j=0;j<lis.length;j++) {
		if(lis[j].nodeName == "LI") {
			lis[j].className = lis[j].className.replace("over", "normal");
			if(lis[j].firstChild.className) lis[j].firstChild.className = lis[j].firstChild.className.replace("over", "normal");
			// Klappmen? ausblenden
			ul = lis[j].getElementsByTagName("UL");
			if(ul.length > 0) ul[0].className = ul[0].className.replace("over", "normal");
		}
	}
	sel = document.getElementsByTagName("SELECT");
	if(sel) {
		for(i=0;i<sel.length;i++) {
			sel[i].style.display = "";
		}
	}
}
// Diese Funktion setzt alle Hauptmenupunkte, bis auf "li" zur?ck
function downliteHauptmenuBut(li) {
	if(li.className.indexOf("ebene2") == "0") return;
	lis = document.getElementById("hauptmenu").getElementsByTagName("li");
	for(j=0;j<lis.length;j++) {
		if(lis[j].nodeName == "LI" && lis[j] != li) {
			if(lis[j].className.indexOf("over") > -1) lis[j].className = lis[j].className.replace("over", "normal");
			if(lis[j].firstChild.className) lis[j].firstChild.className = lis[j].firstChild.className.replace("over", "normal");
			// Klappmen? ausblenden
			ul = lis[j].getElementsByTagName("UL");
			if(ul.length > 0) ul[0].className = ul[0].className.replace("over", "normal")
		}
	}
}
// Setzt die Listenpunkte im Klappmen? auf normal
function downliteKlappmenu(li) {
	lis = li.parentNode.getElementsByTagName("LI");
	for(j=0;j<lis.length;j++) {
		if(lis[j] != li) {
			a = lis[j].getElementsByTagName("A")[0];
			if(a) a.className = a.className.replace("over", "normal");
		}
	}
}
// Untermenuepunkt highliten
function highliteUntermenu(evt) {
	clearTimeout(timerHauptmenu);
	obj = getGetTarget(evt);
	if (obj.nodeName == "LI") {
		a = obj.getElementsByTagName("A")[0];
		if(a) a.className = a.className.replace("normal", "over");
		downliteUntermenuBut(obj);
	}
}

// Damit man nicht genau die Links treffen muss:
function goToChildHref(evt) {
		//Get the firing Element
	li = getGetTarget(evt);
	location.href = li.childNodes[0].href;
}

// Funktionen f?r Eingabefelder
function reset(evt) {
	obj = getGetTarget(evt);
	if(obj.nodeName == "INPUT") {
		if(obj.value == 'Suchen...') {
			obj.value = '';
		}
	}
}

// Popus, externe Links
function openWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

// Verstecken / Anzeigen
function hideShowSiblingUl(el) {
	if(el.parentNode) {
		sibUl = el.parentNode.getElementsByTagName("UL")[0];
		if(sibUl) {
			if( ( sibUl.style.display == "none" || sibUl.style.display == "" ) ) { sibUl.style.display = "block"; sibUl.style.visibility = "visible"; }
			else { sibUl.style.display = "none"; sibUl.style.visibility = "hidden";  }
		}
	}
}
function hideShowSiblingDiv(el) {
	if(el.parentNode) {
		sibDiv = el.parentNode.getElementsByTagName("DIV")[0];
		if(sibDiv) {
			if(sibDiv.style.display == "none" || sibDiv.style.display == "") sibDiv.style.display = "block";
			else sibDiv.style.display = "none";
		}
	}
}

function openPopBilderdetails(welche) {
	window.open("/diashow.php?p="+welche,'Bildetails','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=260,height=250');
}

function openPopup(pic)
{
        window.open('/bild.php?pic=' + pic,'Bildansicht','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=10,height=10');
}

function add_favourite() {

	if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
		window.external.AddFavorite (location.href,"FLEX Power Tools");
	}
	else
	{
		var msg = "Um flex-tools.de zu den Favoriten hinzuzufuegen";
		if(navigator.appName == "Netscape") msg += " (STRG+D) klicken";
		alert(msg);
	}
}
function addToFavorites() {
	add_favourite(location.href,document.title);
}

function swapImgRestore() { //v3.0
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

function findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function swapImage() { //v3.0
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.pgW=innerWidth; document.pgH=innerHeight; onresize=reloadPage; }}
  else if (innerWidth!=document.pgW || innerHeight!=document.pgH) location.reload();
}
reloadPage(true);

function resizeContent() {
	if(document.getElementById("inhaltMitte").offsetHeight < 327) {
		document.getElementById("inhaltMitte").style.height = "327px";
	}
	if(document.getElementById("inhaltRechts")) {
		if(document.getElementById("inhaltMitte").offsetHeight < document.getElementById("inhaltRechts").offsetHeight) {
			document.getElementById("inhaltMitte").style.height = document.getElementById("inhaltRechts").offsetHeight+"px";
		}
	}
}
function getSortimenDiv(obj) {
	if(obj.nextSibling.tagName == "DIV") {
		div = obj.nextSibling;
	} else div = obj.nextSibling.nextSibling;

	if(div.tagName == "DIV") {
		return div;
	}
}
function showSortiment(obj) {
		getSortimenDiv(obj).className = "suchergebnisSortimentOpen";
}
function hideSortiment(obj) {
	getSortimenDiv(obj).className = "suchergebnisSortiment";
}

function checkSuchfeld(){
	if(document.forms.frmSearch.term.value == ""){
		alert("Bitte geben Sie den Suchbegriff ein");
		return false;
	} else {
		if(document.getElementById("stichwort").checked == true){
			welcheSuche = "/de/suchergebnisse.php";
		}
		if(document.getElementById("typen").checked == true){
			welcheSuche = "/de/suchergebnisseTypen.php";
		}
		return true;
	}
}

function checkRoutenplaner(){
	if(document.forms.wFormular.sstreet.value == "" || document.forms.wFormular.szip.value == "" || document.forms.wFormular.scity.value == "") {
		alert("Bitte geben Sie die komplette Start-Adresse ein");
		return false;
	}
 else {
		return true;
	}
}

/**
 * SWFObject v1.4.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
if(typeof deconcept == "undefined") var deconcept = new Object();
if(typeof deconcept.util == "undefined") deconcept.util = new Object();
if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object();
deconcept.SWFObject = function(swf, id, w, h, ver, c, useExpressInstall, quality, xiRedirectUrl, redirectUrl, detectKey){
	if (!document.getElementById) { return; }
	this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
	this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
	this.params = new Object();
	this.variables = new Object();
	this.attributes = new Array();
	if(swf) { this.setAttribute('swf', swf); }
	if(id) { this.setAttribute('id', id); }
	if(w) { this.setAttribute('width', w); }
	if(h) { this.setAttribute('height', h); }
	if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); }
	this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
	if(c) { this.addParam('bgcolor', c); }
	var q = quality ? quality : 'high';
	this.addParam('quality', q);
	this.setAttribute('useExpressInstall', useExpressInstall);
	this.setAttribute('doExpressInstall', false);
	var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
	this.setAttribute('xiRedirectUrl', xir);
	this.setAttribute('redirectUrl', '');
	if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); }
}
deconcept.SWFObject.prototype = {
	setAttribute: function(name, value){
		this.attributes[name] = value;
	},
	getAttribute: function(name){
		return this.attributes[name];
	},
	addParam: function(name, value){
		this.params[name] = value;
	},
	getParams: function(){
		return this.params;
	},
	addVariable: function(name, value){
		this.variables[name] = value;
	},
	getVariable: function(name){
		return this.variables[name];
	},
	getVariables: function(){
		return this.variables;
	},
	getVariablePairs: function(){
		var variablePairs = new Array();
		var key;
		var variables = this.getVariables();
		for(key in variables){
			variablePairs.push(key +"="+ variables[key]);
		}
		return variablePairs;
	},
	getSWFHTML: function() {
		var swfNode = "";
		if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
			if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "PlugIn"); }
			swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'"';
			swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
			var params = this.getParams();
			 for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
			var pairs = this.getVariablePairs().join("&");
			 if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
			swfNode += '/>';
		} else { // PC IE
			if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "ActiveX"); }
			swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">';
			swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
			var params = this.getParams();
			for(var key in params) {
			 swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
			}
			var pairs = this.getVariablePairs().join("&");
			if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
			swfNode += "</object>";
		}
		return swfNode;
	},
	write: function(elementId){
		if(this.getAttribute('useExpressInstall')) {
			// check to see if we need to do an express install
			var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]);
			if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
				this.setAttribute('doExpressInstall', true);
				this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
				document.title = document.title.slice(0, 47) + " - Flash Player Installation";
				this.addVariable("MMdoctitle", document.title);
			}
		}
		if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
			var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
			n.innerHTML = this.getSWFHTML();
			return true;
		}else{
			if(this.getAttribute('redirectUrl') != "") {
				document.location.replace(this.getAttribute('redirectUrl'));
			}
		}
		return false;
	}
}

/* ---- detection functions ---- */
deconcept.SWFObjectUtil.getPlayerVersion = function(){
	var PlayerVersion = new deconcept.PlayerVersion([0,0,0]);
	if(navigator.plugins && navigator.mimeTypes.length){
		var x = navigator.plugins["Shockwave Flash"];
		if(x && x.description) {
			PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
		}
	}else{
		// do minor version lookup in IE, but avoid fp6 crashing issues
		// see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
		try{
			var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		}catch(e){
			try {
				var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
				PlayerVersion = new deconcept.PlayerVersion([6,0,21]);
				axo.AllowScriptAccess = "always"; // throws if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
			} catch(e) {
				if (PlayerVersion.major == 6) {
					return PlayerVersion;
				}
			}
			try {
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			} catch(e) {}
		}
		if (axo != null) {
			PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
		}
	}
	return PlayerVersion;
}
deconcept.PlayerVersion = function(arrVersion){
	this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
	this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
	this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
}
deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
	if(this.major < fv.major) return false;
	if(this.major > fv.major) return true;
	if(this.minor < fv.minor) return false;
	if(this.minor > fv.minor) return true;
	if(this.rev < fv.rev) return false;
	return true;
}
/* ---- get value of query string param ---- */
deconcept.util = {
	getRequestParameter: function(param) {
		var q = document.location.search || document.location.hash;
		if(q) {
			var pairs = q.substring(1).split("&");
			for (var i=0; i < pairs.length; i++) {
				if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
					return pairs[i].substring((pairs[i].indexOf("=")+1));
				}
			}
		}
		return "";
	}
}
/* fix for video streaming bug */
deconcept.SWFObjectUtil.cleanupSWFs = function() {
	if (window.opera || !document.all) return;
	var objects = document.getElementsByTagName("OBJECT");
	for (var i=0; i < objects.length; i++) {
		objects[i].style.display = 'none';
		for (var x in objects[i]) {
			if (typeof objects[i][x] == 'function') {
				objects[i][x] = function(){};
			}
		}
	}
}
// fixes bug in fp9 see http://blog.deconcept.com/2006/07/28/swfobject-143-released/
deconcept.SWFObjectUtil.prepUnload = function() {
	__flash_unloadHandler = function(){};
	__flash_savedUnloadHandler = function(){};
	if (typeof window.onunload == 'function') {
		var oldUnload = window.onunload;
		window.onunload = function() {
			deconcept.SWFObjectUtil.cleanupSWFs();
			oldUnload();
		}
	} else {
		window.onunload = deconcept.SWFObjectUtil.cleanupSWFs;
	}
}
if (typeof window.onbeforeunload == 'function') {
	var oldBeforeUnload = window.onbeforeunload;
	window.onbeforeunload = function() {
		deconcept.SWFObjectUtil.prepUnload();
		oldBeforeUnload();
	}
} else {
	window.onbeforeunload = deconcept.SWFObjectUtil.prepUnload;
}
/* add Array.push if needed (ie5) */
if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }}

/* add some aliases for ease of use/backwards compatibility */
var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject; // for legacy support
var SWFObject = deconcept.SWFObject;
