$().ready(function() {
	debug = true;
	$.wbAjaxLock = 0;
	$.wbAjaxType = "POST";
	$.wbAjaxFormPars = false;
	$.wbAjaxStore = false;
	$.wbAjaxSaveState = false;
	$.wbAjaxPositionState = 0;
	$.wbAjaxBack = true;
	$.wbAjaxScrollLock = false;
	$.refreshAnim = true;

	videoPlayerInit = function () {
		$(".flash_default, .WBFlash").each(function(){
		  var el = $(this);
		  var id = "video_player_"+Math.round(Math.random()*10000);
		  el.after("<div id='"+id+"'></div>");
		  swfobject.embedSWF($.base+"public/flash/vplayer.swf", id, "480", "360", "9.0.0", "expressInstall.swf", { vurl: $(this).attr("alt") }, {allowFullScreen: true, bgcolor: "#000000"});
		  el.remove();
		});
	}

	$.linkInit = function() {
		$("#mainContent").find('a').each(function() {
			var $this = $(this), href = $this.attr('href');

			if ((href.search($.base) < 0) && (href[0] != '#')) $this.attr('target', '_blank');
		});
	}


	$.initAutoGallery = function() {
		/*
	    $("#mainContent img.WBImage").each(function() {
	        var $img = $(this);
	        var fl = $img.css("float");
	        var srcPage 	= $img.attr("src");
	        var srcOrig 	= srcPage.replace("_medium/", "").replace("_small/", "").replace("_large/", "");
	        var srcGallery 	= srcPage.replace("_medium/", "_large/").replace("_small/", "_large/");

			var style = "";
			if ($img.get(0).width != "") style += "width: " + $img.get(0).width + "px; ";
			if ($img.get(0).height != "") style += "height: " + $img.get(0).height + "px;";

	        var html = '<div class="gallery_image" style="float: '+fl+'"><a href="'+srcOrig+'" title="" rel="'+srcGallery+'" rev="'+srcOrig+'" target="_blank">';
	        html += '<img src="'+srcPage+'" alt="" style="'+style+'" /></a></div>';

			$(this).replaceWith(html);
		});

		initGallery();*/
	}

	loading = function (status) {
		if (status) {
			$("#loader").css({ opacity: 1, display: "block" }).stop().animate({ opacity: 1 }, 200, "swing");
		  	if ($.refreshAnim && !$.browser.msie) {
			  $("#mainContent").stop().animate({ opacity: 0 }, 200, "swing");
		  	}
		} else {
		 	$("#loader").stop().animate({ opacity: 0 }, 200, "swing", function () {
				$(this).css({ opacity: 0, display: "none" });
   		 	});
		  	if ($.refreshAnim && !$.browser.msie) {
			  $("#mainContent").stop().animate({ opacity: 1 }, 200, "swing");
		  	} else {
		  		$.refreshAnim = true;
		  	}
		}
	}

	StateManager = EXANIMO.managers.StateManager;

	$("a.remoteBack").die().live("click", function() {
		history.back(1);
	    return false;
	});

	setSearchLinks = function () {
		if ($("#searchForm").length && $.trim($("#searchForm input[name='search']").val()) != "" ) {
			var searchQuery = $("#searchForm").serialize();
			$(".pagination a").each(function(){
				$(this).attr("href", $(this).attr("href").split("?")[0]+"?"+searchQuery);
			});
		}
	}

	setStoreLinks = function () {
		$(".basketPlusitem").die("click").live("click", function() {
			var $inp = $(this).parent().find("input[name=amount]");
			$inp.val(parseInt($inp.val()) + 1).closest("form").submit();
		});

		$(".basketMinusitem").die("click").live("click", function() {
			var $inp = $(this).parent().find("input[name=amount]");
			$inp.val(parseInt($inp.val()) - 1).closest("form").submit();
		});
	}

	$.executeRemoteLink = function($this) {
		$.wbAjaxFormPars = false;
		$.wbAjaxBack = false;
		$.wbAjaxPositionState = $('html').scrollTop();

		if ($this.hasClass("noRefreshAnim")) $.refreshAnim = false;
		else $.refreshAnim = true;

		if ($this.hasClass("scrollLock")) $.wbAjaxScrollLock = true;
		else $.wbAjaxScrollLock = false;

		var uri = $this.attr('href').replace($.base,'');

		if ($this.hasClass("historyLock")) $.wbAjaxLoad(uri);
		else StateManager.setState(uri);

		return false;
	}

	$.executeRemoteForm = function($this) {
		if ($("#dayCheck").length > 0 && $("#dayCheck").val() == 0) {
			alert(window.daycheckError);
			return false;
		}

		if ($this.hasClass("modifyBasket"))
		{
			$.wbAjaxStore = true;
			$.wbAjaxSaveState = window.location.toString();
		}

		if (($this.find("input[name='file']").length <= 0) || ($this.find("input[name='file']").length && !$this.find("input[name='file']").val())) {

			if ($this.hasClass("noRefreshAnim")) $.refreshAnim = false;
			else $.refreshAnim = true;

			if ($this.hasClass("scrollLock")) $.wbAjaxScrollLock = true;
			else $.wbAjaxScrollLock = false;

			$.wbAjaxBack = false;
			$.wbAjaxPositionState = $('html').scrollTop();

			var frag = window.location.toString().split("#")[1];
			var uri = "";

			if ($this.attr("method").toLowerCase() == "get") {
				$.wbAjaxType = "GET";

				$.wbAjaxFormPars = $this.serialize();

				uri = $this.attr('action').replace($.base,'') + "?" + $.wbAjaxFormPars;
				$.wbAjaxFormPars = false;

			} else {
				$.wbAjaxFormPars = $this.append("<input type='hidden' name='ajax' value='true' />").serializeArray();
				$this.children("input[name='ajax']").remove();

				uri = $this.attr('action').replace($.base,'');
			}

			if ($this.hasClass("historyLock")) $.wbAjaxLoad(uri);
			else StateManager.setState(uri);

			if ($.wbAjaxSaveState !== false) {
				if (frag) window.location = $.wbAjaxSaveState;
				$.wbAjaxSaveState = false;
			}
			return false;
		}
	}

	$.setRemoteLink = function(el) {
		el.unbind("click").click(function() {
			var $this = $(this);
			if ($this.hasClass("remoteConfirm")) {
				if (confirm($this.attr("lang"))) return $.executeRemoteLink($this);
				else return false;
			} else return $.executeRemoteLink($this);
		});
	}

	$.setRemoteForm = function(el) {
		el.unbind("submit").submit(function() {
			return $.executeRemoteForm($(this));
		});
	}

	setRemoteLinks = function (remoteLinkContainer) {
		if ((typeof remoteLinkContainer == "undefined") || (typeof remoteLinkContainer == "null")) remoteLinkContainer = "";
		else remoteLinkContainer += " ";

		$(remoteLinkContainer + 'a.remote').each(function (i) {
			return $.setRemoteLink($(this));
	    });

		$(remoteLinkContainer + 'form.remote').each(function (i) {
			return $.setRemoteForm($(this));
	    });

	}

	$.wbAjaxLoad = function(url) {
		if (!$.wbAjaxLock) {
			$.wbAjaxLock = 1;

			var pars = ($.wbAjaxFormPars?$.wbAjaxFormPars:{ ajax: 'true' });
			var ajaxStore = $.wbAjaxStore;

			$.wbAjaxStore = false;
			$.wbAjaxFormPars = false;

			if (ajaxStore) $.refreshAnim = false;
			loading(1);

			if (!$.wbAjaxScrollLock && ($.wbAjaxBack === false)) {
				//var mTop = ($("#searchContent").length) ? $("#searchContent").offset().top : $("#mainContent").offset().top;
				var mTop = $("#mainContent").offset().top;
				if ($('html').scrollTop() > mTop) $('html, body').animate({ scrollTop: 0 }, 'slow');
			}

			if ($("#searchContent .gsc-tabsArea").length) $("#searchContent .gsc-tabsArea").removeClass("gsc-tabsArea").addClass("gsc-tabsAreaInvisible");
			if ($("#searchContent .gsc-resultsbox-visible").length) $("#searchContent .gsc-resultsbox-visible").removeClass("gsc-resultsbox-visible").addClass("gsc-resultsbox-invisible");

			$("#searchContent").hide();

			$.ajax({
				type: $.wbAjaxType,
				url: $.base+url,
				data: pars,
				dataType: "html",
				complete: function (data, status) {
					if (!ajaxStore) $("#mainContent").html(data.responseText);
					else $("#basket").replaceWith(data.responseText);

					if (typeof _gaq == "object") _gaq.push(['_trackPageview', "/" + url]);

					loading(0);

					initFunctions("#mainContent");

					if (!$.wbAjaxScrollLock) {
						if ($.wbAjaxBack === false) {
							$.wbAjaxBack = true;
						} else {
							$('html, body').animate({ scrollTop: $.wbAjaxPositionState }, "fast");
						}
					}

					$.wbAjaxScrollLock = false;
				}
			});

			$.wbAjaxType = "POST";
		}
	}

	StateManager.onstatechange = function(e) {
	    if (e.id!="") {

			var loc = window.location.toString().split("#")[0];

    		if (($.base != loc) && !$.wbAjaxFormPars) {
    			window.location = $.base + "#" + e.id.split("?")[0];
    		} else {
				$.wbAjaxLoad(e.id);
    		}
	    }
	}

	initFunctions = function (remoteLinkContainer) {
		if ((typeof remoteLinkContainer == "undefined") || (typeof remoteLinkContainer == "null")) remoteLinkContainer = "";

		$.wbAjaxLock = 0;
		setRemoteLinks(remoteLinkContainer);
		videoPlayerInit();
		setSearchLinks();
		setStoreLinks();
        $.initAutoGallery();
        $.linkInit();
        $.initWBForm();
	}

	initWbPage = function () {
		initFunctions();
		StateManager.initialize();

	}

	checkIE6 = function () {
	    return ($.browser.msie && parseInt($.browser.version)<7);
	}

	checkIE = function () {
	    return ($.browser.msie);
	}


	addTag = function (str) {
		var selection = "";
		var value = $("#commentText").val();
		var range = $("#commentText").getSelection();
		var before = value.substring(0, range.start);
		var after = value.substring(range.end, value.length);

		if ((range.text.length > 0) || (str != "img" && str != "url")) {
			if ((str == "url" || str == "img") && range.text.substr(0,7) != "http://" ) {
				range.text = "http://" + range.text;
			}
			var trailing = "";
			if (range.text[range.length-1] == " ") {
				range.text = range.text.substring(0, range.length-1);
				trailing = " ";
			}
    		var selection = "["+str+"]" + range.text + "[/"+str+"]";
			$("#commentText").val(before + selection + trailing + after);
		} else if (str == "url") {
			if (selection = prompt("Adja meg az urlt!","http://")) {
				$("#commentText").val(before + "[url]" + selection + "[/url] " + after);
			}
		} else if (str == "img") {
			if (selection = prompt("Adja meg az kép url-t!","http://")) {
				$("#commentText").val(before + "[img]" + selection + "[/img] " + after);
			}
		}
	};

	htmlToBBCode = function (s) {
		s = $.trim(s);

		function rep(re, str) {
			s = s.replace(re, str);
		};

		rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");
		rep(/<font.*?color=\"(.*?)\".*?class=\"codeStyle\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]");
		rep(/<font.*?color=\"(.*?)\".*?class=\"quoteStyle\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]");
		rep(/<font.*?class=\"codeStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]");
		rep(/<font.*?class=\"quoteStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]");
		rep(/<font.*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[color=$1]$2[/color]");
		rep(/<font>(.*?)<\/font>/gi,"$1");
		rep(/<img.*?src=\"(.*?)\".*?>/gi,"[img]$1[/img]");
		rep(/<img.*?src=\"(.*?)\".*?\/>/gi,"[img]$1[/img]");
		rep(/<span class=\"codeStyle\">(.*?)<\/span>/gi,"[code]$1[/code]");
		rep(/<span class=\"quoteStyle\">(.*?)<\/span>/gi,"[quote]$1[/quote]");
		rep(/<strong class=\"codeStyle\">(.*?)<\/strong>/gi,"[code][b]$1[/b][/code]");
		rep(/<strong class=\"quoteStyle\">(.*?)<\/strong>/gi,"[quote][b]$1[/b][/quote]");
		rep(/<em class=\"codeStyle\">(.*?)<\/em>/gi,"[code][i]$1[/i][/code]");
		rep(/<em class=\"quoteStyle\">(.*?)<\/em>/gi,"[quote][i]$1[/i][/quote]");
		rep(/<u class=\"codeStyle\">(.*?)<\/u>/gi,"[code][u]$1[/u][/code]");
		rep(/<u class=\"quoteStyle\">(.*?)<\/u>/gi,"[quote][u]$1[/u][/quote]");
		rep(/<\/(strong|b)>/gi,"[/b]");
		rep(/<(strong|b)>/gi,"[b]");
		rep(/<\/(em|i)>/gi,"[/i]");
		rep(/<(em|i)>/gi,"[i]");
		rep(/<\/u>/gi,"[/u]");
		rep(/<u>/gi,"[u]");
		rep(/<br \/>/gi,"\n");
		rep(/<br\/>/gi,"\n");
		rep(/<br>/gi,"\n");
		rep(/<p>/gi,"");
		rep(/<\/p>/gi,"\n");
		rep(/&nbsp;/gi," ");
		rep(/&quot;/gi,"\"");
		rep(/&lt;/gi,"<");
		rep(/&gt;/gi,">");
		rep(/&amp;/gi,"&");
		rep(/&undefined;/gi,"'"); // quickfix
		return s;
	}


	// USERNAME AND PASSWORD FIELD TEXT HIDER
	$(".usernameInput").click(function() {
		if ($(this).val() == "Felhasználónév") {
			$(this).val("");
		}
	});

	$(".usernameInput").blur(function() {
		if ($.trim($(this).val()) == "") {
			$(this).val("Felhasználónév");
		}
	});

	$(".passwordInput").click(function() {
		if ($(this).val() == "jelszo") {
			$(this).val("");
		}
	});

	$(".passwordInput").blur(function() {
		if ($.trim($(this).val()) == "") {
			$(this).val("jelszo");
		}
	});

	$(".searchInput").click(function() {
		if ($(this).val() == "Termék kereső") {
			$(this).val("");
		}
	});

	$(".searchInput").blur(function() {
		if ($.trim($(this).val()) == "") {
			$(this).val("Termék kereső");
		}
	});

	// GALLERY INITIALIZATION
	initGallery = function (disableSlideshow, disableFull) {
		var contentOffset = $("#mainContent").offset();
		window.contentLeft = contentOffset.left;
		window.contentTop = contentOffset.top;
		window.gLoading = 0;
		gallery_slideshow = 0;
		gallery_nextEl = new Object();
		gallery_slideTimer = new Object();

		$(".gallery_image img").css({ opacity: 1 });
		$(".gallery_image > div").css({ zIndex: 10, display: "block", opacity: 0 });
		$(".gallery_image > a").click(function() {
			return false;
		});

		$(".gallery_image > div").mouseover(function () {
				$(this).stop().animate({ opacity: 0.5 }, 100, "swing", function () {
					$(this).animate({opacity: 0 }, 200);
				});
		});

		$(".gallery_image a, .gallery_image div").click(function () {
		    if (!window.gLoading) {
		      window.gLoading = 1;
		      $(this).parent().children("div").before('<div id="galleryLoader">&nbsp;</div>');
			  galleryLoad($(this).parent());
		    }
		});

		resizeImg = function (img, MaxWidth, MaxHeight)	{
            var widthRatio = img.width / MaxWidth;
            var heightRatio = img.height / MaxHeight;
            var ratio = Math.max(widthRatio, heightRatio);
            img.width = Math.floor(img.width / ratio);
           	img.height = Math.floor(img.height / ratio);
            return img;
		}

		galleryShow = function () {
			galleryLoader();
			$("#galleryTable").css({ opacity: 0, display: "block" }).stop().animate({ opacity: 1 });
		}

		galleryClose = function (el) {
			clearTimeout(gallery_slideTimer);
		    $("#galleryPrev").remove();
		    $("#galleryNext").remove();
		    $("#galleryLoader").remove();

		    if (!checkIE()) {
			    $("#galleryClose, #gallerySlideBtn, #gallerySlider").stop().animate({ opacity: 0 }, 100, function() {
	                $("#galleryClose, #gallerySlideBtn, #gallerySlider").remove();
			    });
		    } else {
		    	$("#galleryClose, #gallerySlideBtn, #gallerySlider").remove();
		    }

		    $("#galleryImageContainer").stop().animate({ opacity: 0 }, 400, "linear", function() {
		        $("#galleryImageContainer").remove();
		        if (el == "next" || el == "prev") {
		           galleryLoadPage(el);
		        } else if (el) {
        	       window.gLoading = 1;
                   $(el).children("div").before('<div id="galleryLoader">&nbsp;</div>');
        	       galleryLoad($(el));
		        } else {
		        	$("object").css({ visibility: "visible" });
		        	gallery_slideshow = 0;
		        	$("#fullPageOverlay").stop().animate({ opacity: 0 }, 200, "swing", function() {
		        		$("#fullPageOverlay").remove();
		        	});
		        }
		    });

		}

		galleryLoadPage = function (str) {
		    var el = (str=="next")?$("#paginationNext"):$("#paginationPrev");
		    var href = el.attr('href').replace($.base,'');
			if (!$.wbAjaxLock) {
			  	loading(1);
				$.wbAjaxLock = 1;
				$("#mainContent").load($.base+href+"?ajax=true", function (){
					setRemoteLinks();
					$.wbAjaxLock = 0;
					loading(0);
					(str=="next")?galleryLoad($(".gallery_image:first")):galleryLoad($(".gallery_image:last"));
				});
			}
		}

		galleryNextSlide = function () {
			if (gallery_slideshow && gallery_nextEl.next(".gallery_image").length)
				galleryClose(gallery_nextEl.next(".gallery_image"));
		}

		galleryStartSlide = function (el, width) {
			gallery_slideshow = 1;
			jQuery.easing.def = "easeOutCubic";
			$("#gallerySlideBtn").addClass("gallerySlideStop");
			$("#gallerySlider").stop().animate({ width: (width-20)+"px" }, 5000);
			gallery_nextEl = el;
			gallery_slideTimer = setTimeout("galleryNextSlide();", 5000);
		}

		galleryStopSlide = function () {
			clearTimeout(gallery_slideTimer);
			gallery_slideshow = 0;
			jQuery.easing.def = "jswing";
			$("#gallerySlideBtn").removeClass("gallerySlideStop");
			$("#gallerySlider").stop().animate({ width: 0 });
		}

		galleryLoad = function (el) {
			$("object").css({ visibility: "hidden" });
			if (!$("#fullPageOverlay").length) {
				$("body").prepend("<div id='fullPageOverlay' style='position: absolute; left: 0; z-index: 10000; top: 0; width: 100%; height: "+$(document).height()+"px; opacity: 0; background-color: black; display: none;'>&nbsp;</div>");
				$("#fullPageOverlay").css({ opacity: 0, display: 'block' }).animate({ opacity: 0.5 }, 200);
				$("#fullPageOverlay").click(function(){galleryClose()});
			}

			offsets = el.offset();

            var left = offsets.left;
            var top = offsets.top;
			var image = el.children("a").attr("rel");
			var imageOri = el.children("a").attr("rev");
            //var image = $.base + el.children("a").attr("rel") + "_large/" + el.children("a").attr("title");
            //var imageOri = $.base + el.children("a").attr("rel") + el.children("a").attr("title");
            var title = el.children("a").children("img:eq(1)").attr("alt");

			img = new Image();

		    img.onload=function (){
		      window.gLoading = 0;
		      $("#galleryLoader").remove();
		      var width = 0;
		      var height = 0;
		      width = img.width;
		      height = img.height;
			  img = resizeImg(img,150,150);

			  if (img.width < 150) {
			  	left += Math.floor((150-img.width)/2);
			  }

    		  if (img.height < 150) {
    		  	top += Math.floor((150-img.height)/2);
    		  }

		      $("body").prepend("<div id='galleryImageContainer' style='position: absolute; display: none; left: "+left+"px; top: "+top+"px;'><img id='galleryImage' style='width: "+img.width+"px; height: "+img.height+"px' src='"+image+"' alt='' /><div id='galleryDesc'>"+(title?title:"")+"<br /><a id='galleryFullImage' href='"+imageOri+"' target='_blank'></a></div></div>");

              $("#galleryImageContainer").css({ display: "block", opacity: 0 });

		      var targetLeft = Math.floor($(window).width()/2) - Math.floor(width/2);
		      var targetTop  = $(window).scrollTop() + Math.floor($(window).height()/2) - Math.floor(height/2);

		      jQuery.easing.def = "easeInOutQuart";

		      $("#galleryImageContainer").animate({ opacity: 1, left: targetLeft, top: targetTop },500,"swing");
		      $("#galleryImage").animate({ width: width, height: height },500,"swing", function () {
		      	jQuery.easing.def = "easeOutQuad";

		        $("#galleryDesc").css({ width: width+"px", display: "block", opacity: 0 }).animate({ opacity: 1 });

		        $("body").prepend("<div id='galleryClose' style='left: "+(targetLeft-10)+"px; top: "+(targetTop-10)+"px'></div>");
		        $("body").prepend("<div id='gallerySlideBtn' style='left: "+(targetLeft+4)+"px; top: "+(targetTop-9)+"px'></div>");
		        $("body").prepend("<div id='gallerySlider' style='left: "+(targetLeft+31)+"px; top: "+(targetTop+3)+"px'></div>");
		        $("body").prepend("<div id='galleryPrev'  style='left: "+targetLeft+"px; top: "+targetTop+"px; width: "+Math.floor(width/2)+"px; height: "+height+"px;'>&nbsp;</div>");
		        $("body").prepend("<div id='galleryNext'  style='left: "+(targetLeft+Math.floor(width/2)+5)+"px; top: "+targetTop+"px; width: "+Math.floor(width/2)+"px; height: "+height+"px;'>&nbsp;</div>");

		        $("#galleryPrev, #galleryNext").css({ display: "block", opacity: 0 });

		        $("#gallerySlideBtn").hover(
		        	function(){
		        		$(this).stop().animate({ left: targetLeft + 13 + "px" });
		        	},
		        	function(){
		        		$(this).stop().animate({ left: targetLeft + 3 + "px" });
		        	}
		        );

		        $("#gallerySlideBtn").click(function(){
		        	if (gallery_slideshow) 	galleryStopSlide();
		        	else 					galleryStartSlide(el, width);
		        });

		        if (el.prev(".gallery_image").length || $("#paginationPrev").length ) {
		            $("#galleryPrev").css({ display: "block", opacity: 0, cursor: "pointer" });
    		        $("#galleryPrev").hover(
    		          function(){
    		              $(this).stop().animate({ opacity: 1 });
    		          },
    		          function(){
    		              $(this).stop().animate({ opacity: 0 });
    		          }
    		        );

    		        $("#galleryPrev").click(function(){
    		              if (el.prev(".gallery_image").length) {
    		                  galleryClose(el.prev(".gallery_image"));
    		              } else {
    		                  galleryClose("prev");
    		              }
    		        });
		        }

		        if (el.next(".gallery_image").length || $("#paginationNext").length) {
		            $("#galleryNext").css({ display: "block", opacity: 0, cursor: "pointer" });
    		        $("#galleryNext").hover(
    		          function(){
    		              $(this).stop().animate({ opacity: 1 });
    		          },
    		          function(){
    		              $(this).stop().animate({ opacity: 0 });
    		          }
    		        );

    		        $("#galleryNext").click(function(){
    		              if (el.next(".gallery_image").length) {
    		                  galleryClose(el.next(".gallery_image"));
    		              } else {
    		                  galleryClose("next");
    		              }
    		        });
		        }

				if (!checkIE()) $("#galleryClose, #gallerySlideBtn").css({ display: "block", opacity: 0 }).animate({ opacity: 1 });
				else $("#galleryClose, #gallerySlideBtn, #gallerySlider").css({ display: "block" });

		        $("#galleryClose").click(function(){
		          galleryClose();
		        });

		        if (gallery_slideshow) galleryStartSlide(el, width);

				if ((typeof disableSlideshow != "undefined")
					&& (typeof disableSlideshow != "null")
					&& (disableSlideshow === true)) {
					$("#gallerySlider").hide();
					$("#gallerySlideBtn").hide();
				} else {
					$("#gallerySlider").show();
					$("#gallerySlideBtn").show();
				}

				if ((typeof disableFull != "undefined")
					&& (typeof disableFull != "null")
					&& (disableFull === true)) {
					$("#galleryFullImage").hide();
				} else {
					$("#galleryFullImage").show();
				}

		      });
		    }
		    img.src = image;
		}
	}

	initWbPage();
});


// Google Search engine
if (typeof google !== "undefined") {
	google.load('search', '1');
	function OnLoad() {
		// create a search control
		var searchControl = new google.search.SearchControl();
		searchControl.setLinkTarget(google.search.Search.LINK_TARGET_SELF);
		searchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);
		searchControl.setSearchCompleteCallback(null, function() {
			$("#searchContent a.gs-title").each(function() {
				$this = $(this);
				if (!$this.hasClass("remote")) $this.addClass("remote");
				$this.attr("href", $this.attr("href").replace("#", ""));
			});

			$("#searchContent").show();
			setRemoteLinks("#searchContent");
		});

		var drawOptions = new google.search.DrawOptions();
		drawOptions.setSearchFormRoot(document.getElementById("searchBox"));
		drawOptions.setDrawMode(GSearchControl.DRAW_MODE_TABBED);

		var searcher = new google.search.WebSearch();
		var searcherOptions = new google.search.SearcherOptions();
		searcherOptions.setExpandMode(google.search.SearchControl.EXPAND_MODE_OPEN);
		searcher.setSiteRestriction("009507706445901008216:r52vwhvjpdo");
		searcher.setUserDefinedLabel("Keresési találatok az oldalon");
		searchControl.addSearcher(searcher, searcherOptions);

		searchControl.draw(document.getElementById("searchContent"), drawOptions);

		$("input.gsc-search-button").val("");
	}
	google.setOnLoadCallback(OnLoad, true);
}
