jQuery(document).ready(function(){var myPreferences=['SCRIPTURLPATH','SYSTEMWEB','WEB','trinadv.jumpbox.searchvaluedefault'];if(typeof(foswiki.getPreference)==='function'){$.each(myPreferences,function(index,element){foswiki.getPreference(element);});}else{if(typeof(foswiki)==='object'&&typeof(foswiki.preferences)==='undefined'){foswiki.preferences=[];}
$.each(myPreferences,function(index,element){var prefElement;switch(element){case'SCRIPTURLPATH':prefElement='scriptUrlPath';break;case'SYSTEMWEB':prefElement='systemWebName';break;case'WEB':prefElement='web';break;default:prefElement=element;break;}
foswiki.preferences[element]=foswiki[prefElement];});}
function trinLog(param){}
function applySuperfish(elementSelector){var selectorString='',displayProperty='';jQuery(elementSelector).find('li.sf-item-with-ul').each(function(){if(!jQuery(this).children('ul').length){jQuery(this).append('<ul></ul>');}});if(typeof(elementSelector.attr)!=='undefined'){selectorString='#'+elementSelector.attr('id');}else if(typeof(elementSelector)==='string'){selectorString=elementSelector;}
trinLog('applySuperfish() to "'+selectorString+'" (matches '+
jQuery(elementSelector).size()+' elements).');displayProperty=jQuery(elementSelector).children('ul').css('display');jQuery(elementSelector).children('ul').css('display','block');jQuery(elementSelector).supersubs({minWidth:12,maxWidth:27,extraWidth:1});jQuery(elementSelector).children('ul').css('display',displayProperty);jQuery(elementSelector).superfish({speed:'normal',delay:1200,autoArrows:false,onBeforeShow:function(){var theElement=this;if(theElement.hasClass('sf-item-with-ul')){}else{theElement=this.parent();}
if(typeof(theElement.attr('id'))!=='undefined'){if(!theElement.hasClass('sf-loaded')&&!theElement.hasClass('sf-loading')){theElement.addClass('sf-loading');trinLog('onBeforeShow(): Loading "#'+theElement.attr('id')+'".');loadMenuChildren(theElement);}}}});}
function loadMenuChildren(jqElement){var updateHtml_cb=function(data){jqElement.children('ul').append(data);applySuperfish(jqElement);jqElement.removeClass('sf-loading');jqElement.addClass('sf-loaded');return false;},qstring=foswiki.preferences['SCRIPTURLPATH']+'/view/'+foswiki.preferences['SYSTEMWEB']+
'/TrinSkin?contenttype=text/html;skin=text;section=topicchildren;qcallingweb='+
foswiki.preferences['WEB'],idparts=jqElement.attr('id').match(/^sf-(topic)-ns([^-]+)-(.*)_-5lash-_(.*?)$/);if(!idparts){idparts=jqElement.attr('id').match(/^sf-(web|subweb)-ns([^-]+)-(.*)$/);}
if(idparts){qstring=qstring+';qns='+idparts[2];qstring=qstring+';qweb='+idparts[3].replace(/_-5lash-_/g,'/');if(idparts[4]){qstring=qstring+';qtopic='+idparts[4];}
jQuery.get(qstring,{},updateHtml_cb);}}
function updateSearchbox(){if(jQuery('input[name=web]:checked').val()==='help'){jQuery('#trinjumpbox-recurse-on').attr('disabled','disabled');}else{jQuery('#trinjumpbox-recurse-on').removeAttr('disabled');}
if(jQuery('input[name=scope]:checked').val()==='names'){jQuery('#searchbox:not(.ac_local)').autocomplete(foswiki.preferences['SCRIPTURLPATH']+'/view/'+foswiki.preferences['SYSTEMWEB']+
'/TrinSkin?section=trintopic;contenttype=text/plain;skin=text',{matchContains:true,minChars:2,max:50,formatItem:function(row,i,n,q){var topic=/(.+?)\.(.*)/.exec(row[0]),inWeb='';if(jQuery('input[name=web]:checked').val()==='all'){inWeb=' in <a href="'+foswiki.preferences['SCRIPTURLPATH']+'/view/'+
topic[1]+'.WebHome">'+topic[1]+'</a>';}
return topic[2]+inWeb;}}).result(function(event,item,formatted){window.location.href=foswiki.preferences['SCRIPTURLPATH']+'/view/'+item;});jQuery('#searchbox').autocomplete().setOptions({extraParams:{baseweb:function(){switch(jQuery('input[name=web]:checked').val()){case'all':return'all';case'this':return foswiki.preferences['WEB'];default:return foswiki.preferences['WEB'];}},recurse:function(){return jQuery('input[name=recurse]:checked').val();}}}).flushCache();}else{jQuery('#searchbox:not(.ac_local)').autocomplete().setOptions({minChars:999999});}
return;}
function doSearchBoxTextValueEvents(theSelector){jQuery(theSelector).blur(function(){if(this.value===''){this.value=foswiki.getPreference('trinadv.jumpbox.searchvaluedefault');}});jQuery(theSelector).focus(function(){if(this.value=foswiki.getPreference('trinadv.jumpbox.searchvaluedefault')){this.value='';}});}
applySuperfish('ul.sf-menu');doSearchBoxTextValueEvents('#searchbox');jQuery('#searchform').change(updateSearchbox);jQuery('#searchform').submit(function(){if(jQuery('input[name=web]:checked').val()==='this'){jQuery('input[name=web]').val(foswiki.preferences['WEB']);}});updateSearchbox();if(typeof(jQuery().cycle)!=='undefined'){jQuery('.jqcycle').cycle({timeout:5000,pause:1,random:1});}});