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];
};
}

function validateEmail(_1){
var _2=true;
var _3=null;
var i=0;
var _5=new Array();
var _6=eval("new "+jcv_retrieveFormName(_1)+"_email()");
for(var x in _6){
if(!jcv_verifyArrayElement(x,_6[x])){
continue;
}
var _8=_1[_6[x][0]];
if(!jcv_isFieldPresent(_8)){
continue;
}
if((_8.type=="hidden"||_8.type=="text"||_8.type=="textarea")&&(_8.value.length>0)){
if(!jcv_checkEmail(_8.value)){
if(i==0){
_3=_8;
}
_5[i++]=_6[x][1];
_2=false;
}
}
}
if(_5.length>0){
jcv_handleErrors(_5,_3);
}
return _2;
}
function jcv_checkEmail(_9){
if(_9.length==0){
return true;
}
var _a=0;
var _b=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var _c=/^(.+)@(.+)$/;
var _d="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var _e="[^\\s"+_d+"]";
var _f="(\"[^\"]*\")";
var _10=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var _11=_e+"+";
var _12="("+_11+"|"+_f+")";
var _13=new RegExp("^"+_12+"(\\."+_12+")*$");
var _14=new RegExp("^"+_11+"(\\."+_11+")*$");
var _15=_9.match(_c);
var i;
if(_15==null){
return false;
}
var _17=_15[1];
var _18=_15[2];
for(i=0;i<_17.length;i++){
if(_17.charCodeAt(i)>127){
return false;
}
}
for(i=0;i<_18.length;i++){
if(_18.charCodeAt(i)>127){
return false;
}
}
if(_17.match(_13)==null){
return false;
}
var _19=_18.match(_10);
if(_19!=null){
for(var i=1;i<=4;i++){
if(_19[i]>255){
return false;
}
}
return true;
}
var _1a=new RegExp("^"+_11+"$");
var _1b=_18.split(".");
var len=_1b.length;
for(i=0;i<len;i++){
if(_1b[i].search(_1a)==-1){
return false;
}
}
if(_a&&_1b[_1b.length-1].length!=2&&_1b[_1b.length-1].search(_b)==-1){
return false;
}
if(len<2){
return false;
}
return true;
}

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);
};
})();

var SWFUpload=function(_1){
this.initSWFUpload(_1);
};
SWFUpload.prototype.initSWFUpload=function(_2){
try{
document.execCommand("BackgroundImageCache",false,true);
}
catch(ex1){
}
try{
this.customSettings={};
this.settings={};
this.eventQueue=[];
this.movieName="SWFUpload_"+SWFUpload.movieCount++;
this.movieElement=null;
SWFUpload.instances[this.movieName]=this;
this.initSettings(_2);
this.loadFlash();
this.displayDebugInfo();
}
catch(ex2){
this.debug(ex2);
}
};
SWFUpload.instances={};
SWFUpload.movieCount=0;
SWFUpload.QUEUE_ERROR={QUEUE_LIMIT_EXCEEDED:-100,FILE_EXCEEDS_SIZE_LIMIT:-110,ZERO_BYTE_FILE:-120,INVALID_FILETYPE:-130};
SWFUpload.UPLOAD_ERROR={HTTP_ERROR:-200,MISSING_UPLOAD_URL:-210,IO_ERROR:-220,SECURITY_ERROR:-230,UPLOAD_LIMIT_EXCEEDED:-240,UPLOAD_FAILED:-250,SPECIFIED_FILE_ID_NOT_FOUND:-260,FILE_VALIDATION_FAILED:-270,FILE_CANCELLED:-280,UPLOAD_STOPPED:-290};
SWFUpload.FILE_STATUS={QUEUED:-1,IN_PROGRESS:-2,ERROR:-3,COMPLETE:-4,CANCELLED:-5};
SWFUpload.prototype.initSettings=function(_3){
this.addSetting("upload_url",_3.upload_url,"");
this.addSetting("file_post_name",_3.file_post_name,"Filedata");
this.addSetting("post_params",_3.post_params,{});
this.addSetting("file_types",_3.file_types,"*.*");
this.addSetting("file_types_description",_3.file_types_description,"All Files");
this.addSetting("file_size_limit",_3.file_size_limit,"1024");
this.addSetting("file_upload_limit",_3.file_upload_limit,"0");
this.addSetting("file_queue_limit",_3.file_queue_limit,"0");
this.addSetting("flash_url",_3.flash_url,"swfupload.swf");
this.addSetting("flash_width",_3.flash_width,"1px");
this.addSetting("flash_height",_3.flash_height,"1px");
this.addSetting("flash_color",_3.flash_color,"#FFFFFF");
this.addSetting("debug_enabled",_3.debug,false);
this.flashReady_handler=SWFUpload.flashReady;
this.swfUploadLoaded_handler=this.retrieveSetting(_3.swfupload_loaded_handler,SWFUpload.swfUploadLoaded);
this.fileDialogStart_handler=this.retrieveSetting(_3.file_dialog_start_handler,SWFUpload.fileDialogStart);
this.fileQueued_handler=this.retrieveSetting(_3.file_queued_handler,SWFUpload.fileQueued);
this.fileQueueError_handler=this.retrieveSetting(_3.file_queue_error_handler,SWFUpload.fileQueueError);
this.fileDialogComplete_handler=this.retrieveSetting(_3.file_dialog_complete_handler,SWFUpload.fileDialogComplete);
this.uploadStart_handler=this.retrieveSetting(_3.upload_start_handler,SWFUpload.uploadStart);
this.uploadProgress_handler=this.retrieveSetting(_3.upload_progress_handler,SWFUpload.uploadProgress);
this.uploadError_handler=this.retrieveSetting(_3.upload_error_handler,SWFUpload.uploadError);
this.uploadSuccess_handler=this.retrieveSetting(_3.upload_success_handler,SWFUpload.uploadSuccess);
this.uploadComplete_handler=this.retrieveSetting(_3.upload_complete_handler,SWFUpload.uploadComplete);
this.debug_handler=this.retrieveSetting(_3.debug_handler,SWFUpload.debug);
this.customSettings=this.retrieveSetting(_3.custom_settings,{});
};
SWFUpload.prototype.loadFlash=function(){
var _4,_5,_6;
if(document.getElementById(this.movieName)!==null){
return false;
}
try{
_5=document.getElementsByTagName("body")[0];
if(typeof (_5)==="undefined"||_5===null){
this.debug("Could not find the BODY element. SWFUpload failed to load.");
return false;
}
}
catch(ex){
return false;
}
_6=document.createElement("div");
_6.style.width=this.getSetting("flash_width");
_6.style.height=this.getSetting("flash_height");
_5.appendChild(_6);
_6.innerHTML=this.getFlashHTML();
};
SWFUpload.prototype.getFlashHTML=function(){
var _7="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
_7="<embed type=\"application/x-shockwave-flash\" src=\""+this.getSetting("flash_url")+"\" width=\""+this.getSetting("flash_width")+"\" height=\""+this.getSetting("flash_height")+"\"";
_7+=" id=\""+this.movieName+"\" name=\""+this.movieName+"\" ";
_7+="bgcolor=\""+this.getSetting("flash_color")+"\" quality=\"high\" menu=\"false\" flashvars=\"";
_7+=this.getFlashVars();
_7+="\" />";
}else{
_7="<object id=\""+this.movieName+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getSetting("flash_width")+"\" height=\""+this.getSetting("flash_height")+"\">";
_7+="<param name=\"movie\" value=\""+this.getSetting("flash_url")+"\">";
_7+="<param name=\"bgcolor\" value=\""+this.getSetting("flash_color")+"\" />";
_7+="<param name=\"quality\" value=\"high\" />";
_7+="<param name=\"menu\" value=\"false\" />";
_7+="<param name=\"flashvars\" value=\""+this.getFlashVars()+"\" />";
_7+="</object>";
}
return _7;
};
SWFUpload.prototype.getFlashVars=function(){
var _8=this.buildParamString();
var _9="";
_9+="movieName="+encodeURIComponent(this.movieName);
_9+="&uploadURL="+encodeURIComponent(this.getSetting("upload_url"));
_9+="&params="+encodeURIComponent(_8);
_9+="&filePostName="+encodeURIComponent(this.getSetting("file_post_name"));
_9+="&fileTypes="+encodeURIComponent(this.getSetting("file_types"));
_9+="&fileTypesDescription="+encodeURIComponent(this.getSetting("file_types_description"));
_9+="&fileSizeLimit="+encodeURIComponent(this.getSetting("file_size_limit"));
_9+="&fileUploadLimit="+encodeURIComponent(this.getSetting("file_upload_limit"));
_9+="&fileQueueLimit="+encodeURIComponent(this.getSetting("file_queue_limit"));
_9+="&debugEnabled="+encodeURIComponent(this.getSetting("debug_enabled"));
return _9;
};
SWFUpload.prototype.getMovieElement=function(){
if(typeof (this.movieElement)==="undefined"||this.movieElement===null){
this.movieElement=document.getElementById(this.movieName);
}
return this.movieElement;
};
SWFUpload.prototype.buildParamString=function(){
var _a=this.getSetting("post_params");
var _b=[];
var i,_d,_e;
if(typeof (_a)==="object"){
for(_e in _a){
if(_a.hasOwnProperty(_e)){
if(typeof (_a[_e])==="string"){
_b.push(encodeURIComponent(_e)+"="+encodeURIComponent(_a[_e]));
}
}
}
}
return _b.join("&");
};
SWFUpload.prototype.addSetting=function(_f,_10,_11){
if(typeof (_10)==="undefined"||_10===null){
this.settings[_f]=_11;
}else{
this.settings[_f]=_10;
}
return this.settings[_f];
};
SWFUpload.prototype.getSetting=function(_12){
if(typeof (this.settings[_12])==="undefined"){
return "";
}else{
return this.settings[_12];
}
};
SWFUpload.prototype.retrieveSetting=function(_13,_14){
if(typeof (_13)==="undefined"||_13===null){
return _14;
}else{
return _13;
}
};
SWFUpload.prototype.displayDebugInfo=function(){
var key,_16="";
_16+="----- SWFUPLOAD SETTINGS     ----\nID: "+this.moveName+"\n";
_16+=this.outputObject(this.settings);
_16+="----- SWFUPLOAD SETTINGS END ----\n";
_16+="\n";
this.debug(_16);
};
SWFUpload.prototype.outputObject=function(_17,_18){
var _19="",key;
if(typeof (_18)!=="string"){
_18="";
}
if(typeof (_17)!=="object"){
return "";
}
for(key in _17){
if(_17.hasOwnProperty(key)){
if(typeof (_17[key])==="object"){
_19+=(_18+key+": { \n"+this.outputObject(_17[key],"\t"+_18)+_18+"}"+"\n");
}else{
_19+=(_18+key+": "+_17[key]+"\n");
}
}
}
return _19;
};
SWFUpload.prototype.selectFile=function(){
var _1b=this.getMovieElement();
if(_1b!==null&&typeof (_1b.SelectFile)==="function"){
try{
_1b.SelectFile();
}
catch(ex){
this.debug("Could not call SelectFile: "+ex);
}
}else{
this.debug("Could not find Flash element");
}
};
SWFUpload.prototype.selectFiles=function(){
var _1c=this.getMovieElement();
if(_1c!==null&&typeof (_1c.SelectFiles)==="function"){
try{
_1c.SelectFiles();
}
catch(ex){
this.debug("Could not call SelectFiles: "+ex);
}
}else{
this.debug("Could not find Flash element");
}
};
SWFUpload.prototype.startUpload=function(_1d){
var _1e=this;
var _1f=this.getMovieElement();
if(_1f!==null&&typeof (_1f.StartUpload)==="function"){
setTimeout(function(){
try{
_1f.StartUpload(_1d);
}
catch(ex){
_1e.debug("Could not call StartUpload: "+ex);
}
},0);
}else{
this.debug("Could not find Flash element");
}
};
SWFUpload.prototype.cancelUpload=function(_20){
var _21=this.getMovieElement();
if(_21!==null&&typeof (_21.CancelUpload)==="function"){
try{
_21.CancelUpload(_20);
}
catch(ex){
this.debug("Could not call CancelUpload: "+ex);
}
}else{
this.debug("Could not find Flash element");
}
};
SWFUpload.prototype.stopUpload=function(){
var _22=this.getMovieElement();
if(_22!==null&&typeof (_22.StopUpload)==="function"){
try{
_22.StopUpload();
}
catch(ex){
this.debug("Could not call StopUpload: "+ex);
}
}else{
this.debug("Could not find Flash element");
}
};
SWFUpload.prototype.getStats=function(){
var _23=this;
var _24=this.getMovieElement();
if(_24!==null&&typeof (_24.GetStats)==="function"){
try{
return _24.GetStats();
}
catch(ex){
_23.debug("Could not call GetStats");
}
}else{
this.debug("Could not find Flash element");
}
};
SWFUpload.prototype.setStats=function(_25){
var _26=this;
var _27=this.getMovieElement();
if(_27!==null&&typeof (_27.SetStats)==="function"){
try{
_27.SetStats(_25);
}
catch(ex){
_26.debug("Could not call SetStats");
}
}else{
this.debug("Could not find Flash element");
}
};
SWFUpload.prototype.getFile=function(_28){
var _29=this;
var _2a=this.getMovieElement();
if(typeof (_28)==="number"){
if(_2a!==null&&typeof (_2a.GetFileByIndex)==="function"){
try{
return _2a.GetFileByIndex(_28);
}
catch(ex){
_29.debug("Could not call GetFileByIndex");
}
}else{
this.debug("Could not find Flash element");
}
}else{
if(_2a!==null&&typeof (_2a.GetFile)==="function"){
try{
return _2a.GetFile(_28);
}
catch(ex){
_29.debug("Could not call GetFile");
}
}else{
this.debug("Could not find Flash element");
}
}
};
SWFUpload.prototype.addFileParam=function(_2b,_2c,_2d){
var _2e=this;
var _2f=this.getMovieElement();
if(_2f!==null&&typeof (_2f.AddFileParam)==="function"){
try{
return _2f.AddFileParam(_2b,_2c,_2d);
}
catch(ex){
_2e.debug("Could not call AddFileParam");
}
}else{
this.debug("Could not find Flash element");
}
};
SWFUpload.prototype.removeFileParam=function(_30,_31){
var _32=this;
var _33=this.getMovieElement();
if(_33!==null&&typeof (_33.RemoveFileParam)==="function"){
try{
return _33.RemoveFileParam(_30,_31);
}
catch(ex){
_32.debug("Could not call AddFileParam");
}
}else{
this.debug("Could not find Flash element");
}
};
SWFUpload.prototype.setUploadURL=function(url){
var _35=this.getMovieElement();
if(_35!==null&&typeof (_35.SetUploadURL)==="function"){
try{
this.addSetting("upload_url",url);
_35.SetUploadURL(this.getSetting("upload_url"));
}
catch(ex){
this.debug("Could not call SetUploadURL");
}
}else{
this.debug("Could not find Flash element in setUploadURL");
}
};
SWFUpload.prototype.setPostParams=function(_36){
var _37=this.getMovieElement();
if(_37!==null&&typeof (_37.SetPostParams)==="function"){
try{
this.addSetting("post_params",_36);
_37.SetPostParams(this.getSetting("post_params"));
}
catch(ex){
this.debug("Could not call SetPostParams");
}
}else{
this.debug("Could not find Flash element in SetPostParams");
}
};
SWFUpload.prototype.setFileTypes=function(_38,_39){
var _3a=this.getMovieElement();
if(_3a!==null&&typeof (_3a.SetFileTypes)==="function"){
try{
this.addSetting("file_types",_38);
this.addSetting("file_types_description",_39);
_3a.SetFileTypes(this.getSetting("file_types"),this.getSetting("file_types_description"));
}
catch(ex){
this.debug("Could not call SetFileTypes");
}
}else{
this.debug("Could not find Flash element in SetFileTypes");
}
};
SWFUpload.prototype.setFileSizeLimit=function(_3b){
var _3c=this.getMovieElement();
if(_3c!==null&&typeof (_3c.SetFileSizeLimit)==="function"){
try{
this.addSetting("file_size_limit",_3b);
_3c.SetFileSizeLimit(this.getSetting("file_size_limit"));
}
catch(ex){
this.debug("Could not call SetFileSizeLimit");
}
}else{
this.debug("Could not find Flash element in SetFileSizeLimit");
}
};
SWFUpload.prototype.setFileUploadLimit=function(_3d){
var _3e=this.getMovieElement();
if(_3e!==null&&typeof (_3e.SetFileUploadLimit)==="function"){
try{
this.addSetting("file_upload_limit",_3d);
_3e.SetFileUploadLimit(this.getSetting("file_upload_limit"));
}
catch(ex){
this.debug("Could not call SetFileUploadLimit");
}
}else{
this.debug("Could not find Flash element in SetFileUploadLimit");
}
};
SWFUpload.prototype.setFileQueueLimit=function(_3f){
var _40=this.getMovieElement();
if(_40!==null&&typeof (_40.SetFileQueueLimit)==="function"){
try{
this.addSetting("file_queue_limit",_3f);
_40.SetFileQueueLimit(this.getSetting("file_queue_limit"));
}
catch(ex){
this.debug("Could not call SetFileQueueLimit");
}
}else{
this.debug("Could not find Flash element in SetFileQueueLimit");
}
};
SWFUpload.prototype.setFilePostName=function(_41){
var _42=this.getMovieElement();
if(_42!==null&&typeof (_42.SetFilePostName)==="function"){
try{
this.addSetting("file_post_name",_41);
_42.SetFilePostName(this.getSetting("file_post_name"));
}
catch(ex){
this.debug("Could not call SetFilePostName");
}
}else{
this.debug("Could not find Flash element in SetFilePostName");
}
};
SWFUpload.prototype.setDebugEnabled=function(_43){
var _44=this.getMovieElement();
if(_44!==null&&typeof (_44.SetDebugEnabled)==="function"){
try{
this.addSetting("debug_enabled",_43);
_44.SetDebugEnabled(this.getSetting("debug_enabled"));
}
catch(ex){
this.debug("Could not call SetDebugEnabled");
}
}else{
this.debug("Could not find Flash element in SetDebugEnabled");
}
};
SWFUpload.prototype.flashReady=function(){
var _45=this;
if(typeof (_45.fileDialogStart_handler)==="function"){
this.eventQueue[this.eventQueue.length]=function(){
_45.flashReady_handler();
};
setTimeout(function(){
_45.executeNextEvent();
},0);
}else{
this.debug("fileDialogStart event not defined");
}
};
SWFUpload.prototype.executeNextEvent=function(){
var f=this.eventQueue.shift();
if(typeof (f)==="function"){
f();
}
};
SWFUpload.prototype.fileDialogStart=function(){
var _47=this;
if(typeof (_47.fileDialogStart_handler)==="function"){
this.eventQueue[this.eventQueue.length]=function(){
_47.fileDialogStart_handler();
};
setTimeout(function(){
_47.executeNextEvent();
},0);
}else{
this.debug("fileDialogStart event not defined");
}
};
SWFUpload.prototype.fileQueued=function(_48){
var _49=this;
if(typeof (_49.fileQueued_handler)==="function"){
this.eventQueue[this.eventQueue.length]=function(){
_49.fileQueued_handler(_48);
};
setTimeout(function(){
_49.executeNextEvent();
},0);
}else{
this.debug("fileQueued event not defined");
}
};
SWFUpload.prototype.fileQueueError=function(_4a,_4b,_4c){
var _4d=this;
if(typeof (_4d.fileQueueError_handler)==="function"){
this.eventQueue[this.eventQueue.length]=function(){
_4d.fileQueueError_handler(_4a,_4b,_4c);
};
setTimeout(function(){
_4d.executeNextEvent();
},0);
}else{
this.debug("fileQueueError event not defined");
}
};
SWFUpload.prototype.fileDialogComplete=function(_4e){
var _4f=this;
if(typeof (_4f.fileDialogComplete_handler)==="function"){
this.eventQueue[this.eventQueue.length]=function(){
_4f.fileDialogComplete_handler(_4e);
};
setTimeout(function(){
_4f.executeNextEvent();
},0);
}else{
this.debug("fileDialogComplete event not defined");
}
};
SWFUpload.prototype.uploadStart=function(_50){
var _51=this;
if(typeof (_51.fileDialogComplete_handler)==="function"){
this.eventQueue[this.eventQueue.length]=function(){
_51.returnUploadStart(_51.uploadStart_handler(_50));
};
setTimeout(function(){
_51.executeNextEvent();
},0);
}else{
this.debug("uploadStart event not defined");
}
};
SWFUpload.prototype.returnUploadStart=function(_52){
var _53=this.getMovieElement();
if(_53!==null&&typeof (_53.ReturnUploadStart)==="function"){
try{
_53.ReturnUploadStart(_52);
}
catch(ex){
this.debug("Could not call ReturnUploadStart");
}
}else{
this.debug("Could not find Flash element in returnUploadStart");
}
};
SWFUpload.prototype.uploadProgress=function(_54,_55,_56){
var _57=this;
if(typeof (_57.uploadProgress_handler)==="function"){
this.eventQueue[this.eventQueue.length]=function(){
_57.uploadProgress_handler(_54,_55,_56);
};
setTimeout(function(){
_57.executeNextEvent();
},0);
}else{
this.debug("uploadProgress event not defined");
}
};
SWFUpload.prototype.uploadError=function(_58,_59,_5a){
var _5b=this;
if(typeof (this.uploadError_handler)==="function"){
this.eventQueue[this.eventQueue.length]=function(){
_5b.uploadError_handler(_58,_59,_5a);
};
setTimeout(function(){
_5b.executeNextEvent();
},0);
}else{
this.debug("uploadError event not defined");
}
};
SWFUpload.prototype.uploadSuccess=function(_5c,_5d){
var _5e=this;
if(typeof (_5e.uploadSuccess_handler)==="function"){
this.eventQueue[this.eventQueue.length]=function(){
_5e.uploadSuccess_handler(_5c,_5d);
};
setTimeout(function(){
_5e.executeNextEvent();
},0);
}else{
this.debug("uploadSuccess event not defined");
}
};
SWFUpload.prototype.uploadComplete=function(_5f){
var _60=this;
if(typeof (_60.uploadComplete_handler)==="function"){
this.eventQueue[this.eventQueue.length]=function(){
_60.uploadComplete_handler(_5f);
};
setTimeout(function(){
_60.executeNextEvent();
},0);
}else{
this.debug("uploadComplete event not defined");
}
};
SWFUpload.prototype.debug=function(_61){
var _62=this;
if(typeof (_62.debug_handler)==="function"){
this.eventQueue[this.eventQueue.length]=function(){
_62.debug_handler(_61);
};
setTimeout(function(){
_62.executeNextEvent();
},0);
}else{
this.eventQueue[this.eventQueue.length]=function(){
_62.debugMessage(_61);
};
setTimeout(function(){
_62.executeNextEvent();
},0);
}
};
SWFUpload.flashReady=function(){
try{
this.debug("Flash called back and is ready.");
if(typeof (this.swfUploadLoaded_handler)==="function"){
this.swfUploadLoaded_handler();
}
}
catch(ex){
this.debug(ex);
}
};
SWFUpload.swfUploadLoaded=function(){
};
SWFUpload.fileDialogStart=function(){
};
SWFUpload.fileQueued=function(_63){
};
SWFUpload.fileQueueError=function(_64,_65,_66){
try{
switch(_65){
case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
this.debug("Error Code: File too big, File name: "+_64.name+", File size: "+_64.size+", Message: "+_66);
break;
case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
this.debug("Error Code: Zero Byte File, File name: "+_64.name+", File size: "+_64.size+", Message: "+_66);
break;
case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:
this.debug("Error Code: Upload limit reached, File name: "+_64.name+", File size: "+_64.size+", Message: "+_66);
break;
case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
this.debug("Error Code: File extension is not allowed, Message: "+_66);
break;
default:
this.debug("Error Code: Unhandled error occured. Errorcode: "+_65);
}
}
catch(ex){
this.debug(ex);
}
};
SWFUpload.fileDialogComplete=function(_67){
};
SWFUpload.uploadStart=function(_68){
return true;
};
SWFUpload.uploadProgress=function(_69,_6a,_6b){
this.debug("File Progress: "+_69.id+", Bytes: "+_6a+". Total: "+_6b);
};
SWFUpload.uploadSuccess=function(_6c,_6d){
};
SWFUpload.uploadComplete=function(_6e){
};
SWFUpload.debug=function(_6f){
if(this.getSetting("debug_enabled")){
this.debugMessage(_6f);
}
};
SWFUpload.uploadError=function(_70,_71,_72){
try{
switch(errcode){
case SWFUpload.UPLOAD_ERROR.SPECIFIED_FILE_ID_NOT_FOUND:
this.debug("Error Code: File ID specified for upload was not found, Message: "+msg);
break;
case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:
this.debug("Error Code: HTTP Error, File name: "+_70.name+", Message: "+msg);
break;
case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL:
this.debug("Error Code: No backend file, File name: "+_70.name+", Message: "+msg);
break;
case SWFUpload.UPLOAD_ERROR.IO_ERROR:
this.debug("Error Code: IO Error, File name: "+_70.name+", Message: "+msg);
break;
case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:
this.debug("Error Code: Security Error, File name: "+_70.name+", Message: "+msg);
break;
case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
this.debug("Error Code: Upload limit reached, File name: "+_70.name+", File size: "+_70.size+", Message: "+msg);
break;
case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:
this.debug("Error Code: Upload Initialization exception, File name: "+_70.name+", File size: "+_70.size+", Message: "+msg);
break;
case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED:
this.debug("Error Code: uploadStart callback returned false, File name: "+_70.name+", File size: "+_70.size+", Message: "+msg);
break;
case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
this.debug("Error Code: The file upload was cancelled, File name: "+_70.name+", File size: "+_70.size+", Message: "+msg);
break;
case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
this.debug("Error Code: The file upload was stopped, File name: "+_70.name+", File size: "+_70.size+", Message: "+msg);
break;
default:
this.debug("Error Code: Unhandled error occured. Errorcode: "+errcode);
}
}
catch(ex){
this.debug(ex);
}
};
SWFUpload.prototype.debugMessage=function(_73){
var _74,_75;
if(typeof (_73)==="object"&&typeof (_73.name)==="string"&&typeof (_73.message)==="string"){
_74="";
_75=[];
for(var key in _73){
_75.push(key+": "+_73[key]);
}
_74=_75.join("\n");
_75=_74.split("\n");
_74="EXCEPTION: "+_75.join("\nEXCEPTION: ");
SWFUpload.Console.writeLine(_74);
}else{
SWFUpload.Console.writeLine(_73);
}
};
SWFUpload.Console={};
SWFUpload.Console.writeLine=function(_77){
var _78,_79;
try{
_78=document.getElementById("SWFUpload_Console");
if(!_78){
_79=document.createElement("form");
document.getElementsByTagName("body")[0].appendChild(_79);
_78=document.createElement("textarea");
_78.id="SWFUpload_Console";
_78.style.fontFamily="monospace";
_78.setAttribute("wrap","off");
_78.wrap="off";
_78.style.overflow="auto";
_78.style.width="700px";
_78.style.height="350px";
_78.style.margin="5px";
_79.appendChild(_78);
}
_78.value+=_77+"\n";
_78.scrollTop=_78.scrollHeight-_78.clientHeight;
}
catch(ex){
alert("Exception: "+ex.name+" Message: "+ex.message);
}
};

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="http://reisenet.maptales.com/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 Path=Class.create();
Path.prototype={seperators:["=","&","%","#","?"],initialize:function(_1){
this.contextObject=null;
this.view=null;
this.templatePath=null;
this.parameters=null;
if(_1){
if(typeof _1=="string"||!isNaN(_1)){
this.parsePath(_1+"");
}else{
this.copyParameters(_1);
}
}
},setContextObject:function(_2){
this.contextObject=_2;
},getContextObject:function(){
return this.contextObject;
},setView:function(_3){
this.view=_3;
},getView:function(){
return this.view;
},setTemplatePath:function(_4){
this.templatePath=_4;
},getTemplatePath:function(){
return this.templatePath;
},setParameters:function(_5){
this.parameters=_5;
},getParameters:function(){
return this.parameters;
},parsePath:function(_6){
var _7;
var _8=this.getNextSeperator(_6);
if(_8==-1){
this.contextObject=_6;
return;
}else{
if(_8>0){
this.contextObject=_6.substring(0,_8);
}
}
this.parameters=this.deserializeParameters(_6);
var _9=_6.indexOf("#");
if(_9!=-1){
_9++;
var _a=this.getNextSeperator(_6,_9);
if(_a==-1){
_a=_6.length;
}
this.view=_6.substring(_9,_a);
}
var _b=_6.indexOf("%");
if(_b!=-1){
_b++;
var _a=this.getNextSeperator(_6,_b);
if(_a==-1){
_a=_6.length;
}
this.templatePath=_6.substring(_b,_a);
}
},toString:function(){
var _c="";
if(this.contextObject){
if(typeof this.contextObject=="string"){
_c=this.contextObject;
}else{
if(this.contextObject==maptales.ui){
_c=this.contextObject.getAppName();
}else{
if(this.contextObject instanceof ContentObject){
_c=this.contextObject.id;
}
}
}
}
if(this.view){
_c+="#"+this.view;
}
if(this.templatePath){
_c+="%"+this.templatePath;
}
_c+=this.serializeParameters();
return _c;
},toURL:function(){
var _d=maptales.baseURL;
if(this.contextObject){
if(typeof this.contextObject=="string"){
_d+="/view/"+this.contextObject;
}else{
if(this.contextObject==maptales.ui){
if(this.view=="browse"){
_d+="/browse/";
if(this.parameters&&this.parameters.searchString){
_d+=this.parameters.searchString;
}
return _d;
}else{
_d+="/";
}
}else{
if(this.contextObject instanceof ContentObject){
_d+="/view/"+this.contextObject.id;
}
}
}
}
if(this.view){
_d+="#"+this.view;
}
if(this.templatePath){
_d+="?"+this.templatePath;
}
_d+=this.serializeParameters();
return _d;
},deserializeParameters:function(_e){
var _f={};
var _10=_e.indexOf("?");
if(_10==-1){
return null;
}
var _11=_e.substring(_10+1,_e.length);
var _12=true;
while(_12){
var _13=_11.indexOf("=");
if(_13==-1){
_12=false;
}else{
var _14=_11.substring(0,_13);
_11=_11.substring(_13+1);
var _15=_11.indexOf("&");
if(_15==-1){
_12=false;
var _16=this.getNextSeperator(_11);
if(_16!=-1){
var _17=_11.substring(0,_16);
}else{
var _17=_11;
}
}else{
var _17=_11.substring(0,_15);
_11=_11.substring(_15+1);
}
_f[_14]=_17;
}
}
return _f;
},getNextSeperator:function(_18,_19){
var _1a=-1;
for(var i=0;i<this.seperators.length;i++){
var _1c=_18.indexOf(this.seperators[i],_19);
if(_1c!=-1){
if(_1a==-1){
_1a=_1c;
}else{
if(_1a>_1c){
_1a=_1c;
}
}
}
}
return _1a;
},serializeParameters:function(){
if(this.parameters){
var _1d="?";
var _1e=false;
for(parameterName in this.parameters){
if(_1e){
_1d+="&";
}
if(this.parameters[parameterName] instanceof ContentObject){
_1d+=parameterName+"="+this.parameters[parameterName].id;
}else{
_1d+=parameterName+"="+this.parameters[parameterName];
}
if(_1e==false){
_1e=true;
}
}
return _1d;
}else{
return "";
}
},getStringOfObject:function(_1f){
if(!isNaN(_1f)||_1f instanceof ContentObject){
_1f=$O(_1f);
return UIAdapter.getLabel(_1f);
}
},compare:function(){
alert("compare is deprecated");
},equals:function(_20){
if(this.contextObject!=_20.contextObject){
return false;
}
if(this.view!=_20.view){
return false;
}
if(this.templatePath!=_20.templatePath){
return false;
}
if(!this.parametersEquals(_20.parameters)){
return false;
}
return true;
},parametersEquals:function(_21){
if(_21==null){
if(this.parameters==null){
return true;
}else{
return false;
}
}
if(this.parameters==null){
if(_21==null){
return true;
}else{
return false;
}
}
for(parameterName in _21){
if(this.parameters[parameterName]!=_21[parameterName]){
return false;
}
}
for(parameterName in this.parameters){
if(this.parameters[parameterName]!=_21[parameterName]){
return false;
}
}
return true;
},copyParameters:function(_22){
if(_22==null){
return;
}
this.contextObject=_22.contextObject;
this.view=_22.view;
this.templatePath=_22.templatePath;
this.parameters=_22.parameters;
}};

var HistoryController=Class.create();
HistoryController.prototype={historyFrame:{},historyArray:[],initialize:function(){
document.body.historyController=this;
this.historyFrame=document.createElement("iframe");
document.body.appendChild(this.historyFrame);
this.historyFrame.style.position="absolute";
this.historyFrame.style.width="1px";
this.historyFrame.style.height="1px";
this.historyFrame.style.visibility="hidden";
if(maptales.remoteServer){
this.historyFrameLocation=maptales.remoteServer+"/history.html";
}else{
this.historyFrameLocation=maptales.baseURL+"/history.html";
}
this.historyFrame.src=this.historyFrameLocation+"?index=0";
this.historyArray=[];
this.index=0;
},addToHistory:function(_1,_2){
if(this.historyArray.length>0){
if(_1.equals(this.historyArray[this.index].path)){
return;
}
}
if(this.index<(this.historyArray.length-1)){
this.historyArray=this.historyArray.slice(0,parseInt(this.index+1));
}
this.historyArray.push({path:_1,callbackObject:_2});
this.index=this.historyArray.length-1;
this.historyFrame.src=this.historyFrameLocation+"?index="+this.index;
},moveBack:function(){
this.gotoIndex(this.index-1);
},moveForeward:function(){
this.gotoIndex(this.index+1);
},gotoIndex:function(_3){
if(_3==this.index){
return;
}
if(_3>=this.historyArray.length){
return;
}
if(_3<0){
return;
}
this.index=parseInt(_3);
var _4=this.historyArray[_3].callbackObject;
var _5=this.historyArray[_3].path;
var _6=new Action("gotoPath",{path:_5});
_4.handleBubbleAction(_6);
}};

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 hexcase=0;
var b64pad="";
var chrsz=8;
function hex_md5(s){
return binl2hex(core_md5(str2binl(s),s.length*chrsz));
}
function b64_md5(s){
return binl2b64(core_md5(str2binl(s),s.length*chrsz));
}
function str_md5(s){
return binl2str(core_md5(str2binl(s),s.length*chrsz));
}
function hex_hmac_md5(_4,_5){
return binl2hex(core_hmac_md5(_4,_5));
}
function b64_hmac_md5(_6,_7){
return binl2b64(core_hmac_md5(_6,_7));
}
function str_hmac_md5(_8,_9){
return binl2str(core_hmac_md5(_8,_9));
}
function md5_vm_test(){
return hex_md5("abc")=="900150983cd24fb0d6963f7d28e17f72";
}
function core_md5(x,_b){
x[_b>>5]|=128<<((_b)%32);
x[(((_b+64)>>>9)<<4)+14]=_b;
var a=1732584193;
var b=-271733879;
var c=-1732584194;
var d=271733878;
for(var i=0;i<x.length;i+=16){
var _11=a;
var _12=b;
var _13=c;
var _14=d;
a=md5_ff(a,b,c,d,x[i+0],7,-680876936);
d=md5_ff(d,a,b,c,x[i+1],12,-389564586);
c=md5_ff(c,d,a,b,x[i+2],17,606105819);
b=md5_ff(b,c,d,a,x[i+3],22,-1044525330);
a=md5_ff(a,b,c,d,x[i+4],7,-176418897);
d=md5_ff(d,a,b,c,x[i+5],12,1200080426);
c=md5_ff(c,d,a,b,x[i+6],17,-1473231341);
b=md5_ff(b,c,d,a,x[i+7],22,-45705983);
a=md5_ff(a,b,c,d,x[i+8],7,1770035416);
d=md5_ff(d,a,b,c,x[i+9],12,-1958414417);
c=md5_ff(c,d,a,b,x[i+10],17,-42063);
b=md5_ff(b,c,d,a,x[i+11],22,-1990404162);
a=md5_ff(a,b,c,d,x[i+12],7,1804603682);
d=md5_ff(d,a,b,c,x[i+13],12,-40341101);
c=md5_ff(c,d,a,b,x[i+14],17,-1502002290);
b=md5_ff(b,c,d,a,x[i+15],22,1236535329);
a=md5_gg(a,b,c,d,x[i+1],5,-165796510);
d=md5_gg(d,a,b,c,x[i+6],9,-1069501632);
c=md5_gg(c,d,a,b,x[i+11],14,643717713);
b=md5_gg(b,c,d,a,x[i+0],20,-373897302);
a=md5_gg(a,b,c,d,x[i+5],5,-701558691);
d=md5_gg(d,a,b,c,x[i+10],9,38016083);
c=md5_gg(c,d,a,b,x[i+15],14,-660478335);
b=md5_gg(b,c,d,a,x[i+4],20,-405537848);
a=md5_gg(a,b,c,d,x[i+9],5,568446438);
d=md5_gg(d,a,b,c,x[i+14],9,-1019803690);
c=md5_gg(c,d,a,b,x[i+3],14,-187363961);
b=md5_gg(b,c,d,a,x[i+8],20,1163531501);
a=md5_gg(a,b,c,d,x[i+13],5,-1444681467);
d=md5_gg(d,a,b,c,x[i+2],9,-51403784);
c=md5_gg(c,d,a,b,x[i+7],14,1735328473);
b=md5_gg(b,c,d,a,x[i+12],20,-1926607734);
a=md5_hh(a,b,c,d,x[i+5],4,-378558);
d=md5_hh(d,a,b,c,x[i+8],11,-2022574463);
c=md5_hh(c,d,a,b,x[i+11],16,1839030562);
b=md5_hh(b,c,d,a,x[i+14],23,-35309556);
a=md5_hh(a,b,c,d,x[i+1],4,-1530992060);
d=md5_hh(d,a,b,c,x[i+4],11,1272893353);
c=md5_hh(c,d,a,b,x[i+7],16,-155497632);
b=md5_hh(b,c,d,a,x[i+10],23,-1094730640);
a=md5_hh(a,b,c,d,x[i+13],4,681279174);
d=md5_hh(d,a,b,c,x[i+0],11,-358537222);
c=md5_hh(c,d,a,b,x[i+3],16,-722521979);
b=md5_hh(b,c,d,a,x[i+6],23,76029189);
a=md5_hh(a,b,c,d,x[i+9],4,-640364487);
d=md5_hh(d,a,b,c,x[i+12],11,-421815835);
c=md5_hh(c,d,a,b,x[i+15],16,530742520);
b=md5_hh(b,c,d,a,x[i+2],23,-995338651);
a=md5_ii(a,b,c,d,x[i+0],6,-198630844);
d=md5_ii(d,a,b,c,x[i+7],10,1126891415);
c=md5_ii(c,d,a,b,x[i+14],15,-1416354905);
b=md5_ii(b,c,d,a,x[i+5],21,-57434055);
a=md5_ii(a,b,c,d,x[i+12],6,1700485571);
d=md5_ii(d,a,b,c,x[i+3],10,-1894986606);
c=md5_ii(c,d,a,b,x[i+10],15,-1051523);
b=md5_ii(b,c,d,a,x[i+1],21,-2054922799);
a=md5_ii(a,b,c,d,x[i+8],6,1873313359);
d=md5_ii(d,a,b,c,x[i+15],10,-30611744);
c=md5_ii(c,d,a,b,x[i+6],15,-1560198380);
b=md5_ii(b,c,d,a,x[i+13],21,1309151649);
a=md5_ii(a,b,c,d,x[i+4],6,-145523070);
d=md5_ii(d,a,b,c,x[i+11],10,-1120210379);
c=md5_ii(c,d,a,b,x[i+2],15,718787259);
b=md5_ii(b,c,d,a,x[i+9],21,-343485551);
a=safe_add(a,_11);
b=safe_add(b,_12);
c=safe_add(c,_13);
d=safe_add(d,_14);
}
return Array(a,b,c,d);
}
function md5_cmn(q,a,b,x,s,t){
return safe_add(bit_rol(safe_add(safe_add(a,q),safe_add(x,t)),s),b);
}
function md5_ff(a,b,c,d,x,s,t){
return md5_cmn((b&c)|((~b)&d),a,b,x,s,t);
}
function md5_gg(a,b,c,d,x,s,t){
return md5_cmn((b&d)|(c&(~d)),a,b,x,s,t);
}
function md5_hh(a,b,c,d,x,s,t){
return md5_cmn(b^c^d,a,b,x,s,t);
}
function md5_ii(a,b,c,d,x,s,t){
return md5_cmn(c^(b|(~d)),a,b,x,s,t);
}
function core_hmac_md5(key,_38){
var _39=str2binl(key);
if(_39.length>16){
_39=core_md5(_39,key.length*chrsz);
}
var _3a=Array(16),_3b=Array(16);
for(var i=0;i<16;i++){
_3a[i]=_39[i]^909522486;
_3b[i]=_39[i]^1549556828;
}
var _3d=core_md5(_3a.concat(str2binl(_38)),512+_38.length*chrsz);
return core_md5(_3b.concat(_3d),512+128);
}
function safe_add(x,y){
var lsw=(x&65535)+(y&65535);
var msw=(x>>16)+(y>>16)+(lsw>>16);
return (msw<<16)|(lsw&65535);
}
function bit_rol(num,cnt){
return (num<<cnt)|(num>>>(32-cnt));
}
function str2binl(str){
var bin=Array();
var _46=(1<<chrsz)-1;
for(var i=0;i<str.length*chrsz;i+=chrsz){
bin[i>>5]|=(str.charCodeAt(i/chrsz)&_46)<<(i%32);
}
return bin;
}
function binl2str(bin){
var str="";
var _4a=(1<<chrsz)-1;
for(var i=0;i<bin.length*32;i+=chrsz){
str+=String.fromCharCode((bin[i>>5]>>>(i%32))&_4a);
}
return str;
}
function binl2hex(_4c){
var _4d=hexcase?"0123456789ABCDEF":"0123456789abcdef";
var str="";
for(var i=0;i<_4c.length*4;i++){
str+=_4d.charAt((_4c[i>>2]>>((i%4)*8+4))&15)+_4d.charAt((_4c[i>>2]>>((i%4)*8))&15);
}
return str;
}
function binl2b64(_50){
var tab="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var str="";
for(var i=0;i<_50.length*4;i+=3){
var _54=(((_50[i>>2]>>8*(i%4))&255)<<16)|(((_50[i+1>>2]>>8*((i+1)%4))&255)<<8)|((_50[i+2>>2]>>8*((i+2)%4))&255);
for(var j=0;j<4;j++){
if(i*8+j*6>_50.length*32){
str+=b64pad;
}else{
str+=tab.charAt((_54>>6*(3-j))&63);
}
}
}
return str;
}

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;
}};

if(maptales==null){
var maptales={};
}
maptales.event={};
maptales.event.events={};
maptales.event.logger=maptales.getLogger("com.maptales.event");
maptales.event.registerEventListener=function(_1,_2){
if(maptales.event.events[_1]==null){
maptales.event.events[_1]=[];
}
maptales.event.events[_1].push(_2);
};
maptales.event.removeEventListener=function(_3,_4){
if(maptales.event.events[_3]!=null){
maptales.event.events[_3].removeEntry(_4);
}
};
maptales.event.callEventListener=function(_5,_6,_7){
try{
var _8=maptales.event.events[_5];
if(_8!=null){
for(var e=0;e<_8.length;e++){
_8[e](_6,_7);
}
}
}
catch(e){
maptales.event.logger.error("Notifying event: '"+_5+"' listener threw exception. ",e);
}
};

if(!maptales){
var maptales={};
}
if(!maptales.rpc){
maptales.rpc={};
}
maptales.rpc.group={};
maptales.rpc.group.addTag=function(_1,_2){
var _3={groupId:_1.groupId,tag:_1.tag};
var _4="parameters="+JSON.stringify(_3);
maptales.rpc.callRPC("/groups/addTag",_4,"post",function(_5){
if(_5.wasSuccessful()){
_2(maptales.cache.makeObjects(_5.getData().tag));
}else{
ajaxLog.warn("Error adding Tag to Group: "+_5.getReplyMessage());
_2(new SnapMapException("Error adding Tag to Group",_5.getReplyMessage()));
}
});
};
maptales.rpc.group.removeTag=function(_6,_7){
var _8={groupId:_6.groupId,tag:_6.tag};
var _9="parameters="+JSON.stringify(_8);
maptales.rpc.callRPC("/groups/removeTag",_9,"post",function(_a){
if(_a.wasSuccessful()){
_7(_a);
}else{
ajaxLog.warn("Error Removing Tag from Group: "+_a.getReplyMessage());
_7(new SnapMapException("Error Removing Tag from Group",_a.getReplyMessage()));
}
});
};
maptales.rpc.group.inviteUsers=function(_b,_c){
var _d={groupId:_b.groupId,userIds:_b.userIds};
var _e="parameters="+JSON.stringify(_d);
maptales.rpc.callRPC("/groups/inviteUsers",_e,"post",function(_f){
if(_f.wasSuccessful()){
_c(_f);
}else{
ajaxLog.warn("Error Inviting users: "+_f.getReplyMessage());
_c(new SnapMapException("Error Inviting users",_f.getReplyMessage()));
}
});
};
maptales.rpc.group.addMap=function(_10,_11){
var _12={groupId:_10.groupId,map:_10.map};
var _13="parameters="+JSON.stringify(_12);
maptales.rpc.callRPC("/groups/addMap",_13,"post",function(_14){
if(_14.wasSuccessful()){
_11(_14);
}else{
ajaxLog.warn("Error Storing Group Map: "+_14.getReplyMessage());
_11(new SnapMapException("Error Storing Group Map",_14.getReplyMessage()));
}
});
};
maptales.rpc.group.removeMap=function(_15,_16){
var _17={groupId:_15.groupId,mapId:_15.mapId};
var _18="parameters="+JSON.stringify(_17);
maptales.rpc.callRPC("/groups/removeMap",_18,"post",function(_19){
if(_19.wasSuccessful()){
_16(_19);
}else{
ajaxLog.warn("Error Removing Group Map: "+_19.getReplyMessage());
_16(new SnapMapException("Error Removing Group Map",_19.getReplyMessage()));
}
});
};
maptales.rpc.group.addMedias=function(_1a,_1b){
if(!(_1a.mediaId instanceof Array)){
_1a.mediaId=[_1a.mediaId];
}
var _1c={groupId:_1a.groupId,mediaIds:_1a.mediaId,mapId:_1a.mapId};
var _1d="parameters="+JSON.stringify(_1c);
maptales.rpc.callRPC("/groups/addMedias",_1d,"post",function(_1e){
if(_1e.wasSuccessful()){
_1b(_1e);
}else{
ajaxLog.warn("Error Storing Group Post: "+_1e.getReplyMessage());
_1b(new SnapMapException("Error Storing Group Post",_1e.getReplyMessage()));
}
});
};
maptales.rpc.group.storePost=function(_1f,_20){
if(!_1f.groupPost){
throw new SnapMapException("group.storePost has to have a groupPost parameter");
}
var _21="parameters={post:"+JSON.stringify(_1f.groupPost)+"}";
maptales.rpc.callRPC("/groups/storePost",_21,"post",function(_22){
if(_22.wasSuccessful()){
var _23=maptales.cache.makeObjects(_22.getData().post);
_20(_23);
}else{
ajaxLog.warn("Error Storing Group Post: "+_22.getReplyMessage());
_20(new SnapMapException("Error Storing Group Post",_22.getReplyMessage()));
}
});
};
maptales.rpc.group.deletePost=function(_24,_25){
if(!_24.postId){
throw new SnapMapException("group.deletePost has to have a groupPost parameter");
}
var _26="parameters={postId:"+JSON.stringify(_24.postId)+"}";
maptales.rpc.callRPC("/groups/deletePost",_26,"post",function(_27){
if(_27.wasSuccessful()){
_25(_27);
}else{
ajaxLog.warn("Error Deleting Group Post: "+_27.getReplyMessage());
_25(new SnapMapException("Error Deleting Group Post",_27.getReplyMessage()));
}
});
};
maptales.rpc.group.acceptMedias=function(_28,_29){
if(!(_28 instanceof Array)){
_28=[_28];
}
var _2a={acceptanceQueue:_28};
var _2b="parameters="+JSON.stringify(_2a);
maptales.rpc.callRPC("/groups/acceptMedias",_2b,"post",function(_2c){
if(_2c.wasSuccessful()){
_29(_2c);
}else{
ajaxLog.warn("Error accepting media items: "+_2c.getReplyMessage());
_29(new SnapMapException("Error occured while accepting Medias"));
}
});
};
maptales.rpc.group.addUser=function(_2d,_2e){
var _2f={groupId:_2d.groupId,userId:_2d.userId};
var _30="parameters="+JSON.stringify(_2f);
maptales.rpc.callRPC("/groups/addUser",_30,"post",function(_31){
if(_31.wasSuccessful()){
_2e(_31);
}else{
ajaxLog.warn("Error adding User: "+_31.getReplyMessage());
_2e(new SnapMapException("Error occured while adding User"));
}
});
};
maptales.rpc.group.removeUser=function(_32,_33){
var _34={groupId:_32.groupId,userId:_32.userId};
var _35="parameters="+JSON.stringify(_34);
maptales.rpc.callRPC("/groups/removeUser",_35,"post",function(_36){
if(_36.wasSuccessful()){
_33(_36);
}else{
ajaxLog.warn("Error adding User: "+_36.getReplyMessage());
_33(new SnapMapException("Error occured while adding User"));
}
});
};
maptales.rpc.group.setMemberRank=function(_37,_38){
var _39={userId:_37.userId,groupId:_37.groupId,rank:_37.rank};
var _3a="parameters="+JSON.stringify(_39);
maptales.rpc.callRPC("/groups/setMemberRank",_3a,"post",function(_3b){
if(_3b.wasSuccessful()){
_38(_3b);
}else{
ajaxLog.warn("Error setting MemberRank: "+_3b.getReplyMessage());
_38(new SnapMapException("Error occured while setting MemberRanks"));
}
});
};
maptales.rpc.group.removeMedia=function(_3c,id,_3e,_3f){
var _40={mediaIds:[id],groupId:_3c};
var _41="parameters="+JSON.stringify(_40);
maptales.rpc.callRPC("/groups/removeMedias",_41,"post",function(_42){
if(_42.wasSuccessful()){
if(_3e){
_3e(_42);
}
if(_3f){
$g(_3c+"%objects/Group/flaggedItems",_3f);
}
}else{
ajaxLog.warn("Error accepting media items: "+_42.getReplyMessage());
_3e(new SnapMapException("Error occured while accepting Medias"));
}
});
};

if(!maptales){
var maptales={};
}
if(!maptales.rpc){
maptales.rpc={};
}
maptales.rpc.map={};
maptales.rpc.map.addMedias=function(_1,_2){
if(!(_1.mediaIds instanceof Array)){
_1.mediaIds=[_1.mediaIds];
}
if(!(_1.mapId)){
throw new SnapMapException("MapId has to be defined when calling addMedias");
}
var _3=_1;
var _4="parameters="+JSON.stringify(_3);
maptales.rpc.callRPC("/maps/addMedias",_4,"post",function(_5){
if(_5.wasSuccessful()){
_2(_5);
}else{
ajaxLog.warn("Error adding Medias: "+_5.getReplyMessage());
_2(new SnapMapException("Error occured while adding Medias"));
}
});
};
maptales.rpc.map.removeMedias=function(_6,_7){
if(!(_6.mediaIds instanceof Array)){
_6.mediaIds=[_6.mediaIds];
}
if(!(_6.mapId)){
throw new SnapMapException("MapId has to be defined when calling addMedias");
}
var _8=_6;
var _9="parameters="+JSON.stringify(_8);
maptales.rpc.callRPC("/maps/removeMedias",_9,"post",function(_a){
if(_a.wasSuccessful()){
_7(_a);
}else{
ajaxLog.warn("Error removing Medias: "+_a.getReplyMessage());
_7(new SnapMapException("Error occured while removing Medias"));
}
});
};

if(!maptales){
var maptales={};
}
if(!maptales.rpc){
maptales.rpc={};
}
maptales.rpc.user={};
maptales.rpc.user.register=function(_1,_2){
if(_1.name==null){
_2(new SnapMapFormException("name","Please enter a user name"));
return;
}
if(_1.name.length<2){
_2(new SnapMapFormException("name","The username has to have at least 2 characters."));
return;
}
if(_1.name.indexOf(" ")!=-1){
_2(new SnapMapFormException("name","The username needs to be one word. No whitespace allowed."));
return;
}
var _3=/^([a-zA-Z0-9_-]+)$/;
if(_3.test(_1.name)==false){
_2(new SnapMapFormException("name","Sorry but please only use A to Z, 0 to 9 and underscores for your username"));
return;
}
if(_1.pass==null||_1.pass.length<6){
_2(new SnapMapFormException("pass","Password has to have at least 6 characters."));
return;
}
if(_1.passVerification!=_1.pass){
_2(new SnapMapFormException("passVerification","The two passwords do not match."));
return;
}
if(_1.email==null||_1.email==""){
_2(new SnapMapFormException("email","Please enter your email address."));
return;
}
if(jcv_checkEmail(_1.email)==false){
_2(new SnapMapFormException("email","The email you entered is not a valid email adress."));
return;
}
if(!_1.TOS){
_2(new SnapMapFormException("TOS","You have to agree with our Terms of Service to become a Maptales member."));
return;
}
_1.pass=hex_md5(_1.pass);
_1.passVerification=hex_md5(_1.passVerification);
var _4={newUser:_1};
var _5="parameters="+JSON.stringify(_4);
maptales.rpc.callRPC("/register",_5,"post",function(_6){
if(_6.wasSuccessful()){
_2(_6);
}else{
if(_6.exception){
if(_6.exception.type=="SnapMapFormException"){
_2(new SnapMapFormException(_6.exception.fieldName,_6.exception.message));
return;
}
}
ajaxLog.warn("login reply was exception: "+_6.getReplyMessage());
_2(new SnapMapException("LoginError","Could not log in"));
}
});
};
maptales.rpc.user.login=function(_7,_8){
var _9={user:_7.name,pass:hex_md5(_7.pass)};
var _a="_acegi_security_remember_me="+_7.rememberMe+"&authentication="+JSON.stringify(_9);
maptales.rpc.callRPC("/login",_a,"post",function(_b){
if(_b.wasSuccessful()){
maptales.rpc.checkServerSessionTimeout();
maptales.cache.clearCache();
maptales.rpc.user.loginCallback(_b.getData(),_8);
}else{
ajaxLog.warn("login reply was exception: "+_b.getReplyMessage());
_8(new SnapMapException("LoginError","Could not log in"));
}
});
};
maptales.rpc.user.reestablishSession=function(_c,_d){
var _e={user:_c.name,pass:hex_md5(_c.pass)};
var _f="authentication="+JSON.stringify(_e)+"_acegi_security_remember_me=1";
maptales.rpc.callRPC("/login",_f,"post",function(_10){
if(_10.wasSuccessful()){
maptales.rpc.checkServerSessionTimeout();
maptales.rpc.user.loginCallback(_10.getData(),_d);
}else{
ajaxLog.warn("login reply was exception: "+_10.getReplyMessage());
_d(new SnapMapException("LoginError","Could not log in"));
}
});
};
maptales.rpc.user.logout=function(_11,_12){
maptales.rpc.stopCheckServerSessionTimeout();
maptales.rpc.callRPC("/logout",null,"post",function(_13){
if(_13.wasSuccessful()){
_12(_13);
}else{
ajaxLog.warn("logout>Server Problem");
_12(new SnapMapException("Logout Exception",""));
}
});
};
maptales.rpc.user.loginCallback=function(_14,_15){
var _16=maptales.cache.makeObjects(_14.user);
maptales.rpc.sessionId=_14["JSESSIONID"];
setCookie("JSESSIONID",_14["JSESSIONID"],1);
var _17=maptales.cache.makeObjects(_14.user.inboxItems);
var _18=maptales.cache.makeObjects(_14.user.looseMapobjects);
_16.insertIntoSlot("medias",_17,0,[{type:"fieldFilter",field:"mapobject",comparator:"=",value:null},{type:"fieldFilter",field:"story",comparator:"=",value:null}],"creationDate desc",_14.user.inboxItemsNum);
_15(_16);
};
maptales.rpc.user.sendVerificationEmail=function(_19,_1a){
maptales.rpc.callRPC("/users/sendVerificationEmail",null,"post",function(_1b){
if(_1b.wasSuccessful()){
_1a(_1b.getData());
}else{
ajaxLog.warn("sendVerificationEmail returned error. message: "+_1b.getReplyMessage());
_1a(new SnapMapException("sendVerificationEmail",_1b.getReplyMessage()));
}
});
};
maptales.rpc.user.forgotPassword=function(_1c,_1d){
var _1e={user:_1c.user};
var _1f="parameters="+JSON.stringify(_1e);
maptales.rpc.callRPC("/forgotPassword",_1f,"post",function(_20){
if(_20.wasSuccessful()){
_1d(_20.getData());
}else{
ajaxLog.warn("forgotPassword returned error. message: "+_20.getReplyMessage());
_1d(new SnapMapException("forgotPassword",_20.getReplyMessage()));
}
});
};
maptales.rpc.user.addContact=function(_21,_22){
var _23={contactId:_21.contactId,tag:_21.tag};
var _24="parameters="+JSON.stringify(_23);
maptales.rpc.callRPC("/addContact",_24,"post",function(_25){
if(_25.wasSuccessful()){
_22(_25.getData());
}else{
ajaxLog.warn("addContact returned error. message: "+_25.getReplyMessage());
_22(new SnapMapException("addContact",_25.getReplyMessage()));
}
});
};
maptales.rpc.user.storeProfileImage=function(_26,_27){
var _28={imageId:_26.imageId,userId:maptales.service.user.getCurrentUserId(),topPercentage:_26.topPercentage,leftPercentage:_26.leftPercentage,widthPercentage:_26.widthPercentage,heightPercentage:_26.heightPercentage};
var _29="parameters="+JSON.stringify(_28);
maptales.rpc.callRPC("/storeProfileImage",_29,"post",function(_2a){
if(_2a.wasSuccessful()){
maptales.service.user.getCurrentUser().set("profileIcon",_2a.getData().profileImagePath);
_27(_2a.getData().profileImagePath);
}else{
ajaxLog.warn("Error Making Profile Image: "+_2a.getReplyMessage());
_27(new SnapMapException("Error Making Profile Image",_2a.getReplyMessage()));
}
});
};
maptales.rpc.user.storeStatus=function(_2b,_2c){
var _2d={status:_2b.status,userId:maptales.service.user.getCurrentUserId()};
var _2e="parameters="+JSON.stringify(_2d);
maptales.rpc.callRPC("/users/setStatus",_2e,"post",function(_2f){
if(_2f.wasSuccessful()){
maptales.service.user.getCurrentUser().set("status",_2b.status);
_2c(_2b.status);
}else{
ajaxLog.warn("Error Storing Status: "+_2f.getReplyMessage());
_2c(new SnapMapException("Error Storing Status",_2f.getReplyMessage()));
}
});
};

if(!maptales){
var maptales={};
}
if(!maptales.rpc){
maptales.rpc={};
}
maptales.rpc.flickr={};
maptales.rpc.flickr.importFromFlickr=function(_1,_2){
var _3={num:_1.num,page:_1.page,tags:_1.tags};
var _4="parameters="+JSON.stringify(_3);
maptales.rpc.callRPC("/importFromFlickr",_4,"post",function(_5){
if(_5.wasSuccessful()){
var _6=maptales.cache.makeObjects(_5.getData().flickrItems);
_2({flickrItems:_6});
}else{
ajaxLog.warn("importFromFlickr returned error. message: "+_5.getReplyMessage());
_2(new SnapMapException("importFromFlickr",_5.getReplyMessage()));
}
});
};

if(!maptales){
var maptales={};
}
if(!maptales.rpc){
maptales.rpc={};
}
var ajaxLog=maptales.getLogger("com.maptales.webclient.rpc");
maptales.rpc.checkServerTimeoutInterval=null;
maptales.rpc.serverIsOnline=true;
maptales.rpc.sessionTimeout=30*60*1000;
maptales.rpc.lastServerCall=new Date().getTime();
maptales.rpc.session=null;
maptales.rpc.sessionExpirationCallbacks=[];
maptales.rpc.serverOfflineCallbacks=[];
maptales.rpc.fileUploadIFrameId="fileUploadIFrame";
maptales.rpc.fileUploadFlash=null;
maptales.rpc.uploadReplyListeners=[];
maptales.rpc.sessionTimoutCheckInterval=0.5*60*1000;
maptales.rpc.uploadedFilesNum=0;
maptales.rpc.completeFilesNum=0;
maptales.rpc.uploadProgressListener=[];
maptales.rpc.uploadErrorListener=[];
maptales.rpc.uploadSuccessListener=[];
maptales.rpc.uploadCompleteListener=[];
maptales.rpc.uploadedObjects=[];
maptales.rpc.getCompleteFilesNum=function(){
if(maptales.rpc.completeFilesNum&&maptales.rpc.completeFilesNum>0){
return maptales.rpc.completeFilesNum;
}else{
return 0;
}
};
maptales.rpc.addSessionExpirationCallback=function(_1){
maptales.rpc.sessionExpirationCallbacks.push(_1);
};
maptales.rpc.callSessionExpirationCallbacks=function(){
for(var i=0;i<maptales.rpc.sessionExpirationCallbacks.length;i++){
maptales.rpc.sessionExpirationCallbacks[i]();
}
};
maptales.rpc.removeSessionExpirationCallback=function(_3){
maptales.rpc.sessionExpirationCallbacks.removeEntry(_3);
};
maptales.rpc.addServerOfflineCallback=function(_4){
maptales.rpc.serverOfflineCallbacks.push(_4);
};
maptales.rpc.callServerOfflineCallbacks=function(_5){
for(var i=0;i<maptales.rpc.serverOfflineCallbacks.length;i++){
maptales.rpc.serverOfflineCallbacks[i](_5);
}
};
maptales.rpc.getUploadedMapObjects=function(){
var _7=[];
if(maptales.rpc.uploadedObjects!=null&&maptales.rpc.uploadedObjects.length>0){
for(var e=0;e<maptales.rpc.uploadedObjects.length;e++){
if(maptales.rpc.uploadedObjects[e] instanceof Media){
_7.push(maptales.rpc.uploadedObjects[e].getRefFromCache("mapobject"));
}else{
if(maptales.rpc.uploadedObjects[e] instanceof MapObject){
_7.push(maptales.rpc.uploadedObjects[e]);
}
}
}
}
return _7;
};
maptales.rpc.getUploadedIds=function(){
var _9=[];
if(maptales.rpc.uploadedObjects!=null&&maptales.rpc.uploadedObjects.length>0){
for(var e=0;e<maptales.rpc.uploadedObjects.length;e++){
_9.push(maptales.rpc.uploadedObjects[e].id);
}
}
return _9;
};
maptales.rpc.uploadSuccess=function(_b,_c){
maptales.rpc.completeFilesNum++;
if(maptales.rpc.uploadedFilesNum<=maptales.rpc.completeFilesNum){
maptales.rpc.uploadComplete();
}
if(_c){
maptales.rpc.parseUploadReply(_c);
}
maptales.rpc.callUploadSuccessListeners(_c);
};
maptales.rpc.callUploadSuccessListeners=function(_d){
for(var i=0;i<maptales.rpc.uploadSuccessListener.length;i++){
maptales.rpc.uploadSuccessListener[i](_d);
}
};
maptales.rpc.addUploadSuccessListener=function(_f){
maptales.rpc.uploadSuccessListener.push(_f);
};
maptales.rpc.removeUploadSuccessListener=function(_10){
maptales.rpc.uploadSuccessListener.removeEntry(_10);
};
maptales.rpc.addUploadErrorListener=function(_11){
maptales.rpc.uploadErrorListener.push(_11);
};
maptales.rpc.uploadError=function(_12,_13,_14){
maptales.imageUploadInProgress=false;
for(var i=0;i<maptales.rpc.uploadErrorListener.length;i++){
maptales.rpc.uploadErrorListener[i](_12,_13,_14);
}
};
maptales.rpc.removeUploadErrorListener=function(_16){
maptales.rpc.uploadErrorListener.removeEntry(_16);
};
maptales.rpc.addUploadCompleteListener=function(_17){
maptales.rpc.uploadCompleteListener.push(_17);
};
maptales.rpc.uploadComplete=function(){
maptales.imageUploadInProgress=false;
for(var i=0;i<maptales.rpc.uploadCompleteListener.length;i++){
maptales.rpc.uploadCompleteListener[i](maptales.rpc.uploadedObjects);
}
};
maptales.rpc.removeUploadCompleteListener=function(_19){
maptales.rpc.uploadCompleteListener.removeEntry(_19);
};
maptales.rpc.uploadProgress=function(_1a,_1b,_1c){
for(var i=0;i<maptales.rpc.uploadProgressListener.length;i++){
maptales.rpc.uploadProgressListener[i](_1a,_1b,_1c);
}
};
maptales.rpc.addUploadProgressListener=function(_1e){
maptales.rpc.uploadProgressListener.push(_1e);
};
maptales.rpc.removeUploadProgressListener=function(_1f){
maptales.rpc.uploadProgressListener.removeEntry(_1f);
};
maptales.rpc.startFormUpload=function(){
maptales.rpc.completeFilesNum=-1;
maptales.rpc.uploadedObjects=[];
if(maptales.rpc.uploadUpdateInterval!=-1){
window.clearInterval(maptales.rpc.uploadUpdateInterval);
}
maptales.rpc.uploadUpdateInterval=window.setInterval(maptales.rpc.getUploadStatus,3000);
};
maptales.rpc.getUploadStatus=function(){
maptales.rpc._getUploadStatus(function(_20){
if(_20 instanceof SnapMapException){
maptales.rpc.uploadError(null,-2,"The upload has failed because of: "+_20.getMessage());
window.clearInterval(maptales.rpc.uploadUpdateInterval);
maptales.rpc.uploadUpdateInterval=-1;
}else{
if(_20.uploadedFileCounter==-1&&_20.uploadReply!=null){
maptales.rpc.acbUpload(_20);
if(_20.uploadReply){
maptales.rpc.parseUploadReply(_20.uploadReply);
}
maptales.rpc.uploadComplete();
window.clearInterval(maptales.rpc.uploadUpdateInterval);
maptales.rpc.uploadUpdateInterval=-1;
return;
}
if(maptales.rpc.completeFilesNum<_20.uploadedFileCounter){
maptales.rpc.completeFilesNum=_20.uploadedFileCounter;
maptales.rpc.callUploadSuccessListeners(_20);
}else{
maptales.rpc.completeFilesNum=_20.uploadedFileCounter;
}
}
});
};
maptales.rpc._getUploadStatus=function(_21){
maptales.rpc.callRPC("/checkUploadStatus",null,"post",function(_22){
if(_22.wasSuccessful()){
_21(_22.getData());
}else{
ajaxLog.warn("getUploadStatus returned error. message: "+_22.getReplyMessage());
_21(new SnapMapException("getUploadStatus",_22.getReplyMessage()));
}
});
};
maptales.rpc.insertControlpoint=function(_23,_24){
var _25={removedControlpoints:_23.removedControlpoints,lineId:_23.lineId,index:_23.index,point:_23.point,insert:_23.insert};
var _26="parameters="+JSON.stringify(_25);
maptales.rpc.callRPC("/lines/insertControlpoint",_26,"post",function(_27){
if(_27.wasSuccessful()){
_24(_27);
}else{
ajaxLog.warn("getUploadStatus returned error. message: "+_27.getReplyMessage());
_24(new SnapMapException("getUploadStatus",_27.getReplyMessage()));
}
});
};
maptales.rpc.parseUploadReply=function(_28){
try{
if(typeof _28=="string"&&_28.length>0){
var _29=maptales.rpc.evalJSON(_28);
}else{
if(_28==null){
ajaxLog.warn("Upload Reply Exception, Reply was empty "+_28);
maptales.rpc.uploadError("Upload Exception",-2,"Reply was empty");
return;
}else{
var _29=_28;
}
}
var _2a=new Reply(_29);
if(_2a.wasSuccessful()){
var _2b=maptales.cache.makeObjects(_2a.getData().storedItems);
maptales.rpc.uploadedObjects=maptales.rpc.uploadedObjects.concat(_2b);
for(var e=0;e<_2b.length;e++){
maptales.service.onStore(_2b[e]);
}
}else{
ajaxLog.warn("Upload Reply Exception: "+_2a.getReplyMessage());
maptales.rpc.uploadError("Upload Exception",-2,_2a.getReplyMessage());
}
}
catch(e){
ajaxLog.warn("Upload Reply Error: "+_28,e);
maptales.rpc.uploadError("Upload Error",-2,"Could not upload all items");
}
};
maptales.rpc.acbUpload=function(){
maptales.rpc.fileUploadIFrame=$("fileUploadIFrame");
maptales.rpc.fileUploadIFrame.src="";
};
maptales.rpc.evalJSON=function(_2d){
try{
var _2e=eval("("+_2d+")");
}
catch(e){
var _2e=null;
}
return _2e;
};
maptales.rpc.toIdArray=function(_2f){
var ids=[];
if(_2f instanceof Array){
_2f.each(function(_31){
ids.push(maptales.rpc.extractId(_31));
});
}else{
ids.push(maptales.rpc.extractId(_2f));
}
return ids;
};
maptales.rpc.extractId=function(_32){
if(_32 instanceof ContentObject){
return _32.id;
}else{
if(!isNaN(_32)){
return _32;
}
}
};
maptales.rpc.importVideos=function(_33,_34){
if(_33.urls&&_33.urls.indexOf("&")!=-1){
_33.urls=_33.urls.substring(0,_33.urls.indexOf("&"));
}
var _35="parameters="+JSON.stringify(_33);
maptales.rpc.callRPC("/importVideos",_35,"post",function(_36){
if(_36.wasSuccessful()){
var _37=maptales.cache.makeObjects(_36.getData().importetVideos);
_34(_37);
return _37;
}else{
ajaxLog.warn("getById reply is exception: "+_36.getReplyMessage());
_34(new SnapMapException("GetByIdException",_36.getReplyMessage()));
}
});
};
maptales.rpc.sendMessage=function(_38,_39){
var _3a="parameters="+JSON.stringify(_38);
maptales.rpc.callRPC("/messages/sendMessage",_3a,"post",function(_3b){
if(_3b.wasSuccessful()){
_39(null);
return null;
}else{
ajaxLog.warn("getById reply is exception: "+_3b.getReplyMessage());
_39(new SnapMapException("GetByIdException",_3b.getReplyMessage()));
}
});
};
maptales.rpc.deleteMessage=function(_3c,_3d){
var _3e="parameters="+JSON.stringify(_3c);
maptales.rpc.callRPC("/messages/deleteMessage",_3e,"post",function(_3f){
if(_3f.wasSuccessful()){
_3d(null);
return null;
}else{
ajaxLog.warn("delete reply is exception: "+_3f.getReplyMessage());
_3d(new SnapMapException("delete Exception",_3f.getReplyMessage()));
}
});
};
maptales.rpc.markMessageAsRead=function(_40,_41){
_40.messageId=_40.messageId.replace("message_","");
var _42="parameters="+JSON.stringify(_40);
maptales.rpc.callRPC("/messages/markAsRead",_42,"post",function(_43){
});
};
maptales.rpc.getById=function(_44,_45){
var id=null;
if(isNaN(_44)){
id=_44.id;
}else{
id=_44;
}
if(_44.noCache!=true){
var _47=maptales.cache.getFromCache(id);
if(_47){
_45(_47);
return;
}
}
if(isNaN(id)){
_45(new SnapMapException("ArgumentException","Id is not a number"));
return;
}
if(maptales.cache.loading[id]){
maptales.cache.addReplyListener(id,_45);
}
if(!(id instanceof Array)){
var ids=[id];
}
maptales.cache.loading[id]=true;
var _49={id:id};
var _4a="parameters="+JSON.stringify(_49);
maptales.rpc.callRPC("/getById",_4a,"post",function(_4b){
if(_4b.wasSuccessful()){
var _4c=maptales.cache.makeObjects(_4b.getData().persistentObjects[0]);
maptales.cache.callReplyListener(id,_4c);
_45(_4c);
return _4c;
}else{
ajaxLog.warn("getById reply is exception: "+_4b.getReplyMessage());
_45(new SnapMapException("GetByIdException","Could not get object "+id));
}
});
};
maptales.rpc.getByIds=function(ids,_4e){
if(!(ids instanceof Array)){
_4e(new SnapMapException("ArgumentException","Id is not a number"));
return;
}
var _4f=[];
var _50=[];
for(var i=0;i<ids.length;i++){
if(maptales.cache.isInCache(ids[i])){
_4f.push(maptales.cache.getFromCache(ids[i]));
}else{
_50.push(ids[i]);
maptales.cache.loading[ids[i]]=true;
}
}
if(_50.length==0&&(_4f.length==ids.length)){
_4e(_4f);
return;
}
var _52={ids:ids};
var _53="parameters="+JSON.stringify(_52);
maptales.rpc.callRPC("/getById",_53,"post",function(_54){
if(_54.wasSuccessful()){
var _55=maptales.cache.makeObjects(_54.getData().persistentObjects);
_55.each(function(obj){
maptales.cache.loading[obj.id]=null;
maptales.cache.callReplyListener(obj.id,_55);
});
_4e(_55);
return _55;
}else{
ajaxLog.warn("getByIdsReply is exception: "+_54.getReplyMessage());
ids.each(function(id){
maptales.cache.loading[id]=null;
});
_4e(new SnapMapException("Storage Exception","Could not get object "+id));
}
});
};
maptales.rpc.query=function(_58,_59,_5a,_5b){
var _5c="parameters="+JSON.stringify({parameters:_58,queries:_59,sequence:_5a});
maptales.rpc.callRPC("/query",_5c,"post",function(_5d){
if(_5d.wasSuccessful()){
var _5e=_5d.getData();
_5b(_5e);
}else{
ajaxLog.warn("query reply is exception: "+_5d.getReplyMessage());
_5b(new SnapMapException("Query Exception","Could not complete query"));
}
});
};
maptales.rpc.persist=function(_5f,_60){
if(!(_5f instanceof Array)){
_5f=[_5f];
}
var _61=[];
for(var i=0;i<_5f.length;i++){
_61.push(_5f[i].getDirtyData());
}
var _63={objectsToPersist:_61};
var _64="parameters="+encodeURIComponent(JSON.stringify(_63));
try{
maptales.rpc.callRPC("/persist",_64,"post",function(_65){
_5f.each(function(_66){
_66.clean();
});
if(_65.wasSuccessful()){
var _67=maptales.cache.makeObjects(_65.getData().persistetAssociations);
if(_60){
_60(true);
}
}else{
ajaxLog.warn("persist reply is exception: "+_65.getReplyMessage());
if(_60){
if(_65.exception!=null&&_65.exception.type=="SnapMapFormException"){
_60(new SnapMapFormException(_65.exception.fieldName,_65.exception.message));
}else{
_60(new SnapMapException("PersistError","Could not save updates. "+_65.getReplyMessage()));
}
}
}
});
}
catch(e){
alert(e);
}
};
maptales.rpc.store=function(_68,_69){
var _6a=[];
var _6b=[];
if(_68 instanceof Array){
_6a=_68;
}else{
_6a.push(_68);
}
_6a.each(function(_6c){
_6b.push(_6c.getData());
});
var _6d={objectsToStore:_6b};
var _6e="parameters="+encodeURIComponent(JSON.stringify(_6d));
maptales.rpc.callRPC("/store",_6e,"post",function(_6f){
if(_6f.wasSuccessful()){
var _70=maptales.cache.makeObjects(_6f.getData().persistentObjects);
for(var e=0;e<_70.length;e++){
if(_70[e].clean instanceof Function){
_70[e].clean();
}else{
ajaxLog.error("store> object returned is not in cache or is not contentObject: id"+_70[i].id);
}
}
if(_69){
_69(_70);
}
}else{
ajaxLog.warn("store Reply is exception: "+_6f.getReplyMessage());
_6a.each(function(_72){
maptales.rpc.deleteTempObj(_72);
});
if(_6f.subcode==Reply.notAllowed){
if(_69){
_69(new SnapMapException("AccessDenied","You dont have permission, or have to log in to perform this task"));
}
}else{
if(_6f.exception&&_6f.exception.type=="SnapMapFormException"){
_69(new SnapMapFormException(_6f.exception.fieldName,_6f.exception.message));
return;
}else{
if(_69){
_69(new SnapMapException("Server Problem","Could not store item"));
}
}
}
return;
}
});
};
maptales.rpc.deleteTempObj=function(_73){
maptales.cache.removeFromCache(_73.get("id"));
};
maptales.rpc.getSlot=function(_74,_75){
var id=_74.id;
var _77=_74.slotName;
var _78=_74.offset;
var _79=_74.size;
var _7a=_74.filter;
var _7b=_74.sorting;
var _7c=_74.objectTemplate;
if(_74.noCache!=true&&$O(id).isSlotCacheable(_77)){
try{
var _7d=maptales.cache.getSlotFromCache(id,_77,_78,_79,_7a,_7b,_7c);
var _7e={slotItems:_7d,slotNum:maptales.cache.getSlotLengthFromCache(id,_77,_7a),parentId:id,slotName:_77};
try{
_75(_7e);
}
catch(e){
ajaxLog.warn("CallbackException content>getSlot>callback caused error",e);
}
return _7e;
}
catch(e){
ajaxLog.info("CacheFailure: Content>getSlot>could not get slot from cache",e);
}
}
if(maptales.cache.isPartOfSlotLoading(id,_77,_78,_79,_7a,_7b,_7c)){
maptales.cache.addSlotReplyListener(id,_77,_78,_79,_7a,_7b,_7c,_75);
return;
}
maptales.cache.addLoadingSlot(id,_77,_78,_79,_7a,_7b,_7c);
if(_7a!=null){
if(!(_7a instanceof Array)){
if(_7a!=""){
_7a=[_7a];
}
}
}
var _7f=$O(id).getClassName();
var _80={type:_7f,id:id,slot:_77,offset:_78,size:_79,filter:_7a,sorting:_7b};
if(_7c){
_80.objectTemplate=_7c;
}
var _81="parameters="+JSON.stringify(_80);
maptales.rpc.callRPC("/getSlot",_81,"post",function(_82){
if(_82.wasSuccessful()){
var _83=maptales.cache.makeObjects(_82.getData().slotItems);
var _84=_82.getData().slotNum;
if(maptales.cache.isInCache(id)){
maptales.cache.getFromCache(id).insertIntoSlot(_77,_83,_78,_7a,_7b,_84);
}
maptales.cache.callSlotReplyListeners(id,_77,_78,_79,_7a,_7b,_7c);
maptales.cache.removeLoadingSlot(id,_77);
if(_75 instanceof Function){
_75({slotItems:_83,slotNum:_84,parentId:id,slotName:_77});
}
}else{
ajaxLog.warn("getSlotReply is exception: "+_82.getReplyMessage());
if(_75 instanceof Function){
_75(new SnapMapException("Server Problem","Could not get Slot"));
}
}
});
};
maptales.rpc.stopCheckServerSessionTimeout=function(){
ajaxLog.debug("checkServerSessionTimeout stopped");
window.clearInterval(maptales.rpc.checkServerTimeoutInterval);
};
maptales.rpc.checkServerSessionTimeout=function(){
ajaxLog.debug("checkServerSessionTimeout started");
if(maptales.rpc.checkServerTimeoutInterval==null){
maptales.rpc.checkServerTimeoutInterval=window.setInterval(maptales.rpc._checkServerSessionTimeout,maptales.rpc.sessionTimoutCheckInterval);
}
};
maptales.rpc._checkServerSessionTimeout=function(){
ajaxLog.debug("checking session timeout: "+maptales.rpc.sessionTimeout+"<"+_85);
if(readCookie("ACEGI_SECURITY_HASHED_REMEMBER_ME_COOKIE")==null&&readCookie("ACEGI_SECURITY_HASHED_REMEMBER_ME_COOKIE").length<=0){
var _86=new Date().getTime();
var _85=_86-maptales.rpc.lastServerCall;
if(maptales.rpc.sessionTimeout<_85){
maptales.rpc.callSessionExpirationCallbacks();
}
}
};
maptales.rpc.sendMail=function(_87,_88){
var _89="parameters="+JSON.stringify(_87);
maptales.rpc.callRPC("/sendMail",_89,"post",function(_8a){
if(_8a.wasSuccessful()){
_88(_8a);
}else{
ajaxLog.warn("sendMail reply was exception: "+_8a.getReplyMessage());
_88(new SnapMapException("SendMail Exception",""));
}
});
};
maptales.rpc.sendInvitation=function(_8b,_8c){
var _8d={receiver:_8b.receiver,message:_8b.message};
var _8e="parameters="+JSON.stringify(_8d);
maptales.rpc.callRPC("/sendInvitation",_8e,"post",function(_8f){
if(_8f.wasSuccessful()){
_8c(_8f);
}else{
ajaxLog.warn("sendInvitation reply was exception: "+_8f.getReplyMessage());
_8c(new SnapMapException("Send Invitation Exception",""));
}
});
};
maptales.rpc.incrementViewCount=function(id,_91){
var _92={id:id};
var _93="parameters="+JSON.stringify(_92);
maptales.rpc.callRPC("/incrementViewCount",_93,"post",function(_94){
if(!_94.wasSuccessful()){
ajaxLog.warn("incrementViewCount reply was exception: "+_94.getReplyMessage());
}
_91();
});
};
maptales.rpc.currentCalls=0;
maptales.rpc.loadingListeners=[];
maptales.rpc.startLoading=function(){
try{
for(var e=0;e<maptales.rpc.loadingListeners.length;e++){
maptales.rpc.loadingListeners[e](true);
}
}
catch(ex){
ajaxLog.error("error in loading listener",ex);
}
};
maptales.rpc.finishedLoading=function(){
try{
for(var e=0;e<maptales.rpc.loadingListeners.length;e++){
maptales.rpc.loadingListeners[e](false);
}
}
catch(ex){
ajaxLog.error("error in loading listener",ex);
}
};
maptales.rpc.addLoadingListener=function(_97){
maptales.rpc.loadingListeners.push(_97);
};
maptales.rpc.removeLoadingListener=function(_98){
maptales.rpc.loadingListeners.removeEntry(_98);
};
maptales.rpc.callRPC=function(_99,_9a,_9b,_9c){
ajaxLog.debug(_99+" called, "+_9a+" method: "+_9b);
maptales.rpc.lastServerCall=new Date().getTime();
if(maptales.rpc.currentCalls==0){
maptales.rpc.startLoading();
}
maptales.rpc.currentCalls++;
_9a+="&sessionId="+maptales.rpc.sessionId;
new Ajax.Request(maptales.rpcUrl+_99,{method:_9b,encoding:"UTF-8",parameters:_9a,onException:function(_9d){
ajaxLog.error("RPC's Could not Connect to Server. Maybe a Security Issue by calling remote Servers.");
maptales.rpc.callServerOfflineCallbacks("404");
},onComplete:function(_9e){
maptales.rpc.currentCalls--;
if(maptales.rpc.currentCalls==0){
maptales.rpc.finishedLoading();
}
if(_9e.status==200){
ajaxLog.debug(_99+">"+_9e.responseText);
}else{
return;
}
var _9f=new Reply(maptales.rpc.evalJSON(_9e.responseText));
if(_9f.isSessionExpired){
maptales.rpc.callSessionExpirationCallbacks();
}
_9c(_9f);
}});
};
maptales.rpc.storeRSS=function(_a0,_a1){
var _a2=[];
var _a3=0;
maptales.rpc.tempRssItemsToStore.each(function(_a4){
if(_a0[_a3]==true){
_a2.push(_a4);
}
_a3++;
}.bind(this));
maptales.rpc.store(_a2,function(_a5){
if(_a5 instanceof SnapMapException){
_a1(_a5);
return;
}
_a1(_a5);
});
};
maptales.rpc.loadScript=function(url){
var _a7=document.createElement("SCRIPT");
_a7.id=url;
var _a8=new Date();
_a7.src=url+"?"+_a8.getTime();
var _a9=document.getElementsByTagName("HEAD")[0];
_a9.appendChild(_a7);
},maptales.rpc.deleteById=function(_aa,_ab){
var _ac=_aa.ids;
var _ad=_aa.recursive;
var ids=[];
if(!(_ac instanceof Array)){
_ac=[_ac];
}
for(var i=0;i<_ac.length;i++){
var _b0=$O(_ac[i]);
var _b1=_b0.isLoaded();
if(_b0.id<0){
ajaxLog.error("tried to delete an object with temp id.");
throw new SnapMapException("DeleteError","Could not delete object");
}else{
var id=_b0.id;
}
var _b3=$O(id).getClassName();
var _b4={type:_b3};
if(_b1){
if(_ad==false){
_b0.releaseAssociations();
}else{
}
_b4.id=id;
ids.push(_b4);
}else{
_b4.id=id;
_b4.load=$O(_ac[i]).getSlotsToRelease();
ids.push(_b4);
}
}
var _b5=_ad||false;
var _b6={deletedObjects:ids,recursive:_b5};
var _b7="parameters="+JSON.stringify(_b6);
maptales.rpc.callRPC("/delete",_b7,"post",function(_b8){
if(_b8.wasSuccessful()){
var _b9=maptales.cache.makeObjects(_b8.getData().deletedObjects);
if(_ab){
_ab(_b9);
}else{
ajaxLog.error("no callback passed to delete.");
}
}else{
ajaxLog.warn("Storage Exception. Could not delete "+_ac.length+" objects. "+_b8.getReplyMessage());
_ab(new SnapMapException("Storage Exception",_b8.getReplyMessage()));
}
});
};
maptales.rpc.postComment=function(_ba,_bb){
var _bc="parameters={comment:"+JSON.stringify(_ba.getData())+"}";
maptales.rpc.callRPC("/postComment",_bc,"post",function(_bd){
if(_bd.wasSuccessful()){
var _be=maptales.cache.makeObjects(_bd.getData().comment);
_bb(_be);
}else{
ajaxLog.warn("Error Posting Comment: "+_bd.getReplyMessage());
_bb(new SnapMapException("Error Posting Comment",_bd.getReplyMessage()));
}
});
};
maptales.rpc.getFlaggedItems=function(_bf,_c0,_c1,_c2){
maptales.rpc.callRPC("/getflaggedItems","parameters="+JSON.stringify({groupId:_bf}),"post",function(_c3){
if(!_c3.wasSuccessful()){
if(this.widget){
}
}else{
var _c4=maptales.cache.makeObjects(_c3.getData().flaggedItems);
maptales.ui.getMainMap().removeCurrentContext();
maptales.ui.getMainMap().clearAllOverlays();
maptales.ui.getMainMap().addQueryOverlays(_c4);
_c0.display(_c2,{results:_c4,groupId:_bf},null,_c1);
}
}.bind(this));
};

if(!maptales){
var maptales={};
}
if(!maptales.service){
maptales.service={};
}
maptales.service.group={};
maptales.service.group.logger=maptales.getLogger("com.maptales.service.group");
maptales.service.group.setRights=function(_1,_2){
var _3=$O(_1.groupId);
_3.set("hasModeratedAddition",_1.hasModeratedAddition);
_3.set("isInviteOnly",_1.isInviteOnly);
_3.set("isPrivate",_1.isPrivate);
maptales.ui.service.persist(_3,_2);
};
maptales.service.group.store=function(_4,_5){
maptales.service.store(_4,function(_6){
if(!(_6 instanceof SnapMapException)){
try{
$O(_6[0].id).roleOfLoggedInUser=GROUP_ADMIN;
maptales.ui.getCurrentUser().addToSlot("groupsHeAdministers",_6);
}
catch(e){
}
}
_5(_6);
});
};
maptales.service.group.addTag=function(_7,_8){
var _9=maptales.service.create("Tag",{tag:_7.tag});
maptales.rpc.group.addTag(_7,function(_a){
if(!(_a instanceof SnapMapException)){
try{
$O(_7.groupId).addToSlot("tags",_a);
$O(_7.groupId).cleanSlot("tags");
}
catch(e){
}
}
_8(_a);
});
};
maptales.service.group.removeTag=function(_b,_c){
maptales.rpc.group.removeTag(_b,function(_d){
if(!(_d instanceof SnapMapException)){
try{
$O(_b.groupId).removeFromSlot("tags",_b.tagId);
$O(_b.groupId).cleanSlot("tags");
}
catch(e){
}
}
_c(_d);
});
};
maptales.service.group.inviteUsers=function(_e,_f){
if(_e.groupId==null){
throw new SnapMapException("group.addMap: GroupId has to be defined");
}
var _10={};
_10.groupId=_e.groupId;
var _11=true;
var _12=0;
var _13=[];
while(_11){
if(_e["user_"+_12]!=null){
if(_e["user_"+_12]!=false){
_13.push(_e["user_"+_12]);
}
}else{
_11=false;
}
_12++;
}
_10.userIds=_13;
maptales.rpc.group.inviteUsers(_10,function(_14){
if(!(_14 instanceof SnapMapException)){
try{
var _15=$O(_e.groupId);
_15.addToSlot("maps",map);
_15.cleanSlot("maps");
}
catch(e){
}
}
_f(_14);
}.bind(this));
};
maptales.service.group.addMap=function(_16,_17){
if(_16.groupId==null){
throw new SnapMapException("group.addMap: GroupId has to be defined");
}
if(_16.title==null){
throw new SnapMapException("group.addMap: Map has to be defined");
}
var _18={};
var map=maptales.service.create("Map",_16);
_18.map=map.getData();
_18.groupId=_16.groupId;
maptales.rpc.group.addMap(_18,function(_1a){
if(!(_1a instanceof SnapMapException)){
try{
var _1b=$O(_16.groupId);
_1b.addToSlot("maps",map);
_1b.cleanSlot("maps");
}
catch(e){
}
}
_17(_1a);
}.bind(this));
};
maptales.service.group.removeMap=function(_1c,_1d){
if(_1c.groupId==null){
throw new SnapMapException("group.removeMap: GroupId has to be defined");
}
if(_1c.mapId==null){
throw new SnapMapException("group.removeMap: MapId has to be defined");
}
maptales.rpc.group.removeMap(_1c,function(_1e){
if(!(_1e instanceof SnapMapException)){
try{
var _1f=$O(_1c.groupId);
var map=$O(_1c.mapId);
_1f.removeFromSlot("maps",map);
_1f.cleanSlot("maps");
}
catch(e){
}
}
_1d(_1e);
}.bind(this));
};
maptales.service.group.addMedias=function(_21,_22){
if(_21.groupId==null){
throw new SnapMapException("group.addMedias: GroupId has to be defined");
}
if(_21.mediaId==null){
if(_21.mediaIds==null){
throw new SnapMapException("group.addMedias: MediaId has to be defined");
}else{
_21.mediaId=_21.mediaIds;
}
}
maptales.rpc.group.addMedias(_21,function(_23){
if(!(_23 instanceof SnapMapException)){
try{
var _24=$O(_21.groupId);
var _25=$O(_21.mediaId);
if(_24.get("hasModeratedAddition")){
_24.addToSlot("pendingAdditions",_25);
}else{
if(_21.mapId!=null){
var map=$O(_21.mapId);
map.addToSlot("mapAdditions",_25);
}
}
}
catch(e){
}
}
_22(_23);
}.bind(this));
};
maptales.service.group.acceptMedias=function(_27,_28){
var _29=true;
var _2a=0;
if(_27==null){
throw new SnapMapException("Invalid form");
}
var _2b=[];
while(_29){
if(_27["media_"+_2a]!=null){
_2b[_2a]={groupId:_27.groupId,mediaId:_27["media_"+_2a],mapId:_27["map_"+_2a],code:_27["approve_"+_2a]};
}else{
_29=false;
}
_2a++;
}
maptales.rpc.group.acceptMedias(_2b,function(_2c){
if(!(_2c instanceof SnapMapException)){
try{
var _2d=$O(_27.groupId);
for(var e=0;e<_2b.length;e++){
if(_2b[e].code!=-1){
var _2f=_2b[e].mapId;
var _30=_2b[e].mediaId;
var _31=new GroupAddition({group:_27.groupId,map:_2f,media:_30});
_2d.removeFromSlot("pendingAdditions",_31);
_2d.pendingAdditionsNum--;
try{
var map=$O(_2f);
var _33=new MapAddition({map:map,media:_30,dateAdded:new Date()});
map.addToSlot("mapAdditions",_33);
}
catch(e){
}
}
}
}
catch(e){
maptales.service.group.logger.error("removing pending addition did not work",e);
}
}
_28(_2c);
});
};
maptales.service.group.addUser=function(_34,_35){
if(maptales.service.user.getCurrentUser()==null){
throw new SnapMapException("You have to be logged in to join a group");
}
maptales.rpc.group.addUser({groupId:_34.groupId,userId:maptales.service.user.getCurrentUserId()},function(_36){
if(!(_36 instanceof SnapMapException)){
var _37=$O(_34.groupId);
if(_37.get("isInviteOnly")==false){
_37.roleOfLoggedInUser=GROUP_MEMBER;
_37.addToSlot("members",maptales.service.user.getCurrentUser());
}
}
_35(_36);
});
};
maptales.service.group.removeUser=function(_38,_39){
if(maptales.service.user.getCurrentUser()==null){
throw new SnapMapException("You have to be logged in to remove a user from a group");
}
maptales.rpc.group.removeUser({groupId:_38.groupId,userId:_38.userId},function(_3a){
if(!(_3a instanceof SnapMapException)){
var _3b=$O(_38.groupId);
_3b.roleOfLoggedInUser=NOT_GROUP_MEMBER;
_3b.removeFromSlot("members",_38.userId);
_3b.removeFromSlot("admins",_38.userId);
_3b.removeFromSlot("moderators",_38.userId);
}
_39(_3a);
});
};
maptales.service.group.deletePost=function(_3c,_3d){
if(maptales.service.user.getCurrentUser()==null){
throw new SnapMapException("You have to be logged in to post comments");
}
var _3e=$O(_3c.postId);
maptales.rpc.group.deletePost({postId:_3e.id},function(_3f){
if(!(_3f instanceof SnapMapException)){
try{
_3e.getRefFromCache("parentPost").removeFromSlot("replies",_3e);
_3e.getRefFromCache("parentPost").cleanSlot("replies");
}
catch(e){
}
try{
_3e.getRefFromCache("group").removeFromSlot("posts",_3e);
$O(_3c.groupId).cleanSlot("posts");
}
catch(e){
}
}
_3d(_3f);
});
};
maptales.service.group.storePost=function(_40,_41){
if(maptales.service.user.getCurrentUser()==null){
throw new SnapMapException("You have to be logged in to post comments");
}
var _42=maptales.service.create("GroupPost",{group:_40.groupId,parentPost:_40.postId,title:_40.title,text:_40.text,creator:maptales.service.user.getCurrentUser().id});
maptales.rpc.group.storePost({groupPost:_42.getData()},function(_43){
if(!(_43 instanceof SnapMapException)){
try{
if(_40.postId){
$O(_40.postId).addToSlot("replies",_42);
$O(_40.postId).cleanSlot("replies");
}
$O(_40.groupId).addToSlot("posts",_42);
$O(_40.groupId).cleanSlot("posts");
}
catch(e){
}
}
_41(_43);
});
};
maptales.service.group.setMemberRank=function(_44,_45){
if(maptales.service.user.getCurrentUser()==null){
throw new SnapMapException("You have to be logged in to set member rank");
}
if(!_44.userId){
throw new SnapMapException("UserId has to be defined");
}
if(!_44.groupId){
throw new SnapMapException("GroupId has to be defined");
}
if(!_44.rank){
throw new SnapMapException("Rank has to be defined");
}
maptales.rpc.group.setMemberRank(_44,function(_46){
if(!(_46 instanceof SnapMapException)){
try{
if(_44.rank==GROUP_MEMBER){
$O(_44.groupId).addToSlot("members",_44.userId);
}else{
if(_44.rank==GROUP_MODERATOR){
$O(_44.groupId).addToSlot("moderators",_44.userId);
}else{
if(_44.rank==GROUP_ADMIN){
$O(_44.groupId).addToSlot("admins",_44.userId);
}
}
}
if(_44.currentRank==GROUP_MEMBER){
$O(_44.groupId).removeFromSlot("members",_44.userId);
}else{
if(_44.currentRank==GROUP_MODERATOR){
$O(_44.groupId).removeFromSlot("moderators",_44.userId);
}else{
if(_44.currentRank==GROUP_ADMIN){
$O(_44.groupId).removeFromSlot("admins",_44.userId);
}
}
}
}
catch(e){
maptales.service.group.logger.error("error",e);
}
}
_45(_46);
});
};

if(!maptales){
var maptales={};
}
if(!maptales.service){
maptales.service={};
}
maptales.service.map={};
maptales.service.map.addMedias=function(_1,_2){
if(_1.mediaId!=null&&_1.mediaIds==null){
_1.mediaIds=[_1.mediaId];
delete _1.mediaId;
}
maptales.rpc.map.addMedias(_1,function(_3){
if(_3 instanceof SnapMapException){
}else{
try{
var _4=$O(_1.mapId);
var _5=[];
if(_1.mediaIds instanceof Array){
for(var e=0;e<_1.mediaIds.length;e++){
_5.push($O(_1.mediaIds[e]));
}
}else{
_5=[$O(_1.mediaIds)];
}
for(var a=0;a<_5.length;a++){
_5[a].addToSlot("maps",_4);
_4.addToSlot("mapAdditions",_5[a].id);
_4.cleanSlot("mapAdditions");
}
}
catch(e){
}
}
if(_2 instanceof Function){
_2(_3);
}
}.bind(this));
};
maptales.service.map.removeMedias=function(_8,_9){
maptales.rpc.map.removeMedias(_8,function(_a){
if(_a instanceof SnapMapException){
}else{
try{
var _b=$O(_8.mapId);
var _c=[];
if(_8.mediaIds instanceof Array){
for(var e=0;e<_8.mediaIds.length;e++){
_c.push($O(_8.mediaIds[e]));
}
}else{
_c=[$O(_8.mediaIds)];
}
for(var a=0;a<_c.length;a++){
_c[a].removeFromSlot("maps",_b);
_b.removeFromSlot("mapAdditions",_c[a].id);
_b.cleanSlot("mapAdditions");
}
}
catch(e){
}
}
if(_9 instanceof Function){
_9(_a);
}
}.bind(this));
};

if(!maptales){
var maptales={};
}
if(!maptales.service){
maptales.service={};
}
maptales.service.user={logger:maptales.getLogger("com.maptales.service.user"),currentUser:null,loginListeners:[],getCurrentUser:function(){
if(this.currentUser){
return $O(this.currentUser.id);
}else{
return null;
}
},setCurrentUser:function(_1){
if(_1){
this.currentUser=_1;
}else{
this.currentUser=false;
}
},getCurrentUserId:function(){
if(this.currentUser){
return this.currentUser.get("id");
}else{
return false;
}
},currentUserHasRole:function(_2){
if(this.currentUser){
return this.currentUser.hasRole(_2);
}else{
return false;
}
},forgotPassword:function(_3,_4){
maptales.rpc.user.forgotPassword(_3,_4);
},setUserProperty:function(_5,_6){
var _7=this.getCurrentUser();
var _8=false;
for(parameter in _5){
if(_5[parameter]+""!=_7.getProperty(parameter)){
_7.setProperty(parameter,_5[parameter]+"");
_8=true;
}
}
if(_8){
maptales.rpc.persist(_7,function(_9){
});
}
},register:function(_a,_b){
var _c=_a.pass;
maptales.rpc.user.register(_a,function(_d){
if(_d instanceof SnapMapException){
_b(_d);
return _d;
}else{
_d.name=_a.name;
_d.pass=_c;
_b(_d);
return _d;
}
}.bind(this));
},addLoginListener:function(_e){
if(_e instanceof Function){
this.loginListeners.push(_e);
}else{
this.logger.warn("you have to pass a function to the login listeners");
}
},notifyLoginListeners:function(){
for(var i=0;i<this.loginListeners.length;i++){
try{
this.loginListeners[i](this.getCurrentUser());
}
catch(e){
this.logger.error("could not call login listener: "+this.loginListeners[i]);
}
}
},login:function(_10,_11){
return maptales.rpc.user.login(_10,function(_12){
if(!(_12 instanceof SnapMapException)){
if(_12 instanceof User){
this.setCurrentUser(_12);
this.notifyLoginListeners();
}
}
_11(_12);
}.bind(this));
},reEstablishSession:function(_13,_14){
return maptales.rpc.user.reestablishSession(_13,function(_15){
if(_15 instanceof SnapMapException){
$("reEstablishSessionError").innerHTML="Username or Password are incorrect";
}else{
try{
$("reEstablishSessionError").innerHTML="";
$("sessionExpirationNotification").style.display="none";
}
catch(e){
maptales.service.logger.warn("error reseting reestablish session screen.");
}
maptales.service.user.setCurrentUser(_15);
}
});
},logout:function(_16,_17){
this.logger.debug("logout called");
var _18=this.getCurrentUser();
this.setCurrentUser(null);
maptales.rpc.removeSessionExpirationCallback(this.boundOnSessionExpirationCallback);
this.notifyLoginListeners();
return maptales.rpc.user.logout(_16,function(_19){
if(!(_19 instanceof SnapMapException)){
this.logger.debug("logout complete");
}
if(_17){
_17(_19);
}
}.bind(this));
},addContact:function(_1a,_1b){
var tag=null;
if(_1a.tagType=="family"){
tag="family";
}else{
if(_1a.tagType=="friend"){
tag="friend";
}else{
tag=_1a.customTag;
}
}
var _1d=new Contact();
_1d.set("tag",tag);
_1d.setOwner(this.getCurrentUserId());
_1d.setContact(_1a.contactId);
maptales.rpc.user.addContact(_1a,function(_1e){
if(_1e instanceof SnapMapException){
this.logger.warn("could not add contact");
}else{
try{
maptales.cache.addToCache(_1d);
this.getCurrentUser().addToSlot("contacts",_1d);
}
catch(e){
}
}
_1b(_1e);
}.bind(this));
},removeContact:function(_1f,_20){
this.getCurrentUser().removeFromSlot("contacts",_1f.contactId);
maptales.service.deleteById({id:_1f.contactId,recursion:false},_20);
},storeProfileImage:function(_21,_22){
maptales.rpc.user.storeProfileImage(_21,_22);
}};

if(!maptales){
var maptales={};
}
if(!maptales.service){
maptales.service={};
}
maptales.service.flickr={};
maptales.service.flickr.logger=maptales.getLogger("com.maptales.service.flickr");
maptales.service.flickr.importFromFlickr=function(_1,_2){
this.temporaryFlickrImagesSelected=[];
maptales.rpc.flickr.importFromFlickr(_1,function(_3){
if(_3 instanceof SnapMapException){
_2(_3);
}else{
this.temporaryFlickrImages=_3.flickrItems;
_2({flickrItems:_3.flickrItems});
}
}.bind(this));
};
maptales.service.flickr.toggleImportedFlickrPhoto=function(_4,_5){
if(this.temporaryFlickrImagesSelected[_4]==null){
_5.className="loadedFlickrImageSelected";
this.temporaryFlickrImagesSelected[_4]=true;
}else{
this.temporaryFlickrImagesSelected[_4]=!this.temporaryFlickrImagesSelected[_4];
if(this.temporaryFlickrImagesSelected[_4]){
_5.className="loadedFlickrImageSelected";
}else{
_5.className="loadedFlickrImage";
}
}
};
maptales.service.flickr.deselectAllFlickrPhotos=function(){
this.temporaryFlickrImagesSelected=[];
var _6=document.getElementsByClassName("loadedFlickrImageSelected",$("flickrImportReplyBox"));
for(var i=0;i<_6.length;i++){
_6[i].className="loadedFlickrImage";
}
};
maptales.service.flickr.selectAllFlickrPhotos=function(){
this.temporaryFlickrImagesSelected=[];
for(var e=0;e<this.temporaryFlickrImages.length;e++){
this.temporaryFlickrImagesSelected[e]=true;
}
var _9=document.getElementsByClassName("loadedFlickrImage",$("flickrImportReplyBox"));
for(var i=0;i<_9.length;i++){
_9[i].className="loadedFlickrImageSelected";
}
};
maptales.service.flickr.storeFlickrItems=function(_b){
var _c=[];
for(var i=0;i<this.temporaryFlickrImagesSelected.length;i++){
if(this.temporaryFlickrImagesSelected[i]){
if(this.temporaryFlickrImages[i].getRefId("mapobject")!=null){
var _e=this.temporaryFlickrImages[i].getRefFromCache("mapobject");
this.temporaryFlickrImages[i].set("mapobject",null);
_c.push(_e);
}else{
_c.push(this.temporaryFlickrImages[i]);
}
}
}
var _f=document.getChildById("loading",_b);
if(_f){
_f.style.display="block";
}
maptales.service.store(_c,function(_10){
if(_10 instanceof SnapMapException){
var _11=document.getChildById("error",_b);
if(_11){
_11.style.display="block";
}
}else{
if(_f){
_f.style.display="none";
}
var _12=document.getChildById("confirmation",_b);
if(_12){
_12.style.display="block";
}
}
});
};

if(!maptales){
var maptales={};
}
if(!maptales.service){
maptales.service={};
}
maptales.service.logger=maptales.getLogger("com.maptales.service");
maptales.service.insertControlpoint=function(_1,_2){
maptales.rpc.insertControlpoint(_1,_2);
};
maptales.defaultAjaxErrorHandler=function(_3){
if(_3 instanceof SnapMapException){
maptales.ui.addWarning("An error occured while proccesing your request",_3.getMessage());
}
};
maptales.service.importVideos=function(_4,_5){
return maptales.rpc.importVideos(_4,function(_6){
if(!(_6 instanceof SnapMapException)){
var _7=maptales.ui.getCurrentUser();
_7.addToSlot("medias",_6);
}
_5(_6);
});
};
maptales.service.sendMessage=function(_8,_9){
return maptales.rpc.sendMessage(_8,_9);
};
maptales.service.getSlot=function(_a,_b){
return maptales.rpc.getSlot(_a,_b);
};
maptales.service.getById=function(_c,_d){
return maptales.rpc.getById(_c,_d);
};
maptales.service.grantAllRights=function(_e){
if(_e instanceof Tag){
}else{
var _f=DEFAULT_RIGHTS;
$H(_f).each(function(_10){
var key=_10.key;
_e.renderedRights[key]=true;
});
}
};
maptales.service.store=function(_12,_13){
_12=maptales.service.typeCastObjects(_12);
if(!(_12 instanceof Array)){
_12=[_12];
}
for(var i=0;i<_12.length;i++){
maptales.service.onStore(_12[i]);
var _15=_12[i].getTransientRefs();
for(var e=0;e<_15.length;e++){
maptales.service.onStore(_15[e]);
}
}
return maptales.rpc.store(_12,_13);
};
maptales.service.onStore=function(obj){
var _18=maptales.cache.getFromCache(maptales.service.user.getCurrentUserId());
obj.set("creator",_18);
obj.creatorName=_18.get("name");
obj.set("creationDate",new Date());
obj.set("rights",DEFAULT_RIGHTS);
maptales.service.grantAllRights(obj);
if(_18.hasSlotForObject(obj)){
_18.addToSlot(_18.hasSlotForObject(obj),obj);
}
if(obj instanceof Media){
if(obj.getRefId("story")!=null){
try{
maptales.cache.getFromCache(obj.getRefId("story")).addToSlot("medias",obj);
}
catch(e){
}
}
}
};
maptales.service.deleteById=function(_19,_1a){
if(_19.ids){
var ids=_19.ids;
}else{
var ids=[_19.id];
}
return maptales.rpc.deleteById({ids:ids,recursive:_19.recursive},function(_1c){
if(!(_1c instanceof SnapMapException)){
for(var e=0;e<ids.length;e++){
var _1e=$O(ids[e]);
maptales.service.deleteLocally(_1e,_19.recursive);
}
}
if(_1a instanceof Function){
_1a(_1c);
}
});
};
maptales.service.sendMail=function(_1f,_20){
return maptales.rpc.sendMail(_1f,_20);
};
maptales.service.sendInvitation=function(_21,_22){
return maptales.rpc.sendInvitation(_21,_22);
};
maptales.service.loadRSS=function(_23,_24){
return maptales.rpc.loadRSS(_23,_24);
};
maptales.service.storeRSS=function(_25,_26){
return maptales.rpc.storeRSS(_25,_26);
};
maptales.service.persist=function(_27,_28){
if(!_28){
_28=maptales.defaultAjaxErrorHandler;
}
if(_27 instanceof ContentObject||_27 instanceof Array){
return maptales.rpc.persist(_27,_28);
}else{
return maptales.rpc.persist($O(_27),_28);
}
};
maptales.service.getUploadStatus=function(_29){
maptales.rpc.getUploadStatus(_29);
};
maptales.service.incrementViewCount=function(id,_2b){
if($O(id).getRefId("creator")!=maptales.service.user.getCurrentUserId()){
maptales.rpc.incrementViewCount(id,function(_2c){
if(_2c instanceof SnapMapException){
}else{
var _2d=maptales.cache.getFromCache(id);
_2d.set("viewCount",_2d.get("viewCount")+1);
}
if(_2b instanceof Function){
_2b(_2c);
}
});
}
};
maptales.service.create=function(_2e,_2f){
if(!_2f){
_2f={};
}
_2f.id=maptales.tempIdIndex;
maptales.tempParametersForObfuscator=_2f;
try{
var _30=eval("new "+_2e+"(maptales.tempParametersForObfuscator)");
}
catch(e){
maptales.service.logger.error("SnapMap>create>"+_2e,e);
}
maptales.cache.addToCache(_30);
_30.set("creator",maptales.service.user.getCurrentUser());
_30.creatorName=maptales.service.user.getCurrentUser().get("name");
maptales.service.grantAllRights(_30);
maptales.tempIdIndex--;
return _30;
};
maptales.service.deleteLocally=function(_31,_32){
if(_31 instanceof ContentObject){
if(_32==false){
_31.releaseAssociations();
}else{
_31.deleteAssociations();
}
_31.notifyDeleteListener();
maptales.cache.removeFromCache(_31.id);
}
};
maptales.service.getAndIncrementTempId=function(){
return maptales.tempIdIndex--;
};
maptales.service.typeCastObjects=function(obj){
if(!obj){
return [];
}
if(obj instanceof Array){
var _34=[];
obj.each(function(_35,_36){
if(_35 instanceof ContentObject){
_34.push(_35);
}else{
_34.push(maptales.service.typeCastObjects(_35));
}
});
return _34;
}else{
try{
if(obj instanceof ContentObject){
var _37=obj;
}else{
var _37=maptales.service.create(obj.type,obj);
}
}
catch(e){
maptales.service.logger.error("maptales.typeCastObjects > Error: "+obj.type,e);
}
}
return _37;
};
maptales.service.doWithObject=function(_38,_39){
if(isNaN(_38)){
_39(_38);
}else{
maptales.service.getById(_38,_39);
}
};
maptales.service.postComment=function(_3a,_3b){
if(maptales.service.user.getCurrentUser()==null){
_3b(new SnapMapFormException("text","You have to be logged in to post comments"));
}
var _3c=maptales.service.create("Comment",{content:_3a.contentId,text:_3a.text,creator:maptales.service.user.getCurrentUser().id,profileIcon:maptales.service.user.getCurrentUser().get("profileIcon")});
maptales.rpc.postComment(_3c,function(_3d){
if(!(_3d instanceof SnapMapException)){
try{
$O(_3a.contentId).addToSlot("comments",_3d);
$O(_3a.contentId).cleanSlot("comments");
}
catch(e){
}
}
_3b(_3d);
});
};
maptales.service.deleteComment=function(_3e,_3f){
var _40=$O(_3e.commentId).getRefFromCache("content");
maptales.service.deleteById({id:_3e.commentId,recursion:false},function(_41){
if(!(_41 instanceof SnapMapException)){
_40.removeFromSlot("comments",_3e.commentId);
_40.cleanSlot("comments");
}
}.bind(this));
};
maptales.service.setProperty=function(_42,_43){
var _44=$O(_42.id);
var _45=_44.get(_42.fieldName,function(){
});
_44.set(_42.fieldName,_42.fieldValue);
maptales.service.persist(_44,function(_46){
if(_46 instanceof SnapMapException){
_44.set(_42.fieldName,_45);
}
if(_43 instanceof Function){
_43(_46);
}
});
};
maptales.service.removeFromSlot=function(_47,_48){
var _49=$O(_47.id);
_49.removeFromSlot(_47.slotName,_47.slotItemId);
_49.persist(_48);
};
maptales.service.addSelectedItemsToSlot=function(_4a,_4b){
maptales.service.doWithObject(_4a.id,function(obj){
obj.addToSlot(_4a.slot,DragDrop.getDraggedObjects());
obj.persist(_4b);
}.bind(this));
};

if(!maptales){
var maptales={};
}
if(!maptales.service){
maptales.service={};
}
maptales.service.query={logger:maptales.getLogger("com.maptales.webclient.widgets.queryservice"),queries:{},queryListeners:{},queriesResult:{},mapQuerySequence:0,collectQueries:false,groupIdFilter:null,groupMemberFilter:false,groupModeratorFilter:false,parameters:{tags:[],bounds:null,startDate:null,endDate:null,locally:true,zoomLevel:null},parameterListeners:{tags:[],bounds:[],startDate:[],endDate:[],locally:[]},setGroupFilter:function(id){
this.groupIdFilter=id;
},setGroupModeratorFilter:function(_2){
this.groupModeratorFilter=_2;
},setGroupMemberFilter:function(_3){
this.groupMemberFilter=_3;
},addTag:function(_4){
this.parameters.tags.push(_4);
},getTags:function(){
return this.parameters.tags;
},removeTag:function(_5){
this.parameters.tags.removeEntry(_5);
},setTag:function(_6){
if(_6==null){
this.parameters.tags=[];
}else{
this.parameters.tags=[_6];
}
},clearTags:function(){
this.parameters.tags=[];
},observeTags:function(_7){
this.parameterListeners.tags.push(_7);
},stopObservingTags:function(_8){
this.parameterListeners.tags.removeEntry(_8);
},setBounds:function(_9){
this.parameters.bounds=_9;
},setGroup:function(_a){
this.parameters.groupId=_a;
},setMap:function(_b){
this.parameters.mapId=_b;
},setUser:function(_c){
this.parameters.user=_c;
},setStartDate:function(_d){
this.parameters.startDate=_d;
},setEndDate:function(_e){
this.parameters.endDate=_e;
},setZoomLevel:function(_f){
this.parameters.zoomLevel=_f;
},setLocally:function(_10){
this.parameters.locally=convertBoolean(_10);
this.callLocallyObservers();
},isLocal:function(){
return this.parameters.locally;
},observeLocally:function(_11){
this.parameterListeners.locally.push(_11);
},stopObservingLocally:function(_12){
this.parameterListeners.locally.removeEntry(_12);
},callLocallyObservers:function(){
if(this.parameterListeners.locally.length>0){
for(var e=0;e<this.parameterListeners.locally.length;e++){
this.parameterListeners.locally[e](this.locally);
}
}
},clearParameters:function(){
this.parameters={groupId:null,mapId:null,tags:[],bounds:null,startDate:null,endDate:null,locally:true,zoomLevel:null};
},clearQueries:function(){
},addQuery:function(_14,_15){
if(!this.hasQuery(_14)){
this.queries[_14.hash()]=_14;
}else{
try{
var _16=this.getQueryResultSet(_14);
_15(_16);
}
catch(e){
}
}
this.addQueryListener(_14,_15);
if(this.collectQueries==false){
this.searchSingleQuery(_14,_15);
}
},removeQuery:function(_17,_18){
this.removeQueryListener(_17,_18);
if(!this.hasQueryListeners(_17)){
delete this.queries[_17.hash()];
}
},hasQuery:function(_19){
if(_19 instanceof Query){
if(this.queries[_19.hash()]!=null){
return true;
}else{
return false;
}
}else{
throw SnapMapException("Non Query passed to maptales.service.query.hasQuery");
}
},addQueryListener:function(_1a,_1b){
var _1c=this.queryListeners[_1a.hash()];
if(_1c==null){
_1c=[];
}
_1c.push(_1b);
this.queryListeners[_1a.hash()]=_1c;
},removeQueryListener:function(_1d,_1e){
var _1f=this.queryListeners[_1d.hash()];
if(_1f!=null){
_1f.removeEntry(_1e);
}
},hasQueryListeners:function(_20){
var _21=this.queryListeners[_20.hash()];
if(_21==null||_21.length==0){
return false;
}
return true;
},callAllQueryListeners:function(){
for(queryHash in queries){
this.callQueryListeners(queries[queryHash]);
}
},callQueryListeners:function(_22){
var _23=this.queryListeners[_22.hash()];
if(_23!=null){
for(var e=0;e<_23.length;e++){
if(_23[e] instanceof Function){
_23[e](this.getQueryResultSet(_22));
}else{
this.logger.warn("Callback was not a function");
}
}
}
},getQueryResultSet:function(_25){
if(this.queriesResult[_25.hash()]){
return this.queriesResult[_25.hash()];
}else{
throw new SnapMapException("CacheException","Query is not loaded yet");
}
},setQueryResultSet:function(_26,_27){
this.queriesResult[_26.hash()]={};
this.queriesResult[_26.hash()].queryResults=maptales.cache.makeObjects(_27.queryResults);
this.queriesResult[_26.hash()].querySize=_27.querySize;
if(_26.parameters&&_26.parameters.filter){
var _28=_26.parameters.filter[0];
var _29=this.queriesResult[_26.hash()].queryResults;
if(_28.field.indexOf(".")>-1){
var _2a=_28.field.split(".");
var _2b=_2a.last();
}else{
var _2b=_28.field;
}
for(var i=0;i<_29.length;i++){
var _2d=_29[i];
if(_2a){
for(var e=0;e<_2a.length;e++){
_2d=_2d.getRefFromCache(_2a[e]);
}
}
$O(_2d.id).addFieldListener(_2b,function(_2f,_30){
this.evictItem(_26,_28,_2d,_2f,_30);
}.bind(this));
}
}
this.callQueryListeners(_26);
},clearCache:function(){
this.queriesResult=[];
},evictItem:function(_31,_32,_33,_34,_35){
var _36=false;
if(_32.comparator=="="){
if(_34!=_32.value){
_36=true;
}
}else{
if(_32.comparator=="!="){
if(_34==_32.value){
_36=true;
}
}
}
if(_36){
this.queriesResult[_31.hash()].queryResults.removeById(_35);
this.callQueryListeners(_31);
}
},search:function(){
var _37=[];
for(queryHash in this.queries){
_37.push(this.queries[queryHash].parameters);
}
if(_37.length>0){
var _38=++this.mapQuerySequence;
var _39=Object.extend({},this.parameters);
this.addGroupFilters(_39);
maptales.rpc.query(_39,_37,_38,function(_3a){
if(_3a.sequence){
if(_3a.sequence!=this.mapQuerySequence){
return;
}
}
this.queryCallback(_3a);
}.bind(this));
}
},addGroupFilters:function(_3b){
if(this.groupIdFilter!=null){
_3b.groupId=this.groupIdFilter;
}
if(this.groupMemberFilter==true&&this.groupModeratorFilter==false){
_3b.membersOnly=true;
}else{
if(this.groupMemberFilter==false&&this.groupModeratorFilter==true){
_3b.moderatorsOnly=true;
}
}
},queryCallback:function(_3c){
if(_3c instanceof SnapMapException){
this.logger.error("Exception in maptales.service.query callback. "+_3c.getMessage());
}else{
for(var e=0;e<_3c.queries.length;e++){
var qp=_3c.queries[e].query;
var _3f=new Query(qp);
this.setQueryResultSet(_3f,_3c.queries[e]);
}
}
},searchSingleQuery:function(_40,_41){
var _42=[_40.parameters];
var _43=Object.extend({},this.parameters);
this.addGroupFilters(_43);
maptales.rpc.query(_43,_42,null,function(_44){
if(_44 instanceof SnapMapException){
_41(_44);
}else{
_41({queryResults:maptales.cache.makeObjects(_44.queries[0].queryResults),querySize:_44.queries[0].querySize});
}
}.bind(this));
},startQueryBatch:function(){
this.collectQueries=true;
},endQueryBatch:function(){
this.collectQueries=false;
this.search();
}};
maptales.event.registerEventListener("startQueryBatch",maptales.service.query.startQueryBatch.bind(maptales.service.query));
maptales.event.registerEventListener("endQueryBatch",maptales.service.query.endQueryBatch.bind(maptales.service.query));
var Query=Class.create();
Query.prototype={initialize:function(_45){
if(_45==null){
_45={};
}
this.parameters={};
this.parameters.type=_45.type;
if(_45.tags!=null){
if(_45.tags instanceof Array){
this.parameters.tags=_45.tags;
}else{
this.parameters.tags=tokenizeTags(_45.tags);
}
}
if(_45.offset!=null){
this.parameters.offset=_45.offset;
}
if(_45.size!=null){
this.parameters.size=_45.size;
}
if(_45.sorting!=null){
this.parameters.sorting=_45.sorting;
}
if(_45.clustered!=null){
this.parameters.clustered=_45.clustered;
}
if(_45.locally!=null){
this.parameters.locally=_45.locally;
}
if(_45.groupId!=null){
this.parameters.groupId=_45.groupId;
}
if(_45.mapId!=null){
this.parameters.mapId=_45.mapId;
}
if(_45.userId!=null){
this.parameters.userId=_45.userId;
}
if(_45.startDate!=null){
this.parameters.startDate=_45.startDate;
}
if(_45.endDate!=null){
this.parameters.endDate=_45.endDate;
}
if(_45.itemsOfContacts!=null){
this.parameters.itemsOfContacts=_45.itemsOfContacts;
}
if(_45.filter!=null){
this.parameters.filter=_45.filter;
}
if(_45.notInMapId!=null){
this.parameters.notInMapId=_45.notInMapId;
}
},equals:function(_46){
if(this.parameters.type!=_46.parameters.type){
return false;
}
if(this.parameters.clustered!=_46.parameters.clustered){
return false;
}
if(this.parameters.tags!=null&&_46.parameters.tags!=null){
if(this.parameters.tags.length!=_46.parameters.tags.length){
return false;
}
if(!this.parameters.tags.equalsByValue(_46.parameters.tags)){
return false;
}
}else{
if(this.parameters.tags!=_46.parameters.tags){
return false;
}
}
if(this.parameters.clustered==false){
if(this.parameters.offset!=_46.parameters.offset){
return false;
}
if(this.parameters.size!=_46.parameters.size){
return false;
}
if(this.parameters.sorting!=_46.parameters.sorting){
return false;
}
}
if(this.parameters.groupId!=_46.parameters.groupId){
return false;
}
if(this.parameters.mapId!=_46.parameters.mapId){
return false;
}
if(this.parameters.userId!=_46.parameters.userId){
return false;
}
if(this.parameters.startDate!=_46.parameters.startDate){
return false;
}
if(this.parameters.endDate!=_46.parameters.endDate){
return false;
}
if(this.parameters.locally!=_46.parameters.locally){
return false;
}
if(this.parameters.itemsOfContacts!=_46.parameters.itemsOfContacts){
return false;
}
if(this.parameters.filter!=_46.parameters.filter){
return false;
}
if(this.parameters.notInMapId!=_46.parameters.notInMapId){
return false;
}
return true;
},hash:function(){
var _47="";
if(this.parameters.clustered==true){
_47=this.parameters.type+"clustered";
}else{
_47=this.parameters.type+"_offset:"+this.parameters.offset+"_size:"+this.parameters.size+"_sorting:"+this.stringifySorting(this.parameters.sorting);
}
if(this.parameters.tags){
_47+="_tags="+this.parameters.tags.join(", ");
}
if(this.parameters.mapId){
_47+="_map="+this.parameters.mapId;
}
if(this.parameters.notInMapId){
_47+="_notInMap="+this.parameters.notInMapId;
}
if(this.parameters.groupId){
_47+="_groupId="+this.parameters.groupId;
}
if(this.parameters.userId){
_47+="_userId="+this.parameters.userId;
}
if(this.parameters.startDate){
_47+="_startDate="+this.parameters.startDate;
}
if(this.parameters.endDate){
_47+="_endDate="+this.parameters.endDate;
}
if(this.parameters.locally){
_47+="_locally="+this.parameters.locally;
}
if(this.parameters.itemsOfContacts){
_47+="_itemsOfContacts="+this.parameters.itemsOfContacts;
}
if(this.parameters.filter){
_47+="_filter="+this.parameters.filter;
}
return _47;
},toString:function(){
return this.serialize();
},serialize:function(){
return JSON.stringify(this.parameters);
},copy:function(){
var _48=Object.extend({},this.parameters);
var _49=new Query();
_49.parameters=_48;
return _49;
},stringifySorting:function(){
if(this.sorting!=null){
return this.sorting.toLowerCase().replace(/\s/g,"");
}else{
return "";
}
}};

if(!maptales){
var maptales={};
}
if(!maptales.service){
maptales.service={};
}
maptales.service.merge={};
maptales.service.merge.logger=maptales.getLogger("com.maptales.service.merges");
maptales.service.merge={mapObjects:[],medias:[],map:null,offsetMedias:0,seconds:0,minutes:0,hours:0,days:0,years:0,placedMedias:[],unplacedMedias:[],limitToMedias:null,limitToMapObjects:null,MERGE_STATE:3,MERGED_STATE:4,state:this.MERGE_STATE,zoomTo:true,detectMerge:function(_1,_2,_3,_4,_5,_6){
if(this.boundTimestampListener==null){
this.boundTimestampListener=this.onTimestampChange.bind(this);
}
this.state=this.MERGE_STATE;
this.map=_3;
this.map.removeCurrentContext();
this.map.clearAllOverlays();
this.widget=_4;
this.templatePath=_6;
this.elementName=_5;
this.callDetectMerge(_1,_2);
},callDetectMerge:function(_7,_8,_9){
if(_9!=null){
this.offsetMedias=_9;
}else{
this.offsetMedias=0;
}
var _a={};
if(_7){
_a.mapObjects=_7.pluck("id");
}
if(_8){
_a.medias=_8.pluck("id");
}
if(_9!=null){
_a.offsetMedias=_9;
}
this.limitToMedias=_8;
this.limitToMapObjects=_7;
maptales.cache.removeAllFromCache(this.mapObjects);
maptales.cache.removeAllFromCache(this.unplacedMedias);
maptales.cache.removeAllFromCache(this.placedMedias);
maptales.rpc.callRPC("/detectMerge","parameters="+JSON.stringify(_a),"post",function(_b){
if(!_b.wasSuccessful()){
if(_b.subcode==Reply.notFound){
if(this.widget){
this.widget.display("objects/User/noGPXToMerge",null,null,this.elementName);
}
}
}else{
this.placedMedias=[];
this.unplacedMedias=[];
this.mapObjects=maptales.cache.makeObjects(_b.getData().mapObjects);
this.medias=maptales.cache.makeObjects(_b.getData().medias);
if(_9!=null&&(_9>0||_9<0)){
for(var e=0;e<this.medias.length;e++){
var _d=new Date(this.medias[e].get("timestamp").getTime()+_9);
this.medias[e].set("timestamp",_d);
}
}
for(var e=0;e<this.medias.length;e++){
this.medias[e].addFieldListener("timestamp",this.boundTimestampListener);
}
this.map.clearAllOverlays();
this.map.addQueryOverlays(this.mapObjects);
if(this.zoomTo==true){
this.map.showObjectBounds(this.mapObjects);
this.zoomTo=false;
}
this.map.displayContextTemplate("mapPanel/merge");
this.calculateAndPlaceMedias();
this.displayResult();
}
}.bind(this));
},displayResult:function(){
if(this.widget){
this.widget.display(this.templatePath,null,null,this.elementName);
}
},removePlacedMedia:function(id){
var _f=$O(id);
this.map.removeQueryOverlay(_f);
this.placedMedias.removeEntry(_f);
},addPlacedMedia:function(id){
var _11=$O(id);
_11.set("mapobject",null);
this.calculateAndPlaceMedia(_11);
},calculateAndPlaceMedias:function(){
for(var e=0;e<this.medias.length;e++){
this.calculateAndPlaceMedia(this.medias[e]);
}
},calculateAndPlaceMedia:function(_13){
_13=$O(_13.id);
var _14=this.findLocation(_13);
if(_14!=null){
if(_13.getRefId("mapobject")!=null){
var _15=_13.getRefFromCache("mapobject");
_15.set("location",_14);
this.map.updateOverlay(_15);
}else{
var _15=maptales.service.create("Marker",{location:_14,viewZoomLevel:13,viewZoomLevel:13});
_15.insertIntoSlot("medias",[_13],0,null,null,1);
_13.set("mapobject",_15);
this.map.addQueryOverlay(_13);
}
if(this.placedMedias.indexOf(_13)==-1){
this.placedMedias.push(_13);
}
if(this.unplacedMedias.indexOf(_13)!=-1){
this.unplacedMedias.removeEntry(_13);
}
}else{
if(this.placedMedias.indexOf(_13)!=-1){
this.placedMedias.removeEntry(_13);
}
if(this.unplacedMedias.indexOf(_13)==-1){
this.unplacedMedias.push(_13);
}
}
},setTimeshiftMedias:function(_16){
var _17=new Date();
maptales.service.merge.hours=0;
maptales.service.merge.days=0;
maptales.service.merge.minutes=0;
maptales.service.merge.seconds=0;
maptales.service.merge.years=0;
if(!isNaN(_16.seconds)){
maptales.service.merge.seconds=parseInt(_16.seconds);
}
if(!isNaN(_16.minutes)){
maptales.service.merge.minutes=parseInt(_16.minutes);
}
if(!isNaN(_16.hours)){
maptales.service.merge.hours=parseInt(_16.hours);
}
if(!isNaN(_16.days)){
maptales.service.merge.days=parseInt(_16.days);
}
if(!isNaN(_16.years)){
maptales.service.merge.years=parseInt(_16.years);
}
var _18=0;
_18=maptales.service.merge.years*1000*60*60*24*365;
_18+=maptales.service.merge.days*1000*60*60*24;
_18+=maptales.service.merge.hours*1000*60*60;
_18+=maptales.service.merge.minutes*1000*60;
_18+=maptales.service.merge.seconds*1000;
this.callDetectMerge(this.mapObjects,null,_18);
},onTimestampChange:function(_19,_1a){
if(this.state==this.MERGE_STATE){
this.calculateAndPlaceMedia(_1a);
this.displayResult();
}
},findLocation:function(_1b){
var _1c=_1b.get("timestamp").getTime();
var _1d=new Date(_1c);
for(var e=0;e<this.mapObjects.length;e++){
if(this.mapObjects[e] instanceof Line&&this.mapObjects[e].startDate!=null&&this.mapObjects[e].endDate!=null){
if(_1c>this.mapObjects[e].startDate.getTime()&&_1c<this.mapObjects[e].endDate.getTime()){
return this.mapObjects[e].getLocationAtTimestamp(_1d);
}
}else{
}
}
},timeshiftMapObjects:function(){
},mergeAndStoreItems:function(_1f,_20,_21){
this.state=this.MERGED_STATE;
for(var e=0;e<this.medias.length;e++){
this.medias[e].removeFieldListener("timestamp",this.boundTimestampListener);
}
var _23={};
_23.mapObjects=[];
_23.medias=[];
if(this.offsetMedias!=null){
_23.timeshiftMedias=this.offsetMedias;
}
for(var e=0;e<this.placedMedias.length;e++){
_23.medias.push(this.placedMedias[e].id);
}
for(e=0;e<this.mapObjects.length;e++){
_23.mapObjects.push(this.mapObjects[e].id);
}
maptales.rpc.callRPC("/merge","parameters="+JSON.stringify(_23),"post",function(_24){
if(_24.wasSuccessful()){
this.mergedItems=_24.getData().mergedItems;
_20(_24);
}else{
var _25=new SnapMapException("Merge Error","A problem occurred merging your Paths with the Images.");
_20(_25);
}
});
},checkUploadedItemsForTimestamps:function(){
var _26=[];
for(var i=0;i<maptales.rpc.uploadedObjects.length;i++){
var _28=maptales.rpc.uploadedObjects[i];
var _29=_28.getRefFromCache("mapobject");
if(_29 instanceof Line){
if(_29.startDate==null&&_29.endDate==null){
_26.push(_28);
}
}
}
return _26;
},getUploadedItems:function(){
return maptales.rpc.uploadedObjects;
}};

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 QueryWidget=Class.create();
Object.extend(Object.extend(QueryWidget.prototype,Widget.prototype),{logger:maptales.getLogger("com.maptales.webclient.widgets.querywidget"),initialize:function(_1,_2,_3,_4,_5,_6,_7){
this.container=_1;
this.parent=_2;
this.queryResults=[];
this.propertyMinValues={};
this.propertyMaxValues={};
this.boundQueryCallback=this.queryCallback.bind(this);
this.paginationLinksNum=_6.paginationLinksNum||7;
this.triggerAction=_6.triggerAction||"gotoPath";
this.triggerTemplate=_6.triggerTemplate||null;
this.triggerParameters=this.parseJSON(_6.triggerParameters);
this.type=_6.queryType;
this.offset=this.convertToInt(_6.offset,0);
this.size=this.convertToInt(_6.numItems,20);
this.sorting=_6.sorting;
this.locally=this.convertToBoolean(_6.locally,true);
this.clustered=this.convertToBoolean(_6.clustered,false);
this.groupId=_6.groupId;
this.mapId=_6.mapId;
this.userId=_6.userId;
this.notInMapId=_6.notInMapId||null;
this.filter=this.parseJSON(_6.filter);
if(_6.tags instanceof Array){
this.tags=_6.tags;
}else{
this.tags=tokenizeTags(_6.tags);
}
this.templatePath=_5;
this.initializeWidget(this.container,this.parent,null,null,this.templatePath,_6,_7);
this.query=new Query({type:this.type,offset:this.offset,size:this.size,sorting:this.sorting,filter:this.filter,clustered:this.clustered,locally:this.locally,groupId:this.groupId,mapId:this.mapId,userId:this.userId,startDate:this.startDate,endDate:this.endDate,tags:this.tags,notInMapId:this.notInMapId});
this.queryService=this.getApplication().service.query;
this.queryService.addQuery(this.query,this.boundQueryCallback);
this.syncMapWithSlot=this.convertToBoolean(_6.syncMapWithSlot,false);
if(this.syncMapWithSlot==true){
getApplication().setMapToQueryMode(this.query);
}
this.boundMouseUpListener=this.onMouseUp.bindAsEventListener(this);
Event.observe(document.body,"mouseup",this.boundMouseUpListener,true);
this.hasMoreItems=false;
},changeSorting:function(_8){
this.sorting=_8;
this.update();
},makePageArray:function(){
this.pagesArray=[];
if(this.getPagesNum()<this.paginationLinksNum){
var _9=this.getPagesNum();
}else{
_9=this.paginationLinksNum;
}
var _a=this.getPageNum()-(Math.floor(_9/2));
if(_a>(this.getPagesNum()-_9)){
_a=this.getPageNum()-_9;
}
if(_a<1){
_a=1;
}
for(var i=0;i<_9;i++){
this.pagesArray.push(_a++);
}
},parseJSON:function(_c){
var _d=null;
if(typeof _c=="string"){
try{
_d=eval("("+_c+")");
}
catch(e){
}
return _d;
}else{
return _c;
}
},onMouseUp:function(_e){
if(!(_e.shiftKey||_e.ctrlKey||this.triggerAction=="select")){
this.lastSelectedItem=null;
if(DragDrop.isDragging==false){
DragDrop.unregisterAllActiveDraggables();
}
}
},selectDraggables:function(_f,_10){
for(var i=_f;i<_10;i++){
if(this.queryResults[i]){
var id=this.queryResults[i].id;
if(this.draggables[id]){
this.draggables[id].select();
}else{
if(this.draggables[this.queryResults[i].tempId]){
this.draggables[this.queryResults[i].tempId].select();
}
}
}else{
this.logger.error("this.listItems["+i+"] does not exist");
}
}
},getIndexOf:function(id){
for(var e=0;e<this.queryResults.length;e++){
if(id==this.queryResults[e].id||id==this.queryResults[e].tempId){
return e;
}
}
return -1;
},destroy:function(){
this.queryService.removeQuery(this.query,this.boundQueryCallback);
Event.stopObserving(document.body,"mouseup",this.boundMouseUpListener,true);
this._destroy();
},queryCallback:function(_15){
this.propertyMinValues={};
this.propertyMaxValues={};
if(_15 instanceof SnapMapException){
this.display("queryWidget/error");
}else{
this.queryResults=_15.queryResults;
this.querySize=_15.querySize;
if(this.querySize<=this.size+this.offset){
this.hasMoreItems=false;
}else{
this.hasMoreItems=true;
}
this.makePageArray();
this.display();
}
},nextPage:function(){
if(this.hasMoreItems){
this.offset+=this.size;
this.update();
}
},prevPage:function(){
if(this.offset==0){
return;
}
if(this.offset>this.size){
this.offset-=this.size;
}else{
this.offset=0;
}
this.update();
},gotoPage:function(_16){
this.offset=(_16*this.size);
this.upate();
},getPagesNum:function(){
return Math.ceil(this.querySize/this.size);
},getPageNum:function(){
return (this.offset/this.size)+1;
},update:function(){
this.queryService.removeQuery(this.query,this.boundQueryCallback);
this.query=new Query({type:this.type,filter:this.filter,offset:this.offset,size:this.size,sorting:this.sorting,clustered:this.clustered,locally:this.locally,groupId:this.groupId,mapId:this.mapId,userId:this.userId,startDate:this.startDate,endDate:this.endDate,tags:this.tags,notInMapId:this.notInMapId});
this.queryService.addQuery(this.query,this.boundQueryCallback);
},getPropertyMin:function(_17){
if(this.propertyMinValues[_17]){
return this.propertyMinValues[_17];
}else{
var _18=1000000;
this.queryResults.each(function(_19){
if(_19[_17]<_18){
_18=_19[_17];
}
});
this.propertyMinValues[_17]=_18;
return _18;
}
},getPropertyMax:function(_1a){
if(this.propertyMaxValues[_1a]){
return this.propertyMaxValues[_1a];
}else{
var _1b=0;
this.queryResults.each(function(_1c){
if(_1c[_1a]>_1b){
_1b=_1c[_1a];
}
});
this.propertyMaxValues[_1a]=_1b;
return _1b;
}
},handleBubbleAction:function(_1d){
switch(_1d.getType()){
case "listItemClick":
var _1e=new Path(_1d.parameters.id);
if(_1d.event.ctrlKey||this.triggerAction=="select"){
_1d.cancelBubble=true;
}else{
if(_1d.event.shiftKey){
_1d.cancelBubble=true;
if(this.lastSelectedItem){
var _1f=this.getIndexOf(this.lastSelectedItem);
var _20=this.getIndexOf(_1e.getContextObject());
if(_1f<_20){
this.selectDraggables(_1f,_20);
}else{
this.selectDraggables(_20+1,_1f+1);
}
}
}else{
_1d.setType(this.triggerAction);
var _1e=new Path(_1d.parameters.path);
if(this.triggerTemplate){
_1e.setTemplatePath(this.triggerTemplate);
}
if(this.triggerParameters){
_1e.setParameters(Object.extend(_1e.getParameters()||{},this.triggerParameters));
}
_1d.parameters.path=_1e;
}
}
this.lastSelectedItem=_1e.getContextObject();
break;
case "nextPage":
this.nextPage();
_1d.cancelBubble=true;
break;
case "prevPage":
this.prevPage();
_1d.cancelBubble=true;
break;
case "gotoPage":
this.prevPage();
_1d.cancelBubble=true;
break;
case "changeSorting":
this.changeSorting(_1d.parameters.sorting);
_1d.cancelBubble=true;
break;
default:
break;
}
}});
maptales.widgets["QueryWidget"]=QueryWidget;

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 MaptalesWidget=Class.create();
Object.extend(Object.extend(MaptalesWidget.prototype,Widget.prototype),{logger:maptales.getLogger("com.maptales.webclient.maptaleswidget"),initialize:function(_1,_2,_3){
this.boundSetMapMode=this.setMapMode.bind(this);
maptales.event.registerEventListener("setMapMode",this.boundSetMapMode);
maptales.ui=this;
this.service=maptales.service;
maptales.setConfig(_2);
if(_2.loggedInUser){
this.service.user.setCurrentUser(maptales.cache.makeObjects(_2.loggedInUser));
}
this.domain=maptales;
this.container=_1;
this.appName="Maptales";
this.historyController=new HistoryController();
this.rootViews={welcome:{name:"Welcome",template:"MapTales/MapTalesIntro",menuItem:true},tour:{name:"Tour",template:"MapTales/BrowseTutorial",menuItem:true},register:{name:"Sign Up!",template:"MapTales/register",menuItem:true},browse:{name:"Browse",template:"queryWidget/admin",menuItem:true},view:{name:"view",widgetName:"Widget",menuItem:false},mobileClient:{template:"MapTales/MobileClient",menuItem:false},createTutorial:{template:"MapTales/CreateTutorial",menuItem:false},publishTutorial:{template:"MapTales/PublishTutorial",menuItem:false},screencasts:{template:"MapTales/screencasts",menuItem:false}};
this.defaultView="browse";
this.urlToViewMappings={defaultMapping:"browse",welcome:"welcome",view:"view",tags:"browse",browse:"browse",register:"register"};
this.path=this.getPathFromUrl();
this.logger.debug("Init Path is: "+this.path);
if((BrowserDetect.browser=="Safari"&&BrowserDetect.version>10&&BrowserDetect.version<420)||BrowserDetect.browser=="unknown"){
Line.prototype.doShadows=false;
}
this.initializeWidget(this.container,null,null,null,null,null,true);
maptales.rpc.addServerOfflineCallback(this.onServerOffline.bind(this));
this.boundOnSessionExpirationCallback=this.onSessionExpirationCallback.bind(this);
if(maptales.service.user.getCurrentUser()!=null){
maptales.rpc.checkServerSessionTimeout();
maptales.rpc.addSessionExpirationCallback(this.boundOnSessionExpirationCallback);
}
this.boundLoginListener=this.onLogin.bind(this);
maptales.service.user.addLoginListener(this.boundLoginListener);
this.display();
},onLogin:function(_4){
if(_4!=null){
maptales.rpc.addSessionExpirationCallback(this.boundOnSessionExpirationCallback);
this.gotoPath(maptales.service.user.getCurrentUserId());
}else{
maptales.rpc.removeSessionExpirationCallback(this.boundOnSessionExpirationCallback);
this.gotoPath(new Path({view:"welcome",contextObject:this}));
}
},setMapMode:function(_5,_6){
if(_5 instanceof SlotWidget){
this.setMapToSlotMode(_5.getParameters());
}else{
alert("non slotwidget call");
}
},onServerOffline:function(_7){
},onSessionExpirationCallback:function(){
if(maptales.service.user.getCurrentUser()!=null){
this.getElement("sessionExpirationNotification").style.display="block";
}
},getPathFromUrl:function(){
var _8=clientConfig.baseURL;
var _9=document.URL.toLowerCase();
if(_9.indexOf(_8)!=-1){
var _a=_9.indexOf(_8)+_8.length;
_9=_9.substring(_a);
if(_9.charAt(0)=="/"){
_9=_9.substring(1);
}
var _b=[];
_b=_9.split("/");
}
var _c=this.getAppName()+"#welcome";
if(_b==null||_b.length==0){
_c=this.getAppName()+"#welcome";
}else{
if(_b[0]=="view"&&_b[1]){
_c=_b[1];
}else{
if(this.urlToViewMappings[_b[0]]){
if(_b[1]){
var _d="?contextObject="+decodeURI(_b[1]);
}else{
var _d="";
}
_c=this.getAppName()+"#"+this.urlToViewMappings[_b[0]]+_d;
}else{
this.logger.warn("Application does not have view for url extension: "+_9);
}
}
}
this.logger.trace("Path from url is: "+_c);
return _c;
},getCurrentUser:function(){
return maptales.service.user.getCurrentUser();
},getCurrentUserName:function(){
if(maptales.service.user.getCurrentUser()!=null){
return maptales.service.user.getCurrentUser().get("name");
}
},currentUserHasRole:function(_e){
if(maptales.service.user.getCurrentUser()!=null){
return maptales.service.user.getCurrentUser().hasRole(_e);
}else{
return false;
}
},getCurrentUserId:function(){
return maptales.service.user.getCurrentUserId();
},onDisplay:function(){
this.getContentPanel().gotoPath(this.path);
},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];
},hasView:function(_f){
if(this.rootViews[_f]){
return true;
}else{
return false;
}
},getView:function(_10){
if(_10){
return this.rootViews[_10];
}else{
return this.rootViews[this.defaultView];
}
},getTemplateOfView:function(_11){
try{
var _12="";
if(_11=="default"||_11==null){
if(this.rootViews[this.defaultView].template){
_12+=this.rootViews[this.defaultView].template;
}else{
return null;
}
}else{
if(this.rootViews[_11].template){
_12+=this.rootViews[_11].template;
}else{
return null;
}
}
return _12;
}
catch(e){
return false;
}
},getMainMap:function(){
return this.getComponent("map");
},getContentPanel:function(){
return this.getComponent("contentPanel");
},grantAllRights:function(_13){
if(_13 instanceof Tag){
}else{
var _14=DEFAULT_RIGHTS;
$H(_14).each(function(_15){
var key=_15.key;
_13.renderedRights[key]=true;
}.bind(this));
}
},getAndIncrementTempId:function(){
return maptales.tempIdIndex--;
},addStatusMessage:function(_17,_18){
var sb=this.getComponent("statusBar");
if(sb){
sb.addMessage(_17,_18);
}
},addWarning:function(_1a,_1b){
try{
this.addStatusMessage("UserWarning",{title:_1a,text:_1b});
}
catch(e){
}
},addException:function(_1c){
try{
this.addStatusMessage("Exception",_1c);
}
catch(e){
}
},addFailure:function(_1d,_1e){
try{
this.addStatusMessage("Failure",{title:_1d,text:_1e});
}
catch(e){
}
},addInfo:function(_1f,_20){
try{
this.addStatusMessage("Info",{title:_1f,text:_20});
}
catch(e){
}
},checkTip:function(tip,_22,_23){
if(this.currentUser&&this.currentUser.getProperty("showTips")){
var _24=this.currentUser.getPropertyAsArray("shownTips");
if(_24.indexOf(tip)==-1){
if(!Dialog.lastDialog){
if(!_23){
_23=Dialog.NORTH;
}
Dialog.toggle("",this,"tip","tips/"+tip,{},$(_22),_23);
var arr=this.currentUser.getPropertyAsArray("shownTips");
if(!arr){
arr=[];
}
arr.push(tip);
this.currentUser.setPropertyAsArray("shownTips",arr);
this.currentUser.persist();
}
}
}
},showTip:function(tip,_27,_28){
if(!_28){
_28=Dialog.NORTH;
}
Dialog.toggle("",this,"tip","tips/"+tip,{mandatory:true},$(_27),_28);
},checkRights:function(_29){
if(this.getCurrentUserId()!=false){
return false;
}else{
return true;
}
},clusterClicked:function(){
if(this.path=="Maptales#welcome"){
this.getComponent("contentPanel").gotoPath("MapTales#browse");
}
},gotoPath:function(_2a){
this.getComponent("contentPanel").gotoPath(_2a);
},defaultMapSyncParameters:{template:null,parameters:null},mapSyncParameters:this.defaultMapSyncParameters,setMapItemClickVariables:function(_2b,_2c){
this.mapSyncParameters={template:_2b,parameters:_2c};
},setDefaultMapSyncParameters:function(){
this.mapSyncParameters=this.defaultMapSyncParameters;
},onMapItemClick:function(_2d){
var _2e={};
_2e.parameters=this.mapSyncParameters.parameters||{};
_2e.templatePath=this.mapSyncParameters.template;
Object.extend(_2e.parameters,_2d);
_2e.contextObject=_2d.contextObject;
var _2f=new Path(_2e);
this.gotoPath(_2f);
},displayMediaOnMap:function(id){
try{
this.getMainMap().gotoMedia(id);
}
catch(e){
this.logger.warn("Error in displayMediaOnMap ",e);
}
},setMapToSlotMode:function(_31,_32){
try{
if(!_31){
return;
}
this.getMainMap().setToSlotMode(_31);
if(_32==null){
_32=this.defaultMapSyncParameters;
}
this.setMapItemClickVariables(_32.template,_32.parameters);
}
catch(e){
this.logger.warn("Error in setMapToSlotMode ",e);
}
},setMapToQueryMode:function(_33,_34){
try{
this.getMainMap().setToQueryMode(_33);
if(_34==null){
_34=this.defaultMapSyncParameters;
}
this.setMapItemClickVariables(_34.template,_34.parameters);
}
catch(e){
this.logger.warn("Error in setMapToQueryMode ",e);
}
},setMapToItemMode:function(id){
try{
this.getMainMap().gotoMedia(id);
}
catch(e){
this.logger.warn("Error in setMapToItemMode ",e);
}
},handleBubbleAction:function(_36){
this.logger.debug("MaptalesWidget>handleBubbleAction: "+_36.getType());
_36.cancelBubble=true;
switch(_36.getType()){
case "reloadPage":
this.getComponent("contentPanel").reloadPage(_36.parameters);
_36.cancelBubble=true;
break;
case "gotoPath":
this.getComponent("contentPanel").gotoPath(_36.parameters.path);
_36.cancelBubble=true;
break;
case "gotoWelcome":
this.getComponent("map").showEarth();
this.getComponent("contentPanel").gotoPath("Maptales#welcome");
_36.cancelBubble=true;
break;
case "gotoUser":
if(this.getCurrentUser()==null){
this.getComponent("contentPanel").gotoPath("#register");
}else{
this.getComponent("contentPanel").gotoPath(this.getCurrentUserId());
}
_36.cancelBubble=true;
break;
case "searchClicked":
if(_36.parameters.searchString!=null&&_36.parameters.searchString.length>0){
this.service.query.setTag(_36.parameters.searchString);
}
this.getComponent("contentPanel").gotoPath("Maptales#browse");
_36.cancelBubble=true;
break;
case "displayUploadProgress":
var _37={files:maptales.rpc.uploadedFilesNum};
this.getComponent("statusBar").addMessage("UploadStatus",_37);
_36.cancelBubble=true;
window.setTimeout(function(){
Dialog.closeAll();
},50);
break;
default:
break;
}
}});

var GeocoderWidget=Class.create();
Object.extend(Object.extend(GeocoderWidget.prototype,Widget.prototype),{initialize:function(_1,_2,_3,_4,_5,_6,_7){
this.parent=_2;
this.container=_1;
this.initializeWidget(_1,_2,_3,_4,this.template,_6,_7);
this.searchString=_6.searchString||null;
this.templatePath=_6.templatePath||"geocoder/geocoder";
this.size=_6.size||20;
if(this.searchString==null){
this.geocoderResult=["please enter query"];
this.display(this.templatePath);
return;
}
try{
this.geocoder=new GClientGeocoder();
}
catch(e){
}
if(this.geocoder){
this.geocoder.getLocations(this.searchString,function(_8){
if(_8){
if(_8.Status.code!=200){
this.container.style.display="none";
return;
}
this.geocoderResult=_8;
this.geocoderQuery=this.searchString;
this.display(this.templatePath);
this.container.style.display="block";
}
}.bind(this));
}
}});
maptales.widgets["Geocoder"]=GeocoderWidget;

var Dialog=Class.create("Dialog");
Dialog.NORTH=1;
Dialog.EAST=2;
Dialog.SOUTH=3;
Dialog.WEST=4;
Dialog.defaultPane=null;
Dialog.toggle=function(_1,_2,_3,_4,_5,_6,_7,_8,_9,_a){
var _b=null;
if(this.lastDialog){
if(this.lastDialog.focusEl!=_6){
_b=new Dialog(_1,_2,_3,_4,_5,_6,_7,_8,_9,_a);
}
this.lastDialog.destroy();
}else{
_b=new Dialog(_1,_2,_3,_4,_5,_6,_7,_8,_9,_a);
}
this.lastDialog=_b;
return _b;
};
Dialog.toggleFixed=function(_c,_d,_e,_f,_10,_11,_12,_13,_14,_15){
var _16=null;
if(!Dialog.fixedPane){
Dialog.fixedPane=document.createElement("div");
Dialog.fixedPane.id="fixedDialogPane";
document.body.appendChild(Dialog.fixedPane);
}
if(this.lastFixedDialog){
this.lastFixedDialog.destroy();
_16=new Dialog(_c,_d,_e,_f,_10,_11,_12,Dialog.fixedPane,_14,_15);
}else{
_16=new Dialog(_c,_d,_e,_f,_10,_11,_12,Dialog.fixedPane,_14,_15);
}
this.lastFixedDialog=_16;
return _16;
};
Dialog.closeAll=function(){
if(this.lastDialog){
this.lastDialog.destroy();
}
};
Object.extend(Object.extend(Dialog.prototype,Widget.prototype),{logger:maptales.getLogger("com.maptales.webclient.widgets.dialog"),Dialog_constructor:function(_17,_18,_19,_1a,_1b,_1c,_1d,_1e,_1f,_20){
this.callback=_20||null;
if(_1e){
this.dialogPane=_1e;
}else{
if(!Dialog.defaultPane){
Dialog.defaultPane=document.createElement("div");
document.body.appendChild(Dialog.defaultPane);
}
this.dialogPane=Dialog.defaultPane;
}
this.container=document.createElement("div");
this.container.className=_19||"dialog";
this.dialogPane.appendChild(this.container);
this.parent=_18;
this.template="dialog/"+(_19||"dialog");
this.title=_17;
this.focusEl=_1c;
this.boundingEl=_1f;
this.orientation=_1d;
this.contentTemplate=_1a;
this.parameters=_1b;
if(!this.dialogHTML){
this.dialogHTML="loading...";
this.initializeWidget(this.container,this.parent,null,null,this.template,_1b);
this.display();
}
},renderContent:function(_21,_22){
this.dataObject=_21;
this.contentTemplate=_22;
Templates.getTemplate(this.contentTemplate,function(_23){
if(_23){
if(this.getElement("dialogMessageContainer")){
this.dialogHTML=_23.process(this);
this.getElement("dialogMessageContainer").innerHTML=this.dialogHTML;
this.position();
Widget.initWidgetContainer(this.getElement("dialogMessageContainer"),this);
this.position();
}
}else{
}
}.bind(this));
},displayErrorMessage:function(_24){
this.parameters.reply=_24;
this.renderContent(_24,this.replyTemplatePath||"dialog/ErrorDialog");
},displayFormReply:function(_25){
this.parameters.reply=_25;
this.renderContent(_25,this.replyTemplatePath);
},show:function(){
},destroy:function(){
try{
this.dialogPane.removeChild(this.container);
if(Dialog.lastDialog==this){
Dialog.lastDialog=null;
}
}
catch(e){
}
},confirm:function(){
if(this.callback){
this.callback();
}
this.destroy();
},onFormSubmit:function(_26){
if(_26.closeDialog){
this.destroy();
}
},handleBubbleAction:function(_27){
this.logger.debug("BubbleAction>"+_27.getType());
switch(_27.getType()){
case "gotoPath":
var _28=new Path(_27.parameters.path);
this.parameters=_28.getParameters();
this.renderContent(this.parameters,_28.getTemplatePath());
break;
case "dialogDestroy":
this.destroy();
_27.lastWidget=this;
if(this.parent){
this.parent.handleBubbleAction(_27);
}
this.confirm();
break;
case "layoutChanged":
this.position();
break;
case "showLoading":
_27.cancelBubble=true;
this.showLoading();
break;
case "view":
this.renderContent(_27.parameters.context,_27.parameters.template);
break;
default:
if(_27.parameters.closeDialog){
this.destroy();
}
this.bubbleAction(_27);
_27.cancelBubble=true;
break;
}
},bubbleAction:function(_29){
if(!_29.cancelBubble){
if(this.parent){
if(this.parent._handleBubbleAction){
this.parent._handleBubbleAction(_29);
}else{
Actions.bubbleAction(_29,this.focusEl);
this.logger.warn("Parent widget "+this.parent.__className+" does not have composite function _handleBubbleAction, trying to bubble it through DOM tree");
}
}else{
Actions.bubbleAction(_29,this.focusEl);
}
}
},onDisplay:function(){
this.renderContent(this.dataObject,this.contentTemplate);
},position:function(){
var _2a={top:0,left:0,bottom:window.innerHeight,right:window.innerWidth};
if(this.boundigEl){
}
_2a.mX=(_2a.right-_2a.left)/2;
_2a.mY=(_2a.bottom-_2a.top)/2;
try{
var _2b=Position.cumulativeOffset(this.focusEl);
var _2c=Position.realOffset(this.focusEl);
var _2d=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;
var _2e=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0;
var _2f=[_2d,_2e];
_2b=[_2b[0]-_2c[0]+_2f[0],_2b[1]-_2c[1]+_2f[1]];
var _30=Element.getDimensions(this.focusEl);
}
catch(e){
this.logger.error("Dialog.position() error: "+e);
return;
}
this.logger.debug("focusOffset:"+_2b[0]+","+_2b[1]);
this.logger.debug("focusSize:"+_30.width+","+_30.height);
this.container.style.height=((this.getElement("dialogContent").offsetHeight)+5)+"px";
var _31=Element.getDimensions(this.container);
this.logger.debug("mySize:"+_31.width+","+_31.height);
var _32=20;
var _33=30;
var _34=50;
var _35=30;
switch(this.orientation){
case Dialog.NORTH:
if((_2b[0]+_30.width/2+21+_34+_32)>_2a.right){
_34=0;
}
if(_2b[0]+_30.width/2-_31.width<_32){
_34=_31.width-_35-10;
}
this.container.style.top=(_2b[1]-_31.height-28)+"px";
this.container.style.left=Math.round(_2b[0]+_30.width/2+39-10+_34-_31.width)+"px";
document.getChildrenById("dialogbottomarrow",this.container)[0].style.right=_34+"px";
document.getChildrenById("dialogtoparrow",this.container)[0].style.display="none";
document.getChildrenById("dialogbottomarrow",this.container)[0].style.display="block";
document.getChildrenById("dialogleftarrow",this.container)[0].style.display="none";
document.getChildrenById("dialogrightarrow",this.container)[0].style.display="none";
break;
case Dialog.EAST:
if((_2b[1]+_30.height/2-_33)<_32){
_33=0;
}
this.container.style.top=Math.round(_2b[1]+_30.height/2-_33-10)+"px";
this.container.style.left=(_2b[0]+_30.width+20)+"px";
document.getChildrenById("dialogleftarrow",this.container)[0].style.top=_33+"px";
document.getChildrenById("dialogtoparrow",this.container)[0].style.display="none";
document.getChildrenById("dialogbottomarrow",this.container)[0].style.display="none";
document.getChildrenById("dialogleftarrow",this.container)[0].style.display="block";
document.getChildrenById("dialogrightarrow",this.container)[0].style.display="none";
break;
case Dialog.WEST:
if((_2b[1]+_30.height/2-_33)<_32){
_33=0;
}
this.container.style.top=Math.round(_2b[1]+_30.height/2-_33-10)+"px";
this.container.style.left=(_2b[0]-_31.width-26)+"px";
document.getChildrenById("dialogrightarrow",this.container)[0].style.top=_33+"px";
document.getChildrenById("dialogtoparrow",this.container)[0].style.display="none";
document.getChildrenById("dialogbottomarrow",this.container)[0].style.display="none";
document.getChildrenById("dialogleftarrow",this.container)[0].style.display="none";
document.getChildrenById("dialogrightarrow",this.container)[0].style.display="block";
break;
case Dialog.SOUTH:
default:
if((_2b[0]+_30.width/2+(_35-10)+_34+_32)>_2a.right){
_34=0;
}
if(_2b[0]-_31.width<_32){
_34=_31.width-_35-10;
}
this.container.style.top=(_2b[1]+_30.height+40)+"px";
this.container.style.left=Math.round(_2b[0]+_30.width/2-10+_34-_31.width+39)+"px";
document.getChildrenById("dialogtoparrow",this.container)[0].style.right=_34+"px";
document.getChildrenById("dialogtoparrow",this.container)[0].style.display="block";
document.getChildrenById("dialogbottomarrow",this.container)[0].style.display="none";
document.getChildrenById("dialogleftarrow",this.container)[0].style.display="none";
document.getChildrenById("dialogrightarrow",this.container)[0].style.display="none";
break;
}
this.container.style.visibility="visible";
}});
maptales.widgets["Dialog"]=Dialog;

var RightsManager=Class.create();
Object.extend(Object.extend(RightsManager.prototype,Widget.prototype),{initialize:function(_1,_2,_3,_4,_5,_6,_7){
this.container=_1;
this.parent=_2;
this.parameters=_6;
this.contextObject=_3;
this.initializeWidget(this.container,this.parent,_3,_4,_5,_6,_7);
this.boundUpdateFunction=this.update.bind(this);
this.addListener();
this.getApplication().service.getById(_3,function(_8){
if(_8 instanceof SnapMapException){
}else{
this.contextObject=_8;
this.template=_5||"rightsManager/rightsManager";
this.display(this.template);
}
}.bind(this));
},addListener:function(){
this.contextObject.addFieldListener("viewRight",this.boundUpdateFunction);
},removeListener:function(){
this.contextObject.removeFieldListener("viewRight",this.boundUpdateFunction);
},update:function(){
this.display();
},onDisplay:function(){
Actions.initAction("layoutChanged",null,null,this.container);
},handleBubbleAction:function(_9){
if(_9.getType()=="setRights"){
var _a=[];
var _b=this.getFormHashMap("rightsForm");
this.contextObject.setRight("view",_b["view_right"]);
_a.push(this.contextObject);
if(_b.setRightsRecursively){
var _c=this.contextObject.getSlotFromCache("medias",0,-1);
for(var e=0;e<_c.length;e++){
_c[e].setRight("view",_b["view_right"]);
_a.push(_c[e]);
}
}
this.showLoading();
this.getApplication().service.persist(_a,function(_e){
if(_e instanceof SnapMapException){
this.display("rightsManager/error");
}else{
Actions.initAction("dialogDestroy",null,null,this.container);
}
}.bind(this));
}else{
if(_9.getType()=="publish"){
if(this.contextObject instanceof Story){
this.dialog=Dialog.toggle("Publish Contained Items?",this,null,"rightsManager/containedItemsPrompt",null,Event.element(_9.event));
return;
}else{
this.contextObject.setRight("view",RIGHT_PUBLIC);
this.display();
this.getApplication().service.persist(this.contextObject,function(_f){
if(_f instanceof SnapMapException){
Dialog.toggle("Error",this,null,"rightsManager/error",null,this.container);
}
}.bind(this));
}
}else{
if(_9.getType()=="publishRecursiveConfirmation"){
var _a=[];
this.contextObject.setRight("view",RIGHT_PUBLIC);
_a.push(this.contextObject);
if(_9.parameters.setRightsRecursively){
var _c=this.contextObject.getSlotFromCache("medias",0,-1);
for(var e=0;e<_c.length;e++){
_c[e].setRight("view",RIGHT_PUBLIC);
_a.push(_c[e]);
}
}
this.dialog.destroy();
this.getApplication().service.persist(_a,function(_10){
if(_10 instanceof SnapMapException){
Dialog.toggle("Error",this,null,"rightsManager/error",null,this.container);
}
}.bind(this));
}
}
}
}});
maptales.widgets["RightsManager"]=RightsManager;

var DragDrop=Class.create();
DragDrop={logger:maptales.getLogger("com.maptales.webclient.dragdrop"),dropZones:[],activeDropZone:null,activeDraggables:[],isDragging:false,proxyOffsetY:15,proxyOffsetX:5,registerActiveDraggable:function(_1){
DragDrop.logger.debug("registerActiveDraggable: "+_1);
if(!this.isDraggableActive(_1)){
this.activeDraggables.push(_1);
}
},unregisterActiveDraggable:function(_2){
DragDrop.logger.debug("unregisterActiveDraggable: "+_2);
if(this.isDraggableActive(_2)){
this.activeDraggables=this.activeDraggables.findAll(function(_3){
if(_3==_2){
return false;
}
return true;
});
return true;
}else{
return false;
}
},unregisterAllActiveDraggables:function(){
DragDrop.logger.debug("unregisterAllActiveDraggables called");
DragDrop.activeDraggables.each(function(_4){
_4.deselect();
}.bind(this));
this.activeDraggables=[];
},getActiveDraggables:function(){
return this.activeDraggables;
},getDraggedObjects:function(){
DragDrop.logger.trace("getDraggedObjects called");
var _5=[];
this.activeDraggables.each(function(_6){
_5.push(_6.getDraggedObject());
}.bind(this));
return _5;
},getDraggedObjectIds:function(){
DragDrop.logger.trace("getDraggedObjectIds called");
var _7=[];
this.activeDraggables.each(function(_8){
_7.push(_8.getDraggedObject().id);
}.bind(this));
return _7;
},registerDropZone:function(_9){
DragDrop.logger.debug("registerDropZone called: contextObject: "+_9.contextObject.id+", fieldName: "+_9.fieldName);
if(this.isDropZoneRegistered(_9)){
return false;
}else{
this.dropZones.push(_9);
return true;
}
},unregisterDropZone:function(_a){
DragDrop.logger.debug("unregisterDropZone called: contextObject: "+_a.contextObject+", fieldName: "+_a.fieldName);
if(this.isDropZoneRegistered(_a)){
this.dropZones=this.dropZones.findAll(function(_b){
if(_b!=_a){
return true;
}else{
return false;
}
});
return true;
}else{
return false;
}
},getDropZones:function(){
return this.dropZones;
},setActiveDropZone:function(_c){
if(_c){
if(_c.contextObject){
DragDrop.logger.debug("setActiveDropZone called: contextObject: "+_c.contextObject+", fieldName: "+_c.fieldName);
}else{
DragDrop.logger.warn("setActiveDropZone called, but no context object!");
}
}else{
DragDrop.logger.debug("setActiveDropZone called: null");
}
if(this.activeDropZone!=_c){
this.activeDropZone=_c;
}
},getActiveDropZone:function(){
return this.activeDropZone;
},isDropZoneRegistered:function(_d){
var _e=false;
this.dropZones.each(function(_f){
if(_f==_d){
_e=true;
}
});
return _e;
},isDraggableActive:function(_10){
var _11=false;
this.activeDraggables.each(function(_12){
if(_12.getDraggedObject().id==_10.getDraggedObject().id){
_11=true;
}
});
return _11;
},startDrag:function(_13){
DragDrop.logger.debug("startDrag called --------------");
if(!DragDrop.dragProxy){
DragDrop.createProxy();
}
DragDrop.setProxyContent();
Element.show(DragDrop.dragProxy);
Event.observe(document,"mousemove",DragDrop.onMouseMove);
DragDrop.isDragging=true;
var _14=this.getDraggedObjects();
DragDrop.dropZones.each(function(_15){
_15.startDraggingDropItems(_14);
});
Actions.initAction("onStartDrag",_13);
},endDrag:function(){
DragDrop.logger.debug("endDrag called --------------");
if(DragDrop.dragProxy){
Element.hide(DragDrop.dragProxy);
}
Event.stopObserving(document,"mousemove",DragDrop.onMouseMove);
DragDrop.isDragging=false;
var _16=this.getDraggedObjects();
for(var i=0;i<DragDrop.dropZones.length;i++){
DragDrop.dropZones[i].endDraggingDropItems(_16);
}
for(var i=0;i<DragDrop.activeDraggables.length;i++){
DragDrop.activeDraggables[i].shouldDeselectOnMouseUp=false;
DragDrop.activeDraggables[i].endDrag();
}
},onMouseMove:function(e){
DragDrop.positionProxy(e);
},onMouseUp:function(e){
DragDrop.logger.debug("onMouseUp called --------------");
if(DragDrop.isDragging==true){
if(DragDrop.activeDropZone){
try{
DragDrop.activeDropZone.doDrop(DragDrop.activeDraggables,e);
DragDrop.getActiveDraggables().each(function(_1a){
try{
_1a.dropped(DragDrop.activeDropZone);
}
catch(e){
DragDrop.logger.error("draggable cant be dropped",e);
}
});
}
catch(e){
DragDrop.logger.error("no drop Zone selected:"+DragDrop.activeDropZone,e);
}
DragDrop.unregisterAllActiveDraggables();
}else{
DragDrop.getActiveDraggables().each(function(_1b){
try{
_1b.endDrag();
}
catch(e){
DragDrop.logger.error("draggable cant end drag",e);
}
});
}
DragDrop.endDrag();
}
},positionProxy:function(e){
var pos=[Event.pointerX(e),Event.pointerY(e)];
DragDrop.dragProxy.style.top=pos[1]+DragDrop.proxyOffsetY+"px";
DragDrop.dragProxy.style.left=pos[0]+DragDrop.proxyOffsetX+"px";
},setProxyContent:function(){
if(this.getActiveDraggables().length>1){
DragDrop.dragProxy.innerHTML=DragDrop.getActiveDraggables().length+" Items";
}else{
DragDrop.dragProxy.innerHTML=UIAdapter.getLabel(DragDrop.getActiveDraggables()[0].getDraggedObject(),"[untitled]");
}
},createProxy:function(){
if(!DragDrop.dragProxy){
DragDrop.dragProxy=document.createElement("div");
DragDrop.dragProxy.className="dragProxy";
document.body.appendChild(DragDrop.dragProxy);
}
}};
Event.observe(document,"mouseup",DragDrop.onMouseUp,true);

Draggable=Class.create();
Draggable.prototype={logger:maptales.getLogger("com.maptales.webClient.draggable"),initialize:function(_1,_2,_3,_4,_5){
if(!_5.draggable){
return;
}
this._container=$(_1);
if(!_5){
_5={};
}
this._useProxy=_5.useProxy||true;
this._draggedObject=_2;
this.domain=_3;
this.parent=_4;
this._canBeSelected=_5.canBeSelected||true;
this.dragged=false;
this.mouseDown=false;
this._container.draggable=this;
this._boundMouseMove=this.onMouseMove.bind(this);
this._boundMouseUp=this.onMouseUp.bind(this);
this._boundMouseDown=this.onMouseDown.bindAsEventListener(this);
Event.observe(this._container,"mousedown",this._boundMouseDown,false);
},destroy:function(){
Event.stopObserving(this._container,"mousedown",this._boundMouseDown,false);
DragDrop.unregisterActiveDraggable(this);
},getContainer:function(){
return this._container;
},getDraggedObject:function(){
return this._draggedObject;
},setDraggedObject:function(_6){
this._draggedObject=_6;
},isSelected:function(){
return this._isSelected;
},canBeSelected:function(){
return this._canBeSelected;
},getDragElement:function(){
return this._dragElement;
},select:function(){
this.getContainer().className=this.getContainer().className.replace(/draggable-active/,"");
this.getContainer().className+=" draggable-active";
this._isSelected=true;
DragDrop.registerActiveDraggable(this);
},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.deselect();
this.onDrop();
},endDrag:function(){
this.mouseDown=false;
this.dragged=false;
this.onEndDrag();
},onStartDrag:function(){
},onEndDrag:function(){
},onDrop:function(){
},onCancelDrag:function(){
},startDrag:function(_7){
this.dragged=true;
DragDrop.startDrag(_7);
this.onStartDrag(_7);
},onMouseMove:function(_8){
_8.cancelBubble=true;
if(this.mouseDown){
if(!this.dragged){
this._currentMouseDownPosition=[Event.pointerX(_8),Event.pointerY(_8)];
var _9=this._initialMouseDownPosition[0]-this._currentMouseDownPosition[0];
var _a=this._initialMouseDownPosition[1]-this._currentMouseDownPosition[1];
if((Math.abs(_9)>20)||(Math.abs(_a)>20)){
this.dragged=true;
this.startDrag(_8);
Event.stopObserving(document,"mousemove",this._boundMouseMove);
}
}
}
return false;
},onMouseDown:function(_b){
_b.cancelBubble=true;
this.mouseDown=true;
if(Event.isLeftClick(_b)){
if(this.isSelected()){
this.shouldDeselectOnMouseUp=true;
}else{
this.select();
DragDrop.registerActiveDraggable(this);
}
this._initialMouseDownPosition=[Event.pointerX(_b),Event.pointerY(_b)];
Event.observe(document,"mousemove",this._boundMouseMove);
Event.observe(document,"mouseup",this._boundMouseUp);
}
return false;
},onMouseUp:function(_c){
_c.cancelBubble=true;
Event.stopObserving(document,"mousemove",this._boundMouseMove);
Event.stopObserving(document,"mouseup",this._boundMouseUp);
if(this.dragged){
this.onDrop();
this.onEndDrag();
}
this.mouseDown=false;
this.dragged=false;
if(!this.canBeSelected()||this.shouldDeselectOnMouseUp){
this.deselect();
DragDrop.unregisterActiveDraggable(this);
}
this.shouldDeselectOnMouseUp=false;
return false;
}};

var SlotDropZone=new Class.create("SlotDropZone");
SlotDropZone.prototype={logger:maptales.getLogger("com.maptales.webclient.slotdropzone"),SlotDropZone_constructor:function(_1,_2,_3){
this.container=$(_1);
this.fieldName=_3||false;
this.contextObject=_2;
this._messagePositioner=document.createElement("div");
this._messagePositioner.className="dropZoneHover";
this._message=document.createElement("div");
this._message.className="dropZoneMessage";
this._messagePositioner.appendChild(this._message);
this.container.onmouseover=this.onMouseOver.bindAsEventListener(this);
this.container.onmouseout=this.onMouseOut.bindAsEventListener(this);
this.container.className+=" dropZone";
this.indicationElement=null;
DragDrop.registerDropZone(this);
this.inMouseOver=false;
this.indicateThatDroppableShownToggle=false;
this.logger.debug("SlotDropZone initialized with: contextObject: "+this.contextObject+", slot: "+this.fieldName);
},acceptDropContent:function(_4){
var _5=true;
if(this.fieldName){
var _6=this.contextObject.getSlotObjectClass(this.fieldName);
_4.each(function(_7){
if(!(_7 instanceof eval(_6))){
_5=false;
}
});
}else{
_4.each(function(_8){
var _9=this.contextObject.hasSlotForObject(_8);
if(!_9){
_5=false;
}
}.bind(this));
}
this.logger.debug("acceptDropContent contextObject: "+this.contextObject+", slot: "+this.fieldName+" returned "+_5);
return _5;
},startDraggingDropItems:function(_a){
if(this.acceptDropContent(DragDrop.getDraggedObjects())){
this.indicateThatDroppable();
this.logger.debug("startDraggingDropItems contextObject: "+this.contextObject+", slot: "+this.fieldName+" indicated that droppable");
}else{
this.logger.debug("startDraggingDropItems contextObject: "+this.contextObject+", slot: "+this.fieldName+" did not indicate that droppable");
}
},endDraggingDropItems:function(){
this.logger.debug("endDraggingDropItems");
this.showNormalState();
},doDrop:function(_b){
this.logger.debug("doDrop contextObject: "+this.contextObject+", slot: "+this.fieldName);
this.showLoading();
var _c=[];
_b.each(function(_d){
_c.push(_d.getDraggedObject().id);
});
if(this.fieldName&&this.contextObject){
if(this.contextObject.isSlot(this.fieldName)){
this.contextObject.addToSlot(this.fieldName,_c);
this.contextObject.persist(function(){
this.hideLoading();
}.bind(this));
}else{
if(this.contextObject.isRef(this.fieldName)){
this.contextObject.set(this.fieldName,_c[0]);
this.contextObject.persist(function(){
this.hideLoading();
}.bind(this));
}
}
}else{
if(this.contextObject){
var _e=this.contextObject.hasSlotForObject(_b[0].getDraggedObject());
this.contextObject.addToSlot(_e,_c);
this.contextObject.persist(function(){
this.hideLoading();
}.bind(this));
}
}
},showThatUndroppable:function(){
this.container.appendChild(this._messagePositioner);
if(DragDrop.isDragging){
if(this.container.className.search(/dropZone-showCantAccept/)){
this.showNormalState();
this.container.className+=" dropZone-showCantAccept";
}
}
},indicateThatUndroppable:function(){
if(DragDrop.isDragging){
if(this.container.className.search(/dropZone-indicateCantAccept/)==-1){
this.showNormalState();
this.container.className+=" dropZone-indicateCantAccept";
}
}
},indicateThatDroppable:function(){
if(this.indicateThatDroppableShownToggle==false){
this.indicateThatDroppableShownToggle=true;
var _f=document.getChildById("indicateThatDroppable",this.container);
if(_f){
var map=this.container;
var _11=Element.getDimensions(this.container);
_f.style.height=_11.height-4+"px";
_f.style.width=_11.width-4+"px";
Element.show(_f);
}
}
},showThatDroppable:function(){
var _12=document.getChildById("indicateThatDroppable",this.container);
if(_12){
Element.hide(_12);
}
var _12=document.getChildById("showThatDroppable",this.container);
if(_12){
Element.show(_12);
}
},showNormalState:function(){
var _13=document.getChildById("indicateThatDroppable",this.container);
if(_13){
Element.hide(_13);
}
_13=document.getChildById("showThatDroppable",this.container);
if(_13){
Element.hide(_13);
}
this.indicateThatDroppableShownToggle=false;
},showLoading:function(){
var _14=document.getChildById("indicateLoading",this.container);
if(_14){
Element.show(_14);
}
},hideLoading:function(){
var _15=document.getChildById("indicateLoading",this.container);
if(_15){
Element.hide(_15);
}
},onMouseOver:function(_16){
this.logger.debug("onMouseOver contextObject: "+this.contextObject+", slot: "+this.fieldName);
if(!this.inMouseOver){
this.inMouseOver=true;
if(DragDrop.isDragging){
if(this.acceptDropContent(DragDrop.getDraggedObjects())){
DragDrop.setActiveDropZone(this);
this.showThatDroppable();
this.logger.debug("onMouseOver>showing that droppable> contextObject: "+this.contextObject+", slot: "+this.fieldName);
}
}
}
Event.stop(_16);
},onMouseOut:function(){
this.logger.debug("onMouseOut contextObject: "+this.contextObject+", slot: "+this.fieldName);
this.inMouseOver=false;
if(DragDrop.isDragging){
if(this.acceptDropContent(DragDrop.getDraggedObjects())){
this.indicateThatDroppable();
}else{
this.indicateThatUndroppable();
}
}else{
this.showNormalState();
}
DragDrop.setActiveDropZone(null);
}};

var PageWidget=Class.create();
Object.extend(Object.extend(PageWidget.prototype,Widget.prototype),{logger:maptales.getLogger("com.maptales.webclient.widgets.pagewidget"),initialize:function(_1,_2,_3,_4,_5,_6,_7){
this.container=_1;
this.initializeWidget(this.container,_2,null,null,null,_6,true);
this.useInnerHTML=false;
if(_3==null){
this.contextObject=this.getApplication();
}else{
this.contextObject=_3;
}
this.path=this.parsePath(_6.path);
this.displayAreaId="displayArea";
this.undisplayedPath=null;
this.boundLoadListener=this.updateLoading.bind(this);
maptales.rpc.addLoadingListener(this.boundLoadListener);
this.setOnStartRenderingEvent("startQueryBatch");
this.setOnEndRenderingEvent("endQueryBatch");
},updateLoading:function(_8){
if(_8){
this.showLoading();
}else{
this.hideLoading();
}
},showLoading:function(){
if(this.getElement("loading")){
this.getElement("loading").style.display="block";
}
},hideLoading:function(){
if(this.getElement("loading")){
this.getElement("loading").style.display="none";
}
},gotoPath:function(_9){
if(_9){
this.logger.debug("gotoPath: "+_9.toString());
}
this.getApplication().getComponent("map").deselectAll();
this.path=this.parsePath(_9);
this.getApplication().historyController.addToHistory(this.path,this);
this.destroyOldWidgets();
if(this.path.contextObject instanceof ContentObject){
this.displayBusinessObject(this.path.contextObject,this.path.view,this.path.parameters,this.path.templatePath);
}else{
if(isNaN(this.path.contextObject)){
this.displayBusinessObject(this.getApplication(),this.path.view,this.path.parameters,this.path.templatePath);
return;
}else{
this.getApplication().service.getById(this.path.contextObject,function(_a){
if(_a instanceof SnapMapException){
this.displayBusinessObject(this.getApplication(),null,{reply:_a},"error/itemDoesNotExistView");
}else{
this.displayBusinessObject(_a,this.path.view,this.path.parameters,this.path.templatePath);
}
}.bind(this));
}
}
},displayBusinessObject:function(_b,_c,_d,_e){
Dialog.closeAll();
this.logger.debug("displayBusinessObject() contextObject: "+_b.id+" viewName: "+_c+" parameters: "+_d);
this.setContextObject(_b);
this.setParameters(_d);
try{
if(_b&&$O(_b) instanceof UserObject){
maptales.service.incrementViewCount($O(_b).id);
}
}
catch(e){
this.logger.error("error incrementing view count of "+_b,e);
}
var _f=null;
var _10=null;
if(_e==null){
if(_c==null){
if(_b){
_10=_b.getDefaultView();
}
}else{
if(_b){
_10=_b.getView(_c);
}
}
}else{
this.renderToContainer(_e);
return;
}
if(_10!=null){
if(_10.template!=null){
this.renderToContainer(_10.template);
return;
}else{
this.logger.warn("WidgetName of View is not defined, althought it should");
this.renderToContainer("pathPanel/widgetNotDefined");
return;
}
}else{
this.logger.warn("templatePath and view are not defined. therefore we cant display the object");
this.renderToContainer("pathPanel/noDefaultView");
return;
}
},renderToContainer:function(_11,_12){
this.display(_11,_12,null,this.displayAreaId||this.container);
},destroyOldWidgets:function(){
this.destroy();
},getPath:function(){
return this.path;
},goBack:function(){
this.getApplication().historyController.moveBack();
},onDisplay:function(){
if(this.undisplayedPath){
this.gotoPath(this.undisplayedPath);
this.undisplayedPath=null;
}
},parsePath:function(_13){
if(_13){
var _13=new Path(_13);
if(_13.getContextObject()==null){
if(this.path){
_13.setContextObject(this.path.getContextObject());
}else{
_13.setContextObject(this.getApplication());
}
}
}else{
_13=new Path();
_13.setContextObject(this.getApplication());
}
return _13;
},reloadPage:function(_14){
if(_14){
if(_14.contextObject){
this.contextObject=$O(_14.contextObject);
}
if(this.parameters==null){
this.parameters={};
}
Object.extend(this.parameters,_14);
}
this.renderToContainer();
},handleBubbleAction:function(_15){
this.logger.trace("handleBubbleAction() action: "+_15.getType());
switch(_15.getType()){
case "reloadPage":
_15.cancelBubble=true;
this.reloadPage(_15.parameters);
break;
case "reloadPageFromForm":
_15.cancelBubble=true;
if(_15.parameters.formName){
var _16=this.getFormHashMap(_15.parameters.formName);
if(this.parameters==null){
this.parameters={};
}
Object.extend(this.parameters,_16);
}
this.renderToContainer(_16.templatePath);
break;
case "loadPage":
_15.cancelBubble=true;
this.renderToContainer(_15.parameters.template,_15.parameters.parameters);
break;
case "gotoPath":
_15.cancelBubble=true;
this.gotoPath(_15.parameters.path);
break;
case "goBack":
_15.cancelBubble=true;
this.goBack();
break;
case "setPath":
_15.cancelBubble=true;
this.setPathDisplay(_15.parameters.contextObject,_15.parameters.view,_15.parameters.path);
this.getApplication().historyController.addToHistory(_15.parameters.path[_15.parameters.path.length-1].path,this);
break;
}
}});
maptales.widgets["Page"]=PageWidget;

var TabSystem=Class.create();
Object.extend(Object.extend(TabSystem.prototype,Widget.prototype),{initialize:function(_1,_2,_3,_4,_5,_6,_7){
this.container=_1;
this.parent=_2;
this.selectedTab={};
this.contextObject=$O(_6.contextObject);
this.templatePath=_6.templatePath||null;
this.initializeWidget(this.container,this.parent,this.contextObject,_4,this.templatePath,_6,_7);
this.display();
},showTabPage:function(_8){
Element.removeClassName(this.container,"closedTabSystem");
},hideTabPage:function(){
Element.addClassName(this.container,"closedTabSystem");
},showLoading:function(){
Templates.getTemplate("loading",function(_9){
this.tabPageContainer.innerHTML=_9.process();
}.bind(this));
},onDisplay:function(){
this.tabPageContainer=this.getElement("tabPageContainer");
this.tabMenuContainer=this.getElement("tabMenuContainer");
},handleBubbleAction:function(_a){
switch(_a.getType()){
case "onselect":
_a.cancelBubble=true;
_a.cancelPropagation=true;
if(_a.parameters.selectedListItem==this.selectedTab){
this.selectedTab={};
this.hideTabPage();
}else{
this.selectedTab=_a.parameters.selectedListItem;
this.showTabPage(_a);
}
break;
case "loadTabSlot":
_a.cancelBubble=true;
this.destroySubwidgets();
this.showLoading();
var _b={listItemTemplatePath:"",sort:"",includeClass:"",templatePath:"slotPanel/slotPanel",objectTemplate:"",numDisplayedItems:50,filter:""};
Object.extend(_b,_a.parameters.templateData);
if(_a.parameters.templateData.contextObject==null&&this.contextObject){
_b.contextObject=this.contextObject;
}else{
_b.contextObject=$O(_b.contextObject);
}
Templates.getTemplate("slotPanel/dynamicSlot",function(_c){
this.tabPageContainer.innerHTML=_c.process(_b);
Widget.initSubWidgets(this.tabPageContainer,this);
}.bind(this));
if(this.tabMenuContainer){
this.tabMenuContainer.innerHTML="";
if(_a.parameters.menuPath){
Templates.getTemplate(_a.parameters.menuPath,function(_d){
this.tabMenuContainer.innerHTML=_d.process(_b);
Widget.initSubWidgets(this.tabMenuContainer,this);
}.bind(this));
}
}
break;
case "loadTabPage":
_a.cancelBubble=true;
this.destroySubwidgets();
this.showLoading();
Templates.getTemplate(_a.parameters.templatePath,function(_e){
this.tabPageContainer.innerHTML=_e.process(_a.parameters.templateData);
Widget.initSubWidgets(this.tabPageContainer,this);
}.bind(this));
if(this.tabMenuContainer){
this.tabMenuContainer.innerHTML="";
if(_a.parameters.menuPath){
Templates.getTemplate(_a.parameters.menuPath,function(_f){
this.tabMenuContainer.innerHTML=_f.process(this);
Widget.initSubWidgets(this.tabMenuContainer,this);
}.bind(this));
}
}
break;
}
}});
maptales.widgets["tabSystem"]=TabSystem;

var PathWidget=Class.create();
Object.extend(Object.extend(PathWidget.prototype,Widget.prototype),{logger:maptales.getLogger("com.maptales.webclient.widgets.pathwidget"),initialize:function(_1,_2,_3,_4,_5,_6,_7){
this.container=_1;
this.menuOptions=[];
this.path=[];
this.contextObject=null;
this.initializeWidget(_1,_2,null,null,"path/path");
this.rootNode=this.getApplication();
this.setParameters(this.path);
this.getApplication().service.user.addLoginListener(this.displayAfterLogin.bind(this));
this.logger.info("startup with path: "+_6.path);
Event.observe(document.body,"mousedown",this.hideMenus.bind(this));
Event.observe(this.container,"mousedown",this.clearBubble.bind(this));
this.display();
},clearBubble:function(_8){
_8.cancelBubble=true;
},displayAfterLogin:function(){
this.display();
},hideMenus:function(_9){
var _a=document.getElementsByClassName("menuBox",this.container);
for(var e=0;e<_a.length;e++){
Element.hide(_a[e]);
}
},showLoading:function(){
},isSelectedMenu:function(_c){
if(this.currentView.name==_c){
return true;
}else{
return false;
}
},displayPath:function(_d,_e,_f){
this.logger.debug("displayPath called with contextObject:"+_d+", view: "+_e+", displayPath: "+_f);
if(this.contextObject!=_d&&_e==null){
if(_d){
this.currentView=_d.getDefaultView();
}
}else{
if(_e!=null){
this.currentView=_e;
}else{
if(this.currentView==null){
if(_d){
this.currentView=_d.getDefaultView();
}
}
}
}
this.contextObject=_d;
this.setPath(_f);
this.generateMenuOptions();
this.display();
},generateMenuOptions:function(){
this.menuOptions=[];
if(this.contextObject){
var _10=this.contextObject.getViews();
if(_10){
for(viewName in _10){
if(_10[viewName].menuItem){
if(this.checkRightsOfMenuItem(_10[viewName])){
this.menuOptions.push({name:_10[viewName].name,view:viewName});
}
}
}
}
}else{
var _10=this.rootNode.getViews();
for(viewName in _10){
if(_10[viewName].menuItem){
if(this.checkRightsOfMenuItem(_10[viewName])){
this.menuOptions.push({name:_10[viewName].name,view:viewName});
}
}
}
}
},getPath:function(){
return this.path;
},setPath:function(_11){
this.logger.debug("setPath: path: "+_11);
var _12=[];
if(_11){
for(var i=0;i<_11.length;i++){
if(_11[i].name!=this.rootNode.getAppName()){
var _14=_11[i];
_14.path=new Path(_14.path);
_12.push(_14);
}
}
this.path=_12;
}else{
if(this.path==null){
this.path=_12;
}
}
},checkRightsOfMenuItem:function(_15){
var _16=_15.requiredRoles;
var _17=_15.requiredRights;
var _18=false;
if(_16==null&&_17==null){
return true;
}
if(this.contextObject instanceof User&&this.contextObject.id!=this.getApplication().service.user.getCurrentUserId()){
return false;
}
var _19=false;
if(_16!=null){
for(var i=0;i<_16.length;i++){
if((this.getApplication().service.user.getCurrentUser()&&this.getApplication().service.user.getCurrentUser().hasRole(_16[i]))){
_18=true;
}
}
}
if(_17!=null){
for(var i=0;i<_17.length;i++){
if(this.contextObject.checkRights(_17[i])){
_18=true;
}
}
}
return _18;
},setContextObject:function(_1b){
this.logger.debug("setContextObject: contextObject: "+_1b);
if(!isNaN(_1b)||_1b instanceof ContentObject){
this.contextObject=_1b;
}else{
if(_1b==this.rootNode){
this.contextObject=this.rootNode;
}else{
if(_1b==null){
this.contextObject=this.rootNode;
}
}
}
},getContextObject:function(){
return this.contextObject;
},toggleMenu:function(_1c){
var _1d=document.getElementsByClassName("menuBox",this.container);
for(var e=0;e<_1d.length;e++){
if(_1d[e].id==_1c){
Element.toggle(_1d[e]);
}else{
Element.hide(_1d[e]);
}
}
},handleBubbleAction:function(_1f){
this.logger.debug("BubbleAction>"+_1f.getType());
if(_1f.getType()=="showView"){
var _20=new Path();
_20.setContextObject(this.contextObject||this.rootNode);
this.setContextObject(this.contextObject||this.rootNode);
_20.setView(_1f.parameters.view||null);
_1f.parameters.path=_20;
_1f.setType("gotoPath");
this.currentView=this.contextObject.getView(_1f.parameters.view);
this.display();
delete _1f.parameters.view;
}else{
if(_1f.getType()=="toggleMenu"){
_1f.cancelBubble=true;
this.toggleMenu(_1f.parameters.menu);
}else{
if(_1f.getType()=="gotoPath"){
this.hideMenus();
}
}
}
}});
maptales.widgets["Path"]=PathWidget;

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 Radiogroup=new Class.create();
Radiogroup.prototype={initialize:function(_1,_2){
this.length=_1.length;
this.options=_1;
if(_2){
this.setValue(_2);
this.value=_2;
}else{
this.value=this.findValue();
}
this.name=_1[0].name;
this.bindEventHandlers();
},findValue:function(){
var _3="";
this.options.each(function(_4){
if(_4.checked==true){
_3=_4.value;
}
}.bind(this));
return _3;
},bindEventHandlers:function(){
this.options.each(function(_5){
_5.onclick=this._setValue.bindAsEventListener(this);
}.bind(this));
},getValue:function(){
return this.value;
},setValue:function(_6){
this.value=_6;
this.options.each(function(_7){
if(_7.value==_6){
}
}.bind(this));
},_setValue:function(_8){
this.setValue(Event.element(_8).value);
}};

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 SlotWidget=Class.create();
Object.extend(Object.extend(SlotWidget.prototype,Widget.prototype),{logger:maptales.getLogger("com.maptales.webclient.widgets.slotwidget"),initialize:function(_1,_2,_3,_4,_5,_6,_7){
this.parent=_2;
this.container=$(_1);
AssertNotNull(_1,"SlotWidgetInitException","The SlotWidget needs a container to display its contents");
this.contextObject={};
this.contextId=_3;
this.fieldName=_6.fieldName;
this.includeClass=_6.includeClass||null;
this.triggerAction=_6.triggerAction||"gotoPath";
this.triggerTemplate=_6.triggerTemplate||null;
this.multiSelect=false;
if(this.triggerAction=="select"){
this.multiSelect=true;
}
this.setParameters(_6);
this.template=_5||"slotPanel/slotPanel";
this.listItemTemplatePath=_6.listItemTemplatePath||null;
this.listItemTemplate=null;
this.syncSlotOnMap=_6.syncSlotOnMap||false;
this.displayAllItemsOnMap=_6.displayAllItemsOnMap||false;
this.initializeWidget(this.container,this.parent,_3,_4,_5,_6,_7);
this.totalListItems=0;
this.lastSelectedItem=null;
if(typeof _6.objectTemplate=="string"){
try{
this.objectTemplate=eval("("+_6.objectTemplate+")");
}
catch(e){
this.objectTemplate=null;
}
}else{
this.objectTemplate=_6.objectTemplate||null;
}
if(this.objectTemplate&&!this.objectTemplate.type){
this.objectTemplate.type="objectTemplate";
}
this.boundUpdateFunction=this.update.bind(this);
if(this.listItemTemplatePath){
Templates.getTemplate(this.listItemTemplatePath,function(_8){
this.listItemTemplate=_8;
this.initSlotWidget();
}.bind(this));
}else{
this.initSlotWidget();
}
this.boundMouseUpListener=this.onMouseUp.bindAsEventListener(this);
Event.observe(document.body,"mouseup",this.boundMouseUpListener,true);
this.pagesArray=[];
},getParameters:function(){
var _9={};
_9.contextObject=this.contextObject;
_9.slotName=this.fieldName;
_9.offset=(this.page-1)*this.numDisplayedItems;
_9.size=this.numDisplayedItems;
_9.filter=this.filter;
return _9;
},onMouseUp:function(_a){
if(!(_a.shiftKey||_a.ctrlKey||this.triggerAction=="select")){
this.lastSelectedItem=null;
if(DragDrop.isDragging==false){
DragDrop.unregisterAllActiveDraggables();
}
}
},initSlotWidget:function(){
if(isNaN(this.contextId)){
if(this.contextId==this.getApplication().getAppName()){
this.contextObject=this.getApplication();
this.loadPage(this.displaySlot.bind(this));
}else{
if(this.contextId instanceof ContentObject){
this.contextObject=this.contextId;
this.addListener();
this.loadPage(this.displaySlot.bind(this));
}
}
}else{
this.getApplication().service.getById(this.contextId,function(_b){
if(_b instanceof SnapMapException){
this.logger.warn("SlotWidgetInitError: Could not load handler object of the slotWidget");
}else{
this.contextObject=_b;
this.addListener();
this.totalListItems=this.contextObject.getSlotLength(this.fieldName);
this.loadPage(this.displaySlot.bind(this));
}
}.bind(this));
}
},getPageOffset:function(){
return ((this.page-1)*this.numDisplayedItems);
},insertListItem:function(_c){
if(this.listItemTemplate){
var el=this.listItemTemplate.process({listItemIndex:parseInt(_c),listItem:this.listItems[_c],listItems:this.listItems,pageIndex:this.page,pageCount:this.pages,numDisplayedItems:this.numDisplayedItems,contextObject:this.contextObject,_MODIFIERS:this._MODIFIERS});
return el;
}else{
this.logger.warn("SlotTemplateException: The template wants to dynamically insert slotItems, this is not supported by the widget though");
if(this.listItemTemplatePath){
return "listItemTemplate "+this.listItemTemplatePath+" does not exist";
}else{
return "No listItemTemplate given";
}
}
},addListener:function(){
this.contextObject.addSlotListener(this.fieldName,this.filter,this.sort,this.boundUpdateFunction);
},removeListener:function(){
this.contextObject.removeSlotListener(this.fieldName,this.filter,this.sort,this.boundUpdateFunction);
},setParameters:function(_e){
this.parameters=_e;
this.numDisplayedItems=parseInt(_e.numDisplayedItems)||12;
this.listItems=[];
this.draggable=_e.draggable||false;
this.droppable=_e.droppable||false;
this.pages=Math.ceil(this.totalListItems/this.numDisplayedItems);
this.page=1;
this.paginationLinksNum=7;
this.fieldName=_e.fieldName;
if(typeof _e.filter=="string"){
try{
this.filter=eval("("+_e.filter+")");
}
catch(e){
this.filter=null;
}
}else{
this.filter=_e.filter;
}
this.sort=_e.sort||false;
},displaySlot:function(){
this.makePageArray();
this.display(this.template);
},getPagesNum:function(){
return this.pages;
},getPageNum:function(){
return this.page;
},makePageArray:function(){
this.pagesArray=[];
if(this.pages<this.paginationLinksNum){
var _f=this.pages;
}else{
_f=this.paginationLinksNum;
}
var _10=this.page-(Math.floor(_f/2));
if(_10>(this.pages-_f)){
_10=this.pages-_f;
}
if(_10<1){
_10=1;
}
for(var i=0;i<_f;i++){
this.pagesArray.push(_10++);
}
},changeSorting:function(_12){
this.sort=_12;
this.update();
},loadPage:function(_13){
this.loadPageCallback=_13;
this.logger.debug("loadPage");
var _14={id:this.contextObject.id,slotName:this.fieldName,offset:(this.page-1)*this.numDisplayedItems,size:this.numDisplayedItems,filter:this.filter,sorting:this.sort,objectTemplate:this.objectTemplate};
this.getApplication().service.getSlot(_14,this.handleLoadedSlot.bind(this));
},handleLoadedSlot:function(_15){
if(_15 instanceof SnapMapException){
this.logger.warn("handleLoadedSlot got an Exception: "+_15);
this.listItems=[];
this.totalListItems=0;
pages=0;
this.loadPageCallback();
}else{
this.logger.debug("handleLoadedSlot");
this.listItems=_15.slotItems;
if(_15.slotNum){
this.totalListItems=_15.slotNum;
}
this.pages=Math.ceil(this.totalListItems/this.numDisplayedItems);
this.loadPageCallback();
}
},getListItems:function(){
return this.listItems;
},nextPage:function(){
this.logger.debug("nextPage");
if(this.page>=(this.pages)){
this.page=1;
}else{
this.page+=1;
}
this.loadPage(this.displaySlot.bind(this));
},prevPage:function(){
this.logger.debug("prevPage");
if(this.page<=1){
this.page=(this.pages);
}else{
this.page-=1;
}
this.loadPage(this.displaySlot.bind(this));
},gotoPage:function(_16){
this.logger.debug("gotoPage");
this.page=_16;
this.loadPage(this.displaySlot.bind(this));
},update:function(_17){
this.logger.debug("update");
if(this.listItemTemplate&&_17!=null){
this.updateSlot(_17);
}else{
this.loadPage(this.displaySlot.bind(this));
}
},updateSlot:function(_18){
this.logger.debug("updateSlot> deltaChanges.removals: "+_18.removals+",  deltaChanges.additions: "+_18.additions+", deltaChanges.sortChanges: "+_18.sortChanges);
if(_18.removals){
var _19=_18.removals;
for(var i=0;i<_19.length;i++){
this.removeFromListItems(_19[i]-this.getPageOffset());
}
}
if(_18.additions){
var _1b=_18.additions;
for(var i=0;i<_1b.length;i++){
this.addToListItems(_1b[i].insertionIndex-this.getPageOffset(),_1b[i].addedId);
}
}
if(_18.sortChanges){
var _1c=_18.sortChanges;
for(var i=0;i<_1c.length;i++){
var _1d=this.listItems[_1c[i].oldIndex-this.getPageOffset()];
this.removeFromListItems(_1c[i].oldIndex-this.getPageOffset());
this.addToListItems(_1c[i].newIndex-this.getPageOffset(),_1d);
}
}
},removeFromListItems:function(_1e){
this.logger.debug("removeFromListItems> index: "+_1e);
this.removeElement(_1e);
this.listItems.removeIndex(_1e);
if(_1e>0){
var _1f=this.getElement(_1e-1);
_1f.id="tempId";
new Insertion.After(_1f,this.insertListItem(_1e-1));
this.removeElement("tempId");
Widget.initWidgetContainer(this.getElement(_1e-1),this);
}
this.indexGUIList();
},addToListItems:function(_20,id){
this.logger.debug("addToListItems> index: "+_20+", id: "+id);
var _22=this.getElement("slotList");
AssertNotNull(_22,"WidgetElementException","SlotWidget could not find component 'slotList' in template");
if(this.listItems.length==0){
_22.innerHTML="";
}
this.listItems=this.listItems.insertAtPosition(_20,$O(id));
if(_20==0){
new Insertion.Top(_22,this.insertListItem(_20));
Widget.initWidgetContainer(this.getElement(_20),this);
this.indexGUIList();
var _23=_20+1;
if(_23<this.listItems.length){
this.removeElement(_23);
new Insertion.After(this.getElement(_20),this.insertListItem(_23));
Widget.initWidgetContainer(this.getElement(_23),this);
}
}else{
this.logger.debug("addToListItems> adding in middle");
var _24=_20-1;
this.logger.debug("addToListItems> adding in middle previousIndex: "+_24);
var _25=this.getElement(_24);
this.logger.debug("addToListItems> adding in middle previousElement: "+_25);
if(_25){
_25.id="tempId";
this.logger.debug("addToListItems> adding in middle previousIndex: "+_24+" previousElement:"+_25);
new Insertion.After(_25,this.insertListItem(_20));
new Insertion.After(_25,this.insertListItem(_24));
this.logger.debug("addToListItems> finished adding");
this.removeElement("tempId");
this.indexGUIList();
Widget.initWidgetContainer(this.getElement(_20-1),this);
Widget.initWidgetContainer(this.getElement(_20),this);
}else{
this.logger.error("could not find previous element: "+_24+"therefor cant insert");
}
}
},indexGUIList:function(){
this.logger.debug("reIndex GUI list");
var _26=this.getElement("slotList");
if(_26==null){
this.logger.error("WidgetElementException: SlotWidget could not find component 'slotList' in template");
}
Element.cleanWhitespace(_26);
var _27=0;
this.logger.debug("reIndex GUI list has: "+_26.childNodes.length+" elements to reindex");
for(var e=0;e<_26.childNodes.length;e++){
this.logger.debug("does element exist: "+_26.childNodes[e]);
if(_26.childNodes[e]){
this.logger.debug("is it element node? "+(_26.childNodes[e].nodeType==document.ELEMENT_NODE)+" "+_26.childNodes[e].nodeType+" "+document.ELEMENT_NODE);
if(_26.childNodes[e].nodeType==1){
this.logger.debug("reIndex from "+_26.childNodes[e].id+" to "+_27);
_26.childNodes[e].id=_27;
if(_27%2==0){
_26.childNodes[e].className="oddRow";
}else{
_26.childNodes[e].className="evenRow";
}
_27++;
}
}
}
},getMaxSlotCount:function(_29){
var _2a=0;
this.listItems.each(function(_2b){
if(_2b.getSlotLength(_29)>_2a){
_2a=_2b.getSlotLength(_29);
}
});
return _2a;
},getMinSlotCount:function(_2c){
var _2d=1000000;
this.listItems.each(function(_2e){
if(_2e.getSlotLength(_2c)<_2d){
_2d=_2e.getSlotLength(_2c);
}
});
return _2d;
},getPropertyMax:function(_2f){
var _30=0;
this.listItems.each(function(_31){
if(_31[_2f]>_30){
_30=_31[_2f];
}
});
return _30;
},getPropertyMin:function(_32){
var _33=1000000;
this.listItems.each(function(_34){
if(_34[_32]<_33){
_33=_34[_32];
}
});
return _33;
},updateFromCache:function(){
this.listItems=this.contextObject.getSlotFromCache(this.fieldName,(this.page-1)*this.numDisplayedItems,this.numDisplayedItems);
this.totalListItems=this.listItems.length;
},canDrop:function(_35,e){
var _37=true;
var _35=[];
draggableArray.each(function(_38){
_35.push(_38.getDraggedObject());
});
_37=this.contextObject.isSlotForObjects(this.slotName,_35);
if(_37==true){
_35.each(function(obj){
if(this.listItems.include(obj)){
_37=false;
}else{
_37=true;
}
});
}
return _37;
},getIndexOf:function(id){
for(var e=0;e<this.listItems.length;e++){
if(id==this.listItems[e].id||id==this.listItems[e].tempId){
return e;
}
}
return -1;
},moveUp:function(id){
this.logger.debug("moveUp>id: "+id);
var _3d=this.getIndexOf(parseInt(id));
var _3e=_3d-1;
this.changeOrder(_3e,_3d);
},moveDown:function(id){
this.logger.debug("moveDown>id: "+id);
var _40=this.getIndexOf(parseInt(id));
var _41=_40+1;
this.changeOrder(_41,_40);
},changeOrder:function(_42,_43){
AssertNotNull(_42,"SlotWidgetOrderingException","A new index has to be given to change ordering");
AssertNotNull(_43,"SlotWidgetOrderingException","The old index has to be given to change odering");
_42=parseInt(_42)+this.getPageOffset();
_43=parseInt(_43)+this.getPageOffset();
var _44=this.contextObject.getSlotFromCache(this.fieldName,_43,1,this.filter,this.sort)[0];
var _45=this.contextObject.getSlotFromCache(this.fieldName,_42,1,this.filter,this.sort)[0];
this.logger.debug("Changing sorting from "+_43+" to "+_42);
this.logger.debug("Title of moved element: "+_44.get("title"));
var _46=_44.get("timestamp").getTime();
var _47=_45.get("timestamp").getTime();
if(_46>_47){
if(_42==0){
var _48=_47-10000;
}else{
var _49=this.contextObject.getSlotFromCache(this.fieldName,_42-1,1,this.filter,this.sort)[0];
var _4a=_49.get("timestamp").getTime();
var _48=_47-((_47-_4a)/2);
}
}else{
if(_42<this.totalListItems-1){
var _49=this.contextObject.getSlotFromCache(this.fieldName,_42+1,1,this.filter,this.sort)[0];
var _4a=_49.get("timestamp").getTime();
var _48=_47-((_47-_4a)/2);
}else{
var _48=_47+10000;
}
}
this.logger.debug("Changed timestamp from: "+_44.get("timestamp")+" to "+new Date(_48));
_44.set("timestamp",new Date(_48));
_44.persist(function(_4b){
if(_4b instanceof SnapMapException){
Dialog.toggle("Error Reordering",null,null,"dialog/ErrorDialog",{message:"There has been an error while reordering your items"},this,Dialog.NORTH);
}
}.bind(this));
},destroy:function(){
this.logger.debug("destroy called");
DragDrop.unregisterAllActiveDraggables();
this._destroy();
Event.stopObserving(document.body,"mouseup",this.boundMouseUpListener,true);
this.removeListener();
},selectDraggables:function(_4c,_4d){
for(var i=_4c;i<_4d;i++){
if(this.listItems[i]){
var id=this.listItems[i].id;
if(this.draggables[id]){
this.draggables[id].select();
}else{
if(this.draggables[this.listItems[i].tempId]){
this.draggables[this.listItems[i].tempId].select();
}
}
}else{
this.logger.error("this.listItems["+i+"] does not exist");
}
}
},handleBubbleAction:function(_50){
this.logger.trace("handleBubbleAction called: "+_50.getType());
switch(_50.getType()){
case "update":
_50.cancelBubble=true;
this.update();
break;
case "updateFromCache":
_50.cancelBubble=true;
this.updateFromCache();
break;
case "gotoPage":
this.gotoPage(_50.parameters.page);
break;
case "prevPage":
_50.cancelBubble=true;
this.prevPage();
break;
case "nextPage":
_50.cancelBubble=true;
this.nextPage();
break;
case "listItemClick":
var _51=new Path(_50.parameters.path);
if(_50.event.ctrlKey||this.triggerAction=="select"){
_50.cancelBubble=true;
}else{
if(_50.event.shiftKey){
_50.cancelBubble=true;
if(this.lastSelectedItem){
var _52=this.getIndexOf(this.lastSelectedItem);
var _53=this.getIndexOf(_51.getContextObject());
if(_52<_53){
this.selectDraggables(_52,_53);
}else{
this.selectDraggables(_53+1,_52+1);
}
}
}else{
_50.setType(this.triggerAction);
var _51=new Path(_50.parameters.path);
if(this.triggerTemplate){
_51.setTemplatePath(this.triggerTemplate);
}
_50.parameters.path=_51;
}
}
this.lastSelectedItem=_51.getContextObject();
break;
case "moveUp":
this.moveUp(_50.parameters.id);
_50.cancelBubble=true;
break;
case "moveDown":
this.moveDown(_50.parameters.id);
_50.cancelBubble=true;
break;
case "changeOrder":
this.changeOrder(_50.parameters.newIndex,_50.parameters.oldIndex);
_50.cancelBubble=true;
break;
case "delete":
var obj=$O(_50.parameters.id);
var _55=false;
if(obj instanceof Story){
_55=true;
}
Dialog.toggle("Delete Item?",this,null,"Delete_Confirm",{ids:[_50.parameters.id],selectRecursion:_55},_50.sourceHTMLElement,Dialog.NORTH);
break;
case "remove":
this.idToRemove=_50.parameters.id;
Dialog.toggle("Remove/Delete Items?",this,null,"Remove_Confirm",{ids:this.idToRemove},_50.sourceHTMLElement,Dialog.NORTH);
break;
case "changeSorting":
this.changeSorting(_50.parameters.sorting);
_50.cancelBubble=true;
break;
case "removeConfirm":
this.contextObject.removeFromSlot(this.fieldName,this.idToRemove);
this.contextObject.cleanSlot(this.fieldName);
if(_50.parameters.deleteToggle==true){
this.getApplication().service.deleteById(this.idToRemove,function(_56){
});
}else{
if(this.contextObject instanceof Story){
var obj=$O(this.idToRemove);
if(obj instanceof Media){
obj.set("story",0);
obj.persist();
}
}
}
this.idToRemove=null;
break;
default:
break;
}
}});
maptales.widgets["ListWidget"]=SlotWidget;
maptales.widgets["Slot"]=SlotWidget;

var ScrollableSlot=Class.create("ScrollableSlot");
Object.extend(Object.extend(ScrollableSlot.prototype,Widget.prototype),{logger:maptales.getLogger("com.maptales.webclient.widgets.scrollableslot"),ScrollableSlot_constructor:function(_1,_2,_3,_4,_5,_6,_7){
if(!_1){
return;
}
this.parent=_2;
this.container=$(_1);
this.contextObject={};
this.contextId=_3;
this.fieldName=_6.fieldName;
this.templatePath=_6.templatePath||"slotPanel/sidepanelScrollSlot";
this.clickAction="gotoPath";
this.listItems=[];
this.scrollFetchSize=1;
this.lazy=false;
if(_6.lazy){
this.lazy=(_6.lazy=="true");
}
this.actionsEnabled=true;
this.numItems=parseInt(_6.numItems)||3;
this.selectedIndex=parseInt(_6.selectedIndex)||0;
this.startIndex=0;
this.indexObject=parseInt(_6.indexObject);
this.selectAction=_6.selectAction;
this.filter=_6.filter||null;
this.sort=_6.sort||null;
this.boundUpdateFunction=this.update.bind(this);
this.initializeWidget(this.container,this.parent,this.contextObject,null,this.templatePath,_6,_7);
if(isNaN(this.contextId)){
if(this.contextId==this.getApplication().getAppName()){
this.contextObject=this.getApplication();
if(this.lazy){
this.loadSlotItems(this.displaySlot.bind(this));
}else{
this.loadNonLazy(this.displaySlot.bind(this));
}
}else{
this.logger.error("IllegalArgumentException: ContextObject is not defined correctly, contextObject: "+this.contextId);
}
}else{
this.getApplication().service.getById(this.contextId,function(_8){
if(_8 instanceof SnapMapException){
this.logger.error("IllegalArgumentException: Could not get ContextObject since is not defined correctly, contextObject: "+this.contextId);
}else{
this.contextObject=_8;
this.addListener();
if(this.lazy){
this.displaySlot();
}else{
this.loadNonLazy(this.displaySlot.bind(this));
}
}
}.bind(this));
}
},addListener:function(){
this.logger.debug("adding listener to: "+this.contextObject.id+"."+this.fieldName);
this.contextObject.addSlotListener(this.fieldName,this.filter,this.sort,this.boundUpdateFunction);
},removeListener:function(){
this.logger.debug("removing listener to: "+this.contextObject.id+"."+this.fieldName);
this.contextObject.removeSlotListener(this.fieldName,this.filter,this.sort,this.boundUpdateFunction);
},update:function(){
this.logger.debug("updating scrollslot: "+this.contextObject.id+"."+this.fieldName);
this.loadNonLazy(this.displaySlot.bind(this));
},destroy:function(){
this.logger.debug("destroy called");
this.destroySubwidgets();
this.removeListener();
delete this.container;
},loadNonLazy:function(_9){
this.logger.debug("loadNonLazy called");
this.disable();
this.contextObject.getSlot(this.fieldName,0,-1,this.filter,this.sort,function(_a){
this.enable();
if(_a instanceof SnapMapException){
this.listItems=[];
this.totalListItems=0;
_9();
}else{
this.listItems=[];
var _b=$A(_a.slotItems);
var _c=0;
for(var i=0;i<_b.length;i++){
this.listItems.push(_b[i]);
_c++;
if(this.indexObject){
if(_b[i].id==this.indexObject){
this.selectedIndex=i;
}
}
}
this.totalListItems=_c;
this.updateStartIndex();
if(this.selectAction){
$a(this.selectAction,null,{id:this.listItems[this.selectedIndex].id,callback:this.autoAdvanceCallback.bind(this)},this.container);
}
_9();
}
}.bind(this));
},loadSlotItems:function(_e){
this.logger.debug("loadSlotItems called");
var _f={id:this.contextObject.id,slotName:this.fieldName,offset:this.startIndex,size:this.numItems,filter:this.filter,sorting:this.sort,objectTemplate:this.objectTemplate};
this.disable();
this.getApplication().service.getSlot(_f,function(_10){
this.enable();
if(_10 instanceof SnapMapException){
this.listItems=[];
this.totalListItems=0;
_e();
}else{
var _11=_10.slotItems;
var _12=0;
_11.each(function(_13){
this.listItems[this.startIndex+_12]=_13;
_12++;
}.bind(this));
this.totalListItems=_10.slotNum;
_e();
}
}.bind(this));
},scrollForward:function(){
this.logger.debug("scrollForward called");
if(this.startIndex<(this.totalListItems-this.numItems)){
this.startIndex++;
if(!this.secondarySlot&&this.lazy){
this.loadSlotItems(this.displaySlot.bind(this));
}else{
this.displaySlot();
}
}
},scrollBackward:function(){
this.logger.debug("scrollBackward called");
if(this.startIndex>0){
this.startIndex--;
if(!this.secondarySlot&&this.lazy){
this.loadSlotItems(this.displaySlot.bind(this));
}else{
this.displaySlot();
}
}
},scrollToIndex:function(_14){
this.logger.debug("scrollToIndex called, index: "+_14);
if(_14>=0&&_14<=this.totalListItems-this.numItems){
this.startIndex=_14;
if(!this.secondarySlot&&this.lazy){
this.loadSlotItems(this.displaySlot.bind(this));
}else{
this.displaySlot();
}
}
},autoAdvanceCallback:function(){
if(this.listItems[this.selectedIndex] instanceof Media){
if(this.listItems[this.selectedIndex].get("text")==null||this.listItems[this.selectedIndex].get("text")==""){
this.selectIndex(this.selectedIndex+1);
}
}
},selectIndex:function(_15){
this.logger.debug("selectIndex called, index: "+_15);
if(_15>=0&&_15<this.totalListItems&&_15!=this.selectedIndex){
if(this.selectAction){
$a(this.selectAction,null,{id:this.listItems[_15].id,callback:this.autoAdvanceCallback.bind(this)},this.container);
}
this.selectedIndex=_15;
this.updateStartIndex();
if(!this.secondarySlot&&this.lazy){
this.loadSlotItems(this.displaySlot.bind(this));
}else{
this.displaySlot();
}
}
},updateStartIndex:function(){
this.logger.debug("updateStartIndex called");
this.startIndex=this.selectedIndex-Math.round(this.numItems/2-0.5);
if(this.startIndex>this.totalListItems-this.numItems){
this.startIndex=this.totalListItems-this.numItems;
}
if(this.startIndex<0){
this.startIndex=0;
}
},displaySlot:function(){
this.logger.debug("displaySlot called");
this.isAtBeginning=(this.startIndex<=0);
this.isAtEnd=(this.startIndex>=this.totalListItems-this.numItems);
this.displayedListItems=[];
for(var i=this.startIndex;i<this.startIndex+this.numItems&&i<this.totalListItems;i++){
this.displayedListItems.push(this.listItems[i]);
}
this.relativeSelectedIndex=this.selectedIndex-this.startIndex;
if(this.selectedIndex>=0){
this.selectedObject=this.listItems[this.selectedIndex];
}
this.display(this.templatePath);
},disable:function(){
this.logger.debug("disable called");
this.actionsEnabled=false;
},enable:function(){
this.logger.debug("enable called");
this.actionsEnabled=true;
},handleBubbleAction:function(_17){
this.logger.debug("handleBubbleAction called: "+_17.getType());
if(!this.actionsEnabled){
return;
}
switch(_17.getType()){
case "scrollForward":
_17.cancelBubble=true;
this.scrollForward();
break;
case "scrollBackward":
_17.cancelBubble=true;
this.scrollBackward();
break;
case "selectNextItem":
_17.cancelBubble=true;
this.selectIndex(this.selectedIndex+1);
break;
case "selectPreviousItem":
_17.cancelBubble=true;
this.selectIndex(this.selectedIndex-1);
break;
case "selectIndex":
_17.cancelBubble=true;
Actions.initAction("onGotoIndex",null,{index:_17.parameters.index},this.getContainer().parentNode);
this.selectIndex(_17.parameters.index);
break;
default:
break;
}
}});
maptales.widgets["ScrollableSlot"]=ScrollableSlot;

var TAB=9,ENTER=13,ESC=27,KEYUP=38,KEYDN=40;
var AutoComplete=Class.create("AutoComplete");
Object.extend(Object.extend(AutoComplete.prototype,Widget.prototype),{AutoComplete_constructor:function(_1,_2,_3,_4,_5,_6,_7){
this.parent=_2;
this.container=$(_1);
if(!_6){
_6={};
}
this.initializeWidget(_1,_2,_3,_4,_5,_6,_7);
this.input=document.createElement("input");
this.input.setAttribute("type","text");
this.input.setAttribute("autocomplete","off");
this.container.appendChild(this.input);
this.submit=document.createElement("div");
this.submit.className="shortButton";
this.submit.innerHTML=_6.buttonText||"add";
this.submit.style.marginLeft="3px";
this.submit.onclick=function(){
this.useEntry();
this.selectFunc();
}.bind(this);
this.container.appendChild(this.submit);
this.output=document.createElement("div");
this.output.className="autoCompleteOutput";
this.output.style.visibility="hidden";
document.body.appendChild(this.output);
if(_6.mode=="tags"){
this.values=new AutoCompleteTagSource(_6.contextObject);
}else{
if(_6.completionSlot){
this.values=new AutoCompleteSlotSource(this.getApplication(),_6.completionContextObject,_6.completionSlot,_6.completionValue);
}
}
this.maxSize=_6.maxSize?_6.maxSize:20;
this.input.onkeyup=this.onKeyUp.bindAsEventListener(this);
this.input.onkeydown=this.onKeyDown.bindAsEventListener(this);
this.input.onblur=this.hideOutput.bindAsEventListener(this);
this.highlightedIndex=-1;
this.validEntries=this.values;
this.selectFunc=this.finished;
this.multiSelect=_6.multiSelect;
},finished:function(){
if(this.input.value!=""){
var _8=this.multiSelect?this.tokenizeInput():[this.input.value];
Actions.initAction("AutoCompleteAction",null,{values:_8},this.container);
}
this.input.value="";
this.input.focus();
},tokenizeInput:function(_9){
return tokenizeTags(this.input.value,_9);
},onKeyDown:function(_a){
var _b=this.getKeyCode(_a);
switch(_b){
case TAB:
if(this.highlightedIndex==-1){
this.highlightedIndex=0;
}
this.useEntry();
break;
case ENTER:
try{
this.useEntry();
}
catch(e){
}
if(this.selectFunc){
this.selectFunc();
}
break;
case ESC:
this.hideOutput();
break;
case KEYUP:
if(this.highlightedIndex>0){
this.highlightedIndex--;
}
this.changeHighlight(_b);
break;
case KEYDN:
if(this.highlightedIndex<(this.validEntries.length-1)){
this.highlightedIndex++;
}
this.changeHighlight(_b);
break;
}
},onKeyUp:function(_c){
var _d=this.getKeyCode(_c);
if(_d==TAB||_d==ENTER||_d==ESC||_d==KEYUP||_d==KEYDN){
return;
}
while(this.output.hasChildNodes()){
this.output.removeChild(this.output.firstChild);
}
var _e=this.tokenizeInput(true);
var _f=_e.last();
if(_f&&(_f!="")){
this.validEntries=this.values.getValid(_f);
if((this.validEntries.length<this.maxSize)&&(this.validEntries.length>0)){
this.highlightedIndex=-1;
for(var i=0;i<this.validEntries.length;i++){
var _11=document.createElement("div");
if(i==this.highlightedIndex){
_11.className="autoCompleteHighlight";
}else{
_11.className="autoCompleteEntry";
}
_11.innerHTML=this.validEntries[i].label;
_11.autoComplete=this;
_11.value=this.validEntries[i].label;
_11.onmousedown=function(){
this.autoComplete.setText(this.value);
this.autoComplete.selectFunc();
};
this.output.appendChild(_11);
}
this.setPos();
this.output.style.visibility="visible";
}else{
this.hideOutput();
}
}else{
this.hideOutput();
}
},hideOutput:function(_12){
this.output.style.visibility="hidden";
this.highlightedIndex=-1;
},setPos:function(){
var el=this.input;
var x=0;
var y=el.offsetHeight;
while(el.offsetParent&&el.tagName.toUpperCase()!="BODY"){
x+=el.offsetLeft;
y+=el.offsetTop;
el=el.offsetParent;
}
x+=el.offsetLeft;
y+=el.offsetTop;
this.output.style.left=x+"px";
this.output.style.top=y+"px";
},getKeyCode:function(_16){
if(_16){
return _16.keyCode;
}
if(window.event){
return window.event.keyCode;
}
},useEntry:function(){
if(this.highlightedIndex>-1&&this.highlightedIndex<this.validEntries.length){
var val=this.input.value;
if(val.indexOf(" ")>-1){
this.input.value=val.substring(0,val.lastIndexOf(" "))+" ";
}else{
this.input.value="";
}
val=this.validEntries[this.highlightedIndex].label.stripTags();
if(val.indexOf(" ")>-1){
this.input.value+="\""+val+"\" ";
}else{
this.input.value+=val+" ";
}
setTimeout(function(){
this.input.focus();
}.bind(this),0);
}
this.hideOutput();
},setText:function(str){
this.input.value=str;
this.hideOutput();
setTimeout(function(){
this.input.focus();
}.bind(this),0);
},changeHighlight:function(){
var _19=this.output.getElementsByTagName("DIV");
var i;
for(i in _19){
var el=_19[i];
if(this.highlightedIndex==i){
el.className="autoCompleteHighlight";
}else{
el.className="autoCompleteEntry";
}
}
}});
var ACEntry=Class.create();
ACEntry.prototype={initialize:function(_1c,obj){
this.label=_1c;
this.obj=obj||_1c;
}};
var AutoCompleteArraySource=Class.create();
AutoCompleteArraySource.prototype={initialize:function(_1e){
this.values=_1e;
},getValid:function(_1f){
var _20=new Array();
for(var i=0;i<this.values.length;i++){
if(this.values[i].toLowerCase().indexOf(_1f.toLowerCase())==0){
_20.push(new ACEntry(this.values[i]));
}
}
return _20;
}};
var AutoCompleteSlotSource=Class.create("AutoCompleteSlotSource");
AutoCompleteSlotSource.prototype={AutoCompleteSlotSource_constructor:function(_22,_23,_24,_25){
this.valueName=_25;
this.valid=[];
_22.getSlot({id:_23,slotName:_24,offset:0,size:100},function(_26){
if(_26 instanceof SnapMapException){
}else{
this.values=_26.slotItems;
}
}.bind(this));
},getValid:function(_27){
if(this.values){
this.valid=new Array();
for(var i=0;i<this.values.length;i++){
if(this.values[i].get(this.valueName).toLowerCase().indexOf(_27.toLowerCase())==0){
this.valid.push(new ACEntry(this.values[i].get(this.valueName)));
}
}
}
return this.valid;
}};
var AutoCompleteTagSource=Class.create("AutoCompleteTagSource");
AutoCompleteTagSource.prototype={AutoCompleteTagSource_constructor:function(_29){
this.contextObject=$O(_29);
this.valid=[];
this.objectTags=[];
if(maptales.service.user.getCurrentUser()){
maptales.service.user.getCurrentUser().getSlot("tags",0,-1,null,null,function(_2a){
if(_2a instanceof SnapMapException){
}else{
this.values=[];
for(var i=0;i<_2a.slotItems.length;i++){
this.values.push(_2a.slotItems[i].get("tag").toLowerCase());
}
}
}.bind(this));
this.getObjectTags();
}
},getObjectTags:function(){
maptales.service.getSlot({id:this.contextObject.id,slotName:"tags",offset:0,size:100},function(_2c){
if(_2c instanceof SnapMapException){
}else{
this.objectTags=[];
for(var i=0;i<_2c.slotItems.length;i++){
this.objectTags.push(_2c.slotItems[i].get("tag").toLowerCase());
}
}
}.bind(this));
},getValid:function(_2e){
if(this.values){
this.valid=[];
_2e=_2e.toLowerCase();
for(var i=0;i<this.values.length;i++){
var tag=this.values[i];
if(tag.indexOf(_2e)==0){
if(this.objectTags.indexOf(tag)==-1){
this.valid.push(new ACEntry(tag));
}
}
}
}
return this.valid;
}};
maptales.widgets["AutoComplete"]=AutoComplete;

var FileUpload=Class.create();
Object.extend(Object.extend(FileUpload.prototype,Widget.prototype),{logger:maptales.getLogger("com.maptales.webclient.widgets.fileupload"),num:0,initialize:function(_1,_2,_3,_4,_5,_6,_7){
this._container=_1;
this._container.innerHTML="";
this.parent=_2;
this.maxItems=_6.maxItems;
this.fileSelector=null;
var id="";
this.swfu=null;
this.flashFilesCount=0;
this.disableFlash=convertBoolean(_6.disableFlash,false);
this.flashUploaderUrl=_6.flashUploaderUrl||null;
this.finished=false;
if(_6.displayLoadingInStatusBar){
this.displayLoadingInStatusBar=convertBoolean(_6.displayLoadingInStatusBar);
}else{
this.displayLoadingInStatusBar=true;
}
this.fileTypes=_6.fileTypes;
this.fileTypesDescription=_6.fileTypesDescription||"";
this.maxFileSize=_6.maxFileSize;
this.loadingTemplatePath=_6.loadingTemplatePath||"fileUpload/loading";
this.errorTemplatePath=_6.errorTemplatePath||"fileUpload/error";
this.successTemplatePath=_6.successTemplatePath||"fileUpload/successTemplatePath";
this.successCall=_6.successCall||null;
this.actionPath=_6.actionPath;
this.fileClass=_6.fileClass;
try{
this.maxItems=parseInt(_6.maxItems);
}
catch(e){
this.maxItems=1;
}
if(_6.postParameters){
this.postParameters=JSON.eval(_6.postParameters);
}else{
this.postParameters={};
}
this.postParameters.sessionid=getSessionId();
this.initializeWidget(this._container,this.parent,_3,_4,_6.templatePath,_6,_7);
try{
if(this.disableFlash==false&&maptales.getURLParameter("disableFlashUpload")==null&&flashinstalled==2&&flashversion>8){
if(this.flashUploaderUrl){
var _9=this.flashUploaderUrl;
}else{
var _9=maptales.baseURL+"/files/flash/swfupload_f9.swf";
}
this.swfu=new SWFUpload({upload_url:maptales.rpcUrl+this.actionPath,post_params:this.properties,file_size_limit:this.maxFileSize,file_types:this.fileTypes,file_types_description:this.fileTypesDescription,file_upload_limit:this.maxItems,file_queued_handler:this.onFlashAdd.bind(this),upload_progress_handler:maptales.rpc.uploadProgress,upload_error_handler:maptales.rpc.uploadError,upload_complete_handler:function(){
this.onFlashSubmit();
}.bind(this),upload_success_handler:maptales.rpc.uploadSuccess,flash_url:_9,ui_container_id:"fileList",degraded_container_id:"degraded_container",custom_settings:{upload_target:"fileList"},debug:false});
maptales.rpc.fileUploadFlash=this.swfu;
}
}
catch(e){
this.logger.error("could not make flash uploader",e);
this.swfu=null;
}
this.display();
},onFlashSubmit:function(){
var _a=this.postParameters;
_a.sessionid=getSessionId();
var _b=this.getElement("tags");
if(_b!=null){
_a.tags=_b.value;
}
this.finished=false;
this.swfu.setPostParams(_a);
this.swfu.startUpload();
},onFlashAdd:function(_c){
if(_c==null){
return;
}
this.flashFilesCount++;
if(this.flashFiles==null){
this.flashFiles=[];
}
this.flashFiles.push(_c.id);
var _d=_c.name;
var _e=_c.id;
var _f=this.getElement("fileList");
var _10=document.createElement("div");
var _11=document.createElement("div");
_11.className="deleteInline";
_11.innerHTML="&nbsp;&nbsp;&nbsp;&nbsp;";
_10.file_id=_e;
_11._fileUploadParent=this;
_11.file_id=_e;
_11.onclick=function(){
var _12=this.parentNode.parentNode;
this.parentNode.parentNode.removeChild(this.parentNode);
Actions.initAction("layoutChanged",null,null,_12);
this._fileUploadParent.flashFilesCount--;
this._fileUploadParent.flashFiles.removeEntry(this.file_id);
this._fileUploadParent.swfu.cancelUpload(this.file_id);
return false;
};
_10.innerHTML=_d;
_10.appendChild(_11);
_f.appendChild(_10);
Actions.bubbleAction(new Action("layoutChanged",null,this.container),this.container);
},onDisplay:function(){
try{
var _13=this.getElement("fileList");
if(this.swfu==null){
this.fileInput=this.getElement("fileInput");
if(_13&&this.fileInput){
this.fileSelector=new MultiSelector(_13,this.maxItems);
this.fileSelector.addElement(this.fileInput);
}
}
Actions.initAction("layoutChanged",null,{},this.getContainer());
}
catch(e){
alert("FileUpload "+e);
}
},uploadInit:function(_14){
this.finished=false;
if(this.swfu!=null){
maptales.rpc.uploadedObjects=[];
maptales.rpc.completeFilesNum=0;
this.onFlashSubmit();
maptales.rpc.uploadedFilesNum=this.flashFiles.length;
}else{
this.getElement("uploadForm").submit();
if(this.fileSelector){
maptales.rpc.uploadedFilesNum=this.fileSelector.items.length;
}else{
maptales.rpc.uploadedFilesNum=1;
}
maptales.rpc.startFormUpload();
}
maptales.imageUploadInProgress=true;
if(this.displayLoadingInStatusBar){
_14.type="displayUploadProgress";
}else{
_14.cancelBubble=true;
maptales.rpc.addUploadErrorListener(this.error.bind(this));
maptales.rpc.addUploadCompleteListener(this.complete.bind(this));
maptales.rpc.addUploadSuccessListener(this.update.bind(this));
this.update();
}
},update:function(){
if(this.finished==false){
this.display(this.loadingTemplatePath);
}
},complete:function(){
this.finished=true;
if(this.successCall==null){
this.display(this.successTemplatePath);
}else{
try{
eval(this.successCall);
}
catch(e){
this.logger.error("Error calling successCall: "+this.successCall,e);
}
}
},error:function(_15,_16,_17){
this.finished=true;
this.display(this.errorTemplatePath,{message:_17});
},handleBubbleAction:function(_18){
this.logger.debug("FileUpload>BubbleAction>"+_18.getType());
switch(_18.getType()){
case "flashSelect":
this.swfu.selectFiles();
break;
case "showLoading":
window.setTimeout(function(){
this.display("loading");
}.bind(this),1500);
_18.cancelBubble=true;
break;
case "uploadInit":
this.uploadInit(_18);
break;
}
}});
function MultiSelector(_19,max){
this.list_target=_19;
this.count=0;
this.id=0;
if(max){
this.max=max;
}else{
this.max=-1;
}
this.items=[];
this.addElement=function(_1b){
if(_1b.tagName=="INPUT"&&_1b.type=="file"){
_1b.name="file_"+this.id++;
_1b.multi_selector=this;
_1b.onchange=function(){
var _1c=document.createElement("input");
_1c.type="file";
this.style.position="absolute";
this.style.left="-1000px";
this.parentNode.insertBefore(_1c,this);
this.multi_selector.addElement(_1c);
this.multi_selector.addListRow(this);
};
if(this.max!=-1&&this.count>=this.max){
_1b.disabled=true;
}
this.count++;
this.current_element=_1b;
}else{
alert("Error: not a file input element");
}
};
this.addListRow=function(_1d){
if(_1d.value.length>0){
this.items.push(_1d.value);
}
var _1e=document.createElement("li");
var _1f=document.createElement("div");
_1f.className="deleteInline";
_1f.innerHTML="&nbsp;&nbsp;&nbsp;&nbsp;";
_1e.element=_1d;
_1f._fileUploadParent=this;
_1f._fileValueToRemove=_1d.value;
_1f.onclick=function(){
var _20=this.parentNode.parentNode;
this.parentNode.element.parentNode.removeChild(this.parentNode.element);
this.parentNode.parentNode.removeChild(this.parentNode);
this.parentNode.element.multi_selector.count--;
this.parentNode.element.multi_selector.current_element.disabled=false;
Actions.initAction("layoutChanged",null,null,_20);
this._fileUploadParent.count--;
this._fileUploadParent.items.removeEntry(this._fileValueToRemove);
return false;
};
if(_1d.value.length>30){
_1e.innerHTML=_1d.value.slice(0,10)+"..."+_1d.value.slice(_1d.value.length-15,_1d.value.length);
}else{
_1e.innerHTML=_1d.value;
}
_1e.appendChild(_1f);
this.list_target.appendChild(_1e);
Actions.bubbleAction(new Action("layoutChanged",null,this.list_target),this.list_target);
};
}
maptales.widgets["Fileupload"]=FileUpload;

var Login=Class.create();
Object.extend(Object.extend(Login.prototype,Widget.prototype),{logger:maptales.getLogger("com.maptales.webclient.widgets.login"),initialize:function(_1,_2,_3,_4,_5,_6,_7){
this.parent=_2;
this.container=_1;
this.initializeWidget(this.container,this.parent,null,null,"loginPanel/userPanel",null);
if(this.getApplication().getCurrentUser()==null){
this.display("loginPanel/logIn");
}else{
this.display("loginPanel/userPanel");
}
this.boundLoginFunction=this.onLogin.bind(this);
maptales.service.user.addLoginListener(this.boundLoginFunction);
},onLogin:function(_8){
if(_8 instanceof SnapMapException){
this.loginError();
return;
}
if(this.getApplication().getCurrentUser()==null){
this.display("loginPanel/logIn");
}else{
this.display("loginPanel/userPanel");
}
},onDisplay:function(){
try{
this.getElement("pass_field").onkeypress=this.onKeyEvent.bindAsEventListener(this);
this.getElement("login_field").onkeypress=this.onKeyEvent.bindAsEventListener(this);
}
catch(e){
}
},onKeyEvent:function(_9){
var _a;
if(window.event){
_a=window.event.keyCode;
}else{
if(_9){
_a=_9.which;
}else{
return true;
}
}
if(_a==Event.KEY_RETURN){
this.login();
}else{
return true;
}
},login:function(_b,_c){
if(!_b&&!_c){
_b=this.getField("login_field").value;
_c=this.getField("pass_field").value;
try{
var _d=this.getField("rememberMe").checked;
}
catch(e){
var _d=false;
}
}
this.logger.debug("login called with: name:"+_b+" pass:"+_c);
this.display("loginPanel/loading");
maptales.service.user.login({name:_b,pass:_c,rememberMe:_d},this.onLogin.bind(this));
},logout:function(){
this.logger.debug("logout called");
maptales.service.user.logout(null,this.logoutComplete.bind(this));
},logoutComplete:function(){
this.logger.debug("logoutComplete called");
this.display("loginPanel/logIn");
},loginComplete:function(){
this.logger.debug("loginComplete called");
this.display("loginPanel/userPanel");
},loginError:function(_e){
this.display("loginPanel/logIn");
Dialog.toggle("Login Failed!",this,null,"loginPanel/forgotPassword",{},this.getField("pass_field"));
},handleBubbleAction:function(_f){
this.logger.debug("BubbleAction>"+_f.getType());
if(_f.getType()=="login"){
this.login();
_f.cancelBubble=true;
}
if(_f.getType()=="logout"){
this.logout();
_f.cancelBubble=true;
}
}});
maptales.widgets["Login"]=Login;

var TagManager=Class.create("TagManager");
TagManager.prototype.__handleBubbleAction=SlotWidget.prototype.handleBubbleAction;
Object.extend(Object.extend(TagManager.prototype,SlotWidget.prototype),{TagManager_constructor:function(_1,_2,_3,_4,_5,_6,_7){
if(_6){
_6.sort="tag asc";
}else{
_6={sort:"tag asc"};
}
_6.listItemTemplatePath=_6.listItemTemplatePath||"slotPanel/slotTagItem";
this.initialize(_1,_2,_3,_4,_5,_6);
},handleBubbleAction:function(_8){
switch(_8.getType()){
case "AutoCompleteAction":
_8.cancelBubble=true;
if(_8.parameters.values){
var _9=[];
for(var i=0;i<_8.parameters.values.length;i++){
_9.push(this.getApplication().service.create("Tag",{tag:_8.parameters.values[i].toLowerCase()}));
}
var _b=this.contextObject.getSlotFromCache("tags");
for(var i=0;i<_9.length;i++){
if(!this.containsTag(_b,_9[i])){
this.contextObject.addToSlot("tags",_9[i]);
}else{
}
}
try{
var _c=this.getApplication().service.user.getCurrentUser().getSlotFromCache("tags");
}
catch(e){
this.getApplication().service.user.getCurrentUser().getSlot("tags",0,-1,null,"tag asc",function(){
});
_c=[];
}
for(var i=0;i<_9.length;i++){
if(!this.containsTag(_c,_9[i])){
this.getApplication().service.user.getCurrentUser().addToSlot("tags",_9);
}else{
}
}
this.getApplication().service.persist(this.contextObject,function(_d){
if(_d instanceof SnapMapException){
Dialog.toggle("Error Storing Tags",this,null,"dialog/ErrorDialog",{message:"There has been an error storing the tags."},this.getElement("tagInput")||this.getContainer(),Dialog.NORTH);
}else{
}
}.bind(this));
}
break;
}
this.__handleBubbleAction(_8);
},containsTag:function(_e,_f){
var _10=false;
for(var i=0;i<_e.length;i++){
if(_e[i].get("tag")==_f.get("tag")){
_10=true;
}
}
return _10;
}});
maptales.widgets["TagManager"]=TagManager;

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 DatePicker=Class.create();
Object.extend(Object.extend(DatePicker.prototype,Widget.prototype),{monthArray:["January","February","March","April","May","June","July","August","September","October","November","December"],monthArrayShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayArray:["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],weekString:"Week",displayedWeeks:[1,2,3,4,5,6],displayedDays:[1,2,3,4,5,6,7],todayString:"",daysInMonthArray:[31,28,31,30,31,30,31,31,30,31,30,31],initialize:function(_1,_2,_3,_4,_5,_6,_7){
this.container=$(_1);
this.parent=_2;
this.contextObject=$O(_3);
this.field=_6.contextField;
this.date=this.contextObject.get(this.field);
this.initializeWidget(this.container,this.parent,_3,_4,_5||"datePicker/datePicker",_6,_7);
if(this.date==null){
this.date=new Date();
}
this.currentMonth=this.date.getMonth();
this.currentYear=this.date.getFullYear();
this.currentDay=this.date.getDate();
this.currentHour=this.date.getHours();
this.currentMinute=this.date.getMinutes();
this.selectedMonth=this.date.getMonth();
this.selectedYear=this.date.getFullYear();
this.selectedDay=this.date.getDate();
this.selectedHour=this.date.getHours();
this.selectedMinute=this.date.getMinutes();
this.writeCalendarContent();
this.display();
},onDisplay:function(){
Actions.initAction("layoutChanged",null,{},this.container);
},getMinutes:function(){
return this.selectedMinute;
},getHours:function(){
return this.selectedHour;
},writeCalendarContent:function(){
var d=new Date();
d.setFullYear(this.currentYear);
d.setDate(1);
d.setMonth(this.currentMonth);
this.dayStartOfMonth=d.getDay();
if(this.dayStartOfMonth==0){
this.dayStartOfMonth=7;
}
this.dayStartOfMonth--;
this.daysInMonth=this.daysInMonthArray[this.currentMonth];
if(this.daysInMonth==28){
if(this.isLeapYear(this.currentYear)){
this.daysInMonth=29;
}
}
},isLeapYear:function(_9){
if(_9%400==0||(_9%4==0&&_9%100!=0)){
return true;
}
return false;
},isSelectedDay:function(_a){
return (_a==this.currentDay&&this.selectedMonth==this.currentMonth&&this.selectedYear==this.currentYear);
},getCurrentMonthName:function(){
return this.monthArray[this.currentMonth];
},selectYear:function(_b){
this.currentYear=parseInt(_b);
this.writeCalendarContent();
this.display();
},selectMonth:function(_c){
if(_c<0){
this.currentYear=this.currentYear-1;
_c=11;
}else{
if(_c>11){
this.currentYear=this.currentYear+1;
_c=0;
}
}
this.currentMonth=parseInt(_c);
this.writeCalendarContent();
this.display();
},selectDay:function(_d,_e){
this.currentDay=_d;
if(_e){
if(_e<0){
this.currentYear=this.currentYear-1;
_e=11;
}else{
if(_e>11){
this.currentYear=this.currentYear+1;
_e=0;
}
}
this.currentMonth=_e;
}
this.selectedYear=this.currentYear;
this.selectedMonth=this.currentMonth;
this.selectedDay=this.currentDay;
this.writeCalendarContent();
this.display();
},getEndingDaysOfLastMonth:function(_f){
var _10=this.currentMonth-1;
if(_10<0){
_10=11;
}else{
if(_10>11){
_10=0;
}
}
var _11=this.daysInMonthArray[_10];
if(_11==28){
if(this.isLeapYear(this.currentYear)){
_11=29;
}
}
return _11-_f;
},submit:function(){
var _12=new Date();
_12.setYear(this.selectedYear);
_12.setMonth(this.selectedMonth);
_12.setDate(this.selectedDay);
_12.setHours(this.getFormHashMap("datePicker")["hours"]);
_12.setMinutes(this.getFormHashMap("datePicker")["minutes"]);
Actions.initAction("dialogDestroy",null,null,this.container);
this.contextObject.set(this.field,_12);
this.contextObject.persist(function(){
});
},cancel:function(){
Actions.initAction("dialogDestroy",null,null,this.container);
},formatHoursAndMinutes:function(_13){
if(_13<10){
_13="0"+_13;
}
return _13;
},deformatHoursAndMinutes:function(_14){
_14=_14+"";
if(_14[0]=="0"){
_14=_14.slice(1);
}
return _14;
},handleBubbleAction:function(_15){
switch(_15.getType()){
case "selectYear":
_15.cancelBubble=true;
this.selectYear(_15.parameters.year);
break;
case "selectMonth":
_15.cancelBubble=true;
this.selectMonth(_15.parameters.month);
break;
case "selectDay":
_15.cancelBubble=true;
this.selectDay(_15.parameters.day,_15.parameters.month);
break;
case "addMinute":
_15.cancelBubble=true;
var _16=parseInt(this.deformatHoursAndMinutes(this.getElement("datePickerMinute").value))+1;
if(_16>=60){
_16=0;
}
this.getElement("datePickerMinute").value=this.formatHoursAndMinutes(_16);
break;
case "subtractMinute":
_15.cancelBubble=true;
var _16=parseInt(this.deformatHoursAndMinutes(this.getElement("datePickerMinute").value))-1;
if(_16<0){
_16=59;
}
this.getElement("datePickerMinute").value=this.formatHoursAndMinutes(_16);
break;
case "addHour":
_15.cancelBubble=true;
var _16=parseInt(this.deformatHoursAndMinutes(this.getElement("datePickerHour").value))+1;
if(_16>=24){
_16=0;
}
this.getElement("datePickerHour").value=this.formatHoursAndMinutes(_16);
break;
case "subtractHour":
_15.cancelBubble=true;
var _16=parseInt(this.deformatHoursAndMinutes(this.getElement("datePickerHour").value))-1;
if(_16<0){
_16=23;
}
this.getElement("datePickerHour").value=this.formatHoursAndMinutes(_16);
break;
case "submit":
_15.cancelBubble=true;
this.submit();
break;
case "cancel":
_15.cancelBubble=true;
this.cancel();
break;
}
}});
maptales.widgets["datePicker"]=DatePicker;

var StatusBar=Class.create();
Object.extend(Object.extend(StatusBar.prototype,Widget.prototype),{logger:maptales.getLogger("com.maptales.webclient.widgets.statusbar"),initialize:function(_1,_2,_3,_4,_5,_6,_7){
this.parent=_2;
this.messages=[];
this.container=_1;
this.initializeWidget(this.container,this.parent,null,null,"statusBar/statusBar",_6);
this.boundLoginFunction=this.onLogin.bind(this);
maptales.service.user.addLoginListener(this.boundLoginFunction);
if((BrowserDetect.browser=="Safari"&&BrowserDetect.version>10&&BrowserDetect.version<420)||(BrowserDetect.browser=="Explorer"&&BrowserDetect.version<7)||BrowserDetect.browser=="unknown"){
this.displayBrowserWarning=true;
}else{
this.displayBrowserWarning=false;
}
this.display();
},onLogin:function(){
},addMessage:function(_8,_9){
switch(_8){
case "UploadStatus":
if(this.getComponent("uploads")!=null){
this.getComponent("uploads").addMessage(_9);
}
break;
case "IncomingMessage":
if(this.getComponent("messages")!=null){
this.getComponent("messages").addMessage(_9);
}
break;
case "UserWarning":
if(this.getComponent("warnings")!=null){
this.getComponent("warnings").addMessage(_9);
}
break;
default:
if(this.getApplication().service.user.getCurrentUser()&&this.getApplication().service.user.getCurrentUser().hasRole("ROLE_ADMIN")){
if(this.getComponent("debug")!=null){
this.getComponent("debug").addMessage(_9);
}
}
}
},handleBubbleAction:function(_a){
this.logger.debug("Slot>handleBubbleAction>"+_a.getType());
switch(_a.getType()){
case "minPlugin":
this.getComponent(_a.parameters.name).hideBody();
break;
case "maxPlugin":
for(var _b in this._components){
try{
if(_b==_a.parameters.name){
this.getComponent(_b).showBody();
}else{
this.getComponent(_b).hideBody();
}
}
catch(e){
}
}
break;
default:
break;
}
}});
maptales.widgets["statusBar"]=StatusBar;
var LoggerPlugin=Class.create();
Object.extend(Object.extend(LoggerPlugin.prototype,Widget.prototype),{initialize:function(_c,_d,_e,_f,_10,_11,_12){
this.parent=_d;
this.container=_c;
this.initializeWidget(this.container,this.parent,null,null,"statusBar/loggerPlugin",_11);
this.inPageLayout=new log4javascript.PatternLayout("%c %d{HH:mm:ss} %-5p - %m%n");
this.name="logger";
this.bodyVisible=false;
this.display();
this.inPageAppender=null;
},destroy:function(){
maptales.removeRootAppender(this.inPageAppender);
this._destroy();
},onDisplay:function(){
this.inPageAppender=new log4javascript.InPageAppender(this.getElement("loggerContainer"),false,this.inPageLayout,false,false,true,"100%",600,2000);
this.inPageAppender.setLayout(this.inPageLayout);
maptales.addRootAppender(this.inPageAppender);
},showBody:function(){
if(!this.bodyVisible){
var el=this.getElement(this.name+"Plugin");
var _14=el.className.replace(/collapsed/g,"");
_14+=" expanded";
el.className=_14;
this.bodyVisible=true;
}
},hideBody:function(){
if(this.bodyVisible){
var el=this.getElement(this.name+"Plugin");
var _16=el.className.replace(/expanded/g,"");
_16+=" collapsed";
el.className=_16;
this.bodyVisible=false;
}
},handleBubbleAction:function(_17){
switch(_17.getType()){
case "clearPlugin":
_17.cancelBubble=false;
this.container.style.display="none";
break;
}
}});
maptales.widgets["LoggerPlugin"]=LoggerPlugin;
var StatusPlugin=Class.create();
Object.extend(Object.extend(StatusPlugin.prototype,Widget.prototype),{initialize:function(_18,_19,_1a,_1b,_1c,_1d,_1e){
if(!_18){
return;
}
this.parent=_19;
this.messages=[];
this.container=_18;
this.name=_1d.component;
this.bodyVisible=false;
this.templatePath=_1d.templatePath||"statusBar/warningsPlugin";
this.initializeWidget(this.container,this.parent,_1a,_1b,this.templatePath,_1d,_1e);
},addMessage:function(_1f){
this.messages.push(_1f);
this.update();
},clear:function(){
this.messages=[];
this.hideBody();
this.container.innerHTML="";
},showBody:function(){
if(!this.bodyVisible){
var el=this.getElement(this.name+"Plugin");
var _21=el.className.replace(/collapsed/g,"");
_21+=" expanded";
el.className=_21;
this.bodyVisible=true;
}
},hideBody:function(){
if(this.bodyVisible){
var el=this.getElement(this.name+"Plugin");
var _23=el.className.replace(/expanded/g,"");
_23+=" collapsed";
el.className=_23;
this.bodyVisible=false;
}
},showMessageDetails:function(_24,_25){
var _26=this.messages[_24];
if(_26 instanceof SnapMapException){
Dialog.toggleFixed("Exception",this,null,"Exception",{exception:_26},_25,Dialog.NORTH);
}else{
Dialog.toggleFixed(_26.type,this,null,"Message",{title:_26.title,message:_26.text},_25,Dialog.NORTH);
}
},handleBubbleAction:function(_27){
switch(_27.getType()){
case "messageClick":
this.showMessageDetails(_27.parameters.index,_27.parameters.focusElement);
break;
case "clearPlugin":
this.clear();
break;
default:
break;
}
}});
maptales.widgets["StatusPlugin"]=StatusPlugin;
var FileUploadProgress=Class.create();
Object.extend(Object.extend(FileUploadProgress.prototype,StatusPlugin.prototype),{initialize:function(_28,_29,_2a,_2b,_2c,_2d,_2e){
this.parent=_29;
this.messages=[];
this.container=_28;
this.name=_2d.component;
this.bodyVisible=false;
this.files=[];
this.totalFiles=this.files.length;
this.stats={};
this.uploadedFileCounter=0;
this.statusTemplate=null;
Templates.getTemplate("statusBar/fileProgress",function(_2f){
this.statusTemplate=_2f;
}.bind(this));
this.templatePath=_2d.templatePath||"statusBar/uploadsPlugin";
this.initializeWidget(this.container,this.parent,_2a,_2b,this.templatePath,_2d,_2e);
this.boundFinishFunction=this.complete.bind(this);
this.boundErrorFunction=this.error.bind(this);
this.boundUpdateFunction=this.update.bind(this);
this.message=null;
this.isLoading=false;
},error:function(_30,_31,_32){
this.message={title:"Upload Error",message:_32};
this.display("statusBar/uploadsPluginError");
},complete:function(){
this.fileCount=maptales.rpc.uploadedObjects.length;
this.files=maptales.rpc.uploadedObjects;
this.ids=[];
for(var e=0;e<this.files.length;e++){
this.ids.push(this.files[e].id);
}
this.display("statusBar/uploadFinished");
},update:function(_34){
if(maptales.rpc.completeFilesNum>-1){
this.uploadedFileCounter=maptales.rpc.completeFilesNum;
if(this.statusTemplate){
this.getElement("progressMessage").innerHTML=this.statusTemplate.process(this);
}
}
},addMessage:function(_35){
maptales.rpc.addUploadCompleteListener(this.boundFinishFunction);
maptales.rpc.addUploadErrorListener(this.boundErrorFunction);
maptales.rpc.addUploadSuccessListener(this.boundUpdateFunction);
this.messages.push(_35);
this.totalFiles=_35.files;
this.isLoading=true;
this.display("statusBar/uploadsPlugin",null,this.fadeAlert.bind(this));
},fadeAlert:function(){
this.counter=0;
if(this.statusTemplate){
this.getElement("progressMessage").innerHTML=this.statusTemplate.process(this);
}
if(this.fadeInterval!=null){
window.clearInterval(this.fadeInterval);
}
this.fadeInterval=window.setInterval(this.fade.bind(this),40);
this.startColor=new com.snapmap.Color(235,240,0);
this.endColor=new com.snapmap.Color(255,255,255);
var _36=this.getElement("pluginHeader");
if(_36!=null){
_36.style.backgroundColor=this.startColor.toString();
}
},fade:function(){
this.counter=this.counter+1;
this.startColor.blendTo(this.endColor,20);
try{
this.getElement("pluginHeader").style.backgroundColor=this.startColor.toString();
}
catch(e){
}
if(this.counter>100){
try{
this.getElement("pluginHeader").style.backgroundColor=this.endColor.toString();
}
catch(e){
}
window.clearInterval(this.fadeInterval);
}
this.fadeInterval=null;
},clear:function(){
maptales.rpc.removeUploadCompleteListener(this.boundFinishFunction);
maptales.rpc.removeUploadErrorListener(this.boundErrorFunction);
maptales.rpc.removeUploadSuccessListener(this.boundUpdateFunction);
this.uploadedFileCounter=1;
this.messages=[];
this.bodyVisible=false;
this.container.innerHTML="";
},onUploadFinish:function(_37){
this.clear();
}});
maptales.widgets["FileUploadPlugin"]=FileUploadProgress;

var AreaSelect=Class.create("AreaSelect");
Object.extend(Object.extend(AreaSelect.prototype,Widget.prototype),{AreaSelect_constructor:function(_1,_2,_3,_4,_5,_6,_7){
if(!_6){
_6={};
}
this.parent=_2;
this.container=_1;
this.square=_6.square||false;
this.template=_6.templatePath||"areaSelect/areaSelect";
this.draggedCorner=null;
this.initializeWidget(this.container,this.parent,_3,_4,this.template,_6,_7);
this.forceSquare=true;
this.minWidth=15;
this.minHeight=15;
this.boundMouseMainMoveListener=this.mouseMainMoveListen.bind(this);
this.boundStopObservingMain=this.stopObservingMain.bind(this);
this.boundCornerMoveListener=this.cornerMoveListen.bind(this);
this.boundStopObservingCorner=this.stopObservingCorner.bind(this);
Templates.getTemplate("areaSelect/areaSelect",function(_8){
this.getElement("areaSelectContainer").innerHTML=_8.process(null);
this.onDisplay();
}.bind(this));
},startDragMain:function(_9){
Event.observe(document,"mousemove",this.boundMouseMainMoveListener);
Event.observe(document,"mouseup",this.boundStopObservingMain);
this.initialMouseX=parseInt(Event.pointerX(_9.event));
this.initialMouseY=parseInt(Event.pointerY(_9.event));
this.initialMainY=this.getElement("mainArea").offsetTop;
this.initialMainX=this.getElement("mainArea").offsetLeft;
},mouseMainMoveListen:function(_a){
var _b=Event.pointerX(_a)-this.initialMouseX;
var _c=Event.pointerY(_a)-this.initialMouseY;
var _d=(parseInt(this.initialMainY)+parseInt(_c));
if(_d<0){
_d=0;
}
var _e=(parseInt(this.initialMainX)+parseInt(_b));
if(_e<0){
_e=0;
}
var _f=_e+this.getElement("mainArea").offsetWidth;
if(_f>this.getElement("target").offsetWidth){
_e=this.getElement("target").offsetWidth-this.getElement("mainArea").offsetWidth;
}
var _10=_d+this.getElement("mainArea").offsetHeight;
if(_10>this.getElement("target").offsetHeight){
_d=this.getElement("target").offsetHeight-this.getElement("mainArea").offsetHeight;
}
this.getElement("mainArea").style.top=_d+"px";
this.getElement("mainArea").style.left=_e+"px";
this.debug();
this.notify();
},stopObservingMain:function(){
Event.stopObserving(document,"mousemove",this.boundMouseMainMoveListener);
Event.stopObserving(document,"mouseup",this.boundStopObservingMain);
},startScale:function(_11){
this.draggedCorner=this.getElement(_11.parameters.corner);
this.currentCornerName=_11.parameters.corner;
Event.observe(document,"mousemove",this.boundCornerMoveListener);
Event.observe(document,"mouseup",this.boundStopObservingCorner);
this.initialMouseX=parseInt(Event.pointerX(_11.event));
this.initialMouseY=parseInt(Event.pointerY(_11.event));
this.initialWidth=this.getElement("mainArea").offsetWidth;
this.initialHeight=this.getElement("mainArea").offsetHeight;
if(this.forceSquare){
if(this.initialWidth!=this.initialHeight){
if(this.initialWidth>this.initialHeight){
this.initialHeight=this.initialWidth;
}else{
this.initialWidth=this.initialHeight;
}
this.getElement("mainArea").style.height=this.initialHeight+"px";
this.getElement("mainArea").style.width=this.initialWidth+"px";
this.getElement("innerBorder").style.height=(parseInt(this.initialHeight)-2)+"px";
this.getElement("innerBorder").style.width=(parseInt(this.initialWidth)-2)+"px";
}
}
this.initialMainY=this.getElement("mainArea").offsetTop;
this.initialMainX=this.getElement("mainArea").offsetLeft;
},cornerMoveListen:function(_12){
var _13=Event.pointerX(_12)-this.initialMouseX;
var _14=Event.pointerY(_12)-this.initialMouseY;
if(this.forceSquare){
if(this.currentCornerName=="leftTop"||this.currentCornerName=="rightBottom"){
if(Math.abs(_13)>Math.abs(_14)){
_14=_13;
}else{
_13=_14;
}
}else{
if(this.currentCornerName=="leftBottom"||this.currentCornerName=="rightTop"){
if(Math.abs(_13)>Math.abs(_14)){
_14=-_13;
}else{
_13=-_14;
}
}
}
}
if(this.currentCornerName=="leftTop"){
var _15=this.initialWidth-_13;
var _16=this.initialHeight-_14;
var _17=this.initialMainX+_13;
var top=this.initialMainY+_14;
}else{
if(this.currentCornerName=="leftBottom"){
var _15=this.initialWidth-_13;
var _16=this.initialHeight+_14;
var _17=this.initialMainX+_13;
var top=this.initialMainY;
}else{
if(this.currentCornerName=="rightTop"){
var _15=this.initialWidth+_13;
var _16=this.initialHeight-_14;
var _17=this.initialMainX;
var top=this.initialMainY+_14;
}else{
if(this.currentCornerName=="rightBottom"){
var _15=this.initialWidth+_13;
var _16=this.initialHeight+_14;
var _17=this.initialMainX;
var top=this.initialMainY;
}
}
}
}
this.checkConstraintsAndAdjustAfterRescale(_15,_16,top,_17);
},checkSquareConstraint:function(){
if(this.forceSquare){
if(width!=height){
if(Math.abs(this.initialWidth-width)>Math.abs(this.initialHeight-height)){
var _19=height;
height=width;
top=top-(height-_19);
}else{
var _1a=width;
width=height;
left=left-(width-_1a);
}
}
}
},checkConstraintsAndAdjustAfterRescale:function(_1b,_1c,top,_1e){
var _1f=false;
var _20=false;
if(_1c<this.minHeight){
_1c=this.minHeight;
if(this.currentCornerName=="leftTop"){
_1f=true;
_20=true;
}else{
if(this.currentCornerName=="leftBottom"){
_20=true;
}else{
if(this.currentCornerName=="rightTop"){
_1f=true;
}
}
}
}
if(_1b<this.minWidth){
_1b=this.minWidth;
if(this.currentCornerName=="leftTop"){
_1f=true;
_20=true;
}else{
if(this.currentCornerName=="leftBottom"){
_20=true;
}else{
if(this.currentCornerName=="rightTop"){
_1f=true;
}
}
}
}
if(top<0||top==null){
top=0;
}
if(_1e<0||_1e==null){
_1e=0;
}
if((_1e+_1b<this.getElement("target").offsetWidth)&&(top+_1c<this.getElement("target").offsetHeight)){
if(!_1f){
this.getElement("mainArea").style.top=top+"px";
}
if(!_20){
this.getElement("mainArea").style.left=_1e+"px";
}
this.getElement("mainArea").style.width=_1b+"px";
this.getElement("mainArea").style.height=_1c+"px";
this.getElement("innerBorder").style.height=(parseInt(_1c)-2)+"px";
this.getElement("innerBorder").style.width=(parseInt(_1b)-2)+"px";
}else{
var _21=false;
var _22=false;
if(this.currentCornerName=="leftTop"){
if(_1e+_1b>this.getElement("target").offsetWidth){
_21=true;
_1b=this.getElement("target").offsetWidth-_1e;
_1e=0;
}
if(top+_1c>this.getElement("target").offsetHeight){
_22=true;
_1c=this.getElement("target").offsetHeight-top;
top=0;
}
this.getElement("mainArea").style.left=_1e+"px";
this.getElement("mainArea").style.top=top+"px";
}else{
if(this.currentCornerName=="rightTop"){
if(_1e+_1b>this.getElement("target").offsetWidth){
_21=true;
_1b=this.getElement("target").offsetWidth-_1e;
}
if(top+_1c>this.getElement("target").offsetHeight){
_22=true;
_1c=this.getElement("target").offsetHeight-top;
top=0;
}
this.getElement("mainArea").style.top=top+"px";
}else{
if(this.currentCornerName=="leftBottom"){
if(_1e+_1b>this.getElement("target").offsetWidth){
_21=true;
_1b=this.getElement("target").offsetWidth-_1e;
_1e=0;
}
if(top+_1c>this.getElement("target").offsetHeight){
_22=true;
_1c=this.getElement("target").offsetHeight-top;
}
this.getElement("mainArea").style.left=_1e+"px";
}else{
if(this.currentCornerName=="rightBottom"){
if(_1e+_1b>this.getElement("target").offsetWidth){
_21=true;
_1b=this.getElement("target").offsetWidth-_1e;
}
if(top+_1c>this.getElement("target").offsetHeight){
_22=true;
_1c=this.getElement("target").offsetHeight-top;
}
}
}
}
}
if(this.forceSquare){
if(_21&&_22){
if(_1b<_1c){
_1c=_1b;
}else{
_1b=_1c;
}
}else{
if(_21){
_1c=_1b;
}
if(_22){
_1b=_1c;
}
}
}
this.getElement("mainArea").style.width=_1b+"px";
this.getElement("innerBorder").style.width=(parseInt(_1b)-2)+"px";
this.getElement("mainArea").style.height=_1c+"px";
this.getElement("innerBorder").style.height=(parseInt(_1c)-2)+"px";
}
this.notify();
},debug:function(_23,_24,_25,_26,_27,top){
try{
}
catch(e){
}
},notify:function(){
var _29=48;
this.scaleFactor=_29/this.getElement("mainArea").offsetWidth;
var _2a=this.scaleFactor*this.getElement("target").offsetWidth;
var _2b=this.scaleFactor*this.getElement("target").offsetHeight;
var _2c=-this.scaleFactor*this.getElement("mainArea").offsetTop;
var _2d=-this.scaleFactor*this.getElement("mainArea").offsetLeft;
this.debugNotify(this.scaleFactor,_2a,_2b,_2c,_2d);
$a("cropChange",null,{top:_2c,left:_2d,width:_2a,height:_2b},this.container);
},debugNotify:function(_2e,_2f,_30,_31,_32){
try{
log.debug(" targetWidth: "+_2f+"<br /> targetHeight: "+_30+"<br /> scaleFactor: "+_2e+"<br /> targetTop: "+_31+"<br /> targetLeft: "+_32+"<br /> mainWidth: "+this.getElement("target").offsetWidth+"<br /> mainHeight: "+this.getElement("target").offsetHeight);
}
catch(e){
}
},stopObservingCorner:function(){
Event.stopObserving(document,"mousemove",this.boundCornerMoveListener);
Event.stopObserving(document,"mouseup",this.boundStopObservingCorner);
},getBoundsInPercentages:function(){
},getBoundsInPixel:function(){
},onComplete:function(_33){
$a("finishedAreaSelect",null,{},this.container);
if(this.getElement("loading")){
this.getElement("loading").style.display="none";
}
},submit:function(){
this.getApplication().service.user.storeProfileImage({imageId:this.parent.parameters.imageId,topPercentage:this.getElement("mainArea").offsetTop/this.getElement("target").offsetHeight,leftPercentage:this.getElement("mainArea").offsetLeft/this.getElement("target").offsetWidth,widthPercentage:this.getElement("mainArea").offsetWidth/this.getElement("target").offsetWidth,heightPercentage:this.getElement("mainArea").offsetHeight/this.getElement("target").offsetHeight},this.onComplete.bind(this));
this.getElement("mainArea").style.display="none";
if(this.getElement("loading")){
this.getElement("loading").style.width=this.getElement("target").offsetWidth+"px";
this.getElement("loading").style.height=this.getElement("target").offsetHeight+"px";
this.getElement("loading").style.display="block";
}
},handleBubbleAction:function(_34){
switch(_34.getType()){
case "dragMain":
_34.cancelBubble=true;
this.startDragMain(_34);
break;
case "scale":
_34.cancelBubble=true;
this.startScale(_34);
break;
case "submit":
_34.cancelBubble=true;
this.submit();
break;
}
}});
maptales.widgets["AreaSelect"]=AreaSelect;

var PanoViewer=Class.create();
Object.extend(Object.extend(PanoViewer.prototype,Widget.prototype),{initialize:function(_1,_2,_3,_4,_5,_6,_7){
if(!_6){
_6={};
}
this.container=_1;
this.id=_6.id||null;
this.currentSize=_6.currentSize||"large";
this.windowHeight=_6.windowHeight||300;
this.panInterval=_6.panInterval||100;
this.panningDetectorDistance=_6.panningDetectorDistance||20;
this.panningSpeed=_6.panningSpeed||10;
this.exponentialFactor=_6.exponentialFactor||1;
this.initializeWidget(_1,_2,_3,_4,"panoViewer/panoViewer",_6,_7);
this.display(null,null,this.centerImage.bind(this));
this.isPanning=false;
this.isDragging=false;
this.boundMouseMainMoveListener=this.mouseMainMoveListen.bind(this);
this.boundStopObservingMain=this.stopObservingMain.bind(this);
this.boundStartPanListener=this.startPan.bind(this);
this.boundEndPanListener=this.endPan.bind(this);
},onDisplay:function(){
Event.observe(this.getElement("clippingArea"),"mousemove",this.boundStartPanListener);
Event.observe(this.getElement("clippingArea"),"mouseout",this.boundEndPanListener);
},centerImage:function(){
this.getElement("panoImage").style.left=((this.getElement("clippingArea").offsetWidth/2)-(this.getElement("panoImage").offsetWidth/2))+"px";
this.getElement("panoImage").style.top=((this.getElement("clippingArea").offsetHeight/2)-(this.getElement("panoImage").offsetHeight/2))+"px";
},startDrag:function(_8){
this.isDragging=true;
Event.observe(document,"mousemove",this.boundMouseMainMoveListener);
Event.observe(document,"mouseup",this.boundStopObservingMain);
this.initialMouseX=parseInt(Event.pointerX(_8.event));
this.initialMouseY=parseInt(Event.pointerY(_8.event));
this.initialPanoY=this.getElement("panoImage").offsetTop;
this.initialPanoX=this.getElement("panoImage").offsetLeft;
},mouseMainMoveListen:function(_9){
var _a=Event.pointerX(_9)-this.initialMouseX;
var _b=Event.pointerY(_9)-this.initialMouseY;
var _c=this.initialPanoY+_b;
var _d=this.initialPanoX+_a;
this.getElement("panoImage").style.top=this.checkTopConstrain(_c)+"px";
this.getElement("panoImage").style.left=this.checkLeftConstrain(_d)+"px";
},startPan:function(_e){
if(this.isDragging==false){
this.panMousePositionX=Event.pointerX(_e);
this.panMousePositionY=Event.pointerY(_e);
if(this.isPanning==false){
this.isPanning=true;
this.panInterval=window.setInterval(this.pan.bind(this),this.panInterval);
}
}
},endPan:function(){
this.isPanning=false;
window.clearInterval(this.panInterval);
},pan:function(){
if(this.isDragging==false){
var _f=(this.panMousePositionX-this.container.offsetLeft);
var _10=(this.panMousePositionY-this.container.offsetTop);
var _11=(_f-parseInt(this.getElement("clippingArea").offsetWidth/2));
var _12=(_10-parseInt(this.getElement("clippingArea").offsetHeight/2));
this.getElement("debug").innerHTML=_11+" "+_12;
if(Math.abs(_12)>100){
var top=this.getElement("panoImage").offsetTop-_12/20;
this.getElement("panoImage").style.top=this.checkTopConstrain(top)+"px";
}
if(Math.abs(_11)>200){
var _14=this.getElement("panoImage").offsetLeft-_11/20;
this.getElement("panoImage").style.left=this.checkLeftConstrain(_14)+"px";
}
}
},stopObservingMain:function(){
Event.stopObserving(document,"mousemove",this.boundMouseMainMoveListener);
Event.stopObserving(document,"mouseup",this.boundStopObservingMain);
this.isDragging=false;
},checkTopConstrain:function(top){
if(top>0){
top=0;
}
if(this.getElement("panoImage").offsetHeight<this.getElement("clippingArea").offsetHeight){
top=(this.getElement("clippingArea")/2)-(this.getElement("panoImage").offsetHeight/2);
}
if(top<-(this.getElement("panoImage").offsetHeight-this.getElement("clippingArea").offsetHeight)){
top=-(this.getElement("panoImage").offsetHeight-this.getElement("clippingArea").offsetHeight);
}
return top;
},checkLeftConstrain:function(_16){
if(_16>0){
_16=0;
}
if(_16<-(this.getElement("panoImage").offsetWidth-this.getElement("clippingArea").offsetWidth)){
_16=-(this.getElement("panoImage").offsetWidth-this.getElement("clippingArea").offsetWidth);
}
return _16;
},zoomOut:function(){
this.xRatio=this.getElement("panoImage").offsetLeft/this.getElement("panoImage").offsetWidth;
this.yRatio=this.getElement("panoImage").offsetHeight/this.getElement("panoImage").offsetHeight;
this.getElement("panoImage").src="http://localhost:8080/maptales/images/db/large/-535051008.jpg";
var _17=this.xRatio*this.getElement("panoImage").offsetWidth;
var top=this.yRatio*this.getElement("panoImage").offsetHeight;
this.getElement("panoImage").style.left=this.checkLeftConstrain(_17)+"px";
this.getElement("panoImage").style.top=this.checkTopConstrain(top)+"px";
},zoomIn:function(){
this.xRatio=this.getElement("panoImage").offsetLeft/this.getElement("panoImage").offsetWidth;
this.yRatio=this.getElement("panoImage").offsetHeight/this.getElement("panoImage").offsetHeight;
this.getElement("panoImage").src="http://localhost:8080/maptales/images/db/large/gasthaus.jpg";
var _19=this.xRatio*this.getElement("panoImage").offsetWidth;
var top=this.yRatio*this.getElement("panoImage").offsetHeight;
this.getElement("panoImage").style.left=this.checkLeftConstrain(_19)+"px";
this.getElement("panoImage").style.top=this.checkTopConstrain(top)+"px";
},handleBubbleAction:function(_1b){
switch(_1b.getType()){
case "startPan":
_1b.cancelBubble=true;
this.startPan(_1b);
break;
case "endPan":
_1b.cancelBubble=true;
this.endPan(_1b);
break;
case "zoomIn":
_1b.cancelBubble=true;
this.zoomIn();
break;
case "zoomOut":
_1b.cancelBubble=true;
this.zoomOut();
break;
case "startDrag":
_1b.cancelBubble=true;
this.startDrag(_1b);
break;
}
}});
maptales.widgets["PanoViewer"]=PanoViewer;

var Updater=Class.create();
Object.extend(Object.extend(Updater.prototype,Widget.prototype),{logger:maptales.getLogger("com.maptales.webclient.widgets.updater"),initialize:function(_1,_2,_3,_4,_5,_6,_7){
if(_6.serviceFunction==null){
return;
}
this.container=_1;
this.initializeWidget(this.container,_2,null,null,null,_6,true);
this.useInnerHTML=false;
this.serviceFunction=_6.serviceFunction;
try{
var _8=parseInt(_6.interval);
}
catch(e){
}
this.intervalTime=_8||1000;
try{
try{
this.queryParameters=eval("("+_6.parameters+")");
}
catch(e){
this.queryParameters=null;
}
}
catch(e){
}
this.queryParameters.noCache=true;
this.templatePath=_5;
this.boundUpdate=this.update.bind(this);
this.interval=window.setInterval(this.boundUpdate,this.intervalTime);
},update:function(){
this.getApplication().service[this.serviceFunction](this.queryParameters,function(_9){
if(_9 instanceof SnapMapException){
this.logger.error("error in updater server call"+_9.getMessage());
}else{
this.display(this.templatePath,{reply:_9});
}
}.bind(this));
},stopUpdater:function(){
window.clearInterval(this.interval);
},destroy:function(){
this.stopUpdater();
this._destroy();
},handleBubbleAction:function(_a){
}});
maptales.widgets["Updater"]=Updater;

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 Video=Class.create("Video");
Video.prototype=new Media();
Object.extend(Video.prototype,{views:{item:{name:"Video",template:"objects/Video/item"},page:{name:"View",template:"objects/Media/page",menuItem:true}},defaultView:"page",Video_constructor:function(_1){
if(!_1){
_1={};
}
this.Media_constructor(_1);
this.addPersistentField("text",_1.text||"",Field.STRING,true);
this.addPersistentField("mediaLocation",_1.mediaLocation||"",Field.STRING,true);
this.addPersistentField("thumb1",_1.thumb1||"",Field.STRING,true);
this.addPersistentField("thumb2",_1.thumb2||"",Field.STRING,true);
this.addPersistentField("thumb3",_1.thumb3||"",Field.STRING,true);
this.addPersistentField("duration",_1.duration||"",Field.STRING,true);
},getMediaLocation:function(){
return this.get("mediaLocation");
}});

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", "http://reisenet.maptales.com/images/db/",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 Contact=Class.create("Contact");
Contact.prototype=new ContentObject();
Object.extend(Contact.prototype,{views:{overview:{name:"Content",template:"objects/Tag",menuItem:true},browse:{name:"Browse",template:"objects/Story_Browse",menuItem:true}},defaultView:"overview",Contact_constructor:function(_1){
if(!_1){
_1={};
}
this.ContentObject_constructor(_1);
this.addPersistentRef("owner",_1.owner,true,"User");
this.addPersistentField("tag",_1.tag,Field.STRING,true);
this.addPersistentRef("contact",_1.contact,false,"User");
},getId:function(){
return this.id;
},getTag:function(){
return this.get("tag");
},getContact:function(){
return $O(this.getRefId("contact"));
},getProfileIcon:function(){
return $O(this.getRefId("contact")).getProfileIcon();
},setContact:function(_2){
this.set("contact",_2);
},setOwner:function(_3){
this.set("owner",_3);
},isTransient:function(){
return true;
}});

var Map=Class.create("Map");
Map.prototype=new UserObject();
Object.extend(Map.prototype,{defaultView:"overview",views:{overview:{name:"Overview",template:"objects/Map/overview",menuItem:true},browse:{name:"Browse",template:"objects/Map/browse",menuItem:false},selectIcon:{name:"Select Icon",template:"objects/Map/SelectIcon",menuItem:false}},displayableObjects:{Media:"browse",Post:"browse",Picture:"browse"},Map_constructor:function(_1){
if(!_1){
_1={};
}
this.UserObject_constructor(_1);
this.addPersistentField("title",_1.title||null,Field.STRING,true);
this.addPersistentField("text",_1.text||null,Field.STRING,true);
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("group",_1.group,true,"Group","group");
this.addPersistentSlot("mapAdditions",_1.medias,false,"Media","dateAdded desc",null,"maps",(_1.group==null));
this.addPersistentRef("mainImage",_1.mainImage,false,null);
},getPath:function(){
return [{name:this.creatorName,type:"User",path:this.getRefId("creator")},{name:this.get("title"),type:this.getClassName(),path:this.get("id")}];
},addToSlot:function(_2,_3){
if(!(_3 instanceof Array)){
_3=[_3];
}
if(_2=="mapAdditions"){
this._addMapAdditions(_3);
}else{
this._addToSlot(_2,_3);
}
},removeFromSlot:function(_4,_5){
if(!(_5 instanceof Array)){
_5=[_5];
}
if(_4=="mapAdditions"){
this._removeMapAdditions(_5);
}else{
this._removeFromSlot(_4,_5);
}
},_removeMapAdditions:function(_6){
for(var e=0;e<_6.length;e++){
var _8=new MapAddition();
_8.setMap(this);
_8.setMedia(_6[e]);
_8.setAddedOn(new Date());
_8.setUsername(maptales.service.user.getCurrentUser().get("name"));
_8.set("id",this.id+"_"+_6[e]);
_8.id=this.id+"_"+_6[e];
maptales.cache.addToCache(_8);
this._removeFromSlot("mapAdditions",_8);
}
},_addMapAdditions:function(_9){
for(var e=0;e<_9.length;e++){
var _b=new MapAddition();
_b.setMap(this);
_b.setMedia(_9[e]);
_b.setAddedOn(new Date());
_b.setUsername(maptales.service.user.getCurrentUser().get("name"));
maptales.cache.addToCache(_b);
this._addToSlot("mapAdditions",_b);
}
},getIcon:function(){
if(this.getRefId("mainImage")!=null){
return this.getRefFromCache("mainImage").getSquareImageURL();
}else{
return null;
}
},currentUserIsModerator:function(){
if(this.getRefFromCache("group")==null){
return false;
}else{
return this.getRefFromCache("group").currentUserIsModerator();
}
}});

var Group=Class.create("Group");
Group.prototype=new ContentObject();
var GROUP_MEMBER=0;
var GROUP_MODERATOR=1;
var GROUP_ADMIN=2;
var NOT_GROUP_MEMBER=-1;
Object.extend(Group.prototype,{defaultView:"overview",views:{overview:{name:"Overview",template:"objects/Group/overview",menuItem:true},acceptAdditions:{name:"Accept Additions",template:"objects/Group/acceptAdditions",menuItem:false},administration:{name:"Administration",template:"objects/Group/administer",menuItem:true,requiredRights:["edit"]},invite:{name:"Invite",template:"objects/Group/invite",menuItem:true},groupMap:{name:"Group Map",template:"objects/Group/groupMap",menuItem:false},browse:{name:"Browse",template:"objects/Group/browse",menuItem:false}},displayableObjects:{Map:"groupMap",Media:"browse",Post:"browse",Picture:"browse"},Group_constructor:function(_1){
if(!_1){
_1={};
}
this.ContentObject_constructor(_1);
this.addPersistentField("name",_1.name||"",Field.STRING,true);
this.addPersistentField("description",_1.description||"",Field.STRING,true);
this.addPersistentField("hasModeratedAddition",_1.hasModeratedAddition,Field.BOOLEAN,true);
this.addPersistentField("isInviteOnly",_1.isInviteOnly,Field.BOOLEAN,true);
this.addPersistentField("isPrivate",_1.isPrivate,Field.BOOLEAN,true);
this.addPersistentField("extUrl",_1.extUrl,Field.STRING,true);
if(_1.roleOfLoggedInUser==null){
this.roleOfLoggedInUser=NOT_GROUP_MEMBER;
}else{
this.roleOfLoggedInUser=_1.roleOfLoggedInUser;
}
this.addPersistentRef("mainImage",_1.mainImage,false,null);
this.addPersistentSlot("members",_1.members,false,"User",null,null,"groups");
this.addPersistentSlot("moderators",_1.moderators,false,"User",null,null,"groups");
this.addPersistentSlot("admins",_1.admins,false,"User",null,null,"groups");
this.addPersistentSlot("pendingAdditions",_1.pendingAdditions,false,"GroupAddition",null,null,"group",false);
this.addPersistentSlot("maps",_1.maps,false,"Map","title asc",null,"group",false);
this.addPersistentSlot("tags",_1.tags,false,"Tag","tag asc",null,"group");
this.addPersistentSlot("posts",_1.posts,false,"GroupPost","creationDate desc",null,"group",false);
this.renderedRights=_1.renderedRights||{};
},checkRights:function(_2){
if(_2=="post"){
if(this.roleOfLoggedInUser==NOT_GROUP_MEMBER){
return false;
}else{
return true;
}
}else{
if(_2=="edit"){
if(this.roleOfLoggedInUser>=GROUP_MODERATOR){
return true;
}else{
return false;
}
}else{
if(_2=="setMemberRank"){
if(this.roleOfLoggedInUser>=GROUP_MODERATOR){
return true;
}else{
return false;
}
}else{
if(_2=="deleteUser"){
if(this.roleOfLoggedInUser>=GROUP_MODERATOR){
return true;
}else{
return false;
}
}else{
if(_2=="delete"){
if(this.roleOfLoggedInUser>=GROUP_ADMIN){
return true;
}else{
return false;
}
}else{
if(_2=="deletePost"){
if(this.roleOfLoggedInUser>=GROUP_MODERATOR){
return true;
}else{
return false;
}
}else{
if(_2=="tag"){
if(this.roleOfLoggedInUser>=GROUP_MODERATOR){
return true;
}else{
return false;
}
}
}
}
}
}
}
}
return false;
},currentUserIsModerator:function(){
if(this.roleOfLoggedInUser>=GROUP_MODERATOR){
return true;
}else{
return false;
}
},getPath:function(){
return [{name:this.get("name"),type:this.getClassName(),path:this.get("id")}];
},getIcon:function(){
if(this.getRefId("mainImage")!=null){
return this.getRefFromCache("mainImage").getSquareImageURL();
}else{
return maptales.templateFolder+"/css/images/group-48.gif";
}
}});

var MapAddition=Class.create("MapAddition");
MapAddition.prototype=new ContentObject();
Object.extend(MapAddition.prototype,{MapAddition_constructor:function(_1){
if(!_1){
_1={};
}
this.ContentObject_constructor(_1);
this.addPersistentRef("map",_1.map,true,"Map","mapAdditions");
this.addPersistentRef("media",_1.media,true,"Media","mapAdditions");
this.addPersistentField("username",_1.username,Field.STRING,true);
this.addPersistentField("dateAdded",_1.dateAdded||new Date(),Field.DATE,true);
if(_1.id){
this.addPersistentField("id",_1.id,Field.STRING,true);
this.id=_1.id;
}else{
var id=maptales.service.getAndIncrementTempId();
this.addPersistentField("id",id,Field.STRING,true);
this.id=id;
}
},setMedia:function(_3){
this.set("media",_3);
},getMedia:function(){
return this.get("media");
},setMap:function(_4){
this.set("map",_4);
},getMap:function(){
return this.get("map");
},setUsername:function(_5){
this.set("addedOn",_5);
},getUsername:function(){
return this.get("username");
},setAddedOn:function(_6){
this.set("addedOn",_6);
},getAddedOn:function(){
return this.get("addedOn");
}});

var GroupPost=Class.create("GroupPost");
GroupPost.prototype=new ContentObject();
Object.extend(GroupPost.prototype,{defaultView:"overview",views:{overview:{name:"Overview",template:"objects/GroupPost/post",menuItem:true}},GroupPost_constructor:function(_1){
if(!_1){
_1={};
}
this.ContentObject_constructor(_1);
this.addPersistentField("title",_1.title,Field.STRING,true);
this.addPersistentField("text",_1.text,Field.STRING,true);
this.addPersistentRef("creator",_1.creator,true,"User","groupPosts");
this.addPersistentRef("parentPost",_1.parentPost,true,"Post","posts");
this.addPersistentRef("group",_1.group,true,"Group","posts");
this.addPersistentSlot("replies",_1.replies,false,"GroupPost","creationDate desc",null,"group");
this.renderedRights=_1.renderedRights||{};
},checkRights:function(_2){
if(_2=="edit"){
if(this.getRefId("creator")==maptales.service.user.getCurrentUserId()){
return true;
}else{
return false;
}
}else{
if(_2=="delete"){
if(this.getRefId("creator")==maptales.service.user.getCurrentUserId()){
return true;
}else{
return false;
}
}
}
},getPath:function(){
return [{name:this.get("name"),type:this.getClassName(),path:this.get("id")}];
}});

var GroupAddition=Class.create("GroupAddition");
GroupAddition.prototype=new ContentObject();
Object.extend(GroupAddition.prototype,{GroupAddition_constructor:function(_1){
if(!_1){
_1={};
}
this.ContentObject_constructor(_1);
this.addPersistentRef("map",_1.map,true,"Map","mapAdditions");
this.addPersistentRef("media",_1.media,true,"Media","mapAdditions");
this.addPersistentRef("group",_1.group,true,"Group","groupAdditions");
if(_1.group){
if(_1.group instanceof ContentObject||(!isNaN(_1.group))){
var _2=$O(_1.group).id;
}else{
var _2=_1.group.id;
}
}
if(_1.media){
if(_1.media instanceof ContentObject||(!isNaN(_1.media))){
var _3=$O(_1.media).id;
}else{
var _3=_1.media.id;
}
}
if(_1.id){
this.addPersistentField("id",_1.id,Field.STRING,true);
this.id=_1.id;
}else{
var id=_2+"_"+_3;
this.addPersistentField("id",id,Field.STRING,true);
this.id=id;
}
},setMedia:function(_5){
this.set("media",_5);
},getMedia:function(){
return this.get("media");
},setMap:function(_6){
this.set("map",_6);
},getMap:function(){
return this.get("map");
}});

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 Cluster=Class.create("Cluster");
Cluster.prototype=new MapPoint();
Object.extend(Cluster.prototype,new GOverlay());
Object.extend(Cluster.prototype,{Cluster_constructor:function(_1){
if(!_1){
_1={};
}
this.MapPoint_constructor(_1,this);
var _2={size:_1.markersNum};
this.addPersistentSlot("markers",_2,true,"Marker");
this.quadLevel=_1.quadLevel;
this.addPersistentField("viewZoomLevel",_1.quadLevel,Field.NUMBER,true);
this.container.className="cluster";
this.boundsDiv=document.createElement("DIV");
this.boundsDiv.className="clusterBounds";
this.container.appendChild(this.boundsDiv);
this.container.onclick=this.zoomTo.bind(this);
this.container.onmouseover=this.onMouseOver.bindAsEventListener(this);
this.container.onmouseout=this.onMouseOut.bindAsEventListener(this);
},getBoundsDiv:function(){
return this.boundsDiv;
},initialize:function(_3){
this.map=_3;
this.map.getPane(G_MAP_MARKER_PANE).appendChild(this.container);
},remove:function(){
if(this.map.getPane(G_MAP_MARKER_PANE)&&this.container){
try{
this.map.getPane(G_MAP_MARKER_PANE).removeChild(this.container);
}
catch(e){
}
}
this.map=null;
},redraw:function(_4){
if(!_4){
return;
}
if(!this.map){
return;
}
var _5=this.map.fromLatLngToDivPixel(this.get("location"));
this.container.style.left=_5.x+"px";
this.container.style.top=_5.y+"px";
var _6=2;
var _7=this.map.getZoom()-this.quadLevel+7;
for(var i=0;i<_7;i++){
_6*=2;
}
this.boundsDiv.style.width=(_6-1)+"px";
this.boundsDiv.style.height=(_6-1)+"px";
this.boundsDiv.style.marginTop=(-_6/2-1)+"px";
this.boundsDiv.style.marginLeft=(-_6/2-1)+"px";
if(this.quadLevel-this.map.getZoom()<=4){
var _9=this.getSlotLength("markers");
if(_9<1000){
this.boundsDiv.innerHTML=_9+"";
}else{
if(_9<100000){
this.boundsDiv.innerHTML=Math.round(_9/1000)+"K";
}else{
if(_9<10000000){
this.boundsDiv.innerHTML=(Math.round(_9/100000)/10)+"M";
}else{
this.boundsDiv.innerHTML=Math.round(_9/1000000)+"M";
}
}
}
}else{
this.boundsDiv.innerHTML="";
}
this.container.style.zIndex=GOverlay.getZIndex(90);
},isLoaded:function(){
if(this.isSlotInCache("medias",0,-1,null,null)){
return true;
}else{
return false;
}
},zoomTo:function(){
if(this.mapPane){
this.mapPane.setCenter(this.get("location"),this.quadLevel-1);
}
},onMouseDown:function(_a){
if(this.mapPane){
this.mapPane.hideMarkerInfo();
}
},onMouseOver:function(_b){
if(this.mapPane){
this.mapPane.displayMarkerInfo(this);
}
},onMouseOut:function(_c){
if(this.mapPane){
this.mapPane.hideMarkerInfo();
}
}});

var Snapshot=Class.create("Snapshot");
Snapshot.prototype=new UserObject();
Object.extend(Snapshot.prototype,{Snapshot_constructor:function(_1){
if(!_1){
_1={};
}
this.ContentObject_constructor(_1);
this.addPersistentField("title",_1.title||"",Field.STRING,true);
this.addPersistentField("text",_1.text||"",Field.STRING,true);
this.addPersistentField("zoomLevel",_1.zoomLevel||"",Field.NUMBER,true);
this.addPersistentField("timestamp",_1.timestamp,Field.NUMBER,true);
this.addPersistentField("center",_1.center,Field.POINT,true);
this.addPersistentField("mapMode",_1.mapMode||Map.HYBRID_MODE,Field.NUMBER,true);
this.addPersistentRef("creator",_1.creator,true,"User");
},initialize:function(_2){
this.map=_2;
},remove:function(){
},redraw:function(_3){
},snap:function(_4,_5){
return false;
},clip:function(_6){
if(!_6){
return true;
}
return _6.contains(this.get("center"));
}});

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));
}});

var RectangleArea=Class.create("RectangleArea");
RectangleArea.prototype=new MapPoint();
Object.extend(RectangleArea.prototype,{RectangleArea_constructor:function(_1,_2){
this.MapPoint_constructor({location:_1},this);
this.container.className="marker";
this.container.bubbleAction=this.handleBubbleAction.bind(this);
this.zoomLevel=_2||null;
this.center=_1||null;
this.areaDiv=document.createElement("DIV");
this.areaDiv.className="mapArea";
this.container.appendChild(this.areaDiv);
},handleBubbleAction:function(_3){
},initialize:function(_4){
this.map=_4;
this.map.getPane(G_MAP_MARKER_PANE).appendChild(this.container);
},remove:function(){
if(this.map.getPane(G_MAP_MARKER_PANE)&&this.container){
try{
this.map.getPane(G_MAP_MARKER_PANE).removeChild(this.container);
}
catch(e){
}
}
},redraw:function(_5){
if(!_5){
return;
}
var _6=this.map.fromLatLngToDivPixel(this.center);
this.container.style.left=_6.x+"px";
this.container.style.top=_6.y+"px";
var _7=this.map.getZoom();
var _8=this.map.getSize().width;
var _9=this.map.getSize().height;
var _a=this.zoomLevel-_7;
if(_a>0){
var _b=_8/Math.pow(2,_a);
var _c=_9/Math.pow(2,_a);
}else{
this.areaDiv.style.display="none";
}
this.areaDiv.style.position="absolute";
this.areaDiv.style.width=_b+"px";
this.areaDiv.style.height=_c+"px";
this.areaDiv.style.top=-_c/2+"px";
this.areaDiv.style.left=-_b/2+"px";
}});

var com={};
com.snapmap={};
com.snapmap.Color=Class.create();
com.snapmap.Color.prototype={initialize:function(_1,_2,_3){
this.rgb={r:_1,g:_2,b:_3};
},setRed:function(r){
this.rgb.r=r;
},setGreen:function(g){
this.rgb.g=g;
},setBlue:function(b){
this.rgb.b=b;
},setHue:function(h){
var _8=this.asHSB();
_8.h=h;
this.rgb=com.snapmap.Color.HSBtoRGB(_8.h,_8.s,_8.b);
},setSaturation:function(s){
var _a=this.asHSB();
_a.s=s;
this.rgb=com.snapmap.Color.HSBtoRGB(_a.h,_a.s,_a.b);
},setBrightness:function(b){
var _c=this.asHSB();
_c.b=b;
this.rgb=com.snapmap.Color.HSBtoRGB(_c.h,_c.s,_c.b);
},darken:function(_d){
var _e=this.asHSB();
this.rgb=com.snapmap.Color.HSBtoRGB(_e.h,_e.s,Math.max(_e.b-_d,0));
},brighten:function(_f){
var hsb=this.asHSB();
this.rgb=com.snapmap.Color.HSBtoRGB(hsb.h,hsb.s,Math.min(hsb.b+_f,1));
},blend:function(_11){
this.rgb.r=Math.floor((this.rgb.r+_11.rgb.r)/2);
this.rgb.g=Math.floor((this.rgb.g+_11.rgb.g)/2);
this.rgb.b=Math.floor((this.rgb.b+_11.rgb.b)/2);
},blendTo:function(_12,_13){
if(_13==null){
_13=2;
}
this.rgb.r+=Math.floor((_12.rgb.r-this.rgb.r)/_13);
this.rgb.g+=Math.floor((_12.rgb.g-this.rgb.g)/_13);
this.rgb.b+=Math.floor((_12.rgb.b-this.rgb.b)/_13);
},isBright:function(){
var hsb=this.asHSB();
return this.asHSB().b>0.5;
},isDark:function(){
return !this.isBright();
},asRGB:function(){
return "rgb("+this.rgb.r+","+this.rgb.g+","+this.rgb.b+")";
},asHex:function(){
return "#"+this.rgb.r.toColorPart()+this.rgb.g.toColorPart()+this.rgb.b.toColorPart();
},asHSB:function(){
return com.snapmap.Color.RGBtoHSB(this.rgb.r,this.rgb.g,this.rgb.b);
},toString:function(){
return this.asHex();
}};
com.snapmap.Color.createFromHex=function(_15){
if(_15.length==4){
var _16=_15;
var _15="#";
for(var i=1;i<4;i++){
_15+=(_16.charAt(i)+_16.charAt(i));
}
}
if(_15.indexOf("#")==0){
_15=_15.substring(1);
}
var red=_15.substring(0,2);
var _19=_15.substring(2,4);
var _1a=_15.substring(4,6);
return new com.snapmap.Color(parseInt(red,16),parseInt(_19,16),parseInt(_1a,16));
};
com.snapmap.Color.createColorFromBackground=function(_1b){
var _1c=RicoUtil.getElementsComputedStyle($(_1b),"backgroundColor","background-color");
if(_1c=="transparent"&&_1b.parentNode){
return com.snapmap.Color.createColorFromBackground(_1b.parentNode);
}
if(_1c==null){
return new com.snapmap.Color(255,255,255);
}
if(_1c.indexOf("rgb(")==0){
var _1d=_1c.substring(4,_1c.length-1);
var _1e=_1d.split(",");
return new com.snapmap.Color(parseInt(_1e[0]),parseInt(_1e[1]),parseInt(_1e[2]));
}else{
if(_1c.indexOf("#")==0){
return com.snapmap.Color.createFromHex(_1c);
}else{
return new com.snapmap.Color(255,255,255);
}
}
};
com.snapmap.Color.HSBtoRGB=function(hue,_20,_21){
var red=0;
var _23=0;
var _24=0;
if(_20==0){
red=parseInt(_21*255+0.5);
_23=red;
_24=red;
}else{
var h=(hue-Math.floor(hue))*6;
var f=h-Math.floor(h);
var p=_21*(1-_20);
var q=_21*(1-_20*f);
var t=_21*(1-(_20*(1-f)));
switch(parseInt(h)){
case 0:
red=(_21*255+0.5);
_23=(t*255+0.5);
_24=(p*255+0.5);
break;
case 1:
red=(q*255+0.5);
_23=(_21*255+0.5);
_24=(p*255+0.5);
break;
case 2:
red=(p*255+0.5);
_23=(_21*255+0.5);
_24=(t*255+0.5);
break;
case 3:
red=(p*255+0.5);
_23=(q*255+0.5);
_24=(_21*255+0.5);
break;
case 4:
red=(t*255+0.5);
_23=(p*255+0.5);
_24=(_21*255+0.5);
break;
case 5:
red=(_21*255+0.5);
_23=(p*255+0.5);
_24=(q*255+0.5);
break;
}
}
return {r:parseInt(red),g:parseInt(_23),b:parseInt(_24)};
};
com.snapmap.Color.RGBtoHSB=function(r,g,b){
var hue;
var _2e;
var _2f;
var _30=(r>g)?r:g;
if(b>_30){
_30=b;
}
var _31=(r<g)?r:g;
if(b<_31){
_31=b;
}
_2f=_30/255;
if(_30!=0){
_2e=(_30-_31)/_30;
}else{
_2e=0;
}
if(_2e==0){
hue=0;
}else{
var _32=(_30-r)/(_30-_31);
var _33=(_30-g)/(_30-_31);
var _34=(_30-b)/(_30-_31);
if(r==_30){
hue=_34-_33;
}else{
if(g==_30){
hue=2+_32-_34;
}else{
hue=4+_33-_32;
}
}
hue=hue/6;
if(hue<0){
hue=hue+1;
}
}
return {h:hue,s:_2e,b:_2f};
};

if(!maptales){
var maptales={};
}
if(!maptales.service){
maptales.service={};
}
if(!maptales.service.tip){
maptales.service.tip={};
}
maptales.service.tip.tips=[{title:"Welcome to Maptales!",text:"<p>To add content on Maptales "+"you can use the menu items in the \"Inbox\" tab. "+"Once you have items in your inbox, you can place them on the map "+"by dragging them onto the desired location.</p>"+"<p style='border:1px solid #c9c9c9; padding: 4px; background-color:#ffffff;'>"+"<strong>Note to beta testers:</strong><br>"+"Thank you for helping us improve the Maptales platform - feel free to experiment! "+"If you find a bug or have a question, please email to <a href='mailto:contact@maptales.com'>contact@maptales.com</a>. If you "+"don't have any relevant content for now and you use dummy content to try out the application, "+"please remove it again after your testing sessions. Have fun!</p>",pointcut:{obj:Widget,fname:"initWidgetContainer"},advice:function(f,_2){
var _3=_2[0];
var _4=_2[1];
if(_3.hasAttribute("import-template")){
var _5=_3.getAttribute("import-template");
}else{
var _5=_4.templatePath;
}
if(_5=="tabSystem/mediasMenu"){
Dialog.toggle(this.title,maptales.ui,"tip","dialog/TipOfTheDay",this,document.getElementById("inboxLabel"),Dialog.NORTH);
maptales.ui.disableTip(this);
}
}},{title:"Tip: Place content on the map",text:"You can place content from your inbox on the map by dragging its icon onto the map area. If you "+"want to delete an item, just drag it to the recycle bin in the bottom right corner.",pointcut:{obj:SlotWidget.prototype,fname:"displaySlot"},advice:function(f,_7,_8,_9){
if(_9.fieldName=="medias"&&_9.listItems.length>0){
this.focusEl=_9.container.childNodes[0].childNodes[1].childNodes[1];
if(this.focusEl){
window.setTimeout(this.show.bind(this),1000);
}
}
},show:function(){
Dialog.toggle(this.title,maptales.ui,"dialog/TipOfTheDay",this,this.focusEl,Dialog.NORTH);
maptales.ui.disableTip(this);
}},{title:"Tip: Manipulate markers",text:"You can drag your markers around to change their location on the map. "+"When you hover the mouse over one of your markers, the buttons "+"that appear allow you to manipulate the marker:"+"<table><tr><td valign='middle'><img src='/styles/default/css/images/mapitems/crosshairs.gif'/></td><td>Zoom in to the item's location.</td></tr>"+"<tr><td valign='middle'><img src='/styles/default/css/images/mapitems/line.gif'/></td><td>Drag this button to create a new route.</td></tr>"+"<tr><td valign='middle'><img src='/styles/default/css/images/mapitems/delete.gif'/></td><td>Delete the marker from the map.</td></tr></table>",pointcut:{obj:Map.prototype,fname:"doDrop"},advice:function(f,_b,_c,_d){
this.focusEl=maptales.ui.getMainMap().slotOverlays[0].imageDiv;
window.setTimeout(this.show.bind(this),1000);
},show:function(){
Dialog.toggle(this.title,maptales.ui,"dialog/TipOfTheDay",this,this.focusEl,Dialog.SOUTH);
maptales.ui.disableTip(this);
}}];

