﻿/*
* jQuery UI Multi Open Accordion Plugin
* Author	: Anas Nakawa (http://anasnakawa.wordpress.com/)
* Date		: 25-01-2011
* Released Under MIT License
* You are welcome to enhance this plugin at https://code.google.com/p/jquery-multi-open-accordion/
*/
(function ($) {
    $.fn.extend({
        //pass the options variable to the function
        multiAccordion: function (options) {
            // TODO: no defaults yet
            var defaults = {
                active: 0
            }
            var options = $.extend(defaults, options);
            return this.each(function () {
                var $this = $(this);
                var $h3 = $this.children('h3');
                var $div = $this.children('div');
                $this.addClass('ui-accordion ui-widget ui-helper-reset ui-accordion-icons');
                $h3.each(function (index) {
                    var $this = $(this);
                    $this.addClass('ui-accordion-header ui-helper-reset ui-state-default ui-corner-all').prepend('<span class="ui-icon ui-icon-triangle-1-e"></span>');
                    if (isActive(index)) {
                        showTab($this)
                    }
                });
                $this.children('div').each(function (index) {
                    var $this = $(this);
                    $this.addClass('ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom');
                });
                $h3.click(function () {
                    var $this = $(this);
                    if ($this.hasClass('ui-state-default')) {
                        showTab($this);
                    } else {
                        hideTab($this);
                    }
                });
                $h3.hover(
					function () {
					    $(this).addClass('ui-state-hover');
					}, function () {
					    $(this).removeClass('ui-state-hover');
					}
				);
            });

            function showTab($this) {
                var $span = $this.children('span.ui-icon');
                var $div = $this.next();
                $this.removeClass('ui-state-default ui-corner-all').addClass('ui-state-active ui-corner-top');
                $span.removeClass('ui-icon-triangle-1-e').addClass('ui-icon-triangle-1-s');
                $div.slideDown('fast', function () {
                    $div.addClass('ui-accordion-content-active');
                });
            }

            function hideTab($this) {
                var $span = $this.children('span.ui-icon');
                var $div = $this.next();
                $this.removeClass('ui-state-active ui-corner-top').addClass('ui-state-default ui-corner-all');
                $span.removeClass('ui-icon-triangle-1-s').addClass('ui-icon-triangle-1-e');
                $div.slideUp('fast', function () {
                    $div.removeClass('ui-accordion-content-active');
                });
            }

            function isActive(num) {
                // if array
                if (typeof options.active == "boolean" && !options.active) {
                    return false;
                } else {
                    if (options.active.length != undefined) {
                        for (var i = 0; i < options.active.length; i++) {
                            if (options.active[i] == num)
                                return true;
                        }
                    } else {
                        return options.active == num;
                    }
                }
                return false;
            }
        }
    });
})(jQuery);

/* Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
* Licensed under the MIT License (LICENSE.txt).
*
* Version 0.2
*/
(function (a) { a.fn.spellcheck = function (b) { return this.each(function () { var c = a(this); if (!c.is("[type=password]") && !a(this).data("spellchecker")) { a(this).data("spellchecker", new a.SpellChecker(this, b)); } }); }; a.fn.checkspelling = function () { return this.each(function () { var b = a(this).data("spellchecker"); b && b.checkSpelling(); }); }; a.SpellChecker = function (c, b) { this.$element = a(c); this.options = a.extend({ lang: "en", autocheck: 750, events: "keypress blur paste", url: "spellcheck.php", ignorecaps: 1, ignoredigits: 1 }, b); this.bindEvents(); }; a.SpellChecker.prototype = { bindEvents: function () { if (!this.options.events) { return; } var b = this, c; this.$element.bind(this.options.events, function (d) { if (/^key[press|up|down]/.test(d.type)) { if (c) { clearTimeout(c); } c = setTimeout(function () { b.checkSpelling(); }, b.options.autocheck); } else { b.checkSpelling(); } }); }, checkSpelling: function () { var c = this.text, d = this.$element.val(), b = this; if (c === d) { return; } this.text = this.$element.val(); a.get(this.options.url, { text: this.text, lang: this.options.lang, ignorecaps: this.options.ignorecaps, ignoredigits: this.options.ignoredigits }, function (e) { b.parseResults(e); }); }, parseResults: function (c) { var b = this; this.results = []; a(c).find("c").each(function () { var e = a(this), f = e.attr("o"), d = e.attr("l"); b.results.push({ word: b.text.substr(f, d), suggestions: e.text().split(/\s/) }); }); this.displayResults(); }, displayResults: function () { a("#spellcheckresults").remove(); if (!this.results.length) { return; } var h = a('<div id="spellcheckresults"></div>').appendTo("body"), e = [], j = this, c = this.$element.offset(), g = this.$element[0].offsetHeight, d, b; for (d = 0; d < this.results.length; d++) { var l = this.results[d], f = l.suggestions; e.push("<dl><dt>" + l.word + "</dt>"); for (b = 0; b < f.length; b++) { e.push("<dd>" + f[b] + "</dd>"); } e.push('<dd class="ignore">ignore</dd></dl>'); } h.append(e.join("")).find("dd").bind("click", function (i) { var m = a(this), k = m.parent(); if (!m.is(".ignore")) { j.$element.val(j.$element.val().replace(k.find("dt").text(), m.text())); } k.remove(); if (a("#spellcheckresults").is(":empty")) { a("#spellcheckresults").remove(); } this.blur(); }).end().css({ top: c.top + g, left: c.left }); } }; })(jQuery);
