var jkmegamenu={effectduration:10,delaytimer:200,megamenulabels:[],megamenus:[],zIndexVal:1000,$shimobj:null,addshim:function(a){a(document.body).append('<IFRAME id="outlineiframeshim" src="'+(location.protocol=="https:"?"blank.htm":"about:blank")+'" style="display:none; left:0; top:0; z-index:999; position:absolute; filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)" frameBorder="0" scrolling="no"></IFRAME>');this.$shimobj=a("#outlineiframeshim")},alignmenu:function(d,g,a){var f=this.megamenus[a];var c=f.$anchorobj;var b=f.$menuobj;var i=(d(window).width()-(f.offsetx-d(document).scrollLeft())>f.actualwidth)?f.offsetx:f.offsetx-f.actualwidth+f.anchorwidth;var h=f.offsety+f.anchorheight;b.css({left:i+"px",top:h+"px"});this.$shimobj.css({width:f.actualwidth+"px",height:f.actualheight+"px",left:i+"px",top:h+"px",display:"block"})},showmenu:function(f,a){var d=this.megamenus[a];var c=d.$menuobj;var b=d.$menuinner;if(c.css("display")=="none"){this.alignmenu(jQuery,f,a);c.css("z-index",++this.zIndexVal);c.show(this.effectduration,function(){b.css("visibility","visible")})}else{if(c.css("display")=="block"&&f.type=="click"){this.hidemenu(f,a)}}return false},hidemenu:function(f,a){var d=this.megamenus[a];var c=d.$menuobj;var b=d.$menuinner;b.css("visibility","hidden");this.$shimobj.css({display:"none",left:0,top:0});c.hide(this.effectduration)},definemenu:function(a,b,c){this.megamenulabels.push([a,b,c])},render:function(b){for(var a=0,d=this.megamenulabels[a];a<this.megamenulabels.length;a++,d=this.megamenulabels[a]){if(b("#"+d[0]).length!=1||b("#"+d[1]).length!=1){return}this.megamenus.push({$anchorobj:b("#"+d[0]),$menuobj:b("#"+d[1]),$menuinner:b("#"+d[1]).children("ul:first-child"),revealtype:d[2],hidetimer:null});var c=this.megamenus[a];c.$anchorobj.add(c.$menuobj).attr("_megamenupos",a+"pos");c.actualwidth=c.$menuobj.outerWidth();c.actualheight=c.$menuobj.outerHeight();c.offsetx=c.$anchorobj.offset().left;c.offsety=c.$anchorobj.offset().top;c.anchorwidth=c.$anchorobj.outerWidth();c.anchorheight=c.$anchorobj.outerHeight();b(document.body).append(c.$menuobj);c.$menuobj.css("z-index",++this.zIndexVal).hide();c.$menuinner.css("visibility","hidden");c.$anchorobj.bind(c.revealtype=="click"?"click":"mouseenter",function(f){var g=jkmegamenu.megamenus[parseInt(this.getAttribute("_megamenupos"))];clearTimeout(g.hidetimer);return jkmegamenu.showmenu(f,parseInt(this.getAttribute("_megamenupos")))});c.$anchorobj.bind("mouseleave",function(f){var g=jkmegamenu.megamenus[parseInt(this.getAttribute("_megamenupos"))];if(f.relatedTarget!=g.$menuobj.get(0)&&b(f.relatedTarget).parents("#"+g.$menuobj.get(0).id).length==0){g.hidetimer=setTimeout(function(){jkmegamenu.hidemenu(f,parseInt(g.$menuobj.get(0).getAttribute("_megamenupos")))},jkmegamenu.delaytimer)}});c.$menuobj.bind("mouseenter",function(f){var g=jkmegamenu.megamenus[parseInt(this.getAttribute("_megamenupos"))];clearTimeout(g.hidetimer)});c.$menuobj.bind("click mouseleave",function(f){var g=jkmegamenu.megamenus[parseInt(this.getAttribute("_megamenupos"))];g.hidetimer=setTimeout(function(){jkmegamenu.hidemenu(f,parseInt(g.$menuobj.get(0).getAttribute("_megamenupos")))},jkmegamenu.delaytimer)})}if(/Safari/i.test(navigator.userAgent)){b(window).bind("resize load",function(){for(var e=0;e<jkmegamenu.megamenus.length;e++){var g=jkmegamenu.megamenus[e];var f=(g.$anchorobj.children().length==1&&g.$anchorobj.children().eq(0).is("img"))?g.$anchorobj.children().eq(0):null;if(f){g.offsetx=f.offset().left;g.offsety=f.offset().top;g.anchorwidth=f.width();g.anchorheight=f.height()}}})}else{b(window).bind("resize",function(){for(var e=0;e<jkmegamenu.megamenus.length;e++){var f=jkmegamenu.megamenus[e];f.offsetx=f.$anchorobj.offset().left;f.offsety=f.$anchorobj.offset().top}})}jkmegamenu.addshim(b)}};jQuery(document).ready(function(a){jkmegamenu.render(a)});