/*!
 * HTML 5 Page Menu
 *
 * Copyright 2011, http://webworld-develop.blogspot.com/
 * Artistic License 2.0
 * http://www.opensource.org/licenses/artistic-license-2.0
 *
 * Date: 5/26/2011
**/
// button delcaration examle
// { id:null, imagePath: null, text: 'msg', className:'', href:null, click:null, dataProvider: function(callback) {}, externalUrl:null }

(function($){var l={location:"top",customOffset:null,buttons:new Array(),innerHtml:null,imagePath:"",dynamicContent:false,maxHeight:460,openDefault:false,onShowMenu:function(){},onHideMenu:function(){}};var m=[{location:"top",arrow:"/images/v2/build/arrow_bottom.png",arrowOff:"/images/v2/build/arrow_top.png",cssClass:"wwtop",showMenuBeforeButton:false,offset:{top:0,left:'46%'},onanimation:function(e,a){$(e).slideDown("fast",a)},offanimation:function(e,a){$(e).slideUp("fast",a)}},{location:"bottom",arrow:"/images/v2/build/arrow_top.png",arrowOff:"/images/v2/build/arrow_bottom.png",cssClass:"wwbottom",showMenuBeforeButton:true,offset:{bottom:0,left:'60%'},onanimation:function(e,a){$(e).slideDown("fast",a)},offanimation:function(e,a){$(e).slideUp("fast",a)}},{location:"left",arrow:"/images/v2/build/arrow_right.png",arrowOff:"/images/v2/build/arrow_left.png",cssClass:"wwleft",showMenuBeforeButton:false,offset:{top:'10%',left:0},onanimation:function(e,a){$(e).show("fast",a)},offanimation:function(e,a){$(e).hide("fast",a)}},{location:"right",arrow:"/images/v2/build/arrow_left.png",arrowOff:"/images/v2/build/arrow_right.png",cssClass:"wwright",showMenuBeforeButton:false,offset:{top:'10%',right:0},onanimation:function(e,a){$(e).show("fast",a)},offanimation:function(e,a){$(e).hide("fast",a)}}];var n={getLocationHelper:function(){var a=m[0];$.each(m,function(i,v){if(v.location==l.location){a=v;return}});return a},buildMenuButtons:function(){var b="<strong style='color:#FFF;background-color:red;'>Incorrect menu data!</strong>";if(l.innerHtml&&l.innerHtml!=""){b=l.innerHtml}else if(l.buttons&&l.buttons.length>0){b="<ul class='actionButtons'>";$.each(l.buttons,function(i,v){var a=(v.className&&v.className!="")?"class='"+v.className+"' ":"";v.href=(v.href&&v.href!=""&&v.href!="#")?v.href:"javascript:void(0);";b+="<li><a id='"+v.id+"' href='"+v.href+"' "+a+" >";b+=(v.imagePath)?"<img src='"+v.imagePath+"' alt='"+v.text+"' />":v.text;b+="</a></li>"});b+="</ul>"}return b},createMainMenuContainer:function(a){var b=$("<div id='wwmenu'></div>").appendTo($("body")).addClass(a.cssClass);var c=$("<div class='menuContent'>"+n.buildMenuButtons()+"</div>").appendTo(b);if(l.dynamicContent){c.append("<div class='wwloader'><img src='"+l.imagePath+"loading.gif' alt='loading...' /></div>");c.append("<div class='wwtabcontent'></div>");c.append("<a class='wwclosebutton' href='javascript:$.WwAdvMenu.HideMenuContent();' style='display:none;'></a>")}if(a.showMenuBeforeButton){b.prepend("<a class='slider'><img src='"+l.imagePath+a.arrow+"' alt='' /></a>")}else{b.append("<a class='slider'><img src='"+l.imagePath+a.arrow+"' alt='' /></a>")}if(l.customOffset){a.offset=l.customOffset}a.offset=n.fixDefaulOffset(a.offset);if(a.offset.top){b.css("top",a.offset.top)}if(a.offset.right){b.css("right",a.offset.right)}if(a.offset.bottom){b.css("bottom",a.offset.bottom)}if(a.offset.left){b.css("left",a.offset.left)}return b},getButtonHandler:function(a){var b=null;$.each(l.buttons,function(i,v){if(v.id==a){b=v;return}});return b},loadButtonContent:function(c,d,e,f,g){var h=e.find(".wwtabcontent");var i=e.find(".wwclosebutton");if(d.hasClass("active")&&h.is(":visible")){n.hideMenuContent()}else{c.removeClass("active");var j=e.find(".wwloader");d.addClass("active");h.height("auto");var k=function(){if(f){f(function(a){j.hide();h.html(a);h.show();i.show();n.checkMaxHeight(h)})}else if(g){j.hide();h.html("").show();i.show();var b=$("<iframe id='wwmenuexternal' style='width:365px; height:"+l.maxHeight+"px;' frameborder='0' >").appendTo(h);b.attr("src",g)}};if(h.is(":visible")){h.hide();j.show();k()}else{j.slideDown("fast",k)}}},hideMenuContent:function(){var a=$("#wwmenu");a.find("ul.actionButtons").find("a").removeClass("active");a.find(".wwtabcontent").slideUp("fast");a.find(".wwclosebutton").hide()},udpateContent:function(a){var b=$("#wwmenu").find(".wwtabcontent");b.html(a);n.checkMaxHeight(b)},checkMaxHeight:function(a){if(a.height()>l.maxHeight){a.height(l.maxHeight)}},fixDefaulOffset:function(a){if(typeof(a.top)!="undefined"&&a.top==0){a.top="0px"}if(typeof(a.right)!="undefined"&&a.right==0){a.right="0px"}if(typeof(a.bottom)!="undefined"&&a.bottom==0){a.bottom="0px"}if(typeof(a.left)!="undefined"&&a.left==0){a.left="0px"}return a},toggle:function(a){var b=$("#wwmenu");var c=b.find("a.slider");var d=b.find("div.menuContent");if(a){if(d.is(":visible")){c.click()}}else{if(!d.is(":visible")){c.click()}}}};var o={init:function(h){return $(this).each(function(){if(h){$.extend(l,h)}if(l.buttons&&l.buttons.length>0){for(var i=0;i<l.buttons.length;i++){l.buttons[i].id=(l.buttons[i].id&&l.buttons[i].id!="")?l.buttons[i].id:"wwmenubtn"+i}}var c=n.getLocationHelper();var d=n.createMainMenuContainer(c);var e=d.find("a.slider");var f=d.find("div.menuContent");var g=d.find("ul.actionButtons").find("a");e.click(function(){var a=$(this);if(f.is(":visible")){n.hideMenuContent();c.offanimation(f,function(){a.find("img").attr("src",l.imagePath+c.arrow);l.onHideMenu()})}else{c.onanimation(f,function(){a.find("img").attr("src",l.imagePath+c.arrowOff);l.onShowMenu()})}});if(g.length>0){g.click(function(){var a=$(this);var b=n.getButtonHandler(a.attr("id"));if(b!=null){if(b.click){b.click(a)}if(b.dataProvider||b.externalUrl){n.loadButtonContent(g,a,f,b.dataProvider,b.externalUrl)}}})}if(l.openDefault){e.click()}})}};$.fn.wwAdvMenu=function(a){if(o[a]){return o[a].apply(this,Array.prototype.slice.call(arguments,1))}else if(typeof a==='object'||!a){return o.init.apply(this,arguments)}else{$.error('Method '+a+' does not exist on jQuery.tooltip')}};$.WwAdvMenu={Create:function(a){$("body").wwAdvMenu(a)},HideMenuContent:function(){n.hideMenuContent()},UpdateContent:function(a){n.udpateContent(a)},ToggleContent:function(a){n.toggle(a)},Show:function(){$("#wwmenu").show("fast")},Hide:function(){$("#wwmenu").hide("fast")}}})(jQuery);
