/* ------------------------------------------------------------------------------------------------------------------------------------
* All plugin are made by Boris Strahija
* Copyright 2009, Boris Strahija
* http://www.creolab.hr/
*
* ------------------------------------------------------------------------------------------------------------------------------------ */

/* ------------------------------------------------------------------------------------------------------------------------------------
* Contact picker
* ------------------------------------------------------------------------------------------------------------------------------------ */
(function($jq) {
    $.fn.contactPicker = function(params) {
        // Default options
        var params = jQuery.extend({

    }, params);

    $jq(this).each(function() {
        var el = this;

        // First find the picker
        var picker = $jq(el).find("select");

        // Continue if picker exists
        if (picker.length > 0) {
            // Hide all content
            $jq(el).children("ul").hide().eq($jq(picker).val() - 1).show();

            // Add change event
            $jq(picker).change(function() {
                $jq(el).children("ul").hide().eq($jq(picker).val() - 1).show();
            });

        } //end if

    }); //end each()

}; //end function()
})(jQuery);



/* ------------------------------------------------------------------------------------------------------------------------------------
* Accordion
* ------------------------------------------------------------------------------------------------------------------------------------ */
(function($jq) {
    $.fn.accordion = function(params) {
        // Default options
        var params = jQuery.extend({
            all_closed: false
			 , open: 0
			 , multi: false 	// Allow for multiple blocks to be opened
			 , close: true 	// Allow to close current block
			 , speedUp: 330 	// Speed of close animation
			 , speedDown: 300 	// Speed of open animation
        }, params);

        $jq(this).each(function() {
            var el = $jq(this);
            var current = params.open;
            var animating = false;

            // Set the count
            var total = $jq(el).children(".acc").length;

            // Add special class to last element
            $jq(el).children(".acc:last").addClass("last");

            // Init content
            $jq(el).find(".acc .cont").hide();
            if (!params.all_closed == true) {
                if (current[0] === undefined) {
                    current_num = current;
                    current = new Array(current);
                    current[0] = current_num;
                } //end if

                $jq(current).each(function(ind, vl) {
                    $jq(el).find("a.toggle:eq(" + this + ")").parent("li").addClass("open");
                    $jq(el).find("a.toggle:eq(" + this + ")").addClass("open");
                    $jq(el).find(".acc:eq(" + this + ") .cont").addClass("open").show();
                });
            } //end if

            // Add click events
            $jq(el).find("a.toggle").css("outline", "none");
            $jq(el).find("a.toggle").each(function(num) {
                $jq(this).click(function() {
                    var num_open = $jq(el).find("a.toggle.open").length;

                    // Toggle clicked item
                    if (params.multi) { // Item can be closed
                        if ($jq(this).hasClass("open")) {
                            $jq(this).removeClass("open");
                            $jq(el).find(".acc:eq(" + num + ") .cont").slideUp(params.speedDown).removeClass("open");
                        } else {
                            $jq(this).addClass("open");
                            $jq(el).find(".acc:eq(" + num + ") .cont").slideDown(params.speedDown).addClass("open");
                        } //end if

                    } else {
                        if (!$jq(this).hasClass("open")) {
                            // Close all other if multi open is disabled
                            $jq(el).find("a.toggle.open").removeClass("open");
                            $jq(el).find(".cont.open").slideUp(params.speedUp).removeClass("open");

                            // Open current
                            $jq(this).addClass("open");
                            $jq(el).find(".acc:eq(" + num + ") .cont").slideDown(params.speedDown).addClass("open");
                        } else if (params.close) {
                            $jq(this).removeClass("open");
                            $jq(el).find(".acc:eq(" + num + ") .cont").slideUp(params.speedDown).removeClass("open");
                        } //end if
                    } //end if

                    return false;
                }); //end click()
            }); //end each()
        }); // end each()
    }; //end function()
})(jQuery);





/* ------------------------------------------------------------------------------------------------------------------------------------
* News scroller
* ------------------------------------------------------------------------------------------------------------------------------------ */
(function($jq) {
    $.fn.newsScroller = function(params) {
        // Default options
        var params = jQuery.extend({
            controls: $jq(".news-scroll")
			, circular: true
        }, params);

        $jq(this).each(function() {
            var el = $jq(this);
            var current = 0;
            var animating = false;

            // Set the count
            var total = $jq(el).children(".scroll").length;
            $jq(params.controls).children("span").html("1 / " + total);

            // Init content
            $jq(params.controls).find("a.prev").css("outline", "none");
            $jq(params.controls).find("a.next").css("outline", "none");
            $jq(el).find(".scroll").hide();
            $jq(el).find(".scroll:eq(" + current + ")").show();

            // Add click events
            $jq(params.controls).find("a.next").click(function() {
                go_slide(1);
                return false;
            });
            $jq(params.controls).find("a.prev").click(function() {
                go_slide(-1);
                return false;
            });

            function go_slide(inc) {
                var next = current + inc;
                if (params.circular) {
                    if (next < 0) next = total - 1;
                    if (next >= total) next = 0;
                } else {
                    if (next < 0) next = 0;
                    if (next >= total) next = total - 1;
                } //end if

                // Animate
                if (!animating) {
                    animating = true;
                    $jq(el).find(".scroll:eq(" + current + ")").fadeOut(200, function() {
                        $jq(el).find(".scroll:eq(" + next + ")").fadeIn(200, function() {
                            current = next;
                            $jq(params.controls).children("span").html((current + 1) + " / " + total);
                            animating = false;
                        });
                    });
                } //end if
            } //end go_slide()
        }); // end each()
    }; //end function()
})(jQuery);



/* ------------------------------------------------------------------------------------------------------------------------------------
* Tabs
* ------------------------------------------------------------------------------------------------------------------------------------ */
(function($jq) {
    $.fn.tabbed = function() {
        $jq(this).each(function() {
            var el = $jq(this);

            var param;

            if ($jq(document).getUrlParam('tabid'))
            { param = $jq(document).getUrlParam('tabid'); }
            else {
                param = 0;
            }
            
            if ($jq(el).find(".tabs a").hasClass('tab' + param)) {
                $jq(el).find(".tabs a").removeClass("on");
                //$jq(el).find(".tabs a:eq(" + 'tab' + param + ")").addClass("on");
                $jq(el).find(".tabs a:eq("+param+")").addClass("on");
            }
            
            // Init marker
            $jq(el).find(".tabs a").css("outline", "none");
            //$jq(el).find(".tabs a").removeClass("on");
            //$jq(el).find(".tabs a:eq(1)").addClass("on");

            // Init content
            $jq(el).find(".content > div").hide();
            //$jq(el).find(".content > div:eq(0)").show();
            $jq(el).find(".content > div:eq(" + param + ")").show();

            // Fix tabs in IE6
            if ($jq.browser.msie) $jq(el).find(".tabs a em").wrapInner('<span></span>');

            // Add click events
            $jq(el).find(".tabs a").each(function(num) {
                $jq(this).click(function() {
                    // Marker
                    $jq(el).find(".tabs a").removeClass("on");
                    $jq(this).addClass("on");

                    //content
                    $jq(el).find(".content > div").hide();
                    $jq(el).find(".content > div:eq(" + num + ")").show();

                    return false;
                }); //end click()
            }); //end each()
        }); // end each()
    }; //end function()
})(jQuery);



/* ------------------------------------------------------------------------------------------------------------------------------------
* Align an element vertical
* ------------------------------------------------------------------------------------------------------------------------------------ */
(function($jq) {
    // VERTICALLY ALIGN FUNCTION
    $.fn.vAlign = function() {
        return this.each(function(i) {
            var ah = $jq(this).height();
            var ph = $jq(this).parent().height();
            var mh = (ph - ah) / 2;
            $jq(this).css('padding-top', mh);
        });
    };
})(jQuery);



/* ------------------------------------------------------------------------------------------------------------------------------------
* Add custom buttons
* ------------------------------------------------------------------------------------------------------------------------------------ */
(function($jq) {
    $.fn.customButton = function() {
        $jq(this).each(function() {
            var el = $jq(this);
            var tt = el.text() || el.val();

            if ($jq(':submit,:button', this)) {
                el.after('<a href="#" class="btn btn-' + el.attr("type") + '"><em>' + tt + '</em></a>'); new_el = el.next("a");

                // Add submit action
                if (el.attr("type") == "submit") {
                    new_el.click(function() {
                        var form = $jq(this).parents('form:first');
                        form.submit();
                        return false;
                    }); //end click

                } else if (el.attr("type") == "submit") {
                    new_el.click(function() {
                        var form = $jq(this).parents('form:first');
                        form.reset();
                        return false;
                    }); //end click

                } else {
                    new_el.click(function() { return false; });

                } // end if

                // Add hover class
                $jq(new_el).hover(
					 function() { $jq(this).addClass("hover"); }
					, function() { $jq(this).removeClass("hover"); }
				);

                // Remove the button
                el.remove();
            } //end if
        }); // end each()
    }; //end function()
})(jQuery);




(function($jq) {
    // VERTICALLY ALIGN FUNCTION
    $.fn.customButtons = function() {
        var b = $jq(this);
        var tt = b.text() || b.val();

    };
})(jQuery);




/* ------------------------------------------------------------------------------------------------------------------------------------
* Equal height columns
* ------------------------------------------------------------------------------------------------------------------------------------ */
$.fn.equalHeight = function(substract) {
    var tallest = 0;
    $jq(this).each(function() {
        var this_height = $jq(this).height();
        if (this_height > tallest) {
            tallest = this_height;
        } //end if
    });
    if (substract) tallest -= substract;
    $jq(this).height(tallest);
};


/* ------------------------------------------------------------------------
Table sorter
------------------------------------------------------------------------- */
(function($) { $.extend({ tablesorter: new function() { var parsers = [], widgets = []; this.defaults = { cssHeader: "header", cssAsc: "headerSortUp", cssDesc: "headerSortDown", sortInitialOrder: "asc", sortMultiSortKey: "shiftKey", sortForce: null, sortAppend: null, textExtraction: "simple", parsers: {}, widgets: [], widgetZebra: { css: ["even", "odd"] }, headers: {}, widthFixed: false, cancelSelection: true, sortList: [], headerList: [], dateFormat: "us", decimal: '.', debug: false }; function benchmark(s, d) { log(s + "," + (new Date().getTime() - d.getTime()) + "ms"); } this.benchmark = benchmark; function log(s) { if (typeof console != "undefined" && typeof console.debug != "undefined") { console.log(s); } else { alert(s); } } function buildParserCache(table, $headers) { if (table.config.debug) { var parsersDebug = ""; } var rows = table.tBodies[0].rows; if (table.tBodies[0].rows[0]) { var list = [], cells = rows[0].cells, l = cells.length; for (var i = 0; i < l; i++) { var p = false; if ($.metadata && ($($headers[i]).metadata() && $($headers[i]).metadata().sorter)) { p = getParserById($($headers[i]).metadata().sorter); } else if ((table.config.headers[i] && table.config.headers[i].sorter)) { p = getParserById(table.config.headers[i].sorter); } if (!p) { p = detectParserForColumn(table, cells[i]); } if (table.config.debug) { parsersDebug += "column:" + i + " parser:" + p.id + "\n"; } list.push(p); } } if (table.config.debug) { log(parsersDebug); } return list; }; function detectParserForColumn(table, node) { var l = parsers.length; for (var i = 1; i < l; i++) { if (parsers[i].is($.trim(getElementText(table.config, node)), table, node)) { return parsers[i]; } } return parsers[0]; } function getParserById(name) { var l = parsers.length; for (var i = 0; i < l; i++) { if (parsers[i].id.toLowerCase() == name.toLowerCase()) { return parsers[i]; } } return false; } function buildCache(table) { if (table.config.debug) { var cacheTime = new Date(); } var totalRows = (table.tBodies[0] && table.tBodies[0].rows.length) || 0, totalCells = (table.tBodies[0].rows[0] && table.tBodies[0].rows[0].cells.length) || 0, parsers = table.config.parsers, cache = { row: [], normalized: [] }; for (var i = 0; i < totalRows; ++i) { var c = table.tBodies[0].rows[i], cols = []; cache.row.push($(c)); for (var j = 0; j < totalCells; ++j) { cols.push(parsers[j].format(getElementText(table.config, c.cells[j]), table, c.cells[j])); } cols.push(i); cache.normalized.push(cols); cols = null; }; if (table.config.debug) { benchmark("Building cache for " + totalRows + " rows:", cacheTime); } return cache; }; function getElementText(config, node) { if (!node) return ""; var t = ""; if (config.textExtraction == "simple") { if (node.childNodes[0] && node.childNodes[0].hasChildNodes()) { t = node.childNodes[0].innerHTML; } else { t = node.innerHTML; } } else { if (typeof (config.textExtraction) == "function") { t = config.textExtraction(node); } else { t = $(node).text(); } } return t; } function appendToTable(table, cache) { if (table.config.debug) { var appendTime = new Date() } var c = cache, r = c.row, n = c.normalized, totalRows = n.length, checkCell = (n[0].length - 1), tableBody = $(table.tBodies[0]), rows = []; for (var i = 0; i < totalRows; i++) { rows.push(r[n[i][checkCell]]); if (!table.config.appender) { var o = r[n[i][checkCell]]; var l = o.length; for (var j = 0; j < l; j++) { tableBody[0].appendChild(o[j]); } } } if (table.config.appender) { table.config.appender(table, rows); } rows = null; if (table.config.debug) { benchmark("Rebuilt table:", appendTime); } applyWidget(table); setTimeout(function() { $(table).trigger("sortEnd"); }, 0); }; function buildHeaders(table) { if (table.config.debug) { var time = new Date(); } var meta = ($.metadata) ? true : false, tableHeadersRows = []; for (var i = 0; i < table.tHead.rows.length; i++) { tableHeadersRows[i] = 0; }; $tableHeaders = $("thead th", table); $tableHeaders.each(function(index) { this.count = 0; this.column = index; this.order = formatSortingOrder(table.config.sortInitialOrder); if (checkHeaderMetadata(this) || checkHeaderOptions(table, index)) this.sortDisabled = true; if (!this.sortDisabled) { $(this).addClass(table.config.cssHeader); } table.config.headerList[index] = this; }); if (table.config.debug) { benchmark("Built headers:", time); log($tableHeaders); } return $tableHeaders; }; function checkCellColSpan(table, rows, row) { var arr = [], r = table.tHead.rows, c = r[row].cells; for (var i = 0; i < c.length; i++) { var cell = c[i]; if (cell.colSpan > 1) { arr = arr.concat(checkCellColSpan(table, headerArr, row++)); } else { if (table.tHead.length == 1 || (cell.rowSpan > 1 || !r[row + 1])) { arr.push(cell); } } } return arr; }; function checkHeaderMetadata(cell) { if (($.metadata) && ($(cell).metadata().sorter === false)) { return true; }; return false; } function checkHeaderOptions(table, i) { if ((table.config.headers[i]) && (table.config.headers[i].sorter === false)) { return true; }; return false; } function applyWidget(table) { var c = table.config.widgets; var l = c.length; for (var i = 0; i < l; i++) { getWidgetById(c[i]).format(table); } } function getWidgetById(name) { var l = widgets.length; for (var i = 0; i < l; i++) { if (widgets[i].id.toLowerCase() == name.toLowerCase()) { return widgets[i]; } } }; function formatSortingOrder(v) { if (typeof (v) != "Number") { i = (v.toLowerCase() == "desc") ? 1 : 0; } else { i = (v == (0 || 1)) ? v : 0; } return i; } function isValueInArray(v, a) { var l = a.length; for (var i = 0; i < l; i++) { if (a[i][0] == v) { return true; } } return false; } function setHeadersCss(table, $headers, list, css) { $headers.removeClass(css[0]).removeClass(css[1]); var h = []; $headers.each(function(offset) { if (!this.sortDisabled) { h[this.column] = $(this); } }); var l = list.length; for (var i = 0; i < l; i++) { h[list[i][0]].addClass(css[list[i][1]]); } } function fixColumnWidth(table, $headers) { var c = table.config; if (c.widthFixed) { var colgroup = $('<colgroup>'); $("tr:first td", table.tBodies[0]).each(function() { colgroup.append($('<col>').css('width', $(this).width())); }); $(table).prepend(colgroup); }; } function updateHeaderSortCount(table, sortList) { var c = table.config, l = sortList.length; for (var i = 0; i < l; i++) { var s = sortList[i], o = c.headerList[s[0]]; o.count = s[1]; o.count++; } } function multisort(table, sortList, cache) { if (table.config.debug) { var sortTime = new Date(); } var dynamicExp = "var sortWrapper = function(a,b) {", l = sortList.length; for (var i = 0; i < l; i++) { var c = sortList[i][0]; var order = sortList[i][1]; var s = (getCachedSortType(table.config.parsers, c) == "text") ? ((order == 0) ? "sortText" : "sortTextDesc") : ((order == 0) ? "sortNumeric" : "sortNumericDesc"); var e = "e" + i; dynamicExp += "var " + e + " = " + s + "(a[" + c + "],b[" + c + "]); "; dynamicExp += "if(" + e + ") { return " + e + "; } "; dynamicExp += "else { "; } var orgOrderCol = cache.normalized[0].length - 1; dynamicExp += "return a[" + orgOrderCol + "]-b[" + orgOrderCol + "];"; for (var i = 0; i < l; i++) { dynamicExp += "}; "; } dynamicExp += "return 0; "; dynamicExp += "}; "; eval(dynamicExp); cache.normalized.sort(sortWrapper); if (table.config.debug) { benchmark("Sorting on " + sortList.toString() + " and dir " + order + " time:", sortTime); } return cache; }; function sortText(a, b) { return ((a < b) ? -1 : ((a > b) ? 1 : 0)); }; function sortTextDesc(a, b) { return ((b < a) ? -1 : ((b > a) ? 1 : 0)); }; function sortNumeric(a, b) { return a - b; }; function sortNumericDesc(a, b) { return b - a; }; function getCachedSortType(parsers, i) { return parsers[i].type; }; this.construct = function(settings) { return this.each(function() { if (!this.tHead || !this.tBodies) return; var $this, $document, $headers, cache, config, shiftDown = 0, sortOrder; this.config = {}; config = $.extend(this.config, $.tablesorter.defaults, settings); $this = $(this); $headers = buildHeaders(this); this.config.parsers = buildParserCache(this, $headers); cache = buildCache(this); var sortCSS = [config.cssDesc, config.cssAsc]; fixColumnWidth(this); $headers.click(function(e) { $this.trigger("sortStart"); var totalRows = ($this[0].tBodies[0] && $this[0].tBodies[0].rows.length) || 0; if (!this.sortDisabled && totalRows > 0) { var $cell = $(this); var i = this.column; this.order = this.count++ % 2; if (!e[config.sortMultiSortKey]) { config.sortList = []; if (config.sortForce != null) { var a = config.sortForce; for (var j = 0; j < a.length; j++) { if (a[j][0] != i) { config.sortList.push(a[j]); } } } config.sortList.push([i, this.order]); } else { if (isValueInArray(i, config.sortList)) { for (var j = 0; j < config.sortList.length; j++) { var s = config.sortList[j], o = config.headerList[s[0]]; if (s[0] == i) { o.count = s[1]; o.count++; s[1] = o.count % 2; } } } else { config.sortList.push([i, this.order]); } }; setTimeout(function() { setHeadersCss($this[0], $headers, config.sortList, sortCSS); appendToTable($this[0], multisort($this[0], config.sortList, cache)); }, 1); return false; } }).mousedown(function() { if (config.cancelSelection) { this.onselectstart = function() { return false }; return false; } }); $this.bind("update", function() { this.config.parsers = buildParserCache(this, $headers); cache = buildCache(this); }).bind("sorton", function(e, list) { $(this).trigger("sortStart"); config.sortList = list; var sortList = config.sortList; updateHeaderSortCount(this, sortList); setHeadersCss(this, $headers, sortList, sortCSS); appendToTable(this, multisort(this, sortList, cache)); }).bind("appendCache", function() { appendToTable(this, cache); }).bind("applyWidgetId", function(e, id) { getWidgetById(id).format(this); }).bind("applyWidgets", function() { applyWidget(this); }); if ($.metadata && ($(this).metadata() && $(this).metadata().sortlist)) { config.sortList = $(this).metadata().sortlist; } if (config.sortList.length > 0) { $this.trigger("sorton", [config.sortList]); } applyWidget(this); }); }; this.addParser = function(parser) { var l = parsers.length, a = true; for (var i = 0; i < l; i++) { if (parsers[i].id.toLowerCase() == parser.id.toLowerCase()) { a = false; } } if (a) { parsers.push(parser); }; }; this.addWidget = function(widget) { widgets.push(widget); }; this.formatFloat = function(s) { var i = parseFloat(s); return (isNaN(i)) ? 0 : i; }; this.formatInt = function(s) { var i = parseInt(s); return (isNaN(i)) ? 0 : i; }; this.isDigit = function(s, config) { var DECIMAL = '\\' + config.decimal; var exp = '/(^[+]?0(' + DECIMAL + '0+)?$)|(^([-+]?[1-9][0-9]*)$)|(^([-+]?((0?|[1-9][0-9]*)' + DECIMAL + '(0*[1-9][0-9]*)))$)|(^[-+]?[1-9]+[0-9]*' + DECIMAL + '0+$)/'; return RegExp(exp).test($.trim(s)); }; this.clearTableBody = function(table) { if ($.browser.msie) { function empty() { while (this.firstChild) this.removeChild(this.firstChild); } empty.apply(table.tBodies[0]); } else { table.tBodies[0].innerHTML = ""; } }; } }); $.fn.extend({ tablesorter: $.tablesorter.construct }); var ts = $.tablesorter; ts.addParser({ id: "text", is: function(s) { return true; }, format: function(s) { return $.trim(s.toLowerCase()); }, type: "text" }); ts.addParser({ id: "digit", is: function(s, table) { var c = table.config; return $.tablesorter.isDigit(s, c); }, format: function(s) { return $.tablesorter.formatFloat(s); }, type: "numeric" }); ts.addParser({ id: "currency", is: function(s) { return /^[£$€?.]/.test(s); }, format: function(s) { return $.tablesorter.formatFloat(s.replace(new RegExp(/[^0-9.]/g), "")); }, type: "numeric" }); ts.addParser({ id: "ipAddress", is: function(s) { return /^\d{2,3}[\.]\d{2,3}[\.]\d{2,3}[\.]\d{2,3}$/.test(s); }, format: function(s) { var a = s.split("."), r = "", l = a.length; for (var i = 0; i < l; i++) { var item = a[i]; if (item.length == 2) { r += "0" + item; } else { r += item; } } return $.tablesorter.formatFloat(r); }, type: "numeric" }); ts.addParser({ id: "url", is: function(s) { return /^(https?|ftp|file):\/\/$/.test(s); }, format: function(s) { return jQuery.trim(s.replace(new RegExp(/(https?|ftp|file):\/\//), '')); }, type: "text" }); ts.addParser({ id: "isoDate", is: function(s) { return /^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(s); }, format: function(s) { return $.tablesorter.formatFloat((s != "") ? new Date(s.replace(new RegExp(/-/g), "/")).getTime() : "0"); }, type: "numeric" }); ts.addParser({ id: "percent", is: function(s) { return /\%$/.test($.trim(s)); }, format: function(s) { return $.tablesorter.formatFloat(s.replace(new RegExp(/%/g), "")); }, type: "numeric" }); ts.addParser({ id: "usLongDate", is: function(s) { return s.match(new RegExp(/^[A-Za-z]{3,10}\.? [0-9]{1,2}, ([0-9]{4}|'?[0-9]{2}) (([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(AM|PM)))$/)); }, format: function(s) { return $.tablesorter.formatFloat(new Date(s).getTime()); }, type: "numeric" }); ts.addParser({ id: "shortDate", is: function(s) { return /\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/.test(s); }, format: function(s, table) { var c = table.config; s = s.replace(/\-/g, "/"); if (c.dateFormat == "us") { s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/, "$3/$1/$2"); } else if (c.dateFormat == "uk") { s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/, "$3/$2/$1"); } else if (c.dateFormat == "dd/mm/yy" || c.dateFormat == "dd-mm-yy") { s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{2})/, "$1/$2/$3"); } return $.tablesorter.formatFloat(new Date(s).getTime()); }, type: "numeric" }); ts.addParser({ id: "time", is: function(s) { return /^(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(am|pm)))$/.test(s); }, format: function(s) { return $.tablesorter.formatFloat(new Date("2000/01/01 " + s).getTime()); }, type: "numeric" }); ts.addParser({ id: "metadata", is: function(s) { return false; }, format: function(s, table, cell) { var c = table.config, p = (!c.parserMetadataName) ? 'sortValue' : c.parserMetadataName; return $(cell).metadata()[p]; }, type: "numeric" }); ts.addWidget({ id: "zebra", format: function(table) { if (table.config.debug) { var time = new Date(); } $("tr:visible", table.tBodies[0]).filter(':even').removeClass(table.config.widgetZebra.css[1]).addClass(table.config.widgetZebra.css[0]).end().filter(':odd').removeClass(table.config.widgetZebra.css[0]).addClass(table.config.widgetZebra.css[1]); if (table.config.debug) { $.tablesorter.benchmark("Applying Zebra widget", time); } } }); })(jQuery);


/* ------------------------------------------------------------------------
prettyCheckboxes
	
Developped By: Stephane Caron (http://www.no-margin-for-errors.com)
Inspired By: All the non user friendly custom checkboxes solutions ;)
Version: 1.1
	
Copyright: Feel free to redistribute the script/modify it, as
long as you leave my infos at the top.
------------------------------------------------------------------------- */
jQuery.fn.prettyCheckboxes = function(A) { A = jQuery.extend({ checkboxWidth: 17, checkboxHeight: 17, className: "prettyCheckbox", display: "list" }, A); $jq(this).each(function() { $label = $jq('label[for="' + $jq(this).attr("id") + '"]'); $label.prepend("<span class='holderWrap'><span class='holder'></span></span>"); if ($jq(this).is(":checked")) { $label.addClass("checked") } $label.addClass(A.className).addClass($jq(this).attr("type")).addClass(A.display); $label.find("span.holderWrap").width(A.checkboxWidth).height(A.checkboxHeight); $label.find("span.holder").width(A.checkboxWidth); $jq(this).addClass("hiddenCheckbox"); $label.bind("click", function() { $jq("input#" + $jq(this).attr("for")).triggerHandler("click"); if ($jq("input#" + $jq(this).attr("for")).is(":checkbox")) { $jq(this).toggleClass("checked"); $jq("input#" + $jq(this).attr("for")).checked = true; $jq(this).find("span.holder").css("top", 0) } else { $toCheck = $jq("input#" + $jq(this).attr("for")); $jq('input[name="' + $toCheck.attr("name") + '"]').each(function() { $jq('label[for="' + $jq(this).attr("id") + '"]').removeClass("checked") }); $jq(this).addClass("checked"); $toCheck.checked = true } }); $jq("input#" + $label.attr("for")).bind("keypress", function(B) { if (B.keyCode == 32) { if ($.browser.msie) { $jq('label[for="' + $jq(this).attr("id") + '"]').toggleClass("checked") } else { $jq(this).trigger("click") } return false } }) }) }; checkAllPrettyCheckboxes = function(B, A) { if ($jq(B).is(":checked")) { $jq(A).find("input[type=checkbox]:not(:checked)").each(function() { $jq('label[for="' + $jq(this).attr("id") + '"]').trigger("click"); if ($.browser.msie) { $jq(this).attr("checked", "checked") } else { $jq(this).trigger("click") } }) } else { $jq(A).find("input[type=checkbox]:checked").each(function() { $jq('label[for="' + $jq(this).attr("id") + '"]').trigger("click"); if ($.browser.msie) { $jq(this).attr("checked", "") } else { $jq(this).trigger("click") } }) } };

/* ------------------------------------------------------------------------
ClearType fix for IE
------------------------------------------------------------------------- */

if ($.browser.msie) {
    (function($) {
        $.fn.fadeIn = function(speed, callback) {
            return this.animate({ opacity: 'show' }, speed, function() {
                if ($.browser.msie) {
                    this.style.removeAttribute('filter');
                }
                if ($.isFunction(callback)) {
                    callback.call(this);
                }
            });
        };

        $.fn.fadeOut = function(speed, callback) {
            return this.animate({ opacity: 'hide' }, speed, function() {
                if ($.browser.msie) {
                    this.style.removeAttribute('filter');
                }
                if ($.isFunction(callback)) {
                    callback.call(this);
                }
            });
        };

        $.fn.fadeTo = function(speed, to, callback) {
            return this.animate({ opacity: to }, speed, function() {
                if (to == 1 && $.browser.msie) {
                    this.style.removeAttribute('filter');
                }
                if ($.isFunction(callback)) {
                    callback.call(this);
                }
            });
        };
    })(jQuery);
} //end if


/*
* jQuery Corners 0.3
* Copyright (c) 2008 David Turnbull, Steven Wittens
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*/
jQuery.fn.corners = function(C) { var N = "rounded_by_jQuery_corners"; var V = B(C); var F = false; try { F = (document.body.style.WebkitBorderRadius !== undefined); var Y = navigator.userAgent.indexOf("Chrome"); if (Y >= 0) { F = false } } catch (E) { } var W = false; try { W = (document.body.style.MozBorderRadius !== undefined); var Y = navigator.userAgent.indexOf("Firefox"); if (Y >= 0 && parseInt(navigator.userAgent.substring(Y + 8)) < 3) { W = false } } catch (E) { } return this.each(function(b, h) { $e = jQuery(h); if ($e.hasClass(N)) { return } $e.addClass(N); var a = /{(.*)}/.exec(h.className); var c = a ? B(a[1], V) : V; var j = h.nodeName.toLowerCase(); if (j == "input") { h = O(h) } if (F && c.webkit) { K(h, c) } else { if (W && c.mozilla && (c.sizex == c.sizey)) { M(h, c) } else { var d = D(h.parentNode); var f = D(h); switch (j) { case "a": case "input": Z(h, c, d, f); break; default: R(h, c, d, f); break } } } }); function K(d, c) { var a = "" + c.sizex + "px " + c.sizey + "px"; var b = jQuery(d); if (c.tl) { b.css("WebkitBorderTopLeftRadius", a) } if (c.tr) { b.css("WebkitBorderTopRightRadius", a) } if (c.bl) { b.css("WebkitBorderBottomLeftRadius", a) } if (c.br) { b.css("WebkitBorderBottomRightRadius", a) } } function M(d, c) { var a = "" + c.sizex + "px"; var b = jQuery(d); if (c.tl) { b.css("-moz-border-radius-topleft", a) } if (c.tr) { b.css("-moz-border-radius-topright", a) } if (c.bl) { b.css("-moz-border-radius-bottomleft", a) } if (c.br) { b.css("-moz-border-radius-bottomright", a) } } function Z(k, n, l, a) { var m = S("table"); var i = S("tbody"); m.appendChild(i); var j = S("tr"); var d = S("td", "top"); j.appendChild(d); var h = S("tr"); var c = T(k, n, S("td")); h.appendChild(c); var f = S("tr"); var b = S("td", "bottom"); f.appendChild(b); if (n.tl || n.tr) { i.appendChild(j); X(d, n, l, a, true) } i.appendChild(h); if (n.bl || n.br) { i.appendChild(f); X(b, n, l, a, false) } k.appendChild(m); if (jQuery.browser.msie) { m.onclick = Q } k.style.overflow = "hidden" } function Q() { if (!this.parentNode.onclick) { this.parentNode.click() } } function O(c) { var b = document.createElement("a"); b.id = c.id; b.className = c.className; if (c.onclick) { b.href = "javascript:"; b.onclick = c.onclick } else { jQuery(c).parent("form").each(function() { b.href = this.action }); b.onclick = I } var a = document.createTextNode(c.value); b.appendChild(a); c.parentNode.replaceChild(b, c); return b } function I() { jQuery(this).parent("form").each(function() { this.submit() }); return false } function R(d, a, b, c) { var f = T(d, a, document.createElement("div")); d.appendChild(f); if (a.tl || a.tr) { X(d, a, b, c, true) } if (a.bl || a.br) { X(d, a, b, c, false) } } function T(j, i, k) { var b = jQuery(j); var l; while (l = j.firstChild) { k.appendChild(l) } if (j.style.height) { var f = parseInt(b.css("height")); k.style.height = f + "px"; f += parseInt(b.css("padding-top")) + parseInt(b.css("padding-bottom")); j.style.height = f + "px" } if (j.style.width) { var a = parseInt(b.css("width")); k.style.width = a + "px"; a += parseInt(b.css("padding-left")) + parseInt(b.css("padding-right")); j.style.width = a + "px" } k.style.paddingLeft = b.css("padding-left"); k.style.paddingRight = b.css("padding-right"); if (i.tl || i.tr) { k.style.paddingTop = U(j, i, b.css("padding-top"), true) } else { k.style.paddingTop = b.css("padding-top") } if (i.bl || i.br) { k.style.paddingBottom = U(j, i, b.css("padding-bottom"), false) } else { k.style.paddingBottom = b.css("padding-bottom") } j.style.padding = 0; return k } function U(f, a, d, c) { if (d.indexOf("px") < 0) { try { console.error("%s padding not in pixels", (c ? "top" : "bottom"), f) } catch (b) { } d = a.sizey + "px" } d = parseInt(d); if (d - a.sizey < 0) { try { console.error("%s padding is %ipx for %ipx corner:", (c ? "top" : "bottom"), d, a.sizey, f) } catch (b) { } d = a.sizey } return d - a.sizey + "px" } function S(b, a) { var c = document.createElement(b); c.style.border = "none"; c.style.borderCollapse = "collapse"; c.style.borderSpacing = 0; c.style.padding = 0; c.style.margin = 0; if (a) { c.style.verticalAlign = a } return c } function D(b) { try { var d = jQuery.css(b, "background-color"); if (d.match(/^(transparent|rgba\(0,\s*0,\s*0,\s*0\))$/i) && b.parentNode) { return D(b.parentNode) } if (d == null) { return "#ffffff" } if (d.indexOf("rgb") > -1) { d = A(d) } if (d.length == 4) { d = L(d) } return d } catch (a) { return "#ffffff" } } function L(a) { return "#" + a.substring(1, 2) + a.substring(1, 2) + a.substring(2, 3) + a.substring(2, 3) + a.substring(3, 4) + a.substring(3, 4) } function A(h) { var a = 255; var d = ""; var b; var e = /([0-9]+)[, ]+([0-9]+)[, ]+([0-9]+)/; var f = e.exec(h); for (b = 1; b < 4; b++) { d += ("0" + parseInt(f[b]).toString(16)).slice(-2) } return "#" + d } function B(b, d) { var b = b || ""; var c = { sizex: 5, sizey: 5, tl: false, tr: false, bl: false, br: false, webkit: true, mozilla: true, transparent: false }; if (d) { c.sizex = d.sizex; c.sizey = d.sizey; c.webkit = d.webkit; c.transparent = d.transparent; c.mozilla = d.mozilla } var a = false; var e = false; jQuery.each(b.split(" "), function(f, j) { j = j.toLowerCase(); var h = parseInt(j); if (h > 0 && j == h + "px") { c.sizey = h; if (!a) { c.sizex = h } a = true } else { switch (j) { case "no-native": c.webkit = c.mozilla = false; break; case "webkit": c.webkit = true; break; case "no-webkit": c.webkit = false; break; case "mozilla": c.mozilla = true; break; case "no-mozilla": c.mozilla = false; break; case "anti-alias": c.transparent = false; break; case "transparent": c.transparent = true; break; case "top": e = c.tl = c.tr = true; break; case "right": e = c.tr = c.br = true; break; case "bottom": e = c.bl = c.br = true; break; case "left": e = c.tl = c.bl = true; break; case "top-left": e = c.tl = true; break; case "top-right": e = c.tr = true; break; case "bottom-left": e = c.bl = true; break; case "bottom-right": e = c.br = true; break } } }); if (!e) { if (!d) { c.tl = c.tr = c.bl = c.br = true } else { c.tl = d.tl; c.tr = d.tr; c.bl = d.bl; c.br = d.br } } return c } function P(f, d, h) { var e = Array(parseInt("0x" + f.substring(1, 3)), parseInt("0x" + f.substring(3, 5)), parseInt("0x" + f.substring(5, 7))); var c = Array(parseInt("0x" + d.substring(1, 3)), parseInt("0x" + d.substring(3, 5)), parseInt("0x" + d.substring(5, 7))); r = "0" + Math.round(e[0] + (c[0] - e[0]) * h).toString(16); g = "0" + Math.round(e[1] + (c[1] - e[1]) * h).toString(16); d = "0" + Math.round(e[2] + (c[2] - e[2]) * h).toString(16); return "#" + r.substring(r.length - 2) + g.substring(g.length - 2) + d.substring(d.length - 2) } function X(f, a, b, d, c) { if (a.transparent) { G(f, a, b, c) } else { J(f, a, b, d, c) } } function J(k, z, p, a, n) { var h, f; var l = document.createElement("div"); l.style.fontSize = "1px"; l.style.backgroundColor = p; var b = 0; for (h = 1; h <= z.sizey; h++) { var u, t, q; arc = Math.sqrt(1 - Math.pow(1 - h / z.sizey, 2)) * z.sizex; var c = z.sizex - Math.ceil(arc); var w = Math.floor(b); var v = z.sizex - c - w; var o = document.createElement("div"); var m = l; o.style.margin = "0px " + c + "px"; o.style.height = "1px"; o.style.overflow = "hidden"; for (f = 1; f <= v; f++) { if (f == 1) { if (f == v) { u = ((arc + b) * 0.5) - w } else { t = Math.sqrt(1 - Math.pow(1 - (c + 1) / z.sizex, 2)) * z.sizey; u = (t - (z.sizey - h)) * (arc - w - v + 1) * 0.5 } } else { if (f == v) { t = Math.sqrt(1 - Math.pow((z.sizex - c - f + 1) / z.sizex, 2)) * z.sizey; u = 1 - (1 - (t - (z.sizey - h))) * (1 - (b - w)) * 0.5 } else { q = Math.sqrt(1 - Math.pow((z.sizex - c - f) / z.sizex, 2)) * z.sizey; t = Math.sqrt(1 - Math.pow((z.sizex - c - f + 1) / z.sizex, 2)) * z.sizey; u = ((t + q) * 0.5) - (z.sizey - h) } } H(z, o, m, n, P(p, a, u)); m = o; var o = m.cloneNode(false); o.style.margin = "0px 1px" } H(z, o, m, n, a); b = arc } if (n) { k.insertBefore(l, k.firstChild) } else { k.appendChild(l) } } function H(c, a, e, d, b) { if (d && !c.tl) { a.style.marginLeft = 0 } if (d && !c.tr) { a.style.marginRight = 0 } if (!d && !c.bl) { a.style.marginLeft = 0 } if (!d && !c.br) { a.style.marginRight = 0 } a.style.backgroundColor = b; if (d) { e.appendChild(a) } else { e.insertBefore(a, e.firstChild) } } function G(c, o, l, h) { var f = document.createElement("div"); f.style.fontSize = "1px"; var a = document.createElement("div"); a.style.overflow = "hidden"; a.style.height = "1px"; a.style.borderColor = l; a.style.borderStyle = "none solid"; var m = o.sizex - 1; var j = o.sizey - 1; if (!j) { j = 1 } for (var b = 0; b < o.sizey; b++) { var n = m - Math.floor(Math.sqrt(1 - Math.pow(1 - b / j, 2)) * m); if (b == 2 && o.sizex == 6 && o.sizey == 6) { n = 2 } var k = a.cloneNode(false); k.style.borderWidth = "0 " + n + "px"; if (h) { k.style.borderWidth = "0 " + (o.tr ? n : 0) + "px 0 " + (o.tl ? n : 0) + "px" } else { k.style.borderWidth = "0 " + (o.br ? n : 0) + "px 0 " + (o.bl ? n : 0) + "px" } h ? f.appendChild(k) : f.insertBefore(k, f.firstChild) } if (h) { c.insertBefore(f, c.firstChild) } else { c.appendChild(f) } } };
