jQuery.fn.supersleight = function(settings) {
	settings = jQuery.extend({
		imgs: true,
		backgrounds: true,
		shim: '/themes/hahnsmarket/images/blank.gif',
		apply_positioning: true
	}, settings);
	
	return this.each(function(){
		if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7 && parseInt(jQuery.browser.version, 10) > 4) {
			jQuery(this).find('*').andSelf().each(function(i,obj) {
				var self = jQuery(obj);
				// background pngs
				if (settings.backgrounds && self.css('background-image').match(/\.png/i) !== null) {
					var bg = self.css('background-image');
					var src = bg.substring(5,bg.length-2);
					var mode = (self.css('background-repeat') == 'no-repeat' ? 'crop' : 'scale');
					var styles = {
						'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + mode + "')",
						'background-image': 'url('+settings.shim+')'
					};
					self.css(styles);
				};
				// image elements
				if (settings.imgs && self.is('img[src$=png]')){
					var styles = {
						'width': self.width() + 'px',
						'height': self.height() + 'px',
						'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + self.attr('src') + "', sizingMethod='scale')"
					};
					self.css(styles).attr('src', settings.shim);
				};
				// apply position to 'active' elements
				if (settings.apply_positioning && self.is('a, input') && (self.css('position') === '' || self.css('position') == 'static')){
					self.css('position', 'relative');
				};
			});
		};
	});
};;
(function($) {
  /*
	 * Animate #top link scroll on click
	 */


	$('.form-error').find('a.scroll[href^="#"]').bind('click.scroll', function(e) {
    var $target = $($(this).attr('href'));
    
    if($target.length > 0) {
      var offsetTop = $target.offset().top;
      $('html, body').animate({scrollTop: offsetTop}, 'slow');
    }
    
		return false;
	});
  
  
	/*
	 * Merge objects
	 */

	var merge = function(slave, master) {
		slave = slave || {};
		master = master || {};

		var newObj = {};

		for(p in slave) {
			newObj[p] = slave[p];
		}for(p in master) {
			newObj[p] = master[p];
		}

		return newObj;
	};

	/*
	 * Key Code Map
	 * Full reference: http://protocolsofmatrix.blogspot.com/2007/09/javascript-keycode-reference-table-for.html
	 */

	KeyCode = {
		// Backspace & Tab
		BACKSPACE: 8,
		TAB: 9,

		// Enter/Return
		ENTER: 13,
		RETURN: 13,

		// Modifier keys
		SHIFT: 16,
		CTRL: 17,
		ALT: 18,

		// Pause/Break
		PAUSE_BREAK: 19,

		// Caps Lock
		CAPS: 20,
		CAPSLOCK: 20,
		CAPS_LOCK: 20,

		// Escape
		ESC: 27,
		ESCAPE: 27,

		// Space
		SPACE: 32,

		// Page Up
		PAGEUP: 33,
		PAGE_UP: 33,

		// Page Down
		PAGEDOWN: 34,
		PAGE_DOWN: 34,

		// Home & End
		END: 35,
		HOME: 36,

		// Arrow keys
		LEFT: 37,
		UP: 38,
		RIGHT: 39,
		DOWN: 40,

		// Insert
		INS: 45,
		INSERT: 45,

		// Delete
		DEL: 46,
		DELETE: 46
	};

	/*
	 * DOM Node emulation for IE
	 */

	if(!window.Node || !window.Node.ELEMENT_NODE) {
		var Node = {
			ELEMENT_NODE: 1, ATTRIBUTE_NODE: 2, TEXT_NODE: 3, CDATA_SECTION_NODE: 4, ENTITY_REFERENCE_NODE: 5,  ENTITY_NODE: 6, PROCESSING_INSTRUCTION_NODE: 7, COMMENT_NODE: 8, DOCUMENT_NODE: 9, DOCUMENT_TYPE_NODE: 10, DOCUMENT_FRAGMENT_NODE: 11, NOTATION_NODE: 12
		};
	}

	/*
	 * String Functions
	 */

	String.prototype.replaceOuter = function(findLeft, findRight, replaceLeft, replaceRight) {
		// Oddly enough, "this" is an Object containing the string's individual characters,
		// so we need to call the this.toString() to get a workable copy of the string.
		var strNew = this.toString();

		// Get the positions of findLeft and findRight
		var leftPos = strNew.indexOf(findLeft);
		var rightPos = strNew.lastIndexOf(findRight);

		if(leftPos > -1 && rightPos > -1) {
			strNew = strNew.substring(0, leftPos) + replaceLeft +
					 strNew.substring(leftPos + findLeft.length, rightPos) + replaceRight +
					 strNew.substring(rightPos + findRight.length, strNew.length);
		}

		return strNew;
	};

	String.prototype.removeOuter = function(strLeft, strRight) {
		return this.replaceOuter(strLeft, strRight, "", "");
	};

	String.prototype.toArray = function() {
		var l = this.length;
		var a = new Array(l);
		for(var i = 0; i < l; i++) {
			a[i] = this.charAt(i);
		}
		return a;
	};

	String.prototype.stripTags = function() {
		return this.replace(/(<([^>]+)>)/ig, '');
	}

	String.prototype.getCurrencies = function() {
		return this.stripTags().match(/\$[0-9]+\.[0-9]{2}/g);
	}

	/*
	 * RegExp functions
	 */

	RegExp.escape = function(text) {
		return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
	}

	/*
	 * Date Functions
	 *
	 * Credit: http://jacwright.com/projects/javascript/date_format
	 */

	// Simulates PHP's date function
	Date.prototype.format = function(format) {
		var returnStr = '';
		var replace = Date.replaceChars;
		for (var i = 0; i < format.length; i++) {
			var curChar = format.charAt(i);
			if (i - 1 >= 0 && format.charAt(i - 1) == "\\") {
				returnStr += curChar;
			}
			else if (replace[curChar]) {
				returnStr += replace[curChar].call(this);
			} else if (curChar != "\\"){
				returnStr += curChar;
			}
		}
		return returnStr;
	};

	Date.replaceChars = {
		shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
		longMonths: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
		shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
		longDays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],

		// Day
		d: function() {return (this.getDate() < 10 ? '0' : '') + this.getDate();},
		D: function() {return Date.replaceChars.shortDays[this.getDay()];},
		j: function() {return this.getDate();},
		l: function() {return Date.replaceChars.longDays[this.getDay()];},
		N: function() {return this.getDay() + 1;},
		S: function() {return (this.getDate() % 10 == 1 && this.getDate() != 11 ? 'st' : (this.getDate() % 10 == 2 && this.getDate() != 12 ? 'nd' : (this.getDate() % 10 == 3 && this.getDate() != 13 ? 'rd' : 'th')));},
		w: function() {return this.getDay();},
		z: function() {var d = new Date(this.getFullYear(),0,1);return Math.ceil((this - d) / 86400000);}, // Fixed now
		// Week
		W: function() {var d = new Date(this.getFullYear(), 0, 1);return Math.ceil((((this - d) / 86400000) + d.getDay() + 1) / 7);}, // Fixed now
		// Month
		F: function() {return Date.replaceChars.longMonths[this.getMonth()];},
		m: function() {return (this.getMonth() < 9 ? '0' : '') + (this.getMonth() + 1);},
		M: function() {return Date.replaceChars.shortMonths[this.getMonth()];},
		n: function() {return this.getMonth() + 1;},
		t: function() {var d = new Date();return new Date(d.getFullYear(), d.getMonth(), 0).getDate()}, // Fixed now, gets #days of date
		// Year
		L: function() {var year = this.getFullYear();return (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0));},	// Fixed now
		o: function() {var d  = new Date(this.valueOf());d.setDate(d.getDate() - ((this.getDay() + 6) % 7) + 3);return d.getFullYear();}, //Fixed now
		Y: function() {return this.getFullYear();},
		y: function() {return ('' + this.getFullYear()).substr(2);},
		// Time
		a: function() {return this.getHours() < 12 ? 'am' : 'pm';},
		A: function() {return this.getHours() < 12 ? 'AM' : 'PM';},
		B: function() {return Math.floor((((this.getUTCHours() + 1) % 24) + this.getUTCMinutes() / 60 + this.getUTCSeconds() / 3600) * 1000 / 24);}, // Fixed now
		g: function() {return this.getHours() % 12 || 12;},
		G: function() {return this.getHours();},
		h: function() {return ((this.getHours() % 12 || 12) < 10 ? '0' : '') + (this.getHours() % 12 || 12);},
		H: function() {return (this.getHours() < 10 ? '0' : '') + this.getHours();},
		i: function() {return (this.getMinutes() < 10 ? '0' : '') + this.getMinutes();},
		s: function() {return (this.getSeconds() < 10 ? '0' : '') + this.getSeconds();},
		u: function() {var m = this.getMilliseconds();return (m < 10 ? '00' : (m < 100 ?
	'0' : '')) + m;},
		// Timezone
		e: function() {return "Not Yet Supported";},
		I: function() {return "Not Yet Supported";},
		O: function() {return (-this.getTimezoneOffset() < 0 ? '-' : '+') + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? '0' : '') + (Math.abs(this.getTimezoneOffset() / 60)) + '00';},
		P: function() {return (-this.getTimezoneOffset() < 0 ? '-' : '+') + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? '0' : '') + (Math.abs(this.getTimezoneOffset() / 60)) + ':00';}, // Fixed now
		T: function() {var m = this.getMonth();this.setMonth(0);var result = this.toTimeString().replace(/^.+ \(?([^\)]+)\)?$/, '$1');this.setMonth(m);return result;},
		Z: function() {return -this.getTimezoneOffset() * 60;},
		// Full Date/Time
		c: function() {return this.format("Y-m-d\\TH:i:sP");}, // Fixed now
		r: function() {return this.toString();},
		U: function() {return this.getTime() / 1000;}
	};

	/*
	 * IE 6-7 :hover fix
	 */

	$(function() {
		if($.browser.msie && $.browser.version <= 7) {
			$('.ie-hover').hover(
				function() {
					$(this).addClass('hover');
				},
				function() {
					$(this).removeClass('hover');
				}
			);
		}
	});

	/*
	 * Button helper functions
	 */

	var $document = $(document);

	var ieSelectStart = function() {
		return false;
	};

	var buttonUpEvent = function() {
		($document
			.unbind('mouseup', buttonUpEvent)
			.data('curButtonDown') || $())
				.removeClass('down')
				.removeClass('keydown');

		document.onselectstart = null;
	};

	var buttonSubmit = function() {
		$(this).closest('.button').find(':submit, :image').closest('form').submit();
	};

	/*
	 * jQuery Extensions
	 */

	jQuery.fn.extend({
		/*
		 * Redraw (IE 5-7)
		 */

		redraw: function() {
			if($.browser.msie && $.browser.version <= 7) {
				var self = this;

				setTimeout(function() {
					self.css('opacity', 0.99).css('opacity', 1);
				}, 50);
			}
		},

		/*
		 * Button
		 */
		makeButton: function(clickEvent) {
			var $buttonContainer = $(this);

			// Sanitize input
			clickEvent = (typeof clickEvent === 'function' ? clickEvent : buttonSubmit);

			// Hide non-JS element
			$buttonContainer.find('.no-js').css('display', 'none');

			// Uncomment JS text
			$buttonContainer.find('.text').each(function(){
				this.innerHTML = $(this).uncommentHTML()
			});

			// Find js element
			var $buttonJS = $buttonContainer.find('.js');

			if($buttonJS.length == 0) {
				$buttonJS = $buttonContainer;
			}

			if(typeof console !== 'undefined' && DEBUG) {
				console.log('$.button called!');
				console.log($buttonJS);
			}

			/*
			 * "If given a [tabIndex] value of 0, the element can be focused via the keyboard and falls into the tabbing flow of the document"
			 * From http://snook.ca/archives/accessibility_and_usability/elements_focusable_with_tabindex
			 */

			$buttonJS
				.attr('tabIndex', 0)
				.addClass('display')
				.hover(function() {$(this).addClass('hover');}, function() {$(this).removeClass('hover');})
				.mousedown(function(event) {
					var $this = $(this);

					$this.focus();
					$this.addClass('down');

					$document.data('curButtonDown', $this);
					$document.bind('mouseup', buttonUpEvent);

					document.onselectstart = ieSelectStart;

					return (event.which === 3);
				}).keydown(function(event) {
					var $this = $(this);

					if(event.keyCode == KeyCode.SPACE || event.keyCode == KeyCode.ENTER) {
						$this.trigger('mousedown', event);
						$document.bind('mouseup', buttonUpEvent);
						$this.addClass('keydown');
					}
				}).keyup(function(event) {
					var $this = $(this);

					if(event.keyCode == KeyCode.SPACE || event.keyCode == KeyCode.ENTER) {
						$document.trigger('mouseup', event);
						$document.bind('mouseup', buttonUpEvent);
						$this.trigger('click', event);
					}
				}).click(clickEvent);

			return $buttonContainer;
		},

		/*
		 * Usage:
		 *
		 * var uncommentedHTML = $('selector').uncommentHTML();
		 *
		 * Example:
		 *
		 * <div id="single-el">
		 *   <!--
		 *     <span class="text">Hello!</span>
		 *   -->
		 * </div>
		 *
		 * <div class="multiple-els">
		 *   <!--
		 *     <span class="text">Hello 1!</span>
		 *   -->
		 * </div>
		 * <div class="multiple-els">
		 *   <!--
		 *     <span class="text">Hello 2!</span>
		 *   -->
		 * </div>
		 *
		 * $('#single-el').uncommentHTML(); // = "<span class="text">Hello!</span>"
		 * $('.multiple-els').uncommentHTML(); // = [ "<span class="text">Hello 1!</span>", "<span class="text">Hello 2!</span>" ]
		 *
		 * .
		 *
		 */
		uncommentHTML: function() {
			var markup = [];

			var uncomment = function(html) {
				var newHTML = html;
					newHTML = newHTML.removeOuter("<!--", "-->");
					newHTML = newHTML.replaceOuter("<!-!-", "-!-!>", "<!--", "-->");

				return newHTML;
			};

			this.each(function() {
				markup.push(this.nodeType == Node.ELEMENT_NODE ? uncomment(this.innerHTML) : this);
			});

			if(markup.length == 0) {
				markup = '';
			} else if(markup.length == 1) {
				markup = markup[0];
			}

			return markup;
		},

		uncomment: function() {
			return $(this.uncommentHTML());
		},

		/*
		 * Usage:
		 *   $('selector').placehold( [value], [options] )
		 */
		placehold: function() {
			var defaultOptions = {
				select: false,
				placeholderClass: 'placeheld',
				focusClass: 'focus',
				blurClass: 'blur'
			};

			var arg, options = {};

			if(jQuery.isPlainObject(arguments[0])) {
				options = arguments[0];
			}
			else {
				arg = arguments[0];
				options = arguments[1];
			}

			options = jQuery.extend({}, defaultOptions, options);

			// Remove any existing placeholder event handlers
			this.unbind('.placehold');

			// Detect native browser support for the HTML5 placeholder attribute
			var nativeSupport = 'placeholder' in document.createElement('input');

			this.each(function() {
				var $this = $(this);

				// Get placeholder text
				var placeholder = arg || $this.attr('placeholder') || $this.attr('alt') || $this.val() || '';

				// Store placeholder text
				$this.data('placeholder', placeholder);

				// Reset number of clicks
				$this.data('clicks', 0);
			}).bind('focus.placehold', function(event, data) {
				var $this = $(this);

				data = data || {};

				data.select = data.select || options.select;

				if($this.val() == $this.data('placeholder') && !data.disabled && !data.select && !nativeSupport) {
					$this.val('');
				}

				if(data.select) {
					$this.select();
				}

				$this.removeClass(options.placeholderClass + ' ' + options.blurClass).addClass(options.focusClass);
			}).bind('blur.placehold init.placehold', function(event, data) {
				var $this = $(this);

        if($this.data('disablePlaceholder'))
          return;

				if(($this.val() || '').length == 0 || $this.val() == $this.data('placeholder')) {
					if(!nativeSupport) {
						$this.val($this.data('placeholder'));
					}
					$this.addClass(options.placeholderClass);
				}
				else {
					$this.removeClass(options.placeholderClass);
				}

				$this.removeClass(options.focusClass).addClass(options.blurClass);

				$this.data('clicks', 0);
			}).bind('mouseup.placehold', function(event, data) {
				var $this = $(this);

				if($this.val() == $this.data('placeholder')) {
					if(($this.data('clicks') || 0) <= 0) {
						event.preventDefault();
						$this.focus();
					}
				}

				$this.data('clicks', $this.data('clicks') + 1);
			}).trigger('init');

			return this;
		},

		isPlaceholderValue: function() {
			return (this.data('placeholder') && this.val() == this.data('placeholder'));
		},

		hasVal: function() {
			return !(/^$/.test(this.val()) || this.isPlaceholderValue());
		},

		placeholderVal: function() {
			return (this.hasVal() ? this.val() : '');
		},

		placeholderSerialize: function() {
			return jQuery.param(this.placeholderSerializeArray());
		},

		placeholderSerializeArray: function() {
			var rselectTextarea = /select|textarea/i;
			var rinput = /color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i;

			return this.map(function() {
				return this.elements ? jQuery.makeArray(this.elements) : this;
			})
			.filter(function() {
				return this.name && !this.disabled &&
					(this.checked || rselectTextarea.test(this.nodeName) ||
						rinput.test(this.type));
			})
			.map(function( i, elem ) {
				var val = jQuery(this).placeholderVal();

				return val == null ?
					null :
					jQuery.isArray(val) ?
						jQuery.map( val, function( val, i ) {
							return {name: elem.name, value: val};
						}) :
						{name: elem.name, value: val};
			}).get();
		},

		equals: function(that) {
			var $that = $(that);

			var equal = false;

			if(this.length == $that.length) {
				equal = true;

				this.each(function(index, el) {
					equal &= (el === $that.get(index));
				});
			}

			return equal;
		}
	});
  
  
  /*
   * Initialize Placeholder Fields
   */
  
  $('input, textarea').not(':password, :radio, :checkbox, :submit, :button, :reset, :image, :file, :hidden').placehold();
  
  $('form').bind('submit', function() {
    var $form = $(this);
    
    $form.find('input, textarea').not(':password, :radio, :checkbox, :submit, :button, :reset, :image, :file, :hidden').each(function(index, el) {
      var $el = $(el);
      
      if($el.isPlaceholderValue()) {
        $el.val('').data('disablePlaceholder', true);
      }
    })
  });
  
  
})(jQuery);;
(function($) {
	$(function() {
		$('.ie-lte-6 .nice-menu > li').hover(
			function(){
				$(this).addClass('hover');
			},
			function(){
				$(this).removeClass('hover');
			}
		);

		if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7 && parseInt(jQuery.browser.version, 10) > 4) {
			$('#header').find('img').attr('src', '/themes/hahnsmarket/logo.ie.png');
		}
		
	});
})(jQuery);;
jQuery(function() {
	var $ = jQuery;
	var $document = $(document);

	var $loginBox = $('#block-user-login .content');
	    $loginBox.attr('id', 'login-box');

	$loginBox.append($('<span class="center-corner-rotate"/>'));

	var focusFn = function() {
		$loginBox.find('#edit-name').focus();
	};

	var clickFn = function(event) {
		if($(event.target).closest('#login-box').length == 0) {
			$loginBox.trigger('hide');
		}
	};

	var keydownFn = function(event) {
		if(event.keyCode === KeyCode.ESC) {
			$loginBox.trigger('hide');
		}
	};

	$loginBox.bind('show', function() {
		$loginBox.css('top', '-' + ($loginBox.outerHeight() + 10) + 'px');
		$loginBox.css('left', '-' + ($loginBox.width() / 2) + 'px');

		$loginBox.fadeIn('fast', focusFn);

		$document.bind('click.hideLoginBox', clickFn);
		$document.bind('keydown.hideLoginBox', keydownFn);
	});

	$loginBox.bind('hide', function() {
		$loginBox.fadeOut('fast');

		$document.unbind('.hideLoginBox');
	});

	function toggleLoginBox() {
		if($loginBox.css('display') == 'none') {
			$loginBox.trigger('show');
		}
		else {
			$loginBox.trigger('hide');
		}

		return false;
	}

	$('#block-user-login h2')
		.bind('click', toggleLoginBox)
		.bind('keydown', function(event) {
			if(event.keyCode === KeyCode.ENTER) {
				toggleLoginBox();
			}
		})
		.attr('tabindex', '');
});;

