

	function loadAlsoBuyed(id, ln) {
		$("#" + id).html("<table width='100%' cellpadding='20px'><tr><td align='center'><img src='images/wait.gif'> Lade Daten ... </td></tr></table>");
		$.ajax({
			  url: "xgetProductAlsoBuyed.php?ln=" + ln,
			  cache: false,
			  type: "POST",
			  success: function(html){
			   $('#' + id).html(html);
			  }
			});
	}
	
	function loadAdvice() {
		//$("#waitAdvice").html("<img src='images/wait.gif'>");
		/*$.ajax({
			  url: "xgetAdvice.php",
			  cache: false,
			  type: "POST",
			  success: function(html){
			   $('#advice').html(html);
			   $("#waitAdvice").html("");
			  }
			});*/	
			
			if (!browserAction) {
					callBrowserAction("loadAdvice()");
					return false;
			}
		
			browserAction = false;
			actualContent = parseInt(actualContent) + 1;
			actualItem = "Deine Empfehlungen";
			target='content'+actualContent;
			loadingCategorie = "Empfehlungen werden geladen";
			loadingText = "einen Moment bitte!";
			makeRequest("xgetAdvice.php","");
			bigSize=true;
			return noJs;			
	}

	function loadComment(id) {
		$('#commentContainer' + id).html("<img src='images/wait.gif'> Lade Kommentar ...");
		$.ajax({
			  url: "xgetComments.php?ln=" + id,
			  cache: false,
			  type: "POST",
			  success: function(html){
			   $('#commentContainer' + id).html(html);
			  }
			});
	}
	
	function saveComment(x, id) {
		var pdata = "";
		pdata += "&user=" + escape($("#user"+x).val());
		pdata += "&mail=" + escape($("#mail"+x).val());
		pdata += "&comment=" + escape($("#comment"+x).val());

		$("#commentSave"+x).parent().html("<img src='images/wait.gif'> Wird gespeichert...");
			$.ajax({
			  url: "xgetComments.php?do=save",
			  cache: false,
			  type: "POST",
			  data: pdata + "&id="+id,
			  success: function(html){
	//		  $("#commentSave"+x).parent().html(html);
			   loadComment(id);
			  }
			});
	}
	
	
	
	
	function loadPromotion(table) {
	
		if (document.getElementById("promotionContainer") != null) {
			$("#promotionContainer").toggle();
			return;
		}
			
		div = ($(table).clone());
		
		var width = document.body.offsetWidth;
		var height = document.body.offsetHeight;
		
		
		var div = document.createElement("div");
		$(document.body).append(div);
		div = $(div).css({
			"left": (width/2) - 200,
			"top":-300,
			"border": "1px solid #E7C715",
			"height":300,
			"width":400,
			"position":"absolute",
			"background-color":"#2B2A53",
			"color": "#FFF"
		}).html("<br><br><br><br><img src=\"../pictures/ajaxload.gif\"><br><br>Einen Moment bitte...").attr({
			"align" : "center",
			"id" : "promotionContainer"
		});
		
		div.animate({
			top: 200,
			width: 400,
			height: 300
		}, "slow", function() { 
			$.ajax({
			  url: "xgetPromotion.php",
			  cache: false,
			  type: "POST",
			  success: function(html){
				   $('#promotionContainer').html(html);
			  }
			});		
		});
	}
	
	function showProductPicture(picture, name, ln, s) {

		if (document.getElementById("showPicture_" + ln) != null) {
			$("#showPicture_" + ln).fadeIn();
			$(".lookThroughBG").show();
			return;
		}


		var div = document.createElement("div");
		$(document.body).append(div);
		div = $(div);
		div.hide();
		div.attr({
			"class": "productPicture",
			"id": "showPicture_" + ln
		}); 
		

		var bdiv = document.createElement("div");
		$(document.body).append(bdiv);
		bdiv = $(bdiv);
		bdiv.attr("class", "lookThroughBG");
		bdiv.css( {
			"width": document.body.offsetWidth,
			"height": document.body.offsetHeight,
			"background-color": "#050512",
			"opacity": 0.3,
			"left":0,
			"top":0,
			"z-index":5,
			"position":"absolute"
		}).show();
		
		div.click(function() {
			$(".lookThroughBG").hide();
			$(".productPicture").fadeOut();
		});
		
		div.css({
			border:"1px solid #E7C715",
			"position":"absolute",
			"background-color": "#050512",
			"text-align":"center",
			"align":"center",
			"width": 300,
			"height": 200,
			"z-index": "6",
			left: (screen.availWidth / 2) - 200,
			top: (screen.availHeight / 2) - 100	
		}).fadeIn();
//		div.html();
		bdiv.click(function() {
			$(".lookThroughBG").hide();
			$(".productPicture").fadeOut();
		});
		
		div.html('<table align="right" cellspacing="0"><tr><td class="boxheader">'+name+'</td><td style="cursor:pointer;" align="right" class="boxheader"><img src="../pictures/close.gif" title="Bild schlie&szlig;en" alt="Bild schlie&szlig;en"></td></tr></table><br><br>');


		var load = document.createElement("img");
		div.append(load);
		$(load).attr({
			"src": "../pictures/ajaxload2.gif",
			"class": "loader"
		});
		
		var pic = document.createElement("img");
		div.append(pic);
		var img = $(pic).attr("src", picture).hide();

		img.error(function(){$(this).hide();});
		
		img.load(function(){
			var tt = this;
			var timg = $(this);
			var div = $(tt.parentNode);
			$(".loader", div).hide();
			
			var swidth=screen.availWidth;
		    var sheight =screen.availHeight;
	
			
			var width = timg.width();
			var height = timg.height();
						
			var t = ((sheight/2) - height);
			var l = ((swidth/2) - width/2);			
										
			div.animate({
				left: (l < 0 ? 0 : l ),
				top: (t < 0 ? 0 : t),
				"width": (width + 20),
				"height": (height + 50)
			}, "slow", function() { 
				$("img", this).each(function() {
					if ($(this).attr("class") != "loader")
						$(this).fadeIn();
				});
			});
				
				
			div.append(this);	
			$("table", div).each(function() {
				this.style.width = width + 20;
			});
		});
	}
	
	function closeProductPicture(div, bdiv) {
		div.hide();
		bdiv.hide();
	}