var $j=jQuery.noConflict();if(!window.APP_SETTINGS)var APP_SETTINGS={};try{APP_SETTINGS.DOMAIN=document.domain=window.location.hostname.replace(/.*\.(.+\..+)$/,'$1');}catch(e){if(console&&console.warn)console.warn(e.message);}
(function(){if(!window.console||!console.firebug){var names=["log","debug","info","warn","error","assert","dir","dirxml","group","groupEnd","time","timeEnd","count","trace","profile","profileEnd","notifyFirebug"];window.console={};for(var i=0;i<names.length;++i){window.console[names[i]]=function(){};}}})();var callableType=function(constructor){return function(){var callableInstance=function(){var args=[];for(var i=0;i<arguments.length;i++){args[i]=arguments[i];}
args.unshift($j(this));return callableInstance.__call__.apply(callableInstance,args);};constructor.apply(callableInstance,arguments);return callableInstance;};};var extend=function(self,parents){var l=parents.length,i=0;for(i;i<l;i++){var parent=parents[i];var __constr__=self.prototype.__init__;var __super__=function(self,parent){return function(){parent.prototype.__init__.apply(this,arguments);__constr__.apply(this,arguments);};};self.prototype.__init__=__super__(self,parent);for(var m in parent.prototype){if(m!="__init__"){self.prototype[m]=parent.prototype[m];}}}};var __makeDispatchable=function(singleton){singleton._dispatcher=new ls.EventDispatcher();singleton.addEventListener=function(event,callback,weight){this._dispatcher.addEventListener(event,callback,weight);};singleton.addEventOnce=function(event,callback,weight){this._dispatcher.addEventOnce(event,callback,weight);};singleton.removeEventListener=function(event){this._dispatcher.removeEventListener(event);};singleton.dispatchEvent=function(event){this._dispatcher.dispatchEvent(event);};};var cp=function(from,base){var obj=typeof base=="object"?base:{};for(var k in from){obj[k]=from[k];}
return obj;};var isArray=function(value){return value&&typeof value==="object"&&typeof value.length==="number"&&typeof value.splice==="function"&&!(value.propertyIsEnumerable("length"));};Array.prototype.contains=function(value){for(var i=0;i<this.length;i++){if(this[i]===value){return true;}}
return false;};Array.prototype.index=function(value){for(var i=0;i<this.length;i++){if(this[i]===value){return i;}}
return null;};Array.prototype.groupBy=function(k,i){var key=k||null;var indexed=i||false;if(!key)return this;var a=[];var b=indexed?{}:[];for(var i=0;i<this.length;i++){var v=this[i][k];if(!a.contains(v)){a.push(v);if(indexed){b[v]=[];}else{b.push([]);}}
if(indexed){b[v].push(this[i]);}else{var j=a.index(v);b[j].push(this[i]);}}
return b;};Array.prototype.orderBy=function(k,o){var key=k||null;var order=(o&&["asc","desc"].contains(o))?o:"asc";if(!key)return this;this.sort(function(a,b){var ak=a[key];var bk=b[key];if(!ak||!bk)return 0;if(ak==bk)return 0;return(ak>bk)?1:-1;});if(order=="desc")return this.reverse();return this;};String.prototype.trim=function(chars){var res=this.toString().replace(/^\s+|\s+$/g,"");if(chars){if(typeof chars=="string"){var re=new RegExp(chars,"g");res=res.replace(re,"");}else if(isArray(chars)){var regStr="";for(var i=0;i<chars.length;i++){regStr+=chars[i];if(i<chars.length-1)regStr+="|";}
regStr=ls.LovelyUtils.compileString("[${args}]",{"args":regStr});var re=new RegExp(regStr,"g");res=res.replace(re,"");}else if(typeof chars=="number"){var max=parseInt(chars,10);if(max<=res.length)max=res.length;res=res.substr(0,max);}}
return res;};String.prototype.unicode=function(prefix){var prefix=prefix||"\\u00";var res=this.toString();for(var i=128;i<256;i++){var charx=String.fromCharCode(i);var re=new RegExp(charx,"ig");res=res.replace(re,escape(charx).replace("%",prefix));}
return res;};String.prototype.normalize=function(){var res=this.toString().toLowerCase();var repl=[[String.fromCharCode(228),"ae"],[String.fromCharCode(246),"oe"],[String.fromCharCode(252),"ue"],[String.fromCharCode(223),"ss"],[String.fromCharCode(38),"und"]];res=res.replace(/^\s+|\s+$/g,"");for(var i=0;i<repl.length;i++){var re=new RegExp(repl[i][0],"ig");res=res.replace(re,repl[i][1]);}
res=res.replace(/[\+\.,;\\\/?!\^§$%\(\)]+/g," ");res=res.replace(/\s+/g,"-");res=res.replace(/[#\*'`´"“”˜·¯˙˚]+/g,"");return res;};String.prototype.noUmlNormalize=function(){var res=this.toString().toLowerCase();res=res.replace(/^\s+|\s+$/g,"");res=res.replace(/[\+\.,;\\\/?!\^§$%\(\)]+/g," ");res=res.replace(/\s+/g,"-");res=res.replace(/[#\*'`´"“”˜·¯˙˚]+/g,"");return res;};var com={};com.lovelysystems={VERSION:"0.1rc1",AUTHOR:"Lovely Systems AG",load:function(lib,callback,hash){var js="com.lovelysystems."+lib+".js";if(hash)js+="?hash="+hash;var e=new Error();var m=e.fileName.split("/");var url=e.fileName.replace(m[m.length-1],js);var start=new Date().getTime();var h=document.getElementsByTagName("head")[0];var k=document.createElement("script");k.setAttribute("type","application/x-javascript");k.setAttribute("language","javascript");k.setAttribute("charset","UTF-8");k.setAttribute("src",url);k.onload=callback||function(){var end=new Date().getTime();var d=end-start;console.info(url+" loaded in "+d+"ms");};h.appendChild(k);},Application:{CSS_CLASS:'appCmd',NAMESPACE:'ajax',ATTR:'attr',CMD:'command',context:null,commands:{},toString:function(){return"<com.lovelysystems.Application "+com.lovelysystems.VERSION+">";},execute:function(context){this.context=context||document;var elements=$j("."+this.CSS_CLASS,this.context);var len=elements.length;for(var i=0;i<len;i++){var elem=elements[i];var ajax_attr=this.getCommandAttrs(elem);var native_attr=this.getNativeAttrs(elem);var nsCmd=this.NAMESPACE+':'+this.CMD;var cmd=elem.getAttribute(nsCmd);if(cmd){if(typeof this.commands[cmd]==="function"){this.commands[cmd].call(this.commands[cmd],cmd,elem,ajax_attr,native_attr);}else{console.warn(cmd+" is not a valid function");}}}},getCommandAttrs:function(elem){var nsAttr=this.NAMESPACE+':'+this.ATTR;var plist=elem.getAttribute(nsAttr);plist=plist?plist.trim().split(";"):[];var attrs={};for(var j=0;j<plist.length;j++){var q=plist[j].trim();if(q){var p=q.split("=");var key=p[0].trim();attrs[key]=eval(p[1]);}}
return attrs;},getNativeAttrs:function(elem){var native_attr={};for(var k=0;k<elem.attributes.length;k++){var a=elem.attributes[k];if(a.nodeName.indexOf(this.NAMESPACE)==-1){native_attr[a.nodeName]=a.nodeValue;}}
return native_attr;},registerCommand:function(cmd,callback){this.commands[cmd]=callback;},removeCommand:function(cmd){if(this.commands[cmd]){this.commands[cmd]=null;delete this.commands[cmd];}},setBodyClass:function(){var body=document.getElementsByTagName('body')[0];if(isIE6)body.className="ie6";if(isIE7)body.className="ie7";if(isIE8)body.className="ie8";if(isFF)body.className="ff";if(isSF)body.className="safari";},registry:{add:function(key,obj){if(this.datastore[key]){this.datastore[key].push(obj);}else{this.datastore[key]=[obj];}
return obj;},get:function(key){var res=this.datastore[key]||[];return res;},datastore:{}}}};;(function($){$.fn.ajaxSubmit=function(options){if(!this.length){log('ajaxSubmit: skipping submit process - no element selected');return this;}
if(typeof options=='function')
options={success:options};options=$.extend({url:this.attr('action')||window.location.toString(),type:this.attr('method')||'GET'},options||{});var veto={};this.trigger('form-pre-serialize',[this,options,veto]);if(veto.veto){log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');return this;}
if(options.beforeSerialize&&options.beforeSerialize(this,options)===false){log('ajaxSubmit: submit aborted via beforeSerialize callback');return this;}
var a=this.formToArray(options.semantic);if(options.data){options.extraData=options.data;for(var n in options.data){if(options.data[n]instanceof Array){for(var k in options.data[n])
a.push({name:n,value:options.data[n][k]})}
else
a.push({name:n,value:options.data[n]});}}
if(options.beforeSubmit&&options.beforeSubmit(a,this,options)===false){log('ajaxSubmit: submit aborted via beforeSubmit callback');return this;}
this.trigger('form-submit-validate',[a,this,options,veto]);if(veto.veto){log('ajaxSubmit: submit vetoed via form-submit-validate trigger');return this;}
var q=$.param(a);if(options.type.toUpperCase()=='GET'){options.url+=(options.url.indexOf('?')>=0?'&':'?')+q;options.data=null;}
else
options.data=q;var $form=this,callbacks=[];if(options.resetForm)callbacks.push(function(){$form.resetForm();});if(options.clearForm)callbacks.push(function(){$form.clearForm();});if(!options.dataType&&options.target){var oldSuccess=options.success||function(){};callbacks.push(function(data){$(options.target).html(data).each(oldSuccess,arguments);});}
else if(options.success)
callbacks.push(options.success);options.success=function(data,status){for(var i=0,max=callbacks.length;i<max;i++)
callbacks[i].apply(options,[data,status,$form]);};var files=$('input:file',this).fieldValue();var found=false;for(var j=0;j<files.length;j++)
if(files[j])
found=true;if(options.iframe||found){if($.browser.safari&&options.closeKeepAlive)
$.get(options.closeKeepAlive,fileUpload);else
fileUpload();}
else
$.ajax(options);this.trigger('form-submit-notify',[this,options]);return this;function fileUpload(){var form=$form[0];if($(':input[name=submit]',form).length){alert('Error: Form elements must not be named "submit".');return;}
var opts=$.extend({},$.ajaxSettings,options);var s=jQuery.extend(true,{},$.extend(true,{},$.ajaxSettings),opts);var id='jqFormIO'+(new Date().getTime());var $io=$('<iframe id="'+id+'" name="'+id+'" />');var io=$io[0];if($.browser.msie||$.browser.opera)
io.src='javascript:false;document.write("");';$io.css({position:'absolute',top:'-1000px',left:'-1000px'});var xhr={aborted:0,responseText:null,responseXML:null,status:0,statusText:'n/a',getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(){this.aborted=1;$io.attr('src','about:blank');}};var g=opts.global;if(g&&!$.active++)$.event.trigger("ajaxStart");if(g)$.event.trigger("ajaxSend",[xhr,opts]);if(s.beforeSend&&s.beforeSend(xhr,s)===false){s.global&&jQuery.active--;return;}
if(xhr.aborted)
return;var cbInvoked=0;var timedOut=0;var sub=form.clk;if(sub){var n=sub.name;if(n&&!sub.disabled){options.extraData=options.extraData||{};options.extraData[n]=sub.value;if(sub.type=="image"){options.extraData[name+'.x']=form.clk_x;options.extraData[name+'.y']=form.clk_y;}}}
setTimeout(function(){var t=$form.attr('target'),a=$form.attr('action');$form.attr({target:id,method:'POST',action:opts.url});if(!options.skipEncodingOverride){$form.attr({encoding:'multipart/form-data',enctype:'multipart/form-data'});}
if(opts.timeout)
setTimeout(function(){timedOut=true;cb();},opts.timeout);var extraInputs=[];try{if(options.extraData)
for(var n in options.extraData)
extraInputs.push($('<input type="hidden" name="'+n+'" value="'+options.extraData[n]+'" />').appendTo(form)[0]);$io.appendTo('body');io.attachEvent?io.attachEvent('onload',cb):io.addEventListener('load',cb,false);form.submit();}
finally{$form.attr('action',a);t?$form.attr('target',t):$form.removeAttr('target');$(extraInputs).remove();}},10);function cb(){if(cbInvoked++)return;io.detachEvent?io.detachEvent('onload',cb):io.removeEventListener('load',cb,false);var operaHack=0;var ok=true;try{if(timedOut)throw'timeout';var data,doc;doc=io.contentWindow?io.contentWindow.document:io.contentDocument?io.contentDocument:io.document;if(doc.body==null&&!operaHack&&$.browser.opera){operaHack=1;cbInvoked--;setTimeout(cb,100);return;}
xhr.responseText=doc.body?doc.body.innerHTML:null;xhr.responseXML=doc.XMLDocument?doc.XMLDocument:doc;xhr.getResponseHeader=function(header){var headers={'content-type':opts.dataType};return headers[header];};if(opts.dataType=='json'||opts.dataType=='script'){var ta=doc.getElementsByTagName('textarea')[0];xhr.responseText=ta?ta.value:xhr.responseText;}
else if(opts.dataType=='xml'&&!xhr.responseXML&&xhr.responseText!=null){xhr.responseXML=toXml(xhr.responseText);}
data=$.httpData(xhr,opts.dataType);}
catch(e){ok=false;$.handleError(opts,xhr,'error',e);}
if(ok){opts.success(data,'success');if(g)$.event.trigger("ajaxSuccess",[xhr,opts]);}
if(g)$.event.trigger("ajaxComplete",[xhr,opts]);if(g&&!--$.active)$.event.trigger("ajaxStop");if(opts.complete)opts.complete(xhr,ok?'success':'error');setTimeout(function(){$io.remove();xhr.responseXML=null;},100);};function toXml(s,doc){if(window.ActiveXObject){doc=new ActiveXObject('Microsoft.XMLDOM');doc.async='false';doc.loadXML(s);}
else
doc=(new DOMParser()).parseFromString(s,'text/xml');return(doc&&doc.documentElement&&doc.documentElement.tagName!='parsererror')?doc:null;};};};$.fn.ajaxForm=function(options){return this.ajaxFormUnbind().bind('submit.form-plugin',function(){$(this).ajaxSubmit(options);return false;}).each(function(){$(":submit,input:image",this).bind('click.form-plugin',function(e){var form=this.form;form.clk=this;if(this.type=='image'){if(e.offsetX!=undefined){form.clk_x=e.offsetX;form.clk_y=e.offsetY;}else if(typeof $.fn.offset=='function'){var offset=$(this).offset();form.clk_x=e.pageX-offset.left;form.clk_y=e.pageY-offset.top;}else{form.clk_x=e.pageX-this.offsetLeft;form.clk_y=e.pageY-this.offsetTop;}}
setTimeout(function(){form.clk=form.clk_x=form.clk_y=null;},10);});});};$.fn.ajaxFormUnbind=function(){this.unbind('submit.form-plugin');return this.each(function(){$(":submit,input:image",this).unbind('click.form-plugin');});};$.fn.formToArray=function(semantic,forceemptystring){var a=[];if(this.length==0)return a;var form=this[0];var els=semantic?form.getElementsByTagName('*'):form.elements;if(!els)return a;for(var i=0,max=els.length;i<max;i++){var el=els[i];var n=el.name;if(!n)continue;if(semantic&&form.clk&&el.type=="image"){if(!el.disabled&&form.clk==el)
a.push({name:n+'.x',value:form.clk_x},{name:n+'.y',value:form.clk_y});continue;}
var v=$.fieldValue(el,true,forceemptystring);if(v&&v.constructor==Array){for(var j=0,jmax=v.length;j<jmax;j++)
a.push({name:n,value:v[j]});}
else if(v!==null&&typeof v!='undefined')
a.push({name:n,value:v});}
if(!semantic&&form.clk){var inputs=form.getElementsByTagName("input");for(var i=0,max=inputs.length;i<max;i++){var input=inputs[i];var n=input.name;if(n&&!input.disabled&&input.type=="image"&&form.clk==input)
a.push({name:n+'.x',value:form.clk_x},{name:n+'.y',value:form.clk_y});}}
return a;};$.fn.formSerialize=function(semantic,forceemptystring){return $.param(this.formToArray(semantic,forceemptystring));};$.fn.fieldSerialize=function(successful){var a=[];this.each(function(){var n=this.name;if(!n)return;var v=$.fieldValue(this,successful);if(v&&v.constructor==Array){for(var i=0,max=v.length;i<max;i++)
a.push({name:n,value:v[i]});}
else if(v!==null&&typeof v!='undefined')
a.push({name:this.name,value:v});});return $.param(a);};$.fn.fieldValue=function(successful){for(var val=[],i=0,max=this.length;i<max;i++){var el=this[i];var v=$.fieldValue(el,successful);if(v===null||typeof v=='undefined'||(v.constructor==Array&&!v.length))
continue;v.constructor==Array?$.merge(val,v):val.push(v);}
return val;};$.fieldValue=function(el,successful,forceemptystring){var n=el.name,t=el.type,tag=el.tagName.toLowerCase();if(typeof successful=='undefined')successful=true;if(successful&&t=='checkbox'&&!el.checked)
return false;if(successful&&!forceemptystring&&t=='text'&&el.value==='')
return null;if(successful&&(!n||el.disabled||t=='reset'||t=='button'||(t=='checkbox'||t=='radio')&&!el.checked||(t=='submit'||t=='image')&&el.form&&el.form.clk!=el||tag=='select'&&el.selectedIndex==-1))
return null;if(tag=='select'){var index=el.selectedIndex;if(index<0)return null;var a=[],ops=el.options;var one=(t=='select-one');var max=(one?index+1:ops.length);for(var i=(one?index:0);i<max;i++){var op=ops[i];if(op.selected){var v=$.browser.msie&&!(op.attributes['value'].specified)?op.text:op.value;if(one)return v;a.push(v);}}
return a;}
return el.value;};$.fn.clearForm=function(){return this.each(function(){$('input,select,textarea',this).clearFields();});};$.fn.clearFields=$.fn.clearInputs=function(){return this.each(function(){var t=this.type,tag=this.tagName.toLowerCase();if(t=='text'||t=='password'||tag=='textarea')
this.value='';else if(t=='checkbox'||t=='radio')
this.checked=false;else if(tag=='select')
this.selectedIndex=-1;});};$.fn.resetForm=function(){return this.each(function(){if(typeof this.reset=='function'||(typeof this.reset=='object'&&!this.reset.nodeType))
this.reset();});};$.fn.enable=function(b){if(b==undefined)b=true;return this.each(function(){this.disabled=!b});};$.fn.selected=function(select){if(select==undefined)select=true;return this.each(function(){var t=this.type;if(t=='checkbox'||t=='radio')
this.checked=select;else if(this.tagName.toLowerCase()=='option'){var $sel=$(this).parent('select');if(select&&$sel[0]&&$sel[0].type=='select-one'){$sel.find('option').selected(false);}
this.selected=select;}});};function log(){if($.fn.ajaxSubmit.debug&&window.console&&window.console.log)
window.console.log('[jquery.form] '+Array.prototype.join.call(arguments,''));};})(jQuery);if(!this.JSON2){JSON2={};}
(function(){function f(n){return n<10?'0'+n:n;}
if(typeof Date.prototype.toJSON2!=='function'){Date.prototype.toJSON2=function(key){return this.getUTCFullYear()+'-'+
f(this.getUTCMonth()+1)+'-'+
f(this.getUTCDate())+'T'+
f(this.getUTCHours())+':'+
f(this.getUTCMinutes())+':'+
f(this.getUTCSeconds())+'Z';};String.prototype.toJSON2=Number.prototype.toJSON2=Boolean.prototype.toJSON2=function(key){return this.valueOf();};}
var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapeable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapeable.lastIndex=0;return escapeable.test(string)?'"'+string.replace(escapeable,function(a){var c=meta[a];if(typeof c==='string'){return c;}
return'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}
function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON2==='function'){value=value.toJSON2(key);}
if(typeof rep==='function'){value=rep.call(holder,key,value);}
switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
gap+=indent;partial=[];if(typeof value.length==='number'&&!value.propertyIsEnumerable('length')){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}
v=partial.length===0?'[]':gap?'[\n'+gap+
partial.join(',\n'+gap)+'\n'+
mind+']':'['+partial.join(',')+']';gap=mind;return v;}
if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}
v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+
mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}
if(typeof JSON2.stringify!=='function'){JSON2.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}
rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON2.stringify');}
return str('',{'':value});};}
if(typeof JSON2.parse!=='function'){JSON2.parse=function(text,reviver){if(!reviver){var reviver=function(key,value){var a;if(key==="__jsonclass__"&&typeof value==="object"){a=value.date;if(a){return a;}}
return value;};};var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}
return reviver.call(holder,key,value);}
cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+
('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}
if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
throw new SyntaxError('JSON2.parse');};}})();var ls=ls||{};ls.VERSION="0.1a";ls.AUTHOR="Lovely Systems";ls.DEBUG=false;ls.log=function(){if(this.DEBUG){if(console.notifyFirebug){console.notifyFirebug(arguments,'debug','firebugAppendConsole');}else{for(var i=0;i<arguments.length;i++){console.log(i,arguments[i]);}}}};ls.get=function(url,callback){$j.ajax({method:"GET",url:url,error:function(e){ls.log(e);},success:function(response){var res;try{res=JSON2.parse(response);}catch(e){res=response;}
callback.call(this,res);}});};ls.filename=function(){var e=new TypeError("FILENAME");for(var key in e){console.log(key+":",e[key]);}
return e.fileName;};ls.Delegate={context:null,delegations:[],create:function(obj,func,data){var delegation=new ls.Delegation(obj,func,data);this.delegations.push(delegation);return delegation;},destroy:function(){for(var i=0;i<this.delegations.length;i++){this.delegations[i].destroy();this.delegations[i]=null;}
this.delegations=null;delete this.delegations;}};ls.Delegation=callableType(function(obj,func,data){this.obj=obj;this.func=func;this.data=data;this.__call__=function(){var args=ls.Utils.createArgumentsArray(arguments);args.unshift(this.data);this.func.apply(this.obj,args);};this.destroy=function(){this.obj=null;this.func=null;this.data=null;delete this.obj;delete this.func;delete this.data;};});ls.DOMClass=function(){this.DOMClass.apply(this,arguments);};ls.DOMClass.prototype.DOMClass=function(n,p,a){this.context=n||$j(document);this.p=p||{};this.a=a||{};this.__init__.apply(this,arguments);};ls.DOMClass.prototype.__init__=function(){ls.log(this.toString(),arguments);};ls.DOMClass.prototype.toString=function(){return"[object DOMClass]";};ls.EventDispatcher=function(){this.EventDispatcher.apply(this,arguments);};ls.EventDispatcher.prototype.EventDispatcher=function(){this.__init__.apply(this,arguments);};ls.EventDispatcher.prototype.__init__=function(){this.listeners={};this.once={};this.unique={};};ls.EventDispatcher.prototype.addEventListener=function(event,callback,weight){if(typeof(event)!="string"){ls.log("Could not register Event ",event);return;}
if(!this.listeners[event])this.listeners[event]=[];var info={"callback":callback};this.listeners[event].push(info);if(weight){this.listeners[event].sort(function(a,b){return a.weight-b.weight;});}};ls.EventDispatcher.prototype.removeEventListener=function(id){if(!id){ls.log("Could not unregister Event ",id);return;}
var e=id.split('-')[0];var i=parseInt(id.split('-')[1],10);var spliced=this.listeners[e].splice(i,1);if(spliced.length==1){return true;}else{return false;}};ls.EventDispatcher.prototype.dispatchEvent=function(event){var stack=this.listeners[event.type];if(stack){for(var i=0;i<stack.length;i++){ls.log("CALLBACK",i,stack[i].callback,event.data);stack[i].callback.call(this,event.data);}}
this.clearOnce(event);};ls.EventDispatcher.prototype.addEventOnce=function(event,callback,weight){if(!this.once[event])this.once[event]=[];var id=this.addEventListener(event,callback,weight);this.once[event].push(id);return id;};ls.EventDispatcher.prototype.unique=function(event,key,callback,weight){if(!this.unique[event])this._unique[event]={};if(this.unique[event][key])this.removeEventListener(this.unique[event][key]);var id=this.addEventListener(event,callback,weight);this.unique[event][key]=id;};ls.EventDispatcher.prototype.clearOnce=function(event){if(!this.once[event])return;for(var i=0;i<this._once[event].length;i++){this.unregister(this._once[event][i]);}
delete this.once[event];};ls.Document=new ls.EventDispatcher();ls.AjaxLoader={WRAP:"<div id='${id}\' class='${class}'></div>",LOADER:"<div class='loader-image-holder'><div class='loader-image'><img src='${src}' /></div></div>",LOADERSOURCE:APP_SETTINGS.MEDIA_URL+"images/ajax-loader.gif",ERRORSOURCE:APP_SETTINGS.MEDIA_URL+"images/ajax-error.gif",HTTPSTATUS:null,AJAX_CLASS:"ajax-wrapper",target:null,init:function(data,context,event){event.preventDefault();var url=$j(event.target).attr("href");var target=$j(event.target).attr("target");this.load(url,target,true,event);},load:function(url,id,o,event){console.log("AjaxLoader.load",url,id,o,event);if(!url||!id){console.log("AjaxLoader.load abort");return false;}
this.target=$j(document.getElementById(id));console.log("target: ",this.target);var showOverlay=typeof o=="boolean"?o:true;if(this.target.length<0||this.target.length>1){ls.log("No or too many targets.",arguments);return false;}
if(!this.target.parent().hasClass(this.AJAX_CLASS)){var wrapper=ls.Utils.compileString(this.WRAP,{"id":"ajax-wrapper-"+new Date().getTime(),"class":this.AJAX_CLASS});this.target.wrap(wrapper);}
var node=this.target.parent();if(node.attr("ajax:current")==url){return;}else if(!url.match(/comment/)){node.attr("ajax:current",url);}
var historyData={"key":id,"value":url};this.dispatchEvent(new ls.AjaxEvent(ls.Event.AJAX_LOAD,historyData));if(showOverlay)this.createLoaderImage();var eventData={'node':node,'event':event};$j.ajax({url:url,type:"GET",error:function(xhr){console.log("AjaxLoader on error: ",xhr,arguments);ls.AjaxLoader.HTTPSTATUS=xhr.status;ls.AjaxLoader.onErrorHTTP(url);},success:ls.Delegate.create(ls.AjaxLoader,ls.AjaxLoader.onAjaxLoadComplete,eventData)});return false;},onAjaxLoadComplete:function(data,context,response){if(response.indexOf("document.write")!=-1){console.error("abort. must not inject content with document.write commands.");return;}
data.node.empty().append(response);var attr=com.lovelysystems.Application.getCommandAttrs(data.event.target);var eventData={'node':data.node,'code':attr.code};this.dispatchEvent(new ls.AjaxEvent(ls.Event.AJAX_COMPLETE,eventData));ls.Scrolling.scrollToNode(data[0]);},onErrorHTTP:function(url){ls.log('Got a '+this.HTTPSTATUS+' Status by this url: '+url);this.destroyLoaderImage(url);return;},createLoaderImage:function(){if(this.LOADERSOURCE){var node=this.target.parent();node.css("position","relative");if($j('.loader-image-holder',node).length<1){var w=this.target.width();var h=this.target.height();node.prepend(ls.Utils.compileString(this.LOADER,{"src":this.LOADERSOURCE}));var loader=$j(".loader-image-holder",node);loader.css("height",h);loader.css("width",w);var image=$j(".loader-image",loader);var t=h/2-image.height()/2;image.css("top",t);}}},destroyLoaderImage:function(url){var node=this.target.parent();var loaderNode=$j(".loader-image",node);var tpl='<p class="error">${message}<br />${status}<br />URL: ${url}</p>';var d={'message':_('error-occured'),'status':this.HTTPSTATUS,'url':url};if(loaderNode.children().length<2){loaderNode.append(ls.Utils.compileString(tpl,d));}},restoreHistory:function(data,context,event){for(n in event){if(document.getElementById(n)!=null){var id=n;var url=event[n];if(url=="DEFAULT"){url=this.getBaseURL(id);}
if(!url||!url.indexOf("/")==0){ls.log(url+" is not a valid url");}else{this.load(url,id);}}}},getBaseURL:function(id){if(typeof id=="string"){var node=$j(document.getElementById(id));return node?node.attr("ajax:base"):null;}}};__makeDispatchable(ls.AjaxLoader);ls.NavigationDropdown=function(node){this.NavigationDropdown(node);};ls.NavigationDropdown.prototype.NavigationDropdown=function(node){this.context=node;this.__init__(node);};ls.NavigationDropdown.prototype.__init__=function(node){this.bind();};ls.NavigationDropdown.prototype.bind=function(){this.context.bind("change",ls.Delegate.create(this,this.onSelect,null));};ls.NavigationDropdown.prototype.onSelect=function(data,context,event){ls.Utils.redirect(event.target.value);};ls.GApiController=function(){this.GApiController.apply(this,arguments);};ls.GApiController.prototype.GApiController=function(c,l,f,b,r){this.countryCode=c||"";this.languageCode=l||"";this.format=f||"json";this.box=b||null;this.rsz=r||"small";this.__init__.apply(this,arguments);};ls.GApiController.prototype.__init__=function(){if(!ls.__google)ls.__google={};};ls.GApiController.prototype.toString=function(){return"[object ls.GApiController]";};ls.GApiController.prototype.setCountryCode=function(l){this.countryCode=l||"";return this.countryCode;};ls.GApiController.prototype.setLanguageCode=function(c){this.languageCode=c||"";return this.languageCode;};ls.GApiController.prototype.setFormat=function(f){this.format=f||this.format;return this.format;};ls.GApiController.prototype.setDomain=function(d){this.domain=d||this.domain;return this.domain;};ls.GApiController.prototype.setViewport=function(vp){ls.log("Not implemented yet.");return vp;};ls.GApiController.prototype.fetch=function(){var s=this.getURL.apply(this,arguments);ls.log(this.toString(),s);var h=document.getElementsByTagName("head")[0];var k=document.createElement("script");k.setAttribute("type","text/javascript");k.setAttribute("charset","UTF-8");k.setAttribute("src",s);k.onload=ls.Delegate.create(this,this.onLoad,arguments);h.appendChild(k);};ls.GApiController.prototype.onLoad=function(){ls.log(this.toString(),"onLoad",arguments);};extend(ls.GApiController,[ls.EventDispatcher]);ls.GGeoController=function(){this.GGeoController.apply(this,arguments);};ls.GGeoController.prototype.GGeoController=function(c,l,f,d){this.languageCode=l||"";this.countryCode=c||"";this.format=f||"json";this.domain=d||"";this.__init__.apply(this,arguments);};ls.GGeoController.prototype.toString=function(){return"[object ls.GGeoController]";};ls.GGeoController.prototype.__init__=function(){this.id="geo_"+Math.floor(Math.random()*1000000);ls.__google[this.id]=null;};ls.GGeoController.prototype.getURL=function(q,cb){var s="http://${domain}/maps/geo?${args}";ls.__google[this.id]=cb;var args={},d={},a=[];args.q=encodeURIComponent(q);args.mapclient="jsapi";args.oe="utf-8";args.output=this.format;args.hl=this.languageCode||APP_SETTINGS.GMAP_LANGUAGE||window._mHL;args.gl=this.countryCode||APP_SETTINGS.GMAP_COUNTRY||window._mGL;args.key=APP_SETTINGS.GMAP_API_KEY||"";d.domain=this.domain||APP_SETTINGS.GMAP_DOMAIN||"maps.google.com";args.callback="ls.__google."+this.id;for(k in args){a.push(k+"="+args[k]);}
d.args=a.join("&");return ls.Utils.compileString(s,d);};extend(ls.GGeoController,[ls.GApiController]);ls.GLocalController=function(){this.GLocalController.apply(this,arguments);};ls.GLocalController.prototype.GLocalController=function(c,l,f,b,r){this.countryCode=c||"";this.languageCode=l||"";this.format=f||"json";this.box=b||null;this.rsz=r||"small";this.__init__.apply(this,arguments);};ls.GLocalController.prototype.__init__=function(){this.API="http://ajax.googleapis.com/ajax/services/search/local?${args}";this.API_VERSION="1.0";this.MRT="localonly";this.ENC_TYPE="utf-8";this.id="local_"+Math.floor(Math.random()*1000000);ls.__google[this.id]=null;};ls.GLocalController.prototype.toString=function(){return"[object ls.GLocalController]";};ls.GLocalController.prototype.getURL=function(q,geo,cb){var args={},d={},a=[];ls.__google[this.id]=cb;if(geo&&geo.lat&&geo.lng){args.sll=geo.lat+","+geo.lng;args.spn="0.0001,0.0001";}else{var box=geo||this.box||APP_SETTINGS.GEO_BOX;var spnlng=box.east-box.west;var spnlat=box.north-box.south;args.spn=spnlat+","+spnlng;args.sll=(box.north-spnlat/2)+","+(box.east-spnlng/2);}
q=q.replace(/&/g," ");args.q=encodeURIComponent(q);args.oe=this.ENC_TYPE;args.v=this.API_VERSION;args.mrt=this.MRT;args.output=this.format;args.rsz=this.rsz;args.hl=this.languageCode||APP_SETTINGS.GMAP_LANGUAGE||window._mHL;args.gl=this.countryCode||APP_SETTINGS.GMAP_COUNTRY||window._mGL;args.callback="ls.__google."+this.id;for(k in args){a.push(k+"="+args[k]);}
d.args=a.join("&");return ls.Utils.compileString(this.API,d);};extend(ls.GLocalController,[ls.GApiController]);var ls=ls||{};ls.Pixel={toString:function(){return"[object ls.Pixel]";},PATTERNS:{'IVW':["http://${account}.ivwbox.de/cgi-bin/ivw/${type}/${code}?r=${referrer}&d=${random}"],'WEMF':["http://${account}.wemfbox.ch/cgi-bin/ivw/${type}/${code}?r=${referrer}&d=${random}"]},info:{},addInfo:function(k,v){this.info[k]=v;},accounts:[],register:function(accounts){for(var k in accounts){if(accounts[k]){if(!this.accounts.contains(k)){this.accounts.push([k,accounts[k]]);}else{ls.log(a+" already registered.");}}}},track:function(account,data){console.log("Pixel.track "+account,data);if(!this.PATTERNS[account[0]]||!data)return;var d=cp(this.info,{referrer:escape(document.location.href),random:Math.random()*1000000,account:account[1]});d=cp(data,d);var url=ls.Utils.compileString(this.PATTERNS[account[0]][0],d);var img=new Image();img.src=url;img.onload=ls.Delegate.create(this,this.onSuccess,url);img.onerror=ls.Delegate.create(this,this.onError,url);img.setAttribute("width",1);img.style.width=1;img.setAttribute("height",1);img.style.height=1;console.log("Pixel.track done: "+url);document.getElementsByTagName("body")[0].appendChild(img);},onEvent:function(data,context,event){console.log("Pixel.onEvent",data,context,event);for(var i=0;i<this.accounts.length;i++){var trackingData=(event&&event.code)?event:((data&&data.code)?data:null);if(trackingData){this.track(this.accounts[i],trackingData);}}},onSuccess:function(){ls.log(this.toString(),"success",arguments);},onError:function(){ls.log(this.toString(),"error",arguments);}};__makeDispatchable(ls.Pixel);ls.GoogleAnalytics={tracker:[],triggerPageView:function(url){if(!url)url=document.location;for(i=0;i<this.tracker.length;i++){this.tracker[i]._trackPageview(url);}},onEvent:function(data,context,event){var url=(event&&event.code)?event.code:((data&&data.code)?data.code:null);if(url)this.triggerPageView(url);else console.log("GoogleAnalytics.onEvent failed.");}}
__makeDispatchable(ls.GoogleAnalytics);if(window.googleMapsAPI==true){function ExtInfoWindow(a,b,c,d){this.html_=c;this.marker_=a;this.infoWindowId_=b;this.options_=d==null?{}:d;this.ajaxUrl_=this.options_.ajaxUrl==null?null:this.options_.ajaxUrl;this.callback_=this.options_.ajaxCallback==null?null:this.options_.ajaxCallback;this.borderSize_=this.options_.beakOffset==null?0:this.options_.beakOffset;this.paddingX_=this.options_.paddingX==null?0+this.borderSize_:this.options_.paddingX+this.borderSize_;this.paddingY_=this.options_.paddingY==null?0+this.borderSize_:this.options_.paddingY+this.borderSize_;this.map_=null;this.container_=document.createElement('div');this.container_.style.position='relative';this.container_.style.display='none';this.contentDiv_=document.createElement('div');this.contentDiv_.id=this.infoWindowId_+'_contents';this.contentDiv_.innerHTML=this.html_;this.contentDiv_.style.display='block';this.contentDiv_.style.visibility='hidden';this.wrapperDiv_=document.createElement('div')};ExtInfoWindow.prototype=new GOverlay();ExtInfoWindow.prototype.initialize=function(a){this.map_=a;this.defaultStyles={containerWidth:this.map_.getSize().width/2,borderSize:1};this.wrapperParts={tl:{t:0,l:0,w:0,h:0,domElement:null},t:{t:0,l:0,w:0,h:0,domElement:null},tr:{t:0,l:0,w:0,h:0,domElement:null},l:{t:0,l:0,w:0,h:0,domElement:null},r:{t:0,l:0,w:0,h:0,domElement:null},bl:{t:0,l:0,w:0,h:0,domElement:null},b:{t:0,l:0,w:0,h:0,domElement:null},br:{t:0,l:0,w:0,h:0,domElement:null},beak:{t:0,l:0,w:0,h:0,domElement:null},close:{t:0,l:0,w:0,h:0,domElement:null}};for(var i in this.wrapperParts){var b=document.createElement('div');b.id=this.infoWindowId_+'_'+i;b.style.visibility='hidden';document.body.appendChild(b);b=document.getElementById(this.infoWindowId_+'_'+i);var c=eval('this.wrapperParts.'+i);c.w=parseInt(this.getStyle_(b,'width'));c.h=parseInt(this.getStyle_(b,'height'));document.body.removeChild(b)}for(var i in this.wrapperParts){if(i=='close'){this.wrapperDiv_.appendChild(this.contentDiv_)}var d=null;if(this.wrapperParts[i].domElement==null){d=document.createElement('div');this.wrapperDiv_.appendChild(d)}else{d=this.wrapperParts[i].domElement}d.id=this.infoWindowId_+'_'+i;d.style.position='absolute';d.style.width=this.wrapperParts[i].w+'px';d.style.height=this.wrapperParts[i].h+'px';d.style.top=this.wrapperParts[i].t+'px';d.style.left=this.wrapperParts[i].l+'px';this.wrapperParts[i].domElement=d}this.map_.getPane(G_MAP_FLOAT_PANE).appendChild(this.container_);this.container_.id=this.infoWindowId_;var e=this.getStyle_(document.getElementById(this.infoWindowId_),'width');this.container_.style.width=(e==null?this.defaultStyles.containerWidth:e);this.map_.getContainer().appendChild(this.contentDiv_);this.contentWidth=this.getDimensions_(this.container_).width;this.contentDiv_.style.width=this.contentWidth+'px';this.contentDiv_.style.position='absolute';this.container_.appendChild(this.wrapperDiv_);GEvent.bindDom(this.container_,'mousedown',this,this.onClick_);GEvent.bindDom(this.container_,'dblclick',this,this.onClick_);GEvent.bindDom(this.container_,'DOMMouseScroll',this,this.onClick_);GEvent.trigger(this.map_,'extinfowindowopen');if(this.ajaxUrl_!=null){this.ajaxRequest_(this.ajaxUrl_)}};ExtInfoWindow.prototype.onClick_=function(e){if(navigator.userAgent.toLowerCase().indexOf('msie')!=-1&&document.all){window.event.cancelBubble=true;window.event.returnValue=false}else{e.stopPropagation()}};ExtInfoWindow.prototype.remove=function(){if(this.map_.getExtInfoWindow()!=null){GEvent.trigger(this.map_,'extinfowindowbeforeclose');GEvent.clearInstanceListeners(this.container_);if(this.container_.outerHTML){this.container_.outerHTML=''}if(this.container_.parentNode){this.container_.parentNode.removeChild(this.container_)}this.container_=null;GEvent.trigger(this.map_,'extinfowindowclose');this.map_.setExtInfoWindow_(null)}};ExtInfoWindow.prototype.copy=function(){return new ExtInfoWindow(this.marker_,this.infoWindowId_,this.html_,this.options_)};ExtInfoWindow.prototype.redraw=function(a){if(!a||this.container_==null)return;var b=this.contentDiv_.offsetHeight;this.contentDiv_.style.height=b+'px';this.contentDiv_.style.left=this.wrapperParts.l.w+'px';this.contentDiv_.style.top=this.wrapperParts.tl.h+'px';this.contentDiv_.style.visibility='visible';this.wrapperParts.tl.t=0;this.wrapperParts.tl.l=0;this.wrapperParts.t.l=this.wrapperParts.tl.w;this.wrapperParts.t.w=(this.wrapperParts.l.w+this.contentWidth+this.wrapperParts.r.w)-this.wrapperParts.tl.w-this.wrapperParts.tr.w;this.wrapperParts.t.h=this.wrapperParts.tl.h;this.wrapperParts.tr.l=this.wrapperParts.t.w+this.wrapperParts.tl.w;this.wrapperParts.l.t=this.wrapperParts.tl.h;this.wrapperParts.l.h=b;this.wrapperParts.r.l=this.contentWidth+this.wrapperParts.l.w;this.wrapperParts.r.t=this.wrapperParts.tr.h;this.wrapperParts.r.h=b;this.wrapperParts.bl.t=b+this.wrapperParts.tl.h;this.wrapperParts.b.l=this.wrapperParts.bl.w;this.wrapperParts.b.t=b+this.wrapperParts.tl.h;this.wrapperParts.b.w=(this.wrapperParts.l.w+this.contentWidth+this.wrapperParts.r.w)-this.wrapperParts.bl.w-this.wrapperParts.br.w;this.wrapperParts.b.h=this.wrapperParts.bl.h;this.wrapperParts.br.l=this.wrapperParts.b.w+this.wrapperParts.bl.w;this.wrapperParts.br.t=b+this.wrapperParts.tr.h;this.wrapperParts.close.l=this.wrapperParts.tr.l+this.wrapperParts.tr.w-this.wrapperParts.close.w-this.borderSize_;this.wrapperParts.close.t=this.borderSize_;this.wrapperParts.beak.l=this.borderSize_+(this.contentWidth/2)-(this.wrapperParts.beak.w/2);this.wrapperParts.beak.t=this.wrapperParts.bl.t+this.wrapperParts.bl.h-this.borderSize_;for(var i in this.wrapperParts){if(i=='close'){this.wrapperDiv_.insertBefore(this.contentDiv_,this.wrapperParts[i].domElement)}var c=null;if(this.wrapperParts[i].domElement==null){c=document.createElement('div');this.wrapperDiv_.appendChild(c)}else{c=this.wrapperParts[i].domElement}c.id=this.infoWindowId_+'_'+i;c.style.position='absolute';c.style.width=this.wrapperParts[i].w+'px';c.style.height=this.wrapperParts[i].h+'px';c.style.top=this.wrapperParts[i].t+'px';c.style.left=this.wrapperParts[i].l+'px';this.wrapperParts[i].domElement=c}var d=this.marker_;var e=this.map_;GEvent.addDomListener(this.wrapperParts.close.domElement,'click',function(){e.closeExtInfoWindow()});var f=this.map_.fromLatLngToDivPixel(this.marker_.getPoint());this.container_.style.position='absolute';var g=this.marker_.getIcon();this.container_.style.left=(f.x-(this.contentWidth/2)-g.iconAnchor.x+g.infoWindowAnchor.x)+'px';this.container_.style.top=(f.y-this.wrapperParts.bl.h-b-this.wrapperParts.tl.h-this.wrapperParts.beak.h-g.iconAnchor.y+g.infoWindowAnchor.y+this.borderSize_)+'px';this.container_.style.display='block';if(this.map_.getExtInfoWindow()!=null){this.repositionMap_()}};ExtInfoWindow.prototype.resize=function(){var a=this.contentDiv_.cloneNode(true);a.id=this.infoWindowId_+'_tempContents';a.style.visibility='hidden';a.style.height='auto';document.body.appendChild(a);a=document.getElementById(this.infoWindowId_+'_tempContents');var b=a.offsetHeight;document.body.removeChild(a);this.contentDiv_.style.height=b+'px';var c=this.contentDiv_.offsetWidth;var d=this.map_.fromLatLngToDivPixel(this.marker_.getPoint());var e=this.wrapperParts.t.domElement.offsetHeight+this.wrapperParts.l.domElement.offsetHeight+this.wrapperParts.b.domElement.offsetHeight;var f=this.wrapperParts.t.domElement.offsetTop;this.wrapperParts.l.domElement.style.height=b+'px';this.wrapperParts.r.domElement.style.height=b+'px';var g=this.wrapperParts.b.domElement.offsetTop-b;this.wrapperParts.l.domElement.style.top=g+'px';this.wrapperParts.r.domElement.style.top=g+'px';this.contentDiv_.style.top=g+'px';windowTHeight=parseInt(this.wrapperParts.t.domElement.style.height);g-=windowTHeight;this.wrapperParts.close.domElement.style.top=g+this.borderSize_+'px';this.wrapperParts.tl.domElement.style.top=g+'px';this.wrapperParts.t.domElement.style.top=g+'px';this.wrapperParts.tr.domElement.style.top=g+'px';this.repositionMap_()};ExtInfoWindow.prototype.repositionMap_=function(){var a=this.map_.fromLatLngToDivPixel(this.map_.getBounds().getNorthEast());var b=this.map_.fromLatLngToDivPixel(this.map_.getBounds().getSouthWest());var c=this.map_.fromLatLngToDivPixel(this.marker_.getPoint());var d=0;var e=0;var f=this.paddingX_;var g=this.paddingY_;var h=this.marker_.getIcon().infoWindowAnchor;var i=this.marker_.getIcon().iconAnchor;var j=this.wrapperParts.t.domElement;var k=this.wrapperParts.l.domElement;var l=this.wrapperParts.b.domElement;var m=this.wrapperParts.r.domElement;var n=this.wrapperParts.beak.domElement;var o=c.y-(-h.y+i.y+this.getDimensions_(n).height+this.getDimensions_(l).height+this.getDimensions_(k).height+this.getDimensions_(j).height+this.paddingY_);if(o<a.y){e=a.y-o}else{var p=c.y+this.paddingY_;if(p>=b.y){e=-(p-b.y)}}var q=Math.round(c.x+this.getDimensions_(this.container_).width/2+this.getDimensions_(m).width+this.paddingX_+h.x-i.x);if(q>a.x){d=-(q-a.x)}else{var r=-(Math.round((this.getDimensions_(this.container_).width/2-this.marker_.getIcon().iconSize.width/2)+this.getDimensions_(k).width+this.borderSize_+this.paddingX_)-c.x-h.x+i.x);if(r<b.x){d=b.x-r}}if(d!=0||e!=0&&this.map_.getExtInfoWindow()!=null){this.map_.panBy(new GSize(d,e))}};ExtInfoWindow.prototype.ajaxRequest_=function(d){var e=this.map_;var f=this.callback_;GDownloadUrl(d,function(a,b){var c=document.getElementById(e.getExtInfoWindow().infoWindowId_+'_contents');if(a==null||b==-1){c.innerHTML='<span class="error">ERROR: The Ajax request failed to get HTML content from "'+d+'"</span>'}else{c.innerHTML=a}if(f!=null){f()}e.getExtInfoWindow().resize();GEvent.trigger(e,'extinfowindowupdate')})};ExtInfoWindow.prototype.getDimensions_=function(a){var b=this.getStyle_(a,'display');if(b!='none'&&b!=null){return{width:a.offsetWidth,height:a.offsetHeight}}var c=a.style;var d=c.visibility;var e=c.position;var f=c.display;c.visibility='hidden';c.position='absolute';c.display='block';var g=a.clientWidth;var h=a.clientHeight;c.display=f;c.position=e;c.visibility=d;return{width:g,height:h}};ExtInfoWindow.prototype.getStyle_=function(a,b){var c=false;b=this.camelize_(b);var d=a.style[b];if(!d){if(document.defaultView&&document.defaultView.getComputedStyle){var e=document.defaultView.getComputedStyle(a,null);d=e?e[b]:null}else if(a.currentStyle){d=a.currentStyle[b]}}if((d=='auto')&&(b=='width'||b=='height')&&(this.getStyle_(a,'display')!='none')){if(b=='width'){d=a.offsetWidth}else{d=a.offsetHeight}}return(d=='auto')?null:d};ExtInfoWindow.prototype.camelize_=function(a){var b=a.split('-'),len=b.length;if(len==1)return b[0];var c=a.charAt(0)=='-'?b[0].charAt(0).toUpperCase()+b[0].substring(1):b[0];for(var i=1;i<len;i++){c+=b[i].charAt(0).toUpperCase()+b[i].substring(1)}return c};GMap.prototype.ExtInfoWindowInstance_=null;GMap.prototype.ClickListener_=null;GMap.prototype.InfoWindowListener_=null;GMarker.prototype.openExtInfoWindow=function(b,c,d,e){if(b==null){throw'Error in GMarker.openExtInfoWindow: map cannot be null';return false}if(c==null||c==''){throw'Error in GMarker.openExtInfoWindow: must specify a cssId';return false}b.closeInfoWindow();if(b.getExtInfoWindow()!=null){b.closeExtInfoWindow()}if(b.getExtInfoWindow()==null){b.setExtInfoWindow_(new ExtInfoWindow(this,c,d,e));if(b.ClickListener_==null){b.ClickListener_=GEvent.addListener(b,'click',function(a){if(!a&&b.getExtInfoWindow()!=null){b.closeExtInfoWindow()}})}if(b.InfoWindowListener_==null){b.InfoWindowListener_=GEvent.addListener(b,'infowindowopen',function(a){if(b.getExtInfoWindow()!=null){b.closeExtInfoWindow()}})}b.addOverlay(b.getExtInfoWindow())}};GMarker.prototype.closeExtInfoWindow=function(a){if(a.getExtInfWindow()!=null){a.closeExtInfoWindow()}};GMap2.prototype.getExtInfoWindow=function(){return this.ExtInfoWindowInstance_};GMap2.prototype.setExtInfoWindow_=function(a){this.ExtInfoWindowInstance_=a}
GMap2.prototype.closeExtInfoWindow=function(){if(this.getExtInfoWindow()!=null){this.ExtInfoWindowInstance_.remove()}};}
ls.RecaptchaManager={DEBUG:false,API:"http://api.recaptcha.net/js/recaptcha_ajax.js",KEY:null,template:"/__recaptcha_base__",currentId:null,context:null,docs:"http://recaptcha.net/apidocs/captcha/client.html",isAPILoaded:true,toString:function(){return"[object ls.RecaptchaManager]";},setKey:function(key){this.KEY=key;},setTemplate:function(url){this.template=url;},initCaptcha:function(id,template){if(!this.KEY){ls.log("No Recaptcha key set!");return;}
if(!this.isAPILoaded){$j.getScript(this.API,ls.Delegate.create(this,this.onAPIReady,{"id":id,"template":template}));}else{if(this.currentId&&this.currentId!=id){Recaptcha.destroy();this.dispatchEvent(new ls.AjaxEvent(ls.Event.CAPTCHA_INIT,null));$j("#recaptcha_widget_"+this.currentId).empty();$j("#recaptcha_widget_"+this.currentId).attr("id",this.currentId);$j("#"+this.currentId).hide();}
if(this.currentId!=id){this.context=$j("#"+id);this.currentId=id;this.loadTemplate(template);}}},onAPIReady:function(data,context,event){ls.log("ReCaptcha API loaded.");this.isAPILoaded=true;this.initCaptcha(data.id,data.template);},loadTemplate:function(template){var tpl=template?template:this.template;this.getTarget().load(tpl,ls.Delegate.create(this,this.createCaptcha,null));},createCaptcha:function(data,context,response){Recaptcha.create(this.KEY,this.currentId,{theme:'custom',tabindex:0,lang:'de',custom_theme_widget:'recaptcha_widget_'+this.currentId});},reloadCaptcha:function(reason){if(Recaptcha&&typeof RecaptchaState==="undefined")return;ls.log(reason);Recaptcha.reload(reason);},destroyCaptcha:function(){if(Recaptcha&&typeof RecaptchaState==="undefined")return;Recaptcha.destroy();this.currentId=null;},getTarget:function(){var div="<div class='captchaContainer' id='recaptcha_widget_"+this.currentId+"'></div>";if(!this.context.parent().hasClass("captchaContainer")){this.context.wrap(div);}
return this.context.parent();},showHelp:function(){ls.log("Show help.");}};__makeDispatchable(ls.RecaptchaManager);ls.Coverflow=function(){this.Coverflow.apply(this,arguments);};ls.Coverflow.prototype.Coverflow=function(){this.__init__.apply(this,arguments);};ls.Coverflow.prototype.__init__=function(node,params,attrs){this.context=node;this.p=params;this.a=attrs;this.list=$j("ul",this.context);this.items=$j("li",this.list);this.nextButton=$j(".next",this.context);this.prevButton=$j(".prev",this.context);this.locked=false;this.setConf();};ls.Coverflow.prototype.toString=function(){return"[object ls.Coverflow]";};ls.Coverflow.prototype.setConf=function(conf){var o=conf||{};this.speed=o.speed||500;this.ratio=o.ratio||0.75;this.easing=o.easing||null;this.visible=o.visible||3;this.start=o.start||0;this.initialCss=o.css||{width:0,height:0};};ls.Coverflow.prototype.bind=function(){if(this.items.length<this.visible)return;this.setup();this.nextButton.bind('click',ls.Delegate.create(this,this.next));this.prevButton.bind('click',ls.Delegate.create(this,this.prev));this.go(this.start+(this.visible-1)/2);};ls.Coverflow.prototype.prev=function(){var prev=this.current-1;this.go(prev);this.onPrev();};ls.Coverflow.prototype.next=function(){var next=this.current+1;this.go(next);this.onNext();};ls.Coverflow.prototype.lock=function(l){var locked=typeof l=="boolean"?l:true;this.locked=locked;return this.locked;};ls.Coverflow.prototype.setup=function(){var r=this.ratio;var ici=[];this.img=$j("img",this.items);this.items.each(function(i,dom){var img=$j("img",$j(this))[0];var size={"width":img?img.width:160,"height":img?img.height:100};ici.push(size);if(img){$j(img).css({"width":size.width*r,"height":size.height*r});}});this.initCssImg=ici;this.list.prepend(this.items.slice(this.items.size()-this.visible).clone()).append(this.items.slice(0,this.visible).clone());var suf=this.initCssImg.slice(this.initCssImg.length-this.visible);var pre=this.initCssImg.slice(0,this.visible);this.initCssImg=pre.concat(this.initCssImg.concat(suf));this.list=$j("ul",this.context);this.items=$j("li",this.list);this.img=$j("img",this.items);this.start+=this.visible;this.current=this.start;this.links=$j("a.gallery-image-link",this.items);this.context.css("visibility","visible");this.initCssLi=this.initialCss;this.initCssLi['marginLeft']=this.initCssLi['marginRight']=-1*(this.initialCss.width-this.initialCss.width*this.ratio)/2;this.initCssLi['marginTop']=this.initCssLi['marginBottom']=-1*(this.initialCss.height-this.initialCss.height*this.ratio)/2;padTop=(this.initialCss.height-this.initialCss.height*this.ratio)/2;this.initCssLi['height']=this.initialCss.height-padTop+10;ici=this.initCssImg;this.links.each(function(i,dom){$j(this).css({"width":ici[i].width*r,"height":ici[i].height*r});});this.list.css({"height":this.initialCss.height,"margin":"0","padding":"0","position":"relative","list-style-type":"none","z-index":"1"});$j(".carousel",this.context).css({"overflow":"hidden","position":"relative","z-index":"2","left":"0"});this.items.css({"width":this.initialCss.width*this.ratio,"height":this.initialCss.height*this.ratio,"margin":0,"overflow":"hidden","float":"left"});this.liSize=this.getWidth(this.items);this.ulSize=this.liSize*(this.items.length+1);this.divSize=this.liSize*this.visible;this.list.css("width",this.ulSize+"px").css("left",-(this.current*this.liSize));$j(".carousel",this.context).css("width",this.divSize+"px");};ls.Coverflow.prototype.go=function(to,context,event){if(this.locked)return;if(event)event.preventDefault();var ici=this.initCssImg;var icl=this.initCssLi;var r=this.ratio;if(to<=this.start-this.visible-1){this.list.css("left",-((this.items.length-(this.visible*2))*this.liSize)+"px");this.current=this.items.length-(this.visible*2)-1;}else if(to>=this.items.length-this.visible+1){this.list.css("left",-((this.visible)*this.liSize)+"px");this.current=this.visible+1;}else{this.current=to;}
this.items.removeClass("carousel-item-active");this.items.removeClass("carousel-item-selected");this.items.unbind("click");this.list.animate({left:-(this.current*this.liSize)},this.speed,this.easing,ls.Delegate.create(this,this.lock,false));this.items.css({"width":this.initCssLi.width*this.ratio,"height":this.initCssLi.height*this.ratio,"margin":0,"padding":"10px","z-index":1});this.items.children(".carousel-business").css("margin-top",0);var c=this.current+(this.visible-1)/2;var currLi=$j(this.items[c]);for(var i=0;i<this.items.size();i++){if(i<c){var prev=this.current-1;$j(this.items[i]).bind("click",ls.Delegate.create(this,this.go,prev));}else if(i>c){var next=this.current+1;$j(this.items[i]).bind("click",ls.Delegate.create(this,this.go,next));}}
currLi.addClass("carousel-item-selected");currLi.css({"z-index":100,"padding-top":padTop+'px'});currLi.children(".carousel-business").css("margin-top",-1*(padTop-10));currLi.animate(this.initCssLi,this.speed,this.easing,function(){$j(this).addClass("carousel-item-active");});this.links.each(function(i,dom){$j(this).css({"width":ici[i].width*r,"height":ici[i].height*r});});this.img.each(function(i,dom){this.width=ici[i].width*r;this.height=ici[i].height*r;$j(this).css({"width":ici[i].width*r,"height":ici[i].height*r});});this.items.each(function(i,dom){$j(this).css({"width":icl.width*r,"height":(icl.height+padTop-10)*r});});var currA=$j($j("a",currLi)[0]);currA.animate(this.initCssImg[c],this.speed,this.easing);var currImg=$j("img",currLi);currImg.animate(this.initCssImg[c],this.speed,this.easing);};ls.Coverflow.prototype.vis=function(){return this.items.slice(this.current).slice(0,this.visible);};ls.Coverflow.prototype.getCSS=function(el,prop){var p=$j.css(el[0],prop);return!isNaN(p)?parseInt(p,10):0;};ls.Coverflow.prototype.getSize=function(el){var w=this.getWidth(el);var h=this.getHeight(el);return{width:w,height:h};};ls.Coverflow.prototype.getWidth=function(el){return el[0].offsetWidth+this.getCSS(el,'marginLeft')+this.getCSS(el,'marginRight');};ls.Coverflow.prototype.getHeight=function(el){return el[0].offsetHeight+this.getCSS(el,'marginTop')+this.getCSS(el,'marginBottom');};ls.Coverflow.prototype.beforeAnimation=function(){};ls.Coverflow.prototype.afterAnimation=function(){};ls.Coverflow.prototype.onPrev=function(){};ls.Coverflow.prototype.onNext=function(){};extend(ls.Coverflow,[ls.EventDispatcher]);ls.GMapController=function(){this.GMapController.apply(this,arguments);};ls.GMapController.prototype.GMapController=function(elem,params,attrs){this.DEFAULT_MAP_ZOOM=15;this.elem=elem;this.a=attrs;this.p=params;this.__init__.apply(this,arguments);};ls.GMapController.prototype.__init__=function(){this.node=$j(this.elem);json=ls.GMapControllerJSON;this.jsondata=json&&JSON2.parse(json.trim());this.map=new GMap2(this.elem);this.map.addControl(new GSmallZoomControl3D());this.marker=GMarker;this.tmpmarker=GMarker;this.pins=[];this.markers=[];this.currentMarker=null;};ls.GMapController.prototype.toString=function(){return"[object ls.GMapController]";};ls.GMapController.prototype.init=function(){this.initialGeoData={lat:this.p.lat,lon:this.p.lon,north:this.p.north,south:this.p.south,east:this.p.east,west:this.p.west};ls.Document.addEventListener(ls.Event.HOVER_OVER,ls.Delegate.create(this,this.onHoverEvent,"focus"));ls.Document.addEventListener(ls.Event.HOVER_OUT,ls.Delegate.create(this,this.onHoverEvent,"blur"));ls.Document.addEventListener(ls.Event.GEOPOS_OVER,ls.Delegate.create(this,this.onGeoposEvent,"focus"));ls.Document.addEventListener(ls.Event.GEOPOS_OUT,ls.Delegate.create(this,this.onGeoposEvent,"blur"));ls.Document.addEventListener(ls.Event.PIN_DATA,ls.Delegate.create(this,this.onGeoData,ls.Event.MAP_ADD_GEODATA));ls.Document.addEventListener(ls.Event.MAP_ADD_PIN,ls.Delegate.create(this,this.onGeoData,null));GEvent.addListener(this.map,'extinfowindowclose',ls.Delegate.create(this,this.extinfowindowClose));this.loadGeoData();};ls.GMapController.prototype.setMap=function(geo,animate){var animate=animate||false;var geo=geo||this.initialGeoData;if(!this.map||!geo)return;var zoom=geo.zoom?parseInt(geo.zoom,10):this.getZoom();if(geo.lat&&geo.lon){var center=new GLatLng(geo.lat,geo.lon);}else if(geo.north&&geo.south&&geo.west&&geo.east){var lon=geo.east-(geo.east-geo.west)/2;var lat=geo.south-(geo.south-geo.north)/2;var center=new GLatLng(lat,lon);}else{return;}
if(animate){this.map.panTo(center);this.map.setZoom(zoom);}else{this.map.setCenter(center,zoom);}}
ls.GMapController.prototype.loadGeoData=function(){if(this.p.jsonurl){ls.get(this.p.jsonurl,ls.Delegate.create(this,this.onGeoData,ls.Event.MAP_NEW_GEODATA));}else if(this.jsondata){this.setMap();var data=this.p.issearchresult?ls.Event.MAP_NEW_GEODATA:null;this.onGeoData(data,null,this.jsondata);}else{this.setMap(this.p.geo);}};ls.GMapController.prototype.onGeoData=function(data,context,response){ls.log("onGeoData",arguments);if(data){var ev={'response':response,'type':data};ls.Document.dispatchEvent(new ls.AjaxEvent(ls.Event.MAP_DATA,ev));}
this.createPins(response,true);};ls.GMapController.prototype.createPins=function(pins,autofit,type){var i=0,len=pins.length;for(i;i<len;i++){var p=pins[i];if(p.lat&&p.lon){this.pins.push(p);var marker=this.createMarker(p,type);this.markers.push(marker);this.map.addOverlay(marker);}}
if(autofit&&this.pins.length>1){this.fitToPins();}else if(autofit&&this.pins.length==1){this.setMap(this.pins[0]);}else if(this.pins.length==0){this.setMap();}};ls.GMapController.prototype.createMarker=function(p,type){var _map=this.map;var point=new GLatLng(p.lat,p.lon);var m=type||this.marker;var icon=new GIcon(m);icon.__data__=p;var options={'icon':icon};var marker=new GMarker(point,options);marker.lock=function(){this.locked=true;}
marker.unlock=function(){this.locked=false;}
marker.onMouseOver=function(){_map.closeExtInfoWindow();var data=this.getIcon().__data__;this.setImage(this.getIcon().hover);var eventData={"map":_map,"marker":this,"id":data.ident};ls.Document.dispatchEvent(new ls.AjaxEvent(ls.Event.MAP_MARKER_SELECT,eventData));};marker.onMouseOut=function(force){if(!this.locked){var data=this.getIcon().__data__;this.setImage(this.getIcon().image);var eventData={"map":_map,"marker":this,"id":data.ident};ls.Document.dispatchEvent(new ls.AjaxEvent(ls.Event.MAP_MARKER_UNSELECT,eventData));}};marker.onClick=function(){var data=this.getIcon().__data__;if(data.url){var tpl='<b><a class="dark" href="${url}" title="${title}">${title}</a></b><br />${street}';}else{var tpl='<b>${title}</b><br />${street}';}
var html=ls.Utils.compileString(tpl,data);var opts={beakOffset:0,paddingX:20,paddingY:0};this.lock();this.openExtInfoWindow(_map,'mk-map-overlay',html,opts);};GEvent.addListener(marker,"mouseover",function(){this.onMouseOver.apply(this,arguments);});GEvent.addListener(marker,"mouseout",function(){this.onMouseOut.apply(this,arguments);});GEvent.addListener(marker,"click",function(){this.onClick.apply(this,arguments);});return marker;};ls.GMapController.prototype.extinfowindowClose=function(data,context,event){for(var i=0;i<this.markers.length;i++){this.markers[i].unlock();this.markers[i].onMouseOut();}}
ls.GMapController.prototype.onHoverEvent=function(data,context,event){var id=event.attr("id");if(data=="focus"){this.focusPin(id);}else if(data=="blur"){this.blurPin(id);}};ls.GMapController.prototype.onGeoposEvent=function(data,context,event){var attr=com.lovelysystems.Application.getCommandAttrs(event);if(data=="focus"){this.createPins([attr],true,this.tmpmarker);}else if(data=="blur"){this.dropPin(attr.ident);}};ls.GMapController.prototype.focusPin=function(id){var pin=this.getPinById(id);if(!pin)return;for(var i=0;i<this.markers.length;i++){this.markers[i].onMouseOut();}
pin.marker.onMouseOver();this.setMap(pin.pin,false);this.currentMarker=pin.marker;};ls.GMapController.prototype.blurPin=function(id){if(this.currentMarker){this.currentMarker.onMouseOut();this.currentMarker=null;}else{var pin=this.getPinById(id);if(!pin)return;pin.marker.onMouseOut();}};ls.GMapController.prototype.dropPin=function(id){var pin=this.getPinById(id);if(!pin)return;this.map.removeOverlay(pin.marker);var p=this.pins.splice(pin.index,pin.index+1);var m=this.markers.splice(pin.index,pin.index+1);delete pin.marker;delete pin.pin;delete pin;this.fitToPins();return true;};ls.GMapController.prototype.getPinById=function(ident){var i=0,l=this.pins.length;for(i;i<l;i++){if(this.pins[i].ident==ident)return{'index':i,'pin':this.pins[i],'marker':this.markers[i]};}
return null;};ls.GMapController.prototype.fitToPins=function(pins){var p=pins||this.pins;var lat=0,lon=0,maxLat=-90,maxLon=-180,i=0;for(i;i<p.length;i++){var pin=p[i];lat+=parseFloat(pin.lat);lon+=parseFloat(pin.lon);if(pin.lat>maxLat)maxLat=parseFloat(pin.lat);if(pin.lon>maxLon)maxLon=parseFloat(pin.lon);}
var avgLat=lat/p.length;var avgLon=lon/p.length;var minLat=avgLat-(maxLat-avgLat);var minLon=avgLon-(maxLon-avgLon);var bounds=new GLatLngBounds(new GLatLng(minLat,minLon),new GLatLng(maxLat,maxLon));var zoom=this.map.getBoundsZoomLevel(bounds,this.map.getSize());zoom=zoom>this.DEFAULT_MAP_ZOOM?this.DEFAULT_MAP_ZOOM:zoom;this.setMap({lat:avgLat,lon:avgLon,zoom:zoom});};ls.GMapController.prototype.getZoom=function(){var zoom=this.DEFAULT_MAP_ZOOM;if(this.initialGeoData.north&&this.initialGeoData.east&&this.initialGeoData.south&&this.initialGeoData.west){var ne=new GLatLng(this.initialGeoData.east,this.initialGeoData.north);var sw=new GLatLng(this.initialGeoData.west,this.initialGeoData.south);var bounds=new GLatLngBounds(sw,ne);zoom=this.map.getBoundsZoomLevel(bounds,this.map.getSize());}
return zoom;};extend(ls.GMapController,[ls.EventDispatcher]);var i18n=callableType(function(k){var dict={};this.toString=function(){return"[callableType i18n]";};this.extend=function(d){dict=cp(dict,d);return this.getDict();};this.getDict=function(){var d=(APP_SETTINGS&&APP_SETTINGS.i18n)?APP_SETTINGS.i18n:{};return cp(dict,d);};this.__call__=function(){var messageId=arguments[1]||null;var trans=this.getDict()[messageId]||messageId;return trans;};});var _=new i18n();ls.Utils={toString:function(){return"[object ls.Utils]";},compileString:function(string,dict){var string=unescape(string);for(var p in dict){var re=new RegExp('\\${'+p+'}','g');var repl=dict[p]||'';string=string.replace(re,repl);}
return string;},equal:function(obj1,obj2){if(!obj1&&obj2)return false;if(obj1&&!obj2)return false;var equal=true;for(p in obj1){if(obj1[p]!=obj2[p])return false;}
return equal;},equalArr:function(arr1,arr2){if(arr1.length!=arr2.length)return false;equal=true;for(var i=0;i<arr1.length;i++){if(arr1[i]!=arr2[i])return false;}
return equal;},bool:function(obj){if(typeof(obj)=='object'){for(var p in obj)return true;return false;}
return Boolean(obj);},regMap:function(str,map){for(var name in map)if(str.match(map[name]))return name;},createArgumentsArray:function(args){var arr=[];for(var i=0;i<args.length;i++){arr[i]=args[i];}
return arr;},convertTimestamp:function(timestamp){var date=new Date(timestamp);var day=(date.getDate().toString().length==1)?"0"+date.getDate():date.getDate();var month=(date.getMonth().toString().length==1)?"0"+date.getMonth():date.getMonth();var year=date.getFullYear();var hours=(date.getHours().toString().length==1)?"0"+date.getHours():date.getHours();var seconds=(date.getMinutes().toString().length==1)?"0"+date.getMinutes():date.getMinutes();return day+"."+month+"."+year+" "+hours+":"+seconds+" Uhr";},getNSAttributes:function(elem,namespace){var attrs={};for(var k=0;k<elem.attributes.length;k++){var a=elem.attributes[k];if(a.nodeName.indexOf(namespace)==0){attrs[a.nodeName]=a.nodeValue;}}
return attrs;},parseQueryString:function(qs,type,html){var queryString=(typeof qs==="string"&&qs.length>0)?qs:null;if(!queryString)return null;var type=['dict','data'].contains(type)?type:'dict';var allowHtml=typeof html==='boolean'?html:false;var kvpairs=queryString.split("&");if(!kvpairs){if(type=='data'){return{'data':{}};}else if(type=='dict'){return{};}}
var o={};for(var i=0;i<kvpairs.length;i++){var kv=kvpairs[i].split("=");o=this.extendObject(o,kv);}
ls.log("parseQueryString:",qs,type,html,o);return o;},extendObject:function(obj,kv){ls.log(obj,kv);var v=kv[1];var k=kv[0].split('.');var key=k.shift();if(!obj){if(key){var obj={};}else{v=decodeURIComponent(v.replace(/\+/g,"%20"));v=v.replace(/<script\b[^>]*>(.*?)<\/script>/i,"");if(['True','true'].contains(v))v=true;if(['False','false'].contains(v))v=false;if(['None','none'].contains(v))v=null;return v;}}
obj[key]=this.extendObject(obj[key],[k.join('.'),v]);return obj;},redirect:function(url,context,event){if(!url)return;if(event){event.preventDefault();event.stopPropagation();}
var same=false;if(url.match(/#/g)&&window.location.href&&url){var h=window.location.href.split('#');var u=url.split('#');if(h&&u&&(h[0].indexOf(u[0])>=0)){same=true;}}
if(same){window.location.href=url;window.location.reload();}else{window.setTimeout(function(){window.location.href=url;},5);}},reload:function(){window.setTimeout(function(){window.location.hash='';window.location.reload();},5);}};ls.Scrolling={toString:function(){return"[object ls.Scrolling]";},scrollToElement:function(elementId,yoffset){var yoffset=(yoffset)?yoffset:0;var el=document.getElementById(elementId);window.scrollTo(0,this.getOffset(el,yoffset));},scrollToNode:function(element){if(!element)return;var offset=this.getOffset(element,0);if(offset<window.pageYOffset){window.scrollTo(0,offset);}},getOffset:function(element,offset){var yoffset=yoffset?yoffset:0;var scrollY=0;while(element!=null){scrollY+=element.offsetTop;element=element.offsetParent;}
return scrollY+offset;}};ls.GarbageCollector={toString:function(){return"[object ls.GarbageCollector]";},garbage:[],addItem:function(item){this.garbage.push(item);},purge:function(){while(this.garbage.length>0){var item=this.garbage.pop();delete item;}}};__makeDispatchable(ls.GarbageCollector);ls.Cookie={toString:function(){return"[object ls.Cookie]";},set:function(c_name,value,expire,path){if(!path)path="/";var exdate=new Date();if(typeof(expire)==="object"){exdate=expire;}
else{exdate.setDate(exdate.getDate()+expire);}
var c=c_name+"="+value;if(expire!=null)c+=";expires="+exdate.toGMTString();c+=";path="+path;document.cookie=c;},get:function(c_name){if(document.cookie.length>0){c_start=document.cookie.indexOf(c_name+"=");if(c_start!=-1){c_start=c_start+c_name.length+1;c_end=document.cookie.indexOf(";",c_start);if(c_end==-1)c_end=document.cookie.length;return unescape(document.cookie.substring(c_start,c_end));}}
return false;}};ls.StorageManager={toString:function(){return"[object ls.StorageManager]";},getDomain:function(){return window.location.hostname.replace(/\./g,"");},getWindowData:function(){var data={};try{data=(window.name!="")?JSON2.parse(window.name):{};}catch(e){window.name="{}";}
return data;},getData:function(key){var ns=this.getDomain();var win=this.getWindowData();return win[ns]?(win[ns][key]||win[ns]):{};},addData:function(key,val){var win=this.getWindowData();var ns=this.getDomain();if(!win[ns])win[ns]={};win[ns][key]=val;window.name=JSON2.stringify(win);},pushData:function(key,val){var data=this.getData(key);if(isArray(data)){if(isArray(val)){for(var i=0;i<val.length;i++){data.push(val[i]);}}else{data.push(val);}}else{data=[val];}
this.addData(key,data);}};__makeDispatchable(ls.StorageManager);ls.AjaxEvent=function(type,data){this.type=type;this.data=(data)?data:null;this.target=null;};ls.Event={toString:function(){return"[object ls.Event]";},AJAX_LOAD:"load",AJAX_COMPLETE:"complete",AJAX_SUCCESS:"success",AJAX_FAIL:"fail",AJAX_READY:"ready",AJAX_HISTORY:"history",USER_ACTION:"user_action",USER_READY:"ready",USER_LOGIN:"login",USER_LOGOUT:"logout",CAPTCHA_INIT:"init",CAPTCHA_LOAD:"load",CAPTCHA_CREATE:"create",CAPTCHA_COMPLETE:"complete",CAPTCHA_DESTROY:"destroy",CAPTCHA_RELOAD:"reload",OVERLAY_INIT:"init",OVERLAY_LOAD:"load",OVERLAY_COMPLETE:"open",OVERLAY_CLOSE:"close",OVERLAY_CHANGE:"change",UPLOAD_SELECT:"select",UPLOAD_PROGRESS:"progress",UPLOAD_COMPLETE:"complete",UPLOAD_ERROR:"error",UPLOAD_DEFAULT:"default",FORM_BEFORE_SUBMIT:"beforeSubmit",FORM_SUBMIT:"submit",FORM_RESPONSE:"response",FORM_SUCCESS:"success",FORM_FAIL:"fail",FORM_FORMDATA:"formdata",FORM_CLOSE:"formClose",FORM_LOAD:"formLoad",FORM_SWITCH:"formSwitch",FORM_CUSTOM:"formCustom",RPC_RESPONSE:"response",RPC_ERROR:"error",RPC_SUCCESS:"success",RPC_FAIL:"fail",HOVER_OVER:"hoverOver",HOVER_OUT:"hoverOut",GEOPOS_OVER:"geoPosOver",GEOPOS_OUT:"geoPosOut",MAP_CHANGED:"mapChanged",MAP_DATA:"mapData",MAP_MARKER_SELECT:"mapMarkerSelected",MAP_MARKER_UNSELECT:"mapMarkerUnselected",MAP_NEW_GEODATA:"newGeodata",MAP_ADD_GEODATA:"addGeodata",MAP_ADD_PIN:"mapAddPin",PIN_DATA:"pinData",LINK_CLICKED:"linkClicked",TAB_SELECTED:"tabSelected",TAB_SWITCHED:"tabSwitched",CAROUSEL_BEFORE:"carouselBeforeAnimation",CAROUSEL_AFTER:"carouselAfterAnimation",CAROUSEL_NEXT:"carouselNext",CAROUSEL_PREV:"carouselPrev",GOOGLE_LOCAL_LOADED:"googleLocalLoaded"};ls.OverlayManager={OFFSET_TOP:25,isOpen:false,context:null,params:null,holder:$j("#overlay-holder"),content:$j("#overlay-content",this.holder),loading:$j('<div align="right"><img src="'+APP_SETTINGS.MEDIA_URL+'images/ajax-loader.gif" alt="'+_('loading-data')+'" title="'+_('loading-data')+'" /></div>'),awaiting:0,minHeight:100,toString:function(){return"[object ls.OverlayManager]";},closeButton:function(){return $j(".close",this.holder);},backButton:function(){return $j(".back",this.holder);},reloadButton:function(){return $j(".reload",this.holder);},setOverlay:function(holderId,contentId){if(!holderId||!contentId){return;}else{this.holder=$j("#"+holderId);this.content=$j("#"+contentId,this.holder);}},initLink:function(node,params,attrs){var url=attrs.href||(params.url||null);if(!url)return;var processor=params.processor||null;var overlayURL=url.replace(/(.*)([\/r|#]\/)(.*)/,"/$3");var action=this.isOpen?this.switchOverlay:this.openOverlay;node.bind("click",ls.Delegate.create(this,action,{'url':overlayURL,'processor':processor,'p':params,'a':attrs}));},openOverlay:function(data,context,event){if(event){event.preventDefault();event.stopPropagation();}
var h=$j(document).height();if($j.browser.safari){var top=document.body.scrollTop;}else{var top=document.documentElement.scrollTop;}
$j("#overlay").css("top",top+this.OFFSET_TOP);$j("#overlayBackground").css("height",h);$j("#overlayBackgroundIFrame").css("height",h);this.holder.show();this.loadOverlayContent(data);},loadOverlayContent:function(data,context,response){this.setBusy(true);this.dispatchEvent(new ls.AjaxEvent(ls.Event.OVERLAY_LOAD,data.url));$j.ajax({url:data.url,type:"GET",error:ls.Delegate.create(this,this.onError,null),success:ls.Delegate.create(this,this.onSuccess,data)});},onSuccess:function(data,context,response){if(data.p.width)this.content.css("width",data.p.width);if(data.p.height){if(data.p.height=='max'){this.setMaxHeight();}else{this.content.css("height",data.p.height);}}
if(data.processor){response=data.processor.call(context,response,data.p);}
this.content.css("visibility","hidden");this.content.empty().append(response);var img=$j("img",this.content);if(img.length>0){this.awaiting=img.length-1;img.bind("load",ls.Delegate.create(this,this.onOverlayComplete,data));img.bind("error",ls.Delegate.create(this,this.onOverlayComplete,data));}else{this.onOverlayComplete(data);}},onError:function(data,context,response){var xhr=response||{'status':'undefined','statusText':'No XHR response!'};var response='<h4 class="ajax-error">${hint}</h4><p>${code} ${text}</p>';var repl={"hint":_('error-occured'),"code":xhr.status,"text":xhr.statusText};this.content.css("visibility","hidden");this.content.empty().append(ls.Utils.compileString(response,repl));this.onOverlayComplete(null);},onOverlayComplete:function(data){if(this.awaiting>0){this.awaiting-=1;return;}
$j('#mk-page-content OBJECT').hide();$j('#mk-page-content .business-info-image-substitute iframe').hide();$j(".close-button span",this.content).show();this.closeButton().unbind("click");this.closeButton().bind("click",ls.Delegate.create(this,this.closeOverlay,null));if(data.p.back){var data={'url':data.p.back,'processor':null,'p':{},'a':{}};this.backButton().show().unbind("click");this.backButton().bind("click",ls.Delegate.create(this,this.switchOverlay,data));}
this.reloadButton().unbind("click");this.reloadButton().bind("click",ls.Delegate.create(ls.Utils,ls.Utils.reload,null));var context=this.holder;this.content.css("height","");this.content.css("visibility","visible");var code=data.p.code||'';this.dispatchEvent(new ls.AjaxEvent(ls.Event.OVERLAY_COMPLETE,{'code':code,'context':context,'data':data}));},switchOverlay:function(data,context,event){event.preventDefault();event.stopPropagation();if(this.isOpen){var h=this.content.height();this.content.css("height",h);this.loadOverlayContent(data);}else{ls.log("No open overlay!");}},closeOverlay:function(data,context,event){if(event)event.preventDefault();$j(document).unbind("keypress");this.holder.hide();this.onOverlayClosed();this.isOpen=false;},onOverlayClosed:function(){$j(".close-button span",this.content).hide();this.backButton().hide();this.content.css("width","");this.content.css("height","");this.content.empty();$j('#mk-page-content OBJECT').show();$j('#mk-page-content .business-info-image-substitute iframe').show();this.dispatchEvent(new ls.AjaxEvent(ls.Event.OVERLAY_CLOSE,null));},setBusy:function(bool,event){this.isOpen=true;if(bool===true){this.content.empty().append(this.loading);$j(".close-button span",this.content).hide();this.backButton().hide();}else if(bool===false){this.content.empty();}},setMaxHeight:function(){var clientHeight=document.documentElement.clientHeight;var scrollTop=document.documentElement.scrollTop;var h=clientHeight-scrollTop-(2*this.OFFSET_TOP);h=(h<=this.minHeight)?this.minHeight:h;$j("#overlay").css("height",h);this.content.css("height",h-55);},setMinHeight:function(h){if(isNaN(h))return;this.minHeight=parseInt(h,10);return this.minHeight;}};__makeDispatchable(ls.OverlayManager);ls.JsonRPC=function(){this.JsonRPC.apply(this,arguments);};ls.JsonRPC.prototype.JsonRPC=function(endpoint,host){this.endpoint=endpoint;if(host){this.host=host;}
else{this.host=window.location.protocol+"//"+window.location.host;}
this.url=this.host+this.endpoint;this.__init__.apply(this,arguments);};ls.JsonRPC.prototype.__init__=function(){this.errors=["Invalid Captcha","NoSuchUser","UserExists","AlreadyLoggedIn","Invalid old_pass","Empty old_pass","Invalid new_email","name and email must be provided","old_pass and new_pass are equal","old_email and new_email are equal"];};ls.JsonRPC.prototype.call=function(method,params){if(!typeof params==="object")return;var id=Math.floor(Math.random()*1000000);var data=new Object();data.method=method;data.id=id;data.version="1.1";data.params=params;if(this.endpoint){var jsonData=JSON2.stringify(data);$j.post(this.url,jsonData,ls.Delegate.create(this,this.onResponse,null));}else{ls.log("No endpoint");}};ls.JsonRPC.prototype.onResponse=function(data,context,response){this.dispatchEvent(new ls.AjaxEvent(ls.Event.RPC_RESPONSE,response));if(response.result){ls.log("JSON-RPC/Response: ",response.result);this.dispatchEvent(new ls.AjaxEvent(ls.Event.RPC_SUCCESS,response.result));}else if(response.result===false){ls.log("JSON-RPC/Response: ",response.result);this.dispatchEvent(new ls.AjaxEvent(ls.Event.RPC_FAIL,response.result));}else if(response.error){var error=null;for(var i=0;i<this.errors.length;i++){var re=new RegExp(this.errors[i]);if(response.error.message.match(re)||response.error.type.match(re)){var name=this.errors[i].replace(/\s/g,"-").toLowerCase();error={"name":name,"error":response.error};}}
var eventData=error||response;this.dispatchEvent(new ls.AjaxEvent(ls.Event.RPC_FAIL,eventData));ls.log("JSON-RPC/Error/Message: ",response.error.message);ls.log("JSON-RPC/Error/Type: ",response.error.type);}};extend(ls.JsonRPC,[ls.EventDispatcher]);ls.FormManager=function(){this.FormManager.apply(this,arguments);};ls.FormManager.prototype.FormManager=function(){this.__init__.apply(this,arguments);};ls.FormManager.prototype.__init__=function(){};ls.FormManager.prototype.toString=function(){return"[object ls.FormManager]";};ls.FormManager.actions={overlay:function(){var overlay={'url':this.params.ajaxurl,'a':{},'p':{}};ls.Document.dispatchEvent(new ls.AjaxEvent(ls.Event.FORM_SWITCH,overlay));},close:function(){window.setTimeout(function(){ls.Document.dispatchEvent(new ls.AjaxEvent(ls.Event.FORM_CLOSE,null));},2000);},reload:function(){ls.Utils.reload();},redirect:function(){var url=this.params.ajaxurl;ls.Utils.redirect(url);},load:function(){var data={'target':this.params.target,'url':this.params.ajaxurl};ls.Document.dispatchEvent(new ls.AjaxEvent(ls.Event.FORM_LOAD,data));},custom:function(){var data=this.params;ls.Document.dispatchEvent(new ls.AjaxEvent(ls.Event.FORM_CUSTOM,data));}};ls.FormManager.validators={required:function(val,params){if(val.length==0)return false;return val;},notRequired:function(validation,val,params){if(val.length==0)return val;return validation;},email:function(val,params){if(val.length==0)return false;var re=/(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$/;if(!val.match(re))return false;return val;},change_email:function(val,params){var valid=ls.FormManager.validators.email(val,params);if(!valid)return valid;var currentmail=$j("#current_email").val();if(currentmail==val)return false;return val;},url:function(val,params){var url=val;if(!val.match(/^(http:\/\/)(.*)$/))url="http://"+val;var re=/(http|https):\/\/[\w\-_]+(\.[\w-_]+)+([\w\-\.,@?^=%&amp;:\/~\+#]*[\w\-\@?^=%&amp;\/~\+#])?/;if(!re.test(url))return false;return url;},zipcode:function(val,params){var re=/^\d{4,6}$/;if(!val.match(re))return false;return val;},phone:function(val,params){var re=/^[\d\+\(\)\/\- ]+$/;if(!val.match(re))return false;return val;},notrequired_phone:function(val,params){var valid=ls.FormManager.validators.phone(val,params);return ls.FormManager.validators.notRequired(valid,val,params);},notrequired_url:function(val,params){var valid=ls.FormManager.validators.url(val,params);return ls.FormManager.validators.notRequired(valid,val,params);},notrequired_zipcode:function(val,params){var valid=ls.FormManager.validators.zipcode(val,params);return ls.FormManager.validators.notRequired(valid,val,params);},notrequired_password:function(val,params){var valid=ls.FormManager.validators.password(val,params);return ls.FormManager.validators.notRequired(valid,val,params);},confirm:function(val,params){var target=$j(params.target);if(target.val()!=val)return false;return val;},remote:function(val,params){},password:function(val,params){var re=/^\S{6,}$/;if(!val.match(re))return false;return val;},checked:function(val,params,checkbox){return checkbox.checked;}};extend(ls.FormManager,[ls.EventDispatcher]);ls.RPCFormManager=function(){this.RPCFormManager.apply(this,arguments);};ls.RPCFormManager.prototype.RPCFormManager=function(node,params,attrs){this.context=node;this.params=params;this.attrs=attrs;this.info={};this.type=this.params.type||"dict";this.autofill=this.params.fill||false;this.formId=this.attrs.id;this.submitButton=$j("input#"+this.formId+"-submit",this.context);this.onEnterSubmit=this.params.onentersubmit?eval(this.params.onentersubmit):true;this.allowHTML=this.params.allowhtml?eval(this.params.allowhtml):false;this.formPart=this.params.formpart?$j(this.params.formpart,this.context):null;this.successPart=this.params.successpart?$j(this.params.successpart,this.context):null;this.errorPart=this.params.errorpart?$j(this.params.errorpart,this.context):$j(".form-errorpart",this.context);this.__init__.apply(this,arguments);};ls.RPCFormManager.prototype.__init__=function(){if(this.autofill)this.getFormData();};ls.RPCFormManager.prototype.toString=function(){return"[object ls.RPCFormManager]";};ls.RPCFormManager.prototype.getFormData=function(){var formDataProxy=new ls.JsonRPC(this.attrs.action);formDataProxy.addEventListener(ls.Event.RPC_RESPONSE,ls.Delegate.create(this,this.fillFormData,null));formDataProxy.call("asDict",{});};ls.RPCFormManager.prototype.fillFormData=function(data,context,response){var res=response.result;var fields=[];$j("*",this.context).each(function(){if(this.name){for(var k in res){if(this.name.match(k)){if(this.type=="checkbox"||this.type=="radio"){this.checked=res[k];}else{$j(this).val(res[k]);}}}
fields.push($j(this));}})
ls.log($j(fields));$j("input[type=password]",this.context).val("");};ls.RPCFormManager.prototype.init=function(){$j("input:checkbox",this.context).bind("change",function(){if($j(this).val()===""||$j(this).val()==="false"){$j(this).val("true");}else if($j(this).val()==="true"){$j(this).val("false");}});$j("input",this.context).bind("keypress",ls.Delegate.create(this,this.onKeyPress,null));this.submitButton.bind("click",ls.Delegate.create(this,this.submitForm,null));this.proxy=new ls.JsonRPC(this.attrs.action);this.proxy.addEventListener(ls.Event.RPC_FAIL,ls.Delegate.create(this,this.onFormFail,null));this.proxy.addEventListener(ls.Event.RPC_SUCCESS,ls.Delegate.create(this,this.onFormSuccess,null));this.proxy.addEventListener(ls.Event.RPC_RESPONSE,ls.Delegate.create(this,this.onFormResponse,null));$j('.ajax-validate',this.context).bind('blur',ls.Delegate.create(this,function(data,context,event){if(context.val())this.validateFields(context);}));};ls.RPCFormManager.prototype.submitForm=function(data,context,event){event.preventDefault();this.dispatchEvent(new ls.AjaxEvent(ls.Event.FORM_BEFORE_SUBMIT,null));var fes=typeof this.params.forceemptystring=="boolean"?this.params.forceemptystring:false;var fd=this.context.formSerialize(null,fes);var valid=this.validateFields();if(!valid){ls.log("Form didn't pass validation for data",fd);}else{this.submitButton.attr("disabled","disabled");var formData=ls.Utils.parseQueryString(fd,this.type,this.allowHTML);this.info['method']=this.params.method
this.proxy.call(this.params.method,formData);}};ls.RPCFormManager.prototype.validateFields=function(fields){var fields=fields||$j('.ajax-validate',this.context);var globalValid=true;fields.each(function(){var field=$j(this);var attrs=com.lovelysystems.Application.getCommandAttrs(this);var validators=attrs.validator.split(",");for(var i=0;i<validators.length;i++){var method=validators[i].trim();if(method){eval('var validator=ls.FormManager.validators.'+method);var checkbox=field[0].type=="checkbox"?field[0]:null;valid=validator.call(this,field.val(),attrs,checkbox);var fid=field.attr('id').replace(".","\\.");var errormsg=$j('#'+fid+'-'+attrs.validator+'-invalid');var validmsg=$j('#'+fid+'-'+attrs.validator+'-valid');if(valid===false){if(errormsg.length)errormsg.show();if(validmsg.length)validmsg.hide();field.addClass("invalid");field.removeClass("valid");globalValid=false;}else{if(errormsg.length)errormsg.hide();if(validmsg.length)validmsg.show();field.removeClass("invalid");field.addClass("valid");field.val(valid);}}}});return globalValid;};ls.RPCFormManager.prototype.onKeyPress=function(data,context,event){if(event.which==13&&this.onEnterSubmit){this.submitForm(data,context,event);}};ls.RPCFormManager.prototype.onFormResponse=function(data,context,response){ls.Scrolling.scrollToNode(this.context[0]);this.submitButton.removeAttr("disabled");};ls.RPCFormManager.prototype.onFormSuccess=function(data,context,response){this.errorPart.hide();if(this.autofill){var result={"result":response};this.fillFormData(data,context,result);}
if(this.successPart&&!this.formPart){var s=this.successPart;s.show();window.setTimeout(function(){s.hide();},3000);}
if(this.formPart&&this.successPart){this.formPart.hide();this.successPart.show();$j('.ajax-close',this.successPart).bind('click',function(){ls.OverlayManager.closeOverlay();});}
this.info['method']=this.params.method
var eventData={};eventData.method=this.info.method;eventData.response=response;this.dispatchEvent(new ls.AjaxEvent(ls.Event.FORM_SUCCESS,eventData));var event=this.params.event;if(event&&ls.FormManager.actions[event])ls.FormManager.actions[event].call(this);};ls.RPCFormManager.prototype.onFormFail=function(data,context,response){if(response&&response.name){$j("."+response.name,this.context).show();}else if(response&&response.error){this.errorPart.show();$j(".form-errormessage",this.context).text(response.error.message);}else{this.errorPart.show();}
var eventData={};eventData.method=this.info.method;eventData.response=response;this.dispatchEvent(new ls.AjaxEvent(ls.Event.FORM_FAIL,eventData));};ls.RPCFormManager.prototype.clearErrorMessage=function(data,context,event){};ls.RPCFormManager.prototype.setField=function(fieldName,val){var field=$j("#"+this.formId+"_"+fieldName);if(field.length>0){field.val(val.toString());}};extend(ls.RPCFormManager,[ls.FormManager]);ls.TemplateParser=function(node){this.TemplateParser(node);};ls.TemplateParser.prototype.TemplateParser=function(node){this.fade=false;this.context=node;this.html=this.context.html();this.context.empty();this.__init__();};ls.TemplateParser.prototype.__init__=function(){};ls.TemplateParser.prototype.toString=function(){return"[object ls.TemplateParser]";};ls.TemplateParser.prototype.parseTemplate=function(obj,pos,node){var obj=obj?obj:{};var pos=pos?pos:"append";var node=node?node:this.context;var html=ls.Utils.compileString(this.html,obj);if(pos=="prepend"){if(this.fade){var tmp=$j(html);tmp.hide();node.show();node.prepend(tmp);tmp.fadeIn("slow");}else{node.prepend(html).show();}}else if(pos=="append"){if(this.fade){var tmp=$j(html);tmp.hide();node.append(tmp);tmp.fadeIn("slow");}else{node.append(html).show();}}};ls.TemplateParser.prototype.clearNode=function(str){if(str){this.context.empty().append(str);}else{this.context.empty();}};extend(ls.TemplateParser,[ls.EventDispatcher]);var mk={DESCRIPTION:_('marketizer'),SEARCH_RESULT_DATA_KEY:"mk.searchresults",GOOGLE_LOCAL_URL:"/business/${lat}/${lng}/${title}",POWERED_BY:'<img src="http://maps.gstatic.com/intl/de_at/mapfiles/poweredby.png" alt="Powered by Google" title="Powered by Google" class="google-local-branding" />'};mk.TextProcessors={compile:function(text,data){return ls.Utils.compileString(text,data);}};mk.Context={_context:null,get:function(){if(!this._context)this._context=$j('#mk');return this._context;}}
mk.getGLatLngBounds=function(){if(window.googleMapsAPI==false)
return 0;var ne=new GLatLng(APP_SETTINGS.GEO_BOX.east,APP_SETTINGS.GEO_BOX.north);var sw=new GLatLng(APP_SETTINGS.GEO_BOX.west,APP_SETTINGS.GEO_BOX.south);var bounds=new GLatLngBounds(sw,ne);return bounds;};mk.AutoCompleteLocation=function(element,params,attrs){this.AutoCompleteLocation(element,params,attrs);};mk.AutoCompleteLocation.prototype.AutoCompleteLocation=function(element,params,attrs){this.context=element;this.a=attrs;this.p=params;this.geocoder=new ls.GGeoController();this.geocoder.setCountryCode(APP_SETTINGS.GMAP_COUNTRY);this.geocoder.setLanguageCode(APP_SETTINGS.GMAP_LANGUAGE);this.geocoder.setFormat("json");this.geocoder.setViewport(mk.getGLatLngBounds());this.__init__();};mk.AutoCompleteLocation.prototype.__init__=function(){this.lastQuery="";this.current=-1;this.results=null;this.loaderImageUrl=APP_SETTINGS.MEDIA_URL+"images/ajax-loader.gif";if(this.context.val()!="")this.preload();};mk.AutoCompleteLocation.prototype.bind=function(){this.error=$j(".no-result",this.context.parent());var div="<div id='${id}' class='${class}'></div>";var wrapper=ls.Utils.compileString(div,{"id":"auto-complete-field-"+new Date().getTime(),"class":"auto-complete-field"});this.context.wrap(wrapper);this.context.parent().append('<ul class="autocomplete-list"></ul>');this.resultList=$j("ul.autocomplete-list",this.context.parent());var cssClass="latlonbox";var id=cssClass+new Date().getTime();this.context.parent().append('<input type="hidden" class="'+cssClass+'" id="'+id+'" name="'+cssClass+'" />');this.locationField=$j("input#"+id,this.context.parent());this.context.bind("keyup",ls.Delegate.create(this,this.onInput,null));};mk.AutoCompleteLocation.prototype.preload=function(){var val=this.context.val();this.setLoading(true);this.geocoder.fetch(val,ls.Delegate.create(this,this.onResponse,false));};mk.AutoCompleteLocation.prototype.onInput=function(data,context,event){if(event.which==13){event.preventDefault();this.resultList.hide();return;}else if(event.which==38&&this.results){event.preventDefault();this.keyHover(-1);return;}else if(event.which==40&&this.results){event.preventDefault();this.keyHover(1);return;}
var val=event.target.value;if(val.length===0){this.error.hide();this.setLatLonBox();}
if(this.lastQuery==val)return;this.lastQuery=val;if(this.geocoder&&val.length>1){if(APP_SETTINGS.GMAP_SUFFIX&&!APP_SETTINGS.GMAP_SUFFIX.match(val)){val+=", "+APP_SETTINGS.GMAP_SUFFIX;}
this.setLoading(true);this.geocoder.fetch(val,ls.Delegate.create(this,this.onResponse,true));}};mk.AutoCompleteLocation.prototype.reset=function(){this.setLatLonBox({'error':true});this.setLoading(false);this.resultList.empty().hide();return;};mk.AutoCompleteLocation.prototype.onResponse=function(data,context,response){if(response.Status.code!=200)return this.reset();this.resultList.empty();this.current=-1;this.results=response.Placemark;if(!this.results)return this.reset();var res=[];for(var i=0;i<this.results.length;i++){if(window.googleMapsAPI==true){var geo=this.results[i].ExtendedData.LatLonBox;var point=new GLatLng(this.results[i].Point.coordinates[0],this.results[i].Point.coordinates[1]);if(mk.getGLatLngBounds().containsLatLng(point)){var address=this.results[i].address;var li=$j('<li class="autocomplete-item">'+address+'</li>');li.unbind("click").bind("click",ls.Delegate.create(this,this.onSelect,geo));li.bind('mouseover',function(event){$j(this).addClass("hover");});li.bind('mouseout',function(event){$j(this).removeClass("hover");});this.resultList.append(li);res.push(this.results[i]);}}else{res.push(this.results[i]);}}
if(res.length>=1&&data)this.resultList.show();if(res.length==1){this.setLatLonBox(res[0].ExtendedData.LatLonBox);}
this.error.hide();this.setLoading(false);};mk.AutoCompleteLocation.prototype.onSelect=function(data,context,event){this.select(context.text(),data);this.resultList.empty();this.resultList.hide();};mk.AutoCompleteLocation.prototype.select=function(text,box){this.context.val(text);this.setLatLonBox(box);};mk.AutoCompleteLocation.prototype.setLatLonBox=function(latlonbox){var res=latlonbox?JSON2.stringify(latlonbox):"";this.locationField.val(res);this.dispatchEvent(new ls.AjaxEvent(ls.Event.AJAX_READY,res));};mk.AutoCompleteLocation.prototype.keyHover=function(step){var items=this.resultList.children();if(this.current+step<0||this.current+step>=items.length)return;$j(items[this.current]).removeClass("hover");this.current+=step;$j(items[this.current]).addClass("hover");var text=$j(items[this.current]).text();var geo=this.results[this.current].ExtendedData.LatLonBox;this.select(text,geo);};mk.AutoCompleteLocation.prototype.setLoading=function(bool){if(bool){var right=this.context.width()-10;this.context.css("background","#FFFFFF url("+this.loaderImageUrl+") no-repeat scroll "+right+"px center");}else{this.context.css("background","#FFFFFF none no-repeat scroll 0 0");}};extend(mk.AutoCompleteLocation,[ls.EventDispatcher]);mk.SearchForm=function(element,params,attrs){this.SearchForm(element,params,attrs);};mk.SearchForm.prototype.SearchForm=function(element,params,attrs){this.context=element;this.p=params;this.a=attrs;this.__init__();};mk.SearchForm.prototype.__init__=function(){this.CHAR_PLACEHOLDER="-";this.COOKIE="mk-search";this.SEPARATOR="::";this.errorNode=$j(".no-result",this.context);this.inputFieldBusiness=$j("input#"+this.a.id+"-business",this.context);this.inputFieldLocation=$j("input#"+this.a.id+"-location",this.context);this.submitButton=$j("input.submit",this.context);var parts=location.href.split("/");if(parts.length>3&&parts[3]=="search"){this.fill(parts[4]);}
if(this.isCategorySearch()){$j('.ajaxSearchScope').show();$j('#searchCategory').attr("checked","checked");}};mk.SearchForm.prototype.isCategorySearch=function(){return(document.location.href.indexOf('/cat/')!=-1)};mk.SearchForm.prototype.hasCategoryDropdown=function(){return $j('#mainsearch-form-category-select').length>0;}
mk.SearchForm.prototype.fill=function(cookie){return false;};mk.SearchForm.prototype.bind=function(){this.submitButton.bind("click",ls.Delegate.create(this,this.onSubmit,null));};mk.SearchForm.prototype.onSubmit=function(data,context,event){event.preventDefault();var query=this.inputFieldBusiness.val();var location=this.inputFieldLocation.val();var geo=$j("input.latlonbox",this.context).val();var cat=$j('#mainsearch-form-category-select').val();if(!cat&&!query&&(!location||!geo))return;try{geo=JSON2.parse(geo);}catch(e){geo={north:"0",south:"0",east:"0",west:"0"};ls.log("fallback",geo);}
if(geo.error){this.errorNode.show();return;}
var dict={"n":geo.north,"s":geo.south,"e":geo.east,"w":geo.west,"query":encodeURIComponent(query.toLowerCase().replace("/"," "))};var url=ls.Utils.compileString('/search/${n}/${s}/${e}/${w}/${query}',dict);if(this.isCategorySearch()){$j('input[name=searchScope]').each(function(e){if($j(this).attr("checked")&&$j(this).val()=="searchCategory"){var parts=document.location.href.split('/cat/')[1].split("/");if(parts.length>0){if(url.substr(url.length-1)!=='/')url+='/';url+="cat/"+parts[0];}
if(parts.length>1){url+='/'+parts[1];}}});}
if(this.hasCategoryDropdown()){if(url.substr(url.length-1)=='/')url=url.substring(0,url.length-1);url+=$j('#mainsearch-form-category-select').val();}
var cookie=query+this.SEPARATOR+location;ls.Cookie.set(this.COOKIE,cookie);var doSearch=function(){window.location=url;};window.setTimeout(doSearch,5);};mk.CountLink=function(element){this.CountLink(element);};mk.CountLink.prototype.CountLink=function(element){this.context=$j(element);this.__init__();};mk.CountLink.prototype.__init__=function(){this.bind();};mk.CountLink.prototype.bind=function(){this.context.bind("click",ls.Delegate.create(this,this.onLinkClicked));};mk.CountLink.prototype.onLinkClicked=function(data,context,event){var data=com.lovelysystems.Application.getCommandAttrs(event.target);this.dispatchEvent(new ls.AjaxEvent(ls.Event.LINK_CLICKED,data));};extend(mk.CountLink,[ls.EventDispatcher]);mk.TabBox=function(element){this.TabBox(element);};mk.TabBox.prototype.TabBox=function(element){this.context=$j(element);this.menu=$j(".tab-menu",this.context);this.menuItems=$j("td",this.menu);this.body=$j(".tab-body",this.context);this.bodyItems=this.body.children();this.currentTab=null;this.__init__();};mk.TabBox.prototype.__init__=function(){this.bind();};mk.TabBox.prototype.bind=function(){this.menuItems.bind("click",ls.Delegate.create(this,this.onTabSelected));};mk.TabBox.prototype.onTabSelected=function(data,context,event){var data=com.lovelysystems.Application.getCommandAttrs(event.target);this.dispatchEvent(new ls.AjaxEvent(ls.Event.TAB_SELECTED,data));var index=this.menuItems.index(context);if(index==this.currentTab-1)return;this.switchTab(index,event);};mk.TabBox.prototype.switchTab=function(index,event){var data=com.lovelysystems.Application.getCommandAttrs(event.target);this.dispatchEvent(new ls.AjaxEvent(ls.Event.TAB_SWITCHED,data));this.menuItems.removeClass("tab-item-active");$j(this.menuItems[index]).addClass("tab-item-active");if(this.currentTab){var c=$j(this.bodyItems[this.currentTab-1]);c.fadeOut("fast",ls.Delegate.create(this,this.fadeIn,index));}else{this.bodyItems.fadeOut("fast");this.fadeIn(index);}};mk.TabBox.prototype.fadeIn=function(index){$j(this.bodyItems[index]).fadeIn("fast");this.currentTab=index+1;};extend(mk.TabBox,[ls.EventDispatcher]);if(window.googleMapsAPI==true){mk.BusinessMarker=new GIcon(G_DEFAULT_ICON);mk.BusinessMarker.image=APP_SETTINGS.IMAGE_URL+"/pin.png";mk.BusinessMarker.hover=APP_SETTINGS.IMAGE_URL+"/pin-active.png";mk.BusinessMarker.shadow=APP_SETTINGS.IMAGE_URL+"/pin-shadow.png";mk.BusinessMarker.iconSize=new GSize(26,46);mk.BusinessMarker.shadowSize=new GSize(26,46);mk.BusinessMarker.iconAnchor=new GPoint(13,45);mk.BusinessMarker.infoWindowAnchor=new GPoint(78,48);mk.BusinessMarker.imageMap=[13,44,23,12,21,5,13,0,6,4,3,13];mk.BusinessMarker.__data__=null;mk.TempMarker=new GIcon(G_DEFAULT_ICON);mk.TempMarker.image=APP_SETTINGS.IMAGE_URL+"/pin2.png";mk.TempMarker.hover=APP_SETTINGS.IMAGE_URL+"/pin-active.png";mk.TempMarker.shadow=APP_SETTINGS.IMAGE_URL+"/pin-shadow.png";mk.TempMarker.iconSize=new GSize(26,46);mk.TempMarker.shadowSize=new GSize(26,46);mk.TempMarker.iconAnchor=new GPoint(13,45);mk.TempMarker.infoWindowAnchor=new GPoint(78,48);mk.TempMarker.imageMap=[13,44,23,12,21,5,13,0,6,4,3,13];mk.TempMarker.__data__=null;}
mk.Carousel=function(){this.Carousel.apply(this,arguments);};mk.Carousel.prototype.Carousel=function(){this.__init__.apply(this,arguments);};mk.Carousel.prototype.__init__=function(){};mk.Carousel.prototype.toString=function(){return"[object mk.Carousel]";};mk.Carousel.prototype.beforeAnimation=function(){this.dispatchEvent(new ls.AjaxEvent(ls.Event.CAROUSEL_BEFORE,{code:'/marketizer/coverflow'}));};mk.Carousel.prototype.afterAnimation=function(){this.dispatchEvent(new ls.AjaxEvent(ls.Event.CAROUSEL_AFTER,{code:'/marketizer/coverflow'}));};mk.Carousel.prototype.onPrev=function(){this.dispatchEvent(new ls.AjaxEvent(ls.Event.CAROUSEL_PREV,{code:'/marketizer/coverflow'}));};mk.Carousel.prototype.onNext=function(){this.dispatchEvent(new ls.AjaxEvent(ls.Event.CAROUSEL_NEXT,{code:'/marketizer/coverflow'}));};extend(mk.Carousel,[ls.Coverflow]);mk.ResultBatcher=function(node,params,attrs){this.ResultBatcher(node,params,attrs);};mk.ResultBatcher.prototype.ResultBatcher=function(node,params,attrs){this.context=node;this.p=params;this.a=attrs;this.__init__();};mk.ResultBatcher.prototype.__init__=function(){this.prev=$j("a.prev",this.context);this.next=$j("a.next",this.context);this.results=ls.StorageManager.getData(mk.SEARCH_RESULT_DATA_KEY);this.bind();};mk.ResultBatcher.prototype.bind=function(){var pos=this.getCurrentPosition();var pos_next=pos+1<this.results.length?pos+1:null;if(pos_next&&!isNaN(pos_next)){this.next.bind("click",ls.Delegate.create(this,this.onClick,pos_next));this.next.attr("title",this.results[pos_next].title);this.next.attr("href","#"+this.results[pos_next].url);}else{this.next.attr("title",_('no-more-results'));this.next.hide();}
var pos_prev=pos-1>=0?pos-1:null;if(pos_prev!==null&&!isNaN(pos_prev)){this.prev.bind("click",ls.Delegate.create(this,this.onClick,pos_prev));this.prev.attr("title",this.results[pos_prev].title);this.prev.attr("href","#"+this.results[pos_prev].url);}else{this.prev.attr("title",_('no-more-results'));this.prev.hide();}
this.context.show();};mk.ResultBatcher.prototype.getCurrentPosition=function(){if(!isArray(this.results))return null;var ident=APP_SETTINGS.business?APP_SETTINGS.business.ident:null
for(var i=0;i<this.results.length;i++){var res=this.results[i];if(res.ident==ident)return i;}
return null;};mk.ResultBatcher.prototype.onClick=function(data,context,event){this.next.unbind("click");this.prev.unbind("click");this.context.fadeTo("fast",0.25);event.preventDefault();var url=this.results[data].url;if(url){window.setTimeout(function(){window.location.href=url;},5);}
return;};mk.SearchResultLoader=function(node,params,attrs){this.SearchResultLoader(node,params,attrs);};mk.SearchResultLoader.prototype.SearchResultLoader=function(node,params,attrs){this.context=node;this.p=params;this.a=attrs;this.__init__();};mk.SearchResultLoader.prototype.toString=function(){return"[object mk.SearchResultLoader]";};mk.SearchResultLoader.prototype.__init__=function(){this.results=[]
var template=$j("#"+this.p.template);var target=$j("#"+this.a.target);this.parser=new ls.TemplateParser(template);this.parser.fade=true;};mk.SearchResultLoader.prototype.init=function(data,context,event){$j("#"+this.p.more_link).show();this.context.bind("click",ls.Delegate.create(this,this.onClick,null));};mk.SearchResultLoader.prototype.onClick=function(data,context,event){event.preventDefault();this.context.text(_('loading-data'));this.context.unbind("click");ls.get(this.a.href,ls.Delegate.create(this,this.onData,null));};mk.SearchResultLoader.prototype.onData=function(data,context,response){for(var i=0;i<response.length;i++){var res=response[i];if($j("#"+res.ident).length===0){this.results.push(res);}}
if(this.results.length>0){this.injectResults();this.context.hide();}else{ls.log("no results");}};mk.SearchResultLoader.prototype.injectResults=function(){var target=$j("#"+this.a.target);var res=this.results.shift();this.parser.parseTemplate(res,"append",target);if(!res.lat||!res.lon)$j("#map-reference-"+res.ident).hide();ls.Document.dispatchEvent(new ls.AjaxEvent(ls.Event.PIN_DATA,[res]));if(this.results.length>0){var that=this;window.setTimeout(function(){that.injectResults();},150);}else{$j("#"+this.p.all_link).show();com.lovelysystems.Application.execute(target.parent());target.children().removeClass("last");$j("#"+res.ident).addClass("last");}};mk.Utils={isMobile:function(){var uagent=navigator.userAgent.toLowerCase();var list=["midp","240x320","blackberry","netfront","nokia","panasonic","portalmmm","sharp","sie-","sonyericsson","symbian","windows ce","benq","mda","mot-","opera mini","philips","pocket pc","sagem","samsung","sda","sgh-","vodafone","xda","palm","iphone","ipod","android"];for(var d=0;d<list.length;d+=1){if(uagent.indexOf(list[d])!=-1){return true;}}
return false;},checkMobile:function(){if(ls.Cookie.get("mobileversion")==="false"){return;}
if(this.isMobile()){var loc=document.location.href;if(loc.indexOf("/business/")!=-1||loc.indexOf("/cat/")!=-1||document.location.host.length+8===loc.length){document.location.href="http://"+document.location.host+"/m"+document.location.pathname;}}},backToMobile:function(){ls.Cookie.set("mobileversion","true");document.location.href="/m/";},checkStartupHash:function(){var items=["/overlay/.+"];for(var i=0;i<items.length;i++){var re=new RegExp(items[0]);if(re.test(window.location.hash)){var url=window.location.hash.substr(1);var p={},a={},processor=null;var context=$j("[href$='"+url+"']");if(context.length>0){a=com.lovelysystems.Application.getNativeAttrs(context[0]);p=com.lovelysystems.Application.getCommandAttrs(context[0]);processor=p.processor;}
ls.OverlayManager.openOverlay({"url":url,"a":a,"p":p,"processor":processor});if(!isIE)window.location.hash="#";}}},checkBrowser:function(params){var type=params&&params.type||'page';if(type==='page'){if(!browser||!APP_SETTINGS.BROWSER_WARNING)return;var notSupported=APP_SETTINGS.BROWSER_NOT_SUPPORTED;for(var i=0;i<notSupported.length;i++){if(browser[notSupported[i].trim()]){jQuery.get('/__old_browser_warning__',function(val){$j('body').prepend("<div id='browser-warning' class='browser-warning'></div>");$j("#browser-warning").html(val);$j("#browser-warning").slideDown("slow")});}}}
else{if(!browser||!APP_SETTINGS.BROWSER_WARNING_EDITOR)return;var notSupported=APP_SETTINGS.BROWSER_NOT_SUPPORTED_EDITOR;for(var i=0;i<notSupported.length;i++){if(browser[notSupported[i].trim()]){jQuery.get('/__old_browser_warning_editor__',function(val){$j("#editor-browser-warning").html(val);$j("#editor-browser-warning").slideDown("slow")});}}}
if(this.isMobile()){jQuery.get('/__back_to_mobile_info__',function(val){$j('body').prepend("<div id='mobile-info' class='mobile-info'></div>");$j("#mobile-info").html(val);$j("#mobile-info").show();});}},SearchResults:{KEY:'srl',endpoint:'/common',method:'more',submit:function(){var proxy=new ls.JsonRPC(this.endpoint);proxy.addEventListener(ls.Event.RPC_RESPONSE,ls.Delegate.create(this,this.onResponse,null));var data=this.getData();if(data.length<1)return;proxy.call(this.method,[data]);},getData:function(){var items=[];$j('.more-link-tag').each(function(){var item=JSON2.parse(this.title);items.push(item);});return items;},onResponse:function(data,context,response){if(response.error)return;var srl=com.lovelysystems.Application.registry.get(this.KEY);for(var i=0;i<response.result.length;i++){var city=response.result[i][0];var more=response.result[i][1];for(var j=0;j<srl.length;j++){var re=new RegExp(city,"i");if(re.test(srl[j].a.title)&&more){ls.log(city,more,srl[j]);srl[j].init();}}}}}};mk.Tracking=callableType(function(){this.proxy=null,this.countSelector='co',this.searchSelector='so',this.endpoint='/common',this.method='count',this.toString=function(){return"[callableType mk.Tracking]";},this.__call__=function(ctref,context){var items=this.getData(context);if(!items.length)return;this.track(items);},this.track=function(data){if(!data)return;if(!this.proxy){this.proxy=new ls.JsonRPC(this.endpoint);this.proxy.addEventListener(ls.Event.RPC_RESPONSE,ls.Delegate.create(this,this.onResponse,null));}else{ls.log(this.toString(),"JSON Proxy already exists!");}
this.proxy.call(this.method,[data]);},this.getData=function(context){var c=typeof context!="object"?$j(document):context;var items=[];$j('.'+this.countSelector,c).each(function(){var item=JSON2.parse(this.title);items.push(item);});$j('.'+this.searchSelector,c).each(function(){var obj=JSON2.parse(this.title);var ht=obj.ht;delete obj.ht;var c=ls.Cookie.get('mk-search');obj.w=c?c.split("::")[0]:'';obj.l=c?c.split("::")[1]:'';var item=[ht,JSON2.stringify(obj)];items.push(item);});return items;},this.trackEvent=function(data,context,event){if(event&&event.counting){this.track([event.counting]);}else{ls.log(this.toString(),"No counting post data.");}},this.trackTab=function(data,context,event){ls.log("trackTab",event.counting);this.trackEvent(data,context,event);},this.trackLink=function(data,context,event){ls.log("trackLink",event.counting);this.trackEvent(data,context,event);},this.onResponse=function(data,context,response){ls.log(this.toString(),response);}})();extend(mk.Tracking,[ls.EventDispatcher]);mk.ScrollingBox=function(node){this.ScrollingBox(node);};mk.ScrollingBox.prototype.ScrollingBox=function(node){this.context=node;this.offsetY=this.context.position().top;if(isIE7)this.offsetY-=20;if(isIE6)this.offsetY+=20;this.height=this.context.height();this.additional_height=this.context.parent().height()-this.height;this.context.parent().css("height",(this.height+this.additional_height));this.context.css("top",this.offsetY);this.scrolling=false;this.offButton=$j(".scrolling-off",this.context);this.offButton.bind("click",ls.Delegate.create(this,this.toggleScrolling,null));this.offButton.show();this.onButton=$j(".scrolling-on",this.context);this.onButton.bind("click",ls.Delegate.create(this,this.toggleScrolling,null));this.onButton.hide();this.startInterval();};mk.ScrollingBox.prototype.getMaxOffsetY=function(){var maxOffsetY=mk.Context.get().offset().top
+mk.Context.get().height()
-this.context.height();return maxOffsetY;}
mk.ScrollingBox.prototype.checkPosition=function(){var scroll=0;if(typeof window.pageYOffset=='number'){scroll=window.pageYOffset;}else if(document.body&&document.body.scrollTop){scroll=document.body.scrollTop;}else if(document.documentElement&&document.documentElement.scrollTop){scroll=document.documentElement.scrollTop;}
var maxOffsetY=this.getMaxOffsetY();scroll=scroll>maxOffsetY?maxOffsetY:scroll;var h=this.context.height();if(h!=this.height){this.height=h;this.context.parent().css({"height":(this.height+this.additional_height)});}
if(scroll>this.offsetY){this.context.animate({"top":scroll});}else{this.context.animate({"top":this.offsetY});}};mk.ScrollingBox.prototype.toggleScrolling=function(data,context,event){event.preventDefault();if(this.scrolling){this.stopInterval();}else{this.startInterval();}};mk.ScrollingBox.prototype.startInterval=function(){this.scrolling=true;this.onButton.hide();this.offButton.show();var that=this;this.interval=window.setInterval(function(){that.context.css("position","absolute");that.checkPosition();},500);};mk.ScrollingBox.prototype.stopInterval=function(){this.scrolling=false;this.onButton.show();this.offButton.hide();var iid=this.interval;window.clearInterval(this.interval);};mk.BusinessSearch=function(node,params,attrs){this.BusinessSearch(node,params,attrs);};mk.BusinessSearch.prototype.BusinessSearch=function(node,params,attrs){this.context=node;this.p=params;this.a=attrs;this.__init__();};mk.BusinessSearch.prototype.__init__=function(node){this.input=$j('#business-search-input',this.context);this.lastQuery=null;this.bind();};mk.BusinessSearch.prototype.bind=function(){this.input.bind('keydown',ls.Delegate.create(this,this.onKeyDown,null));$j('.submit',this.context).bind('click',ls.Delegate.create(this,this.onSubmit,null));if(this.input.val()!=""){$j('.submit',this.context).click();}};mk.BusinessSearch.prototype.onKeyDown=function(data,context,event){if(event.which==13){this.onSubmit(data,context,event);}};mk.BusinessSearch.prototype.onSubmit=function(data,context,event){event.preventDefault();this.query=this.input.val();this.fetch(this.query,context,event);};mk.BusinessSearch.prototype.fetch=function(query,context,event){var q=query||this.query;if(q.length<3)return;if(q==this.lastQuery)return;this.lastQuery=q;this.url='/search/business/'+encodeURIComponent(q.toLowerCase());var target=$j("#"+this.p.target);$j(".no-results",target).hide();$j(".loader",target).show();ls.AjaxLoader.load(this.url,this.p.target,false,event);};extend(mk.BusinessSearch,[ls.EventDispatcher]);mk.BEOverlayManager=cp(ls.OverlayManager);mk.BEOverlayManager.toString=function(){return"[object mk.BEOverlayManager]";};mk.BEOverlayManager.bindExtraEvents=function(){this.closeButton().bind("click",ls.Delegate.create(this,this.unloadEvents,null));this.setMinHeight(515);this.setMaxHeight();this.setIFrameHeight();$j(window).bind("resize",ls.Delegate.create(this,this.setMaxHeight,null));$j(window).bind("resize",ls.Delegate.create(this,this.setIFrameHeight,null));};mk.BEOverlayManager.unloadEvents=function(data,context,response){$j(window).unbind("resize");ls.Utils.reload();};mk.BEOverlayManager.setIFrameHeight=function(data,context,response){var h=this.content.height()-35;h=(h<=5)?5:h;var ifr=$j("iframe",this.content);ifr.css("height",h);};mk.GoogleLocalResults=function(){this.GoogleLocalResults.apply(this,arguments);};mk.GoogleLocalResults.prototype.GoogleLocalResults=function(node,p,a){this.context=node;this.p=p;this.a=a;this.__init__.apply(this,arguments);};mk.GoogleLocalResults.prototype.__init__=function(){var c=ls.Cookie.get('mk-search');this.query=this.p.query||(c?c.split("::")[0]:'');this.location=this.p.query?null:(c?c.split("::")[1]:null);this.template=$j("#"+this.p.template);var listTemplate=$j(".result-list-template",this.template);this.listParser=new ls.TemplateParser(listTemplate);this.parser=new ls.TemplateParser(this.template);this.localProxy=new ls.GLocalController(APP_SETTINGS.GMAP_COUNTRY,APP_SETTINGS.GMAP_LANGUAGE,"json",null,"large");this.geoProxy=new ls.GGeoController(APP_SETTINGS.GMAP_COUNTRY,APP_SETTINGS.GMAP_LANGUAGE,"json",APP_SETTINGS.GMAP_DOMAIN);};mk.GoogleLocalResults.prototype.toString=function(){return"[object mk.GoogleLocalResults]";};mk.GoogleLocalResults.prototype.load=function(){if(this.location){this.geoProxy.fetch(this.location,ls.Delegate.create(this,this.onLocation));}else{this.localProxy.fetch(this.query,APP_SETTINGS.GEO_BOX,ls.Delegate.create(this,this.onResults));}};mk.GoogleLocalResults.prototype.onLocation=function(data,context,response){if(response.Status.code==200){var res=response.Placemark;if(res.length>0){var box=res[0].ExtendedData.LatLonBox;this.localProxy.fetch(this.query,box,ls.Delegate.create(this,this.onResults));}}else{ls.log(this.toString(),"Error loading data.",response.responseStatus);}};mk.GoogleLocalResults.prototype.onResults=function(data,context,response){if(response.responseStatus==200){var res=response.responseData.results;if(res.length==0){$j(".loading",this.context).hide();$j("#no-results-placeholder").append("<h4>"+_('no-results')+"</h4>");}
res=res.groupBy("city");for(var r=0;r<res.length;r++){this.injectResults(res[r]);}
this.template.show();this.context.hide();}else{ls.log(this.toString(),"Error loading data.",response.responseStatus);}};mk.GoogleLocalResults.prototype.injectResults=function(res){var city=res[0].city;var target=$j("#result-list-"+city.normalize());if(target.size()<1){this.parser.parseTemplate({"city":city,"cityId":city.normalize()});target=$j("#result-list-"+city.normalize());}
var lastId="";var added=false;while(res.length>0){var data=res.shift();var item={};var t=(data.titleNoFormatting.replace("&","")).noUmlNormalize();var ident=data.lat+"-"+data.lng+"-"+t;var zipcode=(data.addressLines.length>1)?data.addressLines[1].match(/^(\d+)/):"";var phone=(data.phoneNumbers&&data.phoneNumbers[0]&&!data.phoneNumbers[0].type)?data.phoneNumbers[0].number:"-";ident=ident.normalize();item.decorationlevel=0;item.lat=data.lat;item.lon=data.lng;item.ident=ident;item.title=data.titleNoFormatting;item.street=data.addressLines?data.addressLines[0]:"";item.zipcode=zipcode?zipcode[0]:"";item.city=data.city;item.phone=phone;item.css_verified_display='hide-verified';var url=mk.GOOGLE_LOCAL_URL;item.url=ls.Utils.compileString(url,{'title':t,'lat':data.lat,'lng':data.lng});var append=true;for(var i=0;i<target.children().length;i++){var element=$j(target.children()[i])
var title=element.children()[0].title
if(title==item.title){append=false;}}
if(append==true){added=true;this.listParser.parseTemplate(item,"append",target);$j("#"+item.ident).prepend($j(mk.POWERED_BY));if(!item.lat||!item.lon)$j("#map-reference-"+res.ident).hide();ls.Document.dispatchEvent(new ls.AjaxEvent(ls.Event.PIN_DATA,[item]));lastId=ident;}}
com.lovelysystems.Application.execute(target.parent());if(added==true){target.children().removeClass("last");$j("#"+lastId).addClass("last");}};mk.GoogleLocalPage=function(){this.GoogleLocalPage.apply(this,arguments);};mk.GoogleLocalPage.prototype.GoogleLocalPage=function(node,params,attrs){this.node=node;this.a=attrs;this.p=params;this.__init__.apply(this,arguments);};mk.GoogleLocalPage.prototype.__init__=function(){if(window.googleMapsAPI==true){this.query=this.p.q;this.lat=this.p.lat;this.lng=this.p.lon;this.geopos=new GLatLng(this.lat,this.lng);this.dataProvider=new ls.GLocalController(APP_SETTINGS.GMAP_COUNTRY,APP_SETTINGS.GMAP_LANGUAGE,"json");this.load();}};mk.GoogleLocalPage.prototype.toString=function(){return"[object mk.GoogleLocalPage]";};mk.GoogleLocalPage.prototype.load=function(){var geo={lat:this.lat,lng:this.lng};this.dataProvider.fetch(this.query.replace("-"," "),geo,ls.Delegate.create(this,this.onLoad,geo));};mk.GoogleLocalPage.prototype.onLoad=function(data,context,response){if(response.responseStatus==200){var b=this.getBusiness(response.responseData.results,data);if(b){var business=this._b(b);this.applyData(business);}else{this.applyNotFound();}}else{ls.log(this.toString(),"onload",arguments);}};mk.GoogleLocalPage.prototype.getBusiness=function(items,geo){for(var i=0;i<items.length;i++){if(items[i].lat==geo.lat&&items[i].lng==geo.lng){return items[i];}}
return null;};mk.GoogleLocalPage.prototype.applyData=function(business){$j(".gl-data").each(function(){var attr=com.lovelysystems.Application.getCommandAttrs(this);var text=[];for(var i=0;i<attr.keys.length;i++){var k=attr.keys[i];text.push(business[k]||"");}
$j(this).append(text.join(" "));});document.title=business.title+", "+(business.city||"");ls.Document.dispatchEvent(new ls.AjaxEvent(ls.Event.MAP_ADD_PIN,[business]));ls.Document.dispatchEvent(new ls.AjaxEvent(ls.Event.GOOGLE_LOCAL_LOADED,business));};mk.GoogleLocalPage.prototype.applyNotFound=function(){var notFound={title:_("error-occured"),phone:_("page-not-found")};$j(".contact-options").hide();$j(".business-address").hide();$j(".business-actions").hide();this.applyData(notFound);};mk.GoogleLocalPage.prototype._b=function(business){if(!business)return{};var phones=function(p){phones=[]
for(var i=0;i<p.length;i++){phones.push(p[i].type||_('phone'));phones.push(p[i].number||_('phone'));phones.push("<br />");}
return phones.join(" ");};var zipcode=business.addressLines[1].match(/^(\d+)/);var b=cp({br:'<br />',lat:business.lat,lon:business.lng,title:business.titleNoFormatting,street:business.streetAddress,url:ls.Utils.compileString(mk.GOOGLE_LOCAL_URL,{'title':business.titleNoFormatting.normalize(),'lat':business.lat,'lng':business.lng}),phonenumber:business.phoneNumbers[0].number,phone:_('phone'),phones:phones(business.phoneNumbers),street:business.addressLines[0],zipcode:zipcode?zipcode[0]:"",city:business.city},business);return b;};mk.tabHelper={showTab:function(tab,head){var profilebox=document.getElementsByTagName("div");var tabhead=document.getElementsByTagName("td");for(var x=0;x<profilebox.length;x++){name=profilebox[x].getAttribute("name");if(name=='profilebox'){if(profilebox[x].id==tab){profilebox[x].style.display='block';}
else{profilebox[x].style.display='none';}}}
for(var x=0;x<tabhead.length;x++){tabname=tabhead[x].getAttribute("name");if(tabname=='tabhead'){if(tabhead[x].id==head){tabhead[x].className='tab-selected';}
else{tabhead[x].className='tab-not-selected';}}}}}
mk.Utils.checkMobile();var app=com.lovelysystems.Application;app.registerCommand('AjaxLink',function(cmd,element,params,attrs){$j(element).bind('click',ls.Delegate.create(ls.AjaxLoader,ls.AjaxLoader.init,null));});app.registerCommand('AjaxView',function(cmd,element,params,attrs){var rid='__ajaxview_'+Math.ceil(new Date().getTime()*Math.random())+"__";$j(element).attr('id',rid);ls.AjaxLoader.load(params.url,rid,false,{'target':element});});app.registerCommand('OverlayLink',function(cmd,element,params,attrs){ls.OverlayManager.initLink($j(element),params,attrs);});app.registerCommand('ReloadOverlay',function(cmd,element,params,attrs){mk.BEOverlayManager.bindExtraEvents();});app.registerCommand('RPCFormManager',function(cmd,element,params,attrs){var fm=new ls.RPCFormManager($j(element),params,attrs);fm.addEventListener(ls.Event.FORM_FAIL,ls.Delegate.create(ls.RecaptchaManager,ls.RecaptchaManager.reloadCaptcha,"t"));fm.addEventListener(ls.Event.FORM_FAIL,function(eventData){ls.GoogleAnalytics.triggerPageView("/formsubmit/"+eventData.method+"/fail");});fm.addEventListener(ls.Event.FORM_SUCCESS,function(eventData){ls.GoogleAnalytics.triggerPageView("/formsubmit/"+eventData.method+"/success");});fm.init();});app.registerCommand('RegisterBusinessFormManager',function(cmd,element,params,attrs){var fm=new ls.RPCFormManager($j(element),params,attrs);fm.addEventListener(ls.Event.FORM_SUCCESS,function(eventData){ls.Utils.redirect(eventData.response);});fm.addEventListener(ls.Event.FORM_FAIL,ls.Delegate.create(ls.RecaptchaManager,ls.RecaptchaManager.reloadCaptcha,"t"));fm.init();});app.registerCommand('ResetPasswordFormManager',function(cmd,element,params,attrs){var fm=new ls.RPCFormManager($j(element),params,attrs);fm.addEventListener(ls.Event.FORM_SUCCESS,function(eventData){var url='/user/${key}/my-businesses';url=ls.Utils.compileString(url,{'key':eventData.response});ls.Utils.redirect(url);});fm.addEventListener(ls.Event.FORM_FAIL,ls.Delegate.create(ls.RecaptchaManager,ls.RecaptchaManager.reloadCaptcha,"t"));fm.init();});app.registerCommand('SearchForm',function(cmd,element,params,attrs){var fm=new mk.SearchForm($j(element),params,attrs);fm.bind();});app.registerCommand('AutoCompleteLocation',function(cmd,element,params,attrs){var input=new mk.AutoCompleteLocation($j(element),params,attrs);input.bind();});app.registerCommand('Recaptcha',function(cmd,element,params,attrs){var id=attrs.id;if(!id){id='recaptcha_'+Math.ceil(new Date().getTime()*Math.random());$j(element).attr('id',id);}
ls.RecaptchaManager.initCaptcha(id);});app.registerCommand('PrintObject',function(cmd,element,params,attrs){$j(element).bind('click',function(event){var pdoc=window.open($j(this).attr('href'),'printobject','width=810,height=582,left=10,top=10,toolbar=no,status=no,scrollbars=yes,resizable=yes');event.preventDefault();});});app.registerCommand('HoverList',function(cmd,element,params,attrs){var list=$j(element);var color=attrs.color;$j("li",list).each(function(){var li=$j(this);li.unbind('mouseover');li.bind('mouseover',function(event){var node=$j(this);node.addClass("hover");var event=new ls.AjaxEvent(ls.Event.HOVER_OVER,node);ls.Document.dispatchEvent(event);});li.unbind('mouseout');li.bind('mouseout',function(event){var node=$j(this);node.removeClass("hover");var event=new ls.AjaxEvent(ls.Event.HOVER_OUT,node);ls.Document.dispatchEvent(event);});});});app.registerCommand('SinglePinList',function(cmd,element,params,attrs){var list=$j(element);var color=attrs.color;$j("li",list).each(function(i,dom){$j(this).bind("mouseover",function(event){event.preventDefault();var h=$j("a",$j(this))[0];if(event.target==h){var event=new ls.AjaxEvent(ls.Event.GEOPOS_OVER,this);ls.Document.dispatchEvent(event);}});$j(this).bind("mouseout",function(event){event.preventDefault();var h=$j("a",$j(this))[0];if(event.target==h){var event=new ls.AjaxEvent(ls.Event.GEOPOS_OUT,this);ls.Document.dispatchEvent(event);}});});});app.registerCommand('ExpandableItem',function(cmd,element,params,attrs){$j(".open-close-button",$j(element)).bind("click",function(event){event.preventDefault();$j(".expandable",$j(this).parent()).slideToggle();var t=$j(this).text();t=t.indexOf("+")!=-1?t.replace("+","-"):t.replace("-","+");$j(this).text(t);});});app.registerCommand('GMap',function(cmd,element,params,attrs){if(window.googleMapsAPI==true){app.gmap=new ls.GMapController(element,params,attrs);app.gmap.marker=mk.BusinessMarker;app.gmap.tmpmarker=mk.TempMarker;app.gmap.init();}});app.registerCommand('CountLink',function(cmd,element,params,attrs){var cl=new mk.CountLink(element);cl.addEventListener(ls.Event.LINK_CLICKED,ls.Delegate.create(mk.Tracking,mk.Tracking.trackLink,null));cl.addEventListener(ls.Event.LINK_CLICKED,ls.Delegate.create(ls.Pixel,ls.Pixel.onEvent,null));cl.addEventListener(ls.Event.LINK_CLICKED,ls.Delegate.create(ls.GoogleAnalytics,ls.GoogleAnalytics.onEvent,null));});app.registerCommand('TabBox',function(cmd,element,params,attrs){var tb=new mk.TabBox(element);tb.addEventListener(ls.Event.TAB_SWITCHED,ls.Delegate.create(mk.Tracking,mk.Tracking.trackTab,null));tb.addEventListener(ls.Event.TAB_SWITCHED,ls.Delegate.create(ls.Pixel,ls.Pixel.onEvent,null));tb.addEventListener(ls.Event.TAB_SWITCHED,ls.Delegate.create(ls.GoogleAnalytics,ls.GoogleAnalytics.onEvent,null));});app.registerCommand('BusinessCarousel',function(cmd,element,params,attrs){var carousel=new mk.Carousel($j(element),params,attrs);var cfg={css:{width:160,height:140},ratio:0.5,speed:400};carousel.setConf(cfg);carousel.bind();carousel.addEventListener(ls.Event.CAROUSEL_PREV,ls.Delegate.create(ls.Pixel,ls.Pixel.onEvent,null));carousel.addEventListener(ls.Event.CAROUSEL_NEXT,ls.Delegate.create(ls.Pixel,ls.Pixel.onEvent,null));carousel.addEventListener(ls.Event.CAROUSEL_NEXT,ls.Delegate.create(ls.GoogleAnalytics,ls.GoogleAnalytics.onEvent,null));});app.registerCommand('ScrollingBox',function(cmd,element,params,attrs){new mk.ScrollingBox($j(element));});app.registerCommand('ResultBatcher',function(cmd,element,params,attrs){new mk.ResultBatcher($j(element),params,attrs);});app.registerCommand('SearchResultLoader',function(cmd,element,params,attrs){var srl=new mk.SearchResultLoader($j(element),params,attrs);if(params.autoinit){srl.init();}else{app.registry.add(mk.Utils.SearchResults.KEY,srl);}});app.registerCommand('MoreLinks',function(cmd,element,params,attrs){mk.Utils.SearchResults.submit();});app.registerCommand('BusinessSearch',function(cmd,element,params,attrs){window.bs=new mk.BusinessSearch($j(element),params,attrs);});app.registerCommand('BusinessSearchLink',function(cmd,element,params,attrs){$j(element).bind("click",function(event){event.preventDefault();$j(this).unbind("click");var geobox=$j(".latlonbox",$j("#mainsearch-form"));geobox.val('');window.interval=setInterval(function(){if(geobox.val()!=''){clearInterval(window.interval);$j("#mainsearch-form-submit").click();}},100);$j("#mainsearch-form-business").val(params.query);$j("#mainsearch-form-location").val(params.location).keyup();});});app.registerCommand('NavigationDropdown',function(cmd,element,params,attrs){new ls.NavigationDropdown($j(element));});app.registerCommand('RegisterBusinessLink',function(cmd,element,params,attrs){var pr=new ls.JsonRPC("/auth");pr.addEventListener(ls.Event.RPC_RESPONSE,function(res){if(res.error){return;}else if(res.result){$j(element).bind("click",ls.Delegate.create(ls.Utils,ls.Utils.redirect,'/business/register'));}else{ls.OverlayManager.initLink($j(element),params,attrs);}});pr.call("whoami");});app.registerCommand('GoogleLocalResults',function(cmd,element,params,attrs){var local=new mk.GoogleLocalResults($j(element),params,attrs);local.load();});app.registerCommand('GoogleLocalPage',function(cmd,element,params,attrs){var page=new mk.GoogleLocalPage($j(element),params,attrs);});app.registerCommand('GoogleLocalRecommendFix',function(cmd,element,params,attrs){var context=$j(element);var fieldTitle=$j("#title",context);var fieldURL=$j("#url",context);if(!fieldTitle.val())fieldTitle.val($j("h1").text().trim());if(!fieldURL.val())fieldURL.val(document.location.href);});__onDOMLoaded=function(){var start=new Date().getTime();__addDocumentEvents();ls.RecaptchaManager.setKey(APP_SETTINGS.RECAPTCHA_PUBKEY);ls.Pixel.register(APP_SETTINGS.TRACKING.accounts);ls.Pixel.addInfo('type',APP_SETTINGS.TRACKING.type);com.lovelysystems.Application.execute();mk.Utils.checkStartupHash();mk.Utils.checkBrowser();mk.Tracking();if(typeof(pageTracker)!='undefined')ls.GoogleAnalytics.tracker.push(pageTracker);if(typeof(mkTracker)!='undefined')ls.GoogleAnalytics.tracker.push(mkTracker);var end=new Date().getTime();var duration=end-start;console.info("INIT",duration+"ms");};__onDOMUnLoad=function(){GUnloadApi();};__addDocumentEvents=function(){ls.OverlayManager.addEventListener(ls.Event.OVERLAY_COMPLETE,function(eventData){com.lovelysystems.Application.execute(eventData.context);});ls.OverlayManager.addEventListener(ls.Event.OVERLAY_COMPLETE,ls.Delegate.create(ls.Pixel,ls.Pixel.onEvent,null));ls.OverlayManager.addEventListener(ls.Event.OVERLAY_COMPLETE,ls.Delegate.create(ls.GoogleAnalytics,ls.GoogleAnalytics.onEvent,null));ls.OverlayManager.addEventListener(ls.Event.OVERLAY_LOAD,ls.Delegate.create(ls.GarbageCollector,ls.GarbageCollector.purge,null));ls.AjaxLoader.addEventListener(ls.Event.AJAX_COMPLETE,function(eventData){com.lovelysystems.Application.execute(eventData.node);});ls.AjaxLoader.addEventListener(ls.Event.AJAX_COMPLETE,ls.Delegate.create(ls.Pixel,ls.Pixel.onEvent,null));ls.AjaxLoader.addEventListener(ls.Event.AJAX_COMPLETE,ls.Delegate.create(ls.GoogleAnalytics,ls.GoogleAnalytics.onEvent,null));ls.AjaxLoader.addEventListener(ls.Event.AJAX_COMPLETE,function(eventData){mk.Tracking(eventData);});ls.Document.addEventListener(ls.Event.MAP_DATA,function(eventData){if(eventData.type==ls.Event.MAP_NEW_GEODATA){ls.StorageManager.addData(mk.SEARCH_RESULT_DATA_KEY,eventData.response);}else if(eventData.type==ls.Event.MAP_ADD_GEODATA){ls.StorageManager.pushData(mk.SEARCH_RESULT_DATA_KEY,eventData.response);}});ls.Document.addEventListener(ls.Event.MAP_MARKER_SELECT,function(eventData){$j("#"+eventData.id).addClass("hover");});ls.Document.addEventListener(ls.Event.MAP_MARKER_UNSELECT,function(eventData){$j("#"+eventData.id).removeClass("hover");});ls.Document.addEventListener(ls.Event.FORM_CLOSE,ls.Delegate.create(ls.OverlayManager,ls.OverlayManager.closeOverlay,null));ls.Document.addEventListener(ls.Event.FORM_SWITCH,function(eventData){ls.OverlayManager.loadOverlayContent(eventData);});ls.Document.addEventListener(ls.Event.FORM_LOAD,function(eventData){ls.AjaxLoader.load(eventData.url,eventData.target,true,eventData);});ls.Document.addEventListener(ls.Event.FORM_CUSTOM,function(eventData){var proxy=new ls.JsonRPC("/auth");proxy.addEventListener(ls.Event.RPC_SUCCESS,function(response){var url='/user/${key}/my-businesses';url=ls.Utils.compileString(url,response);window.setTimeout(function(){window.location.href=url;},5);});proxy.call('whoami',{});});};window.onload=__onDOMLoaded;window.onunload=__onDOMUnLoad;
