    var lock=true;
    var e=false;
    var thiswin = window;
    var openpopup = thiswin.open;
	var intern;
	var schongedrueckt = 0;
	var curleft;
	var curtop;
	var pageObjectStatus = 'draussen';
	var base = (document.getElementsByTagName ('BASE')[0] && document.getElementsByTagName( 'BASE')[0].href) || location.href;
	var firstLogin = false;
	galleryImages = new Array();
    galleryTexts = new Array();

	function logintmp() {
		makeResponse();
		AJAXsubmit('','loginM','callback_CheckLogin');
	}

	function firstHelpClose() {
		if(window.XMLHttpRequest) {
			http = new XMLHttpRequest();
		} else if(window.ActiveXObject) {
			http = new ActiveXObject("Microsoft.XMLHTTP");
		}
		if(http != null) {
			http.open("GET", "./ajax_calls/close_firstHelp_ajax.php?wpID=" + wpID, true);
			http.onreadystatechange = function () {
				if (http.readyState == 4) {
					window.location.href = window.location.pathname;
				}
			}
		}
		http.send(null);		
	}
	
	function closeStarthelp() {		
		$("#starthelp").load("./ajax_calls/close_firstHelp_ajax.php?act=close&wpID=" + wpID, function(response, status, xhr) {
						  if (status == "error") {
						    var msg = "Es ist ein Fehler aufgetreten: ";
						    $("#error").html(msg + xhr.status + " " + xhr.statusText);
						  }
						});

		$('.starthelpIcon').css('display', 'none');

		document.getElementById("starthelp").style.display = "none";
		document.getElementById("EGschattenALL").style.display = "none";
	}
	
	function minimizeStarthelp() {
		$("#starthelp").load("./ajax_calls/close_firstHelp_ajax.php?act=minimize&wpID=" + wpID, function(response, status, xhr) {
						  if (status == "error") {
						    var msg = "Es ist ein Fehler aufgetreten: ";
						    $("#error").html(msg + xhr.status + " " + xhr.statusText);
						  }
						});
		
		$('.starthelpIcon').css('display', 'block');
		
		document.getElementById("starthelp").style.display = "none";
		document.getElementById("EGschattenALL").style.display = "none";		
	}

	function showStarthelp() {
		$("#starthelp").load("./ajax_calls/close_firstHelp_ajax.php?act=show&wpID=" + wpID, function(response, status, xhr) {
						  if (status == "error") {
						    var msg = "Es ist ein Fehler aufgetreten: ";
						    $("#error").html(msg + xhr.status + " " + xhr.statusText);
						  }
						});

		document.getElementById("starthelp").style.display = "block";
		document.getElementById("EGschattenALL").style.display = "block";
	}

	function aenderHiddenFeld(formebene,elementhidden,elementvalue,elementstandart) {
		var hiddenfeld = document.getElementById(formebene + elementhidden + "hidden");
		var bild = document.getElementById(formebene + "" + elementhidden);
	
		if(hiddenfeld.value == elementvalue) {
			hiddenfeld.value = elementstandart;
			var alteKlassen = bild.className.split(" ");
			bild.className = alteKlassen[0];
		} else {
			hiddenfeld.value = elementvalue;
			bild.className = bild.className + " active";
		}
	}

	function tollesaccordion(name) {
		$(name).accordion({ fillSpace: true });
	}

	function adminfaq(wo,was1,was2,was3,was4,id) {
		document.getElementById('Inhaltsbereich_' + wo + '_faq').innerHTML = "";
		document.getElementById('Inhaltsbereich_' + wo + '_faq').innerHTML = "<form method='POST' name='adminfaq'><input type='hidden' name='adminfaq' value='true' /><input type='hidden' name='was1' value='" + was1 + "' /><input type='hidden' name='was2' value='" + was2 + "' /><input type='hidden' name='was3' value='" + was3 + "' /><input type='hidden' name='was4' value='" + was4 + "' /><input type='hidden' name='modus' value='" + was1 + "' /><input type='hidden' name='where' value='" + wo + "' /><input type='text' size='5' name='faqid' value='" + id + "' /><input type='submit' value='speichern' /></form>";
	}

	function TasteGedrueckt (Ereignis) {

		if (!Ereignis)
			Ereignis = window.event;
		if (Ereignis.which) {
			Tastencode = Ereignis.which;
		} else if (Ereignis.keyCode) {
			Tastencode = Ereignis.keyCode;
		}

		if(schongedrueckt == 17 && Tastencode == 69) {
			if(pageObjectStatus == 'draussen') displayLogin();
			else if(pageObjectStatus == 'zwischen') reLogin();
			schongedrueckt = 0;
		}
		else if(schongedrueckt == 69 && Tastencode == 17) {
			if(pageObjectStatus == 'draussen') displayLogin();
			else if(pageObjectStatus == 'zwischen') reLogin();
			schongedrueckt = 0;
		} else if(schongedrueckt == 0) schongedrueckt = Tastencode;
		else schongedrueckt = 0;
	}
	
	document.onkeyup = TasteGedrueckt;

	function displayLogin() {
		if(firstLogin == false) {
			firstLogin = true;
			if(window.XMLHttpRequest) {
				http = new XMLHttpRequest();
			} else if(window.ActiveXObject) {
				http = new ActiveXObject("Microsoft.XMLHTTP");
			}
			if(http != null) {
				http.open("GET", "./ajax_calls/login.php", true);
				http.onreadystatechange = function () {
					if (http.readyState == 4) {
						var div=document.createElement("div");
						div.innerHTML=http.responseText;
						document.body.appendChild(div);
						 if (document.getElementById('EGschattenALL')) {
						 	document.getElementById('EGschattenALL').style.display = 'block';
						 	document.getElementById('EGlogin').style.display = 'block';
						 	self.focus();
						 	document.loginM.username.focus();
						 }
					}
				}
			}
			http.send(null);
		} else if (document.getElementById('EGschattenALL')) {
			document.getElementById('EGschattenALL').style.display = 'block';
			document.getElementById('EGlogin').style.display = 'block';
			self.focus();
			document.loginM.username.focus();
			
		}
	}
	
	function dontDisplayLogin() {
		document.getElementById('EGschattenALL').style.display = 'none';
		document.getElementById('EGlogin').style.display = 'none';
	}

	function doChallengeResponseVisitor() {
		if(typeof document.forms.loginVisitor.submit=="function") document.forms.loginVisitor.submit();
		else if(typeof document.forms.loginVisitor.submit.click=="function") document.forms.loginVisitor.submit.click();
	}
	
	//var donotsubmittest = false;
	function doChallengeResponse() {
		//donotsubmittest = true;
		if(typeof document.forms.loginM.submit=="function") document.forms.loginM.submit();
		else document.forms.loginM.submit.click();
	}
	
	function doChallengeResponseVisitorSubmit() {
		var str = document.forms.loginVisitor.username.value + ":" +
		      document.forms.loginVisitor.password.value + ":" +
		      document.forms.loginVisitor.webID.value + ":" +
		      document.forms.loginVisitor.challenge.value;
		
		document.forms.loginVisitor.response.value = MD5(str);
		document.forms.loginVisitor.password.value = "";
		return true;
	}
	
	function doChallengeResponseSubmit() {
		//makeResponse();
		//document.forms.loginM.password.value = "";
		return true;
	}

    function handleUnload() {

    }

	function getEditorContents(ename){
		if(FCKeditorAPI.GetInstance(ename)) return FCKeditorAPI.GetInstance(ename).GetData();
		else{
			var e = document.getElementById(ename);
			if(e) return e.value;
			else return false;
		}
	}

	function AJAXclose(wo,was,reload) {
		if(wo == "reload") {
			window.location.href = window.location.pathname + "?alleszu=true";
		} else {
			old = "?newmodus=" + was;
			if(reload == true) window.location.href = window.location.pathname + was + "&wo=" + wo;
			else ajaxcall(wo,window.location.pathname + "?newmodus=" + was);
		}
	}
	
	function linkTo(wo) {
		window.location.href = window.location.pathname + wo;
	}
	
	function reLogin() {
		window.location.href = window.location.pathname + "?status=drin";
	}

	function wordInputCheck(wo,was,dann) {
	    if(FCKeditorAPI.GetInstance('titleShort') != undefined) var titleshort = FCKeditorAPI.GetInstance('titleShort').GetHTML().replace(/<meta[^>^]*>/g, '');
	    else var titleshort = "";
	    if(FCKeditorAPI.GetInstance('content') != undefined) var content = FCKeditorAPI.GetInstance('content').GetHTML().replace(/<meta[^>^]*>/g, '');
	    else var content = "";
	    
	    if((was == "newsinput" || was == "newsletterinput") && document.getElementById("title").value == "") { alert("Bitte einen Titel eingeben."); return false; }
	    
	    if(FCKeditorAPI.GetInstance('titleShort') != undefined) FCKeditorAPI.GetInstance('titleShort').Value = titleshort;
	    if(FCKeditorAPI.GetInstance('content') != undefined) FCKeditorAPI.GetInstance('content').Value = content;
	    
		if( titleshort.indexOf('href="file:///C:') > -1 || content.indexOf('href="file:///C:') > -1) {
			alert("In Ihrem Text sind Reste aus Word oder OpenOffice enthalten, bitte entfernen Sie diese bevor der Text gespeichert werden kann.\nHierfür gibt es zwei Möglichkeiten:\n- Sie können den 'Einfügen aus Word' Button im Editor nutzen\n- Oder aber den Text aus Word zuerst in ein anderes Textbearbeitungsprogramm einfügen (z.B. Editor, Notepad etc.) zu finden über Ihr Startmenu");
		} else {
	  		AJAXsubmit(wo,was,dann);
		}
	}

	function menuwechsel(wohin,dontclose) {
		if(dontclose != true) x('exhaust');
		
		if(wohin == "admin") {
			document.getElementById("Menu_design").style.display = "none";
			document.getElementById("Menu_inhalt").style.display = "none";
			document.getElementById("Menu_admin").style.display = "block";
		} else if(wohin == "design") {
			document.getElementById("Menu_design").style.display = "block";
			document.getElementById("Menu_inhalt").style.display = "none";
			document.getElementById("Menu_admin").style.display = "none";
		} else {
			document.getElementById("Menu_design").style.display = "none";
			document.getElementById("Menu_inhalt").style.display = "block";
			document.getElementById("Menu_admin").style.display = "none";
		}
		
		if (window.XMLHttpRequest) {
			http = new XMLHttpRequest();
		}
		else
			if (window.ActiveXObject) {
				http = new ActiveXObject("Microsoft.XMLHTTP");
			}
			
		if(navigator.userAgent.indexOf('Firefox') != -1) { // FF4 macht es mit JQuery
			$.get("./ajax_calls/menu_ajax.php?wohin=" + wohin + "&menuwechsel=1&webID=" + webID, function(response, status, xhr) {
					  if (status == "error") {
					    var msg = "Es ist ein Fehler aufgetreten: ";
					    $("#error").html(msg + xhr.status + " " + xhr.statusText);
					  }
					});
		}
		else if(http != null) {
			http.open("GET", "./ajax_calls/menu_ajax.php?wohin=" + wohin + "&menuwechsel=1&webID=" + webID, false);
			http.send(null);
		}
	}

	function ajaxcall(wo,was,close) {
		
		if(wo == "reload") {
			window.location.href = window.location.href + "/" + was;
			return;
		}

		if( old != null && typeof(old) == "string" && old.slice(-25) == "newmodus=fckeditorToolbar") {
			var check = confirm("Soll diese Seite wirklich verlassen werden?\n\nAlle nicht gespeicherten Änderungen im Editor gehen dabei verloren.\n\nWählen Sie OK, um fortzufahren, oder Abbrechen, um auf der aktuellen Seite zu bleiben.");
			if(check == false) return;
			else {
				AJAXclose(wo,was,true);
			}
		}

		if(myopen == true && old == was) {
			if(wo == "EGextra") {
				curleftExtra = StopposEGextra.left;
				curtopExtra = StopposEGextra.top;
			} else if(wo == "exhaust") {
                document.getElementById('domMenu_drumherum').style.width = "108px";
			}
			if(wo == "exhaust" || close === true) {
				
				x(wo);
				
				//document.getElementById(wo).style.display = "none";
				//var Knoten = document.getElementById(wo).firstChild;
				//document.getElementById(wo).removeChild(Knoten);
				//myopen = false;
			}
		} else {
			if(wo == "exhaust") {
				document.getElementById('domMenu_drumherum').style.width = "361px";
				//document.getElementById('domMenu_drumherum').style.zIndex = document.getElementById('EGextra').style.zIndex + 1;
				if(close && close !== true) {
					menuwechsel(close,true);
				}
			} else if(wo == "EGextra") {
				document.getElementById('EGextra').style.width = "615px";
				document.getElementById('EGextra').style.height = "510px";
				//document.getElementById('EGextra').style.zIndex = document.getElementById('domMenu_drumherum').style.zIndex + 1;
			}
			if(window.XMLHttpRequest) {
				http = new XMLHttpRequest();
			} else if(window.ActiveXObject) {
				http = new ActiveXObject("Microsoft.XMLHTTP");
			}

			if(navigator.userAgent.indexOf('Firefox') != -1) { // FF macht es mit JQuery
				$("#"+wo).load("./ajax_calls/modus_ajax.php" + was + "&wo=" + wo + "&newwpID=" + wpID, function(response, status, xhr) {
						  if (status == "error") {
						    var msg = "Es ist ein Fehler aufgetreten: ";
						    $("#error").html(msg + xhr.status + " " + xhr.statusText);
						  } else if(response == "Neu einloggen") {
						  		window.location.href = window.location.pathname + "?logineinblendensofort=true";
						  }
						});

				document.getElementById(wo).style.display = "block";
			}
			else if(http != null) {
				http.open("GET", "./ajax_calls/modus_ajax.php" + was + "&wo=" + wo + "&newwpID=" + wpID, true);
				http.onreadystatechange = function () {
					if (http.readyState == 4) {
					
						//old school
						//document.getElementById(wo).innerHTML = "";
						//var div=document.createElement("div");
						//div.innerHTML=http.responseText;
						//document.getElementById(wo).appendChild(div);	
						
						//new school					
						while ( document.getElementById(wo).firstChild ) {
							var contentNode = document.getElementById(wo);
							document.getElementById(wo).removeChild(contentNode.firstChild);
						}
						var divElement = document.createElement('div');
						divElement.innerHTML = http.responseText;
						var docFrag = document.createDocumentFragment();
						while (divElement.firstChild) docFrag.appendChild(divElement.firstChild);
						document.getElementById(wo).appendChild(docFrag);

						if (navigator.userAgent.indexOf('Safari') != -1) {
							var st = document.getElementById(wo).getElementsByTagName('script');
  							for(var i=0;i<st.length; i++) { 
 								var strExec = st[i].innerHTML;

 								try { 
 									eval(strExec); 
 								} catch(e) { 
 									alert(e);
 								}
 							}
 						}
						
						
						//anzeigen
						document.getElementById(wo).style.display = "block";
					}
				};
				http.send(null);
			}
			myopen = true;
			old = was;
		}
	}

	function x(was) {

		if(was == "exhaust") {
			myopen = false;
			document.getElementById('domMenu_drumherum').style.width = "108px";
		} else if(was == "EGextra") {
			myopen = false;
			curleftExtra = StopposEGextra.left;
			curtopExtra = StopposEGextra.top;
		}
		document.getElementById(was).style.display = "none";

		if (window.XMLHttpRequest) {
			httpx = new XMLHttpRequest();
		}
		else
			if (window.ActiveXObject) {
				httpx = new ActiveXObject("Microsoft.XMLHTTP");
			}
		if (httpx != null) {
			httpx.open("GET", "./ajax_calls/menu_ajax.php?was=" + was + "&close=1&webID=" + webID, false);
			httpx.send(null);
		}		
	}
	
	function openFloater(was) {
		
		if (was == "exhaust") {
			if (myopen == true) {
				x('exhaust');
				return;
			}
			myopen = true;
			document.getElementById('domMenu_drumherum').style.width = "361px";
		} else if(was == "EGextra") {
			myopen = true;
		}
		document.getElementById(was).style.display = "block";
		
	}
	
	function move(was) {
		//if(dd.elements[was].myIsDraggable == false) {
    	//	dd.elements[was].myIsDraggable = true;
		//	dd.elements[was].setDraggable(true);
		//} else {
    	//	dd.elements[was].myIsDraggable = false;
		//	dd.elements[was].setDraggable(false);
		//}
	}

	function getController() {
		return "domMenu_drumherum";
	}

    function deactivateUnlock() {
        lock = false;
    }

	function IsDigit(code){
		return ((code >= 48) && (code <= 57));
	}
	
	function winopen(src, width, height) {
		var pop = window.open(src,'pop','width='+width+',height='+height+',scrollbars=yes,resizable=yes,toolbar=no,status=no,left=0,top=0');
		pop.focus();
		return false;
	}

	function deleteSession() {
	  deactivateUnlock();
	  var wname = "";
	  var woptions = "width=100,height=100";
	  var url = pURL+'/popups/logoutSession.php?&MttgSession='+MttgSession;
  	  openpopup(url,wname,woptions);
	  return true;
	}

	function check(elementID,form,maxNumber) {
		var formID = document.forms[form];
		var count = 0;
		
		for (i=0; i<formID.length; i++) {
			if (formID.elements[i].type=="checkbox" && formID.elements[i].checked==true && count<=maxNumber) {
				count++;
			}
		}
		
		if (count>maxNumber) {
			elementID.checked = false;
			alert ("Es dürfen nur maximal "+maxNumber+" Checkboxen ausgwählt werden!");
		}
	}
	
	function AJAXsubmit(wo,was,aufrufen,postTheAction) {
		var poststr = false;
		for (var i = 0; i < document.forms[was].length; ++i) {
			if ((document.forms[was].elements[i].type != "checkbox" && document.forms[was].elements[i].type != "radio") || ((document.forms[was].elements[i].type == "checkbox" && document.forms[was].elements[i].checked == true) || (document.forms[was].elements[i].type == "radio" && document.forms[was].elements[i].checked == true)) ) {
				if (poststr == false) {
					if (document.forms[was].elements[i].id == document.forms[was].elements[i].name && (document.forms[was].elements[i].name == "templateStr" || document.forms[was].elements[i].name.substr(0,8) == "var_fck_" || document.forms[was].elements[i].name == "var_info" || document.forms[was].elements[i].name == "template" || document.forms[was].elements[i].name == "titleShort" || document.forms[was].elements[i].name == "content" || document.forms[was].elements[i].name == "htmltextarea")) {
						var oEditor = FCKeditorAPI.GetInstance(document.forms[was].elements[i].name);
						poststr = encodeURIComponent(document.forms[was].elements[i].name) + "=" + encodeURIComponent(oEditor.GetHTML());
					}
					else
						poststr = encodeURIComponent(document.forms[was].elements[i].name) + "=" + encodeURIComponent(document.forms[was].elements[i].value);
				}
				else {
					if (document.forms[was].elements[i].id == document.forms[was].elements[i].name && (document.forms[was].elements[i].name == "templateStr" || document.forms[was].elements[i].name.substr(0,8) == "var_fck_" || document.forms[was].elements[i].name == "template" || document.forms[was].elements[i].name == "titleShort" || document.forms[was].elements[i].name == "content" || document.forms[was].elements[i].name == "htmltextarea")) {
						var oEditor = FCKeditorAPI.GetInstance(document.forms[was].elements[i].name);
						poststr = poststr + "&" + encodeURIComponent(document.forms[was].elements[i].name) + "=" + encodeURIComponent(oEditor.GetHTML());
					}
					else
						poststr = poststr + "&" + encodeURIComponent(document.forms[was].elements[i].name) + "=" + encodeURIComponent(document.forms[was].elements[i].value);
				}
			}
		}

		makePOSTRequest(poststr,wo,aufrufen,postTheAction, was);
	}
	
	function makePOSTRequest(parameters, wo, aufrufen, postTheAction, was) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }

      if(postTheAction == true) http_request.open('POST', document.forms[was].action, true);
      else 						http_request.open('POST', './ajax_calls/post_ajax.php', true);
      http_request.onreadystatechange = function() {
	      if (http_request.readyState == 4) {
	         if (http_request.status == 200) {
    			if(aufrufen) {
					myopen = false;
					if(aufrufen == "reload") window.location.href = window.location.pathname + "?alleszu=true" + http_request.responseText;
					else if(aufrufen.substr(0,6) == "reload") {
						if(aufrufen.substr(6) == "") {
							window.location.href = window.location.pathname + "?true=true" + http_request.responseText;
						}
						else if (aufrufen.substr(6,1) != "?") {
							window.location.href = window.location.pathname + "?wo=" + aufrufen.substr(6) + http_request.responseText;
						}
						else {
							window.location.href = window.location.pathname + aufrufen.substr(6) + http_request.responseText;
						}
					}
					else if(aufrufen.substr(0,8) == "callback") {
						var t = encodeURIComponent(http_request.responseText);
						if(t.length > 1000) t = true;
						eval(aufrufen.substr(9) + "('" + t + "')");
				 	} else ajaxcall(wo,aufrufen + http_request.responseText);
	            } else {
					var res = http_request.responseText;
					res = decodeURIComponent(res.substr(9));

					var replace = " ";
					while(res.lastIndexOf("+") != -1) {
					   res = res.replace("+", " ");
					}
	            	document.getElementById("msg").innerHTML = res;
	            	//document.getElementById("msg").style.display = "block";
	            }
	         }
	      }	  	
	  };
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      //http_request.setRequestHeader("Content-length", parameters.length);
      //http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

	function makeResponse() {
		var str = document.forms.loginM.username.value + ":" +
		  document.forms.loginM.password.value + ":" +
		  document.forms.loginM.webID.value + ":" +
		  document.forms.loginM.challenge.value;

		document.forms.loginM.response.value = MD5(str);
		
		document.forms.loginM.password.value = "";
	}

   	function CheckLogin(res) {
		if(res == false) {
			$('#EGlogin').effect("shake", { times:3, distance:50 }, 75);
		} else {
			document.forms.loginM.submit();
		}
   	}
   
	function modauswahl() {
		if(document.getElementById("module").style.display == "block") {
			document.getElementById("module").style.display = "none";
			document.getElementById("modauswahl").style.display = "block";
		} else {
			document.getElementById("module").style.display = "block";
			document.getElementById("modauswahl").style.display = "none";			
		}
	}

    function mttg_printme(searchstring) {
        if( !searchstring ) searchstring = location.search;
        sessionstring = 'MttgSession='+MttgSession
        var url = pURL+'/popups/printview.php';
        if( searchstring ) {
            url += searchstring;
            sessionstring = "&"+sessionstring;
        } else {
            sessionstring = "?"+sessionstring;
        }
        if( url.search(/MttgSession=/) == -1 ) url += sessionstring;
        var wname = 'printview';
        var woptions = "dependent=yes,height=400,width=600,hotkeys=false,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no";
        openpopup(url,wname,woptions);
    }

    function mttg_checkForm(formElement, felderzumpruefen, alerttext) {
        if( !felderzumpruefen ) return true;

		var allesgut = true;
		var teilgut = false;

		 for(var pflichtfeld in felderzumpruefen) { //Alle übergebenen Felder anschauen
		 	pflichtfeld = felderzumpruefen[pflichtfeld];
		 	if(typeof(pflichtfeld) == "object") { //Wenn es ein Array ist gibt es wohl ein entweder oder
		 		teilgut = false;
				for (var teilpflicht in pflichtfeld) {
					teilpflicht = pflichtfeld[teilpflicht];
					if(fieldfilled(formElement.elements[teilpflicht]) == true) teilgut = true;
				}
				if(teilgut == false) allesgut = false;
			} else { //ansonsten ist es ein "richtiges" pflichtfeld
				if(fieldfilled(formElement.elements[pflichtfeld]) == false) allesgut = false;
			}
		 }

		 if(allesgut == true) return true;
		 else {
		 	alert(alerttext);
			return false;
		}
    }
	
	function fieldfilled(field) {

		var einfeldchecked;

		if(typeof(field) == "undefined") return true; // wenn es das feld nicht gibt

		if(typeof(field.type) != "undefined") {

			switch(field.type) {
				case "checkbox":
				  	if(!field.checked) return false;
				  	break;
				case "select-one":
				  	einfeldchecked = false;
					for (var i = 0; i < field.options.length; i++) 
						if (field.options[i].selected && field.options[i].value != "") einfeldchecked = true;
					if(!einfeldchecked) return false;
					else return true;
				  	break;
				case "select-multiple":
				  	einfeldchecked = false;
					for(var i=0;i<field.options.length;i++)	if(field.options[i].selected && field.options[i].value != "") einfeldchecked = true;	
					if(!einfeldchecked) return false;
					else return true;
				  	break;
				default:
				  	if(field.value == "") return false;
				  	else return true;
					break;
			}
		} else {
			einfeldchecked = false;
			for(var i=0;i<field.length;i++)	if(field[i].checked) einfeldchecked = true;	
			if(!einfeldchecked) return false;
			else return true;	
		}
	}

	function pop(src,width,height) {
		var pop = window.open(src,'pop','width='+width+',height=<'+$height+',scrollbars=yes,resizable=yes,toolbar=no,status=no,left=0,top=0');
		pop.focus();
		return false;
	}
	function changeImage(dir,index) { 
	  var img = document.getElementById(dir);
	  if( img ) img.src = galleryImages[dir][index].src;

	  var text = document.getElementById(dir+'_description');
	  if( text ) {
		while( text.hasChildNodes() ) text.removeChild(text.firstChild);
		text.innerHTML = galleryTexts[dir][index];
	  }

	  var imgs = document.getElementsByTagName('img');
	  for( var i = 0; i < imgs.length; i++ ) {
		var idx = index;
		if( !imgs[i].id || imgs[i].id.substr(0,dir.length+1) != dir+'_' ) continue;
		var direction = imgs[i].id.substr(dir.length+1,4);
		var n = 1;

		if( imgs[i].length > dir.length+5 ) 
		  n = parseInt(imgs[i].id.substring(dir.length+5,imgs[i].length));
		
		switch(direction) {
		  case 'next': idx += n; break;
		  case 'prev': idx -= n; break;
		}
		while ( idx < 0 ) idx += galleryImages[dir].length;
		while ( idx >= galleryImages[dir].length ) idx -= galleryImages[dir].length;
		imgs[i].src = galleryImages[dir][idx].src;
	  }
	}
	
	function putInCart(was,go) {
		
		var field = "";
		var getstring = "";
		var variantenanzahl = document.getElementById("varianten_anzahl_" + was).value;
		var anzahl = document.getElementById("anzahl_" + was).value;
		var warenkorbwpID = document.getElementById("warenkorbwpID").value;

		for(var i = 1; i <= variantenanzahl; i++) {
			var field = document.getElementById("varianten_" + was + "_" + i);
			switch(field.type) {
				case "checkbox":
				  	if(field.checked) getstring = getstring + "&" + field.name + "=1";
				  	break;
				case "radio":
					for(var j=0;j<field.length;j++)	if(field[j].checked) getstring = getstring + "&" + field[j].name + "=" + field[j].value;
				  	break;
				case "select-one":
					for(var j=0;j<field.options.length;j++) if(field.options[j].selected) getstring = getstring + "&" + field.name + "=" + field.options[j].value;
				  	break;
				case "select":
					for(var j=0;j<field.options.length;j++)	if(field.options[j].selected) getstring = getstring + "&" + field.name + "=" + field.options[j].value;
				  	break;
				default:
				  	getstring = getstring + "&" + field.name + "=" + field.value;
					break;
			}
		}
		
		if(window.XMLHttpRequest) {
			http = new XMLHttpRequest();
		} else if(window.ActiveXObject) {
			http = new ActiveXObject("Microsoft.XMLHTTP");
		}
		if(http != null) {
			http.open("GET", "./ajax_calls/shop/additem.php?katalogID=" + was + "&anzahl=" + anzahl + "&webID=" + webID + "&warenkorbwpID=" + warenkorbwpID + getstring, true);
			http.onreadystatechange = function () {
				if (http.readyState == 4) {
					if(go > 0) window.location.href="?newwpID=" + go + "&MttgSession=" + MttgSession + "&webID=" + webID;
					else document.getElementById("Warenkorb").innerHTML = http.responseText;
				}
			};
			http.send(null);
		}
	}
	
	function deleteFromCart(was,go,varname,varvalue,gross) {

		var warenkorbwpID =$("#warenkorbwpID").val();

		$.ajax({
		     async: false,
		     type: 'GET',
		     url: "./ajax_calls/shop/deleteitem.php?deleteid=" + was + "&varname=" + varname + "&varvalue=" + varvalue + "&webID=" + webID + "&warenkorbwpID=" + warenkorbwpID + "&gross=" + gross,
		     success: function(data) {
			    if(go) window.location.href = "./?newwpID=" + go;
			    else $('#Warenkorb').html(data);
			  }
		});
	}
		
	function showText(id) {
		 var elm = document.getElementById(id);
		 if( elm ) elm.style.display = 'block';
	}
	
	function hideText(id) {
		 var elm = document.getElementById(id);
		 if( elm ) elm.style.display = 'none';
	}
	
	function gibtssoviel(bestellt,vorhanden,id) {
		if(vorhanden === false || bestellt <= vorhanden) return true;
		else {
			document.getElementById('anzahl_' + id).value = vorhanden;
			alert("Soviel haben wir leider nicht vorrätig, die Menge wird auf die verfügbare Menge reduziert.");
			return false;
		}
	}
	
	function introAlert() {
		if (document.intropagePopupForm.showIntro.checked == true)
			alert("Vergessen Sie nicht, auf der Vorschaltseite einen Link auf Ihre Startseite zu setzen!!\nAnderenfalls machen Sie Ihr Web für sich und andere unzugänglich!");
	}
	
/* Katalog */
function mttg_makeChanger(index) {
	var i = index;
	return function() { mttg_changeVariationName(i,this.value) };
}

function mttg_showVariations() {
	var into = document.getElementById('variationen');
	while(into.hasChildNodes()) {
		into.removeChild(into.firstChild);
	}
	if( !into ) return;
	for( var i = 0; currentVariations[i]; i++ ) {
		var nameinput = document.createElement('input');
		nameinput.name = 'variationName_'+i;
		nameinput.value = currentVariations[i][0];
		nameinput.onchange = mttg_makeChanger(i);
		into.appendChild(nameinput);
		
		var values = document.createElement('ul');
		for( var j = 1; currentVariations[i][j]; j++ ) {
			nameinput = document.createElement('input');
			nameinput.type = 'hidden';
			nameinput.name = 'variationValue_'+i+'_'+j;
			nameinput.value = currentVariations[i][j][1];
			into.appendChild(nameinput);
			if(currentVariations[i][j][0]) {
				nameinput = document.createElement('input');
				nameinput.type = 'hidden';
				nameinput.name = 'variationID_'+i+'_'+j;
				nameinput.value = currentVariations[i][j][0];
				into.appendChild(nameinput);
			}
			var entry = document.createElement('li');
			var valuename = document.createTextNode(currentVariations[i][j][1]+' ');
			var linktext = document.createTextNode('löschen'); 
			var link = document.createElement('a');
			link.href = 'javascript:mttg_delVariation(\''+currentVariations[i][0]+'\',\''+currentVariations[i][j][1]+'\')';
			link.appendChild(linktext);
			entry.appendChild(valuename);
			entry.appendChild(link);
			values.appendChild(entry);
		}
		into.appendChild(values);
		
		nameinput = document.createElement('input');
		nameinput.name = 'variationNewValue_'+i;
		nameinput.id = 'variationNewValue_'+i;
		nameinput.value = 'neuer Wert';
		into.appendChild(nameinput);
		
		var linktext = document.createTextNode('Wert hinzufügen'); 
		var link = document.createElement('a');
		link.href = 'javascript:mttg_addVariation(\''+currentVariations[i][0]+'\',document.getElementById(\'variationNewValue_'+i+'\').value)';
		link.appendChild(linktext);
		into.appendChild(link);
		
		linktext = document.createTextNode('Variation löschen'); 
		link = document.createElement('a');
		link.href = 'javascript:mttg_delVariation(\''+currentVariations[i][0]+'\',false)';
		link.appendChild(linktext);
		into.appendChild(link);
		
		into.appendChild(document.createElement('hr'));
	}
}

function mttg_addVariation(name,value) {
	if( !currentVariations ) currentVariations = new Array();
	for( var i = 0; currentVariations[i]; i++ ) {
		if( currentVariations[i][0] == name ) break;
	}
	if( !currentVariations[i] || currentVariations[i][0] != name ) {
		currentVariations[i] = new Array();
		currentVariations[i][0] = name;
	}
	if( value ) {
		var doAddValue = true;
		for( var j = 1; currentVariations[i][j]; j++ ) 
			if( currentVariations[i][j][1] == value ) 
				doAddValue = false;
		if( doAddValue ) currentVariations[i][currentVariations[i].length] = new Array(false,value);
	}
	mttg_showVariations();
}

function mttg_changeVariationName(index,newname) {
	if( !currentVariations ) currentVariations = new Array();
	if( !currentVariations[index] ) currentVariations[index] = new Array();
	currentVariations[index][0] = newname;
	mttg_showVariations();
}

function mttg_delVariation(name,value) {
	if( !currentVariations ) return;
	for( var i = 0; currentVariations[i]; i++ ) {
		if( currentVariations[i][0] == name ) break;
	}
	if( !currentVariations[i] || currentVariations[i][0] != name ) return;
	if( value ) {
		for( var j = 1; currentVariations[i][j]; j++ ){
			if( currentVariations[i][j][1] == value ) {
				currentVariations[i] = currentVariations[i].slice(0,j).concat(currentVariations[i].slice(j+1,currentVariations[i].length));
				break;
			}
		}
	} else {
		currentVariations = currentVariations.slice(0,i).concat(currentVariations.slice(i+1,currentVariations.length));
	}
	mttg_showVariations();
}
/* Katalog Ende */

/* Gallerie */
	function showTEXTFELDER() {
		document.getElementById("pe").style.display = "block";
		document.getElementById("r").style.display = "none";

	}

	function hideTEXTFELDER() {
		document.getElementById("r").style.display = "block";
		document.getElementById("pe").style.display = "none";
	}
/* Gallerie Ende */

$(document).ready(function(){

  // Reset Font Size
  var originalFontSize = $('html').css('font-size');
  $(".resetFont").click(function(){
  	$('html').css('font-size', originalFontSize);
  });

  // Increase Font Size
  $(".increaseFont").click(function(){
  	var currentFontSize = $('html').css('font-size');
 	var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum*1.2;
	$('html').css('font-size', newFontSize);

	return false;
  });

  // Decrease Font Size
  $(".decreaseFont").click(function(){
  	var currentFontSize = $('html').css('font-size');
 	var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum*0.8;
	$('html').css('font-size', newFontSize);

	return false;
  });

  // smooth scrolling
  $('a[href*=#]').click(function() {
	 if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
	 && location.hostname == this.hostname) {
	   var $target = $(this.hash);
	   $target = $target.length && $target
	   || $('[name=' + this.hash.slice(1) +']');
	   if ($target.length) {
	  var targetOffset = $target.offset().top;
	  $('html,body')
	  .animate({scrollTop: targetOffset}, 900);
	    return false;
	   }
	  }
  });

});


