﻿(function (c) { function p(d, b, a) { var e = this, l = d.add(this), h = d.find(a.tabs), i = b.jquery ? b : d.children(b), j; h.length || (h = d.children()); i.length || (i = d.parent().find(b)); i.length || (i = c(b)); c.extend(this, { click: function (f, g) { var k = h.eq(f); if (typeof f == "string" && f.replace("#", "")) { k = h.filter("[href*=" + f.replace("#", "") + "]"); f = Math.max(h.index(k), 0) } if (a.rotate) { var n = h.length - 1; if (f < 0) return e.click(n, g); if (f > n) return e.click(0, g) } if (!k.length) { if (j >= 0) return e; f = a.initialIndex; k = h.eq(f) } if (f === j) return e; g = g || c.Event(); g.type = "onBeforeClick"; l.trigger(g, [f]); if (!g.isDefaultPrevented()) { o[a.effect].call(e, f, function () { g.type = "onClick"; l.trigger(g, [f]) }); j = f; h.removeClass(a.current); k.addClass(a.current); return e } }, getConf: function () { return a }, getTabs: function () { return h }, getPanes: function () { return i }, getCurrentPane: function () { return i.eq(j) }, getCurrentTab: function () { return h.eq(j) }, getIndex: function () { return j }, next: function () { return e.click(j + 1) }, prev: function () { return e.click(j - 1) }, destroy: function () { h.unbind(a.event).removeClass(a.current); i.find("a[href^=#]").unbind("click.T"); return e } }); c.each("onBeforeClick,onClick".split(","), function (f, g) { c.isFunction(a[g]) && c(e).bind(g, a[g]); e[g] = function (k) { k && c(e).bind(g, k); return e } }); if (a.history && c.fn.history) { c.tools.history.init(h); a.event = "history" } h.each(function (f) { c(this).bind(a.event, function (g) { e.click(f, g); return g.preventDefault() }) }); i.find("a[href^=#]").bind("click.T", function (f) { e.click(c(this).attr("href"), f) }); if (location.hash && a.tabs == "a" && d.find("[href=" + location.hash + "]").length) e.click(location.hash); else if (a.initialIndex === 0 || a.initialIndex > 0) e.click(a.initialIndex) } c.tools = c.tools || { version: "1.2.5" }; c.tools.tabs = { conf: { tabs: "a", current: "current", onBeforeClick: null, onClick: null, effect: "default", initialIndex: 0, event: "click", rotate: false, history: false }, addEffect: function (d, b) { o[d] = b } }; var o = { "default": function (d, b) { this.getPanes().hide().eq(d).show(); b.call() }, fade: function (d, b) { var a = this.getConf(), e = a.fadeOutSpeed, l = this.getPanes(); e ? l.fadeOut(e) : l.hide(); l.eq(d).fadeIn(a.fadeInSpeed, b) }, slide: function (d, b) { this.getPanes().slideUp(200); this.getPanes().eq(d).slideDown(400, b) }, ajax: function (d, b) { this.getPanes().eq(0).load(this.getTabs().eq(d).attr("href"), b) } }, m; c.tools.tabs.addEffect("horizontal", function (d, b) { m || (m = this.getPanes().eq(0).width()); this.getCurrentPane().animate({ width: 0 }, function () { c(this).hide() }); this.getPanes().eq(d).animate({ width: m }, function () { c(this).show(); b.call() }) }); c.fn.tabs = function (d, b) { var a = this.data("tabs"); if (a) { a.destroy(); this.removeData("tabs") } if (c.isFunction(b)) b = { onBeforeClick: b }; b = c.extend({}, c.tools.tabs.conf, b); this.each(function () { a = new p(c(this), d, b); c(this).data("tabs", a) }); return b.api ? a : this } })(jQuery); (function (c) { function p(g, a) { function m(f) { var e = c(f); return e.length < 2 ? e : g.parent().find(f) } var b = this, i = g.add(this), d = g.data("tabs"), h, j = true, n = m(a.next).click(function () { d.next() }), k = m(a.prev).click(function () { d.prev() }); c.extend(b, { getTabs: function () { return d }, getConf: function () { return a }, play: function () { if (h) return b; var f = c.Event("onBeforePlay"); i.trigger(f); if (f.isDefaultPrevented()) return b; h = setInterval(d.next, a.interval); j = false; i.trigger("onPlay"); return b }, pause: function () { if (!h) return b; var f = c.Event("onBeforePause"); i.trigger(f); if (f.isDefaultPrevented()) return b; h = clearInterval(h); i.trigger("onPause"); return b }, stop: function () { b.pause(); j = true } }); c.each("onBeforePlay,onPlay,onBeforePause,onPause".split(","), function (f, e) { c.isFunction(a[e]) && c(b).bind(e, a[e]); b[e] = function (q) { return c(b).bind(e, q) } }); a.autopause && d.getTabs().add(n).add(k).add(d.getPanes()).hover(b.pause, function () { j || b.play() }); a.autoplay && b.play(); a.clickable && d.getPanes().click(function () { d.next() }); if (!d.getConf().rotate) { var l = a.disabledClass; d.getIndex() || k.addClass(l); d.onBeforeClick(function (f, e) { k.toggleClass(l, !e); n.toggleClass(l, e == d.getTabs().length - 1) }) } } var o; o = c.tools.tabs.slideshow = { conf: { next: ".forward", prev: ".backward", disabledClass: "disabled", autoplay: false, autopause: true, interval: 3E3, clickable: true, api: false} }; c.fn.slideshow = function (g) { var a = this.data("slideshow"); if (a) return a; g = c.extend({}, o.conf, g); this.each(function () { a = new p(c(this), g); c(this).data("slideshow", a) }); return g.api ? a : this } })(jQuery);

jQuery.cookie = function (name, value, options) {
    if (typeof value != 'undefined') {
        options = options || {}; if (value === null) { value = ''; 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();
        }
        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 {
        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]); if (cookie.substring(0, name.length + 1) == (name + '=')) { cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); break; } } }
        return cookieValue;
    } 
}; function ddtabcontent(tabinterfaceid) {
    this.tabinterfaceid = tabinterfaceid
    this.tabs = document.getElementById(tabinterfaceid).getElementsByTagName("a")
    this.enabletabpersistence = true
    this.hottabspositions = []
    this.currentTabIndex = 0
    this.subcontentids = []
    this.revcontentids = []
    this.selectedClassTarget = "link"
}
ddtabcontent.getCookie = function (Name) {
    var re = new RegExp(Name + "=[^;]+", "i"); if (document.cookie.match(re))
        return document.cookie.match(re)[0].split("=")[1]
    return ""
}
ddtabcontent.setCookie = function (name, value) { document.cookie = name + "=" + value + ";path=/" }
ddtabcontent.prototype = { expandit: function (tabid_or_position) {
    this.cancelautorun()
    var tabref = ""
    try {
        if (typeof tabid_or_position == "string" && document.getElementById(tabid_or_position).getAttribute("rel"))
            tabref = document.getElementById(tabid_or_position)
        else if (parseInt(tabid_or_position) != NaN && this.tabs[tabid_or_position].getAttribute("rel"))
            tabref = this.tabs[tabid_or_position]
    }
    catch (err) { alert("Invalid Tab ID or position entered!") }
    if (tabref != "")
        this.expandtab(tabref)
}, cycleit: function (dir, autorun) {
    if (dir == "next") { var currentTabIndex = (this.currentTabIndex < this.hottabspositions.length - 1) ? this.currentTabIndex + 1 : 0 }
    else if (dir == "prev") { var currentTabIndex = (this.currentTabIndex > 0) ? this.currentTabIndex - 1 : this.hottabspositions.length - 1 }
    if (typeof autorun == "undefined")
        this.cancelautorun()
    this.expandtab(this.tabs[this.hottabspositions[currentTabIndex]])
}, setpersist: function (bool) { this.enabletabpersistence = bool }, setselectedClassTarget: function (objstr) { this.selectedClassTarget = objstr || "link" }, getselectedClassTarget: function (tabref) { return (this.selectedClassTarget == ("linkparent".toLowerCase())) ? tabref.parentNode : tabref }, urlparamselect: function (tabinterfaceid) {
    var result = window.location.search.match(new RegExp(tabinterfaceid + "=(\\d+)", "i"))
    return (result == null) ? null : parseInt(RegExp.$1)
}, expandtab: function (tabref) {
    var subcontentid = tabref.getAttribute("rel")
    var associatedrevids = (tabref.getAttribute("rev")) ? "," + tabref.getAttribute("rev").replace(/\s+/, "") + "," : ""
    this.expandsubcontent(subcontentid)
    this.expandrevcontent(associatedrevids)
    for (var i = 0; i < this.tabs.length; i++) { this.getselectedClassTarget(this.tabs[i]).className = (this.tabs[i].getAttribute("rel") == subcontentid) ? "selected" : "" }
    if (this.enabletabpersistence)
        ddtabcontent.setCookie(this.tabinterfaceid, tabref.tabposition)
    this.setcurrenttabindex(tabref.tabposition)
}, expandsubcontent: function (subcontentid) {
    for (var i = 0; i < this.subcontentids.length; i++) {
        var subcontent = document.getElementById(this.subcontentids[i])
        subcontent.style.display = (subcontent.id == subcontentid) ? "block" : "none"
    } 
}, expandrevcontent: function (associatedrevids) {
    var allrevids = this.revcontentids
    for (var i = 0; i < allrevids.length; i++) { document.getElementById(allrevids[i]).style.display = (associatedrevids.indexOf("," + allrevids[i] + ",") != -1) ? "block" : "none" } 
}, setcurrenttabindex: function (tabposition) {
    for (var i = 0; i < this.hottabspositions.length; i++) {
        if (tabposition == this.hottabspositions[i]) {
            this.currentTabIndex = i
            break
        } 
    } 
}, autorun: function () { this.cycleit('next', true) }, cancelautorun: function () {
    if (typeof this.autoruntimer != "undefined")
        clearInterval(this.autoruntimer)
}, init: function (automodeperiod) {
    var persistedtab = ddtabcontent.getCookie(this.tabinterfaceid)
    var selectedtab = -1
    var selectedtabfromurl = this.urlparamselect(this.tabinterfaceid)
    this.automodeperiod = automodeperiod || 0
    for (var i = 0; i < this.tabs.length; i++) {
        this.tabs[i].tabposition = i
        if (this.tabs[i].getAttribute("rel")) {
            var tabinstance = this
            this.hottabspositions[this.hottabspositions.length] = i
            this.subcontentids[this.subcontentids.length] = this.tabs[i].getAttribute("rel")
            this.tabs[i].onclick = function () {
                tabinstance.expandtab(this)
                tabinstance.cancelautorun()
                return false
            }
            if (this.tabs[i].getAttribute("rev")) { this.revcontentids = this.revcontentids.concat(this.tabs[i].getAttribute("rev").split(/\s*,\s*/)) }
            if (selectedtabfromurl == i || this.enabletabpersistence && selectedtab == -1 && parseInt(persistedtab) == i || !this.enabletabpersistence && selectedtab == -1 && this.getselectedClassTarget(this.tabs[i]).className == "selected") { selectedtab = i } 
        } 
    }
    if (selectedtab != -1)
        this.expandtab(this.tabs[selectedtab])
    else
        this.expandtab(this.tabs[this.hottabspositions[0]])
    if (parseInt(this.automodeperiod) > 500 && this.hottabspositions.length > 1) { this.autoruntimer = setInterval(function () { tabinstance.autorun() }, this.automodeperiod) } 
} 
}
