﻿




function onCalendarShown(sender, args) {
    //ensures calendars are on top of EVERYTHING
    sender._popupBehavior._element.style.zIndex = 100002;
}


Sys.Browser.WebKit = {}; //Safari 3 is considered WebKit
if (navigator.userAgent.indexOf('WebKit/') > -1) {
    Sys.Browser.agent = Sys.Browser.WebKit;
    Sys.Browser.version = parseFloat(navigator.userAgent.match(/WebKit\/(\d+(\.\d+)?)/)[1]);
    Sys.Browser.name = 'WebKit';
}


/*pulse any object with the pulse class*/

function classPulse() {
    $(".pulse").animate({ backgroundColor: "yellow" }, 1000)
               .animate({ backgroundColor: "white" }, 1000);
    $(".pulse").removeClass("pulse");
}

function objPulse(obj) {
    $(obj).animate({ backgroundColor: "yellow" }, 1000)
          .animate({ backgroundColor: "white" }, 1000);
}

/*
* jQuery Color Animations
* Copyright 2007 John Resig
* Released under the MIT and GPL licenses.
*/

(function(jQuery) {

    // We override the animation for all of these color styles
    jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function(i, attr) {
        jQuery.fx.step[attr] = function(fx) {
            if (fx.state == 0) {
                fx.start = getColor(fx.elem, attr);
                fx.end = getRGB(fx.end);
            }

            fx.elem.style[attr] = "rgb(" + [
				Math.max(Math.min(parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0),
				Math.max(Math.min(parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0),
				Math.max(Math.min(parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0)
			].join(",") + ")";
        }
    });

    // Color Conversion functions from highlightFade
    // By Blair Mitchelmore
    // http://jquery.offput.ca/highlightFade/

    // Parse strings looking for color tuples [255,255,255]
    function getRGB(color) {
        var result;

        // Check if we're already dealing with an array of colors
        if (color && color.constructor == Array && color.length == 3)
            return color;

        // Look for rgb(num,num,num)
        if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
            return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];

        // Look for rgb(num%,num%,num%)
        if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
            return [parseFloat(result[1]) * 2.55, parseFloat(result[2]) * 2.55, parseFloat(result[3]) * 2.55];

        // Look for #a0b1c2
        if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
            return [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16)];

        // Look for #fff
        if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
            return [parseInt(result[1] + result[1], 16), parseInt(result[2] + result[2], 16), parseInt(result[3] + result[3], 16)];

        // Otherwise, we're most likely dealing with a named color
        return colors[jQuery.trim(color).toLowerCase()];
    }

    function getColor(elem, attr) {
        var color;

        do {
            color = jQuery.curCSS(elem, attr);

            // Keep going until we find an element that has color, or we hit the body
            if (color != '' && color != 'transparent' || jQuery.nodeName(elem, "body"))
                break;

            attr = "backgroundColor";
        } while (elem = elem.parentNode);

        return getRGB(color);
    };

    // Some named colors to work with
    // From Interface by Stefan Petre
    // http://interface.eyecon.ro/

    var colors = {
        aqua: [0, 255, 255],
        azure: [240, 255, 255],
        beige: [245, 245, 220],
        black: [0, 0, 0],
        blue: [0, 0, 255],
        brown: [165, 42, 42],
        cyan: [0, 255, 255],
        darkblue: [0, 0, 139],
        darkcyan: [0, 139, 139],
        darkgrey: [169, 169, 169],
        darkgreen: [0, 100, 0],
        darkkhaki: [189, 183, 107],
        darkmagenta: [139, 0, 139],
        darkolivegreen: [85, 107, 47],
        darkorange: [255, 140, 0],
        darkorchid: [153, 50, 204],
        darkred: [139, 0, 0],
        darksalmon: [233, 150, 122],
        darkviolet: [148, 0, 211],
        fuchsia: [255, 0, 255],
        gold: [255, 215, 0],
        green: [0, 128, 0],
        indigo: [75, 0, 130],
        khaki: [240, 230, 140],
        lightblue: [173, 216, 230],
        lightcyan: [224, 255, 255],
        lightgreen: [144, 238, 144],
        lightgrey: [211, 211, 211],
        lightpink: [255, 182, 193],
        lightyellow: [255, 255, 224],
        lime: [0, 255, 0],
        magenta: [255, 0, 255],
        maroon: [128, 0, 0],
        navy: [0, 0, 128],
        olive: [128, 128, 0],
        orange: [255, 165, 0],
        pink: [255, 192, 203],
        purple: [128, 0, 128],
        violet: [128, 0, 128],
        red: [255, 0, 0],
        silver: [192, 192, 192],
        white: [255, 255, 255],
        yellow: [255, 255, 0]
    };

})(jQuery);




/**
* jquery.simpletip 1.3.1. A simple tooltip plugin
* 
* Copyright (c) 2009 Craig Thompson
* http://craigsworks.com
*
* Licensed under GPLv3
* http://www.opensource.org/licenses/gpl-3.0.html
*
* Launch  : February 2009
* Version : 1.3.1
* Released: February 5, 2009 - 11:04am
*/
eval(function(p, a, c, k, e, r) { e = function(c) { return (c < 62 ? '' : e(parseInt(c / 62))) + ((c = c % 62) > 35 ? String.fromCharCode(c + 29) : c.toString(36)) }; if ('0'.replace(0, e) == 0) { while (c--) r[e(c)] = k[c]; k = [function(e) { return r[e] || e } ]; e = function() { return '([3-9a-zB-Z]|1\\w)' }; c = 1 }; while (c--) if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]); return p } ('(6($){6 Z(f,3){4 7=n;f=b(f);4 5=b(document.createElement(\'div\')).B(3.10).B((3.p)?3.11:\'\').B((3.C)?3.12:\'\').13(3.q).appendTo(f);a(!3.14)5.t();o 5.r();a(!3.C){f.hover(6(c){7.t(c)},6(){7.r()});a(!3.p){f.mousemove(6(c){a(5.D(\'N\')!==\'u\')7.E(c)})}}o{f.click(6(c){a(c.15===f.16(0)){a(5.D(\'N\')!==\'u\')7.r();o 7.t()}});b(v).mousedown(6(c){a(5.D(\'N\')!==\'u\'){4 17=(3.O)?b(c.15).parents(\'.5\').andSelf().filter(6(){d n===5.16(0)}).length:0;a(17===0)7.r()}})};b.18(7,{getVersion:6(){d[1,2,0]},getParent:6(){d f},getTooltip:6(){d 5},getPos:6(){d 5.i()},19:6(8,9){4 e=f.i();a(s 8==\'F\')8=G(8)+e.k;a(s 9==\'F\')9=G(9)+e.l;5.D({k:8,l:9});d 7},t:6(c){3.1a.m(7);7.E((3.p)?P:c);Q(3.1b){g\'H\':5.fadeIn(3.I);h;g\'1c\':5.slideDown(3.I,7.E);h;g\'1d\':3.1e.m(5,3.I);h;w:g\'u\':5.t();h};5.B(3.R);3.1f.m(7);d 7},r:6(){3.1g.m(7);Q(3.1h){g\'H\':5.fadeOut(3.J);h;g\'1c\':5.slideUp(3.J);h;g\'1d\':3.1i.m(5,3.J);h;w:g\'u\':5.r();h};5.removeClass(3.R);3.1j.m(7);d 7},update:6(q){5.13(q);3.q=q;d 7},1k:6(1l,K){3.1m.m(7);5.1k(1l,K,6(){3.1n.m(7)});d 7},L:6(8,9){4 1o=8+5.S();4 1p=9+5.T();4 1q=b(v).width()+b(v).scrollLeft();4 1r=b(v).height()+b(v).scrollTop();d[(1o>=1q),(1p>=1r)]},E:6(c){4 x=5.S();4 y=5.T();a(!c&&3.p){a(3.j.constructor==Array){8=G(3.j[0]);9=G(3.j[1])}o a(b(3.j).attr(\'nodeType\')===1){4 i=b(3.j).i();8=i.k;9=i.l}o{4 e=f.i();4 z=f.S();4 M=f.T();Q(3.j){g\'l\':4 8=e.k-(x/2)+(z/2);4 9=e.l-y;h;g\'bottom\':4 8=e.k-(x/2)+(z/2);4 9=e.l+M;h;g\'k\':4 8=e.k-x;4 9=e.l-(y/2)+(M/2);h;g\'right\':4 8=e.k+z;4 9=e.l-(y/2)+(M/2);h;w:g\'w\':4 8=(z/2)+e.k+20;4 9=e.l;h}}}o{4 8=c.pageX;4 9=c.pageY};a(s 3.j!=\'object\'){8=8+3.i[0];9=9+3.i[1];a(3.L){4 U=7.L(8,9);a(U[0])8=8-(x/2)-(2*3.i[0]);a(U[1])9=9-(y/2)-(2*3.i[1])}}o{a(s 3.j[0]=="F")8=1s(8);a(s 3.j[1]=="F")9=1s(9)};7.19(8,9);d 7}})};b.fn.V=6(3){4 W=b(n).eq(s 3==\'number\'?3:0).K("V");a(W)d W;4 X={q:\'A simple 5\',C:1t,O:1t,14:Y,j:\'w\',i:[0,0],L:Y,p:Y,1b:\'H\',I:1u,1e:P,1h:\'H\',J:1u,1i:P,10:\'5\',R:\'active\',11:\'p\',12:\'C\',focusClass:\'O\',1a:6(){},1f:6(){},1g:6(){},1j:6(){},1m:6(){},1n:6(){}};b.18(X,3);n.each(6(){4 el=new Z(b(n),X);b(n).K("V",el)});d n}})();', [], 93, '|||conf|var|tooltip|function|self|posX|posY|if|jQuery|event|return|elemPos|elem|case|break|offset|position|left|top|call|this|else|fixed|content|hide|typeof|show|none|window|default|tooltipWidth|tooltipHeight|elemWidth||addClass|persistent|css|updatePos|string|parseInt|fade|showTime|hideTime|data|boundryCheck|elemHeight|display|focus|null|switch|activeClass|outerWidth|outerHeight|overflow|simpletip|api|defaultConf|true|Simpletip|baseClass|fixedClass|persistentClass|html|hidden|target|get|check|extend|setPos|onBeforeShow|showEffect|slide|custom|showCustom|onShow|onBeforeHide|hideEffect|hideCustom|onHide|load|uri|beforeContentLoad|onContentLoad|newX|newY|windowWidth|windowHeight|String|false|150'.split('|'), 0, {}))

/**
* jQuery.ScrollTo - Easy element scrolling using jQuery.
* Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
* Dual licensed under MIT and GPL.
* Date: 5/25/2009
* @author Ariel Flesler
* @version 1.4.2
*
* http://flesler.blogspot.com/2007/10/jqueryscrollto.html
*/
; (function (d) { var k = d.scrollTo = function (a, i, e) { d(window).scrollTo(a, i, e) }; k.defaults = { axis: 'xy', duration: parseFloat(d.fn.jquery) >= 1.3 ? 0 : 1 }; k.window = function (a) { return d(window)._scrollable() }; d.fn._scrollable = function () { return this.map(function () { var a = this, i = !a.nodeName || d.inArray(a.nodeName.toLowerCase(), ['iframe', '#document', 'html', 'body']) != -1; if (!i) return a; var e = (a.contentWindow || a).document || a.ownerDocument || a; return d.browser.safari || e.compatMode == 'BackCompat' ? e.body : e.documentElement }) }; d.fn.scrollTo = function (n, j, b) { if (typeof j == 'object') { b = j; j = 0 } if (typeof b == 'function') b = { onAfter: b }; if (n == 'max') n = 9e9; b = d.extend({}, k.defaults, b); j = j || b.speed || b.duration; b.queue = b.queue && b.axis.length > 1; if (b.queue) j /= 2; b.offset = p(b.offset); b.over = p(b.over); return this._scrollable().each(function () { var q = this, r = d(q), f = n, s, g = {}, u = r.is('html,body'); switch (typeof f) { case 'number': case 'string': if (/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)) { f = p(f); break } f = d(f, this); case 'object': if (f.is || f.style) s = (f = d(f)).offset() } d.each(b.axis.split(''), function (a, i) { var e = i == 'x' ? 'Left' : 'Top', h = e.toLowerCase(), c = 'scroll' + e, l = q[c], m = k.max(q, i); if (s) { g[c] = s[h] + (u ? 0 : l - r.offset()[h]); if (b.margin) { g[c] -= parseInt(f.css('margin' + e)) || 0; g[c] -= parseInt(f.css('border' + e + 'Width')) || 0 } g[c] += b.offset[h] || 0; if (b.over[h]) g[c] += f[i == 'x' ? 'width' : 'height']() * b.over[h] } else { var o = f[h]; g[c] = o.slice && o.slice(-1) == '%' ? parseFloat(o) / 100 * m : o } if (/^\d+$/.test(g[c])) g[c] = g[c] <= 0 ? 0 : Math.min(g[c], m); if (!a && b.queue) { if (l != g[c]) t(b.onAfterFirst); delete g[c] } }); t(b.onAfter); function t(a) { r.animate(g, j, b.easing, a && function () { a.call(this, n, b) }) } }).end() }; k.max = function (a, i) { var e = i == 'x' ? 'Width' : 'Height', h = 'scroll' + e; if (!d(a).is('html,body')) return a[h] - d(a)[e.toLowerCase()](); var c = 'client' + e, l = a.ownerDocument.documentElement, m = a.ownerDocument.body; return Math.max(l[h], m[h]) - Math.min(l[c], m[c]) }; function p(a) { return typeof a == 'object' ? a : { top: a, left: a} } })(jQuery);

//remove alpha filter if the browser is IE
function removeFilter(elem) {
    var $elem = $(elem);
    if ($.browser.msie && $elem.css("filter") && $elem.css("opacity") ==
    1)
        $elem[0].style.removeAttribute('filter');
}

$.fn.centerInClient = function(options) {
    /// <summary>Centers the selected items in the browser window. Takes into account scroll position.
    /// Ideally the selected set should only match a single element.
    /// </summary>    
    /// <param name="fn" type="Function">Optional function called when centering is complete. Passed DOM element as parameter</param>    
    /// <param name="forceAbsolute" type="Boolean">if true forces the element to be removed from the document flow 
    ///  and attached to the body element to ensure proper absolute positioning. 
    /// Be aware that this may cause ID hierachy for CSS styles to be affected.
    /// </param>
    /// <returns type="jQuery" />
    var opt = { forceAbsolute: false,
        container: window,    // selector of element to center in
        completeHandler: null
    };
    $.extend(opt, options);

    return this.each(function(i) {
        var el = $(this);
        var jWin = $(opt.container);
        var isWin = opt.container == window;

        // force to the top of document to ENSURE that 
        // document absolute positioning is available
        if (opt.forceAbsolute) {
            if (isWin)
                el.remove().appendTo("body");
            else
                el.remove().appendTo(jWin.get(0));
        }

        // have to make absolute
        el.css("position", "absolute");

        // height is off a bit so fudge it
        var heightFudge = isWin ? 2.0 : 1.8;

        var x = (isWin ? jWin.width() : jWin.outerWidth()) / 2 - el.outerWidth() / 2;
        var y = (isWin ? jWin.height() : jWin.outerHeight()) / heightFudge - el.outerHeight() / 2;

        el.css("left", x + jWin.scrollLeft());
        el.css("top", y + jWin.scrollTop());

        // if specified make callback and pass element
        if (opt.completeHandler)
            opt.completeHandler(this);
    });
}

//this collection of .ready() functions are used on a lot of different pages
$(document).ready(function() {
    //creates the background-switching effect on LI elements with the choice_li class
    //Extends the href of the anchor tag INSIDE the li to the entire element
    $("li.choice_li")
        .hover(
            function() { $(this).toggleClass("choice_li_on") },
            function() { $(this).toggleClass("choice_li_on") })
        .click(function(e) {
            e.preventDefault();
            window.location = $(this).children("a").attr("href");
        })
        .prepend("<div>&nbsp;</div>"); //this creates the space where the image is
    });


    function configureTabs(tbid) {

        if (!tbid) {
            tbid = "ul.tablist"
        }

        if (!currentTab) {
            var currentTab = 0;
        }
        //set the anchor tag current class of the active tab
        var currTab = $(tbid + " > li:eq(" + currentTab + ")");
        if(!($(currTab).hasClass("current"))) {
            $(tbid + " > li:eq(" + currentTab + ")").toggleClass("current");
        }
        if (!($("" + tbid + "").parent("div").hasClass("tablistwrap"))) {
            
            $(""+tbid+"").wrap("<div class='tablistwrap' />")    
        }

        //add the current index as a "tab=##" value to each anchor tag in the tab list
        $(tbid + " > li ").each(function(index) {
            var thisParent = $(this).parent("ul");
            //assume that the FIRST anchor tag in the tab list is the "tab"
            //get it's href
            $(this).children("a:first").click(function(e) {
                e.preventDefault();
                currentTab = index;
                var newTab = $(this).parent("li");
                $(tbid + " > li.current > div.content").fadeOut("fast", function() {
                    $(this).parent("li").removeClass("current");
                    $(newTab).addClass("current");
                    $(newTab).children("div.content").hide().fadeIn();
                });

            });

        });


    }

    function hrefAppend(obj, index) {

        var thisUrl = $(obj).attr("href");
        var thisQString = "tab=" + index;

        //add the current desired tab index to the tab link
        thisQString = thisUrl + uriAppender(thisUrl) + thisQString;

        //finish the alteration by setting the object href
        $(obj).attr("href", thisQString);
    }

    function uriAppender(uri) {
        //if there is no question mark in the current uri, add it, otherwise, return an "&"
        var result = (uri.indexOf("?") == -1) ? "?" : "&"
        return result;
    }


    function getParameterByName(name, def) {
        //fun little javascript function that parses querystring variables
        //send in the name of the querystring variable, get the value out

        name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
        var regexS = "[\\?&]" + name + "=([^&#]*)";
        var regex = new RegExp(regexS);
        var results = regex.exec(window.location.href);
        if (results == null)
            return def;
        else
            return results[1];
    }

    function ValidateControl(source, args) {
        var cntrl_id = $(source).attr("controltovalidate");
        var cntrl = $("#" + cntrl_id);
        var is_valid = $(cntrl).val() != "";
        is_valid ? $(cntrl).removeClass("error") : $(cntrl).addClass("error").focus();

        args.IsValid = is_valid;
    }

    function getPort() {
        var prt = window.location.port;
        if (prt.length > 0) {
            prt = ":" + prt;
        }

        return prt;
    }

    function getFlowplayerSWF() {
        var result = "http://" + window.location.hostname + getPort() + "/flowplayer-3.1.5.swf"
        return result;
    }


    function checkit(obj) {
        var $inp = $(obj);
        if ($inp.val().length != 0) {
            $inp.removeClass("required");
        } else {
            $inp.addClass("required");
        }
    }

    /**
    *  Ajax Autocomplete for jQuery, version 1.1.3
    *  (c) 2010 Tomas Kirda
    *
    *  Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
    *  For details, see the web site: http://www.devbridge.com/projects/autocomplete/jquery/
    *
    *  Last Review: 04/19/2010
    */

    (function (d) { function l(b, a, c) { a = "(" + c.replace(m, "\\$1") + ")"; return b.replace(new RegExp(a, "gi"), "<strong>$1</strong>") } function i(b, a) { this.el = d(b); this.el.attr("autocomplete", "off"); this.suggestions = []; this.data = []; this.badQueries = []; this.selectedIndex = -1; this.currentValue = this.el.val(); this.intervalId = 0; this.cachedResponse = []; this.onChangeInterval = null; this.ignoreValueChange = false; this.serviceUrl = a.serviceUrl; this.isLocal = false; this.options = { autoSubmit: false, minChars: 1, maxHeight: 300, deferRequestBy: 0, width: 0, highlight: true, params: {}, fnFormatResult: l, delimiter: null, zIndex: 9999 }; this.initialize(); this.setOptions(a) } var m = new RegExp("(\\/|\\.|\\*|\\+|\\?|\\||\\(|\\)|\\[|\\]|\\{|\\}|\\\\)", "g"); d.fn.autocomplete = function (b) { return new i(this.get(0) || d("<input />"), b) }; i.prototype = { killerFn: null, initialize: function () { var b, a, c; b = this; a = Math.floor(Math.random() * 1048576).toString(16); c = "Autocomplete_" + a; this.killerFn = function (e) { if (d(e.target).parents(".autocomplete").size() === 0) { b.killSuggestions(); b.disableKillerFn() } }; if (!this.options.width) this.options.width = this.el.width(); this.mainContainerId = "AutocompleteContainter_" + a; d('<div id="' + this.mainContainerId + '" style="position:absolute;z-index:9999;"><div class="autocomplete-w1"><div class="autocomplete" id="' + c + '" style="display:none; width:300px;"></div></div></div>').appendTo("body"); this.container = d("#" + c); this.fixPosition(); window.opera ? this.el.keypress(function (e) { b.onKeyPress(e) }) : this.el.keydown(function (e) { b.onKeyPress(e) }); this.el.keyup(function (e) { b.onKeyUp(e) }); this.el.blur(function () { b.enableKillerFn() }); this.el.focus(function () { b.fixPosition() }) }, setOptions: function (b) { var a = this.options; d.extend(a, b); if (a.lookup) { this.isLocal = true; if (d.isArray(a.lookup)) a.lookup = { suggestions: a.lookup, data: []} } d("#" + this.mainContainerId).css({ zIndex: a.zIndex }); this.container.css({ maxHeight: a.maxHeight + "px", width: a.width }) }, clearCache: function () { this.cachedResponse = []; this.badQueries = [] }, disable: function () { this.disabled = true }, enable: function () { this.disabled = false }, fixPosition: function () { var b = this.el.offset(); d("#" + this.mainContainerId).css({ top: b.top + this.el.innerHeight() + "px", left: b.left + "px" }) }, enableKillerFn: function () { d(document).bind("click", this.killerFn) }, disableKillerFn: function () { d(document).unbind("click", this.killerFn) }, killSuggestions: function () { var b = this; this.stopKillSuggestions(); this.intervalId = window.setInterval(function () { b.hide(); b.stopKillSuggestions() }, 300) }, stopKillSuggestions: function () { window.clearInterval(this.intervalId) }, onKeyPress: function (b) { if (!(this.disabled || !this.enabled)) { switch (b.keyCode) { case 27: this.el.val(this.currentValue); this.hide(); break; case 9: case 13: if (this.selectedIndex === -1) { this.hide(); return } this.select(this.selectedIndex); if (b.keyCode === 9) return; break; case 38: this.moveUp(); break; case 40: this.moveDown(); break; default: return } b.stopImmediatePropagation(); b.preventDefault() } }, onKeyUp: function (b) { if (!this.disabled) { switch (b.keyCode) { case 38: case 40: return } clearInterval(this.onChangeInterval); if (this.currentValue !== this.el.val()) if (this.options.deferRequestBy > 0) { var a = this; this.onChangeInterval = setInterval(function () { a.onValueChange() }, this.options.deferRequestBy) } else this.onValueChange() } }, onValueChange: function () { clearInterval(this.onChangeInterval); this.currentValue = this.el.val(); var b = this.getQuery(this.currentValue); this.selectedIndex = -1; if (this.ignoreValueChange) this.ignoreValueChange = false; else b === "" || b.length < this.options.minChars ? this.hide() : this.getSuggestions(b) }, getQuery: function (b) { var a; a = this.options.delimiter; if (!a) return d.trim(b); b = b.split(a); return d.trim(b[b.length - 1]) }, getSuggestionsLocal: function (b) { var a, c, e, g, f; c = this.options.lookup; e = c.suggestions.length; a = { suggestions: [], data: [] }; b = b.toLowerCase(); for (f = 0; f < e; f++) { g = c.suggestions[f]; if (g.toLowerCase().indexOf(b) === 0) { a.suggestions.push(g); a.data.push(c.data[f]) } } return a }, getSuggestions: function (b) { var a, c; if ((a = this.isLocal ? this.getSuggestionsLocal(b) : this.cachedResponse[b]) && d.isArray(a.suggestions)) { this.suggestions = a.suggestions; this.data = a.data; this.suggest() } else if (!this.isBadQuery(b)) { c = this; c.options.params.query = b; d.get(this.serviceUrl, c.options.params, function (e) { c.processResponse(e) }, "text") } }, isBadQuery: function (b) { for (var a = this.badQueries.length; a--; ) if (b.indexOf(this.badQueries[a]) === 0) return true; return false }, hide: function () { this.enabled = false; this.selectedIndex = -1; this.container.hide() }, suggest: function () { if (this.suggestions.length === 0) this.hide(); else { var b, a, c, e, g, f, j, k; b = this; a = this.suggestions.length; e = this.options.fnFormatResult; g = this.getQuery(this.currentValue); j = function (h) { return function () { b.activate(h) } }; k = function (h) { return function () { b.select(h) } }; this.container.hide().empty(); for (f = 0; f < a; f++) { c = this.suggestions[f]; c = d((b.selectedIndex === f ? '<div class="selected"' : "<div") + ' title="' + c + '">' + e(c, this.data[f], g) + "</div>"); c.mouseover(j(f)); c.click(k(f)); this.container.append(c) } this.enabled = true; this.container.show() } }, processResponse: function (b) { var a; try { a = eval("(" + b + ")") } catch (c) { return } if (!d.isArray(a.data)) a.data = []; if (!this.options.noCache) { this.cachedResponse[a.query] = a; a.suggestions.length === 0 && this.badQueries.push(a.query) } if (a.query === this.getQuery(this.currentValue)) { this.suggestions = a.suggestions; this.data = a.data; this.suggest() } }, activate: function (b) { var a, c; a = this.container.children(); this.selectedIndex !== -1 && a.length > this.selectedIndex && d(a.get(this.selectedIndex)).removeClass(); this.selectedIndex = b; if (this.selectedIndex !== -1 && a.length > this.selectedIndex) { c = a.get(this.selectedIndex); d(c).addClass("selected") } return c }, deactivate: function (b, a) { b.className = ""; if (this.selectedIndex === a) this.selectedIndex = -1 }, select: function (b) { var a; if (a = this.suggestions[b]) { this.el.val(a); if (this.options.autoSubmit) { a = this.el.parents("form"); a.length > 0 && a.get(0).submit() } this.ignoreValueChange = true; this.hide(); this.onSelect(b) } }, moveUp: function () { if (this.selectedIndex !== -1) if (this.selectedIndex === 0) { this.container.children().get(0).className = ""; this.selectedIndex = -1; this.el.val(this.currentValue) } else this.adjustScroll(this.selectedIndex - 1) }, moveDown: function () { this.selectedIndex !== this.suggestions.length - 1 && this.adjustScroll(this.selectedIndex + 1) }, adjustScroll: function (b) { var a, c, e; a = this.activate(b).offsetTop; c = this.container.scrollTop(); e = c + this.options.maxHeight - 25; if (a < c) this.container.scrollTop(a); else a > e && this.container.scrollTop(a - this.options.maxHeight + 25); this.el.val(this.getValue(this.suggestions[b])) }, onSelect: function (b) { var a, c; a = this.options.onSelect; c = this.suggestions[b]; b = this.data[b]; this.el.val(this.getValue(c)); d.isFunction(a) && a(c, b, this.el) }, getValue: function (b) { var a, c; a = this.options.delimiter; if (!a) return b; c = this.currentValue; a = c.split(a); if (a.length === 1) return b; return c.substr(0, c.length - a[a.length - 1].length) + b } } })(jQuery);
