﻿/*
* jqModal - Minimalist Modaling with jQuery
*   (http://dev.iceburg.net/jquery/jqModal/)
*
* Copyright (c) 2007,2008 Brice Burgess <bhb@iceburg.net>
* Dual licensed under the MIT and GPL licenses:
*   http://www.opensource.org/licenses/mit-license.php
*   http://www.gnu.org/licenses/gpl.html
* 
* $Version: 03/01/2009 +r14
*/
(function($) {
    $.fn.jqm = function(o) {
        var p = {
            overlay: 50,
            overlayClass: 'jqmOverlay',
            closeClass: 'jqmClose',
            trigger: '.jqModal',
            ajax: F,
            ajaxText: '',
            target: F,
            modal: F,
            toTop: F,
            onShow: F,
            onHide: F,
            onLoad: F
        };
        return this.each(function() {
            if (this._jqm) return H[this._jqm].c = $.extend({}, H[this._jqm].c, o); s++; this._jqm = s;
            H[s] = { c: $.extend(p, $.jqm.params, o), a: F, w: $(this).addClass('jqmID' + s), s: s };
            if (p.trigger) $(this).jqmAddTrigger(p.trigger);
        });
    };

    $.fn.jqmAddClose = function(e) { return hs(this, e, 'jqmHide'); };
    $.fn.jqmAddTrigger = function(e) { return hs(this, e, 'jqmShow'); };
    $.fn.jqmShow = function(t) { return this.each(function() { t = t || window.event; $.jqm.open(this._jqm, t); }); };
    $.fn.jqmHide = function(t) { return this.each(function() { t = t || window.event; $.jqm.close(this._jqm, t) }); };

    $.jqm = {
        hash: {},
        open: function(s, t) {
            var h = H[s], c = h.c, cc = '.' + c.closeClass, z = (parseInt(h.w.css('z-index'))), z = (z > 0) ? z : 3000, o = $('<div></div>').css({ height: '100%', width: '100%', position: 'fixed', left: 0, top: 0, 'z-index': z - 1, opacity: c.overlay / 100 }); if (h.a) return F; h.t = t; h.a = true; h.w.css('z-index', z);
            if (c.modal) { if (!A[0]) L('bind'); A.push(s); }
            else if (c.overlay > 0) h.w.jqmAddClose(o);
            else o = F;

            h.o = (o) ? o.addClass(c.overlayClass).prependTo('body') : F;
            if (ie6) { $('html,body').css({ height: '100%', width: '100%' }); if (o) { o = o.css({ position: 'absolute' })[0]; for (var y in { Top: 1, Left: 1 }) o.style.setExpression(y.toLowerCase(), "(_=(document.documentElement.scroll" + y + " || document.body.scroll" + y + "))+'px'"); } }

            if (c.ajax) {
                var r = c.target || h.w, u = c.ajax, r = (typeof r == 'string') ? $(r, h.w) : $(r), u = (u.substr(0, 1) == '@') ? $(t).attr(u.substring(1)) : u;
                r.html(c.ajaxText).load(u, function() { if (c.onLoad) c.onLoad.call(this, h); if (cc) h.w.jqmAddClose($(cc, h.w)); e(h); });
            }
            else if (cc) h.w.jqmAddClose($(cc, h.w));

            if (c.toTop && h.o) h.w.before('<span id="jqmP' + h.w[0]._jqm + '"></span>').insertAfter(h.o);
            (c.onShow) ? c.onShow(h) : h.w.show(); e(h); return F;
        },
        close: function(s) {
            var h = H[s]; if (!h.a) return F; h.a = F;
            if (A[0]) { A.pop(); if (!A[0]) L('unbind'); }
            if (h.c.toTop && h.o) $('#jqmP' + h.w[0]._jqm).after(h.w).remove();
            if (h.c.onHide) h.c.onHide(h); else { h.w.hide(); if (h.o) h.o.remove(); } return F;
        },
        params: {}
    };
    var s = 0, H = $.jqm.hash, A = [], ie6 = $.browser.msie && ($.browser.version == "6.0"), F = false,
i = $('<iframe src="javascript:false;document.write(\'\');" class="jqm"></iframe>').css({ opacity: 0 }),
e = function(h) { if (ie6) if (h.o) h.o.html('<p style="width:100%;height:100%"/>').prepend(i); else if (!$('iframe.jqm', h.w)[0]) h.w.prepend(i); f(h); },
f = function(h) { try { $(':input:visible', h.w)[0].focus(); } catch (_) { } },
L = function(t) { $()[t]("keypress", m)[t]("keydown", m)[t]("mousedown", m); },
m = function(e) { var h = H[A[A.length - 1]], r = (!$(e.target).parents('.jqmID' + h.s)[0]); if (r) f(h); return !r; },
hs = function(w, t, c) {
    return w.each(function() {
        var s = this._jqm; $(t).each(function() {
            if (!this[c]) { this[c] = []; $(this).click(function() { for (var i in { jqmShow: 1, jqmHide: 1 }) for (var s in this[i]) if (H[this[i][s]]) H[this[i][s]].w[i](this); return F; }); } this[c].push(s);
        });
    });
};
})(jQuery);

/* Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
* Licensed under the MIT License (LICENSE.txt).
*
* Version 2.1.2
*/
(function(a) { a.fn.bgiframe = (a.browser.msie && /msie 6\.0/i.test(navigator.userAgent) ? function(d) { d = a.extend({ top: "auto", left: "auto", width: "auto", height: "auto", opacity: true, src: "javascript:false;" }, d); var c = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="' + d.src + '"style="display:block;position:absolute;z-index:-1;' + (d.opacity !== false ? "filter:Alpha(Opacity='0');" : "") + "top:" + (d.top == "auto" ? "expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+'px')" : b(d.top)) + ";left:" + (d.left == "auto" ? "expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+'px')" : b(d.left)) + ";width:" + (d.width == "auto" ? "expression(this.parentNode.offsetWidth+'px')" : b(d.width)) + ";height:" + (d.height == "auto" ? "expression(this.parentNode.offsetHeight+'px')" : b(d.height)) + ';"/>'; return this.each(function() { if (a(this).children("iframe.bgiframe").length === 0) { this.insertBefore(document.createElement(c), this.firstChild) } }) } : function() { return this }); a.fn.bgIframe = a.fn.bgiframe; function b(c) { return c && c.constructor === Number ? c + "px" : c } })(jQuery);

/*
* jQuery blockUI plugin
* Version 2.18 (16-APR-2009)
* @requires jQuery v1.2.3 or later
*
* Examples at: http://malsup.com/jquery/block/
* Copyright (c) 2007-2008 M. Alsup
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* Thanks to Amir-Hossein Sobhi for some excellent contributions!
*/

; (function($) {

    if (/1\.(0|1|2)\.(0|1|2)/.test($.fn.jquery) || /^1.1/.test($.fn.jquery)) {
        alert('blockUI requires jQuery v1.2.3 or later!  You are using v' + $.fn.jquery);
        return;
    }

    $.fn._fadeIn = $.fn.fadeIn;

    // global $ methods for blocking/unblocking the entire page
    $.blockUI = function(opts) { install(window, opts); };
    $.unblockUI = function(opts) { remove(window, opts); };

    // convenience method for quick growl-like notifications  (http://www.google.com/search?q=growl)
    $.growlUI = function(title, message, timeout) {
        var $m = $('<div class="growlUI"></div>');
        if (title) $m.append('<h1>' + title + '</h1>');
        if (message) $m.append('<h2>' + message + '</h2>');
        if (timeout == undefined) timeout = 3000;
        $.blockUI({
            message: $m, fadeIn: 700, fadeOut: 1000, centerY: false,
            timeout: timeout, showOverlay: false,
            css: $.blockUI.defaults.growlCSS
        });
    };

    // plugin method for blocking element content
    $.fn.block = function(opts) {
        return this.unblock({ fadeOut: 0 }).each(function() {
            if ($.css(this, 'position') == 'static')
                this.style.position = 'relative';
            if ($.browser.msie)
                this.style.zoom = 1; // force 'hasLayout'
            install(this, opts);
        });
    };

    // plugin method for unblocking element content
    $.fn.unblock = function(opts) {
        return this.each(function() {
            remove(this, opts);
        });
    };

    $.blockUI.version = 2.18; // 2nd generation blocking at no extra cost!

    // override these in your code to change the default behavior and style
    $.blockUI.defaults = {
        // message displayed when blocking (use null for no message)
        message: '<h1>Please wait...</h1>',

        // styles for the message when blocking; if you wish to disable
        // these and use an external stylesheet then do this in your code:
        // $.blockUI.defaults.css = {};
        css: {
            padding: 0,
            margin: 0,
            width: '30%',
            top: '40%',
            left: '35%',
            textAlign: 'center',
            color: '#000',
            border: '3px solid #aaa',
            backgroundColor: '#fff',
            cursor: 'wait'
        },

        // styles for the overlay
        overlayCSS: {
            backgroundColor: '#000',
            opacity: '0.6'
        },

        // styles applied when using $.growlUI
        growlCSS: {
            width: '350px',
            top: '10px',
            left: '',
            right: '10px',
            border: 'none',
            padding: '5px',
            opacity: '0.6',
            cursor: null,
            color: '#fff',
            backgroundColor: '#000',
            '-webkit-border-radius': '10px',
            '-moz-border-radius': '10px'
        },

        iframeSrc: 'javascript:false', // 'about:blank' fails on HTTPS

        // force usage of iframe in non-IE browsers (handy for blocking over objects and applets)
        forceIframe: false,

        // z-index for the blocking overlay
        baseZ: 1000,

        // set these to true to have the message automatically centered
        centerX: true, // <-- only effects element blocking (page block controlled via css above)
        centerY: true,

        // allow body element to be stetched in ie6; this makes blocking look better
        // on "short" pages.  disable if you wish to prevent changes to the body height
        allowBodyStretch: true,

        // be default blockUI will supress tab navigation from leaving blocking content;
        constrainTabKey: true,

        // fadeIn time in millis; set to 0 to disable fadeIn on block
        fadeIn: 200,

        // fadeOut time in millis; set to 0 to disable fadeOut on unblock
        fadeOut: 400,

        // time in millis to wait before auto-unblocking; set to 0 to disable auto-unblock
        timeout: 0,

        // disable if you don't want to show the overlay
        showOverlay: true,

        // if true, focus will be placed in the first available input field when
        // page blocking
        focusInput: true,

        // suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity)
        applyPlatformOpacityRules: true,

        // callback method invoked when unblocking has completed; the callback is
        // passed the element that has been unblocked (which is the window object for page
        // blocks) and the options that were passed to the unblock call:
        //     onUnblock(element, options)
        onUnblock: null,

        // don't ask; if you really must know: http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/2f6a79a77a78e493#2f6a79a77a78e493
        quirksmodeOffsetHack: 4
    };

    // private data and functions follow...

    var ie6 = $.browser.msie && /MSIE 6.0/.test(navigator.userAgent);
    var pageBlock = null;
    var pageBlockEls = [];

    function install(el, opts) {
        var full = (el == window);
        var msg = opts && opts.message !== undefined ? opts.message : undefined;
        opts = $.extend({}, $.blockUI.defaults, opts || {});
        opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {});
        var css = $.extend({}, $.blockUI.defaults.css, opts.css || {});
        msg = msg === undefined ? opts.message : msg;

        // remove the current block (if there is one)
        if (full && pageBlock)
            remove(window, { fadeOut: 0 });

        // if an existing element is being used as the blocking content then we capture
        // its current place in the DOM (and current display style) so we can restore
        // it when we unblock
        if (msg && typeof msg != 'string' && (msg.parentNode || msg.jquery)) {
            var node = msg.jquery ? msg[0] : msg;
            var data = {};
            $(el).data('blockUI.history', data);
            data.el = node;
            data.parent = node.parentNode;
            data.display = node.style.display;
            data.position = node.style.position;
            if (data.parent)
                data.parent.removeChild(node);
        }

        var z = opts.baseZ;

        // blockUI uses 3 layers for blocking, for simplicity they are all used on every platform;
        // layer1 is the iframe layer which is used to supress bleed through of underlying content
        // layer2 is the overlay layer which has opacity and a wait cursor
        // layer3 is the message content that is displayed while blocking

        var lyr1 = ($.browser.msie) ? $('<iframe class="blockUI" style="z-index:' + (z++) + ';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="' + opts.iframeSrc + '"></iframe>')
                                : $('<div class="blockUI" style="display:none"></div>');
        var lyr2 = $('<div class="blockUI blockOverlay" style="z-index:' + (z++) + ';display:none;cursor:wait;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');
        var lyr3 = full ? $('<div class="blockUI blockMsg blockPage" style="z-index:' + z + ';display:none;position:fixed"></div>')
                    : $('<div class="blockUI blockMsg blockElement" style="z-index:' + z + ';display:none;position:absolute"></div>');

        // if we have a message, style it
        if (msg)
            lyr3.css(css);

        // style the overlay
        if (!opts.applyPlatformOpacityRules || !($.browser.mozilla && /Linux/.test(navigator.platform)))
            lyr2.css(opts.overlayCSS);
        lyr2.css('position', full ? 'fixed' : 'absolute');

        // make iframe layer transparent in IE
        if ($.browser.msie)
            lyr1.css('opacity', '0.0');

        $([lyr1[0], lyr2[0], lyr3[0]]).appendTo(full ? 'body' : el);

        // ie7 must use absolute positioning in quirks mode and to account for activex issues (when scrolling)
        var expr = $.browser.msie && ($.browser.version < 8 || !$.boxModel) && (!$.boxModel || $('object,embed', full ? null : el).length > 0);
        if (ie6 || (expr && lyr3[0].style.setExpression)) {
            // give body 100% height
            if (full && opts.allowBodyStretch && $.boxModel)
                $('html,body').css('height', '100%');

            // fix ie6 issue when blocked element has a border width
            if ((ie6 || !$.boxModel) && !full) {
                var t = sz(el, 'borderTopWidth'), l = sz(el, 'borderLeftWidth');
                var fixT = t ? '(0 - ' + t + ')' : 0;
                var fixL = l ? '(0 - ' + l + ')' : 0;
            }

            // simulate fixed position
            $.each([lyr1, lyr2, lyr3], function(i, o) {
                var s = o[0].style;
                s.position = 'absolute';
                if (i < 2) {
                    full ? s.setExpression('height', 'Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.boxModel?0:' + opts.quirksmodeOffsetHack + ') + "px"')
                     : s.setExpression('height', 'this.parentNode.offsetHeight + "px"');
                    full ? s.setExpression('width', 'jQuery.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"')
                     : s.setExpression('width', 'this.parentNode.offsetWidth + "px"');
                    if (fixL) s.setExpression('left', fixL);
                    if (fixT) s.setExpression('top', fixT);
                }
                else if (opts.centerY) {
                    if (full) s.setExpression('top', '(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"');
                    s.marginTop = 0;
                }
                else if (!opts.centerY && full) {
                    var top = (opts.css && opts.css.top) ? parseInt(opts.css.top) : 0;
                    var expression = '((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + ' + top + ') + "px"';
                    s.setExpression('top', expression);
                }
            });
        }

        // show the message
        if (msg) {
            lyr3.append(msg);
            if (msg.jquery || msg.nodeType)
                $(msg).show();
        }

        if ($.browser.msie && opts.showOverlay)
            lyr1.show(); // opacity is zero
        if (opts.fadeIn) {
            if (opts.showOverlay)
                lyr2._fadeIn(opts.fadeIn);
            if (msg)
                lyr3.fadeIn(opts.fadeIn);
        }
        else {
            if (opts.showOverlay)
                lyr2.show();
            if (msg)
                lyr3.show();
        }

        // bind key and mouse events
        bind(1, el, opts);

        if (full) {
            pageBlock = lyr3[0];
            pageBlockEls = $(':input:enabled:visible', pageBlock);
            if (opts.focusInput)
                setTimeout(focus, 20);
        }
        else
            center(lyr3[0], opts.centerX, opts.centerY);

        if (opts.timeout) {
            // auto-unblock
            var to = setTimeout(function() {
                full ? $.unblockUI(opts) : $(el).unblock(opts);
            }, opts.timeout);
            $(el).data('blockUI.timeout', to);
        }
    };

    // remove the block
    function remove(el, opts) {
        var full = el == window;
        var $el = $(el);
        var data = $el.data('blockUI.history');
        var to = $el.data('blockUI.timeout');
        if (to) {
            clearTimeout(to);
            $el.removeData('blockUI.timeout');
        }
        opts = $.extend({}, $.blockUI.defaults, opts || {});
        bind(0, el, opts); // unbind events
        var els = full ? $('body').children().filter('.blockUI') : $('.blockUI', el);

        if (full)
            pageBlock = pageBlockEls = null;

        if (opts.fadeOut) {
            els.fadeOut(opts.fadeOut);
            setTimeout(function() { reset(els, data, opts, el); }, opts.fadeOut);
        }
        else
            reset(els, data, opts, el);
    };

    // move blocking element back into the DOM where it started
    function reset(els, data, opts, el) {
        els.each(function(i, o) {
            // remove via DOM calls so we don't lose event handlers
            if (this.parentNode)
                this.parentNode.removeChild(this);
        });

        if (data && data.el) {
            data.el.style.display = data.display;
            data.el.style.position = data.position;
            if (data.parent)
                data.parent.appendChild(data.el);
            $(data.el).removeData('blockUI.history');
        }

        if (typeof opts.onUnblock == 'function')
            opts.onUnblock(el, opts);
    };

    // bind/unbind the handler
    function bind(b, el, opts) {
        var full = el == window, $el = $(el);

        // don't bother unbinding if there is nothing to unbind
        if (!b && (full && !pageBlock || !full && !$el.data('blockUI.isBlocked')))
            return;
        if (!full)
            $el.data('blockUI.isBlocked', b);

        if (b && !opts.showOverlay) // don't prevent events when overlay not in use
            return;

        // bind anchors and inputs for mouse and key events
        var events = 'mousedown mouseup keydown keypress';
        b ? $(document).bind(events, opts, handler) : $(document).unbind(events, handler);

        // former impl...
        //    var $e = $('a,:input');
        //    b ? $e.bind(events, opts, handler) : $e.unbind(events, handler);
    };

    // event handler to suppress keyboard/mouse events when blocking
    function handler(e) {
        // allow tab navigation (conditionally)
        if (e.keyCode && e.keyCode == 9) {
            if (pageBlock && e.data.constrainTabKey) {
                var els = pageBlockEls;
                var fwd = !e.shiftKey && e.target == els[els.length - 1];
                var back = e.shiftKey && e.target == els[0];
                if (fwd || back) {
                    setTimeout(function() { focus(back) }, 10);
                    return false;
                }
            }
        }
        // allow events within the message content
        if ($(e.target).parents('div.blockMsg').length > 0)
            return true;

        // allow events for content that is not being blocked
        return $(e.target).parents().children().filter('div.blockUI').length == 0;
    };

    function focus(back) {
        if (!pageBlockEls)
            return;
        var e = pageBlockEls[back === true ? pageBlockEls.length - 1 : 0];
        if (e)
            e.focus();
    };

    function center(el, x, y) {
        var p = el.parentNode, s = el.style;
        var l = ((p.offsetWidth - el.offsetWidth) / 2) - sz(p, 'borderLeftWidth');
        var t = ((p.offsetHeight - el.offsetHeight) / 2) - sz(p, 'borderTopWidth');
        if (x) s.left = l > 0 ? (l + 'px') : '0';
        if (y) s.top = t > 0 ? (t + 'px') : '0';
    };

    function sz(el, p) {
        return parseInt($.css(el, p)) || 0;
    };

})(jQuery);


/**
* jQuery.timers - Timer abstractions for jQuery
* Written by Blair Mitchelmore (blair DOT mitchelmore AT gmail DOT com)
* Licensed under the WTFPL (http://sam.zoy.org/wtfpl/).
* Date: 2009/10/16
*
* @author Blair Mitchelmore
* @version 1.2
*
**/

jQuery.fn.extend({
    everyTime: function(interval, label, fn, times) {
        return this.each(function() {
            jQuery.timer.add(this, interval, label, fn, times);
        });
    },
    oneTime: function(interval, label, fn) {
        return this.each(function() {
            jQuery.timer.add(this, interval, label, fn, 1);
        });
    },
    stopTime: function(label, fn) {
        return this.each(function() {
            jQuery.timer.remove(this, label, fn);
        });
    }
});

jQuery.extend({
    timer: {
        global: [],
        guid: 1,
        dataKey: "jQuery.timer",
        regex: /^([0-9]+(?:\.[0-9]*)?)\s*(.*s)?$/,
        powers: {
            // Yeah this is major overkill...
            'ms': 1,
            'cs': 10,
            'ds': 100,
            's': 1000,
            'das': 10000,
            'hs': 100000,
            'ks': 1000000
        },
        timeParse: function(value) {
            if (value == undefined || value == null)
                return null;
            var result = this.regex.exec(jQuery.trim(value.toString()));
            if (result[2]) {
                var num = parseFloat(result[1]);
                var mult = this.powers[result[2]] || 1;
                return num * mult;
            } else {
                return value;
            }
        },
        add: function(element, interval, label, fn, times) {
            var counter = 0;

            if (jQuery.isFunction(label)) {
                if (!times)
                    times = fn;
                fn = label;
                label = interval;
            }

            interval = jQuery.timer.timeParse(interval);

            if (typeof interval != 'number' || isNaN(interval) || interval < 0)
                return;

            if (typeof times != 'number' || isNaN(times) || times < 0)
                times = 0;

            times = times || 0;

            var timers = jQuery.data(element, this.dataKey) || jQuery.data(element, this.dataKey, {});

            if (!timers[label])
                timers[label] = {};

            fn.timerID = fn.timerID || this.guid++;

            var handler = function() {
                if ((++counter > times && times !== 0) || fn.call(element, counter) === false)
                    jQuery.timer.remove(element, label, fn);
            };

            handler.timerID = fn.timerID;

            if (!timers[label][fn.timerID])
                timers[label][fn.timerID] = window.setInterval(handler, interval);

            this.global.push(element);

        },
        remove: function(element, label, fn) {
            var timers = jQuery.data(element, this.dataKey), ret;

            if (timers) {

                if (!label) {
                    for (label in timers)
                        this.remove(element, label, fn);
                } else if (timers[label]) {
                    if (fn) {
                        if (fn.timerID) {
                            window.clearInterval(timers[label][fn.timerID]);
                            delete timers[label][fn.timerID];
                        }
                    } else {
                        for (var fn in timers[label]) {
                            window.clearInterval(timers[label][fn]);
                            delete timers[label][fn];
                        }
                    }

                    for (ret in timers[label]) break;
                    if (!ret) {
                        ret = null;
                        delete timers[label];
                    }
                }

                for (ret in timers) break;
                if (!ret)
                    jQuery.removeData(element, this.dataKey);
            }
        }
    }
});

jQuery(window).bind("unload", function() {
    jQuery.each(jQuery.timer.global, function(index, item) {
        jQuery.timer.remove(item);
    });
});


/*
* JTip
* By Cody Lindley (http://www.codylindley.com)
* Under an Attribution, Share Alike License
* JTip is built on top of the very light weight jquery library.
*/

//on page load (as soon as its ready) call JT_init
$(document).ready(JT_init);

function JT_init() {

    $("a.jTip").live("mouseover", function(e) {
        e.stopImmediatePropagation()
        JT_show($(this).attr("href"), this.id, this.name)
    })
    .live("mouseout", function(e) {
        e.stopImmediatePropagation()
        $('#JT').remove()
    })
    .live("click", function(e) {
        e.stopImmediatePropagation()
        return false;
    })
}

function JT_show(url, linkId, title) {
    if (title == false) title = "&nbsp;";
    var de = document.documentElement;
    var w = self.innerWidth || (de && de.clientWidth) || document.body.clientWidth;
    var hasArea = w - getAbsoluteLeft(linkId);
    var clickElementy = getAbsoluteTop(linkId) - 3; //set y position

    var queryString = url.replace(/^[^\?]+\??/, '');
    var params = parseQuery(queryString);
    if (params['width'] === undefined) { params['width'] = 250 };
    if (params['link'] !== undefined) {
        $('#' + linkId).bind('click', function() { window.location = params['link'] });
        $('#' + linkId).css('cursor', 'pointer');
    }

    if (hasArea > ((params['width'] * 1) + 75)) {
        $("body").append("<div id='JT' style='width:" + params['width'] * 1 + "px'><div class='tt_bottom'><div class='tt_top'><div class='tt_left'><div class='tt_right'><div class='tt_background'><div id='JT_copy'><div class='JT_loader'><div></div></div></div></div></div></div></div></div>"); //right side
        var arrowOffset = getElementWidth(linkId) + 11;
        var clickElementx = getAbsoluteLeft(linkId) + arrowOffset; //set x position
    } else {
        $("body").append("<div id='JT' style='width:" + params['width'] * 1 + "px'><div class='tt_bottom'><div class='tt_top'><div class='tt_left'><div class='tt_right'><div class='tt_background'><div id='JT_copy'><div class='JT_loader'><div></div></div></div></div></div></div></div></div></div>"); //left side
        var clickElementx = getAbsoluteLeft(linkId) - ((params['width'] * 1) - 50); //set x position
    }


    $('#JT').css({ left: clickElementx + "px", top: (clickElementy - 30) + "px" });
    $('#JT').show();

    var newUrl = '/content/ttcontent/' + url.replace('#', '') + '.html';
    $.get(newUrl, function(data) {
        $('#JT_copy').html(data);
    });

}

function getElementWidth(objectId) {
    x = document.getElementById(objectId);
    return x.offsetWidth;
}

function getAbsoluteLeft(objectId) {
    // Get an object left position from the upper left viewport corner
    o = document.getElementById(objectId)
    oLeft = o.offsetLeft            // Get left position from the parent object
    while (o.offsetParent != null) {   // Parse the parent hierarchy up to the document element
        oParent = o.offsetParent    // Get parent object reference
        oLeft += oParent.offsetLeft // Add parent left position
        o = oParent
    }
    return oLeft
}

function getAbsoluteTop(objectId) {
    // Get an object top position from the upper left viewport corner
    o = document.getElementById(objectId)
    oTop = o.offsetTop            // Get top position from the parent object
    while (o.offsetParent != null) { // Parse the parent hierarchy up to the document element
        oParent = o.offsetParent  // Get parent object reference
        oTop += oParent.offsetTop // Add parent top position
        o = oParent
    }
    return oTop
}

function parseQuery(query) {
    var Params = new Object();
    if (!query) return Params; // return empty object
    var Pairs = query.split(/[;&]/);
    for (var i = 0; i < Pairs.length; i++) {
        var KeyVal = Pairs[i].split('=');
        if (!KeyVal || KeyVal.length != 2) continue;
        var key = unescape(KeyVal[0]);
        var val = unescape(KeyVal[1]);
        val = val.replace(/\+/g, ' ');
        Params[key] = val;
    }
    return Params;
}

function blockEvents(evt) {
    if (evt.target) {
        evt.preventDefault();
    } else {
        evt.returnValue = false;
    }
}
/*=:project
scalable Inman Flash Replacement (sIFR) version 3, revision 419

=:file
Copyright: 2006 Mark Wubben.
Author: Mark Wubben, <http://novemberborn.net/>

=:history
* IFR: Shaun Inman
* sIFR 1: Mike Davidson, Shaun Inman and Tomas Jogin
* sIFR 2: Mike Davidson, Shaun Inman, Tomas Jogin and Mark Wubben

=:license
This software is licensed and provided under the CC-GNU LGPL.
See <http://creativecommons.org/licenses/LGPL/2.1/>    
*/

var sIFR = new function() { var O = this; var E = { ACTIVE: "sIFR-active", REPLACED: "sIFR-replaced", IGNORE: "sIFR-ignore", ALTERNATE: "sIFR-alternate", CLASS: "sIFR-class", LAYOUT: "sIFR-layout", FLASH: "sIFR-flash", FIX_FOCUS: "sIFR-fixfocus", DUMMY: "sIFR-dummy" }; E.IGNORE_CLASSES = [E.REPLACED, E.IGNORE, E.ALTERNATE]; this.MIN_FONT_SIZE = 6; this.MAX_FONT_SIZE = 126; this.FLASH_PADDING_BOTTOM = 5; this.VERSION = "419"; this.isActive = false; this.isEnabled = true; this.fixHover = true; this.autoInitialize = true; this.setPrefetchCookie = true; this.cookiePath = "/"; this.domains = []; this.forceWidth = true; this.fitExactly = false; this.forceTextTransform = true; this.useDomLoaded = true; this.useStyleCheck = false; this.hasFlashClassSet = false; this.repaintOnResize = true; this.replacements = []; var L = 0; var R = false; function Y() { } function D(c) { function d(e) { return e.toLocaleUpperCase() } this.normalize = function(e) { return e.replace(/\n|\r|\xA0/g, D.SINGLE_WHITESPACE).replace(/\s+/g, D.SINGLE_WHITESPACE) }; this.textTransform = function(e, f) { switch (e) { case "uppercase": return f.toLocaleUpperCase(); case "lowercase": return f.toLocaleLowerCase(); case "capitalize": return f.replace(/^\w|\s\w/g, d) } return f }; this.toHexString = function(e) { if (e.charAt(0) != "#" || e.length != 4 && e.length != 7) { return e } e = e.substring(1); return "0x" + (e.length == 3 ? e.replace(/(.)(.)(.)/, "$1$1$2$2$3$3") : e) }; this.toJson = function(g, f) { var e = ""; switch (typeof (g)) { case "string": e = '"' + f(g) + '"'; break; case "number": case "boolean": e = g.toString(); break; case "object": e = []; for (var h in g) { if (g[h] == Object.prototype[h]) { continue } e.push('"' + h + '":' + this.toJson(g[h])) } e = "{" + e.join(",") + "}"; break } return e }; this.convertCssArg = function(e) { if (!e) { return {} } if (typeof (e) == "object") { if (e.constructor == Array) { e = e.join("") } else { return e } } var l = {}; var m = e.split("}"); for (var h = 0; h < m.length; h++) { var k = m[h].match(/([^\s{]+)\s*\{(.+)\s*;?\s*/); if (!k || k.length != 3) { continue } if (!l[k[1]]) { l[k[1]] = {} } var g = k[2].split(";"); for (var f = 0; f < g.length; f++) { var n = g[f].match(/\s*([^:\s]+)\s*\:\s*([^;]+)/); if (!n || n.length != 3) { continue } l[k[1]][n[1]] = n[2].replace(/\s+$/, "") } } return l }; this.extractFromCss = function(g, f, i, e) { var h = null; if (g && g[f] && g[f][i]) { h = g[f][i]; if (e) { delete g[f][i] } } return h }; this.cssToString = function(f) { var g = []; for (var e in f) { var j = f[e]; if (j == Object.prototype[e]) { continue } g.push(e, "{"); for (var i in j) { if (j[i] == Object.prototype[i]) { continue } var h = j[i]; if (D.UNIT_REMOVAL_PROPERTIES[i]) { h = parseInt(h, 10) } g.push(i, ":", h, ";") } g.push("}") } return g.join("") }; this.escape = function(e) { return escape(e).replace(/\+/g, "%2B") }; this.encodeVars = function(e) { return e.join("&").replace(/%/g, "%25") }; this.copyProperties = function(g, f) { for (var e in g) { if (f[e] === undefined) { f[e] = g[e] } } return f }; this.domain = function() { var f = ""; try { f = document.domain } catch (g) { } return f }; this.domainMatches = function(h, g) { if (g == "*" || g == h) { return true } var f = g.lastIndexOf("*"); if (f > -1) { g = g.substr(f + 1); var e = h.lastIndexOf(g); if (e > -1 && (e + g.length) == h.length) { return true } } return false }; this.uriEncode = function(e) { return encodeURI(decodeURIComponent(e)) }; this.delay = function(f, h, g) { var e = Array.prototype.slice.call(arguments, 3); setTimeout(function() { h.apply(g, e) }, f) } } D.UNIT_REMOVAL_PROPERTIES = { leading: true, "margin-left": true, "margin-right": true, "text-indent": true }; D.SINGLE_WHITESPACE = " "; function U(e) { var d = this; function c(g, j, h) { var k = d.getStyleAsInt(g, j, e.ua.ie); if (k == 0) { k = g[h]; for (var f = 3; f < arguments.length; f++) { k -= d.getStyleAsInt(g, arguments[f], true) } } return k } this.getBody = function() { return document.getElementsByTagName("body")[0] || null }; this.querySelectorAll = function(f) { return window.parseSelector(f) }; this.addClass = function(f, g) { if (g) { g.className = ((g.className || "") == "" ? "" : g.className + " ") + f } }; this.removeClass = function(f, g) { if (g) { g.className = g.className.replace(new RegExp("(^|\\s)" + f + "(\\s|$)"), "").replace(/^\s+|(\s)\s+/g, "$1") } }; this.hasClass = function(f, g) { return new RegExp("(^|\\s)" + f + "(\\s|$)").test(g.className) }; this.hasOneOfClassses = function(h, g) { for (var f = 0; f < h.length; f++) { if (this.hasClass(h[f], g)) { return true } } return false }; this.ancestorHasClass = function(g, f) { g = g.parentNode; while (g && g.nodeType == 1) { if (this.hasClass(f, g)) { return true } g = g.parentNode } return false }; this.create = function(f, g) { var h = document.createElementNS ? document.createElementNS(U.XHTML_NS, f) : document.createElement(f); if (g) { h.className = g } return h }; this.getComputedStyle = function(h, i) { var f; if (document.defaultView && document.defaultView.getComputedStyle) { var g = document.defaultView.getComputedStyle(h, null); f = g ? g[i] : null } else { if (h.currentStyle) { f = h.currentStyle[i] } } return f || "" }; this.getStyleAsInt = function(g, i, f) { var h = this.getComputedStyle(g, i); if (f && !/px$/.test(h)) { return 0 } return parseInt(h) || 0 }; this.getWidthFromStyle = function(f) { return c(f, "width", "offsetWidth", "paddingRight", "paddingLeft", "borderRightWidth", "borderLeftWidth") }; this.getHeightFromStyle = function(f) { return c(f, "height", "offsetHeight", "paddingTop", "paddingBottom", "borderTopWidth", "borderBottomWidth") }; this.getDimensions = function(j) { var h = j.offsetWidth; var f = j.offsetHeight; if (h == 0 || f == 0) { for (var g = 0; g < j.childNodes.length; g++) { var k = j.childNodes[g]; if (k.nodeType != 1) { continue } h = Math.max(h, k.offsetWidth); f = Math.max(f, k.offsetHeight) } } return { width: h, height: f} }; this.getViewport = function() { return { width: window.innerWidth || document.documentElement.clientWidth || this.getBody().clientWidth, height: window.innerHeight || document.documentElement.clientHeight || this.getBody().clientHeight} }; this.blurElement = function(g) { try { g.blur(); return } catch (h) { } var f = this.create("input"); f.style.width = "0px"; f.style.height = "0px"; g.parentNode.appendChild(f); f.focus(); f.blur(); f.parentNode.removeChild(f) } } U.XHTML_NS = "http://www.w3.org/1999/xhtml"; function H(r) { var g = navigator.userAgent.toLowerCase(); var q = (navigator.product || "").toLowerCase(); var h = navigator.platform.toLowerCase(); this.parseVersion = H.parseVersion; this.macintosh = /^mac/.test(h); this.windows = /^win/.test(h); this.quicktime = false; this.opera = /opera/.test(g); this.konqueror = /konqueror/.test(q); this.ie = false/*@cc_on || true@*/; this.ieSupported = this.ie && !/ppc|smartphone|iemobile|msie\s5\.5/.test(g)/*@cc_on && @_jscript_version >= 5.5@*/; this.ieWin = this.ie && this.windows/*@cc_on && @_jscript_version >= 5.1@*/; this.windows = this.windows && (!this.ie || this.ieWin); this.ieMac = this.ie && this.macintosh/*@cc_on && @_jscript_version < 5.1@*/; this.macintosh = this.macintosh && (!this.ie || this.ieMac); this.safari = /safari/.test(g); this.webkit = !this.konqueror && /applewebkit/.test(g); this.khtml = this.webkit || this.konqueror; this.gecko = !this.webkit && q == "gecko"; this.ieVersion = this.ie && /.*msie\s(\d\.\d)/.exec(g) ? this.parseVersion(RegExp.$1) : "0"; this.operaVersion = this.opera && /.*opera(\s|\/)(\d+\.\d+)/.exec(g) ? this.parseVersion(RegExp.$2) : "0"; this.webkitVersion = this.webkit && /.*applewebkit\/(\d+).*/.exec(g) ? this.parseVersion(RegExp.$1) : "0"; this.geckoVersion = this.gecko && /.*rv:\s*([^\)]+)\)\s+gecko/.exec(g) ? this.parseVersion(RegExp.$1) : "0"; this.konquerorVersion = this.konqueror && /.*konqueror\/([\d\.]+).*/.exec(g) ? this.parseVersion(RegExp.$1) : "0"; this.flashVersion = 0; if (this.ieWin) { var l; var o = false; try { l = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7") } catch (m) { try { l = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); this.flashVersion = this.parseVersion("6"); l.AllowScriptAccess = "always" } catch (m) { o = this.flashVersion == this.parseVersion("6") } if (!o) { try { l = new ActiveXObject("ShockwaveFlash.ShockwaveFlash") } catch (m) { } } } if (!o && l) { this.flashVersion = this.parseVersion((l.GetVariable("$version") || "").replace(/^\D+(\d+)\D+(\d+)\D+(\d+).*/g, "$1.$2.$3")) } } else { if (navigator.plugins && navigator.plugins["Shockwave Flash"]) { var n = navigator.plugins["Shockwave Flash"].description.replace(/^.*\s+(\S+\s+\S+$)/, "$1"); var p = n.replace(/^\D*(\d+\.\d+).*$/, "$1"); if (/r/.test(n)) { p += n.replace(/^.*r(\d*).*$/, ".$1") } else { if (/d/.test(n)) { p += ".0" } } this.flashVersion = this.parseVersion(p); var j = false; for (var k = 0, c = this.flashVersion >= H.MIN_FLASH_VERSION; c && k < navigator.mimeTypes.length; k++) { var f = navigator.mimeTypes[k]; if (f.type != "application/x-shockwave-flash") { continue } if (f.enabledPlugin) { j = true; if (f.enabledPlugin.description.toLowerCase().indexOf("quicktime") > -1) { c = false; this.quicktime = true } } } if (this.quicktime || !j) { this.flashVersion = this.parseVersion("0") } } } this.flash = this.flashVersion >= H.MIN_FLASH_VERSION; this.transparencySupport = this.macintosh || this.windows; this.computedStyleSupport = this.ie || !!document.defaultView.getComputedStyle; this.fixFocus = this.gecko && this.windows; this.nativeDomLoaded = this.gecko || this.webkit && this.webkitVersion >= this.parseVersion("525") || this.konqueror && this.konquerorMajor > this.parseVersion("03") || this.opera; this.mustCheckStyle = this.khtml || this.opera; this.forcePageLoad = this.webkit && this.webkitVersion < this.parseVersion("523"); this.properDocument = typeof (document.location) == "object"; this.supported = this.flash && this.properDocument && (!this.ie || this.ieSupported) && this.computedStyleSupport && (!this.opera || this.operaVersion >= this.parseVersion("9.50")) && (!this.webkit || this.webkitVersion >= this.parseVersion("412")) && (!this.gecko || this.geckoVersion >= this.parseVersion("1.8.0.12")) && (!this.konqueror) } H.parseVersion = function(c) { return c.replace(/(^|\D)(\d+)(?=\D|$)/g, function(f, e, g) { f = e; for (var d = 4 - g.length; d >= 0; d--) { f += "0" } return f + g }) }; H.MIN_FLASH_VERSION = H.parseVersion("8"); function F(c) { this.fix = c.ua.ieWin && window.location.hash != ""; var d; this.cache = function() { d = document.title }; function e() { document.title = d } this.restore = function() { if (this.fix) { setTimeout(e, 0) } } } function S(l) { var e = null; function c() { try { if (l.ua.ie || document.readyState != "loaded" && document.readyState != "complete") { document.documentElement.doScroll("left") } } catch (n) { return setTimeout(c, 10) } i() } function i() { if (l.useStyleCheck) { h() } else { if (!l.ua.mustCheckStyle) { d(null, true) } } } function h() { e = l.dom.create("div", E.DUMMY); l.dom.getBody().appendChild(e); m() } function m() { if (l.dom.getComputedStyle(e, "marginLeft") == "42px") { g() } else { setTimeout(m, 10) } } function g() { if (e && e.parentNode) { e.parentNode.removeChild(e) } e = null; d(null, true) } function d(n, o) { l.initialize(o); if (n && n.type == "load") { if (document.removeEventListener) { document.removeEventListener("DOMContentLoaded", d, false) } if (window.removeEventListener) { window.removeEventListener("load", d, false) } } } function j() { l.prepareClearReferences(); if (document.readyState == "interactive") { document.attachEvent("onstop", f); setTimeout(function() { document.detachEvent("onstop", f) }, 0) } } function f() { document.detachEvent("onstop", f); k() } function k() { l.clearReferences() } this.attach = function() { if (window.addEventListener) { window.addEventListener("load", d, false) } else { window.attachEvent("onload", d) } if (!l.useDomLoaded || l.ua.forcePageLoad || l.ua.ie && window.top != window) { return } if (l.ua.nativeDomLoaded) { document.addEventListener("DOMContentLoaded", i, false) } else { if (l.ua.ie || l.ua.khtml) { c() } } }; this.attachUnload = function() { if (!l.ua.ie) { return } window.attachEvent("onbeforeunload", j); window.attachEvent("onunload", k) } } var Q = "sifrFetch"; function N(c) { var e = false; this.fetchMovies = function(f) { if (c.setPrefetchCookie && new RegExp(";?" + Q + "=true;?").test(document.cookie)) { return } try { e = true; d(f) } catch (g) { if (c.debug) { throw g } } if (c.setPrefetchCookie) { document.cookie = Q + "=true;path=" + c.cookiePath } }; this.clear = function() { if (!e) { return } try { var f = document.getElementsByTagName("script"); for (var g = f.length - 1; g >= 0; g--) { var h = f[g]; if (h.type == "sifr/prefetch") { h.parentNode.removeChild(h) } } } catch (j) { } }; function d(f) { for (var g = 0; g < f.length; g++) { document.write('<script defer type="sifr/prefetch" src="' + f[g].src + '"><\/script>') } } } function b(e) { var g = e.ua.ie; var f = g && e.ua.flashVersion < e.ua.parseVersion("9.0.115"); var d = {}; var c = {}; this.fixFlash = f; this.register = function(h) { if (!g) { return } var i = h.getAttribute("id"); this.cleanup(i, false); c[i] = h; delete d[i]; if (f) { window[i] = h } }; this.reset = function() { if (!g) { return false } for (var j = 0; j < e.replacements.length; j++) { var h = e.replacements[j]; var k = c[h.id]; if (!d[h.id] && (!k.parentNode || k.parentNode.nodeType == 11)) { h.resetMovie(); d[h.id] = true } } return true }; this.cleanup = function(l, h) { var i = c[l]; if (!i) { return } for (var k in i) { if (typeof (i[k]) == "function") { i[k] = null } } c[l] = null; if (f) { window[l] = null } if (i.parentNode) { if (h && i.parentNode.nodeType == 1) { var j = document.createElement("div"); j.style.width = i.offsetWidth + "px"; j.style.height = i.offsetHeight + "px"; i.parentNode.replaceChild(j, i) } else { i.parentNode.removeChild(i) } } }; this.prepareClearReferences = function() { if (!f) { return } __flash_unloadHandler = function() { }; __flash_savedUnloadHandler = function() { } }; this.clearReferences = function() { if (f) { var j = document.getElementsByTagName("object"); for (var h = j.length - 1; h >= 0; h--) { c[j[h].getAttribute("id")] = j[h] } } for (var k in c) { if (Object.prototype[k] != c[k]) { this.cleanup(k, true) } } } } function K(d, g, f, c, e) { this.sIFR = d; this.id = g; this.vars = f; this.movie = null; this.__forceWidth = c; this.__events = e; this.__resizing = 0 } K.prototype = { getFlashElement: function() { return document.getElementById(this.id) }, getAlternate: function() { return document.getElementById(this.id + "_alternate") }, getAncestor: function() { var c = this.getFlashElement().parentNode; return !this.sIFR.dom.hasClass(E.FIX_FOCUS, c) ? c : c.parentNode }, available: function() { var c = this.getFlashElement(); return c && c.parentNode }, call: function(c) { var d = this.getFlashElement(); return Function.prototype.apply.call(d[c], d, Array.prototype.slice.call(arguments, 1)) }, attempt: function() { if (!this.available()) { return false } try { this.call.apply(this, arguments) } catch (c) { if (this.sIFR.debug) { throw c } return false } return true }, updateVars: function(c, e) { for (var d = 0; d < this.vars.length; d++) { if (this.vars[d].split("=")[0] == c) { this.vars[d] = c + "=" + e; break } } var f = this.sIFR.util.encodeVars(this.vars); this.movie.injectVars(this.getFlashElement(), f); this.movie.injectVars(this.movie.html, f) }, storeSize: function(c, d) { this.movie.setSize(c, d); this.updateVars(c, d) }, fireEvent: function(c) { if (this.available() && this.__events[c]) { this.sIFR.util.delay(0, this.__events[c], this, this) } }, resizeFlashElement: function(c, d, e) { if (!this.available()) { return } this.__resizing++; var f = this.getFlashElement(); f.setAttribute("height", c); this.updateVars("renderheight", c); this.storeSize("height", c); if (d !== null) { f.setAttribute("width", d); this.movie.setSize("width", d) } if (this.__events.onReplacement) { this.sIFR.util.delay(0, this.__events.onReplacement, this, this); delete this.__events.onReplacement } if (e) { this.sIFR.util.delay(0, function() { this.attempt("scaleMovie"); this.__resizing-- }, this) } else { this.__resizing-- } }, blurFlashElement: function() { if (this.available()) { this.sIFR.dom.blurElement(this.getFlashElement()) } }, resetMovie: function() { this.sIFR.util.delay(0, this.movie.reset, this.movie, this.getFlashElement(), this.getAlternate()) }, resizeAfterScale: function() { if (this.available() && this.__resizing == 0) { this.sIFR.util.delay(0, this.resize, this) } }, resize: function() { if (!this.available()) { return } this.__resizing++; var g = this.getFlashElement(); var f = g.offsetWidth; if (f == 0) { return } var e = g.getAttribute("width"); var l = g.getAttribute("height"); var m = this.getAncestor(); var o = this.sIFR.dom.getHeightFromStyle(m); g.style.width = "1px"; g.style.height = "1px"; m.style.minHeight = o + "px"; var c = this.getAlternate().childNodes; var n = []; for (var k = 0; k < c.length; k++) { var h = c[k].cloneNode(true); n.push(h); m.appendChild(h) } var d = this.sIFR.dom.getWidthFromStyle(m); for (var k = 0; k < n.length; k++) { m.removeChild(n[k]) } g.style.width = g.style.height = m.style.minHeight = ""; g.setAttribute("width", this.__forceWidth ? d : e); g.setAttribute("height", l); if (sIFR.ua.ie) { g.style.display = "none"; var j = g.offsetHeight; g.style.display = "" } if (d != f) { if (this.__forceWidth) { this.storeSize("width", d) } this.attempt("resize", d) } this.__resizing-- }, replaceText: function(g, j) { var d = this.sIFR.util.escape(g); if (!this.attempt("replaceText", d)) { return false } this.updateVars("content", d); var f = this.getAlternate(); if (j) { while (f.firstChild) { f.removeChild(f.firstChild) } for (var c = 0; c < j.length; c++) { f.appendChild(j[c]) } } else { try { f.innerHTML = g } catch (h) { } } return true }, changeCSS: function(c) { c = this.sIFR.util.escape(this.sIFR.util.cssToString(this.sIFR.util.convertCssArg(c))); this.updateVars("css", c); return this.attempt("changeCSS", c) }, remove: function() { if (this.movie && this.available()) { this.movie.remove(this.getFlashElement(), this.id) } } }; var X = new function() { this.create = function(p, n, j, i, f, e, g, o, l, h, m) { var k = p.ua.ie ? d : c; return new k(p, n, j, i, f, e, g, o, ["flashvars", l, "wmode", h, "bgcolor", m, "allowScriptAccess", "always", "quality", "best"]) }; function c(s, q, l, h, f, e, g, r, n) { var m = s.dom.create("object", E.FLASH); var p = ["type", "application/x-shockwave-flash", "id", f, "name", f, "data", e, "width", g, "height", r]; for (var o = 0; o < p.length; o += 2) { m.setAttribute(p[o], p[o + 1]) } var j = m; if (h) { j = W.create("div", E.FIX_FOCUS); j.appendChild(m) } for (var o = 0; o < n.length; o += 2) { if (n[o] == "name") { continue } var k = W.create("param"); k.setAttribute("name", n[o]); k.setAttribute("value", n[o + 1]); m.appendChild(k) } while (l.firstChild) { l.removeChild(l.firstChild) } l.appendChild(j); this.html = j.cloneNode(true) } c.prototype = { reset: function(e, f) { e.parentNode.replaceChild(this.html.cloneNode(true), e) }, remove: function(e, f) { e.parentNode.removeChild(e) }, setSize: function(e, f) { this.html.setAttribute(e, f) }, injectVars: function(e, g) { var h = e.getElementsByTagName("param"); for (var f = 0; f < h.length; f++) { if (h[f].getAttribute("name") == "flashvars") { h[f].setAttribute("value", g); break } } } }; function d(p, n, j, h, f, e, g, o, k) { this.dom = p.dom; this.broken = n; this.html = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="' + f + '" width="' + g + '" height="' + o + '" class="' + E.FLASH + '"><param name="movie" value="' + e + '"></param></object>'; var m = ""; for (var l = 0; l < k.length; l += 2) { m += '<param name="' + k[l] + '" value="' + k[l + 1] + '"></param>' } this.html = this.html.replace(/(<\/object>)/, m + "$1"); j.innerHTML = this.html; this.broken.register(j.firstChild) } d.prototype = { reset: function(f, g) { g = g.cloneNode(true); var e = f.parentNode; e.innerHTML = this.html; this.broken.register(e.firstChild); e.appendChild(g) }, remove: function(e, f) { this.broken.cleanup(f) }, setSize: function(e, f) { this.html = this.html.replace(e == "height" ? /(height)="\d+"/ : /(width)="\d+"/, '$1="' + f + '"') }, injectVars: function(e, f) { if (e != this.html) { return } this.html = this.html.replace(/(flashvars(=|\"\svalue=)\")[^\"]+/, "$1" + f) } } }; this.errors = new Y(O); var A = this.util = new D(O); var W = this.dom = new U(O); var T = this.ua = new H(O); var G = { fragmentIdentifier: new F(O), pageLoad: new S(O), prefetch: new N(O), brokenFlashIE: new b(O) }; this.__resetBrokenMovies = G.brokenFlashIE.reset; var J = { kwargs: [], replaceAll: function(d) { for (var c = 0; c < this.kwargs.length; c++) { O.replace(this.kwargs[c]) } if (!d) { this.kwargs = [] } } }; this.activate = function() { if (!T.supported || !this.isEnabled || this.isActive || !C() || a()) { return } G.prefetch.fetchMovies(arguments); this.isActive = true; this.setFlashClass(); G.fragmentIdentifier.cache(); G.pageLoad.attachUnload(); if (!this.autoInitialize) { return } G.pageLoad.attach() }; this.setFlashClass = function() { if (this.hasFlashClassSet) { return } W.addClass(E.ACTIVE, W.getBody() || document.documentElement); this.hasFlashClassSet = true }; this.removeFlashClass = function() { if (!this.hasFlashClassSet) { return } W.removeClass(E.ACTIVE, W.getBody()); W.removeClass(E.ACTIVE, document.documentElement); this.hasFlashClassSet = false }; this.initialize = function(c) { if (!this.isActive || !this.isEnabled) { return } if (R) { if (!c) { J.replaceAll(false) } return } R = true; J.replaceAll(c); if (O.repaintOnResize) { if (window.addEventListener) { window.addEventListener("resize", Z, false) } else { window.attachEvent("onresize", Z) } } G.prefetch.clear() }; this.replace = function(w, t) { if (!T.supported) { return } if (t) { w = A.copyProperties(w, t) } if (!R) { return J.kwargs.push(w) } if (this.onReplacementStart) { this.onReplacementStart(w) } var AL = w.elements || W.querySelectorAll(w.selector); if (AL.length == 0) { return } var v = M(w.src); var AQ = A.convertCssArg(w.css); var u = B(w.filters); var AM = w.forceSingleLine === true; var AR = w.preventWrap === true && !AM; var p = AM || (w.fitExactly == null ? this.fitExactly : w.fitExactly) === true; var AC = p || (w.forceWidth == null ? this.forceWidth : w.forceWidth) === true; var r = w.ratios || []; var AD = w.pixelFont === true; var q = parseInt(w.tuneHeight) || 0; var y = !!w.onRelease || !!w.onRollOver || !!w.onRollOut; if (p) { A.extractFromCss(AQ, ".sIFR-root", "text-align", true) } var s = A.extractFromCss(AQ, ".sIFR-root", "font-size", true) || "0"; var e = A.extractFromCss(AQ, ".sIFR-root", "background-color", true) || "#FFFFFF"; var n = A.extractFromCss(AQ, ".sIFR-root", "kerning", true) || ""; var AV = A.extractFromCss(AQ, ".sIFR-root", "opacity", true) || "100"; var k = A.extractFromCss(AQ, ".sIFR-root", "cursor", true) || "default"; var AO = parseInt(A.extractFromCss(AQ, ".sIFR-root", "leading")) || 0; var AI = w.gridFitType || (A.extractFromCss(AQ, ".sIFR-root", "text-align") == "right") ? "subpixel" : "pixel"; var h = this.forceTextTransform === false ? "none" : A.extractFromCss(AQ, ".sIFR-root", "text-transform", true) || "none"; s = /^\d+(px)?$/.test(s) ? parseInt(s) : 0; AV = parseFloat(AV) < 1 ? 100 * parseFloat(AV) : AV; var AB = w.modifyCss ? "" : A.cssToString(AQ); var AF = w.wmode || ""; if (!AF) { if (w.transparent) { AF = "transparent" } else { if (w.opaque) { AF = "opaque" } } } if (AF == "transparent") { if (!T.transparencySupport) { AF = "opaque" } else { e = "transparent" } } for (var AU = 0; AU < AL.length; AU++) { var AE = AL[AU]; if (W.hasOneOfClassses(E.IGNORE_CLASSES, AE) || W.ancestorHasClass(AE, E.ALTERNATE)) { continue } var AN = W.getDimensions(AE); var f = AN.height; var c = AN.width; var z = W.getComputedStyle(AE, "display"); if (!f || !c || !z || z == "none") { continue } c = W.getWidthFromStyle(AE); var m, AG; if (!s) { var AK = I(AE); m = Math.min(this.MAX_FONT_SIZE, Math.max(this.MIN_FONT_SIZE, AK.fontSize)); if (AD) { m = Math.max(8, 8 * Math.round(m / 8)) } AG = AK.lines; if (isNaN(AG) || !isFinite(AG) || AG == 0) { AG = 1 } if (AG > 1 && AO) { f += Math.round((AG - 1) * AO) } } else { m = s; AG = 1 } var d = W.create("span", E.ALTERNATE); var AW = AE.cloneNode(true); AE.parentNode.appendChild(AW); for (var AT = 0, AS = AW.childNodes.length; AT < AS; AT++) { d.appendChild(AW.childNodes[AT].cloneNode(true)) } if (w.modifyContent) { w.modifyContent(AW, w.selector) } if (w.modifyCss) { AB = w.modifyCss(AQ, AW, w.selector) } var o = P(AW, h, w.uriEncode); AW.parentNode.removeChild(AW); if (w.modifyContentString) { o.text = w.modifyContentString(o.text, w.selector) } if (o.text == "") { continue } f = Math.round(AG * m); var AJ = Math.round(AG * V(m, r) * m) + this.FLASH_PADDING_BOTTOM + q; var AA = AC ? c : "100%"; var AH = "sIFR_replacement_" + L++; var AP = ["id=" + AH, "content=" + A.escape(o.text), "width=" + c, "height=" + f, "renderheight=" + AJ, "link=" + A.escape(o.primaryLink.href || ""), "target=" + A.escape(o.primaryLink.target || ""), "size=" + m, "css=" + A.escape(AB), "cursor=" + k, "tunewidth=" + (w.tuneWidth || 0), "tuneheight=" + q, "offsetleft=" + (w.offsetLeft || ""), "offsettop=" + (w.offsetTop || ""), "fitexactly=" + p, "preventwrap=" + AR, "forcesingleline=" + AM, "antialiastype=" + (w.antiAliasType || ""), "thickness=" + (w.thickness || ""), "sharpness=" + (w.sharpness || ""), "kerning=" + n, "gridfittype=" + AI, "flashfilters=" + u, "opacity=" + AV, "blendmode=" + (w.blendMode || ""), "selectable=" + (w.selectable == null || AF != "" && !sIFR.ua.macintosh && sIFR.ua.gecko && sIFR.ua.geckoVersion >= sIFR.ua.parseVersion("1.9") ? "true" : w.selectable === true), "fixhover=" + (this.fixHover === true), "events=" + y, "delayrun=" + G.brokenFlashIE.fixFlash, "version=" + this.VERSION]; var x = A.encodeVars(AP); var g = new K(O, AH, AP, AC, { onReplacement: w.onReplacement, onRollOver: w.onRollOver, onRollOut: w.onRollOut, onRelease: w.onRelease }); g.movie = X.create(sIFR, G.brokenFlashIE, AE, T.fixFocus && w.fixFocus, AH, v, AA, AJ, x, AF, e); this.replacements.push(g); this.replacements[AH] = g; if (w.selector) { if (!this.replacements[w.selector]) { this.replacements[w.selector] = [g] } else { this.replacements[w.selector].push(g) } } d.setAttribute("id", AH + "_alternate"); AE.appendChild(d); W.addClass(E.REPLACED, AE) } G.fragmentIdentifier.restore() }; this.getReplacementByFlashElement = function(d) { for (var c = 0; c < O.replacements.length; c++) { if (O.replacements[c].id == d.getAttribute("id")) { return O.replacements[c] } } }; this.redraw = function() { for (var c = 0; c < O.replacements.length; c++) { O.replacements[c].resetMovie() } }; this.prepareClearReferences = function() { G.brokenFlashIE.prepareClearReferences() }; this.clearReferences = function() { G.brokenFlashIE.clearReferences(); G = null; J = null; delete O.replacements }; function C() { if (O.domains.length == 0) { return true } var d = A.domain(); for (var c = 0; c < O.domains.length; c++) { if (A.domainMatches(d, O.domains[c])) { return true } } return false } function a() { if (document.location.protocol == "file:") { if (O.debug) { O.errors.fire("isFile") } return true } return false } function M(c) { if (T.ie && c.charAt(0) == "/") { c = window.location.toString().replace(/([^:]+)(:\/?\/?)([^\/]+).*/, "$1$2$3") + c } return c } function V(d, e) { for (var c = 0; c < e.length; c += 2) { if (d <= e[c]) { return e[c + 1] } } return e[e.length - 1] || 1 } function B(g) { var e = []; for (var d in g) { if (g[d] == Object.prototype[d]) { continue } var c = g[d]; d = [d.replace(/filter/i, "") + "Filter"]; for (var f in c) { if (c[f] == Object.prototype[f]) { continue } d.push(f + ":" + A.escape(A.toJson(c[f], A.toHexString))) } e.push(d.join(",")) } return A.escape(e.join(";")) } function Z(d) { var e = Z.viewport; var c = W.getViewport(); if (e && c.width == e.width && c.height == e.height) { return } Z.viewport = c; if (O.replacements.length == 0) { return } if (Z.timer) { clearTimeout(Z.timer) } Z.timer = setTimeout(function() { delete Z.timer; for (var f = 0; f < O.replacements.length; f++) { O.replacements[f].resize() } }, 200) } function I(g) { var h, d; if (!T.ie) { h = W.getStyleAsInt(g, "lineHeight"); d = Math.floor(W.getStyleAsInt(g, "height") / h) } else { if (T.ie) { var h = W.getComputedStyle(g, "fontSize"); if (h.indexOf("px") > 0) { h = parseInt(h) } else { var f = g.innerHTML; g.style.visibility = "visible"; g.style.overflow = "visible"; g.style.position = "static"; g.style.zoom = "normal"; g.style.writingMode = "lr-tb"; g.style.width = g.style.height = "auto"; g.style.maxWidth = g.style.maxHeight = g.style.styleFloat = "none"; var i = g; var c = g.currentStyle.hasLayout; if (c) { g.innerHTML = '<div class="' + E.LAYOUT + '">X<br>X<br>X</div>'; i = g.firstChild } else { g.innerHTML = "X<br>X<br>X" } var e = i.getClientRects(); h = e[1].bottom - e[1].top; h = Math.ceil(h * 0.8); if (c) { g.innerHTML = '<div class="' + E.LAYOUT + '">' + f + "</div>"; i = g.firstChild } else { g.innerHTML = f } e = i.getClientRects(); d = e.length; if (c) { g.innerHTML = f } g.style.visibility = g.style.width = g.style.height = g.style.maxWidth = g.style.maxHeight = g.style.overflow = g.style.styleFloat = g.style.position = g.style.zoom = g.style.writingMode = "" } } } return { fontSize: h, lines: d} } function P(c, g, s) { s = s || A.uriEncode; var q = [], m = []; var k = null; var e = c.childNodes; var o = false, p = false; var j = 0; while (j < e.length) { var f = e[j]; if (f.nodeType == 3) { var t = A.textTransform(g, A.normalize(f.nodeValue)).replace(/</g, "&lt;"); if (o && p) { t = t.replace(/^\s+/, "") } m.push(t); o = /\s$/.test(t); p = false } if (f.nodeType == 1 && !/^(style|script)$/i.test(f.nodeName)) { var h = []; var r = f.nodeName.toLowerCase(); var n = f.className || ""; if (/\s+/.test(n)) { if (n.indexOf(E.CLASS) > -1) { n = n.match("(\\s|^)" + E.CLASS + "-([^\\s$]*)(\\s|$)")[2] } else { n = n.match(/^([^\s]+)/)[1] } } if (n != "") { h.push('class="' + n + '"') } if (r == "a") { var d = s(f.getAttribute("href") || ""); var l = f.getAttribute("target") || ""; h.push('href="' + d + '"', 'target="' + l + '"'); if (!k) { k = { href: d, target: l} } } m.push("<" + r + (h.length > 0 ? " " : "") + h.join(" ") + ">"); p = true; if (f.hasChildNodes()) { q.push(j); j = 0; e = f.childNodes; continue } else { if (!/^(br|img)$/i.test(f.nodeName)) { m.push("</", f.nodeName.toLowerCase(), ">") } } } if (q.length > 0 && !f.nextSibling) { do { j = q.pop(); e = f.parentNode.parentNode.childNodes; f = e[j]; if (f) { m.push("</", f.nodeName.toLowerCase(), ">") } } while (j == e.length - 1 && q.length > 0) } j++ } return { text: m.join("").replace(/^\s+|\s+$|\s*(<br>)\s*/g, "$1"), primaryLink: k || {}} } };
var parseSelector = (function() { var B = /\s*,\s*/; var A = /\s*([\s>+~(),]|^|$)\s*/g; var L = /([\s>+~,]|[^(]\+|^)([#.:@])/g; var F = /(^|\))[^\s>+~]/g; var M = /(\)|^)/; var K = /[\s#.:>+~()@]|[^\s#.:>+~()@]+/g; function H(R, P) { P = P || document.documentElement; var S = R.split(B), X = []; for (var U = 0; U < S.length; U++) { var N = [P], W = G(S[U]); for (var T = 0; T < W.length; ) { var Q = W[T++], O = W[T++], V = ""; if (W[T] == "(") { while (W[T++] != ")" && T < W.length) { V += W[T] } V = V.slice(0, -1) } N = I(N, Q, O, V) } X = X.concat(N) } return X } function G(N) { var O = N.replace(A, "$1").replace(L, "$1*$2").replace(F, D); return O.match(K) || [] } function D(N) { return N.replace(M, "$1 ") } function I(N, P, Q, O) { return (H.selectors[P]) ? H.selectors[P](N, Q, O) : [] } var E = { toArray: function(O) { var N = []; for (var P = 0; P < O.length; P++) { N.push(O[P]) } return N } }; var C = { isTag: function(O, N) { return (N == "*") || (N.toLowerCase() == O.nodeName.toLowerCase()) }, previousSiblingElement: function(N) { do { N = N.previousSibling } while (N && N.nodeType != 1); return N }, nextSiblingElement: function(N) { do { N = N.nextSibling } while (N && N.nodeType != 1); return N }, hasClass: function(N, O) { return (O.className || "").match("(^|\\s)" + N + "(\\s|$)") }, getByTag: function(N, O) { return O.getElementsByTagName(N) } }; var J = { "#": function(N, P) { for (var O = 0; O < N.length; O++) { if (N[O].getAttribute("id") == P) { return [N[O]] } } return [] }, " ": function(O, Q) { var N = []; for (var P = 0; P < O.length; P++) { N = N.concat(E.toArray(C.getByTag(Q, O[P]))) } return N }, ">": function(O, R) { var N = []; for (var Q = 0, S; Q < O.length; Q++) { S = O[Q]; for (var P = 0, T; P < S.childNodes.length; P++) { T = S.childNodes[P]; if (T.nodeType == 1 && C.isTag(T, R)) { N.push(T) } } } return N }, ".": function(O, Q) { var N = []; for (var P = 0, R; P < O.length; P++) { R = O[P]; if (C.hasClass([Q], R)) { N.push(R) } } return N }, ":": function(N, P, O) { return (H.pseudoClasses[P]) ? H.pseudoClasses[P](N, O) : [] } }; H.selectors = J; H.pseudoClasses = {}; H.util = E; H.dom = C; return H })();


function mask(str, textbox, loc, delim) {
    var locs = loc.split(',');
    for (var i = 0; i <= locs.length; i++) {
        for (var k = 0; k <= str.length; k++) {
            if (k == locs[i]) {
                if (str.substring(k, k + 1) != delim) {
                    if (event.keyCode != 8) { //backspace
                        str = str.substring(0, k) + delim + str.substring(k, str.length);
                    }
                }
            }
        }
    }
    textbox.value = str
}

function camelcase(str) {

    // split string on spaces
    arrStr = str.split(" ");

    var strOut = "";

    for (i = 0; i < arrStr.length; i++) {
        // split string
        firstChar = arrStr[i].substring(0, 1);
        remainChar = arrStr[i].substring(1);

        // convert case
        firstChar = firstChar.toUpperCase();
        remainChar = remainChar.toLowerCase();

        strOut += firstChar + remainChar + " ";
    }

    // return string, but drop the last space
    return strOut.substring(0, strOut.length - 1);

}

function changeCase(frmValue) {

    alert(frmValue);

    var index;
    var tmpStr;
    var tmpChar;
    var preString;
    var postString;
    var strlen;
    tmpStr = frmValue.toLowerCase();
    strLen = tmpStr.length;

    if (strLen > 0) {
        for (index = 0; index < strLen; index++) {
            if (index == 0) {
                tmpChar = tmpStr.substring(0, 1).toUpperCase();
                postString = tmpStr.substring(1, strLen);
                tmpStr = tmpChar + postString;
            }
            else {
                tmpChar = tmpStr.substring(index, index + 1);
                if (tmpChar == " " && index < (strLen - 1)) {
                    tmpChar = tmpStr.substring(index + 1, index + 2).toUpperCase();
                    preString = tmpStr.substring(0, index + 1);
                    postString = tmpStr.substring(index + 2, strLen);
                    tmpStr = preString + tmpChar + postString;
                }
            }
        }
    }
    return tmpStr;
}

var CTRL_PASTE = 22;
var CTRL_COPY = 3;
var CTRL_CUT = 24;
var TAB_KEY = 9;
var DELETE_KEY = 46;
var BACKSPACE_KEY = 8;
var ENTER_KEY = 13;
var RIGHT_ARROW_KEY = 39;
var DOWN_ARROW_KEY = 40;
var UP_ARROW_KEY = 38;
var LEFT_ARROW_KEY = 37;
var HOME_KEY = 36;
var END_KEY = 35;
var PAGEUP_KEY = 33;
var PAGEDOWN_KEY = 34;
var CAPS_LOCK_KEY = 20;
var ESCAPE_KEY = 27;
function tbMask(textBox) {
    var keyCode = event.keyCode;
    var keyCharacter = cleanKeyCode(keyCode);
    var retVal = false;
    var mask = textBox.mask;
    switch (keyCode) {
        case BACKSPACE_KEY:
            var c = getCursorPos(textBox);
            if (c > 0) {
                var currentMaskChar;
                // get next available char to delete except mask chars 
                while (c > 0) {
                    c--;
                    currentMaskChar = mask.charAt(c);
                    if (currentMaskChar == '9' || currentMaskChar == 'X' || currentMaskChar == 'A') {
                        // found a spot.....replace that char with '_' 
                        var x = textBox.value.substring(0, c);
                        var y = textBox.value.substring(c + 1, textBox.value.length);
                        textBox.value = x + '_' + y;
                        setCursorPos(textBox, c);
                        textBox.curPos = c;
                        break;
                    }
                }
            }
            break;
        case TAB_KEY: // keep track of cursor b4 tabbing out of field 
            var c = getCursorPos(textBox);
            textBox.curPos = c;
            retVal = true;
            break;
        case HOME_KEY: // just move/keep track of cursor 
            setCursorPos(textBox, 0);
            textBox.curPos = c;
            break;
        case END_KEY: // just move/keep track of cursor 
            setCursorPos(textBox, textBox.value.length);
            textBox.curPos = textBox.value.length;
            break;
        case ENTER_KEY:
            retVal = true;
            break;
        case DELETE_KEY:
            var c = getCursorPos(textBox);
            if (c > -1) {
                var currentMaskChar = mask.charAt(c);
                // only allow delete if it's a valid char 
                if (currentMaskChar == '9' || currentMaskChar == 'X' || currentMaskChar == 'A') {
                    var x = textBox.value.substring(0, c);
                    var y = textBox.value.substring(c + 1, textBox.value.length);
                    textBox.value = x + '_' + y;
                    setCursorPos(textBox, c);
                    textBox.curPos = c;
                }
            }
            break;
        case LEFT_ARROW_KEY: // just move/keep track of cursor 
            var c = getCursorPos(textBox);
            if (c > 0) {
                setCursorPos(textBox, c - 1);
                textBox.curPos = c - 1;
            }
            break;
        case RIGHT_ARROW_KEY: // just move/keep track of cursor 
            var c = getCursorPos(textBox);
            if (c < textBox.value.length) {
                setCursorPos(textBox, c + 1);
                textBox.curPos = c + 1;
            }
            break;
        default: // adding a new char somewhere in the field 
            var c = getCursorPos(textBox);
            var currentMaskChar;
            // get next available to change.....except masking chars 
            while (c < textBox.value.length) {
                currentMaskChar = mask.charAt(c);
                if (currentMaskChar == '9' || currentMaskChar == 'X' || currentMaskChar == 'A') break;
                c++;
            }
            switch (currentMaskChar) {
                case '9': // numeric only 
                    if ('0123456789'.indexOf(keyCharacter) != -1)
                        addNewKey(textBox, keyCharacter, c);
                    break;
                case 'A': // alpha only 
                    if ('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.indexOf(keyCharacter) != -1)
                        addNewKey(textBox, keyCharacter, c);
                    break;
                case 'X': // alphanumeric 
                    if ('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'.indexOf(keyCharacter) != -1)
                        addNewKey(textBox, keyCharacter, c);
                    break;
                default:
                    break;
            }
    }

    return retVal;
}


function tbPaste(textBox) {

    // grab the textBox value and the mask 
    var pastedVal = window.clipboardData.getData("Text");
    var mask = textBox.mask;
    var newVal = '';
    var curPastedVal = 0;

    for (var i = 0; i < mask.length; i++) {
        var currentMaskChar = mask.charAt(i);
        // if current mask pos allows entry 
        if (currentMaskChar == '9' || currentMaskChar == 'X' || currentMaskChar == 'A') {
            var currentPastedChar = pastedVal.charAt(curPastedVal);
            // check each current mask char against new keystroke 
            // return false if any are out of sync 
            if (currentMaskChar == '9') {
                if ('0123456789'.indexOf(currentPastedChar) == -1)
                    return false;
            } else if (currentMaskChar == 'A') {
                if ('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.indexOf(currentPastedChar) == -1)
                    return false;
            } else if (currentMaskChar == 'X') {
                if ('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'.indexOf(currentPastedChar) == -1)
                    return false;
            } else {
                return false;
            }

            // add new key 
            newVal += currentPastedChar;
            curPastedVal++;
        }
        else {
            // add mask literal 
            newVal += currentMaskChar;
        }
    }
    textBox.value = newVal;
    return false;
}
// -------------------------------------------------------------------- 
// puts masked thingie in tb ie: '(___) ___-____' 
// -------------------------------------------------------------------- 
function tbFocus(textBox) {
    var val = textBox.value;
    var mask = textBox.mask;
    var startVal = '';
    if (textBox.curPos == 'undefined' || textBox.curPos == null)
        textBox.curPos = -1;
    if (val.length == 0 || val == null) {
        for (var i = 0; i < mask.length; i++) {
            var c = mask.charAt(i);
            if (c == '9' || c == 'X' || c == 'A') {
                startVal += '_';
                if (textBox.curPos == -1) textBox.curPos = i;
            }
            else {
                startVal += c;
            }
        }
        textBox.value = startVal;
    }

    // otherwise just set proper cursor pos 
    if (textBox.curPos == -1) {
        textBox.curPos = textBox.value.length;
    }
    setCursorPos(textBox, textBox.curPos);
    // set just in case. 
    textBox.maxlength = mask.length;
    return true;
}

function cleanKeyCode(key) {
    switch (key) {
        case 96: return "0"; break;
        case 97: return "1"; break;
        case 98: return "2"; break;
        case 99: return "3"; break;
        case 100: return "4"; break;
        case 101: return "5"; break;
        case 102: return "6"; break;
        case 103: return "7"; break;
        case 104: return "8"; break;
        case 105: return "9"; break;
        default: return String.fromCharCode(key); break;
    }
}

function getCursorPos(el) {
    var sel, rng, r2, i = -1;

    if (document.selection && el.createTextRange) {
        sel = document.selection;
        if (sel) {
            r2 = sel.createRange();
            rng = el.createTextRange();
            rng.setEndPoint("EndToStart", r2);
            i = rng.text.length;
        }
    }
    return i;
}
function setCursorPos(field, pos) {
    if (field.createTextRange) {
        var r = field.createTextRange();
        r.moveStart('character', pos);
        r.collapse();
        r.select();
    }
}

function addNewKey(tb, key, pos) {
    // add the new key to the textbox at pos 
    var startSel = tb.value.substring(0, pos);
    var endSel = tb.value.substring(pos + 1, tb.value.length);
    tb.value = startSel + key + endSel;

    // advance cursor to next '_' 
    while (pos < tb.value.length) {
        curChar = tb.value.charAt(pos);
        if (curChar == '_') break;
        pos++;
    }
    setCursorPos(tb, pos);
    tb.curPos = pos;
}