// Begin ~/Scripts/jquery.utilities.js

(function($) { $.fn.reverseOrder = function() { return this.each(function() { $(this).prependTo($(this).parent()); }); }; })(jQuery); jQuery.fn.reverse = function() { return this.pushStack(this.get().reverse(), arguments); }; jQuery.fn.sort = function() { return this.pushStack([].sort.apply(this, arguments), []); };

// End ~/Scripts/jquery.utilities.js

// Begin ~/Scripts/jquery.autocomplete.js

jQuery.autocomplete = function(input, options) {
    var me = this; var $input = $(input).attr("autocomplete", "off"); if (options.inputClass) $input.addClass(options.inputClass); var results = document.createElement("div"); var $results = $(results); $results.hide().addClass(options.resultsClass).css("position", "absolute"); if (options.width > 0) $results.css("width", options.width); $("body").append(results); input.autocompleter = me; var timeout = null; var prev = null; var active = -1; var cache = {}; var keyb = false; var hasFocus = false; var lastKeyPressCode = null; function flushCache() { cache = {}; cache.data = {}; cache.length = 0; }; flushCache(); if (options.data != null) {
        var sFirstChar = "", stMatchSets = {}, row = []; if (typeof options.url != "string") options.cacheLength = 1; for (var i = 0; i < options.data.length; i++) { row = ((typeof options.data[i] == "string") ? [options.data[i]] : options.data[i]); if (row[0].length > 0) { sFirstChar = row[0].substring(0, 1).toLowerCase(); if (!stMatchSets[sFirstChar]) stMatchSets[sFirstChar] = []; stMatchSets[sFirstChar].push(row); } }
        for (var k in stMatchSets) { options.cacheLength++; addToCache(k, stMatchSets[k]); } 
    }
    $input.keydown(function(e) {
        lastKeyPressCode = e.keyCode; switch (e.keyCode) {
            case 38: e.preventDefault(); moveSelect(-1); break; case 40: e.preventDefault(); moveSelect(1); break; case 9: case 13: if (selectCurrent()) { $input.get(0).blur(); e.preventDefault(); }
                break; default: active = -1; if (timeout) clearTimeout(timeout); timeout = setTimeout(function() { onChange(); }, options.delay); break;
        } 
    }).focus(function() {
        if (options.minChars == -1) { requestData(""); }
        hasFocus = true;
    }).blur(function() { hasFocus = false; hideResults(); }); hideResultsNow(); function onChange() { if (lastKeyPressCode == 46 || (lastKeyPressCode > 8 && lastKeyPressCode < 32)) return $results.hide(); var v = $input.val(); prev = v; if (v.length >= options.minChars) { $input.addClass(options.loadingClass); requestData(v); } else { $input.removeClass(options.loadingClass); $results.hide(); } }; function moveSelect(step) {
        var lis = $("li", results); if (!lis) return; active += step; if (active < 0) { active = 0; } else if (active >= lis.size()) { active = lis.size() - 1; }
        lis.removeClass("ac_over"); $(lis[active]).addClass("ac_over");
    }; function selectCurrent() {
        var li = $("li.ac_over", results)[0]; if (!li) { var $li = $("li", results); if (options.selectOnly) { if ($li.length == 1) li = $li[0]; } else if (options.selectFirst) { li = $li[0]; } }
        if (li) { selectItem(li); return true; } else { return false; } 
    }; function selectItem(li) {
        if (!li) { li = document.createElement("li"); li.extra = []; li.selectValue = ""; }
        var v = $.trim(li.selectValue ? li.selectValue : li.innerHTML); input.lastSelected = v; prev = v; $results.html(""); $input.val(v); hideResultsNow(); if (options.onItemSelect) setTimeout(function() { options.onItemSelect(li) }, 1);
    }; function createSelection(start, end) {
        var field = $input.get(0); if (field.createTextRange) { var selRange = field.createTextRange(); selRange.collapse(true); selRange.moveStart("character", start); selRange.moveEnd("character", end); selRange.select(); } else if (field.setSelectionRange) { field.setSelectionRange(start, end); } else { if (field.selectionStart) { field.selectionStart = start; field.selectionEnd = end; } }
        field.focus();
    }; function autoFill(sValue) { if (lastKeyPressCode != 8) { $input.val($input.val() + sValue.substring(prev.length)); createSelection(prev.length, sValue.length); } }; function showResults() { var pos = findPos(input); var iWidth = (options.width > 0) ? options.width : $input.width(); $results.css({ width: parseInt(iWidth) + "px", top: (pos.y + input.offsetHeight) + "px", left: pos.x + "px" }).show(); }; function hideResults() { if (timeout) clearTimeout(timeout); timeout = setTimeout(hideResultsNow, 200); }; function hideResultsNow() {
        if (timeout) clearTimeout(timeout); $input.removeClass(options.loadingClass); if ($results.is(":visible")) { $results.hide(); }
        if (options.mustMatch) { var v = $input.val(); if (v != input.lastSelected) { } } 
    }; function receiveData(q, data) {
        if (data) {
            $input.removeClass(options.loadingClass); results.innerHTML = ""; if (!hasFocus || data.length == 0) return hideResultsNow(); if ($.browser.msie) { $results.append(document.createElement('iframe')); }
            results.appendChild(dataToDom(data)); if (options.autoFill && ($input.val().toLowerCase() == q.toLowerCase())) autoFill(data[0][0]); showResults();
        } else { hideResultsNow(); } 
    }; function parseData(data) {
        if (!data) return null; var parsed = []; var rows = data.split(options.lineSeparator); for (var i = 0; i < rows.length; i++) { var row = $.trim(rows[i]); if (row) { parsed[parsed.length] = row.split(options.cellSeparator); } }
        return parsed;
    }; function dataToDom(data) {
        var ul = document.createElement("ul"); var num = data.length; if ((options.maxItemsToShow > 0) && (options.maxItemsToShow < num)) num = options.maxItemsToShow; for (var i = 0; i < num; i++) {
            var row = data[i]; if (!row) continue; var li = document.createElement("li"); if (options.formatItem) { li.innerHTML = options.formatItem(row, i, num); li.selectValue = row[0]; } else { li.innerHTML = row[0]; li.selectValue = row[0]; }
            var extra = null; if (row.length > 1) { extra = []; for (var j = 1; j < row.length; j++) { extra[extra.length] = row[j]; } }
            li.extra = extra; ul.appendChild(li); $(li).hover(function() { $("li", ul).removeClass("ac_over"); $(this).addClass("ac_over"); active = $("li", ul).indexOf($(this).get(0)); }, function() { $(this).removeClass("ac_over"); }).click(function(e) { e.preventDefault(); e.stopPropagation(); selectItem(this) });
        }
        return ul;
    }; function requestData(q) { if (!options.matchCase) q = q.toLowerCase(); var data = options.cacheLength ? loadFromCache(q) : null; if (data) { receiveData(q, data); } else if ((typeof options.url == "string") && (options.url.length > 0)) { $.get(makeUrl(q), function(data) { data = parseData(data); addToCache(q, data); receiveData(q, data); }); } else { $input.removeClass(options.loadingClass); } }; function makeUrl(q) {
        var url = options.url + "?q=" + encodeURI(q); for (var i in options.extraParams) { url += "&" + i + "=" + encodeURI(options.extraParams[i]); }
        return url;
    }; function loadFromCache(q) {
        if (!q) return null; if (cache.data[q]) return cache.data[q]; if (options.matchSubset) {
            for (var i = q.length - 1; i >= options.minChars; i--) {
                var qs = q.substr(0, i); var c = cache.data[qs]; if (c) {
                    var csub = []; for (var j = 0; j < c.length; j++) { var x = c[j]; var x0 = x[0]; if (matchSubset(x0, q)) { csub[csub.length] = x; } }
                    return csub;
                } 
            } 
        }
        return null;
    }; function matchSubset(s, sub) { if (!options.matchCase) s = s.toLowerCase(); var i = s.indexOf(sub); if (i == -1) return false; return i == 0 || options.matchContains; }; this.flushCache = function() { flushCache(); }; this.setExtraParams = function(p) { options.extraParams = p; }; this.findValue = function() {
        var q = $input.val(); if (!options.matchCase) q = q.toLowerCase(); var data = options.cacheLength ? loadFromCache(q) : null; if (data) { findValueCallback(q, data); } else if ((typeof options.url == "string") && (options.url.length > 0)) {
            $.get(makeUrl(q), function(data) {
                data = parseData(data)
                addToCache(q, data); findValueCallback(q, data);
            });
        } else { findValueCallback(q, null); } 
    }
    function findValueCallback(q, data) {
        if (data) $input.removeClass(options.loadingClass); var num = (data) ? data.length : 0; var li = null; for (var i = 0; i < num; i++) {
            var row = data[i]; if (row[0].toLowerCase() == q.toLowerCase()) {
                li = document.createElement("li"); if (options.formatItem) { li.innerHTML = options.formatItem(row, i, num); li.selectValue = row[0]; } else { li.innerHTML = row[0]; li.selectValue = row[0]; }
                var extra = null; if (row.length > 1) { extra = []; for (var j = 1; j < row.length; j++) { extra[extra.length] = row[j]; } }
                li.extra = extra;
            } 
        }
        if (options.onFindValue) setTimeout(function() { options.onFindValue(li) }, 1);
    }
    function addToCache(q, data) {
        if (!data || !q || !options.cacheLength) return; if (!cache.length || cache.length > options.cacheLength) { flushCache(); cache.length++; } else if (!cache[q]) { cache.length++; }
        cache.data[q] = data;
    }; function findPos(obj) {
        var curleft = obj.offsetLeft || 0; var curtop = obj.offsetTop || 0; while (obj = obj.offsetParent) {
            curleft += obj.offsetLeft
            curtop += obj.offsetTop
        }
        return { x: curleft, y: curtop };
    } 
}
jQuery.fn.autocomplete = function(url, options, data) { options = options || {}; options.url = url; options.data = ((typeof data == "object") && (data.constructor == Array)) ? data : null; options.inputClass = options.inputClass || "ac_input"; options.resultsClass = options.resultsClass || "ac_results"; options.lineSeparator = options.lineSeparator || "\n"; options.cellSeparator = options.cellSeparator || "|"; options.minChars = options.minChars || 1; options.delay = options.delay || 400; options.matchCase = options.matchCase || 0; options.matchSubset = options.matchSubset || 1; options.matchContains = options.matchContains || 0; options.cacheLength = options.cacheLength || 1; options.mustMatch = options.mustMatch || 0; options.extraParams = options.extraParams || {}; options.loadingClass = options.loadingClass || "ac_loading"; options.selectFirst = options.selectFirst || false; options.selectOnly = options.selectOnly || false; options.maxItemsToShow = options.maxItemsToShow || -1; options.autoFill = options.autoFill || false; options.width = parseInt(options.width, 10) || 0; this.each(function() { var input = this; new jQuery.autocomplete(input, options); }); return this; }
jQuery.fn.autocompleteArray = function(data, options) { return this.autocomplete(null, options, data); }
jQuery.fn.indexOf = function(e) {
    for (var i = 0; i < this.length; i++) { if (this[i] == e) return i; }
    return -1;
};
// End ~/Scripts/jquery.autocomplete.js

// Begin ~/Scripts/jquery.boxy.js

jQuery.fn.boxy = function(options) {
    options = options || {}; return this.each(function() {
        var node = this.nodeName.toLowerCase(), self = this; if (node == 'a') {
            jQuery(this).click(function() {
                var active = Boxy.linkedTo(this), href = this.getAttribute('href'), localOptions = jQuery.extend({ actuator: this, title: this.title }, options); if (active) { active.show(); } else if (href.indexOf('#') >= 0) { var content = jQuery(href.substr(href.indexOf('#'))), newContent = content.clone(true); content.remove(); localOptions.unloadOnHide = false; new Boxy(newContent, localOptions); } else { if (!localOptions.cache) localOptions.unloadOnHide = true; Boxy.load(this.href, localOptions); }
                return false;
            });
        } else if (node == 'form') { jQuery(this).bind('submit.boxy', function() { Boxy.confirm(options.message || 'Please confirm:', function() { jQuery(self).unbind('submit.boxy').submit(); }); return false; }); } 
    });
}; function Boxy(element, options) {
    this.boxy = jQuery(Boxy.WRAPPER); jQuery.data(this.boxy[0], 'boxy', this); this.visible = false; this.options = jQuery.extend({}, Boxy.DEFAULTS, options || {}); if (this.options.modal) { this.options = jQuery.extend(this.options, { center: true, draggable: false }); }
    if (this.options.actuator) { jQuery.data(this.options.actuator, 'active.boxy', this); }
    this.setContent(element || "<div></div>"); this._setupTitleBar(); this.boxy.css('display', 'none').appendTo(document.body); this.toTop(); if (this.options.fixed) { if (jQuery.browser.msie && jQuery.browser.version < 7) { this.options.fixed = false; } else { this.boxy.addClass('fixed'); } }
    if (this.options.center && Boxy._u(this.options.x, this.options.y)) { this.center(); } else { this.moveTo(Boxy._u(this.options.x) ? this.options.x : Boxy.DEFAULT_X, Boxy._u(this.options.y) ? this.options.y : Boxy.DEFAULT_Y); }
    if (this.options.show) this.show();
}; Boxy.EF = function() { }; jQuery.extend(Boxy, { WRAPPER: "<table cellspacing='0' cellpadding='0' border='0' class='boxy-wrapper'>" + "<tr><td class='top-left'></td><td class='top'></td><td class='top-right'></td></tr>" + "<tr><td class='left'></td><td class='boxy-inner'></td><td class='right'></td></tr>" + "<tr><td class='bottom-left'></td><td class='bottom'></td><td class='bottom-right'></td></tr>" + "</table>", DEFAULTS: { title: null, closeable: true, draggable: true, clone: false, actuator: null, center: true, show: true, modal: false, fixed: true, closeText: 'x', unloadOnHide: false, clickToFront: false, behaviours: Boxy.EF, afterDrop: Boxy.EF, afterShow: Boxy.EF, afterHide: Boxy.EF, beforeUnload: Boxy.EF }, DEFAULT_X: 50, DEFAULT_Y: 50, zIndex: 13370, dragConfigured: false, resizeConfigured: false, dragging: null, load: function(url, options) { options = options || {}; var ajax = { url: url, type: 'GET', dataType: 'html', cache: false, success: function(html) { html = jQuery(html); if (options.filter) html = jQuery(options.filter, html); new Boxy(html, options); } }; jQuery.each(['type', 'cache'], function() { if (this in options) { ajax[this] = options[this]; delete options[this]; } }); jQuery.ajax(ajax); }, get: function(ele) { var p = jQuery(ele).parents('.boxy-wrapper'); return p.length ? jQuery.data(p[0], 'boxy') : null; }, linkedTo: function(ele) { return jQuery.data(ele, 'active.boxy'); }, alert: function(message, callback, options) { return Boxy.ask(message, ['OK'], callback, options); }, confirm: function(message, after, options) { return Boxy.ask(message, ['OK', 'Cancel'], function(response) { if (response == 'OK') after(); }, options); }, ask: function(question, answers, callback, options) {
    options = jQuery.extend({ modal: true, closeable: false }, options || {}, { show: true, unloadOnHide: true }); var body = jQuery('<div></div>').append(jQuery('<div class="question"></div>').html(question)); var map = {}, answerStrings = []; if (answers instanceof Array) { for (var i = 0; i < answers.length; i++) { map[answers[i]] = answers[i]; answerStrings.push(answers[i]); } } else { for (var k in answers) { map[answers[k]] = k; answerStrings.push(answers[k]); } }
    var buttons = jQuery('<form class="answers"></form>'); buttons.html(jQuery.map(answerStrings, function(v) { return "<input type='button' value='" + v + "' />"; }).join(' ')); jQuery('input[type=button]', buttons).click(function() { var clicked = this; Boxy.get(this).hide(function() { if (callback) callback(map[clicked.value]); }); }); body.append(buttons); new Boxy(body, options);
}, isModalVisible: function() { return jQuery('.boxy-modal-blackout').length > 0; }, _u: function() {
    for (var i = 0; i < arguments.length; i++)
        if (typeof arguments[i] != 'undefined') return false; return true;
}, _handleResize: function(evt) { var d = jQuery(document); jQuery('.boxy-modal-blackout').css('display', 'none').css({ width: d.width(), height: d.height() }).css('display', 'block'); }, _handleDrag: function(evt) { var d; if (d = Boxy.dragging) { d[0].boxy.css({ left: evt.pageX - d[1], top: evt.pageY - d[2] }); } }, _nextZ: function() { return Boxy.zIndex++; }, _viewport: function() { var d = document.documentElement, b = document.body, w = window; return jQuery.extend(jQuery.browser.msie ? { left: b.scrollLeft || d.scrollLeft, top: b.scrollTop || d.scrollTop} : { left: w.pageXOffset, top: w.pageYOffset }, !Boxy._u(w.innerWidth) ? { width: w.innerWidth, height: w.innerHeight} : (!Boxy._u(d) && !Boxy._u(d.clientWidth) && d.clientWidth != 0 ? { width: d.clientWidth, height: d.clientHeight} : { width: b.clientWidth, height: b.clientHeight })); } 
}); Boxy.prototype = { estimateSize: function() { this.boxy.css({ visibility: 'hidden', display: 'block' }); var dims = this.getSize(); this.boxy.css('display', 'none').css('visibility', 'visible'); return dims; }, getSize: function() { return [this.boxy.width(), this.boxy.height()]; }, getContentSize: function() { var c = this.getContent(); return [c.width(), c.height()]; }, getPosition: function() { var b = this.boxy[0]; return [b.offsetLeft, b.offsetTop]; }, getCenter: function() { var p = this.getPosition(); var s = this.getSize(); return [Math.floor(p[0] + s[0] / 2), Math.floor(p[1] + s[1] / 2)]; }, getInner: function() { return jQuery('.boxy-inner', this.boxy); }, getContent: function() { return jQuery('.boxy-content', this.boxy); }, setContent: function(newContent) { newContent = jQuery(newContent).css({ display: 'block' }).addClass('boxy-content'); if (this.options.clone) newContent = newContent.clone(true); this.getContent().remove(); this.getInner().append(newContent); this._setupDefaultBehaviours(newContent); this.options.behaviours.call(this, newContent); return this; }, moveTo: function(x, y) { this.moveToX(x).moveToY(y); return this; }, moveToX: function(x) { if (typeof x == 'number') this.boxy.css({ left: x }); else this.centerX(); return this; }, moveToY: function(y) { if (typeof y == 'number') this.boxy.css({ top: y }); else this.centerY(); return this; }, centerAt: function(x, y) { var s = this[this.visible ? 'getSize' : 'estimateSize'](); if (typeof x == 'number') this.moveToX(x - s[0] / 2); if (typeof y == 'number') this.moveToY(y - s[1] / 2); return this; }, centerAtX: function(x) { return this.centerAt(x, null); }, centerAtY: function(y) { return this.centerAt(null, y); }, center: function(axis) { var v = Boxy._viewport(); var o = this.options.fixed ? [0, 0] : [v.left, v.top]; if (!axis || axis == 'x') this.centerAt(o[0] + v.width / 2, null); if (!axis || axis == 'y') this.centerAt(null, o[1] + v.height / 2); return this; }, centerX: function() { return this.center('x'); }, centerY: function() { return this.center('y'); }, resize: function(width, height, after) { if (!this.visible) return; var bounds = this._getBoundsForResize(width, height); this.boxy.css({ left: bounds[0], top: bounds[1] }); this.getContent().css({ width: bounds[2], height: bounds[3] }); if (after) after(this); return this; }, tween: function(width, height, after) { if (!this.visible) return; var bounds = this._getBoundsForResize(width, height); var self = this; this.boxy.stop().animate({ left: bounds[0], top: bounds[1] }); this.getContent().stop().animate({ width: bounds[2], height: bounds[3] }, function() { if (after) after(self); }); return this; }, isVisible: function() { return this.visible; }, show: function() {
    if (this.visible) return; if (this.options.modal) {
        var self = this; if (!Boxy.resizeConfigured) { Boxy.resizeConfigured = true; jQuery(window).resize(function() { Boxy._handleResize(); }); }
        this.modalBlackout = jQuery('<div class="boxy-modal-blackout"></div>').css({ zIndex: Boxy._nextZ(), opacity: 0.7, width: jQuery(document).width(), height: jQuery(document).height() }).appendTo(document.body); this.toTop(); if (this.options.closeable) { jQuery(document.body).bind('keypress.boxy', function(evt) { var key = evt.which || evt.keyCode; if (key == 27) { self.hide(); jQuery(document.body).unbind('keypress.boxy'); } }); } 
    }
    this.boxy.stop().css({ opacity: 1 }).show(); this.visible = true; this._fire('afterShow'); return this;
}, hide: function(after) {
    if (!this.visible) return; var self = this; if (this.options.modal) { jQuery(document.body).unbind('keypress.boxy'); this.modalBlackout.animate({ opacity: 0 }, function() { jQuery(this).remove(); }); }
    this.boxy.stop().animate({ opacity: 0 }, 300, function() { self.boxy.css({ display: 'none' }); self.visible = false; self._fire('afterHide'); if (after) after(self); if (self.options.unloadOnHide) self.unload(); }); return this;
}, toggle: function() { this[this.visible ? 'hide' : 'show'](); return this; }, hideAndUnload: function(after) { this.options.unloadOnHide = true; this.hide(after); return this; }, unload: function() { this._fire('beforeUnload'); this.boxy.remove(); if (this.options.actuator) { jQuery.data(this.options.actuator, 'active.boxy', false); } }, toTop: function() { this.boxy.css({ zIndex: Boxy._nextZ() }); return this; }, getTitle: function() { return jQuery('> .title-bar h2', this.getInner()).html(); }, setTitle: function(t) { jQuery('> .title-bar h2', this.getInner()).html(t); return this; }, _getBoundsForResize: function(width, height) { var csize = this.getContentSize(); var delta = [width - csize[0], height - csize[1]]; var p = this.getPosition(); return [Math.max(p[0] - delta[0] / 2, 0), Math.max(p[1] - delta[1] / 2, 0), width, height]; }, _setupTitleBar: function() {
    if (this.options.title) {
        var self = this; var tb = jQuery("<div class='title-bar'></div>").html("<h2>" + this.options.title + "</h2>"); if (this.options.closeable) { tb.append(jQuery("<a href='#' class='close'></a>").html(this.options.closeText)); }
        if (this.options.draggable) {
            tb[0].onselectstart = function() { return false; }
            tb[0].unselectable = 'on'; tb[0].style.MozUserSelect = 'none'; if (!Boxy.dragConfigured) { jQuery(document).mousemove(Boxy._handleDrag); Boxy.dragConfigured = true; }
            tb.mousedown(function(evt) { self.toTop(); Boxy.dragging = [self, evt.pageX - self.boxy[0].offsetLeft, evt.pageY - self.boxy[0].offsetTop]; jQuery(this).addClass('dragging'); }).mouseup(function() { jQuery(this).removeClass('dragging'); Boxy.dragging = null; self._fire('afterDrop'); });
        }
        this.getInner().prepend(tb); this._setupDefaultBehaviours(tb);
    } 
}, _setupDefaultBehaviours: function(root) {
    var self = this; if (this.options.clickToFront) { root.click(function() { self.toTop(); }); }
    jQuery('.close', root).click(function() { self.hide(); return false; }).mousedown(function(evt) { evt.stopPropagation(); });
}, _fire: function(event) { this.options[event].call(this); } 
};
// End ~/Scripts/jquery.boxy.js

// Begin ~/Scripts/jquery.growl.js

(function($) {
    $.growl = function(title, message, image, priority) { notify(title, message, image, priority); }
    $.growl.version = "1.0.0-b2"; function create(rebuild) {
        var instance = document.getElementById('growlDock'); if (!instance || rebuild) { instance = $(jQuery.growl.settings.dockTemplate).attr('id', 'growlDock').addClass('growl'); if (jQuery.growl.settings.defaultStylesheet) { $('head').append('<link rel="stylesheet" type="text/css" href="' + jQuery.growl.settings.defaultStylesheet + '" />'); } } else { instance = $(instance); }
        $('body').append(instance.css(jQuery.growl.settings.dockCss)); return instance;
    }; function r(text, expr, val) {
        while (expr.test(text)) { text = text.replace(expr, val); }
        return text;
    }; function notify(title, message, image, priority) { var instance = create(); var html = jQuery.growl.settings.noticeTemplate; if (typeof (html) == 'object') html = $(html).html(); html = r(html, /%message%/, (message ? message : '')); html = r(html, /%title%/, (title ? title : '')); html = r(html, /%image%/, (image ? image : jQuery.growl.settings.defaultImage)); html = r(html, /%priority%/, (priority ? priority : 'normal')); var notice = $(html).hide().css(jQuery.growl.settings.noticeCss).fadeIn(jQuery.growl.settings.notice); ; $.growl.settings.noticeDisplay(notice); instance.append(notice); if ($.growl.settings.displayTimeout > 0) { setTimeout(function() { jQuery.growl.settings.noticeRemove(notice, function() { notice.remove(); }); }, jQuery.growl.settings.displayTimeout); } }; $.growl.settings = { dockTemplate: '<div></div>', dockCss: { position: 'fixed', top: '10px', right: '10px', width: '300px', zIndex: 50000 }, noticeTemplate: '<div class="notice growl">' + ' <h3 style="margin-top: 15px">%title%</h3>' + ' <p>%message%</p>' + '</div>', noticeCss: { opacity: .95, backgroundColor: '#FFCC00', color: '#000' }, noticeDisplay: function(notice) { notice.css({ 'opacity': '0' }).fadeIn(jQuery.growl.settings.noticeFadeTimeout); }, noticeRemove: function(notice, callback) { notice.animate({ opacity: '0', height: '0px' }, { duration: jQuery.growl.settings.noticeFadeTimeout, complete: callback }); }, noticeFadeTimeout: 'slow', displayTimeout: 3500, defaultImage: 'growl.jpg', defaultStylesheet: null, noticeElement: function(el) { $.growl.settings.noticeTemplate = $(el); } };
})(jQuery);
// End ~/Scripts/jquery.growl.js

// Begin ~/Scripts/jquery.defaultvalue.js

(function($) {
    $.fn.defaultvalue = function() {
        var elements = this; var args = arguments; var c = 0; return (elements.each(function() {
            var el = $(this); var def = args[c++]; el.val(def).focus(function() {
                if (el.val() == def) { el.val("").removeClass("ghosttext"); }
                el.blur(function() { if (el.val() == "") { el.val(def).addClass("ghosttext"); } });
            });
        }));
    } 
})(jQuery)
// End ~/Scripts/jquery.defaultvalue.js

// Begin ~/Scripts/jquery.innerfade.js

;
(function($) {

    $.fn.innerfade = function(options) {
        return this.each(function() {
            $.innerfade(this, options);
        });
    };

    $.innerfade = function(container, options) {
        var settings = {
            'animationtype': 'fade',
            'speed': 'normal',
            'type': 'sequence',
            'timeout': 2000,
            'containerheight': 'auto',
            'runningclass': 'innerfade',
            'children': null
        };
        if (options)
            $.extend(settings, options);
        if (settings.children === null)
            var elements = $(container).children();
        else
            var elements = $(container).children(settings.children);
        if (elements.length > 1) {
            $(container).css('position', 'relative').css('height', settings.containerheight).addClass(settings.runningclass);
            for (var i = 0; i < elements.length; i++) {
                $(elements[i]).css('z-index', String(elements.length - i)).css('position', 'absolute').hide();
            };
            if (settings.type == "sequence") {
                setTimeout(function() {
                    $.innerfade.next(elements, settings, 1, 0);
                }, settings.timeout);
                $(elements[0]).show();
            } else if (settings.type == "random") {
                var last = Math.floor(Math.random() * (elements.length));
                setTimeout(function() {
                    do {
                        current = Math.floor(Math.random() * (elements.length));
                    } while (last == current);
                    $.innerfade.next(elements, settings, current, last);
                }, settings.timeout);
                $(elements[last]).show();
            } else if (settings.type == 'random_start') {
                settings.type = 'sequence';
                var current = Math.floor(Math.random() * (elements.length));
                setTimeout(function() {
                    $.innerfade.next(elements, settings, (current + 1) % elements.length, current);
                }, settings.timeout);
                $(elements[current]).show();
            } else {
                alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');
            }
        }
    };

    $.innerfade.next = function(elements, settings, current, last) {
        if (settings.animationtype == 'slide') {
            $(elements[last]).slideUp(settings.speed);
            $(elements[current]).slideDown(settings.speed);
        } else if (settings.animationtype == 'fade') {
            $(elements[last]).fadeOut(settings.speed);
            $(elements[current]).fadeIn(settings.speed, function() {
                removeFilter($(this)[0]);
            });
        } else
            alert('Innerfade-animationtype must either be \'slide\' or \'fade\'');
        if (settings.type == "sequence") {
            if ((current + 1) < elements.length) {
                current = current + 1;
                last = current - 1;
            } else {
                current = 0;
                last = elements.length - 1;
            }
        } else if (settings.type == "random") {
            last = current;
            while (current == last)
                current = Math.floor(Math.random() * elements.length);
        } else
            alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');
        setTimeout((function() {
            $.innerfade.next(elements, settings, current, last);
        }), settings.timeout);
    };

})(jQuery);

// **** remove Opacity-Filter in ie ****
function removeFilter(element) {
    if (element.style.removeAttribute) {
        element.style.removeAttribute('filter');
    }
}

// End ~/Scripts/jquery.innerfade.js

// Begin ~/Scripts/jquery.slideshow.lite-0.5.3.js

/**
 * Slideshow Lite plugin for jQuery
 *
 * v0.5.3
 *
 * Copyright (c) 2009 Fred Wu
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */

/**
 * Configuration options:
 *
 * pauseSeconds  float    number of seconds between each photo to be displayed
 * fadeSpeed     float    number of seconds for the fading transition, the value should not exceed 'pauseSeconds'
 * width         integer  width of the slideshow, in pixels
 * height        integer  height of the slideshow, in pixels
 * caption       boolean  display photo caption?
 * cssClass      string   name of the CSS class, defaults to 'slideshowlite'
 */

(function($){
	$.fn.slideshow = function(options){
		
		var defaults = {
			pauseSeconds: 2,
			fadeSpeed: 0.5,
			width: 468,
			height: 120,
			caption: true,
			cssClass: 'slideshowlite'
		};
		
		var options = $.extend(defaults, options);
		
		// ----------------------------------------
		// slideshow objects and variables
		// ----------------------------------------
		
		var target = this;
		var items  = $(target).children("a");
		var instance;
		
		// ----------------------------------------
		// some mandontory styling
		// ----------------------------------------
		
		if ( ! $(this).hasClass(options.cssClass)) $(this).addClass(options.cssClass);
		
		$(this).css({
			width: options.width + "px",
			height: options.height + "px"
		});
		
		// ----------------------------------------
		// create anchor links to make the structure simpler for manupilation
		// ----------------------------------------
		
		$(this).children("img").wrap(document.createElement("a"));
		$(this).children("a").attr("target", "blank");
		
		// ----------------------------------------
		// add item sequence markups
		// ----------------------------------------
		
		var i = 1;
		$(this).children("a").each(function(){
			$(this).attr("rel", i++);
		});
		
		// ----------------------------------------
		// create pagination and caption
		// ----------------------------------------
		
		$(this).append("<ul></ul>");
		$(this).append("<ol></ol>");
		var pagination = $(this).children("ul");
		var caption = $(this).children("ol");
		
		var i = 1;
		var j = 0;
		$(this).children("a").each(function(){
			pagination.append("<li><a href=\"#\">" + i++ + "</a></li>");
			caption.append("<li>" + $("#" + $(target).attr("id") + " img:nth(" + j++ + ")").attr("alt") + "</li>");
		});
		pagination.fadeTo(0, 0.8);
		caption.fadeTo(0, 0.6);
		caption.hide();
		
		// ----------------------------------------
		// shortcuts
		// ----------------------------------------
		
		var firstItem   = $(target).children("a:first");
		var lastItem    = $(target).children("a:last");
		var currentItem = firstItem;
		
		// ----------------------------------------
		// pagination highlight
		// ----------------------------------------
		
		var paginationHighlight = function(sequence){
			pagination.children("li").children("a").removeClass("current");
			pagination.children("li").children("a:nth(" + sequence + ")").addClass("current");
		}
		
		// ----------------------------------------
		// caption
		// ----------------------------------------
		
		var showCaption = function(sequence){
			caption.show();
			caption.children("li").hide();
			caption.children("li:nth(" + sequence + ")").fadeIn();
		}
		
		// ----------------------------------------
		// slideshow logic
		// ----------------------------------------
		
		var makeSlideshow = function(){
			
			// pagination click
			pagination.children("li").children("a").click(function(){
				if ( ! $(this).hasClass("current"))
				{
					// select the current item after the pagination click
					currentItem = $(target).children("a:nth(" + ($(this).text()-1) + ")");

					currentItem.show();
					startSlideshow();
				}
			});
			
			// pagination highlight
			paginationHighlight(currentItem.attr("rel")-1);
			
			// show caption
			if (options.caption == true)
			{
				showCaption(currentItem.attr("rel")-1);
			}
			
			// show the current slide
			currentItem.fadeIn(options.fadeSpeed*1000, function(){
				$(target).children("a").hide();
				$(this).show().css("z-index", 1);
			});
			
			// prepare for the next slide
			// determines the next item (or we need to rewind to the first item?)
			if (currentItem.children("img").attr("src") == lastItem.children("img").attr("src"))
			{
				currentItem = firstItem;
				currentItem.css("z-index", 2);
			}
			else
			{
				currentItem = currentItem.next();
			}
		};
		
		var startSlideshow = function(){
			clearInterval(instance);
			makeSlideshow();
			instance = setInterval(makeSlideshow, options.pauseSeconds*1000);
		};
		
		// ----------------------------------------
		// start the slideshow!
		// ----------------------------------------
		
		startSlideshow();
	};
})(jQuery);
// End ~/Scripts/jquery.slideshow.lite-0.5.3.js

// Begin ~/Scripts/jquery.printarea.js

(function($) {
    var printAreaCount = 0; $.fn.printArea = function() { var ele = $(this); var idPrefix = "printArea_"; removePrintArea(idPrefix + printAreaCount); printAreaCount++; var iframeId = idPrefix + printAreaCount; var iframeStyle = 'position:absolute;width:0px;height:0px;left:-500px;top:-500px;'; iframe = document.createElement('IFRAME'); $(iframe).attr({ style: iframeStyle, id: iframeId }); document.body.appendChild(iframe); var doc = iframe.contentWindow.document; $(document).find("link").filter(function() { return $(this).attr("rel").toLowerCase() == "stylesheet"; }).each(function() { doc.write('<link type="text/css" rel="stylesheet" href="' + $(this).attr("href") + '" >'); }); doc.write('<div class="' + $(ele).attr("class") + '">' + $(ele).html() + '</div>'); doc.close(); var frameWindow = iframe.contentWindow; frameWindow.close(); frameWindow.focus(); frameWindow.print(); }
    var removePrintArea = function(id) { $("iframe#" + id).remove(); };
})(jQuery);
// End ~/Scripts/jquery.printarea.js

// Begin ~/Scripts/jquery.cookie.js

/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

/**
 * Create a cookie with the given name and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 * @param String name The name of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options = $.extend({}, options); // clone object since it's unexpected behavior if the expired property were changed
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // NOTE Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
// End ~/Scripts/jquery.cookie.js

// Begin ~/Scripts/superfish.js

; (function($) {
    $.fn.superfish = function(op) { var sf = $.fn.superfish, c = sf.c, $arrow = $(['<span class="', c.arrowClass, '"> �</span>'].join('')), over = function() { var $$ = $(this), menu = getMenu($$); clearTimeout(menu.sfTimer); $$.showSuperfishUl().siblings().hideSuperfishUl(); }, out = function() { var $$ = $(this), menu = getMenu($$), o = sf.op; clearTimeout(menu.sfTimer); menu.sfTimer = setTimeout(function() { o.retainPath = ($.inArray($$[0], o.$path) > -1); $$.hideSuperfishUl(); if (o.$path.length && $$.parents(['li.', o.hoverClass].join('')).length < 1) { over.call(o.$path); } }, o.delay); }, getMenu = function($menu) { var menu = $menu.parents(['ul.', c.menuClass, ':first'].join(''))[0]; sf.op = sf.o[menu.serial]; return menu; }, addArrow = function($a) { $a.addClass(c.anchorClass).append($arrow.clone()); }; return this.each(function() { var s = this.serial = sf.o.length; var o = $.extend({}, sf.defaults, op); o.$path = $('li.' + o.pathClass, this).slice(0, o.pathLevels).each(function() { $(this).addClass([o.hoverClass, c.bcClass].join(' ')).filter('li:has(ul)').removeClass(o.pathClass); }); sf.o[s] = sf.op = o; $('li:has(ul)', this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over, out).each(function() { if (o.autoArrows) addArrow($('>a:first-child', this)); }).not('.' + c.bcClass).hideSuperfishUl(); var $a = $('a', this); $a.each(function(i) { var $li = $a.eq(i).parents('li'); $a.eq(i).focus(function() { over.call($li); }).blur(function() { out.call($li); }); }); o.onInit.call(this); }).addClass([c.menuClass, c.shadowClass].join(' ')); }; var sf = $.fn.superfish; sf.o = []; sf.op = {}; sf.IE7fix = function() {
        var o = sf.op; if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity != undefined)
            this.toggleClass(sf.c.shadowClass + '-off');
    }; sf.c = { bcClass: 'sf-breadcrumb', menuClass: 'sf-js-enabled', anchorClass: 'sf-with-ul', arrowClass: 'sf-sub-indicator', shadowClass: '' }; sf.defaults = { hoverClass: 'sfHover', pathClass: 'overideThisToUse', pathLevels: 1, delay: 25, animation: { opacity: 'show' }, speed: 20, autoArrows: false, dropShadows: false, disableHI: false, onInit: function() { }, onBeforeShow: function() { }, onShow: function() { }, onHide: function() { } }; $.fn.extend({ hideSuperfishUl: function() { var o = sf.op, not = (o.retainPath === true) ? o.$path : ''; o.retainPath = false; var $ul = $(['li.', o.hoverClass].join(''), this).add(this).not(not).removeClass(o.hoverClass).find('>ul').hide().css('visibility', 'hidden'); $ul.animate(o.animation, o.speed, function() { o.onHide.call($ul); }); return this; }, showSuperfishUl: function() { var o = sf.op, sh = sf.c.shadowClass + '-off', $ul = this.addClass(o.hoverClass).find('>ul:hidden').css('visibility', 'visible'); sf.IE7fix.call($ul); o.onBeforeShow.call($ul); return this; } });
})(jQuery);
// End ~/Scripts/superfish.js

// Begin ~/Scripts/jquery.tooltip.js

(function($) {
    $.fn.extend({ bstip: function(options) {
        var opts = $.extend({}, $.fn.bstip.defaults, options); return this.each(function(i) {
            var nowid = $(this).id, nowtitle = $(this).attr("title"), here = $(this); var nowclass = here.attr("class"), nowrel = here.attr("rel"); here.addClass("souniqueithurts"); if (nowclass == "") { newclass = ""; } else { newclass = nowclass; newclass = newclass.replace(/ /, ""); }
            if (nowid == "") { newid = ""; } else { newid = nowid; }
            if (nowrel == "") { newrel = ""; } else { newrel = nowrel; }
            if (opts.type == "tip") { $("body").append("<div class='" + opts.color + "' id='bs" + i + newclass + newid + newrel + "'>" + opts.forewrap + nowtitle + opts.backwrap + "</div>"); } else if (opts.type == "menu") { nextitem = $('#' + nowtitle); nextcont = nextitem.html(); $("body").append("<div class='" + opts.color + "' id='bs" + i + newclass + newid + newrel + "'>" + opts.forewrap + nextcont + opts.backwrap + "</div>"); nextitem.remove(); }
            var bs_tooltip = $("#bs" + i + newclass + newid + newrel); tipwidth = bs_tooltip.width()
            tipheight = bs_tooltip.height()
            offset = here.offset(); left = offset.left; right = offset.right; nwidth = $(this).width(); nheight = $(this).height(); if (opts.hook == "bottom-right" || opts.hook == "mid-right" || opts.hook == "top-right") { bleft = offset.left + nwidth + opts.xnudge; } else if (opts.hook == "bottom-mid" || opts.hook == "mid-mid" || opts.hook == "top-mid") { bleft = offset.left + (nwidth / 2) - (tipwidth / 2) + opts.xnudge; } else if (opts.hook == "bottom-left" || opts.hook == "mid-left" || opts.hook == "top-left") { bleft = offset.left - opts.xnudge - tipwidth; }
            if (opts.hook == "top-right" || opts.hook == "top-mid" || opts.hook == "top-left") { btop = offset.top - opts.ynudge - tipheight; } else if (opts.hook == "mid-right" || opts.hook == "mid-mid" || opts.hook == "mid-left") { btop = offset.top + opts.ynudge; } else if (opts.hook == "bottom-right" || opts.hook == "bottom-mid" || opts.hook == "bottom-left") { btop = offset.top + nheight + opts.ynudge; }
            bs_tooltip.css({ top: btop, left: bleft, position: "absolute", display: "none" }); if (opts.sticky == "none") { $(this).removeAttr("title").hover(function() { bs_tooltip.css({ "opacity": opts.opacity }).fadeIn(opts.speed); }, function() { t = setTimeout(function() { bs_tooltip.fadeOut(opts.speed); }, opts.tack); }); bs_tooltip.hover(function() { clearTimeout(t); }, function() { t = setTimeout(function() { bs_tooltip.fadeOut(opts.speed); }, opts.tack); }); } else if (opts.sticky == "move") {
                $(this).removeAttr("title").mouseover(function() { bs_tooltip.css({ opacity: opts.opacity, display: "none" }).fadeIn(opts.speed); }).mousemove(function(kmouse) {
                    tipwidth = bs_tooltip.width()
                    tipheight = bs_tooltip.height()
                    if (opts.hook == "bottom-right" || opts.hook == "mid-right" || opts.hook == "top-right") { bleft = kmouse.pageX + opts.xnudge; } else if (opts.hook == "bottom-mid" || opts.hook == "mid-mid" || opts.hook == "top-mid") { bleft = kmouse.pageX - (tipwidth / 2) + opts.xnudge; } else if (opts.hook == "bottom-left" || opts.hook == "mid-left" || opts.hook == "top-left") { bleft = kmouse.pageX - opts.xnudge - tipwidth; }
                    if (opts.hook == "top-right" || opts.hook == "top-mid" || opts.hook == "top-left") { btop = kmouse.pageY - tipheight - opts.ynudge; } else if (opts.hook == "mid-right" || opts.hook == "mid-mid" || opts.hook == "mid-left") { btop = kmouse.pageY - (tipheight / 2) + opts.ynudge; } else if (opts.hook == "bottom-right" || opts.hook == "bottom-mid" || opts.hook == "bottom-left") { btop = kmouse.pageY + opts.ynudge; }
                    bs_tooltip.css({ left: bleft, top: btop });
                }).mouseout(function() { bs_tooltip.fadeOut(opts.speed); });
            } else if (opts.sticky == "slide") {
                $(this).removeAttr("title").mouseover(function() { bs_tooltip.css({ opacity: opts.opacity, display: "none" }).fadeIn(opts.speed); }).mousemove(function(kmouse) {
                    if (opts.hook == "bottom-right" || opts.hook == "mid-right" || opts.hook == "top-right") { bleft = kmouse.pageX + opts.xnudge; } else if (opts.hook == "bottom-mid" || opts.hook == "mid-mid" || opts.hook == "top-mid") { bleft = kmouse.pageX - (tipwidth / 2) + opts.xnudge; } else if (opts.hook == "bottom-left" || opts.hook == "mid-left" || opts.hook == "top-left") { bleft = kmouse.pageX - opts.xnudge - tipwidth; }
                    if (opts.hook == "top-right" || opts.hook == "top-mid" || opts.hook == "top-left") { btop = top - opts.ynudge - tipheight; } else if (opts.hook == "mid-right" || opts.hook == "mid-mid" || opts.hook == "mid-left") { btop = top + opts.ynudge; } else if (opts.hook == "bottom-right" || opts.hook == "bottom-mid" || opts.hook == "bottom-left") { btop = top + nheight + opts.ynudge; }
                    bs_tooltip.css({ left: bleft, top: btop });
                }).mouseout(function() { t = setTimeout(function() { bs_tooltip.fadeOut(opts.speed); }, opts.tack); }); bs_tooltip.hover(function() { clearTimeout(t); }, function() { t = setTimeout(function() { bs_tooltip.fadeOut(opts.speed); }, opts.tack); });
            } 
        });
    } 
    }); $.fn.bstip.defaults = { sticky: 'move', forewrap: '<p>', backwrap: '</p>', hook: 'bottom-right', color: 'bstip', speed: 'fast', type: 'tip', tack: 0, keep: 2000, ynudge: 10, xnudge: 10, opacity: .9 };
})(jQuery);
// End ~/Scripts/jquery.tooltip.js

// Begin ~/Scripts/jquery.validate.min.js

/*
 * jQuery validation plug-in 1.6
 *
 * http://bassistance.de/jquery-plugins/jquery-plugin-validation/
 * http://docs.jquery.com/Plugins/Validation
 *
 * Copyright (c) 2006 - 2008 Jörn Zaefferer
 *
 * $Id: jquery.validate.js 6403 2009-06-17 14:27:16Z joern.zaefferer $
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 * 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
(function($){$.extend($.fn,{validate:function(options){if(!this.length){options&&options.debug&&window.console&&console.warn("nothing selected, can't validate, returning nothing");return;}var validator=$.data(this[0],'validator');if(validator){return validator;}validator=new $.validator(options,this[0]);$.data(this[0],'validator',validator);if(validator.settings.onsubmit){this.find("input, button").filter(".cancel").click(function(){validator.cancelSubmit=true;});if(validator.settings.submitHandler){this.find("input, button").filter(":submit").click(function(){validator.submitButton=this;});}this.submit(function(event){if(validator.settings.debug)event.preventDefault();function handle(){if(validator.settings.submitHandler){if(validator.submitButton){var hidden=$("<input type='hidden'/>").attr("name",validator.submitButton.name).val(validator.submitButton.value).appendTo(validator.currentForm);}validator.settings.submitHandler.call(validator,validator.currentForm);if(validator.submitButton){hidden.remove();}return false;}return true;}if(validator.cancelSubmit){validator.cancelSubmit=false;return handle();}if(validator.form()){if(validator.pendingRequest){validator.formSubmitted=true;return false;}return handle();}else{validator.focusInvalid();return false;}});}return validator;},valid:function(){if($(this[0]).is('form')){return this.validate().form();}else{var valid=true;var validator=$(this[0].form).validate();this.each(function(){valid&=validator.element(this);});return valid;}},removeAttrs:function(attributes){var result={},$element=this;$.each(attributes.split(/\s/),function(index,value){result[value]=$element.attr(value);$element.removeAttr(value);});return result;},rules:function(command,argument){var element=this[0];if(command){var settings=$.data(element.form,'validator').settings;var staticRules=settings.rules;var existingRules=$.validator.staticRules(element);switch(command){case"add":$.extend(existingRules,$.validator.normalizeRule(argument));staticRules[element.name]=existingRules;if(argument.messages)settings.messages[element.name]=$.extend(settings.messages[element.name],argument.messages);break;case"remove":if(!argument){delete staticRules[element.name];return existingRules;}var filtered={};$.each(argument.split(/\s/),function(index,method){filtered[method]=existingRules[method];delete existingRules[method];});return filtered;}}var data=$.validator.normalizeRules($.extend({},$.validator.metadataRules(element),$.validator.classRules(element),$.validator.attributeRules(element),$.validator.staticRules(element)),element);if(data.required){var param=data.required;delete data.required;data=$.extend({required:param},data);}return data;}});$.extend($.expr[":"],{blank:function(a){return!$.trim(""+a.value);},filled:function(a){return!!$.trim(""+a.value);},unchecked:function(a){return!a.checked;}});$.validator=function(options,form){this.settings=$.extend({},$.validator.defaults,options);this.currentForm=form;this.init();};$.validator.format=function(source,params){if(arguments.length==1)return function(){var args=$.makeArray(arguments);args.unshift(source);return $.validator.format.apply(this,args);};if(arguments.length>2&&params.constructor!=Array){params=$.makeArray(arguments).slice(1);}if(params.constructor!=Array){params=[params];}$.each(params,function(i,n){source=source.replace(new RegExp("\\{"+i+"\\}","g"),n);});return source;};$.extend($.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",validClass:"valid",errorElement:"label",focusInvalid:true,errorContainer:$([]),errorLabelContainer:$([]),onsubmit:true,ignore:[],ignoreTitle:false,onfocusin:function(element){this.lastActive=element;if(this.settings.focusCleanup&&!this.blockFocusCleanup){this.settings.unhighlight&&this.settings.unhighlight.call(this,element,this.settings.errorClass,this.settings.validClass);this.errorsFor(element).hide();}},onfocusout:function(element){if(!this.checkable(element)&&(element.name in this.submitted||!this.optional(element))){this.element(element);}},onkeyup:function(element){if(element.name in this.submitted||element==this.lastElement){this.element(element);}},onclick:function(element){if(element.name in this.submitted)this.element(element);else if(element.parentNode.name in this.submitted)this.element(element.parentNode)},highlight:function(element,errorClass,validClass){$(element).addClass(errorClass).removeClass(validClass);},unhighlight:function(element,errorClass,validClass){$(element).removeClass(errorClass).addClass(validClass);}},setDefaults:function(settings){$.extend($.validator.defaults,settings);},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",number:"Please enter a valid number.",digits:"Please enter only digits.",creditcard:"Please enter a valid credit card number.",equalTo:"Please enter the same value again.",accept:"Please enter a value with a valid extension.",maxlength:$.validator.format("Please enter no more than {0} characters."),minlength:$.validator.format("Please enter at least {0} characters."),rangelength:$.validator.format("Please enter a value between {0} and {1} characters long."),range:$.validator.format("Please enter a value between {0} and {1}."),max:$.validator.format("Please enter a value less than or equal to {0}."),min:$.validator.format("Please enter a value greater than or equal to {0}.")},autoCreateRanges:false,prototype:{init:function(){this.labelContainer=$(this.settings.errorLabelContainer);this.errorContext=this.labelContainer.length&&this.labelContainer||$(this.currentForm);this.containers=$(this.settings.errorContainer).add(this.settings.errorLabelContainer);this.submitted={};this.valueCache={};this.pendingRequest=0;this.pending={};this.invalid={};this.reset();var groups=(this.groups={});$.each(this.settings.groups,function(key,value){$.each(value.split(/\s/),function(index,name){groups[name]=key;});});var rules=this.settings.rules;$.each(rules,function(key,value){rules[key]=$.validator.normalizeRule(value);});function delegate(event){var validator=$.data(this[0].form,"validator");validator.settings["on"+event.type]&&validator.settings["on"+event.type].call(validator,this[0]);}$(this.currentForm).delegate("focusin focusout keyup",":text, :password, :file, select, textarea",delegate).delegate("click",":radio, :checkbox, select, option",delegate);if(this.settings.invalidHandler)$(this.currentForm).bind("invalid-form.validate",this.settings.invalidHandler);},form:function(){this.checkForm();$.extend(this.submitted,this.errorMap);this.invalid=$.extend({},this.errorMap);if(!this.valid())$(this.currentForm).triggerHandler("invalid-form",[this]);this.showErrors();return this.valid();},checkForm:function(){this.prepareForm();for(var i=0,elements=(this.currentElements=this.elements());elements[i];i++){this.check(elements[i]);}return this.valid();},element:function(element){element=this.clean(element);this.lastElement=element;this.prepareElement(element);this.currentElements=$(element);var result=this.check(element);if(result){delete this.invalid[element.name];}else{this.invalid[element.name]=true;}if(!this.numberOfInvalids()){this.toHide=this.toHide.add(this.containers);}this.showErrors();return result;},showErrors:function(errors){if(errors){$.extend(this.errorMap,errors);this.errorList=[];for(var name in errors){this.errorList.push({message:errors[name],element:this.findByName(name)[0]});}this.successList=$.grep(this.successList,function(element){return!(element.name in errors);});}this.settings.showErrors?this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors();},resetForm:function(){if($.fn.resetForm)$(this.currentForm).resetForm();this.submitted={};this.prepareForm();this.hideErrors();this.elements().removeClass(this.settings.errorClass);},numberOfInvalids:function(){return this.objectLength(this.invalid);},objectLength:function(obj){var count=0;for(var i in obj)count++;return count;},hideErrors:function(){this.addWrapper(this.toHide).hide();},valid:function(){return this.size()==0;},size:function(){return this.errorList.length;},focusInvalid:function(){if(this.settings.focusInvalid){try{$(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus();}catch(e){}}},findLastActive:function(){var lastActive=this.lastActive;return lastActive&&$.grep(this.errorList,function(n){return n.element.name==lastActive.name;}).length==1&&lastActive;},elements:function(){var validator=this,rulesCache={};return $([]).add(this.currentForm.elements).filter(":input").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function(){!this.name&&validator.settings.debug&&window.console&&console.error("%o has no name assigned",this);if(this.name in rulesCache||!validator.objectLength($(this).rules()))return false;rulesCache[this.name]=true;return true;});},clean:function(selector){return $(selector)[0];},errors:function(){return $(this.settings.errorElement+"."+this.settings.errorClass,this.errorContext);},reset:function(){this.successList=[];this.errorList=[];this.errorMap={};this.toShow=$([]);this.toHide=$([]);this.currentElements=$([]);},prepareForm:function(){this.reset();this.toHide=this.errors().add(this.containers);},prepareElement:function(element){this.reset();this.toHide=this.errorsFor(element);},check:function(element){element=this.clean(element);if(this.checkable(element)){element=this.findByName(element.name)[0];}var rules=$(element).rules();var dependencyMismatch=false;for(method in rules){var rule={method:method,parameters:rules[method]};try{var result=$.validator.methods[method].call(this,element.value.replace(/\r/g,""),element,rule.parameters);if(result=="dependency-mismatch"){dependencyMismatch=true;continue;}dependencyMismatch=false;if(result=="pending"){this.toHide=this.toHide.not(this.errorsFor(element));return;}if(!result){this.formatAndAdd(element,rule);return false;}}catch(e){this.settings.debug&&window.console&&console.log("exception occured when checking element "+element.id
+", check the '"+rule.method+"' method",e);throw e;}}if(dependencyMismatch)return;if(this.objectLength(rules))this.successList.push(element);return true;},customMetaMessage:function(element,method){if(!$.metadata)return;var meta=this.settings.meta?$(element).metadata()[this.settings.meta]:$(element).metadata();return meta&&meta.messages&&meta.messages[method];},customMessage:function(name,method){var m=this.settings.messages[name];return m&&(m.constructor==String?m:m[method]);},findDefined:function(){for(var i=0;i<arguments.length;i++){if(arguments[i]!==undefined)return arguments[i];}return undefined;},defaultMessage:function(element,method){return this.findDefined(this.customMessage(element.name,method),this.customMetaMessage(element,method),!this.settings.ignoreTitle&&element.title||undefined,$.validator.messages[method],"<strong>Warning: No message defined for "+element.name+"</strong>");},formatAndAdd:function(element,rule){var message=this.defaultMessage(element,rule.method),theregex=/\$?\{(\d+)\}/g;if(typeof message=="function"){message=message.call(this,rule.parameters,element);}else if(theregex.test(message)){message=jQuery.format(message.replace(theregex,'{$1}'),rule.parameters);}this.errorList.push({message:message,element:element});this.errorMap[element.name]=message;this.submitted[element.name]=message;},addWrapper:function(toToggle){if(this.settings.wrapper)toToggle=toToggle.add(toToggle.parent(this.settings.wrapper));return toToggle;},defaultShowErrors:function(){for(var i=0;this.errorList[i];i++){var error=this.errorList[i];this.settings.highlight&&this.settings.highlight.call(this,error.element,this.settings.errorClass,this.settings.validClass);this.showLabel(error.element,error.message);}if(this.errorList.length){this.toShow=this.toShow.add(this.containers);}if(this.settings.success){for(var i=0;this.successList[i];i++){this.showLabel(this.successList[i]);}}if(this.settings.unhighlight){for(var i=0,elements=this.validElements();elements[i];i++){this.settings.unhighlight.call(this,elements[i],this.settings.errorClass,this.settings.validClass);}}this.toHide=this.toHide.not(this.toShow);this.hideErrors();this.addWrapper(this.toShow).show();},validElements:function(){return this.currentElements.not(this.invalidElements());},invalidElements:function(){return $(this.errorList).map(function(){return this.element;});},showLabel:function(element,message){var label=this.errorsFor(element);if(label.length){label.removeClass().addClass(this.settings.errorClass);label.attr("generated")&&label.html(message);}else{label=$("<"+this.settings.errorElement+"/>").attr({"for":this.idOrName(element),generated:true}).addClass(this.settings.errorClass).html(message||"");if(this.settings.wrapper){label=label.hide().show().wrap("<"+this.settings.wrapper+"/>").parent();}if(!this.labelContainer.append(label).length)this.settings.errorPlacement?this.settings.errorPlacement(label,$(element)):label.insertAfter(element);}if(!message&&this.settings.success){label.text("");typeof this.settings.success=="string"?label.addClass(this.settings.success):this.settings.success(label);}this.toShow=this.toShow.add(label);},errorsFor:function(element){var name=this.idOrName(element);return this.errors().filter(function(){return $(this).attr('for')==name});},idOrName:function(element){return this.groups[element.name]||(this.checkable(element)?element.name:element.id||element.name);},checkable:function(element){return/radio|checkbox/i.test(element.type);},findByName:function(name){var form=this.currentForm;return $(document.getElementsByName(name)).map(function(index,element){return element.form==form&&element.name==name&&element||null;});},getLength:function(value,element){switch(element.nodeName.toLowerCase()){case'select':return $("option:selected",element).length;case'input':if(this.checkable(element))return this.findByName(element.name).filter(':checked').length;}return value.length;},depend:function(param,element){return this.dependTypes[typeof param]?this.dependTypes[typeof param](param,element):true;},dependTypes:{"boolean":function(param,element){return param;},"string":function(param,element){return!!$(param,element.form).length;},"function":function(param,element){return param(element);}},optional:function(element){return!$.validator.methods.required.call(this,$.trim(element.value),element)&&"dependency-mismatch";},startRequest:function(element){if(!this.pending[element.name]){this.pendingRequest++;this.pending[element.name]=true;}},stopRequest:function(element,valid){this.pendingRequest--;if(this.pendingRequest<0)this.pendingRequest=0;delete this.pending[element.name];if(valid&&this.pendingRequest==0&&this.formSubmitted&&this.form()){$(this.currentForm).submit();this.formSubmitted=false;}else if(!valid&&this.pendingRequest==0&&this.formSubmitted){$(this.currentForm).triggerHandler("invalid-form",[this]);this.formSubmitted=false;}},previousValue:function(element){return $.data(element,"previousValue")||$.data(element,"previousValue",{old:null,valid:true,message:this.defaultMessage(element,"remote")});}},classRuleSettings:{required:{required:true},email:{email:true},url:{url:true},date:{date:true},dateISO:{dateISO:true},dateDE:{dateDE:true},number:{number:true},numberDE:{numberDE:true},digits:{digits:true},creditcard:{creditcard:true}},addClassRules:function(className,rules){className.constructor==String?this.classRuleSettings[className]=rules:$.extend(this.classRuleSettings,className);},classRules:function(element){var rules={};var classes=$(element).attr('class');classes&&$.each(classes.split(' '),function(){if(this in $.validator.classRuleSettings){$.extend(rules,$.validator.classRuleSettings[this]);}});return rules;},attributeRules:function(element){var rules={};var $element=$(element);for(method in $.validator.methods){var value=$element.attr(method);if(value){rules[method]=value;}}if(rules.maxlength&&/-1|2147483647|524288/.test(rules.maxlength)){delete rules.maxlength;}return rules;},metadataRules:function(element){if(!$.metadata)return{};var meta=$.data(element.form,'validator').settings.meta;return meta?$(element).metadata()[meta]:$(element).metadata();},staticRules:function(element){var rules={};var validator=$.data(element.form,'validator');if(validator.settings.rules){rules=$.validator.normalizeRule(validator.settings.rules[element.name])||{};}return rules;},normalizeRules:function(rules,element){$.each(rules,function(prop,val){if(val===false){delete rules[prop];return;}if(val.param||val.depends){var keepRule=true;switch(typeof val.depends){case"string":keepRule=!!$(val.depends,element.form).length;break;case"function":keepRule=val.depends.call(element,element);break;}if(keepRule){rules[prop]=val.param!==undefined?val.param:true;}else{delete rules[prop];}}});$.each(rules,function(rule,parameter){rules[rule]=$.isFunction(parameter)?parameter(element):parameter;});$.each(['minlength','maxlength','min','max'],function(){if(rules[this]){rules[this]=Number(rules[this]);}});$.each(['rangelength','range'],function(){if(rules[this]){rules[this]=[Number(rules[this][0]),Number(rules[this][1])];}});if($.validator.autoCreateRanges){if(rules.min&&rules.max){rules.range=[rules.min,rules.max];delete rules.min;delete rules.max;}if(rules.minlength&&rules.maxlength){rules.rangelength=[rules.minlength,rules.maxlength];delete rules.minlength;delete rules.maxlength;}}if(rules.messages){delete rules.messages}return rules;},normalizeRule:function(data){if(typeof data=="string"){var transformed={};$.each(data.split(/\s/),function(){transformed[this]=true;});data=transformed;}return data;},addMethod:function(name,method,message){$.validator.methods[name]=method;$.validator.messages[name]=message!=undefined?message:$.validator.messages[name];if(method.length<3){$.validator.addClassRules(name,$.validator.normalizeRule(name));}},methods:{required:function(value,element,param){if(!this.depend(param,element))return"dependency-mismatch";switch(element.nodeName.toLowerCase()){case'select':var val=$(element).val();return val&&val.length>0;case'input':if(this.checkable(element))return this.getLength(value,element)>0;default:return $.trim(value).length>0;}},remote:function(value,element,param){if(this.optional(element))return"dependency-mismatch";var previous=this.previousValue(element);if(!this.settings.messages[element.name])this.settings.messages[element.name]={};previous.originalMessage=this.settings.messages[element.name].remote;this.settings.messages[element.name].remote=previous.message;param=typeof param=="string"&&{url:param}||param;if(previous.old!==value){previous.old=value;var validator=this;this.startRequest(element);var data={};data[element.name]=value;$.ajax($.extend(true,{url:param,mode:"abort",port:"validate"+element.name,dataType:"json",data:data,success:function(response){validator.settings.messages[element.name].remote=previous.originalMessage;var valid=response===true;if(valid){var submitted=validator.formSubmitted;validator.prepareElement(element);validator.formSubmitted=submitted;validator.successList.push(element);validator.showErrors();}else{var errors={};var message=(previous.message=response||validator.defaultMessage(element,"remote"));errors[element.name]=$.isFunction(message)?message(value):message;validator.showErrors(errors);}previous.valid=valid;validator.stopRequest(element,valid);}},param));return"pending";}else if(this.pending[element.name]){return"pending";}return previous.valid;},minlength:function(value,element,param){return this.optional(element)||this.getLength($.trim(value),element)>=param;},maxlength:function(value,element,param){return this.optional(element)||this.getLength($.trim(value),element)<=param;},rangelength:function(value,element,param){var length=this.getLength($.trim(value),element);return this.optional(element)||(length>=param[0]&&length<=param[1]);},min:function(value,element,param){return this.optional(element)||value>=param;},max:function(value,element,param){return this.optional(element)||value<=param;},range:function(value,element,param){return this.optional(element)||(value>=param[0]&&value<=param[1]);},email:function(value,element){return this.optional(element)||/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(value);},url:function(value,element){return this.optional(element)||/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value);},date:function(value,element){return this.optional(element)||!/Invalid|NaN/.test(new Date(value));},dateISO:function(value,element){return this.optional(element)||/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(value);},number:function(value,element){return this.optional(element)||/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(value);},digits:function(value,element){return this.optional(element)||/^\d+$/.test(value);},creditcard:function(value,element){if(this.optional(element))return"dependency-mismatch";if(/[^0-9-]+/.test(value))return false;var nCheck=0,nDigit=0,bEven=false;value=value.replace(/\D/g,"");for(var n=value.length-1;n>=0;n--){var cDigit=value.charAt(n);var nDigit=parseInt(cDigit,10);if(bEven){if((nDigit*=2)>9)nDigit-=9;}nCheck+=nDigit;bEven=!bEven;}return(nCheck%10)==0;},accept:function(value,element,param){param=typeof param=="string"?param.replace(/,/g,'|'):"png|jpe?g|gif";return this.optional(element)||value.match(new RegExp(".("+param+")$","i"));},equalTo:function(value,element,param){var target=$(param).unbind(".validate-equalTo").bind("blur.validate-equalTo",function(){$(element).valid();});return value==target.val();}}});$.format=$.validator.format;})(jQuery);;(function($){var ajax=$.ajax;var pendingRequests={};$.ajax=function(settings){settings=$.extend(settings,$.extend({},$.ajaxSettings,settings));var port=settings.port;if(settings.mode=="abort"){if(pendingRequests[port]){pendingRequests[port].abort();}return(pendingRequests[port]=ajax.apply(this,arguments));}return ajax.apply(this,arguments);};})(jQuery);;(function($){$.each({focus:'focusin',blur:'focusout'},function(original,fix){$.event.special[fix]={setup:function(){if($.browser.msie)return false;this.addEventListener(original,$.event.special[fix].handler,true);},teardown:function(){if($.browser.msie)return false;this.removeEventListener(original,$.event.special[fix].handler,true);},handler:function(e){arguments[0]=$.event.fix(e);arguments[0].type=fix;return $.event.handle.apply(this,arguments);}};});$.extend($.fn,{delegate:function(type,delegate,handler){return this.bind(type,function(event){var target=$(event.target);if(target.is(delegate)){return handler.apply(target,arguments);}});},triggerEvent:function(type,target){return this.triggerHandler(type,[$.event.fix({type:type,target:target})]);}})})(jQuery);
// End ~/Scripts/jquery.validate.min.js

// Begin ~/Scripts/jquery.maskedinput.js

/*
Masked Input plugin for jQuery
Copyright (c) 2007-2009 Josh Bush (digitalbush.com)
Licensed under the MIT license (http://digitalbush.com/projects/masked-input-plugin/#license) 
Version: 1.2.2 (03/09/2009 22:39:06)
*/
(function(a) { var c = (a.browser.msie ? "paste" : "input") + ".mask"; var b = (window.orientation != undefined); a.mask = { definitions: { "9": "[0-9]", a: "[A-Za-z]", "*": "[A-Za-z0-9]"} }; a.fn.extend({ caret: function(e, f) { if (this.length == 0) { return } if (typeof e == "number") { f = (typeof f == "number") ? f : e; return this.each(function() { if (this.setSelectionRange) { this.focus(); this.setSelectionRange(e, f) } else { if (this.createTextRange) { var g = this.createTextRange(); g.collapse(true); g.moveEnd("character", f); g.moveStart("character", e); g.select() } } }) } else { if (this[0].setSelectionRange) { e = this[0].selectionStart; f = this[0].selectionEnd } else { if (document.selection && document.selection.createRange) { var d = document.selection.createRange(); e = 0 - d.duplicate().moveStart("character", -100000); f = e + d.text.length } } return { begin: e, end: f} } }, unmask: function() { return this.trigger("unmask") }, mask: function(j, d) { if (!j && this.length > 0) { var f = a(this[0]); var g = f.data("tests"); return a.map(f.data("buffer"), function(l, m) { return g[m] ? l : null }).join("") } d = a.extend({ placeholder: "_", completed: null }, d); var k = a.mask.definitions; var g = []; var e = j.length; var i = null; var h = j.length; a.each(j.split(""), function(m, l) { if (l == "?") { h--; e = m } else { if (k[l]) { g.push(new RegExp(k[l])); if (i == null) { i = g.length - 1 } } else { g.push(null) } } }); return this.each(function() { var r = a(this); var m = a.map(j.split(""), function(x, y) { if (x != "?") { return k[x] ? d.placeholder : x } }); var n = false; var q = r.val(); r.data("buffer", m).data("tests", g); function v(x) { while (++x <= h && !g[x]) { } return x } function t(x) { while (!g[x] && --x >= 0) { } for (var y = x; y < h; y++) { if (g[y]) { m[y] = d.placeholder; var z = v(y); if (z < h && g[y].test(m[z])) { m[y] = m[z] } else { break } } } s(); r.caret(Math.max(i, x)) } function u(y) { for (var A = y, z = d.placeholder; A < h; A++) { if (g[A]) { var B = v(A); var x = m[A]; m[A] = z; if (B < h && g[B].test(x)) { z = x } else { break } } } } function l(y) { var x = a(this).caret(); var z = y.keyCode; n = (z < 16 || (z > 16 && z < 32) || (z > 32 && z < 41)); if ((x.begin - x.end) != 0 && (!n || z == 8 || z == 46)) { w(x.begin, x.end) } if (z == 8 || z == 46 || (b && z == 127)) { t(x.begin + (z == 46 ? 0 : -1)); return false } else { if (z == 27) { r.val(q); r.caret(0, p()); return false } } } function o(B) { if (n) { n = false; return (B.keyCode == 8) ? false : null } B = B || window.event; var C = B.charCode || B.keyCode || B.which; var z = a(this).caret(); if (B.ctrlKey || B.altKey || B.metaKey) { return true } else { if ((C >= 32 && C <= 125) || C > 186) { var x = v(z.begin - 1); if (x < h) { var A = String.fromCharCode(C); if (g[x].test(A)) { u(x); m[x] = A; s(); var y = v(x); a(this).caret(y); if (d.completed && y == h) { d.completed.call(r) } } } } } return false } function w(x, y) { for (var z = x; z < y && z < h; z++) { if (g[z]) { m[z] = d.placeholder } } } function s() { return r.val(m.join("")).val() } function p(y) { var z = r.val(); var C = -1; for (var B = 0, x = 0; B < h; B++) { if (g[B]) { m[B] = d.placeholder; while (x++ < z.length) { var A = z.charAt(x - 1); if (g[B].test(A)) { m[B] = A; C = B; break } } if (x > z.length) { break } } else { if (m[B] == z[x] && B != e) { x++; C = B } } } if (!y && C + 1 < e) { r.val(""); w(0, h) } else { if (y || C + 1 >= e) { s(); if (!y) { r.val(r.val().substring(0, C + 1)) } } } return (e ? B : i) } if (!r.attr("readonly")) { r.one("unmask", function() { r.unbind(".mask").removeData("buffer").removeData("tests") }).bind("focus.mask", function() { q = r.val(); var x = p(); s(); setTimeout(function() { if (x == j.length) { r.caret(0, x) } else { r.caret(x) } }, 0) }).bind("blur.mask", function() { p(); if (r.val() != q) { r.change() } }).bind("keydown.mask", l).bind("keypress.mask", o).bind(c, function() { setTimeout(function() { r.caret(p(true)) }, 0) }) } p() }) } }) })(jQuery);

(function($) {

    $.fn.alphanumeric = function(p) {

        p = $.extend({
            ichars: "!@#$%^&*()+=[]\\\';,/{}|\":<>?~`.- ",
            nchars: "",
            allow: ""
        }, p);

        return this.each
			(
				function() {

				    if (p.nocaps) p.nchars += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
				    if (p.allcaps) p.nchars += "abcdefghijklmnopqrstuvwxyz";

				    s = p.allow.split('');
				    for (i = 0; i < s.length; i++) if (p.ichars.indexOf(s[i]) != -1) s[i] = "\\" + s[i];
				    p.allow = s.join('|');

				    var reg = new RegExp(p.allow, 'gi');
				    var ch = p.ichars + p.nchars;
				    ch = ch.replace(reg, '');

				    $(this).keypress
						(
							function(e) {

							    if (!e.charCode) k = String.fromCharCode(e.which);
							    else k = String.fromCharCode(e.charCode);

							    if (ch.indexOf(k) != -1) e.preventDefault();
							    if (e.ctrlKey && k == 'v') e.preventDefault();

							}

						);

				    $(this).bind('contextmenu', function() { return false });

				}
			);

    };

    $.fn.numeric = function(p) {

        var az = "abcdefghijklmnopqrstuvwxyz";
        az += az.toUpperCase();

        p = $.extend({
            nchars: az
        }, p);

        return this.each(function() {
            $(this).alphanumeric(p);
        }
		);

    };

    $.fn.alpha = function(p) {

        var nm = "1234567890";

        p = $.extend({
            nchars: nm
        }, p);

        return this.each(function() {
            $(this).alphanumeric(p);
        }
		);

    };

})(jQuery);

// End ~/Scripts/jquery.maskedinput.js

// Begin ~/Scripts/jquery.bigPicture-min.js

(function($) {
    $.jquery = $.jquery || {};
    $.jquery.ux = $.jquery.ux || {};
    $.jquery.ux.ui = $.jquery.ux.ui || {};
    $.jquery.ux.ui.BPHelper = function() {
        return {
            AUTO_ID: 1001,
            galleries: {},
            isBoxRendered: function() {
                return $('#bp').size() > 0 ? true : false
            },
            isBoxVisible: function() {
                return $('#bp > .bp-wrap').is(':visible')
            },
            renderBox: function() {
                if ($.jquery.ux.ui.BPHelper.isBoxRendered()) {
                    return
                }
                var sbox = document.createElement('div');
                var mask = document.createElement('div');
                var wrap = document.createElement('div');
                var main = document.createElement('div');
                var view = document.createElement('div');
                var bbar = document.createElement('div');
                $(bbar).addClass('bp-bbar').append('<div class="bp-hide-link"><a href="#"><span>Close</span></a></div>').append('<div class="bp-info-link"><a href="#"><span>Image info</span></a></div>').append('<div class="bp-clear"></div>');
                $(view).addClass('bp-view').css({
                    'margin': 0
                }).append('<div class="bp-nav bp-prev-link"><a href="#"><span>Prev</span></a></div>').append('<div class="bp-nav bp-next-link"><a href="#"><span>Next</span></a></div>').append('<div class="bp-info-wrap"><div class="bp-info"></div></div>');
                $(main).addClass('bp-main').css({
                    'margin-left': 'auto',
                    'margin-right': 'auto'
                }).append(view).append(bbar);
                $(wrap).addClass('bp-wrap').append(main);
                $(mask).addClass('bp-mask');
                $(sbox).attr('id', 'bp').append(mask).append(wrap).appendTo('body');
                $(window).resize(function(e) {
                    if ($.jquery.ux.ui.BPHelper.isBoxVisible()) {
                        $.jquery.ux.ui.BPHelper.onWindowResize()
                    }
                });
                $(mask).click(function(e) {
                    $.jquery.ux.ui.BPHelper.hideBox()
                });
                $(wrap).click(function(e) {
                    $.jquery.ux.ui.BPHelper.hideBox()
                });
                $(main).click(function(e) {
                    e.preventDefault();
                    return false
                });
                $('.bp-hide-link', bbar).click(function(e) {
                    e.preventDefault();
                    $.jquery.ux.ui.BPHelper.hideBox()
                })
            },
            showBox: function() {
                $.jquery.ux.ui.BPHelper.onWindowResize();
                $('#bp .bp-mask').show();
                $('#bp .bp-wrap').show()
            },
            hideBox: function() {
                $.jquery.ux.ui.BPHelper.resetBox();
                $('#bp .bp-wrap').fadeOut('fast',
                function() {
                    $('#bp .bp-mask').hide()
                })
            },
            resetBox: function() {
                $('#bp .bp-bbar').stop().hide();
                $('#bp .bp-info-wrap').stop().hide().css({
                    'marginTop': 0
                });
                $('#bp .bp-info-link > a').removeClass('active');
                $('#bp .bp-view > img').remove()
            },
            onWindowResize: function() {
                var ds = $.jquery.ux.ui.BPHelper.getDimensions();
                var ps = $.jquery.ux.ui.BPHelper.getPageScroll();
                $('#bp .bp-mask').width(ds.pageWidth).height(ds.pageHeight);
                $('#bp .bp-wrap').css({
                    'left': 0,
                    'top': ps.y + (ds.windowHeight * 0.08)
                })
            },
            getDimensions: function() {
                var dims = {};
                var dbw, dbh;
                if (window.innerHeight && window.scrollMaxY) {
                    dbw = window.innerWidth + window.scrollMaxX;
                    dbh = window.innerHeight + window.scrollMaxY
                } else if (document.body.scrollHeight > document.body.offsetHeight) {
                    dbw = document.body.scrollWidth;
                    dbh = document.body.scrollHeight
                } else {
                    dbw = document.body.offsetWidth;
                    dbh = document.body.offsetHeight
                }
                if (self.innerHeight) {
                    if (document.documentElement.clientWidth) {
                        dims.windowWidth = document.documentElement.clientWidth
                    } else {
                        dims.windowWidth = self.innerWidth
                    }
                    dims.windowHeight = self.innerHeight
                } else if (document.documentElement && document.documentElement.clientHeight) {
                    dims.windowWidth = document.documentElement.clientWidth;
                    dims.windowHeight = document.documentElement.clientHeight
                } else if (document.body) {
                    dims.windowWidth = document.body.clientWidth;
                    dims.windowHeight = document.body.clientHeight
                }
                dims.pageHeight = Math.max(dbh, dims.windowHeight);
                dims.pageWidth = Math.max(dbw, dims.windowWidth);
                return dims
            },
            getPageScroll: function() {
                var scroll = {};
                if (self.pageYOffset) {
                    scroll.y = self.pageYOffset;
                    scroll.x = self.pageXOffset
                } else if (document.documentElement && document.documentElement.scrollTop) {
                    scroll.y = document.documentElement.scrollTop;
                    scroll.x = document.documentElement.scrollLeft
                } else if (document.body) {
                    scroll.y = document.body.scrollTop;
                    scroll.x = document.body.scrollLeft
                }
                return scroll
            }
        }
    } ();
    $.jquery.ux.ui.BigPicture = function(el, conf) {
        this.images = [];
        this.index = 0;
        this.gallery = '';
        this.offset = false;
        conf = $.extend({
            'cls': '',
            'prevLabel': 'Prev',
            'nextLabel': 'Next',
            'infoLabel': 'Image info',
            'hideLabel': 'Close',
            'boxEaseFn': '',
            'boxEaseSpeed': 750,
            'enableInfo': false,
            'infoPosition': 'bottom',
            'infoEaseFn': '',
            'infoEaseSpeed': 500
        },
        conf);
        if (!$(el).attr('id')) {
            $(el).attr('id', 'bigPicture-' + $.jquery.ux.ui.BPHelper.AUTO_ID++)
        }
        this.gallery = $(el).attr('rel');
        if (this.gallery && !$.jquery.ux.ui.BPHelper.galleries[this.gallery]) {
            $.jquery.ux.ui.BPHelper.galleries[this.gallery] = $("a[rel='" + this.gallery + "']").get()
        }
        this.launchBox = function() {
            if (this.images.length == 0) {
                if (this.gallery) {
                    this.images = $.jquery.ux.ui.BPHelper.galleries[this.gallery]
                } else {
                    this.images.push(el)
                }
            }
            this.index = 0;
            for (var i = 0; i < this.images.length; i++) {
                if (this.images[i].id == el.id) {
                    this.index = i;
                    break
                }
            }
            this.show()
        };
        this.show = function() {
            $.jquery.ux.ui.BPHelper.renderBox();
            $('#bp').removeClass().addClass(conf.cls);
            $('#bp .bp-prev-link > a > span').html(conf.prevLabel);
            $('#bp .bp-next-link > a > span').html(conf.nextLabel);
            $('#bp .bp-info-link > a > span').html(conf.infoLabel);
            $('#bp .bp-hide-link > a > span').html(conf.hideLabel);
            var sbox = this;
            $('#bp .bp-view').unbind('mouseenter.bp').unbind('mouseleave.bp').bind('mouseenter.bp',
            function() {
                sbox.toggleNavigation(true)
            }).bind('mouseleave.bp',
            function() {
                sbox.toggleNavigation(false)
            });
            $('#bp .bp-prev-link > a').unbind('click.bp').bind('click.bp',
            function(e) {
                e.preventDefault();
                sbox.back()
            });
            $('#bp .bp-next-link > a').unbind('click.bp').bind('click.bp',
            function(e) {
                e.preventDefault();
                sbox.next()
            });
            if (conf.enableInfo) {
                $('#bp .bp-info-link').show();
                $('#bp .bp-info-link > a').unbind('click.bp').bind('click.bp',
                function(e) {
                    e.preventDefault();
                    sbox.toggleInfo(this)
                })
            } else {
                $('#bp .bp-info-link').hide()
            }
            $('#bp .bp-main').width(64).height(64);
            if (!$.jquery.ux.ui.BPHelper.isBoxVisible()) {
                $.jquery.ux.ui.BPHelper.showBox()
            }
            this.load()
        };
        this.hide = function() {
            $.jquery.ux.ui.BPHelper.hideBox()
        };
        this.reset = function() {
            $.jquery.ux.ui.BPHelper.resetBox()
        };
        this.load = function() {
            this.reset();
            $('#bp .bp-main').addClass('loading');
            this.calculateOffset();
            var box = this;
            var img = new Image();
            $(img).load(function() {
                $('#bp .bp-main').animate({
                    'width': img.width + box.offset.x,
                    'height': img.height + box.offset.y
                },
                conf.boxEaseSpeed, conf.boxEaseFn,
                function() {
                    box.onLoad(img)
                })
            }).error(function() {
                box.hide();
                alert('There was an error loading the image')
            }).attr('src', $(this.images[this.index]).attr('href'))
        };
        this.onLoad = function(img) {
            if (conf.enableInfo) {
                var title = $(this.images[this.index]).attr('title');
                var divId = $(this.images[this.index]).attr('name');
                var count = this.images.length;
                var $wrap = $('#bp .bp-info-wrap');
                var txt = '';
                if (count > 1) {
                    txt += '<div class="bp-count">Image ' + (this.index + 1) + ' of ' + count + '</div>'
                }
                txt += title ? '<h2>' + title + '</h2>' : '';
                $('#bp .bp-info').html(txt).append($('#' + divId).contents().clone(true));
                $('#bp .bp-info a').click(function(e) {
                    var href = $(this).attr('href');
                    if (href && href.charAt(0) != '#') {
                        document.location = href
                    }
                });
                var y = conf.infoPosition == 'top' ? (-1 * $wrap.outerHeight()) : img.height;
                $wrap.css({
                    'top': y
                })
            }
            $('#bp .bp-main').removeClass('loading');
            $('#bp .bp-info-wrap').before(img);
            $('#bp .bp-view').width(img.width).height(img.height).fadeIn('normal');
            $('#bp .bp-nav > a').width(Math.floor(img.width / 2)).height(img.height);
            var bh = img.height + this.offset.y + $('#bp .bp-bbar').outerHeight();
            $('#bp .bp-bbar').show();
            $('#bp .bp-nav').show().fadeTo("fast", 0.25);
            $('#bp .bp-main').animate({
                'height': bh
            },
            350);
            $(img).click().focus()
        };
        this.toggleInfo = function(link) {
            if (!conf.enableInfo) {
                return
            }
            var h = $('#bp .bp-info-wrap').outerHeight();
            var b = conf.infoPosition == 'top' ? 0 : $('#bp .bp-view > img').height();
            var hide = false;
            if ($(link).hasClass('active')) {
                $(link).removeClass('active');
                h = conf.infoPosition == 'top' ? h : 0;
                hide = true
            } else {
                $(link).addClass('active');
                h = conf.infoPosition == 'top' ? 0 : h
            }
            $('#bp .bp-info-wrap').show().animate({
                'top': b - h
            },
            conf.infoEaseSpeed, conf.infoEaseFn,
            function() {
                if (hide) {
                    $('#bp .bp-info-wrap').hide()
                }
            })
        };
        this.toggleNavigation = function(show) {
            if (show == true && this.images.length > 1) {
                $('#bp .bp-nav').fadeTo("fast", 1.0)
            } else {
                $('#bp .bp-nav').fadeTo("fast", 0.25)
            }
            return false
        };
        this.back = function() {
            this.index--;
            if (this.index < 0) {
                this.index = this.images.length - 1
            }
            this.load()
        };
        this.next = function() {
            this.index++;
            if (this.index == this.images.length) {
                this.index = 0
            }
            this.load()
        };
        this.calculateOffset = function() {
            if (this.offset) {
                return
            }
            var $view = $('#bp .bp-view');
            this.offset = {
                x: 0,
                y: 0
            };
            this.offset.x = $view.outerWidth() - $view.width();
            this.offset.y = $view.outerHeight() - $view.height()
        }
    };
    $.fn.bigPicture = function(p) {
        return this.each(function() {
            if (this.bigPicture instanceof $.jquery.ux.ui.BigPicture) {
                return this
            }
            var box = new $.jquery.ux.ui.BigPicture(this, p);
            $(this).click(function(e) {
                e.preventDefault();
                box.launchBox()
            });
            this.bigPicture = box;
            return this
        })
    }
})(jQuery);
// End ~/Scripts/jquery.bigPicture-min.js

// Begin ~/Scripts/jquery-ui-personalized-1.5.3.js

;
(function($) {
    $.ui = {
        plugin: {
            add: function(module, option, set) {
                var proto = $.ui[module].prototype;
                for (var i in set) {
                    proto.plugins[i] = proto.plugins[i] || [];
                    proto.plugins[i].push([option, set[i]]);
                }
            },
            call: function(instance, name, args) {
                var set = instance.plugins[name];
                if (!set) {
                    return;
                }
                for (var i = 0; i < set.length; i++) {
                    if (instance.options[set[i][0]]) {
                        set[i][1].apply(instance.element, args);
                    }
                }
            }
        },
        cssCache: {},
        css: function(name) {
            if ($.ui.cssCache[name]) {
                return $.ui.cssCache[name];
            }
            var tmp = $('<div class="ui-gen">').addClass(name).css({
                position: 'absolute',
                top: '-5000px',
                left: '-5000px',
                display: 'block'
            }).appendTo('body');
            $.ui.cssCache[name] = !!((!(/auto|default/).test(tmp.css('cursor')) || (/^[1-9]/).test(tmp.css('height')) || (/^[1-9]/).test(tmp.css('width')) || !(/none/).test(tmp.css('backgroundImage')) || !(/transparent|rgba\(0, 0, 0, 0\)/).test(tmp.css('backgroundColor'))));
            try {
                $('body').get(0).removeChild(tmp.get(0));
            } catch (e) { }
            return $.ui.cssCache[name];
        },
        disableSelection: function(el) {
            $(el).attr('unselectable', 'on').css('MozUserSelect', 'none');
        },
        enableSelection: function(el) {
            $(el).attr('unselectable', 'off').css('MozUserSelect', '');
        },
        hasScroll: function(e, a) {
            var scroll = /top/.test(a || "top") ? 'scrollTop' : 'scrollLeft',
            has = false;
            if (e[scroll] > 0) return true;
            e[scroll] = 1;
            has = e[scroll] > 0 ? true : false;
            e[scroll] = 0;
            return has;
        }
    };
    var _remove = $.fn.remove;
    $.fn.remove = function() {
        $("*", this).add(this).triggerHandler("remove");
        return _remove.apply(this, arguments);
    };
    function getter(namespace, plugin, method) {
        var methods = $[namespace][plugin].getter || [];
        methods = (typeof methods == "string" ? methods.split(/,?\s+/) : methods);
        return ($.inArray(method, methods) != -1);
    }
    $.widget = function(name, prototype) {
        var namespace = name.split(".")[0];
        name = name.split(".")[1];
        $.fn[name] = function(options) {
            var isMethodCall = (typeof options == 'string'),
            args = Array.prototype.slice.call(arguments, 1);
            if (isMethodCall && getter(namespace, name, options)) {
                var instance = $.data(this[0], name);
                return (instance ? instance[options].apply(instance, args) : undefined);
            }
            return this.each(function() {
                var instance = $.data(this, name);
                if (isMethodCall && instance && $.isFunction(instance[options])) {
                    instance[options].apply(instance, args);
                } else if (!isMethodCall) {
                    $.data(this, name, new $[namespace][name](this, options));
                }
            });
        };
        $[namespace][name] = function(element, options) {
            var self = this;
            this.widgetName = name;
            this.widgetBaseClass = namespace + '-' + name;
            this.options = $.extend({},
            $.widget.defaults, $[namespace][name].defaults, options);
            this.element = $(element).bind('setData.' + name,
            function(e, key, value) {
                return self.setData(key, value);
            }).bind('getData.' + name,
            function(e, key) {
                return self.getData(key);
            }).bind('remove',
            function() {
                return self.destroy();
            });
            this.init();
        };
        $[namespace][name].prototype = $.extend({},
        $.widget.prototype, prototype);
    };
    $.widget.prototype = {
        init: function() { },
        destroy: function() {
            this.element.removeData(this.widgetName);
        },
        getData: function(key) {
            return this.options[key];
        },
        setData: function(key, value) {
            this.options[key] = value;
            if (key == 'disabled') {
                this.element[value ? 'addClass' : 'removeClass'](this.widgetBaseClass + '-disabled');
            }
        },
        enable: function() {
            this.setData('disabled', false);
        },
        disable: function() {
            this.setData('disabled', true);
        }
    };
    $.widget.defaults = {
        disabled: false
    };
    $.ui.mouse = {
        mouseInit: function() {
            var self = this;
            this.element.bind('mousedown.' + this.widgetName,
            function(e) {
                return self.mouseDown(e);
            });
            if ($.browser.msie) {
                this._mouseUnselectable = this.element.attr('unselectable');
                this.element.attr('unselectable', 'on');
            }
            this.started = false;
        },
        mouseDestroy: function() {
            this.element.unbind('.' + this.widgetName);
            ($.browser.msie && this.element.attr('unselectable', this._mouseUnselectable));
        },
        mouseDown: function(e) {
            (this._mouseStarted && this.mouseUp(e));
            this._mouseDownEvent = e;
            var self = this,
            btnIsLeft = (e.which == 1),
            elIsCancel = (typeof this.options.cancel == "string" ? $(e.target).parents().add(e.target).filter(this.options.cancel).length : false);
            if (!btnIsLeft || elIsCancel || !this.mouseCapture(e)) {
                return true;
            }
            this._mouseDelayMet = !this.options.delay;
            if (!this._mouseDelayMet) {
                this._mouseDelayTimer = setTimeout(function() {
                    self._mouseDelayMet = true;
                },
                this.options.delay);
            }
            if (this.mouseDistanceMet(e) && this.mouseDelayMet(e)) {
                this._mouseStarted = (this.mouseStart(e) !== false);
                if (!this._mouseStarted) {
                    e.preventDefault();
                    return true;
                }
            }
            this._mouseMoveDelegate = function(e) {
                return self.mouseMove(e);
            };
            this._mouseUpDelegate = function(e) {
                return self.mouseUp(e);
            };
            $(document).bind('mousemove.' + this.widgetName, this._mouseMoveDelegate).bind('mouseup.' + this.widgetName, this._mouseUpDelegate);
            return false;
        },
        mouseMove: function(e) {
            if ($.browser.msie && !e.button) {
                return this.mouseUp(e);
            }
            if (this._mouseStarted) {
                this.mouseDrag(e);
                return false;
            }
            if (this.mouseDistanceMet(e) && this.mouseDelayMet(e)) {
                this._mouseStarted = (this.mouseStart(this._mouseDownEvent, e) !== false);
                (this._mouseStarted ? this.mouseDrag(e) : this.mouseUp(e));
            }
            return !this._mouseStarted;
        },
        mouseUp: function(e) {
            $(document).unbind('mousemove.' + this.widgetName, this._mouseMoveDelegate).unbind('mouseup.' + this.widgetName, this._mouseUpDelegate);
            if (this._mouseStarted) {
                this._mouseStarted = false;
                this.mouseStop(e);
            }
            return false;
        },
        mouseDistanceMet: function(e) {
            return (Math.max(Math.abs(this._mouseDownEvent.pageX - e.pageX), Math.abs(this._mouseDownEvent.pageY - e.pageY)) >= this.options.distance);
        },
        mouseDelayMet: function(e) {
            return this._mouseDelayMet;
        },
        mouseStart: function(e) { },
        mouseDrag: function(e) { },
        mouseStop: function(e) { },
        mouseCapture: function(e) {
            return true;
        }
    };
    $.ui.mouse.defaults = {
        cancel: null,
        distance: 1,
        delay: 0
    };
})(jQuery);
(function($) {
    $.widget("ui.draggable", $.extend({},
    $.ui.mouse, {
        init: function() {
            var o = this.options;
            if (o.helper == 'original' && !(/(relative|absolute|fixed)/).test(this.element.css('position'))) this.element.css('position', 'relative');
            this.element.addClass('ui-draggable');
            (o.disabled && this.element.addClass('ui-draggable-disabled'));
            this.mouseInit();
        },
        mouseStart: function(e) {
            var o = this.options;
            if (this.helper || o.disabled || $(e.target).is('.ui-resizable-handle')) return false;
            var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
            $(this.options.handle, this.element).find("*").andSelf().each(function() {
                if (this == e.target) handle = true;
            });
            if (!handle) return false;
            if ($.ui.ddmanager) $.ui.ddmanager.current = this;
            this.helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [e])) : (o.helper == 'clone' ? this.element.clone() : this.element);
            if (!this.helper.parents('body').length) this.helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo));
            if (this.helper[0] != this.element[0] && !(/(fixed|absolute)/).test(this.helper.css("position"))) this.helper.css("position", "absolute");
            this.margins = {
                left: (parseInt(this.element.css("marginLeft"), 10) || 0),
                top: (parseInt(this.element.css("marginTop"), 10) || 0)
            };
            this.cssPosition = this.helper.css("position");
            this.offset = this.element.offset();
            this.offset = {
                top: this.offset.top - this.margins.top,
                left: this.offset.left - this.margins.left
            };
            this.offset.click = {
                left: e.pageX - this.offset.left,
                top: e.pageY - this.offset.top
            };
            this.offsetParent = this.helper.offsetParent();
            var po = this.offsetParent.offset();
            if (this.offsetParent[0] == document.body && $.browser.mozilla) po = {
                top: 0,
                left: 0
            };
            this.offset.parent = {
                top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"), 10) || 0),
                left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"), 10) || 0)
            };
            var p = this.element.position();
            this.offset.relative = this.cssPosition == "relative" ? {
                top: p.top - (parseInt(this.helper.css("top"), 10) || 0) + this.offsetParent[0].scrollTop,
                left: p.left - (parseInt(this.helper.css("left"), 10) || 0) + this.offsetParent[0].scrollLeft
} : {
    top: 0,
    left: 0
};
                this.originalPosition = this.generatePosition(e);
                this.helperProportions = {
                    width: this.helper.outerWidth(),
                    height: this.helper.outerHeight()
                };
                if (o.cursorAt) {
                    if (o.cursorAt.left != undefined) this.offset.click.left = o.cursorAt.left + this.margins.left;
                    if (o.cursorAt.right != undefined) this.offset.click.left = this.helperProportions.width - o.cursorAt.right + this.margins.left;
                    if (o.cursorAt.top != undefined) this.offset.click.top = o.cursorAt.top + this.margins.top;
                    if (o.cursorAt.bottom != undefined) this.offset.click.top = this.helperProportions.height - o.cursorAt.bottom + this.margins.top;
                }
                if (o.containment) {
                    if (o.containment == 'parent') o.containment = this.helper[0].parentNode;
                    if (o.containment == 'document' || o.containment == 'window') this.containment = [0 - this.offset.relative.left - this.offset.parent.left, 0 - this.offset.relative.top - this.offset.parent.top, $(o.containment == 'document' ? document : window).width() - this.offset.relative.left - this.offset.parent.left - this.helperProportions.width - this.margins.left - (parseInt(this.element.css("marginRight"), 10) || 0), ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.offset.relative.top - this.offset.parent.top - this.helperProportions.height - this.margins.top - (parseInt(this.element.css("marginBottom"), 10) || 0)];
                    if (!(/^(document|window|parent)$/).test(o.containment)) {
                        var ce = $(o.containment)[0];
                        var co = $(o.containment).offset();
                        this.containment = [co.left + (parseInt($(ce).css("borderLeftWidth"), 10) || 0) - this.offset.relative.left - this.offset.parent.left, co.top + (parseInt($(ce).css("borderTopWidth"), 10) || 0) - this.offset.relative.top - this.offset.parent.top, co.left + Math.max(ce.scrollWidth, ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"), 10) || 0) - this.offset.relative.left - this.offset.parent.left - this.helperProportions.width - this.margins.left - (parseInt(this.element.css("marginRight"), 10) || 0), co.top + Math.max(ce.scrollHeight, ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"), 10) || 0) - this.offset.relative.top - this.offset.parent.top - this.helperProportions.height - this.margins.top - (parseInt(this.element.css("marginBottom"), 10) || 0)];
                    }
                }
                this.propagate("start", e);
                this.helperProportions = {
                    width: this.helper.outerWidth(),
                    height: this.helper.outerHeight()
                };
                if ($.ui.ddmanager && !o.dropBehaviour) $.ui.ddmanager.prepareOffsets(this, e);
                this.helper.addClass("ui-draggable-dragging");
                this.mouseDrag(e);
                return true;
            },
            convertPositionTo: function(d, pos) {
                if (!pos) pos = this.position;
                var mod = d == "absolute" ? 1 : -1;
                return {
                    top: (pos.top + this.offset.relative.top * mod + this.offset.parent.top * mod - (this.cssPosition == "fixed" || (this.cssPosition == "absolute" && this.offsetParent[0] == document.body) ? 0 : this.offsetParent[0].scrollTop) * mod + (this.cssPosition == "fixed" ? $(document).scrollTop() : 0) * mod + this.margins.top * mod),
                    left: (pos.left + this.offset.relative.left * mod + this.offset.parent.left * mod - (this.cssPosition == "fixed" || (this.cssPosition == "absolute" && this.offsetParent[0] == document.body) ? 0 : this.offsetParent[0].scrollLeft) * mod + (this.cssPosition == "fixed" ? $(document).scrollLeft() : 0) * mod + this.margins.left * mod)
                };
            },
            generatePosition: function(e) {
                var o = this.options;
                var position = {
                    top: (e.pageY - this.offset.click.top - this.offset.relative.top - this.offset.parent.top + (this.cssPosition == "fixed" || (this.cssPosition == "absolute" && this.offsetParent[0] == document.body) ? 0 : this.offsetParent[0].scrollTop) - (this.cssPosition == "fixed" ? $(document).scrollTop() : 0)),
                    left: (e.pageX - this.offset.click.left - this.offset.relative.left - this.offset.parent.left + (this.cssPosition == "fixed" || (this.cssPosition == "absolute" && this.offsetParent[0] == document.body) ? 0 : this.offsetParent[0].scrollLeft) - (this.cssPosition == "fixed" ? $(document).scrollLeft() : 0))
                };
                if (!this.originalPosition) return position;
                if (this.containment) {
                    if (position.left < this.containment[0]) position.left = this.containment[0];
                    if (position.top < this.containment[1]) position.top = this.containment[1];
                    if (position.left > this.containment[2]) position.left = this.containment[2];
                    if (position.top > this.containment[3]) position.top = this.containment[3];
                }
                if (o.grid) {
                    var top = this.originalPosition.top + Math.round((position.top - this.originalPosition.top) / o.grid[1]) * o.grid[1];
                    position.top = this.containment ? (!(top < this.containment[1] || top > this.containment[3]) ? top : (!(top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
                    var left = this.originalPosition.left + Math.round((position.left - this.originalPosition.left) / o.grid[0]) * o.grid[0];
                    position.left = this.containment ? (!(left < this.containment[0] || left > this.containment[2]) ? left : (!(left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
                }
                return position;
            },
            mouseDrag: function(e) {
                this.position = this.generatePosition(e);
                this.positionAbs = this.convertPositionTo("absolute");
                this.position = this.propagate("drag", e) || this.position;
                if (!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left + 'px';
                if (!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top + 'px';
                if ($.ui.ddmanager) $.ui.ddmanager.drag(this, e);
                return false;
            },
            mouseStop: function(e) {
                var dropped = false;
                if ($.ui.ddmanager && !this.options.dropBehaviour) var dropped = $.ui.ddmanager.drop(this, e);
                if ((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true) {
                    var self = this;
                    $(this.helper).animate(this.originalPosition, parseInt(this.options.revert, 10) || 500,
                function() {
                    self.propagate("stop", e);
                    self.clear();
                });
                } else {
                    this.propagate("stop", e);
                    this.clear();
                }
                return false;
            },
            clear: function() {
                this.helper.removeClass("ui-draggable-dragging");
                if (this.options.helper != 'original' && !this.cancelHelperRemoval) this.helper.remove();
                this.helper = null;
                this.cancelHelperRemoval = false;
            },
            plugins: {},
            uiHash: function(e) {
                return {
                    helper: this.helper,
                    position: this.position,
                    absolutePosition: this.positionAbs,
                    options: this.options
                };
            },
            propagate: function(n, e) {
                $.ui.plugin.call(this, n, [e, this.uiHash()]);
                if (n == "drag") this.positionAbs = this.convertPositionTo("absolute");
                return this.element.triggerHandler(n == "drag" ? n : "drag" + n, [e, this.uiHash()], this.options[n]);
            },
            destroy: function() {
                if (!this.element.data('draggable')) return;
                this.element.removeData("draggable").unbind(".draggable").removeClass('ui-draggable');
                this.mouseDestroy();
            }
        }));
        $.extend($.ui.draggable, {
            defaults: {
                appendTo: "parent",
                axis: false,
                cancel: ":input",
                delay: 0,
                distance: 1,
                helper: "original"
            }
        });
        $.ui.plugin.add("draggable", "cursor", {
            start: function(e, ui) {
                var t = $('body');
                if (t.css("cursor")) ui.options._cursor = t.css("cursor");
                t.css("cursor", ui.options.cursor);
            },
            stop: function(e, ui) {
                if (ui.options._cursor) $('body').css("cursor", ui.options._cursor);
            }
        });
        $.ui.plugin.add("draggable", "zIndex", {
            start: function(e, ui) {
                var t = $(ui.helper);
                if (t.css("zIndex")) ui.options._zIndex = t.css("zIndex");
                t.css('zIndex', ui.options.zIndex);
            },
            stop: function(e, ui) {
                if (ui.options._zIndex) $(ui.helper).css('zIndex', ui.options._zIndex);
            }
        });
        $.ui.plugin.add("draggable", "opacity", {
            start: function(e, ui) {
                var t = $(ui.helper);
                if (t.css("opacity")) ui.options._opacity = t.css("opacity");
                t.css('opacity', ui.options.opacity);
            },
            stop: function(e, ui) {
                if (ui.options._opacity) $(ui.helper).css('opacity', ui.options._opacity);
            }
        });
        $.ui.plugin.add("draggable", "iframeFix", {
            start: function(e, ui) {
                $(ui.options.iframeFix === true ? "iframe" : ui.options.iframeFix).each(function() {
                    $('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>').css({
                        width: this.offsetWidth + "px",
                        height: this.offsetHeight + "px",
                        position: "absolute",
                        opacity: "0.001",
                        zIndex: 1000
                    }).css($(this).offset()).appendTo("body");
                });
            },
            stop: function(e, ui) {
                $("div.DragDropIframeFix").each(function() {
                    this.parentNode.removeChild(this);
                });
            }
        });
        $.ui.plugin.add("draggable", "scroll", {
            start: function(e, ui) {
                var o = ui.options;
                var i = $(this).data("draggable");
                o.scrollSensitivity = o.scrollSensitivity || 20;
                o.scrollSpeed = o.scrollSpeed || 20;
                i.overflowY = function(el) {
                    do {
                        if (/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-y'))) return el;
                        el = el.parent();
                    } while (el[0].parentNode);
                    return $(document);
                } (this);
                i.overflowX = function(el) {
                    do {
                        if (/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-x'))) return el;
                        el = el.parent();
                    } while (el[0].parentNode);
                    return $(document);
                } (this);
                if (i.overflowY[0] != document && i.overflowY[0].tagName != 'HTML') i.overflowYOffset = i.overflowY.offset();
                if (i.overflowX[0] != document && i.overflowX[0].tagName != 'HTML') i.overflowXOffset = i.overflowX.offset();
            },
            drag: function(e, ui) {
                var o = ui.options;
                var i = $(this).data("draggable");
                if (i.overflowY[0] != document && i.overflowY[0].tagName != 'HTML') {
                    if ((i.overflowYOffset.top + i.overflowY[0].offsetHeight) - e.pageY < o.scrollSensitivity) i.overflowY[0].scrollTop = i.overflowY[0].scrollTop + o.scrollSpeed;
                    if (e.pageY - i.overflowYOffset.top < o.scrollSensitivity) i.overflowY[0].scrollTop = i.overflowY[0].scrollTop - o.scrollSpeed;
                } else {
                    if (e.pageY - $(document).scrollTop() < o.scrollSensitivity) $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
                    if ($(window).height() - (e.pageY - $(document).scrollTop()) < o.scrollSensitivity) $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
                }
                if (i.overflowX[0] != document && i.overflowX[0].tagName != 'HTML') {
                    if ((i.overflowXOffset.left + i.overflowX[0].offsetWidth) - e.pageX < o.scrollSensitivity) i.overflowX[0].scrollLeft = i.overflowX[0].scrollLeft + o.scrollSpeed;
                    if (e.pageX - i.overflowXOffset.left < o.scrollSensitivity) i.overflowX[0].scrollLeft = i.overflowX[0].scrollLeft - o.scrollSpeed;
                } else {
                    if (e.pageX - $(document).scrollLeft() < o.scrollSensitivity) $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
                    if ($(window).width() - (e.pageX - $(document).scrollLeft()) < o.scrollSensitivity) $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
                }
            }
        });
        $.ui.plugin.add("draggable", "snap", {
            start: function(e, ui) {
                var inst = $(this).data("draggable");
                inst.snapElements = [];
                $(ui.options.snap === true ? '.ui-draggable' : ui.options.snap).each(function() {
                    var $t = $(this);
                    var $o = $t.offset();
                    if (this != inst.element[0]) inst.snapElements.push({
                        item: this,
                        width: $t.outerWidth(),
                        height: $t.outerHeight(),
                        top: $o.top,
                        left: $o.left
                    });
                });
            },
            drag: function(e, ui) {
                var inst = $(this).data("draggable");
                var d = ui.options.snapTolerance || 20;
                var x1 = ui.absolutePosition.left,
            x2 = x1 + inst.helperProportions.width,
            y1 = ui.absolutePosition.top,
            y2 = y1 + inst.helperProportions.height;
                for (var i = inst.snapElements.length - 1; i >= 0; i--) {
                    var l = inst.snapElements[i].left,
                r = l + inst.snapElements[i].width,
                t = inst.snapElements[i].top,
                b = t + inst.snapElements[i].height;
                    if (!((l - d < x1 && x1 < r + d && t - d < y1 && y1 < b + d) || (l - d < x1 && x1 < r + d && t - d < y2 && y2 < b + d) || (l - d < x2 && x2 < r + d && t - d < y1 && y1 < b + d) || (l - d < x2 && x2 < r + d && t - d < y2 && y2 < b + d))) continue;
                    if (ui.options.snapMode != 'inner') {
                        var ts = Math.abs(t - y2) <= 20;
                        var bs = Math.abs(b - y1) <= 20;
                        var ls = Math.abs(l - x2) <= 20;
                        var rs = Math.abs(r - x1) <= 20;
                        if (ts) ui.position.top = inst.convertPositionTo("relative", {
                            top: t - inst.helperProportions.height,
                            left: 0
                        }).top;
                        if (bs) ui.position.top = inst.convertPositionTo("relative", {
                            top: b,
                            left: 0
                        }).top;
                        if (ls) ui.position.left = inst.convertPositionTo("relative", {
                            top: 0,
                            left: l - inst.helperProportions.width
                        }).left;
                        if (rs) ui.position.left = inst.convertPositionTo("relative", {
                            top: 0,
                            left: r
                        }).left;
                    }
                    if (ui.options.snapMode != 'outer') {
                        var ts = Math.abs(t - y1) <= 20;
                        var bs = Math.abs(b - y2) <= 20;
                        var ls = Math.abs(l - x1) <= 20;
                        var rs = Math.abs(r - x2) <= 20;
                        if (ts) ui.position.top = inst.convertPositionTo("relative", {
                            top: t,
                            left: 0
                        }).top;
                        if (bs) ui.position.top = inst.convertPositionTo("relative", {
                            top: b - inst.helperProportions.height,
                            left: 0
                        }).top;
                        if (ls) ui.position.left = inst.convertPositionTo("relative", {
                            top: 0,
                            left: l
                        }).left;
                        if (rs) ui.position.left = inst.convertPositionTo("relative", {
                            top: 0,
                            left: r - inst.helperProportions.width
                        }).left;
                    }
                };
            }
        });
        $.ui.plugin.add("draggable", "connectToSortable", {
            start: function(e, ui) {
                var inst = $(this).data("draggable");
                inst.sortables = [];
                $(ui.options.connectToSortable).each(function() {
                    if ($.data(this, 'sortable')) {
                        var sortable = $.data(this, 'sortable');
                        inst.sortables.push({
                            instance: sortable,
                            shouldRevert: sortable.options.revert
                        });
                        sortable.refreshItems();
                        sortable.propagate("activate", e, inst);
                    }
                });
            },
            stop: function(e, ui) {
                var inst = $(this).data("draggable");
                $.each(inst.sortables,
            function() {
                if (this.instance.isOver) {
                    this.instance.isOver = 0;
                    inst.cancelHelperRemoval = true;
                    this.instance.cancelHelperRemoval = false;
                    if (this.shouldRevert) this.instance.options.revert = true;
                    this.instance.mouseStop(e);
                    this.instance.element.triggerHandler("sortreceive", [e, $.extend(this.instance.ui(), {
                        sender: inst.element
                    })], this.instance.options["receive"]);
                    this.instance.options.helper = this.instance.options._helper;
                } else {
                    this.instance.propagate("deactivate", e, inst);
                }
            });
            },
            drag: function(e, ui) {
                var inst = $(this).data("draggable"),
            self = this;
                var checkPos = function(o) {
                    var l = o.left,
                r = l + o.width,
                t = o.top,
                b = t + o.height;
                    return (l < (this.positionAbs.left + this.offset.click.left) && (this.positionAbs.left + this.offset.click.left) < r && t < (this.positionAbs.top + this.offset.click.top) && (this.positionAbs.top + this.offset.click.top) < b);
                };
                $.each(inst.sortables,
            function(i) {
                if (checkPos.call(inst, this.instance.containerCache)) {
                    if (!this.instance.isOver) {
                        this.instance.isOver = 1;
                        this.instance.currentItem = $(self).clone().appendTo(this.instance.element).data("sortable-item", true);
                        this.instance.options._helper = this.instance.options.helper;
                        this.instance.options.helper = function() {
                            return ui.helper[0];
                        };
                        e.target = this.instance.currentItem[0];
                        this.instance.mouseCapture(e, true);
                        this.instance.mouseStart(e, true, true);
                        this.instance.offset.click.top = inst.offset.click.top;
                        this.instance.offset.click.left = inst.offset.click.left;
                        this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
                        this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
                        inst.propagate("toSortable", e);
                    }
                    if (this.instance.currentItem) this.instance.mouseDrag(e);
                } else {
                    if (this.instance.isOver) {
                        this.instance.isOver = 0;
                        this.instance.cancelHelperRemoval = true;
                        this.instance.options.revert = false;
                        this.instance.mouseStop(e, true);
                        this.instance.options.helper = this.instance.options._helper;
                        this.instance.currentItem.remove();
                        if (this.instance.placeholder) this.instance.placeholder.remove();
                        inst.propagate("fromSortable", e);
                    }
                };
            });
            }
        });
        $.ui.plugin.add("draggable", "stack", {
            start: function(e, ui) {
                var group = $.makeArray($(ui.options.stack.group)).sort(function(a, b) {
                    return (parseInt($(a).css("zIndex"), 10) || ui.options.stack.min) - (parseInt($(b).css("zIndex"), 10) || ui.options.stack.min);
                });
                $(group).each(function(i) {
                    this.style.zIndex = ui.options.stack.min + i;
                });
                this[0].style.zIndex = ui.options.stack.min + group.length;
            }
        });
    })(jQuery);
    (function($) {
        $.widget("ui.accordion", {
            init: function() {
                var options = this.options;
                if (options.navigation) {
                    var current = this.element.find("a").filter(options.navigationFilter);
                    if (current.length) {
                        if (current.filter(options.header).length) {
                            options.active = current;
                        } else {
                            options.active = current.parent().parent().prev();
                            current.addClass("current");
                        }
                    }
                }
                options.headers = this.element.find(options.header);
                options.active = findActive(options.headers, options.active);
                if ($.browser.msie) {
                    this.element.find('a').css('zoom', '1');
                }
                if (!this.element.hasClass("ui-accordion")) {
                    this.element.addClass("ui-accordion");
                    $("<span class='ui-accordion-left'/>").insertBefore(options.headers);
                    $("<span class='ui-accordion-right'/>").appendTo(options.headers);
                    options.headers.addClass("ui-accordion-header").attr("tabindex", "0");
                }
                var maxHeight;
                if (options.fillSpace) {
                    maxHeight = this.element.parent().height();
                    options.headers.each(function() {
                        maxHeight -= $(this).outerHeight();
                    });
                    var maxPadding = 0;
                    options.headers.next().each(function() {
                        maxPadding = Math.max(maxPadding, $(this).innerHeight() - $(this).height());
                    }).height(maxHeight - maxPadding);
                } else if (options.autoHeight) {
                    maxHeight = 0;
                    options.headers.next().each(function() {
                        maxHeight = Math.max(maxHeight, $(this).outerHeight());
                    }).height(maxHeight);
                }
                options.headers.not(options.active || "").next().hide();
                options.active.parent().andSelf().addClass(options.selectedClass);
                if (options.event) {
                    this.element.bind((options.event) + ".accordion", clickHandler);
                }
            },
            activate: function(index) {
                clickHandler.call(this.element[0], {
                    target: findActive(this.options.headers, index)[0]
                });
            },
            destroy: function() {
                this.options.headers.next().css("display", "");
                if (this.options.fillSpace || this.options.autoHeight) {
                    this.options.headers.next().css("height", "");
                }
                $.removeData(this.element[0], "accordion");
                this.element.removeClass("ui-accordion").unbind(".accordion");
            }
        });
        function scopeCallback(callback, scope) {
            return function() {
                return callback.apply(scope, arguments);
            };
        };
        function completed(cancel) {
            if (!$.data(this, "accordion")) {
                return;
            }
            var instance = $.data(this, "accordion");
            var options = instance.options;
            options.running = cancel ? 0 : --options.running;
            if (options.running) {
                return;
            }
            if (options.clearStyle) {
                options.toShow.add(options.toHide).css({
                    height: "",
                    overflow: ""
                });
            }
            $(this).triggerHandler("accordionchange", [$.event.fix({
                type: 'accordionchange',
                target: instance.element[0]
            }), options.data], options.change);
        }
        function toggle(toShow, toHide, data, clickedActive, down) {
            var options = $.data(this, "accordion").options;
            options.toShow = toShow;
            options.toHide = toHide;
            options.data = data;
            var complete = scopeCallback(completed, this);
            options.running = toHide.size() === 0 ? toShow.size() : toHide.size();
            if (options.animated) {
                if (!options.alwaysOpen && clickedActive) {
                    $.ui.accordion.animations[options.animated]({
                        toShow: jQuery([]),
                        toHide: toHide,
                        complete: complete,
                        down: down,
                        autoHeight: options.autoHeight
                    });
                } else {
                    $.ui.accordion.animations[options.animated]({
                        toShow: toShow,
                        toHide: toHide,
                        complete: complete,
                        down: down,
                        autoHeight: options.autoHeight
                    });
                }
            } else {
                if (!options.alwaysOpen && clickedActive) {
                    toShow.toggle();
                } else {
                    toHide.hide();
                    toShow.show();
                }
                complete(true);
            }
        }
        function clickHandler(event) {
            var options = $.data(this, "accordion").options;
            if (options.disabled) {
                return false;
            }
            if (!event.target && !options.alwaysOpen) {
                options.active.parent().andSelf().toggleClass(options.selectedClass);
                var toHide = options.active.next(),
            data = {
                options: options,
                newHeader: jQuery([]),
                oldHeader: options.active,
                newContent: jQuery([]),
                oldContent: toHide
            },
            toShow = (options.active = $([]));
                toggle.call(this, toShow, toHide, data);
                return false;
            }
            var clicked = $(event.target);
            clicked = $(clicked.parents(options.header)[0] || clicked);
            var clickedActive = clicked[0] == options.active[0];
            if (options.running || (options.alwaysOpen && clickedActive)) {
                return false;
            }
            if (!clicked.is(options.header)) {
                return;
            }
            options.active.parent().andSelf().toggleClass(options.selectedClass);
            if (!clickedActive) {
                clicked.parent().andSelf().addClass(options.selectedClass);
            }
            var toShow = clicked.next(),
        toHide = options.active.next(),
        data = {
            options: options,
            newHeader: clicked,
            oldHeader: options.active,
            newContent: toShow,
            oldContent: toHide
        },
        down = options.headers.index(options.active[0]) > options.headers.index(clicked[0]);
            options.active = clickedActive ? $([]) : clicked;
            toggle.call(this, toShow, toHide, data, clickedActive, down);
            return false;
        };
        function findActive(headers, selector) {
            return selector != undefined ? typeof selector == "number" ? headers.filter(":eq(" + selector + ")") : headers.not(headers.not(selector)) : selector === false ? $([]) : headers.filter(":eq(0)");
        }
        $.extend($.ui.accordion, {
            defaults: {
                selectedClass: "selected",
                alwaysOpen: true,
                animated: 'slide',
                event: "click",
                header: "a",
                autoHeight: true,
                running: 0,
                navigationFilter: function() {
                    return this.href.toLowerCase() == location.href.toLowerCase();
                }
            },
            animations: {
                slide: function(options, additions) {
                    options = $.extend({
                        easing: "swing",
                        duration: 300
                    },
                options, additions);
                    if (!options.toHide.size()) {
                        options.toShow.animate({
                            height: "show"
                        },
                    options);
                        return;
                    }
                    var hideHeight = options.toHide.height(),
                showHeight = options.toShow.height(),
                difference = showHeight / hideHeight;
                    options.toShow.css({
                        height: 0,
                        overflow: 'hidden'
                    }).show();
                    options.toHide.filter(":hidden").each(options.complete).end().filter(":visible").animate({
                        height: "hide"
                    },
                {
                    step: function(now) {
                        var current = (hideHeight - now) * difference;
                        if ($.browser.msie || $.browser.opera) {
                            current = Math.ceil(current);
                        }
                        options.toShow.height(current);
                    },
                    duration: options.duration,
                    easing: options.easing,
                    complete: function() {
                        if (!options.autoHeight) {
                            options.toShow.css("height", "auto");
                        }
                        options.complete();
                    }
                });
                },
                bounceslide: function(options) {
                    this.slide(options, {
                        easing: options.down ? "bounceout" : "swing",
                        duration: options.down ? 1000 : 200
                    });
                },
                easeslide: function(options) {
                    this.slide(options, {
                        easing: "easeinout",
                        duration: 700
                    });
                }
            }
        });
        $.fn.activate = function(index) {
            return this.accordion("activate", index);
        };
    })(jQuery);
    (function($) {
        $.widget("ui.tabs", {
            init: function() {
                this.options.event += '.tabs';
                this.tabify(true);
            },
            setData: function(key, value) {
                if ((/^selected/).test(key)) this.select(value);
                else {
                    this.options[key] = value;
                    this.tabify();
                }
            },
            length: function() {
                return this.$tabs.length;
            },
            tabId: function(a) {
                return a.title && a.title.replace(/\s/g, '_').replace(/[^A-Za-z0-9\-_:\.]/g, '') || this.options.idPrefix + $.data(a);
            },
            ui: function(tab, panel) {
                return {
                    options: this.options,
                    tab: tab,
                    panel: panel,
                    index: this.$tabs.index(tab)
                };
            },
            tabify: function(init) {
                this.$lis = $('ul.tabs>li:has(a[href])', this.element);
                this.$tabs = this.$lis.map(function() {
                    return $('a', this)[0];
                });
                this.$panels = $([]);
                var self = this,
            o = this.options;
                this.$tabs.each(function(i, a) {
                    if (a.hash && a.hash.replace('#', '')) self.$panels = self.$panels.add(a.hash);
                    else if ($(a).attr('href') != '#') {
                        $.data(a, 'href.tabs', a.href);
                        $.data(a, 'load.tabs', a.href);
                        var id = self.tabId(a);
                        a.href = '#' + id;
                        var $panel = $('#' + id);
                        if (!$panel.length) {
                            $panel = $(o.panelTemplate).attr('id', id).addClass(o.panelClass).insertAfter(self.$panels[i - 1] || self.element);
                            $panel.data('destroy.tabs', true);
                        }
                        self.$panels = self.$panels.add($panel);
                    }
                    else o.disabled.push(i + 1);
                });
                if (init) {
                    this.element.addClass(o.navClass);
                    this.$panels.each(function() {
                        var $this = $(this);
                        $this.addClass(o.panelClass);
                    });
                    if (o.selected === undefined) {
                        if (location.hash) {
                            this.$tabs.each(function(i, a) {
                                if (a.hash == location.hash) {
                                    o.selected = i;
                                    if ($.browser.msie || $.browser.opera) {
                                        var $toShow = $(location.hash),
                                    toShowId = $toShow.attr('id');
                                        $toShow.attr('id', '');
                                        setTimeout(function() {
                                            $toShow.attr('id', toShowId);
                                        },
                                    500);
                                    }
                                    scrollTo(0, 0);
                                    return false;
                                }
                            });
                        }
                        else if (o.cookie) {
                            var index = parseInt($.cookie('ui-tabs' + $.data(self.element)), 10);
                            if (index && self.$tabs[index]) o.selected = index;
                        }
                        else if (self.$lis.filter('.' + o.selectedClass).length) o.selected = self.$lis.index(self.$lis.filter('.' + o.selectedClass)[0]);
                    }
                    o.selected = o.selected === null || o.selected !== undefined ? o.selected : 0;
                    o.disabled = $.unique(o.disabled.concat($.map(this.$lis.filter('.' + o.disabledClass),
                function(n, i) {
                    return self.$lis.index(n);
                }))).sort();
                    if ($.inArray(o.selected, o.disabled) != -1) o.disabled.splice($.inArray(o.selected, o.disabled), 1);
                    this.$panels.addClass(o.hideClass);
                    this.$lis.removeClass(o.selectedClass);
                    if (o.selected !== null) {
                        this.$panels.eq(o.selected).show().removeClass(o.hideClass);
                        this.$lis.eq(o.selected).addClass(o.selectedClass);
                        var onShow = function() {
                            $(self.element).triggerHandler('tabsshow', [self.fakeEvent('tabsshow'), self.ui(self.$tabs[o.selected], self.$panels[o.selected])], o.show);
                        };
                        if ($.data(this.$tabs[o.selected], 'load.tabs')) this.load(o.selected, onShow);
                        else onShow();
                    }
                    $(window).bind('unload',
                function() {
                    self.$tabs.unbind('.tabs');
                    self.$lis = self.$tabs = self.$panels = null;
                });
                }
                for (var i = 0, li; li = this.$lis[i]; i++)
                    $(li)[$.inArray(i, o.disabled) != -1 && !$(li).hasClass(o.selectedClass) ? 'addClass' : 'removeClass'](o.disabledClass);
                if (o.cache === false) this.$tabs.removeData('cache.tabs');
                var hideFx, showFx, baseFx = {
                    'min-width': 0,
                    duration: 1
                },
            baseDuration = 'normal';
                if (o.fx && o.fx.constructor == Array) hideFx = o.fx[0] || baseFx,
            showFx = o.fx[1] || baseFx;
                else hideFx = showFx = o.fx || baseFx;
                var resetCSS = {
                    display: '',
                    overflow: '',
                    height: ''
                };
                if (!$.browser.msie) resetCSS.opacity = '';
                function hideTab(clicked, $hide, $show) {
                    $hide.animate(hideFx, hideFx.duration || baseDuration,
                function() {
                    $hide.addClass(o.hideClass).css(resetCSS);
                    if ($.browser.msie && hideFx.opacity) $hide[0].style.filter = '';
                    if ($show) showTab(clicked, $show, $hide);
                });
                }
                function showTab(clicked, $show, $hide) {
                    if (showFx === baseFx) $show.css('display', 'block');
                    $show.animate(showFx, showFx.duration || baseDuration,
                function() {
                    $show.removeClass(o.hideClass).css(resetCSS);
                    if ($.browser.msie && showFx.opacity) $show[0].style.filter = '';
                    $(self.element).triggerHandler('tabsshow', [self.fakeEvent('tabsshow'), self.ui(clicked, $show[0])], o.show);
                });
                }
                function switchTab(clicked, $li, $hide, $show) {
                    $li.addClass(o.selectedClass).siblings().removeClass(o.selectedClass);
                    hideTab(clicked, $hide, $show);
                }
                this.$tabs.unbind('.tabs').bind(o.event,
            function() {
                var $li = $(this).parents('li:eq(0)'),
                $hide = self.$panels.filter(':visible'),
                $show = $(this.hash);
                if (($li.hasClass(o.selectedClass) && !o.unselect) || $li.hasClass(o.disabledClass) || $(this).hasClass(o.loadingClass) || $(self.element).triggerHandler('tabsselect', [self.fakeEvent('tabsselect'), self.ui(this, $show[0])], o.select) === false) {
                    this.blur();
                    return false;
                }
                self.options.selected = self.$tabs.index(this);
                if (o.unselect) {
                    if ($li.hasClass(o.selectedClass)) {
                        self.options.selected = null;
                        $li.removeClass(o.selectedClass);
                        self.$panels.stop();
                        hideTab(this, $hide);
                        this.blur();
                        return false;
                    } else if (!$hide.length) {
                        self.$panels.stop();
                        var a = this;
                        self.load(self.$tabs.index(this),
                        function() {
                            $li.addClass(o.selectedClass).addClass(o.unselectClass);
                            showTab(a, $show);
                        });
                        this.blur();
                        return false;
                    }
                }
                if (o.cookie) $.cookie('ui-tabs' + $.data(self.element), self.options.selected, o.cookie);
                self.$panels.stop();
                if ($show.length) {
                    var a = this;
                    self.load(self.$tabs.index(this), $hide.length ?
                    function() {
                        switchTab(a, $li, $hide, $show);
                    } : function() {
                        $li.addClass(o.selectedClass);
                        showTab(a, $show);
                    });
                } else throw 'jQuery UI Tabs: Mismatching fragment identifier.';
                if ($.browser.msie) this.blur();
                return false;
            });
                if (!(/^click/).test(o.event)) this.$tabs.bind('click.tabs',
            function() {
                return false;
            });
            },
            add: function(url, label, index) {
                if (index == undefined) index = this.$tabs.length;
                var o = this.options;
                var $li = $(o.tabTemplate.replace(/#\{href\}/g, url).replace(/#\{label\}/g, label));
                $li.data('destroy.tabs', true);
                var id = url.indexOf('#') == 0 ? url.replace('#', '') : this.tabId($('a:first-child', $li)[0]);
                var $panel = $('#' + id);
                if (!$panel.length) {
                    $panel = $(o.panelTemplate).attr('id', id).addClass(o.hideClass).data('destroy.tabs', true);
                }
                $panel.addClass(o.panelClass);
                if (index >= this.$lis.length) {
                    $li.appendTo(this.element);
                    $panel.appendTo(this.element[0].parentNode);
                } else {
                    $li.insertBefore(this.$lis[index]);
                    $panel.insertBefore(this.$panels[index]);
                }
                o.disabled = $.map(o.disabled,
            function(n, i) {
                return n >= index ? ++n : n
            });
                this.tabify();
                if (this.$tabs.length == 1) {
                    $li.addClass(o.selectedClass);
                    $panel.removeClass(o.hideClass);
                    var href = $.data(this.$tabs[0], 'load.tabs');
                    if (href) this.load(index, href);
                }
                this.element.triggerHandler('tabsadd', [this.fakeEvent('tabsadd'), this.ui(this.$tabs[index], this.$panels[index])], o.add);
            },
            remove: function(index) {
                var o = this.options,
            $li = this.$lis.eq(index).remove(),
            $panel = this.$panels.eq(index).remove();
                if ($li.hasClass(o.selectedClass) && this.$tabs.length > 1) this.select(index + (index + 1 < this.$tabs.length ? 1 : -1));
                o.disabled = $.map($.grep(o.disabled,
            function(n, i) {
                return n != index;
            }),
            function(n, i) {
                return n >= index ? --n : n
            });
                this.tabify();
                this.element.triggerHandler('tabsremove', [this.fakeEvent('tabsremove'), this.ui($li.find('a')[0], $panel[0])], o.remove);
            },
            enable: function(index) {
                var o = this.options;
                if ($.inArray(index, o.disabled) == -1) return;
                var $li = this.$lis.eq(index).removeClass(o.disabledClass);
                if ($.browser.safari) {
                    $li.css('display', 'inline-block');
                    setTimeout(function() {
                        $li.css('display', 'block');
                    },
                0);
                }
                o.disabled = $.grep(o.disabled,
            function(n, i) {
                return n != index;
            });
                this.element.triggerHandler('tabsenable', [this.fakeEvent('tabsenable'), this.ui(this.$tabs[index], this.$panels[index])], o.enable);
            },
            disable: function(index) {
                var self = this,
            o = this.options;
                if (index != o.selected) {
                    this.$lis.eq(index).addClass(o.disabledClass);
                    o.disabled.push(index);
                    o.disabled.sort();
                    this.element.triggerHandler('tabsdisable', [this.fakeEvent('tabsdisable'), this.ui(this.$tabs[index], this.$panels[index])], o.disable);
                }
            },
            select: function(index) {
                if (typeof index == 'string') index = this.$tabs.index(this.$tabs.filter('[href$=' + index + ']')[0]);
                this.$tabs.eq(index).trigger(this.options.event);
            },
            load: function(index, callback) {
                var self = this,
            o = this.options,
            $a = this.$tabs.eq(index),
            a = $a[0],
            bypassCache = callback == undefined || callback === false,
            url = $a.data('load.tabs');
                callback = callback ||
            function() { };
                if (!url || !bypassCache && $.data(a, 'cache.tabs')) {
                    callback();
                    return;
                }
                var inner = function(parent) {
                    var $parent = $(parent),
                $inner = $parent.find('*:last');
                    return $inner.length && $inner.is(':not(img)') && $inner || $parent;
                };
                var cleanup = function() {
                    self.$tabs.filter('.' + o.loadingClass).removeClass(o.loadingClass).each(function() {
                        if (o.spinner) inner(this).parent().html(inner(this).data('label.tabs'));
                    });
                    self.xhr = null;
                };
                if (o.spinner) {
                    var label = inner(a).html();
                    inner(a).wrapInner('<em></em>').find('em').data('label.tabs', label).html(o.spinner);
                }
                var ajaxOptions = $.extend({},
            o.ajaxOptions, {
                url: url,
                success: function(r, s) {
                    $(a.hash).html(r);
                    cleanup();
                    if (o.cache) $.data(a, 'cache.tabs', true);
                    $(self.element).triggerHandler('tabsload', [self.fakeEvent('tabsload'), self.ui(self.$tabs[index], self.$panels[index])], o.load);
                    o.ajaxOptions.success && o.ajaxOptions.success(r, s);
                    callback();
                }
            });
                if (this.xhr) {
                    this.xhr.abort();
                    cleanup();
                }
                $a.addClass(o.loadingClass);
                setTimeout(function() {
                    self.xhr = $.ajax(ajaxOptions);
                },
            0);
            },
            url: function(index, url) {
                this.$tabs.eq(index).removeData('cache.tabs').data('load.tabs', url);
            },
            destroy: function() {
                var o = this.options;
                this.element.unbind('.tabs').removeClass(o.navClass).removeData('tabs');
                this.$tabs.each(function() {
                    var href = $.data(this, 'href.tabs');
                    if (href) this.href = href;
                    var $this = $(this).unbind('.tabs');
                    $.each(['href', 'load', 'cache'],
                function(i, prefix) {
                    $this.removeData(prefix + '.tabs');
                });
                });
                this.$lis.add(this.$panels).each(function() {
                    if ($.data(this, 'destroy.tabs')) $(this).remove();
                    else $(this).removeClass([o.selectedClass, o.unselectClass, o.disabledClass, o.panelClass, o.hideClass].join(' '));
                });
            },
            fakeEvent: function(type) {
                return $.event.fix({
                    type: type,
                    target: this.element[0]
                });
            }
        });
        $.ui.tabs.defaults = {
            unselect: false,
            event: 'click',
            disabled: [],
            cookie: null,
            spinner: 'Loading…',
            cache: false,
            idPrefix: 'ui-tabs-',
            ajaxOptions: {},
            fx: null,
            tabTemplate: '<li><a href="#{href}"><span>#{label}</span></a></li>',
            panelTemplate: '<div></div>',
            navClass: 'ui-tabs-nav',
            selectedClass: 'ui-tabs-selected',
            unselectClass: 'ui-tabs-unselect',
            disabledClass: 'ui-tabs-disabled',
            panelClass: 'ui-tabs-panel',
            hideClass: 'ui-tabs-hide',
            loadingClass: 'ui-tabs-loading'
        };
        $.ui.tabs.getter = "length";
        $.extend($.ui.tabs.prototype, {
            rotation: null,
            rotate: function(ms, continuing) {
                continuing = continuing || false;
                var self = this,
            t = this.options.selected;
                function start() {
                    self.rotation = setInterval(function() {
                        t = ++t < self.$tabs.length ? t : 0;
                        self.select(t);
                    },
                ms);
                }
                function stop(e) {
                    if (!e || e.clientX) {
                        clearInterval(self.rotation);
                    }
                }
                if (ms) {
                    start();
                    if (!continuing) this.$tabs.bind(this.options.event, stop);
                    else this.$tabs.bind(this.options.event,
                function() {
                    stop();
                    t = self.options.selected;
                    start();
                });
                }
                else {
                    stop();
                    this.$tabs.unbind(this.options.event, stop);
                }
            }
        });
    })(jQuery);
    (function($) {
        var PROP_NAME = 'datepicker';
        function Datepicker() {
            this.debug = false;
            this._curInst = null;
            this._disabledInputs = [];
            this._datepickerShowing = false;
            this._inDialog = false;
            this._mainDivId = 'ui-datepicker-div';
            this._appendClass = 'ui-datepicker-append';
            this._triggerClass = 'ui-datepicker-trigger';
            this._dialogClass = 'ui-datepicker-dialog';
            this._promptClass = 'ui-datepicker-prompt';
            this._unselectableClass = 'ui-datepicker-unselectable';
            this._currentClass = 'ui-datepicker-current-day';
            this.regional = [];
            this.regional[''] = {
                clearText: 'Clear',
                clearStatus: 'Erase the current date',
                closeText: 'Close',
                closeStatus: 'Close without change',
                prevText: '<Prev',
                prevStatus: 'Show the previous month',
                nextText: 'Next>',
                nextStatus: 'Show the next month',
                currentText: 'Today',
                currentStatus: 'Show the current month',
                monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
                monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
                monthStatus: 'Show a different month',
                yearStatus: 'Show a different year',
                weekHeader: 'Wk',
                weekStatus: 'Week of the year',
                dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
                dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
                dayNamesMin: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
                dayStatus: 'Set DD as first week day',
                dateStatus: 'Select DD, M d',
                dateFormat: 'mm/dd/yy',
                firstDay: 0,
                initStatus: 'Select a date',
                isRTL: false
            };
            this._defaults = {
                showOn: 'focus',
                showAnim: 'show',
                showOptions: {},
                defaultDate: null,
                appendText: '',
                buttonText: '...',
                buttonImage: '',
                buttonImageOnly: false,
                closeAtTop: true,
                mandatory: false,
                hideIfNoPrevNext: false,
                navigationAsDateFormat: false,
                gotoCurrent: false,
                changeMonth: true,
                changeYear: true,
                yearRange: '-10:+10',
                changeFirstDay: true,
                highlightWeek: false,
                showOtherMonths: false,
                showWeeks: false,
                calculateWeek: this.iso8601Week,
                shortYearCutoff: '+10',
                showStatus: false,
                statusForDate: this.dateStatus,
                minDate: null,
                maxDate: null,
                duration: 'normal',
                beforeShowDay: null,
                beforeShow: null,
                onSelect: null,
                onChangeMonthYear: null,
                onClose: null,
                numberOfMonths: 1,
                stepMonths: 1,
                rangeSelect: false,
                rangeSeparator: ' - ',
                altField: '',
                altFormat: ''
            };
            $.extend(this._defaults, this.regional['']);
            this.dpDiv = $('<div id="' + this._mainDivId + '" style="display: none;"></div>');
        }
        $.extend(Datepicker.prototype, {
            markerClassName: 'hasDatepicker',
            log: function() {
                if (this.debug) console.log.apply('', arguments);
            },
            setDefaults: function(settings) {
                extendRemove(this._defaults, settings || {});
                return this;
            },
            _attachDatepicker: function(target, settings) {
                var inlineSettings = null;
                for (attrName in this._defaults) {
                    var attrValue = target.getAttribute('date:' + attrName);
                    if (attrValue) {
                        inlineSettings = inlineSettings || {};
                        try {
                            inlineSettings[attrName] = eval(attrValue);
                        } catch (err) {
                            inlineSettings[attrName] = attrValue;
                        }
                    }
                }
                var nodeName = target.nodeName.toLowerCase();
                var inline = (nodeName == 'div' || nodeName == 'span');
                if (!target.id) target.id = 'dp' + new Date().getTime();
                var inst = this._newInst($(target), inline);
                inst.settings = $.extend({},
            settings || {},
            inlineSettings || {});
                if (nodeName == 'input') {
                    this._connectDatepicker(target, inst);
                } else if (inline) {
                    this._inlineDatepicker(target, inst);
                }
            },
            _newInst: function(target, inline) {
                return {
                    id: target[0].id,
                    input: target,
                    selectedDay: 0,
                    selectedMonth: 0,
                    selectedYear: 0,
                    drawMonth: 0,
                    drawYear: 0,
                    inline: inline,
                    dpDiv: (!inline ? this.dpDiv : $('<div class="ui-datepicker-inline"></div>'))
                };
            },
            _connectDatepicker: function(target, inst) {
                var input = $(target);
                if (input.hasClass(this.markerClassName)) return;
                var appendText = this._get(inst, 'appendText');
                var isRTL = this._get(inst, 'isRTL');
                if (appendText) input[isRTL ? 'before' : 'after']('<span class="' + this._appendClass + '">' + appendText + '</span>');
                var showOn = this._get(inst, 'showOn');
                if (showOn == 'focus' || showOn == 'both') input.focus(this._showDatepicker);
                if (showOn == 'button' || showOn == 'both') {
                    var buttonText = this._get(inst, 'buttonText');
                    var buttonImage = this._get(inst, 'buttonImage');
                    var trigger = $(this._get(inst, 'buttonImageOnly') ? $('<img/>').addClass(this._triggerClass).attr({
                        src: buttonImage,
                        alt: buttonText,
                        title: buttonText
                    }) : $('<button type="button"></button>').addClass(this._triggerClass).html(buttonImage == '' ? buttonText : $('<img/>').attr({
                        src: buttonImage,
                        alt: buttonText,
                        title: buttonText
                    })));
                    input[isRTL ? 'before' : 'after'](trigger);
                    trigger.click(function() {
                        if ($.datepicker._datepickerShowing && $.datepicker._lastInput == target) $.datepicker._hideDatepicker();
                        else $.datepicker._showDatepicker(target);
                        return false;
                    });
                }
                input.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).bind("setData.datepicker",
            function(event, key, value) {
                inst.settings[key] = value;
            }).bind("getData.datepicker",
            function(event, key) {
                return this._get(inst, key);
            });
                $.data(target, PROP_NAME, inst);
            },
            _inlineDatepicker: function(target, inst) {
                var input = $(target);
                if (input.hasClass(this.markerClassName)) return;
                input.addClass(this.markerClassName).append(inst.dpDiv).bind("setData.datepicker",
            function(event, key, value) {
                inst.settings[key] = value;
            }).bind("getData.datepicker",
            function(event, key) {
                return this._get(inst, key);
            });
                $.data(target, PROP_NAME, inst);
                this._setDate(inst, this._getDefaultDate(inst));
                this._updateDatepicker(inst);
            },
            _dialogDatepicker: function(input, dateText, onSelect, settings, pos) {
                var inst = this._dialogInst;
                if (!inst) {
                    var id = 'dp' + new Date().getTime();
                    this._dialogInput = $('<input type="text" id="' + id + '" size="1" style="position: absolute; top: -100px;"/>');
                    this._dialogInput.keydown(this._doKeyDown);
                    $('body').append(this._dialogInput);
                    inst = this._dialogInst = this._newInst(this._dialogInput, false);
                    inst.settings = {};
                    $.data(this._dialogInput[0], PROP_NAME, inst);
                }
                extendRemove(inst.settings, settings || {});
                this._dialogInput.val(dateText);
                this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
                if (!this._pos) {
                    var browserWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
                    var browserHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
                    var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
                    var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
                    this._pos = [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
                }
                this._dialogInput.css('left', this._pos[0] + 'px').css('top', this._pos[1] + 'px');
                inst.settings.onSelect = onSelect;
                this._inDialog = true;
                this.dpDiv.addClass(this._dialogClass);
                this._showDatepicker(this._dialogInput[0]);
                if ($.blockUI) $.blockUI(this.dpDiv);
                $.data(this._dialogInput[0], PROP_NAME, inst);
                return this;
            },
            _destroyDatepicker: function(target) {
                var nodeName = target.nodeName.toLowerCase();
                var $target = $(target);
                $.removeData(target, PROP_NAME);
                if (nodeName == 'input') {
                    $target.siblings('.' + this._appendClass).remove().end().siblings('.' + this._triggerClass).remove().end().removeClass(this.markerClassName).unbind('focus', this._showDatepicker).unbind('keydown', this._doKeyDown).unbind('keypress', this._doKeyPress);
                } else if (nodeName == 'div' || nodeName == 'span') $target.removeClass(this.markerClassName).empty();
            },
            _enableDatepicker: function(target) {
                target.disabled = false;
                $(target).siblings('button.' + this._triggerClass).each(function() {
                    this.disabled = false;
                }).end().siblings('img.' + this._triggerClass).css({
                    opacity: '1.0',
                    cursor: ''
                });
                this._disabledInputs = $.map(this._disabledInputs,
            function(value) {
                return (value == target ? null : value);
            });
            },
            _disableDatepicker: function(target) {
                target.disabled = true;
                $(target).siblings('button.' + this._triggerClass).each(function() {
                    this.disabled = true;
                }).end().siblings('img.' + this._triggerClass).css({
                    opacity: '0.5',
                    cursor: 'default'
                });
                this._disabledInputs = $.map(this._disabledInputs,
            function(value) {
                return (value == target ? null : value);
            });
                this._disabledInputs[this._disabledInputs.length] = target;
            },
            _isDisabledDatepicker: function(target) {
                if (!target) return false;
                for (var i = 0; i < this._disabledInputs.length; i++) {
                    if (this._disabledInputs[i] == target) return true;
                }
                return false;
            },
            _changeDatepicker: function(target, name, value) {
                var settings = name || {};
                if (typeof name == 'string') {
                    settings = {};
                    settings[name] = value;
                }
                if (inst = $.data(target, PROP_NAME)) {
                    extendRemove(inst.settings, settings);
                    this._updateDatepicker(inst);
                }
            },
            _setDateDatepicker: function(target, date, endDate) {
                var inst = $.data(target, PROP_NAME);
                if (inst) {
                    this._setDate(inst, date, endDate);
                    this._updateDatepicker(inst);
                }
            },
            _getDateDatepicker: function(target) {
                var inst = $.data(target, PROP_NAME);
                if (inst) this._setDateFromField(inst);
                return (inst ? this._getDate(inst) : null);
            },
            _doKeyDown: function(e) {
                var inst = $.data(e.target, PROP_NAME);
                var handled = true;
                if ($.datepicker._datepickerShowing) switch (e.keyCode) {
                    case 9:
                        $.datepicker._hideDatepicker(null, '');
                        break;
                    case 13:
                        $.datepicker._selectDay(e.target, inst.selectedMonth, inst.selectedYear, $('td.ui-datepicker-days-cell-over', inst.dpDiv)[0]);
                        return false;
                        break;
                    case 27:
                        $.datepicker._hideDatepicker(null, $.datepicker._get(inst, 'duration'));
                        break;
                    case 33:
                        $.datepicker._adjustDate(e.target, (e.ctrlKey ? -1 : -$.datepicker._get(inst, 'stepMonths')), (e.ctrlKey ? 'Y' : 'M'));
                        break;
                    case 34:
                        $.datepicker._adjustDate(e.target, (e.ctrlKey ? +1 : +$.datepicker._get(inst, 'stepMonths')), (e.ctrlKey ? 'Y' : 'M'));
                        break;
                    case 35:
                        if (e.ctrlKey) $.datepicker._clearDate(e.target);
                        break;
                    case 36:
                        if (e.ctrlKey) $.datepicker._gotoToday(e.target);
                        break;
                    case 37:
                        if (e.ctrlKey) $.datepicker._adjustDate(e.target, -1, 'D');
                        break;
                    case 38:
                        if (e.ctrlKey) $.datepicker._adjustDate(e.target, -7, 'D');
                        break;
                    case 39:
                        if (e.ctrlKey) $.datepicker._adjustDate(e.target, +1, 'D');
                        break;
                    case 40:
                        if (e.ctrlKey) $.datepicker._adjustDate(e.target, +7, 'D');
                        break;
                    default:
                        handled = false;
                }
                else if (e.keyCode == 36 && e.ctrlKey) $.datepicker._showDatepicker(this);
                else handled = false;
                if (handled) {
                    e.preventDefault();
                    e.stopPropagation();
                }
            },
            _doKeyPress: function(e) {
                var inst = $.data(e.target, PROP_NAME);
                var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat'));
                var chr = String.fromCharCode(e.charCode == undefined ? e.keyCode : e.charCode);
                return e.ctrlKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1);
            },
            _showDatepicker: function(input) {
                input = input.target || input;
                if (input.nodeName.toLowerCase() != 'input') input = $('input', input.parentNode)[0];
                if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput == input) return;
                var inst = $.data(input, PROP_NAME);
                var beforeShow = $.datepicker._get(inst, 'beforeShow');
                extendRemove(inst.settings, (beforeShow ? beforeShow.apply(input, [input, inst]) : {}));
                $.datepicker._hideDatepicker(null, '');
                $.datepicker._lastInput = input;
                $.datepicker._setDateFromField(inst);
                if ($.datepicker._inDialog) input.value = '';
                if (!$.datepicker._pos) {
                    $.datepicker._pos = $.datepicker._findPos(input);
                    $.datepicker._pos[1] += input.offsetHeight;
                }
                var isFixed = false;
                $(input).parents().each(function() {
                    isFixed |= $(this).css('position') == 'fixed';
                    return !isFixed;
                });
                if (isFixed && $.browser.opera) {
                    $.datepicker._pos[0] -= document.documentElement.scrollLeft;
                    $.datepicker._pos[1] -= document.documentElement.scrollTop;
                }
                var offset = {
                    left: $.datepicker._pos[0],
                    top: $.datepicker._pos[1]
                };
                $.datepicker._pos = null;
                inst.rangeStart = null;
                inst.dpDiv.css({
                    position: 'absolute',
                    display: 'block',
                    top: '-1000px'
                });
                $.datepicker._updateDatepicker(inst);
                inst.dpDiv.width($.datepicker._getNumberOfMonths(inst)[1] * $('.ui-datepicker', inst.dpDiv[0])[0].offsetWidth);
                offset = $.datepicker._checkOffset(inst, offset, isFixed);
                inst.dpDiv.css({
                    position: ($.datepicker._inDialog && $.blockUI ? 'static' : (isFixed ? 'fixed' : 'absolute')),
                    display: 'none',
                    left: offset.left + 'px',
                    top: offset.top + 'px'
                });
                if (!inst.inline) {
                    var showAnim = $.datepicker._get(inst, 'showAnim') || 'show';
                    var duration = $.datepicker._get(inst, 'duration');
                    var postProcess = function() {
                        $.datepicker._datepickerShowing = true;
                        if ($.browser.msie && parseInt($.browser.version) < 7) $('iframe.ui-datepicker-cover').css({
                            width: inst.dpDiv.width() + 4,
                            height: inst.dpDiv.height() + 4
                        });
                    };
                    if ($.effects && $.effects[showAnim]) inst.dpDiv.show(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
                    else inst.dpDiv[showAnim](duration, postProcess);
                    if (duration == '') postProcess();
                    if (inst.input[0].type != 'hidden') inst.input[0].focus();
                    $.datepicker._curInst = inst;
                }
            },
            _updateDatepicker: function(inst) {
                var dims = {
                    width: inst.dpDiv.width() + 4,
                    height: inst.dpDiv.height() + 4
                };
                inst.dpDiv.empty().append(this._generateDatepicker(inst)).find('iframe.ui-datepicker-cover').css({
                    width: dims.width,
                    height: dims.height
                });
                var numMonths = this._getNumberOfMonths(inst);
                inst.dpDiv[(numMonths[0] != 1 || numMonths[1] != 1 ? 'add' : 'remove') + 'Class']('ui-datepicker-multi');
                inst.dpDiv[(this._get(inst, 'isRTL') ? 'add' : 'remove') + 'Class']('ui-datepicker-rtl');
                if (inst.input && inst.input[0].type != 'hidden') $(inst.input[0]).focus();
            },
            _checkOffset: function(inst, offset, isFixed) {
                var pos = inst.input ? this._findPos(inst.input[0]) : null;
                var browserWidth = window.innerWidth || document.documentElement.clientWidth;
                var browserHeight = window.innerHeight || document.documentElement.clientHeight;
                var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
                var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
                if (this._get(inst, 'isRTL') || (offset.left + inst.dpDiv.width() - scrollX) > browserWidth) offset.left = Math.max((isFixed ? 0 : scrollX), pos[0] + (inst.input ? inst.input.width() : 0) - (isFixed ? scrollX : 0) - inst.dpDiv.width() - (isFixed && $.browser.opera ? document.documentElement.scrollLeft : 0));
                else offset.left -= (isFixed ? scrollX : 0);
                if ((offset.top + inst.dpDiv.height() - scrollY) > browserHeight) offset.top = Math.max((isFixed ? 0 : scrollY), pos[1] - (isFixed ? scrollY : 0) - (this._inDialog ? 0 : inst.dpDiv.height()) - (isFixed && $.browser.opera ? document.documentElement.scrollTop : 0));
                else offset.top -= (isFixed ? scrollY : 0);
                return offset;
            },
            _findPos: function(obj) {
                while (obj && (obj.type == 'hidden' || obj.nodeType != 1)) {
                    obj = obj.nextSibling;
                }
                var position = $(obj).offset();
                return [position.left, position.top];
            },
            _hideDatepicker: function(input, duration) {
                var inst = this._curInst;
                if (!inst) return;
                var rangeSelect = this._get(inst, 'rangeSelect');
                if (rangeSelect && this._stayOpen) this._selectDate('#' + inst.id, this._formatDate(inst, inst.currentDay, inst.currentMonth, inst.currentYear));
                this._stayOpen = false;
                if (this._datepickerShowing) {
                    duration = (duration != null ? duration : this._get(inst, 'duration'));
                    var showAnim = this._get(inst, 'showAnim');
                    var postProcess = function() {
                        $.datepicker._tidyDialog(inst);
                    };
                    if (duration != '' && $.effects && $.effects[showAnim]) inst.dpDiv.hide(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
                    else inst.dpDiv[(duration == '' ? 'hide' : (showAnim == 'slideDown' ? 'slideUp' : (showAnim == 'fadeIn' ? 'fadeOut' : 'hide')))](duration, postProcess);
                    if (duration == '') this._tidyDialog(inst);
                    var onClose = this._get(inst, 'onClose');
                    if (onClose) onClose.apply((inst.input ? inst.input[0] : null), [this._getDate(inst), inst]);
                    this._datepickerShowing = false;
                    this._lastInput = null;
                    inst.settings.prompt = null;
                    if (this._inDialog) {
                        this._dialogInput.css({
                            position: 'absolute',
                            left: '0',
                            top: '-100px'
                        });
                        if ($.blockUI) {
                            $.unblockUI();
                            $('body').append(this.dpDiv);
                        }
                    }
                    this._inDialog = false;
                }
                this._curInst = null;
            },
            _tidyDialog: function(inst) {
                inst.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker');
                $('.' + this._promptClass, inst.dpDiv).remove();
            },
            _checkExternalClick: function(event) {
                if (!$.datepicker._curInst) return;
                var $target = $(event.target);
                if (($target.parents('#' + $.datepicker._mainDivId).length == 0) && !$target.hasClass($.datepicker.markerClassName) && !$target.hasClass($.datepicker._triggerClass) && $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI)) $.datepicker._hideDatepicker(null, '');
            },
            _adjustDate: function(id, offset, period) {
                var target = $(id);
                var inst = $.data(target[0], PROP_NAME);
                this._adjustInstDate(inst, offset, period);
                this._updateDatepicker(inst);
            },
            _gotoToday: function(id) {
                var target = $(id);
                var inst = $.data(target[0], PROP_NAME);
                if (this._get(inst, 'gotoCurrent') && inst.currentDay) {
                    inst.selectedDay = inst.currentDay;
                    inst.drawMonth = inst.selectedMonth = inst.currentMonth;
                    inst.drawYear = inst.selectedYear = inst.currentYear;
                }
                else {
                    var date = new Date();
                    inst.selectedDay = date.getDate();
                    inst.drawMonth = inst.selectedMonth = date.getMonth();
                    inst.drawYear = inst.selectedYear = date.getFullYear();
                }
                this._adjustDate(target);
                this._notifyChange(inst);
            },
            _selectMonthYear: function(id, select, period) {
                var target = $(id);
                var inst = $.data(target[0], PROP_NAME);
                inst._selectingMonthYear = false;
                inst[period == 'M' ? 'drawMonth' : 'drawYear'] = select.options[select.selectedIndex].value - 0;
                this._adjustDate(target);
                this._notifyChange(inst);
            },
            _clickMonthYear: function(id) {
                var target = $(id);
                var inst = $.data(target[0], PROP_NAME);
                if (inst.input && inst._selectingMonthYear && !$.browser.msie) inst.input[0].focus();
                inst._selectingMonthYear = !inst._selectingMonthYear;
            },
            _changeFirstDay: function(id, day) {
                var target = $(id);
                var inst = $.data(target[0], PROP_NAME);
                inst.settings.firstDay = day;
                this._updateDatepicker(inst);
            },
            _selectDay: function(id, month, year, td) {
                if ($(td).hasClass(this._unselectableClass)) return;
                var target = $(id);
                var inst = $.data(target[0], PROP_NAME);
                var rangeSelect = this._get(inst, 'rangeSelect');
                if (rangeSelect) {
                    this._stayOpen = !this._stayOpen;
                    if (this._stayOpen) {
                        $('.ui-datepicker td').removeClass(this._currentClass);
                        $(td).addClass(this._currentClass);
                    }
                }
                inst.selectedDay = inst.currentDay = $('a', td).html();
                inst.selectedMonth = inst.currentMonth = month;
                inst.selectedYear = inst.currentYear = year;
                if (this._stayOpen) {
                    inst.endDay = inst.endMonth = inst.endYear = null;
                }
                else if (rangeSelect) {
                    inst.endDay = inst.currentDay;
                    inst.endMonth = inst.currentMonth;
                    inst.endYear = inst.currentYear;
                }
                this._selectDate(id, this._formatDate(inst, inst.currentDay, inst.currentMonth, inst.currentYear));
                if (this._stayOpen) {
                    inst.rangeStart = this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay));
                    this._updateDatepicker(inst);
                }
                else if (rangeSelect) {
                    inst.selectedDay = inst.currentDay = inst.rangeStart.getDate();
                    inst.selectedMonth = inst.currentMonth = inst.rangeStart.getMonth();
                    inst.selectedYear = inst.currentYear = inst.rangeStart.getFullYear();
                    inst.rangeStart = null;
                    if (inst.inline) this._updateDatepicker(inst);
                }
            },
            _clearDate: function(id) {
                var target = $(id);
                var inst = $.data(target[0], PROP_NAME);
                if (this._get(inst, 'mandatory')) return;
                this._stayOpen = false;
                inst.endDay = inst.endMonth = inst.endYear = inst.rangeStart = null;
                this._selectDate(target, '');
            },
            _selectDate: function(id, dateStr) {
                var target = $(id);
                var inst = $.data(target[0], PROP_NAME);
                dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
                if (this._get(inst, 'rangeSelect') && dateStr) dateStr = (inst.rangeStart ? this._formatDate(inst, inst.rangeStart) : dateStr) + this._get(inst, 'rangeSeparator') + dateStr;
                if (inst.input) inst.input.val(dateStr);
                this._updateAlternate(inst);
                var onSelect = this._get(inst, 'onSelect');
                if (onSelect) onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
                else if (inst.input) inst.input.trigger('change');
                if (inst.inline) this._updateDatepicker(inst);
                else if (!this._stayOpen) {
                    this._hideDatepicker(null, this._get(inst, 'duration'));
                    this._lastInput = inst.input[0];
                    if (typeof (inst.input[0]) != 'object') inst.input[0].focus();
                    this._lastInput = null;
                }
            },
            _updateAlternate: function(inst) {
                var altField = this._get(inst, 'altField');
                if (altField) {
                    var altFormat = this._get(inst, 'altFormat');
                    var date = this._getDate(inst);
                    dateStr = (isArray(date) ? (!date[0] && !date[1] ? '' : this.formatDate(altFormat, date[0], this._getFormatConfig(inst)) + this._get(inst, 'rangeSeparator') + this.formatDate(altFormat, date[1] || date[0], this._getFormatConfig(inst))) : this.formatDate(altFormat, date, this._getFormatConfig(inst)));
                    $(altField).each(function() {
                        $(this).val(dateStr);
                    });
                }
            },
            noWeekends: function(date) {
                var day = date.getDay();
                return [(day > 0 && day < 6), ''];
            },
            iso8601Week: function(date) {
                var checkDate = new Date(date.getFullYear(), date.getMonth(), date.getDate());
                var firstMon = new Date(checkDate.getFullYear(), 1 - 1, 4);
                var firstDay = firstMon.getDay() || 7;
                firstMon.setDate(firstMon.getDate() + 1 - firstDay);
                if (firstDay < 4 && checkDate < firstMon) {
                    checkDate.setDate(checkDate.getDate() - 3);
                    return $.datepicker.iso8601Week(checkDate);
                } else if (checkDate > new Date(checkDate.getFullYear(), 12 - 1, 28)) {
                    firstDay = new Date(checkDate.getFullYear() + 1, 1 - 1, 4).getDay() || 7;
                    if (firstDay > 4 && (checkDate.getDay() || 7) < firstDay - 3) {
                        checkDate.setDate(checkDate.getDate() + 3);
                        return $.datepicker.iso8601Week(checkDate);
                    }
                }
                return Math.floor(((checkDate - firstMon) / 86400000) / 7) + 1;
            },
            dateStatus: function(date, inst) {
                return $.datepicker.formatDate($.datepicker._get(inst, 'dateStatus'), date, $.datepicker._getFormatConfig(inst));
            },
            parseDate: function(format, value, settings) {
                if (format == null || value == null) throw 'Invalid arguments';
                value = (typeof value == 'object' ? value.toString() : value + '');
                if (value == '') return null;
                var shortYearCutoff = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff;
                var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
                var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
                var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
                var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
                var year = -1;
                var month = -1;
                var day = -1;
                var literal = false;
                var lookAhead = function(match) {
                    var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
                    if (matches) iFormat++;
                    return matches;
                };
                var getNumber = function(match) {
                    lookAhead(match);
                    var origSize = (match == '@' ? 14 : (match == 'y' ? 4 : 2));
                    var size = origSize;
                    var num = 0;
                    while (size > 0 && iValue < value.length && value.charAt(iValue) >= '0' && value.charAt(iValue) <= '9') {
                        num = num * 10 + (value.charAt(iValue++) - 0);
                        size--;
                    }
                    if (size == origSize) throw 'Missing number at position ' + iValue;
                    return num;
                };
                var getName = function(match, shortNames, longNames) {
                    var names = (lookAhead(match) ? longNames : shortNames);
                    var size = 0;
                    for (var j = 0; j < names.length; j++)
                        size = Math.max(size, names[j].length);
                    var name = '';
                    var iInit = iValue;
                    while (size > 0 && iValue < value.length) {
                        name += value.charAt(iValue++);
                        for (var i = 0; i < names.length; i++)
                            if (name == names[i]) return i + 1;
                        size--;
                    }
                    throw 'Unknown name at position ' + iInit;
                };
                var checkLiteral = function() {
                    if (value.charAt(iValue) != format.charAt(iFormat)) throw 'Unexpected literal at position ' + iValue;
                    iValue++;
                };
                var iValue = 0;
                for (var iFormat = 0; iFormat < format.length; iFormat++) {
                    if (literal) if (format.charAt(iFormat) == "'" && !lookAhead("'")) literal = false;
                    else checkLiteral();
                    else switch (format.charAt(iFormat)) {
                        case 'd':
                            day = getNumber('d');
                            break;
                        case 'D':
                            getName('D', dayNamesShort, dayNames);
                            break;
                        case 'm':
                            month = getNumber('m');
                            break;
                        case 'M':
                            month = getName('M', monthNamesShort, monthNames);
                            break;
                        case 'y':
                            year = getNumber('y');
                            break;
                        case '@':
                            var date = new Date(getNumber('@'));
                            year = date.getFullYear();
                            month = date.getMonth() + 1;
                            day = date.getDate();
                            break;
                        case "'":
                            if (lookAhead("'")) checkLiteral();
                            else literal = true;
                            break;
                        default:
                            checkLiteral();
                    }
                }
                if (year < 100) year += new Date().getFullYear() - new Date().getFullYear() % 100 + (year <= shortYearCutoff ? 0 : -100);
                var date = this._daylightSavingAdjust(new Date(year, month - 1, day));
                if (date.getFullYear() != year || date.getMonth() + 1 != month || date.getDate() != day) throw 'Invalid date';
                return date;
            },
            ATOM: 'yy-mm-dd',
            COOKIE: 'D, dd M yy',
            ISO_8601: 'yy-mm-dd',
            RFC_822: 'D, d M y',
            RFC_850: 'DD, dd-M-y',
            RFC_1036: 'D, d M y',
            RFC_1123: 'D, d M yy',
            RFC_2822: 'D, d M yy',
            RSS: 'D, d M y',
            TIMESTAMP: '@',
            W3C: 'yy-mm-dd',
            formatDate: function(format, date, settings) {
                if (!date) return '';
                var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
                var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
                var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
                var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
                var lookAhead = function(match) {
                    var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
                    if (matches) iFormat++;
                    return matches;
                };
                var formatNumber = function(match, value) {
                    return (lookAhead(match) && value < 10 ? '0' : '') + value;
                };
                var formatName = function(match, value, shortNames, longNames) {
                    return (lookAhead(match) ? longNames[value] : shortNames[value]);
                };
                var output = '';
                var literal = false;
                if (date) for (var iFormat = 0; iFormat < format.length; iFormat++) {
                    if (literal) if (format.charAt(iFormat) == "'" && !lookAhead("'")) literal = false;
                    else output += format.charAt(iFormat);
                    else switch (format.charAt(iFormat)) {
                        case 'd':
                            output += formatNumber('d', date.getDate());
                            break;
                        case 'D':
                            output += formatName('D', date.getDay(), dayNamesShort, dayNames);
                            break;
                        case 'm':
                            output += formatNumber('m', date.getMonth() + 1);
                            break;
                        case 'M':
                            output += formatName('M', date.getMonth(), monthNamesShort, monthNames);
                            break;
                        case 'y':
                            output += (lookAhead('y') ? date.getFullYear() : (date.getYear() % 100 < 10 ? '0' : '') + date.getYear() % 100);
                            break;
                        case '@':
                            output += date.getTime();
                            break;
                        case "'":
                            if (lookAhead("'")) output += "'";
                            else literal = true;
                            break;
                        default:
                            output += format.charAt(iFormat);
                    }
                }
                return output;
            },
            _possibleChars: function(format) {
                var chars = '';
                var literal = false;
                for (var iFormat = 0; iFormat < format.length; iFormat++)
                    if (literal) if (format.charAt(iFormat) == "'" && !lookAhead("'")) literal = false;
                else chars += format.charAt(iFormat);
                else switch (format.charAt(iFormat)) {
                    case 'd':
                    case 'm':
                    case 'y':
                    case '@':
                        chars += '0123456789';
                        break;
                    case 'D':
                    case 'M':
                        return null;
                    case "'":
                        if (lookAhead("'")) chars += "'";
                        else literal = true;
                        break;
                    default:
                        chars += format.charAt(iFormat);
                }
                return chars;
            },
            _get: function(inst, name) {
                return inst.settings[name] !== undefined ? inst.settings[name] : this._defaults[name];
            },
            _setDateFromField: function(inst) {
                var dateFormat = this._get(inst, 'dateFormat');
                var dates = inst.input ? inst.input.val().split(this._get(inst, 'rangeSeparator')) : null;
                inst.endDay = inst.endMonth = inst.endYear = null;
                var date = defaultDate = this._getDefaultDate(inst);
                if (dates.length > 0) {
                    var settings = this._getFormatConfig(inst);
                    if (dates.length > 1) {
                        date = this.parseDate(dateFormat, dates[1], settings) || defaultDate;
                        inst.endDay = date.getDate();
                        inst.endMonth = date.getMonth();
                        inst.endYear = date.getFullYear();
                    }
                    try {
                        date = this.parseDate(dateFormat, dates[0], settings) || defaultDate;
                    } catch (e) {
                        this.log(e);
                        date = defaultDate;
                    }
                }
                inst.selectedDay = date.getDate();
                inst.drawMonth = inst.selectedMonth = date.getMonth();
                inst.drawYear = inst.selectedYear = date.getFullYear();
                inst.currentDay = (dates[0] ? date.getDate() : 0);
                inst.currentMonth = (dates[0] ? date.getMonth() : 0);
                inst.currentYear = (dates[0] ? date.getFullYear() : 0);
                this._adjustInstDate(inst);
            },
            _getDefaultDate: function(inst) {
                var date = this._determineDate(this._get(inst, 'defaultDate'), new Date());
                var minDate = this._getMinMaxDate(inst, 'min', true);
                var maxDate = this._getMinMaxDate(inst, 'max');
                date = (minDate && date < minDate ? minDate : date);
                date = (maxDate && date > maxDate ? maxDate : date);
                return date;
            },
            _determineDate: function(date, defaultDate) {
                var offsetNumeric = function(offset) {
                    var date = new Date();
                    date.setDate(date.getDate() + offset);
                    return date;
                };
                var offsetString = function(offset, getDaysInMonth) {
                    var date = new Date();
                    var year = date.getFullYear();
                    var month = date.getMonth();
                    var day = date.getDate();
                    var pattern = /([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g;
                    var matches = pattern.exec(offset);
                    while (matches) {
                        switch (matches[2] || 'd') {
                            case 'd':
                            case 'D':
                                day += (matches[1] - 0);
                                break;
                            case 'w':
                            case 'W':
                                day += (matches[1] * 7);
                                break;
                            case 'm':
                            case 'M':
                                month += (matches[1] - 0);
                                day = Math.min(day, getDaysInMonth(year, month));
                                break;
                            case 'y':
                            case 'Y':
                                year += (matches[1] - 0);
                                day = Math.min(day, getDaysInMonth(year, month));
                                break;
                        }
                        matches = pattern.exec(offset);
                    }
                    return new Date(year, month, day);
                };
                date = (date == null ? defaultDate : (typeof date == 'string' ? offsetString(date, this._getDaysInMonth) : (typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : date)));
                date = (date && date.toString() == 'Invalid Date' ? defaultDate : date);
                if (date) {
                    date.setHours(0);
                    date.setMinutes(0);
                    date.setSeconds(0);
                    date.setMilliseconds(0);
                }
                return this._daylightSavingAdjust(date);
            },
            _daylightSavingAdjust: function(date) {
                if (!date) return null;
                date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
                return date;
            },
            _setDate: function(inst, date, endDate) {
                var clear = !(date);
                date = this._determineDate(date, new Date());
                inst.selectedDay = inst.currentDay = date.getDate();
                inst.drawMonth = inst.selectedMonth = inst.currentMonth = date.getMonth();
                inst.drawYear = inst.selectedYear = inst.currentYear = date.getFullYear();
                if (this._get(inst, 'rangeSelect')) {
                    if (endDate) {
                        endDate = this._determineDate(endDate, null);
                        inst.endDay = endDate.getDate();
                        inst.endMonth = endDate.getMonth();
                        inst.endYear = endDate.getFullYear();
                    } else {
                        inst.endDay = inst.currentDay;
                        inst.endMonth = inst.currentMonth;
                        inst.endYear = inst.currentYear;
                    }
                }
                this._adjustInstDate(inst);
                if (inst.input) inst.input.val(clear ? '' : this._formatDate(inst) + (!this._get(inst, 'rangeSelect') ? '' : this._get(inst, 'rangeSeparator') + this._formatDate(inst, inst.endDay, inst.endMonth, inst.endYear)));
            },
            _getDate: function(inst) {
                var startDate = (!inst.currentYear || (inst.input && inst.input.val() == '') ? null : this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
                if (this._get(inst, 'rangeSelect')) {
                    return [inst.rangeStart || startDate, (!inst.endYear ? inst.rangeStart || startDate : this._daylightSavingAdjust(new Date(inst.endYear, inst.endMonth, inst.endDay)))];
                } else return startDate;
            },
            _generateDatepicker: function(inst) {
                var today = new Date();
                today = this._daylightSavingAdjust(new Date(today.getFullYear(), today.getMonth(), today.getDate()));
                var showStatus = this._get(inst, 'showStatus');
                var isRTL = this._get(inst, 'isRTL');
                var clear = (this._get(inst, 'mandatory') ? '' : '<div class="ui-datepicker-clear"><a onclick="jQuery.datepicker._clearDate(\'#' + inst.id + '\');"' + (showStatus ? this._addStatus(inst, this._get(inst, 'clearStatus') || ' ') : '') + '>' + this._get(inst, 'clearText') + '</a></div>');
                var controls = '<div class="ui-datepicker-control">' + (isRTL ? '' : clear) + '<div class="ui-datepicker-close"><a onclick="jQuery.datepicker._hideDatepicker();"' + (showStatus ? this._addStatus(inst, this._get(inst, 'closeStatus') || ' ') : '') + '>' + this._get(inst, 'closeText') + '</a></div>' + (isRTL ? clear : '') + '</div>';
                var prompt = this._get(inst, 'prompt');
                var closeAtTop = this._get(inst, 'closeAtTop');
                var hideIfNoPrevNext = this._get(inst, 'hideIfNoPrevNext');
                var navigationAsDateFormat = this._get(inst, 'navigationAsDateFormat');
                var numMonths = this._getNumberOfMonths(inst);
                var stepMonths = this._get(inst, 'stepMonths');
                var isMultiMonth = (numMonths[0] != 1 || numMonths[1] != 1);
                var currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) : new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
                var minDate = this._getMinMaxDate(inst, 'min', true);
                var maxDate = this._getMinMaxDate(inst, 'max');
                var drawMonth = inst.drawMonth;
                var drawYear = inst.drawYear;
                if (maxDate) {
                    var maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(), maxDate.getMonth() - numMonths[1] + 1, maxDate.getDate()));
                    maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
                    while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
                        drawMonth--;
                        if (drawMonth < 0) {
                            drawMonth = 11;
                            drawYear--;
                        }
                    }
                }
                var prevText = this._get(inst, 'prevText');
                prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText, this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)), this._getFormatConfig(inst)));
                var prev = '<div class="ui-datepicker-prev">' + (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ? '<a onclick="jQuery.datepicker._adjustDate(\'#' + inst.id + '\', -' + stepMonths + ', \'M\');"' + (showStatus ? this._addStatus(inst, this._get(inst, 'prevStatus') || ' ') : '') + '>' + prevText + '</a>' : (hideIfNoPrevNext ? '' : '<label>' + prevText + '</label>')) + '</div>';
                var nextText = this._get(inst, 'nextText');
                nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText, this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)), this._getFormatConfig(inst)));
                var next = '<div class="ui-datepicker-next">' + (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ? '<a onclick="jQuery.datepicker._adjustDate(\'#' + inst.id + '\', +' + stepMonths + ', \'M\');"' + (showStatus ? this._addStatus(inst, this._get(inst, 'nextStatus') || ' ') : '') + '>' + nextText + '</a>' : (hideIfNoPrevNext ? '' : '<label>' + nextText + '</label>')) + '</div>';
                var currentText = this._get(inst, 'currentText');
                currentText = (!navigationAsDateFormat ? currentText : this.formatDate(currentText, today, this._getFormatConfig(inst)));
                var html = (prompt ? '<div class="' + this._promptClass + '">' + prompt + '</div>' : '') + (closeAtTop && !inst.inline ? controls : '') + '<div class="ui-datepicker-links">' + (isRTL ? next : prev) + (this._isInRange(inst, (this._get(inst, 'gotoCurrent') && inst.currentDay ? currentDate : today)) ? '<div class="ui-datepicker-current">' + '<a onclick="jQuery.datepicker._gotoToday(\'#' + inst.id + '\');"' + (showStatus ? this._addStatus(inst, this._get(inst, 'currentStatus') || ' ') : '') + '>' + currentText + '</a></div>' : '') + (isRTL ? prev : next) + '</div>';
                var firstDay = this._get(inst, 'firstDay');
                var changeFirstDay = this._get(inst, 'changeFirstDay');
                var dayNames = this._get(inst, 'dayNames');
                var dayNamesShort = this._get(inst, 'dayNamesShort');
                var dayNamesMin = this._get(inst, 'dayNamesMin');
                var monthNames = this._get(inst, 'monthNames');
                var beforeShowDay = this._get(inst, 'beforeShowDay');
                var highlightWeek = this._get(inst, 'highlightWeek');
                var showOtherMonths = this._get(inst, 'showOtherMonths');
                var showWeeks = this._get(inst, 'showWeeks');
                var calculateWeek = this._get(inst, 'calculateWeek') || this.iso8601Week;
                var status = (showStatus ? this._get(inst, 'dayStatus') || ' ' : '');
                var dateStatus = this._get(inst, 'statusForDate') || this.dateStatus;
                var endDate = inst.endDay ? this._daylightSavingAdjust(new Date(inst.endYear, inst.endMonth, inst.endDay)) : currentDate;
                for (var row = 0; row < numMonths[0]; row++)
                    for (var col = 0; col < numMonths[1]; col++) {
                    var selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
                    html += '<div class="ui-datepicker-one-month' + (col == 0 ? ' ui-datepicker-new-row' : '') + '">' + this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate, selectedDate, row > 0 || col > 0, showStatus, monthNames) + '<table class="ui-datepicker" cellpadding="0" cellspacing="0"><thead>' + '<tr class="ui-datepicker-title-row">' + (showWeeks ? '<td>' + this._get(inst, 'weekHeader') + '</td>' : '');
                    for (var dow = 0; dow < 7; dow++) {
                        var day = (dow + firstDay) % 7;
                        var dayStatus = (status.indexOf('DD') > -1 ? status.replace(/DD/, dayNames[day]) : status.replace(/D/, dayNamesShort[day]));
                        html += '<td' + ((dow + firstDay + 6) % 7 >= 5 ? ' class="ui-datepicker-week-end-cell"' : '') + '>' + (!changeFirstDay ? '<span' : '<a onclick="jQuery.datepicker._changeFirstDay(\'#' + inst.id + '\', ' + day + ');"') + (showStatus ? this._addStatus(inst, dayStatus) : '') + ' title="' + dayNames[day] + '">' + dayNamesMin[day] + (changeFirstDay ? '</a>' : '</span>') + '</td>';
                    }
                    html += '</tr></thead><tbody>';
                    var daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
                    if (drawYear == inst.selectedYear && drawMonth == inst.selectedMonth) inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
                    var leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
                    var numRows = (isMultiMonth ? 6 : Math.ceil((leadDays + daysInMonth) / 7));
                    var printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
                    for (var dRow = 0; dRow < numRows; dRow++) {
                        html += '<tr class="ui-datepicker-days-row">' + (showWeeks ? '<td class="ui-datepicker-week-col">' + calculateWeek(printDate) + '</td>' : '');
                        for (var dow = 0; dow < 7; dow++) {
                            var daySettings = (beforeShowDay ? beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, '']);
                            var otherMonth = (printDate.getMonth() != drawMonth);
                            var unselectable = otherMonth || !daySettings[0] || (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
                            html += '<td class="ui-datepicker-days-cell' + ((dow + firstDay + 6) % 7 >= 5 ? ' ui-datepicker-week-end-cell' : '') + (otherMonth ? ' ui-datepicker-otherMonth' : '') + (printDate.getTime() == selectedDate.getTime() && drawMonth == inst.selectedMonth ? ' ui-datepicker-days-cell-over' : '') + (unselectable ? ' ' + this._unselectableClass : '') + (otherMonth && !showOtherMonths ? '' : ' ' + daySettings[1] + (printDate.getTime() >= currentDate.getTime() && printDate.getTime() <= endDate.getTime() ? ' ' + this._currentClass : '') + (printDate.getTime() == today.getTime() ? ' ui-datepicker-today' : '')) + '"' + ((!otherMonth || showOtherMonths) && daySettings[2] ? ' title="' + daySettings[2] + '"' : '') + (unselectable ? (highlightWeek ? ' onmouseover="jQuery(this).parent().addClass(\'ui-datepicker-week-over\');"' + ' onmouseout="jQuery(this).parent().removeClass(\'ui-datepicker-week-over\');"' : '') : ' onmouseover="jQuery(this).addClass(\'ui-datepicker-days-cell-over\')' + (highlightWeek ? '.parent().addClass(\'ui-datepicker-week-over\')' : '') + ';' + (!showStatus || (otherMonth && !showOtherMonths) ? '' : 'jQuery(\'#ui-datepicker-status-' + inst.id + '\').html(\'' + (dateStatus.apply((inst.input ? inst.input[0] : null), [printDate, inst]) || ' ') + '\');') + '"' + ' onmouseout="jQuery(this).removeClass(\'ui-datepicker-days-cell-over\')' + (highlightWeek ? '.parent().removeClass(\'ui-datepicker-week-over\')' : '') + ';' + (!showStatus || (otherMonth && !showOtherMonths) ? '' : 'jQuery(\'#ui-datepicker-status-' + inst.id + '\').html(\' \');') + '" onclick="jQuery.datepicker._selectDay(\'#' + inst.id + '\',' + drawMonth + ',' + drawYear + ', this);"') + '>' + (otherMonth ? (showOtherMonths ? printDate.getDate() : ' ') : (unselectable ? printDate.getDate() : '<a>' + printDate.getDate() + '</a>')) + '</td>';
                            printDate.setDate(printDate.getDate() + 1);
                            printDate = this._daylightSavingAdjust(printDate);
                        }
                        html += '</tr>';
                    }
                    drawMonth++;
                    if (drawMonth > 11) {
                        drawMonth = 0;
                        drawYear++;
                    }
                    html += '</tbody></table></div>';
                }
                html += (showStatus ? '<div style="clear: both;"></div><div id="ui-datepicker-status-' + inst.id + '" class="ui-datepicker-status">' + (this._get(inst, 'initStatus') || ' ') + '</div>' : '') + (!closeAtTop && !inst.inline ? controls : '') + '<div style="clear: both;"></div>' + ($.browser.msie && parseInt($.browser.version) < 7 && !inst.inline ? '<iframe src="javascript:false;" class="ui-datepicker-cover"></iframe>' : '');
                return html;
            },
            _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate, selectedDate, secondary, showStatus, monthNames) {
                minDate = (inst.rangeStart && minDate && selectedDate < minDate ? selectedDate : minDate);
                var html = '<div class="ui-datepicker-header">';
                if (secondary || !this._get(inst, 'changeMonth')) html += monthNames[drawMonth] + ' ';
                else {
                    var inMinYear = (minDate && minDate.getFullYear() == drawYear);
                    var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear);
                    html += '<select class="ui-datepicker-new-month" ' + 'onchange="jQuery.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'M\');" ' + 'onclick="jQuery.datepicker._clickMonthYear(\'#' + inst.id + '\');"' + (showStatus ? this._addStatus(inst, this._get(inst, 'monthStatus') || ' ') : '') + '>';
                    for (var month = 0; month < 12; month++) {
                        if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) html += '<option value="' + month + '"' + (month == drawMonth ? ' selected="selected"' : '') + '>' + monthNames[month] + '</option>';
                    }
                    html += '</select>';
                }
                if (secondary || !this._get(inst, 'changeYear')) html += drawYear;
                else {
                    var years = this._get(inst, 'yearRange').split(':');
                    var year = 0;
                    var endYear = 0;
                    if (years.length != 2) {
                        year = drawYear - 10;
                        endYear = drawYear + 10;
                    } else if (years[0].charAt(0) == '+' || years[0].charAt(0) == '-') {
                        year = endYear = new Date().getFullYear();
                        year += parseInt(years[0], 10);
                        endYear += parseInt(years[1], 10);
                    } else {
                        year = parseInt(years[0], 10);
                        endYear = parseInt(years[1], 10);
                    }
                    year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
                    endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
                    html += '<select class="ui-datepicker-new-year" ' + 'onchange="jQuery.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'Y\');" ' + 'onclick="jQuery.datepicker._clickMonthYear(\'#' + inst.id + '\');"' + (showStatus ? this._addStatus(inst, this._get(inst, 'yearStatus') || ' ') : '') + '>';
                    for (; year <= endYear; year++) {
                        html += '<option value="' + year + '"' + (year == drawYear ? ' selected="selected"' : '') + '>' + year + '</option>';
                    }
                    html += '</select>';
                }
                html += '</div>';
                return html;
            },
            _addStatus: function(inst, text) {
                return ' onmouseover="jQuery(\'#ui-datepicker-status-' + inst.id + '\').html(\'' + text + '\');" ' + 'onmouseout="jQuery(\'#ui-datepicker-status-' + inst.id + '\').html(\' \');"';
            },
            _adjustInstDate: function(inst, offset, period) {
                var year = inst.drawYear + (period == 'Y' ? offset : 0);
                var month = inst.drawMonth + (period == 'M' ? offset : 0);
                var day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period == 'D' ? offset : 0);
                var date = this._daylightSavingAdjust(new Date(year, month, day));
                var minDate = this._getMinMaxDate(inst, 'min', true);
                var maxDate = this._getMinMaxDate(inst, 'max');
                date = (minDate && date < minDate ? minDate : date);
                date = (maxDate && date > maxDate ? maxDate : date);
                inst.selectedDay = date.getDate();
                inst.drawMonth = inst.selectedMonth = date.getMonth();
                inst.drawYear = inst.selectedYear = date.getFullYear();
                if (period == 'M' || period == 'Y') this._notifyChange(inst);
            },
            _notifyChange: function(inst) {
                var onChange = this._get(inst, 'onChangeMonthYear');
                if (onChange) onChange.apply((inst.input ? inst.input[0] : null), [new Date(inst.selectedYear, inst.selectedMonth, 1), inst]);
            },
            _getNumberOfMonths: function(inst) {
                var numMonths = this._get(inst, 'numberOfMonths');
                return (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths));
            },
            _getMinMaxDate: function(inst, minMax, checkRange) {
                var date = this._determineDate(this._get(inst, minMax + 'Date'), null);
                return (!checkRange || !inst.rangeStart ? date : (!date || inst.rangeStart > date ? inst.rangeStart : date));
            },
            _getDaysInMonth: function(year, month) {
                return 32 - new Date(year, month, 32).getDate();
            },
            _getFirstDayOfMonth: function(year, month) {
                return new Date(year, month, 1).getDay();
            },
            _canAdjustMonth: function(inst, offset, curYear, curMonth) {
                var numMonths = this._getNumberOfMonths(inst);
                var date = this._daylightSavingAdjust(new Date(curYear, curMonth + (offset < 0 ? offset : numMonths[1]), 1));
                if (offset < 0) date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
                return this._isInRange(inst, date);
            },
            _isInRange: function(inst, date) {
                var newMinDate = (!inst.rangeStart ? null : this._daylightSavingAdjust(new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay)));
                newMinDate = (newMinDate && inst.rangeStart < newMinDate ? inst.rangeStart : newMinDate);
                var minDate = newMinDate || this._getMinMaxDate(inst, 'min');
                var maxDate = this._getMinMaxDate(inst, 'max');
                return ((!minDate || date >= minDate) && (!maxDate || date <= maxDate));
            },
            _getFormatConfig: function(inst) {
                var shortYearCutoff = this._get(inst, 'shortYearCutoff');
                shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff : new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
                return {
                    shortYearCutoff: shortYearCutoff,
                    dayNamesShort: this._get(inst, 'dayNamesShort'),
                    dayNames: this._get(inst, 'dayNames'),
                    monthNamesShort: this._get(inst, 'monthNamesShort'),
                    monthNames: this._get(inst, 'monthNames')
                };
            },
            _formatDate: function(inst, day, month, year) {
                if (!day) {
                    inst.currentDay = inst.selectedDay;
                    inst.currentMonth = inst.selectedMonth;
                    inst.currentYear = inst.selectedYear;
                }
                var date = (day ? (typeof day == 'object' ? day : this._daylightSavingAdjust(new Date(year, month, day))) : this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
                return this.formatDate(this._get(inst, 'dateFormat'), date, this._getFormatConfig(inst));
            }
        });
        function extendRemove(target, props) {
            $.extend(target, props);
            for (var name in props)
                if (props[name] == null || props[name] == undefined) target[name] = props[name];
            return target;
        };
        function isArray(a) {
            return (a && (($.browser.safari && typeof a == 'object' && a.length) || (a.constructor && a.constructor.toString().match(/\Array\(\)/))));
        };
        $.fn.datepicker = function(options) {
            var otherArgs = Array.prototype.slice.call(arguments, 1);
            if (typeof options == 'string' && (options == 'isDisabled' || options == 'getDate')) return $.datepicker['_' + options + 'Datepicker'].apply($.datepicker, [this[0]].concat(otherArgs));
            return this.each(function() {
                typeof options == 'string' ? $.datepicker['_' + options + 'Datepicker'].apply($.datepicker, [this].concat(otherArgs)) : $.datepicker._attachDatepicker(this, options);
            });
        };
        $.datepicker = new Datepicker();
        $(document).ready(function() {
            $(document.body).append($.datepicker.dpDiv).mousedown($.datepicker._checkExternalClick);
        });
    })(jQuery); ;
    (function($) {
        $.effects = $.effects || {};
        $.extend($.effects, {
            save: function(el, set) {
                for (var i = 0; i < set.length; i++) {
                    if (set[i] !== null) $.data(el[0], "ec.storage." + set[i], el[0].style[set[i]]);
                }
            },
            restore: function(el, set) {
                for (var i = 0; i < set.length; i++) {
                    if (set[i] !== null) el.css(set[i], $.data(el[0], "ec.storage." + set[i]));
                }
            },
            setMode: function(el, mode) {
                if (mode == 'toggle') mode = el.is(':hidden') ? 'show' : 'hide';
                return mode;
            },
            getBaseline: function(origin, original) {
                var y, x;
                switch (origin[0]) {
                    case 'top':
                        y = 0;
                        break;
                    case 'middle':
                        y = 0.5;
                        break;
                    case 'bottom':
                        y = 1;
                        break;
                    default:
                        y = origin[0] / original.height;
                };
                switch (origin[1]) {
                    case 'left':
                        x = 0;
                        break;
                    case 'center':
                        x = 0.5;
                        break;
                    case 'right':
                        x = 1;
                        break;
                    default:
                        x = origin[1] / original.width;
                };
                return {
                    x: x,
                    y: y
                };
            },
            createWrapper: function(el) {
                if (el.parent().attr('id') == 'fxWrapper') return el;
                var props = {
                    width: el.outerWidth({
                        margin: true
                    }),
                    height: el.outerHeight({
                        margin: true
                    }),
                    'float': el.css('float')
                };
                el.wrap('<div id="fxWrapper" style="font-size:100%;background:transparent;border:none;margin:0;padding:0"></div>');
                var wrapper = el.parent();
                if (el.css('position') == 'static') {
                    wrapper.css({
                        position: 'relative'
                    });
                    el.css({
                        position: 'relative'
                    });
                } else {
                    var top = el.css('top');
                    if (isNaN(parseInt(top))) top = 'auto';
                    var left = el.css('left');
                    if (isNaN(parseInt(left))) left = 'auto';
                    wrapper.css({
                        position: el.css('position'),
                        top: top,
                        left: left,
                        zIndex: el.css('z-index')
                    }).show();
                    el.css({
                        position: 'relative',
                        top: 0,
                        left: 0
                    });
                }
                wrapper.css(props);
                return wrapper;
            },
            removeWrapper: function(el) {
                if (el.parent().attr('id') == 'fxWrapper') return el.parent().replaceWith(el);
                return el;
            },
            setTransition: function(el, list, factor, val) {
                val = val || {};
                $.each(list,
            function(i, x) {
                unit = el.cssUnit(x);
                if (unit[0] > 0) val[x] = unit[0] * factor + unit[1];
            });
                return val;
            },
            animateClass: function(value, duration, easing, callback) {
                var cb = (typeof easing == "function" ? easing : (callback ? callback : null));
                var ea = (typeof easing == "object" ? easing : null);
                return this.each(function() {
                    var offset = {};
                    var that = $(this);
                    var oldStyleAttr = that.attr("style") || '';
                    if (typeof oldStyleAttr == 'object') oldStyleAttr = oldStyleAttr["cssText"];
                    if (value.toggle) {
                        that.hasClass(value.toggle) ? value.remove = value.toggle : value.add = value.toggle;
                    }
                    var oldStyle = $.extend({},
                (document.defaultView ? document.defaultView.getComputedStyle(this, null) : this.currentStyle));
                    if (value.add) that.addClass(value.add);
                    if (value.remove) that.removeClass(value.remove);
                    var newStyle = $.extend({},
                (document.defaultView ? document.defaultView.getComputedStyle(this, null) : this.currentStyle));
                    if (value.add) that.removeClass(value.add);
                    if (value.remove) that.addClass(value.remove);
                    for (var n in newStyle) {
                        if (typeof newStyle[n] != "function" && newStyle[n] && n.indexOf("Moz") == -1 && n.indexOf("length") == -1 && newStyle[n] != oldStyle[n] && (n.match(/color/i) || (!n.match(/color/i) && !isNaN(parseInt(newStyle[n], 10)))) && (oldStyle.position != "static" || (oldStyle.position == "static" && !n.match(/left|top|bottom|right/)))) offset[n] = newStyle[n];
                    }
                    that.animate(offset, duration, ea,
                function() {
                    if (typeof $(this).attr("style") == 'object') {
                        $(this).attr("style")["cssText"] = "";
                        $(this).attr("style")["cssText"] = oldStyleAttr;
                    } else $(this).attr("style", oldStyleAttr);
                    if (value.add) $(this).addClass(value.add);
                    if (value.remove) $(this).removeClass(value.remove);
                    if (cb) cb.apply(this, arguments);
                });
                });
            }
        });
        $.fn.extend({
            _show: $.fn.show,
            _hide: $.fn.hide,
            __toggle: $.fn.toggle,
            _addClass: $.fn.addClass,
            _removeClass: $.fn.removeClass,
            _toggleClass: $.fn.toggleClass,
            effect: function(fx, o, speed, callback) {
                return $.effects[fx] ? $.effects[fx].call(this, {
                    method: fx,
                    options: o || {},
                    duration: speed,
                    callback: callback
                }) : null;
            },
            show: function() {
                if (!arguments[0] || (arguments[0].constructor == Number || /(slow|normal|fast)/.test(arguments[0]))) return this._show.apply(this, arguments);
                else {
                    var o = arguments[1] || {};
                    o['mode'] = 'show';
                    return this.effect.apply(this, [arguments[0], o, arguments[2] || o.duration, arguments[3] || o.callback]);
                }
            },
            hide: function() {
                if (!arguments[0] || (arguments[0].constructor == Number || /(slow|normal|fast)/.test(arguments[0]))) return this._hide.apply(this, arguments);
                else {
                    var o = arguments[1] || {};
                    o['mode'] = 'hide';
                    return this.effect.apply(this, [arguments[0], o, arguments[2] || o.duration, arguments[3] || o.callback]);
                }
            },
            toggle: function() {
                if (!arguments[0] || (arguments[0].constructor == Number || /(slow|normal|fast)/.test(arguments[0])) || (arguments[0].constructor == Function)) return this.__toggle.apply(this, arguments);
                else {
                    var o = arguments[1] || {};
                    o['mode'] = 'toggle';
                    return this.effect.apply(this, [arguments[0], o, arguments[2] || o.duration, arguments[3] || o.callback]);
                }
            },
            addClass: function(classNames, speed, easing, callback) {
                return speed ? $.effects.animateClass.apply(this, [{
                    add: classNames
                },
            speed, easing, callback]) : this._addClass(classNames);
            },
            removeClass: function(classNames, speed, easing, callback) {
                return speed ? $.effects.animateClass.apply(this, [{
                    remove: classNames
                },
            speed, easing, callback]) : this._removeClass(classNames);
            },
            toggleClass: function(classNames, speed, easing, callback) {
                return speed ? $.effects.animateClass.apply(this, [{
                    toggle: classNames
                },
            speed, easing, callback]) : this._toggleClass(classNames);
            },
            morph: function(remove, add, speed, easing, callback) {
                return $.effects.animateClass.apply(this, [{
                    add: add,
                    remove: remove
                },
            speed, easing, callback]);
            },
            switchClass: function() {
                return this.morph.apply(this, arguments);
            },
            cssUnit: function(key) {
                var style = this.css(key),
            val = [];
                $.each(['em', 'px', '%', 'pt'],
            function(i, unit) {
                if (style.indexOf(unit) > 0) val = [parseFloat(style), unit];
            });
                return val;
            }
        });
        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(",") + ")";
        }
    });
        function getRGB(color) {
            var result;
            if (color && color.constructor == Array && color.length == 3) return color;
            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])];
            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];
            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)];
            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)];
            if (result = /rgba\(0, 0, 0, 0\)/.exec(color)) return colors['transparent']
            return colors[jQuery.trim(color).toLowerCase()];
        }
        function getColor(elem, attr) {
            var color;
            do {
                color = jQuery.curCSS(elem, attr);
                if (color != '' && color != 'transparent' || jQuery.nodeName(elem, "body")) break;
                attr = "backgroundColor";
            } while (elem = elem.parentNode);
            return getRGB(color);
        };
        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],
            transparent: [255, 255, 255]
        };
        jQuery.easing['jswing'] = jQuery.easing['swing'];
        jQuery.extend(jQuery.easing, {
            def: 'easeOutQuad',
            swing: function(x, t, b, c, d) {
                return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
            },
            easeInQuad: function(x, t, b, c, d) {
                return c * (t /= d) * t + b;
            },
            easeOutQuad: function(x, t, b, c, d) {
                return -c * (t /= d) * (t - 2) + b;
            },
            easeInOutQuad: function(x, t, b, c, d) {
                if ((t /= d / 2) < 1) return c / 2 * t * t + b;
                return -c / 2 * ((--t) * (t - 2) - 1) + b;
            },
            easeInCubic: function(x, t, b, c, d) {
                return c * (t /= d) * t * t + b;
            },
            easeOutCubic: function(x, t, b, c, d) {
                return c * ((t = t / d - 1) * t * t + 1) + b;
            },
            easeInOutCubic: function(x, t, b, c, d) {
                if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
                return c / 2 * ((t -= 2) * t * t + 2) + b;
            },
            easeInQuart: function(x, t, b, c, d) {
                return c * (t /= d) * t * t * t + b;
            },
            easeOutQuart: function(x, t, b, c, d) {
                return -c * ((t = t / d - 1) * t * t * t - 1) + b;
            },
            easeInOutQuart: function(x, t, b, c, d) {
                if ((t /= d / 2) < 1) return c / 2 * t * t * t * t + b;
                return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
            },
            easeInQuint: function(x, t, b, c, d) {
                return c * (t /= d) * t * t * t * t + b;
            },
            easeOutQuint: function(x, t, b, c, d) {
                return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
            },
            easeInOutQuint: function(x, t, b, c, d) {
                if ((t /= d / 2) < 1) return c / 2 * t * t * t * t * t + b;
                return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
            },
            easeInSine: function(x, t, b, c, d) {
                return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
            },
            easeOutSine: function(x, t, b, c, d) {
                return c * Math.sin(t / d * (Math.PI / 2)) + b;
            },
            easeInOutSine: function(x, t, b, c, d) {
                return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
            },
            easeInExpo: function(x, t, b, c, d) {
                return (t == 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;
            },
            easeOutExpo: function(x, t, b, c, d) {
                return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;
            },
            easeInOutExpo: function(x, t, b, c, d) {
                if (t == 0) return b;
                if (t == d) return b + c;
                if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
                return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;
            },
            easeInCirc: function(x, t, b, c, d) {
                return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;
            },
            easeOutCirc: function(x, t, b, c, d) {
                return c * Math.sqrt(1 - (t = t / d - 1) * t) + b;
            },
            easeInOutCirc: function(x, t, b, c, d) {
                if ((t /= d / 2) < 1) return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
                return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
            },
            easeInElastic: function(x, t, b, c, d) {
                var s = 1.70158;
                var p = 0;
                var a = c;
                if (t == 0) return b;
                if ((t /= d) == 1) return b + c;
                if (!p) p = d * .3;
                if (a < Math.abs(c)) {
                    a = c;
                    var s = p / 4;
                }
                else var s = p / (2 * Math.PI) * Math.asin(c / a);
                return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
            },
            easeOutElastic: function(x, t, b, c, d) {
                var s = 1.70158;
                var p = 0;
                var a = c;
                if (t == 0) return b;
                if ((t /= d) == 1) return b + c;
                if (!p) p = d * .3;
                if (a < Math.abs(c)) {
                    a = c;
                    var s = p / 4;
                }
                else var s = p / (2 * Math.PI) * Math.asin(c / a);
                return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
            },
            easeInOutElastic: function(x, t, b, c, d) {
                var s = 1.70158;
                var p = 0;
                var a = c;
                if (t == 0) return b;
                if ((t /= d / 2) == 2) return b + c;
                if (!p) p = d * (.3 * 1.5);
                if (a < Math.abs(c)) {
                    a = c;
                    var s = p / 4;
                }
                else var s = p / (2 * Math.PI) * Math.asin(c / a);
                if (t < 1) return -.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
                return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
            },
            easeInBack: function(x, t, b, c, d, s) {
                if (s == undefined) s = 1.70158;
                return c * (t /= d) * t * ((s + 1) * t - s) + b;
            },
            easeOutBack: function(x, t, b, c, d, s) {
                if (s == undefined) s = 1.70158;
                return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
            },
            easeInOutBack: function(x, t, b, c, d, s) {
                if (s == undefined) s = 1.70158;
                if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
                return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
            },
            easeInBounce: function(x, t, b, c, d) {
                return c - jQuery.easing.easeOutBounce(x, d - t, 0, c, d) + b;
            },
            easeOutBounce: function(x, t, b, c, d) {
                if ((t /= d) < (1 / 2.75)) {
                    return c * (7.5625 * t * t) + b;
                } else if (t < (2 / 2.75)) {
                    return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
                } else if (t < (2.5 / 2.75)) {
                    return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
                } else {
                    return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
                }
            },
            easeInOutBounce: function(x, t, b, c, d) {
                if (t < d / 2) return jQuery.easing.easeInBounce(x, t * 2, 0, c, d) * .5 + b;
                return jQuery.easing.easeOutBounce(x, t * 2 - d, 0, c, d) * .5 + c * .5 + b;
            }
        });
    })(jQuery);
    (function($) {
        $.effects.bounce = function(o) {
            return this.queue(function() {
                var el = $(this),
            props = ['position', 'top', 'left'];
                var mode = $.effects.setMode(el, o.options.mode || 'effect');
                var direction = o.options.direction || 'up';
                var distance = o.options.distance || 20;
                var times = o.options.times || 5;
                var speed = o.duration || 250;
                if (/show|hide/.test(mode)) props.push('opacity');
                $.effects.save(el, props);
                el.show();
                $.effects.createWrapper(el);
                var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
                var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
                var distance = o.options.distance || (ref == 'top' ? el.outerHeight({
                    margin: true
                }) / 3 : el.outerWidth({
                    margin: true
                }) / 3);
                if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance);
                if (mode == 'hide') distance = distance / (times * 2);
                if (mode != 'hide') times--;
                if (mode == 'show') {
                    var animation = {
                        opacity: 1
                    };
                    animation[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
                    el.animate(animation, speed / 2, o.options.easing);
                    distance = distance / 2;
                    times--;
                };
                for (var i = 0; i < times; i++) {
                    var animation1 = {},
                animation2 = {};
                    animation1[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
                    animation2[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
                    el.animate(animation1, speed / 2, o.options.easing).animate(animation2, speed / 2, o.options.easing);
                    distance = (mode == 'hide') ? distance * 2 : distance / 2;
                };
                if (mode == 'hide') {
                    var animation = {
                        opacity: 0
                    };
                    animation[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
                    el.animate(animation, speed / 2, o.options.easing,
                function() {
                    el.hide();
                    $.effects.restore(el, props);
                    $.effects.removeWrapper(el);
                    if (o.callback) o.callback.apply(this, arguments);
                });
                } else {
                    var animation1 = {},
                animation2 = {};
                    animation1[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
                    animation2[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
                    el.animate(animation1, speed / 2, o.options.easing).animate(animation2, speed / 2, o.options.easing,
                function() {
                    $.effects.restore(el, props);
                    $.effects.removeWrapper(el);
                    if (o.callback) o.callback.apply(this, arguments);
                });
                };
                el.queue('fx',
            function() {
                el.dequeue();
            });
                el.dequeue();
            });
        };
    })(jQuery);
    (function($) {
        $.effects.drop = function(o) {
            return this.queue(function() {
                var el = $(this),
            props = ['position', 'top', 'left', 'opacity'];
                var mode = $.effects.setMode(el, o.options.mode || 'hide');
                var direction = o.options.direction || 'left';
                $.effects.save(el, props);
                el.show();
                $.effects.createWrapper(el);
                var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
                var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
                var distance = o.options.distance || (ref == 'top' ? el.outerHeight({
                    margin: true
                }) / 2 : el.outerWidth({
                    margin: true
                }) / 2);
                if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance);
                var animation = {
                    opacity: mode == 'show' ? 1 : 0
                };
                animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance;
                el.animate(animation, {
                    queue: false,
                    duration: o.duration,
                    easing: o.options.easing,
                    complete: function() {
                        if (mode == 'hide') el.hide();
                        $.effects.restore(el, props);
                        $.effects.removeWrapper(el);
                        if (o.callback) o.callback.apply(this, arguments);
                        el.dequeue();
                    }
                });
            });
        };
    })(jQuery);
    (function($) {
        $.effects.puff = function(o) {
            return this.queue(function() {
                var el = $(this);
                var options = $.extend(true, {},
            o.options);
                var mode = $.effects.setMode(el, o.options.mode || 'hide');
                var percent = parseInt(o.options.percent) || 150;
                options.fade = true;
                var original = {
                    height: el.height(),
                    width: el.width()
                };
                var factor = percent / 100;
                el.from = (mode == 'hide') ? original : {
                    height: original.height * factor,
                    width: original.width * factor
                };
                options.from = el.from;
                options.percent = (mode == 'hide') ? percent : 100;
                options.mode = mode;
                el.effect('scale', options, o.duration, o.callback);
                el.dequeue();
            });
        };
        $.effects.scale = function(o) {
            return this.queue(function() {
                var el = $(this);
                var options = $.extend(true, {},
            o.options);
                var mode = $.effects.setMode(el, o.options.mode || 'effect');
                var percent = parseInt(o.options.percent) || (parseInt(o.options.percent) == 0 ? 0 : (mode == 'hide' ? 0 : 100));
                var direction = o.options.direction || 'both';
                var origin = o.options.origin;
                if (mode != 'effect') {
                    options.origin = origin || ['middle', 'center'];
                    options.restore = true;
                }
                var original = {
                    height: el.height(),
                    width: el.width()
                };
                el.from = o.options.from || (mode == 'show' ? {
                    height: 0,
                    width: 0
} : original);
                    var factor = {
                        y: direction != 'horizontal' ? (percent / 100) : 1,
                        x: direction != 'vertical' ? (percent / 100) : 1
                    };
                    el.to = {
                        height: original.height * factor.y,
                        width: original.width * factor.x
                    };
                    if (o.options.fade) {
                        if (mode == 'show') {
                            el.from.opacity = 0;
                            el.to.opacity = 1;
                        };
                        if (mode == 'hide') {
                            el.from.opacity = 1;
                            el.to.opacity = 0;
                        };
                    };
                    options.from = el.from;
                    options.to = el.to;
                    options.mode = mode;
                    el.effect('size', options, o.duration, o.callback);
                    el.dequeue();
                });
            };
            $.effects.size = function(o) {
                return this.queue(function() {
                    var el = $(this),
            props = ['position', 'top', 'left', 'width', 'height', 'overflow', 'opacity'];
                    var props1 = ['position', 'top', 'left', 'overflow', 'opacity'];
                    var props2 = ['width', 'height', 'overflow'];
                    var cProps = ['fontSize'];
                    var vProps = ['borderTopWidth', 'borderBottomWidth', 'paddingTop', 'paddingBottom'];
                    var hProps = ['borderLeftWidth', 'borderRightWidth', 'paddingLeft', 'paddingRight'];
                    var mode = $.effects.setMode(el, o.options.mode || 'effect');
                    var restore = o.options.restore || false;
                    var scale = o.options.scale || 'both';
                    var origin = o.options.origin;
                    var original = {
                        height: el.height(),
                        width: el.width()
                    };
                    el.from = o.options.from || original;
                    el.to = o.options.to || original;
                    if (origin) {
                        var baseline = $.effects.getBaseline(origin, original);
                        el.from.top = (original.height - el.from.height) * baseline.y;
                        el.from.left = (original.width - el.from.width) * baseline.x;
                        el.to.top = (original.height - el.to.height) * baseline.y;
                        el.to.left = (original.width - el.to.width) * baseline.x;
                    };
                    var factor = {
                        from: {
                            y: el.from.height / original.height,
                            x: el.from.width / original.width
                        },
                        to: {
                            y: el.to.height / original.height,
                            x: el.to.width / original.width
                        }
                    };
                    if (scale == 'box' || scale == 'both') {
                        if (factor.from.y != factor.to.y) {
                            props = props.concat(vProps);
                            el.from = $.effects.setTransition(el, vProps, factor.from.y, el.from);
                            el.to = $.effects.setTransition(el, vProps, factor.to.y, el.to);
                        };
                        if (factor.from.x != factor.to.x) {
                            props = props.concat(hProps);
                            el.from = $.effects.setTransition(el, hProps, factor.from.x, el.from);
                            el.to = $.effects.setTransition(el, hProps, factor.to.x, el.to);
                        };
                    };
                    if (scale == 'content' || scale == 'both') {
                        if (factor.from.y != factor.to.y) {
                            props = props.concat(cProps);
                            el.from = $.effects.setTransition(el, cProps, factor.from.y, el.from);
                            el.to = $.effects.setTransition(el, cProps, factor.to.y, el.to);
                        };
                    };
                    $.effects.save(el, restore ? props : props1);
                    el.show();
                    $.effects.createWrapper(el);
                    el.css('overflow', 'hidden').css(el.from);
                    if (scale == 'content' || scale == 'both') {
                        vProps = vProps.concat(['marginTop', 'marginBottom']).concat(cProps);
                        hProps = hProps.concat(['marginLeft', 'marginRight']);
                        props2 = props.concat(vProps).concat(hProps);
                        el.find("*[width]").each(function() {
                            child = $(this);
                            if (restore) $.effects.save(child, props2);
                            var c_original = {
                                height: child.height(),
                                width: child.width()
                            };
                            child.from = {
                                height: c_original.height * factor.from.y,
                                width: c_original.width * factor.from.x
                            };
                            child.to = {
                                height: c_original.height * factor.to.y,
                                width: c_original.width * factor.to.x
                            };
                            if (factor.from.y != factor.to.y) {
                                child.from = $.effects.setTransition(child, vProps, factor.from.y, child.from);
                                child.to = $.effects.setTransition(child, vProps, factor.to.y, child.to);
                            };
                            if (factor.from.x != factor.to.x) {
                                child.from = $.effects.setTransition(child, hProps, factor.from.x, child.from);
                                child.to = $.effects.setTransition(child, hProps, factor.to.x, child.to);
                            };
                            child.css(child.from);
                            child.animate(child.to, o.duration, o.options.easing,
                    function() {
                        if (restore) $.effects.restore(child, props2);
                    });
                        });
                    };
                    el.animate(el.to, {
                        queue: false,
                        duration: o.duration,
                        easing: o.options.easing,
                        complete: function() {
                            if (mode == 'hide') el.hide();
                            $.effects.restore(el, restore ? props : props1);
                            $.effects.removeWrapper(el);
                            if (o.callback) o.callback.apply(this, arguments);
                            el.dequeue();
                        }
                    });
                });
            };
        })(jQuery);
        (function($) {
            $.effects.slide = function(o) {
                return this.queue(function() {
                    var el = $(this),
            props = ['position', 'top', 'left'];
                    var mode = $.effects.setMode(el, o.options.mode || 'show');
                    var direction = o.options.direction || 'left';
                    $.effects.save(el, props);
                    el.show();
                    $.effects.createWrapper(el).css({
                        overflow: 'hidden'
                    });
                    var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
                    var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
                    var distance = o.options.distance || (ref == 'top' ? el.outerHeight({
                        margin: true
                    }) : el.outerWidth({
                        margin: true
                    }));
                    if (mode == 'show') el.css(ref, motion == 'pos' ? -distance : distance);
                    var animation = {};
                    animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance;
                    el.animate(animation, {
                        queue: false,
                        duration: o.duration,
                        easing: o.options.easing,
                        complete: function() {
                            if (mode == 'hide') el.hide();
                            $.effects.restore(el, props);
                            $.effects.removeWrapper(el);
                            if (o.callback) o.callback.apply(this, arguments);
                            el.dequeue();
                        }
                    });
                });
            };
        })(jQuery);
        (function($) {
            $.effects.transfer = function(o) {
                return this.queue(function() {
                    var el = $(this);
                    var mode = $.effects.setMode(el, o.options.mode || 'effect');
                    var target = $(o.options.to);
                    var position = el.offset();
                    var transfer = $('<div class="ui-effects-transfer"></div>').appendTo(document.body);
                    if (o.options.className) transfer.addClass(o.options.className);
                    transfer.addClass(o.options.className);
                    transfer.css({
                        top: position.top,
                        left: position.left,
                        height: el.outerHeight() - parseInt(transfer.css('borderTopWidth')) - parseInt(transfer.css('borderBottomWidth')),
                        width: el.outerWidth() - parseInt(transfer.css('borderLeftWidth')) - parseInt(transfer.css('borderRightWidth')),
                        position: 'absolute'
                    });
                    position = target.offset();
                    animation = {
                        top: position.top,
                        left: position.left,
                        height: target.outerHeight() - parseInt(transfer.css('borderTopWidth')) - parseInt(transfer.css('borderBottomWidth')),
                        width: target.outerWidth() - parseInt(transfer.css('borderLeftWidth')) - parseInt(transfer.css('borderRightWidth'))
                    };
                    transfer.animate(animation, o.duration, o.options.easing,
            function() {
                transfer.remove();
                if (o.callback) o.callback.apply(el[0], arguments);
                el.dequeue();
            });
                });
            };
        })(jQuery);
// End ~/Scripts/jquery-ui-personalized-1.5.3.js

// Begin ~/Scripts/jquery.jplayer.js

/*
Copyright (c) 2009 Happyworm Ltd

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Author: Mark J Panaghiston
Version: 0.2.1.beta
Documentation: www.happyworm.com/jquery/jplayer
*/

(function($) {
	$.jPlayerCount = 0;
	
	var methods = {
		jPlayer: function(options) {
			$.jPlayerCount++;
			
			var config = {
				ready: null,
				cssPrefix: "jqjp",
				swfPath: "js",
				quality: "high",
				width: 0,
				height: 0,
				top: 0,
				left: 0,
				position: "absolute",
				bgcolor: "#ffffff"
			};

			$.extend(config, options);

			var configWithoutOptions = {
				id: $(this).attr("id"),
				swf: config.swfPath + ((config.swfPath != "") ? "/" : "") + "Jplayer.swf",
				fid: config.cssPrefix + "_flash_" + $.jPlayerCount,
				hid: config.cssPrefix + "_force_" + $.jPlayerCount
			};

			$.extend(config, configWithoutOptions);

			$(this).data("jPlayer.config", config);
			
			var events = {
				change: function(e, f) {
					var fid = $(this).data("jPlayer.config").fid;
					var m = $(this).data("jPlayer.getMovie")(fid);
					m.fl_change_mp3(f);
					$(this).trigger("jPlayer.screenUpdate", false);
				},
				play: function(e) {
					var fid = $(this).data("jPlayer.config").fid;
					var m = $(this).data("jPlayer.getMovie")(fid);
					var r = m.fl_play_mp3();
					if(r) {
						$(this).trigger("jPlayer.screenUpdate", true);
					}
					
				},
				pause: function(e) {
					var fid = $(this).data("jPlayer.config").fid;
					var m = $(this).data("jPlayer.getMovie")(fid);
					var r = m.fl_pause_mp3();
					if(r) {
						$(this).trigger("jPlayer.screenUpdate", false);
					}
				},
				stopAudio: function(e) {
					var fid = $(this).data("jPlayer.config").fid;
					var m = $(this).data("jPlayer.getMovie")(fid);
					var r = m.fl_stop_mp3();
					if(r) {
						$(this).trigger("jPlayer.screenUpdate", false);
					}
				},
				playHead: function(e, p) {
					var fid = $(this).data("jPlayer.config").fid;
					var m = $(this).data("jPlayer.getMovie")(fid);
					var r = m.fl_play_head_mp3(p);
					if(r) {
						$(this).trigger("jPlayer.screenUpdate", true);
					}
				},
				volume: function(e, v) {
					var fid = $(this).data("jPlayer.config").fid;
					var m = $(this).data("jPlayer.getMovie")(fid);
					m.fl_volume_mp3(v);
				},
				screenUpdate: function(e, playing) {
					var playId = $(this).data("jPlayer.cssId.play");
					var pauseId = $(this).data("jPlayer.cssId.pause");
					var prefix = $(this).data("jPlayer.config").cssPrefix;

					if(playId != null && pauseId != null) {
						if(playing) {
							var style = $(this).data("jPlayer.cssDisplay.pause");
							$("#"+playId).css("display", "none");
							$("#"+pauseId).css("display", style);
						} else {
							var style = $(this).data("jPlayer.cssDisplay.play");
							$("#"+playId).css("display", style);
							$("#"+pauseId).css("display", "none");
						}
					}
				}
			};
			
			for(var event in events) {
				var e = "jPlayer." + event;
				$(this).unbind(e);
				$(this).bind(e, events[event]);
			}

			var getMovie = function(fid) {
				if ($.browser.msie) {
					return window[fid];
				} else {
					return document[fid];
				}
			};
			$(this).data("jPlayer.getMovie", getMovie);
			
			if($.browser.msie) {
				var html_obj = '<object id="' + config.fid + '"';
				html_obj += ' classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"';
				html_obj += ' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"';
				html_obj += ' type="application/x-shockwave-flash"';
				html_obj += ' width="' + config.width + '" height="' + config.height + '">';
				html_obj += '</object>';
			
				var obj_param = new Array();
				obj_param[0] = '<param name="movie" value="' + config.swf + '" />';
				obj_param[1] = '<param name="quality" value="high" />';
				obj_param[2] = '<param name="FlashVars" value="id=' + escape(config.id) + '&fid=' + escape(config.fid) + '" />';
				obj_param[3] = '<param name="allowScriptAccess" value="always" />';
				obj_param[4] = '<param name="bgcolor" value="' + config.bgcolor + '" />';
				
				var ie_dom = document.createElement(html_obj);
				for(var i=0; i < obj_param.length; i++) {
					ie_dom.appendChild(document.createElement(obj_param[i]));
				}
				$(this).html(ie_dom);
			} else {
				var html_embed = '<embed name="' + config.fid + '" src="' + config.swf + '"';
				html_embed += ' width="' + config.width + '" height="' + config.height + '" bgcolor="' + config.bgcolor + '"';
				html_embed += ' quality="high" FlashVars="id=' + escape(config.id) + '&fid=' + escape(config.fid) + '"';
				html_embed += ' allowScriptAccess="always"';
				html_embed += ' type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
				$(this).html(html_embed);
			}
			
			var html_hidden = '<div id="' + config.hid + '"></div>';
			$(this).append(html_hidden);
			
			$(this).css({'position':config.position, 'top':config.top, 'left':config.left});
			$("#"+config.hid).css({'text-indent':'-9999px'});
			
			return $(this);
		},
		change: function(f) {
			$(this).trigger("jPlayer.change", f);
		},
		play: function() {
			$(this).trigger("jPlayer.play");
		},
		changeAndPlay: function(f) {
			$(this).trigger("jPlayer.change", f);
			$(this).trigger("jPlayer.play");
		},
		pause: function() {
			$(this).trigger("jPlayer.pause");
		},
		stopAudio: function() {
		$(this).trigger("jPlayer.stopAudio");
		},
		playHead: function(p) {
			$(this).trigger("jPlayer.playHead", p);
		},
		volume: function(v) {
			$(this).trigger("jPlayer.volume", v);
		},
		jPlayerId: function(fn, id) {
			if(id != null) {
				var isValid = eval("$(this)."+fn);
				if(isValid != null) {
					$(this).data("jPlayer.cssId." + fn, id);
					var jPlayerId = $(this).data("jPlayer.config").id;
					eval("var myHandler = function(e) { $(\"#" + jPlayerId + "\")." + fn + "(e); return false; }");
					$("#"+id).click(myHandler).hover(this.rollOver, this.rollOut).data("jPlayerId", jPlayerId);
					
					var display = $("#"+id).css("display");
					$(this).data("jPlayer.cssDisplay." + fn, display);
					
					if(fn == "pause") {
						$("#"+id).css("display", "none");
					}
				} else {
					alert("Unknown function assigned in: jPlayerId( fn="+fn+", id="+id+" )");
				}
			} else {
				id = $(this).data("jPlayer.cssId." + fn);
				if(id != null) {
					return id;
				} else {
					alert("Unknown function id requested: jPlayerId( fn="+fn+" )");
					return false;
				}
			}
		},
		loadBar: function(e) {
			var lbId = $(this).data("jPlayer.cssId.loadBar");
			if( lbId != null ) {
				var offset = $("#"+lbId).offset();
				var x = e.pageX - offset.left;
				var w = $("#"+lbId).width();
				var p = 100*x/w;
				$(this).playHead(p);
			}
		},
		playBar: function(e) {
			this.loadBar(e);
		},
		onProgressChange: function(fn) {
			$(this).data("jPlayer.jsFn.onProgressChange", fn);
		},
		updateProgress: function(loadPercent, playedPercentRelative, playedPercentAbsolute, playedTime, totalTime) { // Called from Flash
			var lbId = $(this).data("jPlayer.cssId.loadBar");
			if (lbId != null) {
				$("#"+lbId).width(loadPercent+"%");
			}
			var pbId = $(this).data("jPlayer.cssId.playBar");
			if (pbId != null ) {
				$("#"+pbId).width(playedPercentRelative+"%");
			}
			var onProgressChangeFn = $(this).data("jPlayer.jsFn.onProgressChange");
			if(onProgressChangeFn != null) {
				onProgressChangeFn(loadPercent, playedPercentRelative, playedPercentAbsolute, playedTime, totalTime);
			}
			if (lbId != null || pbId != null || onProgressChangeFn != null) {
				this.forceScreenUpdate();
				return true;
			} else {
				return false;
			}
		},
		volumeMin: function() {
			$(this).volume(0);
		},
		volumeMax: function() {
			$(this).volume(100);
		},
		volumeBar: function(e) {
			var vbId = $(this).data("jPlayer.cssId.volumeBar");
			if( vbId != null ) {
				var offset = $("#"+vbId).offset();
				var x = e.pageX - offset.left;
				var w = $("#"+vbId).width();
				var p = 100*x/w;
				$(this).volume(p);
			}
		},
		volumeBarValue: function(e) {
			this.volumeBar(e);
		},
		updateVolume: function(v) { // Called from Flash
			var vbvId = $(this).data("jPlayer.cssId.volumeBarValue");
			if( vbvId != null ) {
				$("#"+vbvId).width(v+"%");
				this.forceScreenUpdate();
				return true;
			}
		},
		onSoundComplete: function(fn) {
			$(this).data("jPlayer.jsFn.onSoundComplete", fn);
		},
		finishedPlaying: function() { // Called from Flash
			var onSoundCompleteFn = $(this).data("jPlayer.jsFn.onSoundComplete");
			$(this).trigger("jPlayer.screenUpdate", false);
			if(onSoundCompleteFn != null) {
				onSoundCompleteFn();
				return true;
			} else {
				return false;
			}
		},
		setBufferState: function (b) { // Called from Flash
			var lbId = $(this).data("jPlayer.cssId.loadBar");
			if( lbId != null ) {
				var prefix = $(this).data("jPlayer.config").cssPrefix;
				if(b) {
					$("#"+lbId).addClass(prefix + "_buffer");
				} else {
					$("#"+lbId).removeClass(prefix + "_buffer");
				}
				return true;
			} else {
				return false;
			}
		},
		bufferMsg: function() {
			// Empty: Initialized to enable jPlayerId() to work.
			// See setBufferMsg() for code.
		},
		setBufferMsg: function (msg) { // Called from Flash
			var bmId = $(this).data("jPlayer.cssId.bufferMsg");
			if( bmId != null ) {
				$("#"+bmId).html(msg);
				return true;
			} else {
				return false;
			}
		},
		forceScreenUpdate: function() { // For Safari and Chrome
			var hid = $(this).data("jPlayer.config").hid;
			$("#"+hid).html(Math.random());
		},
		rollOver: function() {
			var jPlayerId = $(this).data("jPlayerId");
			var prefix = $("#"+jPlayerId).data("jPlayer.config").cssPrefix;
			$(this).addClass(prefix + "_hover");
		},
		rollOut: function() {
			var jPlayerId = $(this).data("jPlayerId");
			var prefix = $("#"+jPlayerId).data("jPlayer.config").cssPrefix;
			$(this).removeClass(prefix + "_hover");
		},
		flashReady: function() { // Called from Flash
			var readyFn = $(this).data("jPlayer.config").ready;
			if(readyFn != null) {
				readyFn();
			}
		}
	};

	$.each(methods, function(i) {
		$.fn[i] = this;
	});
})(jQuery);

// End ~/Scripts/jquery.jplayer.js

// Begin ~/Scripts/jquery.dataTables.js

/*
 * File:        jquery.dataTables.js
 * Version:     1.5.2
 * CVS:         $Id$
 * Description: Paginate, search and sort HTML tables
 * Author:      Allan Jardine (www.sprymedia.co.uk)
 * Created:     28/3/2008
 * Modified:    $Date$ by $Author$
 * Language:    Javascript
 * License:     GPL v2 or BSD 3 point style
 * Project:     Mtaala
 * Contact:     allan.jardine@sprymedia.co.uk
 * 
 * Copyright 2008-2009 Allan Jardine, all rights reserved.
 *
 * This source file is free software, under either the GPL v2 license or a
 * BSD style license, as supplied with this software.
 * 
 * This source file is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
 * 
 * For details pleease refer to: http://www.datatables.net
 */

/*
 * When considering jsLint, we need to allow eval() as it it is used for reading cookies and 
 * building the dynamic multi-column sort functions.
 */
/*jslint evil: true, undef: true, browser: true */
/*globals $, jQuery,_fnReadCookie,_fnProcessingDisplay,_fnDraw,_fnSort,_fnReDraw,_fnDetectType,_fnSortingClasses,_fnSettingsFromNode,_fnBuildSearchArray,_fnCalculateEnd,_fnFeatureHtmlProcessing,_fnFeatureHtmlPaginate,_fnFeatureHtmlInfo,_fnFeatureHtmlFilter,_fnFilter,_fnSaveState,_fnFilterColumn,_fnEscapeRegex,_fnFilterComplete,_fnFeatureHtmlLength,_fnGetDataMaster,_fnVisibleToColumnIndex,_fnDrawHead,_fnAddData,_fnGetTrNodes,_fnColumnIndexToVisible,_fnCreateCookie,_fnAddOptionsHtml,_fnMap,_fnClearTable,_fnDataToSearch,_fnReOrderIndex,_fnFilterCustom,_fnVisbleColumns,_fnAjaxUpdate,_fnAjaxUpdateDraw,_fnColumnOrdering,fnGetMaxLenString*/

(function($) {
    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    * DataTables variables
    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

    /*
    * Variable: dataTableSettings
    * Purpose:  Store the settings for each dataTables instance
    * Scope:    jQuery.fn
    */
    $.fn.dataTableSettings = [];

    /*
    * Variable: dataTableExt
    * Purpose:  Container for customisable parts of DataTables
    * Scope:    jQuery.fn
    */
    $.fn.dataTableExt = {};
    var _oExt = $.fn.dataTableExt; /* Short reference for fast internal lookup */


    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    * DataTables extensible objects
    * 
    * The _oExt object is used to provide an area where user dfined plugins can be 
    * added to DataTables. The following properties of the object are used:
    *   oApi - Plug-in API functions
    *   aTypes - Auto-detection of types
    *   oSort - Sorting functions used by DataTables (based on the type)
    *   oPagination - Pagination functions for different input styles
    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

    /*
    * Variable: sVersion
    * Purpose:  Version string for plug-ins to check compatibility
    * Scope:    jQuery.fn.dataTableExt
    */
    _oExt.sVersion = "1.5.2";

    /*
    * Variable: iApiIndex
    * Purpose:  Index for what 'this' index API functions should use
    * Scope:    jQuery.fn.dataTableExt
    */
    _oExt.iApiIndex = 0;

    /*
    * Variable: oApi
    * Purpose:  Container for plugin API functions
    * Scope:    jQuery.fn.dataTableExt
    */
    _oExt.oApi = {};

    /*
    * Variable: aFiltering
    * Purpose:  Container for plugin filtering functions
    * Scope:    jQuery.fn.dataTableExt
    */
    _oExt.afnFiltering = [];

    /*
    * Variable: aoFeatures
    * Purpose:  Container for plugin function functions
    * Scope:    jQuery.fn.dataTableExt
    * Notes:    Array of objects with the following parameters:
    *   fnInit: Function for initialisation of Feature. Takes oSettings and returns node
    *   cFeature: Character that will be matched in sDom - case sensitive
    *   sFeature: Feature name - just for completeness :-)
    */
    _oExt.aoFeatures = [];

    /*
    * Variable: ofnSearch
    * Purpose:  Container for custom filtering functions
    * Scope:    jQuery.fn.dataTableExt
    * Notes:    This is an object (the name should match the type) for custom filtering function,
    *   which can be used for live DOM checking or formatted text filtering
    */
    _oExt.ofnSearch = {};

    /*
    * Variable: oStdClasses
    * Purpose:  Storage for the various classes that DataTables uses
    * Scope:    jQuery.fn.dataTableExt
    */
    _oExt.oStdClasses = {
        /* Two buttons buttons */
        "sPagePrevEnabled": "paginate_enabled_previous",
        "sPagePrevDisabled": "paginate_disabled_previous",
        "sPageNextEnabled": "paginate_enabled_next",
        "sPageNextDisabled": "paginate_disabled_next",
        "sPageJUINext": "",
        "sPageJUIPrev": "",

        /* Full numbers paging buttons */
        "sPageButton": "paginate_button",
        "sPageButtonActive": "paginate_active",
        "sPageButtonStaticActive": "paginate_button",
        "sPageFirst": "first",
        "sPagePrevious": "previous",
        "sPageNext": "next",
        "sPageLast": "last",

        /* Stripping classes */
        "sStripOdd": "odd",
        "sStripEven": "even",

        /* Empty row */
        "sRowEmpty": "dataTables_empty",

        /* Features */
        "sWrapper": "dataTables_wrapper",
        "sFilter": "dataTables_filter",
        "sInfo": "dataTables_info",
        "sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */
        "sLength": "dataTables_length",
        "sProcessing": "dataTables_processing",

        /* Sorting */
        "sSortAsc": "sorting_asc",
        "sSortDesc": "sorting_desc",
        "sSortable": "sorting",
        "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
        "sSortJUIAsc": "",
        "sSortJUIDesc": "",
        "sSortJUI": ""
    };

    /*
    * Variable: oJUIClasses
    * Purpose:  Storage for the various classes that DataTables uses - jQuery UI suitable
    * Scope:    jQuery.fn.dataTableExt
    */
    _oExt.oJUIClasses = {
        /* Two buttons buttons */
        "sPagePrevEnabled": "fg-button ui-state-default ui-corner-left",
        "sPagePrevDisabled": "fg-button ui-state-default ui-corner-left ui-state-disabled",
        "sPageNextEnabled": "fg-button ui-state-default ui-corner-right",
        "sPageNextDisabled": "fg-button ui-state-default ui-corner-right ui-state-disabled",
        "sPageJUINext": "ui-icon ui-icon-circle-arrow-e",
        "sPageJUIPrev": "ui-icon ui-icon-circle-arrow-w",

        /* Full numbers paging buttons */
        "sPageButton": "fg-button ui-state-default",
        "sPageButtonActive": "fg-button ui-state-default ui-state-disabled",
        "sPageButtonStaticActive": "fg-button ui-state-default ui-state-disabled",
        "sPageFirst": "first ui-corner-tl ui-corner-bl",
        "sPagePrevious": "previous",
        "sPageNext": "next",
        "sPageLast": "last ui-corner-tr ui-corner-br",

        /* Stripping classes */
        "sStripOdd": "odd",
        "sStripEven": "even",

        /* Empty row */
        "sRowEmpty": "dataTables_empty",

        /* Features */
        "sWrapper": "dataTables_wrapper",
        "sFilter": "dataTables_filter",
        "sInfo": "dataTables_info",
        "sPaging": "dataTables_paginate fg-buttonset fg-buttonset-multi paging_", /* Note that the type is postfixed */
        "sLength": "dataTables_length",
        "sProcessing": "dataTables_processing",

        /* Sorting */
        "sSortAsc": "ui-state-default",
        "sSortDesc": "ui-state-default",
        "sSortable": "ui-state-default",
        "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
        "sSortJUIAsc": "css_right ui-icon ui-icon-triangle-1-n",
        "sSortJUIDesc": "css_right ui-icon ui-icon-triangle-1-s",
        "sSortJUI": "css_right ui-icon ui-icon-triangle-2-n-s"
    };

    /*
    * Variable: oPagination
    * Purpose:  Container for the various type of pagination that dataTables supports
    * Scope:    jQuery.fn.dataTableExt
    */
    _oExt.oPagination = {
        /*
        * Variable: two_button
        * Purpose:  Standard two button (forward/back) pagination
        * Scope:    jQuery.fn.dataTableExt.oPagination
        */
        "two_button": {
            /*
            * Function: oPagination.two_button.fnInit
            * Purpose:  Initalise dom elements required for pagination with forward/back buttons only
            * Returns:  -
            * Inputs:   object:oSettings - dataTables settings object
            *           function:fnCallbackDraw - draw function which must be called on update
            */
            "fnInit": function(oSettings, fnCallbackDraw) {
                var nPaging = oSettings.anFeatures.p;

                /* Store the next and previous elements in the oSettings object as they can be very
                * usful for automation - particularly testing
                */
                if (!oSettings.bJUI) {
                    oSettings.nPrevious = document.createElement('div');
                    oSettings.nNext = document.createElement('div');
                }
                else {
                    oSettings.nPrevious = document.createElement('a');
                    oSettings.nNext = document.createElement('a');

                    var nNextInner = document.createElement('span');
                    nNextInner.className = oSettings.oClasses.sPageJUINext;
                    oSettings.nNext.appendChild(nNextInner);

                    var nPreviousInner = document.createElement('span');
                    nPreviousInner.className = oSettings.oClasses.sPageJUIPrev;
                    oSettings.nPrevious.appendChild(nPreviousInner);
                }

                if (oSettings.sTableId !== '') {
                    nPaging.setAttribute('id', oSettings.sTableId + '_paginate');
                    oSettings.nPrevious.setAttribute('id', oSettings.sTableId + '_previous');
                    oSettings.nNext.setAttribute('id', oSettings.sTableId + '_next');
                }

                oSettings.nPrevious.className = oSettings.oClasses.sPagePrevDisabled;
                oSettings.nNext.className = oSettings.oClasses.sPageNextDisabled;

                oSettings.nPrevious.title = oSettings.oLanguage.oPaginate.sPrevious;
                oSettings.nNext.title = oSettings.oLanguage.oPaginate.sNext;

                nPaging.appendChild(oSettings.nPrevious);
                nPaging.appendChild(oSettings.nNext);
                $(nPaging).insertAfter(oSettings.nTable);

                $(oSettings.nPrevious).click(function() {
                    oSettings._iDisplayStart -= oSettings._iDisplayLength;

                    /* Correct for underrun */
                    if (oSettings._iDisplayStart < 0) {
                        oSettings._iDisplayStart = 0;
                    }

                    fnCallbackDraw(oSettings);
                });

                $(oSettings.nNext).click(function() {
                    /* Make sure we are not over running the display array */
                    if (oSettings._iDisplayStart + oSettings._iDisplayLength < oSettings.fnRecordsDisplay()) {
                        oSettings._iDisplayStart += oSettings._iDisplayLength;
                    }

                    fnCallbackDraw(oSettings);
                });

                /* Take the brutal approach to cancelling text selection */
                $(oSettings.nPrevious).bind('selectstart', function() { return false; });
                $(oSettings.nNext).bind('selectstart', function() { return false; });
            },

            /*
            * Function: oPagination.two_button.fnUpdate
            * Purpose:  Update the two button pagination at the end of the draw
            * Returns:  -
            * Inputs:   object:oSettings - dataTables settings object
            *           function:fnCallbackDraw - draw function which must be called on update
            */
            "fnUpdate": function(oSettings, fnCallbackDraw) {
                if (!oSettings.anFeatures.p) {
                    return;
                }

                oSettings.nPrevious.className =
					(oSettings._iDisplayStart === 0) ?
					oSettings.oClasses.sPagePrevDisabled : oSettings.oClasses.sPagePrevEnabled;

                oSettings.nNext.className =
					(oSettings.fnDisplayEnd() == oSettings.fnRecordsDisplay()) ?
					oSettings.oClasses.sPageNextDisabled : oSettings.oClasses.sPageNextEnabled;
            }
        },


        /*
        * Variable: iFullNumbersShowPages
        * Purpose:  Change the number of pages which can be seen
        * Scope:    jQuery.fn.dataTableExt.oPagination
        */
        "iFullNumbersShowPages": 5,

        /*
        * Variable: full_numbers
        * Purpose:  Full numbers pagination
        * Scope:    jQuery.fn.dataTableExt.oPagination
        */
        "full_numbers": {
            /*
            * Function: oPagination.full_numbers.fnInit
            * Purpose:  Initalise dom elements required for pagination with a list of the pages
            * Returns:  -
            * Inputs:   object:oSettings - dataTables settings object
            *           function:fnCallbackDraw - draw function which must be called on update
            */
            "fnInit": function(oSettings, fnCallbackDraw) {
                var nPaging = oSettings.anFeatures.p;
                var nFirst = document.createElement('span');
                var nPrevious = document.createElement('span');
                var nList = document.createElement('span');
                var nNext = document.createElement('span');
                var nLast = document.createElement('span');

                nFirst.innerHTML = oSettings.oLanguage.oPaginate.sFirst;
                nPrevious.innerHTML = oSettings.oLanguage.oPaginate.sPrevious;
                nNext.innerHTML = oSettings.oLanguage.oPaginate.sNext;
                nLast.innerHTML = oSettings.oLanguage.oPaginate.sLast;

                var oClasses = oSettings.oClasses;
                nFirst.className = oClasses.sPageButton + " " + oClasses.sPageFirst;
                nPrevious.className = oClasses.sPageButton + " " + oClasses.sPagePrevious;
                nNext.className = oClasses.sPageButton + " " + oClasses.sPageNext;
                nLast.className = oClasses.sPageButton + " " + oClasses.sPageLast;

                if (oSettings.sTableId !== '') {
                    nPaging.setAttribute('id', oSettings.sTableId + '_paginate');
                    nFirst.setAttribute('id', oSettings.sTableId + '_first');
                    nPrevious.setAttribute('id', oSettings.sTableId + '_previous');
                    nNext.setAttribute('id', oSettings.sTableId + '_next');
                    nLast.setAttribute('id', oSettings.sTableId + '_last');
                }

                nPaging.appendChild(nFirst);
                nPaging.appendChild(nPrevious);
                nPaging.appendChild(nList);
                nPaging.appendChild(nNext);
                nPaging.appendChild(nLast);

                $(nFirst).click(function() {
                    oSettings._iDisplayStart = 0;
                    fnCallbackDraw(oSettings);
                });

                $(nPrevious).click(function() {
                    oSettings._iDisplayStart -= oSettings._iDisplayLength;

                    /* Correct for underrun */
                    if (oSettings._iDisplayStart < 0) {
                        oSettings._iDisplayStart = 0;
                    }

                    fnCallbackDraw(oSettings);
                });

                $(nNext).click(function() {
                    /* Make sure we are not over running the display array */
                    if (oSettings._iDisplayStart + oSettings._iDisplayLength < oSettings.fnRecordsDisplay()) {
                        oSettings._iDisplayStart += oSettings._iDisplayLength;
                    }

                    fnCallbackDraw(oSettings);
                });

                $(nLast).click(function() {
                    var iPages = parseInt((oSettings.fnRecordsDisplay() - 1) / oSettings._iDisplayLength, 10) + 1;
                    oSettings._iDisplayStart = (iPages - 1) * oSettings._iDisplayLength;

                    fnCallbackDraw(oSettings);
                });

                /* Take the brutal approach to cancelling text selection */
                $('span', nPaging).bind('mousedown', function() { return false; });
                $('span', nPaging).bind('selectstart', function() { return false; });

                oSettings.nPaginateList = nList;
            },

            /*
            * Function: oPagination.full_numbers.fnUpdate
            * Purpose:  Update the list of page buttons shows
            * Returns:  -
            * Inputs:   object:oSettings - dataTables settings object
            *           function:fnCallbackDraw - draw function which must be called on update
            */
            "fnUpdate": function(oSettings, fnCallbackDraw) {
                if (!oSettings.anFeatures.p) {
                    return;
                }

                var iPageCount = jQuery.fn.dataTableExt.oPagination.iFullNumbersShowPages;
                var iPageCountHalf = Math.floor(iPageCount / 2);
                var iPages = Math.ceil((oSettings.fnRecordsDisplay()) / oSettings._iDisplayLength);
                var iCurrentPage = Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength) + 1;
                var sList = "";
                var iStartButton;
                var iEndButton;
                var oClasses = oSettings.oClasses;

                if (iPages < iPageCount) {
                    iStartButton = 1;
                    iEndButton = iPages;
                }
                else {
                    if (iCurrentPage <= iPageCountHalf) {
                        iStartButton = 1;
                        iEndButton = iPageCount;
                    }
                    else {
                        if (iCurrentPage >= (iPages - iPageCountHalf)) {
                            iStartButton = iPages - iPageCount + 1;
                            iEndButton = iPages;
                        }
                        else {
                            iStartButton = iCurrentPage - Math.ceil(iPageCount / 2) + 1;
                            iEndButton = iStartButton + iPageCount - 1;
                        }
                    }
                }

                for (var i = iStartButton; i <= iEndButton; i++) {
                    if (iCurrentPage != i) {
                        sList += '<span class="' + oClasses.sPageButton + '">' + i + '</span>';
                    }
                    else {
                        sList += '<span class="' + oClasses.sPageButtonActive + '">' + i + '</span>';
                    }
                }

                oSettings.nPaginateList.innerHTML = sList;

                /* Take the brutal approach to cancelling text selection */
                $('span', oSettings.nPaginateList).bind('mousedown', function() { return false; });
                $('span', oSettings.nPaginateList).bind('selectstart', function() { return false; });

                $('span', oSettings.nPaginateList).click(function() {
                    var iTarget = (this.innerHTML * 1) - 1;
                    oSettings._iDisplayStart = iTarget * oSettings._iDisplayLength;

                    fnCallbackDraw(oSettings);
                    return false;
                });

                /* Update the 'premanent botton's classes */
                var nButtons = $('span', oSettings.anFeatures.p);
                var nStatic = [nButtons[0], nButtons[1], nButtons[nButtons.length - 2], nButtons[nButtons.length - 1]];
                $(nStatic).removeClass(oClasses.sPageButton + " " + oClasses.sPageButtonActive);
                if (iCurrentPage == 1) {
                    nStatic[0].className += " " + oClasses.sPageButtonStaticActive;
                    nStatic[1].className += " " + oClasses.sPageButtonStaticActive;
                }
                else {
                    nStatic[0].className += " " + oClasses.sPageButton;
                    nStatic[1].className += " " + oClasses.sPageButton;
                }

                if (iCurrentPage == iPages) {
                    nStatic[2].className += " " + oClasses.sPageButtonStaticActive;
                    nStatic[3].className += " " + oClasses.sPageButtonStaticActive;
                }
                else {
                    nStatic[2].className += " " + oClasses.sPageButton;
                    nStatic[3].className += " " + oClasses.sPageButton;
                }
            }
        }
    };

    /*
    * Variable: oSort
    * Purpose:  Wrapper for the sorting functions that can be used in DataTables
    * Scope:    jQuery.fn.dataTableExt
    * Notes:    The functions provided in this object are basically standard javascript sort
    *   functions - they expect two inputs which they then compare and then return a priority
    *   result. For each sort method added, two functions need to be defined, an ascending sort and
    *   a descending sort.
    */
    _oExt.oSort = {
        /*
        * text sorting
        */
        "string-asc": function(a, b) {
            var x = a.toLowerCase();
            var y = b.toLowerCase();
            return ((x < y) ? -1 : ((x > y) ? 1 : 0));
        },

        "string-desc": function(a, b) {
            var x = a.toLowerCase();
            var y = b.toLowerCase();
            return ((x < y) ? 1 : ((x > y) ? -1 : 0));
        },


        /*
        * html sorting (ignore html tags)
        */
        "html-asc": function(a, b) {
            var x = a.replace(/<.*?>/g, "").toLowerCase();
            var y = b.replace(/<.*?>/g, "").toLowerCase();
            return ((x < y) ? -1 : ((x > y) ? 1 : 0));
        },

        "html-desc": function(a, b) {
            var x = a.replace(/<.*?>/g, "").toLowerCase();
            var y = b.replace(/<.*?>/g, "").toLowerCase();
            return ((x < y) ? 1 : ((x > y) ? -1 : 0));
        },


        /*
        * date sorting
        */
        "date-asc": function(a, b) {
            var x = Date.parse(a);
            var y = Date.parse(b);

            if (isNaN(x)) {
                x = Date.parse("01/01/1970 00:00:00");
            }
            if (isNaN(y)) {
                y = Date.parse("01/01/1970 00:00:00");
            }

            return x - y;
        },

        "date-desc": function(a, b) {
            var x = Date.parse(a);
            var y = Date.parse(b);

            if (isNaN(x)) {
                x = Date.parse("01/01/1970 00:00:00");
            }
            if (isNaN(y)) {
                y = Date.parse("01/01/1970 00:00:00");
            }

            return y - x;
        },


        /*
        * numerical sorting
        */
        "numeric-asc": function(a, b) {
            var x = a == "-" ? 0 : a;
            var y = b == "-" ? 0 : b;
            return x - y;
        },

        "numeric-desc": function(a, b) {
            var x = a == "-" ? 0 : a;
            var y = b == "-" ? 0 : b;
            return y - x;
        }
    };


    /*
    * Variable: aTypes
    * Purpose:  Container for the various type of type detection that dataTables supports
    * Scope:    jQuery.fn.dataTableExt
    * Notes:    The functions in this array are expected to parse a string to see if it is a data
    *   type that it recognises. If so then the function should return the name of the type (a
    *   corresponding sort function should be defined!), if the type is not recognised then the
    *   function should return null such that the parser and move on to check the next type.
    *   Note that ordering is important in this array - the functions are processed linearly,
    *   starting at index 0.
    */
    _oExt.aTypes = [
    /*
    * Function: -
    * Purpose:  Check to see if a string is numeric
    * Returns:  string:'numeric' or null
    * Inputs:   string:sText - string to check
    */
		function(sData) {
		    /* Snaity check that we are dealing with a string or quick return for a number */
		    if (typeof sData == 'number') {
		        return 'numeric';
		    }
		    else if (typeof sData.charAt != 'function') {
		        return null;
		    }

		    var sValidFirstChars = "0123456789-";
		    var sValidChars = "0123456789.";
		    var Char;
		    var bDecimal = false;

		    /* Check for a valid first char (no period and allow negatives) */
		    Char = sData.charAt(0);
		    if (sValidFirstChars.indexOf(Char) == -1) {
		        return null;
		    }

		    /* Check all the other characters are valid */
		    for (var i = 1; i < sData.length; i++) {
		        Char = sData.charAt(i);
		        if (sValidChars.indexOf(Char) == -1) {
		            return null;
		        }

		        /* Only allowed one decimal place... */
		        if (Char == ".") {
		            if (bDecimal) {
		                return null;
		            }
		            bDecimal = true;
		        }
		    }

		    return 'numeric';
		},

    /*
    * Function: -
    * Purpose:  Check to see if a string is actually a formatted date
    * Returns:  string:'date' or null
    * Inputs:   string:sText - string to check
    */
		function(sData) {
		    var iParse = Date.parse(sData);
		    if (iParse !== null && !isNaN(iParse)) {
		        return 'date';
		    }
		    return null;
		}
	];


    /*
    * Variable: _oExternConfig
    * Purpose:  Store information for DataTables to access globally about other instances
    * Scope:    jQuery.fn.dataTableExt
    */
    _oExt._oExternConfig = {
        /* int:iNextUnique - next unique number for an instance */
        "iNextUnique": 0
    };


    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    * DataTables prototype
    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

    /*
    * Function: dataTable
    * Purpose:  DataTables information
    * Returns:  -
    * Inputs:   object:oInit - initalisation options for the table
    */
    $.fn.dataTable = function(oInit) {
        /*
        * Variable: _aoSettings
        * Purpose:  Easy reference to data table settings
        * Scope:    jQuery.dataTable
        */
        var _aoSettings = $.fn.dataTableSettings;

        /*
        * Function: classSettings
        * Purpose:  Settings container function for all 'class' properties which are required
        *   by dataTables
        * Returns:  -
        * Inputs:   -
        */
        function classSettings() {
            this.fnRecordsTotal = function() {
                if (this.oFeatures.bServerSide) {
                    return this._iRecordsTotal;
                } else {
                    return this.aiDisplayMaster.length;
                }
            };

            this.fnRecordsDisplay = function() {
                if (this.oFeatures.bServerSide) {
                    return this._iRecordsDisplay;
                } else {
                    return this.aiDisplay.length;
                }
            };

            this.fnDisplayEnd = function() {
                if (this.oFeatures.bServerSide) {
                    return this._iDisplayStart + this.aiDisplay.length;
                } else {
                    return this._iDisplayEnd;
                }
            };

            /*
            * Variable: sInstance
            * Purpose:  Unique idendifier for each instance of the DataTables object
            * Scope:    jQuery.dataTable.classSettings 
            */
            this.sInstance = null;

            /*
            * Variable: oFeatures
            * Purpose:  Indicate the enablement of key dataTable features
            * Scope:    jQuery.dataTable.classSettings 
            */
            this.oFeatures = {
                "bPaginate": true,
                "bLengthChange": true,
                "bFilter": true,
                "bSort": true,
                "bInfo": true,
                "bAutoWidth": true,
                "bProcessing": false,
                "bSortClasses": true,
                "bStateSave": false,
                "bServerSide": false
            };

            /*
            * Variable: anFeatures
            * Purpose:  Array referencing the nodes which are used for the features
            * Scope:    jQuery.dataTable.classSettings 
            * Notes:    The parameters of this object match what is allowed by sDom - i.e.
            *   'l' - Length changing
            *   'f' - Filtering input
            *   't' - The table!
            *   'i' - Information
            *   'p' - Pagination
            *   'r' - pRocessing
            */
            this.anFeatures = [];

            /*
            * Variable: oLanguage
            * Purpose:  Store the language strings used by dataTables
            * Scope:    jQuery.dataTable.classSettings
            * Notes:    The words in the format _VAR_ are variables which are dynamically replaced
            *   by javascript
            */
            this.oLanguage = {
                "sProcessing": "Processing...",
                "sLengthMenu": "Show _MENU_ entries",
                "sZeroRecords": "No matching records found",
                "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
                "sInfoEmpty": "Showing 0 to 0 of 0 entries",
                "sInfoFiltered": "(filtered from _MAX_ total entries)",
                "sInfoPostFix": "",
                "sSearch": "Search:",
                "sUrl": "",
                "oPaginate": {
                    "sFirst": "First",
                    "sPrevious": "Previous",
                    "sNext": "Next",
                    "sLast": "Last"
                }
            };

            /*
            * Variable: aoData
            * Purpose:  Store data information
            * Scope:    jQuery.dataTable.classSettings 
            * Notes:    This is an array of objects with the following parameters:
            *   int: _iId - internal id for tracking
            *   array: _aData - internal data - used for sorting / filtering etc
            *   node: nTr - display node
            *   array node: _anHidden - hidden TD nodes
            */
            this.aoData = [];

            /*
            * Variable: aiDisplay
            * Purpose:  Array of indexes which are in the current display (after filtering etc)
            * Scope:    jQuery.dataTable.classSettings
            */
            this.aiDisplay = [];

            /*
            * Variable: aiDisplayMaster
            * Purpose:  Array of indexes for display - no filtering
            * Scope:    jQuery.dataTable.classSettings
            */
            this.aiDisplayMaster = [];

            /*
            * Variable: aoColumns
            * Purpose:  Store information about each column that is in use
            * Scope:    jQuery.dataTable.classSettings 
            */
            this.aoColumns = [];

            /*
            * Variable: iNextId
            * Purpose:  Store the next unique id to be used for a new row
            * Scope:    jQuery.dataTable.classSettings 
            */
            this.iNextId = 0;

            /*
            * Variable: asDataSearch
            * Purpose:  Search data array for regular expression searching
            * Scope:    jQuery.dataTable.classSettings
            */
            this.asDataSearch = [];

            /*
            * Variable: oPreviousSearch
            * Purpose:  Store the previous search incase we want to force a re-search
            *   or compare the old search to a new one
            * Scope:    jQuery.dataTable.classSettings
            */
            this.oPreviousSearch = {
                "sSearch": "",
                "bEscapeRegex": true
            };

            /*
            * Variable: aoPreSearchCols
            * Purpose:  Store the previous search for each column
            * Scope:    jQuery.dataTable.classSettings
            */
            this.aoPreSearchCols = [];

            /*
            * Variable: aaSorting
            * Purpose:  Sorting information
            * Scope:    jQuery.dataTable.classSettings
            */
            this.aaSorting = [[0, 'asc']];

            /*
            * Variable: aaSortingFixed
            * Purpose:  Sorting information that is always applied
            * Scope:    jQuery.dataTable.classSettings
            */
            this.aaSortingFixed = null;

            /*
            * Variable: asStripClasses
            * Purpose:  Classes to use for the striping of a table
            * Scope:    jQuery.dataTable.classSettings
            */
            this.asStripClasses = [];

            /*
            * Variable: fnRowCallback
            * Purpose:  Call this function every time a row is inserted (draw)
            * Scope:    jQuery.dataTable.classSettings
            */
            this.fnRowCallback = null;

            /*
            * Variable: fnHeaderCallback
            * Purpose:  Callback function for the header on each draw
            * Scope:    jQuery.dataTable.classSettings
            */
            this.fnHeaderCallback = null;

            /*
            * Variable: fnFooterCallback
            * Purpose:  Callback function for the footer on each draw
            * Scope:    jQuery.dataTable.classSettings
            */
            this.fnFooterCallback = null;

            /*
            * Variable: fnDrawCallback
            * Purpose:  Callback function for the whole table on each draw
            * Scope:    jQuery.dataTable.classSettings
            */
            this.fnDrawCallback = null;

            /*
            * Variable: fnInitComplete
            * Purpose:  Callback function for when the table has been initalised
            * Scope:    jQuery.dataTable.classSettings
            */
            this.fnInitComplete = null;

            /*
            * Variable: sTableId
            * Purpose:  Cache the table ID for quick access
            * Scope:    jQuery.dataTable.classSettings
            */
            this.sTableId = "";

            /*
            * Variable: nTable
            * Purpose:  Cache the table node for quick access
            * Scope:    jQuery.dataTable.classSettings
            */
            this.nTable = null;

            /*
            * Variable: iDefaultSortIndex
            * Purpose:  Sorting index which will be used by default
            * Scope:    jQuery.dataTable.classSettings
            */
            this.iDefaultSortIndex = 0;

            /*
            * Variable: bInitialised
            * Purpose:  Indicate if all required information has been read in
            * Scope:    jQuery.dataTable.classSettings
            */
            this.bInitialised = false;

            /*
            * Variable: aoOpenRows
            * Purpose:  Information about open rows
            * Scope:    jQuery.dataTable.classSettings
            * Notes:    Has the parameters 'nTr' and 'nParent'
            */
            this.aoOpenRows = [];

            /*
            * Variable: sDomPositioning
            * Purpose:  Dictate the positioning that the created elements will take
            * Scope:    jQuery.dataTable.classSettings
            * Notes:    The following syntax is expected:
            *   'l' - Length changing
            *   'f' - Filtering input
            *   't' - The table!
            *   'i' - Information
            *   'p' - Pagination
            *   'r' - pRocessing
            *   '<' and '>' - div elements
            *   '<"class" and '>' - div with a class
            *    Examples: '<"wrapper"flipt>', '<lf<t>ip>'
            */
            this.sDomPositioning = 'lfrtip';

            /*
            * Variable: sPaginationType
            * Purpose:  Note which type of sorting should be used
            * Scope:    jQuery.dataTable.classSettings
            */
            this.sPaginationType = "two_button";

            /*
            * Variable: iCookieDuration
            * Purpose:  The cookie duration (for bStateSave) in seconds - default 2 hours
            * Scope:    jQuery.dataTable.classSettings
            */
            this.iCookieDuration = 60 * 60 * 2;

            /*
            * Variable: sAjaxSource
            * Purpose:  Source url for AJAX data for the table
            * Scope:    jQuery.dataTable.classSettings
            */
            this.sAjaxSource = null;

            /*
            * Variable: bAjaxDataGet
            * Purpose:  Note if draw should be blocked while getting data
            * Scope:    jQuery.dataTable.classSettings
            */
            this.bAjaxDataGet = true;

            /*
            * Variable: fnServerData
            * Purpose:  Function to get the server-side data - can be overruled by the developer
            * Scope:    jQuery.dataTable.classSettings
            */
            this.fnServerData = $.getJSON;

            /*
            * Variable: iServerDraw
            * Purpose:  Counter and tracker for server-side processing draws
            * Scope:    jQuery.dataTable.classSettings
            */
            this.iServerDraw = 0;

            /*
            * Variable: _iDisplayLength, _iDisplayStart, _iDisplayEnd
            * Purpose:  Display length variables
            * Scope:    jQuery.dataTable.classSettings
            * Notes:    These variable must NOT be used externally to get the data length. Rather, use
            *   the fnRecordsTotal() (etc) functions.
            */
            this._iDisplayLength = 10;
            this._iDisplayStart = 0;
            this._iDisplayEnd = 10;

            /*
            * Variable: _iRecordsTotal, _iRecordsDisplay
            * Purpose:  Display length variables used for server side processing
            * Scope:    jQuery.dataTable.classSettings
            * Notes:    These variable must NOT be used externally to get the data length. Rather, use
            *   the fnRecordsTotal() (etc) functions.
            */
            this._iRecordsTotal = 0;
            this._iRecordsDisplay = 0;

            /*
            * Variable: bJUI
            * Purpose:  Should we add the markup needed for jQuery UI theming?
            * Scope:    jQuery.dataTable.classSettings
            */
            this.bJUI = false;

            /*
            * Variable: bJUI
            * Purpose:  Should we add the markup needed for jQuery UI theming?
            * Scope:    jQuery.dataTable.classSettings
            */
            this.oClasses = _oExt.oStdClasses;
        }

        /*
        * Variable: oApi
        * Purpose:  Container for publicly exposed 'private' functions
        * Scope:    jQuery.dataTable
        */
        this.oApi = {};


        /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
        * API functions
        * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

        /*
        * Function: fnDraw
        * Purpose:  Redraw the table
        * Returns:  -
        * Inputs:   -
        */
        this.fnDraw = function() {
            _fnReDraw(_fnSettingsFromNode(this[_oExt.iApiIndex]));
        };

        /*
        * Function: fnFilter
        * Purpose:  Filter the input based on data
        * Returns:  -
        * Inputs:   string:sInput - string to filter the table on
        *           int:iColumn - optional - column to limit filtering to
        *           bool:bEscapeRegex - optional - escape regex characters or not - default true
        */
        this.fnFilter = function(sInput, iColumn, bEscapeRegex) {
            var oSettings = _fnSettingsFromNode(this[_oExt.iApiIndex]);

            if (typeof bEscapeRegex == 'undefined') {
                bEscapeRegex = true;
            }

            if (typeof iColumn == "undefined" || iColumn === null) {
                /* Global filter */
                _fnFilterComplete(oSettings, { "sSearch": sInput, "bEscapeRegex": bEscapeRegex }, 1);
            }
            else {
                /* Single column filter */
                oSettings.aoPreSearchCols[iColumn].sSearch = sInput;
                oSettings.aoPreSearchCols[iColumn].bEscapeRegex = bEscapeRegex;
                _fnFilterComplete(oSettings, oSettings.oPreviousSearch, 1);
            }
        };

        /*
        * Function: fnSettings
        * Purpose:  Get the settings for a particular table for extern. manipulation
        * Returns:  -
        * Inputs:   -
        */
        this.fnSettings = function(nNode) {
            return _fnSettingsFromNode(this[_oExt.iApiIndex]);
        };

        /*
        * Function: fnSort
        * Purpose:  Sort the table by a particular row
        * Returns:  -
        * Inputs:   int:iCol - the data index to sort on. Note that this will
        *   not match the 'display index' if you have hidden data entries
        */
        this.fnSort = function(aaSort) {
            var oSettings = _fnSettingsFromNode(this[_oExt.iApiIndex]);
            oSettings.aaSorting = aaSort;
            _fnSort(oSettings);
        };

        /*
        * Function: fnAddData
        * Purpose:  Add new row(s) into the table
        * Returns:  array int: array of indexes (aoData) which have been added (zero length on error)
        * Inputs:   array:mData - the data to be added. The length must match
        *               the original data from the DOM
        *             or
        *             array array:mData - 2D array of data to be added
        *           bool:bRedraw - redraw the table or not - default true
        * Notes:    Warning - the refilter here will cause the table to redraw
        *             starting at zero
        * Notes:    Thanks to Yekimov Denis for contributing the basis for this function!
        */
        this.fnAddData = function(mData, bRedraw) {
            var aiReturn = [];
            var iTest;
            if (typeof bRedraw == 'undefined') {
                bRedraw = true;
            }

            /* Find settings from table node */
            var oSettings = _fnSettingsFromNode(this[_oExt.iApiIndex]);

            /* Check if we want to add multiple rows or not */
            if (typeof mData[0] == "object") {
                for (var i = 0; i < mData.length; i++) {
                    iTest = _fnAddData(oSettings, mData[i]);
                    if (iTest == -1) {
                        return aiReturn;
                    }
                    aiReturn.push(iTest);
                }
            }
            else {
                iTest = _fnAddData(oSettings, mData);
                if (iTest == -1) {
                    return aiReturn;
                }
                aiReturn.push(iTest);
            }

            oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();

            /* Rebuild the search */
            _fnBuildSearchArray(oSettings, 1);

            if (bRedraw) {
                _fnReDraw(oSettings);
            }
            return aiReturn;
        };

        /*
        * Function: fnDeleteRow
        * Purpose:  Remove a row for the table
        * Returns:  array:aReturn - the row that was deleted
        * Inputs:   int:iIndex - index of aoData to be deleted
        *           function:fnCallBack - callback function - default null
        *           bool:bNullRow - remove the row information from aoData by setting the value to
        *             null - default false
        * Notes:    This function requires a little explanation - we don't actually delete the data
        *   from aoData - rather we remove it's references from aiDisplayMastr and aiDisplay. This
        *   in effect prevnts DataTables from drawing it (hence deleting it) - it could be restored
        *   if you really wanted. The reason for this is that actually removing the aoData object
        *   would mess up all the subsequent indexes in the display arrays (they could be ajusted - 
        *   but this appears to do what is required).
        */
        this.fnDeleteRow = function(iAODataIndex, fnCallBack, bNullRow) {
            /* Find settings from table node */
            var oSettings = _fnSettingsFromNode(this[_oExt.iApiIndex]);
            var i;

            /* Delete from the display master */
            for (i = 0; i < oSettings.aiDisplayMaster.length; i++) {
                if (oSettings.aiDisplayMaster[i] == iAODataIndex) {
                    oSettings.aiDisplayMaster.splice(i, 1);
                    break;
                }
            }

            /* Delete from the current display index */
            for (i = 0; i < oSettings.aiDisplay.length; i++) {
                if (oSettings.aiDisplay[i] == iAODataIndex) {
                    oSettings.aiDisplay.splice(i, 1);
                    break;
                }
            }

            /* Rebuild the search */
            _fnBuildSearchArray(oSettings, 1);

            /* If there is a user callback function - call it */
            if (typeof fnCallBack == "function") {
                fnCallBack.call(this);
            }

            /* Check for an 'overflow' they case for dislaying the table */
            if (oSettings._iDisplayStart >= oSettings.aiDisplay.length) {
                oSettings._iDisplayStart -= oSettings._iDisplayLength;
                if (oSettings._iDisplayStart < 0) {
                    oSettings._iDisplayStart = 0;
                }
            }

            _fnCalculateEnd(oSettings);
            _fnDraw(oSettings);

            /* Return the data array from this row */
            var aData = oSettings.aoData[iAODataIndex]._aData.slice();

            if (typeof bNullRow != "undefined" && bNullRow === true) {
                oSettings.aoData[iAODataIndex] = null;
            }

            return aData;
        };

        /*
        * Function: fnClearTable
        * Purpose:  Quickly and simply clear a table
        * Returns:  -
        * Inputs:   bool:bRedraw - redraw the table or not - default true
        * Notes:    Thanks to Yekimov Denis for contributing the basis for this function!
        */
        this.fnClearTable = function(bRedraw) {
            /* Find settings from table node */
            var oSettings = _fnSettingsFromNode(this[_oExt.iApiIndex]);
            _fnClearTable(oSettings);

            if (typeof bRedraw == 'undefined' || bRedraw) {
                _fnDraw(oSettings);
            }
        };

        /*
        * Function: fnOpen
        * Purpose:  Open a display row (append a row after the row in question)
        * Returns:  -
        * Inputs:   node:nTr - the table row to 'open'
        *           string:sHtml - the HTML to put into the row
        *           string:sClass - class to give the new cell
        */
        this.fnOpen = function(nTr, sHtml, sClass) {
            /* Find settings from table node */
            var oSettings = _fnSettingsFromNode(this[_oExt.iApiIndex]);

            /* the old open one if there is one */
            this.fnClose(nTr);


            var nNewRow = document.createElement("tr");
            var nNewCell = document.createElement("td");
            nNewRow.appendChild(nNewCell);
            nNewCell.className = sClass;
            nNewCell.colSpan = _fnVisbleColumns(oSettings);
            nNewCell.innerHTML = sHtml;

            $(nNewRow).insertAfter(nTr);

            /* No point in storing the row if using server-side processing since the nParent will be
            * nuked on a re-draw anyway
            */
            if (!oSettings.oFeatures.bServerSide) {
                oSettings.aoOpenRows.push({
                    "nTr": nNewRow,
                    "nParent": nTr
                });
            }
        };

        /*
        * Function: fnClose
        * Purpose:  Close a display row
        * Returns:  int: 0 (success) or 1 (failed)
        * Inputs:   node:nTr - the table row to 'close'
        */
        this.fnClose = function(nTr) {
            /* Find settings from table node */
            var oSettings = _fnSettingsFromNode(this[_oExt.iApiIndex]);

            for (var i = 0; i < oSettings.aoOpenRows.length; i++) {
                if (oSettings.aoOpenRows[i].nParent == nTr) {
                    var nTrParent = oSettings.aoOpenRows[i].nTr.parentNode;
                    if (nTrParent) {
                        /* Remove it if it is currently on display */
                        nTrParent.removeChild(oSettings.aoOpenRows[i].nTr);
                    }
                    oSettings.aoOpenRows.splice(i, 1);
                    return 0;
                }
            }
            return 1;
        };

        /*
        * Function: fnGetData
        * Purpose:  Return an array with the data which is used to make up the table
        * Returns:  array array string: 2d data array ([row][column]) or array string: 1d data array
        *           or
        *           array string (if iRow specified)
        * Inputs:   int:iRow - optional - if present then the array returned will be the data for
        *             the row with the index 'iRow'
        */
        this.fnGetData = function(iRow) {
            var oSettings = _fnSettingsFromNode(this[_oExt.iApiIndex]);

            if (typeof iRow != 'undefined') {
                return oSettings.aoData[iRow]._aData;
            }
            return _fnGetDataMaster(oSettings);
        };

        /*
        * Function: fnGetNodes
        * Purpose:  Return an array with the TR nodes used for drawing the table
        * Returns:  array node: TR elements
        *           or
        *           node (if iRow specified)
        * Inputs:   int:iRow - optional - if present then the array returned will be the node for
        *             the row with the index 'iRow'
        */
        this.fnGetNodes = function(iRow) {
            var oSettings = _fnSettingsFromNode(this[_oExt.iApiIndex]);

            if (typeof iRow != 'undefined') {
                return oSettings.aoData[iRow].nTr;
            }
            return _fnGetTrNodes(oSettings);
        };

        /*
        * Function: fnGetPosition
        * Purpose:  Get the array indexes of a particular cell from it's DOM element
        * Returns:  int: - row index, or array[ int, int ]: - row index and column index
        * Inputs:   node:nNode - this can either be a TR or a TD in the table, the return is
        *             dependent on this input
        */
        this.fnGetPosition = function(nNode) {
            var oSettings = _fnSettingsFromNode(this[_oExt.iApiIndex]);
            var i;

            if (nNode.nodeName == "TR") {
                for (i = 0; i < oSettings.aoData.length; i++) {
                    if (oSettings.aoData[i] !== null && oSettings.aoData[i].nTr == nNode) {
                        return i;
                    }
                }
            }
            else if (nNode.nodeName == "TD") {
                for (i = 0; i < oSettings.aoData.length; i++) {
                    var iCorrector = 0;
                    for (var j = 0; j < oSettings.aoColumns.length; j++) {
                        if (oSettings.aoColumns[j].bVisible) {
                            //$('>td', oSettings.aoData[i].nTr)[j-iCorrector] == nNode )
                            if (oSettings.aoData[i] !== null &&
								oSettings.aoData[i].nTr.getElementsByTagName('td')[j - iCorrector] == nNode) {
                                return [i, j - iCorrector, j];
                            }
                        }
                        else {
                            iCorrector++;
                        }
                    }
                }
            }
            return null;
        };

        /*
        * Function: fnUpdate
        * Purpose:  Update a table cell or row
        * Returns:  int: 0 okay, 1 error
        * Inputs:   array string 'or' string:mData - data to update the cell/row with
        *           int:iRow - the row (from aoData) to update
        *           int:iColumn - the column to update
        *           bool:bRedraw - redraw the table or not - default true
        */
        this.fnUpdate = function(mData, iRow, iColumn, bRedraw) {
            var oSettings = _fnSettingsFromNode(this[_oExt.iApiIndex]);
            var iVisibleColumn;
            var sDisplay;
            if (typeof bRedraw == 'undefined') {
                bRedraw = true;
            }

            if (typeof mData != 'object') {
                sDisplay = mData;
                oSettings.aoData[iRow]._aData[iColumn] = sDisplay;

                if (oSettings.aoColumns[iColumn].fnRender !== null) {
                    sDisplay = oSettings.aoColumns[iColumn].fnRender({
                        "iDataRow": iRow,
                        "iDataColumn": iColumn,
                        "aData": oSettings.aoData[iRow]._aData
                    });

                    if (oSettings.aoColumns[iColumn].bUseRendered) {
                        oSettings.aoData[iRow]._aData[iColumn] = sDisplay;
                    }
                }

                iVisibleColumn = _fnColumnIndexToVisible(oSettings, iColumn);
                if (iVisibleColumn !== null) {
                    oSettings.aoData[iRow].nTr.getElementsByTagName('td')[iVisibleColumn].innerHTML =
						sDisplay;
                }
            }
            else {
                if (mData.length != oSettings.aoColumns.length) {
                    //alert('Warning: An array passed to fnUpdate must have the same number of columns as ' +
					//	'the table in question - in this case ' + oSettings.aoColumns.length);
                    return 1;
                }

                for (var i = 0; i < mData.length; i++) {
                    sDisplay = mData[i];
                    oSettings.aoData[iRow]._aData[i] = sDisplay;

                    if (oSettings.aoColumns[i].fnRender !== null) {
                        sDisplay = oSettings.aoColumns[i].fnRender({
                            "iDataRow": iRow,
                            "iDataColumn": i,
                            "aData": oSettings.aoData[iRow]._aData
                        });

                        if (oSettings.aoColumns[i].bUseRendered) {
                            oSettings.aoData[iRow]._aData[i] = sDisplay;
                        }
                    }

                    iVisibleColumn = _fnColumnIndexToVisible(oSettings, i);
                    if (iVisibleColumn !== null) {
                        oSettings.aoData[iRow].nTr.getElementsByTagName('td')[iVisibleColumn].innerHTML =
							sDisplay;
                    }
                }
            }

            /* Update the search array */
            _fnBuildSearchArray(oSettings, 1);

            /* Redraw the table */
            if (bRedraw) {
                _fnReDraw(oSettings);
            }
            return 0;
        };


        /*
        * Function: fnShowColoumn
        * Purpose:  Show a particular column
        * Returns:  -
        * Inputs:   int:iCol - the column whose display should be changed
        *           bool:bShow - show (true) or hide (false) the column
        */
        this.fnSetColumnVis = function(iCol, bShow) {
            var oSettings = _fnSettingsFromNode(this[_oExt.iApiIndex]);
            var i, iLen;
            var iColumns = oSettings.aoColumns.length;
            var nTd;

            /* No point in doing anything if we are requesting what is already true */
            if (oSettings.aoColumns[iCol].bVisible == bShow) {
                return;
            }

            var nTrHead = $('thead tr', oSettings.nTable)[0];
            var nTrFoot = $('tfoot tr', oSettings.nTable)[0];
            var anTheadTh = [];
            var anTfootTh = [];
            for (i = 0; i < iColumns; i++) {
                anTheadTh.push(oSettings.aoColumns[i].nTh);
                anTfootTh.push(oSettings.aoColumns[i].nTf);
            }

            /* Show the column */
            if (bShow) {
                var iInsert = 0;
                for (i = 0; i < iCol; i++) {
                    if (oSettings.aoColumns[i].bVisible) {
                        iInsert++;
                    }
                }

                /* Need to decide if we should use appendChild or insertBefore */
                if (iInsert >= _fnVisbleColumns(oSettings)) {
                    nTrHead.appendChild(anTheadTh[iCol]);
                    if (nTrFoot) {
                        nTrFoot.appendChild(anTfootTh[iCol]);
                    }

                    for (i = 0, iLen = oSettings.aoData.length; i < iLen; i++) {
                        nTd = oSettings.aoData[i]._anHidden[iCol];
                        oSettings.aoData[i].nTr.appendChild(nTd);
                    }
                }
                else {
                    /* Which coloumn should we be inserting before? */
                    var iBefore;
                    for (i = iCol; i < iColumns; i++) {
                        iBefore = _fnColumnIndexToVisible(oSettings, i);
                        if (iBefore !== null) {
                            break;
                        }
                    }

                    nTrHead.insertBefore(anTheadTh[iCol], nTrHead.getElementsByTagName('th')[iBefore]);
                    if (nTrFoot) {
                        nTrFoot.insertBefore(anTfootTh[iCol], nTrFoot.getElementsByTagName('th')[iBefore]);
                    }

                    for (i = 0, iLen = oSettings.aoData.length; i < iLen; i++) {
                        nTd = oSettings.aoData[i]._anHidden[iCol];
                        oSettings.aoData[i].nTr.insertBefore(nTd, oSettings.aoData[i].nTr.getElementsByTagName('td')[iBefore]);
                    }
                }

                oSettings.aoColumns[iCol].bVisible = true;
            }
            else {
                /* Remove a column from display */
                nTrHead.removeChild(anTheadTh[iCol]);
                if (nTrFoot) {
                    nTrFoot.removeChild(anTfootTh[iCol]);
                }

                var iVisCol = _fnColumnIndexToVisible(oSettings, iCol);
                for (i = 0, iLen = oSettings.aoData.length; i < iLen; i++) {
                    nTd = oSettings.aoData[i].nTr.getElementsByTagName('td')[iVisCol];
                    oSettings.aoData[i]._anHidden[iCol] = nTd;
                    nTd.parentNode.removeChild(nTd);
                }

                oSettings.aoColumns[iCol].bVisible = false;
            }

            /* If there are any 'open' rows, then we need to alter the colspan for this col change */
            for (i = 0, iLen = oSettings.aoOpenRows.length; i < iLen; i++) {
                oSettings.aoOpenRows[i].nTr.colSpan = _fnVisbleColumns(oSettings);
            }

            /* Since there is no redraw done here, we need to save the state manually */
            _fnSaveState(oSettings);
        };


        /*
        * Plugin API functions
        * 
        * This call will add the functions which are defined in _oExt.oApi to the
        * DataTables object, providing a rather nice way to allow plug-in API functions. Note that
        * this is done here, so that API function can actually override the built in API functions if
        * required for a particular purpose.
        */

        /*
        * Function: _fnExternApiFunc
        * Purpose:  Create a wrapper function for exporting an internal func to an external API func
        * Returns:  function: - wrapped function
        * Inputs:   string:sFunc - API function name
        */
        function _fnExternApiFunc(sFunc) {
            return function() {
                var aArgs = [_fnSettingsFromNode(this[_oExt.iApiIndex])].concat(
						Array.prototype.slice.call(arguments));
                return _oExt.oApi[sFunc].apply(this, aArgs);
            };
        }

        for (var sFunc in _oExt.oApi) {
            if (sFunc) {
                /*
                * Function: anon
                * Purpose:  Wrap the plug-in API functions in order to provide the settings as 1st arg 
                *   and execute in this scope
                * Returns:  -
                * Inputs:   -
                */
                this[sFunc] = _fnExternApiFunc(sFunc);
            }
        }



        /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
        * Local functions
        * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

        /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
        * Initalisation
        */

        /*
        * Function: _fnInitalise
        * Purpose:  Draw the table for the first time, adding all required features
        * Returns:  -
        * Inputs:   object:oSettings - dataTables settings object
        */
        function _fnInitalise(oSettings) {
            /* Ensure that the table data is fully initialised */
            if (oSettings.bInitialised === false) {
                setTimeout(function() { _fnInitalise(oSettings); }, 200);
                return;
            }

            /* Show the display HTML options */
            _fnAddOptionsHtml(oSettings);

            /* Draw the headers for the table */
            _fnDrawHead(oSettings);

            /* If there is default sorting required - let's do it. The sort function
            * will do the drawing for us. Otherwise we draw the table
            */
            if (oSettings.oFeatures.bSort) {
                _fnSort(oSettings, false);
                /*
                * Add the sorting classes to the header and the body (if needed).
                * Reason for doing it here after the first draw is to stop classes being applied to the
                * 'static' table.
                */
                _fnSortingClasses(oSettings);
            }
            else {
                oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
                _fnCalculateEnd(oSettings);
                _fnDraw(oSettings);
            }

            /* if there is an ajax source */
            if (oSettings.sAjaxSource !== null && !oSettings.oFeatures.bServerSide) {
                _fnProcessingDisplay(oSettings, true);

                $.getJSON(oSettings.sAjaxSource, null, function(json) {

                    /* Got the data - add it to the table */
                    for (var i = 0; i < json.aaData.length; i++) {
                        _fnAddData(oSettings, json.aaData[i]);
                    }

                    /* Reset the init display for cookie saving. We've already done a filter, and
                    * therefore cleared it before. So we need to make it appear 'fresh'
                    */
                    oSettings.iInitDisplayStart = oSettings._iDisplayStart;

                    if (oSettings.oFeatures.bSort) {
                        _fnSort(oSettings);
                    }
                    else {
                        oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
                        _fnCalculateEnd(oSettings);
                        _fnDraw(oSettings);
                    }
                    _fnProcessingDisplay(oSettings, false);

                    /* Run the init callback if there is one */
                    if (typeof oSettings.fnInitComplete == 'function') {
                        oSettings.fnInitComplete(oSettings, json);
                    }
                });
                return;
            }

            /* Run the init callback if there is one */
            if (typeof oSettings.fnInitComplete == 'function') {
                oSettings.fnInitComplete(oSettings);
            }
            _fnProcessingDisplay(oSettings, false);
        }

        /*
        * Function: _fnLanguageProcess
        * Purpose:  Copy language variables from remote object to a local one
        * Returns:  -
        * Inputs:   object:oSettings - dataTables settings object
        *           object:oLanguage - Language information
        *           bool:bInit - init once complete
        */
        function _fnLanguageProcess(oSettings, oLanguage, bInit) {
            _fnMap(oSettings.oLanguage, oLanguage, 'sProcessing');
            _fnMap(oSettings.oLanguage, oLanguage, 'sLengthMenu');
            _fnMap(oSettings.oLanguage, oLanguage, 'sZeroRecords');
            _fnMap(oSettings.oLanguage, oLanguage, 'sInfo');
            _fnMap(oSettings.oLanguage, oLanguage, 'sInfoEmpty');
            _fnMap(oSettings.oLanguage, oLanguage, 'sInfoFiltered');
            _fnMap(oSettings.oLanguage, oLanguage, 'sInfoPostFix');
            _fnMap(oSettings.oLanguage, oLanguage, 'sSearch');

            if (typeof oLanguage.oPaginate != 'undefined') {
                _fnMap(oSettings.oLanguage.oPaginate, oLanguage.oPaginate, 'sFirst');
                _fnMap(oSettings.oLanguage.oPaginate, oLanguage.oPaginate, 'sPrevious');
                _fnMap(oSettings.oLanguage.oPaginate, oLanguage.oPaginate, 'sNext');
                _fnMap(oSettings.oLanguage.oPaginate, oLanguage.oPaginate, 'sLast');
            }

            if (bInit) {
                _fnInitalise(oSettings);
            }
        }

        /*
        * Function: _fnAddColumn
        * Purpose:  Add a column to the list used for the table
        * Returns:  -
        * Inputs:   object:oSettings - dataTables settings object
        *           object:oOptions - object with sType, bVisible and bSearchable
        *           node:nTh - the th element for this column
        * Notes:    All options in enter column can be over-ridden by the user
        *   initialisation of dataTables
        */
        function _fnAddColumn(oSettings, oOptions, nTh) {
            oSettings.aoColumns[oSettings.aoColumns.length++] = {
                "sType": null,
                "_bAutoType": true,
                "bVisible": true,
                "bSearchable": true,
                "bSortable": true,
                "sTitle": nTh ? nTh.innerHTML : '',
                "sName": '',
                "sWidth": null,
                "sClass": null,
                "fnRender": null,
                "bUseRendered": true,
                "iDataSort": oSettings.aoColumns.length - 1,
                "nTh": nTh ? nTh : document.createElement('th'),
                "nTf": null
            };

            /* User specified column options */
            var iLength = oSettings.aoColumns.length - 1;
            if (typeof oOptions != 'undefined' && oOptions !== null) {
                var oCol = oSettings.aoColumns[iLength];

                if (typeof oOptions.sType != 'undefined') {
                    oCol.sType = oOptions.sType;
                    oCol._bAutoType = false;
                }

                _fnMap(oCol, oOptions, "bVisible");
                _fnMap(oCol, oOptions, "bSearchable");
                _fnMap(oCol, oOptions, "bSortable");
                _fnMap(oCol, oOptions, "sTitle");
                _fnMap(oCol, oOptions, "sName");
                _fnMap(oCol, oOptions, "sWidth");
                _fnMap(oCol, oOptions, "sClass");
                _fnMap(oCol, oOptions, "fnRender");
                _fnMap(oCol, oOptions, "bUseRendered");
                _fnMap(oCol, oOptions, "iDataSort");
            }

            /* Add a column specific filter */
            if (typeof oSettings.aoPreSearchCols[iLength] == 'undefined' ||
			     oSettings.aoPreSearchCols[iLength] === null) {
                oSettings.aoPreSearchCols[iLength] = {
                    "sSearch": "",
                    "bEscapeRegex": true
                };
            }
            else if (typeof oSettings.aoPreSearchCols[iLength].bEscapeRegex == 'undefined') {
                /* Don't require that the user must specify bEscapeRegex */
                oSettings.aoPreSearchCols[iLength].bEscapeRegex = true;
            }
        }

        /*
        * Function: _fnAddData
        * Purpose:  Add a data array to the table, creating DOM node etc
        * Returns:  int: - >=0 if successful (index of new aoData entry), -1 if failed
        * Inputs:   object:oSettings - dataTables settings object
        *           array:aData - data array to be added
        */
        function _fnAddData(oSettings, aData) {
            /* Sanity check the length of the new array */
            if (aData.length != oSettings.aoColumns.length) {
                //alert("Warning - added data does not match known number of columns");
                return -1;
            }

            /* Create the object for storing information about this new row */
            var iThisIndex = oSettings.aoData.length;
            oSettings.aoData.push({
                "_iId": oSettings.iNextId++,
                "_aData": aData.slice(),
                "nTr": document.createElement('tr'),
                "_anHidden": []
            });

            /* Create the cells */
            var nTd;
            for (var i = 0; i < aData.length; i++) {
                nTd = document.createElement('td');

                if (typeof oSettings.aoColumns[i].fnRender == 'function') {
                    var sRendered = oSettings.aoColumns[i].fnRender({
                        "iDataRow": iThisIndex,
                        "iDataColumn": i,
                        "aData": aData
                    });
                    nTd.innerHTML = sRendered;
                    if (oSettings.aoColumns[i].bUseRendered) {
                        /* Use the rendered data for filtering/sorting */
                        oSettings.aoData[iThisIndex]._aData[i] = sRendered;
                    }
                }
                else {
                    nTd.innerHTML = aData[i];
                }

                if (oSettings.aoColumns[i].sClass !== null) {
                    nTd.className = oSettings.aoColumns[i].sClass;
                }

                /* See if we should auto-detect the column type */
                if (oSettings.aoColumns[i]._bAutoType && oSettings.aoColumns[i].sType != 'string') {
                    /* Attempt to auto detect the type - same as _fnGatherData() */
                    if (oSettings.aoColumns[i].sType === null) {
                        oSettings.aoColumns[i].sType = _fnDetectType(aData[i]);
                    }
                    else if (oSettings.aoColumns[i].sType == "date" ||
					          oSettings.aoColumns[i].sType == "numeric") {
                        oSettings.aoColumns[i].sType = _fnDetectType(aData[i]);
                    }
                }

                if (oSettings.aoColumns[i].bVisible) {
                    oSettings.aoData[iThisIndex].nTr.appendChild(nTd);
                }
                else {
                    oSettings.aoData[iThisIndex]._anHidden[i] = nTd;
                }
            }

            /* Add to the display array */
            oSettings.aiDisplayMaster.push(iThisIndex);
            return iThisIndex;
        }

        /*
        * Function: _fnGatherData
        * Purpose:  Read in the data from the target table
        * Returns:  -
        * Inputs:   object:oSettings - dataTables settings object
        */
        function _fnGatherData(oSettings) {
            var iLoop;
            var i, j;

            /*
            * Process by row first
            * Add the data object for the whole table - storing the tr node. Note - no point in getting
            * DOM based data if we are going to go and replace it with Ajax source data.
            */
            if (oSettings.sAjaxSource === null) {
                $('tbody:eq(0)>tr', oSettings.nTable).each(function() {
                    var iThisIndex = oSettings.aoData.length;
                    oSettings.aoData.push({
                        "_iId": oSettings.iNextId++,
                        "_aData": [],
                        "nTr": this,
                        "_anHidden": []
                    });

                    oSettings.aiDisplayMaster.push(iThisIndex);

                    /* Add the data for this column */
                    var aLocalData = oSettings.aoData[iThisIndex]._aData;
                    $('td', this).each(function(i) {
                        aLocalData[i] = this.innerHTML;
                    });
                });
            }

            /*
            * Now process by column
            */
            var iCorrector = 0;
            for (i = 0; i < oSettings.aoColumns.length; i++) {
                /* Get the title of the column - unless there is a user set one */
                if (oSettings.aoColumns[i].sTitle === null) {
                    oSettings.aoColumns[i].sTitle = oSettings.aoColumns[i].nTh.innerHTML;
                }

                var bAutoType = oSettings.aoColumns[i]._bAutoType;
                var bRender = typeof oSettings.aoColumns[i].fnRender == 'function';
                var bClass = oSettings.aoColumns[i].sClass !== null;
                var bVisible = oSettings.aoColumns[i].bVisible;

                /* A single loop to rule them all (and be more efficient) */
                if (bAutoType || bRender || bClass || !bVisible) {
                    iLoop = oSettings.aoData.length;
                    for (j = 0; j < iLoop; j++) {
                        var nCellNode = oSettings.aoData[j].nTr.getElementsByTagName('td')[i - iCorrector];

                        if (bAutoType) {
                            if (oSettings.aoColumns[i].sType === null) {
                                oSettings.aoColumns[i].sType = _fnDetectType(oSettings.aoData[j]._aData[i]);
                            }
                            else if (oSettings.aoColumns[i].sType == "date" ||
							          oSettings.aoColumns[i].sType == "numeric") {
                                /* If type is date or numeric - ensure that all collected data
                                * in the column is of the same type
                                */
                                oSettings.aoColumns[i].sType = _fnDetectType(oSettings.aoData[j]._aData[i]);
                            }
                            /* The else would be 'type = string' we don't want to do anything
                            * if that is the case
                            */
                        }

                        if (bRender) {
                            var sRendered = oSettings.aoColumns[i].fnRender({
                                "iDataRow": j,
                                "iDataColumn": i,
                                "aData": oSettings.aoData[j]._aData
                            });
                            nCellNode.innerHTML = sRendered;
                            if (oSettings.aoColumns[i].bUseRendered) {
                                /* Use the rendered data for filtering/sorting */
                                oSettings.aoData[j]._aData[i] = sRendered;
                            }
                        }

                        if (bClass) {
                            nCellNode.className += ' ' + oSettings.aoColumns[i].sClass;
                        }

                        if (!bVisible) {
                            oSettings.aoData[j]._anHidden[i] = nCellNode;
                            nCellNode.parentNode.removeChild(nCellNode);
                        }
                    }

                    /* Keep an index corrector for the next loop */
                    if (!bVisible) {
                        iCorrector++;
                    }
                }
            }
        }



        /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
        * Drawing functions
        */

        /*
        * Function: _fnDrawHead
        * Purpose:  Create the HTML header for the table
        * Returns:  -
        * Inputs:   object:oSettings - dataTables settings object
        */
        function _fnDrawHead(oSettings) {
            var i, nTh, iLen;
            var iThs = oSettings.nTable.getElementsByTagName('thead')[0].getElementsByTagName('th').length;
            var iCorrector = 0;

            /* If there is a header in place - then use it - otherwise it's going to get nuked... */
            if (iThs !== 0) {
                /* We've got a thead from the DOM, so remove hidden columns and apply width to vis cols */
                for (i = 0, iLen = oSettings.aoColumns.length; i < iLen; i++) {
                    //oSettings.aoColumns[i].nTh = nThs[i];
                    nTh = oSettings.aoColumns[i].nTh;

                    if (oSettings.aoColumns[i].bVisible) {
                        /* Set width */
                        if (oSettings.aoColumns[i].sWidth !== null) {
                            nTh.style.width = oSettings.aoColumns[i].sWidth;
                        }

                        /* Set the title of the column if it is user defined (not what was auto detected) */
                        if (oSettings.aoColumns[i].sTitle != nTh.innerHTML) {
                            nTh.innerHTML = oSettings.aoColumns[i].sTitle;
                        }
                    }
                    else {
                        nTh.parentNode.removeChild(nTh);
                        iCorrector++;
                    }
                }
            }
            else {
                /* We don't have a header in the DOM - so we are going to have to create one */
                var nTr = document.createElement("tr");

                for (i = 0, iLen = oSettings.aoColumns.length; i < iLen; i++) {
                    if (oSettings.aoColumns[i].bVisible) {
                        nTh = oSettings.aoColumns[i].nTh;

                        if (oSettings.aoColumns[i].sClass !== null) {
                            nTh.className = oSettings.aoColumns[i].sClass;
                        }

                        if (oSettings.aoColumns[i].sWidth !== null) {
                            nTh.style.width = oSettings.aoColumns[i].sWidth;
                        }

                        nTh.innerHTML = oSettings.aoColumns[i].sTitle;
                        nTr.appendChild(nTh);
                    }
                }
                $('thead', oSettings.nTable).html('')[0].appendChild(nTr);
            }

            /* Add the extra markup needed by jQuery UI's themes */
            if (oSettings.bJUI) {
                for (i = 0, iLen = oSettings.aoColumns.length; i < iLen; i++) {
                    var nSpan = document.createElement('span');
                    oSettings.aoColumns[i].nTh.appendChild(nSpan);
                }
            }

            /* Add sort listener */
            if (oSettings.oFeatures.bSort) {
                for (i = 0; i < oSettings.aoColumns.length; i++) {
                    if (oSettings.aoColumns[i].bSortable === false) {
                        continue;
                    }

                    $(oSettings.aoColumns[i].nTh).click(function(e) {
                        var iDataIndex;
                        /* Find which column we are sorting on - can't use index() due to colspan etc */
                        for (var i = 0; i < oSettings.aoColumns.length; i++) {
                            if (oSettings.aoColumns[i].nTh == this) {
                                iDataIndex = i;
                                break;
                            }
                        }

                        /* If the column is not sortable - don't to anything */
                        if (oSettings.aoColumns[iDataIndex].bSortable === false) {
                            return;
                        }

                        /*
                        * This is a little bit odd I admit... I declare a temporary function inside the scope of
                        * _fnDrawHead and the click handler in order that the code presented here can be used 
                        * twice - once for when bProcessing is enabled, and another time for when it is 
                        * disabled, as we need to perform slightly different actions.
                        *   Basically the issue here is that the Javascript engine in modern browsers don't 
                        * appear to allow the rendering engine to update the display while it is still excuting
                        * it's thread (well - it does but only after long intervals). This means that the 
                        * 'processing' display doesn't appear for a table sort. To break the js thread up a bit
                        * I force an execution break by using setTimeout - but this breaks the expected 
                        * thread continuation for the end-developer's point of view (their code would execute
                        * too early), so we on;y do it when we absolutely have to.
                        */
                        var fnInnerSorting = function() {
                            if (e.shiftKey) {
                                /* If the shift key is pressed then we are multipe column sorting */
                                var bFound = false;
                                for (var i = 0; i < oSettings.aaSorting.length; i++) {
                                    if (oSettings.aaSorting[i][0] == iDataIndex) {
                                        if (oSettings.aaSorting[i][1] == "asc") {
                                            oSettings.aaSorting[i][1] = "desc";
                                        }
                                        else {
                                            oSettings.aaSorting.splice(i, 1);
                                        }
                                        bFound = true;
                                        break;
                                    }
                                }

                                if (bFound === false) {
                                    oSettings.aaSorting.push([iDataIndex, "asc"]);
                                }
                            }
                            else {
                                /* If no shift key then single column sort */
                                if (oSettings.aaSorting.length == 1 && oSettings.aaSorting[0][0] == iDataIndex) {
                                    oSettings.aaSorting[0][1] = oSettings.aaSorting[0][1] == "asc" ? "desc" : "asc";
                                }
                                else {
                                    oSettings.aaSorting.splice(0, oSettings.aaSorting.length);
                                    oSettings.aaSorting.push([iDataIndex, "asc"]);
                                }
                            }

                            /* Run the sort */
                            _fnSort(oSettings);
                        }; /* /fnInnerSorting */

                        if (!oSettings.oFeatures.bProcessing) {
                            fnInnerSorting();
                        }
                        else {
                            _fnProcessingDisplay(oSettings, true);
                            setTimeout(function() {
                                fnInnerSorting();
                                if (!oSettings.oFeatures.bServerSide) {
                                    _fnProcessingDisplay(oSettings, false);
                                }
                            }, 0);
                        }
                    }); /* /click */
                } /* For each column */

                /* Take the brutal approach to cancelling text selection due to the shift key */
                $('thead th', oSettings.nTable).mousedown(function(e) {
                    if (e.shiftKey) {
                        this.onselectstart = function() { return false; };
                        return false;
                    }
                });
            } /* /if feature sort */

            /* Set an absolute width for the table such that pagination doesn't
            * cause the table to resize
            */
            if (oSettings.oFeatures.bAutoWidth) {
                oSettings.nTable.style.width = oSettings.nTable.offsetWidth + "px";
            }

            /* Cache the footer elements */
            var nTfoot = oSettings.nTable.getElementsByTagName('tfoot');
            if (nTfoot.length !== 0) {
                iCorrector = 0;
                var nTfs = nTfoot[0].getElementsByTagName('th');
                for (i = 0, iLen = nTfs.length; i < iLen; i++) {
                    oSettings.aoColumns[i].nTf = nTfs[i - iCorrector];
                    if (!oSettings.aoColumns[i].bVisible) {
                        nTfs[i - iCorrector].parentNode.removeChild(nTfs[i - iCorrector]);
                        iCorrector++;
                    }
                }
            }
        }

        /*
        * Function: _fnDraw
        * Purpose:  Insert the required TR nodes into the table for display
        * Returns:  -
        * Inputs:   object:oSettings - dataTables settings object
        */
        function _fnDraw(oSettings) {
            var i;
            var anRows = [];
            var iRowCount = 0;
            var bRowError = false;
            var iStrips = oSettings.asStripClasses.length;
            var iOpenRows = oSettings.aoOpenRows.length;

            /* If we are dealing with Ajax - do it here */
            if (oSettings.oFeatures.bServerSide &&
			     !_fnAjaxUpdate(oSettings)) {
                return;
            }

            if (oSettings.aiDisplay.length !== 0) {
                var iStart = oSettings._iDisplayStart;
                var iEnd = oSettings._iDisplayEnd;

                if (oSettings.oFeatures.bServerSide) {
                    iStart = 0;
                    iEnd = oSettings.aoData.length;
                }

                for (var j = iStart; j < iEnd; j++) {
                    var nRow = oSettings.aoData[oSettings.aiDisplay[j]].nTr;

                    /* Remove any old stripping classes and then add the new one */
                    if (iStrips !== 0) {
                        $(nRow).removeClass(oSettings.asStripClasses.join(' '));
                        $(nRow).addClass(oSettings.asStripClasses[iRowCount % iStrips]);
                    }

                    /* Custom row callback function - might want to manipule the row */
                    if (typeof oSettings.fnRowCallback == "function") {
                        nRow = oSettings.fnRowCallback(nRow,
							oSettings.aoData[oSettings.aiDisplay[j]]._aData, iRowCount, j);
                        if (!nRow && !bRowError) {
                            //alert("Error: A node was not returned by fnRowCallback");
                            bRowError = true;
                        }
                    }

                    anRows.push(nRow);
                    iRowCount++;

                    /* If there is an open row - and it is attached to this parent - attach it on redraw */
                    if (iOpenRows !== 0) {
                        for (var k = 0; k < iOpenRows; k++) {
                            if (nRow == oSettings.aoOpenRows[k].nParent) {
                                anRows.push(oSettings.aoOpenRows[k].nTr);
                            }
                        }
                    }
                }
            }
            else {
                /* Table is empty - create a row with an empty message in it */
                anRows[0] = document.createElement('tr');

                if (typeof oSettings.asStripClasses[0] != 'undefined') {
                    anRows[0].className = oSettings.asStripClasses[0];
                }

                var nTd = document.createElement('td');
                nTd.setAttribute('valign', "top");
                nTd.colSpan = oSettings.aoColumns.length;
                nTd.className = oSettings.oClasses.sRowEmpty;
                //nTd.innerHTML = oSettings.oLanguage.sZeroRecords;

                anRows[iRowCount].appendChild(nTd);
            }

            /* Callback the header and footer custom funcation if there is one */
            if (typeof oSettings.fnHeaderCallback == 'function') {
                oSettings.fnHeaderCallback($('thead tr', oSettings.nTable)[0],
					_fnGetDataMaster(oSettings), oSettings._iDisplayStart, oSettings.fnDisplayEnd(),
					oSettings.aiDisplay);
            }

            if (typeof oSettings.fnFooterCallback == 'function') {
                oSettings.fnFooterCallback($('tfoot tr', oSettings.nTable)[0],
					_fnGetDataMaster(oSettings), oSettings._iDisplayStart, oSettings.fnDisplayEnd(),
					oSettings.aiDisplay);
            }

            /* 
            * Need to remove any old row from the display - note we can't just empty the tbody using
            * .html('') since this will unbind the jQuery event handlers (even although the node still
            * exists!) - note the initially odd ':eq(0)>tr' expression. This basically ensures that we
            * only get tr elements of the tbody that the data table has been initialised on. If there
            * are nested tables then we don't want to remove those elements.
            */
            var nTrs = $('tbody:eq(0)>tr', oSettings.nTable);
            for (i = 0; i < nTrs.length; i++) {
                nTrs[i].parentNode.removeChild(nTrs[i]);
            }

            /* Put the draw table into the dom */
            var nBody = $('tbody:eq(0)', oSettings.nTable);
            if (nBody[0]) {
                for (i = 0; i < anRows.length; i++) {
                    nBody[0].appendChild(anRows[i]);
                }
            }

            /* Update the pagination display buttons */
            if (oSettings.oFeatures.bPaginate) {
                _oExt.oPagination[oSettings.sPaginationType].fnUpdate(oSettings, function(oSettings) {
                    _fnCalculateEnd(oSettings);
                    _fnDraw(oSettings);
                });
            }

            /* Show information about the table */
            if (oSettings.oFeatures.bInfo && oSettings.anFeatures.i) {
                /* Update the information */
                if (oSettings.fnRecordsDisplay() === 0 &&
					   oSettings.fnRecordsDisplay() == oSettings.fnRecordsTotal()) {
                    oSettings.anFeatures.i.innerHTML =
						oSettings.oLanguage.sInfoEmpty + oSettings.oLanguage.sInfoPostFix;
                }
                else if (oSettings.fnRecordsDisplay() === 0) {
                    oSettings.anFeatures.i.innerHTML = oSettings.oLanguage.sInfoEmpty + ' ' +
						oSettings.oLanguage.sInfoFiltered.replace('_MAX_',
							oSettings.fnRecordsTotal()) + oSettings.oLanguage.sInfoPostFix;
                }
                else if (oSettings.fnRecordsDisplay() == oSettings.fnRecordsTotal()) {
                    oSettings.anFeatures.i.innerHTML =
						oSettings.oLanguage.sInfo.
							replace('_START_', oSettings._iDisplayStart + 1).
							replace('_END_', oSettings.fnDisplayEnd()).
							replace('_TOTAL_', oSettings.fnRecordsDisplay()) +
						oSettings.oLanguage.sInfoPostFix;
                }
                else {
                    oSettings.anFeatures.i.innerHTML =
						oSettings.oLanguage.sInfo.
							replace('_START_', oSettings._iDisplayStart + 1).
							replace('_END_', oSettings.fnDisplayEnd()).
							replace('_TOTAL_', oSettings.fnRecordsDisplay()) + ' ' +
						oSettings.oLanguage.sInfoFiltered.replace('_MAX_', oSettings.fnRecordsTotal()) +
						oSettings.oLanguage.sInfoPostFix;
                }
            }

            /* Alter the sorting classes to take account of the changes */
            if (oSettings.oFeatures.bServerSide && oSettings.oFeatures.bSort) {
                _fnSortingClasses(oSettings);
            }

            /* Save the table state on each draw */
            _fnSaveState(oSettings);

            /* Drawing is finished - call the callback if there is one */
            if (typeof oSettings.fnDrawCallback == 'function') {
                oSettings.fnDrawCallback(oSettings);
            }
        }

        /*
        * Function: _fnReDraw
        * Purpose:  Redraw the table - taking account of the various features which are enabled
        * Returns:  -
        * Inputs:   object:oSettings - dataTables settings object
        */
        function _fnReDraw(oSettings) {
            if (oSettings.oFeatures.bSort) {
                /* Sorting will refilter and draw for us */
                _fnSort(oSettings, oSettings.oPreviousSearch);
            }
            else if (oSettings.oFeatures.bFilter) {
                /* Filtering will redraw for us */
                _fnFilterComplete(oSettings, oSettings.oPreviousSearch);
            }
            else {
                _fnCalculateEnd(oSettings);
                _fnDraw(oSettings);
            }
        }

        /*
        * Function: _fnAjaxUpdate
        * Purpose:  Update the table using an Ajax call
        * Returns:  bool: block the table drawing or not
        * Inputs:   object:oSettings - dataTables settings object
        */
        function _fnAjaxUpdate(oSettings) {
            if (oSettings.bAjaxDataGet) {
                _fnProcessingDisplay(oSettings, true);
                var iColumns = oSettings.aoColumns.length;
                var aoData = [];
                var i;

                /* Paging and general */
                oSettings.iServerDraw++;
                aoData.push({ "name": "sEcho", "value": oSettings.iServerDraw });
                aoData.push({ "name": "iColumns", "value": iColumns });
                aoData.push({ "name": "sColumns", "value": _fnColumnOrdering(oSettings) });
                aoData.push({ "name": "iDisplayStart", "value": oSettings._iDisplayStart });
                aoData.push({ "name": "iDisplayLength", "value": oSettings.oFeatures.bPaginate !== false ?
					oSettings._iDisplayLength : -1
                });

                /* Filtering */
                if (oSettings.oFeatures.bFilter !== false) {
                    aoData.push({ "name": "sSearch", "value": oSettings.oPreviousSearch.sSearch });
                    aoData.push({ "name": "bEscapeRegex", "value": oSettings.oPreviousSearch.bEscapeRegex });
                    for (i = 0; i < iColumns; i++) {
                        aoData.push({ "name": "sSearch_" + i, "value": oSettings.aoPreSearchCols[i].sSearch });
                        aoData.push({ "name": "bEscapeRegex_" + i, "value": oSettings.aoPreSearchCols[i].bEscapeRegex });
                    }
                }

                /* Sorting */
                if (oSettings.oFeatures.bSort !== false) {
                    var iFixed = oSettings.aaSortingFixed !== null ? oSettings.aaSortingFixed.length : 0;
                    var iUser = oSettings.aaSorting.length;
                    aoData.push({ "name": "iSortingCols", "value": iFixed + iUser });
                    for (i = 0; i < iFixed; i++) {
                        aoData.push({ "name": "iSortCol_" + i, "value": oSettings.aaSortingFixed[i][0] });
                        aoData.push({ "name": "iSortDir_" + i, "value": oSettings.aaSortingFixed[i][1] });
                    }

                    for (i = 0; i < iUser; i++) {
                        aoData.push({ "name": "iSortCol_" + (i + iFixed), "value": oSettings.aaSorting[i][0] });
                        aoData.push({ "name": "iSortDir_" + (i + iFixed), "value": oSettings.aaSorting[i][1] });
                    }
                }

                oSettings.fnServerData(oSettings.sAjaxSource, aoData, function(json) {
                    _fnAjaxUpdateDraw(oSettings, json);
                });
                return false;
            }
            else {
                return true;
            }
        }

        /*
        * Function: _fnAjaxUpdateDraw
        * Purpose:  Data the data from the server (nuking the old) and redraw the table
        * Returns:  -
        * Inputs:   object:oSettings - dataTables settings object
        *           object:json - json data return from the server.
        *             The following must be defined:
        *               iTotalRecords, iTotalDisplayRecords, aaData
        *             The following may be defined:
        *               sColumns
        */
        function _fnAjaxUpdateDraw(oSettings, json) {
            if (typeof json.sEcho != 'undefined') {
                /* Protect against old returns over-writing a new one. Possible when you get
                * very fast interaction, and later queires are completed much faster
                */
                if (json.sEcho * 1 < oSettings.iServerDraw) {
                    return;
                }
                else {
                    oSettings.iServerDraw = json.sEcho * 1;
                }
            }

            _fnClearTable(oSettings);
            oSettings._iRecordsTotal = json.iTotalRecords;
            oSettings._iRecordsDisplay = json.iTotalDisplayRecords;

            /* Determine if reordering is required */
            var sOrdering = _fnColumnOrdering(oSettings);
            var bReOrder = (json.sColumns != 'undefined' && sOrdering !== "" && json.sColumns != sOrdering);
            if (bReOrder) {
                var aiIndex = _fnReOrderIndex(oSettings, json.sColumns);
            }

            for (var i = 0, iLen = json.aaData.length; i < iLen; i++) {
                if (bReOrder) {
                    /* If we need to re-order, then create a new array with the correct order and add it */
                    var aData = [];
                    for (var j = 0, jLen = oSettings.aoColumns.length; j < jLen; j++) {
                        aData.push(json.aaData[i][aiIndex[j]]);
                    }
                    _fnAddData(oSettings, aData);
                }
                else {
                    /* No re-order required, sever got it "right" - just straight add */
                    _fnAddData(oSettings, json.aaData[i]);
                }
            }
            oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();

            oSettings.bAjaxDataGet = false;
            _fnDraw(oSettings);
            oSettings.bAjaxDataGet = true;
            _fnProcessingDisplay(oSettings, false);
        }

        /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
        * Options (features) HTML
        */

        /*
        * Function: _fnAddOptionsHtml
        * Purpose:  Add the options to the page HTML for the table
        * Returns:  -
        * Inputs:   object:oSettings - dataTables settings object
        */
        function _fnAddOptionsHtml(oSettings) {
            /*
            * Create a temporary, empty, div which we can later on replace with what we have generated
            * we do it this way to rendering the 'options' html offline - speed :-)
            */
            var nHolding = document.createElement('div');
            oSettings.nTable.parentNode.insertBefore(nHolding, oSettings.nTable);

            /* 
            * All DataTables are wrapped in a div - this is not currently optional - backwards 
            * compatability. It can be removed if you don't want it.
            */
            var nWrapper = document.createElement('div');
            nWrapper.className = oSettings.oClasses.sWrapper;
            if (oSettings.sTableId !== '') {
                nWrapper.setAttribute('id', oSettings.sTableId + '_wrapper');
            }

            /* Track where we want to insert the option */
            var nInsertNode = nWrapper;

            /* IE don't treat strings as arrays */
            var sDom = oSettings.sDomPositioning.split('');

            /* Loop over the user set positioning and place the elements as needed */
            var nTmp;
            for (var i = 0; i < sDom.length; i++) {
                var cOption = sDom[i];

                if (cOption == '<') {
                    /* New container div */
                    var nNewNode = document.createElement('div');

                    /* Check to see if we should append a class name to the container */
                    var cNext = sDom[i + 1];
                    if (cNext == "'" || cNext == '"') {
                        var sClass = "";
                        var j = 2;
                        while (sDom[i + j] != cNext) {
                            sClass += sDom[i + j];
                            j++;
                        }
                        nNewNode.className = sClass;
                        i += j; /* Move along the position array */
                    }

                    nInsertNode.appendChild(nNewNode);
                    nInsertNode = nNewNode;
                }
                else if (cOption == '>') {
                    /* End container div */
                    nInsertNode = nInsertNode.parentNode;
                }
                else if (cOption == 'l' && oSettings.oFeatures.bPaginate && oSettings.oFeatures.bLengthChange) {
                    /* Length */
                    nTmp = _fnFeatureHtmlLength(oSettings);
                    oSettings.anFeatures[cOption] = nTmp;
                    nInsertNode.appendChild(nTmp);
                }
                else if (cOption == 'f' && oSettings.oFeatures.bFilter) {
                    /* Filter */
                    nTmp = _fnFeatureHtmlFilter(oSettings);
                    oSettings.anFeatures[cOption] = nTmp;
                    nInsertNode.appendChild(nTmp);
                }
                else if (cOption == 'r' && oSettings.oFeatures.bProcessing) {
                    /* pRocessing */
                    nTmp = _fnFeatureHtmlProcessing(oSettings);
                    oSettings.anFeatures[cOption] = nTmp;
                    nInsertNode.appendChild(nTmp);
                }
                else if (cOption == 't') {
                    /* Table */
                    oSettings.anFeatures[cOption] = oSettings.nTable;
                    nInsertNode.appendChild(oSettings.nTable);
                }
                else if (cOption == 'i' && oSettings.oFeatures.bInfo) {
                    /* Info */
                    nTmp = _fnFeatureHtmlInfo(oSettings);
                    oSettings.anFeatures[cOption] = nTmp;
                    nInsertNode.appendChild(nTmp);
                }
                else if (cOption == 'p' && oSettings.oFeatures.bPaginate) {
                    /* Pagination */
                    nTmp = _fnFeatureHtmlPaginate(oSettings);
                    oSettings.anFeatures[cOption] = nTmp;
                    nInsertNode.appendChild(nTmp);
                }
                else if (_oExt.aoFeatures.length !== 0) {
                    var aoFeatures = _oExt.aoFeatures;
                    for (var k = 0, kLen = aoFeatures.length; k < kLen; k++) {
                        if (cOption == aoFeatures[k].cFeature) {
                            nTmp = aoFeatures[k].fnInit(oSettings);
                            oSettings.anFeatures[cOption] = nTmp;
                            nInsertNode.appendChild(nTmp);
                            break;
                        }
                    }
                }
            }

            /* Built our DOM structure - replace the holding div with what we want */
            nHolding.parentNode.replaceChild(nWrapper, nHolding);
        }

        /*
        * Function: _fnFeatureHtmlFilter
        * Purpose:  Generate the node required for filtering text
        * Returns:  node
        * Inputs:   object:oSettings - dataTables settings object
        */
        function _fnFeatureHtmlFilter(oSettings) {
            var nFilter = document.createElement('div');
            if (oSettings.sTableId !== '') {
                nFilter.setAttribute('id', oSettings.sTableId + '_filter');
            }
            nFilter.className = oSettings.oClasses.sFilter;
            var sSpace = oSettings.oLanguage.sSearch === "" ? "" : " ";
            nFilter.innerHTML = oSettings.oLanguage.sSearch + sSpace + '<input type="text" />';

            var jqFilter = $("input", nFilter);
            jqFilter.val(oSettings.oPreviousSearch.sSearch.replace('"', '&quot;'));
            jqFilter.keyup(function(e) {
                _fnFilterComplete(oSettings, {
                    "sSearch": this.value,
                    "bEscapeRegex": oSettings.oPreviousSearch.bEscapeRegex
                });

                /* Prevent default */
                return false;
            });

            return nFilter;
        }

        /*
        * Function: _fnFeatureHtmlInfo
        * Purpose:  Generate the node required for the info display
        * Returns:  node
        * Inputs:   object:oSettings - dataTables settings object
        */
        function _fnFeatureHtmlInfo(oSettings) {
            var nInfo = document.createElement('div');
            if (oSettings.sTableId !== '') {
                nInfo.setAttribute('id', oSettings.sTableId + '_info');
            }
            nInfo.className = oSettings.oClasses.sInfo;
            return nInfo;
        }

        /*
        * Function: _fnFeatureHtmlPaginate
        * Purpose:  Generate the node required for default pagination
        * Returns:  node
        * Inputs:   object:oSettings - dataTables settings object
        */
        function _fnFeatureHtmlPaginate(oSettings) {
            var nPaginate = document.createElement('div');
            nPaginate.className = oSettings.oClasses.sPaging + oSettings.sPaginationType;
            oSettings.anFeatures.p = nPaginate; /* Need this stored in order to call paging plug-ins */

            _oExt.oPagination[oSettings.sPaginationType].fnInit(oSettings, function(oSettings) {
                _fnCalculateEnd(oSettings);
                _fnDraw(oSettings);
            });
            return nPaginate;
        }

        /*
        * Function: _fnFeatureHtmlLength
        * Purpose:  Generate the node required for user display length changing
        * Returns:  node
        * Inputs:   object:oSettings - dataTables settings object
        */
        function _fnFeatureHtmlLength(oSettings) {
            /* This can be overruled by not using the _MENU_ var/macro in the language variable */
            var sName = (oSettings.sTableId === "") ? "" : 'name="' + oSettings.sTableId + '_length"';
            var sStdMenu =
				'<select size="1" ' + sName + '>' +
					'<option value="10">10</option>' +
					'<option value="25">25</option>' +
					'<option value="50">50</option>' +
					'<option value="100">100</option>' +
				'</select>';

            var nLength = document.createElement('div');
            if (oSettings.sTableId !== '') {
                nLength.setAttribute('id', oSettings.sTableId + '_length');
            }
            nLength.className = oSettings.oClasses.sLength;
            nLength.innerHTML = oSettings.oLanguage.sLengthMenu.replace('_MENU_', sStdMenu);

            /*
            * Set the length to the current display length - thanks to Andrea Pavlovic for this fix,
            * and Stefan Skopnik for fixing the fix!
            */
            $('select option[value="' + oSettings._iDisplayLength + '"]', nLength).attr("selected", true);

            $('select', nLength).click(function(e) {
                //console.log($(this).val());
                oSettings._iDisplayLength = parseInt($(this).val(), 10);

                _fnCalculateEnd(oSettings);

                /* If we have space to show extra rows (backing up from the end point - then do so */
                if (oSettings._iDisplayEnd == oSettings.aiDisplay.length) {
                    oSettings._iDisplayStart = oSettings._iDisplayEnd - oSettings._iDisplayLength;
                    if (oSettings._iDisplayStart < 0) {
                        oSettings._iDisplayStart = 0;
                    }
                }

                if (oSettings._iDisplayLength == -1) {
                    oSettings._iDisplayStart = 0;
                }

                _fnDraw(oSettings);
            });

            return nLength;
        }

        /*
        * Function: _fnFeatureHtmlProcessing
        * Purpose:  Generate the node required for the processing node
        * Returns:  node
        * Inputs:   object:oSettings - dataTables settings object
        */
        function _fnFeatureHtmlProcessing(oSettings) {
            var nProcessing = document.createElement('div');

            if (oSettings.sTableId !== '') {
                nProcessing.setAttribute('id', oSettings.sTableId + '_processing');
            }
            nProcessing.innerHTML = oSettings.oLanguage.sProcessing;
            nProcessing.className = oSettings.oClasses.sProcessing;
            oSettings.nTable.parentNode.insertBefore(nProcessing, oSettings.nTable);

            return nProcessing;
        }

        /*
        * Function: _fnProcessingDisplay
        * Purpose:  Display or hide the processing indicator
        * Returns:  -
        * Inputs:   object:oSettings - dataTables settings object
        *           bool:
        *   true - show the processing indicator
        *   false - don't show
        */
        function _fnProcessingDisplay(oSettings, bShow) {
            if (oSettings.oFeatures.bProcessing) {
                oSettings.anFeatures.r.style.visibility = bShow ? "visible" : "hidden";
            }
        }



        /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
        * Filtering
        */

        /*
        * Function: _fnFilterComplete
        * Purpose:  Filter the table using both the global filter and column based filtering
        * Returns:  -
        * Inputs:   object:oSettings - dataTables settings object
        *           object:oSearch: search information
        *           int:iForce - optional - force a research of the master array (1) or not (undefined or 0)
        */
        function _fnFilterComplete(oSettings, oInput, iForce) {
            /* Filter on everything */
            _fnFilter(oSettings, oInput.sSearch, iForce, oInput.bEscapeRegex);

            /* Now do the individual column filter */
            for (var i = 0; i < oSettings.aoPreSearchCols.length; i++) {
                _fnFilterColumn(oSettings, oSettings.aoPreSearchCols[i].sSearch, i,
					oSettings.aoPreSearchCols[i].bEscapeRegex);
            }

            /* Custom filtering */
            if (_oExt.afnFiltering.length !== 0) {
                _fnFilterCustom(oSettings);
            }

            /* Redraw the table */
            if (typeof oSettings.iInitDisplayStart != 'undefined' && oSettings.iInitDisplayStart != -1) {
                oSettings._iDisplayStart = oSettings.iInitDisplayStart;
                oSettings.iInitDisplayStart = -1;
            }
            else {
                oSettings._iDisplayStart = 0;
            }
            _fnCalculateEnd(oSettings);
            _fnDraw(oSettings);

            /* Rebuild search array 'offline' */
            _fnBuildSearchArray(oSettings, 0);
        }

        /*
        * Function: _fnFilterCustom
        * Purpose:  Apply custom filtering functions
        * Returns:  -
        * Inputs:   object:oSettings - dataTables settings object
        */
        function _fnFilterCustom(oSettings) {
            var afnFilters = _oExt.afnFiltering;
            for (var i = 0, iLen = afnFilters.length; i < iLen; i++) {
                var iCorrector = 0;
                for (var j = 0, jLen = oSettings.aiDisplay.length; j < jLen; j++) {
                    var iDisIndex = oSettings.aiDisplay[j - iCorrector];

                    /* Check if we should use this row based on the filtering function */
                    if (!afnFilters[i](oSettings, oSettings.aoData[iDisIndex]._aData, iDisIndex)) {
                        oSettings.aiDisplay.splice(j - iCorrector, 1);
                        iCorrector++;
                    }
                }
            }
        }

        /*
        * Function: _fnFilterColumn
        * Purpose:  Filter the table on a per-column basis
        * Returns:  -
        * Inputs:   object:oSettings - dataTables settings object
        *           string:sInput - string to filter on
        *           int:iColumn - column to filter
        *           bool:bEscapeRegex - escape regex or not
        */
        function _fnFilterColumn(oSettings, sInput, iColumn, bEscapeRegex) {
            if (sInput === "") {
                return;
            }

            var iIndexCorrector = 0;
            var sRegexMatch = bEscapeRegex ? _fnEscapeRegex(sInput) : sInput;
            var rpSearch = new RegExp(sRegexMatch, "i");

            for (var i = oSettings.aiDisplay.length - 1; i >= 0; i--) {
                var sData = _fnDataToSearch(oSettings.aoData[oSettings.aiDisplay[i]]._aData[iColumn],
					oSettings.aoColumns[iColumn].sType);
                if (!rpSearch.test(sData)) {
                    oSettings.aiDisplay.splice(i, 1);
                    iIndexCorrector++;
                }
            }
        }

        /*
        * Function: _fnFilter
        * Purpose:  Filter the data table based on user input and draw the table
        * Returns:  -
        * Inputs:   object:oSettings - dataTables settings object
        *           string:sInput - string to filter on
        *           int:iForce - optional - force a research of the master array (1) or not (undefined or 0)
        *           bool:bEscapeRegex - escape regex or not
        */
        function _fnFilter(oSettings, sInput, iForce, bEscapeRegex) {
            var i;

            /* Check if we are forcing or not - optional parameter */
            if (typeof iForce == 'undefined' || iForce === null) {
                iForce = 0;
            }

            /* Need to take account of custom filtering functions always */
            if (_oExt.afnFiltering.length !== 0) {
                iForce = 1;
            }

            /* Generate the regular expression to use. Something along the lines of:
            * ^(?=.*?\bone\b)(?=.*?\btwo\b)(?=.*?\bthree\b).*$
            */
            var asSearch = bEscapeRegex ?
				_fnEscapeRegex(sInput).split(' ') :
				sInput.split(' ');
            var sRegExpString = '^(?=.*?' + asSearch.join(')(?=.*?') + ').*$';
            var rpSearch = new RegExp(sRegExpString, "i"); /* case insensitive */

            /*
            * If the input is blank - we want the full data set
            */
            if (sInput.length <= 0) {
                oSettings.aiDisplay.splice(0, oSettings.aiDisplay.length);
                oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
            }
            else {
                /*
                * We are starting a new search or the new search string is smaller 
                * then the old one (i.e. delete). Search from the master array
                */
                if (oSettings.aiDisplay.length == oSettings.aiDisplayMaster.length ||
					   oSettings.oPreviousSearch.sSearch.length > sInput.length || iForce == 1 ||
					   sInput.indexOf(oSettings.oPreviousSearch.sSearch) !== 0) {
                    /* Nuke the old display array - we are going to rebuild it */
                    oSettings.aiDisplay.splice(0, oSettings.aiDisplay.length);

                    /* Force a rebuild of the search array */
                    _fnBuildSearchArray(oSettings, 1);

                    /* Search through all records to populate the search array
                    * The the oSettings.aiDisplayMaster and asDataSearch arrays have 1 to 1 
                    * mapping
                    */
                    for (i = 0; i < oSettings.aiDisplayMaster.length; i++) {
                        if (rpSearch.test(oSettings.asDataSearch[i])) {
                            oSettings.aiDisplay.push(oSettings.aiDisplayMaster[i]);
                        }
                    }
                }
                else {
                    /* Using old search array - refine it - do it this way for speed
                    * Don't have to search the whole master array again
                    */
                    var iIndexCorrector = 0;

                    /* Search the current results */
                    for (i = 0; i < oSettings.asDataSearch.length; i++) {
                        if (!rpSearch.test(oSettings.asDataSearch[i])) {
                            oSettings.aiDisplay.splice(i - iIndexCorrector, 1);
                            iIndexCorrector++;
                        }
                    }
                }
            }
            oSettings.oPreviousSearch.sSearch = sInput;
            oSettings.oPreviousSearch.bEscapeRegex = bEscapeRegex;
        }



        /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
        * Sorting
        */

        /*
        * Function: _fnSort
        * Purpose:  Change the order of the table
        * Returns:  -
        * Inputs:   object:oSettings - dataTables settings object
        *           bool:bApplyClasses - optional - should we apply classes or not
        * Notes:    We always sort the master array and then apply a filter again
        *   if it is needed. This probably isn't optimal - but atm I can't think
        *   of any other way which is (each has disadvantages)
        */
        function _fnSort(oSettings, bApplyClasses) {
            /*
            * Funny one this - we want to sort aiDisplayMaster - but according to aoData[]._aData
            *
            * function _fnSortText ( a, b )
            * {
            * 	var iTest;
            * 	var oSort = _oExt.oSort;
            * 	
            * 	iTest = oSort['string-asc']( aoData[ a ]._aData[ COL ], aoData[ b ]._aData[ COL ] );
            * 	if ( iTest === 0 )
            * 		...
            * }
            */

            /* Here is what we are looking to achieve here (custom sort functions add complication...)
            * function _fnSortText ( a, b )
            * {
            * 	var iTest;
            *  var oSort = _oExt.oSort;
            * 	iTest = oSort['string-asc']( a[0], b[0] );
            * 	if ( iTest === 0 )
            * 		iTest = oSort['string-asc']( a[1], b[1] );
            * 		if ( iTest === 0 )
            * 			iTest = oSort['string-asc']( a[2], b[2] );
            * 	
            * 	return iTest;
            * }
            */
            var aaSort = [];
            var oSort = _oExt.oSort;
            var aoData = oSettings.aoData;
            var iDataSort;
            var iDataType;
            var i;

            if (oSettings.aaSorting.length !== 0 || oSettings.aaSortingFixed !== null) {
                if (oSettings.aaSortingFixed !== null) {
                    aaSort = oSettings.aaSortingFixed.concat(oSettings.aaSorting);
                }
                else {
                    aaSort = oSettings.aaSorting.slice();
                }

                if (!window.runtime) {
                    var fnLocalSorting;
                    var sDynamicSort = "fnLocalSorting = function(a,b){" +
						"var iTest;";

                    for (i = 0; i < aaSort.length - 1; i++) {
                        iDataSort = oSettings.aoColumns[aaSort[i][0]].iDataSort;
                        iDataType = oSettings.aoColumns[iDataSort].sType;
                        sDynamicSort += "iTest = oSort['" + iDataType + "-" + aaSort[i][1] + "']" +
							"( aoData[a]._aData[" + iDataSort + "], aoData[b]._aData[" + iDataSort + "] ); if ( iTest === 0 )";
                    }

                    iDataSort = oSettings.aoColumns[aaSort[aaSort.length - 1][0]].iDataSort;
                    iDataType = oSettings.aoColumns[iDataSort].sType;
                    sDynamicSort += "iTest = oSort['" + iDataType + "-" + aaSort[aaSort.length - 1][1] + "']" +
						"( aoData[a]._aData[" + iDataSort + "], aoData[b]._aData[" + iDataSort + "] ); return iTest;}";

                    /* The eval has to be done to a variable for IE */
                    eval(sDynamicSort);
                    oSettings.aiDisplayMaster.sort(fnLocalSorting);
                }
                else {
                    /*
                    * Support for Adobe AIR - AIR doesn't allow eval with a function
                    * Note that for reasonable sized data sets this method is around 1.5 times slower than
                    * the eval above (hence why it is not used all the time). Oddly enough, it is ever so
                    * slightly faster for very small sets (presumably the eval has overhead).
                    *   Single column (1083 records) - eval: 32mS   AIR: 38mS
                    *   Two columns (1083 records) -   eval: 55mS   AIR: 66mS
                    */

                    /* Build a cached array so the sort doesn't have to process this stuff on every call */
                    var aAirSort = [];
                    var iLen = aaSort.length;
                    for (i = 0; i < iLen; i++) {
                        iDataSort = oSettings.aoColumns[aaSort[i][0]].iDataSort;
                        aAirSort.push([
							iDataSort,
							oSettings.aoColumns[iDataSort].sType + '-' + aaSort[i][1]
						]);
                    }

                    oSettings.aiDisplayMaster.sort(function(a, b) {
                        var iTest;
                        for (var i = 0; i < iLen; i++) {
                            iTest = oSort[aAirSort[i][1]](aoData[a]._aData[aAirSort[i][0]], aoData[b]._aData[aAirSort[i][0]]);
                            if (iTest !== 0) {
                                return iTest;
                            }
                        }
                        return 0;
                    });
                }
            }

            /* Alter the sorting classes to take account of the changes */
            if (typeof bApplyClasses == 'undefined' || bApplyClasses) {
                _fnSortingClasses(oSettings);
            }

            /* Copy the master data into the draw array and re-draw */
            if (oSettings.oFeatures.bFilter) {
                /* _fnFilter() will redraw the table for us */
                _fnFilterComplete(oSettings, oSettings.oPreviousSearch, 1);
            }
            else {
                oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
                oSettings._iDisplayStart = 0; /* reset display back to page 0 */
                _fnCalculateEnd(oSettings);
                _fnDraw(oSettings);
            }
        }

        /*
        * Function: _fnSortingClasses
        * Purpose:  Set the sortting classes on the header
        * Returns:  -
        * Inputs:   object:oSettings - dataTables settings object
        */
        function _fnSortingClasses(oSettings) {
            var i, j, iFound;
            var aaSort, sClass;
            var iColumns = oSettings.aoColumns.length;
            var oClasses = oSettings.oClasses;

            for (i = 0; i < iColumns; i++) {
                $(oSettings.aoColumns[i].nTh).removeClass(oClasses.sSortAsc + " " + oClasses.sSortDesc +
				 	" " + oClasses.sSortable);
            }

            if (oSettings.aaSortingFixed !== null) {
                aaSort = oSettings.aaSortingFixed.concat(oSettings.aaSorting);
            }
            else {
                aaSort = oSettings.aaSorting.slice();
            }

            /* Apply the required classes to the header */
            for (i = 0; i < oSettings.aoColumns.length; i++) {
                if (oSettings.aoColumns[i].bSortable && oSettings.aoColumns[i].bVisible) {
                    sClass = oClasses.sSortable;
                    iFound = -1;
                    for (j = 0; j < aaSort.length; j++) {
                        if (aaSort[j][0] == i) {
                            sClass = (aaSort[j][1] == "asc") ?
								oClasses.sSortAsc : oClasses.sSortDesc;
                            iFound = j;
                            break;
                        }
                    }
                    $(oSettings.aoColumns[i].nTh).addClass(sClass);

                    if (oSettings.bJUI) {
                        /* jQuery UI uses extra markup */
                        var jqSpan = $("span", oSettings.aoColumns[i].nTh);
                        jqSpan.removeClass(oClasses.sSortJUIAsc + " " + oClasses.sSortJUIDesc + " " +
							oClasses.sSortJUI);

                        var sSpanClass;
                        if (iFound == -1) {
                            sSpanClass = oClasses.sSortJUI;
                        }
                        else if (aaSort[iFound][1] == "asc") {
                            sSpanClass = oClasses.sSortJUIAsc;
                        }
                        else {
                            sSpanClass = oClasses.sSortJUIDesc;
                        }

                        jqSpan.addClass(sSpanClass);
                    }
                }
            }

            /* 
            * Apply the required classes to the table body
            * Note that this is given as a feature switch since it can significantly slow down a sort
            * on large data sets (adding and removing of classes is always slow at the best of times..)
            */
            if (oSettings.oFeatures.bSortClasses) {
                var nTrs = _fnGetTrNodes(oSettings);
                sClass = oClasses.sSortColumn;
                $('td', nTrs).removeClass(sClass + "1 " + sClass + "2 " + sClass + "3");

                var iClass = 1;
                for (i = 0; i < aaSort.length; i++) {
                    var iVis = _fnColumnIndexToVisible(oSettings, aaSort[i][0]);
                    if (iVis !== null) {
                        /* Limit the number of classes to three */
                        if (iClass <= 2) {
                            $('td:eq(' + iVis + ')', nTrs).addClass(sClass + iClass);
                        }
                        else {
                            $('td:eq(' + iVis + ')', nTrs).addClass(sClass + '3');
                        }
                        iClass++;
                    }
                }
            }
        }

        /*
        * Function: _fnVisibleToColumnIndex
        * Purpose:  Covert the index of a visible column to the index in the data array (take account
        *   of hidden columns)
        * Returns:  int:i - the data index
        * Inputs:   object:oSettings - dataTables settings object
        */
        function _fnVisibleToColumnIndex(oSettings, iMatch) {
            var iColumn = -1;

            for (var i = 0; i < oSettings.aoColumns.length; i++) {
                if (oSettings.aoColumns[i].bVisible === true) {
                    iColumn++;
                }

                if (iColumn == iMatch) {
                    return i;
                }
            }

            return null;
        }

        /*
        * Function: _fnColumnIndexToVisible
        * Purpose:  Covert the index of an index in the data array and convert it to the visible
        *   column index (take account of hidden columns)
        * Returns:  int:i - the data index
        * Inputs:   object:oSettings - dataTables settings object
        */
        function _fnColumnIndexToVisible(oSettings, iMatch) {
            var iVisible = -1;
            for (var i = 0; i < oSettings.aoColumns.length; i++) {
                if (oSettings.aoColumns[i].bVisible === true) {
                    iVisible++;
                }

                if (i == iMatch) {
                    return oSettings.aoColumns[i].bVisible === true ? iVisible : null;
                }
            }

            return null;
        }

        /*
        * Function: _fnVisbleColumns
        * Purpose:  Get the number of visible columns
        * Returns:  int:i - the number of visible columns
        * Inputs:   object:oS - dataTables settings object
        */
        function _fnVisbleColumns(oS) {
            var iVis = 0;
            for (var i = 0; i < oS.aoColumns.length; i++) {
                if (oS.aoColumns[i].bVisible === true) {
                    iVis++;
                }
            }
            return iVis;
        }

        /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
        * Support functions
        */

        /*
        * Function: _fnBuildSearchArray
        * Purpose:  Create an array which can be quickly search through
        * Returns:  -
        * Inputs:   object:oSettings - dataTables settings object
        *           int:iMaster - use the master data array - optional
        */
        function _fnBuildSearchArray(oSettings, iMaster) {
            /* Clear out the old data */
            oSettings.asDataSearch.splice(0, oSettings.asDataSearch.length);

            var aArray = (typeof iMaster != 'undefined' && iMaster == 1) ?
			 	oSettings.aiDisplayMaster : oSettings.aiDisplay;

            for (var i = 0, iLen = aArray.length; i < iLen; i++) {
                oSettings.asDataSearch[i] = '';
                for (var j = 0, jLen = oSettings.aoColumns.length; j < jLen; j++) {
                    if (oSettings.aoColumns[j].bSearchable) {
                        var sData = oSettings.aoData[aArray[i]]._aData[j];
                        oSettings.asDataSearch[i] += _fnDataToSearch(sData, oSettings.aoColumns[j].sType) + ' ';
                    }
                }
            }
        }

        /*
        * Function: _fnDataToSearch
        * Purpose:  Convert raw data into something that the user can search on
        * Returns:  string: - search string
        * Inputs:   string:sData - data to be modified
        *           string:sType - data type
        */
        function _fnDataToSearch(sData, sType) {

            if (typeof _oExt.ofnSearch[sType] == "function") {
                return _oExt.ofnSearch[sType](sData);
            }
            else if (sType == "html") {
                return sData.replace(/\n/g, " ").replace(/<.*?>/g, "");
            }
            else if (typeof sData == "string") {
                return sData.replace(/\n/g, " ");
            }
            return sData;
        }

        /*
        * Function: _fnCalculateEnd
        * Purpose:  Rcalculate the end point based on the start point
        * Returns:  -
        * Inputs:   object:oSettings - dataTables settings object
        */
        function _fnCalculateEnd(oSettings) {
            if (oSettings.oFeatures.bPaginate === false) {
                oSettings._iDisplayEnd = oSettings.aiDisplay.length;
            }
            else {
                /* Set the end point of the display - based on how many elements there are
                * still to display
                */
                if (oSettings._iDisplayStart + oSettings._iDisplayLength > oSettings.aiDisplay.length ||
					   oSettings._iDisplayLength == -1) {
                    oSettings._iDisplayEnd = oSettings.aiDisplay.length;
                }
                else {
                    oSettings._iDisplayEnd = oSettings._iDisplayStart + oSettings._iDisplayLength;
                }
            }
        }

        /*
        * Function: _fnConvertToWidth
        * Purpose:  Convert a CSS unit width to pixels (e.g. 2em)
        * Returns:  int:iWidth - width in pixels
        * Inputs:   string:sWidth - width to be converted
        *           node:nParent - parent to get the with for (required for
        *             relative widths) - optional
        */
        function _fnConvertToWidth(sWidth, nParent) {
            if (!sWidth || sWidth === null || sWidth === '') {
                return 0;
            }

            if (typeof nParent == "undefined") {
                nParent = document.getElementsByTagName('body')[0];
            }

            var iWidth;
            var nTmp = document.createElement("div");
            nTmp.style.width = sWidth;

            nParent.appendChild(nTmp);
            iWidth = nTmp.offsetWidth;
            nParent.removeChild(nTmp);

            return (iWidth);
        }

        /*
        * Function: _fnCalculateColumnWidths
        * Purpose:  Calculate the width of columns for the table
        * Returns:  -
        * Inputs:   object:oSettings - dataTables settings object
        */
        function _fnCalculateColumnWidths(oSettings) {
            var iTableWidth = oSettings.nTable.offsetWidth;
            var iTotalUserIpSize = 0;
            var iTmpWidth;
            var iVisibleColumns = 0;
            var iColums = oSettings.aoColumns.length;
            var i;
            var oHeaders = $('thead th', oSettings.nTable);

            /* Convert any user input sizes into pixel sizes */
            for (i = 0; i < iColums; i++) {
                if (oSettings.aoColumns[i].bVisible) {
                    iVisibleColumns++;

                    if (oSettings.aoColumns[i].sWidth !== null) {
                        iTmpWidth = _fnConvertToWidth(oSettings.aoColumns[i].sWidth,
							oSettings.nTable.parentNode);

                        /* Total up the user defined widths for later calculations */
                        iTotalUserIpSize += iTmpWidth;

                        oSettings.aoColumns[i].sWidth = iTmpWidth + "px";
                    }
                }
            }

            /* If the number of columns in the DOM equals the number that we
            * have to process in dataTables, then we can use the offsets that are
            * created by the web-browser. No custom sizes can be set in order for
            * this to happen
            */
            if (iColums == oHeaders.length && iTotalUserIpSize === 0 && iVisibleColumns == iColums) {
                for (i = 0; i < oSettings.aoColumns.length; i++) {
                    oSettings.aoColumns[i].sWidth = oHeaders[i].offsetWidth + "px";
                }
            }
            else {
                /* Otherwise we are going to have to do some calculations to get
                * the width of each column. Construct a 1 row table with the maximum
                * string sizes in the data, and any user defined widths
                */
                var nCalcTmp = oSettings.nTable.cloneNode(false);
                nCalcTmp.setAttribute("id", '');

                var sTableTmp = '<table class="' + nCalcTmp.className + '">';
                var sCalcHead = "<tr>";
                var sCalcHtml = "<tr>";

                /* Construct a tempory table which we will inject (invisibly) into
                * the dom - to let the browser do all the hard word
                */
                for (i = 0; i < iColums; i++) {
                    if (oSettings.aoColumns[i].bVisible) {
                        sCalcHead += '<th>' + oSettings.aoColumns[i].sTitle + '</th>';

                        if (oSettings.aoColumns[i].sWidth !== null) {
                            var sWidth = '';
                            if (oSettings.aoColumns[i].sWidth !== null) {
                                sWidth = ' style="width:' + oSettings.aoColumns[i].sWidth + ';"';
                            }

                            sCalcHtml += '<td' + sWidth + ' tag_index="' + i + '">' + fnGetMaxLenString(oSettings, i) + '</td>';
                        }
                        else {
                            sCalcHtml += '<td tag_index="' + i + '">' + fnGetMaxLenString(oSettings, i) + '</td>';
                        }
                    }
                }

                sCalcHead += "</tr>";
                sCalcHtml += "</tr>";

                /* Create the tmp table node (thank you jQuery) */
                nCalcTmp = $(sTableTmp + sCalcHead + sCalcHtml + '</table>')[0];
                nCalcTmp.style.width = iTableWidth + "px";
                nCalcTmp.style.visibility = "hidden";
                nCalcTmp.style.position = "absolute"; /* Try to aviod scroll bar */

                oSettings.nTable.parentNode.appendChild(nCalcTmp);

                var oNodes = $("td", nCalcTmp);
                var iIndex;

                /* Gather in the browser calculated widths for the rows */
                for (i = 0; i < oNodes.length; i++) {
                    iIndex = oNodes[i].getAttribute('tag_index');

                    oSettings.aoColumns[iIndex].sWidth = $("td", nCalcTmp)[i].offsetWidth + "px";
                }

                oSettings.nTable.parentNode.removeChild(nCalcTmp);
            }
        }

        /*
        * Function: fnGetMaxLenString
        * Purpose:  Get the maximum strlen for each data column
        * Returns:  string: - max strlens for each column
        * Inputs:   object:oSettings - dataTables settings object
        *           int:iCol - column of interest
        */
        function fnGetMaxLenString(oSettings, iCol) {
            var iMax = 0;
            var iMaxIndex = -1;

            for (var i = 0; i < oSettings.aoData.length; i++) {
                if (oSettings.aoData[i]._aData[iCol].length > iMax) {
                    iMax = oSettings.aoData[i]._aData[iCol].length;
                    iMaxIndex = i;
                }
            }

            if (iMaxIndex >= 0) {
                return oSettings.aoData[iMaxIndex]._aData[iCol];
            }
            return '';
        }

        /*
        * Function: _fnArrayCmp
        * Purpose:  Compare two arrays
        * Returns:  0 if match, 1 if length is different, 2 if no match
        * Inputs:   array:aArray1 - first array
        *           array:aArray2 - second array
        */
        function _fnArrayCmp(aArray1, aArray2) {
            if (aArray1.length != aArray2.length) {
                return 1;
            }

            for (var i = 0; i < aArray1.length; i++) {
                if (aArray1[i] != aArray2[i]) {
                    return 2;
                }
            }

            return 0;
        }

        /*
        * Function: _fnDetectType
        * Purpose:  Get the sort type based on an input string
        * Returns:  string: - type (defaults to 'string' if no type can be detected)
        * Inputs:   string:sData - data we wish to know the type of
        * Notes:    This function makes use of the DataTables plugin objct _oExt 
        *   (.aTypes) such that new types can easily be added.
        */
        function _fnDetectType(sData) {
            var aTypes = _oExt.aTypes;
            var iLen = aTypes.length;

            for (var i = 0; i < iLen; i++) {
                var sType = aTypes[i](sData);
                if (sType !== null) {
                    return sType;
                }
            }

            return 'string';
        }

        /*
        * Function: _fnSettingsFromNode
        * Purpose:  Return the settings object for a particular table
        * Returns:  object: Settings object - or null if not found
        * Inputs:   node:nTable - table we are using as a dataTable
        */
        function _fnSettingsFromNode(nTable) {
            for (var i = 0; i < _aoSettings.length; i++) {
                if (_aoSettings[i].nTable == nTable) {
                    return _aoSettings[i];
                }
            }

            return null;
        }

        /*
        * Function: _fnGetDataMaster
        * Purpose:  Return an array with the full table data
        * Returns:  array array:aData - Master data array
        * Inputs:   object:oSettings - dataTables settings object
        */
        function _fnGetDataMaster(oSettings) {
            var aData = [];
            var iLen = oSettings.aoData.length;
            for (var i = 0; i < iLen; i++) {
                if (oSettings.aoData[i] === null) {
                    aData.push(null);
                }
                else {
                    aData.push(oSettings.aoData[i]._aData);
                }
            }
            return aData;
        }

        /*
        * Function: _fnGetTrNodes
        * Purpose:  Return an array with the TR nodes for the table
        * Returns:  array array:aData - TR array
        * Inputs:   object:oSettings - dataTables settings object
        */
        function _fnGetTrNodes(oSettings) {
            var aNodes = [];
            var iLen = oSettings.aoData.length;
            for (var i = 0; i < iLen; i++) {
                if (oSettings.aoData[i] === null) {
                    aNodes.push(null);
                }
                else {
                    aNodes.push(oSettings.aoData[i].nTr);
                }
            }
            return aNodes;
        }

        /*
        * Function: _fnEscapeRegex
        * Purpose:  scape a string stuch that it can be used in a regular expression
        * Returns:  string: - escaped string
        * Inputs:   string:sVal - string to escape
        */
        function _fnEscapeRegex(sVal) {
            var acEscape = ['/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^'];
            var reReplace = new RegExp('(\\' + acEscape.join('|\\') + ')', 'g');
            return sVal.replace(reReplace, '\\$1');
        }

        /*
        * Function: _fnReOrderIndex
        * Purpose:  Figure out how to reorder a display list
        * Returns:  array int:aiReturn - index list for reordering
        * Inputs:   object:oSettings - dataTables settings object
        */
        function _fnReOrderIndex(oSettings, sColumns) {
            var aColumns = sColumns.split(',');
            var aiReturn = [];

            for (var i = 0, iLen = oSettings.aoColumns.length; i < iLen; i++) {
                for (var j = 0; j < iLen; j++) {
                    if (oSettings.aoColumns[i].sName == aColumns[j]) {
                        aiReturn.push(j);
                        break;
                    }
                }
            }

            return aiReturn;
        }

        /*
        * Function: _fnColumnOrdering
        * Purpose:  Get the column ordering that DataTables expects
        * Returns:  string: - comma separated list of names
        * Inputs:   object:oSettings - dataTables settings object
        */
        function _fnColumnOrdering(oSettings) {
            var sNames = '';
            for (var i = 0, iLen = oSettings.aoColumns.length; i < iLen; i++) {
                sNames += oSettings.aoColumns[i].sName + ',';
            }
            if (sNames.length == iLen) {
                return "";
            }
            return sNames.slice(0, -1);
        }

        /*
        * Function: _fnClearTable
        * Purpose:  Nuke the table
        * Returns:  -
        * Inputs:   object:oSettings - dataTables settings object
        */
        function _fnClearTable(oSettings) {
            oSettings.aoData.length = 0;
            oSettings.aiDisplayMaster.length = 0;
            oSettings.aiDisplay.length = 0;
            _fnCalculateEnd(oSettings);
        }

        /*
        * Function: _fnSaveState
        * Purpose:  Save the state of a table in a cookie such that the page can be reloaded
        * Returns:  -
        * Inputs:   object:oSettings - dataTables settings object
        */
        function _fnSaveState(oSettings) {
            if (!oSettings.oFeatures.bStateSave) {
                return;
            }

            /* Store the interesting variables */
            var i;
            var sValue = "{";
            sValue += '"iStart": ' + oSettings._iDisplayStart + ',';
            sValue += '"iEnd": ' + oSettings._iDisplayEnd + ',';
            sValue += '"iLength": ' + oSettings._iDisplayLength + ',';
            sValue += '"sFilter": "' + oSettings.oPreviousSearch.sSearch.replace('"', '\\"') + '",';
            sValue += '"sFilterEsc": ' + oSettings.oPreviousSearch.bEscapeRegex + ',';

            sValue += '"aaSorting": [ ';
            for (i = 0; i < oSettings.aaSorting.length; i++) {
                sValue += "[" + oSettings.aaSorting[i][0] + ",'" + oSettings.aaSorting[i][1] + "'],";
            }
            sValue = sValue.substring(0, sValue.length - 1);
            sValue += "],";

            sValue += '"aaSearchCols": [ ';
            for (i = 0; i < oSettings.aoPreSearchCols.length; i++) {
                sValue += "['" + oSettings.aoPreSearchCols[i].sSearch.replace("'", "\'") +
					"'," + oSettings.aoPreSearchCols[i].bEscapeRegex + "],";
            }
            sValue = sValue.substring(0, sValue.length - 1);
            sValue += "],";

            sValue += '"abVisCols": [ ';
            for (i = 0; i < oSettings.aoColumns.length; i++) {
                sValue += oSettings.aoColumns[i].bVisible + ",";
            }
            sValue = sValue.substring(0, sValue.length - 1);
            sValue += "]";

            sValue += "}";
            _fnCreateCookie("SpryMedia_DataTables_" + oSettings.sInstance, sValue,
				oSettings.iCookieDuration);
        }

        /*
        * Function: _fnLoadState
        * Purpose:  Attempt to load a saved table state from a cookie
        * Returns:  -
        * Inputs:   object:oSettings - dataTables settings object
        *           object:oInit - DataTables init object so we can override settings
        */
        function _fnLoadState(oSettings, oInit) {
            if (!oSettings.oFeatures.bStateSave) {
                return;
            }

            var oData;
            var sData = _fnReadCookie("SpryMedia_DataTables_" + oSettings.sInstance);
            if (sData !== null && sData !== '') {
                /* Try/catch the JSON eval - if it is bad then we ignore it */
                try {
                    /* Use the JSON library for safety - if it is available */
                    if (typeof JSON == 'object' && typeof JSON.parse == 'function') {
                        /* DT 1.4.0 used single quotes for a string - JSON.parse doesn't allow this and throws
                        * an error. So for now we can do this. This can be removed in future it is just to
                        * allow the tranfrer to 1.4.1+ to occur
                        */
                        oData = JSON.parse(sData.replace(/'/g, '"'));
                    }
                    else {
                        oData = eval('(' + sData + ')');
                    }
                }
                catch (e) {
                    return;
                }

                /* Restore key features */
                oSettings._iDisplayStart = oData.iStart;
                oSettings.iInitDisplayStart = oData.iStart;
                oSettings._iDisplayEnd = oData.iEnd;
                oSettings._iDisplayLength = oData.iLength;
                oSettings.oPreviousSearch.sSearch = oData.sFilter;
                oSettings.aaSorting = oData.aaSorting.slice();

                /* Search filtering - global reference added in 1.4.1 */
                if (typeof oData.sFilterEsc != 'undefined') {
                    oSettings.oPreviousSearch.bEscapeRegex = oData.sFilterEsc;
                }

                /* Column filtering - added in 1.5.0 beta 6 */
                if (typeof oData.aaSearchCols != 'undefined') {
                    for (var i = 0; i < oData.aaSearchCols.length; i++) {
                        oSettings.aoPreSearchCols[i] = {
                            "sSearch": oData.aaSearchCols[i][0],
                            "bEscapeRegex": oData.aaSearchCols[i][1]
                        };
                    }
                }

                /* Column visibility state - added in 1.5.0 beta 10 */
                if (typeof oData.abVisCols != 'undefined') {
                    /* We need to override the settings in oInit for this */
                    if (typeof oInit.aoColumns == 'undefined') {
                        oInit.aoColumns = [];
                    }

                    for (i = 0; i < oData.abVisCols.length; i++) {
                        if (typeof oInit.aoColumns[i] == 'undefined' || oInit.aoColumns[i] === null) {
                            oInit.aoColumns[i] = {};
                        }

                        oInit.aoColumns[i].bVisible = oData.abVisCols[i];
                    }
                }
            }
        }

        /*
        * Function: _fnCreateCookie
        * Purpose:  Create a new cookie with a value to store the state of a table
        * Returns:  -
        * Inputs:   string:sName - name of the cookie to create
        *           string:sValue - the value the cookie should take
        *           int:iSecs - duration of the cookie
        */
        function _fnCreateCookie(sName, sValue, iSecs) {
            var date = new Date();
            date.setTime(date.getTime() + (iSecs * 1000));

            /* 
            * Shocking but true - it would appear IE has major issues with having the path being
            * set to anything but root. We need the cookie to be available based on the path, so we
            * have to append the pathname to the cookie name. Appalling.
            */
            sName += '_' + window.location.pathname.replace(/[\/:]/g, "").toLowerCase();

            document.cookie = sName + "=" + sValue + "; expires=" + date.toGMTString() + "; path=/";
        }

        /*
        * Function: _fnReadCookie
        * Purpose:  Read an old cookie to get a cookie with an old table state
        * Returns:  string: - contents of the cookie - or null if no cookie with that name found
        * Inputs:   string:sName - name of the cookie to read
        */
        function _fnReadCookie(sName) {
            var sNameEQ = sName + '_' + window.location.pathname.replace(/[\/:]/g, "").toLowerCase() + "=";
            var sCookieContents = document.cookie.split(';');

            for (var i = 0; i < sCookieContents.length; i++) {
                var c = sCookieContents[i];

                while (c.charAt(0) == ' ') {
                    c = c.substring(1, c.length);
                }

                if (c.indexOf(sNameEQ) === 0) {
                    return c.substring(sNameEQ.length, c.length);
                }
            }
            return null;
        }

        /*
        * Function: _fnGetUniqueThs
        * Purpose:  Get an array of unique th elements, one for each column
        * Returns:  array node:aReturn - list of unique ths
        * Inputs:   node:nThead - The thead element for the table
        */
        function _fnGetUniqueThs(nThead) {
            var nTrs = nThead.getElementsByTagName('tr');

            /* Nice simple case */
            if (nTrs.length == 1) {
                return nTrs[0].getElementsByTagName('th');
            }

            /* Otherwise we need to figure out the layout array to get the nodes */
            var aLayout = [], aReturn = [];
            var ROWSPAN = 2, COLSPAN = 3, TDELEM = 4;
            var i, j, k, iLen, jLen, iColumnShifted;
            var fnShiftCol = function(a, i, j) {
                while (typeof a[i][j] != 'undefined') {
                    j++;
                }
                return j;
            };
            var fnAddRow = function(i) {
                if (typeof aLayout[i] == 'undefined') {
                    aLayout[i] = [];
                }
            };

            /* Calculate a layout array */
            for (i = 0, iLen = nTrs.length; i < iLen; i++) {
                fnAddRow(i);
                var iColumn = 0;
                var nTds = [];

                for (j = 0, jLen = nTrs[i].childNodes.length; j < jLen; j++) {
                    if (nTrs[i].childNodes[j].nodeName == "TD" || nTrs[i].childNodes[j].nodeName == "TH") {
                        nTds.push(nTrs[i].childNodes[j]);
                    }
                }

                for (j = 0, jLen = nTds.length; j < jLen; j++) {
                    var iColspan = nTds[j].getAttribute('colspan') * 1;
                    var iRowspan = nTds[j].getAttribute('rowspan') * 1;

                    if (!iColspan || iColspan === 0 || iColspan === 1) {
                        iColumnShifted = fnShiftCol(aLayout, i, iColumn);
                        aLayout[i][iColumnShifted] = (nTds[j].nodeName == "TD") ? TDELEM : nTds[j];
                        if (iRowspan || iRowspan === 0 || iRowspan === 1) {
                            for (k = 1; k < iRowspan; k++) {
                                fnAddRow(i + k);
                                aLayout[i + k][iColumnShifted] = ROWSPAN;
                            }
                        }
                        iColumn++;
                    }
                    else {
                        iColumnShifted = fnShiftCol(aLayout, i, iColumn);
                        for (k = 0; k < iColspan; k++) {
                            aLayout[i][iColumnShifted + k] = COLSPAN;
                        }
                        iColumn += iColspan;
                    }
                }
            }

            /* Convert the layout array into a node array
            * Note the use of aLayout[0] in the outloop, we want the outer loop to occur the same
            * number of times as there are columns. Unusual having nested loops this way around
            * but is what we need here.
            */
            for (i = 0, iLen = aLayout[0].length; i < iLen; i++) {
                for (j = 0, jLen = aLayout.length; j < jLen; j++) {
                    if (typeof aLayout[j][i] == 'object') {
                        aReturn.push(aLayout[j][i]);
                    }
                }
            }

            return aReturn;
        }

        /*
        * Function: _fnMap
        * Purpose:  See if a property is defined on one object, if so assign it to the other object
        * Returns:  - (done by reference)
        * Inputs:   object:oRet - target object
        *           object:oSrc - source object
        *           string:sName - property
        *           string:sMappedName - name to map too - optional, sName used if not given
        */
        function _fnMap(oRet, oSrc, sName, sMappedName) {
            if (typeof sMappedName == 'undefined') {
                sMappedName = sName;
            }
            if (typeof oSrc[sName] != 'undefined') {
                oRet[sMappedName] = oSrc[sName];
            }
        }

        /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
        * API
        * 
        * I'm not overly happy with this solution - I'd much rather that there was a way of getting
        * a list of all the private functions and do what we need to dynamically - but that doesn't
        * appear to be possible. Bonkers. A better solution would be to provide a 'bind' type object
        * To do - bind type method in DTs 1.6.
        */
        this.oApi._fnInitalise = _fnInitalise;
        this.oApi._fnLanguageProcess = _fnLanguageProcess;
        this.oApi._fnAddColumn = _fnAddColumn;
        this.oApi._fnAddData = _fnAddData;
        this.oApi._fnGatherData = _fnGatherData;
        this.oApi._fnDrawHead = _fnDrawHead;
        this.oApi._fnDraw = _fnDraw;
        this.oApi._fnAjaxUpdate = _fnAjaxUpdate;
        this.oApi._fnAddOptionsHtml = _fnAddOptionsHtml;
        this.oApi._fnFeatureHtmlFilter = _fnFeatureHtmlFilter;
        this.oApi._fnFeatureHtmlInfo = _fnFeatureHtmlInfo;
        this.oApi._fnFeatureHtmlPaginate = _fnFeatureHtmlPaginate;
        this.oApi._fnFeatureHtmlLength = _fnFeatureHtmlLength;
        this.oApi._fnFeatureHtmlProcessing = _fnFeatureHtmlProcessing;
        this.oApi._fnProcessingDisplay = _fnProcessingDisplay;
        this.oApi._fnFilterComplete = _fnFilterComplete;
        this.oApi._fnFilterColumn = _fnFilterColumn;
        this.oApi._fnFilter = _fnFilter;
        this.oApi._fnSortingClasses = _fnSortingClasses;
        this.oApi._fnVisibleToColumnIndex = _fnVisibleToColumnIndex;
        this.oApi._fnColumnIndexToVisible = _fnColumnIndexToVisible;
        this.oApi._fnVisbleColumns = _fnVisbleColumns;
        this.oApi._fnBuildSearchArray = _fnBuildSearchArray;
        this.oApi._fnDataToSearch = _fnDataToSearch;
        this.oApi._fnCalculateEnd = _fnCalculateEnd;
        this.oApi._fnConvertToWidth = _fnConvertToWidth;
        this.oApi._fnCalculateColumnWidths = _fnCalculateColumnWidths;
        this.oApi._fnArrayCmp = _fnArrayCmp;
        this.oApi._fnDetectType = _fnDetectType;
        this.oApi._fnGetDataMaster = _fnGetDataMaster;
        this.oApi._fnGetTrNodes = _fnGetTrNodes;
        this.oApi._fnEscapeRegex = _fnEscapeRegex;
        this.oApi._fnReOrderIndex = _fnReOrderIndex;
        this.oApi._fnColumnOrdering = _fnColumnOrdering;
        this.oApi._fnClearTable = _fnClearTable;
        this.oApi._fnSaveState = _fnSaveState;
        this.oApi._fnLoadState = _fnLoadState;
        this.oApi._fnCreateCookie = _fnCreateCookie;
        this.oApi._fnReadCookie = _fnReadCookie;
        this.oApi._fnGetUniqueThs = _fnGetUniqueThs;

        /* Want to be able to reference "this" inside the this.each function */
        var _that = this;


        /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
        * Constructor
        */
        return this.each(function() {
            /* Make a complete and independent copy of the settings object */
            var oSettings = new classSettings();
            _aoSettings.push(oSettings);

            var i = 0, iLen;
            var bInitHandedOff = false;
            var bUsePassedData = false;

            /* Set the id */
            var sId = this.getAttribute('id');
            if (sId !== null) {
                oSettings.sTableId = sId;
                oSettings.sInstance = sId;
            }
            else {
                oSettings.sInstance = _oExt._oExternConfig.iNextUnique++;
            }

            /* Set the table node */
            oSettings.nTable = this;

            /* Bind the API functions to the settings, so we can perform actions whenever oSettings is
            * available
            */
            oSettings.oApi = _that.oApi;

            /* Store the features that we have available */
            if (typeof oInit != 'undefined' && oInit !== null) {
                _fnMap(oSettings.oFeatures, oInit, "bPaginate");
                _fnMap(oSettings.oFeatures, oInit, "bLengthChange");
                _fnMap(oSettings.oFeatures, oInit, "bFilter");
                _fnMap(oSettings.oFeatures, oInit, "bSort");
                _fnMap(oSettings.oFeatures, oInit, "bInfo");
                _fnMap(oSettings.oFeatures, oInit, "bProcessing");
                _fnMap(oSettings.oFeatures, oInit, "bAutoWidth");
                _fnMap(oSettings.oFeatures, oInit, "bSortClasses");
                _fnMap(oSettings.oFeatures, oInit, "bServerSide");
                _fnMap(oSettings, oInit, "asStripClasses");
                _fnMap(oSettings, oInit, "fnRowCallback");
                _fnMap(oSettings, oInit, "fnHeaderCallback");
                _fnMap(oSettings, oInit, "fnFooterCallback");
                _fnMap(oSettings, oInit, "fnDrawCallback");
                _fnMap(oSettings, oInit, "fnInitComplete");
                _fnMap(oSettings, oInit, "fnServerData");
                _fnMap(oSettings, oInit, "aaSorting");
                _fnMap(oSettings, oInit, "aaSortingFixed");
                _fnMap(oSettings, oInit, "sPaginationType");
                _fnMap(oSettings, oInit, "sAjaxSource");
                _fnMap(oSettings, oInit, "sDom", "sDomPositioning");
                _fnMap(oSettings, oInit, "oSearch", "oPreviousSearch");
                _fnMap(oSettings, oInit, "aoSearchCols", "aoPreSearchCols");
                _fnMap(oSettings, oInit, "iDisplayLength", "_iDisplayLength");
                _fnMap(oSettings, oInit, "bJQueryUI", "bJUI");

                if (typeof oInit.bJQueryUI != 'undefined') {
                    /* Use the JUI classes object for display. You could clone the oStdClasses object if 
                    * you want to have multiple tables with multiple independent classes 
                    */
                    oSettings.oClasses = _oExt.oJUIClasses;

                    if (typeof oInit.sDom == 'undefined') {
                        /* Set the DOM to use a layout suitable for jQuery UI's theming */
                        oSettings.sDomPositioning =
							'<"fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix"lfr>' +
							't' +
							'<"fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix"ip>';
                    }
                }

                if (typeof oInit.iDisplayStart != 'undefined' &&
				     typeof oSettings.iInitDisplayStart == 'undefined') {
                    /* Display start point, taking into account the save saving */
                    oSettings.iInitDisplayStart = oInit.iDisplayStart;
                    oSettings._iDisplayStart = oInit.iDisplayStart;
                }

                /* Must be done after everything which can be overridden by a cookie! */
                if (typeof oInit.bStateSave != 'undefined') {
                    oSettings.oFeatures.bStateSave = oInit.bStateSave;
                    _fnLoadState(oSettings, oInit);
                }

                if (typeof oInit.aaData != 'undefined') {
                    bUsePassedData = true;
                }

                /* Backwards compatability */
                /* aoColumns / aoData - remove at some point... */
                if (typeof oInit != 'undefined' && typeof oInit.aoData != 'undefined') {
                    oInit.aoColumns = oInit.aoData;
                }

                /* Language definitions */
                if (typeof oInit.oLanguage != 'undefined') {
                    if (typeof oInit.oLanguage.sUrl != 'undefined' && oInit.oLanguage.sUrl !== "") {
                        /* Get the language definitions from a file */
                        oSettings.oLanguage.sUrl = oInit.oLanguage.sUrl;
                        $.getJSON(oSettings.oLanguage.sUrl, null, function(json) {
                            _fnLanguageProcess(oSettings, json, true);
                        });
                        bInitHandedOff = true;
                    }
                    else {
                        _fnLanguageProcess(oSettings, oInit.oLanguage, false);
                    }
                }
                /* Warning: The _fnLanguageProcess function is async to the remainder of this function due
                * to the XHR. We use _bInitialised in _fnLanguageProcess() to check this the processing 
                * below is complete. The reason for spliting it like this is optimisation - we can fire
                * off the XHR (if needed) and then continue processing the data.
                */
            }

            /* Add the strip classes now that we know which classes to apply - unless overruled */
            if (typeof oInit == 'undefined' || typeof oInit.asStripClasses == 'undefined') {
                oSettings.asStripClasses.push(oSettings.oClasses.sStripOdd);
                oSettings.asStripClasses.push(oSettings.oClasses.sStripEven);
            }

            /* See if we should load columns automatically or use defined ones - a bit messy this... */
            var nThead = this.getElementsByTagName('thead');
            var nThs = nThead.length === 0 ? null : _fnGetUniqueThs(nThead[0]);
            var bUseCols = typeof oInit != 'undefined' && typeof oInit.aoColumns != 'undefined';
            for (i = 0, iLen = bUseCols ? oInit.aoColumns.length : nThs.length; i < iLen; i++) {
                var col = bUseCols ? oInit.aoColumns[i] : null;
                var n = nThs ? nThs[i] : null;
                _fnAddColumn(oSettings, col, n);
            }

            /* Sanity check that there is a thead and tfoot. If not let's just create them */
            if (this.getElementsByTagName('thead').length === 0) {
                this.appendChild(document.createElement('thead'));
            }

            if (this.getElementsByTagName('tbody').length === 0) {
                this.appendChild(document.createElement('tbody'));
            }

            /* Check if there is data passing into the constructor */
            if (bUsePassedData) {
                for (i = 0; i < oInit.aaData.length; i++) {
                    _fnAddData(oSettings, oInit.aaData[i]);
                }
            }
            else {
                /* Grab the data from the page */
                _fnGatherData(oSettings);
            }

            /* Copy the data index array */
            oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();

            /* Calculate sizes for columns */
            if (oSettings.oFeatures.bAutoWidth) {
                _fnCalculateColumnWidths(oSettings);
            }

            /* Initialisation complete - table can be drawn */
            oSettings.bInitialised = true;

            /* Check if we need to initialise the table (it might not have been handed off to the
            * language processor)
            */
            if (bInitHandedOff === false) {
                _fnInitalise(oSettings);
            }
        });
    };
})(jQuery);

// End ~/Scripts/jquery.dataTables.js

// Begin ~/Scripts/jquery.swfobject.min.js

/* jquery.swfobject.license.txt */
(function(A){A.flashPlayerVersion=function(){var D,B=null,I=false,H="ShockwaveFlash.ShockwaveFlash";if(!(D=navigator.plugins["Shockwave Flash"])){try{B=new ActiveXObject(H+".7")}catch(G){try{B=new ActiveXObject(H+".6");D=[6,0,21];B.AllowScriptAccess="always"}catch(F){if(D&&D[0]===6){I=true}}if(!I){try{B=new ActiveXObject(H)}catch(E){D="X 0,0,0"}}}if(!I&&B){try{D=B.GetVariable("$version")}catch(C){}}}else{D=D.description}D=D.match(/^[A-Za-z\s]*?(\d+)(\.|,)(\d+)(\s+r|,)(\d+)/);return[D[1]*1,D[3]*1,D[5]*1]}();A.flashExpressInstaller="expressInstall.swf";A.hasFlashPlayer=(A.flashPlayerVersion[0]!==0);A.hasFlashPlayerVersion=function(C){var B=A.flashPlayerVersion;C=(/string|integer/.test(typeof C))?C.toString().split("."):C;return(C)?(B[0]>=(C.major||C[0]||B[0])&&B[1]>=(C.minor||C[1]||B[1])&&B[2]>=(C.release||C[2]||B[2])):(B[0]!==0)};A.flash=function(M){if(!A.hasFlashPlayer){return false}var C=M.swf||"",K=M.params||{},E=document.createElement("body"),B,L,H,D,J,I,G,F;M.height=M.height||180;M.width=M.width||320;if(M.hasVersion&&!A.hasFlashPlayerVersion(M.hasVersion)){A.extend(M,{id:"SWFObjectExprInst",height:Math.max(M.height,137),width:Math.max(M.width,214)});C=M.expressInstaller||A.flashExpressInstaller;K={flashvars:{MMredirectURL:window.location.href,MMplayerType:(A.browser.msie&&A.browser.win)?"ActiveX":"PlugIn",MMdoctitle:document.title.slice(0,47)+" - Flash Player Installation"}}}if(M.flashvars&&typeof K==="object"){A.extend(K,{flashvars:M.flashvars})}for(J in (I=["swf","expressInstall","hasVersion","params","flashvars"])){delete M[I[J]]}B=[];for(J in M){if(typeof M[J]==="object"){L=[];for(I in M[J]){L.push(I.replace(/([A-Z])/,"-$1").toLowerCase()+":"+M[J][I]+";")}M[J]=L.join("")}B.push(J+'="'+M[J]+'"')}M=B.join(" ");if(typeof K==="object"){B=[];for(J in K){if(typeof K[J]==="object"){L=[];for(I in K[J]){if(typeof K[J][I]==="object"){H=[];for(G in K[J][I]){if(typeof K[J][I][G]==="object"){D=[];for(F in K[J][I][G]){D.push(F.replace(/([A-Z])/,"-$1").toLowerCase()+":"+K[J][I][G][F]+";")}K[J][I][G]=D.join("")}H.push(G+"{"+K[J][I][G]+"}")}K[J][I]=H.join("")}L.push(window.escape(I)+"="+window.escape(K[J][I]))}K[J]=L.join("&amp;")}B.push('<PARAM NAME="'+J+'" VALUE="'+K[J]+'">')}K=B.join("")}if(!(/style=/.test(M))){M+=' style="vertical-align:text-top;"'}if(!(/style=(.*?)vertical-align/.test(M))){M=M.replace(/style="/,'style="vertical-align:text-top;')}if(A.browser.msie){M+=' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';K='<PARAM NAME="movie" VALUE="'+C+'">'+K}else{M+=' type="application/x-shockwave-flash" data="'+C+'"'}E.innerHTML="<OBJECT "+M+">"+K+"</OBJECT>";return A(E.firstChild)};A.fn.flash=function(C){if(!A.hasFlashPlayer){return this}var B=0,D;while((D=this.eq(B++))[0]){D.html(A.flash(A.extend({},C)));if(D[0].firstChild.getAttribute("id")==="SWFObjectExprInst"){B=this.length}}return this}}(jQuery));
// End ~/Scripts/jquery.swfobject.min.js


