
// usage: log('inside coolFunc', this, arguments);
window.log = function(){
  log.history = log.history || [];   // store logs to an array for reference
  log.history.push(arguments);
  if(this.console) {
      arguments.callee = arguments.callee.caller;
      console.log( Array.prototype.slice.call(arguments) );
  }
};
(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();)b[a]=b[a]||c})(window.console=window.console||{});

// Underscore.js 1.2.4
// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
// Underscore is freely distributable under the MIT license.
// Portions of Underscore are inspired or borrowed from Prototype,
// Oliver Steele's Functional, and John Resig's Micro-Templating.
// For all details and documentation:
// http://documentcloud.github.com/underscore
(function(){function r(a,c,d){if(a===c)return a!==0||1/a==1/c;if(a==null||c==null)return a===c;if(a._chain)a=a._wrapped;if(c._chain)c=c._wrapped;if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return false;switch(e){case "[object String]":return a==String(c);case "[object Number]":return a!=+a?c!=+c:a==0?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source==
c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if(typeof a!="object"||typeof c!="object")return false;for(var f=d.length;f--;)if(d[f]==a)return true;d.push(a);var f=0,g=true;if(e=="[object Array]"){if(f=a.length,g=f==c.length)for(;f--;)if(!(g=f in a==f in c&&r(a[f],c[f],d)))break}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return false;for(var h in a)if(m.call(a,h)&&(f++,!(g=m.call(c,h)&&r(a[h],c[h],d))))break;if(g){for(h in c)if(m.call(c,
h)&&!f--)break;g=!f}}d.pop();return g}var s=this,G=s._,o={},k=Array.prototype,p=Object.prototype,i=k.slice,H=k.unshift,l=p.toString,m=p.hasOwnProperty,w=k.forEach,x=k.map,y=k.reduce,z=k.reduceRight,A=k.filter,B=k.every,C=k.some,q=k.indexOf,D=k.lastIndexOf,p=Array.isArray,I=Object.keys,t=Function.prototype.bind,b=function(a){return new n(a)};if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports)exports=module.exports=b;exports._=b}else typeof define==="function"&&define.amd?
define("underscore",function(){return b}):s._=b;b.VERSION="1.2.4";var j=b.each=b.forEach=function(a,c,b){if(a!=null)if(w&&a.forEach===w)a.forEach(c,b);else if(a.length===+a.length)for(var e=0,f=a.length;e<f;e++){if(e in a&&c.call(b,a[e],e,a)===o)break}else for(e in a)if(m.call(a,e)&&c.call(b,a[e],e,a)===o)break};b.map=function(a,c,b){var e=[];if(a==null)return e;if(x&&a.map===x)return a.map(c,b);j(a,function(a,g,h){e[e.length]=c.call(b,a,g,h)});if(a.length===+a.length)e.length=a.length;return e};
b.reduce=b.foldl=b.inject=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(y&&a.reduce===y)return e&&(c=b.bind(c,e)),f?a.reduce(c,d):a.reduce(c);j(a,function(a,b,i){f?d=c.call(e,d,a,b,i):(d=a,f=true)});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(z&&a.reduceRight===z)return e&&(c=b.bind(c,e)),f?a.reduceRight(c,d):a.reduceRight(c);var g=b.toArray(a).reverse();e&&!f&&
(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect=function(a,c,b){var e;E(a,function(a,g,h){if(c.call(b,a,g,h))return e=a,true});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(A&&a.filter===A)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;
if(B&&a.every===B)return a.every(c,b);j(a,function(a,g,h){if(!(e=e&&c.call(b,a,g,h)))return o});return e};var E=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(C&&a.some===C)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return o});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;return q&&a.indexOf===q?a.indexOf(c)!=-1:b=E(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,
function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck=function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,
b,h){b=c?c.call(d,a,b,h):a;b<e.computed&&(e={value:a,computed:b})});return e.value};b.shuffle=function(a){var c=[],b;j(a,function(a,f){f==0?c[0]=a:(b=Math.floor(Math.random()*(f+1)),c[f]=c[b],c[b]=a)});return c};b.sortBy=function(a,c,d){return b.pluck(b.map(a,function(a,b,g){return{value:a,criteria:c.call(d,a,b,g)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return c<d?-1:c>d?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};j(a,function(a,b){var c=
e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a,c,d){d||(d=b.identity);for(var e=0,f=a.length;e<f;){var g=e+f>>1;d(a[g])<d(c)?e=g+1:f=g}return e};b.toArray=function(a){return!a?[]:a.toArray?a.toArray():b.isArray(a)?i.call(a):b.isArguments(a)?i.call(a):b.values(a)};b.size=function(a){return b.toArray(a).length};b.first=b.head=function(a,b,d){return b!=null&&!d?i.call(a,0,b):a[0]};b.initial=function(a,b,d){return i.call(a,0,a.length-(b==null||d?1:b))};b.last=function(a,b,d){return b!=
null&&!d?i.call(a,Math.max(a.length-b,0)):a[a.length-1]};b.rest=b.tail=function(a,b,d){return i.call(a,b==null||d?1:b)};b.compact=function(a){return b.filter(a,function(a){return!!a})};b.flatten=function(a,c){return b.reduce(a,function(a,e){if(b.isArray(e))return a.concat(c?e:b.flatten(e));a[a.length]=e;return a},[])};b.without=function(a){return b.difference(a,i.call(arguments,1))};b.uniq=b.unique=function(a,c,d){var d=d?b.map(a,d):a,e=[];b.reduce(d,function(d,g,h){if(0==h||(c===true?b.last(d)!=
g:!b.include(d,g)))d[d.length]=g,e[e.length]=a[h];return d},[]);return e};b.union=function(){return b.uniq(b.flatten(arguments,true))};b.intersection=b.intersect=function(a){var c=i.call(arguments,1);return b.filter(b.uniq(a),function(a){return b.every(c,function(c){return b.indexOf(c,a)>=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1));return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=
0;e<c;e++)d[e]=b.pluck(a,""+e);return d};b.indexOf=function(a,c,d){if(a==null)return-1;var e;if(d)return d=b.sortedIndex(a,c),a[d]===c?d:-1;if(q&&a.indexOf===q)return a.indexOf(c);for(d=0,e=a.length;d<e;d++)if(d in a&&a[d]===c)return d;return-1};b.lastIndexOf=function(a,b){if(a==null)return-1;if(D&&a.lastIndexOf===D)return a.lastIndexOf(b);for(var d=a.length;d--;)if(d in a&&a[d]===b)return d;return-1};b.range=function(a,b,d){arguments.length<=1&&(b=a||0,a=0);for(var d=arguments[2]||1,e=Math.max(Math.ceil((b-
a)/d),0),f=0,g=Array(e);f<e;)g[f++]=a,a+=d;return g};var F=function(){};b.bind=function(a,c){var d,e;if(a.bind===t&&t)return t.apply(a,i.call(arguments,1));if(!b.isFunction(a))throw new TypeError;e=i.call(arguments,2);return d=function(){if(!(this instanceof d))return a.apply(c,e.concat(i.call(arguments)));F.prototype=a.prototype;var b=new F,g=a.apply(b,e.concat(i.call(arguments)));return Object(g)===g?g:b}};b.bindAll=function(a){var c=i.call(arguments,1);c.length==0&&(c=b.functions(a));j(c,function(c){a[c]=
b.bind(a[c],a)});return a};b.memoize=function(a,c){var d={};c||(c=b.identity);return function(){var b=c.apply(this,arguments);return m.call(d,b)?d[b]:d[b]=a.apply(this,arguments)}};b.delay=function(a,b){var d=i.call(arguments,2);return setTimeout(function(){return a.apply(a,d)},b)};b.defer=function(a){return b.delay.apply(b,[a,1].concat(i.call(arguments,1)))};b.throttle=function(a,c){var d,e,f,g,h,i=b.debounce(function(){h=g=false},c);return function(){d=this;e=arguments;var b;f||(f=setTimeout(function(){f=
null;h&&a.apply(d,e);i()},c));g?h=true:a.apply(d,e);i();g=true}};b.debounce=function(a,b){var d;return function(){var e=this,f=arguments;clearTimeout(d);d=setTimeout(function(){d=null;a.apply(e,f)},b)}};b.once=function(a){var b=false,d;return function(){if(b)return d;b=true;return d=a.apply(this,arguments)}};b.wrap=function(a,b){return function(){var d=[a].concat(i.call(arguments,0));return b.apply(this,d)}};b.compose=function(){var a=arguments;return function(){for(var b=arguments,d=a.length-1;d>=
0;d--)b=[a[d].apply(this,b)];return b[0]}};b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=I||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var b=[],d;for(d in a)m.call(a,d)&&(b[b.length]=d);return b};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)b[d]!==
void 0&&(a[d]=b[d])});return a};b.defaults=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return r(a,b,[])};b.isEmpty=function(a){if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(m.call(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=p||function(a){return l.call(a)==
"[object Array]"};b.isObject=function(a){return a===Object(a)};b.isArguments=function(a){return l.call(a)=="[object Arguments]"};if(!b.isArguments(arguments))b.isArguments=function(a){return!(!a||!m.call(a,"callee"))};b.isFunction=function(a){return l.call(a)=="[object Function]"};b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};
b.isDate=function(a){return l.call(a)=="[object Date]"};b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.noConflict=function(){s._=G;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e<a;e++)b.call(d,e)};b.escape=function(a){return(""+a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,"&#x2F;")};
b.mixin=function(a){j(b.functions(a),function(c){J(c,b[c]=a[c])})};var K=0;b.uniqueId=function(a){var b=K++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var u=/.^/;b.template=function(a,c){var d=b.templateSettings,d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.escape||u,function(a,b){return"',_.escape("+b.replace(/\\'/g,"'")+"),'"}).replace(d.interpolate||
u,function(a,b){return"',"+b.replace(/\\'/g,"'")+",'"}).replace(d.evaluate||u,function(a,b){return"');"+b.replace(/\\'/g,"'").replace(/[\r\n\t]/g," ").replace(/\\\\/g,"\\")+";__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",e=new Function("obj","_",d);return c?e(c,b):function(a){return e.call(this,a,b)}};b.chain=function(a){return b(a).chain()};var n=function(a){this._wrapped=a};b.prototype=n.prototype;var v=function(a,c){return c?b(a).chain():
a},J=function(a,c){n.prototype[a]=function(){var a=i.call(arguments);H.call(a,this._wrapped);return v(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];n.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return v(d,this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];n.prototype[a]=function(){return v(b.apply(this._wrapped,arguments),this._chain)}});
n.prototype.chain=function(){this._chain=true;return this};n.prototype.value=function(){return this._wrapped}}).call(this);

// dice
(function($,undefined){var diagnosticsToRun=[],diagnosticsRan=!1;$.dicejsAPI={addFunctions:function(a){$.extend(cssFunctionsGlobal,a)},addVariables:function(a){$.extend(cssVariablesGlobal,a)},addDiagnostics:function(a){$.extend(cssDiagnostics,a)},runDiagnostic:function(a,b){diagnosticsRan?runDiagnostic({name:a,options:b}):diagnosticsToRun.push({name:a,options:b})}},$(document).ready(function(){diagnosticsRan=!0;for(var a=0;a<diagnosticsToRun.length;a++)runDiagnostic(diagnosticsToRun[a])});var runDiagnostic=function(a){var b=a.name,c=a.options,d={cssVariablesGlobal:cssVariablesGlobal,cssFunctionsGlobal:cssFunctionsGlobal,styles:allCSSObjects};return cssDiagnostics[b].apply({},[d,c])},cssDiagnostics={},allCSSObjects=[],cssFunctionsGlobal={},cssVariablesGlobal={expr:function(params){var units="";return params=params.replace(/px|\%|em/ig,function(a){return units=a,""}),Math.round(eval(params+";"),0)+units}},seed=0,getNewSeed=function(){return seed++,seed};$.dicejs=function(a,b,c){var c=c||{},d={autoStart:!1,localize:"",push:!0},e=$.extend({},d,c);e.push&&allCSSObjects.push({name:a,styles:b});var f={};f.groupName=a,f.cssObjects=[];var g="",h={},i={},j=function(a){$.extend(h,a)},k=function(a){$.extend(cssFuntions,a)},l=function(a){for(var b in a)cssVariablesGlobal[b]=r(q(a[b]))},m=function(a){$.extend(cssFunctionsGlobal,a)};f.getPrivates=function(){return{cssVariables:h,cssVariablesGlobal:cssVariablesGlobal}},f.localize=function(a,b){e.localize=a,$("#dicejs-"+f.groupName).remove();var b=b||!0;b&&this.injectStyles()},f.addCSSObjects=function(a){if(a.constructor.toString().indexOf("Array")!=-1)for(var b=0;b<a.length;b++)this.addCSSObjects(a[b]);else f.cssObjects.push(a)},f.clearCSS=function(a){f.cssObjects=[],$("#dicejs-"+f.groupName).remove(),a&&f.cssObjects.push(a)},f.injectStyles=function(b){var c=new Date,d=c.getTime();f.groupName=f.groupName||getNewSeed(),($("#dicejs-"+f.groupName).length==0||b)&&$('<style id="dicejs-'+f.groupName+'">'+o(f.cssObjects,a)+"</style>").appendTo($("head"));var e=new Date};var n=function(a){var b=a.toString();return b.substring(b.indexOf(" ")+1,b.indexOf("("))},o=function(a,b,c,d){var d=d||0,f="";d==0&&(f=g);var b=b||"cssjs",c=c||"",h="";for(var n=0;n<a.length;n++){var p=a[n];for(var t in p){var u=e.localize+" "+(c||"")+(t||"");if(t!="cssDescription"&&t!="cssVariables"&&t!="cssVariablesPrivate"&&t!="cssFunctions"&&t!="cssFunctionsPrivate"){h=h+"  "+u+" {";var v="";for(var w in p[t])if(w!="subs"&&!i[w]&&!cssFunctionsGlobal[w])h=h+w.replace(/_/g,"-")+":"+s(p[t][w])+"; ";else if(w=="subs")v=v+o([p[t][w]],"",u,d+1)+" ";else{var x=p[t][w];typeof x=="string"&&x.indexOf("$")!=-1&&(x=r(q(x))),i[w]?h+=i[w](x):h+=cssFunctionsGlobal[w](x)}h=h+"}\n "+v}else switch(t){case"cssDescription":h=h+"\n \n /*"+p[t]+"*/ \n";break;case"cssVariablesPrivate":j(p[t]);break;case"cssVariables":l(p[t]);break;case"cssFunctionsPrivate":k(p[t]);break;case"cssFunctions":m(p[t])}}}return h},p=function(a){return a=h[a.replace("$","")]?r(q(h[a.replace("$","")])):cssVariablesGlobal[a.replace("$","")]?r(q(cssVariablesGlobal[a.replace("$","")])):a,a},q=function(a){return a=a.replace(/\$/g," $").replace(/\+|\-|\*|\^|\%|\!\/|,/g,function(a){return" "+a+" "}).replace(/\$\s+/g,"$").replace(/\s{2,}/g," ").replace(/\(\s{0,}/g,"( ").replace(/\s+\(/g," (").replace(/\)\s{0,}/g,") ").replace(/\s{0,}\)/g," )").replace(/^\s+|\s+$/g,""),a},r=function(a){var b=a.split(" "),c=[],d=[],e=null,f=0;for(var g=0;g<b.length;g++)if(b[g].match(/\$[A-Z]{1,}\(/i))e?c.push(b[g]):e=b[g].replace(/\$|\(/g,""),f++;else if(b[g].match(/\$[A-Z]{1,}/i))e?c.push(p(b[g])):d.push(p(b[g]));else if(b[g]=="(")e?c.push(b[g]):d.push(b[g]),f++;else if(b[g]==")"){f--;if(f>0)e?c.push(b[g]):d.push(b[g]);else if(e){try{cssVariablesGlobal[e]?d.push(cssVariablesGlobal[e](r(c.join(" ")))):d.push(h[e](r(c.join(" "))))}catch(i){}e=null,c=[]}else d.push(b[g])}else b[g].match(/\(/)?(e?c.push(b[g]):d.push(b[g]),f++):e?c.push(b[g]):d.push(b[g]);var j=d.join(" ");return j=j.replace(/[A-Z]\s\-\s[A-Z]/gi,function(a){return a.replace(/\s/g,"")}),j},s=function(a){return $.type(a)==="string"?a.indexOf("$")==-1?a:r(q(a)):a};return f.addCSSObjects(b),f}})(jQuery),function(a,b){var c=["-moz-","-webkit-","-ms-","-o-",""];a.dicejsAPI.addFunctions({transitionAll:function(a){return["transition:all "+a,"-moz-transition:all "+a,"-webkit-transition:all "+a].join("; ")+"; "},vertical_gradient:function(a){var a=a.split(" ");return["background-image: -moz-linear-gradient(100% 100% 90deg, "+a[1]+", "+a[0]+")","background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from("+a[0]+"), to("+a[1]+"))"].join("; ")+";"},border_radius:function(a){return this.rounded_corners(a)},rounded_corners:function(a){return["border-radius:"+a,"-moz-border-radius:"+a,"-webkit-border-radius:"+a].join("; ")+";"},leafUL:function(a){return["border-top-left-radius:"+a,"-moz-border-radius-topleft:"+a,"border-bottom-right-radius:"+a,"-moz-border-radius-bottomright:"+a].join("; ")+";"},leafUR:function(a){return["border-top-right-radius:"+a,"-moz-border-radius-topright:"+a,"border-bottom-left-radius:"+a,"-moz-border-radius-bottomleft:"+a].join("; ")+";"},tab:function(a){return["-moz-border-radius-topright:"+a,"border-top-right-radius:"+a,"-moz-border-radius-topleft:"+a,"border-top-left-radius:"+a].join("; ")+";"},inner_shadow:function(a){var a=a.split(" "),b=a[0],c=a[1],d=a[2],e=a[3];return[["-webkit-box-shadow: inset",b,c,d,e].join(" "),["-moz-box-shadow: inset",b,c,d,e].join(" "),["box-shadow: inset",b,c,d,e].join(" ")].join(";")+";"},box_shadow:function(a){var a=a.split(" "),b=a[0],c=a[1],d=a[2],e=a[3];return[["-moz-box-shadow:",b,c,d,e].join(" "),["-webkit-box-shadow:",b,c,d,e].join(" "),["box-shadow:",b,c,d,e].join(" "),["-ms-filter:progid:DXImageTransform.Microsoft.Shadow(Strength=",d,",Direction=90,Color='",e,"')"].join("")].join(";")+";"},rotate:function(b){return a.map(c,function(a){return[[a,"transform:rotate("].join(""),b,"deg)"].join("")}).join(";\n")+";\n"},transition:function(b){var d=b.split(" "),e=d[0]?d[0]:"",f=d[1]?d[1]:"",g=d[2]?d[2]:"",h,i,j,k,l=!1;if(e.split(",").length>1||f.split(",").length>1||g.split(",").length>1)l=!0;return l?(h=a.map(c,function(a){return[[a,"transition-property:"].join(""),e].join(" ")}).join(";\n")+";\n",i=a.map(c,function(a){return[[a,"transition-duration:"].join(""),f].join(" ")}).join(";\n")+";\n",j=a.map(c,function(a){return[[a,"transition-timing-function:"].join(""),g].join(" ")}).join(";\n")+";\n",k=[h,i,j].join("\n")):k=a.map(c,function(a){return[[a,"transition:"].join(""),e,f,g].join(" ")}).join(";\n")+";\n",k}})}(jQuery);var dicejsColorsUtils;(function(a,c){var d={hexMap:{0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15},decMap:{0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9",10:"A",11:"B",12:"C",13:"D",14:"E",15:"F"},hexToDec:function(a){return parseInt(this.hexMap[a.substr(0,1)])*16+parseInt(this.hexMap[a.substr(1,1)])},decToHex:function(a){var b=Math.floor(a/16),c=a-b*16;return this.decMap[b]+this.decMap[c]},toRGB:function(a){a=a.replace(/#/g,""),a.length<6&&(a=a.substr(0,1)+a.substr(0,1)+a.substr(0,2)+a.substr(0,2)+a.substr(0,3)+a.substr(0,3));var b=this.hexToDec(a.substr(0,2)),c=this.hexToDec(a.substr(2,2)),d=this.hexToDec(a.substr(4,2));return{r:b,g:c,b:d}},toHEX:function(a){return r=this.decToHex(Math.round(a.r,0)),g=this.decToHex(Math.round(a.g,0)),b=this.decToHex(Math.round(a.b,0)),"#"+r+g+b},RGBtoHSL:function(a){var b=a.r/255,c=a.g/255,d=a.b/255,e=Math.min(b,c,d),f=Math.max(b,c,d),g=f-e,h=(f+e)/2,i=S=0;if(g==0)i=0,S=0;else{h<.5?S=g/(f+e):S=g/(2-f-e);var j=((f-b)/6+g/2)/g,k=((f-c)/6+g/2)/g,l=((f-d)/6+g/2)/g;b==f?i=l-k:c==f?i=1/3+j-l:d==f&&(i=2/3+k-j),i<0&&(i+=1),i>1&&(i-=1)}return{H:i,S:S,L:h}},HSLtoRGB:function(a){var b=function(a,b,c){return c<0&&(c+=1),c>1&&(c-=1),6*c<1?a+(b-a)*6*c:2*c<1?b:3*c<2?a+(b-a)*(2/3-c)*6:a},c=a.S,d=a.H,e=a.L,f,g,h;if(c==0)f=e*255,g=e*255,h=e*255;else{var i,j;e<.5?j=e*(1+c):j=e+c-c*e,i=2*e-j,f=255*b(i,j,d+1/3),g=255*b(i,j,d),h=255*b(i,j,d-1/3)}return{r:f,g:g,b:h}}};d.helpers={invert:function(a){var b=d.toRGB(a);return b.r=255-b.r,b.g=255-b.g,b.b=255-b.b,d.toHEX(b)},hsl:function(a){var a=a.split(","),b=a[0],c=parseFloat(a[1]),e=parseFloat(a[2]),f=parseFloat(a[3]),g=d.toRGB(b),h=d.RGBtoHSL(g);h.H=(h.H+c/100)%1,f&&f!=-1&&(h.L=Math.max(Math.min(f/100,1),0)),e&&e!=-1&&(h.S=Math.max(Math.min(e/100,1),0));var i=d.HSLtoRGB(h);return d.toHEX(i)},compliment:function(a){var a=a.split(","),b=a[0],c=100;a[1]&&(c=parseInt(a[1]));var e=d.toRGB(b),f=d.RGBtoHSL(e);f.H=(f.H+.5)%1;var g=d.HSLtoRGB(f);return d.toHEX(g)},lightness:function(a){var a=a.split(","),b=a[0],c=100;a[1]&&(c=parseInt(a[1]));var e=d.toRGB(b),f=d.RGBtoHSL(e);f.L=c/100;var g=d.HSLtoRGB(f);return d.toHEX(g)},saturation:function(a){var a=a.split(","),b=a[0],c=100;a[1]&&(c=parseInt(a[1]));var e=d.toRGB(b),f=d.RGBtoHSL(e);f.S=c/100;var g=d.HSLtoRGB(f);return d.toHEX(g)}},a.dicejsAPI.addVariables(d.helpers),dicejsColorsUtils=d,dicejsColorsHelpers=d.helpers})(jQuery),function(a,b){var c={color:dicejsColorsUtils,isArray:function(a){return a.constructor.toString().indexOf("Array")==-1?!1:!0},isString:function(a){return typeof a=="string"},templateReplace:function(a,b){return a=a.replace(/\$\{([a-z0-9\-_ ]{1,})\}/gi,function(a){return b[a.replace(/\$|\{|\}/g,"")]}),a},template:function(b,d,e){var f={data:d},g={};if(c.isArray(d)){var h=[];for(var i=0;i<d.length;i++){var j=a(c.templateReplace(b,d[i]));f.node=j,a.isFunction(e)&&e.apply(this,[f]),h.push(j[0])}g=a(h)}else{var h=c.templateReplace(b,d);f.node=a(h),a.isFunction(e)&&e.apply(this,[f]),g=f.node}return g},getVariables:function(a){var b=[];for(var d=0;d<a.length;d++){var e=c.extractVariables(a[d].styles);b=b.concat(e)}return b},extractVariables:function(a){var b=[];for(var d in a)if(c.isArray(a[d]))for(j=0;j<a[d].length;j++){var e=c.extractVariables(a[d][j]);b=b.concat(e)}else if(d=="cssVariables")for(var f in a[d])b.push({name:f,value:a[d][f]});else if(!c.isString(a[d])){var e=c.extractVariables(a[d]);b=b.concat(e)}return b},setVariable:function(a,b){var d=!1;for(var e=0;e<a.length;e++)d||(d=c.findVariable(a[e].styles,b));return d},findVariable:function(a,b){var d=!1;for(var e in a)if(c.isArray(a[e]))for(j=0;j<a[e].length;j++)d=c.findVariable(a[e][j],b);else if(e=="cssVariables")for(var f in a[e])f==b.name&&(d=!0,a[e][f]=b.value);else c.isString(a[e])||(d=c.findVariable(a[e],b));return d},styles:{cssDescription:"dicejs.production.js - toolbar styles",html:{position:"relative"}," .dicejs-production-slider-helper":{cursor:"pointer",display:"inline-block",top:"0",left:"0",width:"100%",height:"100%",z_index:"9999999",position:"absolute"},"#dicejs-production-button":{cursor:"pointer",z_index:"1000020",background:"url(http://dicejs.com/images/util.png) center center no-repeat",position:"absolute",right:"15px",top:"15px",width:"25px",height:"25px"},"#dicejs-production":{text_align:"center",display:"none",color:"#fff",z_index:"1000000",top:"0",left:"0",position:"absolute",width:"100%",height:"60px",subs:{" #dicejs-production-toolbar":{position:"relative",z_index:"1000010",display:"none"}," #dicejs-production-options":{display:"none"}," #dicejs-production-content":{display:"none",position:"absolute",top:"100%",width:"100%",padding_top:"10px"}," #dicejs-production-content-main":{}," #dicejs-production-content-sub":{display:"none",position:"relative"}," #dicejs-production-content-sub-back":{vertical_align:"middle",cursor:"pointer",margin_right:"10px",display:"inline-block",padding:"10px",rounded_corners:"10px",background:"#000",opacity:"0.8",subs:{":hover":{opacity:"1"}}}," #dicejs-production-content-sub-content":{vertical_align:"middle",display:"inline-block",padding:"10px",rounded_corners:"10px",background:"#000"}," #dicejs-production-toolbar-inner":{border:"1px solid #000",padding:"10px",height:"38px"}," #dicejs-production-screen":{z_index:"1000005",border_bottom:"2px solid #444",background:"#000",opacity:"0.75",position:"absolute",top:"0",left:"0",width:"100%",height:"60px"}," .dicejs-production-options-button":{cursor:"pointer",display:"inline-block",background:"#333",border:"1px solid #666",rounded_corners:"5px",padding:"5px 20px",margin:"0 10px 10px 0",subs:{":hover":{background:"#555",border:"1px solid #888"}," span":{vertical_align:"middle"}," span.value":{color:"#DDD"}," .dicejs-production-variable-color":{vertical_align:"top",display:"inline-block",width:"50px",height:"17px",border:"1px solid #ddd"}}}," .dicejs-production-slider-label":{margin_left:"15px",vertical_align:"top",display:"inline-block",padding_top:"8px"}," .dicejs-production-slider":{display:"inline-block",position:"relative",margin:"0 15px 0 10px",height:"30px",subs:{" .dicejs-production-slider-bar":{rounded_corners:"5px",left:"0",position:"absolute",display:"inline-block",width:"100%",height:"5px",top:"14px",background:"#fff"}," .dicejs-production-slider-handle":{cursor:"pointer",rounded_corners:"5px",position:"absolute",display:"inline-block",width:"13px",height:"13px",left:"20px",top:"10px",background:"#6AA"}}}}}},slider:function(b,d,e,f,g,h){var f=f||0,i=0,j=100,k=!1,l=function(b){b.node.find(".dicejs-production-slider").css("width",g+"px");var c=6,d,h=Math.round(g*f/100,0)-c;b.node.find(".dicejs-production-slider-handle").css("left",h+"px"),b.node.find(".dicejs-production-slider-handle").mousedown(function(f){d=a("<span class='dicejs-production-slider-helper'></span>"),k=!0,document.onselectstart=function(a){return a.preventDefault(),!1};var h=f.clientX,l=b.node.find(".dicejs-production-slider-handle").css("left").replace("px","");a("html").prepend(d),d.mouseup(function(a){d.remove(),k=!1,document.onselectstart=function(a){return!0}}),d.mousemove(function(a){if(k){var d=h-a.clientX,f=l-d;f=Math.max(Math.min(f,g-c),0),b.node.find(".dicejs-production-slider-handle").css("left",f+"px");var m=f/(g-c)*(j-i)+i;e(m)}}),d.mouseout(function(a){d.remove(),k=!1,document.onselectstart=function(a){return!0}})})},m={markup:c.template(c.templates.slider,{id:b,title:h},l)};return m.markup.appendTo(d),m}};c.cssObj=a.dicejs("dicejs.production.js",c.styles),a.styles=c.styles,c.templates={wrapper:['<div id="dicejs-production-button"><span></span></div>','<div id="dicejs-production">','<div id="dicejs-production-screen"></div>','<div id="dicejs-production-toolbar">','<div id="dicejs-production-toolbar-inner">','<div id="dicejs-production-options"></div>','<div id="dicejs-production-content">','<div id="dicejs-production-content-main"></div>','<span id="dicejs-production-content-sub">','<span id="dicejs-production-content-sub-back">Back</span>','<span id="dicejs-production-content-sub-content"></span>',"</span>","</div>","</div>","</div>","</div>"].join(""),button:['<span class="dicejs-production-options-button" id="${buttonId}"><span>${buttonName}</span></span>'].join(""),variableButton:['<span class="dicejs-production-options-button variable" id="${name}"><span>${name}</span> : <span class="value" >${value}</span></span>'].join(""),variableButtonColor:['<span class="dicejs-production-options-button variable" id="${name}"><span>${name}</span> : <span class="value" ><span class="dicejs-production-variable-color" style="background:${value};"></span></span></span>'].join(""),variables:['<div id="dicejs-production-variables"></div>'].join(""),slider:["<span>",'<span class="dicejs-production-slider-label">${title}</span>','<span id="${id}" class="dicejs-production-slider">','<span class="dicejs-production-slider-bar"></span>','<span class="dicejs-production-slider-handle"></span>',"</span>","</span>"].join(""),editColor:['<span class="dicejs-production-edit-color">','<span class="dicejs-production-edit-title"></span>','<span class="dicejs-production-edit-hue"></span>','<span class="dicejs-production-edit-saturation"></span>','<span class="dicejs-production-edit-lightness"></span>',"</span>"].join(""),editValue:['<span class="dicejs-production-edit-value">','<span class="dicejs-production-edit-title"></span>','<span class="dicejs-production-edit-value"></span>',"</span>"].join("")};var d={};a.dicejs.setVariables=function(b){for(prop in b)c.setVariable(d,{name:prop,value:b[prop]});for(var e=0;e<d.length;e++)a.dicejs(d[e].name,d[e].styles,{push:!1}).injectStyles(!0)},a.dicejsAPI.addDiagnostics({production:function(b,e){d=b.styles;var f={},e=e||{},g={useIcon:!0,useDebug:!0,useVariables:!0,usePrint:!0,onVariableChanged:function(a){}},e=a.extend({},g,e);c.cssObj.injectStyles(),a("#dicejs-production").remove(),a("body").prepend(a(c.templates.wrapper)),f.container=a("#dicejs-production"),f.toolbar=a("#dicejs-production-toolbar"),f.buttons=a("#dicejs-production-options"),f.content=a("#dicejs-production-content"),f.contentMain=a("#dicejs-production-content-main"),f.contentSub=a("#dicejs-production-content-sub"),f.contentSubBack=a("#dicejs-production-content-sub-back"),f.contentSubContent=a("#dicejs-production-content-sub-content"),f.show=function(){f.content.hide(),f.contentMain.show(),f.contentSub.hide(),f.container.stop(!0,!0).slideDown(300,function(){f.buttons.show(),f.toolbar.stop(!0,!0).fadeIn()})},f.hide=function(){f.toolbar.stop(!0,!0).fadeOut(300,function(){f.container.stop(!0,!0).slideUp(300)})},f.showHide=function(){f.toolbar.css("display")=="none"?f.show():f.hide()},e.useIcon?a("#dicejs-production-button").click(function(a){a.preventDefault(),f.showHide()}):a("#dicejs-production-button").remove(),f.cancelCallBack=a.noop,f.closeSubContent=function(){f.contentSub.fadeOut(300,function(){a("#"+f.currentButton).click()})},f.contentSubBack.click(function(){f.closeSubContent(),f.cancelCallBack()});var h=function(a){var b=function(b){b.node.click(function(b){f.currentButton=a.buttonId,f.show(),b.preventDefault(),f.contentMain.html(""),f.content.hide(),c.template(a.contentTemplate,a,a.contentPostProcess).appendTo(f.contentMain),f.content.fadeIn()})};c.template(c.templates.button,a,b).appendTo(f.buttons)};f.currentButton={};if(e.useVariables){var i=c.getVariables(b.styles),j=function(d){var e=d,g=!1;d.node.click(function(){f.contentMain.slideUp(300,function(){f.contentSubContent.html(""),e.data.value.indexOf("#")==-1?c.template(c.templates.editValue,{},function(b){var d=c.slider("slider-value-"+e.data.name,b.node.find(".dicejs-production-edit-value"),a.noop,30,400,"Value")}).appendTo(f.contentSubContent):c.template(c.templates.editColor,{},function(d){var f=c.color.RGBtoHSL(c.color.toRGB(e.data.value)),h=c.slider("slider-hue-"+e.data.name,d.node.find(".dicejs-production-edit-hue"),function(d){f.H=d/100;var h=c.color.toHEX(c.color.HSLtoRGB(f));e.data.value=h,g?(clearTimeout(g),g=setTimeout(function(){c.setVariable(b.styles,{name:e.data.name,value:h});for(var d=0;d<b.styles.length;d++)a.dicejs(b.styles[d].name,b.styles[d].styles,{push:!1}).injectStyles(!0);clearTimeout(g),g=!1},200)):g=setTimeout(function(){c.setVariable(b.styles,{name:e.data.name,value:h});for(var d=0;d<b.styles.length;d++)a.dicejs(b.styles[d].name,b.styles[d].styles,{push:!1}).injectStyles(!0);clearTimeout(g),g=!1},200)},Math.round(f.H*100,0),150,"H"),i=c.slider("slider-saturation-"+e.data.name,d.node.find(".dicejs-production-edit-saturation"),function(d){f.S=d/100;var h=c.color.toHEX(c.color.HSLtoRGB(f));e.data.value=h,g?(clearTimeout(g),g=setTimeout(function(){c.setVariable(b.styles,{name:e.data.name,value:h});for(var d=0;d<b.styles.length;d++)a.dicejs(b.styles[d].name,b.styles[d].styles,{push:!1}).injectStyles(!0);clearTimeout(g),g=!1},200)):g=setTimeout(function(){c.setVariable(b.styles,{name:e.data.name,value:h});for(var d=0;d<b.styles.length;d++)a.dicejs(b.styles[d].name,b.styles[d].styles,{push:!1}).injectStyles(!0);clearTimeout(g),g=!1},200)},Math.round(f.S*100,0),150,"S"),j=c.slider("slider-lightness-"+e.data.name,d.node.find(".dicejs-production-edit-lightness"),function(d){f.L=d/100;var h=c.color.toHEX(c.color.HSLtoRGB(f));e.data.value=h,g?(clearTimeout(g),g=setTimeout(function(){c.setVariable(b.styles,{name:e.data.name,value:h});for(var d=0;d<b.styles.length;d++)a.dicejs(b.styles[d].name,b.styles[d].styles,{push:!1}).injectStyles(!0);clearTimeout(g),g=!1},200)):g=setTimeout(function(){c.setVariable(b.styles,{name:e.data.name,value:h});for(var d=0;d<b.styles.length;d++)a.dicejs(b.styles[d].name,b.styles[d].styles,{push:!1}).injectStyles(!0);clearTimeout(g),g=!1},200)},Math.round(f.L*100,0),150,"L")}).appendTo(f.contentSubContent),f.contentSub.fadeIn()})})},k=function(a){a.node.click(function(){f.contentMain.slideUp(300,function(){f.contentSubContent.html("markup goes here"),f.contentSub.fadeIn()})})},l=function(a){var b;for(var d=0;d<i.length;d++){var b=c.templates.variableButton;i[d].value.indexOf("$")!=-1?c.template(b,i[d],k).appendTo(a.node):i[d].value.indexOf("#")!=-1?(b=c.templates.variableButtonColor,c.template(b,i[d],j).appendTo(a.node)):c.template(b,i[d],j).appendTo(a.node)}};e.useVariables&&h({buttonId:"adjust-variables",buttonName:"Variables",contentTemplate:c.templates.variables,contentPostProcess:l,data:i})}return e.usePrint&&h({buttonId:"print",buttonName:"Print",contentTemplate:c.templates.debug,contentPostProcess:a.noop,data:{}}),e.useDebug&&h({buttonId:"debug",buttonName:"Debug",contentTemplate:c.templates.debug,contentPostProcess:a.noop,data:{}}),f}})}(jQuery)

