
/*
 * 3dtin.js
 * Copyright (C) 2010-2011  Jayesh Salvi <jayesh@3dtin.com>
 * All Rights Reserved
 */
(function(a){function h(n){return n<10?"000":n<100?"00":n<1E3?"0":""}var m={};m.C={n0d5:59,n182:180,adrefill_interval:6E4,n179:-1,n211:1,n285:2};if(tin_appVersion==0||document.location.hostname=="ubuntu.local"){m.C.factory_host="ubuntu.local";m.C.s3_host="com.3dtin.cadmiumtest.s3-website-us-east-1.amazonaws.com"}else{m.C.factory_host="factory.3dtin.com";m.C.s3_host="com.3dtin.cadmium.s3-website-us-east-1.amazonaws.com"}m.C.useMetalBackend=false;m.C.cadCacheSizeLimit=64;m.n0f4=10;m.utils={};a.app=
m;if(typeof console==="undefined")console={log:function(){},warn:function(){},error:function(){}};m.reportLog=function(n){var d={};try{d={msg:n,sketchuid:m.sketch&&m.sketch.meta?m.sketch.meta.uid_:"not_saved",action:m.editor.action,camera:m.editor.camera.toString(),mirror:m.editor?m.editor.isMirrorOn():undefined,version:tin_appVersion,usetime:m.now()/1E3,backend:m.editor?m.editor.getBackend():undefined}}catch(b){d={oops:""+b}}console.log(d);d.type="log";a.post("/_factory/report",m.sign(d))};m.reportError=
function(n,d){var b={};try{b={msg:""+n,trace:printStackTrace({e:n}).join("</br>"),extra:d,sketchuid:m.sketch&&m.sketch.meta?m.sketch.meta.uid_:"not_saved",opqdump:m.editor?m.editor.model.getOpqDump(5):undefined,action:m.editor.action,camera:m.editor.camera.toString(),mirror:m.editor?m.editor.isMirrorOn():undefined,version:tin_appVersion,usetime:m.now()/1E3,backend:m.editor?m.editor.getBackend():undefined};console.error(b.msg);console.error(b.trace);b.type="error";a.post("/_factory/report",m.sign(b))}catch(g){}};
m.reportStat=function(n){var d={};try{d={msg:n,sketchuid:m.sketch&&m.sketch.meta?m.sketch.meta.uid_:"not_saved",action:m.editor.action,camera:m.editor.camera.toString(),mirror:m.editor?m.editor.isMirrorOn():undefined,version:tin_appVersion,usetime:m.now()/1E3,backend:m.editor?m.editor.getBackend():undefined};d.type="stat";a.post("/_factory/report",m.sign(d))}catch(b){}};m.now=function(){return(new Date).getTime()-m.startTimestamp};m.scratchpad={};m.sign=function(n){return n};m.formatNumber=function(n){return _.isUsableNumber(n)?
h(n)+n:"0000"}})(jQuery);
(function(a){function h(){}function m(){}var n=$.app;a.hotkeys={version:"0.8",specialKeys:{8:"backspace",9:"tab",13:"return",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",
121:"f10",122:"f11",123:"f12",144:"numlock",145:"scroll",191:"/",224:"meta"},shiftNums:{"`":"~","1":"!","2":"@","3":"#","4":"$","5":"%","6":"^","7":"&","8":"*","9":"(","0":")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"}};h.init=function(){h.windowStack=[];$(document).keydown(m)};h.keyHandler=function(d){if(d.handler==m)d.handler=function(b){b.stopPropagation();var g=b.type!=="keypress"&&a.hotkeys.specialKeys[b.which],e=String.fromCharCode(b.which).toLowerCase(),f="";if(this!==
b.target&&(/textarea|select/i.test(b.target.nodeName)||b.target.type==="text"))if(!(g==="esc"||g==="return"))return;var c=h.windowStack[h.windowStack.length-1];if(g=="down"||g=="up")b.preventDefault();if(b.altKey&&g!=="alt")f+="alt+";if(b.ctrlKey&&g!=="ctrl")f+="ctrl+";if(b.metaKey&&!b.ctrlKey&&g!=="meta")f+="meta+";if(b.shiftKey&&g!=="shift")f+="shift+";f+=g?g:e;(g=_.detect(c.handlers,function(j){return f===j.key}))&&g.func(b)}};h.pushHandler=function(d){h.windowStack.push(d)};h.popHandler=function(){h.windowStack.pop()};
a.each(["keydown"],function(){a.event.special[this]={add:h.keyHandler}});n.KBD=h})(jQuery);
(function(a){var h={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(m){var n="",d,b,g,e,f,c,j=0;for(m=h._utf8_encode(m);j<m.length;){d=m.charCodeAt(j++);b=m.charCodeAt(j++);g=m.charCodeAt(j++);e=d>>2;d=(d&3)<<4|b>>4;f=(b&15)<<2|g>>6;c=g&63;if(isNaN(b))f=c=64;else if(isNaN(g))c=64;n=n+this._keyStr.charAt(e)+this._keyStr.charAt(d)+this._keyStr.charAt(f)+this._keyStr.charAt(c)}return n},decode:function(m){var n="",d,b,g,e,f,c=0;for(m=m.replace(/[^A-Za-z0-9\+\/\=]/g,
"");c<m.length;){d=this._keyStr.indexOf(m.charAt(c++));b=this._keyStr.indexOf(m.charAt(c++));e=this._keyStr.indexOf(m.charAt(c++));f=this._keyStr.indexOf(m.charAt(c++));d=d<<2|b>>4;b=(b&15)<<4|e>>2;g=(e&3)<<6|f;n+=String.fromCharCode(d);if(e!=64)n+=String.fromCharCode(b);if(f!=64)n+=String.fromCharCode(g)}return n=h._utf8_decode(n)},_utf8_encode:function(m){m=m.replace(/\r\n/g,"\n");for(var n="",d=0;d<m.length;d++){var b=m.charCodeAt(d);if(b<128)n+=String.fromCharCode(b);else{if(b>127&&b<2048)n+=
String.fromCharCode(b>>6|192);else{n+=String.fromCharCode(b>>12|224);n+=String.fromCharCode(b>>6&63|128)}n+=String.fromCharCode(b&63|128)}}return n},_utf8_decode:function(m){for(var n="",d=0,b=c1=c2=0;d<m.length;){b=m.charCodeAt(d);if(b<128){n+=String.fromCharCode(b);d++}else if(b>191&&b<224){c2=m.charCodeAt(d+1);n+=String.fromCharCode((b&31)<<6|c2&63);d+=2}else{c2=m.charCodeAt(d+1);c3=m.charCodeAt(d+2);n+=String.fromCharCode((b&15)<<12|(c2&63)<<6|c3&63);d+=3}}return n}};a.app.Base64=h})(jQuery);
(function(a){var h=a.app,m=function(e,f){var c=this,j=e.find("img:first"),s=0,o=100,w=100,l=0,B=100,C=100,G=0,A=0,x,t,p=[],D=function(q){for(var y=0;y<p.length;y++)p[y].call(c,c,q)},E=function(q){var y=e.offset();x={l:y.left|0,t:y.top|0};clearTimeout(t);t=setTimeout(function(){k.call(c,q)},0);a(document).bind("mousemove",z).bind("mouseup",u);q.stopPropagation();q.preventDefault();return false},z=function(q){clearTimeout(t);t=setTimeout(function(){k.call(c,q)},0);q.stopPropagation();q.preventDefault();
return false},u=function(q){a(document).unbind("mouseup",u).unbind("mousemove",z);q.stopPropagation();q.preventDefault();return false},k=function(q){var y=q.pageX-x.l;q=q.pageY-x.t;var I=e.w,J=e.h;if(y<0)y=0;else if(y>I)y=I;if(q<0)q=0;else if(q>J)q=J;H.call(c,"xy",{x:y/I*w+s,y:q/J*C+l})},H=function(q,y,I){if(y===undefined){if(q===undefined||q==null)q="xy";switch(q.toLowerCase()){case "x":return G;case "y":return A;case "xy":default:return{x:G,y:A}}}if(!(I!=null&&I==c)){var J=false,N,P;if(q==null)q=
"xy";switch(q.toLowerCase()){case "x":N=y&&(y.x&&y.x|0||y|0)||0;break;case "y":P=y&&(y.y&&y.y|0||y|0)||0;break;case "xy":default:N=y&&y.x&&y.x|0||0;P=y&&y.y&&y.y|0||0;break}if(N!=null){if(N<s)N=s;else if(N>o)N=o;if(G!=N){G=N;J=true}}if(P!=null){if(P<l)P=l;else if(P>B)P=B;if(A!=P){A=P;J=true}}J&&D.call(c,I||c)}},Q=function(q){a.isFunction(q)&&p.push(q)};a.extend(true,c,{val:H,range:function(q,y){if(y===undefined){if(q===undefined||q==null)q="all";switch(q.toLowerCase()){case "minx":return s;case "maxx":return o;
case "rangex":return{minX:s,maxX:o,rangeX:w};case "miny":return l;case "maxy":return B;case "rangey":return{minY:l,maxY:B,rangeY:C};case "all":default:return{minX:s,maxX:o,rangeX:w,minY:l,maxY:B,rangeY:C}}}var I,J,N,P;if(q==null)q="all";switch(q.toLowerCase()){case "minx":I=y&&(y.minX&&y.minX|0||y|0)||0;break;case "maxx":J=y&&(y.maxX&&y.maxX|0||y|0)||0;break;case "rangex":I=y&&y.minX&&y.minX|0||0;J=y&&y.maxX&&y.maxX|0||0;break;case "miny":N=y&&(y.minY&&y.minY|0||y|0)||0;break;case "maxy":P=y&&(y.maxY&&
y.maxY|0||y|0)||0;break;case "rangey":N=y&&y.minY&&y.minY|0||0;P=y&&y.maxY&&y.maxY|0||0;break;case "all":default:I=y&&y.minX&&y.minX|0||0;J=y&&y.maxX&&y.maxX|0||0;N=y&&y.minY&&y.minY|0||0;P=y&&y.maxY&&y.maxY|0||0;break}if(I!=null&&s!=I){s=I;w=o-s}if(J!=null&&o!=J){o=J;w=o-s}if(N!=null&&l!=N){l=N;C=B-l}if(P!=null&&B!=P){B=P;C=B-l}},bind:Q,unbind:function(q){if(a.isFunction(q))for(var y;(y=a.inArray(q,p))!=-1;)p.splice(y,1)},destroy:function(){a(document).unbind("mouseup",u).unbind("mousemove",z);e.unbind("mousedown",
E);p=j=e=null}});j.src=f.arrow&&f.arrow.image;j.w=f.arrow&&f.arrow.width||j.width();j.h=f.arrow&&f.arrow.height||j.height();e.w=f.map&&f.map.width||e.width();e.h=f.map&&f.map.height||e.height();e.bind("mousedown",E);Q.call(c,function(){var q=0,y=0,I=e.w,J=e.h,N=j.w,P=j.h;setTimeout(function(){if(w>0)q=G==o?I:G/w*I|0;if(C>0)y=A==B?J:A/C*J|0;if(N>=I)q=(I>>1)-(N>>1);else q-=N>>1;if(P>=J)y=(J>>1)-(P>>1);else y-=P>>1;j.css({left:q+"px",top:y+"px"})},0)})},n=function(e,f,c){var j=this;e=e.find("td.Text input");
var s=e.eq(3),o=e.eq(4),w=e.eq(5),l=e.length>7?e.eq(6):null,B=e.eq(0),C=e.eq(1),G=e.eq(2),A=e.eq(e.length>7?7:6),x=e.length>7?e.eq(8):null,t=function(u){if(!(u.target.value==""&&u.target!=A.get(0)&&(c!=null&&u.target!=c.get(0)||c==null))){if(!D(u))return u;switch(u.target){case s.get(0):s.val(E.call(j,s.val(),0,255));f.val("r",s.val(),u.target);break;case o.get(0):o.val(E.call(j,o.val(),0,255));f.val("g",o.val(),u.target);break;case w.get(0):w.val(E.call(j,w.val(),0,255));f.val("b",w.val(),u.target);
break;case l&&l.get(0):l.val(E.call(j,l.val(),0,100));f.val("a",l.val(),u.target);break;case B.get(0):B.val(E.call(j,B.val(),0,360));f.val("h",B.val(),u.target);break;case C.get(0):C.val(E.call(j,C.val(),0,100));f.val("s",C.val(),u.target);break;case G.get(0):G.val(E.call(j,G.val(),0,100));f.val("v",G.val(),u.target);break;case A.get(0):A.val(A.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6));c&&c.val(A.val());f.val("hex",A.val()!=""?A.val():null,u.target);break;case c&&c.get(0):c.val(c.val().replace(/[^a-fA-F0-9]/g,
"").toLowerCase().substring(0,6));A.val(c.val());f.val("hex",c.val()!=""?c.val():null,u.target);break;case x&&x.get(0):x.val(x.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,2));f.val("a",x.val()!=null?parseInt(x.val(),16)*100/255:null,u.target);break}}},p=function(u){if(f.val()!=null)switch(u.target){case s.get(0):s.val(f.val("r"));break;case o.get(0):o.val(f.val("g"));break;case w.get(0):w.val(f.val("b"));break;case l&&l.get(0):l.val(f.val("a"));break;case B.get(0):B.val(f.val("h"));
break;case C.get(0):C.val(f.val("s"));break;case G.get(0):G.val(f.val("v"));break;case A.get(0):case c&&c.get(0):A.val(f.val("hex"));c&&c.val(f.val("hex"));break;case x&&x.get(0):x.val(f.val("ahex").substring(6));break}},D=function(u){switch(u.keyCode){case 9:case 16:case 29:case 37:case 38:case 40:return false;case "c".charCodeAt():case "v".charCodeAt():if(u.ctrlKey)return false}return true},E=function(u,k,H){if(u==""||isNaN(u))return k;if(u>H)return H;if(u<k)return k;return u},z=function(u,k){u=
u.val("all");if(k!=s.get(0))s.val(u!=null?u.r:"");if(k!=o.get(0))o.val(u!=null?u.g:"");if(k!=w.get(0))w.val(u!=null?u.b:"");if(l&&k!=l.get(0))l.val(u!=null?u.a:"");if(k!=B.get(0))B.val(u!=null?u.h:"");if(k!=C.get(0))C.val(u!=null?u.s:"");if(k!=G.get(0))G.val(u!=null?u.v:"");if(k!=A.get(0)&&(c&&k!=c.get(0)||!c))A.val(u!=null?u.hex:"");if(c&&k!=c.get(0)&&k!=A.get(0))c.val(u!=null?u.hex:"");if(x&&k!=x.get(0))x.val(u!=null?u.ahex.substring(6):"")};a.extend(true,j,{destroy:function(){s.add(o).add(w).add(l).add(B).add(C).add(G).add(A).add(c).add(x).unbind("keyup",
t).unbind("blur",p);f.unbind(z);x=A=G=C=B=l=w=o=s=null}});s.add(o).add(w).add(l).add(B).add(C).add(G).add(A).add(c).add(x).bind("keyup",t).bind("blur",p);f.bind(z)};a.jPicker={List:[],Color:function(e){var f=this,c,j,s,o,w,l,B,C=[],G=function(x){for(var t=0;t<C.length;t++)C[t].call(f,f,x)},A=function(x,t,p){if(t===undefined){if(x===undefined||x==null||x=="")x="all";switch(x.toLowerCase()){case "ahex":return c!=null?g.rgbaToHex({r:c,g:j,b:s,a:o}):null;case "hex":return(t=A("ahex"))&&t.substring(0,
6)||null;case "all":return c!=null?{r:c,g:j,b:s,a:o,h:w,s:l,v:B,hex:A.call(f,"hex"),ahex:A.call(f,"ahex")}:null;default:t={};for(var D=0;D<x.length;D++)switch(x.charAt(D)){case "r":if(x.length==1)t=c;else t.r=c;break;case "g":if(x.length==1)t=j;else t.g=j;break;case "b":if(x.length==1)t=s;else t.b=s;break;case "a":if(x.length==1)t=o;else t.a=o;break;case "h":if(x.length==1)t=w;else t.h=w;break;case "s":if(x.length==1)t=l;else t.s=l;break;case "v":if(x.length==1)t=B;else t.v=B;break}return t=={}?A.call(f,
"all"):t}}if(!(p!=null&&p==f)){var E=false;if(x==null)x="";if(t==null){if(c!=null){c=null;E=true}if(j!=null){j=null;E=true}if(s!=null){s=null;E=true}if(o!=null){o=null;E=true}if(w!=null){w=null;E=true}if(l!=null){l=null;E=true}if(B!=null){B=null;E=true}E&&G.call(f,p||f)}else switch(x.toLowerCase()){case "ahex":case "hex":t=g.hexToRgba(t&&(t.ahex||t.hex)||t||"00000000");A.call(f,"rgba",{r:t.r,g:t.g,b:t.b,a:x=="ahex"?t.a:o!=null?o:100},p);break;default:if(t&&(t.ahex!=null||t.hex!=null)){A.call(f,"ahex",
t.ahex||t.hex||"00000000",p);return}var z={},u=false,k=false;if(t.r!==undefined&&!x.indexOf("r")==-1)x+="r";if(t.g!==undefined&&!x.indexOf("g")==-1)x+="g";if(t.b!==undefined&&!x.indexOf("b")==-1)x+="b";if(t.a!==undefined&&!x.indexOf("a")==-1)x+="a";if(t.h!==undefined&&!x.indexOf("h")==-1)x+="h";if(t.s!==undefined&&!x.indexOf("s")==-1)x+="s";if(t.v!==undefined&&!x.indexOf("v")==-1)x+="v";for(D=0;D<x.length;D++)switch(x.charAt(D)){case "r":if(k)continue;u=true;z.r=t&&t.r&&t.r|0||t&&t|0||0;if(z.r<0)z.r=
0;else if(z.r>255)z.r=255;if(c!=z.r){c=z.r;E=true}break;case "g":if(k)continue;u=true;z.g=t&&t.g&&t.g|0||t&&t|0||0;if(z.g<0)z.g=0;else if(z.g>255)z.g=255;if(j!=z.g){j=z.g;E=true}break;case "b":if(k)continue;u=true;z.b=t&&t.b&&t.b|0||t&&t|0||0;if(z.b<0)z.b=0;else if(z.b>255)z.b=255;if(s!=z.b){s=z.b;E=true}break;case "a":z.a=t&&t.a!=null?t.a|0:t!=null?t|0:100;if(z.a<0)z.a=0;else if(z.a>100)z.a=100;if(o!=z.a){o=z.a;E=true}break;case "h":if(u)continue;k=true;z.h=t&&t.h&&t.h|0||t&&t|0||0;if(z.h<0)z.h=
0;else if(z.h>360)z.h=360;if(w!=z.h){w=z.h;E=true}break;case "s":if(u)continue;k=true;z.s=t&&t.s!=null?t.s|0:t!=null?t|0:100;if(z.s<0)z.s=0;else if(z.s>100)z.s=100;if(l!=z.s){l=z.s;E=true}break;case "v":if(u)continue;k=true;z.v=t&&t.v!=null?t.v|0:t!=null?t|0:100;if(z.v<0)z.v=0;else if(z.v>100)z.v=100;if(B!=z.v){B=z.v;E=true}break}if(E){if(u){c=c||0;j=j||0;s=s||0;t=g.rgbToHsv({r:c,g:j,b:s});w=t.h;l=t.s;B=t.v}else if(k){w=w||0;l=l!=null?l:100;B=B!=null?B:100;t=g.hsvToRgb({h:w,s:l,v:B});c=t.r;j=t.g;
s=t.b}o=o!=null?o:100;G.call(f,p||f)}break}}};a.extend(true,f,{val:A,bind:function(x){a.isFunction(x)&&C.push(x)},unbind:function(x){if(a.isFunction(x))for(var t;(t=a.inArray(x,C))!=-1;)C.splice(t,1)},destroy:function(){C=null}});if(e)if(e.hex!=null)A("hex",e);else if(e.ahex!=null)A("ahex",e);else if(e.r!=null&&e.g!=null&&e.b!=null)A("rgb",e);else e.h!=null&&e.s!=null&&e.v!=null&&A("hsv",e)},ColorMethods:{hexToRgba:function(e){e=this.validateHex(e);if(e=="")return{r:null,g:null,b:null,a:null};var f=
"00",c="00",j="00",s="100";if(e.length==6)e+="ff";if(e.length>6){f=e.substring(0,2);c=e.substring(2,4);j=e.substring(4,6);s=e.substring(6,e.length)}else{if(e.length>4){f=e.substring(4,e.length);e=e.substring(0,4)}if(e.length>2){c=e.substring(2,e.length);e=e.substring(0,2)}if(e.length>0)j=e.substring(0,e.length)}return{r:this.hexToInt(f),g:this.hexToInt(c),b:this.hexToInt(j),a:this.hexToInt(s)*100/255|0}},validateHex:function(e){e=e.toLowerCase().replace(/[^a-f0-9]/g,"");if(e.length>8)e=e.substring(0,
8);return e},rgbaToHex:function(e){return this.intToHex(e.r)+this.intToHex(e.g)+this.intToHex(e.b)+this.intToHex(e.a*255/100|0)},intToHex:function(e){e=(e|0).toString(16);if(e.length==1)e="0"+e;return e.toLowerCase()},hexToInt:function(e){return parseInt(e,16)},rgbToHsv:function(e){var f=e.r/255,c=e.g/255;e=e.b/255;var j={h:0,s:0,v:0},s=0,o=0;if(f>=c&&f>=e){o=f;s=c>e?e:c}else if(c>=e&&c>=f){o=c;s=f>e?e:f}else{o=e;s=c>f?f:c}j.v=o;j.s=o?(o-s)/o:0;if(j.s){s=o-s;j.h=f==o?(c-e)/s:c==o?2+(e-f)/s:4+(f-c)/
s;j.h=parseInt(j.h*60);if(j.h<0)j.h+=360}else j.h=0;j.s=j.s*100|0;j.v=j.v*100|0;return j},hsvToRgb:function(e){var f={r:0,g:0,b:0,a:100},c=e.h,j=e.s;e=e.v;if(j==0)f.r=e==0?(f.g=f.b=0):(f.g=f.b=e*255/100|0);else{if(c==360)c=0;c/=60;j/=100;e/=100;var s=c|0,o=c-s;c=e*(1-j);var w=e*(1-j*o);j=e*(1-j*(1-o));switch(s){case 0:f.r=e;f.g=j;f.b=c;break;case 1:f.r=w;f.g=e;f.b=c;break;case 2:f.r=c;f.g=e;f.b=j;break;case 3:f.r=c;f.g=w;f.b=e;break;case 4:f.r=j;f.g=c;f.b=e;break;case 5:f.r=e;f.g=c;f.b=w;break}f.r=
f.r*255|0;f.g=f.g*255|0;f.b=f.b*255|0}return f}}};var d=a.jPicker.Color,b=a.jPicker.List,g=a.jPicker.ColorMethods;a.fn.jPicker=function(e){var f=arguments;return this.each(function(){var c=this,j=a.extend(true,{},a.fn.jPicker.defaults,e);if(a(c).get(0).nodeName.toLowerCase()=="input"){a.extend(true,j,{window:{bindToInput:true,expandable:true,input:a(c)}});if(g.validateHex(a(c).val())){j.color.active=new d({hex:a(c).val(),a:j.color.active.val("a")});j.color.current=new d({hex:a(c).val(),a:j.color.active.val("a")})}}if(j.window.expandable)a(c).after('<span class="jPicker"><span class="Icon"><span class="Color">&nbsp;</span><span class="Alpha">&nbsp;</span><span class="Image" title="Click To Open Color Picker">&nbsp;</span><span class="Container">&nbsp;</span></span></span>');
else j.window.liveUpdate=false;var s=parseFloat(navigator.appVersion.split("MSIE")[1])<7&&document.body.filters,o=null,w=null,l=null,B=null,C=null,G=null,A=null,x=null,t=null,p=null,D=null,E=null,z=null,u=null,k=null,H=null,Q=null,q=null,y=null,I=null,J=null,N=null,P=null,V=null,ea=null,W=null,fa=null,ga=null,ia=function(r){var v=K.active,F=v.val("hex"),R,T;j.color.mode=r;switch(r){case "h":setTimeout(function(){S.call(c,w,"transparent");O.call(c,B,0);L.call(c,B,100);O.call(c,C,260);L.call(c,C,100);
S.call(c,l,"transparent");O.call(c,A,0);L.call(c,A,100);O.call(c,x,260);L.call(c,x,100);O.call(c,t,260);L.call(c,t,100);O.call(c,p,260);L.call(c,p,100);O.call(c,E,260);L.call(c,E,100)},0);z.range("all",{minX:0,maxX:100,minY:0,maxY:100});u.range("rangeY",{minY:0,maxY:360});if(v.val("ahex")==null)break;z.val("xy",{x:v.val("s"),y:100-v.val("v")},z);u.val("y",360-v.val("h"),u);break;case "s":setTimeout(function(){S.call(c,w,"transparent");O.call(c,B,-260);O.call(c,C,-520);O.call(c,A,-260);O.call(c,x,
-520);O.call(c,E,260);L.call(c,E,100)},0);z.range("all",{minX:0,maxX:360,minY:0,maxY:100});u.range("rangeY",{minY:0,maxY:100});if(v.val("ahex")==null)break;z.val("xy",{x:v.val("h"),y:100-v.val("v")},z);u.val("y",100-v.val("s"),u);break;case "v":setTimeout(function(){S.call(c,w,"000000");O.call(c,B,-780);O.call(c,C,260);S.call(c,l,F);O.call(c,A,-520);O.call(c,x,260);L.call(c,x,100);O.call(c,E,260);L.call(c,E,100)},0);z.range("all",{minX:0,maxX:360,minY:0,maxY:100});u.range("rangeY",{minY:0,maxY:100});
if(v.val("ahex")==null)break;z.val("xy",{x:v.val("h"),y:100-v.val("s")},z);u.val("y",100-v.val("v"),u);break;case "r":R=-1040;T=-780;z.range("all",{minX:0,maxX:255,minY:0,maxY:255});u.range("rangeY",{minY:0,maxY:255});if(v.val("ahex")==null)break;z.val("xy",{x:v.val("b"),y:255-v.val("g")},z);u.val("y",255-v.val("r"),u);break;case "g":R=-1560;T=-1820;z.range("all",{minX:0,maxX:255,minY:0,maxY:255});u.range("rangeY",{minY:0,maxY:255});if(v.val("ahex")==null)break;z.val("xy",{x:v.val("b"),y:255-v.val("r")},
z);u.val("y",255-v.val("g"),u);break;case "b":R=-2080;T=-2860;z.range("all",{minX:0,maxX:255,minY:0,maxY:255});u.range("rangeY",{minY:0,maxY:255});if(v.val("ahex")==null)break;z.val("xy",{x:v.val("r"),y:255-v.val("g")},z);u.val("y",255-v.val("b"),u);break;case "a":setTimeout(function(){S.call(c,w,"transparent");O.call(c,B,-260);O.call(c,C,-520);O.call(c,A,260);O.call(c,x,260);L.call(c,x,100);O.call(c,E,0);L.call(c,E,100)},0);z.range("all",{minX:0,maxX:360,minY:0,maxY:100});u.range("rangeY",{minY:0,
maxY:100});if(v.val("ahex")==null)break;z.val("xy",{x:v.val("h"),y:100-v.val("v")},z);u.val("y",100-v.val("a"),u);break;default:throw"Invalid Mode";}switch(r){case "h":break;case "s":case "v":case "a":setTimeout(function(){L.call(c,B,100);L.call(c,A,100);O.call(c,t,260);L.call(c,t,100);O.call(c,p,260);L.call(c,p,100)},0);break;case "r":case "g":case "b":setTimeout(function(){S.call(c,w,"transparent");S.call(c,l,"transparent");L.call(c,A,100);L.call(c,B,100);O.call(c,B,R);O.call(c,C,R-260);O.call(c,
A,T-780);O.call(c,x,T-520);O.call(c,t,T);O.call(c,p,T-260);O.call(c,E,260);L.call(c,E,100)},0);break}v.val("ahex")!=null&&ha.call(c,v)},ha=function(r,v){if(v==null||v!=u&&v!=z)ua.call(c,r,v);setTimeout(function(){va.call(c,r);wa.call(c,r);xa.call(c,r)},0)},ya=function(r,v){var F=K.active;if(!(v!=z&&F.val()==null)){r=r.val("all");switch(j.color.mode){case "h":F.val("sv",{s:r.x,v:100-r.y},v);break;case "s":case "a":F.val("hv",{h:r.x,v:100-r.y},v);break;case "v":F.val("hs",{h:r.x,s:100-r.y},v);break;
case "r":F.val("gb",{g:255-r.y,b:r.x},v);break;case "g":F.val("rb",{r:255-r.y,b:r.x},v);break;case "b":F.val("rg",{r:r.x,g:255-r.y},v);break}}},za=function(r,v){var F=K.active;if(!(v!=u&&F.val()==null))switch(j.color.mode){case "h":F.val("h",{h:360-r.val("y")},v);break;case "s":F.val("s",{s:100-r.val("y")},v);break;case "v":F.val("v",{v:100-r.val("y")},v);break;case "r":F.val("r",{r:255-r.val("y")},v);break;case "g":F.val("g",{g:255-r.val("y")},v);break;case "b":F.val("b",{b:255-r.val("y")},v);break;
case "a":F.val("a",100-r.val("y"),v);break}},ua=function(r,v){if(v!=z)switch(j.color.mode){case "h":var F=r.val("sv");z.val("xy",{x:F!=null?F.s:100,y:100-(F!=null?F.v:100)},v);break;case "s":case "a":F=r.val("hv");z.val("xy",{x:F&&F.h||0,y:100-(F!=null?F.v:100)},v);break;case "v":F=r.val("hs");z.val("xy",{x:F&&F.h||0,y:100-(F!=null?F.s:100)},v);break;case "r":F=r.val("bg");z.val("xy",{x:F&&F.b||0,y:255-(F&&F.g||0)},v);break;case "g":F=r.val("br");z.val("xy",{x:F&&F.b||0,y:255-(F&&F.r||0)},v);break;
case "b":F=r.val("rg");z.val("xy",{x:F&&F.r||0,y:255-(F&&F.g||0)},v);break}if(v!=u)switch(j.color.mode){case "h":u.val("y",360-(r.val("h")||0),v);break;case "s":r=r.val("s");u.val("y",100-(r!=null?r:100),v);break;case "v":r=r.val("v");u.val("y",100-(r!=null?r:100),v);break;case "r":u.val("y",255-(r.val("r")||0),v);break;case "g":u.val("y",255-(r.val("g")||0),v);break;case "b":u.val("y",255-(r.val("b")||0),v);break;case "a":r=r.val("a");u.val("y",100-(r!=null?r:100),v);break}},va=function(r){try{var v=
r.val("all");I.css({backgroundColor:v&&"#"+v.hex||"transparent"});L.call(c,I,v&&v.a||0)}catch(F){}},wa=function(r){switch(j.color.mode){case "h":S.call(c,w,(new d({h:r.val("h")||0,s:100,v:100})).val("hex"));break;case "s":case "a":var v=r.val("s");L.call(c,C,100-(v!=null?v:100));break;case "v":v=r.val("v");L.call(c,B,v!=null?v:100);break;case "r":L.call(c,C,(r.val("r")||0)/255*100);break;case "g":L.call(c,C,(r.val("g")||0)/255*100);break;case "b":L.call(c,C,(r.val("b")||0)/255*100);break}r=r.val("a");
L.call(c,G,100-(r||0))},xa=function(r){switch(j.color.mode){case "h":var v=r.val("a");L.call(c,D,100-(v||0));break;case "s":v=r.val("hva");var F=new d({h:v&&v.h||0,s:100,v:v!=null?v.v:100});S.call(c,l,F.val("hex"));L.call(c,x,100-(v!=null?v.v:100));L.call(c,D,100-(v&&v.a||0));break;case "v":v=r.val("hsa");F=new d({h:v&&v.h||0,s:v!=null?v.s:100,v:100});S.call(c,l,F.val("hex"));L.call(c,D,100-(v&&v.a||0));break;case "r":case "g":case "b":F=v=0;r=r.val("rgba");if(j.color.mode=="r"){v=r&&r.b||0;F=r&&
r.g||0}else if(j.color.mode=="g"){v=r&&r.b||0;F=r&&r.r||0}else if(j.color.mode=="b"){v=r&&r.r||0;F=r&&r.g||0}var R=F>v?v:F;L.call(c,x,v>F?(v-F)/(255-F)*100:0);L.call(c,t,F>v?(F-v)/(255-v)*100:0);L.call(c,p,R/255*100);L.call(c,D,100-(r&&r.a||0));break;case "a":v=r.val("a");S.call(c,l,r.val("hex")||"000000");L.call(c,D,v!=null?0:100);L.call(c,E,v!=null?100:0);break}},S=function(r,v){r.css({backgroundColor:v&&v.length==6&&"#"+v||"transparent"})},U=function(r,v){if(s&&(v.indexOf("AlphaBar.png")!=-1||
v.indexOf("Bars.png")!=-1||v.indexOf("Maps.png")!=-1)){r.attr("pngSrc",v);r.css({backgroundImage:"none",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+v+"', sizingMethod='scale')"})}else r.css({backgroundImage:"url("+v+")"})},O=function(r,v){r.css({top:v+"px"})},L=function(r,v){r.css({visibility:v>0?"visible":"hidden"});if(v>0&&v<100)if(s){var F=r.attr("pngSrc");F!=null&&(F.indexOf("AlphaBar.png")!=-1||F.indexOf("Bars.png")!=-1||F.indexOf("Maps.png")!=-1)?r.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+
F+"', sizingMethod='scale') progid:DXImageTransform.Microsoft.Alpha(opacity="+v+")"}):r.css({opacity:v/100})}else r.css({opacity:v/100});else if(v==0||v==100)if(s){F=r.attr("pngSrc");F!=null&&(F.indexOf("AlphaBar.png")!=-1||F.indexOf("Bars.png")!=-1||F.indexOf("Maps.png")!=-1)?r.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+F+"', sizingMethod='scale')"}):r.css({opacity:""})}else r.css({opacity:""})},ja=function(){K.active.val("ahex",K.current.val("ahex"))},Aa=function(){K.current.val("ahex",
K.active.val("ahex"))},ka=function(r){ia.call(c,r.target.value)},la=function(){ja.call(c)},ma=function(){ja.call(c);j.window.expandable&&ba.call(c);a.isFunction(X)&&X.call(c,K.active,P)},na=function(){Aa.call(c);j.window.expandable&&ba.call(c);a.isFunction(Y)&&Y.call(c,K.active,N)},oa=function(){ca.call(c);return false},Ba=function(r){var v=r.val("hex");J.css({backgroundColor:v&&"#"+v||"transparent"});L.call(c,J,r.val("a")||0)},Ca=function(r){var v=r.val("hex");r=r.val("va");if(M.doColorIcon)ea.css({backgroundColor:v&&
"#"+v||"transparent"});L.call(c,W,100-(r&&r.a||0));if(j.window.bindToInput)j.window.input.css({backgroundColor:v&&"#"+v||"transparent",color:r&&r.v>75?"#000000":"#ffffff"})},ra=function(r){H=parseInt(o.css("left"));Q=parseInt(o.css("top"));q=r.pageX;y=r.pageY;a(document).bind("mousemove",pa).bind("mouseup",qa);r.stopPropagation();r.preventDefault();return false},pa=function(r){o.css({left:H-(q-r.pageX)+"px",top:Q-(y-r.pageY)+"px"});r.stopPropagation();r.preventDefault();return false},qa=function(r){a(document).unbind("mousemove",
pa).unbind("mouseup",qa);r.stopPropagation();r.preventDefault();return false},sa=function(r){r.preventDefault();r.stopPropagation();K.active.val("ahex",a(this).attr("title")||null,r.target);return false},Y=a.isFunction(f[1])&&f[1]||null,Z=a.isFunction(f[2])&&f[2]||null,X=a.isFunction(f[3])&&f[3]||null,aa=a.isFunction(f[4])&&f[4]||null,ca=function(){a.isFunction(aa)&&aa.call(c);if(document.all){var r=false;for(i=0;i<b.length;i++){r&&b[i].icon.css({display:"none"});if(b[i]==c)r=true}}K.current.val("ahex",
K.active.val("ahex"));switch(j.window.effects.type){case "fade":o.fadeIn(j.window.effects.speed.show);break;case "slide":o.slideDown(j.window.effects.speed.show);break;case "show":default:o.show(j.window.effects.speed.show);break}},ba=function(){if(document.all){var r=false;for(i=0;i<b.length;i++){r&&b[i].icon.css({display:"inline-block"});if(b[i]==c)r=true}}switch(j.window.effects.type){case "fade":o.fadeOut(j.window.effects.speed.hide);break;case "slide":o.slideUp(j.window.effects.speed.hide);break;
case "show":default:o.hide(j.window.effects.speed.hide);break}},Da=function(){var r=j.window;o=r.expandable?a(c).next().find(".Container:first"):a(c);if(r.expandable)o.css({left:r.position.x=="left"?-520-(r.position.y=="center"?25:0)+"px":r.position.x=="center"?"-249px":r.position.x=="right"?0+(r.position.y=="center"?25:0)+"px":r.position.x=="screenCenter"?(a(document).width()>>1)-249-a(c).next().offset().left+"px":r.position.x,position:"absolute",top:r.position.y=="top"?"-312px":r.position.y=="center"?
"-156px":r.position.y=="bottom"?"25px":r.position.y=="screenCenter"?(a(document).height()>>1)-312-a(c).next().offset().top+"px":r.position.y});if((typeof K.active).toString().toLowerCase()=="string")K.active=new d({ahex:K.active});o.html('<table class="jPicker" cellpadding="0" cellspacing="0"><tbody>'+(r.expandable?'<tr><td class="Move" colspan="6">&nbsp;</td></tr>':"")+'<tr><td rowspan="9"><h2 class="Title">'+(r.title||h.msg.dragmarkers)+'</h2><div class="Map"><span class="Map1">&nbsp;</span><span class="Map2">&nbsp;</span><span class="Map3">&nbsp;</span><img src="'+
M.clientPath+M.colorMap.arrow.file+'" class="Arrow"/></div></td><td rowspan="9"><div class="Bar"><span class="Map1">&nbsp;</span><span class="Map2">&nbsp;</span><span class="Map3">&nbsp;</span><span class="Map4">&nbsp;</span><span class="Map5">&nbsp;</span><span class="Map6">&nbsp;</span><img src="'+M.clientPath+M.colorBar.arrow.file+'" class="Arrow"/></div></td><td colspan="3" class="Preview">'+h.msg["new"]+'<div><span class="Active" title="">&nbsp;</span><span class="Current" title="">&nbsp;</span></div>'+
h.msg.current+'</td><td rowspan="9" class="Button"><input type="button" class="Ok" value="'+h.msg.ok+'" title="'+h.msg.ok+'"/><input type="button" class="Cancel" value="'+h.msg.cancel+'" title="'+h.msg.cancel+'"/><hr/><div class="Grid">&nbsp;</div></td></tr><tr class="Hue"><td class="Radio"><input type="radio" id="jPicker_Hue_'+b.length+'" name="jPicker_Mode_'+b.length+'" value="h" title=""'+(j.color.mode=="h"?' checked="checked"':"")+'/></td><td class="Label"><label for="jPicker_Hue_'+b.length+'" title="">H:</label></td><td class="Text"><input type="text" maxlength="3" value="'+
K.active.val("h")+'" title=""/>&nbsp;&deg;</td></tr><tr class="Saturation"><td class="Radio"><input type="radio" id="jPicker_Saturation_'+b.length+'" name="jPicker_Mode_'+b.length+'" value="s" title=""'+(j.color.mode=="s"?' checked="checked"':"")+'/></td><td class="Label"><label for="jPicker_Saturation_'+b.length+'" title="">S:</label></td><td class="Text"><input type="text" maxlength="3" value="'+K.active.val("s")+'" title=""/>&nbsp;%</td></tr><tr class="Value"><td class="Radio"><input type="radio" id="jPicker_Value_'+
b.length+'" name="jPicker_Mode_'+b.length+'" value="v" title=""'+(j.color.mode=="v"?' checked="checked"':"")+'/><br/><br/></td><td class="Label"><label for="jPicker_Value_'+b.length+'" title="">V:</label><br/><br/></td><td class="Text"><input type="text" maxlength="3" value="'+K.active.val("v")+'" title=""/>&nbsp;%<br/><br/></td></tr><tr class="Red"><td class="Radio"><input type="radio" id="jPicker_Red_'+b.length+'" name="jPicker_Mode_'+b.length+'" value="r" title=""'+(j.color.mode=="r"?' checked="checked"':
"")+'/></td><td class="Label"><label for="jPicker_Red_'+b.length+'" title="">R:</label></td><td class="Text"><input type="text" maxlength="3" value="'+K.active.val("r")+'" title=""/></td></tr><tr class="Green"><td class="Radio"><input type="radio" id="jPicker_Green_'+b.length+'" name="jPicker_Mode_'+b.length+'" value="g" title=""'+(j.color.mode=="g"?' checked="checked"':"")+'/></td><td class="Label"><label for="jPicker_Green_'+b.length+'" title="">G:</label></td><td class="Text"><input type="text" maxlength="3" value="'+
K.active.val("g")+'" title=""/></td></tr><tr class="Blue"><td class="Radio"><input type="radio" id="jPicker_Blue_'+b.length+'" name="jPicker_Mode_'+b.length+'" value="b" title=""'+(j.color.mode=="b"?' checked="checked"':"")+'/></td><td class="Label"><label for="jPicker_Blue_'+b.length+'" title="">B:</label></td><td class="Text"><input type="text" maxlength="3" value="'+K.active.val("b")+'" title=""/></td></tr><tr class="Alpha"><td class="Radio">'+(r.alphaSupport?'<input type="radio" id="jPicker_Alpha_'+
b.length+'" name="jPicker_Mode_'+b.length+'" value="a" title=""'+(j.color.mode=="a"?' checked="checked"':"")+"/>":"&nbsp;")+'</td><td class="Label">'+(r.alphaSupport?'<label for="jPicker_Alpha_'+b.length+'" title="">A:</label>':"&nbsp;")+'</td><td class="Text">'+(r.alphaSupport?'<input type="text" maxlength="3" value="'+K.active.val("a")+'" title=""/>&nbsp;%':"&nbsp;")+'</td></tr><tr class="Hex"><td colspan="3" class="Text"><label for="jPicker_Hex_'+b.length+'" title="">#:</label><input type="text" maxlength="6" class="Hex" id="jPicker_Hex_'+
b.length+'" value="'+K.active.val("hex")+'" title=""/>'+(r.alphaSupport?'<input type="text" maxlength="2" class="AHex" value="'+K.active.val("ahex").substring(6)+'" title=""/></td>':"&nbsp;")+"</tr></tbody></table>");var v=o.find("tbody:first");w=v.find("div.Map:first");l=v.find("div.Bar:first");var F=w.find("span"),R=l.find("span");B=F.filter(".Map1:first");C=F.filter(".Map2:first");G=F.filter(".Map3:first");A=R.filter(".Map1:first");x=R.filter(".Map2:first");t=R.filter(".Map3:first");p=R.filter(".Map4:first");
D=R.filter(".Map5:first");E=R.filter(".Map6:first");z=new m(w,{map:{width:M.colorMap.width,height:M.colorMap.height},arrow:{image:M.clientPath+M.colorMap.arrow.file,width:M.colorMap.arrow.width,height:M.colorMap.arrow.height}});z.bind(ya);u=new m(l,{map:{width:M.colorBar.width,height:M.colorBar.height},arrow:{image:M.clientPath+M.colorBar.arrow.file,width:M.colorBar.arrow.width,height:M.colorBar.arrow.height}});u.bind(za);k=new n(v,K.active,r.expandable&&r.bindToInput?r.input:null);F=K.active.val("hex");
var T=v.find(".Preview");R=v.find(".Button");I=T.find(".Active:first").css({backgroundColor:F&&"#"+F||"transparent"});J=T.find(".Current:first").css({backgroundColor:F&&"#"+F||"transparent"}).bind("click",la);N=R.find(".Ok:first").bind("click",na);P=R.find(".Cancel:first").bind("click",ma);V=R.find(".Grid:first");setTimeout(function(){U.call(c,B,M.clientPath+"Maps.png");U.call(c,C,M.clientPath+"Maps.png");U.call(c,G,M.clientPath+"map-opacity.png");U.call(c,A,M.clientPath+"Bars.png");U.call(c,x,M.clientPath+
"Bars.png");U.call(c,t,M.clientPath+"Bars.png");U.call(c,p,M.clientPath+"Bars.png");U.call(c,D,M.clientPath+"bar-opacity.png");U.call(c,E,M.clientPath+"AlphaBar.png");U.call(c,T.find("div:first"),M.clientPath+"preview-opacity.png")},0);v.find("td.Radio input").bind("click",ka);if(K.quickList&&K.quickList.length>0){R="";for(i=0;i<K.quickList.length;i++){if((typeof K.quickList[i]).toString().toLowerCase()=="string")K.quickList[i]=new d({hex:K.quickList[i]});var ta=K.quickList[i].val("ahex"),da=K.quickList[i].val("hex");
R+='<span class="QuickColor" title="'+(ta&&"#"+ta||"")+'" style="background-color: '+(da&&"#"+da||"transparent")+";"+(da?"":" background-image: url("+M.clientPath+"NoColor.png);")+'">&nbsp;</span>'}V.html(R);V.find(".QuickColor").click(sa)}ia.call(c,j.color.mode);K.active.bind(ha);a.isFunction(Z)&&K.active.bind(Z);K.current.bind(Ba);if(r.expandable){c.icon=o.parents(".Icon:first");if(M.doColorIcon)ea=c.icon.find(".Color:first").css({backgroundColor:F&&"#"+F||"transparent"});W=c.icon.find(".Alpha:first");
U.call(c,W,M.clientPath+"bar-opacity.png");L.call(c,W,100-K.active.val("a"));fa=c.icon.find(".Image:first").css({backgroundImage:"url("+M.clientPath+M.picker.file+")",width:M.picker.width,height:M.picker.height,padding:M.picker.padding,margin:M.picker.margin}).bind("click",oa);if(r.bindToInput)r.input.css({backgroundColor:F&&"#"+F||"transparent",color:K.active.val("v")>75?"#000000":"#ffffff"});ga=v.find(".Move:first").bind("mousedown",ra);K.active.bind(Ca)}else ca.call(c);b.push(c)},M=j.images,K=
{active:(typeof j.color.active).toString().toLowerCase()=="string"?new d({ahex:j.color.active}):new d({ahex:j.color.active.val("ahex")}),current:(typeof j.color.active).toString().toLowerCase()=="string"?new d({ahex:j.color.active}):new d({ahex:j.color.active.val("ahex")}),quickList:j.color.quickList};a.extend(true,c,{commitCallback:Y,liveCallback:Z,cancelCallback:X,showCallback:aa,color:K,show:ca,hide:ba,destroy:function(){o.find("td.Radio input").unbind("click",ka);J.unbind("click",la);P.unbind("click",
ma);N.unbind("click",na);if(j.window.expandable){fa.unbind("click",oa);ga.unbind("mousedown",ra);c.icon=null}o.find(".QuickColor").unbind("click",sa);E=D=p=t=x=A=G=C=B=l=w=null;z.destroy();z=null;u.destroy();u=null;k.destroy();aa=Z=X=Y=V=P=N=J=I=k=null;o.html("");for(i=0;i<b.length;i++)b[i]==c&&b.splice(i,1)}});setTimeout(function(){Da.call(c)},0)})};a.fn.jPicker.defaults={window:{title:null,effects:{type:"slide",speed:{show:"slow",hide:"fast"}},position:{x:"screenCenter",y:"top"},expandable:false,
liveUpdate:true,alphaSupport:false},color:{mode:"h",active:new d({ahex:"#ffcc00ff"}),quickList:[new d({h:360,s:33,v:100}),new d({h:360,s:66,v:100}),new d({h:360,s:100,v:100}),new d({h:360,s:100,v:75}),new d({h:360,s:100,v:50}),new d({h:180,s:0,v:100}),new d({h:30,s:33,v:100}),new d({h:30,s:66,v:100}),new d({h:30,s:100,v:100}),new d({h:30,s:100,v:75}),new d({h:30,s:100,v:50}),new d({h:180,s:0,v:90}),new d({h:60,s:33,v:100}),new d({h:60,s:66,v:100}),new d({h:60,s:100,v:100}),new d({h:60,s:100,v:75}),
new d({h:60,s:100,v:50}),new d({h:180,s:0,v:80}),new d({h:90,s:33,v:100}),new d({h:90,s:66,v:100}),new d({h:90,s:100,v:100}),new d({h:90,s:100,v:75}),new d({h:90,s:100,v:50}),new d({h:180,s:0,v:70}),new d({h:120,s:33,v:100}),new d({h:120,s:66,v:100}),new d({h:120,s:100,v:100}),new d({h:120,s:100,v:75}),new d({h:120,s:100,v:50}),new d({h:180,s:0,v:60}),new d({h:150,s:33,v:100}),new d({h:150,s:66,v:100}),new d({h:150,s:100,v:100}),new d({h:150,s:100,v:75}),new d({h:150,s:100,v:50}),new d({h:180,s:0,
v:50}),new d({h:180,s:33,v:100}),new d({h:180,s:66,v:100}),new d({h:180,s:100,v:100}),new d({h:180,s:100,v:75}),new d({h:180,s:100,v:50}),new d({h:180,s:0,v:40}),new d({h:210,s:33,v:100}),new d({h:210,s:66,v:100}),new d({h:210,s:100,v:100}),new d({h:210,s:100,v:75}),new d({h:210,s:100,v:50}),new d({h:180,s:0,v:30}),new d({h:240,s:33,v:100}),new d({h:240,s:66,v:100}),new d({h:240,s:100,v:100}),new d({h:240,s:100,v:75}),new d({h:240,s:100,v:50}),new d({h:180,s:0,v:20}),new d({h:270,s:33,v:100}),new d({h:270,
s:66,v:100}),new d({h:270,s:100,v:100}),new d({h:270,s:100,v:75}),new d({h:270,s:100,v:50}),new d({h:180,s:0,v:10}),new d({h:300,s:33,v:100}),new d({h:300,s:66,v:100}),new d({h:300,s:100,v:100}),new d({h:300,s:100,v:75}),new d({h:300,s:100,v:50}),new d({h:180,s:0,v:0}),new d({h:330,s:33,v:100}),new d({h:330,s:66,v:100}),new d({h:330,s:100,v:100}),new d({h:330,s:100,v:75}),new d({h:330,s:100,v:50}),new d]},images:{clientPath:"/jPicker/images/",colorMap:{width:256,height:256,arrow:{file:"mappoint.gif",
width:15,height:15}},colorBar:{width:20,height:256,arrow:{file:"rangearrows.gif",width:20,height:7}},picker:{file:"picker.gif",width:25,height:24,padding:0,margin:0},doColorIcon:true},localization:{}}})(jQuery,"1.1.2");
(function(a){function h(b){b.minWidth=parseInt(b.minWidth);b.fontSize=parseInt(b.fontSize);b.maxWidth=parseInt(b.maxWidth);var g=a(this).val().length*b.fontSize;if(g>b.minWidth&&g<b.maxWidth){b=a(this).width()+b.fontSize/2;a(this).width(b)}}function m(){var b=this.data("tags"),g=b[b.length-1];this.find(".tagged-tagsbox").children().last().width();Array.remove(b,b.length-1);this.find(".tagged-textbox").val(g);this.find(".tagged-tagsbox").children().last().remove()}function n(b){var g=a("<span></span>").attr("class",
"tagged-tagbody");b=a("<span></span>").attr("class","tagged-tagbody-tag").text(b);g.append(b);return g}Array.remove=function(b,g,e){e=b.slice((e||g)+1||b.length);b.length=g<0?b.length+g:g;return b.push.apply(b,e)};var d={init:function(b){var g=this;this.settings=a.extend({width:"400px",height:"80px",tags:[],mode:"r"},b);this.settings.width=parseInt(this.settings.width);this.textboxSettings={minWidth:"60px",fontSize:"14px",maxWidth:g.settings.width};g.empty().css({"max-height":this.settings.height,
width:this.settings.width+15,border:"1px solid transparent"});this.data("tags",[]);this.data("settings",this.settings);var e=a("<input>").attr("class","tagged-textbox").css("width",this.textboxSettings.minWidth).bind("keydown blur",function(c){if(c.which==32||c.which==188||c.which==13||c.which==186||c.type=="blur"){c.preventDefault();if(a(this).val()=="")return;var j=a(this).val().trim();g.data("tags").push(j);j=n.call(g,j,g.settings.mode);g.find(".tagged-tagsbox").append(j);a(this).width(g.textboxSettings.minWidth).val("")}if(c.which==
8){if(a(this).val()=="")if(!f.is(":empty")){c.preventDefault();m.call(g)}}else h.call(this,g.textboxSettings)}).bind("blur",function(){g.settings.focusOut&&g.settings.focusOut.call(g)}),f=a("<span></span>").attr("class","tagged-tagsbox");this.unbind("hover click").hover(function(){g.settings.mode=="r"&&!_.isEmpty(g.settings.tags)&&a(this).css({"background-color":"#fafafa",cursor:"text"})},function(){a(this).css("background-color","#fff")}).click(function(c){c.stopPropagation();a(this).css("background-color",
"#fff");a(this).tagged({mode:"rw",width:g.settings.width,height:"60px",focusOut:g.settings.focusOut,tags:g.settings.tags})}).append(f);_.isEmpty(this.settings.tags)?this.append(a("<div></div>").attr("class","tagged-addtags").text("Add Tags").unbind("click").click(function(c){a(this).remove();c.stopPropagation();g.settings.mode="rw";g.append(a("<span></span>").append(e)).css("border","1px solid #aaa").find(".tagged-textbox").focus()})):d.addTags.call(this,this.settings.tags,this.settings.mode);if(this.settings.mode==
"rw"){this.append(a("<span></span>").append(e));this.find(".tagged-textbox").focus();this.css("border","1px solid #aaa")}},getTags:function(){return this.data("tags")},getSettings:function(){return this.data("settings")},addTags:function(b,g){var e=this;b instanceof Array&&b.forEach(function(f){e.data("tags").push(f);f=n.call(e,f,g);e.find(".tagged-tagsbox").append(f)})}};a.fn.tagged=function(b){if(d[b]){var g=Array.prototype.slice.call(arguments,1);return d[b].apply(this,g)}else if(typeof b==="object"||
!b)return d.init.call(this,b);else a.error("Method "+b+" does not exist on jQuery.tagged")}})(jQuery);
(function(a){function h(){this.tinui=a("<div></div>").attr("class","tinui").css({position:"absolute",width:"400px",height:"180px"});this.content=a("<div></div>").attr("id","content").css({width:"400px",height:"130px"});this.buttonpanel=a("<div></div>").attr("id","buttonpanel").css({width:"400px",height:"50px"});this.tinui.append(this.content);this.tinui.append(this.buttonpanel)}var m=a.app;h.prototype={set:function(d,b,g){this.content.append(a("<div></div>").attr("id","msg").html(d));g&&this.buttonpanel.append(a("<div></div>").attr("class",
"button").attr("id","no").text(g));b&&this.buttonpanel.append(a("<div></div>").attr("class","button").attr("id","yes").text(b))},n24a:function(d,b,g,e,f){function c(){n.hide();e&&e()}function j(){n.hide();f&&f()}this.reset();this.set(d,b,g);a("#no",this.buttonpanel).click(function(){j()});a("#yes",this.buttonpanel).click(function(){c()});m.KBD.pushHandler({element:"#dialog",handlers:[{key:"esc",func:function(){j()}},{key:"return",func:function(){c()}}]})},n253:function(d,b,g,e,f,c,j,s){function o(){var B=
a("#invalue",l.content).val(),C;if(s)C=a(s,l.content).attr("id");n.hide();e&&e(B,C)}function w(){n.hide();f&&f()}var l=this;this.reset();this.set(d,b,g);this.content.append(a("<input></input>").attr("id","invalue"));c&&a("#invalue",this.content).val(c);a("#yes",this.buttonpanel).click(function(){o()});a("#no",this.buttonpanel).click(function(){w()});j&&this.content.append(a("<div></div>").attr("id","extra").html(j));m.KBD.pushHandler({element:"#dialog",handlers:[{key:"esc",func:function(){w()}},{key:"return",
func:function(){o()}}]})},show:function(){a("body").append(this.tinui);var d=this.tinui.width(),b=this.tinui.height();b=Math.floor(b/2);d=Math.floor(d/2);this.tinui.css({top:"50%",left:"50%",marginTop:"-"+b+"px",marginLeft:"-"+d+"px"});this.tinui.show()},hide:function(){this.tinui.hide();this.tinui.remove();this.reset();m.KBD.popHandler()},submit:function(){a("#yes",this.buttonpanel).click()},reset:function(){this.content.empty();this.buttonpanel.empty()}};var n=new h;h.n1be=function(d,b,g,e,f,c,
j,s){n.n253(d,b,g,e,f,c,j,s);n.show();a("#invalue",n.content).focus()};h.n1f6=function(d,b,g,e,f){n.n24a(d,b,g,e,f);n.show()};h.n206=h.n1da=function(){n.hide()};h.enterPrompt=function(d){n.tinui.find("#invalue").val(d)};h.submit=function(){n.submit()};m.Dialog=h})(jQuery);
(function(a){function h(){this.saveui=a("<div></div>").attr("class","saveui").css({position:"absolute",width:"400px",height:"220px"});this.content=a("<div></div>").attr("id","content").css({width:"400px",height:"170px"});this.buttonpanel=a("<div></div>").attr("id","buttonpanel").css({width:"400px",height:"50px"});this.saveui.append(this.content);this.saveui.append(this.buttonpanel)}var m=a.app;h.prototype={set:function(d,b,g){this.content.append(a("<div></div>").attr("id","msg").html(d));g&&this.buttonpanel.append(a("<div></div>").attr("class",
"button").attr("id","no").text(g));b&&this.buttonpanel.append(a("<div></div>").attr("class","button").attr("id","yes").text(b))},reset:function(){this.content.empty();this.buttonpanel.empty()},setSave:function(d,b,g,e,f,c,j){function s(){var B=a("#invalue",l.content).val(),C=a("input[name=license]:checked",l.content).attr("id"),G=a("#tag-ed-dialog").tagged("getTags");n.hide();e(B,C,G)}function o(){n.hide()}function w(){a("#tag-ed-dialog").tagged({mode:"r",width:"270px",height:"30px",focusOut:this.settings.focusOut,
tags:this.data("tags")})}var l=this;this.reset();this.set(d,b,g);a("#yes",this.buttonpanel).click(function(){s()});a("#no",this.buttonpanel).click(function(){o()});d=a("<input>").attr("id","invalue");f&&d.val(f);f=a("<input>").attr("type","radio").attr("name","license").attr("id","cc");b=a("<input>").attr("type","radio").attr("name","license").attr("id","private");c?b.prop("checked",true):f.prop("checked",true);m.identity.premium_?b.prop("disabled",false):b.prop("disabled",true);c=a("<div></div>").css("margin-top",
"7px").append(m.msg.license).append(f).append('<a target="_blank" rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="/_images/cc-by-sa.png" /></a>').append(b).append('<span>Private</span>&nbsp;<a href="#" id="private_premium">Premium only</a>');f=a("<div></div>").attr("class","tag_container");b=a("<div></div>").attr("id","tag-ed-dialog");b.tagged({mode:"r",width:"270px",height:"30px",focusOut:w,tags:j});f.append(b);this.content.append(d).append(c).append(f);
m.KBD.pushHandler({element:"#dialog",handlers:[{key:"esc",func:function(){o()}},{key:"return",func:function(){s()}}]})},show:function(){a("body").append(this.saveui);var d=this.saveui.width(),b=this.saveui.height();b=Math.floor(b/2);d=Math.floor(d/2);this.saveui.css({top:"50%",left:"50%",marginTop:"-"+b+"px",marginLeft:"-"+d+"px"});this.saveui.show()},hide:function(){this.saveui.hide();this.saveui.remove();this.reset();m.KBD.popHandler()}};var n=new h;h.showSavePrompt=function(d,b,g,e,f,c,j){n.setSave(d,
b,g,e,f,c,j);n.show();a("#invalue",n.content).focus()};m.saveDialog=h})(jQuery);
(function(a){function h(){}var m=a.app,n=0,d=[{message:"Go Premium ",icon:"/_images/clip-premium-arrow.png",duration:3E4,click:function(){m.identity.state_==m.C.n285?m.Gui.showPremiumSubscription():m.Gui.n157()}},{message:'<a href="https://chrome.google.com/webstore/detail/algoakekcdmbbikdjgjdahbfihboglmi/reviews" target="_blank">Rate Us </a>',icon:"/_images/ratingblank.png",duration:2E4,click:function(){}}];h.prototype={load:function(g){var e=this;this.n2a5=a("#htoolbar2 #msgclip");this.n2a5.fadeOut("slow",
function(){e.n2a5.empty().append("<span>"+g.message+"</span>").append("<img src="+g.icon+" />").unbind("click").bind("click",g.click).fadeIn("slow");setTimeout(function(){n=n+1==d.length?0:n+1;e.load(d[n])},g.duration)})}};var b=new h;h.start=function(){setTimeout(function(){b.load(d[0])},15E3)};m.MsgClip=h})(jQuery);
(function(a){function h(g){var e=g.text,f=a("#proxy_usernick_a");f.text(e);var c=g.maxFontSize;f.css("font-size",c);for(var j=f.width();j>g.maxWidth;){if(c>g.minFontSize){c-=1;f.css("font-size",c)}else{e=e.substring(e.length-1,0);f.text(e+"..")}j=f.width()}e=f.text();return{fontSize:c,text:e}}function m(g){this.n2a5=g;this.n147()}var n=a.app,d=window.localStorage,b={premium_:false};m.prototype={n120:function(g){this.persistence_=g;this.n2a5.find("#persistence").text(n.formatNumber(g))},incPersistence:function(){if(!_.isUsableNumber(this.persistence_))this.persistence_=
0;this.persistence_+=1;this.n2a5.find("#persistence").text(n.formatNumber(this.persistence_))},n147:function(){var g=d.getItem("identity");a.extend(this,b,g?JSON.parse(g):{});d.removeItem("identity")},sync:function(g){var e=this;a.ajax("/_auth/check",{type:"POST",data:n.sign({backend:n.editor.getBackend()}),success:function(f){f=JSON.parse(f);if(f.result==="err_unauthorized"){e.state_=n.C.n211;e.n1f4=f.loginurl;e.premium_=false;a("#usernick").append('<a href="#">Login</a>');a("#usernick").find("a").click(n.Gui.showLoginOptions);
a("#persistence",e.n2a5).text(n.formatNumber(0));a("#reputation",e.n2a5).text(n.formatNumber(0));n.config.isFullScreen=false}else{a.extend(e,{state_:n.C.n285,n1e5:f.logouturl,n1e2:f.profileid,n1f1:f.nickname,persistence_:f.persistence,n19c:f.reputation,premium_:f.premium_acc});if(e.persistence_>1E3)n.n0f4=15;else if(e.persistence_>5E3)n.n0f4=20;a("#persistence",e.n2a5).text(n.formatNumber(e.persistence_));a("#reputation",e.n2a5).text(n.formatNumber(e.n19c));var c=h({text:e.n1f1,maxFontSize:16,minFontSize:14,
maxWidth:80});a("#usernick",e.n2a5).css("font-size",c.fontSize).html('<img src="/_images/profile.png" /><a href="#">'+c.text+"</a>").click(function(){n.filebrowser.load(n.identity,true)});f.touaccepted||n.Gui.showTou()}n.identity.premium_&&n.config.isFullScreen?e.n2a5.hide():e.n2a5.show();g&&g()},error:function(){e.state_=n.C.n179;g&&g()}})},n1b4:function(){d.setItem("identity",JSON.stringify({n1f1:this.n1f1,premium_:this.premium_}))}};n.Identity=m})(jQuery);
(function(a){function h(e){var f=this;this.n2a5=e;this.n2a5.mouseenter(function(){g=true;return false});this.n2a5.mouseleave(function(){return g=false});this.select_sun();this.n2a5.find("input:radio[value=sun]").attr("checked",true);this.n2a5.find("#dirdirdial").dialgroup({onchange:m});this.n2a5.find("#pointposdial").dialgroup({onchange:n});this.reset();this.n2a5.find("input:radio[value=sun]").click(function(){f.select_sun()});this.n2a5.find("input:radio[value=bulb]").click(function(){f.select_bulb()});
this.n2a5.find("input:radio[value=ambient]").click(function(){f.select_ambient()});this.n2a5.find("input:radio[value=background]").click(function(){f.select_background()});this.n2a5.find("#dirlightcolor").click(function(){a.jPicker.List[1].show();return false});this.n2a5.find("#pointlightcolor").click(function(){a.jPicker.List[2].show();return false});this.n2a5.find("#amblightcolor").click(function(){a.jPicker.List[3].show();return false});this.n2a5.find("#bgcolor").click(function(){a.jPicker.List[4].show();
return false})}function m(e){d.editor.n062(e,true)}function n(e){d.editor.n06a(e,true);d.editor.showLightPosition()}var d=a.app,b=a.tin,g=false;h.prototype={show:function(e){var f=this;this.n2a5.css("top",e.clientY-60+"px").show();d.editor.setAction(b.C.n1db);d.editor.showLightPosition();setTimeout(function(){f.hide()},3E3)},hide:function(){var e=this;if(g)setTimeout(function(){e.hide()},3E3);else{d.editor.hideLightPosition();this.n2a5.hide();d.editor.setAction(b.C.n177)}},select_sun:function(){this.n2a5.find("#pointposdial, #pointcolbar, #ambcolbar, #bgcolbar").hide();
this.n2a5.find("#dirdirdial, #dircolbar").show()},select_bulb:function(){this.n2a5.find("#dirdirdial, #dircolbar, #ambcolbar, #bgcolbar").hide();this.n2a5.find("#pointposdial, #pointcolbar").show()},select_ambient:function(){this.n2a5.find("#dirdirdial, #dircolbar, #pointposdial, #pointcolbar, #bgcolbar").hide();this.n2a5.find("#ambcolbar").show()},select_background:function(){this.n2a5.find("#dirdirdial, #dircolbar, #pointposdial, #pointcolbar, #ambcolbar").hide();this.n2a5.find("#bgcolbar").show()},
setLightColor:function(e,f){if(!_(f.r).isUsableNumber())f.r=0;if(!_(f.g).isUsableNumber())f.g=0;if(!_(f.b).isUsableNumber())f.b=0;if(!_(f.a).isUsableNumber())f.a=100;switch(e){case b.C.lighttype_directional:id="#dirlightcolor";break;case b.C.lighttype_point:id="#pointlightcolor";break;case b.C.lighttype_ambient:id="#amblightcolor";break;default:return null}this.n2a5.find(id).css("backgroundColor","rgb("+f.r+","+f.g+","+f.b+")");d.editor.n0a8(e,f,true)},setBackgroundColor:function(e){this.n2a5.find("#bgcolor").css("backgroundColor",
"rgb("+e.r+","+e.g+","+e.b+")");d.editor.n074(e,true)},reset:function(){this.syncDirectionalLightDirection();this.syncDirectionalLightColor();this.syncPointLightPosition();this.syncPointLightColor();this.syncAmbientLightColor();this.syncBackgroundColor()},syncDirectionalLightDirection:function(){var e=d.editor.getDirectionalLightDirection();this.n2a5.find("#dirdirdial").resetdialgroup({values:{dx:e[0],dy:e[1],dz:e[2]}})},syncDirectionalLightColor:function(){var e=d.editor.getLightColor(b.C.lighttype_directional);
this.n2a5.find("#dirlightcolor").css("backgroundColor","rgb("+e.r+","+e.g+","+e.b+")")},syncPointLightPosition:function(){var e=d.editor.getPointLightPosition();this.n2a5.find("#pointposdial").resetdialgroup({values:{x:e[0],y:e[1],z:e[2]}})},syncPointLightColor:function(){var e=d.editor.getLightColor(b.C.lighttype_point);this.n2a5.find("#pointlightcolor").css("backgroundColor","rgb("+e.r+","+e.g+","+e.b+")")},syncAmbientLightColor:function(){var e=d.editor.getLightColor(b.C.lighttype_ambient);this.n2a5.find("#amblightcolor").css("backgroundColor",
"rgb("+e.r+","+e.g+","+e.b+")")},syncBackgroundColor:function(){var e=d.editor.getBackgroundColor();this.n2a5.find("#bgcolor").css("backgroundColor","rgb("+e.r+","+e.g+","+e.b+")")}};d.LightOptions=h})(jQuery);
(function(a){function h(f){this.n2a5=f;var c=this;a(".closeIcon",f).click(function(){c.hide()})}function m(f){a("#tabwindow_container",this.n2a5).children().hide();f.show()}function n(){a("#tabs_container .title",this.n2a5).addClass("tab");a("#tabwindow_container",this.n2a5).children().height(420);a("#tabs_container #mysketchestitle",this.n2a5).addClass("activetab").click(function(){a("#tabs_container .title",this.n2a5).removeClass("activetab");a(this).addClass("activetab");m(a("#sketchlist",this.n2a5))}).hover(function(){a(this).addClass("focustab")},
function(){a(this).removeClass("focustab")}).show();a("#tabs_container #mysourcestitle",this.n2a5).click(function(){a("#tabs_container .title",this.n2a5).removeClass("activetab");a(this).addClass("activetab");m(a("#sourcelist",this.n2a5))}).hover(function(){a(this).addClass("focustab")},function(){a(this).removeClass("focustab")}).show();a("#tabs_container #myderivativestitle",this.n2a5).click(function(){a("#tabs_container .title",this.n2a5).removeClass("activetab");a(this).addClass("activetab");
m(a("#derivativelist",this.n2a5))}).hover(function(){a(this).addClass("focustab")},function(){a(this).removeClass("focustab")}).show()}function d(){a("#tabwindow_container",this.n2a5).children().height(550);a(".title").removeClass("activetab tab");a("#mysourcestitle",this.n2a5).hide();a("#myderivativestitle",this.n2a5).hide()}function b(f,c,j,s,o){var w=a("<div></div>").attr("class","sketchrow"),l=0,B;_(f).each(function(C){if(l>=6&&l%6===0){j.append(w);w=a("<div></div>").attr("class","sketchrow")}B=
C.is_private;var G=a("<div></div>").attr("class","sketchentry").data("name",C.name).data("uid",C.uid),A=a("<div></div>").attr("class","thumbentry").append('<div class="name">'+C.name+"</div>").append('<div class="user">'+e.msg.modified+": "+C.relative_tstamp+"</div>");A=a("<img></img>").attr("src",C.thumburl).attr("class","preview").data("parent",G).click(function(){var p=a(this).data("parent").data("uid");c.hide();a(document).trigger("sketch_load_requested",p)}).tipsy({fallback:A,html:true});C="<div>"+
C.name+"</div>";if(o){var x;x=s?a('<img id="delIcon" src="/_images/sketchdel.png"/>').data("parent",G).mouseenter(function(){a(this).attr("src","/_images/sketchdelfocus.png")}).mouseleave(function(){a(this).attr("src","/_images/sketchdel.png")}).click(function(){if(e.identity.premium_){var p=a(this).data("parent"),D=p.data("name"),E=p.data("uid");c.hide();e.Dialog.n1f6(e.msg.delete_confirm+'"'+D+'"?',e.msg.yes,e.msg.no,function(){e.Store.deleteFromCloud(E,function(z){z!=="SUCCESS"&&e.Dialog.n1f6(e.msg.delete_failure+
": "+z,e.msg.cancel)})})}else{c.hide();e.Gui.showPremiumSubscription()}}):"";var t;t=B?a('<img id="prvIcon" src="/_images/lock.png" />').attr("title",e.msg.private_sketch):""}G.append(A).append(C).append(x).append(t);w.append(G);l++});j.append(w)}function g(f,c,j){var s=a("<div></div>").attr("id","editbar"),o=a("<div></div>").attr("id","userinfo"),w=a("<div></div>").attr("id","avatar"),l=a("<div></div>").attr("id","externlinks"),B="/_user/"+c.n1e2,C;if(j){j=a("<a></a>").attr("href",c.n1e5).text(e.msg.logout);
C=a("<a></a>").attr("href","/_user/"+c.n1e2+"?action=edit").text("Edit Profile")}else C=j="";s.append(C).append(j);j="<a href="+B+">"+e.msg.permalink.toLowerCase()+"</a>";c=a("<div></div>").attr("id","profile_nickname").html(c.n1f1+j);j=a("<div></div>").attr("id","profile_rep").attr("title",e.msg.reputation).html('<img src="/_images/reputation.png" />'+e.formatNumber(f.reputation)).tipsy({gravity:"w"});C=a("<div></div>").attr("id","profile_persistence").attr("title",e.msg.persistence).html('<img src="/_images/persistence.png" />'+
e.formatNumber(f.persistence)).tipsy({gravity:"w"});o.append(c).append(j).append(C);f.twitter&&l.append('<a href="https://twitter.com/'+f.twitter+'"><img src=https://si0.twimg.com/a/1320689271/images/logos/twitter_newbird_blue.png />@'+f.twitter+"</a>");f.flattr&&l.append('<a class="FlattrButton" style="display:none;" rev="flattr;" href="'+B+'"></a>');w.append('<img src="'+f.profile_img_url+'">');a("#userprofile",this.n2a5).append(s).append(w).append(o).append(l)}var e=a.app;h.prototype={load:function(f,
c){var j=this;e.KBD.pushHandler({element:"#filebrowser",handlers:[{key:"esc",func:function(){e.filebrowser.hide()}}]});var s=f.state_===e.C.n285&&f.n1e2===e.identity.n1e2;if(c){a("#wait",this.n2a5).show().addClass("superwait");a("#userprofile",this.n2a5).empty();a.ajax("/_user/"+f.n1e2,{type:"GET",data:"format=json",success:function(o){o=JSON.parse(o);g(o,f,s);j.n0ff(o.sketches,s,f);j.load_source_list(o.roots,s);j.load_derivative_list(o.branches,s);a("#userprofile").show();n();m(a("#sketchlist"));
a("#wait",j.n2a5).hide().removeClass("superwait")}})}else{c=a("#sketchlist",this.n2a5);a("#mysketchestitle",this.n2a5).text(s?"My Sketches":f.n1f1+"'s Sketches");a("#wait",this.n2a5).show();this.load_sketch_browser(f.n1e2,s);d();m(c)}this.n2a5.show();a("#curtain").fadeIn()},load_source_list:function(f,c){a("#sourcelist",this.n2a5).empty();b(f,this,a("#sourcelist",this.n2a5),c,false);a("#mysourcestitle",this.n2a5).text(e.msg.sources)},load_derivative_list:function(f,c){a("#derivativelist",this.n2a5).empty();
b(f,this,a("#derivativelist",this.n2a5),c,false);a("#myderivativestitle",this.n2a5).text(e.msg.derivatives)},n0ff:function(f,c,j){a("#sketchlist",this.n2a5).empty();b(f,this,a("#sketchlist",this.n2a5),c,true);a("#mysketchestitle",this.n2a5).text(c?"My Sketches":j.n1f1+"'s Sketches")},load_sketch_browser:function(f,c){var j=a("#sketchlist",this.n2a5),s=this;a.post("/_sketch/list",e.sign({profile_id:f}),function(o){o=JSON.parse(o);if(o.result!="SUCCESS")e.Dialog.n1f6(e.msg.list_failure+" : "+o.result,
e.msg.cancel);else{b(o.list,s,j,c,true);a("#wait",s.n2a5).hide();j.show()}})},hide:function(f){a("#curtain").hide();a("body").find(".tipsy").first().remove();d();a("#userprofile",this.n2a5).hide();a("#sketchlist").empty();a("#sourcelist").empty();a("#derivativelist").empty();a(this.n2a5).hide(f);e.KBD.popHandler()}};e.n1a3=h})(jQuery);
(function(a){var h={items:[],offset:0,count:40,onScrollBottom:function(){}};a.fn.itemBrowser=function(m){var n=a.extend({},h,m);return a(this).each(function(){function d(g,e){b.find(".wait").hide();var f=b.find(".itemlist");_(g).each(function(c){var j=a('<img title="'+c.info+'" src="'+c.imgsrc+'"/>');j.data("tin",c.data);j.click(function(){e.click(a(this).data("tin"));b.hide()});f.append(j)});n.offset+=g.length;b.find(".title").html(n.title+" ["+n.startOffset+"-"+n.offset+"]");n.reachedEnd=g.length<
n.count}var b=a(this);n.startOffset=n.offset;b.find(".title").html(n.title);b.find(".close").click(function(){b.hide()});n.itemLoader(n.offset,n.count,d);b.find(".itemlist").empty();b.find(".itemlist").unbind("scroll");b.find(".itemlist").bind("scroll",function(){var g=a(this).get(0).scrollHeight-a(this).innerHeight()-1;if(a(this).scrollTop()>=g)n.reachedEnd||n.itemLoader(n.offset,n.count,d)})})}})(jQuery);
(function(a){function h(){a("#leaderboard .closeIcon").click(d)}function m(){return false}function n(){a("#curtain, #leaderboard").fadeIn()}function d(){a("#curtain, #leaderboard").fadeOut();g.KBD.popHandler()}function b(e){var f=a("#leaderboard");a("#wait",f).show();a("#lists",f).hide();a.post("/_leaders",g.sign(e),function(c){c=JSON.parse(c);var j,s=function(l){var B=a("<img/>").attr("class","profile_img").attr("src",l.profile_img_url),C=a("<div></div>").attr("class","detailbox"),G=a("<div></div>").attr("class",
"infobox"),A=a("<div></div>").attr("class","previewbox"),x='<a href="/_user/'+l.profile_id+'"><div class="nickname">'+l.nickname+"</div></a>",t=a("<span></span>").attr("class","scoreline").html('<img class="n19cicon" src="/_images/reputation.png"/>&nbsp;<span class="reputation">'+l.reputation+'</span>&nbsp;<img class="persistence_icon" src="/_images/persistence.png"/>&nbsp;<span class="persistence">'+l.persistence+"</span>");_(l.tins).each(function(p){A.append('<img class="previewimg" id="'+p.uid+
'" alt="'+p.name+'" src="'+p.thumburl+'"/>')});G.append(x);G.append(t);C.append(G);C.append(A);a(".previewimg",A).click(function(){a(document).trigger("sketch_load_requested",a(this).attr("id"));d();return true});return a("<div></div>").attr("class","entry").append(B).append(C)},o=a("#mostactive",f).empty();o.append('<div class="title">'+g.msg.mostactive+"</div>");j=_(c.most_active).map(s);_(j).each(function(l){o.append(l)});var w=a("#mostpopular",f).empty();w.append('<div class="title">'+g.msg.mostpopular+
"</div>");j=_(c.most_popular).map(s);_(j).each(function(l){w.append(l)});a("#wait",f).hide();a("#lists",f).show();f.data("isPopulated",true)})}var g=a.app;h.prototype={show:function(){var e=a("#leaderboard");g.KBD.pushHandler({element:"#leaderboard",handlers:[{key:"esc",func:function(){d()}}]});if(e.data("isPopulated"))n();else{n();a("input[value=weekly]",e).attr("checked",true);e.data("scope","weekly");a("input[name=leaderscope]",e).click(function(){e.data("scope",a(this).attr("value"));b({scope:a(this).attr("value")})});
e.mousedown(m).mouseup(m);b({scope:"weekly"})}}};g.n1ae=h})(jQuery);
(function(a){function h(g){this.portal=g.get(0).contentWindow}function m(g){b=g;this.portal=g.get(0).contentWindow}var n=a.app,d=0,b;h.prototype={post:function(g,e,f){e&&b.bind("onfactorysuccess"+d,e);f&&b.bind("onfactoryfailure"+d,f);g.id=d;this.portal.postMessage(JSON.stringify(g),"http://"+n.C.factory_host);d++}};m.prototype={post:function(g,e){e&&b.bind("ons3success"+d,e);g.id=d;this.portal.postMessage(JSON.stringify(g),"http://"+n.C.s3_host);d++}};a(window).bind("message",function(g){g=g.originalEvent;
if(g.origin==="http://"+n.C.factory_host){g=a.parseJSON(g.data);g.response?b.trigger("onfactorysuccess"+g.id,g.response):b.trigger("onfactoryfailure"+g.id);b.unbind("onfactorysuccess"+g.id);b.unbind("onfactoryfailure"+g.id)}else if(g.origin==="http://"+n.C.s3_host){g=a.parseJSON(g.data);b.trigger("ons3success"+g.id,g.data);b.unbind("ons3success"+g.id)}else console&&console.log("Portal ignoring message")});n.FactoryPortal=h;n.S3Portal=m})(jQuery);
(function(a){function h(b){this.n2a5=b;var g=this;a(".closeIcon",b).click(function(){g.hide()})}function m(){a("#scale #slider",this.n2a5).slider({value:34,disabled:false}).css({opacity:0.9}).removeAttr("title")}function n(){a("#scale #slider",this.n2a5).slider({value:34,disabled:true}).css({opacity:0.3}).attr("title","DAE "+d.msg.only)}var d=a.app;h.prototype={load:function(b,g,e,f,c,j,s,o,w,l,B){function C(){var D=a("#tag-ed").tagged("getTags"),E=d.sketch.meta,z={},u=this;z.uid=E.uid_;z.tags=JSON.stringify(D);
a.post("/_sketch/updatetags",d.sign(z),function(k){k=JSON.parse(k);E.tags_=k.tags;u.empty();a("#tag-ed").tagged({mode:"r",width:"270px",height:"60px",focusOut:u.settings.focusOut,tags:k.tags});d.titlebox.update(E.uid_,E.name_,E.n1dd,E.n19e,E.n1bf,E.userpoints_,E.n294,E.n227,E.thumburl_,E.private_,E.tags_)})}function G(){a("input[name=destination]",this.n2a5).attr("disabled",true);a("input[name=format]",this.n2a5).attr("disabled",true)}var A=this.n2a5,x=this,t=l?"/_images/lock.png":"/_images/cc.png";
l=l?d.msg.private_sketch:d.msg.cc_sketch;var p;d.KBD.pushHandler({element:"#sketchdetail",handlers:[{key:"esc",func:function(){d.sketchdetail.hide()}}]});e!=d.identity.n1e2?a("#main #left #edit",A).hide():a("#main #left #edit",A).unbind("click").html("<span>"+d.msg.edit+"</span>").click(function(){d.sketchdetail.updateMeta()}).show();a("#main #left #preview",this.n2a5).css("backgroundImage",'url("'+w+'")');a("#main #left #title",this.n2a5).text(g).append(a('<img id="licence"></img>').attr("src",t).attr("title",
l));a("#main #left #author",this.n2a5).text(d.msg.by+" "+f);a("#curtain").fadeIn();this.n2a5.fadeIn();w="http://www.3dtin.com/"+b;t="http://3dt.in/"+b;g=d.msg.checkout+' "'+g+'"';if(f)g+=" "+d.msg.by+" "+f;g+=" "+t;a("#twitter",this.n2a5).attr("href","http://twitter.com/home?status="+encodeURI(g));a("#facebook",this.n2a5).attr("href","http://www.facebook.com/share.php?u="+w);a("#rating",this.n2a5).rating({score:c,points:j,disabled:e==d.identity.n1e2,onclick:function(D,E){a.post("/_sketch/rate",d.sign({uid:b,
points:D}),function(z){z=JSON.parse(z);if(z.result==="SUCCESS")E(true,z.avgrating,D);else{z.result==="UNAUTHORIZED"?d.Gui.n157():d.Dialog.n1f6(z.result,d.msg.cancel);E(false)}})}});a("#permalink",this.n2a5).html('<a href="http://www.3dtin.com/'+b+'">http://www.3dtin.com/'+b+"</a>");a("#tag-ed").tagged({mode:"r",width:"270px",height:"60px",focusOut:C,tags:B});a("#rootlist",this.n2a5).empty();_(s).each(function(D,E){if(!(E>5)){D=a("<img />").attr("src",D.thumburl).data("uid",D.uid).click(function(){a(document).trigger("sketch_load_requested",
a(this).data("uid"));x.hide()});a("#rootlist",this.n2a5).append(D)}},this);a("#branchlist",this.n2a5).empty();_(o).each(function(D,E){if(!(E>5)){D=a("<img></img>").attr("src",D.thumburl).data("uid",D.uid).click(function(){a(document).trigger("sketch_load_requested",a(this).data("uid"));x.hide()});a("#branchlist",this.n2a5).append(D)}},this);a("input[name=destination]",this.n2a5).attr("disabled",false);a("input[name=destination]",this.n2a5).attr("checked",false);a("input[name=format]",this.n2a5).attr("disabled",
false);a("input[name=format]",this.n2a5).attr("checked",false);a("#thingiverse",A).removeClass("disabledtext");a("input[name=format]",this.n2a5).unbind("click");a("input[name=format]",this.n2a5).click(function(){switch(a(this).attr("value")){case "png":a("input[value=desktop]",A).attr("checked",true);a("#thingiverse",A).addClass("disabledtext");a("input[value=thingiverse]",A).attr("disabled",true);a("input[value=imat]",A).attr("disabled",true);n();break;case "svg":a("input[value=desktop]",A).attr("checked",
true);a("#thingiverse",A).addClass("disabledtext");a("input[value=thingiverse]",A).attr("disabled",true);a("input[value=imat]",A).attr("disabled",true);n();break;case "obj":a("input[value=desktop]",A).attr("checked",true);a("#thingiverse",A).addClass("disabledtext");a("input[value=thingiverse]",A).attr("disabled",true);a("input[value=imat]",A).attr("disabled",true);n();break;case "dae":a("input[value=desktop]",A).attr("checked",true);a("#thingiverse",A).addClass("disabledtext");a("input[value=thingiverse]",
A).attr("disabled",true);a("input[value=imat]",A).attr("disabled",true);m();break;case "stl":a("input[value=desktop]",A).attr("checked",true);a("#thingiverse",A).removeClass("disabledtext");a("input[value=thingiverse]",A).attr("disabled",false);a("input[value=imat]",A).attr("disabled",false);n();break}});a("input[value=stl]",this.n2a5).attr("checked",true);a("input[value=desktop]",A).attr("checked",true);a("#scale #slider","#sketchdetail").slider({disabled:true,value:34,change:function(D,E){x.changeUnit(E.value,
function(z){p=z/1E3})}});a(".infoscript",A).unbind("hover");a(".infoscript",A).hover(function(){var D;if(a(this).attr("id")=="q_imat")D=d.msg.imat_info+'<br /><br /><a href="http://i.materialise.com">  - i.materialise.com</a>';else if(a(this).attr("id")=="q_thing")D=d.msg.thing_info+'<br /><br /><a href="http://www.thingiverse.com">  - www.thingiverse.com</a>';else return;D=a('<div id="info"></div>').append('<div class="trg"></div>').append("<div>"+D+"</div>");a(this).append(D)},function(){var D=
a(this).parent();a("#info",D).remove()});a("#exportbtn",A).unbind("click");a("#exportbtn",A).removeData();a("#exportbtn",A).html(d.msg["export"]);a("#exportbtn",A).click(function(){G();var D=a("input[name=format]:checked").attr("value"),E=a("input[name=destination]:checked").attr("value");if(E==="desktop")switch(D){case "png":window.open(d.editor.getScreenshot());break;case "svg":case "stl":case "obj":case "dae":a.ajax("/_factory/export/"+D+"/"+b,{type:"POST",data:d.sign({unit:p}),timeout:2E5,success:function(z){try{var u=
a.parseJSON(z);if(u.result!="SUCCESS"){d.sketchdetail.hide();d.Dialog.n1f6(u.result,d.msg.cancel)}else{a("#exportbtn").html('<a href="'+u.url+'">'+d.msg.download+"</a>");n()}}catch(k){d.sketchdetail.hide();d.Dialog.n1f6(d.msg.failedexport,d.msg.cancel)}},error:function(z,u,k){d.Dialog.n1f6(d.msg.failedexport+": "+u+", "+k,d.msg.cancel);d.sketchdetail.hide()}});a(this).html(d.msg.generating).unbind("click");break}else if(E==="thingiverse"){a.ajax("/_factory/export/stl/"+b,{type:"POST",data:d.sign({unit:p}),
timeout:2E5,success:function(z){z=a.parseJSON(z);z="/_thingiverseexport?uid="+b+"&exporturl="+encodeURIComponent(z.url);a("#exportbtn").html('<a target="_blank" href="'+z+'">'+d.msg.proceed+"</a>")},error:function(z,u,k){d.Dialog.n1f6(d.msg.failedexport+": "+u+", "+k,d.msg.cancel);d.sketchdetail.hide()}});a(this).html(d.msg.generating).unbind("click")}else if(E==="imat"){a.ajax("/_factory/export/imat/"+b,{type:"POST",data:d.sign({unit:p}),timeout:2E5,success:function(z){z=a.parseJSON(z);a("#exportbtn").html('<a target="_blank" href="'+
z.url+'">'+d.msg.proceed+"</a>")},error:function(z,u,k){d.Dialog.n1f6(d.msg.failedexport+": "+u+", "+k,d.msg.cancel);d.sketchdetail.hide()}});a(this).html(d.msg.generating).unbind("click")}});n()},hide:function(){a("#curtain").fadeOut();d.KBD.popHandler();this.n2a5.fadeOut(function(){})},updateMeta:function(){var b=d.sketch.meta,g={};this.hide();d.Gui.n0cd(b.name_,function(e,f,c){g.uid=b.uid_;g.name=e;g.license=f;g.tags=JSON.stringify(c);a.post("/_sketch/updatemeta",d.sign(g),function(j){j=JSON.parse(j);
if(j.result!="SUCCESS")d.Dialog.n1f6(j.result,d.msg.cancel);else{b.name_=j.name;b.private_=j.is_private;b.tags_=j.tags;d.titlebox.update(b.uid_,b.name_,b.n1dd,b.n19e,b.n1bf,b.userpoints_,b.n294,b.n227,b.thumburl_,b.private_,b.tags_)}})},b.private_,b.tags_)},changeUnit:function(b,g){var e=Math.exp(0.0697753*(b-1)).toFixed(0),f=d.editor.model.getVolume();b=e<10?e+"mm":e/10+"cm";a("#scale .field","#sketchdetail").text(d.msg.scale);a("#scale #unit","#sketchdetail").html('<span style="font-size:90%">'+
b);var c=_.any(_.map(f,function(j){return j*e}),function(j){return j>1E4});f=_.map(f,function(j){return c?(j*(e/1E3)).toFixed(2)+"m":(j*(e/10)).toFixed(2)+"cm"});a("#volume").html('<span class="field">'+d.msg.size+"</span> <strong>"+f[0]+" (X)</strong> x <strong>"+f[1]+" (Y)</strong> x <strong>"+f[2]+" (Z)</strong><br/></span>");g(e)}};d.n17c=h})(jQuery);
(function(a){function h(){var l=window.localStorage.getItem("cadCacheMap");o=l?a.parseJSON(l):[]}function m(l,B){try{if(!_(o).any(function(G){return G==l})){for(;o.length>=c.C.cadCacheSizeLimit;){window.localStorage.removeItem(o[0]);o.splice(0,1)}o.push(l)}window.localStorage.setItem(l,JSON.stringify(B));window.localStorage.setItem("cadCacheMap",JSON.stringify(o))}catch(C){c.reportError(C,"saveToCache failed: "+l)}}function n(){console.log("Deleting "+o.length+" template cache entries");_(o).each(function(l){window.localStorage.removeItem(l)});
o=[];window.localStorage.setItem("cadCacheMap",JSON.stringify(o))}function d(l){return _(o).any(function(B){return B==l})?window.localStorage.getItem(l):null}function b(){}function g(){w.localhit++;w.totalReq++}function e(l){w.s3latency=(w.s3latency*w.s3hit+l)/(w.s3hit+1);w.s3hit++;w.totalReq++}function f(l){w.factorylatency=(w.factorylatency*w.factoryhit+l)/(w.factoryhit+1);w.factoryhit++;w.totalReq++}var c=a.app,j=a.tin,s=j.C.min_align,o,w={totalReq:0,factoryhit:0,s3hit:0,localhit:0,s3latency:0,
factorylatency:0};b.prototype={getMesh:function(l,B,C,G){var A=(new Date).getTime(),x=j.n18e.getInstanceSignature(l,B),t=d(x);if(t){g();C(a.parseJSON(t))}else c.s3Portal.post({sig:x},function(p,D){if(D){e((new Date).getTime()-A);m(x,D);C(D)}else a.ajax("/_factory/cadmium/runid",{type:"POST",data:c.sign({uid:l,params:JSON.stringify(B)}),timeout:6E4,success:function(E){f((new Date).getTime()-A);if(E.error)G(E.error);else{m(x,E);C(E)}},error:function(E,z){G(z)}})})},instantiateGeometries:function(l,
B){function C(t){var p=j.n18e.getInstanceSignature(t.uid,t.params);if(G[p]){x++;x<l.length?C(l[x]):B(G)}else A.getMesh(t.uid,t.params,function(D){var E=new a.tin.Mesh3D(c.editor);E.n196(D.surfaces);G[p]={mesh:E,alignment:{x:s,y:s,z:s}};x++;x<l.length?C(l[x]):B(G)},function(D){c.Dialog.n1f6(D,c.msg.cancel)})}var G={},A=this,x=0;C(l[x])}};b.stats=w;b.clear=n;h();c.CadmiumCache=b})(jQuery);
(function(a){function h(f,c,j){var s=a.parseJSON(c.meta);f.find("#name").text(s.soliddetail.shortName||s.soliddetail.name);f.find("#summary").text(s.soliddetail.summary);f.find("#preview img").attr("src",c.previewurl);var o=f.find("#parameters > p").empty();_(s.argdetails).each(function(w){o.append(a("<div></div>").CadmiumTemplateParam(a.extend({uservalues:j},w)))})}function m(f){var c={},j={},s={};f.find(".cadmiumparam").each(function(){c[a(this).data("name")]=a(this).data("valueType");j[a(this).data("name")]=
a(this).data("transportValue");s[a(this).data("name")]=a(this).data("valid")});if(_(s).chain().values().all(_.identity).value())return{values:j,types:c}}var n=a.app,d=1,b=2,g=a.tin.C.min_align;a.fn.CadmiumTemplateParam=function(f){function c(w,l){var B;if(l.valueType=="enum"){B=a("<select></select>");_(l.validValues).each(function(C){B.append('<option value="'+C+'">'+C+"</option>")})}else B=a('<input type="text"></input>');w.find(".inputwrapper").append(B)}function j(w,l){var B;if(l.uservalues&&l.uservalues[l.name])if(l.valueType==
"str"||l.valueType=="enum"){B=l.uservalues[l.name];l=n.Base64.decode(decodeURIComponent(B))}else B=l=l.uservalues[l.name];else if(l.valueType=="str"||l.valueType=="enum"){l=l.defaultValue;B=encodeURIComponent(n.Base64.encode(l))}else B=l=l.defaultValue;w.find(".inputwrapper > *").val(l);w.data("displayValue",l);w.data("transportValue",B);w.data("valid",true)}function s(w,l){var B=w.find(".inputwrapper > *");l.valueType=="enum"?B.change(function(){w.data("displayValue",a(this).val());w.data("transportValue",
encodeURIComponent(n.Base64.encode(a(this).val())))}):B.change(function(){var C=a(this).val(),G,A;switch(l.valueType){case "int":A=G=parseInt(C,10);break;case "float":A=G=parseFloat(C);break;case "str":A=C;G=encodeURIComponent(n.Base64.encode(C));break}if((l.valueType=="int"||l.valueType=="float")&&isNaN(A)){w.data("value",undefined);B.css("backgroundColor","#f88");w.data("valid",false)}else{B.val(A);w.data("displayValue",A);w.data("transportValue",G);if(l.valueRange)if(l.valueRange==d){if(A<=0){B.css("backgroundColor",
"#f88");w.data("valid",false);return}}else if(l.valueRange==b){if(A>=0){B.css("backgroundColor","#f88");w.data("valid",false);return}}else try{if(l.endpointInclusion){if(l.endpointInclusion[0]){if(A<l.valueRange[0])throw"invalid";}else if(A<=l.valueRange[0])throw"invalid";if(l.endpointInclusion[1]){if(A>l.valueRange[1])throw"invalid";}else if(A>=l.valueRange[1])throw"invalid";}else if(A<=l.valueRange[0]||A>=l.valueRange[1])throw"invalid";}catch(x){if(x=="invalid"){B.css("backgroundColor","#f88");
w.data("valid",false);return}else throw x;}if(l.invalidValues)if(_(l.invalidValues).any(function(t){return C==t})){B.css("backgroundColor","#f88");w.data("valid",false);return}B.css("backgroundColor","#fff");w.data("valid",true)}})}var o=a.extend({},f);return a(this).each(function(){var w=a(this);w.attr("class","cadmiumparam");w.empty();w.append(o.name+'&nbsp;&nbsp<span class="inputwrapper"></span><br/><span class="shortname">'+o.shortName+'</span>&nbsp;&nbsp<span class="arginfo"></span>');w.data("name",
o.name);var l=w.find(".arginfo");if(o.valueRange)if(o.valueRange==d)l.text("(+ve)");else if(o.valueRange==b)l.text("(-ve)");else{var B="";if(o.endpointInclusion){B+=o.endpointInclusion[0]?"[":"(";B+=o.valueRange[0]+"-"+o.valueRange[1];B+=o.endpointInclusion[1]?"]":")"}else B="("+o.valueRange[0]+"-"+o.valueRange[1]+")";l.text(B)}w.data("valueType",o.valueType);c(w,o);j(w,o);s(w,o)})};var e={addHandler:function(){},cancelHandler:function(){},container:null,showPreview:true,alignment:{x:g,y:g,z:g},template:null,
uid:null,params:null};a.fn.CadmiumTemplateFiller=function(f){var c=a.extend({},e,f);return a(this).each(function(){a(this);a(this).empty();a(this).append('<div id="name"></div><div id="preview">  <img/>  <div id="summary"></div></div><div id="controls">  <div id="parameters">    <p></p>  </div>  <div id="buttonpanel">    <div id="add">'+(c.addText||n.msg.add)+"</div>  </div><div>");var j=a(this).find("#parameters > p");a(document).unbind("add_template");a(document).bind("add_template",function(){try{var o=
m(j);o&&c.addHandler(c.template,o,c.alignment)}catch(w){if(w!="INVALID_VALUE")throw w;}finally{a(this).find("input").focusout()}});a(this).find("#add").unbind("click");a(this).find("#add").click(function(){a(document).trigger("add_template")});if(c.template)h(a(this),c.template);else if(c.uid){var s=a(this);a.post("/_cadmium/load",n.sign({uid:c.uid,version:"basic"}),function(o){o=a.parseJSON(o);if(o.result!="SUCCESS")n.Dialog.n1f6(o.result,n.msg.cancel);else{c.template=o;h(s,o,c.params)}})}a(this).find("input").first().focus()})}})(jQuery);
(function(a){function h(d){this.n2a5=d;this.history=new n(7);this.load()}var m=a.app,n=Queue.extend({constructor:function(d){this.sizelimit=d;this.base()},enqueue:function(d){this.base(d);this.getSize()>this.sizelimit&&this.dequeue()},contains:function(d){return _(this.getElementArray()).any(function(b){return _.isEqual(b,d)})},getElementArray:function(){return this.queue.slice(this.queueSpace,this.queueSpace+this.getSize())}});h.prototype={add:function(d){this.history.contains(d)||this.history.enqueue(d);
this.save()},save:function(){var d=this.history.getElementArray();window.localStorage.setItem("cadmiumHistory",JSON.stringify(d))},load:function(){var d=window.localStorage.getItem("cadmiumHistory");if(window.localStorage.getItem("cadmiumHistoryVersion")!=1){window.localStorage.removeItem("cadmiumHistory");window.localStorage.setItem("cadmiumHistoryVersion",1)}else d&&_(a.parseJSON(d)).each(this.add,this)},show:function(){var d=this.n2a5.empty();if(this.history.getSize()>0){d.append('<div id="title">Recently used</div>');
_(this.history.getElementArray().reverse()).each(function(b){var g=a.parseJSON(b.cadtemp.meta),e='<img src="'+b.cadtemp.thumburl+'"/>';e+='<div id="name">'+b.cadtemp.name+"</div>";_(g.argdetails).each(function(f){var c;c=b.params.types[f.name]=="str"||b.params.types[f.name]=="enum"?m.Base64.decode(decodeURIComponent(b.params.values[f.name])):b.params.values[f.name];e+='<div id="param">';e+='  <div id="pname">'+f.name+"</div>";e+='  <div id="pvalue">'+c+"</div>";e+="</div>"});e+='<div class="add">Add</div>';
g=a("<div></div>").attr("id","entry").append(e);a(".add",g).data("item",b);d.append(g)},this)}a(".add",d).click(function(){if(m.editor.getBackend()!=="WebGL"){m.cadmiumBrowser.hide();m.Dialog.n1f6(m.msg.webglreqmsg,m.msg.cancel)}else{m.reportStat("Template History Used");var b=a(this).data("item");m.Gui.n15e(m.msg.loading);m.cadmiumCache.getMesh(b.cadtemp.uid,b.params.values,function(g){m.Gui.n15e();mesh=new a.tin.Mesh3D(m.editor);this.mesh.n196(g.surfaces);m.editor.setCurrentGeometry(b.cadtemp.uid,
b.params.values,mesh);m.editor.setAction(a.tin.C.n1d1)},function(g){m.Gui.n15e();m.Dialog.n1f6(m.msg.error+": "+g,m.msg.cancel)});m.cadmiumBrowser.hide()}})}};m.CadmiumHistory=h})(jQuery);
(function(a){function h(){this.n2a5=a("#cadmiumbrowser");var x=this;a(".closeIcon",this.n2a5).click(function(){x.hide()});a("#minicadContainer #cadexpand").click(x.maximize);a("#minicadContainer #left",this.n2a5).click(n);a("#minicadContainer #right",this.n2a5).click(d);B=new c.CadmiumHistory(this.n2a5.find("#details #history"));A=parseInt(a("#cadtemplist").height()/G)}function m(x,t){if(c.editor.getBackend()!=="WebGL")c.Dialog.n1f6(c.msg.webglreqmsg,c.msg.cancel);else{c.Gui.n15e(c.msg.loading);c.CadmiumBrowser.lastTemplate=
x;a("#invisiblescreen").show();c.cadmiumCache.getMesh(x.uid,t.values,function(p){a("#invisiblescreen").hide();c.Gui.n15e();var D=new a.tin.Mesh3D(c.editor);D.n196(p.surfaces);c.editor.setCurrentGeometry(x.uid,t.values,D);c.editor.setAction(a.tin.C.n1d1);B.add({cadtemp:x,params:t})},function(p){a("#invisiblescreen").hide();c.Gui.n15e();c.Dialog.n1f6(c.msg.error+": "+p,c.msg.cancel)})}c.cadmiumBrowser.hide()}function n(){a("#minicadContainer #right").show();j-=s*o;if(j<=0)j=0;a("#minicadtemplist").animate({scrollLeft:j});
j==0&&a("#minicadContainer #left").hide()}function d(){a("#minicadContainer #left").show();j+=s*o;if(j+w+l>=a("#minicadtemplist").get(0).scrollWidth)j=a("#minicadtemplist").get(0).scrollWidth-w;a("#minicadtemplist").animate({scrollLeft:j});j==a("#minicadtemplist").get(0).scrollWidth-w&&a("#minicadContainer #right").hide()}function b(x){var t=parseInt(x.index/C);if(x.direction=="up"){x=parseInt(x.count/C);if((x-t)%A!=0)return}else if(x.direction=="down")if(t%A!=0)return;t=parseInt(t/A)*a("#cadtemplist").height();
a("#cadtemplist").animate({scrollTop:t},{duration:500})}function g(x){x=a(f(x));x.addClass("focus");x.children(".title").show()}function e(x){x=a(f(x));x.removeClass("focus");x.children(".title").hide()}function f(x){var t=parseInt(x/C);return"#cadtemplist .cadtemprow:nth-child("+(t+1)+") .cadtempentry:nth-child("+(x-t*C+1)+")"}var c=a.app,j=0,s=106,o=7,w=s*o,l=6,B,C=6,G=124,A;h.prototype={show:function(x){function t(D){c.CadmiumBrowser.lastTemplate=D.data("cadtemp");p.n2a5.find("#cadtempfiller").CadmiumTemplateFiller({template:D.data("cadtemp"),
addHandler:m,container:p.n2a5});B.show();a("#details").show();p.minimize()}var p=this;p.currEntryIndex=0;p.prevEntryIndex=0;a("#minicadContainer #left").hide();a("#minicadContainer #right").show();a("#minicadtemplist").css({width:w+"px"});c.KBD.pushHandler({element:"#cadmiumbrowser",handlers:[{key:"esc",func:function(){a("#cadtemplist").is(":visible")?c.cadmiumBrowser.hide():c.cadmiumBrowser.maximize()}},{key:"return",func:function(){if(a("#cadtemplist").is(":visible")){var D=a(f(p.currEntryIndex));
t(D)}else a(document).trigger("add_template")}},{key:"right",func:function(){if(a("#cadtemplist").is(":visible")){e(p.prevEntryIndex);p.currEntryIndex++;if(p.currEntryIndex>p.tempCount-1)p.currEntryIndex=p.tempCount-1;b({direction:"down",index:p.currEntryIndex,count:p.tempCount});g(p.currEntryIndex);p.prevEntryIndex=p.currEntryIndex}else d()}},{key:"left",func:function(){if(a("#cadtemplist").is(":visible")){e(p.prevEntryIndex);p.currEntryIndex--;if(p.currEntryIndex<0)p.currEntryIndex=0;b({direction:"up",
index:p.currEntryIndex,count:p.tempCount});g(p.currEntryIndex);p.prevEntryIndex=p.currEntryIndex}else n()}},{key:"up",func:function(){if(a("#cadtemplist").is(":visible")){e(p.prevEntryIndex);p.currEntryIndex-=C;if(p.currEntryIndex<0)p.currEntryIndex=0;b({direction:"up",index:p.currEntryIndex,count:p.tempCount});g(p.currEntryIndex);p.prevEntryIndex=p.currEntryIndex}}},{key:"down",func:function(){if(a("#cadtemplist").is(":visible")){e(p.prevEntryIndex);p.currEntryIndex+=C;if(p.currEntryIndex>p.tempCount)p.currEntryIndex=
p.tempCount-1;b({direction:"down",index:p.currEntryIndex,count:p.tempCount});g(p.currEntryIndex);p.prevEntryIndex=p.currEntryIndex}}}]});c.CadmiumBrowser.lastTemplate&&p.n2a5.find("#cadtempfiller").CadmiumTemplateFiller({template:c.CadmiumBrowser.lastTemplate,addHandler:m,container:p.n2a5});if(!p.cadtemplist){a("#wait",this.n2a5).show();a.post("/_cadmium/list",c.sign(x||{}),function(D){a("#wait",p.n2a5).hide();D=JSON.parse(D);if(D.result!="SUCCESS"){c.Dialog.n1f6(c.msg.list_failure+" : "+D.result,
c.msg.cancel);p.hide()}else{var E=a("<div></div>").attr("class","cadtemprow"),z=a("#cadtemplist").empty(),u=a("#minicadtemplist").empty();p.tempCount=0;p.cadtemplist=D.cadtemplist;_(p.cadtemplist).each(function(k,H){if(p.tempCount>=C&&p.tempCount%C===0){z.append(E);E=a("<div></div>").attr("class","cadtemprow")}H=a("<div></div>").attr("class","cadtempentry").data("cadtemp",k).data("index",H).append('<img src="'+k.thumburl+'" alt="'+k.name+'"/>').append('<div class="title" id="'+k.uid+'">'+k.name+"</div>").click(function(){t(a(this))}).hover(function(){e(p.prevEntryIndex);
p.currEntryIndex=parseInt(a(this).data("index"));g(p.currEntryIndex);p.prevEntryIndex=p.currEntryIndex},function(){p.currEntryIndex=parseInt(a(this).data("index"));e(p.prevEntryIndex)});var Q=a("<div></div>").attr("class","minicadentry");Q.data("name",k.name);Q.data("uid",k.uid);Q.data("cadtemp",k);Q.append('<img src="'+k.thumburl+'" alt="'+k.name+'"/>').append('<div class="title">'+k.name+"</div>").click(function(){p.n2a5.find("#cadtempfiller").CadmiumTemplateFiller({template:a(this).data("cadtemp"),
addHandler:m,container:p.n2a5});c.CadmiumBrowser.lastTemplate=a(this).data("cadtemp")}).hover(function(){a(this).children(".title").css("visibility","visible")},function(){a(this).children(".title").css("visibility","hidden")});u.append(Q);E.append(H);p.tempCount++});z.append(E);g(p.currEntryIndex)}})}a("#curtain").fadeIn();this.n2a5.show();g(p.currEntryIndex);a("#cadtemplist",this.n2a5).scrollTop(0);a("#minicadtemplist",this.n2a5).scrollLeft(0);B.show()},minimize:function(){j=0;this.n2a5.find("#cadtemplist").hide();
this.n2a5.find("#minicadContainer").show();this.n2a5.find("#minicadContainer #left").hide();this.n2a5.find("#minicadContainer #right").show();this.n2a5.find("#minicadtemplist").scrollLeft(0);e(this.currEntryIndex)},maximize:function(){j=0;c.cadmiumBrowser.currEntryIndex=0;c.cadmiumBrowser.prevEntryIndex=0;a("#minicadContainer",this.n2a5).hide();a("#details",this.n2a5).hide();a("#cadtemplist",this.n2a5).show().scrollTop(0);g(c.cadmiumBrowser.currEntryIndex)},hide:function(){j=0;a("#curtain").hide();
this.n2a5.find("#cadtempfiller").CadmiumTemplateFiller({addHandler:null});this.n2a5.hide();e(this.currEntryIndex);c.KBD.popHandler()}};c.CadmiumBrowser=h})(jQuery);
(function(a){function h(e){this.n2a5=e}var m=a.app,n=a.tin,d=n.C.center_align,b=n.C.min_align,g=n.C.max_align;h.prototype={show:function(e){function f(){j.n2a5.hide();a("#curtain").hide();m.KBD.popHandler();j.n2a5.find("#cadtempfiller").CadmiumTemplateFiller({addHandler:null})}var c=e.alignment,j=this;this.n2a5.show();a("#curtain").fadeIn();this.n2a5.find("#aligneditor").hide();this.n2a5.find("#alignprompt").hide();this.n2a5.find("#cadtempfiller").CadmiumTemplateFiller({uid:e.type,params:e.params,
alignment:e.alignment,showAlignmentPrompt:true,container:a("#cadtempeditor"),addText:m.msg.apply,addHandler:function(o,w){if(m.editor.getBackend()!=="WebGL"){m.cadmiumBrowser.hide();m.Dialog.n1f6(m.msg.webglreqmsg,m.msg.cancel)}else{m.Gui.n15e(m.msg.loading);f();a("#curtain").hide();a("#invisiblescreen").show();m.cadmiumCache.getMesh(o.uid,w.values,function(l){m.Gui.n15e();var B=new a.tin.Mesh3D(m.editor);B.n196(l.surfaces);e?m.editor._jq.trigger("oo.edit",{geometry:e,newmesh:B,newparams:w.values,
newalignment:c||{x:b,y:b,z:b}}):console.error("Geometry focus lost");a("#invisiblescreen").hide()},function(l){m.Gui.n15e();a("#invisiblescreen").hide();m.Dialog.n1f6(m.msg.error+": "+l,m.msg.cancel)})}}});var s=this.n2a5.find("#aligneditor");this.n2a5.find("#alignprompt").click(function(){var o=[];o[b]="min";o[g]="max";o[d]="center";s.find("input[name=xalign][value="+o[c.x]+"]").attr("checked",true);s.find("input[name=yalign][value="+o[c.y]+"]").attr("checked",true);s.find("input[name=zalign][value="+
o[c.z]+"]").attr("checked",true);j.n2a5.find("#cadtempfiller").hide();j.n2a5.find("#aligneditor").show();j.n2a5.find("#alignprompt").hide();j.n2a5.find(".closeIcon").hide()});this.n2a5.find("#aligneditor #done").click(function(){j.n2a5.find("#aligneditor").hide();j.n2a5.find("#cadtempfiller").show();j.n2a5.find("#alignprompt").show();var o={min:b,center:d,max:g};c={x:o[s.find("input[name=xalign]:checked").val()],y:o[s.find("input[name=yalign]:checked").val()],z:o[s.find("input[name=zalign]:checked").val()]};
j.n2a5.find(".closeIcon").show()});m.KBD.pushHandler({element:"#oowindow",handlers:[{key:"esc",func:f},{key:"return",func:function(){a(document).trigger("add_template")}}]});this.n2a5.find(".closeIcon").unbind("click");this.n2a5.find(".closeIcon").click(f)}};m.CEditor=h})(jQuery);
(function(a){var h={maximum:5,disabled:false,score:0,points:0,onclick:null,imgBlank:"/_images/ratingblank.png",imgDisabled:"/_images/ratingdisabled.png",imgSelected:"/_images/rating.png",imgWaiting:"/_images/wait16trans.gif"};a.fn.rating=function(m){var n=a.extend({},h,m);return a(this).each(function(){function d(f){for(var c=1;c<=n.maximum;c++)e.find("#rate"+c).attr("src",c<=f?n.imgSelected:n.imgBlank)}function b(){e.find("img").attr("src",n.disabled?n.imgDisabled:n.imgBlank)}var g=false,e=a(this);
a(this).find("#score").text(n.score.toFixed(1));b();n.disabled||d(n.points);if(n.disabled){a(this).find("img").unbind("mouseover");a(this).unbind("mouseleave");a(this).find("img").unbind("click")}else{a(this).find("img").mouseover(function(){if(!g){var f=a(this).attr("id");f=parseInt(/rate(\d+)/.exec(f)[1],10);d(f)}});a(this).mouseleave(function(){g||d(n.points)});a(this).find("img").click(function(){var f=a(this).attr("id");f=parseInt(/rate(\d+)/.exec(f)[1],10);if(n.onclick){g=true;e.find("img").attr("src",
n.imgWaiting);n.onclick(f,function(c,j,s){g=false;if(c){n.points=s;d(n.points);e.find("#score").text(j.toFixed(1))}else{b();d(n.points)}})}})}})}})(jQuery);
(function(a){var h={value:1,min:-Infinity,max:Infinity,onmin:function(){},onmax:function(){},onchange:function(){}};a.fn.dial=function(n){var d=a.extend({},h,n);return a(this).each(function(){var b=a(this);b.removeData();b.data("value",d.value);b.find(".dialvalue").text(d.value);b.find(".dialminus").unbind("click");b.find(".dialminus").click(function(){var g=parseInt(b.data("value"),10);if(g-1<d.min)d.onmin.call(b,b.attr("id"));else{g-=1;b.data("value",g);b.find(".dialvalue").text(g);d.onchange.call(b,
b.attr("id"),g)}});b.find(".dialplus").unbind("click");b.find(".dialplus").click(function(){var g=parseInt(b.data("value"),10);if(g+1>d.max)d.onmax.call(b,b.attr("id"));else{g+=1;b.data("value",g);b.find(".dialvalue").text(g);d.onchange.call(b,b.attr("id"),g)}})})};var m={values:{},onchange:function(){}};a.fn.dialgroup=function(n){var d=a.extend({},m,n);return a(this).each(function(){function b(){var e=g.find(".dial").map(function(){return parseInt(a(this).data("value"),10)});d.onchange(_(e).map(function(f){return f}))}
var g=a(this);g.find(".dial").each(function(){a(this).dial({value:d.values[a(this).attr("id")],onchange:b})})})};a.fn.resetdial=function(n){return a(this).each(function(){var d=a(this);d.data("value",n.value);d.find(".dialvalue").text(n.value)})};a.fn.resetdialgroup=function(n){return a(this).each(function(){a(this).find(".dial").each(function(){a(this).resetdial({value:n.values[a(this).attr("id")]})})})}})(jQuery);
(function(a){function h(n){this.n2a5=n}var m=a.app;h.prototype={update:function(n,d,b,g,e,f,c,j,s,o,w){a("#titlebar #name",this.n2a5).text(d?d:"<"+m.msg.newsketch+">");a("#titlebar #name",this.n2a5).data("namestring",d?d:"<"+m.msg.newsketch+">");if(b){var l;l=b===m.identity.n1e2?m.msg.you:g;a("#titlebar #author",this.n2a5).empty().append('<a class="loadlist" id="'+b+'">'+l+"</a>")}else a("#titlebar #author",this.n2a5).empty().text(m.msg.you);if(n){a("#minibar",this.n2a5).show();a("#minibar #roots",
this.n2a5).text(c.length);a("#minibar #branches",this.n2a5).text(j.length);a("#minibar #rating",this.n2a5).text(e.toFixed(1));m.searchbar.n2a5.css("margin-top","65px")}else{a("#minibar",this.n2a5).hide();m.searchbar.n2a5.css("margin-top","35px")}o?a("#minibar #lock",this.n2a5).attr("title",m.msg.private_sketch).attr("src","/_images/lock.png").show().tipsy():a("#minibar #lock",this.n2a5).attr("title",m.msg.cc_sketch).attr("src","/_images/cc.png").show().tipsy();a("#minibar #flag").addClass("inactive").unbind("click").click(function(){var B=
this;a.post("/_sketch/flag",{uid:n,flagged:true},function(C){JSON.parse(C).result=="SUCCESS"&&a(B).removeClass("inactive").addClass("active")})}).attr("title",m.msg.inappropriate).tipsy();a(".loadlist",this.n2a5).unbind("click");a(".loadlist",this.n2a5).click(function(){b===m.identity.n1e2?m.filebrowser.load(m.identity,true):m.filebrowser.load({state_:m.C.n211,n1f1:g,n1e2:b},true)}).css("cursor","pointer");a("#minibar #more",this.n2a5).unbind("click");a("#minibar #more",this.n2a5).click(function(){m.sketchdetail.load(n,
d,b,g,e,f,c,j,s,o,w)});this.n2a5.show()},setTitleDirty:function(n){var d=a("#titlebar #name").data("namestring");if(n)/\*$/.test(d)||a("#titlebar #name").text(d+"*");else/\*$/.test(d)&&a("#titlebar #name").text(d)}};m.n249=h})(jQuery);
(function(a){function h(){}function m(){return false}function n(){var u=a(this).attr("id");u&&a(document).trigger("sketch_load_requested",u)}function d(u,k){var H=u.thumburl;H=a("<img></img>").attr("src",H).each(function(){this.complete&&a(this).trigger("load")});var Q=a("<div></div>").attr("class","thumbentry").append('<div class="name">'+u.name+"</div>").append('<div class="user">'+u.user+"</div>");return a("<div></div>").attr("id",u.uid).attr("class","member").data("name",u.name).data("user",u.user).data("count",
k).append(H).click(n).mousedown(m).mouseup(m).css({paddingTop:G+"px",paddingBottom:G+"px"}).tipsy({fallback:Q,gravity:"e",html:true})}function b(){var u=0;a("#galleryContainer .member").each(function(){a(this).data("count",u);u++})}function g(){for(var u=0;u<C/3;u++){a("#galleryContainer .member:first").remove();n1a0+=1;endOffset+=1;if(n1a0==n208.length)n1a0=0;if(endOffset==n208.length)endOffset=0;galleryContainer.append(d(n208[endOffset],0))}b();galleryContainer.scrollTop(0);x=false;galleryContainer.animate({scrollTop:C/
3*(w+2*G)},{duration:500,queue:false,complete:function(){x=true}})}function e(){for(var u=0;u<C/3;u++){a("#galleryContainer .member:last").remove();n1a0-=1;endOffset-=1;if(n1a0==-1)n1a0=n208.length-1;if(endOffset==-1)endOffset=n208.length-1;galleryContainer.prepend(d(n208[n1a0],0))}b();galleryContainer.scrollTop(galleryContainer.get(0).scrollHeight+2*G);x=false;galleryContainer.animate({scrollTop:C/3*(w+2*G)},{duration:500,queue:false,complete:function(){x=true}})}function f(){endOffset=(n1a0+C)%
n208.length;if(C>n208.length)console.log("Not enough sketches in Gallery. Gallery Size = "+C+" Entry List = "+n208.length);else{for(var u=0;u<C;u++)galleryContainer.append(d(n208[u],u));n1a0=0;endOffset=C-1;o.append(l);o.append(galleryContainer);o.append(B);galleryContainer.scrollTop(A/2*(w+2*G));B.click(function(){x&&g()}).mousedown(m).mouseup(m);l.click(function(){x&&e()}).mousedown(m).mouseup(m)}}function c(){D=parseInt(a("#hideButton").css("height"),10);s.identity.premium_?h.load({bottomMargin:D+
t}):j(true)}function j(u){a.post("/_getad",s.sign({index:E,count:z}),function(k){var H=a(document).width(),Q=JSON.parse(k);E=Q.index;k=function(){a("#amazon").remove();var q=a("<div></div>").attr("id","amazon").html('<a href="'+Q.link+'" target="_blank"><img src="_images2/products/'+Q.imgname+'.jpg"/></a>').css({left:H+"px","margin-top":"-65px"});a("img",q).load(function(){if(/\.jpg$/.test(a(this).attr("src"))){a(this).removeAttr("width").removeAttr("height").css({width:"",height:"",margin:""});if(this.width>
160){var y=this.height,I=160/(1*this.width);this.width=160;this.height=I*y}this.height<160&&a(this).css({"margin-top":(160-this.height)/2+"px","margin-bottom":(160-this.height)/2+"px"});bottom_offset=160+D+t+p;q.css("bottom",D+t+"px");q.animate({left:"-="+(this.width+5+(80-this.width/2))+"px"});u===true&&h.load({bottomMargin:bottom_offset})}});a("body").append(q)};u===true?k():a("#amazon").fadeOut(k)});z++;setTimeout(j,s.C.adrefill_interval)}var s=a.app,o,w=124,l,B,C,G,A,x=true,t=2,p=2,D,E,z=0;h.load=
function(u){a.post("/_gallery/list",s.sign({}),function(k){k=JSON.parse(k);if(k.result=="SUCCESS"){n208=k.list;n1a0=0;galleryContainer=a("<div></div>").attr("id","galleryContainer");l=a("<div></div>").attr("class","arrow").attr("id","up");B=a("<div></div>").attr("class","arrow").attr("id","down");k=window.innerHeight-(u.bottomMargin+120+40+6);C=Math.min(n208.length,parseInt(k/w,10));A=2*C;G=parseInt((k-C*w)/(2*C),10);galleryContainer.css({height:(w+2*G)*C+"px",position:"relative",overflow:"hidden"});
C+=A;f();o.css({top:"120px"});o.show()}})};h.unloadPanel=function(u){var k=a("#identity"),H=a("#amazon"),Q=a(document).width()+300;o.animate({right:"-300px"},{complete:u});k.animate({right:"-300px"});H.animate({left:Q+"px"})};h.init=function(){o=a("#gallery");if(!s.identity.premium_||!s.config.isFullScreen)c()};s.Gallery=h})(jQuery);
(function(a){function h(){}app=a.app;h.n147=function(m){function n(){window.localStorage.removeItem("content");window.localStorage.removeItem("meta")}if(window.localStorage){var d=window.localStorage,b=d.getItem("content");if(b){var g;if(d=d.getItem("meta"))g=a.parseJSON(d);g||(g={persistence_:0,effort_:0});n();m&&m(b,g);return}}n();m&&m()};h.n1b4=function(m,n){if(window.localStorage){var d=window.localStorage;d.setItem("content",m.content);d.setItem("meta",JSON.stringify(m.meta))}n&&n()};h.n189=
function(m){a(document).trigger("sketch_save_started");if(tin_projectId)m.projectid=tin_projectId;a.ajax("/_sketch/save",{type:"POST",data:app.sign(m),timeout:6E4,success:function(n){n=JSON.parse(n);if(n.result!="SUCCESS")app.Dialog.n1f6(n.result,app.msg.cancel);else{var d=app.sketch.meta;d.uid_=n.uid;d.n294=JSON.parse(n.roots);d.n227=JSON.parse(n.branches);d.n1bf=n.avgrating;if(m.baseuid)d.baseuid_=m.baseuid;d.thumburl_=n.thumburl;d.private_=n.isprivate;d.tags_=n.tags;d.n1dd=app.identity.n1e2;d.n19e=
app.identity.n1f1;app.identity.n120(n.userpersistence);app.editor.setModelDirty(false);app.titlebox.update(d.uid_,d.name_,d.n1dd,d.n19e,d.n1bf,d.userpoints_,d.n294,d.n227,d.thumburl_,d.private_,d.tags_)}a(document).trigger("sketch_save_finished")},error:function(n,d,b){app.Dialog.n1f6(app.msg.failedsave+": "+d+", "+b,app.msg.cancel);a(document).trigger("sketch_save_finished")}})};h.deleteFromCloud=function(m,n){a.post("/_sketch/archive",app.sign({uid:m}),function(d){d=JSON.parse(d);n&&n(d.result)})};
h.n139=function(m,n){a(document).trigger("sketch_load_started");a.post("/_sketch/load",app.sign({uid:m}),function(d){d=JSON.parse(d);if(d.result!="SUCCESS"){app.Dialog.n1f6(d.result,app.msg.cancel);a(document).trigger("sketch_load_finished")}else{var b=d.content,g={};g.uid_=d.uid;g.baseuid_=d.baseuid;g.name_=d.name;g.n19e=d.author;g.n1dd=d.authorpid;g.private_=d.isPrivate;g.n294=JSON.parse(d.roots);g.n227=JSON.parse(d.branches);g.tags_=JSON.parse(d.tags);g.n1bf=d.avgrating;g.userpoints_=d.userpoints;
g.thumburl_=d.thumburl;g.effort_=0;g.persistence_=g.n1dd===app.identity.n1e2?d.persistence:0;a(document).trigger("sketch_load_finished");n&&n(b,g)}})};h.list=function(){};app.Store=h})(jQuery);
(function(a){function h(){var b=document.getElementById("voxelizer"),g=this;b.ondragover=function(){this.className="hover";return false};b.ondragend=function(){this.className="";return false};b.ondrop=function(e){this.className="";e.preventDefault();e=e.dataTransfer.files[0];var f=new FileReader;if(e.type.match("image.*")){f.onload=function(c){var j=document.createElement("img");j.onload=function(){n.editor.importPNG(this,parseInt(a("#voxelizer select[name=thickness]").val(),10),parseInt(a("#voxelizer select[name=resolution]").val(),
10));g.n164()};j.src=c.target.result};f.readAsDataURL(e);return false}else n.Dialog.n1f6(n.msg.notimgfile,n.msg.cancel)};a("#voxelizer #droparea input[id=imgfiles]").change(function(e){e=e.currentTarget.files[0];var f=new FileReader;if(e.type.match("image.*")){f.onload=function(c){var j=document.createElement("img");j.onload=function(){n.editor.importPNG(this,parseInt(a("#voxelizer select[name=thickness]").val(),10),parseInt(a("#voxelizer select[name=resolution]").val(),10));g.n164()};j.src=c.target.result};
f.readAsDataURL(e);return false}else n.Dialog.n1f6(n.msg.notimgfile,n.msg.cancel)});a("#voxelizer .closeIcon").click(function(){a("#voxelizer #droparea").show();a("#voxelizer #colorspectrum").hide();a("#voxelizer #colorspectrum #colorlist").empty();a("#voxelizer").hide()})}function m(b){var g=b.color,e=a(d);e.data("payload",b);e.find(".erasecolor").data("payload",b).data("action","remove").click(function(){var f=a(this).data("payload");if(a(this).data("action")=="remove"){n.editor.voxelizer.removeColor(f.color);
a(this).data("action","add");a(this).attr("src","/_images/addcube.png")}else{n.editor.voxelizer.addColor(f.color);a(this).data("action","remove");a(this).attr("src","/_images/eraser.png")}});e.find(".count").text(b.voxels.length);e.find(".preview").css("background","rgba("+g.r+","+g.g+","+g.b+","+g.a+")");return e}var n=a.app,d='<li> <span class="preview">&nbsp;&nbsp;&nbsp;&nbsp;</span> <span class="count"></span> <img class="erasecolor" src="/_images/eraser.png"/> </li>';h.prototype={show:function(){typeof window.FileReader===
"undefined"?n.Dialog.n1f6(n.msg.filereadernotsupported,n.msg.cancel):a("#voxelizer").show()},n164:function(){var b=n.editor.voxelizer.n1a5(),g=a("#voxelizer");g.find("#droparea").hide();g.find("#colorspectrum").show();var e=a("<ul></ul>");b.sort(function(f,c){return c.voxels.length-f.voxels.length});_(b).each(function(f){e.append(m(f))},this);g.find("#colorlist").css("overflow-y","scroll").append(e)}};n.n110=h})(jQuery);
(function(a){function h(){return false}function m(){if(f)return f;if(_.isArray(e))return f=g.editor.createTempn14d(e);else return e}function n(){if(f){g.editor.destroyTempn14d(f);f=null}}function d(c){function j(p){return Math.pow(10,p/100)/10}function s(p,D){D||(D=j(p));return{scaleX:c.find("#scaledim input[name=scaleX]").prop("checked")?D:1,scaleY:c.find("#scaledim input[name=scaleY]").prop("checked")?D:1,scaleZ:c.find("#scaledim input[name=scaleZ]").prop("checked")?D:1,scale:D}}function o(p){return p/
25}function w(p,D){D||(D=o(p));return{shearType:a("#sheardim input[name=shearType]:checked").attr("value"),shearRatio:D}}var l=this;this.n2a5=c;this.oowindow=c.find("#oowindow");this.border_proximity_threshold=0.1*Math.min(g.editor.width,g.editor.height);var B={slide:function(p,D){p=s(D.value);l.n2a5.find("#ratiobanner").html(p.scale.toFixed(2));g.editor._jq.trigger("oo.scale.continue",_.extend({geometry:m()},p))},start:function(){a(this).data("focused_geometry",m());l.oowindow.unbind("mousedown");
l.oowindow.unbind("mousemove");l.oowindow.unbind("mouseleave");l.oowindow.unbind("mouseup");g.editor._jq.trigger("oo.scale.start",{geometry:m()})},stop:function(p,D){l.oowindow.bind("mousedown",A);l.oowindow.bind("mousemove",x);l.oowindow.bind("mouseleave",t);l.oowindow.bind("mouseup",t);g.editor._jq.trigger("oo.scale.stop",_.extend({geometry:a(this).data("focused_geometry")},s(D.value)));a(this).removeData("focused_geometry");n();l.disable()},value:100,min:0,max:200},C={slide:function(p,D){l.n2a5.find("#degreebanner #degrees").html(D.value+
"&deg;");g.editor._jq.trigger("oo.rotate.continue",{geometry:m(),clockwise:D.value>0,angle:Math.abs(D.value)})},start:function(){a(this).data("focused_geometry",m());l.oowindow.unbind("mousedown");l.oowindow.unbind("mousemove");l.oowindow.unbind("mouseleave");l.oowindow.unbind("mouseup");g.editor._jq.trigger("oo.rotate.start",{geometry:m()})},stop:function(p,D){l.oowindow.bind("mousedown",A);l.oowindow.bind("mousemove",x);l.oowindow.bind("mouseleave",t);l.oowindow.bind("mouseup",t);g.editor._jq.trigger("oo.rotate.stop",
{geometry:a(this).data("focused_geometry"),clockwise:D.value>0,angle:Math.abs(D.value)});a(this).removeData("focused_geometry");n();l.disable()},value:0,min:-180,max:180},G={slide:function(p,D){p=w(D.value);l.n2a5.find("#ratiobanner").html(p.shearRatio.toFixed(2));g.editor._jq.trigger("oo.shear.continue",_.extend({geometry:m()},p))},start:function(){a(this).data("focused_geometry",m());l.oowindow.unbind("mousedown");l.oowindow.unbind("mousemove");l.oowindow.unbind("mouseleave");l.oowindow.unbind("mouseup");
g.editor._jq.trigger("oo.shear.start",{geometry:m()})},stop:function(p,D){l.oowindow.bind("mousedown",A);l.oowindow.bind("mousemove",x);l.oowindow.bind("mouseleave",t);l.oowindow.bind("mouseup",t);g.editor._jq.trigger("oo.shear.stop",_.extend({geometry:m()},w(D.value)));a(this).removeData("focused_geometry");n();l.disable()},value:0,min:-100,max:100};this.n2a5.find("#bottombar #stdrotate .stdrotatecontrol").click(function(){var p=a(this).attr("id");g.editor._jq.trigger("oo.rotate.standard",{geometry:m(),
clockwise:p.indexOf("plus")==0,angle:parseInt(/(plus|minus)(\d+)/.exec(p)[2],10)});n();l.disable()});this.n2a5.find("#oorotate").click(function(){l.n2a5.find("#rotateslider").slider(C);l.n2a5.find("#bottombar .xformbar").hide();l.n2a5.find("#ratiobanner").hide();l.n2a5.find("#valignbar, #halignbar").hide();l.n2a5.find("#bottombar #stdrotate").show();if(e.geomType==b.C.n14e||e.geomType==b.C.n117||_.isArray(e)){l.n2a5.find("#bottombar #rotateslider").show();l.n2a5.find("#degreebanner").show();l.n2a5.find("#bottombar #rotateslider").slider({value:0});
var p=l.n2a5.find("#bottombar #rotateslider").slider("option","value");l.n2a5.find("#degreebanner #degrees").html(p+"&deg;")}l.n2a5.find("#bottombar").show()}).mousedown(h).mouseup(h);this.n2a5.find("#ooscale").click(function(){l.n2a5.find("#rotateslider").slider(B);l.n2a5.find("#bottombar .xformbar").hide();l.n2a5.find("#degreebanner").hide();l.n2a5.find("#valignbar, #halignbar").hide();l.n2a5.find("#bottombar #rotateslider").slider({value:100});l.n2a5.find("#bottombar #rotateslider").show();l.n2a5.find("#bottombar #scaledim").show();
l.n2a5.find("#bottombar #scaledim input").prop("checked",true);l.n2a5.find("#ratiobanner").show();var p=l.n2a5.find("#bottombar #rotateslider").slider("option","value");l.n2a5.find("#ratiobanner").html(j(p).toFixed(2));l.n2a5.find("#ratiobanner").data("xformtype","scale");l.n2a5.find("#bottombar").show()}).mousedown(h).mouseup(h);this.n2a5.find("#ooshear").click(function(){l.n2a5.find("#rotateslider").slider(G);l.n2a5.find("#bottombar .xformbar").hide();l.n2a5.find("#degreebanner").hide();l.n2a5.find("#valignbar, #halignbar").hide();
l.n2a5.find("#bottombar #rotateslider").slider({value:0});l.n2a5.find("#bottombar #rotateslider").show();l.n2a5.find("#bottombar #sheardim").show();l.n2a5.find("#bottombar #sheardim input[value=horz]").prop("checked",true);l.n2a5.find("#ratiobanner").show();var p=l.n2a5.find("#bottombar #rotateslider").slider("option","value");l.n2a5.find("#ratiobanner").html(o(p).toFixed(2));l.n2a5.find("#ratiobanner").data("xformtype","shear");l.n2a5.find("#bottombar").show()}).mousedown(h).mouseup(h);this.n2a5.find("#degreebanner").click(function(){l.hide();
var p=m();g.Dialog.n1be(g.msg.rotateangle+"(&deg;)",g.msg.rotate,g.msg.cancel,function(D){_.isUsableNumber(parseInt(D,10))?g.editor._jq.trigger("oo.rotate.standard",{geometry:p,clockwise:parseInt(D,10)>0,angle:Math.abs(parseInt(D,10))}):g.Dialog.n1f6(g.msg.invalidinput,g.msg.cancel);n();l.disable()},function(){})});this.n2a5.find("#ratiobanner").click(function(){l.hide();var p=a(this).data("xformtype"),D=p=="scale"?g.msg.scalefactor:g.msg.shearfactor,E=p=="scale"?g.msg.scale:g.msg.shear,z=m();g.Dialog.n1be(D,
E,g.msg.cancel,function(u){if(_.isUsableNumber(parseFloat(u)))p=="scale"?g.editor._jq.trigger("oo.scale.stop",_.extend({geometry:z},s(null,parseFloat(u)))):g.editor._jq.trigger("oo.shear.stop",_.extend({geometry:z},w(null,parseFloat(u))));else g.Dialog.n1f6(g.msg.invalidinput,g.msg.cancel);n();l.disable()},function(){})});this.n2a5.find("#bottombar #flipbar #oovflip").click(function(){g.editor._jq.trigger("oo.flip",{geometry:m(),horizFlip:false});n();l.disable()}).mousedown(h).mouseup(h);this.n2a5.find("#bottombar #flipbar #oohflip").click(function(){g.editor._jq.trigger("oo.flip",
{geometry:m(),horizFlip:true});n();l.disable()}).mousedown(h).mouseup(h);this.n2a5.find("#ooflip").click(function(){l.n2a5.find("#bottombar .xformbar").hide();l.n2a5.find("#degreebanner").hide();l.n2a5.find("#ratiobanner").hide();l.n2a5.find("#valignbar, #halignbar").hide();l.n2a5.find("#bottombar #flipbar").show();l.n2a5.find("#bottombar").show()}).mousedown(h).mouseup(h);this.n2a5.find("#ooclone").click(function(){g.editor._jq.trigger("oo.clone",{geometry:e});l.disable()}).mousedown(h).mouseup(h);
this.n2a5.find("#ooungroup").click(function(){g.editor._jq.trigger("oo.ungroup",{geometry:e});l.disable()}).mousedown(h).mouseup(h);this.n2a5.find("#oogroup").click(function(){g.editor._jq.trigger("oo.group",{geometry:e});l.disable()}).mousedown(h).mouseup(h);this.n2a5.find("#oo2x").click(function(){g.editor._jq.trigger("oo.2x",{geometry:e});l.disable()}).mousedown(h).mouseup(h);this.n2a5.find("#oodelete").click(function(){g.editor._jq.trigger("oo.delete",{geometry:e});l.disable()}).mousedown(h).mouseup(h);
this.n2a5.find("#ooedit").click(function(){if(e.isCSG){g.ceditor=new g.CEditor(a("#cadtempeditor"));g.ceditor.show(e);l.disable()}else{l.n2a5.find("#bottombar .xformbar").hide();l.n2a5.find("#bottombar #oosmooth").show();l.n2a5.find("#bottombar").show()}}).mousedown(h).mouseup(h);this.n2a5.find("#valignbar #topalign").click(function(){g.editor._jq.trigger("oo.topalign",{geometry:m()});n();l.disable()}).mousedown(h).mouseup(h);this.n2a5.find("#valignbar #bottomalign").click(function(){g.editor._jq.trigger("oo.bottomalign",
{geometry:m()});n();l.disable()}).mousedown(h).mouseup(h);this.n2a5.find("#valignbar #vcenteralign").click(function(){g.editor._jq.trigger("oo.vcenteralign",{geometry:m()});n();l.disable()}).mousedown(h).mouseup(h);this.n2a5.find("#halignbar #leftalign").click(function(){g.editor._jq.trigger("oo.leftalign",{geometry:m()});n();l.disable()}).mousedown(h).mouseup(h);this.n2a5.find("#halignbar #rightalign").click(function(){g.editor._jq.trigger("oo.rightalign",{geometry:m()});n();l.disable()}).mousedown(h).mouseup(h);
this.n2a5.find("#halignbar #hcenteralign").click(function(){g.editor._jq.trigger("oo.hcenteralign",{geometry:m()});n();l.disable()}).mousedown(h).mouseup(h);var A=function(p,D){a(this).css("cursor","url(/_cursors/hand-closed.png), auto");p=D&&D.ev?D.ev:p;g.editor._jq.trigger("oo.move.start",{geometry:m(),ev:p});a(this).data("inmotion",true);return false},x=function(p){if(a(this).data("inmotion")){a(this).data("motionhappened",true);g.editor._jq.trigger("oo.move.continue",{geometry:m(),ev:p});if(p=
m().get2dextents(g.editor)){p=l.extents2css(p);a(this).css(p.oow);l.n2a5.css(p.wrapper)}return false}},t=function(p){if(a(this).data("inmotion")){a(this).css("cursor","url(/_cursors/hand-open.png), auto");g.editor._jq.trigger("oo.move.stop",{geometry:m(),ev:p});n();a(this).removeData("start");a(this).removeData("inmotion");a(this).data("motionhappened");a(this).removeData("motionhappened");return false}};this.oowindow.mousedown(A);this.oowindow.mousemove(x);this.oowindow.mouseup(t);this.oowindow.mouseleave(t)}
var b=a.tin,g=a.app,e=null,f=null;d.prototype={extents2css:function(c){var j=c.xmax-c.xmin,s=c.ymax-c.ymin,o=Math.max(j,238),w=Math.max(s,128);j=(o-j)/2;s=(w-s)/2;this.xmax=c.xmax+j;this.xmin=c.xmin-j;this.ymax=c.ymax+s;this.ymin=c.ymin-s;return{oow:{top:28,left:28,width:this.xmax-this.xmin,height:this.ymax-this.ymin},wrapper:{top:this.ymin-28,left:this.xmin-28,width:this.xmax-this.xmin+28,height:this.ymax-this.ymin+56},valignbar:{top:28,height:this.ymax-this.ymin},halignbar:{width:this.xmax-this.xmin,
left:28},topbar:{width:this.xmax-this.xmin,left:28},bottombar:{width:this.xmax-this.xmin,left:28}}},show:function(c,j){if(this.isEnabled){g.Gui.hide_biginfo();j&&this.oowindow.trigger("mousedown",{ev:c.ev});this.oowindow.show();this.n2a5.show()}},enable:function(c){this.isEnabled=true;g.Gui.show_biginfo(g.msg.click4controls);var j=this.extents2css(c.extents);this.oowindow.css(j.oow);this.n2a5.css(j.wrapper);this.n2a5.find("#valignbar").css(j.valignbar);this.n2a5.find("#halignbar").css(j.halignbar);
this.n2a5.find("#topbar").css(j.topbar);this.n2a5.find("#bottombar").css(j.bottombar);e=c.geometry;if(_.isArray(e)&&e.length>1){this.n2a5.find("#ooedit").hide();this.n2a5.find("#oosmooth").hide();this.n2a5.find("#rotateslider").hide();this.n2a5.find("#degreebanner").hide();this.n2a5.find("#ratiobanner").hide();this.n2a5.find("#oogroup").show();this.n2a5.find("#ooungroup").hide();this.n2a5.find("#oo2x").hide();this.n2a5.find("#ooclone").hide();this.n2a5.find("#oodelete").show();this.n2a5.find("#ooscale").show();
this.n2a5.find("#ooshear").show()}else{this.n2a5.find("#valignbar").hide();this.n2a5.find("#halignbar").hide();if(_.isArray(e))e=e[0];this.n2a5.find("#oosmooth").dial({value:e.smoothness,min:0,max:b.C.max_smoothness,onchange:function(s,o){g.editor._jq.trigger("oo.smooth",{geometry:e,smoothness:o})}}).mousedown(h).mouseup(h);c=["x","y","z"][e.n1a9.view.n1b5];this.n2a5.find("#degreebanner #axisicon").attr("src","/_images/"+c+"rotate.png");this.n2a5.find("#oosmooth").hide();this.n2a5.find("#rotateslider").hide();
this.n2a5.find("#degreebanner").hide();this.n2a5.find("#ratiobanner").hide();this.n2a5.find("#oogroup").hide();this.n2a5.find("#ooungroup").hide();this.n2a5.find("#oodelete").show();switch(e.geomType){case b.C.n0b2:this.n2a5.find("#oo2x").show();this.n2a5.find("#ooclone").hide();this.n2a5.find("#ooedit").show();this.n2a5.find("#ooscale").hide();this.n2a5.find("#ooshear").hide();break;case b.C.n14e:this.n2a5.find("#oo2x").hide();this.n2a5.find("#ooclone").show();this.n2a5.find("#ooedit").show();this.n2a5.find("#ooscale").show();
this.n2a5.find("#ooshear").show();break;case b.C.n117:this.n2a5.find("#oo2x").hide();this.n2a5.find("#ooclone").show();this.n2a5.find("#ooungroup").show();this.n2a5.find("#ooedit").hide();this.n2a5.find("#ooscale").show();this.n2a5.find("#ooshear").show();break}}},disable:function(){this.isEnabled=false;e=null;g.Gui.hide_biginfo();this.hide()},hide:function(){this.oowindow.hide();this.n2a5.hide();this.n2a5.find("#bottombar").hide();this.oowindow.removeData()},deleteFocusedGeometry:function(){e&&g.editor._jq.trigger("oo.delete",
{geometry:e});this.disable()}};g.OOWindow=d})(jQuery);
(function(a){function h(g){var e={query:a("input",b.searchbar.n2a5).val(),offset:b.searchbar.offset,limit:10,filter:g},f,c,j=a("<div></div>").attr("id","wait").append('<img src="/_images/wait30trans.gif"/>');if(g=="users"){f=a("#user_results");c=a("#sketch_results")}else if(g=="sketches"){f=a("#sketch_results");c=a("#user_results")}f.append(j);a.ajax({type:"POST",url:"/_search",data:e,success:function(s){s=JSON.parse(s);f.find("#wait").remove();c.empty();b.searchbar.offset+=10;b.searchbar.n2a5.find(".more").remove();
n(s)}})}function m(){b.searchbar.MAX_HEIGHT<a("#search_results").height()&&a("#search_results").height(b.searchbar.MAX_HEIGHT)}function n(g){if(_.isEmpty(g.sketches)&&_.isEmpty(g.users))a("#no_results").text(b.msg.no_results).show();else{a("#no_results").hide();_.each(g.sketches,function(f){var c=a("<span></span>").attr("class","search_title").text(f.name),j=a("<img></img>").attr("src",f.thumburl),s=a("<span></span>").attr("class","sketch_author").text(f.author);f=a("<div></div>").attr("class","search_entries").data("uid",
f.uid).append(j).append(c).append(s).click(function(){var o=a(this).data("uid");b.searchbar.hide(function(){a(document).trigger("sketch_load_requested",o)})});m();a("#sketch_results").append(f)});if(b.searchbar.n2a5.find("#sketch_results").children(".search_entries").length==b.searchbar.offset){var e=a("<div></div>").text("more").attr("class","more");e.click(function(){h("sketches")});a("#sketch_results").append(e)}_.each(g.users,function(f){var c=a("<span></span>").attr("class","search_title").html('<a href="/_user/"'+
f.profile_id+">"+f.nickname+"</a>"),j=a("<img></img>").attr("src",f.thumburl),s=a("<span></span>").attr("class","sketches_preview");_.each(f.sketches,function(o){o=a("<img></img>").attr("src",o.thumburl).attr("title",o.name);s.append(o)});f=a("<div></div>").attr("class","search_entries").append(j).append(c).append(s);m();a("#user_results").append(f)});if(b.searchbar.n2a5.find("#user_results").children(".search_entries").length==b.searchbar.offset){g=a("<div></div>").text("more").attr("class","more");
g.click(function(){h("users")});a("#user_results").append(g)}}}function d(g){var e=this;this.n2a5=g;e.enabled=false;g=a("#zoombar").height()+parseInt(a("#zoombar").css("bottom"),10);e.MAX_HEIGHT=a(document).height()-g-120-30;a("input",this.n2a5).focus(function(){a(this).css("background-color","#fff")});a("#do_search",this.n2a5).click(function(){a("#search_results",e.n2a5).height("");if(e.enabled){e.offset=0;var f={query:a("input",e.n2a5).val(),offset:e.offset,limit:3,filter:"all"};if(!f.query||f.query.trim().length==
0)a("input",e.jquery).css("background-color","#f88");else{var c=a("<div></div>").attr("id","wait").append('<img src="/_images/wait30trans.gif"/>');a("#search_results",e.n2a5).children().empty();a("#search_results",e.n2a5).show().append(c);a.ajax({type:"POST",url:"/_search",data:f,success:function(j){j=JSON.parse(j);a("#search_results").find("#wait").remove();e.offset+=3;n(j)}})}}else e.load()});a("#exit_search",this.n2a5).click(function(){e.hide()})}var b=a.app;d.prototype={load:function(){var g=
this;g.enabled=true;b.KBD.pushHandler({element:"#searchbar",handlers:[{key:"return",func:function(){a("#do_search",g.n2a5).trigger("click")}}]});a("#searchbox",this.n2a5).show();a("input",this.n2a5).show(100,function(){a(this).focus().val("")})},hide:function(g){var e=this;e.enabled=false;b.KBD.popHandler();a("#search_results",e.n2a5).hide();a("input",this.n2a5).val("").hide(100,function(){a(this).blur();a("#searchbox",e.n2a5).hide();g&&g()})}};b.SearchBar=d})(jQuery);
(function(a){function h(q){return q.target&&(q.target.nodeName.toLowerCase()=="input"||q.target.nodeName.toLowerCase()=="textarea")}function m(){a("#alpha").jPicker({window:{position:{x:"screenCenter",y:"100px"},expandable:true,effects:{type:"fade"},alphaSupport:true},color:{active:new a.jPicker.Color(k.editor.n10e())},images:{clientPath:"/_images/jpicker/",picker:{file:"empty.png",width:0,height:0,padding:0,margin:0},doColorIcon:false}},function(q){k.editor.setCurrentColor(q.val("rgba"));p.n0a9()},
null,null,function(){});p.n0a9();a("#alpha1").jPicker({window:{position:{x:"screenCenter",y:"100px"},expandable:true,effects:{type:"fade"},alphaSupport:false},color:{mode:"v",active:new a.jPicker.Color(k.editor.getLightColor(H.C.lighttype_directional))},images:{clientPath:"/_images/jpicker/",picker:{file:"empty.png",width:0,height:0,padding:0,margin:0},doColorIcon:false}},function(q){q=q.val("rgba");k.lightOptions.setLightColor(H.C.lighttype_directional,q)},null,null,function(){});a("#alpha2").jPicker({window:{position:{x:"screenCenter",
y:"100px"},expandable:true,effects:{type:"fade"},alphaSupport:false},color:{mode:"v",active:new a.jPicker.Color(k.editor.getLightColor(H.C.lighttype_point))},images:{clientPath:"/_images/jpicker/",picker:{file:"empty.png",width:0,height:0,padding:0,margin:0},doColorIcon:false}},function(q){q=q.val("rgba");k.lightOptions.setLightColor(H.C.lighttype_point,q)},null,null,function(){});a("#alpha3").jPicker({window:{position:{x:"screenCenter",y:"100px"},expandable:true,effects:{type:"fade"},alphaSupport:false},
color:{mode:"v",active:new a.jPicker.Color(k.editor.getLightColor(H.C.lighttype_ambient))},images:{clientPath:"/_images/jpicker/",picker:{file:"empty.png",width:0,height:0,padding:0,margin:0},doColorIcon:false}},function(q){q=q.val("rgba");k.lightOptions.setLightColor(H.C.lighttype_ambient,q)},null,null,function(){});a("#alpha4").jPicker({window:{position:{x:"screenCenter",y:"100px"},expandable:true,effects:{type:"fade"},alphaSupport:false},color:{mode:"v",active:new a.jPicker.Color(k.editor.getBackgroundColor())},
images:{clientPath:"/_images/jpicker/",picker:{file:"empty.png",width:0,height:0,padding:0,margin:0},doColorIcon:false}},function(q){q=q.val("rgb");k.lightOptions.setBackgroundColor(q)},null,null,function(){})}function n(){k.KBD.pushHandler({element:"#canvas",handlers:[{key:"shift+/",func:function(){w()}},{key:"ctrl+n",func:function(){s()}},{key:"ctrl+s",func:function(){c()}},{key:"ctrl+o",func:function(){j()}},{key:"ctrl+a",func:function(){e()}},{key:"esc",func:function(){a("#vtoolbar .button").removeClass("focusaction");
a("#vtoolbar #rotate").addClass("focusaction");k.editor.resetState();k.oowindow.disable()}},{key:"del",func:function(){k.oowindow.deleteFocusedGeometry()}},{key:"a",func:function(q){if(h(q))return true;a("#vtoolbar .button").removeClass("focusaction");a("#vtoolbar #add").addClass("focusaction");k.editor.setCurrentGeometry(null);k.editor.setAction(H.C.n1d1);k.oowindow.hide();return false}},{key:"x",func:function(q){if(h(q))return true;a("#vtoolbar .button").removeClass("focusaction");a("#vtoolbar #extrude").addClass("focusaction");
k.editor.setAction(H.C.n136);k.oowindow.hide();return false}},{key:"e",func:function(q){if(h(q))return true;a("#vtoolbar .button").removeClass("focusaction");a("#vtoolbar #remove").addClass("focusaction");k.editor.setAction(H.C.n165);k.oowindow.hide();return false}},{key:"c",func:function(q){if(h(q))return true;a("#vtoolbar .button").removeClass("focusaction");a("#vtoolbar #color").addClass("focusaction");k.editor.setAction(H.C.n16b);k.oowindow.hide();return false}},{key:"r",func:function(q){if(h(q))return true;
a("#vtoolbar .button").removeClass("focusaction");a("#vtoolbar #rotate").addClass("focusaction");k.editor.setAction(H.C.n177);return false}},{key:"up",func:function(){k.editor.adjustView(H.C.cam_view_delta_top)}},{key:"left",func:function(){k.editor.adjustView(H.C.cam_view_delta_left)}},{key:"down",func:function(){k.editor.adjustView(H.C.cam_view_delta_bottom)}},{key:"right",func:function(){k.editor.adjustView(H.C.cam_view_delta_right)}},{key:"ctrl+z",func:function(){a("#undo").data("enabled")&&k.editor.undo()}},
{key:"ctrl+y",func:function(){a("#redo").data("enabled")&&k.editor.redo()}},{key:"ctrl+p",func:f},{key:"ctrl+up",func:function(){k.editor.adjustView(H.C.cam_view_top)}},{key:"ctrl+down",func:function(){k.editor.adjustView(H.C.cam_view_bottom)}},{key:"ctrl+left",func:function(){k.editor.adjustView(H.C.cam_view_left)}},{key:"ctrl+right",func:function(){k.editor.adjustView(H.C.cam_view_right)}},{key:"shift+up",func:function(){k.editor.adjustView(H.C.cam_view_front)}},{key:"shift+down",func:function(){k.editor.adjustView(H.C.cam_view_back)}},
{key:"s",func:function(){k.editor.setAction(H.C.n148)}},{key:"ctrl+k",func:function(q){if(h(q))return true;k.debug()}},{key:"ctrl+j",func:function(){k.admin&&k.Dialog.n1be("Admin command",k.msg.ok,k.msg.cancel,k.admin.shell)}},{key:"/",func:function(){k.searchbar.load()}}]})}function d(){a("#add").click(function(){a("#vtoolbar .button").removeClass("focusaction");a(this).addClass("focusaction");k.editor.setCurrentGeometry(null);k.editor.setAction(H.C.n1d1);return false});a("#extrude").click(function(){a("#vtoolbar .button").removeClass("focusaction");
a(this).addClass("focusaction");k.editor.setAction(H.C.n136);return false});a("#remove").click(function(){a("#vtoolbar .button").removeClass("focusaction");a(this).addClass("focusaction");k.editor.setAction(H.C.n165);return false});a("#select").click(function(){a("#vtoolbar .button").removeClass("focusaction");a(this).addClass("focusaction");k.editor.setAction(H.C.n148);return false});a("#color").click(function(){a("#vtoolbar .button").removeClass("focusaction");a(this).addClass("focusaction");k.editor.setAction(H.C.n16b);
return false});a("#colorpick").click(function(){a("#vtoolbar .button").removeClass("focusaction");a(this).addClass("focusaction");k.editor.setAction(H.C.n0f0);return false});a("#rotate").click(function(){a("#vtoolbar .button").removeClass("focusaction");a(this).addClass("focusaction");k.editor.setAction(H.C.n177);return false});a("#projn").click(f);a("#mirror").click(function(){k.editor.setMirrorOn(!k.editor.isMirrorOn());a(this).css("backgroundImage","url(/_images/"+(k.editor.isMirrorOn()?"mirroron":
"mirroroff")+".png)")});a("#mirror").css("backgroundImage","url(/_images/"+(k.editor.isMirrorOn()?"mirroron":"mirroroff")+".png)");a("#grid").click(function(){k.editor.setGridOn(!k.editor.isGridOn());a(this).css("backgroundImage","url(/_images/"+(k.editor.isGridOn()?"gridon":"gridoff")+".png)")});a("#grid").css("backgroundImage","url(/_images/"+(k.editor.isGridOn()?"gridon":"gridoff")+".png)");a("#snap2grid").click(function(){if(k.editor.getSnapToGrid()){a(this).css("backgroundImage","url(/_images/snap2gridOff.png)");
k.editor.setSnapToGrid(false)}else{a(this).css("backgroundImage","url(/_images/snap2gridOn.png)");k.editor.setSnapToGrid(true)}});a("#snap2grid").css("backgroundImage","url(/_images/snap2grid"+(k.editor.getSnapToGrid()?"On":"Off")+".png)");if(k.editor.getBackend()=="WebGL")a("#light").mouseover(function(q){k.lightOptions.show(q);a("#cameraoptions").hide();return false});else{a("#light").remove();a("#snap2grid").remove();a("#select").remove()}a("#camera").mouseover(function(q){G(q);return false});
a("#cameraoptions").mouseenter(function(){Q=true;return false});a("#cameraoptions").mouseleave(function(){return Q=false});a(".camoption").click(function(){k.Controller.n0ee(a(this).attr("id"));return false});a("#cameraoptions #home").click(function(){k.editor.resetCamera();a("#cameraoptions").hide();return false});a("#zoomin").click(function(){k.oowindow.hide();k.editor.zoomIn()});a("#zoomout").click(function(){k.oowindow.hide();k.editor.zoomOut()});a("#colorpalette .ocolor").click(function(){a("#colorpalette .ocolor").removeClass("ocolorsel");
a(this).addClass("ocolorsel");k.editor.setCurrentColor(a(this).data("color"));k.editor.action!==H.C.n1d1&&k.editor.action!==H.C.n136&&k.editor.setAction(H.C.n16b);return false});a("#colorp").click(function(){a.jPicker.List[0].show();return false});a("#new").click(s);a("#save").click(c);a("#saveas").click(function(){k.Controller.n169();return false});a("#export").click(function(){if(k.sketch.meta.uid_){var q=k.sketch.meta;k.sketchdetail.load(q.uid_,q.name_,q.n1dd,q.n19e,q.n1bf,q.userpoints_,q.n294,
q.n227,q.thumburl_,q.private_)}else k.Dialog.n1f6(k.msg.unsaved_warning_1,k.msg.cancel);return false});a("#import").click(function(){k.voxdlg.show()});a("#open").click(j);a("#help").click(w);a("#settings").click(l);a("#hideButton").click(b);a("#unmaximize").click(function(){k.config.isFullScreen=false;window.location.reload()});a(document).bind("sketch_load_requested",k.Controller.n1cb);a("#leaderboard_launcher").click(function(){k.leaderboard.show()});g();a(document).bind("contextmenu",function(){return false})}
function b(){if(!(k.identity.premium_&&k.config.isFullScreen))if(k.identity.state_==k.C.n285)if(k.identity.premium_){k.config.isFullScreen=true;k.Gallery.unloadPanel(function(){window.location.reload()})}else k.Gui.showPremiumSubscription();else k.Gui.n157()}function g(){a("#addgeomtoolbar #addgeom").click(e)}function e(){k.cadmiumBrowser.show();return false}function f(){if(k.editor.getProjection()==H.C.proj_perspective){k.editor.performProjection(H.C.proj_orthographic);a("#projn").css("backgroundImage",
"url(/_images/ortho.png)")}else{k.editor.performProjection(H.C.proj_perspective);a("#projn").css("backgroundImage","url(/_images/persp.png)")}return false}function c(){k.Controller.n1ba();return false}function j(){k.identity.state_==k.C.n285?k.filebrowser.load(k.identity,false):k.Gui.n157();return false}function s(){if(k.editor.isModelDirty())k.Dialog.n1f6(k.msg.unsaved_warning,k.msg.yes,k.msg.no,function(){k.Controller.n22a();a(document).trigger("sketch_loaded")});else{k.Controller.n22a();a(document).trigger("sketch_loaded")}return false}
function o(){k.KBD.popHandler();a("#helpscreen").hide()}function w(){k.KBD.pushHandler({element:"#helpscreen",handlers:[{key:"esc",func:function(){o()}}]});if(!a("#helpscreen").is(":visible")){var q=k.msg.using+" "+k.editor.getBackend()+" (v"+tin_appVersion+")";if(k.cachingStarted)q+=k.cacheProgress;a("#helpscreen #debugmsg").text(q);a("#helpscreen").fadeIn();a("#helpscreen .closeIcon").unbind("click").click(o)}}function l(){a("#helpscreen").is(":visible")&&o();a("#settingscreen").fadeIn();a("#settingscreen").find("#tempcache_reset").unbind("click").bind("click",
function(){k.CadmiumCache.clear();B();k.Dialog.n1f6(k.msg.tempcache_cleared,k.msg.ok)});a("#settingscreen").find("#localstorage_reset").unbind("click").bind("click",function(){window.localStorage.clear();B();k.Dialog.n1f6(k.msg.localstorage_cleared,k.msg.ok)});k.KBD.pushHandler({element:"#settingscreen",handlers:[{key:"esc",func:B}]});a("#settingscreen .closeIcon").unbind("click").click(B)}function B(){k.KBD.popHandler();a("#settingscreen").hide()}function C(){var q=a("#statscreen"),y=k.CadmiumCache.stats;
if(y.totalReq){q.find("#localhits").text(parseInt(100*y.localhit/y.totalReq,10)+"%");q.find("#s3hits").text(parseInt(100*y.s3hit/y.totalReq,10)+"%");q.find("#factoryhits").text(parseInt(100*y.factoryhit/y.totalReq,10)+"%");q.find("#s3latency").text(y.s3latency.toFixed(2)+" msec");q.find("#factorylatency").text(y.factorylatency.toFixed(2)+" msec")}else q.find("#localhits, #s3hits, #factoryhits, #s3latency, #factorylatency").text("Not used");q.find("#cachesize").text(k.C.cadCacheSizeLimit+" entries");
if(typeof performance!="undefined"&&performance.memory&&performance.memory.totalJSHeapSize){y=performance.memory.usedJSHeapSize;var I=performance.memory.totalJSHeapSize;q.find("#jsheapmem").text((y/1048576).toFixed(2)+" MB ("+(100*y/I).toFixed(2)+"%)")}else q.find("#jsheapmem").html("<strong>Not found</strong> use --enable-memory-info");q.find("#glbufsize").text((H.stats.bufsize/1024).toFixed(2)+" KB");q.click(function(){a(this).fadeOut()});q.show()}function G(q){a("#cameraoptions").css("top",q.clientY-
60+"px").show();a("#lightoptions").hide();setTimeout(A,3E3)}function A(){Q?setTimeout(A,3E3):a("#cameraoptions").hide()}function x(q,y){var I=q.getContext("2d");I.clearRect(0,0,q.width,q.height);I.beginPath();I.strokeStyle="#bbb";I.lineWidth=36;I.arc(80,80,52,Math.PI*1.5,Math.PI*(y+270)/180);I.stroke();I.closePath()}function t(){_(k.tooltips).each(function(q,y){_(q).each(function(I,J){a("#"+J).attr("title",I).tipsy({gravity:y,html:true})},this)},this)}function p(){}function D(){_.each(a(".sectiontitle",
"#tutorialdialog"),function(q,y){a(q).html(k.msg.tut_title[y])});_.each(a(".row","#tutorialdialog"),function(q,y){a(".rightcolumn",q).html(k.msg.tut_row[y])})}function E(){a("#welcome","#homedialog").html(k.msg.home_welcome);_.each(k.msg.home_titles,function(q,y){a("#title"+y,"#homedialog").html(q)});_.each(k.msg.home_contents,function(q,y){a("#content"+y,"#homedialog").html(q)});a("#start","#homedialog").html(k.msg.home_start);a("#quicktutorial","#homedialog").html(k.msg.home_quicktut)}function z(q){console.log(q);
a.post("/_checkcreds",{backend:k.editor.getBackend()},function(y){y=a.parseJSON(y);if(y.result=="OK")y.premium_acc?k.Dialog.n1f6("Congratulations! You are now a Premium member",k.msg.cancel):k.Dialog.n1f6("Payment went through, but you are not yet automatically marked Premium member. Please contact admin@3dtin.com. Sorry for the inconvenience.",k.msg.cancel)})}function u(){k.Dialog.n1f6("Something went wrong with the Payment. Please contact admin@3dtin.com if this was unexpected.",k.msg.cancel)}var k=
a.app,H=a.tin,Q;p.n0a9=function(){var q=k.editor.n10e(),y=k.editor.getColorPalette(),I=a("#colorpalette");I.find(".ocolor").removeClass("ocolorsel");_(y).each(function(J,N){I.find("#ocolor"+N).css("background-color","rgb("+J.r+","+J.g+","+J.b+")").data("color",J);q&&q.r==J.r&&q.g==J.g&&q.b==J.b&&I.find("#ocolor"+N).addClass("ocolorsel")})};p.showLoginOptions=function(){function q(){a("#login_options").hide();a("#curtain").fadeOut();k.KBD.popHandler()}k.KBD.pushHandler({element:"#login_options",handlers:[{key:"esc",
func:q}]});a("#login_options").show();a("#curtain").fadeIn();a("#login_options").find(".closeIcon").unbind("click").click(q)};p.setCurrentGeometry=function(q,y){if(typeof q=="string"){k.Gui.n15e(k.msg.loading);k.cadmiumCache.getMesh(q,y,function(I){k.Gui.n15e();mesh=new a.tin.Mesh3D(k.editor);this.mesh.n196(I.surfaces);k.editor.setCurrentGeometry(q,y,mesh);k.editor.setAction(a.tin.C.n1d1)},function(I){k.Gui.n15e();k.Dialog.n1f6(k.msg.error+": "+I,k.msg.cancel)})}else{k.editor.setCurrentGeometry(q,
y);k.editor.setAction(H.C.n1d1)}};p.show_stats=C;p.n157=function(){var q=k.msg.please+" "+k.msg.login;if(window.localStorage)q+="<br/>"+k.msg.tmpsave;k.Dialog.n1f6(q,k.msg.login,k.msg.cancel,k.Gui.showLoginOptions)};p.n0cd=function(q,y,I,J){k.saveDialog.showSavePrompt(k.msg.entername,k.msg.ok,k.msg.cancel,function(N,P,V){if(N&&N.trim().length>0)y&&y(N,P,V);else k.Dialog.n1f6(k.msg.invalidname+", "+k.msg.tryagain,k.msg.cancel)},q,I,J);a("#private_premium").click(function(){k.Dialog.n1da();k.Gui.showPremiumSubscription()})};
p.n15e=function(q,y){var I=a("#subbottombar2 #bigwait").find("#piewait").get(0);if(q){p.do_wait=true;a("#subbottombar2 #bigwait").show();if(isNaN(y)){a("#piewait","#subbottombar2").hide();a("#gifwait","#subbottombar2").show()}else{a("#gifwait","#subbottombar2").hide();a("#piewait","#subbottombar2").show();x(I,y*3.6)}a("#subbottombar2 #bigwait span").html(q);a("#subbottombar2").show()}else{p.do_wait=false;a("#subbottombar2 #bigwait").hide();a("#subbottombar2").hide()}};p.show_biginfo=function(q,y){if(!p.do_wait){a("#subbottombar2 #biginfo span").html(q);
a("#subbottombar2").show();a("#subbottombar2 #biginfo").show();y&&setTimeout(p.hide_biginfo,y)}};p.hide_biginfo=function(){a("#subbottombar2").hide();a("#subbottombar2 #biginfo").hide()};p.show_bigwarning=function(q){if(!p.do_wait){a("#subbottombar2 #bigwarning span").html(q);a("#subbottombar2").show();a("#subbottombar2 #bigwarning").show();setTimeout(function(){a("#subbottombar2").hide();a("#subbottombar2 #bigwarning").hide()},1500)}};p.bind=function(q){k.KBD.init();n();d();m();t();a("#toulaunch").click(k.Gui.showTou);
a(document).bind("sketch_save_started",function(){p.n15e(k.msg.saving)});a(document).bind("sketch_save_finished",function(){p.n15e()});a(document).bind("sketch_load_started",function(){p.n15e(k.msg.loading)});a(document).bind("sketch_load_finished",function(){p.n15e()});a(document).bind("sketch_loaded",function(){});a("#colorpalette #colorp").click(function(){a.jPicker.List[0].show()});a("#undo").css("background-image","url('/_images/noundo.png')").data("enabled",false);a("#redo").css("background-image",
"url('/_images/noredo.png')").data("enabled",false);a("#undo").click(function(){a(this).data("enabled")&&k.editor.undo()});a("#redo").click(function(){a(this).data("enabled")&&k.editor.redo()});if(q){a("#htoolbar2").css("right",10);a("#searchbar").css("margin-right",10);a("#unmaximize").show();a("#rightbar").css("right",0);a("#hideButton").hide();a("#siteinfo").hide();a("#bottombar").css("width","100%");a("#subbottombar2").css("right","0px")}else a("#bottombar").css("width",a(document).width()-k.C.n182);
a("#homeicon").click(function(){if(tin_projectId=="8e480faeeda58cb35a5f136e5ee48e9c")window.open("http://www.playkide.com");else{k.KBD.pushHandler({element:"#homedialog",handlers:[{key:"esc",func:y}]});E();a("#curtain").fadeIn();a("#homedialog").fadeIn();k.config.isHomeDialogShown=true}});var y=function(){a("#curtain").fadeOut();a("#homedialog").fadeOut();k.KBD.popHandler()};a("#homedialog #start").click(y);a("#homedialog .closeIcon").click(y);var I=function(){a("#curtain").fadeOut();a("#tutorialdialog").fadeOut();
a("#tutorialdialog #wrapper").remove();k.KBD.popHandler()};a("#homedialog #quicktutorial").click(function(){a("#homedialog").animate({left:"-=100%"},function(){a(this).hide().css("left","50%");k.KBD.popHandler();k.KBD.pushHandler({element:"#homedialog",handlers:[{key:"esc",func:I}]})});a.get("/_html/tutorial.html",function(J){a("#tutorialdialog").append(J);D()});a("#tutorialdialog").fadeIn()});a("#tutorialdialog .closeIcon").click(I)};p.showTou=function(){function q(){k.KBD.popHandler();a.post("/_marktouaccepted",
k.sign({}));a("#toudialog, #curtain").fadeOut()}k.KBD.pushHandler({element:"#tou",handlers:[{key:"return",func:q}]});a("#toudialog #toutext").load("/_static/tou.html");a("#toudialog, #curtain").fadeIn();a("#toudialog #touaccept").click(q)};p.showHints=function(){};p.showPremiumSubscription=function(q){function y(){I.hide();k.KBD.popHandler();q?q():a("#curtain").fadeOut()}q||a("#curtain").fadeIn();k.KBD.pushHandler({element:"#youtube_registration",handlers:[{key:"esc",func:function(){y()}}]});var I=
a("#premium_subscription").show();I.load("/_payment/form",function(){a(".closeIcon",I).click(function(){y()});var J=a("#google_buy input[name=googjwt]").val();a("#google_buy #googbuy").click(function(){goog.payments.inapp.buy({jwt:J,success:z,failure:u});y()})})};k.Gui=p;k.debug=function(){}})(jQuery);
(function(a){function h(){}function m(f,c){function j(){var o=(new Date).getTime();if(b.s3Portal){b.scratchpad.waitForPortalSuccess=true;a("#invisiblescreen").hide();b.Gui.n15e();f(true)}else if(o>s+c){b.reportLog("Portal load failed: S3 "+b.s3Portal+", after "+(o-s)/1E3+" sec");b.scratchpad.waitForPortalTimeout=true;a("#invisiblescreen").hide();b.Gui.n15e();f(false)}else setTimeout(j,1E3)}var s=(new Date).getTime();a("#invisiblescreen").show();b.Gui.n15e(b.msg.loading);j()}function n(){window.onbeforeunload=
function(){if(b.editor.isModelDirty()){var f=b.editor.modelToString();b.Store.n1b4({content:f,meta:b.sketch.meta})}if(b.cachingStarted&&!b.cachingFinished)return"Application update is in progress ("+b.cacheProgress+"% complete). Are you sure you want to quit?";b.identity.n1b4();b.config.save()};if(typeof window.applicationCache!=="undefined"){window.applicationCache.ondownloading=function(){b.cachingStarted=true};window.applicationCache.onprogress=function(f){if(_.isUsableNumber(f.loaded)&&_.isUsableNumber(f.total)){f=
Math.round(100*f.loaded/f.total);if(f>=100){b.cachingFinished=true;b.cacheProgress="(Update Ready)"}else b.cacheProgress="("+f+"%)"}else b.cacheProgress="(Updating)"};window.applicationCache.onupdateready=function(){b.cachingFinished=true;b.cacheProgress="(Update Ready)"};window.applicationCache.onerror=function(f){console.log("Error updating application cache: "+f)}}}function d(){typeof tin_inittin!=="undefined"&&tin_inittin!=="_NULL_"?a(document).trigger("sketch_load_requested",tin_inittin):m(function(f){if(!f)if(tin_appVersion){a("#curtain").show();
b.Dialog.n1f6(b.msg.portalloadfail);return}else b.Dialog.n1f6(b.msg.portalloadfail,b.msg.cancel);b.Store.n147(function(c,j){if(c){b.sketch={content:c,meta:j};b.scratchpad.sketchLoadedFromLocal=true;try{b.editor.modelFromString(c,function(o){if(o){if(o.message===g.C.exception_geomprepare_failed){b.Dialog.n1f6(b.msg.geomprepare_failed,b.msg.cancel);b.reportError(o,"GeomPrepare failed:"+uid)}}else b.editor.setModelDirty(true);b.editor._jq.trigger("sketchelem_load_finished")})}catch(s){if(s.message===
g.C.exception_corrupt_file)b.Dialog.n1f6(s.message,b.msg.cancel);else if(s.message==g.C.exception_webgl_req_advgeom){b.Dialog.n1f6(b.msg.webgl_req_advgeom,b.msg.cancel);b.editor.resetModel();b.editor.ren286();b.editor._jq.trigger("sketchelem_load_finished")}else{b.reportError(s,"loadLocalSketch");b.Dialog.n1f6(s.message,b.msg.cancel)}}b.titlebox&&b.titlebox.update(null,null,null,"You",0,0,[],[],null)}else b.Controller.n22a();a(document).trigger("sketch_loaded")})},e)}var b=a.app,g=a.tin,e=12E4;h.n0ee=
function(f){switch(f){case "camleft":b.editor.adjustView(g.C.cam_view_left);break;case "camright":b.editor.adjustView(g.C.cam_view_right);break;case "camtop":b.editor.adjustView(g.C.cam_view_top);break;case "cambottom":b.editor.adjustView(g.C.cam_view_bottom);break;case "camfront":b.editor.adjustView(g.C.cam_view_front);break;case "camback":b.editor.adjustView(g.C.cam_view_back);break}};h.n1cb=function(f,c){function j(s,o){b.sketch={content:s,meta:o};b.scratchpad.sketchLoadedFromCloud=true;b.editor.resetModel();
b.editor.ren286();try{b.editor.modelFromString(s,function(l){if(l){if(l.message===g.C.exception_geomprepare_failed){b.Dialog.n1f6(b.msg.geomprepare_failed,b.msg.cancel);b.reportError(l,"GeomPrepare failed:"+c)}}else{b.editor.setModelDirty(false);b.Gui.n0a9()}b.editor._jq.trigger("sketchelem_load_finished")})}catch(w){if(w.message===g.C.exception_corrupt_file)b.Dialog.n1f6(w.message,b.msg.cancel);else if(w.message==g.C.exception_webgl_req_advgeom){b.Dialog.n1f6(b.msg.webgl_req_advgeom,b.msg.cancel);
b.editor.resetModel();b.editor.ren286();b.editor._jq.trigger("sketchelem_load_finished")}else{b.Dialog.n1f6(w.message,b.msg.cancel);b.reportError(w,"n1cb:"+c)}}o=b.sketch.meta;b.titlebox.update(o.uid_,o.name_,o.n1dd,o.n19e,o.n1bf,o.userpoints_,o.n294,o.n227,o.thumburl_,o.private_,o.tags_);a(document).trigger("sketch_loaded")}m(function(s){if(!s)if(tin_appVersion){b.Dialog.n1f6(b.msg.portalloadfail);a("#curtain").show();return}else b.Dialog.n1f6(b.msg.portalloadfail,b.msg.cancel);b.editor.isModelDirty()?
b.Dialog.n1f6(b.msg.unsaved_warning,b.msg.yes,b.msg.no,function(){b.Store.n139(c,j)}):b.Store.n139(c,j)},e)};h.n1ba=function(){var f={};if(b.identity.state_==b.C.n285){b.editor.setAction(g.C.n177);var c=b.sketch.meta;f.persistence=c.persistence_;f.content=b.editor.modelToString();f.thumbnail=b.editor.getThumbnail(256,256,"image/jpeg");if(c.uid_)if(c.n1dd===b.identity.n1e2){if(c.baseuid_)f.baseuid=c.baseuid_;f.uid=c.uid_;f.name=c.name_;f.license=c.private_?"private":"cc";b.Store.n189(f)}else b.Gui.n0cd(c.name_,
function(j,s,o){f.baseuid=c.baseuid_=c.uid_;delete c.uid_;delete c.name_;f.name=c.name_=j;f.license=s;f.tags=JSON.stringify(o);b.Store.n189(f)},c.private_,c.tags_);else b.Gui.n0cd(null,function(j,s,o){f.name=c.name_=j;f.license=s;f.tags=JSON.stringify(o);b.Store.n189(f)})}else b.Gui.n157()};h.n169=function(){var f={};if(b.identity.state_==b.C.n285){var c=b.sketch.meta;b.editor.setAction(g.C.n177);b.Gui.n0cd(c.name_,function(j,s,o){if(c.n1dd!=b.identity.n1e2){if(c.uid_)f.baseuid=c.uid_}else f.baseuid=
c.baseuid_;delete c.uid_;f.name=c.name_=j;f.persistence=c.persistence_=0;f.content=b.editor.modelToString();f.thumbnail=b.editor.getThumbnail(256,256,"image/jpeg");f.license=s;f.tags=JSON.stringify(o);b.Store.n189(f)},c.private_,c.tags_)}else b.Gui.n157()};h.n22a=function(){b.sketch={content:null,meta:{persistence_:0,effort_:0}};b.scratchpad.sketchLoadedNew=true;b.editor.resetModel();b.editor.ren286();b.editor.resetCamera();b.editor.setProjection(a.tin.C.proj_perspective);b.titlebox&&b.titlebox.update(null,
null,null,"You",0,0,[],[],null);b.editor.setModelDirty(false)};h.n161=function(){if(b.sketch){var f=b.sketch.meta;f.effort_++;if(f.effort_>b.n0f4){f.effort_=0;f.persistence_+=1;b.identity.incPersistence()}}else{f=b.now()/1E3+" seconds "+JSON.stringify(b.scratchpad);b.reportLog("app.sketch "+b.sketch+" : "+f)}};h.s3_ready=function(){b.s3Portal=new b.S3Portal(a("#s3iframe"))};h.init=function(){n();d()};b.Controller=h})(jQuery);
(function(a){var h=a.app,m={addcubes:"Add Cubes",addgeom:"Add Geometries",erasecubes:"Erase Cubes",rotate:"Rotate",select:"Select",rotateangle:"Rotation angle",scalefactor:"Scale Factor",shearfactor:"Shear Factor",rotatepan:"Rotate (and Pan)",changecolor:"Change Color",pickcolor:"Pick Color",extrude:"Extrude",moveobj:"Move Objects",rotateobj:"Rotate",inflateobj:"Inflate",flipobj:"Flip",newsketch:"New Sketch",savesketch:"Save Sketch",opensketch:"Open Sketch",hflip:"Horizontal Flip",vflip:"Vertical Flip",
horizontal:"Horizontal",vertical:"Vertical",add:"Add",apply:"Apply",open:"Open",undo:"Undo",redo:"Redo",save:"Save",edit:"Edit",clone:"Clone","delete":"Delete",group:"Group",ungroup:"UnGroup",left:"Left",right:"Right",saveas:"Save As",colorpicker:"Color Picker",mostactive:"Most Active",mostpopular:"Most Popular",reset:"Reset",click2edit:"Click to Edit",topview:"Top View",bottomview:"Bottom View",leftview:"Left View",rightview:"Right View",frontview:"Front View",backview:"Back View",toggleproj:"Toggle Projection",
helpscreen:"Help Screen",submityt:"Submit Video",submit:"Submit",leaders:"Leaders",loopanim:"Loop Animation",sun:"Sun",bulb:"Bulb",ambient:"Ambient",color:"Color",dirrays:"Direction of rays",locbulb:"Location of Bulb",add_tags:"Add Tags",ytfooter:"This dialog can also be accessed from ",yt_confirmation:"Video has been submitted. You will be informed once it is approved.",delete_confirm:"Are you sure you want to delete ",portalloadfail:"Failed to connect to Factory servers. Please try again.",list_failure:"Failed to list",
delete_failure:"Failed to delete",export_failure:"Failed to export",modified:"Modified",unsaved_warning:"You have unsaved changes. Proceed?",unsaved_warning_1:"Please save the sketch before exporting",tmpsave:"Your sketch will be stored temporarily",failedsave:"Failed to save sketch",failedexport:"Failed to export",dragmarkers:"Drag markers to pick a color",cc_sketch:"Creative Commons",private_sketch:"Private",notimgfile:"Not an image file",no_results:"No results found.",filereadernotsupported:"Your browser doesn't support FileReader API",
csgwebglmsg:"This sketch contains advanced geometry, which requires WebGL for correct rendering. Please use WebGL enabled browser.",webglperfmsg:"Please use WebGL enabled browser for better performance",geomprepare_failed:"Failed to generate geometry. Try again.",tempcache_cleared:"Template cache is cleared",localstorage_cleared:"LocalStorage is cleared",enteryt:"Paste YouTube URL here...",entername:"Enter Name",invalidname:"Invalid name",inappropriate:"Mark as Inappropriate",error:"Error",unknown_failure:"Unknown failure",
invalidinput:"Invalid input",tryagain:"Try again",hide_panel:"Hide",gallery:"Gallery",mysketches:"My Sketches",modelextents:"Model extents",size:"Size",scale:"Scale",shear:"Shear",topalign:"Top Align",bottomalign:"Bottom Align",vcenteralign:"Vertical Center Align",leftalign:"Left Align",rightalign:"Right Align",hcenteralign:"Horizontal Center Align",only:"only",feedback:"Feedback",credits:"Credits",contact:"Contact",sources:"Sources",derivatives:"Derivatives",destination:"Destination",desktop:"Desktop",
review:"Review",manifold:"Manifold",reset_tempcache:"Reset Template Cache",reset_localstorage:"Reset Local Storage",violations:"violations",webglreqmsg:"Advanced Geometry requires WebGL for correct rendering. Please use browser with WebGL support.",webgl_req_advgeom:"This sketch contains advanced Geometry that requires WebGL for correct rendering",assumecubevol:"Assuming cube volume",expsmoothness:"Exported smoothness",expmodecubicle:"Exported mode will be",toomanypolygons:"Too many polygons",overlapavoided:"Avoiding Geometry overlap",
webglfailure:"WebGL Failure. Please refresh the page",click4controls:"Click to open controls",inflatenotsup:"Geometry cannot inflate",orthographic:"Orthographic",symmsketch:"Symmetric Sketch",snap2grid:"Snap to Grid",perspective:"Perspective",checkout:"Check out",reputation:"Reputation",persistence:"Persistence",license:"License",using:"using",saving:"Saving",loading:"Loading",working:"Working",rate:"Rate",share:"Share",mode:"Mode",cubicle:"Cubicle",smooth:"Smooth",smoothness:"Smoothness",permalink:"Permalink",
weekly:"Weekly",alltime:"All time",please:"Please",format:"Format",login:"Login",logout:"Logout",premium:"You need to be a Premium User",grid:"Grid","export":"Export","import":"Import",generating:"Generating",download:"Download",proceed:"Proceed",current:"Current",ok:"Ok",cancel:"Cancel","new":"New",yes:"Yes",no:"No",you:"You",by:"by",premium_mem:"Premium Membership",yt_header:"Submit a Video tutorial and become Premium member for FREE",yt_text:"Create an instructional video that shows how 3DTin can be used to create awesome 3D models and submit it to us. As long as you meet following guidelines you will get Premium Membership for FREE. The video should ...",
yt_rules:["primarily demonstrate usage of 3DTin","be at least 1 minute long, but no longer than 10 minutes","include instructions in human voice","be uploaded to Youtube"],home_welcome:"Welcome! 3D modeling has never been easier.",home_titles:["No installation required ","FREE ","Simple interface ","Accessible from anywhere ","Export to standard file formats "],home_contents:["All you need is Google Chrome or Firefox with WebGL support. Type 3dtin.com in address bar and start designing. Any operating system.",
"All functionality is available to everyone. For FREE. ... as long as the sketch is shared under Creative Commons. Become premium member for private storage.","Choose 3D shapes from a huge library of templates and add them to your sketch. All through an intuitive interface. If you still need help, check out the quick tutorial.","All sketches are stored in cloud. You can access them from anywhere and share with unique URL.","All sketches can be exported in STL, OBJ, DAE file formats, which can be imported in other modeling tools."],
home_start:"Start",home_quicktut:"Quick Tutorial",tut_title:["Getting Started","Build with cubes","Colors","Lights","Camera"],tut_row:["Click the &quot;Add Geometry&quot; icon near the upper left corner","Click on the geometry you want to add to your sketch","Fill in different properties of the geometry and click &quot;Add&quot;","Move the mouse to select the location of the geometry on the grid. Click when the geometry is at a location you want.","Click on the &quot;View Rotate&quot; icon to exit Geometry addition. You can now rotate the camera by clicking and dragging in empty space. Hover over any geometry to move or modify it.",
"You can click on a geometry and drag to &quot;move&quot; it elsewhere. Clicking also opens controls that you can use to &quot;rotate&quot; and &quot;flip&quot; the geometry.","Click on the &quot;Pencil&quot; icon in left toolbar to select cube addition","Move the mouse over the grid and click where you want to add cubes. You can click and drag the mouse to add multiple cubes in one go.","You can use &quot;Eraser&quot; to remove any unwanted cubes.","You can use the &quot;Extrude&quot; tool to extend existing structures along their sides by adding multiple cubes in one go.",
"Click on the Color Pallette icon to open Color Picker dialog. You can choose any color and it will become your current color. All new n1c9 will take that color. Recently used colors are added to the pallette for quick access.","Click on the &quot;Paint Brush&quot; icon to change color of existing n1c9 to current color.","Click on the dropper icon to pick color of any existing geometry and making it current color.","You can manipulate the lights in your sketch from the Light Dialog. Hover over the Light icon in toolbar in lower left part.",
"You can use the &quot;Camera Popup&quot; to align the camera to standard orientations or reset it to default position."],imat_info:"'i.matertialize' is an easy to use '3D Printing Service' for everyone with an eye for design and head full of ideas.",thing_info:"'Thingiverse' is a place to share digital designs that can be made into real, physical objects."};html_id2msg_map={help_addcubes:"addcubes",help_erasecubes:"erasecubes",help_rotatepan:"rotatepan",help_changecolor:"changecolor",help_extrude:"extrude",
help_move:"moveobj",help_rotateobj:"rotateobj",help_new:"newsketch",help_save:"savesketch",help_open:"opensketch",help_undo:"undo",help_redo:"redo",help_colorpicker:"colorpicker",help_reset:"reset",help_topview:"topview",help_bottomview:"bottomview",help_leftview:"leftview",help_rightview:"rightview",help_frontview:"frontview",help_backview:"backview",help_toggleproj:"toggleproj",help_help:"helpscreen",leaderboard_launcher:"leaders",leaderstitle:"leaders",loopanimtitle:"loopanim",sourcestitle:"sources",
derivtitle:"derivatives",desttitle:"destination",desktoptitle:"desktop",formattitle:"format",ratetitle:"rate",sharetitle:"share",permatitle:"permalink",weeklytitle:"weekly",alltimetitle:"alltime",mysketchestitle:"mysketches",feedbacktitle:"feedback",creditstitle:"credits",contacttitle:"contact",modetitle:"mode",cubicletitle:"cubicle",smoothtitle:"smooth",smoothnesstitle:"smoothness",tempcache_reset:"reset_tempcache",localstorage_reset:"reset_localstorage",exportbtn:"export",lightsun:"sun",lightbulb:"bulb",
lightambient:"ambient",dirraystitle:"dirrays",locbulbtitle:"locbulb",hideButton:"hide_panel",byclause:"by"};html_class2msg_map={colortitle:"color"};var n="en";h.setLocale=function(d,b){n=d;h.msg=m;if(n=="en")b&&b();else a.ajax("/_static/msg-"+n+".json",{type:"GET",success:function(g){a.extend(h.msg,typeof g=="string"?a.parseJSON(g):g);b&&b()},error:function(){console.log("Failed to load locale "+n);n="en";b&&b()}})};h.reloadMessages=function(){_(html_id2msg_map).each(function(d,b,g){a("#"+b).html(h.msg[g[b]])});
_(html_class2msg_map).each(function(d,b,g){a("."+b).html(h.msg[g[b]])});h.tooltips={w:{degreebanner:h.msg.click2edit,ratiobanner:h.msg.click2edit,rotate:h.msg.rotatepan,add:h.msg.addcubes,addgeom:h.msg.addgeom,extrude:h.msg.extrude,remove:h.msg.erasecubes,select:h.msg.select,color:h.msg.changecolor,colorpick:h.msg.pickcolor,projn:h.msg.orthographic+"/"+h.msg.perspective,mirror:h.msg.symmsketch,grid:h.msg.grid+" On/Off",snap2grid:h.msg.snap2grid},n:{save:h.msg.save,saveas:h.msg.saveas,"export":h.msg["export"],
"import":h.msg["import"],open:h.msg.open,"new":h.msg["new"],undo:h.msg.undo,redo:h.msg.redo,help:"Help",leftalign:h.msg.leftalign,rightalign:h.msg.rightalign,hcenteralign:h.msg.hcenteralign,"shear-horz":h.msg.horizontal,"shear-vert":h.msg.vertical},s:{move:h.msg.moveobj,ooedit:h.msg.edit,oodelete:h.msg["delete"],ooclone:h.msg.clone,oogroup:h.msg.group,ooungroup:h.msg.ungroup,minus90:"90&deg; "+h.msg.left,plus90:"90&deg; "+h.msg.right,ooflip:h.msg.flipobj,oohflip:h.msg.hflip,oovflip:h.msg.vflip,oo2x:h.msg.inflateobj,
ooscale:h.msg.scale,ooshear:h.msg.shear,oorotate:h.msg.rotateobj},e:{zoomin:"Zoom in",zoomout:"Zoom out",topalign:h.msg.topalign,bottomalign:h.msg.bottomalign,vcenteralign:h.msg.vcenteralign,unmaximize:"UnMaximize"}}};h.Locale={init:function(d){var b;if(window.localStorage)b=window.localStorage.getItem("userlocale");b=b||"en";h.setLocale(b,function(){h.reloadMessages();d&&d();h.warnings=[];h.warnings[a.tin.C.n075]=h.msg.overlapavoided;h.warnings[a.tin.C.n063]=h.msg.inflatenotsup;h.errors=[];h.errors[a.tin.C.n069]=
h.msg.webglfailure});a("#locales").val(b);a("#locales").change(function(){h.setLocale(a(this).val(),function(){h.reloadMessages()});window.localStorage&&window.localStorage.setItem("userlocale",a(this).val())})}}})(jQuery);
(function(a){function h(){var b=n.getItem("config");a.extend(this,d,b?JSON.parse(b):{})}var m=a.app,n=window.localStorage,d={isFullScreen:false,isHomeDialogShown:false};h.prototype={save:function(){n.setItem("config",JSON.stringify({isFullScreen:this.isFullScreen,isHomeDialogShown:this.isHomeDialogShown}))}};m.Config=h})(jQuery);
(function(a){var h=a.app;a(document).ready(function(){try{h.startTimestamp=(new Date).getTime();h.identity=new h.Identity(a("#identity"));h.config=new h.Config;var m=h.identity.premium_&&h.config.isFullScreen;h.cadmiumCache=new h.CadmiumCache;h.editor=a("#canvas3d").tin({height:a(document).height()-h.C.n0d5,width:m?a(document).width():a(document).width()-h.C.n182,meshLoader:h.cadmiumCache,user_warning:function(d){h.Gui.show_bigwarning(h.warnings[d])},user_alert:function(d){h.Dialog.n1f6(h.errors[d],
h.msg.cancel)},selectcanvas:a("#selectcanvas"),forceSyncSmoothing:false,log:h.reportLog,error:h.reportError}).bind("op_done",function(){h.Controller.n161();h.titlebox.setTitleDirty(h.editor.isModelDirty())}).bind("undo_stack_populated",function(){a("#undo").css("background-image","url('/_images/undo.png')").data("enabled",true)}).bind("redo_stack_populated",function(){a("#redo").css("background-image","url('/_images/redo.png')").data("enabled",true)}).bind("undo_stack_finished",function(){a("#undo").css("background-image",
"url('/_images/noundo.png')").data("enabled",false)}).bind("redo_stack_finished",function(){a("#redo").css("background-image","url('/_images/noredo.png')").data("enabled",false)}).bind("color_changed",function(){h.Gui.n0a9()}).bind("smoothen_started",function(){a("#invisiblescreen").show();h.Gui.n15e(h.msg.working)}).bind("smoothen_finished",function(){a("#invisiblescreen").hide();h.Gui.n15e()}).bind("sketchelem_load_started",function(){h.Gui.n15e(h.msg.loading)}).bind("sketchelem_load_inprogress",
function(d,b){h.Gui.n15e(h.msg.loading,b)}).bind("sketchelem_load_finished",function(){h.Gui.n15e()}).bind("current_geom_extents",function(d,b){d=a.tin.C.cube_size;a("#posstatus").find("#xmin").text((b.xmin/d).toFixed(2));a("#posstatus").find("#xmax").text((b.xmax/d).toFixed(2));a("#posstatus").find("#ymin").text((b.ymin/d).toFixed(2));a("#posstatus").find("#ymax").text((b.ymax/d).toFixed(2));a("#posstatus").find("#zmin").text((b.zmin/d).toFixed(2));a("#posstatus").find("#zmax").text((b.zmax/d).toFixed(2));
a("#posstatus").show()}).bind("projection_changed",function(d,b){b==a.tin.C.proj_perspective?a("#projn").css("backgroundImage","url(/_images/persp.png)"):a("#projn").css("backgroundImage","url(/_images/ortho.png)")}).bind("dirlight_dir_changed",function(){h.lightOptions&&h.lightOptions.syncDirectionalLightDirection()}).bind("dirlight_col_changed",function(){h.lightOptions&&h.lightOptions.syncDirectionalLightColor()}).bind("pointlight_pos_changed",function(){h.lightOptions&&h.lightOptions.syncPointLightPosition()}).bind("pointlight_col_changed",
function(){h.lightOptions&&h.lightOptions.syncPointLightColor()}).bind("amblight_col_changed",function(){h.lightOptions&&h.lightOptions.syncAmbientLightColor()}).bind("background_col_changed",function(){h.lightOptions&&h.lightOptions.syncBackgroundColor()}).bind("geometry_focused",function(d,b){h.oowindow.isEnabled&&h.oowindow.disable();h.oowindow.enable(b)}).bind("geometry_clicked",function(d,b){h.oowindow.show(b,true)}).bind("geometry_defocused",function(){a("#posstatus").hide();h.oowindow.disable()}).bind("geometry_selected",
function(d,b){h.oowindow.enable(b);h.oowindow.show(b)}).data("instance");h.Locale.init(function(){h.identity.sync(function(){if(m&&h.identity.state_!==h.C.n285)window.location.reload();else if(m&&!h.identity.premium_)window.location.reload();else{h.Gallery.init();h.identity.premium_||h.MsgClip.start()}});h.filebrowser=new h.n1a3(a("#filebrowser"));h.leaderboard=new h.n1ae;h.cadmiumBrowser=new h.CadmiumBrowser;h.titlebox=new h.n249(a("#titlebox"));h.sketchdetail=new h.n17c(a("#sketchdetail"));h.oowindow=
new h.OOWindow(a("#oowindowwrapper"));if(h.editor.getBackend()=="WebGL")h.lightOptions=new h.LightOptions(a("#lightoptions"));h.voxdlg=new h.n110;h.searchbar=new h.SearchBar(a("#searchbar"));h.Gui.bind(m);h.Controller.init();h.Gui.showHints();if(h.Admin)h.admin=new h.Admin;h.config.isHomeDialogShown||a("#homeicon").click()})}catch(n){h.reportError(n,"Ready")}})})(jQuery);(function(a){a.tin.C.ccworker_path="/_build/ccw-v508.js"})(jQuery);

