$(window).load(function () {	equalHeight($(".puff-start"));	equalHeight($(".puff-drink"));	equalHeight($("#page-content .column"));});	$(document).ready(function () {						initMenus();			$('#loading').html('<p>Laddar...</p>');		$('#loading').hide();		$('#random_recipe').hide();				$.history.init(pageload);		    		//highlight the selected link		$('a[href=' + document.location.hash + ']').addClass('selected');				//Seearch for link with REL set to ajax		$('a[rel=ajax]').click(function () {						//grab the full url			var hash = this.href;						//remove the # value			hash = hash.replace(/^.*#/, '');						//for back button		 	$.history.load(hash);			 			 	//clear the selected class and add the class class to the selected link		 	$('a[rel=ajax]').removeClass('selected');		 	$(this).addClass('selected');		 			 	//hide the content and show the progress bar		 	$('#show_recipe').hide();		 	$('#loading').show();		 			 	//run the ajax			getPage();					//cancel the anchor tag behaviour			return false;		});					$('.popup').modalPanel();		$('.popup').click(function () {			var id = $(this).attr('rel');		 	//hide the content and show the progress bar		 	$('#show_recipe').hide();		 	$('#loading').show();		 	//run the ajax			getRecipe(id);			//cancel the anchor tag behaviour			return false;		});				$("#recipe-dropdown").change(function () {          var str = "";          var category = "";          $("#recipe-dropdown option:selected").each(function () {                str += $(this).text() + " ";                category += $(this).val();          });          //$("#recipe-list-all").text(str);          if (category != '') {          	getCat(category);          }                  })        .change();			});				function pageload(hash) {		//if hash value exists, run the ajax		if (hash) {			$('#random_recipe').hide();			$('#loading').show();			getPage();		} else {			$('#random_recipe').show();			$('#show_recipe').hide();		}	}				function getPage() {		var url = document.location.hash;		var hash = url.replace(/^.*#/, '');				$("#show_recipe").load("http://jokk.se/ajax/", {id: hash}, function(){			$('#loading').hide();			$('#random_recipe').hide();			$('#show_recipe').fadeIn().show();		});	}		function getRecipe(id) {		var loading = $("<div id='loading'>Laddar...</div>");		var modalWindow = $("<div id='popup_recipe'><div id='close'><a id='popup_close' href='#'><span>Stäng</span></a></div><div id='popup_content'><div id='loading'>Laddar...</div></div></div>");		$("body").append(modalWindow);		//$(modalWindow).append(loading);		$(modalWindow).css({top: getPageScroll()[1] + (getPageHeight() / 6) });			$("#popup_content").load("http://jokk.se/ajax/", {id: id}, function(){			$(loading).hide().empty();			$('#popup_content').show();		});	}	function initMenus() {		$('ul.menu ul').hide();		$.each($('ul.menu li'), function(){			$('.expandfirst ul:first').show();		});		$('ul.menu li a').click(			function() {				var checkElement = $(this).next();				//var parent = this.parentNode.parentNode.id;				var menu = $(this).closest('ul.menu')[0];				var parent = $(menu).attr('id')					if($('#' + parent).hasClass('noaccordion')) {					$(this).next().slideToggle('normal');					return false;				}				if((checkElement.is('ul')) && (checkElement.is(':visible'))) {					if($('#' + parent).hasClass('collapsible')) {						$('#' + parent + ' ul:visible').slideUp('normal');					}					return false;				}				if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {					$('#' + parent + ' ul:visible').slideUp('normal');					$('#' + parent + ' ul:visible').parent('li').removeClass('selected-list');					checkElement.slideDown('normal');					checkElement.parent('li').addClass('selected-list');					return false;				}			}		);	}		function getCat(id) {		//$('#recipe-list-all').empty();		$("#recipe-list-all").load("http://jokk.se/ajax/", {cat: id}, function(){			$('#recipe-list-all').show();		});	}(function($){    $.fn.extend({      modalPanel: function() {          //Create our overlay object          var overlay = $("<div id='modal-overlay'></div>");          return this.each(function() {                      //Listen for clicks on objects passed to the plugin              $(this).click(function(e) {                  //Append the overlay to the document body                  $("body").append(overlay.click(function() {                       modalHide();                   }))                                    	$('#popup_close').live("click", function () {						modalHide();						return false;					});                  //Set the css and fade in our overlay                  overlay.css("opacity", 0.5);                  overlay.fadeIn(150);                  //Prevent the anchor link from loading                  e.preventDefault();                  //Activate a listener                   $(document).keydown(handleEscape);		              });          });          //Our function for hiding the modalbox         function modalHide() {			$(document).unbind("keydown", handleEscape)			var remove = function() { $(this).remove(); };			overlay.fadeOut(remove);			$("#loading").hide().empty();			$("#popup_recipe").hide().remove();		}          //Our function that listens for escape key.          function handleEscape(e) {                      if (e.keyCode == 27) {                              modalHide();              }          }      }  });})(jQuery);function equalHeight(group) {	tallest = 0;	group.each(function() {		thisHeight = $(this).height();		if(thisHeight > tallest) {			tallest = thisHeight;		}	});	group.height(tallest);}// getPageScroll() by quirksmode.comfunction getPageScroll() {    var xScroll, yScroll;    if (self.pageYOffset) {      yScroll = self.pageYOffset;      xScroll = self.pageXOffset;    } else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict      yScroll = document.documentElement.scrollTop;      xScroll = document.documentElement.scrollLeft;    } else if (document.body) {// all other Explorers      yScroll = document.body.scrollTop;      xScroll = document.body.scrollLeft;	    }    return new Array(xScroll,yScroll) }// Adapted from getPageSize() by quirksmode.comfunction getPageHeight() {    var windowHeight    if (self.innerHeight) {	// all except Explorer      windowHeight = self.innerHeight;    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode      windowHeight = document.documentElement.clientHeight;    } else if (document.body) { // other Explorers      windowHeight = document.body.clientHeight;    }	    return windowHeight}