/*
*
* jQuery listnav plugin
* Copyright (c) 2009 iHwy, Inc.
* Author: Jack Killpatrick
*
* Version 2.1 (08/09/2009)
* Requires jQuery 1.3.2, jquery 1.2.6 or jquery 1.2.x plus the jquery dimensions plugin
*
* Visit http://www.ihwy.com/labs/jquery-listnav-plugin.aspx for more information.
*
* Dual licensed under the MIT and GPL licenses:
*   http://www.opensource.org/licenses/mit-license.php
*   http://www.gnu.org/licenses/gpl.html
*
*/(function(e){e.fn.listnav=function(t){var n=e.extend({},e.fn.listnav.defaults,t),r=["_","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","-"],i=!1;n.prefixes=e.map(n.prefixes,function(e){return e.toLowerCase()});return this.each(function(){function v(){t.append(x());u=e(".ln-letters",t).slice(0,1);n.showCounts&&(a=e(".ln-letter-count",t).slice(0,1));g();w();n.flagDisabled&&b();S();n.includeAll||o.show();n.includeAll||e(".all",u).remove();n.includeNums||e("._",u).remove();n.includeOther||e(".-",u).remove();e(":last",u).addClass("ln-last");if(e.cookie&&n.cookieName!=null){var s=e.cookie(n.cookieName);s!=null&&(n.initLetter=s)}if(n.initLetter!=""){i=!0;e("."+n.initLetter.toLowerCase(),u).slice(0,1).click()}else if(n.includeAll)e(".all",u).addClass("ln-selected");else for(var f=n.includeNums?0:1;f<r.length;f++)if(l[r[f]]>0){i=!0;e("."+r[f],u).slice(0,1).click();break}}function m(){a.css({top:e(".a",u).slice(0,1).offset({margin:!1,border:!0}).top-a.outerHeight({margin:!0})})}function g(){var t,r,i,s,u,a=n.prefixes.length>0;e(o).children().each(function(){u=e(this),r="";n.attribute&&(t=e.trim(u.attr(n.attribute)).toLowerCase());if(!n.attribute||t=="")t=e.trim(u.text()).toLowerCase();if(t!=""){if(a){s=t.split(" ");if(s.length>1&&e.inArray(s[0],n.prefixes)>-1){r=s[1].charAt(0);y(r,u,!0)}}r=t.charAt(0);y(r,u)}})}function y(e,t,n){/\W/.test(e)&&(e="-");isNaN(e)||(e="_");t.addClass("ln-"+e);l[e]==undefined&&(l[e]=0);l[e]++;n||c++}function b(){for(var t=0;t<r.length;t++)l[r[t]]==undefined&&e("."+r[t],u).addClass("ln-disabled")}function w(){o.append('<li class="ln-no-match" style="display:none">'+n.noMatchText+"</li>")}function E(t){if(e(t).hasClass("all"))return c;var n=l[e(t).attr("class").split(" ")[0]];return n!=undefined?n:0}function S(){n.showCounts&&t.mouseover(function(){m()});if(n.showCounts){e("a",u).mouseover(function(){var t=e(this).position().left,n=e(this).outerWidth({margin:!0})-1+"px",r=E(this);a.css({left:t,width:n}).text(r).show()});e("a",u).mouseout(function(){a.hide()})}e("a",u).click(function(){e("a.ln-selected",u).removeClass("ln-selected");var t=e(this).attr("class").split(" ")[0];if(t=="all"){o.children().show();o.children(".ln-no-match").hide();h=!0}else{if(h){o.children().hide();h=!1}else d!=""&&o.children(".ln-"+d).hide();var r=E(this);if(r>0){o.children(".ln-no-match").hide();o.children(".ln-"+t).show()}else o.children(".ln-no-match").show();d=t}e.cookie&&n.cookieName!=null&&e.cookie(n.cookieName,t);e(this).addClass("ln-selected");e(this).blur();!i&&n.onClick!=null?n.onClick(t):i=!1;return!1})}function x(){var e=[];for(var t=1;t<r.length;t++){e.length==0&&e.push('<a class="all" href="#">ALL</a><a class="_" href="#">0-9</a>');e.push('<a class="'+r[t]+'" href="#">'+(r[t]=="-"?"...":r[t].toUpperCase())+"</a>")}return'<div class="ln-letters">'+e.join("")+"</div>"+(n.showCounts?'<div class="ln-letter-count" style="display:none; position:absolute; top:0; left:0; width:20px;">0</div>':"")}var t,s,o,u,a,f;f=this.id;t=e("<div/>");o=e(this);o.before(t);var l={},c=0,h=!0,p=0,d="";v()})};e.fn.listnav.defaults={initLetter:"",includeAll:!0,includeOther:!0,includeNums:!0,flagDisabled:!0,noMatchText:"No matching entries",showCounts:!1,cookieName:null,onClick:null,prefixes:[],attribute:!1}})(jQuery);