/* Copyright 2009 Simply Extras Ltd */
var g_menu;function g_menu_init(b,a){g_menu=new DynamicMenu(b,a);g_menu.init()}function DynamicMenu(d,a){var c=this;c.gosajax=new GOSAjax("/menu_ajax.php");c.selected_menu=d;c.selected_submenu=a;c.init=function(){c.gosajax.call("fetch_menu",[c.selected_menu,c.selected_submenu],b)};function b(f,g,h){var i="";var e=0;if(g==-1){i="Sorry, the request to fetch the top navigation menu timed out."}if(g==0){i="Sorry, there was an error fetching the top navigation menu."}if(i==""){document.getElementById("dynamicmenuwrapper").innerHTML=f;tabdropdown.init("dynamicmenu",c.selected_menu)}i="";GOSAjax.done(i)}}var tabdropdown={disappeardelay:200,disablemenuclick:false,enableiframeshim:1,dropmenuobj:null,ie:document.all,firefox:document.getElementById&&!document.all,previousmenuitem:null,currentpageurl:window.location.href.replace("http://"+window.location.hostname,"").replace(/^\//,""),getposOffset:function(d,c){var b=(c=="left")?d.offsetLeft:d.offsetTop;var a=d.offsetParent;while(a!=null){b=(c=="left")?b+a.offsetLeft:b+a.offsetTop;a=a.offsetParent}return b},showhide:function(c,b,a){if(this.ie||this.firefox){this.dropmenuobj.style.left=this.dropmenuobj.style.top="-500px"}if(b.type=="click"&&c.visibility==hidden||b.type=="mouseover"){if(a.parentNode.className.indexOf("default")==-1){a.parentNode.className="selected"}c.visibility="visible"}else{if(b.type=="click"){c.visibility="hidden"}}},iecompattest:function(){return(document.compatMode&&document.compatMode!="BackCompat")?document.documentElement:document.body},clearbrowseredge:function(e,c){var b=0;if(c=="rightedge"){var d=this.ie&&!window.opera?this.standardbody.scrollLeft+this.standardbody.clientWidth-15:window.pageXOffset+window.innerWidth-15;this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetWidth;if(d-this.dropmenuobj.x<this.dropmenuobj.contentmeasure){b=this.dropmenuobj.contentmeasure-e.offsetWidth}}else{var a=this.ie&&!window.opera?this.standardbody.scrollTop:window.pageYOffset;var d=this.ie&&!window.opera?this.standardbody.scrollTop+this.standardbody.clientHeight-15:window.pageYOffset+window.innerHeight-18;this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetHeight;if(d-this.dropmenuobj.y<this.dropmenuobj.contentmeasure){b=this.dropmenuobj.contentmeasure+e.offsetHeight;if((this.dropmenuobj.y-a)<this.dropmenuobj.contentmeasure){b=this.dropmenuobj.y+e.offsetHeight-a}}this.dropmenuobj.firstlink.style.borderTopWidth=(b==0)?0:"1px"}return b},dropit:function(c,b,a){if(this.dropmenuobj!=null){this.dropmenuobj.style.visibility="hidden";if(this.previousmenuitem!=null&&this.previousmenuitem!=c){if(this.previousmenuitem.parentNode.className.indexOf("default")==-1){this.previousmenuitem.parentNode.className=""}}}this.clearhidemenu();if(this.ie||this.firefox){c.onmouseout=function(){tabdropdown.delayhidemenu(c)};c.onclick=function(){return !tabdropdown.disablemenuclick};this.dropmenuobj=document.getElementById(a);this.dropmenuobj.onmouseover=function(){tabdropdown.clearhidemenu()};this.dropmenuobj.onmouseout=function(d){tabdropdown.dynamichide(d,c)};this.dropmenuobj.onclick=function(){tabdropdown.delayhidemenu(c)};this.showhide(this.dropmenuobj.style,b,c);this.dropmenuobj.x=this.getposOffset(c,"left");this.dropmenuobj.y=this.getposOffset(c,"top");this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(c,"rightedge")+"px";this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(c,"bottomedge")+c.offsetHeight+1+"px";this.previousmenuitem=c;this.positionshim()}},contains_firefox:function(d,c){while(c.parentNode){if((c=c.parentNode)==d){return true}}return false},dynamichide:function(c,b){var a=window.event?window.event:c;if(this.ie&&!this.dropmenuobj.contains(a.toElement)){this.delayhidemenu(b)}else{if(this.firefox&&c.currentTarget!=a.relatedTarget&&!this.contains_firefox(a.currentTarget,a.relatedTarget)){this.delayhidemenu(b)}}},delayhidemenu:function(a){this.delayhide=setTimeout(function(){tabdropdown.hideshim();tabdropdown.dropmenuobj.style.visibility="hidden";if(a.parentNode.className.indexOf("default")==-1){a.parentNode.className=""}},this.disappeardelay)},clearhidemenu:function(){if(this.delayhide!="undefined"){clearTimeout(this.delayhide)}},positionshim:function(){if(this.enableiframeshim&&this.shimobject){if(this.dropmenuobj.style.visibility=="visible"){this.shimobject.style.width=this.dropmenuobj.offsetWidth+"px";this.shimobject.style.height=this.dropmenuobj.offsetHeight+"px";this.shimobject.style.left=this.dropmenuobj.style.left;this.shimobject.style.top=this.dropmenuobj.style.top}this.shimobject.style.display=(this.dropmenuobj.style.visibility=="visible")?"block":"none"}},hideshim:function(){if(this.enableiframeshim&&this.shimobject){this.shimobject.style.display="none"}},isSelected:function(a){var a=a.replace("http://"+a.hostname,"").replace(/^\//,"");return(tabdropdown.currentpageurl==a)},init:function(e,c){if(this.enableiframeshim&&typeof this.shimobject=="undefined"){this.shimobject=(this.shimobject=document.getElementById("iframe_shim"))?this.shimobject:null}this.standardbody=(document.compatMode=="CSS1Compat")?document.documentElement:document.body;var f=document.getElementById(e).getElementsByTagName("a");for(var d=0;d<f.length;d++){if(f[d].getAttribute("rel")){var a=f[d].getAttribute("rel");document.getElementById(a).firstlink=document.getElementById(a).getElementsByTagName("a")[0];f[d].onmouseover=function(h){var g=typeof h!="undefined"?h:window.event;tabdropdown.dropit(this,g,this.getAttribute("rel"))}}if(c=="auto"&&typeof b=="undefined"&&this.isSelected(f[d].href)){f[d].parentNode.className+=" selected default";var b=true}else{if(parseInt(c)==d){f[d].parentNode.className+=" selected default"}}}}};
