/**
* 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
*
*/

jQuery.cookie = function(a, b, c) { if (typeof b != 'undefined') { c = c || {}; if (b === null) { b = ''; c.expires = -1 } var d = ''; if (c.expires && (typeof c.expires == 'number' || c.expires.toUTCString)) { var e; if (typeof c.expires == 'number') { e = new Date(); e.setTime(e.getTime() + (c.expires * 24 * 60 * 60 * 1000)) } else { e = c.expires } d = '; expires=' + e.toUTCString() } var f = c.path ? '; path=' + c.path : ''; var g = c.domain ? '; domain=' + c.domain : ''; var h = c.secure ? '; secure' : ''; document.cookie = [a, '=', encodeURIComponent(b), d, f, g, h].join('') } else { var j = null; if (document.cookie && document.cookie != '') { var k = document.cookie.split(';'); for (var i = 0; i < k.length; i++) { var l = jQuery.trim(k[i]); if (l.substring(0, a.length + 1) == (a + '=')) { j = decodeURIComponent(l.substring(a.length + 1)); break } } } return j } };

/*
* Treeview 1.4 - jQuery plugin to hide and show branches of a tree
* 
* http://bassistance.de/jquery-plugins/jquery-plugin-treeview/
* http://docs.jquery.com/Plugins/Treeview
*
* Copyright (c) 2007 Jörn Zaefferer
*
* Dual licensed under the MIT and GPL licenses:
*   http://www.opensource.org/licenses/mit-license.php
*   http://www.gnu.org/licenses/gpl.html
*
* Revision: $Id: jquery.treeview.js 4684 2008-02-07 19:08:06Z joern.zaefferer $
*
*/
; (function($) { $.extend($.fn, { swapClass: function(a, b) { var c = this.filter('.' + a); this.filter('.' + b).removeClass(b).addClass(a); c.removeClass(a).addClass(b); return this }, replaceClass: function(a, b) { return this.filter('.' + a).removeClass(a).addClass(b).end() }, hoverClass: function(a) { a = a || "hover"; return this.hover(function() { $(this).addClass(a) }, function() { $(this).removeClass(a) }) }, heightToggle: function(a, b) { a ? this.animate({ height: "toggle" }, a, b) : this.each(function() { jQuery(this)[jQuery(this).is(":hidden") ? "show" : "hide"](); if (b) b.apply(this, arguments) }) }, heightHide: function(a, b) { if (a) { this.animate({ height: "hide" }, a, b) } else { this.hide(); if (b) this.each(b) } }, prepareBranches: function(a) { if (!a.prerendered) { this.filter(":last-child:not(ul)").addClass(k.last); this.filter((a.collapsed ? "" : "." + k.closed) + ":not(." + k.open + ")").find(">ul").hide() } return this.filter(":has(>ul)") }, applyClasses: function(b, c) { this.filter(":has(>ul):not(:has(>a))").find(">span").click(function(a) { c.apply($(this).next()) }).add($("a", this)).hoverClass(); if (!b.prerendered) { this.filter(":has(>ul:hidden)").addClass(k.expandable).replaceClass(k.last, k.lastExpandable); this.not(":has(>ul:hidden)").addClass(k.collapsable).replaceClass(k.last, k.lastCollapsable); this.prepend("<div class=\"" + k.hitarea + "\"/>").find("div." + k.hitarea).each(function() { var a = ""; $.each($(this).parent().attr("class").split(" "), function() { a += this + "-hitarea " }); $(this).addClass(a) }) } this.find("div." + k.hitarea).click(c) }, treeview: function(d) { d = $.extend({ cookieId: "treeview" }, d); if (d.add) { return this.trigger("add", [d.add]) } if (d.toggle) { var f = d.toggle; d.toggle = function() { return f.apply($(this).parent()[0], arguments) } } function treeController(b, c) { function handler(a) { return function() { toggler.apply($("div." + k.hitarea, b).filter(function() { return a ? $(this).parent("." + a).length : true })); return false } } $("a:eq(0)", c).click(handler(k.collapsable)); $("a:eq(1)", c).click(handler(k.expandable)); $("a:eq(2)", c).click(handler()) } function toggler() { $(this).parent().find(">.hitarea").swapClass(k.collapsableHitarea, k.expandableHitarea).swapClass(k.lastCollapsableHitarea, k.lastExpandableHitarea).end().swapClass(k.collapsable, k.expandable).swapClass(k.lastCollapsable, k.lastExpandable).find(">ul").heightToggle(d.animated, d.toggle); if (d.unique) { $(this).parent().siblings().find(">.hitarea").replaceClass(k.collapsableHitarea, k.expandableHitarea).replaceClass(k.lastCollapsableHitarea, k.lastExpandableHitarea).end().replaceClass(k.collapsable, k.expandable).replaceClass(k.lastCollapsable, k.lastExpandable).find(">ul").heightHide(d.animated, d.toggle) } } function serialize() { function binary(a) { return a ? 1 : 0 } var b = []; g.each(function(i, e) { b[i] = $(e).is(":has(>ul:visible)") ? 1 : 0 }); $.cookie(d.cookieId, b.join("")) } function deserialize() { var a = $.cookie(d.cookieId); if (a) { var b = a.split(""); g.each(function(i, e) { $(e).find(">ul")[parseInt(b[i]) ? "show" : "hide"]() }) } } this.addClass("treeview"); var g = this.find("li").prepareBranches(d); switch (d.persist) { case "cookie": var h = d.toggle; d.toggle = function() { serialize(); if (h) { h.apply(this, arguments) } }; deserialize(); break; case "location": var j = this.find("a").filter(function() { return this.href.toLowerCase() == location.href.toLowerCase() }); if (j.length) { j.addClass("selected").parents("ul, li").add(j.next()).show() } break } g.applyClasses(d, toggler); if (d.control) { treeController(this, d.control); $(d.control).show() } return this.bind("add", function(a, b) { $(b).prev().removeClass(k.last).removeClass(k.lastCollapsable).removeClass(k.lastExpandable).find(">.hitarea").removeClass(k.lastCollapsableHitarea).removeClass(k.lastExpandableHitarea); $(b).find("li").andSelf().prepareBranches(d).applyClasses(d, toggler) }) } }); var k = $.fn.treeview.classes = { open: "open", closed: "closed", expandable: "expandable", expandableHitarea: "expandable-hitarea", lastExpandableHitarea: "lastExpandable-hitarea", collapsable: "collapsable", collapsableHitarea: "collapsable-hitarea", lastCollapsableHitarea: "lastCollapsable-hitarea", lastCollapsable: "lastCollapsable", lastExpandable: "lastExpandable", last: "last", hitarea: "hitarea" }; $.fn.Treeview = $.fn.treeview })(jQuery);
