/*
 * Supposition v0.2 - an optional enhancer for Superfish jQuery menu widget
 *
 * Copyright (c) 2008 Joel Birch - based mostly on work by Jesse Klaasse and credit goes largely to him.
 * Special thanks to Karl Swedberg for valuable input.
 *
 * Dual licensed under the MIT and GPL licenses:
 * 	http://www.opensource.org/licenses/mit-license.php
 * 	http://www.gnu.org/licenses/gpl.html
 */
(function(a){a.fn.supposition=function(){var f=a(window),d=function(g){return window[g=="y"?"pageYOffset":"pageXOffset"]||document.documentElement&&document.documentElement[g=="y"?"scrollTop":"scrollLeft"]||document.body[g=="y"?"scrollTop":"scrollLeft"]},e=function(){$topNav=a("li",this);var g=parseInt($topNav.css("z-index"))+$topNav.length;$topNav.each(function(){a(this).css({zIndex:--g})})},c=function(){this.css({marginTop:"",marginLeft:""})},b=function(){this.each(function(){var l=a(this);l.css("display","block");var m=l.width(),p=l.parents("ul").width(),i=f.width()+d("x"),k=l.offset().left+m;if(k>i){l.css("margin-left",(l.parents("ul").length==1?i-k:-(m+p))+"px")}var g=f.height(),h=l.offset().top,j=l.height(),o=g+d("y");var n=(h+j>o);if(n){l.css("margin-top",o-(j+h))}l.css("display","none")})};return this.each(function(){var j=a.fn.superfish.o[this.serial];var g=j.onInit,h=j.onBeforeShow,i=j.onHide;a.extend(a.fn.superfish.o[this.serial],{onInit:function(){e.call(this);g.call(this)},onBeforeShow:function(){b.call(this);h.call(this)},onHide:function(){c.call(this);i.call(this)}})})}})(jQuery);