var Prototype={Version:"1.4.0_rc2",emptyFunction:function(){
},K:function(x){
return x;
}};
var Class={create:function(_2){
return function(){
if(_2){
if(this[_2+"_constructor"]){
this[_2+"_constructor"].apply(this,arguments);
}else{
alert("Prototype: constructor - "+_2+"_constructor not defined");
}
this.__className=_2;
this.getClassName=function(){
return this.__className;
};
}else{
this.initialize.apply(this,arguments);
this.getClassName=function(){
return "anonymous";
};
}
};
}};
var Abstract=new Object();
Object.extend=function(_3,_4){
for(property in _4){
_3[property]=_4[property];
}
return _3;
};
Object.inspect=function(_5){
try{
if(_5==undefined){
return "undefined";
}
if(_5==null){
return "null";
}
return _5.inspect?_5.inspect():_5.toString();
}
catch(e){
if(e instanceof RangeError){
return "...";
}
throw e;
}
};
Function.prototype.bind=function(_6){
var _7=this;
return function(){
return _7.apply(_6,arguments);
};
};
Function.prototype.bindAsEventListener=function(_8){
var _9=this;
return function(_a){
return _9.call(_8,_a||window.event);
};
};
Object.extend(Number.prototype,{toColorPart:function(){
var _b=this.toString(16);
if(this<16){
return "0"+_b;
}
return _b;
},succ:function(){
return this+1;
},times:function(_c){
$R(0,this,true).each(_c);
return this;
}});
var Try={these:function(){
var _d;
for(var i=0;i<arguments.length;i++){
var _f=arguments[i];
try{
_d=_f();
break;
}
catch(e){
}
}
return _d;
}};
var PeriodicalExecuter=Class.create();
PeriodicalExecuter.prototype={initialize:function(_10,_11){
this.callback=_10;
this.frequency=_11;
this.currentlyExecuting=false;
this.registerCallback();
},registerCallback:function(){
setInterval(this.onTimerEvent.bind(this),this.frequency*1000);
},onTimerEvent:function(){
if(!this.currentlyExecuting){
try{
this.currentlyExecuting=true;
this.callback();
}
finally{
this.currentlyExecuting=false;
}
}
}};
function $(){
var _12=new Array();
for(var i=0;i<arguments.length;i++){
var _14=arguments[i];
if(typeof _14=="string"){
_14=document.getElementById(_14);
}
if(arguments.length==1){
return _14;
}
_12.push(_14);
}
return _12;
}
Object.extend(String.prototype,{stripTags:function(){
return this.replace(/<\/?[^>]+>/gi,"");
},escapeHTML:function(){
var div=document.createElement("div");
var _16=document.createTextNode(this);
div.appendChild(_16);
return div.innerHTML;
},unescapeHTML:function(){
var div=document.createElement("div");
div.innerHTML=this.stripTags();
return div.childNodes[0]?div.childNodes[0].nodeValue:"";
},toQueryParams:function(){
var _18=this.match(/^\??(.*)$/)[1].split("&");
return _18.inject({},function(_19,_1a){
var _1b=_1a.split("=");
_19[_1b[0]]=_1b[1];
return _19;
});
},toArray:function(){
return this.split("");
},camelize:function(){
var _1c=this.split("-");
if(_1c.length==1){
return _1c[0];
}
var _1d=this.indexOf("-")==0?_1c[0].charAt(0).toUpperCase()+_1c[0].substring(1):_1c[0];
for(var i=1,len=_1c.length;i<len;i++){
var s=_1c[i];
_1d+=s.charAt(0).toUpperCase()+s.substring(1);
}
return _1d;
},inspect:function(){
return "'"+this.replace("\\","\\\\").replace("'","\\'")+"'";
}});
String.prototype.parseQuery=String.prototype.toQueryParams;
var $break=new Object();
var $continue=new Object();
var Enumerable={each:function(_21){
var _22=0;
try{
this._each(function(_23){
try{
_21(_23,_22++);
}
catch(e){
if(e!=$continue){
throw e;
}
}
});
}
catch(e){
if(e!=$break){
throw e;
}
}
},all:function(_24){
var _25=true;
this.each(function(_26,_27){
if(!(_25&=(_24||Prototype.K)(_26,_27))){
throw $break;
}
});
return _25;
},any:function(_28){
var _29=true;
this.each(function(_2a,_2b){
if(_29&=(_28||Prototype.K)(_2a,_2b)){
throw $break;
}
});
return _29;
},collect:function(_2c){
var _2d=[];
this.each(function(_2e,_2f){
_2d.push(_2c(_2e,_2f));
});
return _2d;
},detect:function(_30){
var _31;
this.each(function(_32,_33){
if(_30(_32,_33)){
_31=_32;
throw $break;
}
});
return _31;
},findAll:function(_34){
var _35=[];
this.each(function(_36,_37){
if(_34(_36,_37)){
_35.push(_36);
}
});
return _35;
},grep:function(_38,_39){
var _3a=[];
this.each(function(_3b,_3c){
var _3d=_3b.toString();
if(_3d.match(_38)){
_3a.push((_39||Prototype.K)(_3b,_3c));
}
});
return _3a;
},include:function(_3e){
var _3f=false;
this.each(function(_40){
if(_40==_3e){
_3f=true;
throw $break;
}
});
return _3f;
},inject:function(_41,_42){
this.each(function(_43,_44){
_41=_42(_41,_43,_44);
});
return _41;
},invoke:function(_45){
var _46=$A(arguments).slice(1);
return this.collect(function(_47){
return _47[_45].apply(_47,_46);
});
},max:function(_48){
var _49;
this.each(function(_4a,_4b){
_4a=(_48||Prototype.K)(_4a,_4b);
if(_4a>=(_49||_4a)){
_49=_4a;
}
});
return _49;
},min:function(_4c){
var _4d;
this.each(function(_4e,_4f){
_4e=(_4c||Prototype.K)(_4e,_4f);
if(_4e<=(_4d||_4e)){
_4d=_4e;
}
});
return _4d;
},partition:function(_50){
var _51=[],_52=[];
this.each(function(_53,_54){
((_50||Prototype.K)(_53,_54)?_51:_52).push(_53);
});
return [_51,_52];
},pluck:function(_55){
var _56=[];
this.each(function(_57,_58){
_56.push(_57[_55]);
});
return _56;
},reject:function(_59){
var _5a=[];
this.each(function(_5b,_5c){
if(!_59(_5b,_5c)){
_5a.push(_5b);
}
});
return _5a;
},sortBy:function(_5d){
return this.collect(function(_5e,_5f){
return {value:_5e,criteria:_5d(_5e,_5f)};
}).sort(function(_60,_61){
var a=_60.criteria,b=_61.criteria;
return a<b?-1:a>b?1:0;
}).pluck("value");
},toArray:function(){
return this.collect(Prototype.K);
},zip:function(){
var _64=Prototype.K,_65=$A(arguments);
if(typeof _65.last()=="function"){
_64=_65.pop();
}
var _66=[this].concat(_65).map($A);
return this.map(function(_67,_68){
_64(_67=_66.pluck(_68));
return _67;
});
},inspect:function(){
return "#<Enumerable:"+this.toArray().inspect()+">";
}};
Object.extend(Enumerable,{map:Enumerable.collect,find:Enumerable.detect,select:Enumerable.findAll,member:Enumerable.include,entries:Enumerable.toArray});
var $A=Array.from=function(_69){
if(_69.toArray){
return _69.toArray();
}else{
var _6a=[];
for(var i=0;i<_69.length;i++){
_6a.push(_69[i]);
}
return _6a;
}
};
Object.extend(Array.prototype,Enumerable);
Object.extend(Array.prototype,{_each:function(_6c){
for(var i=0;i<this.length;i++){
_6c(this[i]);
}
},first:function(){
return this[0];
},last:function(){
return this[this.length-1];
},compact:function(){
return this.select(function(_6e){
return _6e!=undefined||_6e!=null;
});
},flatten:function(){
return this.inject([],function(_6f,_70){
return _6f.concat(_70.constructor==Array?_70.flatten():[_70]);
});
},without:function(){
var _71=$A(arguments);
return this.select(function(_72){
return !_71.include(_72);
});
},indexOf:function(_73){
for(var i=0;i<this.length;i++){
if(this[i]==_73){
return i;
}
}
return -1;
},reverse:function(){
var _75=[];
for(var i=this.length;i>0;i--){
_75.push(this[i-1]);
}
return _75;
},inspect:function(){
return "["+this.map(Object.inspect).join(", ")+"]";
}});
var Hash={_each:function(_77){
for(key in this){
var _78=this[key];
if(typeof _78=="function"){
continue;
}
var _79=[key,_78];
_79.key=key;
_79.value=_78;
_77(_79);
}
},keys:function(){
return this.pluck("key");
},values:function(){
return this.pluck("value");
},merge:function(_7a){
return $H(_7a).inject($H(this),function(_7b,_7c){
_7b[_7c.key]=_7c.value;
return _7b;
});
},toQueryString:function(){
return this.map(function(_7d){
return _7d.map(encodeURIComponent).join("=");
}).join("&");
},inspect:function(){
return "#<Hash:{"+this.map(function(_7e){
return _7e.map(Object.inspect).join(": ");
}).join(", ")+"}>";
}};
function $H(_7f){
var _80=Object.extend({},_7f||{});
Object.extend(_80,Enumerable);
Object.extend(_80,Hash);
return _80;
}
var Range=Class.create();
Object.extend(Range.prototype,Enumerable);
Object.extend(Range.prototype,{initialize:function(_81,end,_83){
this.start=_81;
this.end=end;
this.exclusive=_83;
},_each:function(_84){
var _85=this.start;
do{
_84(_85);
_85=_85.succ();
}while(this.include(_85));
},include:function(_86){
if(_86<this.start){
return false;
}
if(this.exclusive){
return _86<this.end;
}
return _86<=this.end;
}});
var $R=function(_87,end,_89){
return new Range(_87,end,_89);
};
var Ajax={getTransport:function(){
return Try.these(function(){
return new ActiveXObject("Msxml2.XMLHTTP");
},function(){
return new ActiveXObject("Microsoft.XMLHTTP");
},function(){
return new XMLHttpRequest();
})||false;
},activeRequestCount:0};
Ajax.Responders={responders:[],_each:function(_8a){
this.responders._each(_8a);
},register:function(_8b){
if(!this.include(_8b)){
this.responders.push(_8b);
}
},unregister:function(_8c){
this.responders=this.responders.without(_8c);
},dispatch:function(_8d,_8e,_8f,_90){
this.each(function(_91){
if(_91[_8d]&&typeof _91[_8d]=="function"){
try{
_91[_8d].apply(_91,[_8e,_8f,_90]);
}
catch(e){
}
}
});
}};
Object.extend(Ajax.Responders,Enumerable);
Ajax.Responders.register({onCreate:function(){
Ajax.activeRequestCount++;
},onComplete:function(){
Ajax.activeRequestCount--;
}});
Ajax.Base=function(){
};
Ajax.Base.prototype={setOptions:function(_92){
this.options={method:"post",asynchronous:true,parameters:""};
Object.extend(this.options,_92||{});
},responseIsSuccess:function(){
try{
var _93=this.transport.status==undefined||this.transport.status==0||(this.transport.status>=200&&this.transport.status<300);
return _93;
}
catch(e){
return false;
}
},responseIsFailure:function(){
return !this.responseIsSuccess();
}};
Ajax.Request=Class.create();
Ajax.Request.Events=["Uninitialized","Loading","Loaded","Interactive","Complete"];
Ajax.Request.prototype=Object.extend(new Ajax.Base(),{initialize:function(url,_95){
this.transport=Ajax.getTransport();
this.setOptions(_95);
this.request(url);
},request:function(url){
var _97=this.options.parameters||"";
if(_97.length>0){
_97+="&_=";
}
try{
this.url=url;
if(this.options.method=="get"&&_97.length>0){
this.url+=(this.url.match(/\?/)?"&":"?")+_97;
}
Ajax.Responders.dispatch("onCreate",this,this.transport);
this.transport.open(this.options.method,this.url,this.options.asynchronous);
if(this.options.asynchronous){
this.transport.onreadystatechange=this.onStateChange.bind(this);
setTimeout((function(){
this.respondToReadyState(1);
}).bind(this),10);
}
this.setRequestHeaders();
var _98=this.options.postBody?this.options.postBody:_97;
this.transport.send(this.options.method=="post"?_98:null);
}
catch(e){
(this.options.onException||Prototype.emptyFunction)(this,e);
Ajax.Responders.dispatch("onException",this,e);
}
},setRequestHeaders:function(){
var _99=["X-Requested-With","XMLHttpRequest","X-Prototype-Version",Prototype.Version];
if(this.options.method=="post"){
_99.push("Content-type","application/x-www-form-urlencoded");
if(this.transport.overrideMimeType){
_99.push("Connection","close");
}
}
if(this.options.requestHeaders){
_99.push.apply(_99,this.options.requestHeaders);
}
for(var i=0;i<_99.length;i+=2){
this.transport.setRequestHeader(_99[i],_99[i+1]);
}
},onStateChange:function(){
var _9b=this.transport.readyState;
if(_9b!=1){
this.respondToReadyState(this.transport.readyState);
}
},evalJSON:function(){
try{
var _9c=this.transport.getResponseHeader("X-JSON"),_9d;
_9d=eval(_9c);
return _9d;
}
catch(e){
}
},respondToReadyState:function(_9e){
var _9f=Ajax.Request.Events[_9e];
var _a0=this.transport,_a1=this.evalJSON();
if(_9f=="Complete"){
try{
(this.options["on"+this.transport.status]||this.options["on"+(this.responseIsSuccess()?"Success":"Failure")]||Prototype.emptyFunction)(_a0,_a1);
}
catch(e){
this.options["onException"](_a0,_a1);
}
}
(this.options["on"+_9f]||Prototype.emptyFunction)(_a0,_a1);
Ajax.Responders.dispatch("on"+_9f,this,_a0,_a1);
if(_9f=="Complete"){
this.transport.onreadystatechange=Prototype.emptyFunction;
}
}});
Ajax.Updater=Class.create();
Ajax.Updater.ScriptFragment="(?:<script.*?>)((\n|.)*?)(?:</script>)";
Object.extend(Object.extend(Ajax.Updater.prototype,Ajax.Request.prototype),{initialize:function(_a2,url,_a4){
this.containers={success:_a2.success?$(_a2.success):$(_a2),failure:_a2.failure?$(_a2.failure):(_a2.success?null:$(_a2))};
this.transport=Ajax.getTransport();
this.setOptions(_a4);
var _a5=this.options.onComplete||Prototype.emptyFunction;
this.options.onComplete=(function(_a6,_a7){
this.updateContent();
_a5(_a6,_a7);
}).bind(this);
this.request(url);
},updateContent:function(){
var _a8=this.responseIsSuccess()?this.containers.success:this.containers.failure;
var _a9=new RegExp(Ajax.Updater.ScriptFragment,"img");
var _aa=this.transport.responseText.replace(_a9,"");
var _ab=this.transport.responseText.match(_a9);
if(_a8){
if(this.options.insertion){
new this.options.insertion(_a8,_aa);
}else{
_a8.innerHTML=_aa;
}
}
if(this.responseIsSuccess()){
if(this.onComplete){
setTimeout(this.onComplete.bind(this),10);
}
}
if(this.options.evalScripts&&_ab){
_a9=new RegExp(Ajax.Updater.ScriptFragment,"im");
setTimeout((function(){
for(var i=0;i<_ab.length;i++){
eval(_ab[i].match(_a9)[1]);
}
}).bind(this),10);
}
}});
Ajax.PeriodicalUpdater=Class.create();
Ajax.PeriodicalUpdater.prototype=Object.extend(new Ajax.Base(),{initialize:function(_ad,url,_af){
this.setOptions(_af);
this.onComplete=this.options.onComplete;
this.frequency=(this.options.frequency||2);
this.decay=(this.options.decay||1);
this.updater={};
this.container=_ad;
this.url=url;
this.start();
},start:function(){
this.options.onComplete=this.updateComplete.bind(this);
this.onTimerEvent();
},stop:function(){
this.updater.onComplete=undefined;
clearTimeout(this.timer);
(this.onComplete||Prototype.emptyFunction).apply(this,arguments);
},updateComplete:function(_b0){
if(this.options.decay){
this.decay=(_b0.responseText==this.lastText?this.decay*this.options.decay:1);
this.lastText=_b0.responseText;
}
this.timer=setTimeout(this.onTimerEvent.bind(this),this.decay*this.frequency*1000);
},onTimerEvent:function(){
this.updater=new Ajax.Updater(this.container,this.url,this.options);
}});
document.getElementsByClassName=function(_b1,_b2){
var _b3=($(_b2)||document.body).getElementsByTagName("*");
return $A(_b3).inject([],function(_b4,_b5){
if(_b5.className.match(new RegExp("(^|\\s)"+_b1+"(\\s|$)"))){
_b4.push(_b5);
}
return _b4;
});
};
if(!window.Element){
var Element=new Object();
}
Object.extend(Element,{visible:function(_b6){
return $(_b6).style.display!="none";
},toggle:function(){
for(var i=0;i<arguments.length;i++){
var _b8=$(arguments[i]);
Element[Element.visible(_b8)?"hide":"show"](_b8);
}
},hide:function(){
for(var i=0;i<arguments.length;i++){
var _ba=$(arguments[i]);
_ba.style.display="none";
}
},show:function(){
for(var i=0;i<arguments.length;i++){
var _bc=$(arguments[i]);
_bc.style.display="";
}
},remove:function(_bd){
_bd=$(_bd);
_bd.parentNode.removeChild(_bd);
},getHeight:function(_be){
_be=$(_be);
return _be.offsetHeight;
},classNames:function(_bf){
return new Element.ClassNames(_bf);
},hasClassName:function(_c0,_c1){
if(!(_c0=$(_c0))){
return;
}
return Element.classNames(_c0).include(_c1);
},addClassName:function(_c2,_c3){
if(!(_c2=$(_c2))){
return;
}
return Element.classNames(_c2).add(_c3);
},removeClassName:function(_c4,_c5){
if(!(_c4=$(_c4))){
return;
}
return Element.classNames(_c4).remove(_c5);
},cleanWhitespace:function(_c6){
_c6=$(_c6);
for(var i=0;i<_c6.childNodes.length;i++){
var _c8=_c6.childNodes[i];
if(_c8.nodeType==3&&!/\S/.test(_c8.nodeValue)){
Element.remove(_c8);
}
}
},empty:function(_c9){
return $(_c9).innerHTML.match(/^\s*$/);
},scrollTo:function(_ca){
_ca=$(_ca);
var x=_ca.x?_ca.x:_ca.offsetLeft,y=_ca.y?_ca.y:_ca.offsetTop;
window.scrollTo(x,y);
},getStyle:function(_cd,_ce){
_cd=$(_cd);
var _cf=_cd.style[_ce.camelize()];
if(!_cf){
if(document.defaultView&&document.defaultView.getComputedStyle){
var css=document.defaultView.getComputedStyle(_cd,null);
_cf=css?css.getPropertyValue(_ce):null;
}else{
if(_cd.currentStyle){
_cf=_cd.currentStyle[_ce.camelize()];
}
}
}
if(window.opera&&["left","top","right","bottom"].include(_ce)){
if(Element.getStyle(_cd,"position")=="static"){
_cf="auto";
}
}
return _cf=="auto"?null:_cf;
},getDimensions:function(_d1){
_d1=$(_d1);
if(Element.getStyle(_d1,"display")!="none"){
return {width:_d1.offsetWidth,height:_d1.offsetHeight};
}
var els=_d1.style;
var _d3=els.visibility;
var _d4=els.position;
els.visibility="hidden";
els.position="absolute";
els.display="";
var _d5=_d1.clientWidth;
var _d6=_d1.clientHeight;
els.display="none";
els.position=_d4;
els.visibility=_d3;
return {width:_d5,height:_d6};
},makePositioned:function(_d7){
_d7=$(_d7);
var pos=Element.getStyle(_d7,"position");
if(pos=="static"||!pos){
_d7._madePositioned=true;
_d7.style.position="relative";
if(window.opera){
_d7.style.top=0;
_d7.style.left=0;
}
}
},undoPositioned:function(_d9){
_d9=$(_d9);
if(_d9._madePositioned){
_d9._madePositioned=undefined;
_d9.style.position=_d9.style.top=_d9.style.left=_d9.style.bottom=_d9.style.right="";
}
},makeClipping:function(_da){
_da=$(_da);
if(_da._overflow){
return;
}
_da._overflow=_da.style.overflow;
if((Element.getStyle(_da,"overflow")||"visible")!="hidden"){
_da.style.overflow="hidden";
}
},undoClipping:function(_db){
_db=$(_db);
if(_db._overflow){
return;
}
_db.style.overflow=_db._overflow;
_db._overflow=undefined;
}});
var Toggle=new Object();
Toggle.display=Element.toggle;
Abstract.Insertion=function(_dc){
this.adjacency=_dc;
};
Abstract.Insertion.prototype={initialize:function(_dd,_de){
this.element=$(_dd);
this.content=_de;
if(this.adjacency&&this.element.insertAdjacentHTML){
try{
this.element.insertAdjacentHTML(this.adjacency,this.content);
}
catch(e){
if(this.element.tagName.toLowerCase()=="tbody"){
this.insertContent(this.contentFromAnonymousTable());
}else{
throw e;
}
}
}else{
this.range=this.element.ownerDocument.createRange();
if(this.initializeRange){
this.initializeRange();
}
this.insertContent([this.range.createContextualFragment(this.content)]);
}
},contentFromAnonymousTable:function(){
var div=document.createElement("div");
div.innerHTML="<table><tbody>"+this.content+"</tbody></table>";
return $A(div.childNodes[0].childNodes[0].childNodes);
}};
var Insertion=new Object();
Insertion.Before=Class.create();
Insertion.Before.prototype=Object.extend(new Abstract.Insertion("beforeBegin"),{initializeRange:function(){
this.range.setStartBefore(this.element);
},insertContent:function(_e0){
_e0.each((function(_e1){
this.element.parentNode.insertBefore(_e1,this.element);
}).bind(this));
}});
Insertion.Top=Class.create();
Insertion.Top.prototype=Object.extend(new Abstract.Insertion("afterBegin"),{initializeRange:function(){
this.range.selectNodeContents(this.element);
this.range.collapse(true);
},insertContent:function(_e2){
_e2.reverse().each((function(_e3){
this.element.insertBefore(_e3,this.element.firstChild);
}).bind(this));
}});
Insertion.Bottom=Class.create();
Insertion.Bottom.prototype=Object.extend(new Abstract.Insertion("beforeEnd"),{initializeRange:function(){
this.range.selectNodeContents(this.element);
this.range.collapse(this.element);
},insertContent:function(_e4){
_e4.each((function(_e5){
this.element.appendChild(_e5);
}).bind(this));
}});
Insertion.After=Class.create();
Insertion.After.prototype=Object.extend(new Abstract.Insertion("afterEnd"),{initializeRange:function(){
this.range.setStartAfter(this.element);
},insertContent:function(_e6){
_e6.each((function(_e7){
this.element.parentNode.insertBefore(_e7,this.element.nextSibling);
}).bind(this));
}});
Element.ClassNames=Class.create();
Element.ClassNames.prototype={initialize:function(_e8){
this.element=$(_e8);
},_each:function(_e9){
this.element.className.split(/\s+/).select(function(_ea){
return _ea.length>0;
})._each(_e9);
},set:function(_eb){
this.element.className=_eb;
},add:function(_ec){
if(this.include(_ec)){
return;
}
this.set(this.toArray().concat(_ec).join(" "));
},remove:function(_ed){
if(!this.include(_ed)){
return;
}
this.set(this.select(function(_ee){
return _ee!=_ed;
}));
},toString:function(){
return this.toArray().join(" ");
}};
Object.extend(Element.ClassNames.prototype,Enumerable);
var Field={clear:function(){
for(var i=0;i<arguments.length;i++){
$(arguments[i]).value="";
}
},focus:function(_f0){
$(_f0).focus();
},present:function(){
for(var i=0;i<arguments.length;i++){
if($(arguments[i]).value==""){
return false;
}
}
return true;
},select:function(_f2){
$(_f2).select();
},activate:function(_f3){
$(_f3).focus();
$(_f3).select();
}};
var Form={serialize:function(_f4){
var _f5=Form.getElements($(_f4));
var _f6=new Array();
for(var i=0;i<_f5.length;i++){
var _f8=Form.Element.serialize(_f5[i]);
if(_f8){
_f6.push(_f8);
}
}
return _f6.join("&");
},getElements:function(_f9){
_f9=$(_f9);
var _fa=new Array();
for(tagName in Form.Element.Serializers){
var _fb=_f9.getElementsByTagName(tagName);
for(var j=0;j<_fb.length;j++){
_fa.push(_fb[j]);
}
}
return _fa;
},getInputs:function(_fd,_fe,_ff){
_fd=$(_fd);
var _100=_fd.getElementsByTagName("input");
if(!_fe&&!_ff){
return _100;
}
var _101=new Array();
for(var i=0;i<_100.length;i++){
var _103=_100[i];
if((_fe&&_103.type!=_fe)||(_ff&&_103.name!=_ff)){
continue;
}
_101.push(_103);
}
return _101;
},disable:function(form){
var _105=Form.getElements(form);
for(var i=0;i<_105.length;i++){
var _107=_105[i];
_107.blur();
_107.disabled="true";
}
},enable:function(form){
var _109=Form.getElements(form);
for(var i=0;i<_109.length;i++){
var _10b=_109[i];
_10b.disabled="";
}
},focusFirstElement:function(form){
form=$(form);
var _10d=Form.getElements(form);
for(var i=0;i<_10d.length;i++){
var _10f=_10d[i];
if(_10f.type!="hidden"&&!_10f.disabled){
Field.activate(_10f);
break;
}
}
},reset:function(form){
$(form).reset();
}};
Form.Element={serialize:function(_111){
_111=$(_111);
var _112=_111.tagName.toLowerCase();
var _113=Form.Element.Serializers[_112](_111);
if(_113){
return encodeURIComponent(_113[0])+"="+encodeURIComponent(_113[1]);
}
},getValue:function(_114){
_114=$(_114);
var _115=_114.tagName.toLowerCase();
var _116=Form.Element.Serializers[_115](_114);
if(_116){
return _116[1];
}
}};
Form.Element.Serializers={input:function(_117){
switch(_117.type.toLowerCase()){
case "submit":
case "hidden":
case "password":
case "text":
return Form.Element.Serializers.textarea(_117);
case "checkbox":
case "radio":
return Form.Element.Serializers.inputSelector(_117);
}
return false;
},inputSelector:function(_118){
if(_118.checked){
return [_118.name,_118.value];
}
},textarea:function(_119){
return [_119.name,_119.value];
},select:function(_11a){
return Form.Element.Serializers[_11a.type=="select-one"?"selectOne":"selectMany"](_11a);
},selectOne:function(_11b){
var _11c="",opt,_11e=_11b.selectedIndex;
if(_11e>=0){
opt=_11b.options[_11e];
_11c=opt.value;
if(!_11c&&!("value" in opt)){
_11c=opt.text;
}
}
return [_11b.name,_11c];
},selectMany:function(_11f){
var _120=new Array();
for(var i=0;i<_11f.length;i++){
var opt=_11f.options[i];
if(opt.selected){
var _123=opt.value;
if(!_123&&!("value" in opt)){
_123=opt.text;
}
_120.push(_123);
}
}
return [_11f.name,_120];
}};
var $F=Form.Element.getValue;
Abstract.TimedObserver=function(){
};
Abstract.TimedObserver.prototype={initialize:function(_124,_125,_126){
this.frequency=_125;
this.element=$(_124);
this.callback=_126;
this.lastValue=this.getValue();
this.registerCallback();
},registerCallback:function(){
setInterval(this.onTimerEvent.bind(this),this.frequency*1000);
},onTimerEvent:function(){
var _127=this.getValue();
if(this.lastValue!=_127){
this.callback(this.element,_127);
this.lastValue=_127;
}
}};
Form.Element.Observer=Class.create();
Form.Element.Observer.prototype=Object.extend(new Abstract.TimedObserver(),{getValue:function(){
return Form.Element.getValue(this.element);
}});
Form.Observer=Class.create();
Form.Observer.prototype=Object.extend(new Abstract.TimedObserver(),{getValue:function(){
return Form.serialize(this.element);
}});
Abstract.EventObserver=function(){
};
Abstract.EventObserver.prototype={initialize:function(_128,_129){
this.element=$(_128);
this.callback=_129;
this.lastValue=this.getValue();
if(this.element.tagName.toLowerCase()=="form"){
this.registerFormCallbacks();
}else{
this.registerCallback(this.element);
}
},onElementEvent:function(){
var _12a=this.getValue();
if(this.lastValue!=_12a){
this.callback(this.element,_12a);
this.lastValue=_12a;
}
},registerFormCallbacks:function(){
var _12b=Form.getElements(this.element);
for(var i=0;i<_12b.length;i++){
this.registerCallback(_12b[i]);
}
},registerCallback:function(_12d){
if(_12d.type){
switch(_12d.type.toLowerCase()){
case "checkbox":
case "radio":
_12d.target=this;
_12d.prev_onclick=_12d.onclick||Prototype.emptyFunction;
_12d.onclick=function(){
this.prev_onclick();
this.target.onElementEvent();
};
break;
case "password":
case "text":
case "textarea":
case "select-one":
case "select-multiple":
_12d.target=this;
_12d.prev_onchange=_12d.onchange||Prototype.emptyFunction;
_12d.onchange=function(){
this.prev_onchange();
this.target.onElementEvent();
};
break;
}
}
}};
Form.Element.EventObserver=Class.create();
Form.Element.EventObserver.prototype=Object.extend(new Abstract.EventObserver(),{getValue:function(){
return Form.Element.getValue(this.element);
}});
Form.EventObserver=Class.create();
Form.EventObserver.prototype=Object.extend(new Abstract.EventObserver(),{getValue:function(){
return Form.serialize(this.element);
}});
if(!window.Event){
var Event=new Object();
}
Object.extend(Event,{KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_DELETE:46,element:function(_12e){
return _12e.target||_12e.srcElement;
},isLeftClick:function(_12f){
return (((_12f.which)&&(_12f.which==1))||((_12f.button)&&(_12f.button==1)));
},pointerX:function(_130){
return _130.pageX||(_130.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft));
},pointerY:function(_131){
return _131.pageY||(_131.clientY+(document.documentElement.scrollTop||document.body.scrollTop));
},stop:function(_132){
if(_132.preventDefault){
_132.preventDefault();
_132.stopPropagation();
}else{
_132.returnValue=false;
_132.cancelBubble=true;
}
},findElement:function(_133,_134){
var _135=Event.element(_133);
while(_135.parentNode&&(!_135.tagName||(_135.tagName.toUpperCase()!=_134.toUpperCase()))){
_135=_135.parentNode;
}
return _135;
},observers:false,_observeAndCache:function(_136,name,_138,_139){
if(!this.observers){
this.observers=[];
}
if(_136.addEventListener){
this.observers.push([_136,name,_138,_139]);
_136.addEventListener(name,_138,_139);
}else{
if(_136.attachEvent){
this.observers.push([_136,name,_138,_139]);
_136.attachEvent("on"+name,_138);
}
}
},unloadCache:function(){
if(!Event.observers){
return;
}
for(var i=0;i<Event.observers.length;i++){
Event.stopObserving.apply(this,Event.observers[i]);
Event.observers[i][0]=null;
}
Event.observers=false;
},observe:function(_13b,name,_13d,_13e){
var _13b=$(_13b);
_13e=_13e||false;
if(name=="keypress"&&(navigator.appVersion.match(/Konqueror|Safari|KHTML/)||_13b.attachEvent)){
name="keydown";
}
this._observeAndCache(_13b,name,_13d,_13e);
},stopObserving:function(_13f,name,_141,_142){
var _13f=$(_13f);
_142=_142||false;
if(name=="keypress"&&(navigator.appVersion.match(/Konqueror|Safari|KHTML/)||_13f.detachEvent)){
name="keydown";
}
if(_13f.removeEventListener){
_13f.removeEventListener(name,_141,_142);
}else{
if(_13f.detachEvent){
_13f.detachEvent("on"+name,_141);
}
}
}});
Event.observe(window,"unload",Event.unloadCache,false);
var Position={includeScrollOffsets:false,prepare:function(){
this.deltaX=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;
this.deltaY=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0;
},realOffset:function(_143){
var _144=0,_145=0;
do{
_144+=_143.scrollTop||0;
_145+=_143.scrollLeft||0;
_143=_143.parentNode;
}while(_143);
return [_145,_144];
},cumulativeOffset:function(_146){
var _147=0,_148=0;
do{
_147+=_146.offsetTop||0;
_148+=_146.offsetLeft||0;
_146=_146.offsetParent;
}while(_146);
return [_148,_147];
},positionedOffset:function(_149){
var _14a=0,_14b=0;
do{
_14a+=_149.offsetTop||0;
_14b+=_149.offsetLeft||0;
_149=_149.offsetParent;
if(_149){
p=Element.getStyle(_149,"position");
if(p=="relative"||p=="absolute"){
break;
}
}
}while(_149);
return [_14b,_14a];
},offsetParent:function(_14c){
if(_14c.offsetParent){
return _14c.offsetParent;
}
if(_14c==document.body){
return _14c;
}
while((_14c=_14c.parentNode)&&_14c!=document.body){
if(Element.getStyle(_14c,"position")!="static"){
return _14c;
}
}
return document.body;
},within:function(_14d,x,y){
if(this.includeScrollOffsets){
return this.withinIncludingScrolloffsets(_14d,x,y);
}
this.xcomp=x;
this.ycomp=y;
this.offset=this.cumulativeOffset(_14d);
return (y>=this.offset[1]&&y<this.offset[1]+_14d.offsetHeight&&x>=this.offset[0]&&x<this.offset[0]+_14d.offsetWidth);
},withinIncludingScrolloffsets:function(_150,x,y){
var _153=this.realOffset(_150);
this.xcomp=x+_153[0]-this.deltaX;
this.ycomp=y+_153[1]-this.deltaY;
this.offset=this.cumulativeOffset(_150);
return (this.ycomp>=this.offset[1]&&this.ycomp<this.offset[1]+_150.offsetHeight&&this.xcomp>=this.offset[0]&&this.xcomp<this.offset[0]+_150.offsetWidth);
},overlap:function(mode,_155){
if(!mode){
return 0;
}
if(mode=="vertical"){
return ((this.offset[1]+_155.offsetHeight)-this.ycomp)/_155.offsetHeight;
}
if(mode=="horizontal"){
return ((this.offset[0]+_155.offsetWidth)-this.xcomp)/_155.offsetWidth;
}
},clone:function(_156,_157){
_156=$(_156);
_157=$(_157);
_157.style.position="absolute";
var _158=this.cumulativeOffset(_156);
_157.style.top=_158[1]+"px";
_157.style.left=_158[0]+"px";
_157.style.width=_156.offsetWidth+"px";
_157.style.height=_156.offsetHeight+"px";
},page:function(_159){
var _15a=0,_15b=0;
var _15c=_159;
do{
_15a+=_15c.offsetTop||0;
_15b+=_15c.offsetLeft||0;
if(_15c.offsetParent==document.body){
if(Element.getStyle(_15c,"position")=="absolute"){
break;
}
}
}while(_15c=_15c.offsetParent);
_15c=_159;
do{
_15a-=_15c.scrollTop||0;
_15b-=_15c.scrollLeft||0;
}while(_15c=_15c.parentNode);
return [_15b,_15a];
},clone:function(_15d,_15e){
var _15f=Object.extend({setLeft:true,setTop:true,setWidth:true,setHeight:true,offsetTop:0,offsetLeft:0},arguments[2]||{});
_15d=$(_15d);
var p=Position.page(_15d);
_15e=$(_15e);
var _161=[0,0];
var _162=null;
if(Element.getStyle(_15e,"position")=="absolute"){
_162=Position.offsetParent(_15e);
_161=Position.page(_162);
}
if(_162==document.body){
_161[0]-=document.body.offsetLeft;
_161[1]-=document.body.offsetTop;
}
if(_15f.setLeft){
_15e.style.left=(p[0]-_161[0]+_15f.offsetLeft)+"px";
}
if(_15f.setTop){
_15e.style.top=(p[1]-_161[1]+_15f.offsetTop)+"px";
}
if(_15f.setWidth){
_15e.style.width=_15d.offsetWidth+"px";
}
if(_15f.setHeight){
_15e.style.height=_15d.offsetHeight+"px";
}
},absolutize:function(_163){
_163=$(_163);
if(_163.style.position=="absolute"){
return;
}
Position.prepare();
var _164=Position.positionedOffset(_163);
var top=_164[1];
var left=_164[0];
var _167=_163.clientWidth;
var _168=_163.clientHeight;
_163._originalLeft=left-parseFloat(_163.style.left||0);
_163._originalTop=top-parseFloat(_163.style.top||0);
_163._originalWidth=_163.style.width;
_163._originalHeight=_163.style.height;
_163.style.position="absolute";
_163.style.top=top+"px";
_163.style.left=left+"px";
_163.style.width=_167+"px";
_163.style.height=_168+"px";
},relativize:function(_169){
_169=$(_169);
if(_169.style.position=="relative"){
return;
}
Position.prepare();
_169.style.position="relative";
var top=parseFloat(_169.style.top||0)-(_169._originalTop||0);
var left=parseFloat(_169.style.left||0)-(_169._originalLeft||0);
_169.style.top=top+"px";
_169.style.left=left+"px";
_169.style.height=_169._originalHeight;
_169.style.width=_169._originalWidth;
}};
if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)){
Position.cumulativeOffset=function(_16c){
var _16d=0,_16e=0;
do{
_16d+=_16c.offsetTop||0;
_16e+=_16c.offsetLeft||0;
if(_16c.offsetParent==document.body){
if(Element.getStyle(_16c,"position")=="absolute"){
break;
}
}
_16c=_16c.offsetParent;
}while(_16c);
return [_16e,_16d];
};
}

var JSON={copyright:"(c)2005 JSON.org",license:"http://www.crockford.com/JSON/license.html",stringify:function(v){
var a=[];
function e(s){
a[a.length]=s;
}
function g(x){
var c,i,l,v;
switch(typeof x){
case "object":
if(x){
if(x instanceof Array){
e("[");
l=a.length;
for(i=0;i<x.length;i+=1){
v=x[i];
if(typeof v!="undefined"&&typeof v!="function"){
if(l<a.length){
e(",");
}
g(v);
}
}
e("]");
return;
}else{
if(typeof x.valueOf=="function"){
e("{");
l=a.length;
for(i in x){
v=x[i];
if(typeof v!="undefined"&&typeof v!="function"&&(!v||typeof v!="object"||typeof v.valueOf=="function")){
if(l<a.length){
e(",");
}
g(i);
e(":");
g(v);
}
}
return e("}");
}
}
}
e("null");
return;
case "number":
e(isFinite(x)?+x:"null");
return;
case "string":
l=x.length;
e("\"");
for(i=0;i<l;i+=1){
c=x.charAt(i);
if(c>=" "){
if(c=="\\"||c=="\""){
e("\\");
}
e(c);
}else{
switch(c){
case "\b":
e("\\b");
break;
case "\f":
e("\\f");
break;
case "\n":
e("\\n");
break;
case "\r":
e("\\r");
break;
case "\t":
e("\\t");
break;
default:
c=c.charCodeAt();
e("\\u00"+Math.floor(c/16).toString(16)+(c%16).toString(16));
}
}
}
e("\"");
return;
case "boolean":
e(String(x));
return;
default:
e("null");
return;
}
}
g(v);
return a.join("");
},parse:function(_8){
return (/^(\s+|[,:{}\[\]]|"(\\["\\\/bfnrtu]|[^\x00-\x1f"\\]+)*"|-?\d+(\.\d*)?([eE][+-]?\d+)?|true|false|null)+$/.test(_8))&&eval("("+_8+")");
}};

var TrimPath;
(function(){
if(TrimPath==null){
TrimPath=new Object();
}
if(TrimPath.evalEx==null){
TrimPath.evalEx=function(_1){
return eval(_1);
};
}
var _2;
if(Array.prototype.pop==null){
Array.prototype.pop=function(){
if(this.length===0){
return _2;
}
return this[--this.length];
};
}
if(Array.prototype.push==null){
Array.prototype.push=function(){
for(var i=0;i<arguments.length;++i){
this[this.length]=arguments[i];
}
return this.length;
};
}
TrimPath.parseTemplate=function(_4,_5,_6){
if(_6==null){
_6=TrimPath.parseTemplate_etc;
}
var _7=_8(_4,_5,_6);
var _9=TrimPath.evalEx(_7,_5,1);
if(_9!=null){
return new _6.Template(_5,_4,_7,_9,_6);
}
return null;
};
try{
String.prototype.process=function(_a,_b){
var _c=TrimPath.parseTemplate(this,null);
if(_c!=null){
return _c.process(_a,_b);
}
return this;
};
}
catch(e){
}
TrimPath.parseTemplate_etc={};
TrimPath.parseTemplate_etc.statementTag="forelse|for|if|elseif|else|var|macro";
TrimPath.parseTemplate_etc.statementDef={"if":{delta:1,prefix:"if (",suffix:") {",paramMin:1},"else":{delta:0,prefix:"} else {"},"elseif":{delta:0,prefix:"} else if (",suffix:") {",paramDefault:"true"},"/if":{delta:-1,prefix:"}"},"for":{delta:1,paramMin:3,prefixFunc:function(_d,_e,_f,etc){
if(_d[2]!="in"){
throw new etc.ParseError(_f,_e.line,"bad for loop statement: "+_d.join(" "));
}
var _11=_d[1];
var _12="__LIST__"+_11;
return ["var ",_12," = ",_d[3],";","var __LENGTH_STACK__;","if (typeof(__LENGTH_STACK__) == 'undefined' || !__LENGTH_STACK__.length) __LENGTH_STACK__ = new Array();","__LENGTH_STACK__[__LENGTH_STACK__.length] = 0;","if ((",_12,") != null) { ","var ",_11,"_ct = 0;","for (var ",_11,"_index in ",_12,") { ",_11,"_ct++;","if (typeof(",_12,"[",_11,"_index]) == 'function') {continue;}","__LENGTH_STACK__[__LENGTH_STACK__.length - 1]++;","var ",_11," = ",_12,"[",_11,"_index];"].join("");
}},"forelse":{delta:0,prefix:"} } if (__LENGTH_STACK__[__LENGTH_STACK__.length - 1] == 0) { if (",suffix:") {",paramDefault:"true"},"/for":{delta:-1,prefix:"} }; delete __LENGTH_STACK__[__LENGTH_STACK__.length - 1];"},"var":{delta:0,prefix:"var ",suffix:";"},"macro":{delta:1,prefixFunc:function(_13,_14,_15,etc){
var _17=_13[1].split("(")[0];
return ["var ",_17," = function",_13.slice(1).join(" ").substring(_17.length),"{ var _OUT_arr = []; var _OUT = { write: function(m) { if (m) _OUT_arr.push(m); } }; "].join("");
}},"/macro":{delta:-1,prefix:" return _OUT_arr.join(''); };"}};
TrimPath.parseTemplate_etc.modifierDef={"eat":function(v){
return "";
},"escape":function(s){
return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
},"capitalize":function(s){
return String(s).toUpperCase();
},"default":function(s,d){
return s!=null?s:d;
}};
TrimPath.parseTemplate_etc.modifierDef.h=TrimPath.parseTemplate_etc.modifierDef.escape;
TrimPath.parseTemplate_etc.Template=function(_1d,_1e,_1f,_20,etc){
this.process=function(_22,_23){
if(_22==null){
_22={};
}
if(_22._MODIFIERS==null){
_22._MODIFIERS={};
}
if(_22.defined==null){
_22.defined=function(str){
return (_22[str]!=undefined);
};
}
for(var k in etc.modifierDef){
if(_22._MODIFIERS[k]==null){
_22._MODIFIERS[k]=etc.modifierDef[k];
}
}
if(_23==null){
_23={};
}
var _26=[];
var _27={write:function(m){
_26.push(m);
}};
try{
_20(_27,_22,_23);
}
catch(e){
if(_23.throwExceptions==true){
throw e;
}
var _29=new String(_26.join("")+"[ERROR: "+e.toString()+(e.message?"; "+e.message:"")+"]");
_29["exception"]=e;
return _29;
}
return _26.join("");
};
this.name=_1d;
this.source=_1e;
this.sourceFunc=_1f;
this.toString=function(){
return "TrimPath.Template ["+_1d+"]";
};
};
TrimPath.parseTemplate_etc.ParseError=function(_2a,_2b,_2c){
this.name=_2a;
this.line=_2b;
this.message=_2c;
};
TrimPath.parseTemplate_etc.ParseError.prototype.toString=function(){
return ("TrimPath template ParseError in "+this.name+": line "+this.line+", "+this.message);
};
var _8=function(_2d,_2e,etc){
_2d=_30(_2d);
var _31=["var TrimPath_Template_TEMP = function(_OUT, _CONTEXT, _FLAGS) { with (_CONTEXT) {"];
var _32={stack:[],line:1};
var _33=-1;
while(_33+1<_2d.length){
var _34=_33;
_34=_2d.indexOf("{",_34+1);
while(_34>=0){
var _35=_2d.indexOf("}",_34+1);
var _36=_2d.substring(_34,_35);
var _37=_36.match(/^\{(cdata|minify|eval)/);
if(_37){
var _38=_37[1];
var _39=_34+_38.length+1;
var _3a=_2d.indexOf("}",_39);
if(_3a>=0){
var _3b;
if(_3a-_39<=0){
_3b="{/"+_38+"}";
}else{
_3b=_2d.substring(_39+1,_3a);
}
var _3c=_2d.indexOf(_3b,_3a+1);
if(_3c>=0){
_3d(_2d.substring(_33+1,_34),_31);
var _3e=_2d.substring(_3a+1,_3c);
if(_38=="cdata"){
_3f(_3e,_31);
}else{
if(_38=="minify"){
_3f(_40(_3e),_31);
}else{
if(_38=="eval"){
if(_3e!=null&&_3e.length>0){
_31.push("_OUT.write( (function() { "+_3e+" })() );");
}
}
}
}
_34=_33=_3c+_3b.length-1;
}
}
}else{
if(_2d.charAt(_34-1)!="$"&&_2d.charAt(_34-1)!="\\"){
var _41=(_2d.charAt(_34+1)=="/"?2:1);
if(_2d.substring(_34+_41,_34+10+_41).search(TrimPath.parseTemplate_etc.statementTag)==0){
break;
}
}
}
_34=_2d.indexOf("{",_34+1);
}
if(_34<0){
break;
}
var _35=_2d.indexOf("}",_34+1);
if(_35<0){
break;
}
_3d(_2d.substring(_33+1,_34),_31);
_42(_2d.substring(_34,_35+1),_32,_31,_2e,etc);
_33=_35;
}
_3d(_2d.substring(_33+1),_31);
if(_32.stack.length!=0){
throw new etc.ParseError(_2e,_32.line,"unclosed, unmatched statement(s): "+_32.stack.join(","));
}
_31.push("}}; TrimPath_Template_TEMP");
return _31.join("");
};
var _42=function(_43,_44,_45,_46,etc){
var _48=_43.slice(1,-1).split(" ");
var _49=etc.statementDef[_48[0]];
if(_49==null){
_3d(_43,_45);
return;
}
if(_49.delta<0){
if(_44.stack.length<=0){
throw new etc.ParseError(_46,_44.line,"close tag does not match any previous statement: "+_43);
}
_44.stack.pop();
}
if(_49.delta>0){
_44.stack.push(_43);
}
if(_49.paramMin!=null&&_49.paramMin>=_48.length){
throw new etc.ParseError(_46,_44.line,"statement needs more parameters: "+_43);
}
if(_49.prefixFunc!=null){
_45.push(_49.prefixFunc(_48,_44,_46,etc));
}else{
_45.push(_49.prefix);
}
if(_49.suffix!=null){
if(_48.length<=1){
if(_49.paramDefault!=null){
_45.push(_49.paramDefault);
}
}else{
for(var i=1;i<_48.length;i++){
if(i>1){
_45.push(" ");
}
_45.push(_48[i]);
}
}
_45.push(_49.suffix);
}
};
var _3d=function(_4b,_4c){
if(_4b.length<=0){
return;
}
var _4d=0;
var _4e=_4b.length-1;
while(_4d<_4b.length&&(_4b.charAt(_4d)=="\n")){
_4d++;
}
while(_4e>=0&&(_4b.charAt(_4e)==" "||_4b.charAt(_4e)=="\t")){
_4e--;
}
if(_4e<_4d){
_4e=_4d;
}
if(_4d>0){
_4c.push("if (_FLAGS.keepWhitespace == true) _OUT.write(\"");
var s=_4b.substring(0,_4d).replace("\n","\\n");
if(s.charAt(s.length-1)=="\n"){
s=s.substring(0,s.length-1);
}
_4c.push(s);
_4c.push("\");");
}
var _50=_4b.substring(_4d,_4e+1).split("\n");
for(var i=0;i<_50.length;i++){
_52(_50[i],_4c);
if(i<_50.length-1){
_4c.push("_OUT.write(\"\\n\");\n");
}
}
if(_4e+1<_4b.length){
_4c.push("if (_FLAGS.keepWhitespace == true) _OUT.write(\"");
var s=_4b.substring(_4e+1).replace("\n","\\n");
if(s.charAt(s.length-1)=="\n"){
s=s.substring(0,s.length-1);
}
_4c.push(s);
_4c.push("\");");
}
};
var _52=function(_53,_54){
var _55="}";
var _56=-1;
while(_56+_55.length<_53.length){
var _57="${",_58="}";
var _59=_53.indexOf(_57,_56+_55.length);
if(_59<0){
break;
}
if(_53.charAt(_59+2)=="%"){
_57="${%";
_58="%}";
}
var _5a=_53.indexOf(_58,_59+_57.length);
if(_5a<0){
break;
}
_3f(_53.substring(_56+_55.length,_59),_54);
var _5b=_53.substring(_59+_57.length,_5a).replace(/\|\|/g,"#@@#").split("|");
for(var k in _5b){
if(_5b[k].replace){
_5b[k]=_5b[k].replace(/#@@#/g,"||");
}
}
_54.push("_OUT.write(");
_5d(_5b,_5b.length-1,_54);
_54.push(");");
_56=_5a;
_55=_58;
}
_3f(_53.substring(_56+_55.length),_54);
};
var _3f=function(_5e,_5f){
if(_5e==null||_5e.length<=0){
return;
}
_5e=_5e.replace(/\\/g,"\\\\");
_5e=_5e.replace(/\n/g,"\\n");
_5e=_5e.replace(/"/g,"\\\"");
_5f.push("_OUT.write(\"");
_5f.push(_5e);
_5f.push("\");");
};
var _5d=function(_60,_61,_62){
var _63=_60[_61];
if(_61<=0){
_62.push(_63);
return;
}
var _64=_63.split(":");
_62.push("_MODIFIERS[\"");
_62.push(_64[0]);
_62.push("\"](");
_5d(_60,_61-1,_62);
if(_64.length>1){
_62.push(",");
_62.push(_64[1]);
}
_62.push(")");
};
var _30=function(_65){
_65=_65.replace(/\t/g,"    ");
_65=_65.replace(/\r\n/g,"\n");
_65=_65.replace(/\r/g,"\n");
_65=_65.replace(/^(\s*\S*(\s+\S+)*)\s*$/,"$1");
return _65;
};
var _40=function(_66){
_66=_66.replace(/^\s+/g,"");
_66=_66.replace(/\s+$/g,"");
_66=_66.replace(/\s+/g," ");
_66=_66.replace(/^(\s*\S*(\s+\S+)*)\s*$/,"$1");
return _66;
};
TrimPath.parseDOMTemplate=function(_67,_68,_69){
if(_68==null){
_68=document;
}
var _6a=_68.getElementById(_67);
var _6b=_6a.value;
if(_6b==null){
_6b=_6a.innerHTML;
}
_6b=_6b.replace(/&lt;/g,"<").replace(/&gt;/g,">");
return TrimPath.parseTemplate(_6b,_67,_69);
};
TrimPath.processDOMTemplate=function(_6c,_6d,_6e,_6f,_70){
return TrimPath.parseDOMTemplate(_6c,_6f,_70).process(_6d,_6e);
};
})();

if(maptales==null){
var maptales={};
}
maptales={ui:{},rpc:{},service:{},cache:{},widgets:{},behaviours:{},scripts:{},tempIdIndex:-2,imageUploadInProgress:false,setConfig:function(_1){
if(window.location.search.indexOf("debug")>-1){
this.debug=true;
}else{
if(_1.debug=="true"||_1.debug==true){
this.debug=true;
}else{
this.debug=false;
}
}
this.appName=_1.appName;
this.baseURL=_1.baseURL;
this.staticBaseURL=_1.staticUrl;
this.imageBaseURL=this.staticBaseURL+"/images/db/";
this.rpcUrl=_1.rpcUrl;
this.remoteServer=_1.remoteServer;
this.templateFolder=_1.templateFolder;
this.templateExtension=_1.templateExtension;
this.rootViews=_1.rootViews;
this.urlToViewMappings=_1.urlToViewMappings;
this.templateRoot=_1.baseURL+"/"+_1.templateFolder;
},loggers:{},loggerConfig:{},initializeLogger:function(_2){
this.loggerConfig=_2;
if(_2["rootLogger"]){
this.setRootLogLevel(_2["rootLogger"]);
}
for(configName in _2){
this.setLogLevel(configName,_2[configName]);
}
},getLogger:function(_3){
if(!this.loggers[_3]){
this.loggers[_3]=log4javascript.getLogger(_3);
if(this.loggerConfig["rootLogger"]){
this.setLogLevel(_3,this.loggerConfig["rootLogger"]);
}
if(this.loggerConfig[_3]){
this.setLogLevel(_3,this.loggerConfig[_3]);
}
}
return this.loggers[_3];
},setRootLogLevel:function(_4){
for(logName in this.loggers){
this.loggers[logName].setLevel(_4);
}
},setLogLevel:function(_5,_6){
if(this.loggers[_5]){
this.loggers[_5].setLevel(_6);
}
},addAppender:function(_7,_8){
if(this.loggers[_7]){
this.loggers[_7].addAppender(_8);
}
},addRootAppender:function(_9){
for(logName in this.loggers){
this.loggers[logName].addAppender(_9);
}
},removeRootAppender:function(_a){
for(logName in this.loggers){
this.loggers[logName].removeAppender(_a);
}
},getURLParameter:function(_b){
_b=_b.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");
var _c="[\\?&]"+_b+"=([^&#]*)";
var _d=new RegExp(_c);
var _e=_d.exec(window.location.href);
if(_e==null){
return null;
}else{
return _e[1];
}
}};
var loggerConfig={rootLogger:log4javascript.Level.WARN,"testLogger":log4javascript.Level.WARN,"com.maptales.webClient.mapObjects.line":log4javascript.Level.DEBUG,"com.maptales.webclient.cache":log4javascript.Level.WARN,"com.maptales.webclient.rpc":log4javascript.Level.WARN,"com.maptales.webclient.map":log4javascript.Level.WARN,"com.maptales.webclient.widgets.dialog":log4javascript.Level.WARN,"com.maptales.webclient.widgets.datafield":log4javascript.Level.WARN,"com.maptales.webclient.widget":log4javascript.Level.WARN,"com.maptales.webclient.widgets.BrowseWidget":log4javascript.Level.WARN,"com.maptales.webclient.widgets.pathwidget":log4javascript.Level.WARN,"com.maptales.webclient.widgets.pathpanel":log4javascript.Level.WARN,"com.maptales.webClient.cache.slot":log4javascript.Level.WARN,"com.maptales.webclient.widgets.slotwidget":log4javascript.Level.WARN,"com.maptales.webclient.dragdrop":log4javascript.Level.WARN,"com.maptales.webclient.slotdropzone":log4javascript.Level.WARN,"com.maptales.webClient.draggable":log4javascript.Level.WARN,"com.maptales.webClient.mapObjects.line":log4javascript.Level.WARN,"com.maptales.webClient.mapObjects.marker":log4javascript.Level.WARN,"com.maptales.webclient.dynamicmediator":log4javascript.Level.WARN,"com.maptales.webclient.maptaleswidget":log4javascript.Level.WARN};
maptales.initializeLogger(loggerConfig);
maptales.logger=maptales.getLogger("com.maptales");

var Templates={};
Templates={logger:maptales.getLogger("com.maptales.webclient.templates"),templates:{},callbackHash:{},disableCache:maptales.getURLParameter("disableTemplateCache"),getTemplate:function(_1,_2){
if(this.disableCache||!this.templates[_1]){
if(maptales.getURLParameter("loadTemplatesFromClient")){
var _3=document.createElement("script");
_3.id="rs";
_3.setAttribute("type","text/javascript");
_3.setAttribute("src","http://localhost:8080/action/loadTemplate?templatePath="+_1);
var hd=document.getElementsByTagName("head")[0];
hd.appendChild(_3);
if(this.callbackHash[_1]==null){
this.callbackHash[_1]=[];
}
this.callbackHash[_1].push(_2);
}else{
var _5=maptales.templateFolder+"/"+_1+maptales.templateExtension+"?version="+clientConfig.version;
this.loading=_5;
var _6=new Ajax.Request(_5,{method:"get",onComplete:function(_7){
if(_7.status!=404){
try{
Templates.templates[_1]=TrimPath.parseTemplate(_7.responseText);
try{
_2(Templates.templates[_1],_1);
}
catch(e){
Templates.logger.warn("CallbackError: calling a callback in Templates.js caused an error",e);
}
}
catch(e){
Templates.logger.warn("TemplateParseError: Error parsing themplate with path: "+_5,e);
_2(null,_1);
}
}else{
Templates.logger.warn("FileException: Templates>Could not find: "+_5);
_2(false,_1);
}
},onFailure:Templates.failure.bind(Templates)});
}
}else{
_2(this.templates[_1],_1);
}
},templateCallback:function(_8,_9){
try{
Templates.templates[_8]=TrimPath.parseTemplate(_9);
}
catch(e){
Templates.logger.warn("TemplateParseError: Error parsing themplate with path: "+fullTemplatePath,e);
callback(null,_8);
}
if(this.callbackHash[_8]){
for(var i=0;i<this.callbackHash[_8].length;i++){
try{
this.callbackHash[_8][i](Templates.templates[_8],_8);
}
catch(e){
Templates.logger.warn("CallbackError: calling a callback in Templates.js caused an error",e);
}
}
}
},failure:function(_b){
Templates.logger.warn("TemplateLoadFailure: Error: "+_b.status+"-"+_b.responseText+", could not load template: "+_b.statusText);
}};
if((window.location.search.indexOf("dummycontent")>-1)){
Templates.disableCache=true;
}

var TYPE_FIELD=1;
var TYPE_REF=2;
var TYPE_SLOT=3;
var ACTION_ADD=1;
var ACTION_REMOVE=2;
var ContentObject=Class.create("ContentObject");
ContentObject.prototype={logger:maptales.getLogger("com.maptales.webclient.bus.contentobject"),ContentObject_constructor:function(_1){
if(!_1){
_1={};
}
this._fields={};
this.fields={};
this.refs={};
this.backRefs={};
this.slots={};
this.isDirtyFlags={};
this.addPersistentField("creationDate",_1.creationDate||new Date(),Field.DATE,false);
if(_1.id==null){
if(maptales&&maptales.service&&maptales.service.getAndIncrementTempId){
this.id=maptales.service.getAndIncrementTempId();
}
}else{
this.id=_1.id;
}
this.addPersistentField("id",_1.id,Field.INTEGER,false);
if(this.id<-1){
this.tempId=this.id;
}else{
this.tempId=_1.tempId||null;
}
this.wasLocallyStored=false;
},updateData:function(_2){
for(field in this.fields){
if(_2[field]){
if(_2[field]!=null){
if(this.fieldNeedsUpdate(field,_2[field])){
this.set(field,_2[field]);
}
}
}
}
for(reference in this.refs){
if(_2[reference]){
if(_2[reference]!=null){
if(this.refNeedsUpdate(reference,_2[reference])){
if(_2[reference] instanceof ContentObject){
this.set(reference,_2[reference]);
}else{
if(typeof _2[reference]=="string"||typeof _2[reference]=="number"){
this.set(reference,_2[reference]);
}else{
if(!isNaN(_2[reference].id)){
this.set(reference,_2[reference].id);
}else{
this.logger.error("could not update refenrence...it seems like a wrong value is passed. "+_2[reference]);
}
}
}
}
}
}
}
for(slot in this.slots){
var _3=slot;
var _4=_2[slot];
if(_4){
if(this.slotNeedsUpdate(_3,_4)){
var _5=this.parseAndCacheArray(_4.slotItems);
this.slots[_3].insert(_5,0,null,null,_4.size);
}
}
}
if(_2.renderedRights){
this.renderedRights=_2.renderedRights;
}
this.tempId=_2.tempId||null;
},slotNeedsUpdate:function(_6,_7){
if(this.isSlot(_6)){
if(_7!=null&&_7.slotItems!=null){
if(_7.slotItems.length>0){
return true;
}else{
return false;
}
}else{
return false;
}
}else{
return false;
}
},fieldNeedsUpdate:function(_8,_9){
if(this.isField(_8)){
var _a=this.get(_8);
if(_a instanceof Date){
return _a.getTime()!=_9;
}else{
if(_a instanceof Object){
if(_9!={}){
return !(maptales.cache.compareObjects(_a,_9));
}else{
return false;
}
}else{
return _a!=_9;
}
}
}else{
return false;
}
},refNeedsUpdate:function(_b,_c){
if(this.isRef(_b)){
if(typeof _c=="object"){
return this.getRefId(_b)!=_c.id;
}else{
return this.getRefId(_b)!=_c;
}
}else{
return false;
}
},addPersistentField:function(_d,_e,_f,_10,_11,_12){
if(!this._fields){
this._fields=[];
}
this.fields[_d]=new Field(_d,_e,_f,_10,_11,_12);
this.isDirtyFlags[_d]=false;
this._fields[_d]=TYPE_FIELD;
},addPersistentMap:function(_13,map){
if(!this._fields){
this._fields=[];
}
this.fields[_13]=new Field(_13,map||{},Field.Hash,true);
this.isDirtyFlags[_13]=false;
this._fields[_13]=TYPE_FIELD;
},addPersistentRef:function(_15,_16,_17,_18,_19){
var id=this.parseAndCacheRef(_16);
if(!this._fields){
this._fields=[];
}
this.backRefs[_15]=_19;
this.isDirtyFlags[_15]=false;
this._fields[_15]=TYPE_REF;
this.refs[_15]=null;
this.set(_15,id);
},addPersistentSlot:function(_1b,_1c,_1d,_1e,_1f,_20,_21,_22){
if(_1c==null){
_1c={};
}
if(_1c.size==null||_1c.size==false){
_1c.size=-1;
}
if(_1d==null){
_1d=true;
}
this.slots[_1b]=new Slot(this.parseAndCacheArray(_1c.slotItems),_1c.size,_1d,_1f,_20,_1b,this,_21,null,_1e,_22);
this._fields[_1b]=TYPE_SLOT;
},getSymmetricFacet:function(_23){
if(this.isSlot(_23)){
return this.slots[_23].getSymmetricFacet();
}else{
this.logger.warn("Symmetric Facet for Ref not implemented yet: implement it when you get this message");
return false;
}
},isFieldDirty:function(_24){
if(this._fields[_24]==TYPE_SLOT){
return this.slots[_24].isDirty();
}else{
return this.isDirtyFlags[_24];
}
},setDirty:function(_25){
if(this._fields[_25]==TYPE_SLOT){
return this.slots[_25].setDirty();
}else{
return this.isDirtyFlags[_25]=true;
}
},parseAndCacheArray:function(_26){
var _27=[];
if(_26==null){
return _27;
}
if(_26 instanceof Array){
_26.each(function(_28){
if(typeof _28=="object"){
if(_28 instanceof ContentObject){
_27.push(_28.get("id"));
maptales.cache.addToCache(_28);
}else{
var _29=maptales.cache.makeObjects(_28);
_27.push(_29.get("id"));
}
}else{
_27.push(_28);
}
}.bind(this));
}
return _27;
},parseAndCacheRef:function(ref){
if(ref==null){
return null;
}
if(typeof ref=="object"){
if(ref instanceof ContentObject){
maptales.cache.addToCache(ref);
return ref.get("id");
}else{
try{
var _2b=maptales.cache.makeObjects(ref);
}
catch(e){
return null;
}
if(_2b==null){
return null;
}
return _2b.get("id");
}
}else{
return ref;
}
},addIdListener:function(_2c){
if(!this.idListeners){
this.idListeners=[];
}
this.idListeners.push(_2c);
},removeIdListener:function(_2d){
for(var i=0;i<this.idListeners.length;i++){
if((this.idListeners[i]==_2d)){
this.idListeners.splice(i,1);
break;
}
}
},notifyIdListener:function(_2f){
if(this.idListeners){
for(var i=0;i<this.idListeners.length;i++){
try{
this.idListeners[i](this.get("id"),_2f);
}
catch(e){
this.logger.warn("NotifyIdListenerException: ContentObject.notifyIdListeners had an error notifying",e);
}
}
}
},addDeleteListener:function(_31){
if(!this.deleteListeners){
this.deleteListeners=[];
}
this.deleteListeners.push(_31);
},removeDeleteListener:function(_32){
for(var i=0;i<this.deleteListeners.length;i++){
if((this.deleteListeners[i]==_32)){
this.deleteListeners.splice(i,1);
break;
}
}
},notifyDeleteListener:function(){
if(this.deleteListeners){
var _34=[];
for(var i=0;i<this.deleteListeners.length;i++){
_34.push(this.deleteListeners[i]);
}
for(var i=0;i<_34.length;i++){
try{
_34[i](this.get("id"));
}
catch(e){
this.logger.warn("NotifyListenerException: ContentObject.notifyDeleteListeners had an error notifying",e);
}
}
}
},addFieldListener:function(_36,_37){
if(!this.fieldListeners){
this.fieldListeners=[];
}
if(!this.fieldListeners[_36]){
this.fieldListeners[_36]=[];
}
this.fieldListeners[_36].push(_37);
},removeFieldListener:function(_38,_39){
if(this.fieldListeners&&this.fieldListeners[_38]){
for(var i=0;i<this.fieldListeners[_38].length;i++){
if((this.fieldListeners[_38][i]==_39)){
this.fieldListeners[_38].splice(i,1);
break;
}
}
}
},notifyFieldListeners:function(_3b,_3c,_3d){
if(!_3c){
_3c="";
}
if(!_3d){
_3d="";
}
if(this.fieldListeners&&this.fieldListeners[_3b]){
for(var i=0;i<this.fieldListeners[_3b].length;i++){
try{
this.fieldListeners[_3b][i](_3c,this,_3b);
}
catch(e){
this.logger.warn("NotifyFieldListenerException: error calling field listener of: "+this.getClassName()+" id: "+this.get("id")+" field: "+_3b,e);
}
}
}
},addSlotListener:function(_3f,_40,_41,_42){
if(this.isSlot(_3f)){
this.slots[_3f].addSlotListener(_40,_41,_42);
}else{
this.logger.warn("SlotError: the object "+this.getClassName()+" does not have a slot: "+_3f);
}
},removeSlotListener:function(_43,_44,_45,_46){
if(this.isSlot(_43)){
this.slots[_43].removeSlotListener(_44,_45,_46);
}else{
this.logger.warn("SlotError: the object "+this.getClassName()+" does not have a slot: "+_43);
}
},notifySlotListeners:function(_47,_48,_49){
if(this.isSlot(_47)){
this.slots[_47].notifySlotListeners(_48,_49);
}else{
this.logger.warn("SlotError: the object "+this.getClassName()+" does not have a slot: "+_47);
}
},notifyAllSlotListeners:function(_4a,_4b,_4c){
if(this.isSlot(_4a)){
this.slots[_4a].notifyAllSlotListeners(_4b,_4c);
}else{
this.logger.warn("SlotError: the object "+this.getClassName()+" does not have a slot: "+_4a);
}
},isFieldEditable:function(_4d){
if(this.fields[_4d]){
return this.fields[_4d].isEditable();
}else{
return false;
}
},getFieldType:function(_4e){
if(this.fields[_4e]){
return this.fields[_4e].getType();
}else{
return null;
}
},getFieldOptions:function(_4f){
if(this.fields[_4f]){
return this.fields[_4f].getOptions();
}else{
return {};
}
},getFieldDefaultOption:function(_50){
if(this.fields[_50]){
return this.fields[_50].getDefaultSelection();
}else{
return 0;
}
},getSlotObjectClass:function(_51){
if(this.slots[_51]){
return this.slots[_51].getObjectClass();
}else{
return null;
}
},getRefObjectClass:function(_52){
},isField:function(_53){
if(!(this._fields[_53]&&this._fields[_53]==TYPE_FIELD)){
return false;
}else{
return true;
}
},isRef:function(_54){
if(!(this._fields[_54]&&this._fields[_54]==TYPE_REF)){
return false;
}else{
return true;
}
},isSlot:function(_55){
if(!(this._fields[_55]&&this._fields[_55]==TYPE_SLOT)){
return false;
}else{
return true;
}
},getDefaultSlot:function(){
if(this.reflection.defaultSlot){
return this.reflection.defaultSlot;
}else{
return false;
}
},hasSlotForObject:function(_56){
var _57=false;
for(slotName in this.slots){
if(this.slots[slotName].getObjectClass()!=null){
try{
if(_56 instanceof eval(this.slots[slotName].getObjectClass())){
_57=slotName;
}
}
catch(e){
this.logger.error("Slot ObjectType not well defined: "+this.slots[slotName].getObjectClass(),e);
}
}
}
return _57;
},isSlotForObjects:function(_58,_59){
var _5a=true;
_59.each(function(_5b){
if(!(this.isSlotForObject(_58,_5b))){
_5a=false;
}
}.bind(this));
return _5a;
},isSlotForObject:function(_5c,_5d){
if(_5d instanceof eval(this.slots[_5c].getObjectClass())){
return true;
}else{
return false;
}
},hasViewForObject:function(_5e){
if(this.displayableObjects){
var _5f=this.displayableObjects[_5e.getClassName()];
if(_5f){
return _5f;
}else{
return false;
}
}else{
return false;
}
},hasView:function(_60){
if(this.views[_60]){
return true;
}else{
return false;
}
},isView:function(_61){
if(this.views[_61]){
return true;
}else{
return false;
}
},getViews:function(){
return this.views;
},getView:function(_62){
return this.views[_62];
},getTemplateOfView:function(_63){
try{
var _64="";
if(_63=="default"||_63==null){
_64+=this.views[this.defaultView].template;
}else{
_64+=this.views[_63].template;
}
return _64;
}
catch(e){
this.logger.error("There was a problem finding the TemplateOfView...defaulting to default view.");
var _64="";
_64+=this.views[this.defaultView].template;
return _64;
}
},getDefaultView:function(){
if(this.views==null){
return null;
}
if(this.defaultView==null){
return null;
}
return this.views[this.defaultView];
},get:function(_65,_66){
if(!this._fields){
this._fields=[];
}
switch(this._fields[_65]){
case TYPE_SLOT:
maptales.service.getSlot({id:this.id,slotName:_65,offset:0,size:22},_66);
break;
case TYPE_REF:
if(this.refs[_65]){
maptales.service.getById(this.refs[_65],_66);
return this.refs[_65];
}else{
_66(new SnapMapException("CacheException","Reference was not in cache"));
return null;
}
break;
default:
if(this.fields[_65]){
var _67=this.fields[_65].getValue();
}else{
var _67=null;
}
if(_66){
_66(_67);
}
return _67;
}
},set:function(_68,_69){
var _6a=false;
switch(this._fields[_68]){
case TYPE_SLOT:
this.logger.warn("IllegalArgumentException: You cant call 'set' on a slot");
break;
case TYPE_REF:
if(_69 instanceof ContentObject){
var id=_69.id;
}else{
var id=_69;
}
if(id<0){
try{
$O(id).addIdListener(this.changeRefId.bind(this));
}
catch(e){
this.logger.warn("AssociationError: The ref: "+this.getClassName()+"."+_68+" Cant be set since the item is not in cache",e);
}
}
if(id!=this.refs[_68]){
this.refs[_68]=id;
_6a=true;
}
break;
case TYPE_FIELD:
default:
if(_68=="id"){
if(_69!=this.fields[_68].getValue()){
var _6c=this.id;
this.id=_69;
this.fields[_68].setValue(_69);
this.notifyIdListener(_6c);
}
}else{
if(this.fields[_68]&&_69!=this.fields[_68].getValue()){
this.fields[_68].setValue(_69);
_6a=true;
}
}
break;
}
if(_6a){
this.setDirty(_68);
this.notifyFieldListeners(_68,_69,this);
}
},changeRefId:function(_6d,_6e){
for(refname in this.refs){
if(this.refs[refname]==_6e){
this.refs[refname]=_6d;
if(_6e>0){
this.notifyFieldListeners(refname,this.refs[refname],this);
}
}
}
},persist:function(_6f){
maptales.service.persist(this,_6f);
},store:function(_70){
maptales.service.store(this,_70);
},storeLocally:function(){
if(this.isTransient()){
if(this.wasLocallyStored==false){
this.wasLocallyStored=true;
this.onStore();
}
}
},isRefInCache:function(_71){
if(!(this._fields[_71]&&this._fields[_71]==TYPE_REF)){
alert("ref "+_71+" not found in "+this.__className);
return false;
}else{
var id=this.getRefId(_71);
return maptales.cache.isInCache(id);
}
},getRefFromCache:function(_73){
if(!(this._fields[_73]&&this._fields[_73]==TYPE_REF)){
throw new SnapMapException("CacheException","ref "+_73+" not found in "+this.__className);
return false;
}else{
var id=this.getRefId(_73);
if(id>0){
if(maptales.cache.isInCache(id)){
return maptales.cache.getFromCache(id);
}else{
throw new SnapMapException("CacheException","ref "+_73+" not found in "+this.__className);
}
}else{
return maptales.cache.getFromCache(id);
}
}
},getRefId:function(_75){
if(this._fields[_75]==TYPE_REF){
if(this.refs[_75]==0){
return null;
}else{
return this.refs[_75];
}
}
return null;
},getSlot:function(_76,_77,_78,_79,_7a,_7b){
if(!this.isSlot(_76)){
this.logger.error("FieldException: slot "+_76+" does not exist in "+this.getClassName());
_7b(null);
return false;
}
maptales.service.getSlot({id:this.id,slotName:_76,offset:_77,size:_78,filter:_79,sorting:_7a},_7b);
},moveSlotItem:function(_7c,_7d,_7e,_7f,_80,_81){
if(!this.isSlot(_7c)){
this.logger.error("FieldException: slot "+_7c+" does not exist in "+this.getClassName());
_81(null);
return false;
}
var _82=this.slots[_7c].get(_7f,1,_7d,_7e)[0];
var _83=this.slots[_7c].get(_80,1,_7d,_7e)[0];
maptales.service.persist(_82,function(){
});
},addToSlot:function(_84,_85,_86){
if(!this.isSlot(_84)){
this.logger.error("FieldException: slot "+_84+" does not exist in "+this.getClassName());
_86(null);
return false;
}
this._addToSlot(_84,_85);
},_addToSlot:function(_87,_88){
this.slots[_87].add(_88);
},removeFromSlot:function(_89,_8a,_8b){
if(!this.isSlot(_89)){
this.logger.error("FieldException: slot "+_89+" does not exist in "+this.getClassName());
_8b(null);
return false;
}
this._removeFromSlot(_89,_8a);
},_removeFromSlot:function(_8c,_8d){
this.slots[_8c].remove(_8d);
},insertIntoSlot:function(_8e,_8f,_90,_91,_92,_93){
if(!this.isSlot(_8e)){
this.logger.error("FieldException: slot "+_8e+" does not exist in "+this.getClassName());
return false;
}
this.slots[_8e].insert(_8f,_90,_91,_92,_93);
},getSlotFromCache:function(_94,_95,_96,_97,_98){
if(!_95){
_95=0;
}
if(!_96){
_96=-1;
}
if(this.isSlot(_94)){
return this.slots[_94].get(_95,_96,_97,_98);
}else{
throw SnapMapException("CacheException","slot "+_94+" does not exist in "+this.__className);
return false;
}
},clearSlot:function(_99){
if(this.isSlot(_99)){
return this.slots[_99].clear();
}else{
throw SnapMapException("CacheException","slot "+_99+" does not exist in "+this.__className);
return false;
}
},isSlotFullyLoaded:function(_9a){
if(this.isSlot(_9a)){
return this.slots[_9a].isSlotFullyLoaded();
}else{
this.logger.error("FieldException: slot "+_9a+" does not exist in "+this.getClassName());
return false;
}
},isSlotInCache:function(_9b,_9c,_9d,_9e,_9f){
if(this.isSlot(_9b)){
return this.slots[_9b].isSlotInCache(_9c,_9d,_9e,_9f);
}else{
this.logger.error("FieldException: slot "+_9b+" does not exist in "+this.getClassName());
return false;
}
},isSlotCacheable:function(_a0){
if(this.isSlot(_a0)){
return this.slots[_a0].cacheable;
}else{
this.logger.error("FieldException: slot "+_a0+" does not exist in "+this.getClassName());
return false;
}
},getSlotLength:function(_a1,_a2){
try{
return this.slots[_a1].getSlotLength(_a2);
}
catch(e){
this.logger.error("FieldException: slot "+_a1+" does not exist in "+this.getClassName());
}
},setSlotLength:function(_a3,_a4){
this.slots[_a3].setSlotLength(_a4);
},isInSlot:function(_a5,_a6){
return this.slots[_a5].isInSlot(_a6);
},getSlotIndex:function(_a7,_a8,_a9,_aa){
if(this.slots[_a7]){
return this.slots[_a7].getIndexOf(_a8,_a9,_aa);
}else{
throw "Slot: "+_a7+" does not exist in: "+this.getClassName();
}
},getSlotIndexFromCache:function(_ab,_ac,_ad,_ae){
this.slots[_ab].getIndexOf(_ac,_ad,_ae);
},getPath:function(){
return "";
},getSquareImageURL:function(){
return null;
},getPage:function(){
return this.page;
},getData:function(){
var _af={};
_af.type=this.__className;
for(field in this._fields){
if(this._fields[field]==TYPE_FIELD){
if(this.fields[field]!=null){
_af[field]=this.valueToJSON(this.fields[field].getValue());
}
}else{
if(this._fields[field]==TYPE_REF){
if(this.refs[field]!=null&&this.refs[field]!=0){
if(this.refs[field]>0){
_af[field]=this.refs[field];
}else{
_af[field]=maptales.cache.getFromCache(this.refs[field]).getData();
}
}
}else{
if(this._fields[field]==TYPE_SLOT){
if(this.slots[field]!=null){
_af[field]=this.slots[field].getData();
}
}
}
}
}
return _af;
},getDirtyData:function(){
var _b0={};
_b0.type=this.__className;
_b0.id=this.get("id");
for(field in this._fields){
if(this.isFieldDirty(field)){
if(this._fields[field]==TYPE_FIELD){
if(this.fields[field]!=null){
_b0[field]=this.valueToJSON(this.fields[field].getValue());
}
}else{
if(this._fields[field]==TYPE_REF){
if(this.refs[field]!=null){
if(this.refs[field] instanceof ContentObject){
if(this.refs[field].id>0){
_b0[field]=this.refs[field].id;
}else{
_b0[field]=this.refs[field].getData();
}
}else{
_b0[field]=this.refs[field];
}
}
}else{
if(this._fields[field]==TYPE_SLOT){
if(this.slots[field]!=null){
_b0[field]=this.slots[field].getDirtyData();
}
}
}
}
}
}
return _b0;
},valueToJSON:function(_b1){
if(_b1==null){
return null;
}
if(_b1 instanceof Date){
return _b1.getTime()+"";
}else{
if(_b1.distanceFrom!=null){
return {y:_b1.lat(),x:_b1.lng()};
}else{
if(_b1 instanceof Array){
var _b2=[];
for(var i=0;i<_b1.length;i++){
_b2.push(this.valueToJSON(_b1[i]));
}
return _b2;
}else{
return _b1;
}
}
}
},isLoaded:function(){
return true;
},stringify:function(){
return JSON.stringify(this.getData());
},releaseAssociations:function(){
},deleteAssociations:function(){
},getSlotsToRelease:function(){
return {};
},isTransient:function(){
if(this.get("id")<0){
return true;
}else{
return false;
}
},clean:function(){
for(field in this._fields){
if(this.isFieldDirty(field)){
this.isDirtyFlags[field]=false;
if(this._fields[field]==TYPE_SLOT){
if(this.slots[field]!=null){
this.slots[field].clean();
}
}
}
}
},cleanSlot:function(_b4){
if(this.slots[_b4]){
this.slots[_b4].clean();
}
},getTransientRefs:function(){
var _b5=[];
for(reference in this.refs){
if(this.refs[reference]<0){
_b5.push(maptales.cache.getFromCache(this.refs[reference]));
}
}
return _b5;
},isLocked:function(){
}};
var Field=Class.create("Field");
Field.NUMBER=0;
Field.STRING=1;
Field.OPTION=2;
Field.PASSWORD=3;
Field.DATE=4;
Field.POINT=5;
Field.POINTS=6;
Field.BOOLEAN=7;
Field.BOUNDS=8;
Field.TEXT=9;
Field.ZOOMLEVEL=10;
Object.extend(Field.prototype,{Field_constructor:function(_b6,_b7,_b8,_b9,_ba,_bb){
this.name=_b6;
this.type=_b8;
this.setValue(_b7);
this.option=_ba;
this.editable=_b9;
this.options=_ba;
this.defaultSelection=_bb;
},getType:function(){
return this.type;
},isEditable:function(){
return this.editable;
},getOptions:function(){
return this.options;
},getDefaultSelection:function(){
return this.defaultSelection;
},getValue:function(){
return this.value;
},setValue:function(_bc){
if(this.type==Field.STRING||this.type==Field.TEXT){
if(_bc==null){
_bc="";
}else{
_bc=_bc;
}
}else{
if(this.type==Field.NUMBER){
try{
_bc=parseInt(_bc);
}
catch(e){
this.logger.error("Error parsing Number value from server: "+_bc+" field: "+name);
_bc=null;
}
}else{
if(this.type==Field.POINT){
_bc=convertPoint(_bc);
}else{
if(this.type==Field.POINTS){
_bc=convertPoints(_bc);
}else{
if(this.type==Field.BOOLEAN){
_bc=convertBoolean(_bc);
}else{
if(this.type==Field.OPTION){
_bc=_bc;
}else{
if(this.type==Field.DATE){
_bc=convertDate(_bc);
}else{
if(this.type==Field.PASSWORD){
_bc="";
}else{
if(this.type==Field.BOUNDS){
_bc=_bc;
}
}
}
}
}
}
}
}
}
this.value=_bc;
},getFieldName:function(){
return this.name;
}});

var Slot=Class.create();
var slotLogger=maptales.getLogger("com.maptales.webClient.cache.slot");
Slot.prototype={initialize:function(_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b){
if(_1==null){
_1=[];
}
this.logger=slotLogger;
this.objectClass=_a;
this.name=_6;
this.parent=_7;
this.parentSlot=_9;
this._isDirty=false;
this.slotListeners={};
this.localAdditions=[];
this.localRemovals=[];
if(_b!=null){
this.cacheable=_b;
}else{
this.cacheable=true;
}
this.symmetricFacet=_8||null;
this.boundSortListener=this.sortSlotOnChange.bind(this);
this.boundDeleteListener=this.deleteListener.bind(this);
this.boundChangeIdFunction=this.changeId.bind(this);
if(_2==0){
this.slotLength=0;
}else{
this.slotLength=_2||-1;
}
this.lazy=_3||true;
if(_4==false||_4==null){
this.defaultSorting=null;
}else{
if(_4 instanceof SlotSorter){
this.defaultSorting=_4;
}else{
this.defaultSorting=new SlotSorter(_4);
}
}
if(_5==false||_5==null){
this.defaultFilter=null;
}else{
if(_5 instanceof SlotFilter){
alert("slot should not get filter passed from parent");
this.defaultFilter=new SlotFilter(_5,this);
}else{
this.defaultFilter=new SlotFilter(_5,this);
}
}
this.slot=[];
this.sortedSlots={};
this.filteredSlots={};
if(this.lazy==false){
if(_1.length!=this.slotLength){
throw new SnapMapException("CacheException","NonLazy slot "+this.name+" not fully transmitted");
}
this.insert(_1,0);
}else{
if(_1.length>0){
this.insert(_1,0);
}
}
},getObjectClass:function(){
return this.objectClass;
},filterInvalidItems:function(_c){
if(_c==null){
return null;
}
var _d=[];
for(var e=0;e<_c.length;e++){
if(_c[e] instanceof ContentObject){
_d.push(_c[e]);
}else{
if(_c[e]!=null){
_d.push(_c[e]);
}
}
}
return _d;
},insert:function(_f,_10,_11,_12,_13){
this.logger.debug("insert> objects: "+_f+" offset: "+_10+" filter: "+_11+" sort: "+_12+" slotLength: "+_13);
_f=this.filterInvalidItems(_f);
if(_11==null||this.isDefaultFilter(_11)){
if(_13!=null&&_13>=0){
this.setSlotLength(_13);
}
var end=this.clipToSlotLength(parseInt(_10)+_f.length);
if(_12!=false&&_12!=null&&!this.isDefaultSort(_12)){
var _12=new SlotSorter(_12);
if(!this.sortedSlots[_12.toString()]){
this.sortedSlots[_12.toString()]=[];
}
var _15=0;
for(var i=_10;i<end;i++){
var id=_f[_15].id||_f[_15];
this.sortedSlots[_12.toString()][i]=id;
this.registerAllListenersOnItem(id,new SlotSorter(_12));
_15++;
}
}else{
if(this.defaultSorting){
_f.sort(this.defaultSorting.execute.bind(this.defaultSorting));
}
var _15=0;
for(var i=_10;i<end;i++){
var id=_f[_15].id||_f[_15];
this.slot[i]=id;
this.registerAllListenersOnItem(id,this.defaultSorting);
_15++;
}
}
}else{
var _18=new SlotFilter(_11,this);
if(this.filteredSlots[_18.toString()]){
this.filteredSlots[_18.toString()].insert(_f,_10,_11,_12,_13);
}else{
if((!_13)&&(_13!=0)){
_13=-1;
}
this.filteredSlots[_18.toString()]=new Slot(null,_13,true,_12,_11,this.name,this.parent,null,this);
this.filteredSlots[_18.toString()].insert(_f,_10,_11,_12,_13);
}
}
},get:function(_19,_1a,_1b,_1c){
this.logger.debug("get> offset: "+_19+" number: "+_1a+" filter: "+_1b+" sort: "+_1c);
_1a=this.clipToSlotLength(_19+_1a)-_19;
if(this.lazy==false||this.isSlotFullyLoaded()){
return this._getPartOfLoadedSlot(_19,_1a,_1b,_1c);
}else{
if(_1b!=null&&!this.isDefaultFilter(_1b)){
var _1b=new SlotFilter(_1b,this);
if(this.filteredSlots[_1b.toString()]){
return this.filteredSlots[_1b.toString()].get(_19,_1a,null,_1c);
}else{
throw new SnapMapException("CacheException","This Filtered Slot "+this.name+"."+_1b.toString()+" is not in cache yet");
}
}else{
if(_1c!=false&&_1c!=null&&!this.isDefaultSort(_1c)){
if(this.isSlotInCache(_19,_1a)){
var _1c=new SlotSorter(_1c);
return this._getPartOfSortedSlot(_1c.toString(),_19,_1a);
}else{
throw new SnapMapException("CacheException","Part of Slot '"+this.name+"' is not in cache <br />offset:"+_19+" <br />number:"+_1a+" <br />filter:"+_1b+" <br />sort:"+_1c+"<br /><br />SlotInfo> <br />SlotLength: "+this.getSlotLength()+" <br />this.slot.length: "+this.slot.length);
}
}else{
if(this.isSlotInCache(_19,_1a)){
return this._getPartOfDefaultSlot(_19,_1a);
}else{
throw new SnapMapException("CacheException","Part of Slot '"+this.name+"' is not in cache <br />offset:"+_19+" <br />number:"+_1a+" <br />filter:"+_1b+" <br />sort:"+_1c+"<br /><br />SlotInfo> <br />SlotLength: "+this.getSlotLength()+" <br />this.slot.length: "+this.slot.length);
}
}
}
}
},add:function(_1d){
this._isDirty=true;
_1d=this.castToArray(_1d);
_1d=this.filterInputArray(_1d);
if(_1d.length>0){
this.logger.debug("add> contentObjects Num: "+_1d.length);
var _1e=this.filterItemsThatAreInSlotAlready(_1d);
var _1f=this._add(_1e,this.defaultSorting);
if(this.getSlotLength()!=-1){
this.setSlotLength(this.getSlotLength()+_1e.length);
}
this.addToLocalAdditions(_1e);
if(_1f!=null){
this.notifySlotListeners({additions:_1f},this.defaultSorting);
}
for(sortedSlot in this.sortedSlots){
if(sortedSlot.length>0){
var _20=new SlotSorter(sortedSlot.replace(/_/," "));
var _21=this._add(_1e,_20);
if(_21!=null){
this.notifySlotListeners({additions:_21},_20);
}
}
}
for(filteredSlot in this.filteredSlots){
if(this.filteredSlots[filteredSlot] instanceof Slot){
this.filteredSlots[filteredSlot].add(_1d,null,_20);
}
}
}
},_add:function(_22,_23){
var _24=[];
for(var i=0;i<_22.length;i++){
var _26=$O(_22[i]);
if(_23==null){
var id=_26.get("id");
this.slot.unshift(id);
this.registerAllListenersOnItem(id,_23);
_24.push({addedId:id,insertionIndex:0});
}else{
if(this.isDefaultSort(_23)){
var _28=this.slot;
}else{
if(this.sortedSlots[_23.toString()]){
var _28=this.sortedSlots[_23.toString()];
}else{
var _28=[];
}
}
this.registerAllListenersOnItem(_26.get("id"),_23);
if(_28.length==0){
_28[0]=_26.id;
_24.push({addedId:_26.id,insertionIndex:0});
}else{
if(_28.length>0){
var _29=false;
for(var e=0;e<_28.length;e++){
if(_29==false){
var _2b=maptales.cache.getFromCache(_28[e]);
if(_23.execute(_2b,_26)!=-1){
_28=this._addItemAtPosition(_26.get("id"),_28,e);
_29=true;
_24.push({addedId:_26.get("id"),insertionIndex:e});
}
}
}
if(_29==false){
_28.push(_26.id);
_24.push({addedId:_26.id,insertionIndex:_28.length-1});
}
}
}
if(this.isDefaultSort(_23)){
this.slot=_28;
}else{
this.sortedSlots[_23.toString()]=_28;
}
}
}
if(_24.length==0){
return null;
}else{
return _24;
}
},remove:function(_2c){
this.logger.debug("remove> contentObject: "+_2c);
this._isDirty=true;
_2c=this.castToArray(_2c);
var _2d=false;
if(this.slot.length>0){
var _2e=this._remove(_2c,this.defaultSorting);
_2d=true;
}
for(sortedSlot in this.sortedSlots){
if(sortedSlot.length>0){
var _2f=new SlotSorter(sortedSlot.replace(/_/," "));
var _30=this._remove(_2c,_2f);
_2d=true;
}
}
for(filteredSlot in this.filteredSlots){
this.filteredSlots[filteredSlot].remove(_2c);
}
if(_2d){
this.addToLocalRemovals(_2c);
if(_2e!=null&&_30!=null){
var _31=Math.max(_2e.length,_30.length);
}else{
if(_2e!=null){
var _31=_2e.length;
}else{
if(_30!=null){
var _31=_30.length;
}else{
var _31=0;
}
}
}
if(this.getSlotLength()!=-1){
this.setSlotLength(this.getSlotLength()-_31);
}
this.notifySlotListeners({removals:_2e},this.defaultSorting);
for(sortedSlot in this.sortedSlots){
if(sortedSlot.length>0){
this.notifySlotListeners({removals:_30},_2f);
}
}
}
},_remove:function(_32,_33){
var _34=[];
if(this.isDefaultSort(_33)){
var _35=this.slot;
}else{
if(this.sortedSlots[_33.toString()]){
var _35=this.sortedSlots[_33.toString()];
}else{
return null;
}
}
for(var i=0;i<_32.length;i++){
var id=$O(_32[i]).id;
var _38=this._findIndex(_35,id);
if(_38>=0){
this.removeAllListenersFromItem(id);
_35=this._removeIndex(_35,_38);
_34.push(_38);
}
}
if(this.isDefaultSort(_33)){
this.slot=_35;
}else{
if(this.sortedSlots[_33.toString()]){
this.sortedSlots[_33.toString()]=_35;
}
}
return _34;
},_removeIndex:function(_39,_3a){
return _39.slice(0,_3a).concat(_39.slice(_3a+1));
},clear:function(){
this.localAdditions=[];
this.localRemovals=[];
this.sortedSlots={};
this.slot=[];
this.slotLength=-1;
this.lazy=true;
for(filteredSlot in this.filteredSlots){
this.filteredSlots[filteredSlot].clear();
}
},getSymmetricFacet:function(){
return this.symmetricFacet;
},sortSlotOnChange:function(_3b,_3c,_3d){
var _3e=[];
if(this.defaultSorting){
if(this.defaultSorting.getField()==_3d){
var _3e=this._sortSlotOnChange(this.defaultSorting,_3c);
if(_3e){
this.notifySlotListeners({sortChanges:_3e},this.defaultSorting);
}
}
}
if(this.sortedSlots){
for(slot in this.sortedSlots){
if(slot.length>0){
var _3f=new SlotSorter(slot.replace(/_/," "));
if(_3f.getField()==_3d){
var _40=this._sortSlotOnChange(_3f,_3c);
if(_40){
this.notifySlotListeners({sortChanges:_40},_3f);
}
}
}
}
}
},_sortSlotOnChange:function(_41,_42){
var _43=[];
if(this.isDefaultSort(_41)){
var _44=this.slot;
}else{
var _45=this._getSortHash(_41);
var _44=this.sortedSlots[_45];
}
var _46=this._findIndex(_44,_42.id);
_44=this._removeIndex(_44,_46);
var _47=this._findNewPosition(_42,_44,_41);
_44=this._addItemAtPosition(_42.get("id"),_44,_47);
if(this.isDefaultSort(_41)){
this.slot=_44;
}else{
var _45=this._getSortHash(_41);
this.sortedSlots[_45]=_44;
}
if(_46==_47){
return null;
}else{
_43.push({oldIndex:_46,newIndex:_47});
return _43;
}
},_findNewPosition:function(_48,_49,_4a){
var _4b=null;
for(var i=0;i<_49.length;i++){
var _4d=$O(_49[i]);
if(_4a.execute(_4d,_48)!=-1){
_4b=i;
break;
}
}
if(_4b==null){
_4b=_49.length;
}
return _4b;
},expellFromFilteredSlot:function(_4e){
this.logger.debug("expellFromFilteredSlot> contentObject: "+_4e.id);
_4e=this.castToArray(_4e);
for(var i=0;i<_4e.length;i++){
var id=$O(_4e[i]).id;
this.remove(id);
if(this.parentSlot){
this.parentSlot.onExpellFromFilteredSlot(_4e,this);
}else{
}
}
},onExpellFromFilteredSlot:function(_51,_52){
this.logger.debug("onExpellFromFilteredSlot> releasedObjects: "+_51+" slotOfOrigin: "+_52);
for(filteredSlot in this.filteredSlots){
if(this.filteredSlots[filteredSlot]!=_52){
try{
this.filteredSlots[filteredSlot].add(_51);
}
catch(e){
this.logger.warn("AddError: could not add to filtered slot",e);
}
}
}
},registerAllListenersOnItem:function(id,_54){
this.logger.debug("registerAllListenersOnItem> id: "+id+" slotSorter: "+_54);
var _55=$O(id);
if(_55){
this.registerDeleteListener(_55.get("id"));
if(this.defaultFilter){
this.registerFilterListener(_55.get("id"));
}
if(_54){
this.registerSortListener(_55.get("id"),_54);
}
if(_55.get("id")<0){
_55.addIdListener(this.boundChangeIdFunction);
}
}else{
}
},removeAllListenersFromItem:function(id){
this.logger.debug("removeAllListenersFromItem> id: "+id);
var _57=$O(id);
if(_57){
this.removeDeleteListener(_57.get("id"));
if(this.defaultFilter){
this.removeFilterListener(_57.get("id"));
}
if(this.defaultSorting){
this.removeSortListener(_57.get("id"),this.defaultSorting);
}
if(_57.get("id")<0){
_57.removeIdListener(this.boundChangeIdFunction);
}
}else{
this.logger.info("Slot item was removed, but is not in cache yet....therefore no listeners are deregistered");
}
},registerSortListener:function(id,_59){
if(maptales.cache.isInCache(id)){
maptales.cache.getFromCache(id).addFieldListener(_59.getField(),this.boundSortListener);
}
},removeSortListener:function(id,_5b){
if(maptales.cache.isInCache(id)){
maptales.cache.getFromCache(id).removeFieldListener(_5b.getField(),this.boundSortListener);
}
},registerDeleteListener:function(id){
if(maptales.cache.isInCache(id)){
maptales.cache.getFromCache(id).addDeleteListener(this.boundDeleteListener);
}
},removeDeleteListener:function(id){
if(maptales.cache.isInCache(id)){
maptales.cache.getFromCache(id).removeDeleteListener(this.boundDeleteListener);
}
},deleteListener:function(id){
try{
this.remove(id);
}
catch(e){
this.logger.warn("RemoveAfterDeleteError: Item in slot was deleted, but slot is not able to remove it",e);
}
},addSlotListener:function(_5f,_60,_61){
if(!(_61 instanceof Function)){
this.logger.warn("tried to add a slotListener with no callback");
return;
}
if(_5f&&!this.isDefaultFilter(_5f)){
var _62=new SlotFilter(_5f,this);
if(this.filteredSlots[_62.toString()]){
this.filteredSlots[_62.toString()].addSlotListener(_5f,_60,_61);
}else{
this.filteredSlots[_62.toString()]=new Slot(null,null,true,_60,_5f,this.name,this.parent,null,this);
this.filteredSlots[_62.toString()].addSlotListener(_5f,_60,_61);
}
}else{
this._addSlotListener(_60,_61);
}
},_addSlotListener:function(_63,_64){
if(_63==false||_63==null){
_63=this.defaultSorting;
}else{
_63=new SlotSorter(_63);
}
var _65=this._getSortHash(_63);
if(!this.isDefaultSort(_63)){
if(this.sortedSlots[_65]==null){
this.sortedSlots[_65]=[];
if(this.isSlotFullyLoaded()){
var _66=this.get(0,-1,null,_63);
for(var i=0;i<_66.length;i++){
this.registerSortListener(_66[i].id,_63);
this.sortedSlots[_65].push(_66[i].id);
}
}
}
}
if(this.slotListeners[_65]==null){
this.slotListeners[_65]=[];
}
this.slotListeners[_65].push(_64);
},removeSlotListener:function(_68,_69,_6a){
if(_68&&!this.isDefaultFilter(_68)){
var _68=new SlotFilter(_68,this);
if(this.filteredSlots[_68.toString()]){
this.filteredSlots[_68.toString()].removeSlotListener(_68,_69,_6a);
}else{
this.logger.warn("SlotError: Cant register a listener to a filtered "+"slot that does not exist yet: "+this.parent.getClassName()+this.name+"."+_68.toString());
}
}else{
this._removeSlotListener(_69,_6a);
}
},_removeSlotListener:function(_6b,_6c){
var _6d=this._getSortHash(_6b);
if(this.slotListeners[_6d]){
for(var i=0;i<this.slotListeners[_6d].length;i++){
if((this.slotListeners[_6d][i]==_6c)){
this.slotListeners[_6d].splice(i,1);
break;
}
}
}
},notifyAllSlotListeners:function(_6f,_70){
this.notifySlotListeners(_6f,_70);
for(filteredSlot in this.filteredSlots){
this.filteredSlots[filteredSlot].notifyAllSlotListeners(_6f,_70);
}
},notifySlotListeners:function(_71,_72){
if(_72){
var _73=new SlotSorter(_72);
var _74=this._getSortHash(_73);
this._notifySlotListeners(_71,_74);
}else{
this._notifySlotListeners(_71,null);
}
},_notifySlotListeners:function(_75,_76){
if(_76==null){
for(hash in this.slotListeners){
this._notifySlotListeners(_75,hash);
}
}else{
var _77=this.slotListeners[_76];
if(_77){
for(var i=0;i<_77.length;i++){
try{
_77[i](_75,this.parent,this.name,this.defaultFilter,_76);
}
catch(e){
this.logger.warn("NotifyListenerException: Slot.notifySlotListeners had an error notifying",e);
}
}
}
}
},getSlotListenersNum:function(_79,_7a){
if(_79&&!this.isDefaultFilter(_79)){
var _79=new SlotFilter(_79,this);
if(this.filteredSlots[_79.toString()]){
return this.filteredSlots[_79.toString()].getSlotListenersNum(_79,_7a);
}else{
this.logger.warn("SlotError: Cant register a listener to a filtered "+"slot that does not exist yet: "+this.parent.getClassName()+this.name+"."+_79.toString());
return 0;
}
}else{
if(_7a==null){
return this._getSlotListenersNum(this.defaultSorting);
}else{
var _7b=new SlotSorter(_7a);
return this._getSlotListenersNum(_7b);
}
}
},_getSlotListenersNum:function(_7c){
var _7d=this._getSortHash(_7c);
if(this.slotListeners[_7d]){
return this.slotListeners[_7d].length;
}else{
return 0;
}
},_getSortHash:function(_7e){
if(_7e==null){
var _7f="default";
}else{
if(this.isDefaultSort(_7e)){
var _7f="default";
}else{
_7e=new SlotSorter(_7e);
var _7f=_7e.toString();
}
}
return _7f;
},registerFilterListener:function(id){
try{
this.defaultFilter.registerFilterListener(id);
}
catch(e){
this.logger.warn("RegisterFilterListener: Could not add listener to "+id+" - "+maptales.cache.getFromCache(id),e);
}
},removeFilterListener:function(id){
try{
this.defaultFilter.removeFilterListener(id,this.boundFilterItemCallback);
}
catch(e){
this.logger.warn("RemoveFilterListener: Could not remove listener to "+id+" - "+maptales.cache.getFromCache(id),e);
}
},isInSlot:function(_82){
var _83=false;
if(this._isInSlot(this.slot,_82)){
_83=true;
}
for(sortedSlot in this.sortedSlots){
if(sortedSlot.length>0){
if(this._isInSlot(this.sortedSlots[sortedSlot],_82)){
_83=true;
}
}
}
return _83;
},_isInSlot:function(_84,_85){
var _86=false;
var id=$O(_85).get("id");
_84.each(function(_88){
if(_88==id){
_86=true;
}
});
return _86;
},changeId:function(_89,_8a){
this._replaceId(this.slot,_89,_8a);
for(slotIndex in this.sortedSlots){
this._replaceId(this.sortedSlots[slotIndex],_89,_8a);
}
for(slotIndex in this.filteredSlots){
this.filteredSlots[slotIndex].changeId(_89,_8a);
}
},_replaceId:function(_8b,_8c,_8d){
for(var i=0;i<_8b.length;i++){
if(_8b[i]==_8d){
_8b[i]=_8c;
}
}
},isSlotFullyLoaded:function(){
if(this.lazy==false){
return true;
}else{
if(this.getSlotLength()==-1){
return false;
}
if(this.getSlotLength()==0){
return true;
}
if(this.getSlotLength()>this.slot.length){
return false;
}
return this.isSlotInCache(0,this.getSlotLength());
}
},isSlotInCache:function(_8f,_90,_91,_92){
if(!_91){
_91=this.defaultFilter;
}
if(!_92){
_92=this.defaultSorting;
}
if(this.lazy==false){
return true;
}
if(_91!=this.defaultFilter){
if(this.filteredSlots[_91]!=null){
return this.filteredSlots[_91].isSlotInCache(_8f,_90,null,_92);
}else{
return false;
}
}else{
var end=this.clipToSlotLength(parseInt(_8f)+parseInt(_90));
if(this.getSlotLength()==-1&&end==-1){
return false;
}
for(var i=_8f;i<end;i++){
if(this.slot[i]==null||!this.slot[i]){
return false;
}else{
if(maptales.cache.isInCache(this.slot[i])==false){
return false;
}
}
}
return true;
}
},setSlotLength:function(_95,_96){
if(_96==null||this.isDefaultFilter(_96)){
this.slotLength=_95;
}else{
var _96=new SlotFilter(_96,this);
if(this.filteredSlots[_96.toString()]){
this.filteredSlots[_96.toString()].setSlotLength(_95);
}else{
throw new SnapMapException("CacheException","Filtered slot is not loaded yet");
}
}
},getSlotLength:function(_97){
if(_97==null||this.isDefaultFilter(_97)){
return this.slotLength;
}else{
var _97=new SlotFilter(_97,this);
if(this.filteredSlots[_97.toString()]){
return this.filteredSlots[_97.toString()].getSlotLength();
}else{
if(this.isLazy==false||this.isSlotFullyLoaded()){
var _98=_97.execute(this.slot);
return _98.length;
}else{
throw new SnapMapException("CacheException","Filtered slot is not loaded yet");
}
}
}
},isDefaultSort:function(_99){
if(this.defaultSorting==null){
if(_99==null||_99==""||_99==false){
return true;
}else{
return false;
}
}else{
if(_99==null||_99==""||_99==false){
return true;
}
var _9a=new SlotSorter(_99);
return this.defaultSorting.compare(_9a);
}
},isDefaultFilter:function(_9b){
if(this.defaultFilter==null){
if(_9b==null||_9b==""||_9b==false){
return true;
}else{
return false;
}
}else{
if(_9b==null||_9b==""||_9b==false){
return true;
}
if(_9b instanceof SlotFilter){
return this.defaultFilter.compare(_9b);
}else{
var _9c=new SlotFilter(_9b,this);
return this.defaultFilter.compare(_9c);
}
}
},clipToSlotLength:function(_9d){
var end=_9d;
if(this.getSlotLength()!=-1){
if(end>this.getSlotLength()||end==-1){
end=this.getSlotLength();
}
}
return end;
},compareSlotArrays:function(_9f,_a0){
if(_9f.length!=_a0.length){
for(var i=0;i<_9f.length;i++){
if(_9f[i] instanceof ContentObject){
var id1=_9f[i].get("id");
}else{
var id1=_9f[i];
}
if(_a0[i] instanceof ContentObject){
var id2=_a0[i].get("id");
}else{
var id2=_a0[i];
}
if(id1!=id2){
return false;
}
}
return true;
}else{
return false;
}
},isLazy:function(){
return this.lazy;
},getIndexOf:function(_a4,_a5,_a6){
var id=_a4.id||_a4;
if(_a5==null||_a5==false||this.isDefaultFilter(_a5)){
if(_a6==null||_a6==false||this.isDefaultSort(_a6)){
return this._findIndex(this.slot,id);
}else{
var _a8=new SlotSorter(_a6);
if(this.sortedSlots[_a8.toString()]){
var _a9=this._findIndex(this.sortedSlots[_a8.toString()],id);
if(_a9==-1){
throw new SnapMapException("CacheException","Could not determine index of object "+id);
}else{
return _a9;
}
}else{
if(this.isLazy()==false||this.isSlotFullyLoaded()){
this.sortedSlots[_a8.toString()]=this.slot.copy();
this.sortedSlots[_a8.toString()].sort(_a8.execute.bind(_a8));
var _a9=this._findIndex(this.sortedSlots[_a8.toString()],id);
if(_a9==-1){
return false;
}else{
return _a9;
}
}else{
throw new SnapMapException("CacheException","Sorted slot "+_a6.toString()+" is not loaded yet");
}
}
}
}else{
var _a5=new SlotFilter(_a5,this);
if(this.filteredSlots[_a5.toString()]){
return this.filteredSlots[_a5.toString()].getIndexOf(id,null,_a6);
}else{
if(this.isLazy()==false||this.isSlotFullyLoaded()){
var _aa=_a5.execute(this.slot);
if(_a6==null||_a6==false||this.isDefaultSort(_a6)){
var _a9=this._findIndex(_aa,id);
}else{
var _a8=new SlotSorter(_a6);
_aa.sort(_a8.execute.bind(_a8));
var _a9=this._findIndex(_aa,id);
}
if(_a9==-1){
return false;
}else{
return _a9;
}
}else{
throw new SnapMapException("CacheException","Filtered slot "+_a5.toString()+" is not loaded yet");
}
}
}
},getData:function(){
var _ab=[];
this.slot.each(function(_ac){
if(_ac<=0){
_ab.push($O(_ac).getData());
}else{
_ab.push(_ac);
}
}.bind(this));
return _ab;
},getDirtyData:function(){
var _ad={};
_ad.localAdditions=[];
for(var i=0;i<this.localAdditions.length;i++){
addition=maptales.cache.getFromCache(this.localAdditions[i]);
if(addition!=null){
if(addition.isTransient()){
_ad.localAdditions.push(addition.getData());
}else{
_ad.localAdditions.push(addition.get("id"));
}
}
}
_ad.localRemovals=this.localRemovals;
return _ad;
},isDirty:function(){
return this._isDirty;
},setDirty:function(){
this._isDirty=true;
},clean:function(){
this.localAdditions=[];
this.localRemovals=[];
this._isDirty=false;
},addToLocalRemovals:function(_af){
if(_af instanceof Array){
for(var i=0;i<_af.length;i++){
var id=$O(_af[i]).id;
this.localRemovals.push(id);
}
}else{
var id=$O(_af).id;
this.localRemovals.push(id);
}
},addToLocalAdditions:function(_b2){
if(_b2 instanceof Array){
_b2.each(function(_b3){
var id=$O(_b3).id;
this.localAdditions.push(id);
}.bind(this));
}else{
var id=$O(_b2).id;
this.localAdditions.push(id);
}
},_findIndex:function(_b6,id){
var _b8=-1;
_b6.each(function(_b9,_ba){
if(_b9==id){
_b8=_ba;
return _b8;
}
});
return _b8;
},_getPartOfSortedSlot:function(_bb,_bc,_bd){
var _be=[];
if(this.sortedSlots[_bb]){
for(var i=_bc;i<(_bc+_bd);i++){
var id=this.sortedSlots[_bb][i];
if(maptales.cache.isInCache(id)){
_be.push(maptales.cache.getFromCache(id));
}else{
throw new SnapMapException("CacheException","Slot '"+this.name+"' Member at position: "+i+" with id: "+id+" is not in cache");
}
}
}else{
throw new SnapMapException("CacheException","Slot '"+this.name+"' is not in cache in that sort yet");
}
return _be;
},_getPartOfLoadedSlot:function(_c1,_c2,_c3,_c4){
var _c5=this._getLoadedSlot();
if(_c3!=null&&!this.isDefaultFilter(_c3)){
var _c6=new SlotFilter(_c3,this);
_c5=_c6.execute(_c5);
if(this.filteredSlots[_c6.toString()]){
if(this.filteredSlots[_c6.toString()].isSlotFullyLoaded()){
_c5=this.filteredSlots[_c6.toString()]._getPartOfLoadedSlot(_c1,_c2,_c3,_c4);
}else{
this.filteredSlots[_c6.toString()].insert(_c5,_c1,_c3,_c4,_c5.length);
}
}else{
this.filteredSlots[_c6.toString()]=new Slot(null,_c5.length,true,_c4,_c3,this.name,this.parent,null,this);
this.filteredSlots[_c6.toString()].insert(_c5,_c1,_c3,_c4,_c5.length);
}
}
if(_c4!=false&&_c4!=null&&!this.isDefaultSort(_c4)){
var _c7=new SlotSorter(_c4);
_c5.sort(_c7.execute.bind(_c7));
}
var end=this.clipToSlotLength(parseInt(_c1)+parseInt(_c2));
if(end>_c5.length){
end=_c5.length;
}
var _c9=[];
for(var i=_c1;i<end;i++){
_c9.push(_c5[i]);
}
return _c9;
},_getPartOfDefaultSlot:function(_cb,_cc){
var _cd=[];
var end=this.clipToSlotLength(parseInt(_cb)+parseInt(_cc));
for(var i=_cb;i<end;i++){
if(maptales.cache.isInCache(this.slot[i])){
_cd.push(maptales.cache.getFromCache(this.slot[i]));
}else{
throw new SnapMapException("CacheException","Slot '"+this.name+"' Member at position: "+i+" with id: "+this.slot[i]+" is not in cache");
}
}
return _cd;
},_getLoadedSlot:function(){
var _d0=[];
this.slot.each(function(id,_d2){
if(maptales.cache.isInCache(id)){
_d0.push(maptales.cache.getFromCache(id));
}else{
throw new SnapMapException("CacheException","Slot '"+this.name+"' Member at position: "+_d2+" with id: "+id+" is not in cache");
}
});
return _d0;
},castToArray:function(_d3){
if(!(_d3 instanceof Array)){
_d3=[_d3];
}
return _d3;
},filterInputArray:function(_d4){
if(this.defaultFilter){
_d4=this.defaultFilter.execute(_d4);
}
return _d4;
},filterItemsThatAreInSlotAlready:function(_d5){
var _d6=[];
for(var i=0;i<_d5.length;i++){
if(!this.isInSlot(_d5[i])){
_d6.push(_d5[i]);
}
}
return _d6;
},_addItemAtPosition:function(id,_d9,_da){
var _db=_d9.slice(_da);
if(_da>0){
var _dc=_d9.slice(0,_da);
}else{
var _dc=[];
}
_db.unshift(id);
_d9=_dc.concat(_db);
return _d9;
}};
var SlotSorter=Class.create();
SlotSorter.prototype={logger:maptales.getLogger("com.maptales.webclient.slotsorter"),initialize:function(_dd){
if(typeof _dd=="string"){
var _de=_dd.split(" ");
this.field=_de[0];
if(!_de[1]){
_de[1]="asc";
}
this.comparator=_de[1].toLowerCase();
}else{
this.comparator=_dd.comparator;
this.field=_dd.field;
}
},getComparator:function(){
return this.comparator;
},getField:function(){
return this.field;
},execute:function(a,b){
a=$O(a);
b=$O(b);
try{
if(a.get(this.field) instanceof Date){
return this._execute(a.get(this.field).getTime(),b.get(this.field).getTime());
}else{
return this._execute(a.get(this.field),b.get(this.field));
}
}
catch(e){
this.logger.warn("SortError sorting by: "+this.field+"<br /> b.id: "+b.id+" b.field: "+b.get(this.field),e);
}
},compare:function(_e1){
if(this.comparator!=_e1.comparator){
return false;
}
if(this.field!=_e1.field){
return false;
}
return true;
},_execute:function(a,b){
if(a>b){
if(this.comparator=="asc"){
return 1;
}else{
return -1;
}
}else{
if(this.comparator=="asc"){
return -1;
}else{
return 1;
}
}
},toString:function(){
return this.field+"_"+this.comparator;
}};
var SlotFilter=Class.create();
SlotFilter.prototype={logger:maptales.getLogger("com.maptales.webclient.slotfilter"),comparators:[">","<","=","!=","<=",">="],initialize:function(_e4,_e5){
this.slot=_e5;
AssertInstanceOf(Slot,this.slot,"SlotFilterInitException","A Slot filter only works with a slot. No slot is passed to slot filter");
this.filters=[];
if(_e4 instanceof Array){
for(var i=0;i<_e4.length;i++){
try{
this.filters.push(this._makeFilter(_e4[i]));
}
catch(e){
this.logger.warn("Error initializing SlotFilter",e);
}
}
}else{
try{
this.filters.push(this._makeFilter(_e4));
}
catch(e){
this.logger.warn("Error initializing SlotFilter",e);
}
}
},_makeFilter:function(_e7){
if(typeof _e7=="string"){
return this.parseFilter(_e7);
}
if(_e7.type=="refFilter"){
return new RefFilter(_e7,this.slot);
}else{
if(_e7.type=="fieldFilter"){
return new FieldFilter(_e7,this.slot);
}else{
if(_e7.type=="classFilter"){
return new ClassFilter(_e7,this.slot);
}else{
throw new SnapMapException("FilterException","the filter of type: "+_e7.type+" does not exist");
}
}
}
},parseFilter:function(_e8){
_e8=_e8.replace(/\s/,"");
var _e9="";
var _ea="";
var _eb="";
var _ec=this.detectComparator(_e8);
if(_ec!=-1){
var _ed=_e8.split(this.comparators[_ec]);
_ea=_ed[0];
_eb=this.comparators[_ec];
if(_ed[1]=="null"){
_e9=null;
}else{
_e9=_ed[1];
}
return new FieldFilter({comparator:_eb,field:_ea,value:_e9},this.slot);
}else{
this.logger.warn("SlotFilterError: SlotFilter did not have comparator");
}
},detectComparator:function(_ee){
var _ef=-1;
this.comparators.each(function(_f0,_f1){
if(_ee.indexOf(_f0)!=-1){
_ef=_f1;
return _ef;
}
});
return _ef;
},execute:function(_f2){
var _f3=[];
for(var i=0;i<_f2.length;i++){
if(!this.itemHasToBeFiltered(_f2[i])){
_f3.push(_f2[i]);
}
}
return _f3;
},itemHasToBeFiltered:function(_f5){
for(var i=0;i<this.filters.length;i++){
if(this.filters[i].itemHasToBeFiltered(_f5)){
return true;
}
}
return false;
},registerFilterListener:function(id){
for(var i=0;i<this.filters.length;i++){
this.filters[i].registerFilterListener(id);
}
},removeFilterListener:function(id){
for(var i=0;i<this.filters.length;i++){
this.filters[i].removeFilterListener(id);
}
},compare:function(_fb){
for(var i=0;i<this.filters.length;i++){
if(!this.filters[i].compare(_fb.filters[i])){
return false;
}
}
return true;
},toString:function(){
var _fd="";
for(var i=0;i<this.filters.length;i++){
_fd+=this.filters[i].toString();
}
return _fd;
}};
var FieldFilter=Class.create();
FieldFilter.prototype={logger:maptales.getLogger("com.maptales.webclient.fieldfilter"),initialize:function(_ff,slot,_101){
this.slot=slot;
this.parent=_101;
this.field=_ff.field;
this.comparator=_ff.comparator;
if(_ff.value=="null"){
this.value=null;
}else{
this.value=_ff.value;
}
this.boundFilterItemCallback=this.filterItemCallback.bind(this);
},filterItemCallback:function(_102,_103){
try{
if(this.itemHasToBeFiltered(_103)){
if(this.parent){
this.parent.expellFromFilteredSlot(_103);
}else{
this.slot.expellFromFilteredSlot(_103);
}
}
}
catch(e){
if(e instanceof SnapMapException){
this.logger.warn("SlotFilterError: Could not filter item: "+_103+" with id "+_103.id,e);
}else{
this.logger.warn("SlotFilterError: Could not filter item: "+_103+" with id "+_103.id,e);
}
}
},registerFilterListener:function(id){
$O(id).addFieldListener(this.field,this.boundFilterItemCallback);
},removeFilterListener:function(id){
},itemHasToBeFiltered:function(_106){
try{
_106=$O(_106);
}
catch(e){
alert("Filter>filterItem>"+e);
}
if(!_106){
return false;
}
var _107="not set";
if(_106.isField(this.field)){
_107=_106.get(this.field);
}else{
if(_106.isSlot(this.field)){
}else{
if(_106.isRef(this.field)){
_107=_106.getRefId(this.field);
}else{
return false;
}
}
}
if(this.comparator=="="){
if(_107==this.value){
return false;
}
}else{
if(this.comparator=="!="){
if(_107!=this.value){
return false;
}
}else{
if(this.comparator==">"){
if(_107>this.value){
return false;
}
}else{
if(this.comparator=="<"){
if(_107<this.value){
return false;
}
}else{
if(this.comparator=="<="){
if(_107<=this.value){
return false;
}
}else{
if(this.comparator==">="){
if(_107>=this.value){
return false;
}
}
}
}
}
}
}
return true;
},compare:function(_108){
if(this.comparator!=_108.comparator){
return false;
}
if(this.value!=_108.value){
return false;
}
if(this.field!=_108.field){
return false;
}
return true;
},toString:function(){
return this.field+this.comparator+this.value;
}};
var ClassFilter=Class.create();
ClassFilter.prototype={initialize:function(_109,slot,_10b){
this.slot=slot;
this.parent=_10b;
this.exclude=_109.exclude||false;
try{
if(typeof _109.clazz=="string"){
this.clazz=eval(_109.clazz);
this.clazzName=_109.clazz;
}
}
catch(e){
alert("e "+e);
}
},itemHasToBeFiltered:function(_10c){
_10c=$O(_10c);
if(this.exclude){
if(_10c instanceof this.clazz){
return true;
}else{
return false;
}
}else{
if(_10c instanceof this.clazz){
return false;
}else{
return true;
}
}
},compare:function(_10d){
if(this.clazz!=_10d.clazz){
return false;
}
return true;
},toString:function(){
if(this.exclude){
var _10e="exclude>";
}else{
var _10e="only>";
}
return _10e+this.clazzName;
}};
var RefFilter=Class.create();
RefFilter.prototype={logger:maptales.getLogger("com.maptales.webclient.reffilter"),initialize:function(_10f,slot){
this.slot=slot;
this.ref=_10f.ref;
this.refFilter=new FieldFilter(_10f.refFilter,this.slot,this);
AssertInstanceOf(Slot,this.slot,"RefFilterInitException","A Ref filter only works with a slot. No slot is passed to ref filter with ref: "+this.ref+" and filter: "+this.refFilter.toString());
AssertNotNull(this.ref,"RefFilterInitException","A Ref filter only works with a reference. No reference is passed to ref filter with slot: "+this.slot.name+" and filter: "+this.refFilter);
AssertNotNull(this.refFilter,"RefFilterInitException","A Ref filter only works with a filter. No filter is passed to ref filter with slot: "+this.slot.name+" and filter: "+this.refFilter);
this.boundFilterItemCallback=this.filterItemCallback.bind(this);
this.refAssociation={};
},registerFilterListener:function(id){
var ref=$O(id).getRefId(this.ref);
this.refFilter.registerFilterListener(ref);
if(this.refAssociation[ref]==null){
this.refAssociation[ref]=[];
}
if(ref<0){
$O(ref).addIdListener(this.exchangeIds.bind(this));
}
this.refAssociation[ref].push($O(id));
},exchangeIds:function(_113,_114){
var _115=this.refAssociation[_114];
this.refAssociation[_113]=_115;
},removeFilterListener:function(id,_117){
},expellFromFilteredSlot:function(_118){
var ref=$O(_118).id;
if(this.refAssociation[ref]){
this.expellReferencedItems(ref);
}else{
var _11a=$O(_118).tempId;
if(this.refAssociation[_11a]){
this.expellReferencedItems(_11a);
}else{
var _11b="[";
for(association in this.refAssociation){
_11b+=association+", ";
}
_11b+="]";
this.logger.warn("RefFilterException:"+"The association of the reference with id:"+ref+" tempId:"+_11a+" (eg. marker->media) to filter out of the slot is not in hashtable \n"+"The Hastable contains: "+_11b);
}
}
},expellReferencedItems:function(ref){
for(var i=0;i<this.refAssociation[ref].length;i++){
this.slot.expellFromFilteredSlot(this.refAssociation[ref][i]);
}
},filterItemCallback:function(_11e,_11f){
try{
if(this.itemHasToBeFiltered(_11f)){
this.slot.remove(_11f);
this.slot.parent.notifyFieldListeners(this.slot.name);
}
}
catch(e){
this.logger.warn("SlotFilterError: Could not filter item: "+_11f+" with id "+_11f.id,e);
}
},itemHasToBeFiltered:function(_120){
try{
_120=$O(_120);
}
catch(e){
alert("Filter>filterItem>"+e);
}
if(!_120){
return false;
}
var _121=null;
if(_120.isRef(this.ref)){
refObject=_120.getRefFromCache(this.ref);
}
return this.refFilter.itemHasToBeFiltered(refObject);
},compare:function(_122){
if(this.ref!=_122.ref){
return false;
}
if(this.refFilter.compare(_122.refFilter)){
return true;
}else{
return false;
}
},toString:function(){
return this.ref+"."+this.refFilter.toString();
}};

var SnapMapException=Class.create();
SnapMapException.prototype={initialize:function(_1,_2,_3){
this.type=_1;
this.message=_2;
this.title=_1+": "+_2;
this.originalException=_3;
},setType:function(_4){
this.type=_4;
},getType:function(){
return this.type;
},setMessage:function(_5){
this.message=_5;
},getMessage:function(){
return this.message;
},getFuncname:function(f){
if(f==null){
return "";
}
var s=f.toString().match(/function (\w*)/)[1];
if((s==null)||(s.length==0)){
return "anonymous";
}
return s;
},parseErrorStack:function(_8){
var _9=[];
var _a;
if(!_8||!_8.stack){
return _9;
}
var _b=_8.stack.split("\n");
for(var i=0;i<_b.length-1;i++){
var _d=_b[i];
_a=_d.match(/^(\w*)/)[1];
if(!_a){
_a="anonymous";
}
_9[_9.length]=_a;
}
while(_9.length&&_9[_9.length-1]=="anonymous"){
_9.length=_9.length-1;
}
return _9;
},stacktrace:function(){
var _e="Stack Trace: <br />";
if(typeof (arguments.caller)!="undefined"){
for(var a=arguments.caller;a!=null;a=a.caller){
_e+="> "+this.getFuncname(a.callee)+"\n";
if(a.caller==a){
_e+="*";
break;
}
}
}else{
var _10;
try{
foo.bar;
}
catch(_10){
var _11=this.parseErrorStack(_10);
for(var i=1;i<_11.length;i++){
_e+="> "+_11[i]+"<br />";
}
}
}
return _e;
},toString:function(){
return this.type+": "+this.message+"\n";
}};
var SnapMapFormException=Class.create();
SnapMapFormException.prototype={initialize:function(_13,_14){
this.fieldName=_13;
this.message=_14;
},getFieldName:function(){
return this.fieldName;
},getMessage:function(){
return this.message;
}};

maptales.cache.cache={};
maptales.cache.tempCache={};
maptales.cache.loading={};
maptales.cache.loadingSlots={};
maptales.cache.registeredReplyListeners={};
var cacheLog=maptales.getLogger("com.maptales.cache");
maptales.cache.addObjectsToCache=function(_1){
_1.each(function(_2){
maptales.cache.addToCache(_2);
}.bind(this));
};
maptales.cache.clearCache=function(){
cacheLog.debug("clearCache");
maptales.cache.cache={};
};
maptales.cache.getObjectTemplatesFromCache=function(_3,_4){
for(var i=0;i<_3.length;i++){
maptales.cache.getObjectTemplateFromCache(_3[i],_4);
}
};
maptales.cache.getObjectTemplateFromCache=function(_6,_7){
if(_7.type!="objectTemplate"){
throw new SnapMapException("ArgumentException","Did not pass an objectTemplate to maptales.cache.getObjectTemplateFromCache");
}
try{
for(field in _7){
if(field!="type"){
var _8=_7[field];
if(_8.type=="slotTemplate"){
maptales.cache.getSlotTemplateFromCache(_6,field,_8);
}else{
if(_8.type=="objectTemplate"){
maptales.cache.getObjectTemplateFromCache(_6.getRefFromCache(field),_8);
}
}
}
}
}
catch(e){
throw new SnapMapException("CacheException","Template could not be loaded of id: "+_6.id,e);
}
};
maptales.cache.getSlotTemplateFromCache=function(_9,_a,_b){
if(_9.isSlot(_a)){
try{
maptales.cache.getSlotFromCache(_9.id,_a,_b.offset,_b.length,_b.filter,_b.sort);
}
catch(e){
cacheLog.info("CacheFailure: Could not load SlotTemplate. <br />"+"<br />id: "+_9.id+"<br />field: "+_a+"<br />offset: "+_b.offset+"<br />length: "+_b.length+"<br />filter: "+_b.filter+"<br />sort: "+_b.sort,e);
}
}
};
maptales.cache.getSlotFromCache=function(id,_d,_e,_f,_10,_11,_12){
var _13=maptales.cache.getFromCache(id);
var _14=_13.getSlotFromCache(_d,_e,_f,_10,_11);
if(_12){
maptales.cache.getObjectTemplatesFromCache(_14,_12);
}
return _14;
};
maptales.cache.getSlotLengthFromCache=function(id,_16,_17){
var _18=maptales.cache.getFromCache(id);
var _19=_18.getSlotLength(_16,_17);
return _19;
};
maptales.cache.addToCache=function(obj){
if(!maptales.cache.getFromTempCache(obj.id)){
if(obj instanceof ContentObject){
cacheLog.debug("Adding to cache, id: "+obj.id);
if(maptales.cache.cache[obj.id]==null){
maptales.cache.cache[obj.id]=obj;
}
if(maptales.cache.loading[obj.id]){
maptales.cache.loading[obj.id]=null;
}
}
}else{
if(obj instanceof ContentObject){
cacheLog.debug("Adding to temp cache, id: "+obj.id);
if(maptales.cache.tempCache[obj.id]==null){
maptales.cache.tempCache[obj.id]=obj;
}
if(maptales.cache.loading[obj.id]){
maptales.cache.loading[obj.id]=null;
}
}
}
return obj;
};
maptales.cache.replaceTempId=function(_1b,_1c){
cacheLog.debug("replaceTempId oldId: "+_1b+", newId: "+_1c);
var _1d=maptales.cache.tempCache[_1b];
if(!(_1d instanceof ContentObject)){
cacheLog.error("Trying to replace a tempId a second time. There should be an error with duplicate instances of the same object");
}else{
maptales.cache.tempCache[_1b]=_1c;
maptales.cache.cache[_1c]=_1d;
_1d.set("id",_1c);
}
};
maptales.cache.removeAllFromCache=function(_1e){
if(_1e!=null){
for(var i=0;i<_1e.length;i++){
maptales.cache.removeFromCache(_1e[i]);
}
}
};
maptales.cache.removeFromCache=function(_20){
cacheLog.debug("removeFromCache id: "+_20);
if(_20 instanceof ContentObject){
var id=_20.id;
}else{
var id=_20;
}
if(!maptales.cache.getFromTempCache(id)){
if(maptales.cache.cache[id] instanceof ContentObject){
maptales.cache.cache[id]=null;
}
}else{
if(maptales.cache.tempCache[id] instanceof ContentObject){
maptales.cache.tempCache[id]=null;
}
}
};
maptales.cache.getFromTempCache=function(_22){
var _23=parseInt(_22);
if(_23=="NaN"||_23>0){
return false;
}else{
return true;
}
};
maptales.cache.isInCache=function(id){
var _25=false;
if(!maptales.cache.getFromTempCache(id)){
if(maptales.cache.cache[id]){
_25=true;
}
}else{
if(maptales.cache.tempCache[id]){
_25=true;
}
}
cacheLog.debug("isInCache id: "+id+" returned "+_25);
return _25;
};
maptales.cache.isSlotInCache=function(id,_27,_28,_29){
cacheLog.debug("is slot in cache id: "+id+" slotname: "+slotname+", offset: "+_28+", length: "+_29);
if(!maptales.cache.isInCache(id)){
return false;
}
var _2a=maptales.cache.getFromCache(id);
return _2a.isSlotInCache(_27,_28,_29);
};
maptales.cache.getFromCache=function(id){
cacheLog.debug("getFromCache id: "+id);
if(maptales.cache.isInCache(id)){
if(!maptales.cache.getFromTempCache(id)){
return maptales.cache.cache[id];
}else{
if(maptales.cache.tempCache[id] instanceof ContentObject){
return maptales.cache.tempCache[id];
}else{
return maptales.cache.getFromCache(maptales.cache.tempCache[id]);
}
}
}else{
cacheLog.debug("could not get from cache id: "+id);
return null;
}
};
maptales.cache.addReplyListener=function(id,_2d){
cacheLog.debug("adding reply listener to "+id);
if(!maptales.cache.registeredReplyListeners){
maptales.cache.registeredReplyListeners={};
}
if(!maptales.cache.registeredReplyListeners[id]){
maptales.cache.registeredReplyListeners[id]=[];
}
maptales.cache.registeredReplyListeners[id].push(_2d);
};
maptales.cache.callReplyListeners=function(arr){
arr.each(function(_2f,_30){
maptales.cache.callReplyListener(_2f);
}.bind(this));
};
maptales.cache.callReplyListener=function(_31,_32){
cacheLog.debug("trying to call reply listener "+_31);
if(maptales.cache.registeredReplyListeners){
if(maptales.cache.registeredReplyListeners[_31]){
maptales.cache.registeredReplyListeners[_31].each(function(_33){
try{
cacheLog.debug("calling reply listener "+_31,"ReplyListener");
_33(_32);
}
catch(e){
cacheLog.error("Cache>ReplyListenerException>Listener could not be called",e);
}
}.bind(this));
maptales.cache.registeredReplyListeners[_31]="";
}
}
};
maptales.cache.compareObjects=function(_34,_35){
var _36=true;
if(_34==null||_35==null){
if(_34==null&&_35==null){
return true;
}else{
return false;
}
}else{
for(field in _34){
if(typeof _34[field]!="object"){
if(_34[field]!=_35[field]){
_36=false;
}
}else{
if(!maptales.cache.compareObjects(_34[field],_35[field])){
_36=false;
}
}
}
return _36;
}
};
maptales.cache.isPartOfSlotLoading=function(id,_38,_39,_3a,_3b,_3c,_3d){
if(maptales.cache.loadingSlots[id]==null){
return false;
}
if(maptales.cache.loadingSlots[id][_38]==null){
return false;
}
if(maptales.cache.loadingSlots[id][_38].loaded==true){
if(_3d==null||_3d==undefined){
return true;
}else{
return maptales.cache.compareRequests(_39,_3a,_3d,maptales.cache.getSlotRequestParameters(id,_38,null,_3c));
}
}
if(_3b!=null){
var _3e=new SlotFilter(_3b).toString();
if(maptales.cache.loadingSlots[id][_38].filtered[_3e]){
if(maptales.cache.loadingSlots[id][_38].filtered[_3e].loaded==true){
if(_3d==null||_3d==undefined){
return true;
}else{
return maptales.cache.compareRequests(_39,_3a,_3d,maptales.cache.getSlotRequestParameters(id,_38,_3b,_3c));
}
}
}
}
var _3f=maptales.cache.getSlotRequestParameters(id,_38,_3b,_3c);
return maptales.cache.compareRequests(_39,_3a,_3d,_3f);
};
maptales.cache.getSlotRequestParameters=function(id,_41,_42,_43){
if(_42==null||_42==false){
if(_43==null||_43==false){
var _44=maptales.cache.loadingSlots[id][_41].slot;
}else{
if(maptales.cache.loadingSlots[id][_41].loaded==true){
var _44=maptales.cache.loadingSlots[id][_41].slot;
}else{
var _44=maptales.cache.loadingSlots[id][_41].sorted[_43];
}
}
}else{
if(maptales.cache.loadingSlots[id][_41].filtered[_42]==null){
return false;
}
if(_43==null||_43==false){
var _44=maptales.cache.loadingSlots[id][_41].filtered[_42].slot;
}else{
var _44=maptales.cache.loadingSlots[id][_41].filtered[_42].sorted[_43];
}
}
return _44;
};
maptales.cache.addLoadingSlot=function(id,_46,_47,_48,_49,_4a,_4b){
cacheLog.debug("adding loading slot, id: "+id+", slot: "+_46+", offset: "+_47+", length: "+_48+", filter: "+_49+", sorting: "+_4a+", objectTemplate: "+_4b);
if(_48=="all"||_48==-1){
var _4c=true;
}else{
var _4c=false;
}
if(!maptales.cache.loadingSlots[id]){
maptales.cache.loadingSlots[id]=[];
}
if(!maptales.cache.loadingSlots[id][_46]){
maptales.cache.loadingSlots[id][_46]={slot:[],filtered:[],sorted:[],loaded:false};
if(_49==null&&_4c){
maptales.cache.loadingSlots[id][_46].loaded=_4c;
}
}
if(_49==null||_49==false){
if(_4a==null||_4a==false){
maptales.cache.loadingSlots[id][_46].slot.push({offset:_47,length:_48,objectTemplate:_4b});
}else{
if(_4c){
maptales.cache.loadingSlots[id][_46].slot.push({offset:_47,length:_48,objectTemplate:_4b});
}else{
if(!maptales.cache.loadingSlots[id][_46].sorted[_4a]){
maptales.cache.loadingSlots[id][_46].sorted[_4a]=[];
}
maptales.cache.loadingSlots[id][_46].sorted[_4a].push({offset:_47,length:_48,objectTemplate:_4b});
}
}
}else{
var _4d=new SlotFilter(_49).toString();
if(!maptales.cache.loadingSlots[id][_46].filtered[_4d]){
maptales.cache.loadingSlots[id][_46].filtered[_4d]={slot:[],filtered:[],sorted:[],loaded:_4c};
}
if(_4a==null||_4a==false){
maptales.cache.loadingSlots[id][_46].filtered[_4d].slot.push({offset:_47,length:_48,objectTemplate:_4b});
}else{
if(_4c){
maptales.cache.loadingSlots[id][_46].filtered[_4d].slot.push({offset:_47,length:_48,objectTemplate:_4b});
}else{
if(!maptales.cache.loadingSlots[id][_46].filtered[_4d].sorted[_4a]){
maptales.cache.loadingSlots[id][_46].filtered[_4d].sorted[_4a]=[];
}
maptales.cache.loadingSlots[id][_46].filtered[_4d].sorted[_4a].push({offset:_47,length:_48,objectTemplate:_4b});
}
}
}
};
maptales.cache.compareRequests=function(_4e,_4f,_50,_51){
if(!_51){
return false;
}
if(_51.length>0){
var _52=false;
_51.each(function(_53){
if(_4e>=_53.offset){
if(_53.length==-1||(_4e+_4f)<=(_53.offset+_53.length)){
if(_50){
if(_53.objectTemplate){
_52=maptales.cache.compareObjects(_50,_53.objectTemplate);
}else{
_52=false;
}
}else{
_52=true;
}
}
}
});
return _52;
}
return false;
};
maptales.cache.removeLoadingSlot=function(id,_55){
cacheLog.debug("remove loading slot, id: "+id+", slot: "+_55);
if(maptales.cache.loadingSlots[id]){
maptales.cache.loadingSlots[id][_55]=null;
}
};
maptales.cache.addSlotReplyListener=function(id,_57,_58,_59,_5a,_5b,_5c,_5d){
cacheLog.debug("add slot reply listeners, id: "+id+", slot: "+_57+", offset: "+_58+", length: "+_59+", filter: "+_5a+", sorting: "+_5b+", objectTemplate: "+_5c);
var _5e=id+"/"+_57;
if(!maptales.cache.registeredSlotReplyListeners){
maptales.cache.registeredSlotReplyListeners={};
}
if(!maptales.cache.registeredSlotReplyListeners[_5e]){
maptales.cache.registeredSlotReplyListeners[_5e]=[];
}
maptales.cache.registeredSlotReplyListeners[_5e].push({offset:_58,length:_59,sort:_5b,filter:_5a,objectTemplate:_5c,callback:_5d});
};
maptales.cache.callSlotReplyListeners=function(id,_60,_61,_62,_63,_64,_65){
var _66=id+"/"+_60;
var _67=[];
if(maptales.cache.registeredSlotReplyListeners){
if(maptales.cache.registeredSlotReplyListeners[_66]){
maptales.cache.registeredSlotReplyListeners[_66].each(function(_68){
if(_62==-1||_62=="all"){
if(maptales.cache.compareObjects(_65,_68.objectTemplate)){
maptales.cache._callSlotReplyListeners(id,_60,_68.offset,_68.length,_68.filter,_68.sort,_68.callback);
}else{
_67.push(_68);
}
}else{
if(_63==null){
_63=false;
}
if(_68.filter==null){
_68.filter=false;
}
if(_64==null){
_64=false;
}
if(_68.sort==null){
_68.sort=false;
}
if(_63==_68.filter){
if(_64==_68.sort){
if(_61<=_68.offset){
if((_61+_62)>=(_68.offset+_68.length)&&(maptales.cache.compareObjects(_65,_68.objectTemplate))){
maptales.cache._callSlotReplyListeners(id,_60,_68.offset,_68.length,_68.filter,_68.sort,_68.callback);
}else{
_67.push(_68);
}
}
}
}
}
}.bind(this));
maptales.cache.registeredSlotReplyListeners[_66]=_67;
}
}
};
maptales.cache._callSlotReplyListeners=function(id,_6a,_6b,_6c,_6d,_6e,_6f){
cacheLog.debug("calling slot reply listeners, id: "+id+", slot: "+_6a+", offset: "+_6b+", length: "+_6c+", filter: "+_6d+", sorting: "+_6e);
try{
var _70=maptales.cache.getSlotFromCache(id,_6a,_6b,_6c,_6d,_6e);
var _71=maptales.cache.getSlotLengthFromCache(id,_6a,_6d);
}
catch(e){
cacheLog.error("SlotReplyListenerException: error calling slot reply listeners, id: "+id+", slot: "+_6a+", offset: "+_6b+", length: "+_6c+", filter: "+_6d+", sorting: "+_6e,e);
}
if(_6f){
var _72={slotItems:_70,slotNum:_71,parentId:id,slotName:_6a};
_6f(_72);
}
};
maptales.cache.makeObjects=function(obj){
if(!obj){
return [];
}
if(obj instanceof Array){
return obj.collect(maptales.cache.makeObjects);
}else{
try{
if(isNaN(obj)){
cacheLog.trace("Making: "+obj.type);
if(obj.id==null||obj.id<0){
obj.id=maptales.service.getAndIncrementTempId();
}
var _74=eval("new "+obj.type+"(obj)");
if(!maptales.cache.isInCache(_74.id)){
if(_74.tempId&&_74.tempId!=_74.id){
maptales.cache.replaceTempId(_74.tempId,_74.id);
}
_74=maptales.cache.addToCache(_74);
}else{
var _75=maptales.cache.getFromCache(_74.id);
_75.updateData(obj);
if(_75.tempId){
maptales.cache.replaceTempId(_75.tempId,_75.id);
}
_74=_75;
}
}else{
var _74=maptales.cache.getFromCache(obj);
}
}
catch(e){
cacheLog.error("Error Making Objects",e);
if(e instanceof SnapMapException){
return;
}
cacheLog.warn("SyntaxError: Could not create object of type: "+obj.type,e);
}
}
return _74;
};

var actionLogger=maptales.getLogger("com.maptales.webclient.action");
var Actions={initAction:function(_1,_2,_3,_4,_5){
if(!_3){
_3={};
}
if(_4){
var _6=_4;
_2=null;
}else{
if(_2){
var _6=Event.element(_2);
}
}
if(_6==null){
throw new SnapMapException("Action Creation Error","Cannot create an action without root HTML element or event");
}
var _7=new Action(_1,_3,_6,_2,_5);
try{
Actions.bubbleAction(_7,_6);
}
catch(e){
actionLogger.error("ActionException: Could not execute action: "+_1,e);
}
},initFormAction:function(_8,_9,_a,_b){
if(_b){
var _c=_b;
_9=null;
}else{
if(_9){
var _c=Event.element(_9);
}
}
var _d=this.getParentWidget(_c);
var _e=_d.getFormHashMap(_a.formName);
Object.extend(_a,_e);
var _f=new Action(_8,_a,_c,_9,_d.formReply.bind(_d));
if(_a.replyContainerName){
_d.replyContainer=_d.getElement(_a.replyContainerName);
}else{
_d.replyContainer=_d.getElement(_a.formName);
}
_d.formCallbackAction=_a.formCallbackAction||false;
_d.formContainer=_d.getElement(_a.formName);
_d.replyTemplatePath=_a.replyTemplatePath||false;
_d.bubbleAction(_f);
},bubbleAction:function(_10,_11){
if(_11.behaviourBubbleAction){
_11.behaviourBubbleAction(_10);
}
if(_11.handleBubbleAction){
_11.handleBubbleAction(_10);
}else{
if(_10.cancelBubble==false){
if(_11.parentNode){
Actions.bubbleAction(_10,_11.parentNode);
}
}
}
},getParentWidget:function(_12){
if(_12._widget){
return _12._widget;
}else{
if(_12.parentNode){
return (Actions.getParentWidget(_12.parentNode));
}else{
return null;
}
}
}};
var Action=new Class.create();
Action.prototype={type:"undefined",getType:function(){
return this.type;
},setType:function(_13){
this.type=_13;
},initialize:function(_14,_15,_16,_17,_18){
this.type=_14;
this.parameters=_15;
this.sourceHTMLElement=_16||false;
this.event=_17||false;
this.cancelBubble=false;
this.cancelPropagation=false;
this.lastWidget={};
this.callback=_18||null;
},execute:function(){
},_execute:function(){
},getParameters:function(){
return this.parameters;
}};
var $a=function(_19,_1a,_1b,_1c,_1d){
Actions.initAction(_19,_1a,_1b,_1c,_1d);
};
var $g=function(_1e,_1f){
Actions.initAction("gotoPath",_1f,{path:_1e});
};
var $f=function(_20,_21){
Actions.initAction("submitFormAction",_21,_20);
};
var $e=function(_22,_23,_24){
_23.elementName=_22;
Actions.initAction("changeElementStyle",_24,_23);
};
var $s=function(_25,_26,_27,_28){
var _29={};
_29.parameters=_26;
_29.serviceName=_25;
Actions.initAction("triggerService",_27,_29,null,_28);
};
var $r=function(_2a,_2b,_2c,_2d){
var _2e={};
_2e.parameters=_2b;
_2e.rpcName=_2a;
Actions.initAction("triggerRPC",_2c,_2e,null,_2d);
};
var $link=function(_2f,_30,_31){
_31=_31||"mainMenuLink";
return "<a class=\""+_31+"\" href=\""+maptales.baseURL+"/view/"+_2f+"\" onclick=\"$g('"+_2f+"', event); return false;\">"+_30+"</a>";
};
var $m=function(_32,_33){
try{
maptales.ui.getMainMap()[_32](_33);
}
catch(e){
actionLogger.error("MapActionException: Could not execute action: "+_32,e);
}
};

var helpersLogger=maptales.getLogger("com.maptales.webclient.helpers");
Array.prototype.removeEntry=function(_1){
for(var i=0;i<this.length;i++){
if(this[i]==_1){
this.removeIndex(i);
return;
}
}
};
Array.prototype.removeById=function(_3){
for(var i=0;i<this.length;i++){
if(this[i].id==_3.id){
this.removeIndex(i);
return;
}
}
};
Array.prototype.equalsByValue=function(_5){
if(_5==null){
return false;
}
if(this.length!=_5.length){
return false;
}
for(var e=0;e<this.length;e++){
if(this[e]!=_5[e]){
return false;
}
}
return true;
};
Array.prototype.removeIndex=function(i){
for(;i<this.length-1;i++){
this[i]=this[i+1];
}
this.pop();
};
Array.prototype.getIds=function(_8){
var _9=[];
var _a=[];
if(_8){
for(var i=0;i<_8.length;i++){
if(this[_8[i]]){
_9.push(this[_8[i]]);
}else{
_a.push(_8[i]);
}
}
}
return {result:_9,notFound:_a};
};
Array.prototype.copy=function(){
return this.slice(0,this.length);
};
Array.prototype.insertAtPosition=function(_c,_d){
var _e=this.slice(_c);
if(_c>0){
var _f=this.slice(0,_c);
}else{
var _f=[];
}
_e.unshift(_d);
var _10=_f.concat(_e);
return _10;
};
maptales.toPixelString=function(_11){
return Math.round(_11)+"px";
};
document.getChildrenById=function(id,_13){
var _14=($(_13)||document.body).getElementsByTagName("*");
var _15=[];
for(var i=0;i<_14.length;i++){
if(_14[i].id.match(new RegExp("(^|\\s)"+id+"(\\s|$)"))){
_15.push(_14[i]);
}
}
return _15;
};
document.getChildById=function(id,_18){
var _19=($(_18)||document.body).getElementsByTagName("*");
for(var i=0;i<_19.length;i++){
if(_19[i].id.match(new RegExp("(^|\\s)"+id+"(\\s|$)"))){
return _19[i];
}
}
return null;
};
function findParentElementById(_1b,id){
var _1d=Event.element(_1b);
while(_1d.parentNode&&(!_1d.id||(_1d.id!=id))){
_1d=_1d.parentNode;
}
return _1d;
}
Element.getAttributeHashMap=function(el){
var _1f={};
for(var i=0;i<el.attributes.length;i++){
_1f[el.attributes[i].name.camelize()]=el.attributes[i].value;
}
return _1f;
};
Object.getHashMap=function(obj){
var _22="";
$H(obj).each(function(_23){
_22+=_23+"<br />";
}.bind(this));
return _22;
};
document.getElementsByAttribute=function(_24,_25){
var _26=($(_25)||document.body).getElementsByTagName("*");
var _27=[];
for(var i=0;i<_26.length;i++){
if(_26[i].attributes&&_26[i].attributes.getNamedItem(_24)){
_27.push(_26[i]);
}
}
return _27;
};
document.getElementsByAttributeTable=function(_29,_2a){
var _2b=($(_2a)||document.body).getElementsByTagName("*");
var _2c={};
for(var i=0;i<_2b.length;i++){
for(var j=0;j<_29.length;j++){
if(!_2c[_29[j]]){
_2c[_29[j]]=[];
}
if(_2b[i].attributes&&_2b[i].attributes.getNamedItem(_29[j])){
_2c[_29[j]].push(_2b[i]);
}
}
}
return _2c;
};
function $O(_2f){
if(isNaN(_2f)){
if(_2f instanceof ContentObject){
return maptales.cache.getFromCache(_2f.id);
}else{
if(typeof _2f=="string"){
if(_2f==maptales.ui.getAppName()){
return maptales.ui;
}else{
return maptales.cache.getFromCache(_2f);
}
}else{
if(_2f==maptales.ui){
return maptales.ui;
}else{
var _30="";
$H(_2f).each(function(_31){
_30+="\n"+_31;
}.bind(this));
throw new SnapMapException("ArgumentException","Helpers>$O>The arguments '"+_2f+"' you passed are not correct. Type: '"+typeof _2f+"' not supported. \n Object Parse: \n"+_30);
}
}
}
}else{
return maptales.cache.getFromCache(_2f);
}
throw new SnapMapException("CacheException","The object you want '"+_2f+"' is not in cache");
}
function tokenizeTags(_32,_33){
if(_32==null){
return null;
}
_32=_32.replace(/,/g," ");
if(_32.search(/[,;.\/!\+\-()[\]*'{}\$\^\\]/)>-1){
return [];
}
var _34=[];
var _35=false;
var _36=0;
for(var i=0;i<_32.length;i++){
if(!_35&&_32.charAt(i)=="\""){
_35=true;
_36=i+1;
continue;
}
if((_32.charAt(i)=="\"")||(!_35&&_32.charAt(i)==" ")){
var val=_32.substring(_36,i);
if(val!=""&&val!=" "&&val.search(/"/)==-1){
_34.push(val);
}
_36=i+1;
_35=false;
}
}
var val=_32.substring(_36,_32.length);
if(val!=""&&val!=" "&&val.search(/"/)==-1){
_34.push(val);
}else{
if(_33){
_34.push("");
}
}
return _34;
}
function escapeSearchString(str){
if(str.indexOf(" ")>-1&&str.indexOf("\"")==-1){
str="\""+str+"\" ";
}
return str;
}
Aspects=new Object();
Aspects.addBefore=function(_3a,_3b){
_3a.oldFunc=_3a.obj[_3a.fname];
_3a.obj[_3a.fname]=function(){
return _3a.oldFunc.apply(this,_3b(arguments,_3a.oldFunc,this));
};
};
Aspects.addAfter=function(_3c,_3d){
_3c.oldFunc=_3c.obj[_3c.fname];
_3c.obj[_3c.fname]=function(){
return _3d(_3c.oldFunc.apply(this,arguments),arguments,_3c.oldFunc,this);
};
};
Aspects.addAround=function(_3e,_3f){
_3e.oldFunc=_3e.obj[_3e.fname];
_3e.obj[_3e.fname]=function(){
return _3f(arguments,_3e.oldFunc,this);
};
};
Aspects.remove=function(_40){
if(_40.oldFunc){
_40.obj[_40.fname]=_40.oldFunc;
}
};
function AssertEquals(_41,_42,_43,_44){
_44+="<br/><br/>"+this.getStackTrace();
if(_41!=_42){
helpersLogger.warn(_43+" "+_44);
}
}
function AssertNotNull(_45,_46,_47){
_47+="<br/><br/>"+this.getStackTrace();
if(_45==null){
helpersLogger.warn(_46+" "+_47);
}
}
function AssertNull(_48,_49,_4a){
_4a+="<br/><br/>"+this.getStackTrace();
if(_48!=null){
helpersLogger.warn(_49+" "+_4a);
}
}
function AssertInstanceOf(_4b,_4c,_4d,_4e){
_4e+="<br/><br/>"+this.getStackTrace();
if(!(_4c instanceof _4b)){
helpersLogger.warn(_4d+" "+_4e);
}
}
function getStackTrace(){
try{
throw "just to get stack";
}
catch(e){
return e.stack;
}
}
function convertPoint(_4f){
if(_4f){
if(_4f.distanceFrom){
var p=_4f;
}else{
if(_4f.lat!=null){
var p=new GLatLng(_4f.lat,_4f.lng);
}else{
var p=new GLatLng(_4f.y,_4f.x);
}
}
}else{
var p=new GLatLng(0,0);
}
return p;
}
function convertPoints(_51){
var out=[];
if(_51==null){
return out;
}
for(var i=0;i<_51.length;i++){
out.push(convertPoint(_51[i]));
}
return out;
}
function convertDate(_54){
if(_54 instanceof Date){
return _54;
}
try{
return new Date(parseInt(_54));
}
catch(e){
helpersLogger.error("Error parsing date: "+_54,e);
return null;
}
}
function convertBoolean(_55,_56){
if(_55==true||_55=="true"||_55==1){
return true;
}else{
if(_55==false||_55=="false"||_55==0){
return false;
}else{
helpersLogger.debug("Error parsing boolean: "+_55);
return _56;
}
}
}
function checkFileExtensions(el,_58){
if(el.form){
var _59=el.form.elements;
for(var i=0;i<_59.length;i++){
if(_59[i].type=="file"){
var _5b=_59[i].value;
if(_5b==""){
continue;
}
if(_5b.indexOf(".")==-1){
return false;
}
var ext=_5b.substring(_5b.lastIndexOf(".")+1).toLowerCase();
if(_58.indexOf(ext)==-1){
return false;
}
}
}
return true;
}
return false;
}
function getSearchParam(key){
var _5e=window.location.search;
var i=_5e.indexOf(key+"=");
if(i>-1){
i+=(key.length+1);
var j=_5e.indexOf("&",i);
if(j>-1){
return _5e.substring(i,j);
}
return _5e.substring(i);
}
return "";
}
function animate(_61,_62,_63,_64,_65){
var _66={};
_66.curVal=_61;
_66.endVal=_62;
_66.dampingFactor=_63;
_66.stepCallback=_64;
_66.endCallback=_65;
_66.step=function(){
this.curVal+=(this.endVal-this.curVal)/this.dampingFactor;
this.stepCallback(this.curVal);
if(Math.abs(this.curVal-this.endVal)<1){
window.clearInterval(this.timer);
if(this.endCallback){
this.endCallback(this.endVal);
}
}
};
_66.timer=window.setInterval(_66.step.bind(_66),50);
}
function selectMultipleFiles(){
var _67=$("flashUploader");
if(_67!==null&&typeof (_67.SelectFiles)==="function"){
try{
_67.SelectFiles();
}
catch(ex){
helpersLogger.warn("Could not call SelectFile: "+ex);
}
}else{
helpersLogger.warn("Could not find Flash element");
}
}
var BrowserDetect={init:function(){
this.browser=this.searchString(this.dataBrowser)||"unknown";
this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"unknown";
},searchString:function(_68){
for(var i=0;i<_68.length;i++){
var _6a=_68[i].string;
var _6b=_68[i].prop;
this.versionSearchString=_68[i].versionSearch||_68[i].identity;
if(_6a){
if(_6a.indexOf(_68[i].subString)!=-1){
return _68[i].identity;
}
}else{
if(_6b){
return _68[i].identity;
}
}
}
},searchVersion:function(_6c){
var _6d=_6c.indexOf(this.versionSearchString);
if(_6d==-1){
return;
}
return parseFloat(_6c.substring(_6d+this.versionSearchString.length+1));
},dataBrowser:[{string:navigator.vendor,subString:"Apple",identity:"Safari"},{prop:window.opera,identity:"Opera"},{string:navigator.userAgent,subString:"Firefox",identity:"Firefox"},{string:navigator.userAgent,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"},{string:navigator.userAgent,subString:"Gecko",identity:"Mozilla",versionSearch:"rv"}]};
BrowserDetect.init();
var addthis_url="";
var addthis_title="";
var addthis_pub="maptales";
function addthis_click(obj,str){
var _70="http://www.addthis.com/bookmark.php";
_70+="?v=1";
_70+="&pub="+addthis_pub;
_70+="&url="+encodeURIComponent(addthis_url);
_70+="&title="+encodeURIComponent(addthis_title);
window.open(_70,"addthis","scrollbars=yes,menubar=no,width=620,height=520,resizable=yes,toolbar=no,location=no,status=no,screenX=200,screenY=100,left=200,top=100");
return false;
}
function readCookie(_71){
var _72=""+document.cookie;
var ind=_72.indexOf(_71);
if(ind==-1||_71==""){
return "";
}
var _74=_72.indexOf(";",ind);
if(_74==-1){
_74=_72.length;
}
return unescape(_72.substring(ind+_71.length+1,_74));
}
function setCookie(_75,_76,_77){
var _78=new Date();
var _79=new Date();
if(_77==null||_77==0){
_77=1;
}
_79.setTime(_78.getTime()+3600000*24*_77);
document.cookie=_75+"="+escape(_76)+";expires="+_79.toGMTString();
}
function getSessionId(){
var _7a=readCookie("JSESSIONID");
if(_7a==null||_7a.length<1){
return maptales.rpc.sessionId;
}
return _7a;
}

var Reply=Class.create();
Reply.successful=1;
Reply.failed=-1;
Reply.stored=2;
Reply.deleted=3;
Reply.added=4;
Reply.removed=5;
Reply.set=6;
Reply.clientError=7;
Reply.notLoggedIn=8;
Reply.notAllowed=9;
Reply.notFound=10;
Reply.malformedRequest=11;
Reply.serverError=12;
Reply.servletError=13;
Reply.databaseError=14;
Reply.fileError=15;
Reply.notImplemented=16;
Reply.prototype={initialize:function(_1){
this.code=_1.code;
this.subcode=_1.subcode;
this.type=_1.type;
this.message=_1.message||"";
this.exception=_1.exception||null;
this.isSessionExpired=_1.isSessionExpired;
if(_1.data){
this.data=_1.data||{};
}
},getReturnValue:function(_2){
return this.data[_2];
},setData:function(_3){
this.data=_3;
},getData:function(){
return this.data;
},getReplyMessage:function(){
return this.message;
},setReplyMessage:function(_4){
this.message=_4;
},wasSuccessful:function(){
return this.code==Reply.successful;
},wasStored:function(){
return this.subcode==Reply.stored;
},wasDeleted:function(){
return this.subcode==Reply.deleted;
},wasSet:function(){
return this.subcode==Reply.set;
},wasAdded:function(){
return this.subcode==Reply.added;
},wasRemoved:function(){
return this.subcode==Reply.removed;
}};

var Modifiers={cut:function(_1,_2){
if(!_1){
return "";
}
if(_1.length>_2){
return _1.substring(0,_2-2)+"...";
}
return _1;
},defaultText:function(_3,_4){
if(!_3||_3==""){
return _4;
}
return _3;
},escapeAttrib:function(_5){
if(!_5||_5==""){
return "";
}
return _5.replace(/"/g,"&quot;");
},cloudFilter:function(_6,_7,_8,_9,_a){
var _b=parseInt(_6);
var _c=(_b-_7)/(_8-_7);
var _d=_9+_c*(_a-_9);
return _d;
},eatError:function(_e){
return "";
},max:function(_f,_10){
if(parseInt(_f.length)>_10){
return _f=_10;
}
return _f;
},min:function(str,_12){
if(parseInt(str.length)<_12){
return str=_12;
}
return str;
},textToHTML:function(str){
if(str!=null){
return str.replace(/\n/gi,"<br>");
}else{
return null;
}
},htmlToText:function(str){
if(str!=null){
return str.replace(/<br>/gi,"\n");
}else{
return null;
}
},removeBreaks:function(str){
if(str!=null){
return str.replace(/<br>/gi," ");
}else{
return null;
}
},wikiToHTML:function(str){
if(str!=null){
str=str.replace(/\n/g,"<br>");
str=str.replace(/(^|\s|<br>)\/(.|\S.*?\S)\/(?=[\.\?!,;]?(?:$|\s|<br>))/g,"$1<em>$2</em>");
str=str.replace(/(^|\s|<br>)\*(.|\S.*?\S)\*(?=[\.\?!,;]?(?:$|\s|<br>))/g,"$1<strong>$2</strong>");
str=str.replace(/(^|\s|<br>)\[#(\d+):([^\]]+)\]/g,"$1<span class=\"link\" onclick=\"event.cancelBubble = true; $a('gotoPath', event, {path:$2} );\">$3</span>");
str=str.replace(/(^|\s|<br>)#(\d+):(\w+)/g,"$1<span class=\"link\" onclick=\"event.cancelBubble = true; $a('gotoPath', event, {path:$2} );\">$3</span>");
str=str.replace(/(^|\s|<br>)#(\d+)(?=\b|<br>)/g,"$1[<span class=\"link\" onclick=\"event.cancelBubble = true; $a('gotoPath', event, {path:$2} );\">link</span>]");
str=str.replace(/([a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z])/g,"<a href='mailto:$1'>$1</a>");
str=str.replace(/(^|\s|<br>)http:\/\/\S*youtube.com\/watch\?v=([^\s<]+?)(?=$|\s|<br>)/g,"$1<object width=\"425\" height=\"350\" onclick=\"event.cancelBubble=true;\"><param name=\"movie\" value=\"http://www.youtube.com/v/$2\"></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"http://www.youtube.com/v/$2\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"425\" height=\"350\" onclick=\"event.cancelBubble=true;\"></embed></object>");
str=str.replace(/(^|\s|<br>)http:\/\/([^\s<]+?)\.(jpg|jpeg|gif|png)(?=$|\s|<br>)/g,"$1<img src=\"http://$2.$3\">");
str=str.replace(/(^|\s|<br>)\[http:\/\/([^\s<]+?):([^\]]+)\]/g,"$1<a href=\"http://$2\" target=\"_blank\" onclick=\"event.cancelBubble=true;\">$3</a>");
str=str.replace(/(^|\s|<br>)http:\/\/([^\s<]+?):(\w+)/g,"$1<a href=\"http://$2\" target=\"_blank\" onclick=\"event.cancelBubble=true;\">$3</a>");
str=str.replace(/(^|\s|<br>)http:\/\/([^\s<]+?)(?=$|\s|<br>)/g,"$1<a href=\"http://$2\" target=\"_blank\" onclick=\"event.cancelBubble=true;\">$2</a>");
}
return str;
},wikiToText:function(str){
if(str!=null){
str=str.replace(/\n/g,"");
str=str.replace(/(^|\s|<br>)\/(.|\S.*?\S)\/(?=[\.\?!,;]?(?:$|\s|<br>))/g,"$1$2");
str=str.replace(/(^|\s|<br>)\*(.|\S.*?\S)\*(?=[\.\?!,;]?(?:$|\s|<br>))/g,"$1$2");
str=str.replace(/(^|\s|<br>)\[#(\d+):([^\]]+)\]/g,"$1$3");
str=str.replace(/(^|\s|<br>)#(\d+):(\w+)/g,"$1$3");
str=str.replace(/(^|\s|<br>)#(\d+)(?=\b|<br>)/g,"$1");
str=str.replace(/([a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z])/g,"$1");
str=str.replace(/(^|\s|<br>)http:\/\/\S*youtube.com\/watch\?v=([^\s<]+?)(?=$|\s|<br>)/g,"$1");
str=str.replace(/(^|\s|<br>)http:\/\/([^\s<]+?)\.(jpg|jpeg|gif|png)(?=$|\s|<br>)/g,"$1");
str=str.replace(/(^|\s|<br>)\[http:\/\/([^\s<]+?):([^\]]+)\]/g,"$1$3");
str=str.replace(/(^|\s|<br>)http:\/\/([^\s<]+?):(\w+)/g,"$1$3");
str=str.replace(/(^|\s|<br>)http:\/\/([^\s<]+?)(?=$|\s|<br>)/g,"$1$2");
}
return str;
},leadingZero:function(num){
if(num<10){
return "0"+num;
}else{
return num;
}
},longDate:function(_19){
if(_19 instanceof Date){
if(isNaN(_19.getDate())){
return "<em>undefined</em>";
}
var _1a=_19;
var _1b=new Array();
_1b[_1b.length]="January";
_1b[_1b.length]="February";
_1b[_1b.length]="March";
_1b[_1b.length]="April";
_1b[_1b.length]="May";
_1b[_1b.length]="June";
_1b[_1b.length]="July";
_1b[_1b.length]="August";
_1b[_1b.length]="September";
_1b[_1b.length]="October";
_1b[_1b.length]="November";
_1b[_1b.length]="December";
var _1c=new Array();
_1c[_1c.length]="Sunday";
_1c[_1c.length]="Monday";
_1c[_1c.length]="Tuesday";
_1c[_1c.length]="Wednesday";
_1c[_1c.length]="Thursday";
_1c[_1c.length]="Friday";
_1c[_1c.length]="Saturday";
var d0=_1a.getDate()<10?"0":"";
return _1c[_1a.getDay()]+", "+_1b[_1a.getMonth()]+" "+d0+_1a.getDate()+" "+_1a.getFullYear();
}else{
return "<em>undefined</em>";
}
},longDateAndTime:function(_1e){
if(_1e instanceof Date){
if(isNaN(_1e.getDate())){
return "<em>undefined</em>";
}
var _1f=_1e;
var _20=new Array();
_20[_20.length]="Jan";
_20[_20.length]="Feb";
_20[_20.length]="Mar";
_20[_20.length]="Apr";
_20[_20.length]="May";
_20[_20.length]="Jun";
_20[_20.length]="Jul";
_20[_20.length]="Aug";
_20[_20.length]="Sep";
_20[_20.length]="Oct";
_20[_20.length]="Nov";
_20[_20.length]="Dec";
var _21=new Array();
_21[_21.length]="Sun";
_21[_21.length]="Mon";
_21[_21.length]="Tue";
_21[_21.length]="Wed";
_21[_21.length]="Thu";
_21[_21.length]="Fri";
_21[_21.length]="Sat";
var d0=_1f.getDate()<10?"0":"";
var h0=_1f.getHours()<10?"0":"";
var mi0=_1f.getMinutes()<10?"0":"";
return _21[_1f.getDay()]+", "+_20[_1f.getMonth()]+" "+d0+_1f.getDate()+" "+_1f.getFullYear()+", "+h0+_1f.getHours()+":"+mi0+_1f.getMinutes();
}else{
return "<em>undefined</em>";
}
},shortDateAndTime:function(_25){
if(_25 instanceof Date){
var m0=(_25.getMonth()+1)<10?"0":"";
var d0=_25.getDate()<10?"0":"";
var h0=_25.getHours()<10?"0":"";
var mi0=_25.getMinutes()<10?"0":"";
return _25.getFullYear()+"/"+m0+(_25.getMonth()+1)+"/"+d0+_25.getDate()+" "+h0+_25.getHours()+":"+mi0+_25.getMinutes();
}else{
return "<em>undefined</em>";
}
},shortDate:function(_2a){
if(_2a instanceof Date){
var m0=(_2a.getMonth()+1)<10?"0":"";
var d0=_2a.getDate()<10?"0":"";
return _2a.getFullYear()+"/"+m0+(_2a.getMonth()+1)+"/"+d0+_2a.getDate();
}else{
return "<em>undefined</em>";
}
},time:function(_2d){
if(_2d instanceof Date){
var mi0=_2d.getMinutes()<10?"0":"";
return _2d.getHours()+":"+mi0+_2d.getMinutes();
}else{
return "<em>undefined</em>";
}
},timeSince:function(_2f){
if(_2f instanceof Date){
var _30=new Date();
var _31="";
var _32=1000;
var _33=_32*60;
var _34=_33*60;
var _35=_34*24;
var _36=_35*30;
var _37=_35*365;
var _38=null;
var _39=null;
var _3a=null;
var _3b=null;
var _3c=null;
var _3d=null;
var _3e=(_30.getTime()-_2f.getTime());
var _3f=_3e;
var _40=0;
if(_3e>=_37){
_38=_3e/_37;
_3e=_3e%_37;
_31+=Math.floor(_38);
if(_38>=2){
_31+=" years, ";
}else{
_31+=" year, ";
}
_40++;
}
if(_3e>=_36){
_39=_3e/_36;
_3e=_3e%_36;
_31+=Math.floor(_39)+" months, ";
_40++;
}
if(_3e>=_35&&_3f<_36){
_3a=_3e/_35;
_3e=_3e%_35;
_31+=Math.floor(_3a)+" days, ";
_40++;
}
if(_3e>=_34&&_3f<_36){
_3b=_3e/_34;
_3e=_3e%_34;
_31+=Math.floor(_3b)+" hours, ";
_40++;
}
if(_3e>=_33&&_3f<_35){
_3c=_3e/_33;
_3e=_3e%_33;
_31+=Math.floor(_3c)+" minutes, ";
_40++;
}
return _31.substring(0,_31.length-2);
}else{
return "<em>undefined</em>";
}
},zoomLevelToPrecisionString:function(_41){
switch(_41){
case 1:
return "100 km";
case 2:
return "50 km";
case 3:
return "25 km";
case 4:
return "10 km";
case 5:
return "5 km";
case 6:
return "2 km";
case 7:
return "1 km";
case 8:
return "500 m";
case 9:
return "250 m";
case 10:
return "100 m";
case 11:
return "50 m";
case 12:
return "25 m";
case 13:
return "10 m";
case 14:
return "7 m";
case 15:
return "5 m";
case 16:
return "2 m";
case 17:
return "1 m";
case 18:
return "50 cm";
case 19:
return "25 cm";
case 20:
return "15 cm";
}
return "unknown";
},distance:function(_42){
if(_42>100000){
return Math.round(_42/1000)+" km";
}else{
if(_42<1000){
return Math.round(_42)+" m";
}else{
return (Math.round(_42/100)/10)+" km";
}
}
}};

var widgetFactoryLogger=maptales.getLogger("com.maptales.webclient.widgetfactory");
var WidgetFactory={create:function(_1,_2,_3,_4){
if(!_4){
_4={};
}
if(_1&&_1!=""){
var _5=false;
if(_4.useInnerHtml&&_4.useInnerHtml=="true"){
_5=true;
}
if(maptales.widgets[_1]){
var _6=new maptales.widgets[_1](_2,_3,_4.contextObject,_4.view,_4.templatePath,_4,_5);
}else{
throw new SnapMapException("Widget: "+_1+" is not defined");
}
return _6;
}else{
var _6=new Widget(_2,_3,_4.contextObject,_4.view,_4.templatePath,_4,_4.useInnerHtml);
return _6;
}
}};
var Widget=Class.create();
Widget.prototype={logger:maptales.getLogger("com.maptales.webclient.widget"),initialize:function(_7,_8,_9,_a,_b,_c,_d){
if(!_c){
_c={};
}
this.initializeWidget(_7,_8,_9,_a,_b,_c,_d,true);
},initializeWidget:function(_e,_f,_10,_11,_12,_13,_14,_15){
if(_13==null){
_13={};
}
this._MODIFIERS=Modifiers;
this.application=maptales.ui;
this.widget=this;
this.subWidgets=[];
this.draggables={};
this._fields=[];
this._components=[];
this.templateLoadingArray=[];
this.view=null;
this.templatePath=null;
this.renderContainer=null;
this.setOnStartRenderingEvent(_13.onStartRenderingEvent);
this.setOnEndRenderingEvent(_13.onEndRenderingEvent);
if(_e){
this.setContainer(_e);
}
this.parent=_f;
this.parameters=_13||{};
this.useInnerHTML=_14||false;
this.displayAfterInit=_15||false;
if(this.useInnerHTML){
this.innerHTMLText=this.container.innerHTML;
}else{
this.innerHTMLText=null;
}
if(_11){
this.view=_11;
}
if(_12){
this.templatePath=_12;
}
if(_10){
if(_10 instanceof ContentObject||_10==this.getApplication()){
this.contextObject=_10;
}else{
this.loadContextObject(_10,this.loadContextObjectCallback.bind(this));
}
}else{
this.loadContextObjectCallback(this.application);
}
},getWidget:function(){
return this.widget;
},setOnStartRenderingEvent:function(_16){
this.onStartRenderingEvent=_16||false;
},setOnEndRenderingEvent:function(_17){
this.onEndRenderingEvent=_17||false;
},loadContextObject:function(_18,_19){
if(_18==this.application||_18==this.application.getAppName()){
_19(this.application);
}else{
this.application.service.getById(_18,function(_1a){
if(_1a instanceof SnapMapException){
_19(null);
}else{
_19(_1a);
}
});
}
},loadContextObjectCallback:function(_1b){
this.contextObject=_1b;
if(this.displayAfterInit){
this.display();
}
},getContainer:function(){
return this.container;
},setContainer:function(_1c){
this.container=$(_1c);
this.container.handleBubbleAction=this._handleBubbleAction.bind(this);
this.container._widget=this;
},convertToInt:function(_1d,_1e){
if(_1d){
try{
return parseInt(_1d);
}
catch(e){
return _1e;
}
}else{
return _1e;
}
},convertToBoolean:function(_1f,_20){
if(_1f){
if(_1f=="true"||_1f==true){
return true;
}else{
if(_1f=="false"||_1f==false){
return false;
}else{
return _20;
}
}
}else{
return _20;
}
},getTemplatePath:function(){
return this.templatePath;
},setTemplatePath:function(_21){
this.templatePath=_21;
},getPath:function(){
if(this.contextObject){
return this.contextObject.getPath();
}else{
return null;
}
},addSubWidget:function(_22){
this.subWidgets.push(_22);
},getSubWidgets:function(){
return this.subWidgets;
},getField:function(_23){
return this._fields[_23];
},getFields:function(){
return this._fields;
},getFieldsHashMap:function(){
var _24=$H(this._fields);
var _25={};
_24.collect(function(_26){
if(_26[0]&&_26[0].length>0){
if(_26[1].type=="checkbox"){
var _27=false;
if(_26[1].checked){
_27=true;
}
_25[_26[0]]=_27;
}else{
_25[_26[0]]=_26[1].value;
}
}
});
return _25;
},getFormHashMap:function(_28){
var _29={};
var _2a=$A(this.getElement(_28).getElementsByTagName("input"));
_2a.each(function(_2b){
if(_2b.name!=null&&_2b.name!=""){
if(_2b.type=="radio"){
if(_2b.checked){
_29[_2b.name]=_2b.value;
}
}else{
if(_2b.type=="checkbox"){
if(_2b.checked){
_29[_2b.name]=_2b.value;
}else{
_29[_2b.name]=false;
}
}else{
_29[_2b.name]=_2b.value;
}
}
}
});
var _2c=$A(this.getElement(_28).getElementsByTagName("textarea"));
_2c.each(function(_2d){
if(_2d.name!=null&&_2d.name!=""){
_29[_2d.name]=_2d.value;
}
});
var _2e=$A(this.getElement(_28).getElementsByTagName("select"));
_2e.each(function(_2f){
if(_2f.name!=null&&_2f.name!=""){
_29[_2f.name]=_2f.options[_2f.options.selectedIndex].value;
}
});
return _29;
},handleBubbleAction:function(_30){
},triggerService:function(_31,_32,_33){
var _34=this.getServiceFunction(_31);
if(_34!=null){
_34(_32,function(_35){
if(_33){
_33(_35);
}
},this);
return;
}else{
this.logger.warn("Service function: "+_31+" is not defined");
}
},triggerRPC:function(_36,_37,_38){
var _39=this.getRPCFunction(_36);
if(_39!=null){
_39(_37,function(_3a){
if(_38){
_38(_3a);
}
});
return;
}
},getRPCFunction:function(_3b){
if(_3b==null){
return null;
}
var _3c=_3b.split(".");
var _3d=maptales.rpc;
var _3e=null;
for(var e=0;e<_3c.length;e++){
_3e=_3d;
_3d=_3d[_3c[e]];
if(_3d==null){
return null;
}
}
if(_3d instanceof Function){
return _3d.bind(_3e);
}else{
return null;
}
},_handleBubbleAction:function(_40){
if(_40.getType()=="submitFormAction"){
var _41=_40.parameters;
if(_41){
if(_41.formName&&_41.formAction){
this.submitForm(_41.formName,_41.replyContainerName,_41.formAction,_41.replyTemplatePath,_41.formCallbackAction,_40.event);
}else{
alert("missing info to complete form request");
}
}
return;
}else{
if(_40.getType()=="triggerService"){
if(_40.callback instanceof Function){
var _42=_40.callback.bind(this);
}
this.triggerService(_40.parameters.serviceName,_40.parameters.parameters,_42);
return;
}else{
if(_40.getType()=="triggerRPC"){
if(_40.callback instanceof Function){
var _42=_40.callback.bind(this);
}
this.triggerRPC(_40.parameters.rpcName,_40.parameters.parameters,_42);
return;
}else{
if(_40.getType()=="changeElementStyle"){
_40.cancelBubble=true;
var _43=this.getElement(_40.parameters.elementName);
if(_43!=null){
delete _40.parameters.elementName;
for(property in _40.parameters){
_43.style[property]=_40.parameters[property];
}
}
}else{
if(_40.getType()=="refresh"){
this.display(_40.parameters.templatePath,_40.parameters.parameters,_40.parameters.callback,_40.parameters.container);
_40.cancelBubble=true;
}else{
this.handleBubbleAction(_40);
}
}
}
}
}
if(!_40.cancelBubble){
if(this.parent){
if(this.parent._handleBubbleAction){
this.parent._handleBubbleAction(_40);
}else{
this.logger.error("Parent widget "+this.parent.__className+" does not have the composite function: _handleBubbleAction");
}
}
}
},update:function(){
this.display();
},display:function(_44,_45,_46,_47){
this._destroy();
if(_44){
this.templatePath=_44;
}else{
if(this.templatePath==null&&this.contextObject){
this.templatePath=this.contextObject.getTemplateOfView(this.view);
}
}
if(_45!=null){
this.parameters=_45;
}
this.addRequest(this.templatePath);
if(this.useInnerHTML==false){
if(!this.templatePath||this.templatePath.length<1){
this.renderTemplate("404 - no template specified");
return;
}
Templates.getTemplate(this.templatePath,function(_48,_49){
if(_48){
if(!this.isStaleRequest(_49)){
this.removeRequest(_49);
if(this.onStartRenderingEvent!=false){
maptales.event.callEventListener(this.onStartRenderingEvent,this,this.parameters);
}
this.renderTemplate(_48,_47);
if(this.onEndRenderingEvent!=false){
maptales.event.callEventListener(this.onEndRenderingEvent,this,this.parameters);
}
if(_46 instanceof Function){
_46();
}
}
}else{
this.renderTemplate("Could not load requested resource: "+this.templatePath);
this.logger.warn("TemplateLoadingFailure","could not get template: "+this.templatePath+", wrong Path");
}
}.bind(this));
}else{
this.renderTemplate(this.innerHTMLText);
}
},renderTemplate:function(_4a,_4b){
if(typeof _4b=="string"){
_4b=this.getElement(_4b);
}
this.renderContainer=_4b||this.renderContainer||this.container;
if(_4a){
try{
if(this.parameters==null){
this.parameters={};
}
this.logger.debug("before rendering template");
var _4c=_4a.process(this,{throwExceptions:true});
this.renderContainer.innerHTML=_4c;
try{
if(this.useInnerHTML==false){
var _4d=new RegExp("(?:<script.*?>)((\n|.)*?)(?:</script>)","img");
var _4e=_4c.match(_4d);
if(_4e){
setTimeout((function(){
for(var i=0;i<_4e.length;i++){
if(_4e[i].indexOf("src=")==-1){
_4e[i].match(_4d);
eval(RegExp.$1);
}else{
var _50=_4e[i].indexOf("src=")+5;
var _51=_4e[i].substring(_50);
var end=_51.indexOf("\"");
var url=_51.substring(0,end);
maptales.rpc.loadScript(url);
}
}
}).bind(this),10);
}
}
}
catch(e){
this.logger.error("error evaluating inline script",e);
}
this.logger.debug("after rendering template");
try{
Widget.initWidgetContainer(this.renderContainer,this);
this.onDisplay();
}
catch(e){
this.logger.warn("Widget.initWidgetContainer threw exception",e);
}
}
catch(e){
this.logger.warn("WidgetDisplayException: Widget could not display, probably because the container is not on screen anymore. or because template cannot be parsed "+"Did you forget to remove fieldListeners on destroy? container: "+this.renderContainer,e);
try{
if(this.getApplication().getCurrentUser()&&this.getApplication().getCurrentUser().hasRole("ROLE_ADMIN")){
this.renderContainer.innerHTML="<h3>An error ocurred rendering template</h3><p>"+e+"</p>";
}else{
this.renderContainer.innerHTML="<h3>An error ocurred rendering template</h3>";
}
}
catch(e){
}
}
}
},addRequest:function(_54){
if(_54){
this.templateLoadingArray.push(_54);
}
},removeRequest:function(_55){
for(var i=this.templateLoadingArray.length-1;i>=0;i--){
if(this.templateLoadingArray[i]==_55){
this.templateLoadingArray.splice(0,i+1);
break;
}
}
},isStaleRequest:function(_57){
var _58=true;
for(var i=0;i<this.templateLoadingArray.length;i++){
if(this.templateLoadingArray[i]==_57){
_58=false;
}
}
return _58;
},onDisplay:function(){
},destroy:function(){
this._destroy();
},_destroy:function(){
this.destroySubwidgets();
this.destroyDraggables();
},destroySubwidgets:function(){
if(this.subWidgets){
for(var i=0;i<this.subWidgets.length;i++){
if(this.subWidgets[i]){
try{
this.subWidgets[i].destroy();
}
catch(e){
this.logger.error("Exception in destroySubWidgets() ",e);
}
delete this.subWidgets[i];
}
}
this.subWidgets=[];
}
},destroyDraggables:function(){
if(this.draggables){
for(draggableId in this.draggables){
if(this.draggables[draggableId]){
try{
this.draggables[draggableId].destroy();
}
catch(e){
this.logger.error("Exception in destroyDraggables() ",e);
}
delete this.draggables[draggableId];
}
}
this.draggables={};
}
},showLoading:function(){
this.display("loading");
},hideLoading:function(){
var _5b=document.getElementById("hoverMessage");
if(_5b){
_5b.parentNode.removeChild(_5b);
}
},getElement:function(id){
AssertNotNull(this.getContainer(),"WidgetContainerError","The widget lost its container. Therefore the getElement function is applied to the window.");
var _5d=document.getChildById(id,this.getContainer());
if(_5d==null){
this.logger.debug("could not find element: "+id+" in this widget. InnerHTML: "+this.getContainer().innerHTML);
}
return _5d;
},removeElement:function(id){
this.logger.debug("removeElement: "+id);
AssertNotNull(this.getContainer(),"WidgetContainerError","The widget lost its container. Therefore the removeElement function is applied to the window.");
var _5f=document.getChildById(id,this.getContainer());
if(_5f==null){
this.logger.warn("removeElement> could not remove element: "+id+" htmlElement: "+_5f);
}else{
if(_5f.parentNode==null){
this.logger.warn("removeElement> could not remove element: "+id+" htmlElement: "+_5f+" parent: "+_5f.parentNode);
}
}
if(_5f!=null&&_5f.parentNode!=null){
var _60=_5f.parentNode;
_60.removeChild(_5f);
}
},assertComponent:function(_61){
if(!this.checkComponent(_61)){
alert("The widget is missing a component");
}
},checkComponent:function(_62){
if(this._components[_62]!=null){
return true;
}
return false;
},getComponent:function(_63){
return this._components[_63];
},setComponent:function(_64,_65){
this._components[_64]=_65;
},getApplication:function(){
return this.application;
},setApplication:function(app){
this.application=app;
},getContextObject:function(){
return this.contextObject;
},setContextObject:function(_67){
this.contextObject=_67;
},getView:function(){
return this.view;
},setView:function(_68){
this.view=_68;
},getParameters:function(){
return parameters;
},setParameters:function(_69){
this.parameters=_69;
},getServiceFunction:function(_6a){
if(_6a==null){
return null;
}
var _6b=_6a.split(".");
var _6c=maptales.service;
var _6d=null;
for(var e=0;e<_6b.length;e++){
_6d=_6c;
_6c=_6c[_6b[e]];
if(_6c==null){
return null;
}
}
if(_6c instanceof Function){
return _6c.bind(_6d);
}else{
return null;
}
},submitForm:function(_6f,_70,_71,_72,_73,_74){
var _75=this.getFormHashMap(_6f);
this.tempFormParameters=this.getFormHashMap(_6f);
this.formCallbackAction=_73||false;
this.formContainer=this.getElement(_6f);
this.replyTemplatePath=_72||false;
if(_70){
this.replyContainer=this.getElement(_70);
}else{
this.replyContainer=null;
}
if(this.replyContainer){
Templates.getTemplate("loading",function(_76){
if(_76){
this.replyContainer.innerHTML=_76.process();
}
}.bind(this));
}
var _77=this.getServiceFunction(_71);
if(_77!=null){
_77(_75,this.formReply.bind(this),this);
this.onFormSubmit(_75);
return;
}
var _78=new Action(_71,_75,this.getContainer(),null,this.formReply.bind(this));
this._handleBubbleAction(_78);
},onFormSubmit:function(_79){
},putValuesInFields:function(_7a){
for(fieldName in _7a){
this.getField(fieldName).value=_7a[fieldName];
}
},formReply:function(_7b){
if(_7b instanceof SnapMapException){
if(this.replyTemplatePath==null){
this.replyTemplatePath="widgets/error";
}
this.displayFormReply(_7b);
return;
}else{
if(_7b instanceof SnapMapFormException){
this.display(null,null,function(){
var _7c="There has been an error processing your data.";
if(_7b.message){
_7c=_7b.message;
}
Dialog.toggle("Error",this,null,"dialog/ErrorDialog",{message:_7c},this.getField(_7b.getFieldName()),Dialog.NORTH);
this.putValuesInFields(this.tempFormParameters);
}.bind(this));
return;
}else{
if(this.replyContainer&&this.replyTemplatePath){
this.displayFormReply(_7b);
}else{
this.display();
}
}
}
if(this.formCallbackAction){
Actions.initAction(this.formCallbackAction,null,{reply:_7b},this.getContainer());
}
},displayFormReply:function(_7d){
if(!this.parameters){
this.parameters={};
}
this.parameters.reply=_7d;
if(this.replyContainer){
Templates.getTemplate(this.replyTemplatePath,function(_7e){
this.replyContainer.innerHTML=_7e.process(this);
try{
Widget.initWidgetContainer(this.container,this);
}
catch(e){
this.logger.warn("initWidgetContainer: initialising components/subwidgets/draggables/inputfields had an error",e);
}
this.onDisplay();
}.bind(this));
}
},addDraggable:function(_7f){
this.draggables[_7f.getDraggedObject().id]=_7f;
}};
Widget.initWidgetContainer=function(_80,_81){
var _82=new Date().getTime();
var _83=document.getElementsByAttributeTable(["component","widget","import-template","draggable","dropzone","behaviour","tip"],_80);
try{
Widget.initInputAndActions(_80,_81);
Widget.initDraggables(_83["draggable"],_81);
Widget.initDropZones(_83["dropzone"],_81);
Widget.initImportedTemplates(_83["import-template"],_81);
Widget.initSubWidgets(_80,_81);
Widget.initBehaviours(_83["behaviour"],_81);
Widget.initComponents(_83["component"],_81);
Widget.initTips(_83["tip"],_81);
}
catch(e){
_81.logger.error("error in initWidgetContainer: ",e);
}
var _84=new Date().getTime();
};
Widget.initWidgetContainer_new=function(_85,_86){
var _87=_85.getElementsByTagName("*");
for(var i=0;i<_87.length;i++){
Widget.initElement(_87[i],_86);
}
};
Widget.initElement=function(_89,_8a){
Widget.initInputs(_89,_8a);
if(_89.getAttribute("import-template")){
Widget.initImportedTemplates([_89],_8a);
}
if(_89.getAttribute("dropzone")){
Widget.initDropZones([_89],_8a);
}
if(_89.getAttribute("draggable")){
Widget.initDraggables([_89],_8a);
}
if(_89.getAttribute("behaviours")){
Widget.initBehaviour(_89,_8a);
}
if(_89.getAttribute("component")){
Widget.initComponents([_89],_8a);
}
if(_89.getAttribute("tip")){
Widget.initTips([_89],_8a);
}
if(_89.getAttribute("widget")==null){
var _8b=_89.getElementsByTagName("*");
for(var i=0;i<_8b.length;i++){
Widget.initElement(_8b[i],_8a);
}
}else{
Widget.initSubWidget(_89,_8a);
}
};
Widget.initTips=function(_8d,_8e){
if(_8d){
for(var i=0;i<_8d.length;i++){
maptales.ui.checkTip(_8d[i].getAttribute("tip"),_8d[i]);
}
}
};
Widget.initComponents=function(_90,_91){
if(_90){
_90.each(function(_92){
var _93=_92.getAttribute("component");
var _94=_92.getAttribute("widget");
if(_91){
if(_94){
_91.setComponent(_93,_92._widget);
}else{
_91.setComponent(_93,_92);
}
}
});
}
};
Widget.initSubWidgets=function(_95,_96){
var _97=document.getElementsByAttribute("widget",_95);
for(var i=0;i<_97.length;i++){
Widget.initSubWidget(_97[i],_96);
}
};
Widget.initSubWidget=function(_99,_9a){
var _9b=Element.getAttributeHashMap(_99);
var _9c=_9b.widget;
var _9d=WidgetFactory.create(_9c,_99,_9a,_9b);
if(_9d){
if(_9a){
try{
_9a.addSubWidget(_9d);
}
catch(e){
_9a.logger.warn("Widget>initSubWidgets>Could not add Widget to Parent Widget",e);
}
}
}
};
Widget.initImportedTemplates=function(_9e,_9f){
if(_9e){
for(var i=0;i<_9e.length;i++){
var _a1=_9e[i];
var _a2=_a1.getAttribute("import-template");
Templates.getTemplate(_a2,function(_a3){
_a1.innerHTML=_a3.process(_9f,{throwExceptions:true});
Widget.initWidgetContainer(_a1,_9f);
Actions.initAction("layoutChanged",null,{},_9f);
});
}
}
};
Widget.initInputs=function(_a4,_a5){
if(_a4.tagName){
if(_a4.tagName.toLowerCase()=="textarea"||_a4.tagName.toLowerCase()=="input"){
if(_a4.type.toLowerCase()=="radio"){
}
if(_a4.type.toLowerCase()=="checkbox"||_a4.type.toLowerCase()=="hidden"||_a4.type.toLowerCase()=="password"||_a4.type.toLowerCase()=="text"||_a4.type.toLowerCase()=="textarea"){
_a5._fields[_a4.name]=_a4;
}
}
if(_a4.tagName.toLowerCase()=="select"){
_a5._fields[_a4.name]=_a4;
}
}
};
Widget.initInputAndActions=function(_a6,_a7){
var _a8=document.getElementsByTagName("input",_a6);
if(_a8==null||_a8.length==null){
_a8=[];
}
var _a9=[];
for(var i=0;i<_a8.length;i++){
if(_a8[i].type=="radio"){
_a9.push(_a8[i]);
}
}
while(_a9.length!=0){
var _ab=_a9.partition(function(_ac){
if(_a9[0].name==_ac.name){
return true;
}else{
return false;
}
});
if(_a7._fields[_ab[0][0].name]){
_a7._fields[_ab[0][0].name]=new Radiogroup(_ab[0],_a7._fields[_ab[0][0].name].value);
}else{
_a7._fields[_ab[0][0].name]=new Radiogroup(_ab[0]);
}
_a9=_ab[1];
}
for(var i=0;i<_a8.length;i++){
if(_a8[i].type=="checkbox"||_a8[i].type=="hidden"||_a8[i].type=="password"||_a8[i].type=="text"||_a8[i].type=="textarea"){
_a7._fields[_a8[i].name]=_a8[i];
}
}
var _ad=document.getElementsByTagName("textarea",_a6);
for(var i=0;i<_ad.length;i++){
_a7._fields[_ad[i].name]=_ad[i];
}
var _ae=document.getElementsByTagName("select",_a6);
for(var i=0;i<_ae.length;i++){
_a7._fields[_ae[i].name]=_ae[i];
}
};
Widget.initDraggables=function(_af,_b0){
if(_af){
_af.each(function(_b1){
var _b2=Element.getAttributeHashMap(_b1);
if(_b2.draggedObjectId){
var _b3="["+_b2.draggedObjectId+"]";
var arr=eval(_b3);
if(arr.length==1){
_b0.getApplication().service.getById(arr[0],function(_b5){
if(_b5 instanceof SnapMapException){
}else{
var _b6=new Draggable(_b1,_b5,_b0.domain,_b0,_b2);
_b0.addDraggable(_b6);
}
});
}else{
var _b7=new Draggable(_b1,arr,_b0.domain,_b0,_b2);
}
}
});
}
};
Widget.initDropZones=function(_b8,_b9){
if(_b8){
_b8.each(function(_ba){
var _bb=_ba.getAttribute("dropzone-object-id");
if(_bb){
_b9.getApplication().service.getById(_bb,function(_bc){
if(_bc instanceof SnapMapException){
}else{
var _bd=_ba.getAttribute("dropzone-field-name");
var _be=new SlotDropZone(_ba,_bc,_bd);
DragDrop.registerDropZone(_be);
}
});
}
});
}
};
Widget.initBehaviours=function(_bf,_c0){
if(_bf){
for(var i=0;i<_bf.length;i++){
Widget.initBehaviour(_bf[i],_c0);
}
}
};
Widget.initBehaviour=function(_c2,_c3){
var _c4=Element.getAttributeHashMap(_c2);
var _c5=_c2.attributes.getNamedItem("behaviour").value;
try{
var _c6=new maptales.behaviours[_c5](_c2,_c4,_c3);
}
catch(e){
_c3.logger.error("Behaviour: "+_c5+"does not exist.",e);
}
};
Widget.toHashString=function(_c7){
return JSON.stringify(_c7).replace(/"/g,"'");
};
maptales.widgets["Widget"]=Widget;

var ToggleContainer=Class.create();
ToggleContainer.prototype={initialize:function(_1,_2,_3){
this.container=_1;
this.parent=_3;
this.parameters=_2;
this.container.behaviourBubbleAction=this.handleBubbleAction.bind(this);
},handleBubbleAction:function(_4){
if(_4.getType()=="toggleContainer"){
var _5=document.getChildById("toggledContainer",this.container);
Element.toggle(_5);
_4.type="layoutChanged";
}
if(_4.getType()=="showToggleContainer"){
var _5=document.getChildById("toggledContainer",this.container);
Element.show(_5);
_4.type="layoutChanged";
}
}};
maptales.behaviours["toggleContainer"]=ToggleContainer;
var InfoDisplay=Class.create();
InfoDisplay.prototype={initialize:function(_6,_7,_8){
this.container=_6;
this.parent=_8;
this.parameters=_7;
this.container.behaviourBubbleAction=this.handleBubbleAction.bind(this);
},handleBubbleAction:function(_9){
if(_9.getType()=="displayInfo"){
var _a=document.getChildById("infoContainer",this.container);
Templates.getTemplate(_9.parameters.template,function(_b){
_a.innerHTML=_b.process(null);
});
}
}};
maptales.behaviours["infoDisplay"]=InfoDisplay;
var SingleSelectList=Class.create();
SingleSelectList.prototype={initialize:function(_c,_d,_e){
this.container=_c;
this.parent=_e;
this.parameters=_d;
Element.cleanWhitespace(this.container);
this.container.onclick=this.handleClick.bindAsEventListener(this);
this.currentElement={};
},handleClick:function(_f){
var _10=Event.element(_f);
if($A(this.container.childNodes).indexOf(_10)==-1){
var _11=Event.findElement(_f,"li");
this.selectAndDeselect(_11);
}else{
this.selectAndDeselect(_10);
}
},selectAndDeselect:function(_12){
$A(this.container.childNodes).each(function(_13){
if(_13.className){
_13.className=_13.className.replace(/-selected/g,"");
}
}.bind(this));
if(this.currentElement!=_12){
_12.className=_12.className+"-selected";
}
this.currentElement=_12;
}};
maptales.behaviours["singleSelectList"]=SingleSelectList;
var MultipleSelectList=Class.create();
MultipleSelectList.prototype={initialize:function(_14,_15,_16){
this.parent=_16;
this.container=_14;
this.parameters=_15;
Element.cleanWhitespace(this.container);
this.container.behaviourBubbleAction=this.handleBubbleAction.bind(this);
this.currentElement={};
},handleBubbleAction:function(_17){
switch(_17.getType()){
case "select":
_17.cancelBubble=true;
var _18=_17.sourceHTMLElement.getElementsByTagName("input");
$A(_18).each(function(_19){
_19.checked=true;
});
var _1a=_17.sourceHTMLElement.getElementsByTagName("li");
$A(_1a).each(function(_1b){
if(!Element.hasClassName(_1b,"selected")){
Element.addClassName(_1b,"selected");
}
}.bind(this));
break;
case "toggle":
_17.cancelBubble=true;
var _18=_17.sourceHTMLElement.getElementsByTagName("input");
$A(_18).each(function(_1c){
_1c.checked=!_1c.checked;
});
var _1d=_17.sourceHTMLElement.className.indexOf("selected");
if(_1d>=0){
_17.sourceHTMLElement.className=_17.sourceHTMLElement.className.substring(0,_1d);
}else{
_17.sourceHTMLElement.className+=" selected";
}
break;
case "deselectAll":
_17.cancelBubble=true;
var _1a=this.container.getElementsByTagName("li");
$A(_1a).each(function(_1e){
Element.removeClassName(_1e,"selected");
});
var _18=this.container.getElementsByTagName("input");
$A(_18).each(function(_1f){
_1f.checked=false;
}.bind(this));
break;
case "selectAll":
_17.cancelBubble=true;
var _1a=this.container.getElementsByTagName("li");
$A(_1a).each(function(_20){
_20.className+=" selected";
}.bind(this));
var _18=this.container.getElementsByTagName("input");
$A(_18).each(function(_21){
_21.checked=true;
}.bind(this));
break;
default:
break;
}
}};
maptales.behaviours["multipleSelectList"]=MultipleSelectList;
DraggableController=Class.create();
DraggableController.prototype={initialize:function(_22,_23,_24){
this._container=$(_22);
this.parent=_24;
if(!_23){
_23={};
}
this.snappingInterval=2;
this.lastYPos=0;
if(_23.verticalLock){
if(_23.verticalLock=="false"){
this.verticalLock=false;
}else{
if(_23.verticalLock=="true"){
this.verticalLock=true;
}
}
}else{
this.verticalLock=false;
}
if(_23.horizontalLock){
if(_23.horizontalLock=="false"){
this.horizontalLock=false;
}else{
if(_23.horizontalLock=="true"){
this.horizontalLock=true;
}
}
}else{
this.horizontalLock=false;
}
this.dragged=false;
this.mouseDown=false;
this._boundMouseMove=this._onMouseMove.bind(this);
this._boundMouseUp=this._onMouseUp.bind(this);
this._container.onmousedown=this._onMouseDown.bindAsEventListener(this);
},setContainer:function(_25){
this._container=_25;
},getContainer:function(){
return this._container;
},isSelected:function(){
return this._isSelected;
},canBeSelected:function(){
return this._canBeSelected;
},select:function(){
this.getContainer().className+=" draggable-active";
this._isSelected=true;
},deselect:function(){
this.getContainer().className=this.getContainer().className.replace(/draggable-active/,"");
this._isSelected=false;
this.dragged=false;
},dropped:function(){
this.mouseDown=false;
this.dragged=false;
this.onDrop();
},endDrag:function(){
this.mouseDown=false;
this.dragged=false;
this.onEndDrag();
},_endDrag:function(_26){
},_startDrag:function(_27){
var _28=[Event.pointerX(_27),Event.pointerY(_27)];
var _29=Position.cumulativeOffset(this.getContainer());
this.offsetX=(_28[0]-_29[0]);
this.offsetY=(_28[1]-_29[1]);
this.lastYPos=this.offsetY;
},_onMouseMove:function(_2a){
if(this.mouseDown){
if(this.dragged){
this._updateDraggableLocation(_2a);
}else{
this._currentMouseDownPosition=[Event.pointerX(_2a),Event.pointerY(_2a)];
var _2b=this._initialMouseDownPosition[0]-this._currentMouseDownPosition[0];
var _2c=this._initialMouseDownPosition[1]-this._currentMouseDownPosition[1];
if((Math.abs(_2b)>2)||(Math.abs(_2c)>2)){
this.dragged=true;
this._startDrag(_2a);
}
}
}
},_onMouseDown:function(_2d){
this.mouseDown=true;
if(Event.isLeftClick(_2d)){
this._initialMouseDownPosition=[Event.pointerX(_2d),Event.pointerY(_2d)];
Event.observe(document,"mousemove",this._boundMouseMove);
Event.observe(document,"mouseup",this._boundMouseUp);
Event.stop(_2d);
}
},_onMouseUp:function(_2e){
Event.stopObserving(document,"mousemove",this._boundMouseMove);
Event.stopObserving(document,"mouseup",this._boundMouseUp);
if(this.dragged&this.lastYPos>10){
maptales.ui.getMainMap().setHeight(this.lastYPos-85);
}
this.mouseDown=false;
this.dragged=false;
},_updateDraggableLocation:function(_2f){
var _30=Position.cumulativeOffset(this.getContainer());
var pos=[Event.pointerX(_2f),Event.pointerY(_2f)];
if(this.verticalLock!=true){
var _32=pos[1]-this.offsetY;
if(Math.abs(_32-this.lastYPos)>this.snappingInterval){
this.lastYPos=_32;
maptales.ui.getMainMap().setHeightTemp(this.lastYPos-85);
}
}
if(this.horizontalLock!=true){
this._container.style.left=(pos[0]-this.offsetX)+"px";
}
}};
maptales.behaviours["draggableController"]=DraggableController;
var dynamicMediatorConfigs={};
dynamicMediatorConfigs.storyBrowseConfig={actions:{onGotoIndex:[{forwardToComponent:"storyMainContentView",methodToInvoce:"selectIndex",parameters:"index"},{forwardToComponent:"storyScrollList",methodToInvoce:"selectIndex",parameters:"index"}]}};
dynamicMediatorConfigs.markerBrowseConfig={actions:{onGotoIndex:[{forwardToComponent:"markerMainContentView",methodToInvoce:"selectIndex",parameters:"index"}]}};
dynamicMediatorConfigs.profileImageSelectConfig={template:"cropProfileImageMediator",actions:{cropChange:[{methodToInvoce:"styleElement",element:"buddyIcon"}],finishedAreaSelect:[{bubbleAction:"gotoPath",parameters:{path:"#profile"}}]}};
var DynamicMediatorBehaviour=Class.create();
Object.extend(Object.extend(DynamicMediatorBehaviour.prototype,Widget.prototype),{logger:maptales.getLogger("com.maptales.webclient.dynamicmediator"),initialize:function(_33,_34,_35){
this.container=_33;
this.parent=_35;
if(_34.mediatorConfig==null||dynamicMediatorConfigs[_34.mediatorConfig]==null){
this.logger.warn("DynamicMediatorInitException: No config given for the mediator");
}
this.parametersInternal=dynamicMediatorConfigs[_34.mediatorConfig];
this.actions=this.parametersInternal.actions;
this.parameters=_34;
if(this.parametersInternal.template){
this.initializeWidget(this.container,this.parent,null,null,"dynamicMediator/"+this.parametersInternal.template,this.parameters,false);
this.display();
}else{
this.initializeWidget(this.container,this.parent,null,null,null,this.parameters,true);
}
},styleElement:function(_36){
if(_36==null){
return;
}
var _37=document.getChildById("buddyIcon",this.container);
this.logger.debug("StyleElement: "+_37);
if(_36.top){
_37.style.top=_36.top+"px";
}
if(_36.left){
_37.style.left=_36.left+"px";
}
if(_36.width){
_37.style.width=_36.width+"px";
}
if(_36.height){
_37.style.height=_36.height+"px";
}
},handleBubbleAction:function(_38){
this.logger.debug("RedirectActionsBehaviour>handleBubbleAction>"+_38.getType());
if(this.actions[_38.type]){
_38.cancelBubble=true;
for(var i=0;i<this.actions[_38.type].length;i++){
var _3a=this.actions[_38.type][i];
if(!_3a){
continue;
}
if(_3a.forwardToComponent){
var _3b=this.parent.getComponent(_3a.forwardToComponent);
}else{
var _3b=this;
}
if(_3b==null){
this.logger.warn("DynamicMediatorError: Could not get Component: "+_3a.forwardToComponent);
}else{
if(_3a.methodToInvoce){
if(_3a.parameters){
_3b[_3a.methodToInvoce](_38.parameters[_3a.parameters]);
}else{
_3b[_3a.methodToInvoce](_38.parameters);
}
}
if(_3a.bubbleAction){
$a(_3a.bubbleAction,null,_3a.parameters,this.container);
}
}
}
}
}});
maptales.behaviours["dynamicMediator"]=DynamicMediatorBehaviour;
var TrashcanBehaviour=Class.create();
TrashcanBehaviour.prototype={initialize:function(_3c,_3d,_3e){
this.container=_3c;
this.parent=_3e;
this.slotName=_3d.slotName;
this.contextObject=_3d.contextObject||null;
if(this.contextObject){
maptales.service.getById(this.contextObject,function(_3f){
if(_3f instanceof SnapMapException){
}else{
this.contextObject=_3f;
}
}.bind(this));
}
this.container.handleBubbleAction=this.handleBubbleAction.bind(this);
this.container.onmousedown=function(){
Dialog.toggle("Tip: Deleting Items",null,"tip","dialog/TipOfTheDay",{text:"You can drag items to the trashcan to delete them permanently.",mandatory:true},this.container,Dialog.NORTH);
}.bind(this);
DragDrop.registerDropZone(this);
},startDraggingDropItems:function(){
if(this.acceptDropContent(DragDrop.getDraggedObjects())){
this.container.className="trashcanOver";
this.container.onmouseover=this.dropOver.bindAsEventListener(this);
this.container.onmouseout=this.dropOut.bindAsEventListener(this);
}
},endDraggingDropItems:function(){
this.container.className="trashcan";
this.container.onmouseover=null;
this.container.onmouseout=null;
},dropOver:function(_40){
DragDrop.setActiveDropZone(this);
},dropOut:function(_41){
DragDrop.setActiveDropZone(null);
},doDrop:function(_42){
var _43=true;
this.objectsToDelete=[];
for(var i=0;i<_42.length;i++){
this.objectsToDelete.push(_42[i].getDraggedObject());
if(!(_42[i].getDraggedObject() instanceof Story)&&!(_42[i].getDraggedObject() instanceof Map)){
_43=false;
}
}
this.deleteConfirmDialog=Dialog.toggle("Delete Items?",this,null,"Delete_Confirm",{ids:this.objectsToDelete,selectRecursion:_43},this.container,Dialog.NORTH);
},acceptDropContent:function(_45){
return this.contextObject.isSlotForObjects(this.slotName,_45);
},handleBubbleAction:function(_46){
switch(_46.getType()){
case "deleteConfirm":
if(this.deleteConfirmDialog){
this.deleteConfirmDialog.destroy();
}
var _47=new Dialog("Deleting Items",this,null,"loading",this,this.container,Dialog.NORTH);
window.setTimeout(function(){
maptales.service.deleteById({ids:this.objectsToDelete,recursive:_46.parameters.recursion},function(_48){
if(_48 instanceof SnapMapException){
_47.destroy();
_47=new Dialog("Error Deleting",this,null,"dialog/ErrorDialog",{message:"There has been an error deleting the objects"},this.container,Dialog.NORTH);
}else{
_47.destroy();
}
}.bind(this));
}.bind(this),500);
break;
}
}};
maptales.behaviours["trashcan"]=TrashcanBehaviour;
var RemoveBehaviour=Class.create();
RemoveBehaviour.prototype={initialize:function(_49,_4a,_4b){
this.container=_49;
this.parent=_4b;
this.slotName=_4a.slotName;
this.contextObject=_4a.contextObject||null;
if(this.contextObject){
maptales.service.getById(this.contextObject,function(_4c){
if(_4c instanceof SnapMapException){
}else{
this.contextObject=_4c;
}
}.bind(this));
}
DragDrop.registerDropZone(this);
this.container.handleBubbleAction=this.handleBubbleAction.bind(this);
},acceptDropContent:function(_4d){
return true;
},startDraggingDropItems:function(){
if(this.acceptDropContent(DragDrop.getDraggedObjects())){
this.container.className="trashcan12Over";
this.container.onmouseover=this.dropOver.bindAsEventListener(this);
this.container.onmouseout=this.dropOut.bindAsEventListener(this);
}
},endDraggingDropItems:function(){
this.container.className="trashcan12";
this.container.onmouseover=null;
this.container.onmouseout=null;
},dropOver:function(_4e){
DragDrop.setActiveDropZone(this);
},dropOut:function(_4f){
DragDrop.setActiveDropZone(null);
},doDrop:function(_50){
this.objectsToRemove=[];
for(var i=0;i<_50.length;i++){
this.objectsToRemove.push(_50[i].getDraggedObject());
}
Dialog.toggle("Remove Items?",this,null,"Remove_Confirm",this,this.container,Dialog.NORTH);
},handleBubbleAction:function(_52){
switch(_52.getType()){
case "removeConfirm":
_52.cancelBubble=true;
var _53=new Dialog("Removing Items",this,null,"loading",this,this.container,Dialog.NORTH);
window.setTimeout(function(){
this.contextObject.removeFromSlot(this.slotName,this.objectsToRemove);
this.contextObject.persist(function(_54){
if(_54 instanceof SnapMapException){
_53.destroy();
}else{
_53.destroy();
}
}.bind(this));
}.bind(this),500);
break;
}
}};
maptales.behaviours["remove"]=RemoveBehaviour;
var MainTeaserTags=Class.create();
MainTeaserTags.prototype={pool:[["Trips","travel"],["Art","art"],["Sports","sport"],["Nature","nature"],["Love","love"],["Travel","travel"],["Beach","beach"],["Report","report"],["Fun","fun"],["Work","work"],["Adventure","adventure"],["Party","party"],["City","city"],["History","history"],["Books","book"]],initialize:function(_55,_56){
this.container=_55;
this.updateTags();
},updateTags:function(_57){
var _58=[];
while(_58.length<5){
var _59=Math.floor(Math.random()*this.pool.length);
if(_58.indexOf(this.pool[_59])==-1){
_58.push(this.pool[_59]);
}
}
var _5a="";
for(var i=0;i<_58.length;i++){
_5a+="<span onclick=\"$a('gotoPath', event, {path:'Maptales#browse?searchString="+_58[i][1]+"'});\">"+_58[i][0]+"</span> ";
}
this.container.innerHTML=_5a;
}};
maptales.behaviours["mainTeaserTags"]=MainTeaserTags;

var MaptalesExternalApp=Class.create();
Object.extend(Object.extend(MaptalesExternalApp.prototype,Widget.prototype),{logger:maptales.getLogger("com.maptales.webclient.MaptalesExternalApp"),initialize:function(_1,_2,_3){
this.domain=maptales;
this.container=_1;
this.height=Element.getDimensions(this.container).height;
this.width=Element.getDimensions(this.container).width;
this.appName="Maptales";
maptales.setConfig(_2);
maptales.ui=this;
this.story=_3;
this.medias=_3.getSlotFromCache("medias",0,-1,null,null);
this.contentEl=$("content");
this.autoHideInfo=true;
try{
var _4=window.location.search;
var _5=_4.indexOf("autoHide=");
if(_5>-1){
var _6=parseInt(_4.substring(_5+9,_5+10));
this.autoHideInfo=(_6>0);
}
}
catch(e){
}
this.initializeWidget(this.container,this,null,null,null,null,true);
Widget.initWidgetContainer(this.container,this);
this.getMainMap().setMapMode(_3.get("mapMode"));
this.getMainMap().setForceLineDrawing(true);
this.getMainMap().setDoDisplayMarkerInfo(false);
this.mapObjects=[];
for(var i=0;i<this.medias.length;i++){
if(this.medias[i] instanceof MapObject){
this.mapObjects.push(this.medias[i]);
}else{
if(this.medias[i] instanceof Media){
try{
var _8=this.medias[i].getRefFromCache("mapobject");
if(_8){
this.mapObjects.push(_8);
}
}
catch(e){
this.logger.warn("mapobject not loaded nonlazy");
}
}
}
}
this.getMainMap().showObjectBounds(this.mapObjects);
this.mapObjectToAdd=0;
window.setTimeout(this.addInitialMapObject.bind(this),1000);
window.setTimeout(toggleContent,2000);
},addInitialMapObject:function(){
this.getMainMap().addQueryOverlays(this.mapObjects);
},getAppName:function(){
return this.appName;
},getPath:function(){
return [{name:this.getAppName(),path:this.getAppName()}];
},getViews:function(){
return this.rootViews;
},getDefaultView:function(){
return this.rootViews[this.defaultView];
},addLoginListener:function(){
},hasView:function(_9){
if(this.rootViews[_9]){
return true;
}else{
return false;
}
},getView:function(_a){
if(_a){
return this.rootViews[_a];
}else{
return this.rootViews[this.defaultView];
}
},getAndIncrementTempId:function(){
return maptales.tempIdIndex--;
},getTemplateOfView:function(_b){
try{
var _c="";
if(_b=="default"||_b==null){
if(this.rootViews[this.defaultView].template){
_c+=this.rootViews[this.defaultView].template;
}else{
return null;
}
}else{
if(this.rootViews[_b].template){
_c+=this.rootViews[_b].template;
}else{
return null;
}
}
return _c;
}
catch(e){
return false;
}
},typeCastObjects:function(_d){
if(!_d){
return [];
}
if(_d instanceof Array){
var _e=[];
_d.each(function(_f,_10){
if(_f instanceof ContentObject){
_e.push(_f);
}else{
_e.push(maptales.service.typeCastObjects(_f));
}
}.bind(this));
return _e;
}else{
try{
if(_d instanceof ContentObject){
var _11=_d;
}else{
var _11=maptales.service.create(_d.type,_d);
}
}
catch(e){
alert("maptales.typeCastObjects > Error: "+_d.type+" Message: "+e);
}
}
return _11;
},getMainMap:function(){
return this.getComponent("map");
},getContentPanel:function(){
return this.getComponent("storySlot");
},onMapItemClick:function(_12){
for(var i=0;i<this.medias.length;i++){
if(this.medias[i].id==_12.contextObject){
gotoIndex(i+1);
if(!contentVisible){
showContent();
}
return;
}
}
},addStatusMessage:function(_14,_15){
var sb=this.getComponent("statusBar");
if(sb){
sb.addMessage(_14,_15);
}
},setUserProperty:function(_17){
var _18=this.getCurrentUser();
var _19=false;
for(parameter in _17){
if(_17[parameter]+""!=_18.getProperty(parameter)){
_18.setProperty(parameter,_17[parameter]+"");
_19=true;
}
}
if(_19){
this.persist(_18,function(_1a){
});
}
},getSlot:function(id,_1c,_1d,_1e,_1f,_20,_21){
return this.domain.transfer.getSlot(id,_1c,_1d,_1e,_1f,_20,_21);
},getById:function(id,_23){
return this.domain.transfer.getById(id,_23);
},doWithObject:function(_24,_25){
if(isNaN(_24)){
_25(_24);
}else{
this.getById(_24,_25);
}
},setById:function(id,_27,_28){
return this.domain.transfer.setById(id,_27,_28);
},addById:function(id,_2a,_2b,_2c){
return this.domain.transfer.addById(id,_2a,_2b,_2c);
},removeById:function(_2d,_2e,_2f,_30){
return this.domain.transfer.removeById(_2d,_2e,_2f,_30);
},grantAllRights:function(_31){
if(_31 instanceof Tag){
}else{
var _32=_31.get("rights");
$H(_32).each(function(_33){
var key=_33.key;
_31.renderedRights[key]=true;
}.bind(this));
}
},addWarning:function(_35,_36){
try{
this.addStatusMessage("UserWarning",{title:_35,text:_36});
}
catch(e){
}
},addException:function(_37){
try{
this.addStatusMessage("Exception",_37);
}
catch(e){
}
},addFailure:function(_38,_39){
try{
this.addStatusMessage("Failure",{title:_38,text:_39});
}
catch(e){
}
},addInfo:function(_3a,_3b){
try{
this.addStatusMessage("Info",{title:_3a,text:_3b});
}
catch(e){
}
},currentUser:false,getCurrentUser:function(){
return null;
},getCurrentUserId:function(){
return false;
},currentUserHasRole:function(_3c){
return false;
},checkRights:function(_3d){
return false;
},handleBubbleAction:function(_3e){
this.logger.debug("MaptalesWidget>handleBubbleAction: "+_3e.getType());
_3e.cancelBubble=true;
switch(_3e.getType()){
case "selectPreviousItem":
case "selectNextItem":
this.getComponent("storySlot").handleBubbleAction(_3e);
break;
default:
this.getComponent("map").handleBubbleAction(_3e);
break;
}
}});
var contentVisible=false;
function toggleContent(){
if(contentVisible){
hideContent();
}else{
showContent();
}
}
function showContent(){
if(!contentVisible){
animate(-275,1,2,function(_3f){
$("infoPane").style.right=_3f+"px";
},function(_40){
$("infoPane").style.right=_40+"px";
contentVisible=true;
});
window.setTimeout(function(){
var obj=maptales.ui.getMainMap().getSelectedObject();
maptales.ui.getMainMap().setFocusOffset([-140,0]);
if(obj){
if(obj instanceof Line){
if(!maptales.ui.getMainMap().tracedLine){
maptales.ui.getMainMap().panTo(obj.getEndPoint());
}
}else{
maptales.ui.getMainMap().panTo(obj.get("location"));
}
}else{
maptales.ui.getMainMap().panTo(maptales.ui.getMainMap().getCenter());
}
},150);
}
}
function hideContent(){
if(contentVisible){
animate(1,-275,2,function(_42){
$("infoPane").style.right=_42+"px";
},function(_43){
$("infoPane").style.right=_43+"px";
contentVisible=false;
});
window.setTimeout(function(){
var obj=maptales.ui.getMainMap().getSelectedObject();
maptales.ui.getMainMap().setFocusOffset([0,0]);
if(obj){
if(obj instanceof Line){
if(!maptales.ui.getMainMap().tracedLine){
maptales.ui.getMainMap().panTo(obj.getEndPoint());
}
}else{
maptales.ui.getMainMap().panTo(obj.get("location"));
}
}else{
maptales.ui.getMainMap().panTo(maptales.ui.getMainMap().getCenter());
}
},150);
}
}
var currentContentIndex=0;
function gotoIndex(_45){
var el=$("content"+_45);
if(el){
if(maptales.ui.contentEl&&maptales.ui.contentEl.scrollTop){
maptales.ui.contentEl.scrollTop=0;
}
$("content"+currentContentIndex).style.display="none";
el.style.display="block";
currentContentIndex=_45;
var _47=story.getSlotFromCache("medias",0,-1,null,null);
if(maptales.ui.medias&&maptales.ui.medias[_45-1]){
maptales.ui.getMainMap().setFocusOffset(contentVisible?[-140,0]:[0,0]);
var _48=maptales.ui.getMainMap().selectedMapObject;
maptales.ui.getMainMap().selectMapObject(maptales.ui.medias[_45-1].getRefId("mapobject"));
var _49=maptales.ui.getMainMap().selectedMapObject;
if(_48){
if(_49 instanceof Line){
var _4a=false;
if(_48&&_48 instanceof Marker&&_49.getRefFromCache("endMarker")==_48){
_4a=true;
}
maptales.ui.getMainMap().zoomTo(_49.get("viewZoomLevel"));
maptales.ui.getMainMap().traceLine(_49,_4a,null,1000);
}else{
maptales.ui.getMainMap().show(maptales.ui.medias[_45-1].getRefId("mapobject"));
}
}else{
maptales.ui.getMainMap().show(maptales.ui.medias[_45-1].getRefId("mapobject"));
}
}else{
maptales.ui.getComponent("map").selectMapObject(null);
}
if($("content"+(currentContentIndex+1))){
$("mainNextButton").className="aquaNext";
}else{
$("mainNextButton").className="aquaNextDisabled";
}
if($("content"+(currentContentIndex-1))){
$("mainPrevButton").className="aquaPrev";
}else{
$("mainPrevButton").className="aquaPrevDisabled";
}
}
}
function next(){
if(contentVisible){
var _4b=maptales.ui.medias[currentContentIndex-1];
var _4c=maptales.ui.medias[currentContentIndex];
if(!maptales.ui.autoHideInfo||_4b&&_4c&&(!_4c.getRefFromCache("mapobject")||(_4b.getRefFromCache("mapobject")==_4c.getRefFromCache("mapobject")))){
gotoNextIndex();
}else{
if(this.width<500){
hideContent();
window.setTimeout(showContent,2500);
window.setTimeout(gotoNextIndex,1000);
}else{
gotoNextIndex();
}
}
}else{
if(maptales.ui.autoHideInfo){
window.setTimeout(showContent,2000);
}
gotoNextIndex();
}
}
function gotoNextIndex(){
gotoIndex(currentContentIndex+1);
}
function prev(){
gotoIndex(currentContentIndex-1);
}
var DragDrop={};
DragDrop.isDragging=false;

var MapWidget=Class.create();
MapWidget.SATELLITE_MODE=0;
MapWidget.MAP_MODE=1;
MapWidget.HYBRID_MODE=2;
var PROFILING_COUNTER=0;
Object.extend(Object.extend(MapWidget.prototype,Widget.prototype),{reflection:{},logger:maptales.getLogger("com.maptales.webclient.map"),initialize:function(_1,_2,_3,_4,_5,_6,_7){
this._container=$(_1);
this.parent=_2;
this.panSmoothly=_6.panSmoothly||true;
this.skipEmpty=true;
this.browseQuery={};
this.slotOverlays=[];
this.queryOverlays=[];
this.tempOverlays=[];
this.moveListeners=[];
this.focusOffset=null;
this.forceLineDrawing=false;
this.sorting="creationDate asc";
this.offset=0;
this.size=20;
this.querySize=0;
this.locally=true;
this.boundSynchronizedSlotFunction=this.updateSynchronizedSlot.bind(this);
this.doDisplayMarkerInfo=true;
this.initializeWidget(this._container,this.parent,null,null,_6.templatePath||"mapPanel/view",_6,true);
this.display();
this.selectedMapObject=null;
this.overlaysVisible=true;
this.lockZoom=false;
this.boundLoginListener=this.onLogin.bind(this);
if(maptales.service&&maptales.service.user){
maptales.service.user.addLoginListener(this.boundLoginListener);
}
this.boundQueryListener=this.queryCallback.bind(this);
this.queryModeEnabled=false;
this.boundUpdateLoading=this.updateLoading.bind(this);
this.query=null;
this.synchronizedSlotSort=null;
if(this.getApplication().service&&this.getApplication().service.query){
this.queryService=this.getApplication().service.query;
}
if(maptales.rpc&&maptales.rpc.addLoadingListener){
maptales.rpc.addLoadingListener(this.boundUpdateLoading);
}
},setForceLineDrawing:function(_8){
this.forceLineDrawing=_8;
},displayContextTemplate:function(_9){
var _a=this.getElement("contextArea");
if(_a!=null){
if(this.queryModeEnabled){
Templates.getTemplate(_9||"mapPanel/mapBrowseContext",function(_b){
_a.innerHTML=_b.process(this);
}.bind(this));
}else{
Templates.getTemplate(_9||"mapPanel/mapSlotContext",function(_c){
_a.innerHTML=_c.process(this);
}.bind(this));
}
}
},removeCurrentContext:function(){
if(this.query!=null){
this.queryService.removeQuery(this.query,this.boundQueryListener);
this.query=null;
}
this.desynchronizeSlot();
this.clearAllOverlays();
var _d=this.getElement("contextArea");
if(_d){
_d.innerHTML="";
}
},setToQueryMode:function(_e,_f){
if(this.query!=null&&this.query.equals(_e)){
return;
}
this.removeCurrentContext();
this.clearAllOverlays();
this.setOverlayDisplayMode(_e.parameters.clustered);
this.forceLineDrawing=false;
if(_e.parameters.clustered==false){
this.offset=_e.parameters.offset;
this.size=_e.parameters.size;
this.clustered=false;
}else{
this.clustered=true;
}
if(_e.parameters.locally==null){
this.locally=true;
}else{
this.locally=_e.parameters.locally;
}
this.type=_e.parameters.type;
this.queryService.setBounds(this.getBoundsJSON());
this.queryService.setZoomLevel(this.getZoom());
this.queryService.addQuery(_e,this.boundQueryListener);
this.query=_e;
this.queryModeEnabled=true;
this.displayContextTemplate();
},setToSlotMode:function(_10){
this.slotTemplate=_10.templatePath||null;
this.clearAllOverlays();
this.removeCurrentContext();
if(_10.forceLineDrawing){
this.forceLineDrawing=_10.forceLineDrawing;
}else{
_10.forceLineDrawing=true;
}
if(_10.mapMode!=null){
this.setMapMode(_10.mapMode);
var _11=this.mapModeListener.bind(this);
$O(_10.contextObject).addFieldListener("mapMode",_11);
}
this.slotMessage=_10.message;
this.synchronizedSlotSort=_10.sort;
this.synchronizedSlotOffset=_10.offset;
this.synchronizedSlotSize=_10.size;
this.synchronizedSlotTotalSize=0;
this.synchronizeSlotOnMap(_10.contextObject,_10.slotName,_10.filter,null,_10.zoom);
this.queryModeEnabled=false;
this.displayContextTemplate(this.slotTemplate);
},search:function(){
this.queryService.setBounds(this.getBoundsJSON());
this.queryService.setZoomLevel(this.getZoom());
this.queryService.search();
},queryCallback:function(_12){
if(_12 instanceof SnapMapException){
}else{
this.clearQueryOverlays();
if(this.showClustered){
this.addQueryOverlays(_12.queryResults);
}else{
this.addQueryOverlays(_12.queryResults);
this.querySize=_12.querySize;
if(this.locally==false){
this.showObjectBounds(this.queryOverlays);
}
}
this.displayContextTemplate();
this.hideMarkerInfo();
}
},clearQueryOverlays:function(){
this.gmap.clearOverlays();
this.queryOverlays=[];
},addQueryOverlays:function(_13){
if(_13==null){
return;
}
for(var i=0;i<_13.length;i++){
this.addQueryOverlay(_13[i]);
}
},addQueryOverlay:function(_15){
if(_15==null){
return;
}
var _16=_15;
if(_15 instanceof Media){
_15=_15.getRefFromCache("mapobject");
}
if(_15!=null){
try{
this.queryOverlays.push(_15);
_15.setMapPane(this);
_15.setContentType(_16);
this.gmap.addOverlay(_15);
}
catch(e){
this.logger.error("Error placing item on map",e);
}
}
},removeQueryOverlay:function(_17){
if(_17==null){
return;
}
if(_17 instanceof Media){
_17=_17.getRefFromCache("mapobject");
}
if(_17!=null){
this.queryOverlays.removeEntry(_17);
this.gmap.removeOverlay(_17);
this.removeTempOverlay(_17);
}
},updateOverlay:function(_18){
if(this.queryOverlays.indexOf(_18)!=-1){
this.gmap.removeOverlay(_18);
this.gmap.addOverlay(_18);
}
},setOverlayDisplayMode:function(_19){
this.showClustered=_19;
},setFocusOffset:function(_1a){
this.focusOffset=_1a;
},setDoDisplayMarkerInfo:function(_1b){
this.doDisplayMarkerInfo=_1b;
},onMapMove:function(){
$a("gotoPath",null,{contextObject:this.getApplication(),view:"browse"},this._container);
this.removeMoveListener(this);
},onLogin:function(_1c){
if(_1c!=null){
if(this.getElement("snapShotTool")!=null){
this.getElement("snapShotTool").style.display="inline";
}
}else{
if(this.getElement("snapShotTool")!=null){
this.getElement("snapShotTool").style.display="none";
}
}
},onDisplay:function(){
this.gmap=new GMap2(this.getElement("map"));
this.gmap.setCenter(new GLatLng(34,21.5),2);
this.zoomBox=new ZoomBoxControl();
this.gmap.addControl(this.zoomBox);
this.gmap.setMapType(G_HYBRID_MAP);
this.mapMode=MapWidget.HYBRID_MODE;
if(this.gmap.enableContinuousZoom){
this.gmap.enableContinuousZoom();
}
this.pixelPos=Position.cumulativeOffset(this.getElement("map"));
this.markerButtons=new MarkerButtons(this.gmap.getPane(G_MAP_FLOAT_PANE),this.gmap,this);
this.lineButtons=new LineButtons(this.gmap.getPane(G_MAP_FLOAT_PANE),this.gmap,this);
if($("markerInfoContainer")==null){
this.markerInfoContainer=document.createElement("DIV");
this.markerInfoContainer.className="markerInfo";
this.container.appendChild(this.markerInfoContainer);
}else{
this.markerInfoContainer=$("markerInfoContainer");
}
if(this.markerInfoContainer){
this.markerInfoWidget=new Widget(this.markerInfoContainer,this,null,null,"objects/Marker/info");
}
this.lastZoom=this.getZoom();
GEvent.bind(this.gmap,"moveend",this,this.mapMoved.bind(this));
DragDrop.registerDropZone(this);
if(maptales.service.user.getCurrentUser()!=null){
this.onLogin(maptales.service.user.getCurrentUser());
}
},onDropOver:function(_1d){
if(DragDrop.isDragging){
if(this.acceptDropContent(DragDrop.getDraggedObjects())){
DragDrop.setActiveDropZone(this);
}
}
Event.stop(_1d);
},onDropOut:function(_1e){
if(DragDrop.getActiveDropZone()==this){
DragDrop.setActiveDropZone(null);
}
},acceptDropContent:function(_1f){
var _20=true;
$A(_1f).each(function(_21){
if(!(_21 instanceof Media||_21 instanceof Array)){
_20=false;
}
}.bind(this));
return _20;
},startDraggingDropItems:function(_22){
this._container.onmouseover=this.onDropOver.bindAsEventListener(this);
this._container.onmouseout=this.onDropOut.bindAsEventListener(this);
var map=this.getElement("map");
if(navigator.appName!="Microsoft Internet Explorer"){
map.className+=" droppable";
}
},endDraggingDropItems:function(){
this._container.onmouseover=null;
this._container.onmouseout=null;
var map=this.getElement("map");
if(navigator.appName!="Microsoft Internet Explorer"){
map.className=map.className.replace(/droppable/g,"");
}
},doDrop:function(_25,ev){
var pos=[Event.pointerX(ev),Event.pointerY(ev)];
if(Position.within(this._container,pos[0],pos[1])){
var _28=Position.cumulativeOffset($("map"));
var _29=this.gmap.fromContainerPixelToLatLng({x:pos[0]-_28[0],y:pos[1]-_28[1]});
var _2a={creator:maptales.service.user.getCurrentUserId(),location:_29,definitionZoomLevel:this.getZoom(),viewZoomLevel:this.getZoom()};
var _2b=maptales.service.create("Marker",_2a);
_2b.setSlotLength("medias",0);
var _2c=[];
_25.each(function(_2d){
var _2e=_2d.getDraggedObject();
if(_2e instanceof Array){
for(var i=0;i<_2e.length;i++){
var _30=this.onDropAssociationManagement($O(_2e[i]),_2b);
_2c.push(_30);
}
}else{
var _30=this.onDropAssociationManagement(_2e,_2b);
_2c.push(_30);
}
}.bind(this));
_2b.addToSlot("medias",_2c);
_2b.updateIcons();
this.addQueryOverlay(_2b);
this.synchronizedSlotOffset=0;
maptales.ui.checkTip("marker",_2b.container,Dialog.SOUTH);
this.store(_2b,function(_31){
if(_31 instanceof SnapMapException){
Dialog.toggle("Error Storing Marker",this,null,"dialog/ErrorDialog",{message:"The new marker could not be stored."},_2b.container,Dialog.NORTH,null,null,function(){
this.gmap.removeOverlay(_2b);
var _32=[];
_25.each(function(_33){
var _34=_33.getDraggedObject();
_34.set("mapobject",null);
_32.push(_34);
});
_2b.removeFromSlot("medias",media);
}.bind(this));
}else{
this.onDoDrop(_31);
}
}.bind(this));
}
},onDropAssociationManagement:function(_35,_36){
if(_35.getRefId("mapobject")!=null){
try{
var _37=_35.getRefFromCache("mapobject");
_37.removeFromSlot("medias",_35);
}
catch(e){
this.logger.warn("Map could not remove media item: map could not remove media item from marker before placing it into a new one",e);
}
}
_35.set("mapobject",$O(_36.id));
return _35;
},onDoDrop:function(_38){
},store:function(_39,_3a){
this.addToSynchronizedSlot(_39,_3a);
},getContainer:function(){
return this._container;
},snap:function(_3b,_3c,_3d){
for(var i=0;i<this.slotOverlays.length;i++){
if(_3d&&this.slotOverlays[i]==_3d){
continue;
}
if(this.slotOverlays[i].snap){
var ret=this.slotOverlays[i].snap(_3b,_3c);
if(ret){
if(_3d&&ret==_3d){
continue;
}
return ret;
}
}
}
},getGMap:function(){
return this.gmap;
},fromContainerPixelToLatLng:function(x,y){
return this.gmap.fromContainerPixelToLatLng(x,y);
},fromEventToLatLng:function(_42){
var pos=[Event.pointerX(_42),Event.pointerY(_42)];
return this.fromContainerPixelToLatLng({x:pos[0]-this.pixelPos[0],y:pos[1]-this.pixelPos[1]});
},fromLatLngToDivPixel:function(pos){
return this.gmap.fromLatLngToDivPixel(pos);
},fromDivPixelToLatLng:function(pos){
return this.gmap.fromDivPixelToLatLng(pos);
},getBounds:function(){
if(this.getZoom()<=2){
var _46=this.gmap.getBounds();
return new GLatLngBounds(new GLatLng(_46.getSouthWest().lat(),-180),new GLatLng(_46.getNorthEast().lat(),180));
}else{
return this.gmap.getBounds();
}
},getClipBounds:function(){
var _47=this.gmap.getBounds();
var _48=_47.toSpan();
if(_48.lng()>179){
this.clipBounds=null;
}else{
var sw=_47.getSouthWest();
var ne=_47.getNorthEast();
var _4b=ne.lng()+_48.lng()*0.5;
var _4c=sw.lng()-_48.lng()*0.5;
var _4d=new GLatLng(sw.lat()-_48.lat()*0.5,_4c);
var _4e=new GLatLng(ne.lat()+_48.lat()*0.5,_4b);
this.clipBounds=new GLatLngBounds(_4d,_4e);
}
return this.clipBounds;
},getBoundsJSON:function(){
var _4f=this.getBounds();
var _50={sw:{y:_4f.getSouthWest().lat(),x:_4f.getSouthWest().lng()},ne:{y:_4f.getNorthEast().lat(),x:_4f.getNorthEast().lng()}};
return _50;
},getCenter:function(){
return this.gmap.getCenter();
},getZoom:function(){
return this.gmap.getZoom();
},getRelativeZoomLevel:function(_51){
var _52=_51-this.getZoom();
if(_52==0){
return "current";
}
if(_52>0){
return "+"+_52;
}
return _52;
},setCenter:function(_53,_54){
if(this.focusOffset){
this.gmap.setCenter(_53,_54);
var _55=this.fromLatLngToDivPixel(_53);
_55.x-=this.focusOffset[0];
_55.y-=this.focusOffset[1];
var _56=this.fromDivPixelToLatLng(_55);
this.gmap.setCenter(_56,_54);
}else{
this.gmap.setCenter(_53,_54);
}
},gotoMedia:function(id){
var _58=$O(id);
var _59=_58.getRefFromCache("mapobject");
this.setCenter(_59.get("location"),_59.get("viewZoomLevel"));
this.selectMapObject(_59.id);
},showBounds:function(_5a){
if(_5a.getCenter){
var _5b=this.gmap.getBoundsZoomLevel(_5a);
if(_5b>3){
_5b-=1;
}
if(_5b<2){
_5b=2;
}
this.setCenter(_5a.getCenter(),_5b);
}else{
this.logger.info("bounds.getCenter() is not a function - OK in offline version");
}
},showObjectBounds:function(_5c){
if(!_5c instanceof Array){
_5c=[_5c];
}
if(_5c.length==0){
}else{
if(_5c.length==1){
var obj=_5c[0];
if(obj instanceof Media){
obj=obj.getRefFromCache("mapobject");
}
if(obj.get("bounds")){
this.showBounds(obj.get("bounds"));
}else{
if(obj instanceof Line){
this.showBounds(obj.getBounds());
}else{
if(obj.get("location")){
this.setCenter(obj.get("location"),obj.get("viewZoomLevel"));
}
}
}
}else{
var _5e;
var _5f;
var _60;
for(var i=0;i<_5c.length;i++){
var obj=_5c[i];
if(obj instanceof Media){
obj=obj.getRefFromCache("mapobject");
}
if(obj!=null&&obj instanceof ContentObject){
if(obj.get("bounds")){
if(!_5e){
_5e=obj.get("bounds");
if(_5f){
_5e.extend(_5f);
_5f=null;
}
}else{
_5e.extend(obj.get("bounds").getSouthWest());
_5e.extend(obj.get("bounds").getNorthEast());
}
}else{
if(obj instanceof Line){
var a=obj.getStartPoint();
var b=obj.getEndPoint();
if(a&&b){
if(!_5e){
var sw=new GLatLng(Math.min(a.lat(),b.lat()),Math.min(a.lng(),b.lng()));
var ne=new GLatLng(Math.max(a.lat(),b.lat()),Math.max(a.lng(),b.lng()));
_5e=new GLatLngBounds(sw,ne);
if(_5f){
_5e.extend(_5f);
_5f=null;
}
}else{
_5e.extend(a);
_5e.extend(b);
}
}
}else{
if(obj.get("location")){
if(!_5e){
if(_5f){
var a=_5f;
var b=obj.get("location");
var sw=new GLatLng(Math.min(a.lat(),b.lat()),Math.min(a.lng(),b.lng()));
var ne=new GLatLng(Math.max(a.lat(),b.lat()),Math.max(a.lng(),b.lng()));
_5e=new GLatLngBounds(sw,ne);
_5f=null;
}else{
_5f=obj.get("location");
_60=obj.get("viewZoomLevel");
}
}else{
_5e.extend(obj.get("location"));
}
}
}
}
}
}
if(_5e){
this.showBounds(_5e);
}else{
if(_5f){
this.setCenter(_5f,_60);
}
}
}
}
},setToSatellite:function(){
this.gmap.setMapType(G_SATELLITE_TYPE);
},setToMap:function(){
this.gmap.setMapType(G_MAP_TYPE);
},setToHybrid:function(){
this.gmap.setMapType(G_HYBRID_TYPE);
},setToPhysical:function(){
this.gmap.setMapType(G_PHYSICAL_MAP);
},addSlotOverlays:function(_66){
Debug.addMessage("Map.addSlotOverlays()","MAP");
for(var i=0;i<_66.length;i++){
this.addSlotOverlay(_66[i]);
}
},addSlotOverlay:function(_68){
if(this.slotOverlays.indexOf(_68)>-1){
this.logger.warn("Object added a second time to SlotOverlays: "+_68.id);
return;
}
this.slotOverlays.push(_68);
_68.setMapPane(this);
this.gmap.addOverlay(_68);
},addTempOverlay:function(_69){
this.tempOverlays.push(_69);
_69.setMapPane(this);
this.gmap.addOverlay(_69);
},removeSlotOverlay:function(_6a){
this.gmap.removeOverlay(_6a);
var arr=[];
this.slotOverlays.each(function(_6c){
if(_6c!=_6a){
arr.push(_6c);
}
});
this.slotOverlays=arr;
},removeSlotOverlays:function(_6d){
for(var i=0;i<_6d.length;i++){
this.removeSlotOverlay(_6d[i]);
}
},removeTempOverlay:function(_6f){
if(this.queryOverlays.indexOf(_6f)==-1&&this.slotOverlays.indexOf(_6f)==-1){
this.gmap.removeOverlay(_6f);
}
var arr=[];
this.tempOverlays.each(function(_71){
if(_71!=_6f){
arr.push(_71);
}
});
this.tempOverlays=arr;
},clearSlotOverlays:function(){
this.slotOverlays.each(function(_72){
this.gmap.removeOverlay(_72);
}.bind(this));
this.slotOverlays=[];
},clearAllOverlays:function(){
this.clearSlotOverlays();
this.clearQueryOverlays();
},setOverlaysVisible:function(_73){
if(_73!=this.overlaysVisible){
this.overlaysVisible=_73;
if(_73){
this.mapMoved();
}else{
this.slotOverlays.each(function(_74){
this.gmap.removeOverlay(_74);
}.bind(this));
this.queryOverlays.each(function(_75){
this.gmap.removeOverlay(_75);
}.bind(this));
this.tempOverlays.each(function(_76){
this.gmap.removeOverlay(_76);
}.bind(this));
}
}
},synchronizeSlotOnMap:function(id,_78,_79,_7a,_7b){
this.removeMoveListener(this);
if(this.synchronizedHandlerObject){
var _7c=id;
if(isNaN(id)){
_7c=id.get("id");
}
if(_7c==this.synchronizedHandlerObject.get("id")&&_78==this.synchronizedSlot&&_79==this.synchronizedFilter){
return;
}
}
this.clearAllOverlays();
this.desynchronizeSlot();
maptales.service.doWithObject(id,function(_7d){
if(_7d instanceof SnapMapException){
}else{
this.synchronizedSlot=_78;
this.synchronizedHandlerObject=_7d;
this.synchronizedFilter=_79;
this.synchronizedHandlerObject.addSlotListener(_78,this.synchronizedFilter,null,this.boundSynchronizedSlotFunction);
this.updateSynchronizedSlot(_7a,_7b);
}
}.bind(this));
},updateSynchronizedSlot:function(_7e,_7f){
if(this.synchronizedHandlerObject){
this.synchronizedHandlerObject.getSlot(this.synchronizedSlot,this.synchronizedSlotOffset||0,this.synchronizedSlotSize||-1,this.synchronizedFilter,this.synchronizedSlotSort,function(_80){
if(_80 instanceof SnapMapException){
}else{
if(_80.parentId==this.synchronizedHandlerObject.id&&_80.slotName==this.synchronizedSlot){
if(_80.slotItems){
var _81=[];
this.synchronizedSlotTotalSize=_80.slotNum;
this.displayContextTemplate(this.slotTemplate);
for(var i=0;i<_80.slotItems.length;i++){
if(_80.slotItems[i] instanceof MapObject){
_81.push(_80.slotItems[i]);
}else{
if(_80.slotItems[i] instanceof Media){
try{
var _83=_80.slotItems[i].getRefFromCache("mapobject");
if(_83){
_81.push(_83);
}
}
catch(e){
this.logger.warn("mapobject not loaded nonlazy");
}
}else{
if(_80.slotItems[i] instanceof MapAddition){
var _83=_80.slotItems[i].getRefFromCache("media").getRefFromCache("mapobject");
if(_83){
_81.push(_83);
}
}else{
if(_80.slotItems[i] instanceof GroupAddition){
var _83=_80.slotItems[i].getRefFromCache("media").getRefFromCache("mapobject");
if(_83){
_81.push(_83);
}
}
}
}
}
}
if(_7f==true){
var _84=new Date().getTime();
this.showObjectBounds(_81);
this.logger.debug("showObjectBounds took: "+(new Date().getTime()-_84)+" ms");
}
for(var i=0;i<this.slotOverlays.length;i++){
if(_81.indexOf(this.slotOverlays[i])==-1){
this.removeQueryOverlay(this.slotOverlays[i]);
}
}
var _84=new Date().getTime();
for(var i=0;i<_81.length;i++){
this.addQueryOverlay(_81[i]);
}
this.logger.debug("adding objects took: "+(new Date().getTime()-_84)+" ms");
if(_7e instanceof Function){
_7e(_81);
}
}else{
this.logger.warn("MapGotInvalidReply: The reply did not have any slotItems");
}
}
}
}.bind(this));
}
},getSynchronizedSlotName:function(){
return this.synchronizedSlot;
},getSynchronizedHandler:function(){
return this.synchronizedHandlerObject;
},desynchronizeSlot:function(){
if(this.synchronizedHandlerObject){
this.synchronizedHandlerObject.removeSlotListener(this.synchronizedSlot,this.synchronizedFilter,null,this.boundSynchronizedSlotFunction);
this.synchronizedHandlerObject=null;
}
this.synchronizedSlot=null;
this.clearSlotOverlays();
},addToSynchronizedSlot:function(_85,_86){
if(this.synchronizedSlot!=null&&this.synchronizedHandlerObject!=null){
var _87=_85.getSlotFromCache("medias",0,-1);
if(_87&&_87.length>0){
if(this.synchronizedHandlerObject instanceof Story){
for(var i=0;i<_87.length;i++){
_87[i].set("story",this.synchronizedHandlerObject);
}
}
this.synchronizedHandlerObject.addToSlot(this.synchronizedSlot,_87,false);
}
maptales.service.store(_85,function(_89){
if(_89 instanceof SnapMapException){
this.synchronizedHandlerObject.removeFromSlot(this.synchronizedSlot,_85,false);
this.logger.warn("MapStoreException: could not store mapobjects");
}else{
if(this.synchronizedHandlerObject instanceof Story){
for(var i=0;i<_87.length;i++){
_87[i].set("mapobject",_85);
this.synchronizedHandlerObject.notifySlotListeners(this.synchronizedSlot,null,null);
if(_87[i].id>0){
_87[i].persist();
}
}
}
this.synchronizedHandlerObject.clean();
}
if(_86){
_86(_89);
}else{
this.logger.warn("callback is not defined");
}
}.bind(this));
}else{
maptales.service.store(_85,function(_8b){
if(_8b instanceof SnapMapException){
this.logger.warn("MapStoreException: could not store mapobjects");
}
if(_86){
_86(_8b);
}
});
}
},registerMoveListener:function(_8c){
AssertInstanceOf(Function,_8c.onMapMove,"MapListenerError","The class you passed cant be a listener, since it does not implement the interface function onMapMove");
this.moveListeners.push(_8c);
},removeMoveListener:function(_8d){
this.moveListeners.removeEntry(_8d);
},notifyMoveListeners:function(){
for(var i=0;i<this.moveListeners.length;i++){
try{
this.moveListeners[i].onMapMove();
}
catch(e){
this.getApplication().addException(new SnapMapException("MapMoveListenerError","Error while calling moveListeners in map",e));
}
}
},mapMoved:function(){
if(this.queryModeEnabled&&(this.locally==true)){
this.search();
}
this.logger.debug("mapMoved()");
this.hideMarkerInfo();
if(this.overlaysVisible){
for(var i=0;i<this.slotOverlays.length;i++){
if(!this.slotOverlays[i].isOnMap()){
this.gmap.addOverlay(this.slotOverlays[i]);
}else{
if(this.lastZoom==this.getZoom()){
this.slotOverlays[i].redraw(true);
}
}
}
for(var i=0;i<this.queryOverlays.length;i++){
if(!this.queryOverlays[i].isOnMap()){
this.gmap.addOverlay(this.queryOverlays[i]);
}else{
if(this.lastZoom==this.getZoom()){
this.queryOverlays[i].redraw(true);
}
}
}
for(var i=0;i<this.tempOverlays.length;i++){
if(!this.tempOverlays[i].isOnMap()){
this.gmap.addOverlay(this.tempOverlays[i]);
}else{
if(this.lastZoom==this.getZoom()){
this.tempOverlays[i].redraw(true);
}
}
}
}
this.lastZoom=this.getZoom();
this.notifyMoveListeners();
},show:function(_90,_91){
if(!_90){
return;
}
this.forceLineDrawing=true;
var _92=$O(_90);
if(_92 instanceof Media){
try{
_92=_92.getRefFromCache("mapobject");
}
catch(e){
return;
}
if(_92==null){
return;
}
}
if(_92 instanceof Story){
this.showStory(_92);
}else{
if(_92 instanceof Marker){
_92.setHighlighted(false);
var _93=_91?_92.get("definitionZoomLevel"):_92.get("viewZoomLevel");
if(_93==this.gmap.getZoom()||this.lockZoom){
this.panTo(_92.get("location"));
}else{
this.panTo(_92.get("location"));
}
this.addQueryOverlay(_92);
}else{
if(_92 instanceof Line){
this.setForceLineDrawing(true);
_92.setHighlighted(false);
var _93=_91?_92.get("definitionZoomLevel"):_92.get("viewZoomLevel");
if(this.tracedLine!=null){
this.gmap.setZoom(_93);
}else{
this.setCenter(_92.getBounds().getCenter(),this.gmap.getBoundsZoomLevel(_92.getBounds()));
}
this.addQueryOverlay(_92);
}else{
if(_92 instanceof Snapshot){
this.setMapMode(_92.get("mapMode"));
this.setCenter(_92.get("center"),_92.get("zoomLevel"));
}
}
}
}
},showStory:function(_94,_95){
this.setMapMode(_94.get("mapMode"));
var _96=this.mapModeListener.bind(this);
_94.addFieldListener("mapMode",_96);
var _97=true;
if(_95){
_97=false;
}
this.synchronizeSlotOnMap(_94,"medias",null,null,_97);
},showMap:function(map){
this.setMapMode(map.get("mapMode"));
var _99=this.mapModeListener.bind(this);
map.addFieldListener("mapMode",_99);
this.synchronizeSlotOnMap(map,"mapAdditions",null,null,true);
},mapModeListener:function(_9a,_9b){
this.setMapMode(_9a);
},traceLine:function(_9c,_9d,_9e,_9f){
if(this.tracedLine!=null&&this.tracedLine!=_9c){
this.stopTraceLine();
}
this.tracedLine=_9c;
this.traceLineReverse=_9d;
this.traceLineCallback=_9e;
this.traceMoveHandler=GEvent.addListener(this.gmap,"moveend",function(){
window.setTimeout(this.continueTraceLine.bind(this),500);
}.bind(this));
this.traceDownHandler=GEvent.addListener(this.gmap,"click",this.stopTraceLine.bind(this));
this.traceDragHandler=GEvent.addListener(this.gmap,"dragstart",this.stopTraceLine.bind(this));
this.lineButtons.hideAll();
var _a0=this.tracedLine.getClipPoints(this.getBounds());
if(!_a0[4][0]){
this.panTo(this.tracedLine.getStartPoint());
}else{
if(_9f){
window.setTimeout(this.continueTraceLine.bind(this),_9f);
}else{
this.continueTraceLine();
}
}
},continueTraceLine:function(){
if(!this.tracedLine){
return;
}
var _a1=this.tracedLine.getClipPoints(this.getBounds());
if(this.traceLineReverse){
var _a2=_a1[4][0];
}else{
var _a2=_a1[4][1];
}
this.panTo(this.fromDivPixelToLatLng(_a2));
if(_a2.clipDir&&_a2.clipDir>0){
}else{
var _a3=this.traceLineCallback;
this.stopTraceLine();
}
},stopTraceLine:function(){
if(this.traceMoveHandler){
GEvent.removeListener(this.traceMoveHandler);
}
if(this.traceDownHandler){
GEvent.removeListener(this.traceDownHandler);
}
if(this.traceDragHandler){
GEvent.removeListener(this.traceDragHandler);
}
this.traceDownHandler=null;
this.traceMoveHandler=null;
this.traceDragHandler=null;
this.traceLineCallback=null;
this.tracedLine=null;
},setMapObjectHighlighted:function(_a4,_a5){
this.logger.debug("setMapObjectHighlighted() id: "+_a4+" value: "+_a5);
var _a6=$O(_a4);
if(_a6 instanceof MapObject){
if(_a5){
if(!_a6.isHighlighted()){
if(this.queryOverlays.indexOf(_a6)==-1&&this.slotOverlays.indexOf(_a6)==-1){
this.addTempOverlay(_a6);
}
_a6.setHighlighted(true);
_a6.redraw(true);
}
}else{
if(_a6.isHighlighted()){
_a6.setHighlighted(false);
if(this.tempOverlays.indexOf(_a6)>-1&&this.queryOverlays.indexOf(_a6)==-1&&this.slotOverlays.indexOf(_a6)==-1){
this.removeTempOverlay(_a6);
}else{
_a6.redraw(true);
}
}
}
}
},getSelectedObject:function(){
return this.selectedMapObject;
},selectMapObject:function(id){
this.logger.debug("selectMapObject() id: "+id);
this.stopTraceLine();
if(this.selectedMapObject){
this.selectedMapObject.setSelected(false);
if(this.selectedMapObject.isOnMap()){
this.selectedMapObject.redraw(true);
}
}
if(!id){
this.selectedMapObject=null;
return;
}
var _a8=$O(id);
if(_a8 instanceof MapObject){
this.selectedMapObject=_a8;
this.selectedMapObject.setSelected(true);
if(this.selectedMapObject.isOnMap()){
this.selectedMapObject.redraw(true);
}
}
},deselectAll:function(){
if(this.selectedMapObject){
this.selectedMapObject.setSelected(false);
}
},markerClick:function(id){
try{
maptales.service.getSlot({id:id,slotName:"medias",offset:0,size:1},function(_aa){
if(_aa.slotItems){
var _ab=_aa.slotItems[0];
var _ac={};
if(this.queryModeEnabled){
if(this.query&&this.query.parameters){
_ac=this.query.parameters;
}
_ac.contextObject=_ab.id;
}else{
_ac.contextObject=_ab.id;
if(this.getSynchronizedHandler()!=null){
_ac.parentId=this.getSynchronizedHandler().id;
}
}
this.getApplication().onMapItemClick(_ac);
}
}.bind(this));
}
catch(e){
this.logger.warn("Error propagation markerClick to ContentPanel",e);
}
},updateLoading:function(_ad){
if(_ad){
this.showLoading();
}else{
this.hideLoading();
}
},showLoading:function(){
try{
Element.show(this.getElement("loading"));
}
catch(e){
}
},hideLoading:function(){
try{
Element.hide(this.getElement("loading"));
}
catch(e){
}
},displayBounds:function(_ae,_af){
var _b0=new RectangleArea(_ae,_af);
this.gmap.addOverlay(_b0);
if(!this.areas){
this.areas=[];
}
this.areas.push(_b0);
},clearAllBounds:function(){
for(var i=0;i<this.areas.length;i++){
this.gmap.removeOverlay(this.areas[i]);
}
this.areas=[];
},zoomToLine:function(_b2){
try{
var _b3=_b2.getRefFromCache("startMarker").get("location");
}
catch(e){
var _b3=convertPoint(_b2.get("controlpoints")[0]);
}
try{
var _b4=_b2.getRefFromCache("endMarker").get("location");
}
catch(e){
var _b4=convertPoint(_b2.get("controlpoints").last());
}
var _b5=(_b4.lng()-_b3.lng()<0)?_b4.lng():_b3.lng();
var _b6=(_b4.lng()-_b3.lng()<0)?_b3.lng():_b4.lng();
var sw=new GLatLng(Math.min(_b3.lat(),_b4.lat()),_b5);
var ne=new GLatLng(Math.max(_b3.lat(),_b4.lat()),_b6);
var _b9=new GLatLngBounds(sw,ne);
this.showBounds(_b9);
},panToLine:function(_ba){
try{
var pos=_ba.getRefFromCache("startMarker").get("location");
}
catch(e){
var pos=convertPoint(_ba.get("controlpoints")[0]);
}
this.panTo(pos);
},displayMarkerInfo:function(_bc){
if(!this.doDisplayMarkerInfo){
return;
}
if(_bc&&!_bc.isSelected()){
var pos=Position.cumulativeOffset(_bc.container);
if(this.markerInfoContainer.parentNode){
var _be=Position.cumulativeOffset(this.markerInfoContainer.parentNode);
pos[0]=pos[0]-_be[0];
pos[1]=pos[1]-_be[1];
}
if(_bc instanceof Marker){
var _bf=Element.getDimensions(_bc.getImageDiv()).width;
var _c0=Element.getDimensions(_bc.getImageDiv()).height;
_c0=_c0+Element.getDimensions(this.markerInfoContainer).height;
this.markerInfoContainer.style.top=(pos[1]-_c0-2)+"px";
this.markerInfoContainer.style.left=(pos[0]+_bf+2)+"px";
this.markerInfoWidget.setContextObject(null);
this.markerInfoWidget.display();
this.markerInfoContainer.style.visibility="visible";
_bc.getSlot("medias",0,1,null,null,function(_c1){
if(_c1 instanceof SnapMapException){
}else{
var _c2=_c1.slotItems[0];
this.markerInfoWidget.setContextObject(_c2);
this.markerInfoWidget.numItems=_c1.slotNum;
this.markerInfoWidget.display();
}
}.bind(this));
}else{
if(_bc instanceof Cluster){
var _bf=Element.getDimensions(_bc.getBoundsDiv()).width;
var _c0=Element.getDimensions(_bc.getBoundsDiv()).height;
_c0=_c0+Element.getDimensions(this.markerInfoContainer).height;
this.markerInfoContainer.style.top=(pos[1]-_c0)+"px";
this.markerInfoContainer.style.left=(pos[0]+_bf)+"px";
this.markerInfoWidget.setContextObject(_bc);
this.markerInfoWidget.display();
this.markerInfoContainer.style.visibility="visible";
}
}
}else{
this.hideMarkerInfo();
}
},hideMarkerInfo:function(){
if(this.markerInfoContainer){
this.markerInfoContainer.style.visibility="hidden";
this.markerInfoContainer.style.top="0px";
this.markerInfoContainer.style.left="0px";
}
},setHeight:function(_c3){
this.setHeightTemp(_c3);
this.gmap.checkResize();
this.mapMoved();
},setHeightTemp:function(_c4){
if(_c4<50){
_c4=50;
}
$("map").style.height=_c4+"px";
},handleBubbleAction:function(_c5){
this.logger.debug("handleBubbleAction() action: "+_c5.getType());
switch(_c5.getType()){
case "storeSnapshot":
_c5.cancelPropagation=true;
_c5.parameters["center"]=this.gmap.getCenter();
_c5.parameters["zoomLevel"]=this.gmap.getZoom();
_c5.parameters["mapMode"]=this.getMode();
this.getApplication().service.store(_c5.parameters,function(_c6){
if(_c6 instanceof SnapMapException){
_c5.callback(_c6);
}else{
Dialog.closeAll();
}
});
break;
case "searchClicked":
_c5.parameters={searchString:this.getField("search").value};
this.getField("search").value=escapeSearchString(_c5.parameters.searchString);
break;
case "store":
if(_c5.parameters.objectToStore instanceof MapObject){
_c5.cancelBubble=true;
var _c7=_c5.parameters.objectToStore;
this.store(_c7,_c5.callback);
}
break;
case "deleteMarkerConfirmed":
var _c8=_c5.parameters.marker;
this.removeQueryOverlay(_c8);
_c5.cancelBubble=true;
var _c9=this.getSynchronizedHandler();
_c8.getSlot("medias",0,-1,null,null,function(_ca){
if(_ca instanceof SnapMapException){
}else{
for(var i=0;i<_ca.slotItems.length;i++){
_ca.slotItems[i].set("mapobject",null);
}
if(_c9 instanceof Story){
var _cc=this.getSynchronizedSlotName();
_c9.removeFromSlot(_cc,_ca.slotItems);
maptales.service.persist(_c9,function(_cd){
if(_cd instanceof SnapMapException){
}
});
}
}
}.bind(this));
maptales.service.deleteById({id:_c8.id,recursive:_c5.parameters.recursion},function(_ce){
if(_ce instanceof SnapMapException){
this.addOverlay(_c8);
}
}.bind(this));
break;
case "removeMarkerConfirmed":
var _c8=_c5.parameters.marker;
this.removeQueryOverlay(_c8);
_c5.cancelBubble=true;
var _c9=this.getSynchronizedHandler();
var _cf=this.getSynchronizedSlotName();
_c8.getSlot("medias",0,-1,null,null,function(_d0){
_c9.removeFromSlot(_cf,_d0.slotItems);
maptales.service.persist(_c9,function(_d1){
if(_d1 instanceof SnapMapException){
}
});
}.bind(this));
break;
default:
break;
}
},storySelect:function(id){
var _d3=$O(id);
var _d4=_d3.getRefId("mapobject");
if(_d4!=null){
var _d5=this.selectedMapObject;
this.selectMapObject(_d4);
if(this.panSmoothly&&_d5){
if(this.selectedMapObject instanceof Line){
var _d6=false;
if(_d5&&_d5 instanceof Marker&&this.selectedMapObject.getRefFromCache("endMarker")==_d5){
_d6=true;
}
this.traceLine(this.selectedMapObject,_d6,function(){
},1000);
}else{
this.show(_d4);
}
}else{
this.show(_d4);
}
}
},toggleSnapshotsMenu:function(){
this.logger.error("toggleSnapshotsMenu (appears in pop-up and in server log)");
if(!this.snapshotsMenuVisible){
this.snapshotsMenuVisible=true;
if(!this.snapshotsMenu){
this.snapshotsMenu=new SlotWidget(this.getElement("snapshotsMenu"),this,this.getApplication().getCurrentUser(),null,"slotPanel/snapshotsMenu",{numDisplayedItems:50,sort:"title asc",fieldName:"snapshots"});
}else{
this.snapshotsMenu.display();
}
var _d7=Position.cumulativeOffset(this.getElement("toggleSnapshotsMenu"));
this.getElement("snapshotsMenu").style.left=(_d7[0]-20)+"px";
this.getElement("snapshotsMenu").style.display="block";
}else{
this.snapshotsMenuVisible=false;
this.getElement("snapshotsMenu").style.display="none";
}
},showAllMapObjects:function(){
this.showObjectBounds(this.slotOverlays);
},snapshotMenuClicked:function(_d8){
this.snapshotsMenuVisible=false;
this.getElement("snapshotsMenu").style.display="none";
this.show(_d8);
},highlightSnapshot:function(_d9){
var obj=$O(_d9);
if(obj instanceof Snapshot){
this.displayBounds(obj.get("center"),obj.get("zoomLevel"));
}
},clearSnapshot:function(){
this.clearAllBounds();
},zoomToItem:function(_db){
this.show(_db);
},zoomTo:function(_dc){
var _dd=parseInt(_dc);
if(_dd<=2){
_dd=2;
}
if(_dd!=this.gmap.getZoom()){
this.gmap.setZoom(_dd);
}
},zoomIn:function(_de){
if(_de){
this.zoomTo(this.getZoom()+_de);
}else{
this.gmap.zoomIn();
}
},zoomOut:function(_df){
if(_df){
this.zoomTo(this.getZoom()-_df);
}else{
if(this.gmap.getZoom()>2){
try{
this.gmap.zoomOut();
}
catch(e){
this.mapMoved();
this.logger.warn("MapError> Map.js:310 -- strange but harmless(?)",e);
}
}
}
},zoomToLocation:function(_e0){
var _e1=new GLatLng(_e0.lat,_e0.lng);
if(!_e0.zoomLevel||_e0.zoomLevel==this.getZoom()){
this.panTo(_e1);
}else{
this.setCenter(_e1,_e0.zoomLevel);
}
},panToItem:function(id){
var _e3=$O(id);
if(_e3 instanceof Media){
this.panToItem(_e3.getRefId("mapobject"));
}else{
if(_e3 instanceof Marker){
this.panTo(_e3.get("location"));
}else{
if(_e3 instanceof Line){
this.panToLine(_e3);
}
}
}
},panTo:function(_e4){
if(this.focusOffset){
var _e5=this.fromLatLngToDivPixel(_e4);
_e5.x-=this.focusOffset[0];
_e5.y-=this.focusOffset[1];
var _e6=this.fromDivPixelToLatLng(_e5);
this.gmap.panTo(_e6);
}else{
this.gmap.panTo(_e4);
}
},highlight:function(_e7){
var _e8=$O(_e7);
if(_e8==null){
return;
}
if(_e8 instanceof Media&&_e8.getRefId("mapobject")){
this.setMapObjectHighlighted(_e8.getRefId("mapobject"),true);
}else{
if(_e8 instanceof MapObject){
this.setMapObjectHighlighted(_e8,true);
}else{
this.logger.error("passed an item to highlight that was neither media nor mapobject");
}
}
},clearHighlight:function(_e9){
var _ea=$O(_e9);
if(_ea==null){
return;
}
if(_ea instanceof Media&&_ea.getRefId("mapobject")){
this.setMapObjectHighlighted(_ea.getRefId("mapobject"),false);
}else{
if(_ea instanceof MapObject){
this.setMapObjectHighlighted(_ea,false);
}else{
this.logger.error("passed an item to clearHighlight that was neither media nor mapobject");
}
}
},clearAllHighlights:function(){
},select:function(_eb){
this.selectMapObject(_eb);
this.panToItem(_eb);
},hideOverlays:function(){
},showOverlays:function(){
},refresh:function(){
},clear:function(){
},showAllItems:function(){
},showEarth:function(){
this.setCenter(new GLatLng(34,21.5),2);
},showGeocode:function(_ec){
var _ed=[3,4,6,9,12,13,15,16,17];
this.setCenter(new GLatLng(_ec.lat,_ec.lng),_ed[_ec.accuracy]);
},setMapMode:function(_ee){
if(this.mapMode!=_ee){
if(_ee==MapWidget.SATELLITE_MODE){
this.setToSatellite();
}else{
if(_ee==MapWidget.MAP_MODE){
this.setToMap();
}else{
if(_ee==MapWidget.HYBRID_MODE){
this.setToHybrid();
}
}
}
this.mapMode=_ee;
}
},getMode:function(){
return this.mapMode;
},decreaseMapHeight:function(){
this.setHeight(Element.getHeight(this._container)-100);
},increaseMapHeight:function(){
this.setHeight(Element.getHeight(this._container)+100);
},toggleZoomBox:function(){
var _ef=this.getElement("zoomBoxButton");
if(this.zoomBox.active){
_ef.className="zoombox";
}else{
_ef.className="zoomboxActive";
}
this.zoomBox.setActive(!this.zoomBox.active);
},zoomBoxDisabled:function(){
var _f0=this.getElement("zoomBoxButton");
if(_f0){
_f0.className="zoombox";
}
},zoomBoxEnabled:function(){
var _f1=this.getElement("zoomBoxButton");
if(_f1){
_f1.className="zoomboxActive";
}
},toggleOverlays:function(){
this.setOverlaysVisible(!this.overlaysVisible);
},closeMap:function(){
},openMap:function(){
},setClustered:function(_f2){
var _f3=this.query.copy();
_f3.parameters.clustered=_f2;
if(_f2==false){
_f3.parameters.offset=0;
_f3.parameters.size=20;
_f3.parameters.locally=this.locally;
}else{
_f3.parameters.offset=null;
_f3.parameters.size=null;
_f3.parameters.locally=true;
}
this.setToQueryMode(_f3);
},nextPage:function(){
var _f4=this.query.copy();
_f4.parameters.offset=this.offset+this.size;
this.setToQueryMode(_f4);
},prevPage:function(){
var _f5=this.query.copy();
_f5.parameters.offset=this.offset-this.size;
this.setToQueryMode(_f5);
},nextSlotPage:function(){
var _f6=this.synchronizedSlotOffset+this.synchronizedSlotSize;
if(_f6<this.synchronizedSlotTotalSize){
this.synchronizedSlotOffset=_f6;
}
this.updateSynchronizedSlot(null,true);
},prevSlotPage:function(){
var _f7=this.synchronizedSlotOffset-this.synchronizedSlotSize;
if(_f7>0){
this.synchronizedSlotOffset=_f7;
}else{
this.synchronizedSlotOffset=0;
}
this.updateSynchronizedSlot(null,true);
},setLocally:function(_f8){
this.locally=_f8;
var _f9=this.query.copy();
_f9.parameters.locally=this.locally;
_f9.parameters.offset=0;
this.setToQueryMode(_f9);
},setSorting:function(_fa){
this.sorting=_fa;
var _fb=this.query.copy();
_fb.parameters.sorting=this.sorting;
this.setToQueryMode(_fb);
}});
maptales.widgets["Map"]=MapWidget;

var UIAdapter={};
UIAdapter={getLabel:function(_1,_2){
if(!isNaN(_1)){
_1=$O(_1);
}
if(_1 instanceof ContentObject){
if(_1 instanceof Marker){
return _1.get("title")||"no title";
}
if(_1 instanceof Line){
return "Line"||"no title";
}
if(_1 instanceof Snapshot){
return _1.get("title")||"no title";
}
if(_1 instanceof User){
return _1.get("name")||"no title";
}
if(_1 instanceof Picture){
return _1.get("title")||"no name";
}
if(_1 instanceof Audio){
return _1.get("title")||"Untitled Audio";
}
if(_1 instanceof Post){
return _1.get("title")||_2;
}
if(_1 instanceof Comment){
return _1.get("title")||"no title";
}
if(_1 instanceof Tag){
return _1.get("tag")||"no tag name";
}
if(_1 instanceof Group){
return _1.get("name")||"no title";
}
if(_1 instanceof Map){
return _1.get("title")||"no title";
}
if(_1 instanceof Story){
return _1.get("title")||"no title";
}
if(_1 instanceof Video){
return _1.get("title")||"no title";
}
if(_1 instanceof FeedItem){
return _1.get("title")||"no title";
}
if(_1 instanceof Feed){
return _1.get("title")||"no title";
}
}else{
return _2;
}
},getPathIcon:function(_3){
if(_3=="User"){
return "buddy_path.gif";
}
if(_3=="Group"){
return "group_path.gif";
}
if(_3=="Map"){
return "map_path.gif";
}
if(_3=="Tag"){
return "tag.gif";
}
if(_3=="Marker"){
return "imageMarker_path.gif";
}
if(_3=="Image"){
return "image_path.gif";
}
if(_3=="Post"){
return "post_path.gif";
}
if(_3=="Audio"){
return "audio_path.gif";
}
if(_3=="Story"){
return "story_path.gif";
}
if(_3=="Snapshot"){
return "snapshot_path.gif";
}
return "tag.gif";
},getDescription:function(_4){
if(_4 instanceof Marker){
return _4.get("location");
}
if(_4 instanceof User){
return _4.get("description");
}
if(_4 instanceof Picture){
return _4.get("description");
}
if(_4 instanceof Post){
return _4.get("text");
}
if(_4 instanceof Audio){
return _4.get("text");
}
if(_4 instanceof Comment){
return _4.get("text");
}
if(_4 instanceof Tag){
return _4.get("tag");
}
if(_4 instanceof Map){
return _4.get("description");
}
if(_4 instanceof Story){
return _4.get("text");
}
if(_4 instanceof FeedItem){
return _4.get("text")||"no text";
}
if(_4 instanceof Feed){
return _4.get("text")||"no text";
}
return false;
},getIcon:function(_5){
if(_5 instanceof Marker){
return _5.getSquareImageURL()||false;
}
if(_5 instanceof User){
return _5.getSquareImageURL()||false;
}
if(_5 instanceof Picture){
return _5.getSquareImageURL()||false;
}
if(_5 instanceof Post){
return _5.getSquareImageURL()||false;
}
if(_5 instanceof Audio){
return _5.getSquareImageURL()||false;
}
if(_5 instanceof Comment){
return _5.getSquareImageURL()||false;
}
if(_5 instanceof Tag){
return _5.getSquareImageURL()||false;
}
if(_5 instanceof Video){
return _5.get("thumb1")||false;
}
if(_5 instanceof Map){
return _5.getSquareImageURL()||false;
}
if(_5 instanceof Story){
return _5.getSquareImageURL()||false;
}
if(_5 instanceof Snapshot){
return false;
}
if(_5 instanceof FeedItem){
return _5.getSquareImageURL()||false;
}
if(_5 instanceof Feed){
return _5.getSquareImageURL()||false;
}
}};

var DataField=Class.create();
Object.extend(Object.extend(DataField.prototype,Widget.prototype),{logger:maptales.getLogger("com.maptales.webclient.widgets.datafield"),initialize:function(_1,_2,_3,_4,_5,_6,_7){
this.container=_1;
this.contextObject=_3;
this.parent=_2;
this.fieldName=_6.fieldName;
this.boundUpdateFunction=this._update.bind(this);
this.displayEditOnInit=_6.displayEdit||false;
this.logger.debug("init Datafield contextObject: "+_3+" fieldName: "+this.fieldName);
if(!isNaN(_3)){
maptales.service.getById(_3,function(_8){
if(_8 instanceof SnapMapException){
this.logger.error("Datafield could not get contextObject: "+_3);
}else{
this.contextObject=_8;
this.initDatafield(_6);
}
}.bind(this));
}else{
this.initDatafield(_6);
}
},initDatafield:function(_9,_a,_b){
var _c={};
_c["editable"]=this.contextObject.isFieldEditable(this.fieldName);
_c["type"]=this.contextObject.getFieldType(this.fieldName);
_c["options"]=this.contextObject.getFieldOptions(this.fieldName);
_c["defaultOption"]=this.contextObject.getFieldDefaultOption(this.fieldName);
Object.extend(_c,_9);
this.parameters=_c;
this.valueTemplate="datafield/"+(this.parameters.valueTemplate||"datafield");
this.editTemplate=this.parameters.editTemplate;
this.initializeWidget(this.container,this.parent,this.contextObject,_a,this.valueTemplate,this.parameters,_b);
if(this.parameters.editable==false||this.parameters.editable=="false"){
this.editable=false;
}else{
this.editable=true;
}
this.emptyString=this.parameters.emptyString||"no text";
this.emptyEditString=this.parameters.emptyEditString||"click here to enter text";
this.emptyEditString="<em>"+this.emptyEditString+"</em>";
this.indexElement=this.parameters.indexElement||null;
if(this.parameters.render==false||this.parameters.render=="false"){
this.renderOnInit=false;
}else{
this.renderOnInit=true;
}
if(!this.editTemplate){
if(this.parameters.type==Field.STRING||this.parameters.type==Field.EMAIL){
this.editTemplate="inputField";
this.parameters.inputType="inputField";
}else{
if(this.parameters.type==Field.BOOLEAN){
this.editTemplate="boolean";
this.parameters.inputType="boolean";
}else{
if(this.parameters.type==Field.TEXT){
this.editTemplate="textArea";
this.parameters.inputType="textArea";
}else{
if(this.parameters.type==Field.DATE){
this.editTemplate="date";
this.parameters.inputType="date";
}else{
if(this.parameters.type==Field.OPTION){
this.editTemplate="option";
this.parameters.inputType="option";
}else{
if(this.parameters.type==Field.ZOOMLEVEL){
this.parameters.inputType="ZoomLevel";
}
}
}
}
}
}
}
this.editTemplate="datafield/"+this.editTemplate;
this.type=this.contextObject.getFieldType(this.fieldName);
if(this.type==null){
this.type="string";
}
this.setValue(this.contextObject.get(this.fieldName));
this.addListener();
if(this.renderOnInit){
if(this.displayEditOnInit){
this.display(this.editTemplate);
}else{
this.display();
}
}
},addListener:function(){
this.contextObject.addFieldListener(this.fieldName,this.boundUpdateFunction);
if(this.type==Field.ZOOMLEVEL){
maptales.ui.getMainMap().registerMoveListener(this);
}
},removeListener:function(){
if(this.contextObject instanceof ContentObject){
this.contextObject.removeFieldListener(this.fieldName,this.boundUpdateFunction);
}
if(this.type==Field.ZOOMLEVEL){
maptales.ui.getMainMap().removeMoveListener(this);
}
},onMapMove:function(){
this.update();
},isEditable:function(){
if(this.editable==false){
return false;
}
return this.contextObject.checkRights("edit");
},getHandler:function(){
return this.contextObject;
},getFieldName:function(){
return this.fieldName;
},getValue:function(){
this.logger.debug("GetValue called");
if(this.indexElement){
this.logger.debug("GetValue returns with indexElement: "+this.value[this.indexElement]);
return this.value[this.indexElement];
}else{
this.logger.debug("GetValue returns: "+this.value);
if(typeof this.value=="string"){
return this.value;
}
if(this.value==0){
return "0";
}
return this.value;
}
},setValue:function(_d){
if(this.indexElement){
this.logger.debug("SetValue with indexElement called with: "+_d[this.indexElement]);
if(this.value==null){
this.value={};
}
this.value[this.indexElement]=_d[this.indexElement];
}else{
this.logger.debug("SetValue called with: "+_d);
this.value=_d;
}
},getSelectedOptionName:function(){
for(var i=0;i<this.parameters.options.length;i++){
if(this.parameters.options[i].value==this.getValue()){
return this.parameters.options[i].name;
}
}
},addConstrain:function(_f){
this._constraints.push(_f);
},checkConstrains:function(){
},_onSubmit:function(_10){
if(_10 instanceof SnapMapException){
}else{
}
},_update:function(){
this.setValue(this.contextObject.get(this.fieldName));
this.display();
},onSubmit:function(_11){
},onUpdate:function(_12){
},onCancel:function(){
},onMakeEditable:function(){
},onMakeStatic:function(){
},onDisplay:function(){
var _13=document.getElementsByAttribute("inputfocus",this.container);
if(_13[0]&&_13[0].focus){
_13[0].focus();
}
},destroy:function(){
this.destroySubwidgets();
this.removeListener();
},storeValue:function(_14){
var _15=this.getValue();
this.setValue(_14);
this.contextObject.set(this.fieldName,this.getValue(),this._onSubmit.bind(this));
this.contextObject.persist(function(_16){
if(_16 instanceof SnapMapException){
this.setValue(_15);
this.display(this.valueTemplate);
Dialog.toggle("Error Storing New Value",this,null,"dialog/ErrorDialog",{message:"There has been an error storing the new value."},this.getContainer(),Dialog.NORTH);
}else{
if(_16 instanceof SnapMapFormException){
this.setValue(_15);
this.display(this.valueTemplate);
Dialog.toggle("Error Storing New Value",this,null,"dialog/ErrorDialog",{message:_16.getMessage()},this.getContainer(),Dialog.NORTH);
}
}
}.bind(this));
window.setTimeout(function(){
this.display(this.valueTemplate);
}.bind(this),20);
},handleBubbleAction:function(_17){
if(_17.getType()=="makeEditable"){
_17.cancelBubble=true;
if(this.editable==false){
return;
}
if(this.contextObject.checkRights("edit")){
this.display(this.editTemplate);
}
}else{
if(_17.getType()=="submit"){
Dialog.closeAll();
_17.cancelBubble=true;
var _18=null;
if(this.parameters.inputType=="date"){
var _19=this.getElement("hour").value;
var _1a=this.getElement("minute").value;
var day=this.getElement("day").value;
var _1c=this.getElement("month").value;
var _1d=this.getElement("year").value;
_18=new Date(_1d,_1c-1,day,_19,_1a,0);
}else{
if(this.parameters.inputType=="radio"){
_18=this.getField("radioGroup").value;
}else{
if(this.parameters.inputType=="option"){
var _1e=this.getField("option");
_18=_1e.options[_1e.selectedIndex].value;
}else{
if(this.parameters.type==Field.BOOLEAN){
var _1e=this.getField("option");
_18=_1e.options[_1e.selectedIndex].value;
}else{
if(this.parameters.inputType=="ZoomLevel"){
_18=maptales.ui.getMainMap().getZoom();
}else{
_18=this.getElement("dataFieldInput").value;
}
}
}
}
}
this.storeValue(_18);
}else{
if(_17.getType()=="set"){
_17.cancelBubble=true;
this.storeValue(_17.parameters.value);
}else{
if(_17.getType()=="setAndReloadPage"){
_17.cancelBubble=true;
this.storeValue(_17.parameters.value);
$a("reloadPage",null,null,this.container);
}else{
if(_17.getType()=="publish"){
_17.cancelBubble=true;
this.storeValue(RIGHT_PUBLIC);
}else{
if(_17.getType()=="cancel"){
_17.cancelBubble=true;
Dialog.closeAll();
this.display(this.valueTemplate);
}
}
}
}
}
}
}});
maptales.widgets["Datafield"]=DataField;

var Reference=Class.create();
Object.extend(Object.extend(Reference.prototype,Widget.prototype),{logger:maptales.getLogger("com.maptales.webclient.widgets.reference"),initialize:function(_1,_2,_3,_4,_5,_6,_7){
this._widgetParent=_2;
this._container=_1;
this._fieldName=_6.fieldName;
this.parameters=_6||{};
this.contextObject={};
this.referencedObject={};
this.templatePath=_5;
this.boundUpdateFunction=this.update.bind(this);
this.initializeWidget(this._container,_2,_3,_4,this.templatePath,_6,_7);
this.getApplication().service.getById(_3,function(_8){
if(_8 instanceof SnapMapException){
}else{
this.contextObject=_8;
if(this._fieldName){
this.referencedId=this.contextObject.getRefId(this._fieldName);
this.addListener();
this.loadReference(this.displayReference.bind(this));
}else{
this.referencedObject=this.contextObject;
this.displayReference();
}
}
}.bind(this));
},addListener:function(){
if(this.contextObject){
this.contextObject.addFieldListener(this._fieldName,this.boundUpdateFunction);
}
},removeListener:function(){
if(this.contextObject){
this.contextObject.removeFieldListener(this._fieldName,this.boundUpdateFunction);
}
},destroy:function(){
this.destroySubwidgets();
this.removeListener();
delete this._container;
},loadReference:function(_9){
if(this.referencedId){
this.getApplication().service.getById(this.referencedId,function(_a){
if(_a instanceof SnapMapException){
this.referencedObject=null;
_9();
this.logger.warn("ReferenceManager>could not load '"+this.referencedId+"' handlerObject");
return;
}else{
this.referencedObject=_a;
_9();
}
}.bind(this));
}else{
this.referencedObject=false;
_9();
}
},displayReference:function(){
this.display(this.templatePath);
},update:function(){
this.referencedId=this.contextObject.getRefId(this._fieldName);
this.loadReference(this.displayReference.bind(this));
}});
maptales.widgets["Reference"]=Reference;

var UserObject=Class.create("UserObject");
UserObject.prototype=new ContentObject();
var RIGHT_PRIVATE=0;
var RIGHT_PUBLIC=1;
var RIGHT_GROUP=2;
var DEFAULT_RIGHTS={"view":RIGHT_PRIVATE,"edit":RIGHT_PRIVATE,"add":RIGHT_PRIVATE,"comment":RIGHT_PUBLIC,"delete":RIGHT_PRIVATE,"export":RIGHT_PRIVATE};
Object.extend(UserObject.prototype,{UserObject_constructor:function(_1){
if(!(_1 instanceof Object)){
_1={};
}
this.ContentObject_constructor(_1);
this.addPersistentRef("creator",this.parseAndCacheRef(_1.creator),true);
this.addPersistentField("viewRight",_1.viewRight||RIGHT_PRIVATE,Field.NUMBER,true);
this.addPersistentField("viewCount",_1.viewCount||0,Field.NUMBER,false);
this.addPersistentSlot("comments",_1.comments,true,"Comment","creationDate asc",null);
this.addPersistentSlot("tags",_1.tags,false,"Tag","tag asc",null,"userobjects");
this.renderedRights=_1.renderedRights||{};
this.creatorName=_1.creatorName||"anonymous";
this.creatorDisplayName=_1.creatorDisplayName||"anonymous";
this.creatorGroupMemberRank=_1.creatorGroupMemberRank||0;
},getPath:function(){
return [{name:this.creatorName,type:"User",path:this.getRefId("creator")},{name:this.get("title"),type:this.getClassName(),path:this.get("id")}];
},getViewRight:function(){
return this.get("viewRight");
},getRight:function(_2){
return this.get(_2+"Right");
},setRight:function(_3,_4){
this.set(_3+"Right",_4);
},checkRights:function(_5){
if(maptales.service&&maptales.service.user){
if(maptales.service.user.getCurrentUser()!=null&&maptales.service.user.getCurrentUser().hasRole("ROLE_ADMIN")){
return true;
}
if(this.renderedRights[_5]){
return this.renderedRights[_5];
}else{
return false;
}
}else{
return false;
}
}});

var Media=Class.create("Media");
Media.prototype=new UserObject();
Object.extend(Media.prototype,{Media_constructor:function(_1){
if(!_1){
_1={};
}
this.UserObject_constructor(_1);
this.addPersistentField("timestamp",_1.timestamp||new Date(),Field.DATE,true);
this.addPersistentField("title",_1.title||"",Field.STRING,true);
this.addPersistentField("copyright",_1.copyright||null,Field.STRING,true);
this.addPersistentRef("creator",_1.creator,true,"User","medias");
this.addPersistentRef("mapobject",_1.mapobject,true,"MapObject","medias");
this.addPersistentRef("story",_1.story,true,"Story","medias");
this.addPersistentSlot("maps",_1.maps,true,"Map","mapAdditions");
try{
var _2=this.getRefFromCache("mapobject");
if(_2.getSlotLength("medias")==-1){
_2.insertIntoSlot("medias",[this],0,null,null,1);
}else{
_2.addToSlot("medias",this);
}
}
catch(e){
}
},getTitle:function(){
return this.get("title");
},isPlaced:function(){
if(this.getRefId("mapobject")==null||this.getRefId("mapobject")==0){
return false;
}else{
return true;
}
},isPlacedOnLine:function(){
if(!this.isPlaced()){
return false;
}
if(this.getRefFromCache("mapobject") instanceof Line){
return true;
}
return false;
}});

var User=Class.create("User");
User.prototype=new ContentObject();
Object.extend(User.prototype,{views:{home:{name:"Home",template:"objects/User/home",menuItem:true},content:{name:"Manage Content",template:"objects/User/manage",menuItem:true,requiredRoles:["ROLE_REGISTERED","ROLE_UNVERIFIED"],requiredRights:["edit"]},maps:{name:"Manage Maps",template:"objects/User/manageMaps",menuItem:true,requiredRoles:["ROLE_REGISTERED","ROLE_UNVERIFIED"],requiredRights:["edit"]},"import":{name:"Import",template:"objects/User/import",menuItem:true,requiredRoles:["ROLE_REGISTERED","ROLE_UNVERIFIED"],requiredRights:["edit"]},profile:{name:"Profile",template:"objects/User/profile",menuItem:true},network:{name:"Network",template:"objects/User/network",menuItem:true,requiredRoles:["ROLE_ADMIN"]},selectBuddyIcon:{name:"SelectBuddyIcon",template:"objects/User/selectBuddyIcon",menuItem:false,requiredRights:["edit"]},cropProfileIcon:{name:"CropProfileIcon",template:"objects/User/cropProfileIcon",menuItem:false,requiredRights:["edit"]},newBuddyIcon:{name:"NewBuddyIcon",template:"objects/User/newBuddyIcon",menuItem:false,requiredRights:["edit"]}},defaultView:"home",User_constructor:function(_1){
this.ContentObject_constructor(_1);
if(!_1){
_1={};
}
this.addPersistentField("id",_1.id||-1,Field.NUMBER,false);
this.addPersistentField("name",_1.name||null,Field.STRING,false);
this.addPersistentField("firstName",_1.firstName||null,Field.STRING,true);
this.addPersistentField("lastName",_1.lastName||null,Field.STRING,true);
this.addPersistentField("pass",_1.pass||null,Field.PASSWORD,true);
this.addPersistentField("email",_1.email||null,Field.EMAIL,true);
this.addPersistentField("gender",_1.gender,Field.OPTION,true,[{name:"not specified",value:-1},{name:"male",value:0},{name:"female",value:1}],-1);
this.addPersistentField("hasFlickrToken",_1.hasFlickrToken||false,Field.BOOLEAN,false);
this.addPersistentField("isContactOfLoggedInUser",_1.isContactOfLoggedInUser||false,Field.BOOLEAN,false);
this.addPersistentField("birthdate",_1.birthdate,Field.DATE,true);
this.addPersistentField("description",_1.description||null,Field.STRING,true);
this.addPersistentField("country",_1.country||null,Field.STRING,true);
this.addPersistentField("county",_1.county||null,Field.STRING,true);
this.addPersistentField("city",_1.city||null,Field.STRING,true);
this.addPersistentField("profileIcon",_1.profileIcon||null,Field.STRING,false);
this.addPersistentMap("properties",_1.properties||{},Field.STRING,false);
this.addPersistentSlot("tags",_1.tags,true,"Tag","creationDate desc",null,"creator");
this.addPersistentSlot("stories",_1.stories,true,"Story","creationDate desc",null,"creator");
this.addPersistentSlot("maps",_1.maps,true,"Map","creationDate desc",null,"creator");
this.addPersistentSlot("medias",_1.medias,true,"Media","creationDate desc",null,"creator");
this.addPersistentSlot("images",_1.images,true,null,"creationDate desc",null,"creator");
this.addPersistentSlot("mapobjects",_1.mapobjects,true,"MapObject","creationDate desc",null,"creator");
this.addPersistentSlot("snapshots",_1.snapshots,true,"Snapshot","title asc",null,"creator");
this.addPersistentSlot("contacts",_1.contacts,true,"Contact",null,null,null);
this.addPersistentSlot("groupsHeAdministers",_1.groupsHeAdministers,true,"Group",null,null,null);
this.addPersistentSlot("groupsHeModerates",_1.groupsHeAdministers,true,"Group",null,null,null);
this.addPersistentSlot("groupsHeIsMemberOf",_1.groupsHeIsMemberOf,true,"Group",null,null,null);
this.addPersistentSlot("groups",_1.groupsHeIsMemberOf,true,"Group",null,null,null);
this.addPersistentSlot("userFeed",_1.userFeed,true,"UserFeedItem",null,null,"creator");
this.addPersistentSlot("friendFeed",_1.friendFeed,true,"UserFeedItem",null,null,"creator");
this.addPersistentSlot("messageInbox",_1.messageInbox,true,"MaptalesMessage",null,null,"to");
this.addPersistentSlot("messageOutbox",_1.messageOutbox,true,"MaptalesMessage",null,null,"from");
if(!_1.roles){
_1.roles={};
_1.roles.slotItems=[];
_1.roles.slotItems[0]={};
_1.roles.slotItems[0].role="ROLE_ANONYMOUS";
}
this.setRoles(this.parseRoles(_1.roles.slotItems));
},getProfileIcon:function(){
var _2=this.get("profileIcon");
if(_2){
return maptales.baseURL+"/images/db/profileImages/48/"+_2;
}else{
return maptales.baseURL+"/styles/default/css/images/buddy-48.gif";
}
},getProfileIcon24:function(){
var _3=this.get("profileIcon");
if(_3){
return maptales.baseURL+"/images/db/profileImages/24/"+_3;
}else{
return maptales.baseURL+"/styles/default/css/images/buddy-24.gif";
}
},getProfileIcon12:function(){
var _4=this.get("profileIcon");
if(_4){
return maptales.baseURL+"/images/db/profileImages/12/"+_4;
}else{
return maptales.baseURL+"/styles/default/css/images/buddy-12.gif";
}
},parseRoles:function(_5){
var _6=[];
try{
_5.each(function(_7){
_6.push(_7.role);
});
}
catch(e){
}
return _6;
},getPath:function(){
return [{name:this.get("name"),type:"User",path:this.get("id")}];
},setRoles:function(_8){
this.roles=_8;
},getRoles:function(){
return this.roles;
},hasRole:function(_9){
if(this.roles.indexOf(_9)==-1){
return false;
}else{
return true;
}
},getProperties:function(){
return this.get("properties");
},getProperty:function(_a){
return this.get("properties")[_a];
},getPropertyAsArray:function(_b){
if(!this.get("properties")[_b]){
return [];
}
try{
return eval("["+this.get("properties")[_b]+"]");
}
catch(e){
return null;
}
},removeProperty:function(_c){
var _d=this.get("properties");
delete _d[_c];
this.set("properties",_d);
this.setDirty("properties");
},setProperty:function(_e,_f){
var _10=this.get("properties");
_10[_e]=_f;
this.set("properties",_10);
this.setDirty("properties");
},setPropertyAsArray:function(key,arr){
var str="";
for(var i=0;i<arr.length;i++){
if(typeof arr[i]=="string"){
str+="\""+arr[i]+"\"";
}else{
str+=arr[i];
}
if(i<arr.length-1){
str+=",";
}
}
this.setProperty(key,str);
},checkRights:function(_15){
if(this.id==maptales.service.user.getCurrentUserId()){
return true;
}else{
return false;
}
}});

var Comment=Class.create("Comment");
Comment.prototype=new UserObject();
Object.extend(Object.extend(Comment.prototype,UserObject.prototype),{Comment_constructor:function(_1){
if(!_1){
_1={};
}
this.UserObject_constructor(_1);
this.addPersistentField("title",_1.title||"",Field.STRING,true);
this.addPersistentField("text",_1.text||"",Field.STRING,true);
this.addPersistentField("profileIcon",_1.profileIcon||"",Field.STRING,false);
this.addPersistentRef("content",_1.content,true,"UserObject");
}});

var Post=Class.create("Post");
Post.prototype=new Media();
Object.extend(Post.prototype,{views:{item:{name:"Post",template:"objects/Post"},page:{name:"View",template:"objects/Media/page",menuItem:true}},defaultView:"page",Post_constructor:function(_1){
if(!_1){
_1={};
}
this.Media_constructor(_1);
this.addPersistentField("text",_1.text||"",Field.STRING,true);
},clone:function(){
return maptales.service.create("Post",{title:this.get("title"),text:this.get("text"),timestamp:this.get("timestamp")});
}});

var Picture=Class.create("Picture");
Picture.prototype=new Media();
Object.extend(Picture.prototype,{views:{item:{name:"Content",template:"objects/Image"},page:{name:"View",template:"objects/Media/page",menuItem:true},large:{name:"Large",template:"objects/Image/large"},original:{name:"Original",template:"objects/Image/original"}},defaultView:"page",Picture_constructor:function(_1){
if(!_1){
_1={};
}
this.Media_constructor(_1);
this.addPersistentField("text",_1.text||"",Field.STRING,true);
this.addPersistentField("filename",_1.filename,Field.STRING,false);
this.addPersistentField("baseUrl",_1.baseUrl,Field.STRING,false);
this.addPersistentField("secret",_1.secret,Field.STRING,false);
this.addPersistentField("originalSecret",_1.originalSecret,Field.STRING,false);
if(this.get("filename")!=null){
if(this.get("filename").indexOf(".jpg")!=-1){
this.fileExtension="";
}else{
this.fileExtension=".jpg";
}
}
},getOriginalImageURL:function(){
if(this.get("baseUrl").indexOf("flickr")==-1){
return this.get("baseUrl")+"/original/"+this.get("filename")+this.fileExtension;
}else{
return this.get("baseUrl")+"/"+this.get("filename")+"_"+this.get("secret")+"_b"+this.fileExtension;
}
},getLargeImageURL:function(){
if(this.get("baseUrl").indexOf("flickr")==-1){
return this.get("baseUrl")+"/large/"+this.get("filename")+this.fileExtension;
}else{
return this.get("baseUrl")+"/"+this.get("filename")+"_"+this.get("secret")+"_b"+this.fileExtension;
}
},getMediumImageURL:function(){
if(this.get("baseUrl").indexOf("flickr")==-1){
return this.get("baseUrl")+"/medium/"+this.get("filename")+this.fileExtension;
}else{
return this.get("baseUrl")+"/"+this.get("filename")+"_"+this.get("secret")+this.fileExtension;
}
},getMedium380ImageURL:function(){
if(this.get("baseUrl").indexOf("flickr")==-1){
return this.get("baseUrl")+"/medium380/"+this.get("filename")+this.fileExtension;
}else{
return this.get("baseUrl")+"/"+this.get("filename")+"_"+this.get("secret")+"_m"+this.fileExtension;
}
},getSmallImageURL:function(){
if(this.get("baseUrl").indexOf("flickr")==-1){
return this.get("baseUrl")+"/small/"+this.get("filename")+this.fileExtension;
}else{
return this.get("baseUrl")+"/"+this.get("filename")+"_"+this.get("secret")+"_m"+this.fileExtension;
}
},getThumbImageURL:function(){
if(this.get("baseUrl").indexOf("flickr")==-1){
return this.get("baseUrl")+"/thumb/"+this.get("filename")+this.fileExtension;
}else{
return this.get("baseUrl")+"/"+this.get("filename")+"_"+this.get("secret")+"_t"+this.fileExtension;
}
},getSquareImageURL:function(){
if(this.get("baseUrl").indexOf("flickr")==-1){
return this.get("baseUrl")+"/square/"+this.get("filename")+this.fileExtension;
}else{
return this.get("baseUrl")+"/"+this.get("filename")+"_"+this.get("secret")+"_s"+this.fileExtension;
}
}});

var Audio=Class.create("Audio");
Audio.prototype=new Media();
Object.extend(Audio.prototype,{views:{item:{name:"Audio",template:"objects/Audio/audio"},page:{name:"View",template:"objects/Media/page",menuItem:true}},defaultView:"page",Audio_constructor:function(_1){
if(!_1){
_1={};
}
this.Media_constructor(_1);
this.addPersistentField("baseUrl",_1.baseUrl,Field.STRING,false);
this.addPersistentField("filename",_1.filename,Field.STRING,false);
this.addPersistentField("text",_1.text||"",Field.STRING,true);
this.addPersistentField("duration",_1.duration||"",Field.NUMBER,false);
this.addPersistentField("language",_1.language||"",Field.STRING,true);
this.addPersistentField("processed",_1.processed||"",Field.BOOLEAN,true);
},getAudioURL:function(){
return this.get("baseUrl")+"/"+this.get("filename");
}});

var Story=Class.create("Story");
Story.prototype=new UserObject();
Object.extend(Story.prototype,{views:{overview:{name:"Overview",template:"objects/Story/Story",menuItem:true},browse:{name:"Read Story",template:"objects/Story/Story_Browse",menuItem:true},selectIcon:{name:"Select Icon",template:"objects/Story/Story_SelectIcon",menuItem:false}},defaultView:"overview",displayableObjects:{Media:"browse",Post:"browse",Picture:"browse"},logger:maptales.getLogger("com.maptales.webclient.bus.story"),Story_constructor:function(_1){
if(!_1){
_1={};
}
this.UserObject_constructor(_1);
this.addPersistentField("title",_1.title||"",Field.STRING,true);
this.addPersistentField("text",_1.text||"",Field.STRING,true);
this.addPersistentField("latestFirst",_1.latestFirst||false,Field.BOOLEAN,true);
if(_1.bounds){
var _2=new GLatLngBounds(new GLatLng(_1.bounds.s,_1.bounds.w),new GLatLng(_1.bounds.n,_1.bounds.e));
this.addPersistentField("bounds",_2,Field.BOUNDS,true);
}else{
this.addPersistentField("bounds",null,Field.BOUNDS,true);
}
if(_1.mapMode==null){
_1.mapMode=Map.HYBRID_MODE;
}
this.addPersistentField("mapMode",_1.mapMode,Field.OPTION,true,[{name:"Hybrid",value:MapWidget.HYBRID_MODE},{name:"Satellite",value:MapWidget.SATELLITE_MODE},{name:"Map",value:MapWidget.MAP_MODE}],MapWidget.HYBRID_MODE);
this.addPersistentRef("mainImage",_1.mainImage,false,null);
this.addPersistentRef("parentStory",_1.parentStory,false,null);
this.addPersistentRef("creator",_1.creator,true,"stories");
if(this.get("latestFirst")==true){
var _3="timestamp desc";
}else{
var _3="timestamp asc";
}
this.addPersistentSlot("medias",_1.medias,true,"Media",_3,null,null);
this.addPersistentSlot("substories",_1.substories,true,"Story","timestamp asc",null,null);
},getTitle:function(){
return this.get("title");
},containesRightsManagedItems:function(_4){
var _5=false;
try{
var _6=this.getSlotFromCache("medias",0,-1);
for(var i=0;i<_6.length;i++){
if(_6[i].getViewRight()!=UserObject.RIGHT_PUBLIC){
_5=true;
}
}
}
catch(e){
return _4;
}
return _5;
},getSquareImageURL:function(){
if(this.get("thumbUrl")){
return "/images/db/square/"+this.get("thumbUrl");
}else{
return false;
}
},addToSlot:function(_8,_9,_a){
if(!(_9 instanceof Array)){
_9=[_9];
}
if(_8=="medias"){
this._addMedias(_9);
}else{
this._addToSlot(_8,_9);
}
},removeFromSlot:function(_b,_c){
if(!(_c instanceof Array)){
_c=[_c];
}
if(_b=="medias"){
_c.each(function(_d){
this._removeMedia(_d);
}.bind(this));
}else{
this._removeFromSlot(_b,_c);
}
},_addMedia:function(_e){
_e=$O(_e);
this._addToSlot("medias",_e);
_e.set("story",this);
},_addMedias:function(_f){
for(var i=0;i<_f.length;i++){
this._addMedia(_f[i]);
}
},_removeMedia:function(_11){
this._removeFromSlot("medias",_11);
if(_11 instanceof UserObject){
_11.set("story",null);
}else{
maptales.cache.getFromCache(_11).set("story",null);
}
try{
$O(_11).getRefFromCache("creator").addToSlot("medias",_11);
}
catch(e){
alert("Story>_removeMedia>"+e);
}
},releaseAssociations:function(){
try{
var _12=this.getSlotFromCache("medias",0,-1,null,null);
if(_12.length>0){
this.removeFromSlot("medias",_12,false);
try{
for(var i=0;i<_12.length;i++){
_12[i].set("story",null);
var _14=_12[i].getRefFromCache("creator");
_14.addToSlot("medias",_12[i]);
}
}
catch(e){
this.logger.warn("AddError: Could not add media item back to user after story delete",e);
}
}
}
catch(e){
this.logger.warn("AddError: Could not remove media items from story after delete",e);
}
},deleteAssociations:function(){
try{
var _15=this.getSlotFromCache("medias",0,-1,null,null);
if(_15.length>0){
try{
for(var i=0;i<_15.length;i++){
maptales.service.deleteLocally(_15[i],false);
}
}
catch(e){
this.logger.warn("DeleteLocally Error: Could not delete media after story delete",e);
}
}
}
catch(e){
this.logger.warn("DeleteLocally: Could not delete media items of story after delete, seems like medias slot was not loaded",e);
}
},getSlotsToRelease:function(){
return ["medias"];
},isLoaded:function(){
if(this.isSlotInCache("medias",0,-1,null,null)){
return true;
}else{
return false;
}
}});

var Tag=Class.create("Tag");
Tag.prototype=new ContentObject();
Object.extend(Tag.prototype,{views:{overview:{name:"Content",template:"objects/Tag",menuItem:true},browse:{name:"Browse",template:"objects/Story_Browse",menuItem:true}},defaultView:"overview",Tag_constructor:function(_1){
if(!_1){
_1={};
}
this.ContentObject_constructor(_1);
this.addPersistentField("tag",_1.tag,Field.STRING,false);
this.fields["creationDate"]=null;
this.relatedNum=_1.relatedNum||0;
},getTag:function(){
return this.get("tag");
},_updateData:Tag.prototype.updateData,updateData:function(_2){
if(_2.relatedNum){
this.relatedNum=_2.relatedNum;
}
this._updateData(_2);
}});

var Feed=Class.create("Feed");
Feed.prototype=new UserObject();
var reflection={views:{feed:{name:"Feed",template:"objects/Feed"}},defaultView:"feed",fields:{title:{inputType:"inputField"},text:{inputType:"textArea"},timestamp:{inputType:"date"},creationDate:{inputType:"date"},feedUrl:{inputType:"inputField"}},displayableObjects:{},refs:{creator:{view:"User_Signature",objectClass:"User"}},defaultSlot:"weblinks",slots:{weblinks:{inputType:"listWidget",objectClass:"WebLink"},tags:{inputType:"listWidget",objectClass:"Tag"}}};
Object.extend(Feed.prototype,{reflection:reflection,Feed_constructor:function(_1){
if(!_1){
_1={};
}
this.UserObject_constructor(_1);
this.addPersistentField("id",_1.id);
this.addPersistentField("title",_1.title||"");
this.addPersistentField("url",_1.url||"");
this.addPersistentField("creationDate",new Date(parseInt(_1.creationDate))||"");
this.addPersistentRef("creator",this.parseAndCacheArray(_1.creator),true,"feeds");
this.addPersistentSlot("medias",_1.mediasNum,this.parseAndCacheArray(_1.medias),true,"creationDate desc",null,"feed");
this.addPersistentSlot("tags",_1.tagsNum,this.parseAndCacheArray(_1.tags),false);
}});

var FeedItem=Class.create("FeedItem");
FeedItem.prototype=new Media();
Object.extend(FeedItem.prototype,{views:{item:{name:"Content",template:"objects/FeedItem/FeedItem"},page:{name:"View",template:"objects/Media/page",menuItem:true}},defaultView:"page",FeedItem_constructor:function(_1){
if(!_1){
_1={};
}
this.Media_constructor(_1);
this.addPersistentField("author",_1.author||"",Field.STRING,false);
this.addPersistentField("title",_1.title||"",Field.STRING,false);
this.addPersistentField("text",_1.text||"",Field.STRING,false);
this.addPersistentField("thumbUrl",_1.thumbUrl||"",Field.STRING,false);
this.addPersistentField("backlink",_1.backlink||"",Field.STRING,false);
this.addPersistentField("creationDate",_1.creationDate||null,Field.DATE,false);
this.addPersistentField("publishingDate",_1.publishingDate||null,Field.DATE,false);
},getSquareImageURL:function(){
return this.get("thumbUrl");
}});

var MapObject=Class.create("MapObject");
MapObject.prototype=new UserObject();
Object.extend(MapObject.prototype,{MapObject_constructor:function(_1){
if(!_1){
_1={};
}
this.UserObject_constructor(_1);
this.addPersistentField("definitionZoomLevel",_1.definitionZoomLevel,Field.ZOOMLEVEL,true);
this.addPersistentField("viewZoomLevel",_1.viewZoomLevel,Field.ZOOMLEVEL,true);
this.addPersistentField("originOfData",_1.originOfData,Field.NUMBER,true);
this.addPersistentSlot("medias",_1.medias,true,"Media","timestamp desc",null,"mapobject");
this.addPersistentField("location",_1.location,Field.POINT,true);
this.container=document.createElement("DIV");
this.highlighted=false;
this.selected=false;
this.lastZoom=-1;
this.map=null;
},setContentType:function(_2){
if(_2!=null){
if(_2 instanceof Video){
this.styleName="video";
}else{
if(_2 instanceof Post){
this.styleName="post";
}else{
if(_2 instanceof Audio){
this.styleName="audio";
}else{
this.styleName="image";
}
}
}
}else{
this.styleName="image";
}
this.updateIcons();
},updateIcons:function(){
},initialize:function(_3){
var _4=new SnapMapException("NotImplemented","Abstract method initialize() in MapObject called!");
maptales.ui.addException(_4);
throw _4;
},remove:function(){
var _5=new SnapMapException("NotImplemented","Abstract method remove() in MapObject called!");
maptales.ui.addException(_5);
throw _5;
},redraw:function(_6){
var _7=new SnapMapException("NotImplemented","Abstract method redraw() in MapObject called!");
maptales.ui.addException(_7);
throw _7;
},snap:function(_8,_9){
var _a=new SnapMapException("NotImplemented","Abstract method snap() in MapObject called!");
maptales.ui.addException(_a);
throw _a;
},clip:function(_b){
var _c=new SnapMapException("NotImplemented","Abstract method clip() in MapObject called!");
maptales.ui.addException(_c);
throw _c;
},getContainer:function(){
return this.container;
},getMapPane:function(){
return this.mapPane;
},setMapPane:function(_d){
this.mapPane=_d;
},isOnMap:function(){
if(this.map){
return true;
}
return false;
},setHighlighted:function(_e){
if(_e!=this.highlighted&&!this.selected){
if(_e){
this.container.className+=" highlighted";
}else{
this.container.className=this.container.className.replace(/highlighted/,"");
}
this.highlighted=_e;
}
},isHighlighted:function(){
return this.highlighted;
},setSelected:function(_f){
if(_f!=this.selected){
if(_f){
this.setHighlighted(false);
Element.addClassName(this.container,"selected");
}else{
Element.removeClassName(this.container,"selected");
}
this.selected=_f;
}
},isSelected:function(){
return this.selected;
}});

var MarkerButtons=Class.create();
MarkerButtons.prototype={initialize:function(_1,_2,_3){
this.marker=null;
this.gmap=_2;
this.floatPane=_1;
this.mapPane=_3;
this._panel=document.createElement("DIV");
this._panel.style.position="absolute";
this._panel.style.zIndex="9999";
this._panel.style.display="none";
this._panel.style.width="18px";
this._panel.style.height="47px";
this.floatPane.appendChild(this._panel);
this.isVisible=false;
var _4=document.createElement("DIV");
_4.className="zoombutton";
_4.title="zoom to marker";
this._panel.appendChild(_4);
_4.onclick=function(_5){
if(this.marker){
this.hide();
this.marker.zoomAndCenter();
Event.stop(_5);
}
}.bindAsEventListener(this);
var _6=document.createElement("DIV");
_6.className="linebutton";
_6.title="drag to draw a line";
this._panel.appendChild(_6);
this.lineButton=_6;
_6.onmousedown=function(_7){
if(this.marker){
this.lineDragStart(_7);
this.hide();
}
}.bindAsEventListener(this);
var _8=document.createElement("DIV");
_8.className="deletebutton";
_8.title="delete marker";
this._panel.appendChild(_8);
this.deleteButton=_8;
this.deleteButton.onclick=function(_9){
if(this.marker){
this.hide();
if(this.mapPane.getSynchronizedHandler() instanceof Story){
Dialog.toggle("Remove/Delete Marker?",this.marker,null,"objects/Marker_Remove_Confirm",this.marker,this.marker.imageDiv,Dialog.NORTH);
}else{
Dialog.toggle("Delete Marker?",this.marker,null,"objects/Marker_Delete_Confirm",this.marker,this.marker.imageDiv,Dialog.NORTH);
}
}
}.bindAsEventListener(this);
this._updatePosition=this.updatePosition.bind(this);
this._windowMoveHandler=this.onMouseMove.bindAsEventListener(this);
},update:function(_a){
if(_a.id>0){
this.mapPane.lineButtons.hideAll();
if(this.isLineDragging){
return;
}
Event.stopObserving(document,"mousemove",this._windowMoveHandler);
this.marker=_a;
this.updatePosition();
this._panel.style.display="block";
this.isVisible=true;
Event.observe(document,"mousemove",this._windowMoveHandler);
if(maptales.service&&maptales.service.user&&maptales.service.user.getCurrentUser()!=null){
if(this.marker.checkRights("delete")||maptales.service.user.getCurrentUser().hasRole("ROLE_ADMIN")){
Element.show(this.deleteButton);
}else{
Element.hide(this.deleteButton);
}
if(this.marker.checkRights("edit")||maptales.service.user.getCurrentUser().hasRole("ROLE_ADMIN")&&_a.id>=0){
Element.show(this.lineButton);
}else{
Element.hide(this.lineButton);
}
}else{
Element.hide(this.deleteButton);
Element.hide(this.lineButton);
}
}
},onMouseMove:function(_b){
var _c={x:Event.pointerX(_b),y:Event.pointerY(_b)};
if(this.marker.isSelected()){
if((_c.x>this.curPoint.x+24)||(_c.x<this.curPoint.x-36)||(_c.y>this.curPoint.y+12)||(_c.y<this.curPoint.y-49)){
this.hide();
}
}else{
if((_c.x>this.curPoint.x+14)||(_c.x<this.curPoint.x-26)||(_c.y>this.curPoint.y+22)||(_c.y<this.curPoint.y-29)){
this.hide();
}
}
},updatePosition:function(){
this.curPoint=this.marker.getScreenPosition();
var _d=this.gmap.fromLatLngToDivPixel(this.marker.get("location"));
if(this.marker.isSelected()){
this._panel.style.left=(_d.x-27)+"px";
this._panel.style.top=(_d.y-37)+"px";
}else{
this._panel.style.left=(_d.x-24)+"px";
this._panel.style.top=(_d.y-27)+"px";
}
},hide:function(){
Event.stopObserving(document,"mousemove",this._windowMoveHandler);
this._panel.style.display="none";
this.isVisible=false;
if(this.marker){
this.marker.removeFieldListener("location",this._updatePosition);
}
this.curPoint=null;
if(this.mapPane&&this.mapPane.hoverObject&&this.mapPane.hoverObject instanceof Line){
this.mapPane.lineButtons.update({line:this.mapPane.hoverObject,pixel:this.mapPane.hoverObject.mouseDiv});
}
},lineDragStart:function(_e){
if(this.marker){
this.isLineDragging=true;
this.marker.isDragging=false;
this.lineControlPoint=new MapPoint({location:{lat:this.marker.get("location").lat(),lng:this.marker.get("location").lng()}});
this.lineControlPoint.setMapPane(this.mapPane);
this.dragLine=new LineSegment(this.marker,this.lineControlPoint);
this.dragLine.startId=this.marker.id;
this.dragLine.boundLineDragEnd=this.lineDragEnd.bindAsEventListener(this);
this.lineControlPoint.addFieldListener("location",this.dragLine.update.bind(this.dragLine));
this.gmap.addOverlay(this.lineControlPoint);
this.gmap.addOverlay(this.dragLine);
Event.observe(document,"mousemove",this.lineControlPoint.boundDragHandler);
Event.observe(document,"mouseup",this.dragLine.boundLineDragEnd);
Event.stop(_e);
}
},lineDragEnd:function(_f){
Event.stopObserving(document,"mousemove",this.lineControlPoint.boundDragHandler);
Event.stopObserving(document,"mouseup",this.dragLine.boundLineDragEnd);
if(this.lineControlPoint.isDragging){
this.lineControlPoint.isDragging=false;
var pos={x:Event.pointerX(_f),y:Event.pointerY(_f)};
var _11=this.mapPane.snap(pos,8);
if(_11&&_11 instanceof Marker){
this.lineControlPoint.set("location",_11.get("location"));
var _12=maptales.cache.getFromCache(this.dragLine.startId);
var _13={creator:maptales.service.user.getCurrentUserId(),definitionZoomLevel:this.gmap.getZoom(),viewZoomLevel:this.gmap.getZoom(),controlpoints:[_12.get("location"),_11.get("location")],startMarker:_12,endMarker:_11};
var _14=maptales.service.create("Line",_13);
var _15=maptales.service.create("Post",{});
try{
var t1=_12.getSlotFromCache("medias",0,1,null,null)[0].get("timestamp");
var t2=_11.getSlotFromCache("medias",0,1,null,null)[0].get("timestamp");
if(t1<t2){
var _18=t1.getTime()+10000;
}else{
var _18=t2.getTime()+10000;
}
_15.set("timestamp",new Date(_18));
}
catch(e){
}
_14.setSlotLength("medias",0);
_14.addToSlot("medias",_15);
_12.addOutgoingLine(_14);
_11.addIncomingLine(_14);
this.mapPane.addQueryOverlay(_14);
this.gmap.removeOverlay(this.lineControlPoint);
this.gmap.removeOverlay(this.dragLine);
try{
this.mapPane.store(_14,function(_19){
if(_19 instanceof SnapMapException){
Dialog.toggle("Storing Error",null,null,"dialog/ErrorDialog",{message:"Could not store new route"},_12.imageDiv,Dialog.SOUTH);
this.gmap.removeOverlay(_14);
}
_15.set("mapobject",_14);
}.bind(this));
}
catch(e){
throw new SnapMapException("StorageException","MarkerButtons>endDrag>could not store new mapobjects>"+e);
}
}else{
var _12=maptales.cache.getFromCache(this.dragLine.startId);
var _1a={creator:maptales.service.user.getCurrentUserId(),definitionZoomLevel:this.gmap.getZoom(),viewZoomLevel:this.gmap.getZoom(),startMarker:_12,controlpoints:[_12.get("location"),this.lineControlPoint.get("location")],timestamp:new Date()};
var _14=maptales.service.create("Line",_1a);
var _15=maptales.service.create("Post",{});
try{
var t1=_12.getSlotFromCache("medias",0,1,null,null)[0].get("timestamp");
var _18=t1.getTime()+10000;
_15.set("timestamp",new Date(_18));
}
catch(e){
}
_14.setSlotLength("medias",0);
_14.addToSlot("medias",_15);
_12.addOutgoingLine(_14);
this.mapPane.addQueryOverlay(_14);
this.gmap.removeOverlay(this.lineControlPoint);
this.gmap.removeOverlay(this.dragLine);
try{
this.mapPane.store(_14,function(_1b){
if(_1b instanceof SnapMapException){
Dialog.toggle("Storing Error",null,null,"dialog/ErrorDialog",{message:"Could not store new route"},_12.imageDiv,Dialog.SOUTH);
this.gmap.removeOverlay(_14);
}
_15.set("mapobject",_14);
}.bind(this));
}
catch(e){
throw new SnapMapException("StorageException","MarkerButtons>endDrag>could not store new mapobjects>"+e);
}
}
this.isLineDragging=false;
}else{
this.gmap.removeOverlay(this.lineControlPoint);
this.gmap.removeOverlay(this.dragLine);
this.isLineDragging=false;
this.update(this.marker);
maptales.ui.checkTip("routes",this.marker.container,Dialog.SOUTH);
}
}};

var LineButtons=Class.create();
LineButtons.prototype={initialize:function(_1,_2,_3){
this.line=null;
this.pixel=null;
this.gmap=_2;
this.floatPane=_1;
this.mapPane=_3;
this.buttonTimer=null;
this.mapMoveHandler=null;
this.traceLines=true;
this.panel=document.createElement("DIV");
this.panel.style.position="absolute";
this.panel.style.zIndex="9999";
this.panel.style.display="none";
this.floatPane.appendChild(this.panel);
this.zoomButton=document.createElement("DIV");
this.zoomButton.className="zoombutton";
this.zoomButton.title="zoom to route";
this.panel.appendChild(this.zoomButton);
this.zoomButton.onclick=function(_4){
if(this.line){
this.hideAll();
this.mapPane.zoomToLine(this.line);
}
}.bindAsEventListener(this);
this.deleteButton=document.createElement("DIV");
this.deleteButton.className="deletebutton";
this.deleteButton.title="delete this route";
this.panel.appendChild(this.deleteButton);
this.deleteButton.onclick=function(_5){
if(this.line){
this.hideAll();
Dialog.toggle("Delete Route?",this.line,null,"objects/Line/deleteConfirm",this.line,this.pixel,Dialog.NORTH);
}
}.bindAsEventListener(this);
this.followButtons=[];
this.markerButton1=document.createElement("DIV");
this.markerButton1.className="detachmarkerbutton";
this.markerButton1.style.display="none";
this.floatPane.appendChild(this.markerButton1);
this.markerButton1.map=this.mapPane;
this.markerButton1.buttons=this;
this.markerButton2=document.createElement("DIV");
this.markerButton2.className="detachmarkerbutton";
this.markerButton2.style.display="none";
this.floatPane.appendChild(this.markerButton2);
this.markerButton2.map=this.mapPane;
this.markerButton2.buttons=this;
this._updatePosition=this.updatePosition.bind(this);
this._windowMoveHandler=this.onMouseMove.bindAsEventListener(this);
},update:function(_6){
if(_6.line.id>0){
if(this.mapPane.markerButtons.isVisible){
return;
}
this.clearTimeout();
if(this.curPoint&&this.line==_6.line){
return;
}
Event.stopObserving(document,"mousemove",this._windowMoveHandler);
this.line=_6.line;
if(!this.line){
return;
}
if(_6.pixel){
this.pixel=_6.pixel;
this.updatePosition();
}else{
this.placePanelToPos(_6.position);
}
this.panel.style.display="block";
Event.observe(document,"mousemove",this._windowMoveHandler);
if(maptales.service&&maptales.service.user&&maptales.service.user.getCurrentUser()!=null){
if(this.line.checkRights("delete")||maptales.service.user.getCurrentUser().hasRole("ROLE_ADMIN")){
Element.show(this.deleteButton);
}else{
Element.hide(this.deleteButton);
}
}else{
Element.hide(this.deleteButton);
}
}
},onMouseMove:function(_7){
var _8={x:Event.pointerX(_7),y:Event.pointerY(_7)};
if((_8.x>this.curPoint.x+15)||(_8.x<this.curPoint.x-26)||(_8.y>this.curPoint.y+33)||(_8.y<this.curPoint.y-7)){
this.hideLineButtons();
}
},updatePosition:function(){
this.placePanel();
this.placeBorderButtons();
},placePanel:function(){
var _9=Position.cumulativeOffset(this.pixel);
var _a=Position.cumulativeOffset($("map"));
var _b=this.gmap.fromContainerPixelToLatLng(new GPoint(_9[0]-_a[0],_9[1]-_a[1]));
var _c=this.gmap.fromLatLngToDivPixel(_b);
this.curPoint={x:_9[0],y:_9[1]};
this.panel.style.left=(_c.x-22)+"px";
this.panel.style.top=(_c.y-0)+"px";
},placePanelToPos:function(_d){
this.curPoint={x:_d.x,y:_d.y};
this.panel.style.left=(_d.x-22)+"px";
this.panel.style.top=(_d.y-0)+"px";
},placeBorderButtons:function(){
var _e=Element.getDimensions($("map"));
var _f=this.gmap.getBounds();
var _10=this.line.getClipPoints(_f);
this.placeFollowButtons(_10);
this.placeMarkerButtons(_10);
if(!this.mapMoveHandler){
this.mapMoveHandler=GEvent.bind(this.gmap,"moveend",this,this.placeBorderButtons.bind(this));
}
this.setTimeout();
},placeFollowButtons:function(_11){
for(var i=0;i<this.followButtons.length;i++){
this.followButtons[i].style.display="none";
}
var num=0;
for(var i=0;i<4;i++){
for(var j=0;j<_11[i].length;j++){
var pos=new GPoint(_11[i][j].x,_11[i][j].y);
if(j<_11[i].length-1){
var _16=_11[i][j+1];
if(Math.abs(pos.x-_16.x)<150&&Math.abs(pos.y-_16.y)<150){
pos.x=Math.round((pos.x+_16.x)/2);
pos.y=Math.round((pos.y+_16.y)/2);
j++;
}
}
var _17=this.getFollowButton(num);
var _18=0,_19=0;
switch(i+1){
case CLIP_TOP:
_17.style.left=(pos.x-7)+"px";
_17.style.top=(pos.y+7)+"px";
_17.className="followlinebutton up";
pos.y-=140;
break;
case CLIP_BOTTOM:
_17.style.left=(pos.x-7)+"px";
_17.style.top=(pos.y-29)+"px";
_17.className="followlinebutton down";
pos.y+=140;
break;
case CLIP_LEFT:
_17.style.left=(pos.x+3)+"px";
_17.style.top=(pos.y-7)+"px";
_17.className="followlinebutton left";
pos.x-=140;
break;
case CLIP_RIGHT:
_17.style.left=(pos.x-19)+"px";
_17.style.top=(pos.y-7)+"px";
_17.className="followlinebutton right";
pos.x+=140;
break;
}
_17.target=this.mapPane.fromDivPixelToLatLng(pos);
_17.style.display="block";
num++;
}
}
},placeMarkerButtons:function(_1a){
var _1b=this.mapPane.getBounds();
try{
this.placeMarkerButton(this.markerButton1,this.line.getStartPoint(),_1b,_1a[4][0]);
}
catch(e){
}
try{
this.placeMarkerButton(this.markerButton2,this.line.getEndPoint(),_1b,_1a[4][1]);
}
catch(e){
}
},placeMarkerButton:function(_1c,_1d,_1e,_1f){
if(_1e.contains(_1d)){
var pos=this.mapPane.fromLatLngToDivPixel(_1d);
_1c.style.left=(pos.x-8)+"px";
_1c.style.top=(pos.y-8)+"px";
_1c.className="detachmarkerbutton";
_1c.onclick=null;
_1c.onmousedown=function(){
};
_1c.style.display="none";
}else{
switch(_1f.clipDir){
case CLIP_TOP:
_1c.style.left=(_1f.x+9)+"px";
_1c.style.top=(_1f.y+7)+"px";
_1c.className="followmarkerbutton up";
break;
case CLIP_BOTTOM:
_1c.style.left=(_1f.x+9)+"px";
_1c.style.top=(_1f.y-29)+"px";
_1c.className="followmarkerbutton down";
break;
case CLIP_LEFT:
_1c.style.left=(_1f.x+3)+"px";
_1c.style.top=(_1f.y+9)+"px";
_1c.className="followmarkerbutton left";
break;
case CLIP_RIGHT:
_1c.style.left=(_1f.x-19)+"px";
_1c.style.top=(_1f.y+9)+"px";
_1c.className="followmarkerbutton right";
break;
}
_1c.onmousedown=null;
_1c.location=_1d;
_1c.onclick=function(){
this.buttons.hideAll();
if(this.buttons.traceLines){
this.map.traceLine(this.buttons.line,(this==this.buttons.markerButton1));
}else{
this.map.panTo(this.endPoint);
}
};
_1c.style.display="block";
}
},getFollowButton:function(num){
if(!this.followButtons[num]){
this.followButtons[num]=document.createElement("DIV");
this.followButtons[num].map=this.mapPane;
this.followButtons[num].buttons=this;
this.followButtons[num].onclick=function(){
this.buttons.hideBorderButtons();
this.buttons.setMoveHandler();
this.map.panTo(this.target);
};
this.floatPane.appendChild(this.followButtons[num]);
}
return this.followButtons[num];
},hideAll:function(){
Event.stopObserving(document,"mousemove",this._windowMoveHandler);
this.panel.style.display="none";
this.curPoint=null;
this.hideBorderButtons();
},hideLineButtons:function(){
Event.stopObserving(document,"mousemove",this._windowMoveHandler);
this.panel.style.display="none";
this.curPoint=null;
this.setTimeout();
},hideBorderButtons:function(){
this.clearTimeout();
for(var i=0;i<this.followButtons.length;i++){
this.followButtons[i].style.display="none";
}
this.markerButton1.style.display="none";
this.markerButton2.style.display="none";
if(this.mapMoveHandler){
GEvent.removeListener(this.mapMoveHandler);
}
this.mapMoveHandler=null;
},setMoveHandler:function(){
if(!this.mapMoveHandler){
this.mapMoveHandler=GEvent.bind(this.gmap,"moveend",this,this.placeBorderButtons.bind(this));
}
},setTimeout:function(){
this.clearTimeout();
this.buttonTimer=setTimeout(this.hideBorderButtons.bind(this),5000);
},clearTimeout:function(){
if(this.buttonTimer){
clearTimeout(this.buttonTimer);
this.buttonTimer=null;
}
}};

var MapPoint=Class.create("MapPoint");
MapPoint.prototype=new MapObject();
Object.extend(MapPoint.prototype,{MapPoint_constructor:function(_1,_2){
if(!_1){
_1={};
}
this.parentContentObject=_2||null;
this.MapObject_constructor(_1);
this.dragStartListeners=[];
this.dragEndListeners=[];
this.dropListeners=[];
this.displaySize=4;
this.moveable=true;
this.container.className="mapPoint";
this.container.onmousedown=this.onMouseDown.bindAsEventListener(this);
this.boundDragHandler=this.onDrag.bind(this);
this.boundMouseUpHandler=this.onMouseUp.bind(this);
this.container.onmouseover=this.onDropOver.bindAsEventListener(this);
this.container.onmouseout=this.onDropOut.bindAsEventListener(this);
},initialize:function(_3){
this.map=_3;
this.map.getPane(G_MAP_MARKER_PANE).appendChild(this.container);
},remove:function(){
try{
this.map.getPane(G_MAP_MARKER_PANE).removeChild(this.container);
}
catch(e){
}
this.map=null;
},removeLater:function(){
window.setTimeout(function(){
if(this.mapPane){
this.mapPane.removeTempOverlay(this);
}
}.bind(this),1);
},redraw:function(_4){
if(_4){
if(!this.map){
this.mapPane.gmap.addOverlay(this);
return;
}
if(!this.clip(this.mapPane.getClipBounds())){
try{
this.map.getPane(G_MAP_MARKER_PANE).removeChild(this.container);
}
catch(e){
}
window.setTimeout(function(){
if(this.map){
this.map.removeOverlay(this);
}
}.bind(this),1);
return;
}
var _5=this.mapPane.fromLatLngToDivPixel(this.get("location"));
this.container.style.top=_5.y+"px";
this.container.style.left=_5.x+"px";
if(this.highlighted){
this.container.style.zIndex=GOverlay.getZIndex(-90);
}else{
if(this.selected){
this.container.style.zIndex=GOverlay.getZIndex(-90);
}else{
var _6=GOverlay.getZIndex(this.get("location").lat());
this.container.style.zIndex=_6;
}
}
}
},snap:function(_7,_8){
var _9=this.displaySize+_8;
var _a=Position.cumulativeOffset(this.container);
if((_a[0]-_8<_7.x)&&(_a[0]+_9>_7.x)&&(_a[1]-_8<_7.y)&&(_a[1]+_9>_7.y)){
return this;
}
return false;
},clip:function(_b){
if(!_b){
return true;
}
return _b.contains(this.get("location"));
},addDragEndListener:function(_c){
this.dragEndListeners.push(_c);
},removeDragEndListener:function(_d){
for(var i=0;i<this.dragEndListeners.length;i++){
if((this.dragEndListeners[i]==_d)){
this.dragEndListeners.splice(i,1);
break;
}
}
},notifyDragEndListeners:function(){
this.dragEndListeners.each(function(_f){
_f();
});
},addDragStartListener:function(_10){
this.dragStartListeners.push(_10);
},removeDragStartListener:function(_11){
for(var i=0;i<this.dragStartListeners.length;i++){
if((this.dragStartListeners[i]==_11)){
this.dragStartListeners.splice(i,1);
break;
}
}
},notifyDragStartListeners:function(){
this.dragStartListeners.each(function(_13){
_13();
});
},onMouseDown:function(_14){
if(this.mapPane){
this.mapPane.hideMarkerInfo();
}
if(this.parentContentObject==null||this.parentContentObject.checkRights("edit")){
this.startDrag(_14);
}
},startDrag:function(_15){
this._oldMapCursor=this.mapPane.getContainer().style.cursor;
this.mapPane.getContainer().style.cursor="pointer";
this.mapPane.markerButtons.hide();
this.mapPane.lineButtons.hideAll();
if(this.moveable){
this.isDragging=false;
Event.observe(document,"mousemove",this.boundDragHandler);
}
Event.observe(document,"mouseup",this.boundMouseUpHandler);
Event.stop(_15);
},onMouseUp:function(_16){
Event.stopObserving(document,"mouseup",this.boundMouseUpHandler);
Event.stopObserving(document,"mousemove",this.boundDragHandler);
this.mapPane.getContainer().style.cursor=this._oldMapCursor;
if(this.snapObj&&this.snapObj.doDrop){
this.snapObj.doDrop(this);
this.snapObj=null;
}else{
if(this.isDragging){
this.notifyDragEndListeners();
}
}
this.isDragging=false;
},onDrag:function(_17){
if(!this.isDragging){
this.isDragging=true;
this.notifyDragStartListeners();
}
var pos=[Event.pointerX(_17),Event.pointerY(_17)];
this.snapObj=this.mapPane.snap({x:pos[0],y:pos[1]},8,this);
if(!this.snapObj){
var _19=Position.cumulativeOffset($("map"));
var _1a=this.mapPane.fromContainerPixelToLatLng({x:pos[0]-_19[0],y:pos[1]-_19[1]});
this.set("location",_1a);
this.redraw(true);
}else{
try{
this.set("location",this.snapObj.get("location"));
this.redraw(true);
}
catch(e){
maptales.ui.addException(e);
}
}
},addDropListener:function(_1b){
this.dropListeners.push(_1b);
},notifyDropListeners:function(obj){
this.dropListeners.each(function(_1d){
_1d(this,obj);
}.bind(this));
},onDropOver:function(_1e){
Event.stop(_1e);
if(DragDrop.isDragging&&this.acceptDropContent(DragDrop.getDraggedObjects())){
this.dropOver=true;
this.container.className+=" droppable";
DragDrop.setActiveDropZone(this);
Event.stop(_1e);
}else{
this.dropOver=false;
}
},onDropOut:function(_1f){
Event.stop(_1f);
if(this.dropOver){
this.container.className=this.container.className.replace(/droppable/,"");
DragDrop.setActiveDropZone(null);
}
},acceptDropContent:function(_20){
return false;
},doDrop:function(_21){
this.notifyDropListeners(_21);
return true;
},getScreenPosition:function(){
var pos=Position.cumulativeOffset(this.container);
return {x:pos[0],y:pos[1]};
},getPixelPoint:function(){
if(this.map){
return this.map.fromLatLngToDivPixel(this.get("location"));
}else{
return maptales.ui.getMainMap().fromLatLngToDivPixel(this.get("location"));
}
},getScreenSize:function(){
return this.displaySize;
}});

var Marker=Class.create("Marker");
Marker.prototype=new MapPoint();
Object.extend(Marker.prototype,{logger:maptales.getLogger("com.maptales.webClient.mapObjects.marker"),Marker_constructor:function(_1){
if(!_1){
_1={};
}
this.MapPoint_constructor(_1,this);
this.incomingLines=[];
this.outgoingLines=[];
this.container.className="marker";
this.styleName=_1.styleName||null;
this.container.onmouseover=this._onMarkerMouseOver.bindAsEventListener(this);
this.container.onmouseout=this._onMarkerMouseOut.bindAsEventListener(this);
this.container.onclick=this._onMarkerClick.bindAsEventListener(this);
this.container.handleBubbleAction=this._handleBubbleAction.bind(this);
this.imageDiv=document.createElement("DIV");
this.imageDiv.className="markerImage";
this.container.appendChild(this.imageDiv);
this.shadowDiv=document.createElement("DIV");
this.shadowDiv.className="markerShadow";
this.container.appendChild(this.shadowDiv);
this.numberDiv=document.createElement("DIV");
this.numberDiv.className="markerNumbers";
this.container.appendChild(this.numberDiv);
this.boundUpdateFunction=this.updateIcons.bind(this);
this.addListener();
this.addDragStartListener(this.onDragStart.bind(this));
this.addDragEndListener(this.onDragEnd.bind(this));
this.releasedMediaItems=false;
this.selected=false;
this.updateIcons();
},getImageDiv:function(){
return this.imageDiv;
},addIncomingLine:function(_2){
if(!this.incomingLines.include(_2)){
this.incomingLines.push(_2);
}
},getIncomingLines:function(){
return this.incomingLines;
},addOutgoingLine:function(_3){
if(!this.outgoingLines.include(_3)){
this.outgoingLines.push(_3);
}
},getOutgoingLines:function(){
return this.outgoingLines;
},addListener:function(){
this.addFieldListener("medias",this.boundUpdateFunction);
},removeListener:function(){
this.removeFieldListener("medias",this.boundUpdateFunction);
},_handleBubbleAction:function(_4){
this.handleBubbleAction(_4);
if(!_4.cancelBubble){
if(this.mapPane){
this.mapPane._handleBubbleAction(_4);
}
}
},handleBubbleAction:function(_5){
switch(_5.getType()){
case "deleteMarkerConfirmed":
_5.parameters.marker=this;
break;
case "removeMarkerConfirmed":
_5.parameters.marker=this;
break;
}
},initialize:function(_6){
if(_6==null){
return;
}
this.map=_6;
this.map.getPane(G_MAP_MARKER_PANE).appendChild(this.container);
},remove:function(){
if(this.map==null){
return;
}
if(this.map.getPane(G_MAP_MARKER_PANE)&&this.container){
try{
this.map.getPane(G_MAP_MARKER_PANE).removeChild(this.container);
}
catch(e){
}
}
if(this.mapPane&&this.mapPane.hoverObject&&this.mapPane.hoverObject==this){
this.mapPane.hoverObject=null;
}
this.map=null;
},redraw:function(_7){
if(!_7){
return;
}
if(!this.map){
this.mapPane.gmap.addOverlay(this);
return;
}
var _8=this.map.fromLatLngToDivPixel(this.get("location"));
this.container.style.left=_8.x+"px";
this.container.style.top=_8.y+"px";
if(this.highlighted){
this.container.style.zIndex=GOverlay.getZIndex(-90);
}else{
if(this.selected){
this.container.style.zIndex=GOverlay.getZIndex(-90);
}else{
var _9=GOverlay.getZIndex(this.get("location").lat());
this.container.style.zIndex=_9;
}
}
},onDragStart:function(){
if(this.id>0){
if(this.checkRights("edit")){
this.mapPane.markerButtons.hide();
this.container.onclick=null;
this.set("definitionZoomLevel",this.map.getZoom());
this.isDragging=true;
}
}
},onDragEnd:function(){
if(this.checkRights("edit")){
this.set("location",this.get("location"));
this.set("definitionZoomLevel",this.get("definitionZoomLevel"));
this.persist(function(_a){
if(_a instanceof SnapMapException){
Dialog.toggle("Error Storing",null,null,"dialog/ErrorDialog",{message:"The new position could not be stored."},this,Dialog.NORTH);
}
});
this.mapPane.markerButtons.update(this);
window.setTimeout(function(){
this.container.onclick=this.onMarkerClick.bindAsEventListener(this);
}.bind(this),10);
}
},_onMarkerClick:function(_b){
this.onMarkerClick(_b);
},onMarkerClick:function(_c){
if(this.id>0){
_c.cancelBubble=true;
if(this.mapPane){
this.mapPane.markerClick(this.id);
}
}
},_onMarkerMouseOver:function(_d){
this.onMarkerMouseOver(_d);
},onMarkerMouseOver:function(_e){
this.onMouseOver();
if(!this.isDragging){
this.onDropOver(_e);
this.mapPane.hoverObject=this;
if(this.mapPane&&!this.dropOver&&!DragDrop.isDragging){
this.mapPane.markerButtons.update(this);
this.mapPane.displayMarkerInfo(this);
}
}
},_onMarkerMouseOut:function(_f){
this.onMarkerMouseOut(_f);
},onMarkerMouseOut:function(_10){
this.onMouseOut();
this.onDropOut(_10);
if(this.mapPane){
this.mapPane.hoverObject=null;
this.mapPane.hideMarkerInfo();
}
},onMouseOver:function(){
},onMouseOut:function(){
},doDrop:function(_11){
var _12=[];
if(!(_11 instanceof Array)){
_11=[_11];
}
var _13=null;
if(this.mapPane){
var obj=this.mapPane.getSynchronizedHandler();
if(obj&&obj instanceof Story){
_13=obj;
}
}
_11.each(function(_15){
if(_15 instanceof MapPoint){
return;
}
var _16=_15.getDraggedObject();
_12.push(_16);
if(_16.getRefId("mapobject")!=null){
try{
var _17=_16.getRefFromCache("mapobject");
_17.removeFromSlot("medias",_16);
}
catch(e){
this.logger.warn("Marker could not remove media item, marker could not remove media item from marker before placing it into a new one");
}
}
_16.set("mapobject",this.id);
if(_13){
_16.set("story",_13.id);
_13.addToSlot("medias",_16);
}
}.bind(this));
this.addToSlot("medias",_12);
this.updateIcons();
this.persist();
if(_13){
_13.persist();
}
this.notifyDropListeners(obj);
},acceptDropContent:function(_18){
var _19=true;
for(var i=0;i<_18.length;i++){
if(!(_18[i] instanceof Media)){
_19=false;
}
}
return _19;
},updateIcons:function(){
var _1b="marker "+(this.styleName||"image");
if(this.selected){
_1b=_1b+" selected";
}
this.container.className=_1b;
if(this.getSlotLength("medias")>1){
var num=this.getSlotLength("medias");
var _1d="";
while(num>=1){
_1d="<img class='markerDigit' src='/styles/default/css/images/mapitems/"+num%10+".png'>"+_1d;
num-=num%10;
num/=10;
}
this.numberDiv.innerHTML=_1d;
}else{
this.numberDiv.innerHTML="";
}
},zoomAndCenter:function(){
if(this.get("viewZoomLevel")==this.map.getZoom()){
this.mapPane.panTo(this.get("location"));
}else{
this.mapPane.setCenter(this.get("location"),this.get("viewZoomLevel"));
}
},updateZoomLevel:function(){
if(this.map.getZoomLevel()>this.get("definitionZoomLevel")){
this.set("definitionZoomLevel",this.map.getZoom());
this.redraw(true);
}
},finishedStoring:function(_1e){
this.id=_1e.id;
},removeFromSlot:function(_1f,_20){
if(!(_20 instanceof Array)){
_20=[_20];
}
if(_1f=="medias"){
_20.each(function(_21){
maptales.cache.getFromCache(_21.id).set("mapobject",null);
}.bind(this));
this._removeFromSlot("medias",_20);
try{
for(var i=0;i<_20.length;i++){
var _23=_20[i].getRefFromCache("creator");
_23.addToSlot("medias",_20[i]);
}
}
catch(e){
this.logger.warn("ReleaseAssociationError: Could not add media to user after removing it from marker",e);
}
}else{
this._removeFromSlot(_1f,_20);
}
},releaseAssociations:function(){
try{
var _24=this.getSlotFromCache("medias",0,-1,null,null);
if(_24.length>0){
this.removeFromSlot("medias",_24);
}
}
catch(e){
this.logger.warn("ReleaseAssociationError: Could not release medias of marker",e);
}
},getSlotsToRelease:function(){
return ["medias"];
},isLoaded:function(){
if(this.isSlotInCache("medias",0,-1,null,null)){
return true;
}else{
return false;
}
},setSelected:function(_25){
this.selected=_25;
this.updateIcons();
}});

var Line=Class.create("Line");
Line.prototype=new MapObject();
Object.extend(Line.prototype,{doShadows:true,logger:maptales.getLogger("com.maptales.webClient.mapObjects.line"),Line_constructor:function(_1){
this.gpolyline=null;
this.logger.debug("constructor()");
this.removedControlpoints=[];
if(!_1){
_1={};
}
var _2=maptales.cache;
this.controllers=[];
if(_1.location==null){
if(_1.controlpoints!=null){
var _3=Math.floor(_1.controlpoints.length/2);
_1.location=_1.controlpoints[_3];
}else{
throw new SnapMapException("ArgumentError","No location and controlpoints passed");
}
}
this.MapObject_constructor(_1,_2);
this.boundUpdateTemp=this.updateEndPointsTemp.bind(this);
this.boundUpdate=this.updateEndPoints.bind(this);
this.boundDelete=this.onMarkerDelete.bind(this);
this.addPersistentField("controlpoints",_1.controlpoints,Field.POINTS,true);
if(_1.controlpoints!=null){
this.renderControlpointsToEncoded();
}else{
if(_1.encodedLevels==null||_1.encodedPoints==null){
throw new SnapMapException("ArgumentError","No controlpoints and encoded data passed to line");
}
this.encodedLevels=_1.encodedLevels;
this.encodedPoints=_1.encodedPoints;
}
this.timestamps=_1.timestamps||null;
if(_1.startDate){
this.startDate=convertDate(_1.startDate);
}else{
this.startDate=null;
}
if(_1.endDate){
this.endDate=convertDate(_1.endDate);
}else{
this.endDate=null;
}
this.addFieldListener("controlpoints",this.updateGPolyLine.bind(this));
this.addPersistentRef("creator",_1.creator,false,"User");
this.container.handleBubbleAction=this._handleBubbleAction.bind(this);
if(_1.startController){
this.setStartController(_1.startController);
}else{
if(_1.startMarker){
var _4=this.parseAndCacheRef(_1.startMarker,_2);
this.addPersistentRef("startMarker",_4,false,"Marker");
if(typeof _4=="number"){
_4=_2.getFromCache(_4);
}
this.setStartController(_4);
}else{
this.addPersistentRef("startMarker",null,false,"Marker");
}
}
if(_1.endController){
this.setEndController(_1.endController);
}else{
if(_1.endMarker){
var _5=this.parseAndCacheRef(_1.endMarker,_2);
this.addPersistentRef("endMarker",_5,false,"Marker");
if(typeof _5=="number"){
_5=_2.getFromCache(_5);
}
this.setEndController(_5);
}else{
this.addPersistentRef("endMarker",null,false,"Marker");
}
}
this.container.className="line";
this.visibleSegments=[];
this.visiblePoints=[];
this.isInit=true;
this.lastZoom=-1;
this.isHover=false;
this.shadowline=null;
this.mouseDiv=document.createElement("DIV");
this.mouseDiv.className="lineHoverButton";
this.mouseDiv.line=this;
this.mouseDiv.onmouseover=this.onMouseOver.bindAsEventListener(this);
this.mouseDiv.onmouseout=this.onMouseOut.bindAsEventListener(this);
this.mouseDiv.onmousedown=this.onMouseDown.bindAsEventListener(this);
this.mouseDiv.bubbleAction=function(_6){
if(_6.getType()=="deleteLineConfirmed"){
if(this.line){
this.line.doDelete();
}
}
};
this.p1Div=document.createElement("DIV");
this.p1Div.className="lineCorner";
this.p2Div=document.createElement("DIV");
this.p2Div.className="lineCorner";
this.boundDragHandler=this.onDrag.bind(this);
this.boundMouseUpHandler=this.onMouseUp.bind(this);
this.boundMouseMoveHandler=this.mouseMoved.bind(this);
var _7=document.createElement("div");
_7.className="linecolor";
if(typeof MAPTALES_LINE_COLOR!="undefined"){
var _8=MAPTALES_LINE_COLOR;
}else{
var _8=Element.getStyle(_7,"color");
}
var _9=Element.getStyle(_7,"background-color");
this.color=_8||"#ebf000";
this.backgroundColor=_9||"#000";
this.makeMasterLine();
},getLocationAtTimestamp:function(_a){
var _b=this.getControlpoints();
if(this.timestamps!=null){
for(var e=0;e<this.timestamps.length;e++){
if(_a.getTime()<=this.timestamps[e]){
var _d=convertPoint(_b[e]);
if(e>0){
var _e=convertPoint(_b[e-1]);
var _f=(_e.lat()-_d.lat());
var _10=(_e.lng()-_d.lng());
var _11=Math.abs(_a.getTime()-this.timestamps[e]);
var _12=Math.abs(_a.getTime()-this.timestamps[e-1]);
var _13=Math.abs(this.timestamps[e-1]-this.timestamps[e]);
var _14=_12/_13;
var lat=_e.lat()-(_f*_14);
var lng=_e.lng()-(_10*_14);
var _17=new GLatLng(lat,lng);
return _17;
}else{
return _d;
}
}
}
}else{
this.logger.error("Line "+this.id+" does not have timestamps but was queried for timestamps");
}
},_handleBubbleAction:function(_18){
this.handleBubbleAction(_18);
if(!_18.cancelBubble){
if(this.mapPane){
this.mapPane._handleBubbleAction(_18);
}
}
},handleBubbleAction:function(_19){
switch(_19.getType()){
case "deleteLineConfirmed":
this.mapPane.removeQueryOverlay(this);
this.getSlot("medias",0,-1,null,null,function(_1a){
if(_1a instanceof SnapMapException){
this.map.addQueryOverlay(this);
}else{
for(var i=0;i<_1a.slotItems.length;i++){
maptales.service.deleteById(_1a.slotItems[i]);
}
}
}.bind(this));
break;
}
},makeMasterLine:function(){
try{
this.masterLine=new GPolyline.fromEncoded({color:this.color,weight:2,opacity:1,points:this.encodedPoints,levels:this.encodedLevels,zoomFactor:2,numLevels:18});
}
catch(e){
}
},renderControlpointsToEncoded:function(){
var _1c=PEnc_dpEncode(this.get("controlpoints"));
this.encodedPoints=_1c.encodedPoints;
this.encodedLevels=_1c.encodedLevels;
},updateGPolyLine:function(){
if(this.encodedPoints==null){
this.renderControlpointsToEncoded();
this.makeMasterLine();
}
if(this.map){
if(this.mapPane.forceLineDrawing){
this.removeGPolyLine();
if(this.highlighted){
this.highlightline=new GPolyline.fromEncoded({color:this.color,weight:4,opacity:1,points:this.encodedPoints,levels:this.encodedLevels,zoomFactor:2,numLevels:18});
this.map.addOverlay(this.highlightline);
}else{
if(Line.prototype.doShadows){
this.shadowline=new GPolyline.fromEncoded({color:this.backgroundColor,weight:4,opacity:0.7,points:this.encodedPoints,levels:this.encodedLevels,zoomFactor:2,numLevels:18});
this.map.addOverlay(this.shadowline);
}
this.gpolyline=new GPolyline.fromEncoded({color:this.color,weight:2,opacity:1,points:this.encodedPoints,levels:this.encodedLevels,zoomFactor:2,numLevels:18});
this.map.addOverlay(this.gpolyline);
}
}
this.updateIndicationMarker();
this.clip();
}
},getCenterControlpoint:function(){
var _1d=Math.floor(this.masterLine.getVertexCount()/2);
return this.masterLine.getVertex(_1d);
},updateIndicationMarker:function(){
if(!this.mapPane.forceLineDrawing){
if(this.get("location")){
if(this.indicationMarker==null){
this.indicationMarker=new Marker({location:this.get("location"),styleName:"lineMarker"});
this.indicationMarker.onMouseOut();
this.indicationMarker.onMarkerMouseOver=function(){
this.setHighlighted(true);
this.onMouseOver();
}.bind(this);
this.indicationMarker.onMarkerClick=function(){
this.mapPane.markerClick(this.id);
}.bind(this);
this.indicationMarker.onMouseOut=function(){
this.setHighlighted(false);
}.bind(this);
}
this.indicationMarker.setMapPane(this.mapPane);
if(this.indicationMarker!=null){
this.map.addOverlay(this.indicationMarker);
this.indicationMarker=null;
}
}
}else{
if(this.indicationMarker!=null){
this.map.removeOverlay(this.indicationMarker);
this.indicationMarker=null;
}
}
},getControlpoints:function(){
if(this.get("controlpoints")!=null&&this.get("controlpoints").length>0){
return this.get("controlpoints");
}else{
var _1e=[];
for(var e=0;e<this.masterLine.getVertexCount();e++){
_1e[e]=this.masterLine.getVertex(e);
}
return _1e;
}
},updateEndPointsTemp:function(){
var cps=this.getControlpoints();
var _21=false;
if(this.startController){
var loc=this.startController.get("location");
if(!loc.equals(cps[0])){
cps[0]=this.startController.get("location");
_21=true;
}
}
if(this.endController){
var loc=this.endController.get("location");
if(!loc.equals(cps.last())){
cps[cps.length-1]=this.endController.get("location");
_21=true;
}
}
if(_21){
this.encodedPoints=null;
this.encodedLevels=null;
this.set("controlpoints",cps);
this.notifyFieldListeners("controlpoints",cps,this);
}
return _21;
},updateEndPoints:function(){
var _23=this.updateEndPointsTemp();
this.setDirty("controlpoints");
this.persist();
},removeGPolyLine:function(){
if(this.map){
if(this.highlightline){
this.map.removeOverlay(this.highlightline);
}
if(this.gpolyline){
this.map.removeOverlay(this.gpolyline);
}
if(this.shadowline){
this.map.removeOverlay(this.shadowline);
}
this.shadowline=null;
this.gpolyline=null;
this.highlightline=null;
}
},acceptDropContent:function(_24){
for(var i=0;i<_24.length;i++){
if(!(_24[i] instanceof Media)){
return false;
}
}
return true;
},doDrop:function(_26){
this.logger.trace("Line.doDrop()");
var _27=[];
if(!(_26 instanceof Array)){
_26=[_26];
}
var _28=null;
if(this.mapPane){
var obj=this.mapPane.getSynchronizedHandler();
if(obj&&obj instanceof Story){
_28=obj;
}
}
_26.each(function(_2a){
if(_2a instanceof MapPoint){
return;
}
var _2b=_2a.getDraggedObject();
_27.push(_2b);
if(_28){
_2b.set("story",_28.id);
_28.addToSlot("medias",_2b);
}
}.bind(this));
this.split(_27);
},doDelete:function(){
this.mapPane.removeQueryOverlay(this);
this.getSlot("medias",0,-1,null,null,function(_2c){
if(_2c instanceof SnapMapException){
this.map.addQueryOverlay(this);
}else{
for(var i=0;i<_2c.slotItems.length;i++){
maptales.service.deleteById(_2c.slotItems[i]);
}
}
}.bind(this));
},initialize:function(map){
this.map=map;
if(this.startController){
this.startController.addFieldListener("location",this.boundUpdateTemp);
this.startController.addDragEndListener(this.boundUpdate);
}
if(this.endController){
this.endController.addFieldListener("location",this.boundUpdateTemp);
this.endController.addDragEndListener(this.boundUpdate);
}
map.getPane(G_MAP_MARKER_PANE).appendChild(this.mouseDiv);
map.getPane(G_MAP_MARKER_PANE).appendChild(this.p1Div);
map.getPane(G_MAP_MARKER_PANE).appendChild(this.p2Div);
this.mouseMoveHandle=GEvent.addListener(map,"mousemove",this.boundMouseMoveHandler);
},mouseMoved:function(_2f){
if(!this.map){
return;
}
if(!this.mapPane.forceLineDrawing){
return;
}
if(this.mapPane){
if(this.mapPane.hoverObject&&this.mapPane.hoverObject!=this||this.mapPane.tracedLine){
this.mouseDiv.style.visibility="hidden";
return;
}
}
var _30=new Date().getTime();
var _31=this.isEditable();
var _32=-1;
var _33=null;
var _34=this.map.fromLatLngToDivPixel(_2f);
for(var i=0;i<this.visiblePoints.length;i++){
var p=this.visiblePoints[i];
var _37=(_34.x-p.x)*(_34.x-p.x)+(_34.y-p.y)*(_34.y-p.y);
if(_32==-1||_37<_32){
_32=_37;
_33=p;
this.hoverPointNum=p.num;
this.hoverSegmentNum=-1;
}
}
if(_33&&_32!=-1&&_32<49){
this.mouseDiv.style.top=_33.y+"px";
this.mouseDiv.style.left=_33.x+"px";
if(!DragDrop.isDragging){
if(_31){
this.mouseDiv.className="cornerHoverButton";
}else{
this.mouseDiv.className="lineHoverNonEditable";
}
}else{
this.mouseDiv.className="lineDropButton";
}
}
var _38=49;
if(!_31){
_38=16;
}
if(_32==-1||_32>=_38){
for(var i=0;i<this.visibleSegments.length;i++){
var p1=this.visibleSegments[i].p1;
var p2=this.visibleSegments[i].p2;
var u=((_34.x-p1.x)*(p2.x-p1.x)+(_34.y-p1.y)*(p2.y-p1.y))/((p2.x-p1.x)*(p2.x-p1.x)+(p2.y-p1.y)*(p2.y-p1.y));
if(u<=1&&u>=0){
var x=p1.x+u*(p2.x-p1.x);
var y=p1.y+u*(p2.y-p1.y);
var _37=(_34.x-x)*(_34.x-x)+(_34.y-y)*(_34.y-y);
if(_32==-1||_37<_32){
_32=_37;
this.hoverPointNum=-1;
this.hoverSegment=this.visibleSegments[i];
this.hoverSegmentNum=this.visibleSegments[i].num;
if(_37<49){
this.mouseDiv.style.top=y+"px";
this.mouseDiv.style.left=x+"px";
if(!DragDrop.isDragging){
if(_31){
this.mouseDiv.className="lineHoverButton";
}else{
this.mouseDiv.className="lineHoverNonEditable";
}
}else{
if(_31){
this.mouseDiv.className="lineDropButton";
}
}
}
}
}
}
}
if(_32==-1||_32>=49){
this.mouseDiv.style.visibility="hidden";
this.p1Div.style.visibility="hidden";
this.p2Div.style.visibility="hidden";
if(this.mapPane&&this.mapPane.hoverObject&&this.mapPane.hoverObject==this){
this.mapPane.hoverObject=null;
}
if(this.isHover){
this.isHover=false;
if(this.dropOver&&DragDrop.getActiveDropZone()==this){
DragDrop.setActiveDropZone(null);
}
}
}else{
this.mouseDiv.style.visibility="visible";
if(this.mapPane){
this.mapPane.hoverObject=this;
}
if(_31&&!DragDrop.isDragging){
var p1=null;
var p2=null;
if(this.hoverPointNum>-1){
if(_33.index>0&&(this.visiblePoints[_33.index-1].num==_33.num-1)){
p1=this.visiblePoints[_33.index-1];
}
if(_33.index<this.visiblePoints.length-1&&(this.visiblePoints[_33.index+1].num==_33.num+1)){
p2=this.visiblePoints[_33.index+1];
}
}else{
if(this.hoverSegmentNum>-1){
p1=this.hoverSegment.p1;
p2=this.hoverSegment.p2;
}
}
this.positionAdjacentPoints(p1,p2);
}
if(!this.isHover){
this.isHover=true;
this.onHover();
}
}
},positionAdjacentPoints:function(p1,p2){
if(p1){
this.p1Div.style.top=p1.y+"px";
this.p1Div.style.left=p1.x+"px";
this.p1Div.style.visibility="visible";
}else{
this.p1Div.style.visibility="hidden";
}
if(p2){
this.p2Div.style.top=p2.y+"px";
this.p2Div.style.left=p2.x+"px";
this.p2Div.style.visibility="visible";
}else{
this.p2Div.style.visibility="hidden";
}
},hideAdjacentPoints:function(){
this.p1Div.style.visibility="hidden";
this.p2Div.style.visibility="hidden";
},redraw:function(_40){
if(!this.isInit){
return;
}
this.updateIndicationMarker();
if(_40&&this.map){
this.logger.debug("v--- Line.redraw() id: "+this.id+" force: "+_40+" zoomlevel: "+this.map.getZoom());
if(this.lastZoom==-1){
this.updateGPolyLine();
this.lastZoom=this.map.getZoom();
}else{
if(this.gpolyline==null&&this.mapPane.forceLineDrawing){
this.updateGPolyLine();
}else{
this.clip();
}
}
}
},remove:function(){
this.removeGPolyLine();
if(this.startController){
this.startController.removeFieldListener("location",this.boundUpdateTemp);
this.startController.removeDragEndListener(this.boundUpdate);
}
if(this.endController){
this.endController.removeFieldListener("location",this.boundUpdateTemp);
this.endController.removeDragEndListener(this.boundUpdate);
}
if(this.mapPane&&this.mapPane.hoverObject&&this.mapPane.hoverObject==this){
this.mapPane.hoverObject=null;
}
GEvent.removeListener(this.mouseMoveHandle);
if(this.map!=null){
this.map.getPane(G_MAP_MARKER_PANE).removeChild(this.mouseDiv);
this.map.getPane(G_MAP_MARKER_PANE).removeChild(this.p1Div);
this.map.getPane(G_MAP_MARKER_PANE).removeChild(this.p2Div);
if(this.indicationMarker){
this.map.removeOverlay(this.indicationMarker);
this.indicationMarker=null;
}
this.lastZoom=-1;
this.map=null;
}
},isEditable:function(){
if(this.map&&this.checkRights("edit")&&this.id>0){
return true;
}
return false;
},split:function(_41){
if(this.isEditable()){
var _42=[];
var _43=[];
var cps=this.getControlpoints();
if(this.hoverPointNum!=null&&this.hoverPointNum>-1){
if(this.hoverPointNum==0){
this.addContentToStart(_41);
return;
}
if(this.hoverPointNum==cps.length-1){
this.addContentToEnd(_41);
return;
}
var _45=this.hoverPointNum;
var _46=cps[_45];
}else{
if(this.hoverSegmentNum!=null&&this.hoverSegmentNum>-1){
var _46=this.mapPane.fromDivPixelToLatLng({x:this.mouseDiv.offsetLeft+7,y:this.mouseDiv.offsetTop+7});
cps.splice(this.hoverSegmentNum,0,_46);
this.hoverPointNum=this.hoverSegmentNum;
this.hoverSegmentNum=-1;
var _45=this.hoverPointNum;
}else{
return;
}
}
for(var i=0;i<cps.length;i++){
if(i<=_45){
_42.push(cps[i]);
}
if(i>=_45){
_43.push(cps[i]);
}
}
if(_41 instanceof Array){
if(_41.length==0){
return;
}
var _48=maptales.service.create("Marker",{creator:maptales.service.user.getCurrentUserId(),location:_46,definitionZoomLevel:this.mapPane.getZoom(),viewZoomLevel:this.mapPane.getZoom()});
_48.setSlotLength("medias",0);
_48.addToSlot("medias",_41);
this.mapPane.addQueryOverlay(_48);
this.mapPane.store(_48,function(_49){
if(_49 instanceof SnapMapException){
Dialog.toggle("Error Storing Marker",this,null,"dialog/ErrorDialog",{message:"Due to a server error the new marker could not be stored."},_48.container,Dialog.NORTH,null,null,function(){
this.mapPane.removeQueryOverlay(_48);
_48.removeFromSlot("medias",_41);
}.bind(this));
}else{
_41.each(function(_4a){
_4a.set("mapobject",$O(_48.id));
});
this.lastZoom=-1;
var _4b=this.getRefId("endMarker");
this.set("endMarker",_48);
var _4c=maptales.service.create("Line",{creator:maptales.service.user.getCurrentUserId(),startMarker:_48.id,endMarker:_4b,controlpoints:_43,definitionZoomLevel:this.get("definitionZoomLevel"),viewZoomLevel:this.get("viewZoomLevel")});
var _4d;
try{
var _4e=this.getSlotFromCache("medias",0,1)[0];
_4d=_4e.clone();
_4d.set("creationDate",_4e.get("creationDate"));
}
catch(e){
_4d=maptales.service.create("Post",{});
try{
_4d.set("creationDate",this.get("creationDate"));
}
catch(e){
}
}
var _4f=_41[0].get("timestamp").getTime();
_4d.set("timestamp",new Date(_4f+10000));
_4c.setSlotLength("medias",0);
_4c.addToSlot("medias",_4d);
this.mapPane.store(_4c,function(_50){
if(_50 instanceof SnapMapException){
Dialog.toggle("Error Splitting Route",this,null,"dialog/ErrorDialog",{message:"Due to a server error the item could not be inserted in the exisintg route."},_48.container,Dialog.NORTH);
}else{
this.setEndController(_48);
this.encodedLevels=null;
this.encodedPoints=null;
this.set("controlpoints",_42);
this.persist();
this.mapPane.addQueryOverlay(_48);
this.redraw(true);
_4d.set("mapobject",_4c);
_4c.lastZoom=-1;
this.mapPane.addQueryOverlay(_4c);
if(this.getRefId("story")){
_4c.redraw(true);
}
}
}.bind(this));
}
}.bind(this));
}else{
if(_41 instanceof Marker){
}
}
}
},setEndController:function(_51){
if(this.endController){
this.endController.removeFieldListener("location",this.boundUpdateTemp);
this.endController.removeDragEndListener(this.boundUpdate);
this.endController.removeDeleteListener(this.boundDelete);
}
this.endController=_51;
if(this.endController){
if(this.isOnMap()){
this.endController.addFieldListener("location",this.boundUpdateTemp);
this.endController.addDragEndListener(this.boundUpdate);
}
this.endController.addDeleteListener(this.boundDelete);
}
},setStartController:function(_52){
if(this.startController){
this.startController.removeFieldListener("location",this.boundUpdateTemp);
this.startController.removeDragEndListener(this.boundUpdate);
this.startController.removeDeleteListener(this.boundDelete);
}
this.startController=_52;
if(this.startController){
if(this.isOnMap()){
this.startController.addFieldListener("location",this.boundUpdateTemp);
this.startController.addDragEndListener(this.boundUpdate);
}
this.startController.addDeleteListener(this.boundDelete);
}
},addContentToEnd:function(_53){
if(this.endController){
this.endController.addToSlot("medias",_53);
for(var i=0;i<_53.length;i++){
_53[i].set("mapobject",this.endController);
}
this.endController.persist();
}else{
var _55=maptales.service.create("Marker",{creator:maptales.service.user.getCurrentUserId(),location:this.masterLine.getVertex(this.masterLine.getVertexCount()-1),definitionZoomLevel:this.mapPane.getZoom(),viewZoomLevel:this.mapPane.getZoom()});
_55.setSlotLength("medias",0);
_55.addToSlot("medias",_53);
this.mapPane.store(_55,function(_56){
if(_56 instanceof SnapMapException){
}else{
for(var i=0;i<_53.length;i++){
_53[i].set("mapobject",_55);
}
this.set("endMarker",_55);
this.setEndController(_55);
this.persist();
this.mapPane.addQueryOverlay(_55);
}
}.bind(this));
}
},addContentToStart:function(_58){
if(this.startController){
this.startController.addToSlot("medias",_58);
for(var i=0;i<_58.length;i++){
_58[i].set("mapobject",this.startController);
}
this.startController.persist();
}else{
var _5a=maptales.service.create("Marker",{creator:maptales.service.user.getCurrentUserId(),location:this.masterLine.getVertex(0),definitionZoomLevel:this.mapPane.getZoom(),viewZoomLevel:this.mapPane.getZoom()});
_5a.setSlotLength("medias",0);
_5a.addToSlot("medias",_58);
this.mapPane.store(_5a,function(_5b){
if(_5b instanceof SnapMapException){
}else{
for(var i=0;i<_58.length;i++){
_58[i].set("mapobject",_5a);
}
this.set("startMarker",_5a);
this.setStartController(_5a);
this.persist();
this.mapPane.addQueryOverlay(_5a);
}
}.bind(this));
}
},onMarkerDelete:function(id){
if(this.startController&&id==this.startController.id){
this.startController=null;
}
if(this.endController&&id==this.endController.id){
this.endController=null;
}
},clipCode:function(_5e,_5f){
var _60=0;
var lat=_5f.lat();
var lng=_5f.lng();
if(lat<_5e.swlat){
_60=_60|1;
}else{
if(lat>_5e.nelat){
_60=_60|2;
}
}
if(_5e.swlng<_5e.nelng){
if(lng<_5e.swlng){
_60=_60|4;
}else{
if(lng>_5e.nelng){
_60=_60|8;
}
}
}else{
if(lng<_5e.swlng&&lng>_5e.nelng){
_60=_60|4;
}
}
return _60;
},clipCodeXY:function(_63,_64){
var _65=0;
var x=_64.x;
var y=_64.y;
if(x<_63.minX){
_65=_65|1;
}else{
if(x>_63.maxX){
_65=_65|2;
}
}
if(y<_63.minY){
_65=_65|4;
}else{
if(y>_63.maxY){
_65=_65|8;
}
}
return _65;
},clip:function(){
if(!this.mapPane.forceLineDrawing){
return;
}
var _68=new Date().getTime();
if(!this.map){
return;
}
var _69=this.map.getBounds();
this.visibleSegments=[];
this.visiblePoints=[];
var cps=this.getControlpoints();
if(!_69||_69.isFullLng()){
for(var i=0;i<cps.length;i++){
this.visiblePoints[i]=this.mapPane.fromLatLngToDivPixel(cps[i]);
this.visiblePoints[i].num=i;
this.visiblePoints[i].index=i;
if(i>0){
this.visibleSegments.push({p1:this.visiblePoints[i-1],p2:this.visiblePoints[i],num:i});
}
}
return true;
}
var _6c=[];
var any=false;
var _6e={swlng:_69.getSouthWest().lng(),swlat:_69.getSouthWest().lat(),nelng:_69.getNorthEast().lng(),nelat:_69.getNorthEast().lat()};
for(var i=0;i<cps.length;i++){
_6c[i]=this.clipCode(_6e,cps[i]);
var p1=null;
if(_6c[i]==0){
p1=this.mapPane.fromLatLngToDivPixel(cps[i]);
p1.num=i;
p1.index=this.visiblePoints.length;
this.visiblePoints.push(p1);
}
if(i>0){
if(_6c[i]&_6c[i-1]){
continue;
}
if(p1==null){
p1=this.mapPane.fromLatLngToDivPixel(cps[i]);
}
var p2=this.mapPane.fromLatLngToDivPixel(cps[i-1]);
this.visibleSegments.push({p1:p2,p2:p1,num:i});
any=true;
}
}
this.logger.debug("line.clip() took "+(new Date().getTime()-_68)+" ms");
return any;
},snap:function(pos,_72){
return false;
},onHover:function(_73){
this.logger.trace("Line onHover");
if(this.mapPane&&!this.isDragging&&!DragDrop.isDragging){
this.mapPane.lineButtons.update({line:this,pixel:this.mouseDiv});
}
if(DragDrop.isDragging&&this.acceptDropContent(DragDrop.getDraggedObjects())){
this.dropOver=true;
DragDrop.setActiveDropZone(this);
this.logger.trace("Line is active drop zone");
}else{
this.dropOver=false;
}
},onMouseOver:function(_74){
this.logger.trace("Line onMouseOver");
if(DragDrop.isDragging&&this.acceptDropContent(DragDrop.getDraggedObjects())){
DragDrop.setActiveDropZone(this);
Event.stop(_74);
}
},onMouseOut:function(_75){
},onMouseDown:function(_76){
if(this.mapPane){
this.mapPane.hideMarkerInfo();
}
if(this.isEditable()){
this.startDrag(_76);
}
this.mouseDiv.style.visibility="hidden";
},startDrag:function(_77){
this.insertionIndex=null;
this.insertionPoint=null;
this.overwriteControlpoint=null;
this.tempControlpoints=this.getControlpoints();
var p1=null,p2=null;
this.dragLine1=null;
this.dragLine2=null;
if(this.hoverPointNum!=null&&this.hoverPointNum>-1){
var _7a=this.tempControlpoints[this.hoverPointNum];
this.insertionIndex=this.hoverPointNum;
this.overwriteControlpoint=false;
this.insertionPoint=_7a;
var p1=this.tempControlpoints[this.hoverPointNum-1];
var p2=this.tempControlpoints[this.hoverPointNum+1];
}else{
if(this.hoverSegmentNum!=null&&this.hoverSegmentNum>-1){
var _7a=this.mapPane.fromEventToLatLng(_77);
this.insertionIndex=this.hoverSegmentNum;
this.overwriteControlpoint=true;
this.insertionPoint=_7a;
var p1=this.tempControlpoints[this.hoverSegmentNum-1];
var p2=this.tempControlpoints[this.hoverSegmentNum];
}else{
return;
}
}
this.lineControlPoint=new MapPoint({location:_7a});
this.lineControlPoint.setMapPane(this.mapPane);
this.map.addOverlay(this.lineControlPoint);
if(p1){
this.dragLine1=new LineSegment(this.lineControlPoint,new DummyPoint(p1));
this.lineControlPoint.addFieldListener("location",this.dragLine1.update.bind(this.dragLine1));
this.map.addOverlay(this.dragLine1);
}
if(p2){
this.dragLine2=new LineSegment(this.lineControlPoint,new DummyPoint(p2));
this.lineControlPoint.addFieldListener("location",this.dragLine2.update.bind(this.dragLine2));
this.map.addOverlay(this.dragLine2);
}
this._oldMapCursor=this.mapPane.getContainer().style.cursor;
this.mapPane.getContainer().style.cursor="pointer";
this.mapPane.markerButtons.hide();
this.mapPane.lineButtons.hideAll();
this.isDragging=false;
GEvent.removeListener(this.mouseMoveHandle);
Event.observe(document,"mousemove",this.boundDragHandler);
Event.observe(document,"mouseup",this.boundMouseUpHandler);
Event.stop(_77);
},onDrag:function(_7b){
if(!this.isDragging){
this.isDragging=true;
}
var cps=this.tempControlpoints;
var _7d=this.mapPane.fromEventToLatLng(_7b);
this.lineControlPoint.set("location",_7d);
this.lineControlPoint.redraw(true);
if(this.hoverPointNum!=null&&this.hoverPointNum>-1){
this.logger.warn("hoverPointNum: ");
cps[this.hoverPointNum]=_7d;
var xy=this.mapPane.fromLatLngToDivPixel(_7d);
if(cps[this.hoverPointNum-1]){
var nxy=this.mapPane.fromLatLngToDivPixel(cps[this.hoverPointNum-1]);
if(Math.abs(xy.x-nxy.x)<3&&Math.abs(xy.y-nxy.y)<3){
cps=this.removeControlpoint(cps,this.hoverPointNum-1);
this.hoverPointNum-=1;
this.insertionIndex-=1;
if(this.dragLine1&&cps[this.hoverPointNum-1]){
this.dragLine1.setEndPoint(new DummyPoint(cps[this.hoverPointNum-1]));
}else{
if(this.dragLine1){
this.map.removeOverlay(this.dragLine1);
this.dragLine1=null;
}
}
var p1=null;
if(this.hoverPointNum>0){
p1=this.mapPane.fromLatLngToDivPixel(cps[this.hoverPointNum-1]);
}
var p2=this.mapPane.fromLatLngToDivPixel(cps[this.hoverPointNum+1]);
this.positionAdjacentPoints(p1,p2);
}
}
if(cps[this.hoverPointNum+1]){
var nxy=this.mapPane.fromLatLngToDivPixel(cps[this.hoverPointNum+1]);
if(Math.abs(xy.x-nxy.x)<3&&Math.abs(xy.y-nxy.y)<3){
cps=this.removeControlpoint(cps,this.hoverPointNum);
if(this.dragLine2&&cps[this.hoverPointNum+1]){
this.dragLine2.setEndPoint(new DummyPoint(cps[this.hoverPointNum+1]));
}else{
if(this.dragLine2){
this.map.removeOverlay(this.dragLine2);
this.dragLine2=null;
}
}
var p1=this.mapPane.fromLatLngToDivPixel(cps[this.hoverPointNum-1]);
var p2=null;
if(this.hoverPointNum<cps.length-1){
p2=this.mapPane.fromLatLngToDivPixel(cps[this.hoverPointNum+1]);
}
this.positionAdjacentPoints(p1,p2);
}
}
}else{
if(this.hoverSegmentNum!=null&&this.hoverSegmentNum>-1){
this.logger.warn("hoverSegment: ");
cps.splice(this.hoverSegmentNum,0,_7d);
this.hoverPointNum=this.hoverSegmentNum;
this.hoverSegmentNum=-1;
}
}
this.logger.warn("controllpoints: "+cps.length);
this.tempControlpoints=cps;
},removeControlpoint:function(cps,_83){
this.removedControlpoints.push(_83);
cps.splice(_83,1);
return cps;
},onMouseUp:function(_84){
Event.stopObserving(document,"mouseup",this.boundMouseUpHandler);
Event.stopObserving(document,"mousemove",this.boundDragHandler);
this.mouseMoveHandle=GEvent.addListener(this.map,"mousemove",this.boundMouseMoveHandler);
var _85=this.mapPane.fromEventToLatLng(_84);
this.insertionPoint=_85;
this.mapPane.getContainer().style.cursor=this._oldMapCursor;
this.map.removeOverlay(this.lineControlPoint);
if(this.dragLine1){
this.map.removeOverlay(this.dragLine1);
this.dragLine1=null;
}
if(this.dragLine2){
this.map.removeOverlay(this.dragLine2);
this.dragLine2=null;
}
if(this.isDragging){
this.setDirty("controlpoints");
this.encodedPoints=null;
this.encodedLevels=null;
this.oldControlpoints=this.get("controlpoints");
this.set("controlpoints",this.tempControlpoints);
this.notifyFieldListeners("controlpoints",this.tempControlpoints,this);
this.clean();
maptales.service.insertControlpoint({lineId:this.id,removedControlpoints:this.removedControlpoints,point:this.insertionPoint,index:this.insertionIndex,insert:this.overwriteControlpoint},function(_86){
if(_86 instanceof SnapMapException){
this.logger.error("could not store controllpoint");
this.encodedPoints=null;
this.encodedLevels=null;
this.set("controlpoints",this.oldControlpoints);
this.notifyFieldListeners("controlpoints",this.oldControlpoints,this);
alert("An Error Occurred while storing the updates on the Line.");
}
});
this.removedControlpoints=[];
this.hideAdjacentPoints();
}
this.isDragging=false;
},getStartPoint:function(){
if(this.masterLine){
return this.masterLine.getVertex(0);
}else{
return null;
}
},getEndPoint:function(){
if(this.masterLine){
return this.masterLine.getVertex(this.masterLine.getVertexCount()-1);
}else{
return null;
}
},getClipPoints:function(_87){
var _88={minX:this.mapPane.fromLatLngToDivPixel(_87.getSouthWest()).x,maxY:this.mapPane.fromLatLngToDivPixel(_87.getSouthWest()).y,maxX:this.mapPane.fromLatLngToDivPixel(_87.getNorthEast()).x,minY:this.mapPane.fromLatLngToDivPixel(_87.getNorthEast()).y};
var _89=[];
_89[0]=[];
_89[1]=[];
_89[2]=[];
_89[3]=[];
_89[4]=[];
for(var i=0;i<this.visibleSegments.length;i++){
var _8b=this.clipSegment(this.visibleSegments[i],_88);
if(_8b!=null){
if(!_89[4][0]){
_89[4][0]=_8b.p1;
}
if(_8b.p1.clipDir){
_89[_8b.p1.clipDir-1].push(_8b.p1);
_89[4][1]=_8b.p1;
}
if(_8b.p2.clipDir){
_89[_8b.p2.clipDir-1].push(_8b.p2);
}
_89[4][1]=_8b.p2;
}
}
return _89;
},clipSegment:function(_8c,_8d){
if(!_8d){
return {p1:_8c.p1,p2:_8c.p2};
}
var _8e,_8f;
var _90=false,_91=false;
var p1={x:_8c.p1.x,y:_8c.p1.y,clipDir:0};
var p2={x:_8c.p2.x,y:_8c.p2.y,clipDir:0};
var _94=false;
if(_8d.maxX<_8d.minX){
if(_8d.maxX<0){
_8d.maxX+=360;
}else{
_8d.minX-=360;
}
}
while(!_90){
_8e=this.clipCodeXY(_8d,p1);
_8f=this.clipCodeXY(_8d,p2);
if(!(_8e|_8f)){
_90=true;
_91=true;
}else{
if(_8e&_8f){
_90=true;
}else{
if(!_8e){
var _95=p2;
p2=p1;
p1=_95;
_95=_8f;
_8f=_8e;
_8e=_95;
_94=!_94;
}
p1.changed=true;
if(p2.x!=p1.x){
var m=(p2.y-p1.y)/(p2.x-p1.x);
}
if(_8e&1){
p1.y+=(_8d.minX-p1.x)*m;
p1.x=_8d.minX;
p1.clipDir=CLIP_LEFT;
}else{
if(_8e&2){
p1.y+=(_8d.maxX-p1.x)*m;
p1.x=_8d.maxX;
p1.clipDir=CLIP_RIGHT;
}else{
if(_8e&4){
if(p2.x!=p1.x){
p1.x+=(_8d.minY-p1.y)/m;
}
p1.y=_8d.minY;
p1.clipDir=CLIP_TOP;
}else{
if(_8e&8){
if(p2.x!=p1.x){
p1.x+=(_8d.maxY-p1.y)/m;
}
p1.y=_8d.maxY;
p1.clipDir=CLIP_BOTTOM;
}
}
}
}
}
}
}
if(_91){
if(_94){
var _95=p2;
p2=p1;
p1=_95;
}
var _97,end;
return {p1:p1,p2:p2};
}else{
return null;
}
},getLength:function(){
if(this.masterLine&&this.masterLine.getLength instanceof Function){
return this.masterLine.getLength();
}else{
return 0;
}
},getBounds:function(){
return this.masterLine.getBounds();
},onDelete:function(){
},setHighlighted:function(_99){
if(this.indicationMarker){
this.indicationMarker.setHighlighted(_99);
}
if(_99!=this.highlighted&&!this.selected){
if(this.map){
if(_99){
if(!this.highlightline){
this.highlightline=new GPolyline.fromEncoded({color:this.color,weight:4,opacity:1,points:this.encodedPoints,levels:this.encodedLevels,zoomFactor:2,numLevels:18});
}
this.map.addOverlay(this.highlightline);
}else{
if(this.highlightline){
this.map.removeOverlay(this.highlightline);
}
this.highlightline=null;
}
}
this.highlighted=_99;
}
},setSelected:function(_9a){
this.setHighlighted(_9a);
}});
var PEnc_numLevels=18;
var PEnc_zoomFactor=2;
var PEnc_verySmall=0.00001;
var PEnc_forceEndpoints=true;
var PEnc_zoomLevelBreaks=new Array(PEnc_numLevels);
for(i=0;i<PEnc_numLevels;i++){
PEnc_zoomLevelBreaks[i]=PEnc_verySmall*Math.pow(PEnc_zoomFactor,PEnc_numLevels-i-1);
}
function PEnc_dpEncode(_9b){
var _9c=0;
var _9d=[];
var _9e=new Array(_9b.length);
var _9f,_a0,_a1,_a2,_a3,_a4;
var i,_a6,_a7;
var _a8;
if(_9b.length>2){
_9d.push([0,_9b.length-1]);
while(_9d.length>0){
_a4=_9d.pop();
_9f=0;
_a8=Math.pow(_9b[_a4[1]].lat()-_9b[_a4[0]].lat(),2)+Math.pow(_9b[_a4[1]].lng()-_9b[_a4[0]].lng(),2);
for(i=_a4[0]+1;i<_a4[1];i++){
_a1=PEnc_distance(_9b[i],_9b[_a4[0]],_9b[_a4[1]],_a8);
if(_a1>_9f){
_9f=_a1;
_a0=i;
if(_9f>_9c){
_9c=_9f;
}
}
}
if(_9f>PEnc_verySmall){
_9e[_a0]=_9f;
_9d.push([_a4[0],_a0]);
_9d.push([_a0,_a4[1]]);
}
}
}
_a6=PEnc_createEncodings(_9b,_9e);
_a7=PEnc_encodeLevels(_9b,_9e,_9c);
return {encodedPoints:_a6,encodedLevels:_a7,encodedPointsLiteral:_a6.replace(/\\/g,"\\\\")};
}
function PEnc_distance(p0,p1,p2,_ac){
var u,out;
if(p1.lat()===p2.lat()&&p1.lng()===p2.lng()){
out=Math.sqrt(Math.pow(p2.lat()-p0.lat(),2)+Math.pow(p2.lng()-p0.lng(),2));
}else{
u=((p0.lat()-p1.lat())*(p2.lat()-p1.lat())+(p0.lng()-p1.lng())*(p2.lng()-p1.lng()))/_ac;
if(u<=0){
out=Math.sqrt(Math.pow(p0.lat()-p1.lat(),2)+Math.pow(p0.lng()-p1.lng(),2));
}
if(u>=1){
out=Math.sqrt(Math.pow(p0.lat()-p2.lat(),2)+Math.pow(p0.lng()-p2.lng(),2));
}
if(0<u&&u<1){
out=Math.sqrt(Math.pow(p0.lat()-p1.lat()-u*(p2.lat()-p1.lat()),2)+Math.pow(p0.lng()-p1.lng()-u*(p2.lng()-p1.lng()),2));
}
}
return out;
}
function PEnc_createEncodings(_af,_b0){
var i,_b2,_b3;
var _b4=0;
var _b5=0;
var _b6="";
for(i=0;i<_af.length;i++){
if(_b0[i]!=undefined||i==0||i==_af.length-1){
var _b7=_af[i];
var lat=_b7.lat();
var lng=_b7.lng();
var _ba=Math.floor(lat*100000);
var _bb=Math.floor(lng*100000);
_b2=_ba-_b4;
_b3=_bb-_b5;
_b4=_ba;
_b5=_bb;
_b6+=PEnc_encodeSignedNumber(_b2)+PEnc_encodeSignedNumber(_b3);
}
}
return _b6;
}
function PEnc_computeLevel(dd){
var lev;
if(dd>PEnc_verySmall){
lev=0;
while(dd<PEnc_zoomLevelBreaks[lev]){
lev++;
}
return lev;
}
}
function PEnc_encodeLevels(_be,_bf,_c0){
var i;
var _c2="";
_c2+=PEnc_encodeNumber(PEnc_numLevels-1);
for(i=1;i<_be.length-1;i++){
if(_bf[i]!=undefined){
_c2+=PEnc_encodeNumber(PEnc_numLevels-PEnc_computeLevel(_bf[i])-1);
}
}
if(PEnc_forceEndpoints){
_c2+=PEnc_encodeNumber(PEnc_numLevels-1);
}else{
_c2+=PEnc_encodeNumber(PEnc_numLevels-PEnc_computeLevel(_c0)-1);
}
return _c2;
}
function PEnc_encodeNumber(num){
var _c4="";
var _c5,_c6;
while(num>=32){
_c5=(32|(num&31))+63;
_c4+=(String.fromCharCode(_c5));
num>>=5;
}
_c6=num+63;
_c4+=(String.fromCharCode(_c6));
return _c4;
}
function PEnc_encodeSignedNumber(num){
var _c8=num<<1;
if(num<0){
_c8=~(_c8);
}
return (PEnc_encodeNumber(_c8));
}

var CLIP_NONE=0;
var CLIP_TOP=1;
var CLIP_LEFT=2;
var CLIP_BOTTOM=3;
var CLIP_RIGHT=4;
var LineSegment=Class.create("LineSegment");
LineSegment.prototype=new MapObject();
Object.extend(LineSegment.prototype,{LineSegment_constructor:function(_1,_2){
this.startPoint=_1;
this.clippedStart=_1;
this.endPoint=_2;
this.clippedEnd=_2;
this.spacing=10;
this.container=document.createElement("div");
this.container.className="linesegment";
this.pixel=[];
this.isVisible=true;
},setStartPoint:function(_3){
this.startPoint=_3;
this.clippedStart=_3;
this.calcSpacing();
},setEndPoint:function(_4){
this.endPoint=_4;
this.clippedEnd=_4;
this.calcSpacing();
},calcSpacing:function(){
var _5=this.startPoint.getPixelPoint();
var _6=this.endPoint.getPixelPoint();
var dx=_6.x-_5.x;
var dy=_6.y-_5.y;
var _9=Math.sqrt(dx*dx+dy*dy);
this.spacing=Math.round(Math.sqrt(_9/2));
if(this.spacing<4){
this.spacing=4;
}
if(this.spacing>40){
this.spacing=40;
}
},clipCode:function(_a,_b){
var _c=0;
if(_b.x<_a.minX){
_c=_c|1;
}else{
if(_b.x>_a.maxX){
_c=_c|2;
}
}
if(_b.y<_a.minY){
_c=_c|4;
}else{
if(_b.y>_a.maxY){
_c=_c|8;
}
}
return _c;
},clip:function(_d){
if(!_d){
this.isVisible=true;
this.clippedStart=this.startPoint;
this.clippedEnd=this.endPoint;
return true;
}
var _e,_f;
var _10=false,_11=false;
var p1={x:this.startPoint.get("location").lng(),y:this.startPoint.get("location").lat(),clipDir:0};
var p2={x:this.endPoint.get("location").lng(),y:this.endPoint.get("location").lat(),clipDir:0};
var _14=false;
if(_d.maxX<_d.minX){
if(_d.maxX<0){
_d.maxX+=360;
}else{
_d.minX-=360;
}
}
while(!_10){
_e=this.clipCode(_d,p1);
_f=this.clipCode(_d,p2);
if(!(_e|_f)){
_10=true;
_11=true;
}else{
if(_e&_f){
_10=true;
}else{
if(!_e){
var _15=p2;
p2=p1;
p1=_15;
_15=_f;
_f=_e;
_e=_15;
_14=!_14;
}
p1.changed=true;
if(p2.x!=p1.x){
var m=(p2.y-p1.y)/(p2.x-p1.x);
}
if(_e&1){
p1.y+=(_d.minX-p1.x)*m;
p1.x=_d.minX;
p1.clipDir=CLIP_LEFT;
}else{
if(_e&2){
p1.y+=(_d.maxX-p1.x)*m;
p1.x=_d.maxX;
p1.clipDir=CLIP_RIGHT;
}else{
if(_e&4){
if(p2.x!=p1.x){
p1.x+=(_d.minY-p1.y)/m;
}
p1.y=_d.minY;
p1.clipDir=CLIP_BOTTOM;
}else{
if(_e&8){
if(p2.x!=p1.x){
p1.x+=(_d.maxY-p1.y)/m;
}
p1.y=_d.maxY;
p1.clipDir=CLIP_TOP;
}
}
}
}
}
}
}
if(_11){
this.isVisible=true;
if(_14){
var _15=p2;
p2=p1;
p1=_15;
}
if(p1.changed){
this.clippedStart=new ClipPoint(new GLatLng(p1.y,p1.x),p1.clipDir);
}else{
this.clippedStart=this.startPoint;
}
if(p2.changed){
this.clippedEnd=new ClipPoint(new GLatLng(p2.y,p2.x),p2.clipDir);
}else{
this.clippedEnd=this.endPoint;
}
}else{
this.isVisible=false;
this.clippedStart=this.startPoint;
this.clippedEnd=this.endPoint;
}
return this.isVisible;
},intersect:function(_17){
if(!_17){
return {start:this.startPoint,end:this.endPoint};
}
var _18,_19;
var _1a=false,_1b=false;
var p1={x:this.startPoint.get("location").lng(),y:this.startPoint.get("location").lat(),clipDir:0};
var p2={x:this.endPoint.get("location").lng(),y:this.endPoint.get("location").lat(),clipDir:0};
var _1e=false;
if(_17.maxX<_17.minX){
if(_17.maxX<0){
_17.maxX+=360;
}else{
_17.minX-=360;
}
}
while(!_1a){
_18=this.clipCode(_17,p1);
_19=this.clipCode(_17,p2);
if(!(_18|_19)){
_1a=true;
_1b=true;
}else{
if(_18&_19){
_1a=true;
}else{
if(!_18){
var _1f=p2;
p2=p1;
p1=_1f;
_1f=_19;
_19=_18;
_18=_1f;
_1e=!_1e;
}
p1.changed=true;
if(p2.x!=p1.x){
var m=(p2.y-p1.y)/(p2.x-p1.x);
}
if(_18&1){
p1.y+=(_17.minX-p1.x)*m;
p1.x=_17.minX;
p1.clipDir=CLIP_LEFT;
}else{
if(_18&2){
p1.y+=(_17.maxX-p1.x)*m;
p1.x=_17.maxX;
p1.clipDir=CLIP_RIGHT;
}else{
if(_18&4){
if(p2.x!=p1.x){
p1.x+=(_17.minY-p1.y)/m;
}
p1.y=_17.minY;
p1.clipDir=CLIP_BOTTOM;
}else{
if(_18&8){
if(p2.x!=p1.x){
p1.x+=(_17.maxY-p1.y)/m;
}
p1.y=_17.maxY;
p1.clipDir=CLIP_TOP;
}
}
}
}
}
}
}
if(_1b){
if(_1e){
var _1f=p2;
p2=p1;
p1=_1f;
}
var _21,end;
if(p1.changed){
_21=new ClipPoint(new GLatLng(p1.y,p1.x),p1.clipDir);
}else{
_21=this.startPoint;
}
if(p2.changed){
end=new ClipPoint(new GLatLng(p2.y,p2.x),p2.clipDir);
}else{
end=this.endPoint;
}
return {start:_21,end:end};
}else{
return null;
}
},update:function(){
if(this.isVisible){
var x1=this.clippedStart.get("location").lng();
var x2=this.clippedEnd.get("location").lng();
var p1=this.clippedStart;
var p2=this.clippedEnd;
if((x1>x2&&x1-x2<180)||(x1<x2&&x2-x1>180)){
var tmp=p2;
p2=p1;
p1=tmp;
}
this.calcSpacing();
var _28=p1.getPixelPoint();
var _29=p2.getPixelPoint();
if(_28.x>_29.x){
return;
}
this.container.style.display="block";
this.container.style.top=_28.y+"px";
this.container.style.left=_28.x+"px";
var i=0;
if(Math.max(Math.abs(_28.x-_29.x),Math.abs(_28.y-_29.y))<4){
this.setPixel(i++,-1,-1);
}else{
var _2b=-1;
var _2c=_29.x-_28.x-1;
var _2d=-1;
var _2e=_29.y-_28.y-1;
var dx=_2c-_2b;
var dy=_2e-_2d;
var _31=1,_32=1;
var x=_2b;
var y=_2d;
if(dx<0){
_31=-1;
dx=-dx;
}
if(dy<0){
_32=-1;
dy=-dy;
}
var D=0,c,M;
if(dy<=dx){
c=2*dx;
M=2*dy;
for(;;){
if(x%this.spacing==0){
this.setPixel(i++,x,y);
}
if(x==_2c){
break;
}
x+=_31;
D+=M;
if(D>dx){
y+=_32;
D-=c;
}
}
}else{
c=2*dy;
M=2*dx;
for(;;){
if(y%this.spacing==0){
this.setPixel(i++,x,y);
}
if(y==_2e){
break;
}
y+=_32;
D+=M;
if(D>dy){
x+=_31;
D-=c;
}
}
}
}
for(;i<this.pixel.length;i++){
this.pixel[i].style.display="none";
}
}
},setPixel:function(i,x,y){
if(!this.pixel[i]){
this.pixel[i]=document.createElement("div");
this.pixel[i].className="linepixel";
this.pixel[i].line=this;
this.container.appendChild(this.pixel[i]);
}
this.pixel[i].style.display="block";
this.pixel[i].style.left=x+"px";
this.pixel[i].style.top=y+"px";
},initialize:function(map){
this.map=map;
this.map.getPane(G_MAP_MARKER_PANE).appendChild(this.container);
},remove:function(){
try{
this.map.getPane(G_MAP_MARKER_PANE).removeChild(this.container);
}
catch(e){
}
this.map=null;
this.isVisible=false;
},removeLater:function(){
window.setTimeout(function(){
if(this.mapPane){
this.mapPane.removeTempOverlay(this);
}
}.bind(this),1);
},redraw:function(_3c){
if(_3c){
this.update();
}
},snap:function(_3d,_3e){
return false;
},clip:function(_3f){
true;
}});
function ClipPoint(_40,_41){
this.location=convertPoint(_40);
this.clipDir=_41;
this.clipPoint=true;
this.get=function(_42){
if(_42=="location"){
return this.location;
}
};
this.getPixelPoint=function(){
return maptales.ui.getMainMap().fromLatLngToDivPixel(this.location);
};
}
function DummyPoint(_43){
this.location=convertPoint(_43);
this.get=function(_44){
if(_44=="location"){
return this.location;
}
};
this.getPixelPoint=function(){
return maptales.ui.getMainMap().fromLatLngToDivPixel(this.location);
};
}

var ZoomBoxControl=Class.create("ZoomBoxControl");
ZoomBoxControl.prototype=new GControl();
Object.extend(ZoomBoxControl.prototype,{ZoomBoxControl_constructor:function(){
},initialize:function(_1){
this.map=_1;
this.zoomBox=document.createElement("div");
this.zoomBox.className="zoomBox";
this.zoomBoxText1=document.createElement("div");
this.zoomBoxText1.className="zoomBoxText";
this.zoomBoxText1.innerHTML="click to zoom";
this.zoomBoxText1.style.display="none";
this.zoomBox.appendChild(this.zoomBoxText1);
this.zoomBoxInner=document.createElement("div");
this.zoomBoxInner.className="zoomBoxInner";
this.zoomBox.appendChild(this.zoomBoxInner);
this.container=document.createElement("div");
this.captureDiv=document.createElement("div");
this.captureDiv.id="CAPTURE";
this.captureDiv.style.width="100%";
this.captureDiv.style.height="100%";
this.captureDiv.style.position="absolute";
this.captureDiv.style.top="0px";
this.captureDiv.style.left="0px";
this.active=false;
this.isDragging=false;
this._boundDragStart=this.dragStart.bind(this);
this._boundDragMove=this.dragMove.bind(this);
this._boundDragEnd=this.dragEnd.bind(this);
this.map.getContainer().appendChild(this.zoomBox);
this.map.getContainer().appendChild(this.container);
return this.container;
},toggleButton:function(){
this.setActive(!this.active);
},setActive:function(_2){
if(!_2){
this.active=false;
this.zoomBox.style.display="none";
this.map.enableDragging();
this.map.getContainer().removeChild(this.captureDiv);
Event.stopObserving(this.map.getContainer(),"mousedown",this._boundDragStart);
$m("zoomBoxDisabled");
}else{
this.active=true;
this.map.disableDragging();
var _3=this.map.getContainer();
_3.insertBefore(this.captureDiv,_3.childNodes[1]);
Event.observe(this.map.getContainer(),"mousedown",this._boundDragStart);
$m("zoomBoxEnabled");
}
},dragStart:function(_4){
this.zoomBoxText1.style.display="none";
Event.observe(this.map.getContainer(),"mousemove",this._boundDragMove);
Event.observe(this.map.getContainer(),"mouseup",this._boundDragEnd);
var _5=[Event.pointerX(_4),Event.pointerY(_4)];
var _6=Position.cumulativeOffset(this.map.getContainer());
this.startX=_5[0]-_6[0];
this.startY=_5[1]-_6[1];
},dragMove:function(_7){
var _8=[Event.pointerX(_7),Event.pointerY(_7)];
var _9=Position.cumulativeOffset(this.map.getContainer());
var x=_8[0]-_9[0];
var y=_8[1]-_9[1];
var _c=Math.abs(x-this.startX);
var _d=Math.abs(y-this.startY);
if(!this.isDragging){
if(_c>5||_d>5){
this.isDragging=true;
this.zoomBox.onmouseover=null;
this.zoomBox.onmouseout=null;
this.zoomBox.onclick=null;
}
}else{
this.zoomBox.style.top=Math.min(y,this.startY)+"px";
this.zoomBox.style.left=Math.min(x,this.startX)+"px";
this.zoomBox.style.width=_c+"px";
this.zoomBox.style.height=_d+"px";
this.zoomBox.style.display="block";
}
},dragEnd:function(_e){
Event.stopObserving(this.map.getContainer(),"mousemove",this._boundDragMove);
Event.stopObserving(this.map.getContainer(),"mouseup",this._boundDragEnd);
if(!this.isDragging){
this.zoomBox.style.display="none";
return;
}
var _f=[Event.pointerX(_e),Event.pointerY(_e)];
var _10=Position.cumulativeOffset(this.map.getContainer());
var x=_f[0]-_10[0];
var y=_f[1]-_10[1];
if(Math.abs(x-this.startX)<5&&Math.abs(y-this.startY)<5){
return;
}
var sw=this.map.fromContainerPixelToLatLng(new GPoint(Math.min(x,this.startX),Math.max(y,this.startY)));
var ne=this.map.fromContainerPixelToLatLng(new GPoint(Math.max(x,this.startX),Math.min(y,this.startY)));
this.center=this.map.fromContainerPixelToLatLng(new GPoint((x+this.startX)/2,(y+this.startY)/2));
var _15=new GLatLngBounds(sw,ne);
this.zoom=this.map.getBoundsZoomLevel(_15);
this.zoomBox.onmouseover=this.zoomBoxOver.bind(this);
this.zoomBox.onmouseout=this.zoomBoxOut.bind(this);
this.zoomBox.onclick=this.zoomBoxClick.bind(this);
this.zoomBoxOver();
this.isDragging=false;
this.zoomBoxText1.style.display="block";
},zoomBoxOver:function(){
this.zoomBoxInner.style.opacity="0.3";
this.zoomBoxInner.style.filter="alpha(opacity=30)";
},zoomBoxOut:function(){
this.zoomBoxInner.style.opacity="0.1";
this.zoomBoxInner.style.filter="alpha(opacity=10)";
},zoomBoxClick:function(){
this.zoomBox.style.display="none";
this.zoomBoxOut();
this.map.setCenter(this.center,this.zoom);
this.setActive(false);
this.zoomBox.onmouseover=null;
this.zoomBox.onmouseout=null;
this.zoomBox.onclick=null;
},getDefaultPosition:function(){
return new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(20,7));
}});
