/*
 * @author    RocketTheme http://www.rockettheme.com
 * @copyright Copyright (C) 2007 - 2012 RocketTheme, LLC
 * @license   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
 */
var tip;window.sliders={};window.slidersTips={};Array.prototype.compareArrays=function(a){if(!a){return false;}if(this.length!=a.length){return false;}for(var b=0;
b<a.length;b++){if(this[b].compareArrays){if(!this[b].compareArrays(a[b])){return false;}else{continue;}}if(this[b]!=a[b]){return false;}}return true;};
String.implement({baseConversion:function(c,b){var a=this;if(isNaN(c)||c<2||c>36||isNaN(b)||b<2||b>36){throw (new RangeError("Illegal radix. Radices must be integers between 2 and 36, inclusive."));
}a=parseInt(a,c);a=a.toString(b);return a;},hex2dec:function(){if(!isNaN(this.toInt())){return this;}return this.baseConversion(24,10);},dec2hex:function(){return this.baseConversion(10,24);
}});var tip;var createTip=function(b){var a=document.id(b);if(a){return a;}a=new Element("div",{id:b}).inject(document.body).set("text","2 | 2 | 2 | 2 | 2 | 2");
a.set("fade",{duration:200,link:"cancel"}).fade("out");return a;};var updateTip=function(b){var c=b.RT.blocks,a="";c.each(function(f,e){if(f.style.display!="none"){var d=f.className.split(" ")[1].replace("mini-grid-","");
a+=d.hex2dec()+" | ";}});a=a.substring(0,a.length-2);return a;};var updateSlider=function(d,b){var a=d;b=b;a.min=0;a.max=d.RT.list[b].length-1;a.range=a.max-a.min;
a.steps=a.max;a.stepSize=Math.abs(a.range)/a.steps;a.stepWidth=Number((a.stepSize*a.full/Math.abs(a.range)).toFixed(4));var c=(a.stepWidth==Infinity)?a.full:a.stepWidth;
a.drag.options.grid=c;if(!a.steps){a.drag.detach();}else{a.drag.attach();}d.RT.current=b;};var updateBlocks=function(c,a,b){if(!b){b=0;}var e=c.RT.blocks;
var d=c.RT.list[c.RT.current];a=a;e.removeClass("main");e.each(function(k,g){if(g<c.RT.current){e[g].setStyle("display","block");}else{e[g].setStyle("display","none");
}var f=c.RT.list[a][Math.round(b,0)].toString();e[g].className="";var h=(a==1)?c.RT.gridSize:f.charAt(g).hex2dec();e[g].addClass("mini-grid").addClass("mini-grid-"+h);
var j=e[g].innerHTML;if(j==c.RT.keyName&&(j!="")){e[g].addClass("main");}});};var serializeSettings=function(c,b){var a="";a+="a:1:{i:"+c.RT.gridSize+";";
a+="a:"+b.getLength()+":{";b.each(function(f,e){a+="i:"+e+";a:"+f.length+":{";for(i=0,l=f.length;i<l;i++){if(c.RT.type=="custom"){var d=c.RT.store[e][i];
a+="s:"+d.length+':"'+d+'";i:'+f[i].hex2dec()+";";}else{a+="i:"+i+";i:"+f[i].hex2dec()+";";}}a+="}";});a+="}}";return a;};var GantryPositions={add:function(e,a,f,g,m,h,j,n,k){e=document.id(e);
var d=a.replace(/-/,"_"),c=document.id(a+"-grp").getElement(".position"),b=document.id(a+"-grp").getElement(".knob");if(!window.sliders){window.sliders={};
}GantryPositionsTools.setEvent(e,d);window.sliders[d]=new RokSlider(c,b,{offset:5,snap:true,initialize:function(){this.hiddenEl=".$hidden.";this.RT={};
this.RT.current=$$("#"+a+"-grp .list .active a")[0].getFirst().innerHTML.toInt();this.RT.list=j;this.RT.keys=n;this.RT.navigation=document.id(a+"-grp").getElement(".list").getChildren();
this.RT.blocks=document.id(a+"-grp").getElements(".mini-grid");this.RT.settings={};this.RT.gridSize=f;this.RT.defaults=g;this.RT.keyName=m||"";this.RT.type=h;
this.RT.store={};GantryPositionsTools.init.bind(this,[d])();},onComplete:function(){GantryPositionsTools.complete.bind(this,[a,e])();},onDrag:function(o){GantryPositionsTools.drag.bind(this,[o,d])();
},onChange:function(o){GantryPositionsTools.change.bind(this,[o])();}});window.sliders[d].RT.navigation[k].fireEvent("click");b.addEvents({mousedown:function(){this.addClass("down");
},mouseup:function(){this.removeClass("down");}});GantryPositionsTools.wrapperTip(a,d);}};var GantryPositionsTools={init:function(b){this.options.steps=this.RT.list[this.RT.current].length-1;
this.setOptions(this.options);var d=this.RT.current,a=this.RT.navigation,e=this.RT.blocks;var c=this.RT.settings;a.each(function(g,f){c[d]=[];g.addEvent("click",function(k){if(k){new Event(k).stop();
}a.removeClass("active");this.addClass("active");updateSlider(window.sliders[b],this.getFirst().getFirst().innerHTML.toInt());var n=window.sliders[b].RT.defaults[window.sliders[b].RT.current][0];
if(window.sliders[b].RT.type=="custom"){var o=window.sliders[b].RT.defaults[window.sliders[b].RT.current];var j=window.sliders[b].RT.keys[window.sliders[b].RT.current];
var h=[];j.each(function(q,p){if(q.compareArrays(o.keys)){h.push(p);}});var m=window.sliders[b].RT.list[window.sliders[b].RT.current];h.each(function(q,p){if(m[q]==o.values[0]){window.sliders[b].set(q);
}});}else{window.sliders[b].set(window.sliders[b].RT.list[window.sliders[b].RT.current].indexOf(n));}});});updateBlocks(this,d);},complete:function(a,e){this.knob.removeClass("down");
e.setProperty("value",serializeSettings(this,new Hash(this.RT.settings)));var b="";var d=Math.round(this.step);for(i=0,len=this.RT.current;i<len;i++){b+=this.RT.list[this.RT.current][(isNaN(d)||d<0)?0:d].toString().charAt(i);
}if(this.RT.type!="custom"){this.RT.defaults[this.RT.current]=[b];}else{this.RT.defaults[this.RT.current].values=[b];var c=[];for(i=0,l=this.RT.current;
i<l;i++){c.push(this.RT.blocks[i].innerHTML);}this.RT.defaults[this.RT.current].keys=c;}},drag:function(c,b){if($type(c)=="array"){b=c[1];c=c[0];}this.element.getFirst().setStyle("width",c+10);
var f=this.step;var e=this.RT.list[this.RT.current][Math.round(f,0)],a="";if(!e){return;}e=e.toString();this.RT.settings[this.RT.current]=[];this.RT.store[this.RT.current]=[];
for(i=0,len=this.RT.current;i<len;i++){a+=e.charAt(i).hex2dec()+((i==len-1)?"":" | ");if(this.RT.type=="custom"){this.RT.settings[this.RT.current].push(e.charAt(i));
this.RT.store[this.RT.current].push(this.RT.keys[this.RT.current][Math.round(f,0)][i]);}else{this.RT.settings[this.RT.current].push(e.charAt(i));}if(this.RT.keys){var d=this.RT.keys[this.RT.current][Math.round(f,0)][i];
if(this.RT.type=="custom"){this.RT.blocks[i].set("text",d);}}}if(!tip){tip=createTip("positions-tip");}tip.set("html",a);updateBlocks(window.sliders[b],this.RT.current,f);
},change:function(a){if(this.options.snap){a=this.toPosition(this.step);}a=a||0;this.knob.setStyle(this.property,a);this.fireEvent("onDrag",a);},wrapperTip:function(a,b){document.id(a+"-wrapper").addEvents({mouseenter:function(){var c=this.getElement(".mini-container");
var d=c.getCoordinates();tip.setStyles({left:d.left+d.width+5,top:d.top-5});tip.set("html",updateTip(window.sliders[b]));tip.fade("in");},mouseleave:function(){tip.fade("out");
}});},showMax:function(d,f){var g=document.id(d+"-grp").getParent(".chain");if(!g){return;}g=g.getParent();var c=g.getElement(".chain-toggle input[type=checkbox]");
var b=g.getElement(".chain-showmax select");if(!c||!b){return;}var e=document.id(d+"-grp").getElements("ul.list li");var a="toggle"+c.id.replace(/\-/g,"");
if(window[a]){window[a].addEvent("change",function(k){var j=b.get("value").toInt();if(!k){e.setStyle("display","inline");b.fireEvent("detach");}else{var h=$$(e.diff(e.slice(0,j),true));
e[j-1].fireEvent("click");h.setStyle("display","none");b.fireEvent("attach");}});}b.addEvent("change",function(j){if(!j){j=this.value;}else{j+=1;}var h=$$(e.diff(e.slice(0,j),true));
var k=document.id(d+"-grp").getElement("li.active");if(e.indexOf(k)>j-1){e[j-1].fireEvent("click");}e.setStyle("display","inline");h.setStyle("display","none");
});if(window[a]){window[a].fireEvent("change",window[a].state);if(window[a].state){b.fireEvent("attach");}}},setEvent:function(b,a){b.addEvent("set",function(j){var d=window.sliders[a].RT;
if(!j.contains("{")){j=serialize(j.replace(/\s/g,"").split(","));}j=j.unserialize();if(!j[d.gridSize]){return;}else{j=new Hash(j[d.gridSize]);}var k={};
var c={};j.each(function(o,p){k[p]=[];c[p]=[];if(d.type=="custom"){k[p]={};c[p]={};k[p].keys=[];k[p].values=[];c[p].keys=[];c[p].values=[];}$H(o).each(function(q,r){var s=q.toString().dec2hex();
if(d.type!="custom"){k[p].push(s);c[p].push(s);}else{k[p].keys.push(r);c[p].keys.push(r);k[p].values.push(s);c[p].values.push(s);}});if(d.type!="custom"){c[p]=[c[p].join("")];
}else{c[p].values=[c[p].values.join("")];}});d.defaults=$merge(d.defaults,c);if(d.type!="custom"){var m=c[d.current];if(m){var h=d.list[d.current].indexOf(m[0])||0;
window.sliders[a].set(h).fireEvent("onComplete");}}else{var f=d.defaults[d.current];var n=d.keys[d.current];var e=[];n.each(function(p,o){if(p.compareArrays(f.keys)){e.push(o);
}});var g=d.list[d.current];e.each(function(p,o){if(g[p]==f.values[0]){window.sliders[a].set(p);}});}});}};Array.implement({diff:function(a,c){var b=(c)?$A(this):this;
for(i=0;i<a.length;i++){if(b.contains(a[i])){b.erase(a[i]);}}return b;}});