(function ($){
$.fn.listnav=function (options){
var opts=$.extend({}, $.fn.listnav.defaults, options),
letters=['_', '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', '-'],
firstClick=false,
clickEventType='';
if(document.ontouchstart!==null){
clickEventType='click';
}else{
clickEventType='touchend click';
}
opts.prefixes=$.map(opts.prefixes, function (n){
return n.toLowerCase();
});
return this.each(function (){
var $wrapper, $letters, $letterCount, left, width, count,
id=this.id,
$list=$(this),
counts={},
allCount=0, fullCount=0,
isAll=true,
prevLetter='';
if(!$('#' + id + '-nav').length){
$('<div id="' + id + '-nav" class="listNav"/>').insertBefore($list);
}
$wrapper=$('#' + id + '-nav');
function init(){
$wrapper.append(createLettersHtml());
$letters=$('.ln-letters', $wrapper).slice(0, 1);
if(opts.showCounts){
$letterCount=$('.ln-letter-count', $wrapper).slice(0, 1);
}
addClasses();
addNoMatchLI();
bindHandlers();
if(opts.flagDisabled){
addDisabledClass();
}
if(!opts.includeAll){
$('.all', $letters).remove();
}
if(!opts.includeNums){
$('._', $letters).remove();
}
if(!opts.includeOther){
$('.-', $letters).remove();
}
if(opts.removeDisabled){
$('.ln-disabled', $letters).remove();
}
$(':last', $letters).addClass('ln-last');
if($.cookie&&(opts.cookieName!==null)){
var cookieLetter=$.cookie(opts.cookieName);
if(cookieLetter!==null&&typeof cookieLetter!=="undefined"){
opts.initLetter=cookieLetter;
}}
if(opts.initLetter!==''){
firstClick=true;
$('.' + opts.initLetter.toLowerCase(), $letters).slice(0, 1).trigger('click');
}else{
if(opts.initHidden){
addInitHiddenLI();
$list.children().addClass("listNavHide");
$list.children('.ln-init-hidden').removeClass('listNavHide');
}
else if(opts.includeAll){
$('.all', $letters).addClass('ln-selected');
}else{
for(var i=((opts.includeNums) ? 0:1); i < letters.length; i++){
if(counts[letters[i]] > 0){
firstClick=true;
$('.' + letters[i], $letters).slice(0, 1).trigger('click');
break;
}}
}}
}
function setLetterCountTop(){
var letterCountHeight=$letterCount.outerHeight();
$letterCount.css({
top: $('a:first', $wrapper).slice(0, 1).position().top - letterCountHeight
});
}
function addClasses(){
var str, spl, $this,
firstChar='',
hasPrefixes=(opts.prefixes.length > 0),
hasFilterSelector=(opts.filterSelector.length > 0);
$($list).children().each(function (){
$this=$(this);
if(!hasFilterSelector){
str=$.trim($this.text()).toLowerCase();
}else{
str=$.trim($this.find(opts.filterSelector).text()).toLowerCase();
}
if(str!==''){
if(hasPrefixes){
var prefixes=$.map(opts.prefixes, function(value){
return value.indexOf(' ') <=0 ? value + ' ':value;
});
var matches=$.grep(prefixes, function(value){
return str.indexOf(value)===0;
});
if(matches.length > 0){
var afterMatch=str.toLowerCase().split(matches[0])[1];
if(afterMatch!==null){
firstChar=$.trim(afterMatch).charAt(0);
}else{
firstChar=str.charAt(0);
}
addLetterClass(firstChar, $this, true);
return;
}}
firstChar=str.charAt(0);
addLetterClass(firstChar, $this);
}});
}
function addLetterClass(firstChar, $el, isPrefix){
if(/\W/.test(firstChar)){
firstChar='-';
}
if(!isNaN(firstChar)){
firstChar='_';
}
$el.addClass('ln-' + firstChar);
if(counts[firstChar]===undefined){
counts[firstChar]=0;
}
counts[firstChar]++;
if(!isPrefix){
allCount++;
}}
function addDisabledClass(){
for(var i=0; i < letters.length; i++){
if(counts[letters[i]]===undefined){
$('.' + letters[i], $letters).addClass('ln-disabled');
}}
}
function addNoMatchLI(){
$list.append('<li class="ln-no-match listNavHide">' + opts.noMatchText + '</li>');
}
function addInitHiddenLI(){
$list.append('<li class="ln-init-hidden listNavHide">' + opts.initHiddenText + '</li>');
}
function getLetterCount(el){
if($(el).hasClass('all')){
if(opts.dontCount){
fullCount=allCount - $list.find(opts.dontCount).length;
}else{
fullCount=allCount;
}
return fullCount;
}else{
el='.ln-' + $(el).attr('class').split(' ')[0];
if(opts.dontCount){
count=$list.find(el).not(opts.dontCount).length;
}else{
count=$list.find(el).length;
}
return (count!==undefined) ? count:0;
}}
function bindHandlers(){
if(opts.showCounts){
$wrapper.mouseover(function (){
setLetterCountTop();
});
$('.ln-letters a', $wrapper).mouseover(function (){
left=$(this).position().left;
width=($(this).outerWidth()) + 'px';
count=getLetterCount(this);
$letterCount.css({
left: left,
width: width
}).text(count).addClass("letterCountShow").removeClass("listNavHide");
}).mouseout(function (){
$letterCount.addClass("listNavHide").removeClass("letterCountShow");
});
}
$('a', $letters).on(clickEventType, function (e){
e.preventDefault();
var $this=$(this),
letter=$this.attr('class').split(' ')[0],
noMatches=$list.children('.ln-no-match');
if(opts.initHidden){
$list.children('.ln-init-hidden').remove();
}
if(prevLetter!==letter){
$('a.ln-selected', $letters).removeClass('ln-selected');
if(letter==='all'){
$list.children().addClass("listNavShow").removeClass("listNavHide");
noMatches.addClass("listNavHide").removeClass("listNavShow");
isAll=true;
}else{
if(isAll){
$list.children().addClass("listNavHide").removeClass("listNavShow");
isAll=false;
}else if(prevLetter!==''){
$list.children('.ln-' + prevLetter).addClass("listNavHide").removeClass("listNavShow");
}
var count=getLetterCount(this);
if(count > 0){
$list.children('.ln-' + letter).addClass("listNavShow").removeClass("listNavHide");
noMatches.addClass("listNavHide").removeClass("listNavShow");
}else{
noMatches.addClass("listNavShow").removeClass("listNavHide");
}}
prevLetter=letter;
if($.cookie&&(opts.cookieName!==null)){
$.cookie(opts.cookieName, letter, {
expires: 999
});
}
$this.addClass('ln-selected');
$this.blur();
if(!firstClick&&(opts.onClick!==null)){
opts.onClick(letter);
}else{
firstClick=false;
}}
});
}
function createLettersHtml(){
var html=[];
for (var i=1; i < letters.length; i++){
if(html.length===0){
html.push('<a class="all" href="#">'+ opts.allText + '</a><a class="_" href="#">0-9</a>');
}
html.push('<a class="' + letters[i] + '" href="#">' + ((letters[i]==='-') ? '...':letters[i].toUpperCase()) + '</a>');
}
return '<div class="ln-letters">' + html.join('') + '</div>' + ((opts.showCounts) ? '<div class="ln-letter-count listNavHide">0</div>':'');
}
init();
});
};
$.fn.listnav.defaults={
initHidden: false,
initHiddenText: 'Tap a letter above to view matching items',
initLetter: '',
includeAll: true,
allText: 'All',
includeOther: false,
includeNums: true,
flagDisabled: true,
removeDisabled: false,
noMatchText: 'No matching entries',
showCounts: true,
dontCount: '',
cookieName: null,
onClick: null,
prefixes: [],
filterSelector: ''
};})(jQuery);
$(document).ready(function(){
$(".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").click(function(){
$(".headSec").removeClass("listNavHide");
$("form").removeClass("listNavHide");
$("form").addClass("listNavShow");
$(".headSec").addClass("listNavShow");
$(".citieshead").removeClass("listNavHide");
$(".citieshead").addClass("listNavShow");
});
});
$("#listTwo").listnav();
function myFunction(){
var input, filter, table, tr, td, i, txtValue;
input=document.getElementById("myInput");
filter=input.value.toUpperCase();
table=document.getElementById("myTable");
tr=table.getElementsByTagName("tr");
for (i=0; i < tr.length; i++){
td=tr[i].getElementsByTagName("td")[0];
if(td){
txtValue=td.textContent||td.innerText;
if(txtValue.toUpperCase().indexOf(filter) > -1){
tr[i].style.display="";
}else{
tr[i].style.display="none";
}}
}};