
if(dwr==null)var dwr={};if(dwr.engine==null)dwr.engine={};if(DWREngine==null)var DWREngine=dwr.engine;dwr.engine.setErrorHandler=function(handler){dwr.engine._errorHandler=handler;};dwr.engine.setWarningHandler=function(handler){dwr.engine._warningHandler=handler;};dwr.engine.setTextHtmlHandler=function(handler){dwr.engine._textHtmlHandler=handler;};dwr.engine.setTimeout=function(timeout){dwr.engine._timeout=timeout;};dwr.engine.setPreHook=function(handler){dwr.engine._preHook=handler;};dwr.engine.setPostHook=function(handler){dwr.engine._postHook=handler;};dwr.engine.setHeaders=function(headers){dwr.engine._headers=headers;};dwr.engine.setParameters=function(parameters){dwr.engine._parameters=parameters;};dwr.engine.XMLHttpRequest=1;dwr.engine.IFrame=2;dwr.engine.ScriptTag=3;dwr.engine.setRpcType=function(newType){if(newType!=dwr.engine.XMLHttpRequest&&newType!=dwr.engine.IFrame&&newType!=dwr.engine.ScriptTag){dwr.engine._handleError(null,{name:"dwr.engine.invalidRpcType",message:"RpcType must be one of dwr.engine.XMLHttpRequest or dwr.engine.IFrame or dwr.engine.ScriptTag"});return;}
dwr.engine._rpcType=newType;};dwr.engine.setHttpMethod=function(httpMethod){if(httpMethod!="GET"&&httpMethod!="POST"){dwr.engine._handleError(null,{name:"dwr.engine.invalidHttpMethod",message:"Remoting method must be one of GET or POST"});return;}
dwr.engine._httpMethod=httpMethod;};dwr.engine.setOrdered=function(ordered){dwr.engine._ordered=ordered;};dwr.engine.setAsync=function(async){dwr.engine._async=async;};dwr.engine.setActiveReverseAjax=function(activeReverseAjax){if(activeReverseAjax){if(dwr.engine._activeReverseAjax)return;dwr.engine._activeReverseAjax=true;dwr.engine._poll();}
else{if(dwr.engine._activeReverseAjax&&dwr.engine._pollReq)dwr.engine._pollReq.abort();dwr.engine._activeReverseAjax=false;}};dwr.engine.defaultErrorHandler=function(message,ex){dwr.engine._debug("Error: "+ex.name+", "+ex.message,true);if(message==null||message=="")alert("A server error has occured.");else if(message.indexOf("0x80040111")!=-1)dwr.engine._debug(message);else alert(message);};dwr.engine.defaultWarningHandler=function(message,ex){dwr.engine._debug(message);};dwr.engine.beginBatch=function(){if(dwr.engine._batch){dwr.engine._handleError(null,{name:"dwr.engine.batchBegun",message:"Batch already begun"});return;}
dwr.engine._batch=dwr.engine._createBatch();};dwr.engine.endBatch=function(options){var batch=dwr.engine._batch;if(batch==null){dwr.engine._handleError(null,{name:"dwr.engine.batchNotBegun",message:"No batch in progress"});return;}
dwr.engine._batch=null;if(batch.map.callCount==0)return;if(options)dwr.engine._mergeBatch(batch,options);if(dwr.engine._ordered&&dwr.engine._batchesLength!=0){dwr.engine._batchQueue[dwr.engine._batchQueue.length]=batch;}
else{dwr.engine._sendData(batch);}};dwr.engine.setPollMethod=function(type){dwr.engine.setPollType(type);};dwr.engine.setMethod=function(type){dwr.engine.setRpcType(type);};dwr.engine.setVerb=function(verb){dwr.engine.setHttpMethod(verb);};dwr.engine.setPollType=function(){dwr.engine._debug("Manually setting the Poll Type is not supported");};dwr.engine._origScriptSessionId=""+JAWR.dwr_scriptSessionId+"";dwr.engine._sessionCookieName="JSESSIONID";dwr.engine._allowGetForSafariButMakeForgeryEasier="";dwr.engine._scriptTagProtection="throw 'allowScriptTagRemoting is false.';";dwr.engine._defaultPath=""+JAWR.jawr_dwr_path+"";dwr.engine._pollWithXhr="false";dwr.engine._scriptSessionId=null;dwr.engine._getScriptSessionId=function(){if(dwr.engine._scriptSessionId==null){dwr.engine._scriptSessionId=dwr.engine._origScriptSessionId+Math.floor(Math.random()*1000);}
return dwr.engine._scriptSessionId;};dwr.engine._errorHandler=dwr.engine.defaultErrorHandler;dwr.engine._warningHandler=dwr.engine.defaultWarningHandler;dwr.engine._preHook=null;dwr.engine._postHook=null;dwr.engine._batches={};dwr.engine._batchesLength=0;dwr.engine._batchQueue=[];dwr.engine._rpcType=dwr.engine.XMLHttpRequest;dwr.engine._httpMethod="POST";dwr.engine._ordered=false;dwr.engine._async=true;dwr.engine._batch=null;dwr.engine._timeout=0;dwr.engine._DOMDocument=["Msxml2.DOMDocument.6.0","Msxml2.DOMDocument.5.0","Msxml2.DOMDocument.4.0","Msxml2.DOMDocument.3.0","MSXML2.DOMDocument","MSXML.DOMDocument","Microsoft.XMLDOM"];dwr.engine._XMLHTTP=["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.5.0","Msxml2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"];dwr.engine._activeReverseAjax=false;dwr.engine._outstandingIFrames=[];dwr.engine._pollReq=null;dwr.engine._pollCometInterval=200;dwr.engine._pollRetries=0;dwr.engine._maxPollRetries=0;dwr.engine._textHtmlHandler=null;dwr.engine._headers=null;dwr.engine._parameters=null;dwr.engine._postSeperator="\n";dwr.engine._defaultInterceptor=function(data){return data;};dwr.engine._urlRewriteHandler=dwr.engine._defaultInterceptor;dwr.engine._contentRewriteHandler=dwr.engine._defaultInterceptor;dwr.engine._replyRewriteHandler=dwr.engine._defaultInterceptor;dwr.engine._nextBatchId=0;dwr.engine._propnames=["rpcType","httpMethod","async","timeout","errorHandler","warningHandler","textHtmlHandler"];dwr.engine._partialResponseNo=0;dwr.engine._partialResponseYes=1;dwr.engine._partialResponseFlush=2;dwr.engine._execute=function(path,scriptName,methodName,vararg_params){var singleShot=false;if(dwr.engine._batch==null){dwr.engine.beginBatch();singleShot=true;}
var batch=dwr.engine._batch;var args=[];for(var i=0;i<arguments.length-3;i++){args[i]=arguments[i+3];}
if(batch.path==null){batch.path=path;}
else{if(batch.path!=path){dwr.engine._handleError(batch,{name:"dwr.engine.multipleServlets",message:"Can't batch requests to multiple DWR Servlets."});return;}}
var callData;var lastArg=args[args.length-1];if(typeof lastArg=="function"||lastArg==null)callData={callback:args.pop()};else callData=args.pop();dwr.engine._mergeBatch(batch,callData);batch.handlers[batch.map.callCount]={exceptionHandler:callData.exceptionHandler,callback:callData.callback};var prefix="c"+batch.map.callCount+"-";batch.map[prefix+"scriptName"]=scriptName;batch.map[prefix+"methodName"]=methodName;batch.map[prefix+"id"]=batch.map.callCount;for(i=0;i<args.length;i++){dwr.engine._serializeAll(batch,[],args[i],prefix+"param"+i);}
batch.map.callCount++;if(singleShot)dwr.engine.endBatch();};dwr.engine._poll=function(){if(!dwr.engine._activeReverseAjax)return;var batch=dwr.engine._createBatch();batch.map.id=0;batch.map.callCount=1;batch.isPoll=true;if(dwr.engine._pollWithXhr=="true"){batch.rpcType=dwr.engine.XMLHttpRequest;batch.map.partialResponse=dwr.engine._partialResponseNo;}
else{if(navigator.userAgent.indexOf("Gecko/")!=-1){batch.rpcType=dwr.engine.XMLHttpRequest;batch.map.partialResponse=dwr.engine._partialResponseYes;}
else{batch.rpcType=dwr.engine.XMLHttpRequest;batch.map.partialResponse=dwr.engine._partialResponseNo;}}
batch.httpMethod="POST";batch.async=true;batch.timeout=0;batch.path=dwr.engine._defaultPath;batch.preHooks=[];batch.postHooks=[];batch.errorHandler=dwr.engine._pollErrorHandler;batch.warningHandler=dwr.engine._pollErrorHandler;batch.handlers[0]={callback:function(pause){dwr.engine._pollRetries=0;setTimeout("dwr.engine._poll()",pause);}};dwr.engine._sendData(batch);if(batch.rpcType==dwr.engine.XMLHttpRequest&&batch.map.partialResponse==dwr.engine._partialResponseYes){dwr.engine._checkCometPoll();}};dwr.engine._pollErrorHandler=function(msg,ex){dwr.engine._pollRetries++;dwr.engine._debug("Reverse Ajax poll failed (pollRetries="+dwr.engine._pollRetries+"): "+ex.name+" : "+ex.message);if(dwr.engine._pollRetries<dwr.engine._maxPollRetries){setTimeout("dwr.engine._poll()",10000);}
else{dwr.engine._activeReverseAjax=false;dwr.engine._debug("Giving up.");}};dwr.engine._createBatch=function(){var batch={map:{callCount:0,page:window.location.pathname+window.location.search,httpSessionId:dwr.engine._getJSessionId(),scriptSessionId:dwr.engine._getScriptSessionId()},charsProcessed:0,paramCount:0,parameters:{},headers:{},isPoll:false,handlers:{},preHooks:[],postHooks:[],rpcType:dwr.engine._rpcType,httpMethod:dwr.engine._httpMethod,async:dwr.engine._async,timeout:dwr.engine._timeout,errorHandler:dwr.engine._errorHandler,warningHandler:dwr.engine._warningHandler,textHtmlHandler:dwr.engine._textHtmlHandler};if(dwr.engine._preHook)batch.preHooks.push(dwr.engine._preHook);if(dwr.engine._postHook)batch.postHooks.push(dwr.engine._postHook);var propname,data;if(dwr.engine._headers){for(propname in dwr.engine._headers){data=dwr.engine._headers[propname];if(typeof data!="function")batch.headers[propname]=data;}}
if(dwr.engine._parameters){for(propname in dwr.engine._parameters){data=dwr.engine._parameters[propname];if(typeof data!="function")batch.parameters[propname]=data;}}
return batch;};dwr.engine._mergeBatch=function(batch,overrides){var propname,data;for(var i=0;i<dwr.engine._propnames.length;i++){propname=dwr.engine._propnames[i];if(overrides[propname]!=null)batch[propname]=overrides[propname];}
if(overrides.preHook!=null)batch.preHooks.unshift(overrides.preHook);if(overrides.postHook!=null)batch.postHooks.push(overrides.postHook);if(overrides.headers){for(propname in overrides.headers){data=overrides.headers[propname];if(typeof data!="function")batch.headers[propname]=data;}}
if(overrides.parameters){for(propname in overrides.parameters){data=overrides.parameters[propname];if(typeof data!="function")batch.map["p-"+propname]=""+data;}}};dwr.engine._getJSessionId=function(){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=cookies[i];while(cookie.charAt(0)==' ')cookie=cookie.substring(1,cookie.length);if(cookie.indexOf(dwr.engine._sessionCookieName+"=")==0){return cookie.substring(dwr.engine._sessionCookieName.length+1,cookie.length);}}
return"";};dwr.engine._checkCometPoll=function(){for(var i=0;i<dwr.engine._outstandingIFrames.length;i++){var text="";var iframe=dwr.engine._outstandingIFrames[i];try{text=dwr.engine._getTextFromCometIFrame(iframe);}
catch(ex){dwr.engine._handleWarning(iframe.batch,ex);}
if(text!="")dwr.engine._processCometResponse(text,iframe.batch);}
if(dwr.engine._pollReq){var req=dwr.engine._pollReq;var text=req.responseText;if(text!=null)dwr.engine._processCometResponse(text,req.batch);}
if(dwr.engine._outstandingIFrames.length>0||dwr.engine._pollReq){setTimeout("dwr.engine._checkCometPoll()",dwr.engine._pollCometInterval);}};dwr.engine._getTextFromCometIFrame=function(frameEle){var body=frameEle.contentWindow.document.body;if(body==null)return"";var text=body.innerHTML;if(text.indexOf("<PRE>")==0||text.indexOf("<pre>")==0){text=text.substring(5,text.length-7);}
return text;};dwr.engine._processCometResponse=function(response,batch){if(batch.charsProcessed==response.length)return;if(response.length==0){batch.charsProcessed=0;return;}
var firstStartTag=response.indexOf("//#DWR-START#",batch.charsProcessed);if(firstStartTag==-1){batch.charsProcessed=response.length;return;}
var lastEndTag=response.lastIndexOf("//#DWR-END#");if(lastEndTag==-1){return;}
if(response.charCodeAt(lastEndTag+11)==13&&response.charCodeAt(lastEndTag+12)==10){batch.charsProcessed=lastEndTag+13;}
else{batch.charsProcessed=lastEndTag+11;}
var exec=response.substring(firstStartTag+13,lastEndTag);dwr.engine._receivedBatch=batch;dwr.engine._eval(exec);dwr.engine._receivedBatch=null;};dwr.engine._sendData=function(batch){batch.map.batchId=dwr.engine._nextBatchId;dwr.engine._nextBatchId++;dwr.engine._batches[batch.map.batchId]=batch;dwr.engine._batchesLength++;batch.completed=false;for(var i=0;i<batch.preHooks.length;i++){batch.preHooks[i]();}
batch.preHooks=null;if(batch.timeout&&batch.timeout!=0){batch.interval=setInterval(function(){dwr.engine._abortRequest(batch);},batch.timeout);}
if(batch.rpcType==dwr.engine.XMLHttpRequest){if(window.XMLHttpRequest){batch.req=new XMLHttpRequest();}
else if(window.ActiveXObject&&!(navigator.userAgent.indexOf("Mac")>=0&&navigator.userAgent.indexOf("MSIE")>=0)){batch.req=dwr.engine._newActiveXObject(dwr.engine._XMLHTTP);}}
var prop,request;if(batch.req){if(batch.async){batch.req.onreadystatechange=function(){if(typeof dwr!='undefined')dwr.engine._stateChange(batch);};}
if(batch.isPoll){dwr.engine._pollReq=batch.req;if(!document.all)batch.req.batch=batch;}
var indexSafari=navigator.userAgent.indexOf("Safari/");if(indexSafari>=0){var version=navigator.userAgent.substring(indexSafari+7);if(parseInt(version,10)<400){if(dwr.engine._allowGetForSafariButMakeForgeryEasier=="true")batch.httpMethod="GET";else dwr.engine._handleWarning(batch,{name:"dwr.engine.oldSafari",message:"Safari GET support disabled. See getahead.org/dwr/server/servlet and allowGetForSafariButMakeForgeryEasier."});}}
batch.mode=batch.isPoll?dwr.engine._ModePlainPoll:dwr.engine._ModePlainCall;request=dwr.engine._constructRequest(batch);try{batch.req.open(batch.httpMethod,request.url,batch.async);try{for(prop in batch.headers){var value=batch.headers[prop];if(typeof value=="string")batch.req.setRequestHeader(prop,value);}
if(!batch.headers["Content-Type"])batch.req.setRequestHeader("Content-Type","text/plain");}
catch(ex){dwr.engine._handleWarning(batch,ex);}
batch.req.send(request.body);if(!batch.async)dwr.engine._stateChange(batch);}
catch(ex){dwr.engine._handleError(batch,ex);}}
else if(batch.rpcType!=dwr.engine.ScriptTag){var idname=batch.isPoll?"dwr-if-poll-"+batch.map.batchId:"dwr-if-"+batch.map["c0-id"];if(batch.isPoll&&window.ActiveXObject){batch.htmlfile=new window.ActiveXObject("htmlfile");batch.htmlfile.open();batch.htmlfile.write("<html>");batch.htmlfile.write("<div><iframe className='wibble' src='javascript:void(0)' id='"+idname+"' name='"+idname+"' onload='dwr.engine._iframeLoadingComplete("+batch.map.batchId+");'></iframe></div>");batch.htmlfile.write("</html>");batch.htmlfile.close();batch.htmlfile.parentWindow.dwr=dwr;batch.document=batch.htmlfile;}
else{batch.div=document.createElement("div");document.body.appendChild(batch.div);batch.div.innerHTML="<iframe src='javascript:void(0)' frameborder='0' style='width:0px;height:0px;border:0;' id='"+idname+"' name='"+idname+"' onload='dwr.engine._iframeLoadingComplete ("+batch.map.batchId+");'></iframe>";batch.document=document;}
batch.iframe=batch.document.getElementById(idname);batch.iframe.batch=batch;batch.mode=batch.isPoll?dwr.engine._ModeHtmlPoll:dwr.engine._ModeHtmlCall;if(batch.isPoll)dwr.engine._outstandingIFrames.push(batch.iframe);request=dwr.engine._constructRequest(batch);if(batch.httpMethod=="GET"){batch.iframe.setAttribute("src",request.url);}
else{batch.form=batch.document.createElement("form");batch.form.setAttribute("id","dwr-form");batch.form.setAttribute("action",request.url);batch.form.setAttribute("target",idname);batch.form.target=idname;batch.form.setAttribute("method",batch.httpMethod);for(prop in batch.map){var value=batch.map[prop];if(typeof value!="function"){var formInput=batch.document.createElement("input");formInput.setAttribute("type","hidden");formInput.setAttribute("name",prop);formInput.setAttribute("value",value);batch.form.appendChild(formInput);}}
batch.document.body.appendChild(batch.form);batch.form.submit();}}
else{batch.httpMethod="GET";batch.mode=batch.isPoll?dwr.engine._ModePlainPoll:dwr.engine._ModePlainCall;request=dwr.engine._constructRequest(batch);batch.script=document.createElement("script");batch.script.id="dwr-st-"+batch.map["c0-id"];batch.script.src=request.url;document.body.appendChild(batch.script);}};dwr.engine._ModePlainCall="/call/plaincall/";dwr.engine._ModeHtmlCall="/call/htmlcall/";dwr.engine._ModePlainPoll="/call/plainpoll/";dwr.engine._ModeHtmlPoll="/call/htmlpoll/";dwr.engine._constructRequest=function(batch){var request={url:batch.path+batch.mode,body:null};if(batch.isPoll==true){request.url+="ReverseAjax.dwr";}
else if(batch.map.callCount==1){request.url+=batch.map["c0-scriptName"]+"."+batch.map["c0-methodName"]+".dwr";}
else{request.url+="Multiple."+batch.map.callCount+".dwr";}
var sessionMatch=location.href.match(/jsessionid=([^?]+)/);if(sessionMatch!=null){request.url+=";jsessionid="+sessionMatch[1];}
var prop;if(batch.httpMethod=="GET"){batch.map.callCount=""+batch.map.callCount;request.url+="?";for(prop in batch.map){if(typeof batch.map[prop]!="function"){request.url+=encodeURIComponent(prop)+"="+encodeURIComponent(batch.map[prop])+"&";}}
request.url=request.url.substring(0,request.url.length-1);}
else{request.body="";for(prop in batch.map){if(typeof batch.map[prop]!="function"){request.body+=prop+"="+batch.map[prop]+dwr.engine._postSeperator;}}
request.body=dwr.engine._contentRewriteHandler(request.body);}
request.url=dwr.engine._urlRewriteHandler(request.url);return request;};dwr.engine._stateChange=function(batch){var toEval;if(batch.completed){dwr.engine._debug("Error: _stateChange() with batch.completed");return;}
var req=batch.req;try{if(req.readyState!=4)return;}
catch(ex){dwr.engine._handleWarning(batch,ex);dwr.engine._clearUp(batch);return;}
try{var reply=req.responseText;reply=dwr.engine._replyRewriteHandler(reply);var status=req.status;if(reply==null||reply==""){dwr.engine._handleWarning(batch,{name:"dwr.engine.missingData",message:"No data received from server"});}
else if(status!=200){dwr.engine._handleError(batch,{name:"dwr.engine.http."+status,message:req.statusText});}
else{var contentType=req.getResponseHeader("Content-Type");if(!contentType.match(/^text\/plain/)&&!contentType.match(/^text\/javascript/)){if(contentType.match(/^text\/html/)&&typeof batch.textHtmlHandler=="function"){batch.textHtmlHandler({status:status,responseText:reply,contentType:contentType});}
else{dwr.engine._handleWarning(batch,{name:"dwr.engine.invalidMimeType",message:"Invalid content type: '"+contentType+"'"});}}
else{if(batch.isPoll&&batch.map.partialResponse==dwr.engine._partialResponseYes){dwr.engine._processCometResponse(reply,batch);}
else{if(reply.search("//#DWR")==-1){dwr.engine._handleWarning(batch,{name:"dwr.engine.invalidReply",message:"Invalid reply from server"});}
else{toEval=reply;}}}}}
catch(ex){dwr.engine._handleWarning(batch,ex);}
dwr.engine._callPostHooks(batch);dwr.engine._receivedBatch=batch;if(toEval!=null)toEval=toEval.replace(dwr.engine._scriptTagProtection,"");dwr.engine._eval(toEval);dwr.engine._receivedBatch=null;dwr.engine._validateBatch(batch);dwr.engine._clearUp(batch);};dwr.engine._validateBatch=function(batch){if(!batch.completed){for(var i=0;i<batch.map.callCount;i++){if(batch.handlers[i]!=null){dwr.engine._handleWarning(batch,{name:"dwr.engine.incompleteReply",message:"Incomplete reply from server"});break;}}}}
dwr.engine._iframeLoadingComplete=function(batchId){var batch=dwr.engine._batches[batchId];if(batch)dwr.engine._validateBatch(batch);}
dwr.engine._remoteHandleCallback=function(batchId,callId,reply){var batch=dwr.engine._batches[batchId];if(batch==null){dwr.engine._debug("Warning: batch == null in remoteHandleCallback for batchId="+batchId,true);return;}
try{var handlers=batch.handlers[callId];batch.handlers[callId]=null;if(!handlers){dwr.engine._debug("Warning: Missing handlers. callId="+callId,true);}
else if(typeof handlers.callback=="function")handlers.callback(reply);}
catch(ex){dwr.engine._handleError(batch,ex);}};dwr.engine._remoteHandleException=function(batchId,callId,ex){var batch=dwr.engine._batches[batchId];if(batch==null){dwr.engine._debug("Warning: null batch in remoteHandleException",true);return;}
var handlers=batch.handlers[callId];batch.handlers[callId]=null;if(handlers==null){dwr.engine._debug("Warning: null handlers in remoteHandleException",true);return;}
if(ex.message==undefined)ex.message="";if(typeof handlers.exceptionHandler=="function")handlers.exceptionHandler(ex.message,ex);else if(typeof batch.errorHandler=="function")batch.errorHandler(ex.message,ex);};dwr.engine._remoteHandleBatchException=function(ex,batchId){var searchBatch=(dwr.engine._receivedBatch==null&&batchId!=null);if(searchBatch){dwr.engine._receivedBatch=dwr.engine._batches[batchId];}
if(ex.message==undefined)ex.message="";dwr.engine._handleError(dwr.engine._receivedBatch,ex);if(searchBatch){dwr.engine._receivedBatch=null;dwr.engine._clearUp(dwr.engine._batches[batchId]);}};dwr.engine._remotePollCometDisabled=function(ex,batchId){dwr.engine.setActiveReverseAjax(false);var searchBatch=(dwr.engine._receivedBatch==null&&batchId!=null);if(searchBatch){dwr.engine._receivedBatch=dwr.engine._batches[batchId];}
if(ex.message==undefined)ex.message="";dwr.engine._handleError(dwr.engine._receivedBatch,ex);if(searchBatch){dwr.engine._receivedBatch=null;dwr.engine._clearUp(dwr.engine._batches[batchId]);}};dwr.engine._remoteBeginIFrameResponse=function(iframe,batchId){if(iframe!=null)dwr.engine._receivedBatch=iframe.batch;dwr.engine._callPostHooks(dwr.engine._receivedBatch);};dwr.engine._remoteEndIFrameResponse=function(batchId){dwr.engine._clearUp(dwr.engine._receivedBatch);dwr.engine._receivedBatch=null;};dwr.engine._eval=function(script){if(script==null)return null;if(script==""){dwr.engine._debug("Warning: blank script",true);return null;}
return eval(script);};dwr.engine._abortRequest=function(batch){if(batch&&!batch.completed){clearInterval(batch.interval);dwr.engine._clearUp(batch);if(batch.req)batch.req.abort();dwr.engine._handleError(batch,{name:"dwr.engine.timeout",message:"Timeout"});}};dwr.engine._callPostHooks=function(batch){if(batch.postHooks){for(var i=0;i<batch.postHooks.length;i++){batch.postHooks[i]();}
batch.postHooks=null;}};dwr.engine._clearUp=function(batch){if(!batch){dwr.engine._debug("Warning: null batch in dwr.engine._clearUp()",true);return;}
if(batch.completed=="true"){dwr.engine._debug("Warning: Double complete",true);return;}
if(batch.div)batch.div.parentNode.removeChild(batch.div);if(batch.iframe){for(var i=0;i<dwr.engine._outstandingIFrames.length;i++){if(dwr.engine._outstandingIFrames[i]==batch.iframe){dwr.engine._outstandingIFrames.splice(i,1);}}
batch.iframe.parentNode.removeChild(batch.iframe);}
if(batch.form)batch.form.parentNode.removeChild(batch.form);if(batch.req){if(batch.req==dwr.engine._pollReq)dwr.engine._pollReq=null;delete batch.req;}
if(batch.map&&(batch.map.batchId||batch.map.batchId==0)){delete dwr.engine._batches[batch.map.batchId];dwr.engine._batchesLength--;}
batch.completed=true;if(dwr.engine._batchQueue.length!=0){var sendbatch=dwr.engine._batchQueue.shift();dwr.engine._sendData(sendbatch);}};dwr.engine._handleError=function(batch,ex){if(typeof ex=="string")ex={name:"unknown",message:ex};if(ex.message==null)ex.message="";if(ex.name==null)ex.name="unknown";if(batch&&typeof batch.errorHandler=="function")batch.errorHandler(ex.message,ex);else if(dwr.engine._errorHandler)dwr.engine._errorHandler(ex.message,ex);if(batch)dwr.engine._clearUp(batch);};dwr.engine._handleWarning=function(batch,ex){if(typeof ex=="string")ex={name:"unknown",message:ex};if(ex.message==null)ex.message="";if(ex.name==null)ex.name="unknown";if(batch&&typeof batch.warningHandler=="function")batch.warningHandler(ex.message,ex);else if(dwr.engine._warningHandler)dwr.engine._warningHandler(ex.message,ex);if(batch)dwr.engine._clearUp(batch);};dwr.engine._serializeAll=function(batch,referto,data,name){if(data==null){batch.map[name]="null:null";return;}
switch(typeof data){case"boolean":batch.map[name]="boolean:"+data;break;case"number":batch.map[name]="number:"+data;break;case"string":batch.map[name]="string:"+encodeURIComponent(data);break;case"object":if(data instanceof String)batch.map[name]="String:"+encodeURIComponent(data);else if(data instanceof Boolean)batch.map[name]="Boolean:"+data;else if(data instanceof Number)batch.map[name]="Number:"+data;else if(data instanceof Date)batch.map[name]="Date:"+data.getTime();else if(data&&data.join)batch.map[name]=dwr.engine._serializeArray(batch,referto,data,name);else batch.map[name]=dwr.engine._serializeObject(batch,referto,data,name);break;case"function":break;default:dwr.engine._handleWarning(null,{name:"dwr.engine.unexpectedType",message:"Unexpected type: "+typeof data+", attempting default converter."});batch.map[name]="default:"+data;break;}};dwr.engine._lookup=function(referto,data,name){var lookup;for(var i=0;i<referto.length;i++){if(referto[i].data==data){lookup=referto[i];break;}}
if(lookup)return"reference:"+lookup.name;referto.push({data:data,name:name});return null;};dwr.engine._serializeObject=function(batch,referto,data,name){var ref=dwr.engine._lookup(referto,data,name);if(ref)return ref;if(data.nodeName&&data.nodeType){return dwr.engine._serializeXml(batch,referto,data,name);}
var reply="Object_"+dwr.engine._getObjectClassName(data)+":{";var element;for(element in data){if(typeof data[element]!="function"){batch.paramCount++;var childName="c"+dwr.engine._batch.map.callCount+"-e"+batch.paramCount;dwr.engine._serializeAll(batch,referto,data[element],childName);reply+=encodeURIComponent(element)+":reference:"+childName+", ";}}
if(reply.substring(reply.length-2)==", "){reply=reply.substring(0,reply.length-2);}
reply+="}";return reply;};dwr.engine._errorClasses={"Error":Error,"EvalError":EvalError,"RangeError":RangeError,"ReferenceError":ReferenceError,"SyntaxError":SyntaxError,"TypeError":TypeError,"URIError":URIError};dwr.engine._getObjectClassName=function(obj){if(obj&&obj.constructor&&obj.constructor.toString)
{var str=obj.constructor.toString();var regexpmatch=str.match(/function\s+(\w+)/);if(regexpmatch&&regexpmatch.length==2){return regexpmatch[1];}}
if(obj&&obj.constructor){for(var errorname in dwr.engine._errorClasses){if(obj.constructor==dwr.engine._errorClasses[errorname])return errorname;}}
if(obj){var str=Object.prototype.toString.call(obj);var regexpmatch=str.match(/\[object\s+(\w+)/);if(regexpmatch&&regexpmatch.length==2){return regexpmatch[1];}}
return"Object";};dwr.engine._serializeXml=function(batch,referto,data,name){var ref=dwr.engine._lookup(referto,data,name);if(ref)return ref;var output;if(window.XMLSerializer)output=new XMLSerializer().serializeToString(data);else if(data.toXml)output=data.toXml;else output=data.innerHTML;return"XML:"+encodeURIComponent(output);};dwr.engine._serializeArray=function(batch,referto,data,name){var ref=dwr.engine._lookup(referto,data,name);if(ref)return ref;var reply="Array:[";for(var i=0;i<data.length;i++){if(i!=0)reply+=",";batch.paramCount++;var childName="c"+dwr.engine._batch.map.callCount+"-e"+batch.paramCount;dwr.engine._serializeAll(batch,referto,data[i],childName);reply+="reference:";reply+=childName;}
reply+="]";return reply;};dwr.engine._unserializeDocument=function(xml){var dom;if(window.DOMParser){var parser=new DOMParser();dom=parser.parseFromString(xml,"text/xml");if(!dom.documentElement||dom.documentElement.tagName=="parsererror"){var message=dom.documentElement.firstChild.data;message+="\n"+dom.documentElement.firstChild.nextSibling.firstChild.data;throw message;}
return dom;}
else if(window.ActiveXObject){dom=dwr.engine._newActiveXObject(dwr.engine._DOMDocument);dom.loadXML(xml);return dom;}
else{var div=document.createElement("div");div.innerHTML=xml;return div;}};dwr.engine._newActiveXObject=function(axarray){var returnValue;for(var i=0;i<axarray.length;i++){try{returnValue=new ActiveXObject(axarray[i]);break;}
catch(ex){}}
return returnValue;};dwr.engine._debug=function(message,stacktrace){var written=false;try{if(window.console){if(stacktrace&&window.console.trace)window.console.trace();window.console.log(message);written=true;}
else if(window.opera&&window.opera.postError){window.opera.postError(message);written=true;}}
catch(ex){}
if(!written){var debug=document.getElementById("dwr-debug");if(debug){var contents=message+"<br/>"+debug.innerHTML;if(contents.length>2048)contents=contents.substring(0,2048);debug.innerHTML=contents;}}};if(dwr==null)var dwr={};if(dwr.engine==null)dwr.engine={};if(DWREngine==null)var DWREngine=dwr.engine;if(ReviewVoteService==null)var ReviewVoteService={};ReviewVoteService._path=''+JAWR.jawr_dwr_path+'';ReviewVoteService.voteYesForReview=function(p0,callback){dwr.engine._execute(ReviewVoteService._path,'ReviewVoteService','voteYesForReview',p0,callback);}
ReviewVoteService.voteNoForReview=function(p0,callback){dwr.engine._execute(ReviewVoteService._path,'ReviewVoteService','voteNoForReview',p0,callback);}
if(PicturesService==null)var PicturesService={};PicturesService._path=''+JAWR.jawr_dwr_path+'';PicturesService.getPictures=function(p0,callback){dwr.engine._execute(PicturesService._path,'PicturesService','getPictures',p0,false,callback);}
if(MapModulePersistenceService==null)var MapModulePersistenceService={};MapModulePersistenceService._path=''+JAWR.jawr_dwr_path+'';MapModulePersistenceService.get=function(callback){dwr.engine._execute(MapModulePersistenceService._path,'MapModulePersistenceService','get',callback);}
MapModulePersistenceService.store=function(p0,p1,callback){dwr.engine._execute(MapModulePersistenceService._path,'MapModulePersistenceService','store',p0,p1,callback);}
if(ActivityCalendarService==null)var ActivityCalendarService={};ActivityCalendarService._path=''+JAWR.jawr_dwr_path+'';ActivityCalendarService.getActivityDates=function(p0,callback){dwr.engine._execute(ActivityCalendarService._path,'ActivityCalendarService','getActivityDates',p0,false,callback);}
if(FeedsDiscoveryService==null)var FeedsDiscoveryService={};FeedsDiscoveryService._path=''+JAWR.jawr_dwr_path+'';FeedsDiscoveryService.autodiscovery=function(p0,callback){dwr.engine._execute(FeedsDiscoveryService._path,'FeedsDiscoveryService','autodiscovery',p0,callback);}
if(TopListSettingsService==null)var TopListSettingsService={};TopListSettingsService._path=''+JAWR.jawr_dwr_path+'';TopListSettingsService.saveCategoryState=function(p0,p1,p2,callback){dwr.engine._execute(TopListSettingsService._path,'TopListSettingsService','saveCategoryState',p0,p1,p2,callback);}
if(PortalPersistenceService==null)var PortalPersistenceService={};PortalPersistenceService._path=''+JAWR.jawr_dwr_path+'';PortalPersistenceService.removePortlet=function(p0,callback){dwr.engine._execute(PortalPersistenceService._path,'PortalPersistenceService','removePortlet',p0,callback);}
PortalPersistenceService.moveBlock=function(p0,p1,callback){dwr.engine._execute(PortalPersistenceService._path,'PortalPersistenceService','moveBlock',p0,p1,callback);}
jQuery.viewPortSize=function(){var viewportWidth;var viewportHeight;if(typeof window.innerWidth!='undefined'){viewportWidth=window.innerWidth;viewportHeight=window.innerHeight;}else if(typeof document.documentElement!='undefined'&&typeof document.documentElement.clientWidth!='undefined'&&document.documentElement.clientWidth!=0){viewportWidth=document.documentElement.clientWidth;viewportHeight=document.documentElement.clientHeight;}else{viewportWidth=document.getElementsByTagName('body')[0].clientWidth;viewportHeight=document.getElementsByTagName('body')[0].clientHeight;}
return{width:viewportWidth,height:viewportHeight};};(function($){var _evalCallback=function(){var callback=$('#evalCallback').remove().html();if(callback!=null){eval(callback);}};var _getJsonData=function(){var data=$j("#jsonData").remove().html();if(data!=null){eval("data = {"+data+"};");return data;}else{return null;}};var _performRequest=function(opts,url,data){var $loading_img;$.ajax({url:url,type:opts.method,data:data,cache:opts.cache,contentType:opts.contentType,beforeSend:function(){opts.onStart(opts);if(opts.loading_img){var spinnerHome=opts.loading_target?typeof opts.loading_target==='string'?$(opts.loading_target):opts.loading_target:opts.target;$loading_img=$('<div />').attr('id','AjaxifyLoading').append($('<img />').attr({'src':opts.loading_img,'alt':'Loading...'})).appendTo(spinnerHome);}},success:function(HTML){$loading_img&&$loading_img.remove();var content;if(opts.tagToLoad){content=$(HTML).find(opts.tagToLoad).clone();}else{content=$(HTML);}
$(opts.target).empty().append(content);_evalCallback();opts.onSuccess(opts,_getJsonData());},complete:function(){opts.onComplete(opts);},error:function(){$loading_img&&$loading_img.remove();opts.onError(opts);}});};$.fn.ajaxify=function(options){if(!jQuery(this).size()){return false;}
return this.each(function(){var defaults=$.extend({},$.fn.ajaxify.defaults,options),$this=$(this),collectParams=function(){var paramString=defaults.params;if(defaults.forms){paramString+='&'+$(defaults.forms).serialize();}
return paramString;};var eventHandler=function(){_performRequest(defaults,defaults.link||($this.attr('action')||$this.attr('href')),collectParams());return false;};$this.bind(defaults.event,eventHandler);});};$.fn.ajaxify.defaults={event:'click',link:false,target:'#container',tagToLoad:false,method:'GET',loading_img:false,loading_target:false,forms:false,params:'ajax=true',cache:false,onStart:function(op){},onError:function(op){},onSuccess:function(op){},onComplete:function(op){}};})(jQuery);(function($){$.widget("ui.modalDialog",{_init:function(){this._overlayLayer=null;this._lockerLayer=null;this._closed=false;},update:function(){var wnd=$(window);var wndSize=jQuery.viewPortSize();var ww=wndSize.width,wh=wndSize.height,wl=wnd.scrollLeft(),ws=wnd.scrollTop();var dw=this.element.width(),dh=this.element.height();var top=(wh-dh)/2;if(top<0)top=0;top+=ws;var left=(ww-dw)/2;if(left<0)left=0;left+=wl;this.element.css({position:"absolute",zIndex:9999,top:top,left:left});},loadingOverlay:function(loading){if(this.options.overlay){this._showOverlay();if(loading){var overlayLoading=$("<img/>").attr("src",DDI.contextPath+"/img/overlay-loading.gif");$(this._overlayLayer).append(overlayLoading);}else{$("img",this._overlayLayer).remove();}}},_showOverlay:function(){if(this._overlayLayer){return;}
var _this=this;var overlayHeight=function(){var windowHeight=0;if(window.innerHeight&&window.scrollMaxY){windowHeight=window.innerHeight+window.scrollMaxY;}
else{if(document.documentElement&&document.documentElement.scrollHeight){windowHeight=document.documentElement.scrollHeight;}
else{if(document.body&&document.body.scrollHeight){windowHeight=document.body.scrollHeight;}}}
return windowHeight;};this._overlayLayer=$('<div/>').appendTo(document.body).addClass('overlay').css({borderWidth:0,margin:0,padding:0,position:'fixed',top:0,left:0,height:'100%',width:'100%',zIndex:7000});if(this.options.removable===true){this._overlayLayer.css({opacity:0.5,background:"black"}).click(function(){_this.close();});}else{this._overlayLayer.css({opacity:0,background:"black"});}
if($.browser.msie&&/6.0/.test(navigator.userAgent)){$('select').hide();}
var resizeCB=function(){_this.update();if($(document.body).height()>$(window).height()){return;}
var height=overlayHeight();_this._overlayLayer.height(height);_this._overlayLayer.height();};$(window).bind('resize.modaldialog',null,resizeCB);},_destroyOverlay:function(){this._overlayLayer!==null&&this._overlayLayer.remove();this._overlayLayer=null;$(window).unbind('resize.modaldialog');$.browser.msie&&/6.0/.test(navigator.userAgent)&&$('select').show();},open:function(){this._closed=false;this.update();if(this.options.overlay){this.loadingOverlay(false);this._showOverlay();}
this.element.show();this._overlayLayer.height();},closed:function(){return this._closed;},close:function(){this._destroyOverlay();this.element.hide();this.releaseResources();this._closed=true;},lock:function(){this._closed=false;this._lockerLayer=$("<div/>").appendTo(this.element).addClass('locker').css({width:this.element.width(),height:this.element.height()});},unlock:function(){this._lockerLayer!==null&&this._lockerLayer.remove();this._lockerLayer=null;},opened:function(){return this.element.css("display")!=="none";},locked:function(){return this._lockerLayer!==null;},closeHandler:function(fn){this.options.onDialogClose=fn;},removable:function(value){this.options.removable=value;},releaseResources:function(){this.options.onDialogClose();}});$.extend($.ui.modalDialog,{getter:"opened locked closed releaseResources",setter:"closeHandler",defaults:{overlay:true,removable:true,onDialogClose:function(){return false;}}});$(document).ready(function(){$("#modalDialog").modalDialog();});$.fn.extend({dialogAjaxify:function(params){var dialogSelector='#modalDialog';var dialogLayer=$(dialogSelector);var p=$.extend({update_position:true,target:dialogSelector,loading_target:dialogSelector+' .locker',loading_img:DDI.contextPath+'/img/loading.gif'},params);$.extend(p,{onStart:function(){if(params!==undefined&&params['onStart']!==undefined){params.onStart();}
dialogLayer.modalDialog("loadingOverlay",true);dialogLayer.modalDialog("releaseResources");dialogLayer.modalDialog("lock");},onSuccess:function(opts,jsonData){if(!dialogLayer.modalDialog("closed")){dialogLayer.modalDialog("unlock");dialogLayer.modalDialog("loadingOverlay",false);if(!dialogLayer.modalDialog("opened")){dialogLayer.modalDialog("open");}
if(p.update_position){dialogLayer.modalDialog("update");}}
if(params!==undefined&&params['onSuccess']!==undefined){params.onSuccess(jsonData);}
$('.dialogCancel',dialogLayer).click(function(){dialogLayer.modalDialog("close");return false;});}});this.ajaxify(p);},showOverlay:function(){var dialogSelector='#modalDialog';var dialogLayer=$(dialogSelector);dialogLayer.modalDialog("removable",false);dialogLayer.modalDialog("loadingOverlay",false);}});})(jQuery);
(function($){$.extend($.fn,{livequery:function(type,fn,fn2){var self=this,q;if($.isFunction(type))
fn2=fn,fn=type,type=undefined;$.each($.livequery.queries,function(i,query){if(self.selector==query.selector&&self.context==query.context&&type==query.type&&(!fn||fn.$lqguid==query.fn.$lqguid)&&(!fn2||fn2.$lqguid==query.fn2.$lqguid))
return(q=query)&&false;});q=q||new $.livequery(this.selector,this.context,type,fn,fn2);q.stopped=false;q.run();return this;},expire:function(type,fn,fn2){var self=this;if($.isFunction(type))
fn2=fn,fn=type,type=undefined;$.each($.livequery.queries,function(i,query){if(self.selector==query.selector&&self.context==query.context&&(!type||type==query.type)&&(!fn||fn.$lqguid==query.fn.$lqguid)&&(!fn2||fn2.$lqguid==query.fn2.$lqguid)&&!this.stopped)
$.livequery.stop(query.id);});return this;}});$.livequery=function(selector,context,type,fn,fn2){this.selector=selector;this.context=context||document;this.type=type;this.fn=fn;this.fn2=fn2;this.elements=[];this.stopped=false;this.id=$.livequery.queries.push(this)-1;fn.$lqguid=fn.$lqguid||$.livequery.guid++;if(fn2)fn2.$lqguid=fn2.$lqguid||$.livequery.guid++;return this;};$.livequery.prototype={stop:function(){var query=this;if(this.type)
this.elements.unbind(this.type,this.fn);else if(this.fn2)
this.elements.each(function(i,el){query.fn2.apply(el);});this.elements=[];this.stopped=true;},run:function(){if(this.stopped)return;var query=this;var oEls=this.elements,els=$(this.selector,this.context),nEls=els.not(oEls);this.elements=els;if(this.type){nEls.bind(this.type,this.fn);if(oEls.length>0)
$.each(oEls,function(i,el){if($.inArray(el,els)<0)
$.event.remove(el,query.type,query.fn);});}
else{nEls.each(function(){query.fn.apply(this);});if(this.fn2&&oEls.length>0)
$.each(oEls,function(i,el){if($.inArray(el,els)<0)
query.fn2.apply(el);});}}};$.extend($.livequery,{guid:0,queries:[],queue:[],running:false,timeout:null,checkQueue:function(){if($.livequery.running&&$.livequery.queue.length){var length=$.livequery.queue.length;while(length--)
$.livequery.queries[$.livequery.queue.shift()].run();}},pause:function(){$.livequery.running=false;},play:function(){$.livequery.running=true;$.livequery.run();},registerPlugin:function(){$.each(arguments,function(i,n){if(!$.fn[n])return;var old=$.fn[n];$.fn[n]=function(){var r=old.apply(this,arguments);$.livequery.run();return r;}});},run:function(id){if(id!=undefined){if($.inArray(id,$.livequery.queue)<0)
$.livequery.queue.push(id);}
else
$.each($.livequery.queries,function(id){if($.inArray(id,$.livequery.queue)<0)
$.livequery.queue.push(id);});if($.livequery.timeout)clearTimeout($.livequery.timeout);$.livequery.timeout=setTimeout($.livequery.checkQueue,20);},stop:function(id){if(id!=undefined)
$.livequery.queries[id].stop();else
$.each($.livequery.queries,function(id){$.livequery.queries[id].stop();});}});$.livequery.registerPlugin('append','prepend','after','before','wrap','attr','removeAttr','addClass','removeClass','toggleClass','empty','remove');$(function(){$.livequery.play();});var init=$.prototype.init;$.prototype.init=function(a,c){var r=init.apply(this,arguments);if(a&&a.selector)
r.context=a.context,r.selector=a.selector;if(typeof a=='string')
r.context=c||document,r.selector=a;return r;};$.prototype.init.prototype=$.prototype;})(jQuery);;(function($){$.fn.extend({autocomplete:function(urlOrData,options){var isUrl=typeof urlOrData=="string";options=$.extend({},$.Autocompleter.defaults,{url:isUrl?urlOrData:null,data:isUrl?null:urlOrData,delay:isUrl?$.Autocompleter.defaults.delay:10,max:options&&!options.scroll?10:150},options);options.highlight=options.highlight||function(value){return value;};options.formatMatch=options.formatMatch||options.formatItem;return this.each(function(){new $.Autocompleter(this,options);});},result:function(handler){return this.bind("result",handler);},search:function(handler){return this.trigger("search",[handler]);},flushCache:function(){return this.trigger("flushCache");},setOptions:function(options){return this.trigger("setOptions",[options]);},unautocomplete:function(){return this.trigger("unautocomplete");}});$.Autocompleter=function(input,options){var KEY={UP:38,DOWN:40,DEL:46,TAB:9,RETURN:13,ESC:27,COMMA:188,PAGEUP:33,PAGEDOWN:34,BACKSPACE:8};var $input=$(input).attr("autocomplete","off").addClass(options.inputClass);var timeout;var previousValue="";var cache=$.Autocompleter.Cache(options);var hasFocus=0;var lastKeyPressCode;var config={mouseDownOnSelect:false};var select=$.Autocompleter.Select(options,input,selectCurrent,config);var blockSubmit;$.browser.opera&&$(input.form).bind("submit.autocomplete",function(){if(blockSubmit){blockSubmit=false;return false;}});$input.bind(($.browser.opera?"keypress":"keydown")+".autocomplete",function(event){lastKeyPressCode=event.keyCode;switch(event.keyCode){case KEY.UP:event.preventDefault();if(select.visible()){select.prev();}else{onChange(0,true);}
break;case KEY.DOWN:event.preventDefault();if(select.visible()){select.next();}else{onChange(0,true);}
break;case KEY.PAGEUP:event.preventDefault();if(select.visible()){select.pageUp();}else{onChange(0,true);}
break;case KEY.PAGEDOWN:event.preventDefault();if(select.visible()){select.pageDown();}else{onChange(0,true);}
break;case options.multiple&&$.trim(options.multipleSeparator)==","&&KEY.COMMA:case KEY.TAB:case KEY.RETURN:if(selectCurrent()){event.preventDefault();blockSubmit=true;return false;}
break;case KEY.ESC:select.hide();break;default:clearTimeout(timeout);timeout=setTimeout(onChange,options.delay);break;}}).focus(function(){hasFocus++;}).blur(function(){hasFocus=0;if(!config.mouseDownOnSelect){hideResults();}}).click(function(){if(hasFocus++>1&&!select.visible()){onChange(0,true);}}).bind("search",function(){var fn=(arguments.length>1)?arguments[1]:null;function findValueCallback(q,data){var result;if(data&&data.length){for(var i=0;i<data.length;i++){if(data[i].result.toLowerCase()==q.toLowerCase()){result=data[i];break;}}}
if(typeof fn=="function")fn(result);else $input.trigger("result",result&&[result.data,result.value]);}
$.each(trimWords($input.val()),function(i,value){request(value,findValueCallback,findValueCallback);});}).bind("flushCache",function(){cache.flush();}).bind("setOptions",function(){$.extend(options,arguments[1]);if("data"in arguments[1])
cache.populate();}).bind("unautocomplete",function(){select.unbind();$input.unbind();$(input.form).unbind(".autocomplete");});function selectCurrent(){var selected=select.selected();if(!selected)
return false;var v=selected.result;previousValue=v;if(options.multiple){var words=trimWords($input.val());if(words.length>1){v=words.slice(0,words.length-1).join(options.multipleSeparator)+options.multipleSeparator+v;}
v+=options.multipleSeparator;}
$input.val(v);hideResultsNow();$input.trigger("result",[selected.data,selected.value]);return true;}
function onChange(crap,skipPrevCheck){if(lastKeyPressCode==KEY.DEL){select.hide();return;}
var currentValue=$input.val();if(!skipPrevCheck&&currentValue==previousValue)
return;previousValue=currentValue;currentValue=lastWord(currentValue);if(currentValue.length>=options.minChars){$input.addClass(options.loadingClass);if(!options.matchCase)
currentValue=currentValue.toLowerCase();request(currentValue,receiveData,hideResultsNow);}else{stopLoading();select.hide();}};function trimWords(value){if(!value){return[""];}
var words=value.split(options.multipleSeparator);var result=[];$.each(words,function(i,value){if($.trim(value))
result[i]=$.trim(value);});return result;}
function lastWord(value){if(!options.multiple)
return value;var words=trimWords(value);return words[words.length-1];}
function autoFill(q,sValue){if(options.autoFill&&(lastWord($input.val()).toLowerCase()==q.toLowerCase())&&lastKeyPressCode!=KEY.BACKSPACE){$input.val($input.val()+sValue.substring(lastWord(previousValue).length));$.Autocompleter.Selection(input,previousValue.length,previousValue.length+sValue.length);}};function hideResults(){clearTimeout(timeout);timeout=setTimeout(hideResultsNow,200);};function hideResultsNow(){var wasVisible=select.visible();select.hide();clearTimeout(timeout);stopLoading();if(options.mustMatch){$input.search(function(result){if(!result){if(options.multiple){var words=trimWords($input.val()).slice(0,-1);$input.val(words.join(options.multipleSeparator)+(words.length?options.multipleSeparator:""));}
else
$input.val("");}});}
if(wasVisible)
$.Autocompleter.Selection(input,input.value.length,input.value.length);};function receiveData(q,data){if(data&&data.length&&hasFocus){stopLoading();select.display(data,q);autoFill(q,data[0].value);select.show();}else{hideResultsNow();}};function request(term,success,failure){if(!options.matchCase)
term=term.toLowerCase();var data=cache.load(term);if(data&&data.length){success(term,data);}else if((typeof options.url=="string")&&(options.url.length>0)){var extraParams={timestamp:+new Date()};$.each(options.extraParams,function(key,param){extraParams[key]=typeof param=="function"?param():param;});$.ajax({mode:"abort",port:"autocomplete"+input.name,dataType:options.dataType,url:options.url,data:$.extend({q:lastWord(term),limit:options.max},extraParams),success:function(data){var parsed=options.parse&&options.parse(data)||parse(data);cache.add(term,parsed);success(term,parsed);}});}else{select.emptyList();failure(term);}};function parse(data){var parsed=[];var rows=data.split("\n");for(var i=0;i<rows.length;i++){var row=$.trim(rows[i]);if(row){row=row.split("|");parsed[parsed.length]={data:row,value:row[0],result:options.formatResult&&options.formatResult(row,row[0])||row[0]};}}
return parsed;};function stopLoading(){$input.removeClass(options.loadingClass);};};$.Autocompleter.defaults={inputClass:"ac_input",resultsClass:"ac_results",loadingClass:"ac_loading",minChars:1,delay:400,matchCase:false,matchSubset:true,matchContains:false,cacheLength:10,max:100,mustMatch:false,extraParams:{},selectFirst:true,formatItem:function(row){return row[0];},formatMatch:null,autoFill:false,width:0,multiple:false,multipleSeparator:", ",highlight:function(value,term){return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)","gi"),"<strong>$1</strong>");},scroll:true,scrollHeight:180};$.Autocompleter.Cache=function(options){var data={};var length=0;function matchSubset(s,sub){if(!options.matchCase)
s=s.toLowerCase();var i=s.indexOf(sub);if(options.matchContains=="word"){i=s.toLowerCase().search("\\b"+sub.toLowerCase());}
if(i==-1)return false;return i==0||options.matchContains;};function add(q,value){if(length>options.cacheLength){flush();}
if(!data[q]){length++;}
data[q]=value;}
function populate(){if(!options.data)return false;var stMatchSets={},nullData=0;if(!options.url)options.cacheLength=1;stMatchSets[""]=[];for(var i=0,ol=options.data.length;i<ol;i++){var rawValue=options.data[i];rawValue=(typeof rawValue=="string")?[rawValue]:rawValue;var value=options.formatMatch(rawValue,i+1,options.data.length);if(value===false)
continue;var firstChar=value.charAt(0).toLowerCase();if(!stMatchSets[firstChar])
stMatchSets[firstChar]=[];var row={value:value,data:rawValue,result:options.formatResult&&options.formatResult(rawValue)||value};stMatchSets[firstChar].push(row);if(nullData++<options.max){stMatchSets[""].push(row);}};$.each(stMatchSets,function(i,value){options.cacheLength++;add(i,value);});}
setTimeout(populate,25);function flush(){data={};length=0;}
return{flush:flush,add:add,populate:populate,load:function(q){if(!options.cacheLength||!length)
return null;if(!options.url&&options.matchContains){var csub=[];for(var k in data){if(k.length>0){var c=data[k];$.each(c,function(i,x){if(matchSubset(x.value,q)){csub.push(x);}});}}
return csub;}else
if(data[q]){return data[q];}else
if(options.matchSubset){for(var i=q.length-1;i>=options.minChars;i--){var c=data[q.substr(0,i)];if(c){var csub=[];$.each(c,function(i,x){if(matchSubset(x.value,q)){csub[csub.length]=x;}});return csub;}}}
return null;}};};$.Autocompleter.Select=function(options,input,select,config){var CLASSES={ACTIVE:"ac_over"};var listItems,active=-1,data,term="",needsInit=true,element,list;function init(){if(!needsInit)
return;element=$("<div/>").hide().addClass(options.resultsClass).css("position","absolute").appendTo(document.body);list=$("<ul/>").appendTo(element).mouseover(function(event){if(target(event).nodeName&&target(event).nodeName.toUpperCase()=='LI'){active=$("li",list).removeClass(CLASSES.ACTIVE).index(target(event));$(target(event)).addClass(CLASSES.ACTIVE);}}).click(function(event){$(target(event)).addClass(CLASSES.ACTIVE);select();input.focus();return false;}).mousedown(function(){config.mouseDownOnSelect=true;}).mouseup(function(){config.mouseDownOnSelect=false;});if(options.width>0)
element.css("width",options.width);needsInit=false;}
function target(event){var element=event.target;while(element&&element.tagName!="LI")
element=element.parentNode;if(!element)
return[];return element;}
function moveSelect(step){listItems.slice(active,active+1).removeClass(CLASSES.ACTIVE);movePosition(step);var activeItem=listItems.slice(active,active+1).addClass(CLASSES.ACTIVE);if(options.scroll){var offset=0;listItems.slice(0,active).each(function(){offset+=this.offsetHeight;});if((offset+activeItem[0].offsetHeight-list.scrollTop())>list[0].clientHeight){list.scrollTop(offset+activeItem[0].offsetHeight-list.innerHeight());}else if(offset<list.scrollTop()){list.scrollTop(offset);}}};function movePosition(step){active+=step;if(active<0){active=listItems.size()-1;}else if(active>=listItems.size()){active=0;}}
function limitNumberOfItems(available){return options.max&&options.max<available?options.max:available;}
function fillList(){list.empty();var max=limitNumberOfItems(data.length);for(var i=0;i<max;i++){if(!data[i])
continue;var formatted=options.formatItem(data[i].data,i+1,max,data[i].value,term);if(formatted===false)
continue;var li=$("<li/>").html(options.highlight(formatted,term)).addClass(i%2==0?"ac_even":"ac_odd").appendTo(list)[0];$.data(li,"ac_data",data[i]);}
listItems=list.find("li");if(options.selectFirst){listItems.slice(0,1).addClass(CLASSES.ACTIVE);active=0;}
if($.fn.bgiframe)
list.bgiframe();}
return{display:function(d,q){init();data=d;term=q;fillList();},next:function(){moveSelect(1);},prev:function(){moveSelect(-1);},pageUp:function(){if(active!=0&&active-8<0){moveSelect(-active);}else{moveSelect(-8);}},pageDown:function(){if(active!=listItems.size()-1&&active+8>listItems.size()){moveSelect(listItems.size()-1-active);}else{moveSelect(8);}},hide:function(){element&&element.hide();listItems&&listItems.removeClass(CLASSES.ACTIVE);active=-1;},visible:function(){return element&&element.is(":visible");},current:function(){return this.visible()&&(listItems.filter("."+CLASSES.ACTIVE)[0]||options.selectFirst&&listItems[0]);},show:function(){var offset=$(input).offset();element.css({width:typeof options.width=="string"||options.width>0?options.width:$(input).width(),top:offset.top+input.offsetHeight,left:offset.left}).show();if(options.scroll){list.scrollTop(0);list.css({maxHeight:options.scrollHeight,overflow:'auto'});if($.browser.msie&&typeof document.body.style.maxHeight==="undefined"){var listHeight=0;listItems.each(function(){listHeight+=this.offsetHeight;});var scrollbarsVisible=listHeight>options.scrollHeight;list.css('height',scrollbarsVisible?options.scrollHeight:listHeight);if(!scrollbarsVisible){listItems.width(list.width()-parseInt(listItems.css("padding-left"))-parseInt(listItems.css("padding-right")));}}}},selected:function(){var selected=listItems&&listItems.filter("."+CLASSES.ACTIVE).removeClass(CLASSES.ACTIVE);return selected&&selected.length&&$.data(selected[0],"ac_data");},emptyList:function(){list&&list.empty();},unbind:function(){element&&element.remove();}};};$.Autocompleter.Selection=function(field,start,end){if(field.createTextRange){var selRange=field.createTextRange();selRange.collapse(true);selRange.moveStart("character",start);selRange.moveEnd("character",end);selRange.select();}else if(field.setSelectionRange){field.setSelectionRange(start,end);}else{if(field.selectionStart){field.selectionStart=start;field.selectionEnd=end;}}
field.focus();};})(jQuery);(function($){var autocompleteCounter=1;var id;$.fn.extend({ddiAutocomplete:function(options){id=autocompleteCounter++;var defaults={width:320,max:150,autoFill:false,highlight:false,url:DDI.contextPath+"/geochoice/suggest/",formatItem:function(row,i,total,value,term){var matched=row[0];if(row[1]!=undefined){var resulted=row[1];}
matched=matched.replace(new RegExp("(^"+term+")","gi"),"<strong>$1</strong>");return'<div><div style="float:left">'+matched+'</div>'
+(resulted!=undefined?'<div style="float:right">'+resulted+'</div></div>':'</div>');},formatResult:function(row){var result=row[1];if(row[1]==undefined){result=row[0];}
return result;},resultsClass:'ac_results '+id};var opts=$.extend(defaults,options);$(this).autocomplete(opts.url,opts);if($.browser.msie){var this_=this;$("div.ac_results."+id+" ul").livequery('scroll',function(){this_.focus();$(this).trigger('mouseup');});}},ddiAutocompleteDetach:function(){$(this).unautocomplete();$("div.ac_results."+id).remove().hide();}});})(jQuery);;(function($){if(/1\.(0|1|2)\.(0|1|2)/.test($.fn.jquery)||/^1.1/.test($.fn.jquery)){alert('blockUI requires jQuery v1.2.3 or later!  You are using v'+$.fn.jquery);return;}
$.fn._fadeIn=$.fn.fadeIn;$.blockUI=function(opts){install(window,opts);};$.unblockUI=function(opts){remove(window,opts);};$.growlUI=function(title,message,timeout){var $m=$('<div class="growlUI"></div>');if(title)$m.append('<h1>'+title+'</h1>');if(message)$m.append('<h2>'+message+'</h2>');if(timeout==undefined)timeout=3000;$.blockUI({message:$m,fadeIn:700,fadeOut:1000,centerY:false,timeout:timeout,showOverlay:false,css:$.blockUI.defaults.growlCSS});};$.fn.block=function(opts){return this.unblock({fadeOut:0}).each(function(){if($.css(this,'position')=='static')
this.style.position='relative';if($.browser.msie)
this.style.zoom=1;install(this,opts);});};$.fn.unblock=function(opts){return this.each(function(){remove(this,opts);});};$.blockUI.version=2.18;$.blockUI.defaults={message:'<h1>Please wait...</h1>',css:{padding:0,margin:0,width:'30%',top:'40%',left:'35%',textAlign:'center',color:'#000',border:'3px solid #aaa',backgroundColor:'#fff',cursor:'wait'},overlayCSS:{backgroundColor:'#000',opacity:'0.6'},growlCSS:{width:'350px',top:'10px',left:'',right:'10px',border:'none',padding:'5px',opacity:'0.6',cursor:null,color:'#fff',backgroundColor:'#000','-webkit-border-radius':'10px','-moz-border-radius':'10px'},iframeSrc:'javascript:false',forceIframe:false,baseZ:1000,centerX:true,centerY:true,allowBodyStretch:true,constrainTabKey:true,fadeIn:200,fadeOut:400,timeout:0,showOverlay:true,focusInput:true,applyPlatformOpacityRules:true,onUnblock:null,quirksmodeOffsetHack:4};var ie6=$.browser.msie&&/MSIE 6.0/.test(navigator.userAgent);var pageBlock=null;var pageBlockEls=[];function install(el,opts){var full=(el==window);var msg=opts&&opts.message!==undefined?opts.message:undefined;opts=$.extend({},$.blockUI.defaults,opts||{});opts.overlayCSS=$.extend({},$.blockUI.defaults.overlayCSS,opts.overlayCSS||{});var css=$.extend({},$.blockUI.defaults.css,opts.css||{});msg=msg===undefined?opts.message:msg;if(full&&pageBlock)
remove(window,{fadeOut:0});if(msg&&typeof msg!='string'&&(msg.parentNode||msg.jquery)){var node=msg.jquery?msg[0]:msg;var data={};$(el).data('blockUI.history',data);data.el=node;data.parent=node.parentNode;data.display=node.style.display;data.position=node.style.position;if(data.parent)
data.parent.removeChild(node);}
var z=opts.baseZ;var lyr1=($.browser.msie)?$('<iframe class="blockUI" style="z-index:'+(z++)+';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="'+opts.iframeSrc+'"></iframe>'):$('<div class="blockUI" style="display:none"></div>');var lyr2=$('<div class="blockUI blockOverlay" style="z-index:'+(z++)+';display:none;cursor:wait;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');var lyr3=full?$('<div class="blockUI blockMsg blockPage" style="z-index:'+z+';display:none;position:fixed"></div>'):$('<div class="blockUI blockMsg blockElement" style="z-index:'+z+';display:none;position:absolute"></div>');if(msg)
lyr3.css(css);if(!opts.applyPlatformOpacityRules||!($.browser.mozilla&&/Linux/.test(navigator.platform)))
lyr2.css(opts.overlayCSS);lyr2.css('position',full?'fixed':'absolute');if($.browser.msie)
lyr1.css('opacity','0.0');$([lyr1[0],lyr2[0],lyr3[0]]).appendTo(full?'body':el);var expr=$.browser.msie&&($.browser.version<8||!$.boxModel)&&(!$.boxModel||$('object,embed',full?null:el).length>0);if(ie6||(expr&&lyr3[0].style.setExpression)){if(full&&opts.allowBodyStretch&&$.boxModel)
$('html,body').css('height','100%');if((ie6||!$.boxModel)&&!full){var t=sz(el,'borderTopWidth'),l=sz(el,'borderLeftWidth');var fixT=t?'(0 - '+t+')':0;var fixL=l?'(0 - '+l+')':0;}
$.each([lyr1,lyr2,lyr3],function(i,o){var s=o[0].style;s.position='absolute';if(i<2){full?s.setExpression('height','Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.boxModel?0:'+opts.quirksmodeOffsetHack+') + "px"'):s.setExpression('height','this.parentNode.offsetHeight + "px"');full?s.setExpression('width','jQuery.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"'):s.setExpression('width','this.parentNode.offsetWidth + "px"');if(fixL)s.setExpression('left',fixL);if(fixT)s.setExpression('top',fixT);}
else if(opts.centerY){if(full)s.setExpression('top','(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"');s.marginTop=0;}
else if(!opts.centerY&&full){var top=(opts.css&&opts.css.top)?parseInt(opts.css.top):0;var expression='((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + '+top+') + "px"';s.setExpression('top',expression);}});}
if(msg){lyr3.append(msg);if(msg.jquery||msg.nodeType)
$(msg).show();}
if($.browser.msie&&opts.showOverlay)
lyr1.show();if(opts.fadeIn){if(opts.showOverlay)
lyr2._fadeIn(opts.fadeIn);if(msg)
lyr3.fadeIn(opts.fadeIn);}
else{if(opts.showOverlay)
lyr2.show();if(msg)
lyr3.show();}
bind(1,el,opts);if(full){pageBlock=lyr3[0];pageBlockEls=$(':input:enabled:visible',pageBlock);if(opts.focusInput)
setTimeout(focus,20);}
else
center(lyr3[0],opts.centerX,opts.centerY);if(opts.timeout){var to=setTimeout(function(){full?$.unblockUI(opts):$(el).unblock(opts);},opts.timeout);$(el).data('blockUI.timeout',to);}};function remove(el,opts){var full=el==window;var $el=$(el);var data=$el.data('blockUI.history');var to=$el.data('blockUI.timeout');if(to){clearTimeout(to);$el.removeData('blockUI.timeout');}
opts=$.extend({},$.blockUI.defaults,opts||{});bind(0,el,opts);var els=full?$('body').children().filter('.blockUI'):$('.blockUI',el);if(full)
pageBlock=pageBlockEls=null;if(opts.fadeOut){els.fadeOut(opts.fadeOut);setTimeout(function(){reset(els,data,opts,el);},opts.fadeOut);}
else
reset(els,data,opts,el);};function reset(els,data,opts,el){els.each(function(i,o){if(this.parentNode)
this.parentNode.removeChild(this);});if(data&&data.el){data.el.style.display=data.display;data.el.style.position=data.position;if(data.parent)
data.parent.appendChild(data.el);$(data.el).removeData('blockUI.history');}
if(typeof opts.onUnblock=='function')
opts.onUnblock(el,opts);};function bind(b,el,opts){var full=el==window,$el=$(el);if(!b&&(full&&!pageBlock||!full&&!$el.data('blockUI.isBlocked')))
return;if(!full)
$el.data('blockUI.isBlocked',b);if(b&&!opts.showOverlay)
return;var events='mousedown mouseup keydown keypress';b?$(document).bind(events,opts,handler):$(document).unbind(events,handler);};function handler(e){if(e.keyCode&&e.keyCode==9){if(pageBlock&&e.data.constrainTabKey){var els=pageBlockEls;var fwd=!e.shiftKey&&e.target==els[els.length-1];var back=e.shiftKey&&e.target==els[0];if(fwd||back){setTimeout(function(){focus(back)},10);return false;}}}
if($(e.target).parents('div.blockMsg').length>0)
return true;return $(e.target).parents().children().filter('div.blockUI').length==0;};function focus(back){if(!pageBlockEls)
return;var e=pageBlockEls[back===true?pageBlockEls.length-1:0];if(e)
e.focus();};function center(el,x,y){var p=el.parentNode,s=el.style;var l=((p.offsetWidth-el.offsetWidth)/2)-sz(p,'borderLeftWidth');var t=((p.offsetHeight-el.offsetHeight)/2)-sz(p,'borderTopWidth');if(x)s.left=l>0?(l+'px'):'0';if(y)s.top=t>0?(t+'px'):'0';};function sz(el,p){return parseInt($.css(el,p))||0;};})(jQuery);
(function($){$.widget("ui.dropdown",{_init:function(){this.dropDownVisible=false;var _this=this;this.dropDownObserver=function(event){var isChildOf=$(event.target)[0]==$(_this.element)[0];if(!isChildOf){$(event.target).parents().each(function(){isChildOf=isChildOf||$(this)[0]==$(_this.element)[0];});}
if(!isChildOf){_this.hideDropDown();}};$(this.options.opener).click(function(){if(!_this.visible()){_this.showDropDown();}else{_this.hideDropDown();}
return false;});},showDropDown:function(){this.dropDownVisible=true;$(document).bind("click.dropdown_"+this.options.id,null,this.dropDownObserver);this.options.onShow&&this.options.onShow.call($(this.element),$(this.options.opener));this.options.showFn.call($(this.element),this.options.toggleSpeed);},hideDropDown:function(){this.dropDownVisible=false;$(document).unbind("click.dropdown_"+this.options.id,null,this.dropDownObserver);this.options.hideFn.call($(this.element),this.options.toggleSpeed);this.options.afterHide&&this.options.afterHide.call($(this.element),$(this.options.opener));},visible:function(){return this.dropDownVisible;}});$.extend($.ui.dropdown,{getter:"visible",defaults:{id:"",opener:undefined,toggleSpeed:undefined,onShow:undefined,afterHide:undefined,showFn:$().show,hideFn:$().hide}});})(jQuery);(function($){$.widget("ui.dropdownWizard",{_init:function(){this._currentlyOpen=-1;this._stepElements=this._prepareStepElements(this.options.stepElements);var _this=this;this.hideWizardObserver=function(event){if(!event.isPropagationStopped()&&_this.visible()){var currentElement=$(_this._stepElements[_this._currentlyOpen].element)[0];var isChildOf=$(event.target)[0]==currentElement;if(!isChildOf){$(event.target).parents().each(function(){isChildOf=isChildOf||$(this)[0]==currentElement;});}
if(!isChildOf){_this.hideWizard();}}};$(this.options.opener).click(function(){if(!_this.visible()){_this.showWizard();}else{_this.hideWizard();}
return false;});if(this.options.fwdSwitcher){$(this.options.fwdSwitcher).live('click',function(event){event.stopPropagation();_this.stepForward();return false;});}
if(this.options.backSwitcher){$(this.options.backSwitcher).live('click',function(event){event.stopPropagation();_this.stepBack();return false;});}},_prepareStepElements:function(optionsElements){if(optionsElements.length>1&&this.options.content){throw new Error("'content' may be specified if there is only one element.");}
var resultElements=new Array();for(var i=0;i<optionsElements.length;i++){var optionsElement=optionsElements[i];if(optionsElement.element){resultElements[i]=optionsElement;}else{resultElements[i]={element:optionsElement};}
if(this.options.content){resultElements[i].content=this.options.content;}}
return resultElements;},showWizard:function(){var firstStep=this._stepElements[0];if(firstStep){this._currentlyOpen=0;$(document).bind("click.dropdownWizard_"+this.options.id,null,this.hideWizardObserver);this._loadStep(firstStep);}},_loadStep:function(stepInfo){var $stepElement=$(stepInfo.element);var callback=this._createStepShowCallback(this.options,stepInfo);if(stepInfo.content&&!$stepElement.children().length){$stepElement.load(stepInfo.content.url,this._createStepInitCallback(stepInfo,callback));}else{callback();}},_createStepShowCallback:function(options,stepInfo){return function(){var $stepElement=$(stepInfo.element);options.onShow&&options.onShow.call($stepElement);options.showFn.call($stepElement,options.toggleSpeed,stepInfo.afterShow);};},_createStepInitCallback:function(stepInfo,callback){if(!stepInfo.content.init){return callback;}else{return function(){stepInfo.content.init();callback();};}},hideWizard:function(){var wasOpen=this._currentlyOpen;this._currentlyOpen=-1;var wasOpenStep=this._stepElements[wasOpen];if(wasOpenStep){$(document).unbind("click.dropdownWizard_"+this.options.id,null,this.hideWizardObserver);this._hideStep(this.options,wasOpenStep);}},_hideStep:function(options,stepInfo){var $stepElement=$(stepInfo.element);options.hideFn.call($stepElement,options.toggleSpeed,stepInfo.afterHide);options.afterHide&&options.afterHide.call($stepElement);},stepForward:function(){this.switchToStep(this._currentlyOpen+1);},stepBack:function(){this.switchToStep(this._currentlyOpen-1);},switchToStep:function(stepNum){if(this.visible()){var previous=this._currentlyOpen;var previousStep=this._stepElements[previous];var futureStep=this._stepElements[stepNum];if(futureStep){this._currentlyOpen=stepNum;this._hideStep(this.options,previousStep);this._loadStep(futureStep);}}},visible:function(){return this._currentlyOpen>-1&&this._stepElements[this._currentlyOpen];}});$.extend($.ui.dropdownWizard,{defaults:{id:"",opener:undefined,fwdSwitcher:undefined,backSwitcher:undefined,stepElements:[],toggleSpeed:undefined,onShow:undefined,afterHide:undefined,content:null,showFn:$().show,hideFn:$().hide}});})(jQuery);
DDI.Dialog={openDialog:function(url,postParams,callback){$j("#modalDialog").load(url,postParams,function(data,textStatus){if(!$j(this).modalDialog("opened")){$j(this).modalDialog("open");}
if(callback!==undefined){callback(data,textStatus);}});},closeDialog:function(){$j("#modalDialog").modalDialog("close");},isDialogClosed:function(){return $j("#modalDialog").modalDialog("closed");}};(function($){DDI.GeoChoice={mapContainerSelector:null,countyIdMapping:null,initGeoChoice:function(opts){if(opts==null||opts.mapContainerSelector==null||opts.countyIdMapping==null){throw new Error("Illegal argument exception! Required arguments are not specified!");}
this.mapContainerSelector=opts.mapContainerSelector;this.countyIdMapping=opts.countyIdMapping;},detachAutocompleter:function(){$('#munNameAutocomplete').ddiAutocompleteDetach();},createAutocompleter:function(){$('#munNameAutocomplete').ddiAutocomplete({width:250});}};})(jQuery);(function($){$.extend(DDI.GeoChoice,{initMap:function(){var that=this;$("area",this.mapContainerSelector).each(function(){var countyId=that.countyIdMapping[this.id];var thisAreaElement=this;$(this).click(function(){that._loadMunicipalities(countyId);return false;});$("#countyLink"+countyId).click(function(){$(thisAreaElement).click();return false;});$("#countyLink"+countyId).mouseover(function(){$(thisAreaElement).mouseover();});$("#countyLink"+countyId).mouseout(function(){$(thisAreaElement).mouseout();});});},_loadMunicipalities:function(countyId){if(this.currentRequest){this.currentRequest.abort();}
var loader='<img src="'+DDI.contextPath+'/img/ajax-loader.gif" style="top: 50px; left: 45%; position: relative;">';$("#mapCounties").hide();$("#mapRes").empty().append(loader);this.currentRequest=$.ajax({type:"GET",url:DDI.contextPath+"/geochoice/county/",data:{id:countyId},success:function(response){$("#mapRes").html(response);DDI.GeoChoice.initMunicipalityLinks();}});},initChooseForm:function(){var that=this;$('#municipalityForm').submit(function(){var municipalityName=$("#municipalityForm input[name='name']").val();if($.trim(municipalityName).length==0){that._showEmptyMunicipalityError();return false;}
var isMunicipalityNameValid=that._validateMunicipalityName(municipalityName);if(isMunicipalityNameValid||false){$(".geoSelectorWrapper").dropdownWizard("hideWizard");return true;}else{that._showWrongMunicipalityNameError(municipalityName);return false;}});},_validateMunicipalityName:function(municipalityName){var result;$.ajax({type:"GET",url:DDI.contextPath+"/geochoice/validate/",data:{name:municipalityName},dataType:'json',async:false,success:function(response){result=response.valid;}});return result;},_showEmptyMunicipalityError:function(){var formErrors=$("#municipalityForm .msg");$("#municipalityErrorCause",formErrors).html(i18n.validation.errors.blank_query()).show();$("#municipalityErrorHint",formErrors).html(i18n.geochoice.error.suggestion()).show();formErrors.show();},_showWrongMunicipalityNameError:function(municipalityName){var formErrors=$("#municipalityForm .msg");$("#municipalityErrorCause",formErrors).html(i18n.geochoice.error.didnt_match(this._getShortName(municipalityName))).show();$("#municipalityErrorHint",formErrors).html(i18n.geochoice.error.suggestion()).show();formErrors.show();},_getShortName:function(municipalityName){var shortMunicipalityName;if(municipalityName&&municipalityName.length>20){shortMunicipalityName=municipalityName.substring(0,20)+"...";}else{shortMunicipalityName=municipalityName;}
return shortMunicipalityName;},initMunicipalityLinks:function(){$(".municipalityLink").click(function(){$(".geoSelectorWrapper").dropdownWizard("hideWizard");return true;});}});})(jQuery);<!--
function MM_preloadImages(){var d=document;if(d.images){if(!d.MM_p)d.MM_p=new Array();var i,j=d.MM_p.length,a=MM_preloadImages.arguments;for(i=0;i<a.length;i++)
if(a[i].indexOf("#")!=0){d.MM_p[j]=new Image;d.MM_p[j++].src=a[i];}}}
function MM_swapImgRestore(){var i,x,a=document.MM_sr;for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)x.src=x.oSrc;}
function MM_findObj(n,d){var p,i,x;if(!d)d=document;if((p=n.indexOf("?"))>0&&parent.frames.length){d=parent.frames[n.substring(p+1)].document;n=n.substring(0,p);}
if(!(x=d[n])&&d.all)x=d.all[n];for(i=0;!x&&i<d.forms.length;i++)x=d.forms[i][n];for(i=0;!x&&d.layers&&i<d.layers.length;i++)x=MM_findObj(n,d.layers[i].document);if(!x&&d.getElementById)x=d.getElementById(n);return x;}
function MM_swapImage(){var i,j=0,x,a=MM_swapImage.arguments;document.MM_sr=new Array;for(i=0;i<(a.length-2);i+=3)
if((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x;if(!x.oSrc)x.oSrc=x.src;x.src=a[i+2];}}
(function($){DDI.Favorites={loader:'<img class="loader" src="'+DDI.contextPath+'/img/ajax-loader.gif">',init:function(){var _this=this;var showLoader=function(){if($("#favorite-panel").is(":visible")){$("#favorite-panel .list").append(_this.loader);}else{$(".favorite").append(_this.loader);}};var hideLoader=function(){$(".favoritesWrapper .loader").remove();};var updateFavoritesList=function(htmlResponse){$("#favorite-panel .list").empty().html(htmlResponse);};var performFavoritesChange=function(id,action,callback){unBindAll();showLoader();$.ajax({type:"GET",url:DDI.contextPath+"/favorite",data:{id:id,action:action},success:function(response){updateFavoritesList(response);if(callback){callback.call(this);}},complete:function(){hideLoader();bindAll();}});};var addCurrentToFavorites=function(){performFavoritesChange(DDI.municipalityId,"add",function(){$("#saved-msg").slideToggle("slow");window.setTimeout(function(){$("#saved-msg").fadeOut(1000);},5000);$(".addToFavoritesBtn").addClass("added");});return false;};var removeFromFavorites=function(){var id=this.id.replace("delete_","");performFavoritesChange(id,"remove",function(){if(id==DDI.municipalityId){$(".addToFavoritesBtn").removeClass("added");$("#saved-msg").hide();}});return false;};var removeCurrentFromFavorites=function(){$("#saved-msg").hide();performFavoritesChange(DDI.municipalityId,"remove",function(){$(".addToFavoritesBtn").removeClass("added");});return false;};var bindAll=function(){$(".addToFavoritesBtn").live("click",function(){var $this=$(this);if($this.not('.added')){addCurrentToFavorites();}
return false;});$("#undoAddFavorite").live('click',removeCurrentFromFavorites);$("#favorite-panel .delete").click(removeFromFavorites);};var unBindAll=function(){$(".addToFavoritesBtn").unbind("click",addCurrentToFavorites);$("#undoAddFavorite").unbind("click",removeCurrentFromFavorites);$("#favorite-panel .delete").unbind("click",removeFromFavorites);};bindAll();}};})(jQuery);DDI.FBLoginButton={init:function(){var handle_facebook_login=function(){window.location.href=DDI.contextPath+'/auth/facebook';};$j("#fbLogin").click(function(){handle_facebook_login();return false;});}};(function($){$(function(){$.ajaxSetup({cache:false});});})(jQuery);(function($){$(function(){$.blockUI.defaults.message='<img src="'+DDI.contextPath+'/img/loading.gif"/>';$.blockUI.defaults.css.border='none';$.blockUI.defaults.css.backgroundColor='';$.blockUI.defaults.overlayCSS.opacity='0.1';});})(jQuery);(function($){$(function(){$("#favorites-message-container").load(DDI.contextPath+'/fragment/favotire-message.html');$(".save-area").dropdownWizard({id:"favorite",opener:".save-area.favorite-btn",stepElements:["#favorite-panel"],toggleSpeed:"slow",showFn:$().slideDown,hideFn:$().slideUp,content:{url:DDI.contextPath+'/fragment/favorites.html'},onShow:function(){$(".save-area.favorite-btn").addClass("active");$(".geoSelectorWrapper").dropdownWizard("hideWizard");},afterHide:function(){$(".save-area.favorite-btn").removeClass("active");}});DDI.Favorites.init();});})(jQuery);(function($){$(function(){$(".geoSelectorWrapper").dropdownWizard({id:"geoSelect",opener:"#geoSelect, .change-area.area-btn",fwdSwitcher:"#openGeochoice",backSwitcher:"#backToGeoSelect",stepElements:[{element:"#area-panel",content:{url:DDI.contextPath+'/fragment/select-area.html',init:function(){DDI.GeoChoice.createAutocompleter();$("#municipalityForm input[name='name']").ezpz_hint({hintClass:'qHint'});}}},{element:"#map-panel",content:{url:DDI.contextPath+'/fragment/map.html',init:function(){DDI.GeoChoice.initMap();DDI.GeoChoice.initChooseForm();}}}],toggleSpeed:"slow",showFn:$().slideDown,hideFn:$().slideUp,onShow:function(){$(".change-area.area-btn").addClass("active");$("#municipalityForm .msg").hide();var input=$("#municipalityForm input[name='name']");input.val("");input[0].tryShowHint();$("#mapRes").empty();$("#mapCounties").show();$(".save-area").dropdownWizard("hideWizard");},afterHide:function(){$(".change-area.area-btn").removeClass("active");}});});})(jQuery);(function($){$(function(){$("#openLogin").dialogAjaxify({onSuccess:DDI.FBLoginButton.init});$("#openFBLogin").dialogAjaxify({onSuccess:DDI.FBLoginButton.init});$("#createLogin").dialogAjaxify({onSuccess:DDI.FBLoginButton.init});});})(jQuery);(function($){$(function(){$("#mainSearchForm").submit(function(){var q=$j("#mainSearchForm input[name=q]").val();if($.trim(q).length==0){return false;}});$("#mainSearchForm .searchBtn").click(function(){var link=$(this).attr("href")||$(this).parents('form').attr('action');$('#mainSearchForm').attr("action",link).submit();return false;});});})(jQuery);DDI.SignIn={ajaxifyLinks:function(){$j("#forgotPwdLink").dialogAjaxify();$j("#signinSignupLink").dialogAjaxify();}};DDI.ForgotPwd={initDialog:function(){$j("#forgotPwdCancel").click(function(){DDI.Dialog.closeDialog();return false;});}};(function($){$.fn.ezpz_hint=function(options){var defaults={hintClass:'ezpz-hint',hintName:'ezpz_hint_dummy_input'};var settings=$.extend(defaults,options);return this.each(function(i){var hint=new EzpzHint($(this),i,settings);$.extend(this,{tryShowHint:function(){hint.tryShowHint();},hideHint:function(){hint.hideHint();}});});};var EzpzHint=function(input,i,settings){this._init(input,i,settings);};EzpzHint.prototype={_init:function(input,i,settings){var _this=this;_this.inputField=input;_this.hintField=_this._createHintField(i,settings);_this.inputField.attr('autocomplete','off');_this.hintField.focus(function(){_this.hideHint();});_this.inputField.blur(function(){_this.tryShowHint();});_this.hideHint();_this.tryShowHint();},_createHintField:function(i,settings){var input=this.inputField;var id=settings.hintName+'_'+i;var text=input.attr('title');var hint=$('<input type="text" id="'+id+'" value="" />').insertBefore(input);hint.attr('class',input.attr('class'));hint.attr('size',input.attr('size'));hint.attr('autocomplete','off');hint.attr('tabIndex',input.attr('tabIndex'));hint.addClass(settings.hintClass);hint.val(text);return hint;},tryShowHint:function(){if($.trim(this.inputField.val()).length==0){this.inputField.hide();this.hintField.show();}},hideHint:function(){this.inputField.show().focus();this.hintField.hide();}};})(jQuery);(function($){$(function(){$(".searchField").ezpz_hint({hintClass:'qHint'});setTimeout(function(){$(".searchField:first").focus();},1);});})(jQuery);(function($){$.fn.catchEnterAndSendTo=function(target,passEvent){this.bind('keypress.catchEnter',null,function(event){if(event.keyCode==13){target.trigger('click',event.data);return passEvent||false;}});return this;}})(jQuery);(function($){var initSubmitLinks=function(){$(".formSubmitter").live("click",function(){$(this).parents("form:first").submit();return false;});};initSubmitLinks();})(jQuery);(function($){var isFormChanged=false;var listenFormChanges=function(){$('form.prevent-leaving input[type!="submit"][type!="button"], form.prevent-leaving textarea').live('change',processFormDataChanged).bind('change',processFormDataChanged);$('form.prevent-leaving').live('submit',function(){isFormChanged=false;});};var processFormDataChanged=function(){isFormChanged=true;};var displayPopup=function(){if(isFormChanged){return i18n.common.forms.leaving_confirmation();}};if(!window.onbeforeunload){$(listenFormChanges);window.onbeforeunload=displayPopup;}})(jQuery);
jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;}
var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}
expires='; expires='+date.toUTCString();}
var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}
return cookieValue;}};(function($){$.fn.unwrap=$.fn.unwrap||function(expr){return this.each(function(){$(this).parents(expr).eq(0).after(this).remove();});};$.widget("ui.ddislider",{plugins:{},ui:function(e){return{options:this.options,handle:this.currentHandle,value:this.options.axis!="both"||!this.options.axis?Math.round(this.value(null,this.options.axis=="vertical"?"y":"x")):{x:Math.round(this.value(null,"x")),y:Math.round(this.value(null,"y"))},range:this._getRange()};},_propagate:function(n,e){this._trigger(n,e,this.ui());},destroy:function(){this.element.removeClass("ui-ddi-slider ui-ddi-slider-disabled").removeData("slider").unbind(".ddislider");if(this.handle&&this.handle.length){this.handle.unwrap("a");this.handle.each(function(){$(this).data("mouse")._mouseDestroy();});}
this.generated&&this.generated.remove();},_setData:function(key,value){$.widget.prototype._setData.apply(this,arguments);if(/min|max|steps/.test(key)){this._initBoundaries();}
if(key=="range"){value?this.handle.length==2&&this._createRange():this._removeRange();}},_init:function(){var self=this;this.element.addClass("ui-ddi-slider");this._initBoundaries();this.handle=$(this.options.handle,this.element);if(!this.handle.length){self.handle=self.generated=$(self.options.handles||[0]).map(function(){var handle=$("<div/>").addClass("ui-ddi-slider-handle").appendTo(self.element);if(this.id)
handle.attr("id",this.id);return handle[0];});}
var handleclass=function(el){this.element=$(el);this.element.data("mouse",this);this.options=self.options;this.element.bind("mousedown",function(){if(self.currentHandle)this.blur(self.currentHandle);self._focus(this,true);});this._mouseInit();};$.extend(handleclass.prototype,$.ui.mouse,{_mouseStart:function(e){return self._start.call(self,e,this.element[0]);},_mouseStop:function(e){return self._stop.call(self,e,this.element[0]);},_mouseDrag:function(e){return self._drag.call(self,e,this.element[0]);},_mouseCapture:function(){return true;},trigger:function(e){this._mouseDown(e);}});$(this.handle).each(function(){new handleclass(this);}).wrap('<a href="#" style="outline:none;border:none;"></a>').parent().bind('click',function(){return false;}).bind('focus',function(e){self._focus(this.firstChild);}).bind('blur',function(e){self._blur(this.firstChild);}).bind('keydown',function(e){if(!self.options.noKeyboard)return self._keydown(e.keyCode,this.firstChild);});this.element.bind('mousedown.ddislider',function(e){self._click.apply(self,[e]);self.currentHandle.data("mouse").trigger(e);self.firstValue=self.firstValue+1;});$.each(this.options.handles||[],function(index,handle){self.moveTo(handle.start,index,true);});if(!isNaN(this.options.startValue))
this.moveTo(this.options.startValue,0,true);this.previousHandle=$(this.handle[0]);if(this.handle.length==2&&this.options.range)this._createRange();},_initBoundaries:function(){var element=this.element[0],o=this.options;this.actualSize={width:this.element.outerWidth(),height:this.element.outerHeight()};$.extend(o,{axis:o.axis||(element.offsetWidth<element.offsetHeight?'vertical':'horizontal'),max:!isNaN(parseInt(o.max,10))?{x:parseInt(o.max,10),y:parseInt(o.max,10)}:({x:o.max&&o.max.x||100,y:o.max&&o.max.y||100}),min:!isNaN(parseInt(o.min,10))?{x:parseInt(o.min,10),y:parseInt(o.min,10)}:({x:o.min&&o.min.x||0,y:o.min&&o.min.y||0})});o.realMax={x:o.max.x-o.min.x,y:o.max.y-o.min.y};o.stepping={x:o.stepping&&o.stepping.x||parseInt(o.stepping,10)||(o.steps?o.realMax.x/(o.steps.x||parseInt(o.steps,10)||o.realMax.x):0),y:o.stepping&&o.stepping.y||parseInt(o.stepping,10)||(o.steps?o.realMax.y/(o.steps.y||parseInt(o.steps,10)||o.realMax.y):0)};},_keydown:function(keyCode,handle){var k=keyCode;if(/(33|34|35|36|37|38|39|40)/.test(k)){var o=this.options,xpos,ypos;if(/(35|36)/.test(k)){xpos=(k==35)?o.max.x:o.min.x;ypos=(k==35)?o.max.y:o.min.y;}else{var oper=/(34|37|40)/.test(k)?"-=":"+=";var step=/(37|38|39|40)/.test(k)?"_oneStep":"_pageStep";xpos=oper+this[step]("x");ypos=oper+this[step]("y");}
this.moveTo({x:xpos,y:ypos},handle);return false;}
return true;},_focus:function(handle,hard){this.currentHandle=$(handle).addClass('ui-ddi-slider-handle-active');if(hard)
this.currentHandle.parent()[0].focus();},_blur:function(handle){$(handle).removeClass('ui-ddi-slider-handle-active');if(this.currentHandle&&this.currentHandle[0]==handle){this.previousHandle=this.currentHandle;this.currentHandle=null;};},_click:function(e){var pointer=[e.pageX,e.pageY];var clickedHandle=false;this.handle.each(function(){if(this==e.target)
clickedHandle=true;});if(clickedHandle||this.options.disabled||!(this.currentHandle||this.previousHandle))
return;if(!this.currentHandle&&this.previousHandle)
this._focus(this.previousHandle,true);this.offset=this.element.offset();this.moveTo({y:this._convertValue(e.pageY-this.offset.top-this.currentHandle[0].offsetHeight/2,"y"),x:this._convertValue(e.pageX-this.offset.left-this.currentHandle[0].offsetWidth/2,"x")},null,!this.options.distance);},_createRange:function(){if(this.rangeElement)return;this.rangeElement=$('<div></div>').addClass('ui-ddi-slider-range').css({position:'absolute'}).appendTo(this.element);this._updateRange();},_removeRange:function(){this.rangeElement.remove();this.rangeElement=null;},_updateRange:function(){var prop=this.options.axis=="vertical"?"top":"left";var size=this.options.axis=="vertical"?"height":"width";this.rangeElement.css(prop,(parseInt($(this.handle[0]).css(prop),10)||0)+this._handleSize(0,this.options.axis=="vertical"?"y":"x")/2);this.rangeElement.css(size,(parseInt($(this.handle[1]).css(prop),10)||0)-(parseInt($(this.handle[0]).css(prop),10)||0));},_getRange:function(){return this.rangeElement?this._convertValue(parseInt(this.rangeElement.css(this.options.axis=="vertical"?"height":"width"),10),this.options.axis=="vertical"?"y":"x"):null;},_handleIndex:function(){return this.handle.index(this.currentHandle[0]);},value:function(handle,axis){if(this.handle.length==1)this.currentHandle=this.handle;if(!axis)axis=this.options.axis=="vertical"?"y":"x";var curHandle=$(handle!=undefined&&handle!==null?this.handle[handle]||handle:this.currentHandle);if(curHandle.data("mouse").sliderValue){return parseInt(curHandle.data("mouse").sliderValue[axis],10);}else{return parseInt(((parseInt(curHandle.css(axis=="x"?"left":"top"),10)/(this.actualSize[axis=="x"?"width":"height"]-this._handleSize(handle,axis)))*this.options.realMax[axis])+this.options.min[axis],10);}},_convertValue:function(value,axis){return this.options.min[axis]+(value/(this.actualSize[axis=="x"?"width":"height"]-this._handleSize(null,axis)))*this.options.realMax[axis];},_translateValue:function(value,axis){return((value-this.options.min[axis])/this.options.realMax[axis])*(this.actualSize[axis=="x"?"width":"height"]-this._handleSize(null,axis));},_translateRange:function(value,axis){if(this.rangeElement){if(this.currentHandle[0]==this.handle[0]&&value>=this._translateValue(this.value(1),axis))
value=this._translateValue(this.value(1,axis)-this._oneStep(axis),axis);if(this.currentHandle[0]==this.handle[1]&&value<=this._translateValue(this.value(0),axis))
value=this._translateValue(this.value(0,axis)+this._oneStep(axis),axis);}
if(this.options.handles){var handle=this.options.handles[this._handleIndex()];if(value<this._translateValue(handle.min,axis)){value=this._translateValue(handle.min,axis);}else if(value>this._translateValue(handle.max,axis)){value=this._translateValue(handle.max,axis);}}
return value;},_translateLimits:function(value,axis){if(value>=this.actualSize[axis=="x"?"width":"height"]-this._handleSize(null,axis))
value=this.actualSize[axis=="x"?"width":"height"]-this._handleSize(null,axis);if(value<=0)
value=0;return value;},_handleSize:function(handle,axis){return $(handle!=undefined&&handle!==null?this.handle[handle]:this.currentHandle)[0]["offset"+(axis=="x"?"Width":"Height")];},_oneStep:function(axis){return this.options.stepping[axis]||1;},_pageStep:function(axis){return 10;},_start:function(e,handle){var o=this.options;if(o.disabled)return false;this.actualSize={width:this.element.outerWidth(),height:this.element.outerHeight()};if(!this.currentHandle)
this._focus(this.previousHandle,true);this.offset=this.element.offset();this.handleOffset=this.currentHandle.offset();this.clickOffset={top:e.pageY-this.handleOffset.top,left:e.pageX-this.handleOffset.left};this.firstValue=this.value();this._propagate('start',e);this._drag(e,handle);return true;},_stop:function(e){this._propagate('stop',e);if(this.firstValue!=this.value())
this._propagate('change',e);this._focus(this.currentHandle,true);return false;},_drag:function(e,handle){var o=this.options;var position={top:e.pageY-this.offset.top-this.clickOffset.top,left:e.pageX-this.offset.left-this.clickOffset.left};if(!this.currentHandle)this._focus(this.previousHandle,true);position.left=this._translateLimits(position.left,"x");position.top=this._translateLimits(position.top,"y");if(o.stepping.x){var value=this._convertValue(position.left,"x");value=Math.round(value/o.stepping.x)*o.stepping.x;position.left=this._translateValue(value,"x");}
if(o.stepping.y){var value=this._convertValue(position.top,"y");value=Math.round(value/o.stepping.y)*o.stepping.y;position.top=this._translateValue(value,"y");}
position.left=this._translateRange(position.left,"x");position.top=this._translateRange(position.top,"y");if(o.axis!="vertical")this.currentHandle.css({left:position.left});if(o.axis!="horizontal")this.currentHandle.css({top:position.top});this.currentHandle.data("mouse").sliderValue={x:Math.round(this._convertValue(position.left,"x"))||0,y:Math.round(this._convertValue(position.top,"y"))||0};if(this.rangeElement)
this._updateRange();this._propagate('slide',e);return false;},moveTo:function(value,handle,noPropagation){var o=this.options;this.actualSize={width:this.element.outerWidth(),height:this.element.outerHeight()};if(handle==undefined&&!this.currentHandle&&this.handle.length!=1)
return false;if(handle==undefined&&!this.currentHandle)
handle=0;if(handle!=undefined)
this.currentHandle=this.previousHandle=$(this.handle[handle]||handle);if(value.x!==undefined&&value.y!==undefined){var x=value.x,y=value.y;}else{var x=value,y=value;}
if(x!==undefined&&x.constructor!=Number){var me=/^\-\=/.test(x),pe=/^\+\=/.test(x);if(me||pe){x=this.value(null,"x")+parseInt(x.replace(me?'=':'+=',''),10);}else{x=isNaN(parseInt(x,10))?undefined:parseInt(x,10);}}
if(y!==undefined&&y.constructor!=Number){var me=/^\-\=/.test(y),pe=/^\+\=/.test(y);if(me||pe){y=this.value(null,"y")+parseInt(y.replace(me?'=':'+=',''),10);}else{y=isNaN(parseInt(y,10))?undefined:parseInt(y,10);}}
if(o.axis!="vertical"&&x!==undefined){if(o.stepping.x)x=Math.round(x/o.stepping.x)*o.stepping.x;x=this._translateValue(x,"x");x=this._translateLimits(x,"x");x=this._translateRange(x,"x");o.animate?this.currentHandle.stop().animate({left:x},(Math.abs(parseInt(this.currentHandle.css("left"))-x))*(!isNaN(parseInt(o.animate))?o.animate:5)):this.currentHandle.css({left:x});}
if(o.axis!="horizontal"&&y!==undefined){if(o.stepping.y)y=Math.round(y/o.stepping.y)*o.stepping.y;y=this._translateValue(y,"y");y=this._translateLimits(y,"y");y=this._translateRange(y,"y");o.animate?this.currentHandle.stop().animate({top:y},(Math.abs(parseInt(this.currentHandle.css("top"))-y))*(!isNaN(parseInt(o.animate))?o.animate:5)):this.currentHandle.css({top:y});}
if(this.rangeElement)
this._updateRange();this.currentHandle.data("mouse").sliderValue={x:Math.round(this._convertValue(x,"x"))||0,y:Math.round(this._convertValue(y,"y"))||0};if(!noPropagation){this._propagate('start',null);this._propagate('stop',null);this._propagate('change',null);this._propagate("slide",null);}}});$.ui.ddislider.getter="value";$.ui.ddislider.defaults={handle:".ui-ddi-slider-handle",distance:1,animate:false};})(jQuery);(function($){$.widget("ui.coverflip",{_init:function(){$(this.element).show();$.extend(this.options.layers,$.ui.coverflip.defaults.layers);this.position=this.options.position;this.element.css("position","relative").css("overflow","hidden");this.cards=$(this.options.cardClass,this.element);this.cards.css("position","absolute");this.cards.each(function(idx,el){el.position=idx;$("<div></div>").appendTo(el).addClass("coverBlocker");}).mousedown(function(){$(this).parent().coverflip("flip",this.position);return false;});this.update(false);$("img.loading").hide();},update:function(animate){animate=animate!=undefined?animate:true;var current=this.cards.get(this.position);var w0=$(current).width();var w=this.element.width();var m=(w-w0)/2;var _this=this;var bcards=_this.options.backingCards;this.cards.each(function(idx,el){var dlt=_this.position-idx;el.position=dlt;var ridx=bcards-Math.abs(dlt);var zIndex=bcards+101;var options;var layers=_this.options.layers;var lidx=0;if(idx!=_this.position){var left=m*ridx/bcards;if(dlt<0){left=w-w0-left;}
if(ridx>=0){lidx=bcards-ridx;}else{lidx=bcards;}
zIndex=ridx+101;options={left:left};if($("div.coverBlocker",el).width()==0){$("div.coverBlocker",el).css("width",$(el).width());}}else{options={left:(w-w0)/2};$("div.coverBlocker",el).css("width",0);}
$.extend(options,layers[lidx]);if(animate){$(el).stop();$(el).animate(options,'slow',"swing");}else{$(el).css(options);}
$(el).css("z-index",zIndex);});this.options.positionchange(this.position,this.cards.get(this.position));},cardsCount:function(){return this.cards.size();},moveTo:function(p){p=p>=0?p:0;p=p<this.cards.size()?p:this.cards.size()-1;if(this.position!=p){this.position=p;this.update();}},flip:function(d){this.moveTo(this.position-d);},flipLeft:function(){this.flip(1);},flipRight:function(){this.flip(-1);}});$.extend($.ui.coverflip,{getter:"cardsCount",defaults:{position:0,cardClass:".card",backingCards:2,positionchange:function(){},layers:[{width:'450px',height:'210px',fontSize:'1em',top:'5px'},{width:'450px',height:'190px',fontSize:'0.9em',top:'15px'},{width:'450px',height:'180px',fontSize:'0.8em',top:'20px'}]}});})(jQuery);var initCoverflip=function(cardClass,position,callbacks,layers){position=position!=undefined?position:0;layers=layers!=undefined?layers:{};callbacks=$j.extend({positionchange:function(){},coverflowshow:function(){},coverflowhide:function(){}},callbacks);$j("#coverflow").coverflip({cardClass:cardClass,layers:layers,position:position,positionchange:function(position,card){if($j(".coverWrap").is(":visible")){$j("#coverflow-slider").ddislider("moveTo",position);callbacks.positionchange(position,card);}}});var cardsCount=$j("#coverflow").coverflip("cardsCount");$j("#coverflow-slider").ddislider({handle:".slider-handle",min:0,max:cardsCount>1?cardsCount-1:1,startValue:position,change:function(){var position=$j(this).ddislider("value");$j("#coverflow").coverflip("moveTo",position);}});$j("#arrow-left").click(function(){$j("#coverflow").coverflip("flipLeft");});$j("#arrow-right").click(function(){$j("#coverflow").coverflip("flipRight");});$j("a.coverflow-on-btn").click(function(){$j(".coverWrap").show("slow",function(){$j("#coverflow").coverflip("update");$j("a.coverflow-off-btn").show();callbacks.coverflowshow();});$j(this).hide();$j.cookie("hideCoverflow",false,{path:DDI.contextPath||"/",expires:14});return false;});$j("a.coverflow-off-btn").click(function(){$j.cookie("hideCoverflow",true,{path:DDI.contextPath||"/",expires:14});$j(".coverWrap").hide("slow",function(){$j("a.coverflow-on-btn").show();callbacks.coverflowhide();});$j(this).hide();return false;});};var switchPage=function(url){if(url){window.location.href=url;}};
DDI.MiniMap=function(positions,dataRequestUrl,dataRequestParams,searchType,mapTabUrl){this.dataRequestParams=dataRequestParams;this.map=new Eniro.API.Map('mapcontainer',DDI.contextPath+'/mapsv2',{activeLayers:[Eniro.Map.LAYER_MAP],layerSelector:false,zoomBar:false,keyboardControl:false,navigationControl:false});var bounds=new OpenLayers.Bounds();var projection=positions.length>0?positions[0].projection:'EPSG:4326';jQuery.each(positions,function(){bounds.extend(new OpenLayers.LonLat(this.longitude,this.latitude));});bounds.transform(new OpenLayers.Projection(projection),this.map.projection);this._extendExtentToVisibleArea(bounds);this.map.zoomToExtent(bounds);if(positions.length){this.performAddressSearch(dataRequestUrl,searchType,mapTabUrl);}};DDI.MiniMap.prototype={_extendExtentToVisibleArea:function(bounds){var boundsResolution=(bounds.top-bounds.bottom)/this.map.getCurrentSize().h;var bottomOverlapping=jQuery(".resultTabsMap").attr("offsetHeight");bounds.bottom-=bottomOverlapping*boundsResolution;var topOvelapping=jQuery(".dd-search-map").attr("offsetHeight");topOvelapping+=37;topOvelapping+=bottomOverlapping;bounds.top+=topOvelapping*boundsResolution;bounds.left-=27/2*boundsResolution;bounds.right+=27/2*boundsResolution;},performAddressSearch:function(dataRequestUrl,searchType,mapTabUrl){var res=this.poiResolution();var args=jQuery.extend({wRes:res.w,hRes:res.h},this.dataRequestParams);var mapTabLink=this.buildMapTabLinkUrl(args,searchType,mapTabUrl);$j("#minimap a").attr("href",mapTabLink);DDI.Maps.PopupContentLoader.activate();var _this=this;jQuery.ajax({url:dataRequestUrl,type:"GET",data:args,success:function(response){var result=_this.evaluateResponse(response);_this.markResultList(result);_this.buildResultMarkers(result);}});},resultIconResource:{resultListSrc:function(idx){return DDI.contextPath+"/img/icons-map/map-list-marker"+idx+".gif";},src:function(idx){return DDI.contextPath+"/mapsv2/media/markers/search/address-"+idx+".png"},w:27,h:37,pinOffset:{x:-11,y:-35}},buildMapTabLinkUrl:function(args,searchType,mapTabUrl){return mapTabUrl+'?q='+args.q+'#'+jQuery.param({lon:this.map.getCenter().lon,lat:this.map.getCenter().lat,zoom:Math.min(this.map.getZoom()+1,Eniro.Profile.zoomLevels.map.max),q:args.q,type:searchType});},evaluateResponse:function(response){var container=$j("<div/>").html(response);return jQuery.grep(eval($j(".resultData",container).text()),function(e){return e!=null;});},poiResolution:function(){var pos=this.map.getCenter();var area=new OpenLayers.Bounds();area.extend(pos);var res=this.map.getResolution();pos=pos.add(this.resultIconResource.w*res,this.resultIconResource.h*res);area.extend(pos);return area.transform(this.map.baseLayer.projection,new OpenLayers.Projection("EPSG:4326")).getSize();},buildResultMarkers:function(resultList){var _this=this;jQuery.each(resultList,function(idx,group){var markerLonLat=new OpenLayers.LonLat(group.point.lon,group.point.lat).transform(new OpenLayers.Projection(group.point.proj),_this.map.projection);var markerIds=jQuery.map(group.id,function(id){var type=id.split('_')[0];return id.substr(type.length+1);});var marker=new Eniro.Feature.PopupFeature(markerLonLat,{markerIds:markerIds},{popupContents:"<p>"+i18n.common.loading()+"</p>",style:{externalGraphic:_this.resultIconResource.src(idx+1),graphicWidth:_this.resultIconResource.w,graphicHeight:_this.resultIconResource.h,graphicXOffset:_this.resultIconResource.pinOffset.x,graphicYOffset:_this.resultIconResource.pinOffset.y}});marker.loadContent={url:DDI.contextPath+"/map/popup",data:{id:group.id,hide_controls:true,q:_this.dataRequestParams.q,municipality:_this.dataRequestParams.municipality}};_this.map.addFeature(marker);});},markResultList:function(result){jQuery.each(result,function(groupIdx,group){jQuery.each(group.id,function(idIdx,id){var linkElement=$j("#resultNumber_"+id);linkElement.text(groupIdx+1);linkElement.css("display","");});});},highlightMarker:function(markerId){var highlighted=false;var features=this.map.getFeatureGroup('generic');for(var i=0;i<features.length;i++){var ids=features[i].data.markerIds;features[i].style.graphicZIndex=0;for(var j=0;j<ids.length&&!highlighted;j++){if(ids[j]==markerId){features[i].style.graphicZIndex=10;highlighted=true;}}
features[i].show();}},setCenter:function(lon,lat,zoom){zoom=10;var position=new OpenLayers.LonLat(lon,lat);var lonlat=position.transform(new OpenLayers.Projection('EPSG:4326'),this.map.projection);this.map.setCenter(lonlat,zoom,false,true);}};DDI.ClickThrough=OpenLayers.Class(OpenLayers.Control,{type:OpenLayers.Control.TYPE_TOOL,destinationUrl:null,draw:function(){this.handler=new OpenLayers.Handler.Click(this,{"click":this.mapClicked},{stopSingle:true});this.activate();},mapClicked:function(ev){var url=this.destinationUrl;if(jQuery.isFunction(url))
url=url(this.map);document.location=url;},CLASS_NAME:"DDI.ClickThrough"});(function($){var getScreenOffset=function(element){var $element=$(element);var top=$element.offset().top;var left=$element.offset().left;$element.parents().each(function(){top-=this.scrollTop;left-=this.scrollLeft;});return{top:top,left:left};};var updateBlockTop=function(element,aboveBlockHeight,underBlockHeight,totalHeight){var visualTop=getScreenOffset(element).top-aboveBlockHeight;if(Math.abs(visualTop)>1){var $element=$(element);var top=parseInt($element.css("top"));top-=visualTop;var max=totalHeight-$element.outerHeight(true)-aboveBlockHeight-underBlockHeight;top=top>max?max:top;top=top>0?top+10:0;$element.animate({top:Math.round(top)},"slow");}};window.bindScrollHandler=function(totalHeight){var $sponsoredLinks=$(".colThree .ppc");if(!$sponsoredLinks.length){return;}
if(totalHeight==undefined){totalHeight=Math.max($('.colOne').height(),$('.colTwo').height(),$('.colThree').height());$sponsoredLinks.prevAll().each(function(){totalHeight-=this.offsetHeight;});}
$sponsoredLinks.css('position','relative');var repeatable=function(){updateBlockTop($sponsoredLinks,0,0,totalHeight);};window.setInterval(repeatable,1000);};})(jQuery);Eniro.Profile={};Eniro.Profile.zoomLevels={};Eniro.Profile.zoomLevels.map={min:3,max:17};Eniro.Profile.zoomLevels.aerial={min:3,max:17};Eniro.Profile.zoomLevels.hybrid={min:3,max:17};Eniro.Profile.zoomLevels.nautical={min:3,max:17};(function($){DDI.Maps.PopupContentLoader={};DDI.Maps.PopupContentLoader.handler=function(e){var loadContent=e.feature.loadContent;if(loadContent){var size=new OpenLayers.Size(190,100);jQuery.get(loadContent.url,loadContent.data,function(data){if(e.popup.id){e.popup.setSize(size);e.popup.setContentHTML(data);}});}};DDI.Maps.PopupContentLoader.activate=function(){Eniro.AppEvents.on({onPopupOpened:DDI.Maps.PopupContentLoader.handler});};DDI.Maps.PopupContentLoader.deactivate=function(){Eniro.AppEvents.un({onPopupOpened:DDI.Maps.PopupContentLoader.handler});};})(jQuery);
DDI.ListingHighlighter=function(listingSelector,minimap){function isCoverflowVisible(){return $j(".coverWrap").is(":visible");}
function isListingHasMarker(listing){return $j(".mapMarker img",listing).size()>0;}
var obj={initialize:function(){var _this=this;$j(listingSelector).mouseenter(function(){if(!isCoverflowVisible()){_this.highlightNone();if(isListingHasMarker(this)){_this.highlightListing(this);}}}).mouseleave(function(){if(!isCoverflowVisible()){_this.highlightNone();}});},highlightListing:function(listing){$j(listingSelector).removeClass("selected");var selectedListing=typeof listing=='number'?$j(listingSelector).get(listing):$j(listing);$j(selectedListing).addClass("selected");if(minimap){minimap.highlightMarker($j(selectedListing).attr("listing-id"));}},highlightNone:function(){$j(listingSelector).removeClass("selected");if(minimap){minimap.highlightMarker(null);}}};obj.initialize();return obj;};
(function($){$.fn.extend({ddiCalendar:function(options){$.extend($,{ddiCalendar:{getMonthName:function(date){return Date.CultureInfo.monthNames[date.getMonth()];}}});var $container=this;var defaults={nextMonth:$('.ddi-cal-next',$container),prevMonth:$('.ddi-cal-prev',$container),tableClass:'table.calender',isWeeksTurnOn:false,current:Date.today(),today:Date.today(),beforeDayRender:function(){},onMonthChange:function(){},onShow:function(){}};var o=this.o=$.fn.extend({},defaults,options);$.extend(o,{rows:6});this._initOverlay();this.update(o.current);o.onMonthChange.call(this,o.current);var parent=this;o.nextMonth.click(function(){var newDate=o.current.addMonths(1);o.onMonthChange.call(parent,newDate.clone());return false;});o.prevMonth.click(function(){var newDate=o.current.addMonths(-1);o.onMonthChange.call(parent,newDate.clone());return false;});return this;},update:function(date){this._generateBody(date);},showOverlay:function(){this._overlayLayer.css({width:$(this).width(),height:$(this.o.tableClass,this).height()}).show();},hideOverlay:function(){this._overlayLayer.hide();},_generateBody:function(date){var o=this.o;var daysInMonth=Date.getDaysInMonth(date.getYear(),date.getMonth());var firstDayOfMonth=date.clone().moveToFirstDayOfMonth();var lastDayOfMonth=date.clone().moveToLastDayOfMonth();var firstDayOfNextMonth=date.clone().next().month().moveToFirstDayOfMonth();var container=[];var resultTable=$(o.tableClass,this).empty();var tableHeader=$('<thead></thead>').appendTo(resultTable);var tableHeaderRow=$('<tr></tr>').appendTo(tableHeader);tableHeaderRow.append(o.isWeeksTurnOn?$('<th scope="col">&#32;</th>'):'');var firstDayIdx=Date.CultureInfo.firstDayOfWeek;for(var i=firstDayIdx;i<7;i++){tableHeaderRow.append($('<th scope="col">'+i18n.date.short_names[i]()+'</th>'));}
for(var i=0;i<firstDayIdx;i++){tableHeaderRow.append($('<th scope="col">'+i18n.date.short_names[i]()+'</th>'));}
var tableBody=$('<tbody></tbody>').appendTo(resultTable);var firstDayWeekNumber=firstDayOfMonth.getDay()+(firstDayOfMonth.getDay()<firstDayIdx?7:0);for(var i=firstDayIdx;i<firstDayWeekNumber;i++){container.push(firstDayOfMonth.clone().add({days:-firstDayWeekNumber+i}));}
for(var i=0;i<daysInMonth;i++){container.push(firstDayOfMonth.clone().add({days:i}));}
var nextMonthDays=o.rows*7-container.length;for(var i=0;i<nextMonthDays;i++){container.push(firstDayOfNextMonth.clone().add({days:i}));}
for(var i=0;i<o.rows;i++){var tableBodyRow=$('<tr></tr>');tableBodyRow.append(o.isWeeksTurnOn?$('<th scope="row">'+(container[7*i].getWeekOfYear()+1)+'</th>'):'');for(var j=0;j<7;j++){var idate=container[j+7*i];var dateElement=o.beforeDayRender.call(this,idate,firstDayOfMonth,lastDayOfMonth);dateElement.appendTo(tableBodyRow);if(o.today.equals(idate)){dateElement.addClass('today');}}
tableBodyRow.appendTo(tableBody);}
return resultTable;},_initOverlay:function(){this._overlayLayer=$('<div/>').css({borderWidth:0,margin:0,padding:0,position:'absolute',opacity:0.1,background:'#000',zIndex:1000,display:'none'});$('<img src="'+DDI.contextPath+'/img/loading.gif"/>').appendTo(this._overlayLayer).css({top:'41%',left:'45%',position:'relative'});$(this.o.tableClass,this).before(this._overlayLayer);}});})(jQuery);DDI.UrlHelper={rebuildUrl:function(urlParams,pathName){if(urlParams==undefined){urlParams={};}
if(pathName==null){pathName=window.location.href;}
var params=this._changeParameters(this._getParams(pathName),urlParams);var paramsString=this._toParamsString(params);var url=this._getUrl(pathName);return url+(paramsString!=''?('?'+paramsString):'');},getParamValue:function(name){if(name==undefined){return;}
return this._getParams(window.location.search)[name];},navigateWithReferrer:function(url){var fakeLink=document.createElement("a");if(typeof(fakeLink.click)=='undefined'){window.location.href=url;}else{fakeLink.href=url;document.body.appendChild(fakeLink);fakeLink.click();}},_getParams:function(url){var params=new Object();var idx=url.indexOf('?');if(idx<0)return params;var paramsString=url.substring(idx+1);var pairs=paramsString.split('&');for(var i=0;i<pairs.length;i++){var pos=pairs[i].indexOf('=');if(pos==-1)continue;var paramName=pairs[i].substring(0,pos);params[paramName]=pairs[i].substring(pos+1);}
return params;},_changeParameters:function(params,paramsToAdd){var paramsFiltered={};for(var paramName in paramsToAdd){params[paramName]=paramsToAdd[paramName];}
for(var paramName in params){if(params[paramName]!=null){paramsFiltered[paramName]=params[paramName];}}
return paramsFiltered;},_toParamsString:function(params){var paramsArray=[];for(var paramsName in params){paramsArray.push(paramsName+'='+params[paramsName]);}
return paramsArray.join("&");},_getUrl:function(replacePathName){var wndLoc=window.location;var href=wndLoc.protocol+"//"+wndLoc.host;if(replacePathName&&replacePathName.indexOf(href)<0){href+=(replacePathName.indexOf("/")!=0?"/":"")+replacePathName;}else if(replacePathName){href=replacePathName;}else{href+=wndLoc.pathname;}
var idx=href.indexOf("?");if(idx<0){return href;}else{return href.substring(0,idx);}}};(function($){$.fn.extend({activityCalendar:function(options){var selectedDays=options.selectedDays==null?[]:options.selectedDays;var q=options.q;var municipality=options.municipality;var region=options.region;var activityDays=[];var $container=this;var timerId;var opts={nextMonth:$("#ddi-calendar-next",$container),prevMonth:$("#ddi-calendar-prev",$container),today:Date.today(),isWeeksTurnOn:options.isWeeksTurnOn,current:selectedDays.length>0?selectedDays[0].clone():Date.today(),beforeDayRender:function(date,firstDayOfMonth,lastDayOfMonth){var innerElement=date.getDate();var dateElement=$j('<td></td>');for(var i=0;i<activityDays.length;i++){var aDay=activityDays[i];if(aDay.getDate()==date.getDate()&&aDay.getMonth()==date.getMonth()&&aDay.getYear()==date.getYear()){var url=DDI.UrlHelper.rebuildUrl({startDate:aDay.toString("dd-MM-yyyy"),endDate:null,offset:null,category:null},options.linkToPath);innerElement=$j('<a href="'+url+'">'+aDay.getDate()+'</a>');break;}}
dateElement.append(innerElement);if(!date.between(firstDayOfMonth,lastDayOfMonth)){dateElement.addClass('lastNext');}
if(selectedDays.length>1){if(date.between(selectedDays[0],selectedDays[1])){dateElement.addClass('selected');}}else if(selectedDays[0]!=null){if(selectedDays[0].getFullYear()==date.getFullYear()&&selectedDays[0].getMonth()==date.getMonth()&&selectedDays[0].getDate()==date.getDate()){dateElement.addClass('selected');}}
return dateElement;},onMonthChange:function(newDate){$j('div.calNav p',$container).text($j.ddiCalendar.getMonthName(newDate)+' '+newDate.getFullYear());var target=this;target.showOverlay();function submitHandler(){var command={q:q,municipality:municipality,startDate:newDate.clone().moveToFirstDayOfMonth().toString("dd-MM-yyyy"),endDate:newDate.clone().moveToLastDayOfMonth().toString("dd-MM-yyyy")};var r=region;if(region==undefined||region==''){r=DDI.UrlHelper.getParamValue('region');}
if(r!=undefined&&r!=''){$j.extend(command,{region:r});}
ActivityCalendarService.getActivityDates(command,function(adates){activityDays.splice(0,activityDays.length);for(var i=0;i<adates.length;i++){var d=Date.parseExact(adates[i],"yyyy-MM-dd");activityDays.push(d);}
target.update(newDate);target.hideOverlay();});}
if(timerId!=undefined){clearTimeout(timerId);}
timerId=setTimeout(submitHandler,500);}};this.ddiCalendar(opts);}});})(jQuery);
(function($){$.fn.extend({narrowByDate:function(opts){$("li",this).each(function(idx,el){var days;var today=Date.today();var startDate=today.toString("dd-MM-yyyy");switch(idx){case 0:days={startDate:null,endDate:null};break;case 1:days={startDate:startDate,endDate:null};break;case 2:days={startDate:startDate,endDate:new Date(today.getFullYear(),today.getMonth(),today.getDate()+6).toString("dd-MM-yyyy")};break;case 3:days={startDate:startDate,endDate:new Date(today.getFullYear(),today.getMonth(),today.getDate()+13).toString("dd-MM-yyyy")};break;case 4:days={startDate:startDate,endDate:new Date(today.getFullYear(),today.getMonth(),today.getDate()+29).toString("dd-MM-yyyy")};break;}
if(!days){return;}
var isStartsEqual=(days.startDate==null&&opts.selectedDays[0]==null)||(days.startDate!=null&&opts.selectedDays[0]!=null&&days.startDate==opts.selectedDays[0].toString("dd-MM-yyyy"));var isEndsEqual=(days.endDate==null&&opts.selectedDays[1]==null)||(days.endDate!=null&&opts.selectedDays[1]!=null&&days.endDate==opts.selectedDays[1].toString("dd-MM-yyyy"));if(isStartsEqual&&isEndsEqual){var text=$("a",el).text();$("a",el).remove();$(el).text(text);$(el).attr("class","selected");}else{days.offset=null;days.category=null;var url=DDI.UrlHelper.rebuildUrl(days,window.location.pathname+'?'+$.param(opts));$("a",el).attr("href",url);}});}});})(jQuery);DDI.ActivityEvents={initForm:function(options){$j('#choosePeriodLink').dialogAjaxify();$j("div.calContentAdv").activityCalendar(options);$j("#narrowByDate").narrowByDate(options);}};
DDI.ActivityCategories={init:function(selector){$j(selector+' li:not(:has(ul))').css('cursor','default');$j(selector+' li:has(ul)').each(function(){var parent=$j(this);$j('> img',this).click(function(event){if(this==event.target){if(parent.children('ul').is(':hidden')){$j(this).attr('src',DDI.contextPath+'/img/icons/icon-nav-close.gif');parent.children('ul').slideDown('slow');}else{$j(this).attr('src',DDI.contextPath+'/img/icons/icon-nav-open.gif');parent.children('ul').slideUp('slow');}}}).css('cursor','pointer');});}};
DDI.ChoosePeriod={initForm:function(){$j('div.period.calender p.btnsFoot .formCanceller').click(function(){DDI.Dialog.closeDialog();});var dateRange={};var optsleft={nextMonth:$j("#ddi-chooseperiod-left-next"),prevMonth:$j("#ddi-chooseperiod-left-prev"),today:Date.today(),current:Date.today(),beforeDayRender:function(date,firstDayOfMonth,lastDayOfMonth){var target=this;var dateElement=$j('<td></td>');if(date.between(firstDayOfMonth,lastDayOfMonth)){var innerElement=$j('<a href="#">'+date.getDate()+'</a>');dateElement.append(innerElement);innerElement.click(function(){if(dateElement.hasClass('today')){dateElement.removeClass('today').addClass('todayWasHereMarker');}else{$j('td.todayWasHereMarker',target).removeClass('todayWasHereMarker').addClass('today');}
$j('td.selected',target).removeClass('selected');dateElement.addClass('selected');dateRange[target.selector]=date;return false;});}else{dateElement.text(date.getDate());dateElement.addClass('lastNext');}
return dateElement;},onMonthChange:function(newDate){$j('div.calNav p',this).text($j.ddiCalendar.getMonthName(newDate)+' '+newDate.getFullYear());this.update(newDate);},onShow:function(current){$j('div.calNav p',this).text($j.ddiCalendar.getMonthName(current)+' '+current.getFullYear());}};var optsRight=$j.extend({},optsleft,{nextMonth:$j("#ddi-chooseperiod-right-next"),prevMonth:$j("#ddi-chooseperiod-right-prev"),current:Date.today().add(1).months()});$j("div.calContentAdv.left").ddiCalendar(optsleft);$j("div.calContentAdv.right").ddiCalendar(optsRight);$j('div.period.calender p.btnsFoot .formSubmitter').click(function(){var leftDate=dateRange['div.calContentAdv.left'];var rightDate=dateRange['div.calContentAdv.right'];$j('div.period.calender label.error').hide();if(leftDate==null&&rightDate!=null){$j('#startDateUnspec').show('slow');return false;}else if(leftDate==null&&rightDate==null){$j('#dateRangeUnspec').show('slow');return false;}else if(leftDate!=null&&rightDate==null){$j('#endDateUnspec').show('slow');return false;}else if(leftDate.compareTo(rightDate)>0){$j('#dateRangeIncor').show('slow');return false;}
DDI.Dialog.closeDialog();var paramsToAdd={startDate:leftDate.toString("dd-MM-yyyy"),endDate:rightDate.toString("dd-MM-yyyy"),offset:null,category:null};window.location=DDI.UrlHelper.rebuildUrl(paramsToAdd);});}};
(function($){$.widget("ui.stars",{_init:function(){var self=this,o=this.options,id=0;o.isSelect=o.inputType=="select";this.$form=$(this.element).closest("form");this.$selec=o.isSelect?$("select",this.element):null;this.$rboxs=o.isSelect?$("option",this.$selec):$(":radio",this.element);this.$stars=this.$rboxs.map(function(i)
{var el={value:this.value,title:(o.isSelect?this.text:this.title)||this.value,isDefault:(o.isSelect&&this.defaultSelected)||this.defaultChecked};if(i==0){o.split=typeof o.split!="number"?0:o.split;o.val2id=[];o.id2val=[];o.id2title=[];o.name=o.isSelect?self.$selec.get(0).name:this.name;o.disabled=o.disabled||(o.isSelect?$(self.$selec).attr("disabled"):$(this).attr("disabled"));}
if(el.value==o.cancelValue){o.cancelTitle=el.title;return null;}
o.val2id[el.value]=id;o.id2val[id]=el.value;o.id2title[id]=el.title;if(el.isDefault){o.checked=id;o.value=o.defaultValue=el.value;o.title=el.title;}
var $s=$("<div/>").addClass(o.starClass);var $a=$('<a/>').attr("title",o.showTitles?el.title:"").text(el.value);if(o.split){var oddeven=(id%o.split);var stwidth=Math.floor(o.starWidth/o.split);$s.width(stwidth);$a.css("margin-left","-"+(oddeven*stwidth)+"px");}
id++;return $s.append($a).get(0);});o.items=id;o.isSelect?this.$selec.remove():this.$rboxs.remove();this.$cancel=$("<div/>").addClass(o.cancelClass).append($("<a/>").attr("title",o.showTitles?o.cancelTitle:"").text(o.cancelValue));o.cancelShow&=!o.disabled&&!o.oneVoteOnly;o.cancelShow&&this.element.append(this.$cancel);this.element.append(this.$stars);if(o.checked===undefined){o.checked=-1;o.value=o.defaultValue=o.cancelValue;o.title="";}
this.$value=$('<input type="hidden" name="'+o.name+'" value="'+o.value+'" />');this.element.append(this.$value);this.$stars.bind("click.stars",function(e){if(!o.forceSelect&&o.disabled)return false;var i=self.$stars.index(this);o.checked=i;o.value=o.id2val[i];o.title=o.id2title[i];self.$value.attr({disabled:o.disabled?"disabled":"",value:o.value});fillTo(i,false);self._disableCancel();!o.forceSelect&&self.callback(e,"star");}).bind("mouseover.stars",function(){if(o.disabled)return false;var i=self.$stars.index(this);fillTo(i,true);}).bind("mouseout.stars",function(){if(o.disabled)return false;fillTo(self.options.checked,false);});this.$cancel.bind("click.stars",function(e){if(!o.forceSelect&&(o.disabled||o.value==o.cancelValue))return false;o.checked=-1;o.value=o.cancelValue;o.title="";self.$value.val(o.value).attr({disabled:"disabled"});fillNone();self._disableCancel();!o.forceSelect&&self.callback(e,"cancel");}).bind("mouseover.stars",function(){if(self._disableCancel())return false;self.$cancel.addClass(o.cancelHoverClass);fillNone();self._showCap(o.cancelTitle);}).bind("mouseout.stars",function(){if(self._disableCancel())return false;self.$cancel.removeClass(o.cancelHoverClass);self.$stars.triggerHandler("mouseout.stars");});this.$form.bind("reset.stars",function(){!o.disabled&&self.select(o.defaultValue);});$(window).unload(function(){self.$cancel.unbind(".stars");self.$stars.unbind(".stars");self.$form.unbind(".stars");self.$selec=self.$rboxs=self.$stars=self.$value=self.$cancel=self.$form=null;});function fillTo(index,hover){if(index!=-1){var addClass=hover?o.starHoverClass:o.starOnClass;var remClass=hover?o.starOnClass:o.starHoverClass;self.$stars.eq(index).prevAll("."+o.starClass).andSelf().removeClass(remClass).addClass(addClass);self.$stars.eq(index).nextAll("."+o.starClass).removeClass(o.starHoverClass+" "+o.starOnClass);self._showCap(o.id2title[index]);}
else fillNone();};function fillNone(){self.$stars.removeClass(o.starOnClass+" "+o.starHoverClass);self._showCap("");};this.select(o.value);o.disabled&&this.disable();},_disableCancel:function(){var o=this.options,disabled=o.disabled||o.oneVoteOnly||(o.value==o.cancelValue);if(disabled)this.$cancel.removeClass(o.cancelHoverClass).addClass(o.cancelDisabledClass);else this.$cancel.removeClass(o.cancelDisabledClass);this.$cancel.css("opacity",disabled?0.5:1);return disabled;},_disableAll:function(){var o=this.options;this._disableCancel();if(o.disabled)this.$stars.filter("div").addClass(o.starDisabledClass);else this.$stars.filter("div").removeClass(o.starDisabledClass);},_showCap:function(s){var o=this.options;if(o.captionEl)o.captionEl.text(s);},value:function(){return this.options.value;},select:function(val){var o=this.options,e=(val==o.cancelValue)?this.$cancel:this.$stars.eq(o.val2id[val]);o.forceSelect=true;e.triggerHandler("click.stars");o.forceSelect=false;},selectID:function(id){var o=this.options,e=(id==-1)?this.$cancel:this.$stars.eq(id);o.forceSelect=true;e.triggerHandler("click.stars");o.forceSelect=false;},enable:function(){this.options.disabled=false;this._disableAll();},disable:function(){this.options.disabled=true;this._disableAll();},destroy:function(){this.options.isSelect?this.$selec.appendTo(this.element):this.$rboxs.appendTo(this.element);this.$form.unbind(".stars");this.$cancel.unbind(".stars").remove();this.$stars.unbind(".stars").remove();this.$value.remove();this.element.unbind(".stars").removeData("stars");},callback:function(e,type){var o=this.options;o.callback&&o.callback(this,type,o.value,e);o.oneVoteOnly&&!o.disabled&&this.disable();}});$.extend($.ui.stars,{version:"2.1.1",getter:"value",defaults:{inputType:"radio",split:0,disabled:false,cancelTitle:"Cancel Rating",cancelValue:0,cancelShow:true,oneVoteOnly:false,showTitles:false,captionEl:null,callback:null,starWidth:16,cancelClass:'ui-stars-cancel',starClass:'ui-stars-star',starOnClass:'ui-stars-star-on',starHoverClass:'ui-stars-star-hover',starDisabledClass:'ui-stars-star-disabled',cancelHoverClass:'ui-stars-cancel-hover',cancelDisabledClass:'ui-stars-cancel-disabled'}});})(jQuery);(function($){var bindForm=function(){$("#stars-wrapper1").stars({captionEl:$("#stars-txt"),cancelShow:false});$(".content.review form").dialogAjaxify({event:'submit',method:'POST',forms:'.content.review form',onSuccess:bindForm});$(".content.review input[type=button]").click(function(){$(".content.review #title").val("");$(".content.review #text").val("");$("#stars-wrapper1").stars("select",0);});};$(document).ready(function(){$('.reviewsListing .openDialog, .reviewInfo .openDialog').dialogAjaxify({onSuccess:bindForm});})})(jQuery);
DDI.LatestActivitiesMap=function(dataRequestUrl,dataRequestParams,searchType,activityUrl){this.dataRequestParams=dataRequestParams;this.activityUrl=activityUrl;this.map=new Eniro.API.Map('mapActContainer',DDI.contextPath+'/mapsv2',{activeLayers:[Eniro.Map.LAYER_MAP],layerSelector:false,zoomBar:false,keyboardControl:false,navigationControl:false});var res=this.poiResolution();var args=jQuery.extend({wRes:res.w,hRes:res.h},dataRequestParams);var _this=this;jQuery.ajax({url:dataRequestUrl,type:"GET",data:args,success:function(response){var result=_this.evaluateResponse(response);_this.buildResultMarkers(result);}});};DDI.LatestActivitiesMap.prototype={resultLargeIconResource:{src:function(){return DDI.contextPath+"/img/icons-map/icon-activity-map-large.png"},w:29,h:29,pinOffset:{x:-14,y:-14}},resultRegularIconResource:{src:function(){return DDI.contextPath+"/img/icons-map/icon-activity-map-small.png"},w:15,h:15,pinOffset:{x:-7,y:-7}},evaluateResponse:function(response){var container=$j("<div/>").html(response);return jQuery.grep(eval($j(".resultData",container).text()),function(e){return e!=null;});},poiResolution:function(){var pos=this.map.getCenter();var area=new OpenLayers.Bounds();area.extend(pos);var res=this.map.getResolution();pos=pos.add(this.resultLargeIconResource.w*res,this.resultLargeIconResource.h*res);area.extend(pos);return area.transform(this.map.baseLayer.projection,new OpenLayers.Projection("EPSG:4326")).getSize();},buildResultMarkers:function(resultList){var _this=this;var bigMarkerStyle={externalGraphic:_this.resultLargeIconResource.src(),graphicWidth:_this.resultLargeIconResource.w,graphicHeight:_this.resultLargeIconResource.h,graphicXOffset:_this.resultLargeIconResource.pinOffset.x,graphicYOffset:_this.resultLargeIconResource.pinOffset.y};var regularMarkerStyle={externalGraphic:_this.resultRegularIconResource.src(),graphicWidth:_this.resultRegularIconResource.w,graphicHeight:_this.resultRegularIconResource.h,graphicXOffset:_this.resultRegularIconResource.pinOffset.x,graphicYOffset:_this.resultRegularIconResource.pinOffset.y};for(var index=1;index<resultList.length;index++){if(index==0){continue;}
_this.addMarker(index,resultList[index],regularMarkerStyle);}
if(resultList.length>0){_this.addMarker(0,resultList[0],bigMarkerStyle);}},addMarker:function(idx,group,style){var _this=this;var markerLonLat=new OpenLayers.LonLat(group.point.lon,group.point.lat).transform(new OpenLayers.Projection(group.point.proj),_this.map.projection);var markerIds=jQuery.map(group.id,function(id){var type=id.split('_')[0];return id.substr(type.length+1);});var marker=new Eniro.Feature.PopupFeature(markerLonLat,{markerIds:markerIds},{style:style});marker.events.register("click",marker,function(e){location.href=_this.activityUrl+markerIds[0]+"/";});_this.map.addFeature(marker);},setCenter:function(lon,lat,zoom){var position=new OpenLayers.LonLat(lon,lat);var lonlat=position.transform(new OpenLayers.Projection('EPSG:4326'),this.map.projection);this.map.setCenter(lonlat,zoom,false,true);}};
(function($){function init(){bindScrollHandler();$('#signinAddActivity.signinDialog').dialogAjaxify();DDI.ActivityEvents.initForm(DDI.ActivityEvents.options);DDI.ActivityCategories.init('ul.actFilters');}
if($.browser.msie){$(window).load(init);}else{$(document).ready(init);}})(jQuery);
(function($){var truncateNicely={htmlSinglets:['br','col','link','base','img','param','area','hr','input'],tagRe:new RegExp("<(/)?([^ ]+?)(?: (/)| .*?)?>"),searchRe:new RegExp("&.*?;|<.*?>|."),truncateLines:function(element,lines){var $element=$(element);if(!$element.is(":visible")||$element.data("truncated")){return;}
var height=this.suggestLinesHeight($element,lines);var text=$element.html();$element.html('');$element.html(this.truncate({element:$element,text:text,height:height}));$element.data("truncated",true);},suggestLinesHeight:function($element,lines){var $clone=$element.clone().empty();$clone.insertBefore($element);$element.remove();for(var i=0;i<lines;i++){$clone.append('W<br/>');}
var maxHeight=this.elementHeight($clone[0]);$element.insertBefore($clone);$clone.remove();return maxHeight;},elementHeight:function(element){return element.scrollHeight>0?element.scrollHeight:element.offsetHeight;},truncate:function(options){options=$.extend({},options);var $element=$(options.element);var $container=$element.clone().css({visibility:'hidden'}).empty().appendTo($element.parent());var container=$container.get(0);if(this.elementHeight(container)>=options.height){options.height=this.elementHeight(container);}
this.stack=['',''];this.processLines(container,options);$container.remove();return this.stack[0];},processLines:function(container,options){this.cutSymbols=0;this.openTags=[];while(this.elementHeight(container)<=options.height){this.stack.shift();var m=this.searchRe.exec(options.text.substring(this.cutSymbols));if(!m){break;}
var matchedString=m[0];if(matchedString.length>1){if(matchedString[0]=='<'){this.processTag(matchedString,options.tagName);}}
this.cutSymbols+=matchedString.length;var truncatedString=this.getTruncatedString(options.text);$(container).html(truncatedString);this.stack.push(truncatedString);}},processTag:function(matchedString,tagName){var tagInfo=this.tagRe.exec(matchedString),tag={name:tagInfo[2],isClosing:tagInfo[1],selfClosing:tagInfo[3]};if(!tag.selfClosing&&(jQuery.inArray(tag.name,this.htmlSinglets)==-1)){if(tag.isClosing){var tagIndex=jQuery.inArray(tagName,this.openTags);if(tagIndex!=-1){this.openTags=this.openTags.slice(tagIndex+1);}}else{this.openTags.unshift(tagName);}}},getTruncatedString:function(text){if(this.cutSymbols<text.length){var interimString=text.substring(0,this.cutSymbols)+'&hellip;';for(var i=0;i<this.openTags.length;i++){interimString+='</'+this.openTags[i]+'>';}}else{interimString=text;}
return interimString;}};$.fn.truncateNicely=function(nLines){return this.each(function(){truncateNicely.truncateLines(this,nLines);});};})(jQuery);(function($){var init=function(){var initTruncation=function(target){$(".truncate-1",target).truncateNicely(1);$(".truncate-2",target).truncateNicely(2);$(".truncate-3",target).truncateNicely(3);};initTruncation($(document.body));$(document.body).bind("carouselSlideShown",function(event,target){initTruncation(target);});};if($.browser.msie){$(window).load(init);}else{$(document).ready(init);}})(jQuery);
(function($){DDI.ImageCenterHelper={apply:function(parentElement){var proportionIsSame=function(width,height,parentWidth,parentHeight){return Math.abs(width/parentWidth-height/parentHeight)<0.0001;};var heightIsGreater=function(width,height,parentWidth,parentHeight){return height/parentHeight>width/parentWidth;};var resizeImg=function(img,parentWidth,parentHeight){var width=img.width();var height=img.height();var hasNoNulls=width>0&&height>0&&parentHeight>0&&parentWidth>0;if(hasNoNulls){if(proportionIsSame(width,height,parentWidth,parentHeight)){img.css("width",parentWidth);}else{if(heightIsGreater(width,height,parentWidth,parentHeight)){img.css("width",parentWidth);var resizedHeight=parentWidth*height/width;img.css("margin-top",(parentHeight-resizedHeight)/2);}else{img.css("height",parentHeight);var resizedWidth=parentHeight*width/height;img.css("margin-left",(parentWidth-resizedWidth)/2);}}}};var img=$('img',parentElement);var src=img.attr("src");img.attr('src','');var parentWidth=parentElement.width();var parentHeight=parentElement.height();img.load(function(){resizeImg($(this),parentWidth,parentHeight);});img.attr('src',src);}};var centerPictures=function(){$('.imageCenterParent').each(function(){DDI.ImageCenterHelper.apply($(this));});};if($.browser.msie){$(window).load(centerPictures);}else{$(document).ready(centerPictures);}})(jQuery);
