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",{"styles":{"position":"relative"}});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){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(){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"){}mapManager.hide(this)}else{if(!(this.style==="raster")){A.addClass("checked")}if(this.style==="raster"){}mapManager.show(this)}};Layer.prototype.setVirtual=function(A){this.virtual=A};Layer.prototype.isVirtual=function(){return this.virtual};Layer.prototype.isComplete=function(){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(E,D,C,B){B=B||false;C=C||[];if(typeof console!=="undefined"){console.assert(typeof (D)!=="undefined")}if(is_no_color(E)){if(C){if(B){return D}else{return E}}else{return D}}var A;if($type(E)==="object"){A={};for(k in E){if(E.hasOwnProperty(k)){if(C){A[k]=replaceNoColor(E[k],D)}else{A[k]=replaceNoColor(E[k],D,C,true)}}}}else{if($type(E)==="array"){A=E.map(function(F){return replaceNoColor(F,D,C)})}else{A=E}}return A};var replaceNull=function(C,B){console.assert(typeof (B)!=="undefined");if(C===null){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(){var C=this.options;if(this.colorTweaker){var E;if(typeof (this.colorTweaker)!=="undefined"){E=this.colorTweaker.getPatch()}else{E=[]}if(E.length>0){C["patch"]=E}else{delete C["patch"]}}else{}var D=["fill","stroke","fill_start","fill_end","stroke_end"];var A=replaceNoColor(C,null,D);if(can_have_bearing(this)){A.bearing=get_bearing(this.parent.u,this.id)}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(){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]");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);this.registerHandlers()};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={};clear_bearing(this.parent.u,this.id);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"){}var U,T;var S,P;var O,J;var A,H;var B=this.domNode.getElements("[class=_options]");for(S=0;S<B.length;S++){B[S].style.display="none"}if(!this.attribute){}T=this.domNode.getElement("div[id=_filter_toggle]");if(T){T.checked=this.enabled}T=this.domNode.getElement("div[id=_new_filter_toggle]");if(T){T=$(T);if(this.getEnabledMask()){T.addClass("checked")}else{T.removeClass("checked")}}if(this.attribute){T=this.domNode.getElement("select[id=_attribute_select]");for(P=0;P<T.options.length;P++){U=T.options[P];if(U.value===this.attribute){U.selected=true;break}}if(this.attribute==="+all"){this.style="+all"}else{var N=null;var C=this.attributeInfo["attributes"][this.attribute];T=this.domNode.getElement("span[id=_attr_info]");T.style.display="inline";if(C[1]==="number"||C[1]==="integer"){T=getElementById(this.domNode,"_number");T.style.display="inline";N=getElementById(this.domNode,"_number_select")}else{T=getElementById(this.domNode,"_other");T.style.display="inline";N=getElementById(this.domNode,"_other_select")}}if(this.style){if(N){for(P=0;P<N.options.length;P++){T=N.options[P];if(T.value===this.style){T.selected=true;break}}}if(this.style==="+all"){T=this.domNode.getElement("span[id=_as_color_style]");T.style.display="inline"}else{if(this.style==="+each"){T=this.domNode.getElement("span[id=_palette]");T.style.display="inline";T=this.domNode.getElement("select[id=_palette_select]");T.selectedIndex=0}else{if(this.style==="graduated"){T=getElementById(this.domNode,"_simple_graduated_spectrum");T.style.display="inline";T=getElementById(this.domNode,"_simple_from_to");T.style.display="inline"}else{if(this.style==="linear"){T=getElementById(this.domNode,"_from_to_with_range");T.style.display="inline"}else{if(this.style==="predicate+between"){T=getElementById(this.domNode,"_simple_predicate");T.style.display="inline";T=getElementById(this.domNode,"_above");T.style.display="inline";T=getElementById(this.domNode,"_between");T.style.display="inline";T=getElementById(this.domNode,"_below");T.style.display="inline";T=getElementById(this.domNode,"_as_color_style");T.style.display="inline"}else{if(this.style==="predicate+equals"){T=getElementById(this.domNode,"_simple_predicate");T.style.display="inline";T=getElementById(this.domNode,"_equals");T.style.display="inline";T=getElementById(this.domNode,"_as_color_style");T.style.display="inline"}else{if(this.style==="predicate+above"){T=getElementById(this.domNode,"_simple_predicate");T.style.display="inline";T=getElementById(this.domNode,"_above");T.style.display="inline";T=getElementById(this.domNode,"_as_color_style");T.style.display="inline"}else{if(this.style==="predicate+below"){T=getElementById(this.domNode,"_simple_predicate");T.style.display="inline";T=getElementById(this.domNode,"_below");T.style.display="inline";T=getElementById(this.domNode,"_as_color_style");T.style.display="inline"}}}}}}}}}else{N.selectedIndex=0}var Q=function(b,W,g){var Y=$(b);var X,f;if(is_no_color(g)){f=0;X=null}else{if(is_rgba_string(g)){var c=g.substr(6,2);var Z=parseInt(c,16);var a=Z/255;var d=g.substr(0,6);f=a;X="#"+d}else{if(typeof console!=="undefined"){console.assert(false,"unexpected value in update swatch color:"+Json.toString(g));console.error("optionaVal:",g)}}}Y.setStyle(W,X);Y.setOpacity(f)};if(this.options){if(("lower" in this.options)&&("upper" in this.options)){var E=this.options["lower"];var G=this.options["upper"];if((E!==undefined)&&(E===G)){T=getElementById(this.domNode,"_lower_and_upper");T.value=E}}for(O in this.options){if(this.options.hasOwnProperty(O)){J=this.options[O];if(J===undefined){continue}if(J===null){continue}switch(O){case"stroke":var F=[21,21];J=String(J);T=getElementById(this.domNode,"_stroke");if(T){T.value=J}T=getElementById(this.domNode,"_as_color_stroke");console.assert(T,"must have _color_stroke swatch");Q(T,"border-color",J);break;case"fill":J=String(J);T=getElementById(this.domNode,"_fill");if(T){T.value=J}T=getElementById(this.domNode,"_as_color_fill");console.assert(T,"must have _color_stroke swatch");Q(T,"background-color",J);break;case"lower":J=String(J);T=getElementById(this.domNode,"_lower");T.value=J;break;case"upper":J=String(J);T=getElementById(this.domNode,"_upper");T.value=J;break;case"range_start":J=String(J);T=getElementById(this.domNode,"_range_start");T.value=J;break;case"range_end":J=String(J);T=getElementById(this.domNode,"_range_end");T.value=J;break;case"stroke_start":J=String(J);if(this.style==="graduated"){T=getElementById(this.domNode,"_simple_from_color_stroke");console.assert(T,"_color swatch should exist for graduated");Q(T,"border-color",J)}else{if(this.style==="linear"){T=getElementById(this.domNode,"_complex_from_color_stroke");console.assert(T,"_color_swatch should exist for linear");Q(T,"border-color",J)}else{Log.logDebug("this path not yet implemented")}}break;case"stroke_end":J=String(J);if(this.style==="graduated"){T=getElementById(this.domNode,"_simple_to_color_stroke");console.assert(T,"_color swatch should exist for graduated");Q(T,"border-color",J)}else{if(this.style==="linear"){T=getElementById(this.domNode,"_complex_to_color_stroke");console.assert(T,"_color swatch should exist for linear");Q(T,"border-color",J)}else{Log.logDebug("this path not yet implemented")}}break;case"fill_start":J=String(J);if(this.style==="graduated"){T=getElementById(this.domNode,"_simple_from_color_fill");console.assert(T,"_color swatch should exist for graduated");Q(T,"background-color",J)}else{if(this.style==="linear"){T=getElementById(this.domNode,"_complex_from_color_fill");console.assert(T,"_color swatch should exist for linear");Q(T,"background-color",J)}else{Log.logDebug("this path not yet implemented")}}break;case"fill_end":J=String(J);if(this.style==="graduated"){T=getElementById(this.domNode,"_simple_to_color_fill");console.assert(T,"_color swatch should exist for graduated");Q(T,"background-color",J)}else{if(this.style==="linear"){T=getElementById(this.domNode,"_complex_to_color_fill");console.assert(T,"_color swatch should exist for linear");Q(T,"background-color",J)}else{Log.logDebug("this path not yet implemented")}}break;case"num_buckets":J=String(J);T=getElementById(this.domNode,"_num_graduations");console.assert(T,"_num grads does not exist");T.value=J;break;case"type":var V=false;J=String(J);if(this.style==="graduated"){T=getElementById(this.domNode,"_graduation_select");V=$A(T.options).some(function(X){var W=(X.value===J);if(W){X.selected=true}return W})}if(!V){Log.logDebug("Encounterd unhandled type option: k="+String(O)+", v="+String(J))}break;case"palette":J=String(J);T=getElementById(this.domNode,"_palette_select");H=false;for(P=0;(!H)&&(P<T.options.length);P++){A=T.options[P];if(A.value===J){A.selected=true;H=true}}console.assert(H,"Encounterd unhandled option: k="+String(O)+", v="+String(J));break;default:break}}}var M=function(Y,W){if(typeof console!=="undefined"){}if(!Y){return }var X=new Ajax("/cbi/swatch/get_image_swatch",{"method":"get","onComplete":function(a){var e=Json.evaluate(a);var d="/tiles_data/swatches/"+e[0];var f;if(window.ie){f="-36px"}else{f="-42px"}var c=new Element("img",{"styles":{"height":"21px","width":"21px","position":"relative","top":f},"src":d,"class":"image-swatch"});var Z=$E(".fill",Y);var b=$E(".image-swatch",Y);if(b){b.remove()}c.injectAfter(Z)}});X.request(Object.toQueryString(W))};var D;var R,L,K=false;var I=get_bearing(this.parent.u,this.id);if(("stroke" in this.options)&&("fill" in this.options)){L=getElementById(this.domNode,"_as_color_swatch");D={"stroke":this.options.stroke,"fill":this.options.fill,"symbol":this.options.symbol||"square","pattern":this.options.pattern||"solid"};if(I){D["bearing"]=45}M(L,D)}if(["linear","graduated"].contains(this.style)&&("stroke_start" in this.options)&&("fill_start" in this.options)){if(this.style==="graduated"){L=getElementById(this.domNode,"_simple_from_swatch")}else{if(this.style==="linear"){L=getElementById(this.domNode,"_complex_from_swatch")}}D={"stroke":this.options.stroke_start,"fill":this.options.fill_start,"symbol":this.options.symbol||"square","pattern":this.options.pattern||"solid"};if(I){D["bearing"]=45}M(L,D)}if(["linear","graduated"].contains(this.style)&&("stroke_end" in this.options)&&("fill_end" in this.options)){if(this.style==="graduated"){L=getElementById(this.domNode,"_simple_to_swatch")}else{if(this.style==="linear"){L=getElementById(this.domNode,"_complex_to_swatch")}}D={"stroke":this.options.stroke_end,"fill":this.options.fill_end,"symbol":this.options.symbol||"square","pattern":this.options.pattern||"solid"};if(I){D["bearing"]=45}M(L,D)}}}if(this.refreshing){T=getElementById(this.domNode,"_swatch");if(T){T.style.display="block"}T=getElementById(this.domNode,"_filter_toggle");if(T){T.style.display="none"}}else{T=getElementById(this.domNode,"_swatch");if(T){T.style.display="none"}T=getElementById(this.domNode,"_filter_toggle");if(T){T.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||"";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"};if(can_have_bearing(G)){K["bearing"]=get_bearing(G.parent.u,G.id)}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(M==="bearing"){if(typeof console!=="undefined"){console.log("bearing:",N.bearing,G.id,G.parent.u)}if(N.bearing){set_bearing(G.parent.u,G.id)}else{clear_bearing(G.parent.u,G.id)}continue}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");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]")}
