
	/**
	  * Module: core.js Radaddel.de (c) 2007
	  *
	  * created by: Martin Mueller <martin.mueller [at] radaddel.de>
	  *
	  * virtual browserinteraction by Martin Mueller (c) 2007
	  *
	  */




	var use = "ul";
	var target = 'content';
	var bigSize = false;
	var prodCount = 0;
	var tabuse = 1;
	var actualContent = 0;
	var actualItem = false;
	var http_request = false;
	var visibleTab = 0;
	var tabs = new Array();
	var getbreak = 5;
	var availableDivs = new Array('content0');
	var dontshow = false;
	var busy = false;
	var SessionId = 0;
	var screenUpdate = true;
	var delayAction = false;
	var noAJAX = false;
	var browserAction = false;
	var firstLoad = true;
	var clicked = true;
	var loadingPos = 0;
	var loadingAni = false;
	var loadingCategorie = null;
	var loadingText = null;
	var blendingTimer = null;
	var blendingAlpha = 0;
	var scrollUp = true;
	
	var wkShown = false;
	var wkRunning = false;

	/*if(window.opera) {
		var noJs = true;
	}*/
	noJs = false;

			function blendIn(id) {
				if (blendingTimer != null) {
					window.clearTimeout(blendingTimer);
				}
				document.getElementById(id).style.display = "inline";
				$("#" + id).css("opacity" , 1);				
			}

			function blendOut(id) {
				blendingTimer = window.setInterval("blendOutStep('"+id+"')",100);
				blendingAlpha = 100;
				wkRunning = true;
			}
			
			function blendOutStep(id) {
				blendingAlpha -= 10;
				$("#" + id).css({
					"opacity": blendingAlpha/100					
				}); 
		//		alert(document.getElementById(id).getAttribute("style"));
				if (blendingAlpha <= 0) {
					document.getElementById(id).style.display = "none";
					window.clearTimeout(blendingTimer);
					$("#" + id).css({
						"opacity" : 0
					});
					wkShown = false;
					wkRunning = false;
				}
			}

			function refreshPage() {
				//alert("refresh : " + firstLoad);
				if (!firstLoad) location.reload();
				else firstLoad = false;
			}

			function alertInhalt() {

				if (http_request.readyState == 4) {
					if (http_request.status == 200) {
							document.getElementById('content').innerHTML = http_request.responseText;
					} else {
						alert('Bei dem Request ist ein Problem aufgetreten.');
					}
				}
			}

			function hideMenu(ln) {
				for (l = 0; l < document.getElementsByTagName(use).length; ++l)
				{
				objItem = document.getElementsByTagName(use)[l];
					if (objItem.getAttribute('id') == 'cat'+ln)
						{
							   objItem.style.display = 'none';
						}
				}
				return false;
			}


			function loadOnlyProducts(ln,sess,item,anz) {
				if (!browserAction) {
					callBrowserAction("loadOnlyProducts(\""+ln+"\",\""+sess+"\",\""+item+"\",\""+anz+"\")");
					return false;
				}

						if (anz > 0) {
							loadProducts(ln,sess);
							actualItem = item.replace(' ','&nbsp;');
						}
						return noJs;
			}

			function readSession(n) {
				 a = document.cookie;
				 res = '';
				 while(a != '')
				 {
					  while(a.substr(0,1) == ' '){
						  a = a.substr(1,a.length);
					}
					cookiename = a.substring(0,a.indexOf('='));
					if(a.indexOf(';') != -1){
							cookiewert = a.substring(a.indexOf('=')+1,a.indexOf(';'));
					}
					else {
						cookiewert = a.substr(a.indexOf('=')+1,a.length);
					}
					if (n == cookiename) {
						res = cookiewert;
					}
					i = a.indexOf(';')+1;
					if(i == 0) {
						i = a.length
					}
					a = a.substring(i,a.length);
				}

				return res;

			}


			function openNavi(ln) {
				loadProducts(ln);


				var parent = document.getElementById('cat'+ln);
				while(parent) {
					if (parent.tagName && parent.tagName.toLowerCase() == use) {
						if (parent.id == "cat0")
							break;

						parent.style.display = 'inline';
					}
					parent = parent.parentNode;
				}

				return false;

			}

			function updateMenu(ln,anz,sess,item) {

						document.cookie = "SessionId="+sess;
						var loadTheProduct = true;
						
						for (l = 0; l < document.getElementsByTagName(use).length; ++l)
						{
						objItem = document.getElementsByTagName(use)[l];

							if (objItem.getAttribute('id') == 'cat'+ln)
								{
									if (objItem.style.display == 'none') {
										objItem.style.display = 'inline';
										if (document.getElementById('pic'+ln)) {
											document.getElementById('pic'+ln).setAttribute('src','images/minus_end2.gif');
										}
									}
									else {
										loadTheProduct = false;
										objItem.style.display = 'none';
										objItem.style.padding = 0;
										if (document.getElementById('pic'+ln)) {
											document.getElementById('pic'+ln).setAttribute('src','images/plus_end2.gif');
										}
									}
								}
						}
						if (anz > 0 && loadTheProduct) {
							loadProducts(ln,sess);
							actualItem = item.replace(' ','&nbsp;');
						}

						return false;

			}

			function showMenu(ln) {
						for (l = 0; l < document.getElementsByTagName(use).length; ++l)
						{
						objItem = document.getElementsByTagName(use)[l];

						if (objItem.getAttribute('id') == 'cat'+ln)
							{
								   objItem.style.display = 'inline';
							}
						}
						return false;
			}

			function showWait(t) {
				obj = document.getElementById('wait');
				if (t) {
					obj.style.display = 'inline';
					startLoadingAnimation();
					if (loadingCategorie != null) 
						document.getElementById("waitstringa").innerHTML = loadingCategorie;
					else 
						document.getElementById("waitstringa").innerHTML = "Informationen werden geladen";
					if (loadingText != null) 
						document.getElementById("waitstringb").innerHTML = loadingText;
					else 
						document.getElementById("waitstringb").innerHTML = "Bitte warten...";
						
					loadingCategorie = loadingText = null;
					
				}
				else {
					obj.style.display = 'none';
					stopLoadingAnimation();
				}

				return true;
			}
			
			function startLoadingAnimation() {
				loadingAni = window.setTimeout("keepLoadingAnimation()", 100);
			}
			
			function keepLoadingAnimation() {
				var x = document.getElementById("loadingbar");
				if (loadingPos > 150)
					loadingPos = 0;
					
					loadingPos += 10;
				x.style.backgroundPosition  = loadingPos + 'px 0px';;
				loadingAni = window.setTimeout("keepLoadingAnimation()", 100);
				
			}
			
			function stopLoadingAnimation() {
				window.clearTimeout(loadingAni);
			}

			function makeBigScreen(t) {

				if (onlyBigScreen) return false;

				var local = location.href.search(/guestbook.+/);
				if (local > 0) return false;


				var screenwidth = document.body.offsetWidth; //screen.availWidth;
				if (screenwidth > 1010) {
					screenwidth = 1010;
				}
				if (screenUpdate == true) {
					if (t || onlyBigScreen) {
						obj = document.getElementById('rightdata');
						obj.style.display = 'none';
						document.getElementById('leftdata').style.display = 'block';
						document.getElementById('content').style.width = screenwidth - 220;
					}
					else {
						obj = document.getElementById('rightdata');
						obj.style.display = 'block';
						document.getElementById('leftdata').style.display = 'block';
						document.getElementById('content').style.width = screenwidth - 420;
					}
				}
				else {
					screenUpdate = false;
				}
			}

			function loadAction(sess) {
				if (!browserAction) {
					callBrowserAction("loadAction(\""+sess+"\")");
					return false;
				}


			SessionId = sess;
				actualContent = parseInt(actualContent) + 1;
				target='content'+actualContent;
				makeRequest("xgetAction.php","SessionId="+sess);
				bigSize=true;
				return noJs;
			}

			function loadExternalData(data,sess) {
				if (!browserAction) {
					callBrowserAction("loadExternalData(\""+data+"\",\""+sess+"\")");
					return false;
				}
				browserAction = false;

				SessionId = sess;
				actualContent = parseInt(actualContent) + 1;
				target='content'+actualContent;
				makeRequest("xgetExternalData.php","data="+data+"&SessionId="+sess);
				bigSize=false;
				return noJs;
			}

			function loadExtCfgData(data, name) {
 				if (!browserAction) {
					callBrowserAction("loadExtCfgData(\""+data+"\",\""+name+"\")");
				//	alert("calling virtual browser!");
					return false;
				}
				browserAction = false;
				actualContent = parseInt(actualContent) + 1;
				target='content'+actualContent;
				actualItem = name;
				makeRequest("xloadCfgData.php","data="+data);
				bigSize=false;
				return noJs;
			}

			function loadGewinnspiel() {
				actualContent = parseInt(actualContent) + 1;
				target='content'+actualContent;
				makeRequest("gewinnspiel.php","");
				bigSize=false;
				return noJs;
			}
			function loadShippingCosts(sess) {
				if (!browserAction) {
					callBrowserAction("loadShippingCosts(\""+sess+"\")");
					return false;
				}
				browserAction = false;
				SessionId = sess;
				actualContent = parseInt(actualContent) + 1;
				target='content'+actualContent;
				loadingCategorie = "lade Versandkosten";
				loadingText = "einen Moment bitte!";
				makeRequest("xgetShippingCosts.php","SessionId="+sess);
				bigSize=false;
				return noJs;
			}

			function loadNewslist(sess, lower) {

				if (!browserAction) {
					callBrowserAction("loadNewslist(\""+sess+"\",\""+lower+"\")");
					return false;
				}
				browserAction = false;

				SessionId = sess;

				if (lower > 0)
					var tmp = (parseInt(lower) / 20) + 1;
				else
					tmp = 1;

				actualContent = parseInt(actualContent) + 1;
				target='content'+actualContent;
				actualItem = "Neue Produkte";
				if (tmp != 1)
					actualItem = actualItem + " ("+tmp+")";
				
				loadingCategorie = "lade die neusten <br>Produkte im Shop";
				loadingText = "einen Moment bitte!"; 
				makeRequest("xgetNewProducts.php","SessionId="+sess+"&l="+lower);
				bigSize=true;
				return noJs;
			}

			function loadJubi() {
				actualContent = parseInt(actualContent) + 1;
				target='content'+actualContent;
				makeRequest("xgetJubi.php","");
				bigSize=false;
				return noJs;
			}
			function loadAGB() {
				if (!browserAction) {
					callBrowserAction("loadAGB()");
					return false;
				}
				browserAction = false;

				actualContent = parseInt(actualContent) + 1;
				target='content'+actualContent;
				loadingCategorie = "lade AGBs";
				loadingText = "einen Moment bitte!";
				makeRequest("xgetAGB.php","");
				bigSize=false;
				return noJs;
			}

			function saveNewBid(sess, id) {
				SessionId = sess;
				target='actualBid';
				var bid = document.getElementById('newBid').value;
				makeRequest("xsaveBid.php","SessionId="+sess+"&id="+id+"&bid="+bid);
				bigSize=false;
				delayAction = "updateSmallBid()";
				return noJs;
			}

			function updateSmallBid() {
				target='sideBarBid';
				makeRequest("xsaveBid.php","get=only");
				return noJs;
			}

			function sendContact() {

				if (document.getElementById("isbestellung").checked == true)
					var frage = "Bestellung";
				if (document.getElementById("produkte").checked == true)
					var frage = "Produkte";
				if (document.getElementById("sonstiges").checked == true)
					var frage = "Sonstiges";

				var user = document.getElementById('user').value;
				var message = document.getElementById('message').value;
				var mail = document.getElementById('mail').value;
				var betreff = document.getElementById('betreff').value;
				var calc = document.getElementById('calc').value;

				if (document.getElementById('knr'))
					var knr = document.getElementById('knr').value;

				if (document.getElementById('bst'))
					var bst = document.getElementById('bst').value;


				actualContent = parseInt(actualContent) + 1;
				target='content'+actualContent;
				loadingCategorie = "Kontaktanfrage wird gespeichert";
				loadingText = "einen Moment bitte!";
				makeRequest("xgetContact.php","frage="+frage+"&user="+user+"&mail="+mail+"&knr="+knr+"&bst="+bst+"&betreff="+betreff+"&message="+message+"&do=write&calc="+calc);
				bigSize=false;

				return noJs;
			}

			function loadLinks() {
				if (!browserAction) {
					callBrowserAction("loadLinks()");
					return false;
				}
				browserAction = false;
				actualContent = parseInt(actualContent) + 1;
				target='content'+actualContent;
				makeRequest("xgetLinkOverview.php","");
				bigSize=false;
				return noJs;

			}
			function loadLinkPage(kat) {
				if (!browserAction) {
					callBrowserAction("loadLinkPage(\""+kat+"\")");
					return false;
				}
				browserAction = false;
				actualContent = parseInt(actualContent) + 1;
				target='content'+actualContent;
				makeRequest("xgetLinkPage.php","kat="+kat);
				bigSize=false;
				return noJs;

			}

			function loadImpressum() {
				if (!browserAction) {
					callBrowserAction("loadImpressum()");
					return false;
				}
				browserAction = false;
				actualContent = parseInt(actualContent) + 1;
				target='content'+actualContent;
				loadingCategorie = "Impressum wird geladen";
				loadingText = "einen Moment bitte!";
				makeRequest("xgetImpressum.php","");
				bigSize=false;
				return noJs;

			}

			function loadContact() {
				if (!browserAction) {
					callBrowserAction("loadContact()");
					return false;
				}
				browserAction = false;
				actualContent = parseInt(actualContent) + 1;
				target='content'+actualContent;
				loadingCategorie = "Kontaktformular wird geladen!";
				loadingText = "einen Moment bitte!";
				makeRequest("xgetContact.php","");
				return noJs;
			}

			function loadLogin(sess) {
				SessionId = sess;
				actualContent = parseInt(actualContent) + 1;
				target='content'+actualContent;
				loadingCategorie = "Login wird geladen!";
				loadingText = "einen Moment bitte!";
				makeRequest("xgetLogin.php","SessionId="+sess);
				bigSize=false;
				return noJs;
			}

			function loadAuction(sess) {
				SessionId = sess;
				actualItem = "Auktion";
				actualContent = parseInt(actualContent) + 1;
				target='content'+actualContent;
				makeRequest("xgetAuction.php","SessionId="+sess);
				bigSize=false;
				return noJs;
			}

			function sendVLink() {
				if (!browserAction) {
					callBrowserAction("sendVLink()");
					return false;
				}
				browserAction = false;
				var kat = document.getElementById('vkat').value;
				var name = document.getElementById('vlink').value;
				var address = document.getElementById('vadresse').value;
				var banner = document.getElementById('vbanner').value;
				var mail = document.getElementById('vmail').value;
				var text = document.getElementById('vtext').value;

				actualContent = parseInt(actualContent) + 1;
				target='content'+actualContent;
				makeRequest("xgetVLink.php","link="+name+"&kat="+kat+"adresse="+address+"&banner="+banner+"&mail="+mail+"&text="+text+"&do=send");
				bigSize=false;
				return noJs;


			}

			function loadVLink() {
				if (!browserAction) {
					callBrowserAction("loadVLink()");
					return false;
				}
				browserAction = false;
				actualContent = parseInt(actualContent) + 1;
				target='content'+actualContent;
				makeRequest("xgetVLink.php","");
				bigSize=false;
				return noJs;
			}

			function loadXINC(name) {
				if (!browserAction) {
					callBrowserAction("loadXINC(\""+name+"\")");
					return false;
				}
				browserAction = false;
				actualContent = parseInt(actualContent) + 1;
				target='content'+actualContent;
				makeRequest("xincFile.php","data="+name);
				bigSize=false;
				return noJs;
			}

			function loadFAQCategorie(name) {
				if (!browserAction) {
					callBrowserAction("loadFAQCategorie(\""+name+"\")");
					return false;
				}
				browserAction = false;
				actualContent = parseInt(actualContent) + 1;
				target='content'+actualContent;
				makeRequest("xgetFAQCategorie.php","kat="+name);
				bigSize=false;
				return noJs;
			}

			function loadFAQ() {
				if (!browserAction) {
					callBrowserAction("loadFAQ()");
					return false;
				}
				browserAction = false;
				actualContent = parseInt(actualContent) + 1;
				target='content'+actualContent;
				makeRequest("xgetFAQOverview.php","");
				bigSize=false;

				
				return noJs;
			}

			function loadNews(sess) {

			if (!browserAction) {
					callBrowserAction("loadNews(\""+sess+"\")");
					return false;
				}
				browserAction = false;

				SessionId = sess;
				actualContent = parseInt(actualContent) + 1;
				target='content'+actualContent;
				loadingCategorie = "Radaddel.de - News werden geladen.";
				loadingText = "einen Moment bitte!";
				makeRequest("xgetNews.php","SessionId="+sess);

						$("#shortShow").html("<img src='images/wait.gif'> Lade Daten ...");
						$("#lastViewed").html("<img src='images/wait.gif'> Lade Daten ...");
						
						$.post("xgetExternalData.php?data=getShortShow", function(data){
							$('#shortShow').html(data);
						});
						$.post("xgetExternalData.php?data=lastView", function(data){
							$('#lastViewed').html(data);
						});
				
					
					bigSize=false;
				return noJs;
			}

			function loadGame() {
				var mail = document.getElementById('gs_mail').value;
				var t = document.getElementById('gs_try').value;

				actualContent = parseInt(actualContent) + 1;
				target = 'content'+actualContent;
				makeRequest("gewinnspiel.php","mail="+mail+"&try="+t+"&ctl=win");
				bigSize=false;

				return noJs;

			}

			function loadGuestbook(sess) {
				if (!browserAction) {
					callBrowserAction("loadGuestbook(\""+sess+"\")");
					return false;
				}
				browserAction = false;
				SessionId = sess;
				actualContent = parseInt(actualContent) + 1;
				target = 'content'+actualContent;
				loadingCategorie = "Gästebuch wird geladen";
				loadingText = "einen Moment bitte!";
				makeRequest("xgetGuestbook.php","SessionId="+sess);
				bigSize=true;
				return noJs;
			}
			
			function loadGutscheinEvent(field) {
				
				if (field.length > 0) 
					var value = document.getElementById(field).value;
				else {
					var value = "";
					actualContent = parseInt(actualContent) + 1;
					target = 'content'+actualContent;
				}
				
				makeRequest("xgutscheinEvent.php","mail="+value);
				
			}
			
			function loadNextSite(ln,start,sess, name) {
				if (!browserAction) {
					callBrowserAction("loadNextSite(\""+ln+"\",\""+start+"\",\""+sess+"\",\""+name+"\")");
					return false;
				}
				browserAction = false;

				if (start > 0)
					var tmp = (parseInt(start) / 20) + 1;
				else
					tmp = 1;

				actualItem = name.replace(' ','&nbsp;');;
				if (tmp != 1)
					actualItem = actualItem + " ("+tmp+")";

				SessionId = sess;
				actualContent = parseInt(actualContent) + 1;
				target = 'content'+actualContent;
				
				var seite = 1;
				if (start > 0) 
					while((seite * 20) <= start)
						seite++;
				
				
				loadingCategorie = "Seite "+seite+" wird geladen";
				loadingText = "einen Moment bitte!";
				makeRequest("xgetChild.php","cat="+ln+"&l="+start+"&SessionId="+sess);
				bigSize = true;
				return noJs;
			}

			function callBrowserAction(func) {
				clicked = true;
				iframe = document.getElementById("browserframe");
				var site = escape(func);
				iframe.setAttribute("src","loadNewAction.php?q=" + site);
			}


			function setAction(bool) {
		//		alert(bool);
				if (bool && !clicked) {
				//	alert(clicked);
					document.getElementById("browserAct").style.display = "inline";
					window.setTimeout('document.getElementById("browserAct").style.display = "none";', 1000);
				}
				if (!firstLoad)
						browserAction =	bool;

				clicked = false;
			}

			function loadProduct(ln,sess,prodname) {
				if (!browserAction) {
					callBrowserAction("loadProduct(\""+ln+"\",\""+sess+"\",\""+prodname+"\")");
					return false;
				}
				browserAction = false;
			//	alert("am laden!");
				if (prodname == "checkID") {
					prodname = document.getElementById('newslink'+ln).innerHTML;
					actualItem = prodname.replace(/<.*?>/gi, '');
				}
				else {
					actualItem = prodname;
				}

				if (actualItem == "") {
					actualItem = "Artikel";
				}


				SessionId = sess;
				actualContent = parseInt(actualContent) + 1;
				target = 'content'+actualContent;
				loadingCategorie = "Produktinformationen<br> werden geladen.";
				loadingText = "einen Moment bitte!";
				makeRequest("xgetProduct.php","prod="+ln+"&SessionId="+sess);
				bigSize = true;
				return false;
			}

			function loadProducts(ln,sess) {
				if (!browserAction) {
					callBrowserAction("loadProducts(\""+ln+"\",\""+sess+"\")");
					return false;
				}
				browserAction = false;
				SessionId = sess;
				actualContent = parseInt(actualContent) + 1;
				target = 'content'+actualContent;
				loadingCategorie = "Produkte der Kategorie<br> werden geladen.";
				loadingText = "einen Moment bitte!";
				makeRequest("xgetChild.php","cat="+ln+"&SessionId="+sess);
				bigSize = true;
				return false;
			}

			function showMailorder(sess) {
				SessionId = sess;
				window.open('xmailorder.php?&SessionId='+sess,'mailorder','width=800,height=500,left=100,top=200,scrollbars=1,resizable=1');
				return noJs;
			}


			function addProductAdvanced(sess, ln) {
				var basketcount = 0;
				SessionId = sess;
						document.cookie = "SessionId="+sess;

				if (document.getElementById('basketCount'))
					basketcount = parseInt(document.getElementById('basketCount').innerHTML);

				target = 'basket';

				var ln;
				var anz = document.getElementById('prodadd_'+ln).value;

				addProduct(ln,anz,sess);

				return false;

			}

			function loadBasket() {
				SessionId = readSession('SessionId');
				return;
				refreshBasket();
			}

			function publicateExport() {

				loadBasket();
				delayAction = "updateWKAnz()";
			}

			function updateWKAnz() {
				if (document.getElementById('basketCount')) {
					basketcount = parseInt(document.getElementById('basketCount').innerHTML);
					document.getElementById('stringBasket').innerHTML = 'Warenkorb ('+basketcount+' Artikel)';
				}
			}

			function refreshBasket() {
				if (busy == true) {
					window.setTimeout("refreshBasket", 2000);
					return noJs;
				}
				dontshow = true;
				target = 'basket';
				makeRequest("xgetBasket.php","SessionId="+SessionId);
			}

			function performWishlist(sess, cr, actionname) {

				SessionId = sess;
				//var action = document.getElementById("content"+actualContent).getElementById('actionId').value;
				var action = document.getElementById(actionname).options[document.getElementById(actionname).selectedIndex].value
				if (action == 'del') {
					actualItem = 'Wunschlisten bearbeiten';
					actualContent = parseInt(actualContent) + 1;
					target = "content"+actualContent;
					loadingCategorie = "Entferne Produkt";
					loadingText = "einen Moment bitte!";
					makeRequest("xdeleteWishlist.php","SessionId="+sess+"&cr="+cr);
					delayAction = "addWishlist('0','"+SessionId+"')";

					bigSize=false;
					return false;
				}
				if (action == 'wkexport') {
					target = 'basket';
					loadingCategorie = "Verarbeite Wunschliste";
					loadingText = "einen Moment bitte!";
					makeRequest("xexportWishlist.php","SessionId="+sess+"&cr="+cr);
					delayAction="publicateExport()";
				}
				if (action == 'send') {
					actualItem = 'Wunschlisten bearbeiten';
					actualContent = parseInt(actualContent) + 1;
					target = "content"+actualContent;
					loadingCategorie = "Wunschliste wird verarbeitet";
					loadingText = "einen Moment bitte!";
					makeRequest("xsendWishlist.php","SessionId="+sess+"&cr="+cr);

					bigSize=false;
					return false;
				}

			}

			function loadRSS() {
				if (!browserAction) {
					callBrowserAction("loadRSS()");
					return false;
				}
				browserAction = false;

				actualContent = parseInt(actualContent) + 1;
				actualItem = 'RSS-News';
				target = "content"+actualContent;
				loadingCategorie = "RSS Nachrichten werden geladen";
				loadingText = "einen Moment bitte!";
				makeRequest("xgetRSS.php","");

				bigSize=false;
				return false;
			}

			function loadMaxWishlist(sess) {
				if (!browserAction) {
					callBrowserAction("loadMaxWishlist(\""+sess+"\")");
					return false;
				}
				browserAction = false;

				actualContent = parseInt(actualContent) + 1;
				actualItem = 'Wunschlisten bearbeiten';
				target = "content"+actualContent;
				loadingCategorie = "Wunschliste wird geladen";
				loadingText = "einen Moment bitte!";
				makeRequest("xloadWishlist.php","SessionId="+sess);

				bigSize=false;
				return false;
			}

			function openWishlist(sess, cr) {
				window.open('viewWishlist.php?cr='+cr,'Wishlist');

			}

			function loadWishlist(sess) {
				if (!browserAction) {
					callBrowserAction("loadWishlist(\""+sess+"\")");
					return false;
				}
				browserAction = false;
				SessionId = sess;

				target = 'wishlist';
				loadingCategorie = "füge Produkt zur Wunschliste hinzu";
				loadingText = "einen Moment bitte!";
				makeRequest("xaddWishlist.php","prod="+ln+"&SessionId="+sess);

				return false;


			}

			function radioWert(name) {
				var data = document.getElementsByName(name);
			    for (var i=0; i<data.length; i++)
					if (data[i].checked) return data[i].value;
			    return false;
			  }

			function activateWishlistSmall(Sess) {

				var list = radioWert('SloadList');
				target = 'wishlist';

				makeRequest("xaddWishlist.php","do=changeList&list="+list);
			}

			function renameList(sess, name) {
				SessionId = sess;
				
				
				actualItem = 'Wunschlisten bearbeiten';
				actualContent = parseInt(actualContent) + 1;
				target = "content"+actualContent;


				loadingCategorie = "Wunschliste wird geändert!";
				loadingText = "einen Moment bitte!";
				makeRequest("xeditWishlist.php","do=rename&list="+name);
				bigSize=false;
				delayAction = "addWishlist('0','"+SessionId+"')";
				return false;
				

			}

			function addWishlist(ln,sess) {
		/*		if (!browserAction) {
					callBrowserAction("addWishlist(\""+ln+"\",\""+sess+"\")");
					return false;
				}
				browserAction = false; */
		
				SessionId = sess;

				target = 'wishlist';
				loadingCategorie = "Wunschliste wird geladen";
				loadingText = "einen Moment bitte!";
				scrollUp = false;
				makeRequest("xaddWishlist.php","prod="+ln+"&SessionId="+sess);

			
				return false;

			}

			function activateWishlist(sess) {
				if (!browserAction) {
					callBrowserAction("activateWishlist(\""+sess+"\")");
					return false;
				}
				browserAction = false;

				SessionId = sess;
				actualItem = 'Wunschlisten bearbeiten';
				actualContent = parseInt(actualContent) + 1;
				target = "content"+actualContent;

				var list = radioWert('activList');

				loadingCategorie = "Änderungen werden gespeichert";
				loadingText = "einen Moment bitte!";
				makeRequest("xeditWishlist.php","SessionId="+sess+"&do=activate&list="+list);
				bigSize=false;
				delayAction = "addWishlist('0','"+SessionId+"')";
				return false;
			}


			function editWishlist(sess,count,product) {
				if (!browserAction) {
					callBrowserAction("editWishlist(\""+sess+"\",\""+count+"\",\""+product+"\")");
					return false;
				}
				browserAction = false;

				actualItem = 'Wunschlisten bearbeiten';
				actualContent = parseInt(actualContent) + 1;
				target = "content"+actualContent;


				loadingCategorie = "Änderungen werden gespeichert";
				loadingText = "einen Moment bitte!";
				makeRequest("xeditWishlist.php","SessionId="+sess+"&prod="+product+"&count="+count+"&do=change");
				bigSize=false;
				delayAction = "addWishlist('0','"+SessionId+"')";
				return false;
			}

			function addProduct(ln,anz,sess) {
				browserAction = false;

				SessionId = sess;
						document.cookie = "SessionId="+sess;

				var basketcount = 0;

				if (document.getElementById('basketCount'))
					basketcount = parseInt(document.getElementById('basketCount').innerHTML);

				target = 'basket';
				scrollUp = false;
				loadingCategorie = "Warenkorb wird aktualisiert";
				loadingText = "einen Moment bitte!";
				makeRequest("xaddProduct.php","prod="+ln+'&add='+anz+'&SessionId='+sess);
				var prodCount = (basketcount+parseInt(anz));
				//document.getElementById('stringBasket').innerHTML = 'Warenkorb ('+prodCount+' Artikel)';
				var bask = '<a style="text-decoration: none; font-size: 8pt;" href="warenkorb.php?SessionId='+sess+'">' +
											'<img src="../pictures/cart.gif" border="0">Warenkorb ('+prodCount+' Artikel)</a>';
											
				document.getElementById('stringBasket').innerHTML = bask;
				
				return false;
			}

			function loadExtend(Eurl,Eitem,Ebigsize) {
				if (!browserAction) {
					callBrowserAction("loadExtend(\""+Eurl+"\",\""+Eitem+"\",\""+Ebigsize+"\")");
					return false;
				}
				browserAction = false;

				actualItem = Eitem;

				actualContent = parseInt(actualContent) + 1;
				target = "content"+actualContent;

				makeRequest(Eurl,"");
				bigSize=Ebigsize;
				return false;
			}

			function loadSearch(sess) {
				if (!browserAction) {
					callBrowserAction("loadSearch(\""+sess+"\")");
					return false;
				}
				browserAction = false;
				
				if (getObj("AdvSearchArticleNumber") && getObj("AdvSearchArticleNumber").value != "") {
					
					var mark = parseInt(document.getElementById("mark").innerHTML);
					
					loadProduct(getObj("AdvSearchArticleNumber").value, sess, document.getElementById("discovery").childNodes[mark].childNodes[0].innerHTML);
				
					getObj("discoveryDiv").style.display = "none";
					return;
				
				}
				
				actualItem = 'Suche: '+document.getElementById('search').value;
				actualContent = parseInt(actualContent) + 1;
				target = "content"+actualContent;
				loadingCategorie = "Suche wird durchgeführt";
				loadingText = "einen Moment bitte!";
				makeRequest("xsearch.php","q="+document.getElementById('search').value+'&SessionId='+sess);
				bigSize=true;
				return false;
			}

			function getObj(name) {
				return document.getElementById(name);
			}
			
			function getStyle(name) {
				return document.getElementById(name);
			}
			
			function productload() {
				if (target != "basket") {
					onlyBigScreen = false;
				}

				if (http_request.readyState == 4) {
						if (http_request.status == 200) {
							busy = false;
							
							if (scrollUp)
								window.scrollTo(0, 0);
								
							scrollUp = true;
							
							var xmldoc = http_request.responseXML;
							if (document.getElementById(target)) {
								document.getElementById(target).innerHTML = http_request.responseText;
							}
							else {
								var parent = document.getElementById('content');
								var newdiv = document.createElement('div');
								newdiv.setAttribute('class','content');
								newdiv.setAttribute('name','content');
								newdiv.setAttribute('id','content'+actualContent);
								availableDivs.push('content'+actualContent);
								parent.appendChild(newdiv);

								newdiv.innerHTML = http_request.responseText;
								makeAllTabsInvisible();
								makeTabVisible(actualContent);

							}
								makeBigScreen(bigSize);
							screenUpdate = true;

							showWait(false);

							addToTab(actualContent);

							if (delayAction != false) {
								setTimeout(delayAction,1);
								delayAction = false;
							}
						} else {
							noAJAX = true;
						}
					}
			}


			function makeTabVisible(tab,item) {

				visibleTab = tab;
				makeAllTabsInvisible();
				document.getElementById('content'+tab).style.display = 'inline';
			}

			function makeAllTabsInvisible() {

				for (var i=0; i< availableDivs.length; i++) {
					objItem = document.getElementById(availableDivs[i]);
						objItem.style.display = 'none';
				}
			}

			function makeRequest(url,data) {
				busy = true;
				http_request = false;
				if (dontshow == false)
					showWait(true);

				dontshow = false;
				if (window.XMLHttpRequest) {
					http_request = new XMLHttpRequest();
					if (http_request.overrideMimeType) {
						http_request.overrideMimeType('text/xml');
					}
				} else if (window.ActiveXObject) {
					try {
						http_request = new ActiveXObject("Msxml2.XMLHTTP");
					} catch (e) {
						try {
						http_request = new ActiveXObject("Microsoft.XMLHTTP");
						} catch (e) {}
					}
				}

				if (!http_request) {
					alert('Giving up :( Cannot create an XMLHTTP instance');
					return false;
				}

				http_request.onreadystatechange = productload;
				http_request.open('POST', url, true);
				http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				http_request.setRequestHeader('Content-length', data.length);
				http_request.send(data);

				wkrefresh = true;

			}

			function repeatBasketRefresh() {

			}

			function alertContents() {

				if (http_request.readyState == 4) {
					showWait(false);
					if (http_request.status == 200) {
						document.getElementById('content').innerHTML = http_request.responseText;
					} else {
						//alert('There was a problem with the request.'); 	******************************************
					}
				}

			}


			function showSubCategorie(ln) {
				settingLn = ln;
				//alert(ln);
				makeRequest(adress + 'xgetChild.php","cat=' + ln);
			}


			function showAdd(id,t) {
				obj = document.getElementById(id);
				if (t) {
					obj.style.display = 'inline';
				}
				else {
					obj.style.display = 'none';
				}

			}

			function makeAdvSearch() {
				document.getElementById('advancedSearch').style.display = "inline";
			}

			function toggleSearch(on,off) {
				document.getElementById(on).style.display='block';
				document.getElementById(off).style.display='none';

			}
			
			function closeAllTabs() {
				tabs = new Array();
				makeTabVisible(0);
				rebuildTabs();
				makeBigScreen(false);
				document.getElementById("closeAll").style.display = "none";
			}

			function closeActualTab() {

				//new Effect.DropOut(document.getElementById('content'+visibleTab));
				//return;
				makeAllTabsInvisible();

				temptabs = tabs;
				
				tabs = new Array();
				for (var i = 0; i < temptabs.length; i++) {
					if (temptabs[i][1] != visibleTab)
						tabs.push(temptabs[i]);

				}
				
				
				
				//alert(tabs.length);
				if (tabs.length > 0) {
					var newTab = tabs[tabs.length-1][1];
					makeBigScreen(true);
				}
				else {
					var newTab = 0;
					makeBigScreen(false);
				}
				makeTabVisible(newTab);

					

				if (plainScreen == true)
					makePlainScreen(true);

				bigSize=false;
				rebuildTabs();

			}

			function makePlainScreen(t) {
				if (t) {
					document.getElementById('leftdata').style.display = 'none';
					document.getElementById('rightdata').style.display = 'none';
				}
				else {
					document.getElementById('leftdata').style.display = 'block';
					document.getElementById('rightdata').style.display = 'block';
				}
			}
			function closeTab(tab) {

				if (tab == visibleTab) {
					closeActualTab();
				}

				makeAllTabsInvisible();

				temptabs = tabs;
				tabs = new Array();
				for (var i = 0; i < temptabs.length; i++) {
					if (temptabs[i][1] != tab)
						tabs.push(temptabs[i]);

				}
				rebuildTabs();

			}

				function toggleTabs(item) {
					visibleTab = parseInt(item.getAttribute('name').replace('content',''));
					var newtab = item.getAttribute('name');
					makeAllTabsInvisible();
					document.getElementById(newtab).style.display = 'inline';
					makeBigScreen(true);
					bigSize = true;
					rebuildTabs();
				}

				function createTabs() {

					var needtr = Math.ceil(tabs.length / getbreak);
					var parent = document.getElementById('tabmain');
					var container = document.getElementById('tabcontainer');
					

					for (var i = 1 ; i <= needtr ; i++) {
						var newtr = document.createElement('tr');
						newtr.setAttribute('id','tab'+i);
						parent.appendChild(newtr);
					}
					if (tabs.length > 1) 
						document.getElementById("closeAll").style.display = "inline";
					if (tabs.length < 2) 
					document.getElementById("closeAll").style.display = "none";			
					
					for(var i = 0;i < tabs.length; i++) {
						var newtd = document.createElement('td');
						var css;
						if ((parseInt(tabs[i][1])) == parseInt(visibleTab)) {
						//	newtd.setAttribute('style','border: 1px solid #2C2A54'); //2C2A54
							css = "tabs";
						}
						else
							css = "tabsi";
						
						newtd.innerHTML = "<p class='" + css + "' style='height:20px;padding:3px;'>" + tabs[i][0] + "&nbsp;&nbsp;&nbsp;<img src=\"images/cross.gif\" onClick='closeTab(\""+tabs[i][1]+"\");' />" + "</p>";
						newtd.setAttribute('align','center');
						newtd.setAttribute('id','tabnum'+tabs[i][1]);
						newtd.setAttribute('name','content'+tabs[i][1]);
						newtd.setAttribute('nowrap','nowrap');
						
						var cnumber = tabs[i][1];
						newtd.onclick=function(){toggleTabs(this)};
						parenttr = document.getElementById('tab'+(Math.ceil((parseInt(i)+1)/getbreak)));
						parenttr.appendChild(newtd);
					}

				parent.style.display = 'inline';
				container.style.display = 'inline';
				}





			function rebuildTabs() {
			tabuse = 1;
				var container = document.getElementById('tabcontainer');
				container.innerHTML = '<table><tbody id="tabmain"><tr id="tab1"></tr></tbody></table>';

				createTabs();

				makeAllTabsInvisible();
				makeTabVisible(visibleTab);

			}

			function addToTabExact(cnumber) {
				var tabmain = document.getElementById('tabmain');
				var container = document.getElementById('tabcontainer');
				var actualtab = document.getElementById("tab"+tabuse);

				if (actualtab) {
					if (actualtab.childNodes.length % getbreak == 0 && actualtab.childNodes.length) {
						var newtr = document.createElement("tr");
						tabuse = parseInt(tabuse) +1;

						newtr.setAttribute("id","tab"+tabuse);
						tabmain.appendChild(newtr);
					}
				}

				var text = document.createTextNode(decodeURIComponent(actualItem));
				var newtd = document.createElement("td");

				newtd.onclick=function(){makeTabVisible(cnumber)};
				newtd.setAttribute('class','tabs');
				newtd.setAttribute('id','tabnum'+cnumber);

				var tr = document.getElementById('tab'+tabuse);

				newtd.appendChild(text);
				tr.appendChild(newtd);

				newtd.style.display = 'inline';
				container.style.display = 'inline';

			}

			function addToTab(cnumber) {
				if (actualItem != false) {
					for (var i = 0; i < tabs.length; i++) {
						if (tabs[i][0] == actualItem) return false;
					}
					tabs.push(new Array(actualItem, cnumber));
					actualItem = false;
					rebuildTabs();
				}
			}


			function doknr() {

				if (document.getElementById('isbestellung').checked == true) {

					var code1 = 'Kundennummer';
					var code2 = '<input type="text" name="knr" class="input.normal" style="width:100%;" id="knr" />';
					var code3 = 'Bestellnummer';
					var code4 = '<input type="text" name="best" class="input.normal" style="width:100%;" id="bst" />';
						document.getElementById('knr').innerHTML = code1;
						document.getElementById('knr2').innerHTML = code2;
						document.getElementById('bst').innerHTML = code3;
						document.getElementById('bst2').innerHTML = code4;
				}
			}
			
			function nop() {}
				
			