...
 
Commits (2)
/*
* KSS-RPC v0.20-beta
* KSS-RPC v0.21-beta
*
* Copyright (c) 2017, joonis new media
* Author: Thimo Kraemer <thimo.kraemer@joonis.de>
......@@ -61,7 +61,7 @@
******************************************************************************************/
var kss = {
version: '0.20-beta',
version: '0.21-beta',
_initialized: false,
_ruleSheets: {},
_eventBinders: {},
......@@ -919,9 +919,9 @@ kss._EventHandler.prototype = {
|| !(/^(".*"|'.*'|\[.*\]|\{.*\}|true|false|null|[\d.]+)$|\(.*\)/).test(value)) {
return value;
}
var expr = value.replace(/\\["']|["'](?:\\["']|[^"'])*["']|([\w.$]+\s*\()/g,
var expr = value.replace(/\\["']|["'](?:\\["']|[^"'])*["']|([\w$.][\w$.\s]*\()/g,
function(m, g1) {
if (!g1) return m;
if (!g1 || g1[0] == '.') return m;
m = 'kss._paramProviders.' + m;
m = m.replace('(', '.call(this,this.node,');
return m;
......
/*
* KSS-RPC v0.20-beta - http://www.joonis.de/kss
* KSS-RPC v0.21-beta - http://www.joonis.de/kss
* Distributed under the GNU GPL license.
* Copyright (c) 2017 joonis new media, Thimo Kraemer <thimo.kraemer@joonis.de>
*/
"use strict";
!function(){function e(e,s){var t;s=s||{};try{(t=document.createEvent("CustomEvent")).initCustomEvent(e,!!s.bubbles,!!s.cancelable,s.detail)}catch(n){(t=document.createEvent("Event")).initEvent(e,!!s.bubbles,!!s.cancelable),t.detail=s.detail}return t}"function"!=typeof window.CustomEvent&&(e.prototype=window.Event.prototype,window.CustomEvent=e)}();var kss={version:"0.20-beta",_initialized:!1,_ruleSheets:{},_eventBinders:{},_activeBinders:[],_activeHandlers:[],_actionProviders:{},_paramProviders:{},_stateVars:{},_logging:"warn",_observer:null,useObserver:!1,config:{protocol:"json-rpc",endpoint:".",dateEncoding:"iso8601",timeout:1e4,csrfSelector:null,csrfCookie:null,csrfHeader:null},_init:function(){if(kss._initialized)kss.warn("KSS already initialized");else{kss._initialized=!0,kss.createLogger(kss),kss._logging=kss.getSessionVar("kssLogging")||kss._logging,kss.log("Initializing KSS v"+kss.version+" ..."),window.cssQuery?(kss.info("Using an unknown selector engine"),kss._cssQuery=function(e,s){return cssQuery(e,s)}):window.jQuery?(kss.info("Using jQuery selector engine"),kss._cssQuery=function(e,s){return jQuery(e,s)}):window.Sizzle?(kss.info("Using Sizzle selector engine"),kss._cssQuery=function(e,s){return Sizzle(e,s)}):window.Slick?(kss.info("Using Slick (MooTools) selector engine"),kss._cssQuery=function(e,s){return s=s||document,Slick.search(s,e)}):document.querySelectorAll?(kss.info("Using built-in selector engine"),kss._cssQuery=function(e,s){return(s=s||document).querySelectorAll(e)}):kss.error("No selector engine found"),kss.info("Loaded animation library: "+(kss._loadAnimationLib()||"none"));var e=document.getElementsByTagName("link"),s=0;kss.each(e,function(e){"kinetic-stylesheet"==(e.getAttribute("data-rel")||e.rel)&&"text/kss"==e.type&&(kss.addRuleSheet(e.href),s++)}),kss.info("Found "+s+" rulesheet link(s) in document"),kss.useObserver&&window.MutationObserver?(kss.info("Using MutationObserver: yes"),kss._observer=new MutationObserver(kss._observe),kss._observer.observe(document.documentElement,{childList:!0,subtree:!0})):(kss.info("Using MutationObserver: no"),setInterval(kss._cleanUp,6e4)),window.addEventListener("unload",function(){kss._cleanUp(!0)},!1)}}};"undefined"!=typeof window&&document.addEventListener("DOMContentLoaded",kss._init,!1),kss._observe=function(e,s){var t=[],n=!1;function r(e){if(1==e.nodeType){var s=e.tagName.toLowerCase();if("script"!=s&&"style"!=s)return!0}return!1}kss.each(e,function(e){if("childList"==e.type){var s=e.target,i=s.tagName.toLowerCase();if("html"!=i&&"head"!=i){n||(n=kss.each(e.removedNodes,function(e){if(r(e))return!0})||!1);var o=kss.each(e.addedNodes,function(e){if(r(e)&&e.parentNode)return!0})||!1;if(o){for(var a=t.length-1;a>=0;a--){var c=t[a];if(s.contains(c))t.splice(a,1);else if(c.contains(s)){o=!1;break}}o&&t.push(s)}}}}),n&&kss._cleanUp(!1,!0),kss.each(t,function(e){kss.applyRules(e,!0)})},kss._cleanUp=function(e,s){if(!kss._observer||s||e){for(var t=0,n=document.documentElement,r=kss._activeHandlers,i=r.length-1;i>=0;i--){var o=r[i];!e&&n.contains(o.node)||(o.node.removeEventListener(o.eventname,o),o.node._kssRules=null,o.node=null,r.splice(i,1),t++)}var a=kss._activeBinders;for(i=a.length-1;i>=0;i--){var c=a[i];if(e||!n.contains(c.node)){if(c.node=null,c.binder.cleanUp)try{c.binder.cleanUp()}catch(l){kss.error(l)}a.splice(i,1)}}t&&kss.log("Cleand up "+t+" event handler(s)")}},kss._register=function(e,s,t,n){var r={};e instanceof Object?r=e:r[e]=s,kss.each(r,function(e,s){e instanceof Function&&"_"!=s.charAt(0)&&(n?(t[s]||(t[s]=[]),t[s].push(e)):t[s]=e)})},kss.registerActionProvider=function(e,s){kss._register(e,s,kss._actionProviders)},kss.registerParameterProvider=function(e,s){kss._register(e,s,kss._paramProviders)},kss.registerEventBinder=function(e,s){kss._register(e,s,kss._eventBinders,!0)},kss._hyphenateCache={cssFloat:"float",styleFloat:"float"},kss.hyphenate=function(e){return kss._hyphenateCache[e]||(kss._hyphenateCache[e]=e.replace(/([A-Z])/g,"-$1").toLowerCase())},kss._camelCaseCache={},kss.camelCase=function(e){return kss._camelCaseCache[e]||(kss._camelCaseCache[e]=e.replace(/\-(\w)/g,function(e,s){return s.toUpperCase()}))},kss.dateToISO8601=function(e){return[e.getUTCFullYear(),"-",("0"+(e.getUTCMonth()+1)).slice(-2),"-",("0"+e.getUTCDate()).slice(-2),"T",("0"+e.getUTCHours()).slice(-2),":",("0"+e.getUTCMinutes()).slice(-2),":",("0"+e.getUTCSeconds()).slice(-2),".",("00"+e.getUTCMilliseconds()).slice(-3),"Z"].join("")},kss.ISO8601toDate=function(e){var s;if(s=/^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/.exec(e)){for(var t,n=[1,4,5,6,7,10,11],r=0;t=n[r];++r)s[t]=+s[t]||0;s[2]=(+s[2]||1)-1,s[3]=+s[3]||1;var i=0;"Z"!==s[8]&&void 0!==s[9]&&(i=60*s[10]+s[11],"+"===s[9]&&(i=0-i));var o=Date.UTC(s[1],s[2],s[3],s[4],s[5]+i,s[6],s[7]);return new Date(o)}},kss.uniqueId=function(){return Math.random().toString(36).substring(2)+(new Date).getTime().toString(36)},kss.eval=function(__expr__){return eval("("+__expr__+")")},kss.isNativeEvent=function(e,s){var t=e["on"+s];return null===t||"function"==typeof t},kss.isArrayLike=function(e){if(e&&"object"==typeof e&&e!=window){var s=e.length,t=e.propertyIsEnumerable&&e.propertyIsEnumerable("length");return(0===s||"number"==typeof s&&s>0&&s-1 in e)&&(!t||"function"==typeof e.item)}return!1},kss.each=function(e,s,t){if("string"==typeof e&&(e=e.split(/[\s,;]+/)),kss.isArrayLike(e))for(var n=0;n<e.length;n++){if(void 0!==(i=s.call(t,e[n],n)))return i}else if(e)for(var r in e){var i;if(e.hasOwnProperty(r))if(void 0!==(i=s.call(t,e[r],r)))return i}},kss.contains=function(e,s){return"string"==typeof e&&(e=e.split(/[\s,;]+/)),e.indexOf?e.indexOf(s)>-1:kss.each(e,function(e){if(s===e)return!0})||!1},kss._logTimers={},kss._logLevels=["none","error","warn","time","info","log","debug"],kss._log=function(e,s){var t=kss._logLevels;if(window.console&&!(t.indexOf(e)>t.indexOf(kss._logging))){if(s=[].slice.call(s),"time"==e)return kss._logTimers[s[0]]=(new Date).getTime(),s[0];if(s[0]in kss._logTimers){var n=(new Date).getTime()-kss._logTimers[s[0]];s[0]+=" ("+n+"ms)",delete kss._logTimers[s[0]]}if(!this.logHandler||!1!==this.logHandler(s,e)){console.dir||kss.each(s,function(e,t){"object"!=typeof e||e instanceof Error||(s[t]=JSON.stringify(e,null,4)||e)});var r=console[e]||console.log;Function.prototype.apply.call(r,console,s)}}},kss.setLogLevel=function(e){if(kss._logLevels.indexOf(e)<0)throw Error('Invalid loglevel "'+e+'"');kss._logging=e,kss.setSessionVar("kssLogging",e)},kss.createLogger=function(e){return(e=e||{})._log=kss._log,kss.each(kss._logLevels.slice(1),function(s){s in e||(e[s]=function(){return this._log(s,arguments)})}),e},kss.RuleSheet=function(e,s){this.url=e,this.config=s||kss.config,this.source="",this.rules=[],this.status=null},kss.RuleSheet.prototype={load:function(e){if("loaded"!=this.status){var s=this,t=kss.time("Loaded RuleSheet: "+this.url);kss.GET(this.url,{},this.config.timeout,{},function(n){200!=n.status?(s.status="failed",kss.error('Failed to load "'+s.url+'": '+n.status+" "+n.statusText)):(kss.log(t),s.source=n.responseText,s._parse(!0),s.status="loaded"),e&&e()})}else kss.warn("Rulesheet already loaded")},_parse:function(e){var s=kss.time("Parsed RuleSheet: "+this.url),t=new kss.Parser(this.source,this.url).rules(!0);this.rules=[];var n=this.config;kss.each(t,function(s){if("config"!=s.type||s.name&&"kss"!=s.name){if("rule"==s.type){var t={},r=[];kss.each(s.declarations,function(e){if("declaration"==e.type){var n=e.property,i=e.value;i||kss.warn('Missing value for property "'+n+'".',s);var o=r[r.length-1],a=n.match(/^kss-action-(client|server)$/i);a?r.push({type:a[1].toLowerCase(),name:i,props:{},params:{}}):!o||/^evt-/i.test(n)?t[n.toLowerCase()]=i:/^kss-/i.test(n)?o.props[n.toLowerCase()]=i:o.params[n]=i}}),this.rules.push({selectors:s.selectors,props:t,actions:r,config:n,position:s.position,url:this.url}),r.length||kss.warn("Rule without action.",s)}else if(e&&"import"==s.type){var i=s["import"];i=i.replace(/url\s*\(|\)|'|"|\s/g,""),kss.addRuleSheet(i,n)}}else n=Object.create(n),kss.each(s.declarations,function(e){if("declaration"==e.type){var s=kss.camelCase(e.property);n[s]=e.value}})},this),kss.debug(s)},apply:function(e){var s=0;kss.each(this.rules,function(t){kss.each(t.selectors,function(n){var r=kss.cssQuery(n.selector,e),i=n.event;kss.each(r,function(n){if(n._kssRules||(n._kssRules={}),n._kssRules[i]||(n._kssRules[i]=[]),!kss.contains(n._kssRules[i],t))try{new kss._EventHandler(n,i,t,!e),n._kssRules[i].push(t),s++}catch(r){kss.error(r.message,t)}})})}),this.rules.length&&kss.log("Applied rules to "+s+" node(s)")}},kss.addRuleSheet=function(e,s){if((e=kss.toAbsoluteURL(e))in kss._ruleSheets)kss.warn('Rulesheet "'+e+'" already added.');else{var t=new kss.RuleSheet(e,s);kss._ruleSheets[e]=t,t.load(function(){"loaded"==t.status&&t.apply()})}},kss.applyRules=function(e,s){kss._observer&&!s||kss.each(kss._ruleSheets,function(s){s.apply(e)})},kss._EventHandler=function(e,s,t,n){if(!kss.isNativeEvent(e,s)&&!kss._eventBinders[s])throw Error('Unknown event type "'+s+'"');this.node=e,this.eventname=s,this.event={},this.rule=t,this._queuedActions={},this.kssProps=this.propertyGetter({selector:"@samenode",precondition:!0},t.props),this.evtProps=this.propertyGetter({preventdefault:!1,allowbubbling:!1,preventbubbling:!1}),kss.each(kss._eventBinders[s],function(s){kss._activeBinders.push({node:e,binder:new s(this)})},this),e.addEventListener(s,this,!1),kss._activeHandlers.push(this),"load"==s&&(n&&this.evtProps("initial",!0)||!n&&this.evtProps("insert",!0))&&this.dispatchEvent()},kss._EventHandler.prototype={logHandler:function(e,s){if(e.unshift("Event ["+this.eventname+"]:"),"debug"==kss._logging){var t=this.rule.position;e.push("\nRuleSheet: "+this.rule.url),e.push("\nLine: "+t.start.line+" to "+t.end.line)}},propertyGetter:function(e,s){var t="kss";s||(t="evt-"+this.eventname,s=this.rule.props);var n=this;return function(r,i){var o=t+"-"+r;return o in s||"preventdefault"!=r&&"preventbubbling"!=r&&"allowbubbling"!=r||(o="evt-"+r),o in s?n._evalParam(s[o]):void 0!==i?i:e?e[r]:void 0}},dispatchEvent:function(e,s,t){var n=new CustomEvent(this.eventname,{bubbles:!!e,cancelable:!!s,detail:t});return this.node.dispatchEvent(n)},handleEvent:function(e){this.event=e,(this.evtProps("allowbubbling")||e.target==this.node)&&(this.info("Triggered on element",this.node),this.evtProps("preventdefault")&&e.preventDefault(),this.evtProps("preventbubbling")&&e.stopPropagation(),this.kssProps("precondition")&&kss.each(this.rule.actions,function(e){var s=this.propertyGetter({selector:null,precondition:!0,includeform:null,timeout:null},e.props);if(s("precondition")){var t={},n=s("includeform");if(n){var r=null;if(r="@currentform"==n?kss.cssQuery(n,this.node)[0]:document.forms[n]){var i=0;kss.each(kss.getAllFormVars(r),function(e,s){t[s]=e,i++}),this.log("Acquired "+i+' value(s) of form "'+r.name+'"')}else this.warn('Form "'+n+'" not found')}kss.each(e.params,function(e,s){t[s]=this._evalParam(e)},this),"client"==e.type?this._execClientAction(e.name,t,s("selector")):this._execServerAction(e.name,t,s("timeout"))}},this))},_execClientAction:function(e,s,t){if(kss._actionProviders[e]){var n={};kss.each(s,function(e,s){n[kss.camelCase(s)]=e});var r,i={name:e,type:"client",params:n};this._callBinders("onstart",i);try{t=t||this.kssProps("selector");var o=kss.cssQuery(t,this.node,!0);this.log('Execute client action "'+e+'" for '+o.length+' node(s) (selector "'+t+'")'),this.debug("Parameters:",n),kss.each(o,function(s){kss._actionProviders[e].call(this,s,n)},this)}catch(a){this.error(a),r=a}this._callBinders("oncomplete",i,r)}else this.error('Skipping non-existent client action "'+e+'"')},_execServerAction:function(e,s,t){if(e in this._queuedActions)return this.debug('Queued server action "'+e+'" and dropped previous'),void(this._queuedActions[e]=[s,t]);this._queuedActions[e]=null;var n=Object.create(this.rule.config);t&&(n.timeout=t);var r={name:e,type:"server",params:s};!s||"xml-rpc"!=n.protocol&&"json-rpc-v1"!=n.protocol||(s=[s]),this._callBinders("onstart",r);var i=this;function o(s){s&&i.error(s),i._callBinders("oncomplete",r,s);var t=i._queuedActions[e];delete i._queuedActions[e],t&&i._execServerAction(e,t[0],t[1])}try{var a=this.time('Execute server action "'+e+'"');new kss.RPC(n.endpoint,n).invoke(e,s,function(e){var t;try{if("object"!=typeof e||!(e.commands instanceof Array))throw new Error("Invalid KSS response");if(e.error)throw new Error(e.error);i.log(a),i.debug("Parameters:",s),i.log("Server action returned "+e.commands.length+" command(s)"),kss.each(e.commands,function(e){i._execClientAction(e.action,e.params,e.selector)})}catch(n){t=n}o(t)},o)}catch(c){o(c)}},_callBinders:function(e,s,t){kss.each(kss._activeBinders,function(n){var r=n.binder;try{r[e]&&r[e](this,s,t)}catch(i){this.error(i)}},this)},_evalParam:function(e){if(!e||"string"!=typeof e||!/^(".*"|'.*'|\[.*\]|\{.*\}|true|false|null|[\d.]+)$|\(.*\)/.test(e))return e;var s=e.replace(/\\["']|["'](?:\\["']|[^"'])*["']|([\w.$]+\s*\()/g,function(e,s){return s?e=(e="kss._paramProviders."+e).replace("(",".call(this,this.node,"):e});s=s.replace(/,\s*\)/g,")");try{return kss.eval.call(this,s)}catch(t){return t.message='Error evaluating "'+e+'". Error was:\n'+t.message,this.warn(t),null}}},kss.createLogger(kss._EventHandler.prototype),kss.GET=function(e,s,t,n,r){return kss.SEND("GET",e,s,t,n,r)},kss.POST=function(e,s,t,n,r){return kss.SEND("POST",e,s,t,n,r)},kss.SEND=function(e,s,t,n,r,i){var o,a,c=!!i,l=new XMLHttpRequest;if(l.open(e,s,c),r||(r={}),r["X-Requested-With"]="XMLHttpRequest",kss.each(r,function(e,s){"content-type"==s.toLowerCase()&&(o=e),l.setRequestHeader(s,e)}),t instanceof Object)if("application/json"==o)t=kss.toJSON(t);else{if(t instanceof Array)throw Error("invalid data type");t=kss.toQueryString(t),"GET"==e&&(s+=(s.indexOf("?")<0?"?":"&")+t,t=null)}if(c?(l.timeout=n,l.onreadystatechange=function(){4==l.readyState&&i(l)}):n&&(a=setTimeout(l.abort,n)),l.send(t),a){if(0==l.readyState)throw Error("Request timed out");clearTimeout(a)}return l},kss.toAbsoluteURL=function(e){var s=document.createElement("a");return s.href=e||"",s.href},kss.toQueryString=function(e){var s=[];return kss.each(e,function(e,t){e instanceof Array||(e=[e]),kss.each(e,function(e){e||0===e?e instanceof Date&&(e=kss.dateToISO8601(e)):e="",s.push(t+"="+encodeURIComponent(String(e)))})}),s.join("&")},kss.RPC=function(e,s){switch(this._endpoint=e||".",s=s||{},this._protocol=(s.protocol||"json-rpc").toLowerCase(),this._protocol){case"json-rpc":case"json-rpc-v1":case"json-rpc-v2":case"xml-rpc":case"url-encoded":case"json":break;default:throw new Error("unknown protocol")}switch(this._timeout=parseInt(s.timeout||1e4),this._dateEncoding=(s.dateEncoding||"iso8601").toLowerCase(),this._dateEncoding){case"iso8601":case"@timestamp@":case"class-hinting":case"asp.net":break;default:throw new Error("unknown dateEncoding")}this._decodeISO8601=!0,void 0!==s.decodeISO8601&&(this._decodeISO8601=!!s.decodeISO8601),this._csrfSelector=s.csrfSelector,this._csrfCookie=s.csrfCookie,this._csrfHeader=s.csrfHeader,this._methodList=[],"auto"==s.methods?this._methodList=this.invoke("system.listMethods"):s.methods&&(this._methodList=s.methods.slice()),this._methodList.push("system.listMethods"),this._methodList.push("system.describe"),kss.each(this._methodList,function(e){var s=this,t=e.split(/\./);kss.each(t.slice(0,-1),function(e){s[e]||(s[e]={}),s=s[e]});var n=function(e,s){var t={instance:e,method:s};return function(){return t.instance.invoke(t.method,arguments[0],arguments[1],arguments[2],arguments[3])}}(this,e);s[t[t.length-1]]=n},this)},kss.RPC.prototype.invoke=function(e,s,t,n){if(e instanceof Object&&e.method&&(s=e.params,t=e.onSuccess,n=e.onError,e=e.method),s&&!(s instanceof Object))throw Error("params must be an array or object");var r,i,o=kss.toAbsoluteURL(this._endpoint);if("url-encoded"==this._protocol||"json"==this._protocol){o&&"/"!=o.substr(-1)&&(o+="/"),o+=e,r=s||{};var a="application/x-www-form-urlencoded";"json"==this._protocol&&(r=kss.toJSON(r,this._dateEncoding),a="application/json"),i={"Content-Type":a,Accept:"application/json"}}else if("xml-rpc"==this._protocol)r=kss.toXMLRPC(e,s||[]),i={"Content-Type":"text/xml",Accept:"text/xml"};else{var c={method:e,params:s||[],id:kss.uniqueId()};"json-rpc-v1"!=this._protocol&&(c.jsonrpc="2.0"),r=kss.toJSON(c,this._dateEncoding),i={"Content-Type":"application/json",Accept:"application/json"}}if(!o.split("://")[1].indexOf(window.location.host)&&this._csrfHeader){var l;if(this._csrfCookie&&(l=kss.getCookie(this._csrfCookie)),!l&&this._csrfSelector){var u=kss.cssQuery(this._csrfSelector)[0];u&&(l=kss.getDataAttr(u,"csrftoken")||u.value)}l&&(i[this._csrfHeader]=l)}if(o+=o.indexOf("?")<0?"?":"&",o+="_ts="+(new Date).getTime(),!t){var h=kss.POST(o,r,this._timeout,i);return this._getRPCResponse(h)}var f=this;kss.POST(o,r,this._timeout,i,function(e){try{var s=f._getRPCResponse(e)}catch(r){if(!n)throw r;return void n(r)}t(s)})},kss.RPC.prototype._getRPCResponse=function(e){var s=0;try{s=e.status}catch(n){}if(0==s)throw Error("Network error or request timed out");if(200!=s)throw new Error(s+" "+e.statusText);var t={};if("xml-rpc"==this._protocol){if(!e.responseXML)throw Error("Malformed XML document.");t=kss.parseXMLRPC(e.responseXML)}else t=kss.parseJSON(e.responseText,this._decodeISO8601),"url-encoded"!=this._protocol&&"json"!=this._protocol||(t={result:t});if(t.error)throw new Error(t.error.code+" "+t.error.message);return t.result},kss.toJSON=function(e,s){var t=Date.prototype.toJSON;delete Date.prototype.toJSON;var n=JSON.stringify(e,function(e,t){if(t instanceof Date)switch(s){case"class-hinting":return{__jsonclass__:["Date",[t.valueOf()]]};case"@timestamp@":return"@"+t.valueOf()+"@";case"asp.net":return"\\/Date("+t.valueOf()+")\\/";default:return kss.dateToISO8601(t)}return t});return Date.prototype.toJSON=t,n},kss.parseJSON=function(e,s){return JSON.parse(e,function(e,t){if("string"==typeof t){var n;if(s&&(n=kss.ISO8601toDate(t)))return n;if(n=t.match(/^@(\d+)@$/))return new Date(parseInt(n[1],10));if(n=t.match(/^\/Date\((\d+)\)\/$/))return new Date(parseInt(n[1],10))}else if(t instanceof Object&&t.__jsonclass__ instanceof Array&&"Date"==t.__jsonclass__[0])return t.__jsonclass__[1]instanceof Array&&t.__jsonclass__[1][0]?new Date(t.__jsonclass__[1][0]):new Date;return t})},kss.toXMLRPC=function(e,s){var t=['<?xml version="1.0"?><methodCall><methodName>'+e+"</methodName>"];if(s){if(!(s instanceof Array))throw Error("params must be an array");t.push("<params>"),kss.each(s,function(e){t.push("<param>"+kss._toXMLRPCValue(e)+"</param>")}),t.push("</params>")}return t.push("</methodCall>"),t.join("")},kss._toXMLRPCValue=function(e){var s=["<value>"];switch(typeof e){case"number":isFinite(e)?Math.floor(e)==e?s.push("<int>",e.toString(),"</int>"):s.push("<double>",e.toString(),"</double>"):s.push("<nil/>");break;case"boolean":s.push("<boolean>",e?"1":"0","</boolean>");break;case"string":e=e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),s.push("<string>",e,"</string>");break;case"object":null===e?s.push("<nil/>"):e instanceof Date?s.push("<dateTime.iso8601>",kss.dateToISO8601(e),"</dateTime.iso8601>"):e instanceof Array?(s.push("<array><data>"),kss.each(e,function(e){s.push(kss._toXMLRPCValue(e))}),s.push("</data></array>")):(s.push("<struct>"),kss.each(e,function(e,t){s.push("<member>"),s.push("<name>",t,"</name>"),s.push(kss._toXMLRPCValue(e)),s.push("</member>")}),s.push("</struct>"));break;default:s.push("<nil/>"),kss.error('Unable to convert type "'+typeof e+'" to XML-RPC.')}return s.push("</value>"),s.join("")},kss.parseXMLRPC=function(e){var s={result:null},t=e.documentElement;if("methodResponse"!=t.nodeName)throw Error("Invalid XML-RPC document.");var n=t.getElementsByTagName("value")[0],r=n.parentNode;if("param"==r.nodeName&&"params"==r.parentNode.nodeName)s.result=kss._parseXMLRPCValue(n);else{if("fault"!=r.nodeName)throw Error("Invalid XML-RPC document.");var i=kss._parseXMLRPCValue(n);s.error={code:i.faultCode,message:i.faultString}}return s},kss._parseXMLRPCValue=function(e){for(var s="",t=e.childNodes,n=0;n<t.length;n++)if(3==(e=t[n]).nodeType||4==e.nodeType)s+=e.nodeValue.trim();else if(1==e.nodeType){var r=e.nodeName.toLowerCase();if("array"==r){for(var i=[],o=e.firstChild;o&&(1!=o.nodeType||"data"!=o.nodeName);)o=o.nextSibling;if(!o)return i;for(var a=o.firstChild;a;)1==a.nodeType&&"value"==a.nodeName&&i.push(kss._parseXMLRPCValue(a)),a=a.nextSibling;return i}if("struct"==r){var c={};return kss.each(e.childNodes,function(e){if(1==e.nodeType&&"member"==e.nodeName){var s="",t=null;kss.each(e.childNodes,function(e){1==e.nodeType&&("name"==e.nodeName?s=e.firstChild.nodeValue.trim():"value"==e.nodeName&&(t=e))}),s&&t&&(c[s]=kss._parseXMLRPCValue(t))}}),c}var l=e.firstChild;a=l?l.nodeValue.trim():"";switch(r){case"i4":case"int":return parseInt(a,10);case"double":return parseFloat(a);case"boolean":return Boolean(parseInt(a,10));case"string":case"base64":return kss._parseXMLRPCValue(e);case"datetime.iso8601":return kss.ISO8601toDate(a);case"nil":return null;default:return void kss.warn("XML-RPC Parsing Error: Unknown element: "+e.nodeName)}}return s},kss.Parser=function(e,s){for(var t in this.commentre=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,this.atRules=[],kss.Parser.prototype)"at_"==t.slice(0,3)&&this.atRules.push(t);this.source=e.replace(/\r\n?/g,"\n"),this.url=s,this.nestinglevel=0,this.lineno=1,this.column=1},kss.Parser.prototype={position:function(){var e={line:this.lineno,column:this.column},s=this;return function(t){return t.position={start:e,end:{line:s.lineno,column:s.column}},s.whitespace(),t}},logHandler:function(e,s){e.push("\nRuleSheet: "+(this.url||"unknown")),e.push("\nLine: "+this.lineno+", Column: "+this.column)},match:function(e){var s=e.exec(this.source);if(!s)return null;var t=s[0];this.source=this.source.slice(t.length);var n=t.match(/\n/g);n&&(this.lineno+=n.length);var r=t.lastIndexOf("\n");return this.column=~r?t.length-r:this.column+t.length,s},open:function(){var e=this.match(/^\{[{\s]*/);return e?(e[0].trim().length>1&&this.warn("multiple '{'"),this.nestinglevel++,e):this.error("missing '{'")||null},close:function(){var e=1==this.nestinglevel?/^\}[}\s]*/:/^\}\s*/,s=this.match(e);return s?(s[0].trim().length>1&&this.warn("multiple '}'"),this.nestinglevel--,s):this.error("missing '}'")||null},whitespace:function(){this.match(/^\s*/)},comments:function(e){var s;for(e=e||[],this.whitespace();s=this.comment();)e.push(s);return e},comment:function(){var e=this.position(),s=this.match(/^\/\*([\s\S]*?)(\*\/|$)/);return s?(s[2]||this.error("end of comment missing"),e({type:"comment",comment:s[1].trim()})):null},selectors:function(e){var s=this.match(/^([^{]+)/);if(!s)return this.error("selector missing")||[];var t=s[0].trim().replace(this.commentre,"").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g,function(e){return e.replace(/,/g,"")}).split(/\s*(?![^(]*\)),\s*/).map(function(e){return e.replace(/\u200C/g,",")});if(!e)return t;for(var n=[],r=0;r<t.length;r++)(s=t[r].match(/^\s*(.+)\s*:\s*([a-z]+)\s*$/))?n.push({selector:s[1],event:s[2]}):this.error('selector "'+t[r]+'" missing event');return n},declaration:function(){var e=this.position(),s=this.match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(!s)return null;s=s[0].trim();var t=this.match(/^[:\s]*/);(!t||t[0].indexOf(":")<0)&&this.warn('property "'+s+'" missing ":"');var n=this.match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};\n])+)/),r=e({type:"declaration",property:s.replace(this.commentre,""),value:n?n[0].trim().replace(this.commentre,""):""});return(!(t=this.match(/^[;\s]*/))||t[0].indexOf(";")<0)&&this.warn('property "'+s+'" missing ";"'),r},declarations:function(){var e,s=[];if(!this.open())return[];for(this.comments(s);e=this.declaration();)s.push(e),this.comments(s);return s.length||this.warn("no declarations"),this.close(),s},atRuleBlock:function(e){var s=new RegExp("^@("+e+")\\b\\s*"),t=this.position();if(!(n=this.match(s)))return null;e=n[1].trim();var n,r="";return(n=this.match(/^([-\w]+)\s*/))&&(r=n[1]),this.comments(),t({type:e,name:r,declarations:this.declarations()})},atRuleNonBlock:function(e){var s=new RegExp("^@("+e+")\\b\\s*([^;{]+);"),t=this.position(),n=this.match(s);if(!n)return null;var r={type:e=n[1].trim()};return r[e]=n[2].trim(),t(r)},atrule:function(){if("@"!=this.source.charAt(0))return null;var e=kss.each(this.atRules,function(e){return this[e]()||void 0},this);if(!e&&(this.warn('Skipping unknown at-rule "'+this.match(/^@[\w-]*/)[0]+'"'),!this.match(/^\s*[^;{]+;/))){var s,t,n=0;do{this.comments(),(s=this.match(/^[^{}]*{/))&&n++,this.comments(),(t=this.match(/^[^{}]*}/))&&n--}while(n&&(s||t))}return e||null},rule:function(e){var s=this.position(),t=this.selectors(e);return this.comments(),s({type:"rule",selectors:t,declarations:this.declarations()})},rules:function(e){var s,t=[];for(this.comments(t);this.source.length&&"}"!=this.source.charAt(0)&&(s=this.atrule()||this.rule(e));)s&&(t.push(s),this.comments(t));return t},at_config:function(){return this.atRuleBlock("config")},at_import:function(){return this.atRuleNonBlock("import")}},kss.createLogger(kss.Parser.prototype),kss.cssQuery=function(e,s,t){if(!kss._cssQuery)throw new Error("no selector engine available");if("window"==e)return[window];if("document"==e)return[document];if("@"==e.charAt(0)){if(!s)throw new Error("context required for @-selectors");var n=[];switch(e.toLowerCase()){case"@samenode":n=[s];break;case"@parentnode":n=[s.parentNode];break;case"@firstchild":n=[s.firstElementChild];break;case"@lastchild":n=[s.lastElementChild];break;case"@children":case"@childnodes":kss.each(s.childNodes,function(e){1==e.nodeType&&n.push(e)});break;case"@previoussibling":case"@prevsibling":n=[s.previousElementSibling];break;case"@nextsibling":n=[s.nextElementSibling];break;case"@currentform":for(var r=s;r&&r.tagName;){if("form"==r.tagName.toLowerCase()){n=[r];break}r=r.parentNode}break;default:kss.error('invalid selector "'+e+'"')}return n[0]?n:[]}t&&(s=null);n=kss._cssQuery(e,s);try{return[].slice.call(n)}catch(i){return n}},kss.insertNodes=function(e,s,t,n){if("string"==typeof s){var r=kss.cssQuery(s);if(!r.length)return void kss.error('Element with selector "'+s+'" not found to insert nodes');s=r[0]}var i,o;switch(kss.isArrayLike(e)||(e=[e]),t){case"beforebegin":i=s.parentNode,o=s;break;case"afterbegin":i=s,o=s.firstChild;break;case"replaceinner":s.innerHTML="";case"beforeend":i=s,o=null;break;case"replace":case"afterend":i=s.parentNode,o=s.nextSibling;break;default:throw new Error("Invalid position to insert: "+t)}"replace"==t&&i.removeChild(s),kss.each(e,function(e){n&&(e=e.cloneNode(!0)),i.insertBefore(e,o)}),"replace"!=t&&"replaceinner"!=t&&n||kss._cleanUp(),kss.applyRules(i)},kss.parseHTML=function(e,s){var t=document.createElement("div");if(t.innerHTML=e,s){var n=t.getElementsByTagName("script");kss.each(n,function(e){var s=document.createElement("script");s.text=e.text,kss.each(e.attributes,function(e){s.setAttribute(e.name,e.value)}),e.parentNode.replaceChild(s,e)})}var r=[];return kss.each(t.childNodes,function(e){r.push(e)}),r},kss.insertHTML=function(e,s,t,n){var r=kss.parseHTML(s,n);kss.insertNodes(r,e,t)},kss.replaceInnerHTML=function(e,s,t){kss.insertHTML(e,s,"replaceinner",t)},kss.replaceHTML=function(e,s,t){kss.insertHTML(e,s,"replace",t)},kss.appendHTML=function(e,s,t){kss.insertHTML(e,s,"beforeend",t)},kss.prependHTML=function(e,s,t){kss.insertHTML(e,s,"afterbegin",t)},kss.insertHTMLAfter=function(e,s,t){kss.insertHTML(e,s,"afterend",t)},kss.insertHTMLBefore=function(e,s,t){kss.insertHTML(e,s,"beforebegin",t)},kss.deleteNode=function(e){e.parentNode.removeChild(e),kss._cleanUp()},kss.appendNodes=function(e,s,t){kss.insertNodes(e,s,"beforeend",t)},kss.prependNodes=function(e,s,t){kss.insertNodes(e,s,"afterbegin",t)},kss.insertNodesAfter=function(e,s,t){kss.insertNodes(e,s,"afterend",t)},kss.insertNodesBefore=function(e,s,t){kss.insertNodes(e,s,"beforebegin",t)},kss.getNodeAttr=function(e,s,t){do{var n=e.getAttribute(s);e=e.parentNode}while(t&&null===n&&e&&e.getAttribute);return n},kss.setNodeAttr=function(e,s,t){if(null!==t)switch(s){case"checked":case"selected":case"disabled":e[s]=!!t;break;default:e.setAttribute(s,t)}else e.removeAttribute(s)},kss.setNodeAttrs=function(e,s){kss.each(s,function(s,t){this.setNodeAttr(e,t,s)},this)},kss.getDataAttr=function(e,s,t){return this.getNodeAttr(e,"data-"+s.toLowerCase(),t)},kss.setDataAttr=function(e,s,t){this.setNodeAttr(e,"data-"+s.toLowerCase(),t)},kss.setDataAttrs=function(e,s){kss.each(s,function(s,t){this.setDataAttr(e,t,s)},this)},function(){kss._transformProp="transform";var e=document.createElement("div").style;"transform"in e||kss.each(["Webkit","Moz","ms"],function(s){var t=s+"Transform";if(t in e)return kss._transformProp=t,!0})}(),kss._transformProps=["translate","translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","matrix"],kss.getStyle=function(e,s){s=kss.camelCase(s);var t=getComputedStyle(e);if(kss.contains(kss._transformProps,s)){var n=new RegExp("\\b"+s+"\\s*\\(([^)]+)\\s*\\)");s=kss._transformProp;var r=t.getPropertyValue(s).match(n);return r?r[1]:""}return s=kss.hyphenate(s),t.getPropertyValue(s)},kss.setStyle=function(e,s,t){if(s=kss.camelCase(s),kss.contains(kss._transformProps,s)){var n=e.style,r=!1;t=t&&"none"!=t?" "+s+"("+t+")":"";var i=new RegExp("\\b\\s*"+s+"\\s*\\([^)]+\\s*\\)");return n[s=kss._transformProp]=n[s].replace(i,function(){return r=!0,t}),void(!r&&t&&(n[s]+=t))}s in e.style&&(e.style[s]=t)},kss.setStyles=function(e,s){kss.each(s,function(s,t){this.setStyle(e,t,s)},this)},kss.hasClass=function(e,s){return kss.contains(e.className,s)},kss.addClass=function(e,s){this.hasClass(e,s)||(e.className+=" "+s)},kss.removeClass=function(e,s){var t=new RegExp("\\b"+s+"\\b");s=e.className.replace(t,"").trim(),e.className=s.replace(/\s+/g," ")},kss.toggleClass=function(e,s){this.hasClass(e,s)?this.removeClass(e,s):this.addClass(e,s)},kss.submit=function(e){"form"==e.tagName.toLowerCase()?e.submit():kss.warn("Element is not a form!")},kss.focus=function(e){switch(e.tagName.toLowerCase()){case"input":case"select":case"textarea":case"button":e.focus();break;default:kss.warn("Focus on node that cannot have focus!")}},kss.blur=function(e){switch(e.tagName.toLowerCase()){case"input":case"select":case"textarea":case"button":e.blur();break;default:kss.warn("Blur on node that cannot be blurred!")}},kss.getStateVar=function(e){return e in kss._stateVars?kss._stateVars[e]:null},kss.setStateVar=function(e,s){kss._stateVars[e]=s},kss.setStateVars=function(e){kss.each(e,function(e,s){this.setStateVar(s,e)},this)},kss._localStorage={},kss.getLocalVar=function(e){var s=null;try{s=window.localStorage.getItem(e)}catch(t){e in kss._localStorage&&(s=kss._localStorage[e])}try{s=kss.parseJSON(s)}catch(t){}return s},kss.setLocalVar=function(e,s){if(null===s)try{window.localStorage.removeItem(e)}catch(t){delete kss._localStorage[e]}else{s=kss.toJSON(s);try{window.localStorage.setItem(e,s)}catch(t){kss._localStorage[e]=s}}},kss.setLocalVars=function(e){kss.each(e,function(e,s){this.setLocalVar(s,e)},this)},kss._sessionStorage={},kss.getSessionVar=function(e){var s=null;try{s=window.sessionStorage.getItem(e)}catch(t){e in kss._sessionStorage&&(s=kss._sessionStorage[e])}try{s=kss.parseJSON(s)}catch(t){}return s},kss.setSessionVar=function(e,s){if(null===s)try{window.sessionStorage.removeItem(e)}catch(t){delete kss._sessionStorage[e]}else{s=kss.toJSON(s);try{window.sessionStorage.setItem(e,s)}catch(t){kss._sessionStorage[e]=s}}},kss.setSessionVars=function(e){kss.each(e,function(e,s){this.setSessionVar(s,e)},this)},kss.getFormVar=function(e){if(e.disabled)return null;var s;switch((e.tagName||"").toLowerCase()){case"input":switch(e.type){case"text":case"hidden":case"password":return e.value;case"checkbox":case"radio":return e.checked?e.value:null;default:return null}case"textarea":return e.value;case"select":return e.multiple?(s=[],kss.each(e.options,function(e){e.selected&&s.push(e.value)}),s):e.value}if(kss.isArrayLike(e)){var t=[];return kss.each(e,function(e){(s=kss.getFormVar(e))instanceof Array||(s=[s]),kss.each(s,function(e){null!==e&&t.push(e)})}),t.length?1==t.length?t[0]:t:null}return void 0===(s=e.value)&&(kss.warn("Not a form element!"),s=null),s},kss.getAllFormVars=function(e){var s={};return kss.each(e.elements,function(e){e.name&&(s[e.name]=kss.getFormVar(e))}),s},kss._windows={_self:self,_parent:parent,_top:top},kss.openURL=function(e,s){var t={width:"60%",height:"60%",redirect:!1,focus:!0};kss.each(s,function(e,s){t[s]=e});var n=t.target||"_self",r=kss._windows[n]||{closed:!0},i=[];if(r.closed){var o=screen.availWidth,a=screen.availHeight;kss.each({width:o,height:a,left:o,top:a},function(e,s){"string"==typeof t[s]&&"%"==t[s].slice(-1)&&(t[s]=Math.round(e/100*parseInt(t[s])))}),!t.left&&t.width&&(t.left=Math.round((o-t.width)/2)),!t.top&&t.height&&(t.top=Math.round((a-t.height)/2)),kss.each(t,function(e,s){"target"!=s&&"redirect"!=s&&"focus"!=s&&i.push(s+"="+e)})}if(i=i.join(","),e)if(isFinite(e)&&!isNaN(e)){if(r.closed)return;r.history.go(parseInt(e))}else t.redirect&&!r.closed?r.location.replace(e):(r=window.open(e,n,i),"_blank"!=n&&(kss._windows[n]=r));else{if(r.closed)return;r.location.reload(!0)}t.focus&&r&&r.focus()},kss.getCookie=function(e){var s=new RegExp("(^|;)\\s*"+e+"\\s*=([^;]*)"),t=document.cookie.match(s);return t?t[2].trim():null},kss.registerActionProvider({replaceInnerHTML:function(e,s){kss.replaceInnerHTML(e,s.html,s.runScripts)},replaceHTML:function(e,s){kss.replaceHTML(e,s.html,s.runScripts)},appendHTML:function(e,s){kss.appendHTML(e,s.html,s.runScripts)},prependHTML:function(e,s){kss.prependHTML(e,s.html,s.runScripts)},insertHTMLAfter:function(e,s){kss.insertHTMLAfter(e,s.html,s.runScripts)},insertHTMLBefore:function(e,s){kss.insertHTMLBefore(e,s.html,s.runScripts)},deleteNode:function(e,s){kss.deleteNode(e)},moveNodeBefore:function(e,s){kss.insertNodesBefore(e,s.target)},moveNodeAfter:function(e,s){kss.insertNodesAfter(e,s.target)},moveNodeAsFirstChild:function(e,s){kss.prependNodes(e,s.target)},moveNodeAsLastChild:function(e,s){kss.appendNodes(e,s.target)},copyNodeBefore:function(e,s){kss.insertNodesBefore(e,s.target,!0)},copyNodeAfter:function(e,s){kss.insertNodesAfter(e,s.target,!0)},copyNodeAsFirstChild:function(e,s){kss.prependNodes(e,s.target,!0)},copyNodeAsLastChild:function(e,s){kss.appendNodes(e,s.target,!0)},setNodeAttr:function(e,s){kss.setNodeAttr(e,s.name,s.value)},setNodeAttrs:function(e,s){kss.setNodeAttrs(e,s)},setDataAttr:function(e,s){kss.setDataAttr(e,s.name,s.value)},setDataAttrs:function(e,s){kss.setDataAttrs(e,s)},setStyle:function(e,s){kss.setStyle(e,s.name,s.value)},setStyles:function(e,s){kss.setStyles(e,s)},addClass:function(e,s){kss.addClass(e,s.value)},removeClass:function(e,s){kss.removeClass(e,s.value)},toggleClass:function(e,s){kss.toggleClass(e,s.value)},setStateVar:function(e,s){kss.setStateVar(s.name,s.value)},setStateVars:function(e,s){kss.setStateVars(s)},setLocalVar:function(e,s){kss.setLocalVar(s.name,s.value)},setLocalVars:function(e,s){kss.setLocalVars(s)},setSessionVar:function(e,s){kss.setSessionVar(s.name,s.value)},setSessionVars:function(e,s){kss.setSessionVars(s)},openURL:function(e,s){var t=s.href;delete s.href,kss.openURL(t,s)},submit:function(e,s){kss.submit(e)},focus:function(e,s){kss.focus(e)},blur:function(e,s){kss.blur(e)},alert:function(e,s){alert(s.message)},log:function(e,s){var t=s.level;kss._logLevels.indexOf(t)<1&&(t="log"),kss[t](s.message)},error:function(e,s){throw new Error(s.message)}}),kss.registerParameterProvider({nodeAttr:function(e,s,t){return kss.getNodeAttr(e,s,t)},dataAttr:function(e,s,t){return kss.getDataAttr(e,s,t)},stateVar:function(e,s){return kss.getStateVar(s)},localVar:function(e,s){return kss.getLocalVar(s)},sessionVar:function(e,s){return kss.getSessionVar(s)},formVar:function(e,s,t){if(s){var n;if(t){if(!(n=document.forms[t]))return kss.warn('Form "'+t+'" does not exist.'),null}else if(!(n=kss.cssQuery("@currentform",e)[0]))return kss.warn("Element is not a child of a form."),null;if(!(e=n.elements[s]))return kss.warn('Form element "'+s+'" does not exist.'),null}return kss.getFormVar(e)},eventAttr:function(e,s){return s in this.event?this.event[s]:null},errorAttr:function(e,s){var t=this.event.detail;return t instanceof Error&&s in t?t[s]:null},styleVal:function(e,s,t){return t&&!(e=kss.cssQuery(t,e,!0)[0])?null:kss.getStyle(e,s)},hashTag:function(e,s){if("string"==typeof s){var t=s.lastIndexOf("#");return t<0?"":s.slice(t)}return window.location.hash},url:function(e,s){return kss.toAbsoluteURL(s)},contains:function(e,s,t){return kss.contains(s,t)},confirm:function(e,s){return confirm(s)},prompt:function(e,s,t){return prompt(s,t||"")}}),kss.each(["innerText","textContent","innerHTML","outerHTML","clientWidth","clientHeight","offsetWidth","offsetHeight","scrollWidth","scrollHeight"],function(e){kss.registerParameterProvider(e,function(s,t){return t&&!(s=kss.cssQuery(t,s,!0)[0])?null:s[e]})}),kss._historyre=/^#kss-[\w]+$/,kss._historyHash=window.location.hash,kss._loadHistoryHTML=function(e){var s=window.location.hash;if(kss._historyre.test(s)){var t=kss.getSessionVar(s);t&&kss.replaceHTML(document.body,t)}},window.addEventListener("load",kss._loadHistoryHTML,!1),kss._storeHistoryHTML=function(e){var s=kss._historyHash;kss._historyre.test(s)&&kss.setSessionVar(s,document.body.outerHTML)},window.addEventListener("unload",kss._storeHistoryHTML,!1),window.addEventListener("hashchange",function(e){var s=kss._historyHash,t=window.location.hash;s!=t&&(kss._storeHistoryHTML(),kss._historyHash=t,kss._loadHistoryHTML())},!1),kss.addHistoryState=function(){var e=window.location.hash;kss._historyre.test(e)||(kss._historyHash="#kss-"+kss.uniqueId(),window.location.replace(kss._historyHash)),window.location.hash="#kss-"+kss.uniqueId()},kss.registerActionProvider("addHistoryState",kss.addHistoryState),kss._TimeoutEventBinder=function(e){this.eventHandler=e,this.props=e.propertyGetter({delay:null,repeat:!0}),this.hasServerActions=kss.each(e.rule.actions,function(e){if("server"==e.type)return!0})||!1,this.setTimeout()},kss._TimeoutEventBinder.prototype={setTimeout:function(){var e=this.props("delay");if(isNaN(e))this.eventHandler.error('Not a number for timeout-delay: "'+e+'"');else{this.hasServerActions&&e<1e3&&(this.eventHandler.warn("Delay of timeout event must be at least 1000 for rules containing server actions"),e=1e3);var s=this;setTimeout(function(){s.timeout()},e)}},timeout:function(){var e=this.eventHandler.node;document.documentElement.contains(e)&&(this.eventHandler.dispatchEvent(),this.props("repeat")&&this.setTimeout())}},kss.registerEventBinder("timeout",kss._TimeoutEventBinder),kss._SpinnerOnEventBinder=function(e){this.eventHandler=e,this.props=e.propertyGetter({laziness:0,filter:null}),this.timer=null,this.counter=0},kss._SpinnerOnEventBinder.prototype={onstart:function(e,s){if("client"!=s.type){switch(e.eventname){case"spinneron":case"spinneroff":return}var t=this.props("filter");if((!t||kss.contains(t,s.name))&&(this.counter++,!this.timer)){var n=this;this.timer=setTimeout(function(){n.timeout()},this.props("laziness"))}}},oncomplete:function(e,s){if("client"!=s.type){switch(e.eventname){case"spinneron":case"spinneroff":return}var t=this.props("filter");t&&!kss.contains(t,s.name)||(this.counter--,!this.counter&&this.timer&&(clearTimeout(this.timer),this.timer=null))}},timeout:function(){this.eventHandler.dispatchEvent()}},kss.registerEventBinder("spinneron",kss._SpinnerOnEventBinder),kss._SpinnerOffEventBinder=function(e){this.eventHandler=e,this.props=e.propertyGetter({laziness:0,filter:null}),this.timer=null,this.counter=0},kss._SpinnerOffEventBinder.prototype={onstart:function(e,s){if("client"!=s.type){switch(e.eventname){case"spinneroff":return}var t=this.props("filter");t&&!kss.contains(t,s.name)||(this.counter++,this.timer&&(clearTimeout(this.timer),this.timer=null))}},oncomplete:function(e,s){if("client"!=s.type){switch(e.eventname){case"spinneroff":return}var t=this.props("filter");if((!t||kss.contains(t,s.name))&&(this.counter--,!this.counter&&!this.timer)){var n=this;this.timer=setTimeout(function(){n.timeout()},this.props("laziness"))}}},timeout:function(){this.timer=null,this.eventHandler.dispatchEvent()}},kss.registerEventBinder("spinneroff",kss._SpinnerOffEventBinder),kss._ErrorEventBinder=function(e){this.eventHandler=e},kss._ErrorEventBinder.prototype={oncomplete:function(e,s,t){t&&("error"!=e.eventname?(t.action=s,this.eventHandler.dispatchEvent(!1,!1,t)):e.error('Failed to execute action "'+s.name+'" for error event. Error was:\n'+t.message))}},kss.registerEventBinder("error",kss._ErrorEventBinder),kss._loadAnimationLib=function(){var e;function s(e,s,t){var n=s.container;if(delete s.container,(n=n?kss.cssQuery(n)[0]:t)===t){var r=e.id||e.name;r&&window.history.pushState?window.history.pushState({},"","#"+r):window.location.hash="#"+kss.uniqueId()}return n}var t=window.Velocity||window.jQuery&&jQuery.Velocity,n=window.TweenMax||window.TweenLite;if("function"==typeof t)e="Velocity",kss.animate=function(e,n,r){var i={};kss.each(t.defaults,function(e,s){s in n&&(i[s]=n[s],delete n[s])});var o=n.behaviour||"queue";if(delete n.behaviour,kss.hasClass(e,"velocity-animating"))switch(o){case"ignore":return;case"combine":i.queue=!1;break;case"finish":t(e,"finish",!0);break;case"stop":t(e,"stop",!0);break;case"queue":default:i.queue=t.defaults.queue}n.reverse&&(r="reverse"),"scroll"==r?(i.axis=n.axis||["x","y"],i.container=s(e,n),i.queue=!1,kss.each(i.axis,function(s){if(i.axis=s,i.offset=n["offset-"+s]||n.offset||0,i.container){var r="x"==s?"scrollLeft":"scrollTop";i.offset=parseInt(i.offset)-i.container[r]}t(e,"scroll",i)})):t(e,r||n,i)},kss.scroll=function(e,s){kss.animate(e,s,"scroll")};else if(n){e="GreenSock";var r=function(){var e=this.data;this.data=null,e&&e.play()};kss.animate=function(e,s){var t=s.duration||750;delete s.duration;var i=s.behaviour||"queue";delete s.behaviour;var o={};kss.each(s,function(e,s){o[kss.camelCase(s)]=e}),o.paused=!1;var a=n.getTweensOf(e);if(a.length)switch(i){case"ignore":return;case"combine":o.overwrite="auto";break;case"finish":kss.each(a,function(e){e.data=null,e.totalProgress(1).kill()});break;case"stop":o.overwrite="all",kss.each(a,function(e){e.data=null});break;case"queue":default:o.paused=!0}o.onComplete=r;var c=n.to(e,t/1e3,o);o.paused&&(a[a.length-1].data=c)},window.ScrollToPlugin&&(kss.scroll=function(e,t){t.scrollTo=e,kss.animate(s(e,t,window),t)})}else window.jQuery?(e="jQuery",kss.animate=function(e,s){var t={duration:s.duration,easing:s.easing,queue:s.queue};delete s.duration,delete s.easing,delete s.queue;var n=s.behaviour||"queue";delete s.behaviour;var r=$(e);if(r.is(":animated"))switch(n){case"ignore":return;case"combine":t.queue=!1;break;case"finish":r.finish();break;case"stop":r.stop(!0);break;case"queue":default:t.queue=!0}r.animate(s,t)},kss.scroll=function(e,t){var n=$(e).offset();t.scrollTop=n.top,t.scrollLeft=n.left,kss.animate(s(e,t,"html, body"),t)}):window.MooTools&&window.Fx&&Fx.Morph&&(e="MooTools",kss.animate=function(e,s){var t={};s.duration&&(t.duration=s.duration),delete s.duration,s.transition&&(t.transition=s.transition),delete s.transition;var n=s.behaviour||"queue";delete s.behaviour;var r=$(e).get("morph");if(r.isRunning())switch(n){case"ignore":return;case"stop":t.link="cancel";break;case"combine":case"finish":kss.warn('Animation behaviour "'+n+'" not supported');case"queue":default:t.link="chain"}r.setOptions(t),r.start(s)},Fx.Scroll&&(kss.scroll=function(e,t){new Fx.Scroll(s(e,t,window),t).toElement(e,["x","y"])}));return kss.animate||(kss.animate=function(e,s){kss.each(s,function(s,t){switch(t){case"scrollLeft":case"scrollTop":kss.setNodeAttr(e,t,s);break;default:kss.setStyle(e,t,s)}})}),kss.scroll||(kss.scroll=function(e,s){window.location.hash=e.id||kss.uniqueId(),e.scrollIntoView()}),kss.registerActionProvider("animate",kss.animate),kss.registerActionProvider("scroll",kss.scroll),e};
!function(){function e(e,s){var t;s=s||{};try{(t=document.createEvent("CustomEvent")).initCustomEvent(e,!!s.bubbles,!!s.cancelable,s.detail)}catch(n){(t=document.createEvent("Event")).initEvent(e,!!s.bubbles,!!s.cancelable),t.detail=s.detail}return t}"function"!=typeof window.CustomEvent&&(e.prototype=window.Event.prototype,window.CustomEvent=e)}();var kss={version:"0.21-beta",_initialized:!1,_ruleSheets:{},_eventBinders:{},_activeBinders:[],_activeHandlers:[],_actionProviders:{},_paramProviders:{},_stateVars:{},_logging:"warn",_observer:null,useObserver:!1,config:{protocol:"json-rpc",endpoint:".",dateEncoding:"iso8601",timeout:1e4,csrfSelector:null,csrfCookie:null,csrfHeader:null},_init:function(){if(kss._initialized)kss.warn("KSS already initialized");else{kss._initialized=!0,kss.createLogger(kss),kss._logging=kss.getSessionVar("kssLogging")||kss._logging,kss.log("Initializing KSS v"+kss.version+" ..."),window.cssQuery?(kss.info("Using an unknown selector engine"),kss._cssQuery=function(e,s){return cssQuery(e,s)}):window.jQuery?(kss.info("Using jQuery selector engine"),kss._cssQuery=function(e,s){return jQuery(e,s)}):window.Sizzle?(kss.info("Using Sizzle selector engine"),kss._cssQuery=function(e,s){return Sizzle(e,s)}):window.Slick?(kss.info("Using Slick (MooTools) selector engine"),kss._cssQuery=function(e,s){return s=s||document,Slick.search(s,e)}):document.querySelectorAll?(kss.info("Using built-in selector engine"),kss._cssQuery=function(e,s){return(s=s||document).querySelectorAll(e)}):kss.error("No selector engine found"),kss.info("Loaded animation library: "+(kss._loadAnimationLib()||"none"));var e=document.getElementsByTagName("link"),s=0;kss.each(e,function(e){"kinetic-stylesheet"==(e.getAttribute("data-rel")||e.rel)&&"text/kss"==e.type&&(kss.addRuleSheet(e.href),s++)}),kss.info("Found "+s+" rulesheet link(s) in document"),kss.useObserver&&window.MutationObserver?(kss.info("Using MutationObserver: yes"),kss._observer=new MutationObserver(kss._observe),kss._observer.observe(document.documentElement,{childList:!0,subtree:!0})):(kss.info("Using MutationObserver: no"),setInterval(kss._cleanUp,6e4)),window.addEventListener("unload",function(){kss._cleanUp(!0)},!1)}}};"undefined"!=typeof window&&document.addEventListener("DOMContentLoaded",kss._init,!1),kss._observe=function(e,s){var t=[],n=!1;function r(e){if(1==e.nodeType){var s=e.tagName.toLowerCase();if("script"!=s&&"style"!=s)return!0}return!1}kss.each(e,function(e){if("childList"==e.type){var s=e.target,i=s.tagName.toLowerCase();if("html"!=i&&"head"!=i){n||(n=kss.each(e.removedNodes,function(e){if(r(e))return!0})||!1);var o=kss.each(e.addedNodes,function(e){if(r(e)&&e.parentNode)return!0})||!1;if(o){for(var a=t.length-1;a>=0;a--){var c=t[a];if(s.contains(c))t.splice(a,1);else if(c.contains(s)){o=!1;break}}o&&t.push(s)}}}}),n&&kss._cleanUp(!1,!0),kss.each(t,function(e){kss.applyRules(e,!0)})},kss._cleanUp=function(e,s){if(!kss._observer||s||e){for(var t=0,n=document.documentElement,r=kss._activeHandlers,i=r.length-1;i>=0;i--){var o=r[i];!e&&n.contains(o.node)||(o.node.removeEventListener(o.eventname,o),o.node._kssRules=null,o.node=null,r.splice(i,1),t++)}var a=kss._activeBinders;for(i=a.length-1;i>=0;i--){var c=a[i];if(e||!n.contains(c.node)){if(c.node=null,c.binder.cleanUp)try{c.binder.cleanUp()}catch(l){kss.error(l)}a.splice(i,1)}}t&&kss.log("Cleand up "+t+" event handler(s)")}},kss._register=function(e,s,t,n){var r={};e instanceof Object?r=e:r[e]=s,kss.each(r,function(e,s){e instanceof Function&&"_"!=s.charAt(0)&&(n?(t[s]||(t[s]=[]),t[s].push(e)):t[s]=e)})},kss.registerActionProvider=function(e,s){kss._register(e,s,kss._actionProviders)},kss.registerParameterProvider=function(e,s){kss._register(e,s,kss._paramProviders)},kss.registerEventBinder=function(e,s){kss._register(e,s,kss._eventBinders,!0)},kss._hyphenateCache={cssFloat:"float",styleFloat:"float"},kss.hyphenate=function(e){return kss._hyphenateCache[e]||(kss._hyphenateCache[e]=e.replace(/([A-Z])/g,"-$1").toLowerCase())},kss._camelCaseCache={},kss.camelCase=function(e){return kss._camelCaseCache[e]||(kss._camelCaseCache[e]=e.replace(/\-(\w)/g,function(e,s){return s.toUpperCase()}))},kss.dateToISO8601=function(e){return[e.getUTCFullYear(),"-",("0"+(e.getUTCMonth()+1)).slice(-2),"-",("0"+e.getUTCDate()).slice(-2),"T",("0"+e.getUTCHours()).slice(-2),":",("0"+e.getUTCMinutes()).slice(-2),":",("0"+e.getUTCSeconds()).slice(-2),".",("00"+e.getUTCMilliseconds()).slice(-3),"Z"].join("")},kss.ISO8601toDate=function(e){var s;if(s=/^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/.exec(e)){for(var t,n=[1,4,5,6,7,10,11],r=0;t=n[r];++r)s[t]=+s[t]||0;s[2]=(+s[2]||1)-1,s[3]=+s[3]||1;var i=0;"Z"!==s[8]&&void 0!==s[9]&&(i=60*s[10]+s[11],"+"===s[9]&&(i=0-i));var o=Date.UTC(s[1],s[2],s[3],s[4],s[5]+i,s[6],s[7]);return new Date(o)}},kss.uniqueId=function(){return Math.random().toString(36).substring(2)+(new Date).getTime().toString(36)},kss.eval=function(__expr__){return eval("("+__expr__+")")},kss.isNativeEvent=function(e,s){var t=e["on"+s];return null===t||"function"==typeof t},kss.isArrayLike=function(e){if(e&&"object"==typeof e&&e!=window){var s=e.length,t=e.propertyIsEnumerable&&e.propertyIsEnumerable("length");return(0===s||"number"==typeof s&&s>0&&s-1 in e)&&(!t||"function"==typeof e.item)}return!1},kss.each=function(e,s,t){if("string"==typeof e&&(e=e.split(/[\s,;]+/)),kss.isArrayLike(e))for(var n=0;n<e.length;n++){if(void 0!==(i=s.call(t,e[n],n)))return i}else if(e)for(var r in e){var i;if(e.hasOwnProperty(r))if(void 0!==(i=s.call(t,e[r],r)))return i}},kss.contains=function(e,s){return"string"==typeof e&&(e=e.split(/[\s,;]+/)),e.indexOf?e.indexOf(s)>-1:kss.each(e,function(e){if(s===e)return!0})||!1},kss._logTimers={},kss._logLevels=["none","error","warn","time","info","log","debug"],kss._log=function(e,s){var t=kss._logLevels;if(window.console&&!(t.indexOf(e)>t.indexOf(kss._logging))){if(s=[].slice.call(s),"time"==e)return kss._logTimers[s[0]]=(new Date).getTime(),s[0];if(s[0]in kss._logTimers){var n=(new Date).getTime()-kss._logTimers[s[0]];s[0]+=" ("+n+"ms)",delete kss._logTimers[s[0]]}if(!this.logHandler||!1!==this.logHandler(s,e)){console.dir||kss.each(s,function(e,t){"object"!=typeof e||e instanceof Error||(s[t]=JSON.stringify(e,null,4)||e)});var r=console[e]||console.log;Function.prototype.apply.call(r,console,s)}}},kss.setLogLevel=function(e){if(kss._logLevels.indexOf(e)<0)throw Error('Invalid loglevel "'+e+'"');kss._logging=e,kss.setSessionVar("kssLogging",e)},kss.createLogger=function(e){return(e=e||{})._log=kss._log,kss.each(kss._logLevels.slice(1),function(s){s in e||(e[s]=function(){return this._log(s,arguments)})}),e},kss.RuleSheet=function(e,s){this.url=e,this.config=s||kss.config,this.source="",this.rules=[],this.status=null},kss.RuleSheet.prototype={load:function(e){if("loaded"!=this.status){var s=this,t=kss.time("Loaded RuleSheet: "+this.url);kss.GET(this.url,{},this.config.timeout,{},function(n){200!=n.status?(s.status="failed",kss.error('Failed to load "'+s.url+'": '+n.status+" "+n.statusText)):(kss.log(t),s.source=n.responseText,s._parse(!0),s.status="loaded"),e&&e()})}else kss.warn("Rulesheet already loaded")},_parse:function(e){var s=kss.time("Parsed RuleSheet: "+this.url),t=new kss.Parser(this.source,this.url).rules(!0);this.rules=[];var n=this.config;kss.each(t,function(s){if("config"!=s.type||s.name&&"kss"!=s.name){if("rule"==s.type){var t={},r=[];kss.each(s.declarations,function(e){if("declaration"==e.type){var n=e.property,i=e.value;i||kss.warn('Missing value for property "'+n+'".',s);var o=r[r.length-1],a=n.match(/^kss-action-(client|server)$/i);a?r.push({type:a[1].toLowerCase(),name:i,props:{},params:{}}):!o||/^evt-/i.test(n)?t[n.toLowerCase()]=i:/^kss-/i.test(n)?o.props[n.toLowerCase()]=i:o.params[n]=i}}),this.rules.push({selectors:s.selectors,props:t,actions:r,config:n,position:s.position,url:this.url}),r.length||kss.warn("Rule without action.",s)}else if(e&&"import"==s.type){var i=s["import"];i=i.replace(/url\s*\(|\)|'|"|\s/g,""),kss.addRuleSheet(i,n)}}else n=Object.create(n),kss.each(s.declarations,function(e){if("declaration"==e.type){var s=kss.camelCase(e.property);n[s]=e.value}})},this),kss.debug(s)},apply:function(e){var s=0;kss.each(this.rules,function(t){kss.each(t.selectors,function(n){var r=kss.cssQuery(n.selector,e),i=n.event;kss.each(r,function(n){if(n._kssRules||(n._kssRules={}),n._kssRules[i]||(n._kssRules[i]=[]),!kss.contains(n._kssRules[i],t))try{new kss._EventHandler(n,i,t,!e),n._kssRules[i].push(t),s++}catch(r){kss.error(r.message,t)}})})}),this.rules.length&&kss.log("Applied rules to "+s+" node(s)")}},kss.addRuleSheet=function(e,s){if((e=kss.toAbsoluteURL(e))in kss._ruleSheets)kss.warn('Rulesheet "'+e+'" already added.');else{var t=new kss.RuleSheet(e,s);kss._ruleSheets[e]=t,t.load(function(){"loaded"==t.status&&t.apply()})}},kss.applyRules=function(e,s){kss._observer&&!s||kss.each(kss._ruleSheets,function(s){s.apply(e)})},kss._EventHandler=function(e,s,t,n){if(!kss.isNativeEvent(e,s)&&!kss._eventBinders[s])throw Error('Unknown event type "'+s+'"');this.node=e,this.eventname=s,this.event={},this.rule=t,this._queuedActions={},this.kssProps=this.propertyGetter({selector:"@samenode",precondition:!0},t.props),this.evtProps=this.propertyGetter({preventdefault:!1,allowbubbling:!1,preventbubbling:!1}),kss.each(kss._eventBinders[s],function(s){kss._activeBinders.push({node:e,binder:new s(this)})},this),e.addEventListener(s,this,!1),kss._activeHandlers.push(this),"load"==s&&(n&&this.evtProps("initial",!0)||!n&&this.evtProps("insert",!0))&&this.dispatchEvent()},kss._EventHandler.prototype={logHandler:function(e,s){if(e.unshift("Event ["+this.eventname+"]:"),"debug"==kss._logging){var t=this.rule.position;e.push("\nRuleSheet: "+this.rule.url),e.push("\nLine: "+t.start.line+" to "+t.end.line)}},propertyGetter:function(e,s){var t="kss";s||(t="evt-"+this.eventname,s=this.rule.props);var n=this;return function(r,i){var o=t+"-"+r;return o in s||"preventdefault"!=r&&"preventbubbling"!=r&&"allowbubbling"!=r||(o="evt-"+r),o in s?n._evalParam(s[o]):void 0!==i?i:e?e[r]:void 0}},dispatchEvent:function(e,s,t){var n=new CustomEvent(this.eventname,{bubbles:!!e,cancelable:!!s,detail:t});return this.node.dispatchEvent(n)},handleEvent:function(e){this.event=e,(this.evtProps("allowbubbling")||e.target==this.node)&&(this.info("Triggered on element",this.node),this.evtProps("preventdefault")&&e.preventDefault(),this.evtProps("preventbubbling")&&e.stopPropagation(),this.kssProps("precondition")&&kss.each(this.rule.actions,function(e){var s=this.propertyGetter({selector:null,precondition:!0,includeform:null,timeout:null},e.props);if(s("precondition")){var t={},n=s("includeform");if(n){var r=null;if(r="@currentform"==n?kss.cssQuery(n,this.node)[0]:document.forms[n]){var i=0;kss.each(kss.getAllFormVars(r),function(e,s){t[s]=e,i++}),this.log("Acquired "+i+' value(s) of form "'+r.name+'"')}else this.warn('Form "'+n+'" not found')}kss.each(e.params,function(e,s){t[s]=this._evalParam(e)},this),"client"==e.type?this._execClientAction(e.name,t,s("selector")):this._execServerAction(e.name,t,s("timeout"))}},this))},_execClientAction:function(e,s,t){if(kss._actionProviders[e]){var n={};kss.each(s,function(e,s){n[kss.camelCase(s)]=e});var r,i={name:e,type:"client",params:n};this._callBinders("onstart",i);try{t=t||this.kssProps("selector");var o=kss.cssQuery(t,this.node,!0);this.log('Execute client action "'+e+'" for '+o.length+' node(s) (selector "'+t+'")'),this.debug("Parameters:",n),kss.each(o,function(s){kss._actionProviders[e].call(this,s,n)},this)}catch(a){this.error(a),r=a}this._callBinders("oncomplete",i,r)}else this.error('Skipping non-existent client action "'+e+'"')},_execServerAction:function(e,s,t){if(e in this._queuedActions)return this.debug('Queued server action "'+e+'" and dropped previous'),void(this._queuedActions[e]=[s,t]);this._queuedActions[e]=null;var n=Object.create(this.rule.config);t&&(n.timeout=t);var r={name:e,type:"server",params:s};!s||"xml-rpc"!=n.protocol&&"json-rpc-v1"!=n.protocol||(s=[s]),this._callBinders("onstart",r);var i=this;function o(s){s&&i.error(s),i._callBinders("oncomplete",r,s);var t=i._queuedActions[e];delete i._queuedActions[e],t&&i._execServerAction(e,t[0],t[1])}try{var a=this.time('Execute server action "'+e+'"');new kss.RPC(n.endpoint,n).invoke(e,s,function(e){var t;try{if("object"!=typeof e||!(e.commands instanceof Array))throw new Error("Invalid KSS response");if(e.error)throw new Error(e.error);i.log(a),i.debug("Parameters:",s),i.log("Server action returned "+e.commands.length+" command(s)"),kss.each(e.commands,function(e){i._execClientAction(e.action,e.params,e.selector)})}catch(n){t=n}o(t)},o)}catch(c){o(c)}},_callBinders:function(e,s,t){kss.each(kss._activeBinders,function(n){var r=n.binder;try{r[e]&&r[e](this,s,t)}catch(i){this.error(i)}},this)},_evalParam:function(e){if(!e||"string"!=typeof e||!/^(".*"|'.*'|\[.*\]|\{.*\}|true|false|null|[\d.]+)$|\(.*\)/.test(e))return e;var s=e.replace(/\\["']|["'](?:\\["']|[^"'])*["']|([\w$.][\w$.\s]*\()/g,function(e,s){return s&&"."!=s[0]?e=(e="kss._paramProviders."+e).replace("(",".call(this,this.node,"):e});s=s.replace(/,\s*\)/g,")");try{return kss.eval.call(this,s)}catch(t){return t.message='Error evaluating "'+e+'". Error was:\n'+t.message,this.warn(t),null}}},kss.createLogger(kss._EventHandler.prototype),kss.GET=function(e,s,t,n,r){return kss.SEND("GET",e,s,t,n,r)},kss.POST=function(e,s,t,n,r){return kss.SEND("POST",e,s,t,n,r)},kss.SEND=function(e,s,t,n,r,i){var o,a,c=!!i,l=new XMLHttpRequest;if(l.open(e,s,c),r||(r={}),r["X-Requested-With"]="XMLHttpRequest",kss.each(r,function(e,s){"content-type"==s.toLowerCase()&&(o=e),l.setRequestHeader(s,e)}),t instanceof Object)if("application/json"==o)t=kss.toJSON(t);else{if(t instanceof Array)throw Error("invalid data type");t=kss.toQueryString(t),"GET"==e&&(s+=(s.indexOf("?")<0?"?":"&")+t,t=null)}if(c?(l.timeout=n,l.onreadystatechange=function(){4==l.readyState&&i(l)}):n&&(a=setTimeout(l.abort,n)),l.send(t),a){if(0==l.readyState)throw Error("Request timed out");clearTimeout(a)}return l},kss.toAbsoluteURL=function(e){var s=document.createElement("a");return s.href=e||"",s.href},kss.toQueryString=function(e){var s=[];return kss.each(e,function(e,t){e instanceof Array||(e=[e]),kss.each(e,function(e){e||0===e?e instanceof Date&&(e=kss.dateToISO8601(e)):e="",s.push(t+"="+encodeURIComponent(String(e)))})}),s.join("&")},kss.RPC=function(e,s){switch(this._endpoint=e||".",s=s||{},this._protocol=(s.protocol||"json-rpc").toLowerCase(),this._protocol){case"json-rpc":case"json-rpc-v1":case"json-rpc-v2":case"xml-rpc":case"url-encoded":case"json":break;default:throw new Error("unknown protocol")}switch(this._timeout=parseInt(s.timeout||1e4),this._dateEncoding=(s.dateEncoding||"iso8601").toLowerCase(),this._dateEncoding){case"iso8601":case"@timestamp@":case"class-hinting":case"asp.net":break;default:throw new Error("unknown dateEncoding")}this._decodeISO8601=!0,void 0!==s.decodeISO8601&&(this._decodeISO8601=!!s.decodeISO8601),this._csrfSelector=s.csrfSelector,this._csrfCookie=s.csrfCookie,this._csrfHeader=s.csrfHeader,this._methodList=[],"auto"==s.methods?this._methodList=this.invoke("system.listMethods"):s.methods&&(this._methodList=s.methods.slice()),this._methodList.push("system.listMethods"),this._methodList.push("system.describe"),kss.each(this._methodList,function(e){var s=this,t=e.split(/\./);kss.each(t.slice(0,-1),function(e){s[e]||(s[e]={}),s=s[e]});var n=function(e,s){var t={instance:e,method:s};return function(){return t.instance.invoke(t.method,arguments[0],arguments[1],arguments[2],arguments[3])}}(this,e);s[t[t.length-1]]=n},this)},kss.RPC.prototype.invoke=function(e,s,t,n){if(e instanceof Object&&e.method&&(s=e.params,t=e.onSuccess,n=e.onError,e=e.method),s&&!(s instanceof Object))throw Error("params must be an array or object");var r,i,o=kss.toAbsoluteURL(this._endpoint);if("url-encoded"==this._protocol||"json"==this._protocol){o&&"/"!=o.substr(-1)&&(o+="/"),o+=e,r=s||{};var a="application/x-www-form-urlencoded";"json"==this._protocol&&(r=kss.toJSON(r,this._dateEncoding),a="application/json"),i={"Content-Type":a,Accept:"application/json"}}else if("xml-rpc"==this._protocol)r=kss.toXMLRPC(e,s||[]),i={"Content-Type":"text/xml",Accept:"text/xml"};else{var c={method:e,params:s||[],id:kss.uniqueId()};"json-rpc-v1"!=this._protocol&&(c.jsonrpc="2.0"),r=kss.toJSON(c,this._dateEncoding),i={"Content-Type":"application/json",Accept:"application/json"}}if(!o.split("://")[1].indexOf(window.location.host)&&this._csrfHeader){var l;if(this._csrfCookie&&(l=kss.getCookie(this._csrfCookie)),!l&&this._csrfSelector){var u=kss.cssQuery(this._csrfSelector)[0];u&&(l=kss.getDataAttr(u,"csrftoken")||u.value)}l&&(i[this._csrfHeader]=l)}if(o+=o.indexOf("?")<0?"?":"&",o+="_ts="+(new Date).getTime(),!t){var h=kss.POST(o,r,this._timeout,i);return this._getRPCResponse(h)}var f=this;kss.POST(o,r,this._timeout,i,function(e){try{var s=f._getRPCResponse(e)}catch(r){if(!n)throw r;return void n(r)}t(s)})},kss.RPC.prototype._getRPCResponse=function(e){var s=0;try{s=e.status}catch(n){}if(0==s)throw Error("Network error or request timed out");if(200!=s)throw new Error(s+" "+e.statusText);var t={};if("xml-rpc"==this._protocol){if(!e.responseXML)throw Error("Malformed XML document.");t=kss.parseXMLRPC(e.responseXML)}else t=kss.parseJSON(e.responseText,this._decodeISO8601),"url-encoded"!=this._protocol&&"json"!=this._protocol||(t={result:t});if(t.error)throw new Error(t.error.code+" "+t.error.message);return t.result},kss.toJSON=function(e,s){var t=Date.prototype.toJSON;delete Date.prototype.toJSON;var n=JSON.stringify(e,function(e,t){if(t instanceof Date)switch(s){case"class-hinting":return{__jsonclass__:["Date",[t.valueOf()]]};case"@timestamp@":return"@"+t.valueOf()+"@";case"asp.net":return"\\/Date("+t.valueOf()+")\\/";default:return kss.dateToISO8601(t)}return t});return Date.prototype.toJSON=t,n},kss.parseJSON=function(e,s){return JSON.parse(e,function(e,t){if("string"==typeof t){var n;if(s&&(n=kss.ISO8601toDate(t)))return n;if(n=t.match(/^@(\d+)@$/))return new Date(parseInt(n[1],10));if(n=t.match(/^\/Date\((\d+)\)\/$/))return new Date(parseInt(n[1],10))}else if(t instanceof Object&&t.__jsonclass__ instanceof Array&&"Date"==t.__jsonclass__[0])return t.__jsonclass__[1]instanceof Array&&t.__jsonclass__[1][0]?new Date(t.__jsonclass__[1][0]):new Date;return t})},kss.toXMLRPC=function(e,s){var t=['<?xml version="1.0"?><methodCall><methodName>'+e+"</methodName>"];if(s){if(!(s instanceof Array))throw Error("params must be an array");t.push("<params>"),kss.each(s,function(e){t.push("<param>"+kss._toXMLRPCValue(e)+"</param>")}),t.push("</params>")}return t.push("</methodCall>"),t.join("")},kss._toXMLRPCValue=function(e){var s=["<value>"];switch(typeof e){case"number":isFinite(e)?Math.floor(e)==e?s.push("<int>",e.toString(),"</int>"):s.push("<double>",e.toString(),"</double>"):s.push("<nil/>");break;case"boolean":s.push("<boolean>",e?"1":"0","</boolean>");break;case"string":e=e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),s.push("<string>",e,"</string>");break;case"object":null===e?s.push("<nil/>"):e instanceof Date?s.push("<dateTime.iso8601>",kss.dateToISO8601(e),"</dateTime.iso8601>"):e instanceof Array?(s.push("<array><data>"),kss.each(e,function(e){s.push(kss._toXMLRPCValue(e))}),s.push("</data></array>")):(s.push("<struct>"),kss.each(e,function(e,t){s.push("<member>"),s.push("<name>",t,"</name>"),s.push(kss._toXMLRPCValue(e)),s.push("</member>")}),s.push("</struct>"));break;default:s.push("<nil/>"),kss.error('Unable to convert type "'+typeof e+'" to XML-RPC.')}return s.push("</value>"),s.join("")},kss.parseXMLRPC=function(e){var s={result:null},t=e.documentElement;if("methodResponse"!=t.nodeName)throw Error("Invalid XML-RPC document.");var n=t.getElementsByTagName("value")[0],r=n.parentNode;if("param"==r.nodeName&&"params"==r.parentNode.nodeName)s.result=kss._parseXMLRPCValue(n);else{if("fault"!=r.nodeName)throw Error("Invalid XML-RPC document.");var i=kss._parseXMLRPCValue(n);s.error={code:i.faultCode,message:i.faultString}}return s},kss._parseXMLRPCValue=function(e){for(var s="",t=e.childNodes,n=0;n<t.length;n++)if(3==(e=t[n]).nodeType||4==e.nodeType)s+=e.nodeValue.trim();else if(1==e.nodeType){var r=e.nodeName.toLowerCase();if("array"==r){for(var i=[],o=e.firstChild;o&&(1!=o.nodeType||"data"!=o.nodeName);)o=o.nextSibling;if(!o)return i;for(var a=o.firstChild;a;)1==a.nodeType&&"value"==a.nodeName&&i.push(kss._parseXMLRPCValue(a)),a=a.nextSibling;return i}if("struct"==r){var c={};return kss.each(e.childNodes,function(e){if(1==e.nodeType&&"member"==e.nodeName){var s="",t=null;kss.each(e.childNodes,function(e){1==e.nodeType&&("name"==e.nodeName?s=e.firstChild.nodeValue.trim():"value"==e.nodeName&&(t=e))}),s&&t&&(c[s]=kss._parseXMLRPCValue(t))}}),c}var l=e.firstChild;a=l?l.nodeValue.trim():"";switch(r){case"i4":case"int":return parseInt(a,10);case"double":return parseFloat(a);case"boolean":return Boolean(parseInt(a,10));case"string":case"base64":return kss._parseXMLRPCValue(e);case"datetime.iso8601":return kss.ISO8601toDate(a);case"nil":return null;default:return void kss.warn("XML-RPC Parsing Error: Unknown element: "+e.nodeName)}}return s},kss.Parser=function(e,s){for(var t in this.commentre=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,this.atRules=[],kss.Parser.prototype)"at_"==t.slice(0,3)&&this.atRules.push(t);this.source=e.replace(/\r\n?/g,"\n"),this.url=s,this.nestinglevel=0,this.lineno=1,this.column=1},kss.Parser.prototype={position:function(){var e={line:this.lineno,column:this.column},s=this;return function(t){return t.position={start:e,end:{line:s.lineno,column:s.column}},s.whitespace(),t}},logHandler:function(e,s){e.push("\nRuleSheet: "+(this.url||"unknown")),e.push("\nLine: "+this.lineno+", Column: "+this.column)},match:function(e){var s=e.exec(this.source);if(!s)return null;var t=s[0];this.source=this.source.slice(t.length);var n=t.match(/\n/g);n&&(this.lineno+=n.length);var r=t.lastIndexOf("\n");return this.column=~r?t.length-r:this.column+t.length,s},open:function(){var e=this.match(/^\{[{\s]*/);return e?(e[0].trim().length>1&&this.warn("multiple '{'"),this.nestinglevel++,e):this.error("missing '{'")||null},close:function(){var e=1==this.nestinglevel?/^\}[}\s]*/:/^\}\s*/,s=this.match(e);return s?(s[0].trim().length>1&&this.warn("multiple '}'"),this.nestinglevel--,s):this.error("missing '}'")||null},whitespace:function(){this.match(/^\s*/)},comments:function(e){var s;for(e=e||[],this.whitespace();s=this.comment();)e.push(s);return e},comment:function(){var e=this.position(),s=this.match(/^\/\*([\s\S]*?)(\*\/|$)/);return s?(s[2]||this.error("end of comment missing"),e({type:"comment",comment:s[1].trim()})):null},selectors:function(e){var s=this.match(/^([^{]+)/);if(!s)return this.error("selector missing")||[];var t=s[0].trim().replace(this.commentre,"").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g,function(e){return e.replace(/,/g,"")}).split(/\s*(?![^(]*\)),\s*/).map(function(e){return e.replace(/\u200C/g,",")});if(!e)return t;for(var n=[],r=0;r<t.length;r++)(s=t[r].match(/^\s*(.+)\s*:\s*([a-z]+)\s*$/))?n.push({selector:s[1],event:s[2]}):this.error('selector "'+t[r]+'" missing event');return n},declaration:function(){var e=this.position(),s=this.match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(!s)return null;s=s[0].trim();var t=this.match(/^[:\s]*/);(!t||t[0].indexOf(":")<0)&&this.warn('property "'+s+'" missing ":"');var n=this.match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};\n])+)/),r=e({type:"declaration",property:s.replace(this.commentre,""),value:n?n[0].trim().replace(this.commentre,""):""});return(!(t=this.match(/^[;\s]*/))||t[0].indexOf(";")<0)&&this.warn('property "'+s+'" missing ";"'),r},declarations:function(){var e,s=[];if(!this.open())return[];for(this.comments(s);e=this.declaration();)s.push(e),this.comments(s);return s.length||this.warn("no declarations"),this.close(),s},atRuleBlock:function(e){var s=new RegExp("^@("+e+")\\b\\s*"),t=this.position();if(!(n=this.match(s)))return null;e=n[1].trim();var n,r="";return(n=this.match(/^([-\w]+)\s*/))&&(r=n[1]),this.comments(),t({type:e,name:r,declarations:this.declarations()})},atRuleNonBlock:function(e){var s=new RegExp("^@("+e+")\\b\\s*([^;{]+);"),t=this.position(),n=this.match(s);if(!n)return null;var r={type:e=n[1].trim()};return r[e]=n[2].trim(),t(r)},atrule:function(){if("@"!=this.source.charAt(0))return null;var e=kss.each(this.atRules,function(e){return this[e]()||void 0},this);if(!e&&(this.warn('Skipping unknown at-rule "'+this.match(/^@[\w-]*/)[0]+'"'),!this.match(/^\s*[^;{]+;/))){var s,t,n=0;do{this.comments(),(s=this.match(/^[^{}]*{/))&&n++,this.comments(),(t=this.match(/^[^{}]*}/))&&n--}while(n&&(s||t))}return e||null},rule:function(e){var s=this.position(),t=this.selectors(e);return this.comments(),s({type:"rule",selectors:t,declarations:this.declarations()})},rules:function(e){var s,t=[];for(this.comments(t);this.source.length&&"}"!=this.source.charAt(0)&&(s=this.atrule()||this.rule(e));)s&&(t.push(s),this.comments(t));return t},at_config:function(){return this.atRuleBlock("config")},at_import:function(){return this.atRuleNonBlock("import")}},kss.createLogger(kss.Parser.prototype),kss.cssQuery=function(e,s,t){if(!kss._cssQuery)throw new Error("no selector engine available");if("window"==e)return[window];if("document"==e)return[document];if("@"==e.charAt(0)){if(!s)throw new Error("context required for @-selectors");var n=[];switch(e.toLowerCase()){case"@samenode":n=[s];break;case"@parentnode":n=[s.parentNode];break;case"@firstchild":n=[s.firstElementChild];break;case"@lastchild":n=[s.lastElementChild];break;case"@children":case"@childnodes":kss.each(s.childNodes,function(e){1==e.nodeType&&n.push(e)});break;case"@previoussibling":case"@prevsibling":n=[s.previousElementSibling];break;case"@nextsibling":n=[s.nextElementSibling];break;case"@currentform":for(var r=s;r&&r.tagName;){if("form"==r.tagName.toLowerCase()){n=[r];break}r=r.parentNode}break;default:kss.error('invalid selector "'+e+'"')}return n[0]?n:[]}t&&(s=null);n=kss._cssQuery(e,s);try{return[].slice.call(n)}catch(i){return n}},kss.insertNodes=function(e,s,t,n){if("string"==typeof s){var r=kss.cssQuery(s);if(!r.length)return void kss.error('Element with selector "'+s+'" not found to insert nodes');s=r[0]}var i,o;switch(kss.isArrayLike(e)||(e=[e]),t){case"beforebegin":i=s.parentNode,o=s;break;case"afterbegin":i=s,o=s.firstChild;break;case"replaceinner":s.innerHTML="";case"beforeend":i=s,o=null;break;case"replace":case"afterend":i=s.parentNode,o=s.nextSibling;break;default:throw new Error("Invalid position to insert: "+t)}"replace"==t&&i.removeChild(s),kss.each(e,function(e){n&&(e=e.cloneNode(!0)),i.insertBefore(e,o)}),"replace"!=t&&"replaceinner"!=t&&n||kss._cleanUp(),kss.applyRules(i)},kss.parseHTML=function(e,s){var t=document.createElement("div");if(t.innerHTML=e,s){var n=t.getElementsByTagName("script");kss.each(n,function(e){var s=document.createElement("script");s.text=e.text,kss.each(e.attributes,function(e){s.setAttribute(e.name,e.value)}),e.parentNode.replaceChild(s,e)})}var r=[];return kss.each(t.childNodes,function(e){r.push(e)}),r},kss.insertHTML=function(e,s,t,n){var r=kss.parseHTML(s,n);kss.insertNodes(r,e,t)},kss.replaceInnerHTML=function(e,s,t){kss.insertHTML(e,s,"replaceinner",t)},kss.replaceHTML=function(e,s,t){kss.insertHTML(e,s,"replace",t)},kss.appendHTML=function(e,s,t){kss.insertHTML(e,s,"beforeend",t)},kss.prependHTML=function(e,s,t){kss.insertHTML(e,s,"afterbegin",t)},kss.insertHTMLAfter=function(e,s,t){kss.insertHTML(e,s,"afterend",t)},kss.insertHTMLBefore=function(e,s,t){kss.insertHTML(e,s,"beforebegin",t)},kss.deleteNode=function(e){e.parentNode.removeChild(e),kss._cleanUp()},kss.appendNodes=function(e,s,t){kss.insertNodes(e,s,"beforeend",t)},kss.prependNodes=function(e,s,t){kss.insertNodes(e,s,"afterbegin",t)},kss.insertNodesAfter=function(e,s,t){kss.insertNodes(e,s,"afterend",t)},kss.insertNodesBefore=function(e,s,t){kss.insertNodes(e,s,"beforebegin",t)},kss.getNodeAttr=function(e,s,t){do{var n=e.getAttribute(s);e=e.parentNode}while(t&&null===n&&e&&e.getAttribute);return n},kss.setNodeAttr=function(e,s,t){if(null!==t)switch(s){case"checked":case"selected":case"disabled":e[s]=!!t;break;default:e.setAttribute(s,t)}else e.removeAttribute(s)},kss.setNodeAttrs=function(e,s){kss.each(s,function(s,t){this.setNodeAttr(e,t,s)},this)},kss.getDataAttr=function(e,s,t){return this.getNodeAttr(e,"data-"+s.toLowerCase(),t)},kss.setDataAttr=function(e,s,t){this.setNodeAttr(e,"data-"+s.toLowerCase(),t)},kss.setDataAttrs=function(e,s){kss.each(s,function(s,t){this.setDataAttr(e,t,s)},this)},function(){kss._transformProp="transform";var e=document.createElement("div").style;"transform"in e||kss.each(["Webkit","Moz","ms"],function(s){var t=s+"Transform";if(t in e)return kss._transformProp=t,!0})}(),kss._transformProps=["translate","translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","matrix"],kss.getStyle=function(e,s){s=kss.camelCase(s);var t=getComputedStyle(e);if(kss.contains(kss._transformProps,s)){var n=new RegExp("\\b"+s+"\\s*\\(([^)]+)\\s*\\)");s=kss._transformProp;var r=t.getPropertyValue(s).match(n);return r?r[1]:""}return s=kss.hyphenate(s),t.getPropertyValue(s)},kss.setStyle=function(e,s,t){if(s=kss.camelCase(s),kss.contains(kss._transformProps,s)){var n=e.style,r=!1;t=t&&"none"!=t?" "+s+"("+t+")":"";var i=new RegExp("\\b\\s*"+s+"\\s*\\([^)]+\\s*\\)");return n[s=kss._transformProp]=n[s].replace(i,function(){return r=!0,t}),void(!r&&t&&(n[s]+=t))}s in e.style&&(e.style[s]=t)},kss.setStyles=function(e,s){kss.each(s,function(s,t){this.setStyle(e,t,s)},this)},kss.hasClass=function(e,s){return kss.contains(e.className,s)},kss.addClass=function(e,s){this.hasClass(e,s)||(e.className+=" "+s)},kss.removeClass=function(e,s){var t=new RegExp("\\b"+s+"\\b");s=e.className.replace(t,"").trim(),e.className=s.replace(/\s+/g," ")},kss.toggleClass=function(e,s){this.hasClass(e,s)?this.removeClass(e,s):this.addClass(e,s)},kss.submit=function(e){"form"==e.tagName.toLowerCase()?e.submit():kss.warn("Element is not a form!")},kss.focus=function(e){switch(e.tagName.toLowerCase()){case"input":case"select":case"textarea":case"button":e.focus();break;default:kss.warn("Focus on node that cannot have focus!")}},kss.blur=function(e){switch(e.tagName.toLowerCase()){case"input":case"select":case"textarea":case"button":e.blur();break;default:kss.warn("Blur on node that cannot be blurred!")}},kss.getStateVar=function(e){return e in kss._stateVars?kss._stateVars[e]:null},kss.setStateVar=function(e,s){kss._stateVars[e]=s},kss.setStateVars=function(e){kss.each(e,function(e,s){this.setStateVar(s,e)},this)},kss._localStorage={},kss.getLocalVar=function(e){var s=null;try{s=window.localStorage.getItem(e)}catch(t){e in kss._localStorage&&(s=kss._localStorage[e])}try{s=kss.parseJSON(s)}catch(t){}return s},kss.setLocalVar=function(e,s){if(null===s)try{window.localStorage.removeItem(e)}catch(t){delete kss._localStorage[e]}else{s=kss.toJSON(s);try{window.localStorage.setItem(e,s)}catch(t){kss._localStorage[e]=s}}},kss.setLocalVars=function(e){kss.each(e,function(e,s){this.setLocalVar(s,e)},this)},kss._sessionStorage={},kss.getSessionVar=function(e){var s=null;try{s=window.sessionStorage.getItem(e)}catch(t){e in kss._sessionStorage&&(s=kss._sessionStorage[e])}try{s=</