var layerid=0;function Layer(D,E,B){this.virtual=false;this.parent=D;this.attributeInfo=E;this.tilelayer=null;if(B){this.attribute=B.attribute||null;this.options=B.options||{};this.style=B.style||null;this.constructor_args=B;this.enabled=((B.enabled!==undefined)?B.enabled:true);if(B.parent_enabled!==undefined&&!B.parent_enabled){this.parent.setCheckbox(false)}}else{this.attribute=null;this.options={};this.style=null;this.constructor_args={};this.enabled=true}this.renderReady=false;this.modelDirty=(this.attribute||this.options||this.style)?true:false;this.viewDirty=(this.attribute||this.options||this.style)?true:false;this.refreshing=false;this.template=null;this.colorTweaker=null;var C='<img id="_busy" class="_swatches" alt="color swatch" src="/static_cbi/i/loading.gif" height="28px" width="30px" />';this.domNode=new Element("div");this.domNode.innerHTML=C;var F=true;for(var A=0;F&&(A<E.shape_types.length);A++){F=(E.shape_types[A]!=="raster")}if(F){console.log("not raster; loading the framework");this.loadFramework()}else{Log.logDebug("is raster; this is an invisible placeholder layer")}if(!F){this.style="raster"}this.id=layerid;layerid++}Layer.prototype.getEnabledMask=function(){return this.parent.getEnabledMask()&&this.enabled};Layer.prototype.rendertiles=function(){console.log("rendering tiles","maplayer");var A=getElementById(this.domNode,"_new_filter_toggle");console.assert((A||(this.style==="raster")),"you must either have the row toggle or be a raster dataset");if(!this.parent.getEnabledMask()||!this.enabled){if(!(this.style==="raster")){A.removeClass("checked")}if(this.style==="raster"){console.log("HIDING RASTER TILES")}mapManager.hide(this)}else{if(!(this.style==="raster")){A.addClass("checked")}if(this.style==="raster"){console.log("SHOWING RASTER TILES")}mapManager.show(this)}};Layer.prototype.setVirtual=function(A){this.virtual=A};Layer.prototype.isVirtual=function(){return this.virtual};Layer.prototype.isComplete=function(){console.log("is complete?, atr:",this.attribute,", style:",this.style,", options",this.options);if(this.style==="raster"){return true}if(!this.attribute){return false}if(!this.style){return false}if(!this.options){return false}if(this.options){if(this.style==="+all"){if(!is_rgba_string(this.options.fill)&&!is_no_color(this.options.fill)){return false}if(!is_rgba_string(this.options.stroke)&&!is_no_color(this.options.stroke)){return false}}if(this.style==="+each"){if($type(this.options.palette)!=="string"){return false}}if(this.style==="graduated"){if($type(this.options.type)!=="string"){return false}if(this.options.type!=="+quantiles"){return false}if($type(this.options.num_buckets)!=="number"){return false}if(!is_rgba_string(this.options.stroke_start)&&!is_no_color(this.options.stroke_start)){return false}if(!is_rgba_string(this.options.stroke_end)&&!is_no_color(this.options.stroke_end)){return false}if(!is_rgba_string(this.options.fill_start)&&!is_no_color(this.options.fill_start)){return false}if(!is_rgba_string(this.options.fill_end)&&!is_no_color(this.options.fill_end)){return false}}var A=function(B){return is_rgba_string(B)||is_no_color(B)};if(this.style==="linear"){if($type(this.options.range_start)!=="number"){return false}if($type(this.options.range_end)!=="number"){return false}if(!A(this.options.stroke_start)){return false}if(!A(this.options.stroke_end)){return false}if(!A(this.options.fill_start)){return false}if(!A(this.options.fill_end)){return false}}if(this.style==="predicate+between"){if(($type(this.options.upper)!=="number")||($type(this.options.lower)!=="number")){return false}if(!A(this.options.fill)){return false}if(!A(this.options.stroke)){return false}}if(this.style==="predicate+equals"){if(($type(this.options.upper)!=="number")||($type(this.options.lower)!=="number")){return false}if(!A(this.options.fill)){return false}if(!A(this.options.stroke)){return false}}if(this.style==="predicate+above"){if($type(this.options.lower)!=="number"){return false}if(!A(this.options.fill)){return false}if(!A(this.options.stroke)){return false}}if(this.style==="predicate+below"){if($type(this.options.upper)!=="number"){return false}if(!A(this.options.fill)){return false}if(!A(this.options.stroke)){return false}}}return true};var replaceNoColor=function(C,B){console.assert(typeof (B)!=="undefined");if(is_no_color(C)){console.log("encountered no color");return B}var A;if($type(C)==="object"){A={};for(k in C){if(C.hasOwnProperty(k)){A[k]=replaceNoColor(C[k],B)}}}else{if($type(C)==="array"){A=C.map(function(D){return replaceNoColor(D,B)})}else{A=C}}return A};var replaceNull=function(C,B){console.assert(typeof (B)!=="undefined");if(C===null){console.log("encountered no color");return B}var A;if($type(C)==="object"){A={};for(k in C){if(C.hasOwnProperty(k)){A[k]=replaceNull(C[k],B)}}}else{if($type(C)==="array"){A=C.map(function(D){return replaceNull(D,B)})}else{A=C}}return A};Layer.prototype.foo=function(){console.log("this.options:",this.options);var C=this.options;if(this.colorTweaker){var D=(typeof (this.colorTweaker)!=="undefined")?this.colorTweaker.getPatch():[];if(D.length>0){C["patch"]=D}else{delete C["patch"]}}var A=replaceNoColor(C,null);console.log("with no color replaced:",A);var B={"attribute":copyObj(this.attribute),"options":A,"style":copyObj(this.style),"enabled":this.enabled,"parent_enabled":this.parent.enabled};return B};Layer.prototype.toString=function(){var A={uidirty:this.viewDirty,datadirty:this.modelDirty,style:this.style,domNode:this.domNode,enabled:this.enabled,options:this.options};return Json.toString(A)};Layer.prototype.enable=function(){this.enabled=true;this.updateVisibility()};Layer.prototype.disable=function(){this.enabled=false;this.updateVisibility()};Layer.prototype.updateVisibility=function(){if(this.enabled){this.tilelayer.show()}else{this.tilelayer.hide()}};Layer.prototype.configureDOM=function(){console.log("configure map layer dom");var G,E;var I,H;var A;var D,C,B;G=function(O){return[O[1][0],O]};E=function(O){return O[1]};A=iteritems(this.attributeInfo.attributes);A=A.map(G);A.sort();A=A.map(E);var N=this.domNode.getElement("select[id=_attribute_select]");console.log("selectBox:",N);var F,L,M;for(D=0;D<A.length;D++){H=A[D];M=H[1][0];L=H[0];F=new Element("option",{"value":L});F.appendText(M);N.appendChild(F)}var K=this.domNode.getElement("select[id=_palette_select]");var J=get_color_palettes();for(B in J){if(J.hasOwnProperty(B)){K.appendChild(new Element("option",{"value":B}).appendText(B))}}this.colorTweaker=new TweakColorValues($E("div.filterrule",this.domNode),$E("div.tweak_values",this.domNode),this);console.log("registering handlers for map layer");this.registerHandlers();console.log("configured map layer's dom")};Layer.prototype.setRefreshing=function(A){if(this.refreshing!==A){this.refreshing=A;this.viewDirty=true}};Layer.prototype.setEnabled=function(A){if(this.enabled!==A){this.enabled=A;this.modelDirty=true}};Layer.prototype.addEvent=function(A,B){if(typeof (this.registered_events)==="undefined"){this.registered_events={}}if(!(A in this.registered_events)){this.registered_events[A]=[]}this.registered_events[A].push(B)};Layer.prototype.fireEvent=function(B){if(typeof (this.registered_events)==="undefined"){return }if(!(B in this.registered_events)){return }var A=this.registered_events[B];A.each(function(C){C()})};Layer.prototype.clearEvents=function(A){if(typeof (this.registered_events)==="undefined"){return }this.registered_events[A]=[]};Layer.prototype.removeEvent=function(A,B){if(typeof (this.registered_events)==="undefined"){this.registered_events={}}if(!(A in this.registered_events)){this.registered_events[A]=[]}var C=this.registered_events[A];C.remove(B)};Layer.prototype.setStyle=function(B){var A=this.style;if(A!==B){this.style=B;this.modelDirty=true}mapManager.checkModels();if(A!==B){this.fireEvent("onAttributeChange")}};Layer.prototype.clearStyle=function(){this.setStyle(null);mapManager.checkModels()};Layer.prototype.setAttribute=function(A){if(this.attribute!==A){this.attribute=A;this.modelDirty=true}mapManager.checkModels()};Layer.prototype.clearOption=function(A){console.assert(A,"set option requires a key");if(A in this.options){delete this.options[A];this.modelDirty=true}mapManager.checkModels()};Layer.prototype.clearOptions=function(){var A=0;for(var B in this.options){if(this.options.hasOwnProperty(B)){A++}}if(A!==0){this.options={};this.modelDirty=true}mapManager.checkModels()};Layer.prototype.setOptions=function(C){var A=false;var B,D;for(B in C){if(C.hasOwnProperty(B)){D=C[B];if(B in this.options){if(this.options[B]===D){continue}}this.options[B]=D;A=true}}if(A){this.modelDirty=true;mapManager.compareObjects()}};Layer.prototype.setOption=function(A,B){if(A in this.options){if(this.options[A]===B){return }}this.options[A]=B;this.modelDirty=true;mapManager.compareObjects()};Layer.prototype.renderHTML=function(){if(!this.viewDirty){return }if(typeof console!=="undefined"){console.log("atr:",this.attribute,", style:",this.style,", options",this.options)}var R,Q;var P,M;var L,H;var A,G;var B=this.domNode.getElements("[class=_options]");for(P=0;P<B.length;P++){B[P].style.display="none"}if(!this.attribute){}Q=this.domNode.getElement("div[id=_filter_toggle]");if(Q){Q.checked=this.enabled}Q=this.domNode.getElement("div[id=_new_filter_toggle]");if(Q){Q=$(Q);if(this.getEnabledMask()){Q.addClass("checked")}else{Q.removeClass("checked")}}if(this.attribute){Q=this.domNode.getElement("select[id=_attribute_select]");for(M=0;M<Q.options.length;M++){R=Q.options[M];if(R.value===this.attribute){R.selected=true;break}}if(this.attribute==="+all"){this.style="+all"}else{var K=null;var C=this.attributeInfo["attributes"][this.attribute];Q=this.domNode.getElement("span[id=_attr_info]");Q.style.display="inline";if(C[1]==="number"||C[1]==="integer"){Q=getElementById(this.domNode,"_number");Q.style.display="inline";K=getElementById(this.domNode,"_number_select")}else{Q=getElementById(this.domNode,"_other");Q.style.display="inline";K=getElementById(this.domNode,"_other_select")}}if(this.style){if(K){for(M=0;M<K.options.length;M++){Q=K.options[M];if(Q.value===this.style){Q.selected=true;break}}}if(this.style==="+all"){Q=this.domNode.getElement("span[id=_as_color_style]");Q.style.display="inline"}else{if(this.style==="+each"){Q=this.domNode.getElement("span[id=_palette]");Q.style.display="inline";Q=this.domNode.getElement("select[id=_palette_select]");Q.selectedIndex=0}else{if(this.style==="graduated"){Q=getElementById(this.domNode,"_simple_graduated_spectrum");Q.style.display="inline";Q=getElementById(this.domNode,"_simple_from_to");Q.style.display="inline"}else{if(this.style==="linear"){Q=getElementById(this.domNode,"_from_to_with_range");Q.style.display="inline"}else{if(this.style==="predicate+between"){Q=getElementById(this.domNode,"_simple_predicate");Q.style.display="inline";Q=getElementById(this.domNode,"_above");Q.style.display="inline";Q=getElementById(this.domNode,"_between");Q.style.display="inline";Q=getElementById(this.domNode,"_below");Q.style.display="inline";Q=getElementById(this.domNode,"_as_color_style");Q.style.display="inline"}else{if(this.style==="predicate+equals"){Q=getElementById(this.domNode,"_simple_predicate");Q.style.display="inline";Q=getElementById(this.domNode,"_equals");Q.style.display="inline";Q=getElementById(this.domNode,"_as_color_style");Q.style.display="inline"}else{if(this.style==="predicate+above"){Q=getElementById(this.domNode,"_simple_predicate");Q.style.display="inline";Q=getElementById(this.domNode,"_above");Q.style.display="inline";Q=getElementById(this.domNode,"_as_color_style");Q.style.display="inline"}else{if(this.style==="predicate+below"){Q=getElementById(this.domNode,"_simple_predicate");Q.style.display="inline";Q=getElementById(this.domNode,"_below");Q.style.display="inline";Q=getElementById(this.domNode,"_as_color_style");Q.style.display="inline"}}}}}}}}}else{K.selectedIndex=0}var N=function(Y,T,c){var V=$(Y);var U,b;if(is_no_color(c)){b=0;U=null}else{if(is_rgba_string(c)){var Z=c.substr(6,2);var W=parseInt(Z,16);var X=W/255;var a=c.substr(0,6);b=X;U="#"+a}else{if(typeof console!=="undefined"){console.assert(false,"unexpected value in update swatch color:"+Json.toString(c));console.error("optionaVal:",c)}}}V.setStyle(T,U);V.setOpacity(b)};if(this.options){if(("lower" in this.options)&&("upper" in this.options)){var D=this.options["lower"];var F=this.options["upper"];if((D!==undefined)&&(D===F)){Q=getElementById(this.domNode,"_lower_and_upper");Q.value=D}}for(L in this.options){if(this.options.hasOwnProperty(L)){H=this.options[L];if(H===undefined){continue}if(H===null){continue}switch(L){case"stroke":var E=[21,21];H=String(H);Q=getElementById(this.domNode,"_stroke");if(Q){Q.value=H}Q=getElementById(this.domNode,"_as_color_stroke");console.assert(Q,"must have _color_stroke swatch");N(Q,"border-color",H);break;case"fill":H=String(H);Q=getElementById(this.domNode,"_fill");if(Q){Q.value=H}Q=getElementById(this.domNode,"_as_color_fill");console.assert(Q,"must have _color_stroke swatch");N(Q,"background-color",H);break;case"lower":H=String(H);Q=getElementById(this.domNode,"_lower");Q.value=H;break;case"upper":H=String(H);Q=getElementById(this.domNode,"_upper");Q.value=H;break;case"range_start":H=String(H);Q=getElementById(this.domNode,"_range_start");Q.value=H;break;case"range_end":H=String(H);Q=getElementById(this.domNode,"_range_end");Q.value=H;break;case"stroke_start":H=String(H);if(this.style==="graduated"){Q=getElementById(this.domNode,"_simple_from_color_stroke");console.assert(Q,"_color swatch should exist for graduated");N(Q,"border-color",H)}else{if(this.style==="linear"){Q=getElementById(this.domNode,"_complex_from_color_stroke");console.assert(Q,"_color_swatch should exist for linear");N(Q,"border-color",H)}else{Log.logDebug("this path not yet implemented")}}break;case"stroke_end":H=String(H);if(this.style==="graduated"){Q=getElementById(this.domNode,"_simple_to_color_stroke");console.assert(Q,"_color swatch should exist for graduated");N(Q,"border-color",H)}else{if(this.style==="linear"){Q=getElementById(this.domNode,"_complex_to_color_stroke");console.assert(Q,"_color swatch should exist for linear");N(Q,"border-color",H)}else{Log.logDebug("this path not yet implemented")}}break;case"fill_start":H=String(H);if(this.style==="graduated"){Q=getElementById(this.domNode,"_simple_from_color_fill");console.assert(Q,"_color swatch should exist for graduated");N(Q,"background-color",H)}else{if(this.style==="linear"){Q=getElementById(this.domNode,"_complex_from_color_fill");console.assert(Q,"_color swatch should exist for linear");N(Q,"background-color",H)}else{Log.logDebug("this path not yet implemented")}}break;case"fill_end":H=String(H);if(this.style==="graduated"){Q=getElementById(this.domNode,"_simple_to_color_fill");console.assert(Q,"_color swatch should exist for graduated");N(Q,"background-color",H)}else{if(this.style==="linear"){Q=getElementById(this.domNode,"_complex_to_color_fill");console.assert(Q,"_color swatch should exist for linear");N(Q,"background-color",H)}else{Log.logDebug("this path not yet implemented")}}break;case"num_buckets":H=String(H);Q=getElementById(this.domNode,"_num_graduations");console.assert(Q,"_num grads does not exist");Q.value=H;break;case"type":var S=false;H=String(H);if(this.style==="graduated"){Q=getElementById(this.domNode,"_graduation_select");S=$A(Q.options).some(function(U){var T=(U.value===H);if(T){U.selected=true}return T})}if(!S){Log.logDebug("Encounterd unhandled type option: k="+String(L)+", v="+String(H))}break;case"palette":H=String(H);Q=getElementById(this.domNode,"_palette_select");G=false;for(M=0;(!G)&&(M<Q.options.length);M++){A=Q.options[M];if(A.value===H){A.selected=true;G=true}}console.assert(G,"Encounterd unhandled option: k="+String(L)+", v="+String(H));break;default:break}}}var J=function(V,T){if(typeof console!=="undefined"){console.log("update image:",V,T)}if(!V){return }var U=new Ajax("/cbi/swatch/get_image_swatch",{"method":"get","onComplete":function(X){var b=Json.evaluate(X);var a="/tiles_data/swatches/"+b[0];var c;if(window.ie){c="-36px"}else{c="-42px"}var Z=new Element("img",{"styles":{"height":"21px","width":"21px","position":"relative","top":c},"src":a,"class":"image-swatch"});var W=$E(".fill",V);var Y=$E(".image-swatch",V);if(Y){Y.remove()}Z.injectAfter(W)}});U.request(Object.toQueryString(T))};var O,I;if(("stroke" in this.options)&&("fill" in this.options)){I=getElementById(this.domNode,"_as_color_swatch");J(I,{"stroke":this.options.stroke,"fill":this.options.fill,"symbol":this.options.symbol||"square","pattern":this.options.pattern||"solid"})}if(["linear","graduated"].contains(this.style)&&("stroke_start" in this.options)&&("fill_start" in this.options)){if(this.style==="graduated"){I=getElementById(this.domNode,"_simple_from_swatch")}else{if(this.style==="linear"){I=getElementById(this.domNode,"_complex_from_swatch")}}J(I,{"stroke":this.options.stroke_start,"fill":this.options.fill_start,"symbol":this.options.symbol||"square","pattern":this.options.pattern||"solid"})}if(["linear","graduated"].contains(this.style)&&("stroke_end" in this.options)&&("fill_end" in this.options)){if(this.style==="graduated"){I=getElementById(this.domNode,"_simple_to_swatch")}else{if(this.style==="linear"){I=getElementById(this.domNode,"_complex_to_swatch")}}J(I,{"stroke":this.options.stroke_end,"fill":this.options.fill_end,"symbol":this.options.symbol||"square","pattern":this.options.pattern||"solid"})}}}if(this.refreshing){Q=getElementById(this.domNode,"_swatch");if(Q){Q.style.display="block"}Q=getElementById(this.domNode,"_filter_toggle");if(Q){Q.style.display="none"}}else{Q=getElementById(this.domNode,"_swatch");if(Q){Q.style.display="none"}Q=getElementById(this.domNode,"_filter_toggle");if(Q){Q.style.display="inline"}}this.viewDirty=false};Layer.prototype.checkRepresentation=function(){if(!this.attribute){throw new Error("")}};Layer.prototype.loadFramework=function(){var D=function(F){var E=function(I,H){var G=Json.evaluate(I)[0];F.domNode.innerHTML=G;F.configureDOM();F.renderReady=true;F.renderHTML();F.parent.viewDirty=true;F.parent.renderHTML()};return E};var A;if(pageManager.getPageType()==="chart"){A="/cbi/maptool/page6"}else{A="/cbi/maptool/loadmapRule"}var C=D(this);var B=new Ajax(A,{data:Object.toQueryString({uuid:null}),method:"get",onComplete:C});B.request()};Layer.prototype.registerHandlers=function(){var F;var E,D,C;var B,A;C=(function(){this.parent.addVisibleLayer(0);this.viewDirty=true;this.renderHTML();this.parent.viewDirty=true;this.parent.renderHTML()}).bind(this);F=this.domNode.getElement("span[id=_plusbutton]");console.assert(F,"need plus button");F.addEvent("click",C);E=function(G){var H=function(){Log.logDebug("clicked minus button");G.parent.remove(G);G.viewDirty=true;G.renderHTML();G.parent.viewDirty=true;G.parent.renderHTML();mapManager.remove(G)};return H};F=this.domNode.getElement("span[id=_minusbutton]");console.assert(F,"need minus button");F.onclick=E(this);E=function(H,G){var I=function(){var J=H.attributeInfo["attributes"][H.attribute][4];showAttributeInfo($("attrinfoHolder"),G,J)};return I};F=this.domNode.getElement("span[id=_attr_info]");console.assert(F,"need attr_info button");F.onclick=E(this,F.getChildren()[0]);E=function(G){var H=function(){G.viewDirty=true;var J=this.options[this.selectedIndex].value;G.setAttribute(J);G.clearOptions();G.clearStyle();if(J==="+all"){G.setStyle("+all");if(G.attributeInfo.shape_types.contains("polyline")){G.setOption("fill",no_color_value)}else{G.setOption("fill","00ff00ff")}G.setOption("stroke","000000ff")}else{var I=G.attributeInfo["attributes"][G.attribute];if(I[1]==="text"){G.setStyle("+each")}}G.renderHTML()};return H};F=this.domNode.getElement("select[id=_attribute_select]");F.onchange=E(this);E=function(G){var H=function(L){G.colorTweaker.clearPatch();var I=G.style;var K=this.options[this.selectedIndex].value;G.viewDirty=true;G.setStyle(K);if(I&&(I.indexOf("predicate")===0)&&(K.indexOf("predicate")===0)){Log.logDebug("not clearing color");G.clearOption("upper");G.clearOption("lower")}else{G.clearOptions()}var J=G.attributeInfo["attributes"][G.attribute];Log.logDebug("atrinfo: "+Json.toString(J));switch(G.style){case"predicate+between":G.clearOptions();G.setOption("upper",J[3]);G.setOption("lower",J[2]);if(!G.options["stroke"]){G.setOption("stroke","000000ff")}if(!G.options["fill"]){if(G.attributeInfo.shape_types.contains("polyline")){G.setOption("fill",no_color_value)}else{G.setOption("fill","00ff00ff")}}break;case"predicate+equals":G.clearOptions();if(!G.options["stroke"]){G.setOption("stroke","000000ff")}if(!G.options["fill"]){if(G.attributeInfo.shape_types.contains("polyline")){G.setOption("fill",no_color_value)}else{G.setOption("fill","00ff00ff")}}break;case"predicate+above":G.clearOptions();G.setOption("lower",J[2]);if(!G.options["stroke"]){G.setOption("stroke","000000ff")}if(!G.options["fill"]){if(G.attributeInfo.shape_types.contains("polyline")){G.setOption("fill",no_color_value)}else{G.setOption("fill","00ff00ff")}}break;case"predicate+below":G.clearOptions();G.setOption("upper",J[3]);if(!G.options["stroke"]){G.setOption("stroke","000000ff")}if(!G.options["fill"]){if(G.attributeInfo.shape_types.contains("polyline")){G.setOption("fill",no_color_value)}else{G.setOption("fill","00ff00ff")}}break;case"linear":G.clearOptions();G.setOptions({"stroke_start":"000000ff","stroke_end":"000000ff","range_start":J[2],"range_end":J[3]});if(G.attributeInfo.shape_types.contains("polyline")){G.setOptions({"fill_start":no_color_value,"fill_end":no_color_value})}else{G.setOptions({"fill_start":"ff0000ff","fill_end":"000000ff"})}break;case"graduated":G.clearOptions();G.setOption("stroke_start","000000ff");G.setOption("stroke_end","000000ff");if(G.attributeInfo.shape_types.contains("polyline")){G.setOption("fill_start",no_color_value);G.setOption("fill_end",no_color_value)}else{G.setOption("fill_start","ff0000ff");G.setOption("fill_end","000000ff")}G.setOption("type","+quantiles");G.setOption("num_buckets",4);break;default:break}G.renderHTML()};return H};F=this.domNode.getElement("select[id=_other_select]");console.assert(F,"_other_select must be a member of this.domNode");F.onchange=E(this);F=this.domNode.getElement("select[id=_number_select]");console.assert(F,"_number_select must be a member of this.domNode");F.onchange=E(this);E=function(G){var H=function(I){G.viewDirty=true;G.setOption("type",this.options[this.selectedIndex].value);G.renderHTML()};return H};F=this.domNode.getElement("select[id=_graduation_select]");console.assert(F,"_graduation_select does not exist");F.onchange=E(this);E=function(G){var H=function(J){G.viewDirty=true;var I=parseInt(this.value,10);if(!isNaN(I)){G.setOption("num_buckets",I)}G.renderHTML()};return H};F=this.domNode.getElement("input[id=_num_graduations]");console.assert(F,"_num_graduations must exist");$(F).addEvent("change",E(this));E=function(G){var H=function(I){G.colorTweaker.clearPatch();G.viewDirty=true;G.setOption("palette",this.options[this.selectedIndex].value);G.renderHTML()};return H};F=this.domNode.getElement("select[id=_palette_select]");console.assert(F,"_palette_select must exist");F.onchange=E(this);E=function(G){var H=function(I){G.viewDirty=true;G.setEnabled(this.checked);if(G.enabled){mapManager.show(G)}else{mapManager.hide(G)}G.renderHTML()};return H};F=this.domNode.getElement("div[id=_filter_toggle]");if(F){F.onclick=E(this)}E=function(G){var H=function(I){if(!G.parent.getEnabledMask()){return }G.viewDirty=true;G.setEnabled(!G.enabled);if(G.enabled){mapManager.show(G)}else{mapManager.hide(G)}G.renderHTML()};return H};F=this.domNode.getElement("div[id=_new_filter_toggle]");if(F){$(F).addEvent("click",E(this))}else{}E=function(G,H){var I=function(J){G.viewDirty=true;G.setOption(H,parseFloat(this.value));G.renderHTML()};return I};F=this.domNode.getElement("input[id=_range_start]");console.assert(F,"_range_start must exist");F.onchange=E(this,"range_start");F=this.domNode.getElement("input[id=_range_end]");console.assert(F,"_range_end must exist");F.onchange=E(this,"range_end");E=function(G,I){var H=function(L){G.viewDirty=true;var K=parseNumber(this.value);if(isNaN(K)){K=0}for(var J=0;J<I.length;J++){G.setOption(I[J],K)}G.renderHTML()};return H};F=this.domNode.getElement("input[id=_lower]");console.assert(F,"lower must exist");F.onchange=E(this,["lower"]);F=this.domNode.getElement("input[id=_upper]");console.assert(F,"upper must exist");F.onchange=E(this,["upper"]);F=this.domNode.getElement("input[id=_lower_and_upper]");console.assert(F,"lower & upper must exist");F.onchange=E(this,["upper","lower"]);E=function(G,H){var I=function(J){G.viewDirty=true;G.setOption(H,this.value);G.renderHTML()};return I};D=function(G,I){var H=function(L){var J=I||"";console.log("shape types:",G.attributeInfo.shape_types);console.log("options:",G.options);var K={"polyline":G.attributeInfo.shape_types.contains("polyline"),"polygon":G.attributeInfo.shape_types.contains("polygon"),"point":G.attributeInfo.shape_types.contains("point"),"linewidth":G.options["linewidth"+J]||1,"radius":G.options["radius"+J]||10,"symbol":G.options["symbol"],"palettes":get_color_palettes(),"attached_to":this,"pattern":G.options["pattern"]||"solid"};showColorPicker($("popupHolder"),this,G.options["fill"+J],G.options["stroke"+J],function(N){Log.logDebug("recvd callback: "+Json.toString(N));G.viewDirty=true;for(var M in N){if(N.hasOwnProperty(M)){var O=N[M];if(is_rgb_string(O)){O=O+G.options[M].substr(6,2)}else{if(is_no_color(O)){}}G.setOption(M,O)}}G.renderHTML()},J,K)};return H};F=this.domNode.getElement("input[id=_stroke]");if(F){F.onchange=E(this,"stroke")}F=this.domNode.getElement("input[id=_fill]");if(F){F.onchange=E(this,"fill")}F=this.domNode.getElement("div[id=_as_color_swatch]");console.assert(F,"must have color swatch for as color");F.onclick=D(this,null);F=this.domNode.getElement("div[id=_simple_from_swatch]");console.assert(F,"huh");F.onclick=D(this,"_start");console.log("here i am");F=this.domNode.getElement("div[id=_simple_to_swatch]");console.assert(F,"huh");F.onclick=D(this,"_end");F=this.domNode.getElement("div[id=_complex_from_swatch]");console.assert(F,"huh");F.onclick=D(this,"_start");F=this.domNode.getElement("div[id=_complex_to_swatch]");console.assert(F,"huh");F.onclick=D(this,"_end");E=function(G){var H=function(I){var J=parseInt(this.value,10);if(isNaN(J)){Log.logDebug("ummm ... what?"+this.value);G.parent.viewDirty=true;G.parent.renderHTML();return }J=Math.max(J,0);J=Math.min(J,G.parent.layers.length-1);G.parent.remove(G);G.parent.add(G,J);G.viewDirty=true;G.renderHTML();G.parent.viewDirty=true;G.parent.renderHTML();mapManager.checkModels()};return H};F=this.domNode.getElement("input[id=_order]");console.assert(F,"_order element did not exist");$(F).addEvent("change",E(this));F=this.domNode.getElement("div[id=move_dn]");console.assert(F,"need a move down button");F.addEvent("click",function(){var G=this.domNode.getElement("input[id=_order]");G.value=(G.value.toInt()+1);G.fireEvent("change")}.bind(this));F=this.domNode.getElement("div[id=move_up]");console.assert(F,"need a move up button");F.addEvent("click",function(){var G=$(this.domNode).getElement("input[id=_order]");G.value=(G.value.toInt()-1);G.fireEvent("change")}.bind(this));this.colorTweaker.attachEvents()};Layer.prototype.hasRenderedId=function(){return(typeof this.constructor_args.key!==undefined)};Layer.prototype.getRenderedId=function(){return this.constructor_args.key};Layer.prototype.setRenderedId=function(A){this.constructor_args={key:A}};Layer.prototype.showIds=function(B){var C;var A,D=B.length;for(A=0;A<D;A++){C=getElementById(this.domNode,B[A]);if(C){C.style.display="inline"}}};Layer.prototype.hideIds=function(B){var C;var A,D=B.length;for(A=0;A<D;A++){C=getElementById(this.domNode,B[A]);if(C){C.style.display="none"}}};Layer.prototype.getPlusButton=function(){var A=this.domNode.getElement("span[id=_plusbutton]")};Layer.prototype.getMinusButton=function(){elt=layer.domNode.getElementById("span[id=_minusbutton]")}