var geocoder;var searchVideo;google.setOnLoadCallback(function(){Event.addListener(document.body,"unload",function(){GUnload();});__gjsload_maps2_api__('var cachedKgf = wg.g; wg.g = function() { if (arguments[0].indexOf(\'geo\') > -1) {arguments[0] = arguments[0] + "?hl=nl"; } return cachedKgf.apply(this, arguments); };');geocoder=new GClientGeocoder();searchVideo=new google.search.VideoSearch();searchVideo.setResultSetSize(GSearch.LARGE_RESULTSET);searchVideo.setNoHtmlGeneration();searchVideo.setQueryAddition("site:youtube.com");});(function(){var lang=YAHOO.lang,util=YAHOO.util,Ev=util.Event;util.DataSourceBase=function(oLiveData,oConfigs){if(oLiveData===null||oLiveData===undefined){return;}
this.liveData=oLiveData;this._oQueue={interval:null,conn:null,requests:[]};this.responseSchema={};if(oConfigs&&(oConfigs.constructor==Object)){for(var sConfig in oConfigs){if(sConfig){this[sConfig]=oConfigs[sConfig];}}}
var maxCacheEntries=this.maxCacheEntries;if(!lang.isNumber(maxCacheEntries)||(maxCacheEntries<0)){maxCacheEntries=0;}
this._aIntervals=[];this.createEvent("cacheRequestEvent");this.createEvent("cacheResponseEvent");this.createEvent("requestEvent");this.createEvent("responseEvent");this.createEvent("responseParseEvent");this.createEvent("responseCacheEvent");this.createEvent("dataErrorEvent");this.createEvent("cacheFlushEvent");var DS=util.DataSourceBase;this._sName="DataSource instance"+DS._nIndex;DS._nIndex++;};var DS=util.DataSourceBase;lang.augmentObject(DS,{TYPE_UNKNOWN:-1,TYPE_JSARRAY:0,TYPE_JSFUNCTION:1,TYPE_XHR:2,TYPE_JSON:3,TYPE_XML:4,TYPE_TEXT:5,TYPE_HTMLTABLE:6,TYPE_SCRIPTNODE:7,TYPE_LOCAL:8,ERROR_DATAINVALID:"Invalid data",ERROR_DATANULL:"Null data",_nIndex:0,_nTransactionId:0,issueCallback:function(callback,params,error,scope){if(lang.isFunction(callback)){callback.apply(scope,params);}else if(lang.isObject(callback)){scope=callback.scope||scope||window;var callbackFunc=callback.success;if(error){callbackFunc=callback.failure;}
if(callbackFunc){callbackFunc.apply(scope,params.concat([callback.argument]));}}},parseString:function(oData){if(!lang.isValue(oData)){return null;}
var string=oData+"";if(lang.isString(string)){return string;}
else{return null;}},parseNumber:function(oData){var number=oData*1;if(lang.isNumber(number)){return number;}
else{return null;}},convertNumber:function(oData){return DS.parseNumber(oData);},parseDate:function(oData){var date=null;if(!(oData instanceof Date)){date=new Date(oData);}
else{return oData;}
if(date instanceof Date){return date;}
else{return null;}},convertDate:function(oData){return DS.parseDate(oData);}});DS.Parser={string:DS.parseString,number:DS.parseNumber,date:DS.parseDate};DS.prototype={_sName:null,_aCache:null,_oQueue:null,_aIntervals:null,maxCacheEntries:0,liveData:null,dataType:DS.TYPE_UNKNOWN,responseType:DS.TYPE_UNKNOWN,responseSchema:null,toString:function(){return this._sName;},getCachedResponse:function(oRequest,oCallback,oCaller){var aCache=this._aCache;if(this.maxCacheEntries>0){if(!aCache){this._aCache=[];}
else{var nCacheLength=aCache.length;if(nCacheLength>0){var oResponse=null;this.fireEvent("cacheRequestEvent",{request:oRequest,callback:oCallback,caller:oCaller});for(var i=nCacheLength-1;i>=0;i--){var oCacheElem=aCache[i];if(this.isCacheHit(oRequest,oCacheElem.request)){oResponse=oCacheElem.response;this.fireEvent("cacheResponseEvent",{request:oRequest,response:oResponse,callback:oCallback,caller:oCaller});if(i<nCacheLength-1){aCache.splice(i,1);this.addToCache(oRequest,oResponse);}
oResponse.cached=true;break;}}
return oResponse;}}}
else if(aCache){this._aCache=null;}
return null;},isCacheHit:function(oRequest,oCachedRequest){return(oRequest===oCachedRequest);},addToCache:function(oRequest,oResponse){var aCache=this._aCache;if(!aCache){return;}
while(aCache.length>=this.maxCacheEntries){aCache.shift();}
var oCacheElem={request:oRequest,response:oResponse};aCache[aCache.length]=oCacheElem;this.fireEvent("responseCacheEvent",{request:oRequest,response:oResponse});},flushCache:function(){if(this._aCache){this._aCache=[];this.fireEvent("cacheFlushEvent");}},setInterval:function(nMsec,oRequest,oCallback,oCaller){if(lang.isNumber(nMsec)&&(nMsec>=0)){var oSelf=this;var nId=setInterval(function(){oSelf.makeConnection(oRequest,oCallback,oCaller);},nMsec);this._aIntervals.push(nId);return nId;}
else{}},clearInterval:function(nId){var tracker=this._aIntervals||[];for(var i=tracker.length-1;i>-1;i--){if(tracker[i]===nId){tracker.splice(i,1);clearInterval(nId);}}},clearAllIntervals:function(){var tracker=this._aIntervals||[];for(var i=tracker.length-1;i>-1;i--){clearInterval(tracker[i]);}
tracker=[];},sendRequest:function(oRequest,oCallback,oCaller){var oCachedResponse=this.getCachedResponse(oRequest,oCallback,oCaller);if(oCachedResponse){DS.issueCallback(oCallback,[oRequest,oCachedResponse],false,oCaller);return null;}
return this.makeConnection(oRequest,oCallback,oCaller);},makeConnection:function(oRequest,oCallback,oCaller){var tId=DS._nTransactionId++;this.fireEvent("requestEvent",{tId:tId,request:oRequest,callback:oCallback,caller:oCaller});var oRawResponse=this.liveData;this.handleResponse(oRequest,oRawResponse,oCallback,oCaller,tId);return tId;},handleResponse:function(oRequest,oRawResponse,oCallback,oCaller,tId){this.fireEvent("responseEvent",{tId:tId,request:oRequest,response:oRawResponse,callback:oCallback,caller:oCaller});var xhr=(this.dataType==DS.TYPE_XHR)?true:false;var oParsedResponse=null;var oFullResponse=oRawResponse;if(this.responseType===DS.TYPE_UNKNOWN){var ctype=(oRawResponse&&oRawResponse.getResponseHeader)?oRawResponse.getResponseHeader["Content-Type"]:null;if(ctype){if(ctype.indexOf("text/xml")>-1){this.responseType=DS.TYPE_XML;}
else if(ctype.indexOf("application/json")>-1){this.responseType=DS.TYPE_JSON;}
else if(ctype.indexOf("text/plain")>-1){this.responseType=DS.TYPE_TEXT;}}
else{if(YAHOO.lang.isArray(oRawResponse)){this.responseType=DS.TYPE_JSARRAY;}
else if(oRawResponse&&oRawResponse.nodeType&&oRawResponse.nodeType==9){this.responseType=DS.TYPE_XML;}
else if(oRawResponse&&oRawResponse.nodeName&&(oRawResponse.nodeName.toLowerCase()=="table")){this.responseType=DS.TYPE_HTMLTABLE;}
else if(YAHOO.lang.isObject(oRawResponse)){this.responseType=DS.TYPE_JSON;}
else if(YAHOO.lang.isString(oRawResponse)){this.responseType=DS.TYPE_TEXT;}}}
switch(this.responseType){case DS.TYPE_JSARRAY:if(xhr&&oRawResponse&&oRawResponse.responseText){oFullResponse=oRawResponse.responseText;}
oFullResponse=this.doBeforeParseData(oRequest,oFullResponse,oCallback);oParsedResponse=this.parseArrayData(oRequest,oFullResponse);break;case DS.TYPE_JSON:if(xhr&&oRawResponse&&oRawResponse.responseText){oFullResponse=oRawResponse.responseText;}
try{if(lang.isString(oFullResponse)){if(lang.JSON){oFullResponse=lang.JSON.parse(oFullResponse);}
else if(window.JSON&&JSON.parse){oFullResponse=JSON.parse(oFullResponse);}
else if(oFullResponse.parseJSON){oFullResponse=oFullResponse.parseJSON();}
else{while(oFullResponse.length>0&&(oFullResponse.charAt(0)!="{")&&(oFullResponse.charAt(0)!="[")){oFullResponse=oFullResponse.substring(1,oFullResponse.length);}
if(oFullResponse.length>0){var objEnd=Math.max(oFullResponse.lastIndexOf("]"),oFullResponse.lastIndexOf("}"));oFullResponse=oFullResponse.substring(0,objEnd+1);oFullResponse=eval("("+oFullResponse+")");}}}}
catch(e){}
oFullResponse=this.doBeforeParseData(oRequest,oFullResponse,oCallback);oParsedResponse=this.parseJSONData(oRequest,oFullResponse);break;case DS.TYPE_HTMLTABLE:if(xhr&&oRawResponse.responseText){oFullResponse=oRawResponse.responseText;}
oFullResponse=this.doBeforeParseData(oRequest,oFullResponse,oCallback);oParsedResponse=this.parseHTMLTableData(oRequest,oFullResponse);break;case DS.TYPE_XML:if(xhr&&oRawResponse.responseXML){oFullResponse=oRawResponse.responseXML;}
oFullResponse=this.doBeforeParseData(oRequest,oFullResponse,oCallback);oParsedResponse=this.parseXMLData(oRequest,oFullResponse);break;case DS.TYPE_TEXT:if(xhr&&lang.isString(oRawResponse.responseText)){oFullResponse=oRawResponse.responseText;}
oFullResponse=this.doBeforeParseData(oRequest,oFullResponse,oCallback);oParsedResponse=this.parseTextData(oRequest,oFullResponse);break;default:oFullResponse=this.doBeforeParseData(oRequest,oFullResponse,oCallback);oParsedResponse=this.parseData(oRequest,oFullResponse);break;}
oParsedResponse=oParsedResponse||{};if(!oParsedResponse.results){oParsedResponse.results=[];}
if(!oParsedResponse.meta){oParsedResponse.meta={};}
if(oParsedResponse&&!oParsedResponse.error){oParsedResponse=this.doBeforeCallback(oRequest,oFullResponse,oParsedResponse,oCallback);this.fireEvent("responseParseEvent",{request:oRequest,response:oParsedResponse,callback:oCallback,caller:oCaller});this.addToCache(oRequest,oParsedResponse);}
else{oParsedResponse.error=true;this.fireEvent("dataErrorEvent",{request:oRequest,response:oRawResponse,callback:oCallback,caller:oCaller,message:DS.ERROR_DATANULL});}
oParsedResponse.tId=tId;DS.issueCallback(oCallback,[oRequest,oParsedResponse],oParsedResponse.error,oCaller);},doBeforeParseData:function(oRequest,oFullResponse,oCallback){return oFullResponse;},doBeforeCallback:function(oRequest,oFullResponse,oParsedResponse,oCallback){return oParsedResponse;},parseData:function(oRequest,oFullResponse){if(lang.isValue(oFullResponse)){var oParsedResponse={results:oFullResponse,meta:{}};return oParsedResponse;}
return null;},parseArrayData:function(oRequest,oFullResponse){if(lang.isArray(oFullResponse)){var results=[],i,j,rec,field,data;if(lang.isArray(this.responseSchema.fields)){var fields=this.responseSchema.fields;for(i=fields.length-1;i>=0;--i){if(typeof fields[i]!=='object'){fields[i]={key:fields[i]};}}
var parsers={},p;for(i=fields.length-1;i>=0;--i){p=(typeof fields[i].parser==='function'?fields[i].parser:DS.Parser[fields[i].parser+''])||fields[i].converter;if(p){parsers[fields[i].key]=p;}}
var arrType=lang.isArray(oFullResponse[0]);for(i=oFullResponse.length-1;i>-1;i--){var oResult={};rec=oFullResponse[i];if(typeof rec==='object'){for(j=fields.length-1;j>-1;j--){field=fields[j];data=arrType?rec[j]:rec[field.key];if(parsers[field.key]){data=parsers[field.key].call(this,data);}
if(data===undefined){data=null;}
oResult[field.key]=data;}}
else if(lang.isString(rec)){for(j=fields.length-1;j>-1;j--){field=fields[j];data=rec;if(parsers[field.key]){data=parsers[field.key].call(this,data);}
if(data===undefined){data=null;}
oResult[field.key]=data;}}
results[i]=oResult;}}
else{results=oFullResponse;}
var oParsedResponse={results:results};return oParsedResponse;}
return null;},parseTextData:function(oRequest,oFullResponse){if(lang.isString(oFullResponse)){if(lang.isString(this.responseSchema.recordDelim)&&lang.isString(this.responseSchema.fieldDelim)){var oParsedResponse={results:[]};var recDelim=this.responseSchema.recordDelim;var fieldDelim=this.responseSchema.fieldDelim;if(oFullResponse.length>0){var newLength=oFullResponse.length-recDelim.length;if(oFullResponse.substr(newLength)==recDelim){oFullResponse=oFullResponse.substr(0,newLength);}
if(oFullResponse.length>0){var recordsarray=oFullResponse.split(recDelim);for(var i=0,len=recordsarray.length,recIdx=0;i<len;++i){var bError=false,sRecord=recordsarray[i];if(lang.isString(sRecord)&&(sRecord.length>0)){var fielddataarray=recordsarray[i].split(fieldDelim);var oResult={};if(lang.isArray(this.responseSchema.fields)){var fields=this.responseSchema.fields;for(var j=fields.length-1;j>-1;j--){try{var data=fielddataarray[j];if(lang.isString(data)){if(data.charAt(0)=="\""){data=data.substr(1);}
if(data.charAt(data.length-1)=="\""){data=data.substr(0,data.length-1);}
var field=fields[j];var key=(lang.isValue(field.key))?field.key:field;if(!field.parser&&field.converter){field.parser=field.converter;}
var parser=(typeof field.parser==='function')?field.parser:DS.Parser[field.parser+''];if(parser){data=parser.call(this,data);}
if(data===undefined){data=null;}
oResult[key]=data;}
else{bError=true;}}
catch(e){bError=true;}}}
else{oResult=fielddataarray;}
if(!bError){oParsedResponse.results[recIdx++]=oResult;}}}}}
return oParsedResponse;}}
return null;},parseXMLResult:function(result){var oResult={},schema=this.responseSchema;try{for(var m=schema.fields.length-1;m>=0;m--){var field=schema.fields[m];var key=(lang.isValue(field.key))?field.key:field;var data=null;var xmlAttr=result.attributes.getNamedItem(key);if(xmlAttr){data=xmlAttr.value;}
else{var xmlNode=result.getElementsByTagName(key);if(xmlNode&&xmlNode.item(0)&&xmlNode.item(0)){data=xmlNode.item(0).firstChild.nodeValue;var item=xmlNode.item(0);data=(item.text)?item.text:(item.textContent)?item.textContent:null;if(!data){var datapieces=[];for(var j=0,len=item.childNodes.length;j<len;j++){if(item.childNodes[j].nodeValue){datapieces[datapieces.length]=item.childNodes[j].nodeValue;}}
if(datapieces.length>0){data=datapieces.join("");}}}}
if(data===null){data="";}
if(!field.parser&&field.converter){field.parser=field.converter;}
var parser=(typeof field.parser==='function')?field.parser:DS.Parser[field.parser+''];if(parser){data=parser.call(this,data);}
if(data===undefined){data=null;}
oResult[key]=data;}}
catch(e){}
return oResult;},parseXMLData:function(oRequest,oFullResponse){var bError=false,schema=this.responseSchema,oParsedResponse={meta:{}},xmlList=null,metaNode=schema.metaNode,metaLocators=schema.metaFields||{},i,k,loc,v;try{xmlList=(schema.resultNode)?oFullResponse.getElementsByTagName(schema.resultNode):null;metaNode=metaNode?oFullResponse.getElementsByTagName(metaNode)[0]:oFullResponse;if(metaNode){for(k in metaLocators){if(lang.hasOwnProperty(metaLocators,k)){loc=metaLocators[k];v=metaNode.getElementsByTagName(loc)[0];if(v){v=v.firstChild.nodeValue;}else{v=metaNode.attributes.getNamedItem(loc);if(v){v=v.value;}}
if(lang.isValue(v)){oParsedResponse.meta[k]=v;}}}}}
catch(e){}
if(!xmlList||!lang.isArray(schema.fields)){bError=true;}
else{oParsedResponse.results=[];for(i=xmlList.length-1;i>=0;--i){var oResult=this.parseXMLResult(xmlList.item(i));oParsedResponse.results[i]=oResult;}}
if(bError){oParsedResponse.error=true;}
else{}
return oParsedResponse;},parseJSONData:function(oRequest,oFullResponse){var oParsedResponse={results:[],meta:{}};if(lang.isObject(oFullResponse)&&this.responseSchema.resultsList){var schema=this.responseSchema,fields=schema.fields,resultsList=oFullResponse,results=[],metaFields=schema.metaFields||{},fieldParsers=[],fieldPaths=[],simpleFields=[],bError=false,i,len,j,v,key,parser,path;var buildPath=function(needle){var path=null,keys=[],i=0;if(needle){needle=needle.replace(/\[(['"])(.*?)\1\]/g,function(x,$1,$2){keys[i]=$2;return'.@'+(i++);}).replace(/\[(\d+)\]/g,function(x,$1){keys[i]=parseInt($1,10)|0;return'.@'+(i++);}).replace(/^\./,'');if(!/[^\w\.\$@]/.test(needle)){path=needle.split('.');for(i=path.length-1;i>=0;--i){if(path[i].charAt(0)==='@'){path[i]=keys[parseInt(path[i].substr(1),10)];}}}
else{}}
return path;};var walkPath=function(path,origin){var v=origin,i=0,len=path.length;for(;i<len&&v;++i){v=v[path[i]];}
return v;};path=buildPath(schema.resultsList);if(path){resultsList=walkPath(path,oFullResponse);if(resultsList===undefined){bError=true;}}else{bError=true;}
if(!resultsList){resultsList=[];}
if(!lang.isArray(resultsList)){resultsList=[resultsList];}
if(!bError){if(schema.fields){var field;for(i=0,len=fields.length;i<len;i++){field=fields[i];key=field.key||field;parser=((typeof field.parser==='function')?field.parser:DS.Parser[field.parser+''])||field.converter;path=buildPath(key);if(parser){fieldParsers[fieldParsers.length]={key:key,parser:parser};}
if(path){if(path.length>1){fieldPaths[fieldPaths.length]={key:key,path:path};}else{simpleFields[simpleFields.length]={key:key,path:path[0]};}}else{}}
for(i=resultsList.length-1;i>=0;--i){var r=resultsList[i],rec={};for(j=simpleFields.length-1;j>=0;--j){rec[simpleFields[j].key]=(r[simpleFields[j].path]!==undefined)?r[simpleFields[j].path]:r[j];}
for(j=fieldPaths.length-1;j>=0;--j){rec[fieldPaths[j].key]=walkPath(fieldPaths[j].path,r);}
for(j=fieldParsers.length-1;j>=0;--j){var p=fieldParsers[j].key;rec[p]=fieldParsers[j].parser(rec[p]);if(rec[p]===undefined){rec[p]=null;}}
results[i]=rec;}}
else{results=resultsList;}
for(key in metaFields){if(lang.hasOwnProperty(metaFields,key)){path=buildPath(metaFields[key]);if(path){v=walkPath(path,oFullResponse);oParsedResponse.meta[key]=v;}}}}else{oParsedResponse.error=true;}
oParsedResponse.results=results;}
else{oParsedResponse.error=true;}
return oParsedResponse;},parseHTMLTableData:function(oRequest,oFullResponse){var bError=false;var elTable=oFullResponse;var fields=this.responseSchema.fields;var oParsedResponse={results:[]};for(var i=0;i<elTable.tBodies.length;i++){var elTbody=elTable.tBodies[i];for(var j=elTbody.rows.length-1;j>-1;j--){var elRow=elTbody.rows[j];var oResult={};for(var k=fields.length-1;k>-1;k--){var field=fields[k];var key=(lang.isValue(field.key))?field.key:field;var data=elRow.cells[k].innerHTML;if(!field.parser&&field.converter){field.parser=field.converter;}
var parser=(typeof field.parser==='function')?field.parser:DS.Parser[field.parser+''];if(parser){data=parser.call(this,data);}
if(data===undefined){data=null;}
oResult[key]=data;}
oParsedResponse.results[j]=oResult;}}
if(bError){oParsedResponse.error=true;}
else{}
return oParsedResponse;}};lang.augmentProto(DS,util.EventProvider);util.LocalDataSource=function(oLiveData,oConfigs){this.dataType=DS.TYPE_LOCAL;if(oLiveData){if(YAHOO.lang.isArray(oLiveData)){this.responseType=DS.TYPE_JSARRAY;}
else if(oLiveData.nodeType&&oLiveData.nodeType==9){this.responseType=DS.TYPE_XML;}
else if(oLiveData.nodeName&&(oLiveData.nodeName.toLowerCase()=="table")){this.responseType=DS.TYPE_HTMLTABLE;oLiveData=oLiveData.cloneNode(true);}
else if(YAHOO.lang.isString(oLiveData)){this.responseType=DS.TYPE_TEXT;}
else if(YAHOO.lang.isObject(oLiveData)){this.responseType=DS.TYPE_JSON;}}
else{oLiveData=[];this.responseType=DS.TYPE_JSARRAY;}
this.constructor.superclass.constructor.call(this,oLiveData,oConfigs);};lang.extend(util.LocalDataSource,DS);lang.augmentObject(util.LocalDataSource,DS);util.FunctionDataSource=function(oLiveData,oConfigs){this.dataType=DS.TYPE_JSFUNCTION;oLiveData=oLiveData||function(){};this.constructor.superclass.constructor.call(this,oLiveData,oConfigs);};lang.extend(util.FunctionDataSource,DS,{makeConnection:function(oRequest,oCallback,oCaller){var tId=DS._nTransactionId++;this.fireEvent("requestEvent",{tId:tId,request:oRequest,callback:oCallback,caller:oCaller});var oRawResponse=this.liveData(oRequest);if(this.responseType===DS.TYPE_UNKNOWN){if(YAHOO.lang.isArray(oRawResponse)){this.responseType=DS.TYPE_JSARRAY;}
else if(oRawResponse&&oRawResponse.nodeType&&oRawResponse.nodeType==9){this.responseType=DS.TYPE_XML;}
else if(oRawResponse&&oRawResponse.nodeName&&(oRawResponse.nodeName.toLowerCase()=="table")){this.responseType=DS.TYPE_HTMLTABLE;}
else if(YAHOO.lang.isObject(oRawResponse)){this.responseType=DS.TYPE_JSON;}
else if(YAHOO.lang.isString(oRawResponse)){this.responseType=DS.TYPE_TEXT;}}
this.handleResponse(oRequest,oRawResponse,oCallback,oCaller,tId);return tId;}});lang.augmentObject(util.FunctionDataSource,DS);util.ScriptNodeDataSource=function(oLiveData,oConfigs){this.dataType=DS.TYPE_SCRIPTNODE;oLiveData=oLiveData||"";this.constructor.superclass.constructor.call(this,oLiveData,oConfigs);};lang.extend(util.ScriptNodeDataSource,DS,{getUtility:util.Get,asyncMode:"allowAll",scriptCallbackParam:"callback",generateRequestCallback:function(id){return"&"+this.scriptCallbackParam+"=YAHOO.util.ScriptNodeDataSource.callbacks["+id+"]";},makeConnection:function(oRequest,oCallback,oCaller){var tId=DS._nTransactionId++;this.fireEvent("requestEvent",{tId:tId,request:oRequest,callback:oCallback,caller:oCaller});if(util.ScriptNodeDataSource._nPending===0){util.ScriptNodeDataSource.callbacks=[];util.ScriptNodeDataSource._nId=0;}
var id=util.ScriptNodeDataSource._nId;util.ScriptNodeDataSource._nId++;var oSelf=this;util.ScriptNodeDataSource.callbacks[id]=function(oRawResponse){if((oSelf.asyncMode!=="ignoreStaleResponses")||(id===util.ScriptNodeDataSource.callbacks.length-1)){if(oSelf.responseType===DS.TYPE_UNKNOWN){if(YAHOO.lang.isArray(oRawResponse)){oSelf.responseType=DS.TYPE_JSARRAY;}
else if(oRawResponse.nodeType&&oRawResponse.nodeType==9){oSelf.responseType=DS.TYPE_XML;}
else if(oRawResponse.nodeName&&(oRawResponse.nodeName.toLowerCase()=="table")){oSelf.responseType=DS.TYPE_HTMLTABLE;}
else if(YAHOO.lang.isObject(oRawResponse)){oSelf.responseType=DS.TYPE_JSON;}
else if(YAHOO.lang.isString(oRawResponse)){oSelf.responseType=DS.TYPE_TEXT;}}
oSelf.handleResponse(oRequest,oRawResponse,oCallback,oCaller,tId);}
else{}
delete util.ScriptNodeDataSource.callbacks[id];};util.ScriptNodeDataSource._nPending++;var sUri=this.liveData+oRequest+this.generateRequestCallback(id);this.getUtility.script(sUri,{autopurge:true,onsuccess:util.ScriptNodeDataSource._bumpPendingDown,onfail:util.ScriptNodeDataSource._bumpPendingDown});return tId;}});lang.augmentObject(util.ScriptNodeDataSource,DS);lang.augmentObject(util.ScriptNodeDataSource,{_nId:0,_nPending:0,callbacks:[]});util.XHRDataSource=function(oLiveData,oConfigs){this.dataType=DS.TYPE_XHR;this.connMgr=this.connMgr||util.Connect;oLiveData=oLiveData||"";this.constructor.superclass.constructor.call(this,oLiveData,oConfigs);};lang.extend(util.XHRDataSource,DS,{connMgr:null,connXhrMode:"allowAll",connMethodPost:false,connTimeout:0,makeConnection:function(oRequest,oCallback,oCaller){var oRawResponse=null;var tId=DS._nTransactionId++;this.fireEvent("requestEvent",{tId:tId,request:oRequest,callback:oCallback,caller:oCaller});var oSelf=this;var oConnMgr=this.connMgr;var oQueue=this._oQueue;var _xhrSuccess=function(oResponse){if(oResponse&&(this.asyncMode=="ignoreStaleResponses")&&(oResponse.tId!=oQueue.conn.tId)){return null;}
else if(!oResponse){this.fireEvent("dataErrorEvent",{request:oRequest,callback:oCallback,caller:oCaller,message:DS.ERROR_DATANULL});DS.issueCallback(oCallback,[oRequest,{error:true}],true,oCaller);return null;}
else{if(this.responseType===DS.TYPE_UNKNOWN){var ctype=(oResponse.getResponseHeader)?oResponse.getResponseHeader["Content-Type"]:null;if(ctype){if(ctype.indexOf("text/xml")>-1){this.responseType=DS.TYPE_XML;}
else if(ctype.indexOf("application/json")>-1){this.responseType=DS.TYPE_JSON;}
else if(ctype.indexOf("text/plain")>-1){this.responseType=DS.TYPE_TEXT;}}}
this.handleResponse(oRequest,oResponse,oCallback,oCaller,tId);}};var _xhrFailure=function(oResponse){this.fireEvent("dataErrorEvent",{request:oRequest,callback:oCallback,caller:oCaller,message:DS.ERROR_DATAINVALID});if(lang.isString(this.liveData)&&lang.isString(oRequest)&&(this.liveData.lastIndexOf("?")!==this.liveData.length-1)&&(oRequest.indexOf("?")!==0)){}
oResponse=oResponse||{};oResponse.error=true;DS.issueCallback(oCallback,[oRequest,oResponse],true,oCaller);return null;};var _xhrCallback={success:_xhrSuccess,failure:_xhrFailure,scope:this};if(lang.isNumber(this.connTimeout)){_xhrCallback.timeout=this.connTimeout;}
if(this.connXhrMode=="cancelStaleRequests"){if(oQueue.conn){if(oConnMgr.abort){oConnMgr.abort(oQueue.conn);oQueue.conn=null;}
else{}}}
if(oConnMgr&&oConnMgr.asyncRequest){var sLiveData=this.liveData;var isPost=this.connMethodPost;var sMethod=(isPost)?"POST":"GET";var sUri=(isPost||!lang.isValue(oRequest))?sLiveData:sLiveData+oRequest;var sRequest=(isPost)?oRequest:null;if(this.connXhrMode!="queueRequests"){oQueue.conn=oConnMgr.asyncRequest(sMethod,sUri,_xhrCallback,sRequest);}
else{if(oQueue.conn){var allRequests=oQueue.requests;allRequests.push({request:oRequest,callback:_xhrCallback});if(!oQueue.interval){oQueue.interval=setInterval(function(){if(oConnMgr.isCallInProgress(oQueue.conn)){return;}
else{if(allRequests.length>0){sUri=(isPost||!lang.isValue(allRequests[0].request))?sLiveData:sLiveData+allRequests[0].request;sRequest=(isPost)?allRequests[0].request:null;oQueue.conn=oConnMgr.asyncRequest(sMethod,sUri,allRequests[0].callback,sRequest);allRequests.shift();}
else{clearInterval(oQueue.interval);oQueue.interval=null;}}},50);}}
else{oQueue.conn=oConnMgr.asyncRequest(sMethod,sUri,_xhrCallback,sRequest);}}}
else{DS.issueCallback(oCallback,[oRequest,{error:true}],true,oCaller);}
return tId;}});lang.augmentObject(util.XHRDataSource,DS);util.DataSource=function(oLiveData,oConfigs){oConfigs=oConfigs||{};var dataType=oConfigs.dataType;if(dataType){if(dataType==DS.TYPE_LOCAL){lang.augmentObject(util.DataSource,util.LocalDataSource);return new util.LocalDataSource(oLiveData,oConfigs);}
else if(dataType==DS.TYPE_XHR){lang.augmentObject(util.DataSource,util.XHRDataSource);return new util.XHRDataSource(oLiveData,oConfigs);}
else if(dataType==DS.TYPE_SCRIPTNODE){lang.augmentObject(util.DataSource,util.ScriptNodeDataSource);return new util.ScriptNodeDataSource(oLiveData,oConfigs);}
else if(dataType==DS.TYPE_JSFUNCTION){lang.augmentObject(util.DataSource,util.FunctionDataSource);return new util.FunctionDataSource(oLiveData,oConfigs);}}
if(YAHOO.lang.isString(oLiveData)){lang.augmentObject(util.DataSource,util.XHRDataSource);return new util.XHRDataSource(oLiveData,oConfigs);}
else if(YAHOO.lang.isFunction(oLiveData)){lang.augmentObject(util.DataSource,util.FunctionDataSource);return new util.FunctionDataSource(oLiveData,oConfigs);}
else{lang.augmentObject(util.DataSource,util.LocalDataSource);return new util.LocalDataSource(oLiveData,oConfigs);}};lang.augmentObject(util.DataSource,DS);})();YAHOO.util.Number={format:function(nData,oConfig){oConfig=oConfig||{};if(!YAHOO.lang.isNumber(nData)){nData*=1;}
if(YAHOO.lang.isNumber(nData)){var bNegative=(nData<0);var sOutput=nData+"";var sDecimalSeparator=(oConfig.decimalSeparator)?oConfig.decimalSeparator:".";var nDotIndex;if(YAHOO.lang.isNumber(oConfig.decimalPlaces)){var nDecimalPlaces=oConfig.decimalPlaces;var nDecimal=Math.pow(10,nDecimalPlaces);sOutput=Math.round(nData*nDecimal)/nDecimal+"";nDotIndex=sOutput.lastIndexOf(".");if(nDecimalPlaces>0){if(nDotIndex<0){sOutput+=sDecimalSeparator;nDotIndex=sOutput.length-1;}
else if(sDecimalSeparator!=="."){sOutput=sOutput.replace(".",sDecimalSeparator);}
while((sOutput.length-1-nDotIndex)<nDecimalPlaces){sOutput+="0";}}}
if(oConfig.thousandsSeparator){var sThousandsSeparator=oConfig.thousandsSeparator;nDotIndex=sOutput.lastIndexOf(sDecimalSeparator);nDotIndex=(nDotIndex>-1)?nDotIndex:sOutput.length;var sNewOutput=sOutput.substring(nDotIndex);var nCount=-1;for(var i=nDotIndex;i>0;i--){nCount++;if((nCount%3===0)&&(i!==nDotIndex)&&(!bNegative||(i>1))){sNewOutput=sThousandsSeparator+sNewOutput;}
sNewOutput=sOutput.charAt(i-1)+sNewOutput;}
sOutput=sNewOutput;}
sOutput=(oConfig.prefix)?oConfig.prefix+sOutput:sOutput;sOutput=(oConfig.suffix)?sOutput+oConfig.suffix:sOutput;return sOutput;}
else{return nData;}}};(function(){var xPad=function(x,pad,r)
{if(typeof r==='undefined')
{r=10;}
for(;parseInt(x,10)<r&&r>1;r/=10){x=pad.toString()+x;}
return x.toString();};var Dt={formats:{a:function(d,l){return l.a[d.getDay()];},A:function(d,l){return l.A[d.getDay()];},b:function(d,l){return l.b[d.getMonth()];},B:function(d,l){return l.B[d.getMonth()];},C:function(d){return xPad(parseInt(d.getFullYear()/100,10),0);},d:['getDate','0'],e:['getDate',' '],g:function(d){return xPad(parseInt(Dt.formats.G(d)%100,10),0);},G:function(d){var y=d.getFullYear();var V=parseInt(Dt.formats.V(d),10);var W=parseInt(Dt.formats.W(d),10);if(W>V){y++;}else if(W===0&&V>=52){y--;}
return y;},H:['getHours','0'],I:function(d){var I=d.getHours()%12;return xPad(I===0?12:I,0);},j:function(d){var gmd_1=new Date(''+d.getFullYear()+'/1/1 GMT');var gmdate=new Date(''+d.getFullYear()+'/'+(d.getMonth()+1)+'/'+d.getDate()+' GMT');var ms=gmdate-gmd_1;var doy=parseInt(ms/60000/60/24,10)+1;return xPad(doy,0,100);},k:['getHours',' '],l:function(d){var I=d.getHours()%12;return xPad(I===0?12:I,' ');},m:function(d){return xPad(d.getMonth()+1,0);},M:['getMinutes','0'],p:function(d,l){return l.p[d.getHours()>=12?1:0];},P:function(d,l){return l.P[d.getHours()>=12?1:0];},s:function(d,l){return parseInt(d.getTime()/1000,10);},S:['getSeconds','0'],u:function(d){var dow=d.getDay();return dow===0?7:dow;},U:function(d){var doy=parseInt(Dt.formats.j(d),10);var rdow=6-d.getDay();var woy=parseInt((doy+rdow)/7,10);return xPad(woy,0);},V:function(d){var woy=parseInt(Dt.formats.W(d),10);var dow1_1=(new Date(''+d.getFullYear()+'/1/1')).getDay();var idow=woy+(dow1_1>4||dow1_1<=1?0:1);if(idow===53&&(new Date(''+d.getFullYear()+'/12/31')).getDay()<4)
{idow=1;}
else if(idow===0)
{idow=Dt.formats.V(new Date(''+(d.getFullYear()-1)+'/12/31'));}
return xPad(idow,0);},w:'getDay',W:function(d){var doy=parseInt(Dt.formats.j(d),10);var rdow=7-Dt.formats.u(d);var woy=parseInt((doy+rdow)/7,10);return xPad(woy,0,10);},y:function(d){return xPad(d.getFullYear()%100,0);},Y:'getFullYear',z:function(d){var o=d.getTimezoneOffset();var H=xPad(parseInt(Math.abs(o/60),10),0);var M=xPad(Math.abs(o%60),0);return(o>0?'-':'+')+H+M;},Z:function(d){var tz=d.toString().replace(/^.*:\d\d( GMT[+-]\d+)? \(?([A-Za-z ]+)\)?\d*$/,'$2').replace(/[a-z ]/g,'');if(tz.length>4){tz=Dt.formats.z(d);}
return tz;},'%':function(d){return'%';}},aggregates:{c:'locale',D:'%m/%d/%y',F:'%Y-%m-%d',h:'%b',n:'\n',r:'locale',R:'%H:%M',t:'\t',T:'%H:%M:%S',x:'locale',X:'locale'},format:function(oDate,oConfig,sLocale){oConfig=oConfig||{};if(!(oDate instanceof Date)){return YAHOO.lang.isValue(oDate)?oDate:"";}
var format=oConfig.format||"%m/%d/%Y";if(format==='YYYY/MM/DD'){format='%Y/%m/%d';}else if(format==='DD/MM/YYYY'){format='%d/%m/%Y';}else if(format==='MM/DD/YYYY'){format='%m/%d/%Y';}
sLocale=sLocale||"en";if(!(sLocale in YAHOO.util.DateLocale)){if(sLocale.replace(/-[a-zA-Z]+$/,'')in YAHOO.util.DateLocale){sLocale=sLocale.replace(/-[a-zA-Z]+$/,'');}else{sLocale="en";}}
var aLocale=YAHOO.util.DateLocale[sLocale];var replace_aggs=function(m0,m1){var f=Dt.aggregates[m1];return(f==='locale'?aLocale[m1]:f);};var replace_formats=function(m0,m1){var f=Dt.formats[m1];if(typeof f==='string'){return oDate[f]();}else if(typeof f==='function'){return f.call(oDate,oDate,aLocale);}else if(typeof f==='object'&&typeof f[0]==='string'){return xPad(oDate[f[0]](),f[1]);}else{return m1;}};while(format.match(/%[cDFhnrRtTxX]/)){format=format.replace(/%([cDFhnrRtTxX])/g,replace_aggs);}
var str=format.replace(/%([aAbBCdegGHIjklmMpPsSuUVwWyYzZ%])/g,replace_formats);replace_aggs=replace_formats=undefined;return str;}};YAHOO.namespace("YAHOO.util");YAHOO.util.Date=Dt;YAHOO.util.DateLocale={a:['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],A:['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],b:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],B:['January','February','March','April','May','June','July','August','September','October','November','December'],c:'%a %d %b %Y %T %Z',p:['AM','PM'],P:['am','pm'],r:'%I:%M:%S %p',x:'%d/%m/%y',X:'%T'};YAHOO.util.DateLocale['en']=YAHOO.lang.merge(YAHOO.util.DateLocale,{});YAHOO.util.DateLocale['en-US']=YAHOO.lang.merge(YAHOO.util.DateLocale['en'],{c:'%a %d %b %Y %I:%M:%S %p %Z',x:'%m/%d/%Y',X:'%I:%M:%S %p'});YAHOO.util.DateLocale['en-GB']=YAHOO.lang.merge(YAHOO.util.DateLocale['en'],{r:'%l:%M:%S %P %Z'});YAHOO.util.DateLocale['en-AU']=YAHOO.lang.merge(YAHOO.util.DateLocale['en']);})();YAHOO.register("datasource",YAHOO.util.DataSource,{version:"2.6.0",build:"1321"});YAHOO.widget.AutoComplete=function(elInput,elContainer,oDataSource,oConfigs){if(elInput&&elContainer&&oDataSource){if(oDataSource instanceof YAHOO.widget.DataSource){this.dataSource=oDataSource;}
else{return;}
if(YAHOO.util.Dom.inDocument(elInput)){if(YAHOO.lang.isString(elInput)){this._sName="instance"+YAHOO.widget.AutoComplete._nIndex+" "+elInput;this._elTextbox=document.getElementById(elInput);}
else{this._sName=(elInput.id)?"instance"+YAHOO.widget.AutoComplete._nIndex+" "+elInput.id:"instance"+YAHOO.widget.AutoComplete._nIndex;this._elTextbox=elInput;}
YAHOO.util.Dom.addClass(this._elTextbox,"yui-ac-input");}
else{return;}
if(YAHOO.util.Dom.inDocument(elContainer)){if(YAHOO.lang.isString(elContainer)){this._elContainer=document.getElementById(elContainer);}
else{this._elContainer=elContainer;}
if(this._elContainer.style.display=="none"){}
var elParent=this._elContainer.parentNode;var elTag=elParent.tagName.toLowerCase();if(elTag=="div"){YAHOO.util.Dom.addClass(elParent,"yui-ac");}
else{}}
else{return;}
if(oConfigs&&(oConfigs.constructor==Object)){for(var sConfig in oConfigs){if(sConfig){this[sConfig]=oConfigs[sConfig];}}}
this._initContainer();this._initProps();this._initList();this._initContainerHelpers();var oSelf=this;var elTextbox=this._elTextbox;var elContent=this._elContent;YAHOO.util.Event.addListener(elTextbox,"keyup",oSelf._onTextboxKeyUp,oSelf);YAHOO.util.Event.addListener(elTextbox,"keydown",oSelf._onTextboxKeyDown,oSelf);YAHOO.util.Event.addListener(elTextbox,"focus",oSelf._onTextboxFocus,oSelf);YAHOO.util.Event.addListener(elTextbox,"blur",oSelf._onTextboxBlur,oSelf);YAHOO.util.Event.addListener(elContent,"mouseover",oSelf._onContainerMouseover,oSelf);YAHOO.util.Event.addListener(elContent,"mouseout",oSelf._onContainerMouseout,oSelf);YAHOO.util.Event.addListener(elContent,"scroll",oSelf._onContainerScroll,oSelf);YAHOO.util.Event.addListener(elContent,"resize",oSelf._onContainerResize,oSelf);YAHOO.util.Event.addListener(elTextbox,"keypress",oSelf._onTextboxKeyPress,oSelf);YAHOO.util.Event.addListener(window,"unload",oSelf._onWindowUnload,oSelf);this.textboxFocusEvent=new YAHOO.util.CustomEvent("textboxFocus",this);this.textboxKeyEvent=new YAHOO.util.CustomEvent("textboxKey",this);this.dataRequestEvent=new YAHOO.util.CustomEvent("dataRequest",this);this.dataReturnEvent=new YAHOO.util.CustomEvent("dataReturn",this);this.dataErrorEvent=new YAHOO.util.CustomEvent("dataError",this);this.containerExpandEvent=new YAHOO.util.CustomEvent("containerExpand",this);this.typeAheadEvent=new YAHOO.util.CustomEvent("typeAhead",this);this.itemMouseOverEvent=new YAHOO.util.CustomEvent("itemMouseOver",this);this.itemMouseOutEvent=new YAHOO.util.CustomEvent("itemMouseOut",this);this.itemArrowToEvent=new YAHOO.util.CustomEvent("itemArrowTo",this);this.itemArrowFromEvent=new YAHOO.util.CustomEvent("itemArrowFrom",this);this.itemSelectEvent=new YAHOO.util.CustomEvent("itemSelect",this);this.unmatchedItemSelectEvent=new YAHOO.util.CustomEvent("unmatchedItemSelect",this);this.selectionEnforceEvent=new YAHOO.util.CustomEvent("selectionEnforce",this);this.containerCollapseEvent=new YAHOO.util.CustomEvent("containerCollapse",this);this.textboxBlurEvent=new YAHOO.util.CustomEvent("textboxBlur",this);elTextbox.setAttribute("autocomplete","off");YAHOO.widget.AutoComplete._nIndex++;}
else{}};YAHOO.widget.AutoComplete.prototype.dataSource=null;YAHOO.widget.AutoComplete.prototype.minQueryLength=1;YAHOO.widget.AutoComplete.prototype.maxResultsDisplayed=10;YAHOO.widget.AutoComplete.prototype.queryDelay=0.2;YAHOO.widget.AutoComplete.prototype.highlightClassName="yui-ac-highlight";YAHOO.widget.AutoComplete.prototype.prehighlightClassName=null;YAHOO.widget.AutoComplete.prototype.delimChar=null;YAHOO.widget.AutoComplete.prototype.autoHighlight=true;YAHOO.widget.AutoComplete.prototype.typeAhead=false;YAHOO.widget.AutoComplete.prototype.animHoriz=false;YAHOO.widget.AutoComplete.prototype.animVert=true;YAHOO.widget.AutoComplete.prototype.animSpeed=0.3;YAHOO.widget.AutoComplete.prototype.forceSelection=false;YAHOO.widget.AutoComplete.prototype.allowBrowserAutocomplete=true;YAHOO.widget.AutoComplete.prototype.alwaysShowContainer=false;YAHOO.widget.AutoComplete.prototype.useIFrame=false;YAHOO.widget.AutoComplete.prototype.useShadow=false;YAHOO.widget.AutoComplete.prototype.toString=function(){return"AutoComplete "+this._sName;};YAHOO.widget.AutoComplete.prototype.isContainerOpen=function(){return this._bContainerOpen;};YAHOO.widget.AutoComplete.prototype.getListItems=function(){return this._aListItems;};YAHOO.widget.AutoComplete.prototype.getListItemData=function(oListItem){if(oListItem._oResultData){return oListItem._oResultData;}
else{return false;}};YAHOO.widget.AutoComplete.prototype.setHeader=function(sHeader){if(this._elHeader){var elHeader=this._elHeader;if(sHeader){elHeader.innerHTML=sHeader;elHeader.style.display="block";}
else{elHeader.innerHTML="";elHeader.style.display="none";}}};YAHOO.widget.AutoComplete.prototype.setFooter=function(sFooter){if(this._elFooter){var elFooter=this._elFooter;if(sFooter){elFooter.innerHTML=sFooter;elFooter.style.display="block";}
else{elFooter.innerHTML="";elFooter.style.display="none";}}};YAHOO.widget.AutoComplete.prototype.setBody=function(sBody){if(this._elBody){var elBody=this._elBody;if(sBody){elBody.innerHTML=sBody;elBody.style.display="block";elBody.style.display="block";}
else{elBody.innerHTML="";elBody.style.display="none";}
this._maxResultsDisplayed=0;}};YAHOO.widget.AutoComplete.prototype.formatResult=function(oResultItem,sQuery){var sResult=oResultItem[0];if(sResult){return sResult;}
else{return"";}};YAHOO.widget.AutoComplete.prototype.doBeforeExpandContainer=function(elTextbox,elContainer,sQuery,aResults){return true;};YAHOO.widget.AutoComplete.prototype.sendQuery=function(sQuery){this._sendQuery(sQuery);};YAHOO.widget.AutoComplete.prototype.doBeforeSendQuery=function(sQuery){return sQuery;};YAHOO.widget.AutoComplete.prototype.destroy=function(){var instanceName=this.toString();var elInput=this._elTextbox;var elContainer=this._elContainer;this.textboxFocusEvent.unsubscribeAll();this.textboxKeyEvent.unsubscribeAll();this.dataRequestEvent.unsubscribeAll();this.dataReturnEvent.unsubscribeAll();this.dataErrorEvent.unsubscribeAll();this.containerExpandEvent.unsubscribeAll();this.typeAheadEvent.unsubscribeAll();this.itemMouseOverEvent.unsubscribeAll();this.itemMouseOutEvent.unsubscribeAll();this.itemArrowToEvent.unsubscribeAll();this.itemArrowFromEvent.unsubscribeAll();this.itemSelectEvent.unsubscribeAll();this.unmatchedItemSelectEvent.unsubscribeAll();this.selectionEnforceEvent.unsubscribeAll();this.containerCollapseEvent.unsubscribeAll();this.textboxBlurEvent.unsubscribeAll();YAHOO.util.Event.purgeElement(elInput,true);YAHOO.util.Event.purgeElement(elContainer,true);elContainer.innerHTML="";for(var key in this){if(YAHOO.lang.hasOwnProperty(this,key)){this[key]=null;}}};YAHOO.widget.AutoComplete.prototype.textboxFocusEvent=null;YAHOO.widget.AutoComplete.prototype.textboxKeyEvent=null;YAHOO.widget.AutoComplete.prototype.dataRequestEvent=null;YAHOO.widget.AutoComplete.prototype.dataReturnEvent=null;YAHOO.widget.AutoComplete.prototype.dataErrorEvent=null;YAHOO.widget.AutoComplete.prototype.containerExpandEvent=null;YAHOO.widget.AutoComplete.prototype.typeAheadEvent=null;YAHOO.widget.AutoComplete.prototype.itemMouseOverEvent=null;YAHOO.widget.AutoComplete.prototype.itemMouseOutEvent=null;YAHOO.widget.AutoComplete.prototype.itemArrowToEvent=null;YAHOO.widget.AutoComplete.prototype.itemArrowFromEvent=null;YAHOO.widget.AutoComplete.prototype.itemSelectEvent=null;YAHOO.widget.AutoComplete.prototype.unmatchedItemSelectEvent=null;YAHOO.widget.AutoComplete.prototype.selectionEnforceEvent=null;YAHOO.widget.AutoComplete.prototype.containerCollapseEvent=null;YAHOO.widget.AutoComplete.prototype.textboxBlurEvent=null;YAHOO.widget.AutoComplete._nIndex=0;YAHOO.widget.AutoComplete.prototype._sName=null;YAHOO.widget.AutoComplete.prototype._elTextbox=null;YAHOO.widget.AutoComplete.prototype._elContainer=null;YAHOO.widget.AutoComplete.prototype._elContent=null;YAHOO.widget.AutoComplete.prototype._elHeader=null;YAHOO.widget.AutoComplete.prototype._elBody=null;YAHOO.widget.AutoComplete.prototype._elFooter=null;YAHOO.widget.AutoComplete.prototype._elShadow=null;YAHOO.widget.AutoComplete.prototype._elIFrame=null;YAHOO.widget.AutoComplete.prototype._bFocused=true;YAHOO.widget.AutoComplete.prototype._oAnim=null;YAHOO.widget.AutoComplete.prototype._bContainerOpen=false;YAHOO.widget.AutoComplete.prototype._bOverContainer=false;YAHOO.widget.AutoComplete.prototype._aListItems=null;YAHOO.widget.AutoComplete.prototype._nDisplayedItems=0;YAHOO.widget.AutoComplete.prototype._maxResultsDisplayed=0;YAHOO.widget.AutoComplete.prototype._sCurQuery=null;YAHOO.widget.AutoComplete.prototype._sSavedQuery=null;YAHOO.widget.AutoComplete.prototype._oCurItem=null;YAHOO.widget.AutoComplete.prototype._bItemSelected=false;YAHOO.widget.AutoComplete.prototype._nKeyCode=null;YAHOO.widget.AutoComplete.prototype._nDelayID=-1;YAHOO.widget.AutoComplete.prototype._iFrameSrc="javascript:false;";YAHOO.widget.AutoComplete.prototype._queryInterval=null;YAHOO.widget.AutoComplete.prototype._sLastTextboxValue=null;YAHOO.widget.AutoComplete.prototype._initProps=function(){var minQueryLength=this.minQueryLength;if(!YAHOO.lang.isNumber(minQueryLength)){this.minQueryLength=1;}
var maxResultsDisplayed=this.maxResultsDisplayed;if(!YAHOO.lang.isNumber(maxResultsDisplayed)||(maxResultsDisplayed<1)){this.maxResultsDisplayed=10;}
var queryDelay=this.queryDelay;if(!YAHOO.lang.isNumber(queryDelay)||(queryDelay<0)){this.queryDelay=0.2;}
var delimChar=this.delimChar;if(YAHOO.lang.isString(delimChar)&&(delimChar.length>0)){this.delimChar=[delimChar];}
else if(!YAHOO.lang.isArray(delimChar)){this.delimChar=null;}
var animSpeed=this.animSpeed;if((this.animHoriz||this.animVert)&&YAHOO.util.Anim){if(!YAHOO.lang.isNumber(animSpeed)||(animSpeed<0)){this.animSpeed=0.3;}
if(!this._oAnim){this._oAnim=new YAHOO.util.Anim(this._elContent,{},this.animSpeed);}
else{this._oAnim.duration=this.animSpeed;}}
if(this.forceSelection&&delimChar){}};YAHOO.widget.AutoComplete.prototype._initContainerHelpers=function(){if(this.useShadow&&!this._elShadow){var elShadow=document.createElement("div");elShadow.className="yui-ac-shadow";this._elShadow=this._elContainer.appendChild(elShadow);}
if(this.useIFrame&&!this._elIFrame){var elIFrame=document.createElement("iframe");elIFrame.src=this._iFrameSrc;elIFrame.frameBorder=0;elIFrame.scrolling="no";elIFrame.style.position="absolute";elIFrame.style.width="100%";elIFrame.style.height="100%";elIFrame.tabIndex=-1;this._elIFrame=this._elContainer.appendChild(elIFrame);}};YAHOO.widget.AutoComplete.prototype._initContainer=function(){YAHOO.util.Dom.addClass(this._elContainer,"yui-ac-container");if(!this._elContent){var elContent=document.createElement("div");elContent.className="yui-ac-content";elContent.style.display="none";this._elContent=this._elContainer.appendChild(elContent);var elHeader=document.createElement("div");elHeader.className="yui-ac-hd";elHeader.style.display="none";this._elHeader=this._elContent.appendChild(elHeader);var elBody=document.createElement("div");elBody.className="yui-ac-bd";this._elBody=this._elContent.appendChild(elBody);var elFooter=document.createElement("div");elFooter.className="yui-ac-ft";elFooter.style.display="none";this._elFooter=this._elContent.appendChild(elFooter);}
else{}};YAHOO.widget.AutoComplete.prototype._initList=function(){this._aListItems=[];while(this._elBody.hasChildNodes()){var oldListItems=this.getListItems();if(oldListItems){for(var oldi=oldListItems.length-1;oldi>=0;oldi--){oldListItems[oldi]=null;}}
this._elBody.innerHTML="";}
var oList=document.createElement("ul");oList=this._elBody.appendChild(oList);for(var i=0;i<this.maxResultsDisplayed;i++){var oItem=document.createElement("li");oItem=oList.appendChild(oItem);this._aListItems[i]=oItem;this._initListItem(oItem,i);}
this._maxResultsDisplayed=this.maxResultsDisplayed;};YAHOO.widget.AutoComplete.prototype._initListItem=function(oItem,nItemIndex){var oSelf=this;oItem.style.display="none";oItem._nItemIndex=nItemIndex;oItem.mouseover=oItem.mouseout=oItem.onclick=null;YAHOO.util.Event.addListener(oItem,"mouseover",oSelf._onItemMouseover,oSelf);YAHOO.util.Event.addListener(oItem,"mouseout",oSelf._onItemMouseout,oSelf);YAHOO.util.Event.addListener(oItem,"click",oSelf._onItemMouseclick,oSelf);};YAHOO.widget.AutoComplete.prototype._onIMEDetected=function(oSelf){oSelf._enableIntervalDetection();};YAHOO.widget.AutoComplete.prototype._enableIntervalDetection=function(){var currValue=this._elTextbox.value;var lastValue=this._sLastTextboxValue;if(currValue!=lastValue){this._sLastTextboxValue=currValue;this._sendQuery(currValue);}};YAHOO.widget.AutoComplete.prototype._cancelIntervalDetection=function(oSelf){if(oSelf._queryInterval){clearInterval(oSelf._queryInterval);}};YAHOO.widget.AutoComplete.prototype._isIgnoreKey=function(nKeyCode){if((nKeyCode==9)||(nKeyCode==13)||(nKeyCode==16)||(nKeyCode==17)||(nKeyCode>=18&&nKeyCode<=20)||(nKeyCode==27)||(nKeyCode>=33&&nKeyCode<=35)||(nKeyCode>=36&&nKeyCode<=40)||(nKeyCode>=44&&nKeyCode<=45)){return true;}
return false;};YAHOO.widget.AutoComplete.prototype._sendQuery=function(sQuery){if(this.minQueryLength==-1){this._toggleContainer(false);return;}
var aDelimChar=(this.delimChar)?this.delimChar:null;if(aDelimChar){var nDelimIndex=-1;for(var i=aDelimChar.length-1;i>=0;i--){var nNewIndex=sQuery.lastIndexOf(aDelimChar[i]);if(nNewIndex>nDelimIndex){nDelimIndex=nNewIndex;}}
if(aDelimChar[i]==" "){for(var j=aDelimChar.length-1;j>=0;j--){if(sQuery[nDelimIndex-1]==aDelimChar[j]){nDelimIndex--;break;}}}
if(nDelimIndex>-1){var nQueryStart=nDelimIndex+1;while(sQuery.charAt(nQueryStart)==" "){nQueryStart+=1;}
this._sSavedQuery=sQuery.substring(0,nQueryStart);sQuery=sQuery.substr(nQueryStart);}
else if(sQuery.indexOf(this._sSavedQuery)<0){this._sSavedQuery=null;}}
if((sQuery&&(sQuery.length<this.minQueryLength))||(!sQuery&&this.minQueryLength>0)){if(this._nDelayID!=-1){clearTimeout(this._nDelayID);}
this._toggleContainer(false);return;}
sQuery=encodeURIComponent(sQuery);this._nDelayID=-1;sQuery=this.doBeforeSendQuery(sQuery);this.dataRequestEvent.fire(this,sQuery);this.dataSource.getResults(this._populateList,sQuery,this);};YAHOO.widget.AutoComplete.prototype._populateList=function(sQuery,aResults,oSelf){if(aResults===null){oSelf.dataErrorEvent.fire(oSelf,sQuery);}
if(!oSelf._bFocused||!aResults){return;}
var isOpera=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1);var contentStyle=oSelf._elContent.style;contentStyle.width=(!isOpera)?null:"";contentStyle.height=(!isOpera)?null:"";var sCurQuery=decodeURIComponent(sQuery);oSelf._sCurQuery=sCurQuery;oSelf._bItemSelected=false;if(oSelf._maxResultsDisplayed!=oSelf.maxResultsDisplayed){oSelf._initList();}
var nItems=Math.min(aResults.length,oSelf.maxResultsDisplayed);oSelf._nDisplayedItems=nItems;if(nItems>0){oSelf._initContainerHelpers();var aItems=oSelf._aListItems;for(var i=nItems-1;i>=0;i--){var oItemi=aItems[i];var oResultItemi=aResults[i];oItemi.innerHTML=oSelf.formatResult(oResultItemi,sCurQuery);oItemi.style.display="list-item";oItemi._sResultKey=oResultItemi[0];oItemi._oResultData=oResultItemi;}
for(var j=aItems.length-1;j>=nItems;j--){var oItemj=aItems[j];oItemj.innerHTML=null;oItemj.style.display="none";oItemj._sResultKey=null;oItemj._oResultData=null;}
var ok=oSelf.doBeforeExpandContainer(oSelf._elTextbox,oSelf._elContainer,sQuery,aResults);oSelf._toggleContainer(ok);if(oSelf.autoHighlight){var oFirstItem=aItems[0];oSelf._toggleHighlight(oFirstItem,"to");oSelf.itemArrowToEvent.fire(oSelf,oFirstItem);oSelf._typeAhead(oFirstItem,sQuery);}
else{oSelf._oCurItem=null;}}
else{oSelf._toggleContainer(false);}
oSelf.dataReturnEvent.fire(oSelf,sQuery,aResults);};YAHOO.widget.AutoComplete.prototype._clearSelection=function(){var sValue=this._elTextbox.value;var sChar=(this.delimChar)?this.delimChar[0]:null;var nIndex=(sChar)?sValue.lastIndexOf(sChar,sValue.length-2):-1;if(nIndex>-1){this._elTextbox.value=sValue.substring(0,nIndex);}
else{this._elTextbox.value="";}
this._sSavedQuery=this._elTextbox.value;this.selectionEnforceEvent.fire(this);};YAHOO.widget.AutoComplete.prototype._textMatchesOption=function(){var foundMatch=null;for(var i=this._nDisplayedItems-1;i>=0;i--){var oItem=this._aListItems[i];var sMatch=oItem._sResultKey.toLowerCase();if(sMatch==this._sCurQuery.toLowerCase()){foundMatch=oItem;break;}}
return(foundMatch);};YAHOO.widget.AutoComplete.prototype._typeAhead=function(oItem,sQuery){if(!this.typeAhead||(this._nKeyCode==8)){return;}
var elTextbox=this._elTextbox;var sValue=this._elTextbox.value;if(!elTextbox.setSelectionRange&&!elTextbox.createTextRange){return;}
var nStart=sValue.length;this._updateValue(oItem);var nEnd=elTextbox.value.length;this._selectText(elTextbox,nStart,nEnd);var sPrefill=elTextbox.value.substr(nStart,nEnd);this.typeAheadEvent.fire(this,sQuery,sPrefill);};YAHOO.widget.AutoComplete.prototype._selectText=function(elTextbox,nStart,nEnd){if(elTextbox.setSelectionRange){elTextbox.setSelectionRange(nStart,nEnd);}
else if(elTextbox.createTextRange){var oTextRange=elTextbox.createTextRange();oTextRange.moveStart("character",nStart);oTextRange.moveEnd("character",nEnd-elTextbox.value.length);oTextRange.select();}
else{elTextbox.select();}};YAHOO.widget.AutoComplete.prototype._toggleContainerHelpers=function(bShow){var bFireEvent=false;var width=this._elContent.offsetWidth+"px";var height=this._elContent.offsetHeight+"px";if(this.useIFrame&&this._elIFrame){bFireEvent=true;if(bShow){this._elIFrame.style.width=width;this._elIFrame.style.height=height;}
else{this._elIFrame.style.width=0;this._elIFrame.style.height=0;}}
if(this.useShadow&&this._elShadow){bFireEvent=true;if(bShow){this._elShadow.style.width=width;this._elShadow.style.height=height;}
else{this._elShadow.style.width=0;this._elShadow.style.height=0;}}};YAHOO.widget.AutoComplete.prototype._toggleContainer=function(bShow){var elContainer=this._elContainer;if(this.alwaysShowContainer&&this._bContainerOpen){return;}
if(!bShow){this._elContent.scrollTop=0;var aItems=this._aListItems;if(aItems&&(aItems.length>0)){for(var i=aItems.length-1;i>=0;i--){aItems[i].style.display="none";}}
if(this._oCurItem){this._toggleHighlight(this._oCurItem,"from");}
this._oCurItem=null;this._nDisplayedItems=0;this._sCurQuery=null;}
if(!bShow&&!this._bContainerOpen){this._elContent.style.display="none";return;}
var oAnim=this._oAnim;if(oAnim&&oAnim.getEl()&&(this.animHoriz||this.animVert)){if(!bShow){this._toggleContainerHelpers(bShow);}
if(oAnim.isAnimated()){oAnim.stop();}
var oClone=this._elContent.cloneNode(true);elContainer.appendChild(oClone);oClone.style.top="-9000px";oClone.style.display="block";var wExp=oClone.offsetWidth;var hExp=oClone.offsetHeight;var wColl=(this.animHoriz)?0:wExp;var hColl=(this.animVert)?0:hExp;oAnim.attributes=(bShow)?{width:{to:wExp},height:{to:hExp}}:{width:{to:wColl},height:{to:hColl}};if(bShow&&!this._bContainerOpen){this._elContent.style.width=wColl+"px";this._elContent.style.height=hColl+"px";}
else{this._elContent.style.width=wExp+"px";this._elContent.style.height=hExp+"px";}
elContainer.removeChild(oClone);oClone=null;var oSelf=this;var onAnimComplete=function(){oAnim.onComplete.unsubscribeAll();if(bShow){oSelf.containerExpandEvent.fire(oSelf);}
else{oSelf._elContent.style.display="none";oSelf.containerCollapseEvent.fire(oSelf);}
oSelf._toggleContainerHelpers(bShow);};this._elContent.style.display="block";oAnim.onComplete.subscribe(onAnimComplete);oAnim.animate();this._bContainerOpen=bShow;}
else{if(bShow){this._elContent.style.display="block";this.containerExpandEvent.fire(this);}
else{this._elContent.style.display="none";this.containerCollapseEvent.fire(this);}
this._toggleContainerHelpers(bShow);this._bContainerOpen=bShow;}};YAHOO.widget.AutoComplete.prototype._toggleHighlight=function(oNewItem,sType){var sHighlight=this.highlightClassName;if(this._oCurItem){YAHOO.util.Dom.removeClass(this._oCurItem,sHighlight);}
if((sType=="to")&&sHighlight){YAHOO.util.Dom.addClass(oNewItem,sHighlight);this._oCurItem=oNewItem;}};YAHOO.widget.AutoComplete.prototype._togglePrehighlight=function(oNewItem,sType){if(oNewItem==this._oCurItem){return;}
var sPrehighlight=this.prehighlightClassName;if((sType=="mouseover")&&sPrehighlight){YAHOO.util.Dom.addClass(oNewItem,sPrehighlight);}
else{YAHOO.util.Dom.removeClass(oNewItem,sPrehighlight);}};YAHOO.widget.AutoComplete.prototype._updateValue=function(oItem){var elTextbox=this._elTextbox;var sDelimChar=(this.delimChar)?(this.delimChar[0]||this.delimChar):null;var sSavedQuery=this._sSavedQuery;var sResultKey=oItem._sResultKey;elTextbox.focus();elTextbox.value="";if(sDelimChar){if(sSavedQuery){elTextbox.value=sSavedQuery;}
elTextbox.value+=sResultKey+sDelimChar;if(sDelimChar!=" "){elTextbox.value+=" ";}}
else{elTextbox.value=sResultKey;}
if(elTextbox.type=="textarea"){elTextbox.scrollTop=elTextbox.scrollHeight;}
var end=elTextbox.value.length;this._selectText(elTextbox,end,end);this._oCurItem=oItem;};YAHOO.widget.AutoComplete.prototype._selectItem=function(oItem){this._bItemSelected=true;this._updateValue(oItem);this._cancelIntervalDetection(this);this.itemSelectEvent.fire(this,oItem,oItem._oResultData);this._toggleContainer(false);};YAHOO.widget.AutoComplete.prototype._jumpSelection=function(){if(this._oCurItem){this._selectItem(this._oCurItem);}
else{this._toggleContainer(false);}};YAHOO.widget.AutoComplete.prototype._moveSelection=function(nKeyCode){if(this._bContainerOpen){var oCurItem=this._oCurItem;var nCurItemIndex=-1;if(oCurItem){nCurItemIndex=oCurItem._nItemIndex;}
var nNewItemIndex=(nKeyCode==40)?(nCurItemIndex+1):(nCurItemIndex-1);if(nNewItemIndex<-2||nNewItemIndex>=this._nDisplayedItems){return;}
if(oCurItem){this._toggleHighlight(oCurItem,"from");this.itemArrowFromEvent.fire(this,oCurItem);}
if(nNewItemIndex==-1){if(this.delimChar&&this._sSavedQuery){if(!this._textMatchesOption()){this._elTextbox.value=this._sSavedQuery;}
else{this._elTextbox.value=this._sSavedQuery+this._sCurQuery;}}
else{this._elTextbox.value=this._sCurQuery;}
this._oCurItem=null;return;}
if(nNewItemIndex==-2){this._toggleContainer(false);return;}
var oNewItem=this._aListItems[nNewItemIndex];var elContent=this._elContent;var scrollOn=((YAHOO.util.Dom.getStyle(elContent,"overflow")=="auto")||(YAHOO.util.Dom.getStyle(elContent,"overflowY")=="auto"));if(scrollOn&&(nNewItemIndex>-1)&&(nNewItemIndex<this._nDisplayedItems)){if(nKeyCode==40){if((oNewItem.offsetTop+oNewItem.offsetHeight)>(elContent.scrollTop+elContent.offsetHeight)){elContent.scrollTop=(oNewItem.offsetTop+oNewItem.offsetHeight)-elContent.offsetHeight;}
else if((oNewItem.offsetTop+oNewItem.offsetHeight)<elContent.scrollTop){elContent.scrollTop=oNewItem.offsetTop;}}
else{if(oNewItem.offsetTop<elContent.scrollTop){this._elContent.scrollTop=oNewItem.offsetTop;}
else if(oNewItem.offsetTop>(elContent.scrollTop+elContent.offsetHeight)){this._elContent.scrollTop=(oNewItem.offsetTop+oNewItem.offsetHeight)-elContent.offsetHeight;}}}
this._toggleHighlight(oNewItem,"to");this.itemArrowToEvent.fire(this,oNewItem);if(this.typeAhead){this._updateValue(oNewItem);}}};YAHOO.widget.AutoComplete.prototype._onItemMouseover=function(v,oSelf){if(oSelf.prehighlightClassName){oSelf._togglePrehighlight(this,"mouseover");}
else{oSelf._toggleHighlight(this,"to");}
oSelf.itemMouseOverEvent.fire(oSelf,this);};YAHOO.widget.AutoComplete.prototype._onItemMouseout=function(v,oSelf){if(oSelf.prehighlightClassName){oSelf._togglePrehighlight(this,"mouseout");}
else{oSelf._toggleHighlight(this,"from");}
oSelf.itemMouseOutEvent.fire(oSelf,this);};YAHOO.widget.AutoComplete.prototype._onItemMouseclick=function(v,oSelf){oSelf._toggleHighlight(this,"to");oSelf._selectItem(this);};YAHOO.widget.AutoComplete.prototype._onContainerMouseover=function(v,oSelf){oSelf._bOverContainer=true;};YAHOO.widget.AutoComplete.prototype._onContainerMouseout=function(v,oSelf){oSelf._bOverContainer=false;if(oSelf._oCurItem){oSelf._toggleHighlight(oSelf._oCurItem,"to");}};YAHOO.widget.AutoComplete.prototype._onContainerScroll=function(v,oSelf){oSelf._elTextbox.focus();};YAHOO.widget.AutoComplete.prototype._onContainerResize=function(v,oSelf){oSelf._toggleContainerHelpers(oSelf._bContainerOpen);};YAHOO.widget.AutoComplete.prototype._onTextboxKeyDown=function(v,oSelf){var nKeyCode=v.keyCode;switch(nKeyCode){case 9:if(oSelf._oCurItem){if(oSelf.delimChar&&(oSelf._nKeyCode!=nKeyCode)){if(oSelf._bContainerOpen){YAHOO.util.Event.stopEvent(v);}}
oSelf._selectItem(oSelf._oCurItem);}
else{oSelf._toggleContainer(false);}
break;case 13:if(!YAHOO.env.ua.webkit){if(oSelf._oCurItem){if(oSelf._nKeyCode!=nKeyCode){if(oSelf._bContainerOpen){YAHOO.util.Event.stopEvent(v);}}
oSelf._selectItem(oSelf._oCurItem);}
else{oSelf._toggleContainer(false);}}
break;case 27:oSelf._toggleContainer(false);return;case 39:oSelf._jumpSelection();break;case 38:YAHOO.util.Event.stopEvent(v);oSelf._moveSelection(nKeyCode);break;case 40:YAHOO.util.Event.stopEvent(v);oSelf._moveSelection(nKeyCode);break;default:break;}};YAHOO.widget.AutoComplete.prototype._onTextboxKeyPress=function(v,oSelf){var nKeyCode=v.keyCode;if(YAHOO.env.ua.webkit){switch(nKeyCode){case 9:if(oSelf._oCurItem){if(oSelf.delimChar&&(oSelf._nKeyCode!=nKeyCode)){YAHOO.util.Event.stopEvent(v);}}
break;case 13:if(oSelf._oCurItem){if(oSelf._nKeyCode!=nKeyCode){if(oSelf._bContainerOpen){YAHOO.util.Event.stopEvent(v);}}
oSelf._selectItem(oSelf._oCurItem);}
else{oSelf._toggleContainer(false);}
break;default:break;}}
else if(nKeyCode==229){oSelf._queryInterval=setInterval(function(){oSelf._onIMEDetected(oSelf);},500);}};YAHOO.widget.AutoComplete.prototype._onTextboxKeyUp=function(v,oSelf){oSelf._initProps();var nKeyCode=v.keyCode;oSelf._nKeyCode=nKeyCode;var sText=this.value;if(oSelf._isIgnoreKey(nKeyCode)||(sText.toLowerCase()==oSelf._sCurQuery)){return;}
else{oSelf._bItemSelected=false;YAHOO.util.Dom.removeClass(oSelf._oCurItem,oSelf.highlightClassName);oSelf._oCurItem=null;oSelf.textboxKeyEvent.fire(oSelf,nKeyCode);}
if(oSelf.queryDelay>0){var nDelayID=setTimeout(function(){oSelf._sendQuery(sText);},(oSelf.queryDelay*1000));if(oSelf._nDelayID!=-1){clearTimeout(oSelf._nDelayID);}
oSelf._nDelayID=nDelayID;}
else{oSelf._sendQuery(sText);}};YAHOO.widget.AutoComplete.prototype._onTextboxFocus=function(v,oSelf){oSelf._elTextbox.setAttribute("autocomplete","off");oSelf._bFocused=true;if(!oSelf._bItemSelected){oSelf.textboxFocusEvent.fire(oSelf);}};YAHOO.widget.AutoComplete.prototype._onTextboxBlur=function(v,oSelf){if(!oSelf._bOverContainer||(oSelf._nKeyCode==9)){if(!oSelf._bItemSelected){var oMatch=oSelf._textMatchesOption();if(!oSelf._bContainerOpen||(oSelf._bContainerOpen&&(oMatch===null))){if(oSelf.forceSelection){oSelf._clearSelection();}
else{oSelf.unmatchedItemSelectEvent.fire(oSelf);}}
else{if(oSelf.forceSelection){oSelf._selectItem(oMatch);}}}
if(oSelf._bContainerOpen){oSelf._toggleContainer(false);}
oSelf._cancelIntervalDetection(oSelf);oSelf._bFocused=false;oSelf.textboxBlurEvent.fire(oSelf);}};YAHOO.widget.AutoComplete.prototype._onWindowUnload=function(v,oSelf){if(oSelf&&oSelf._elTextbox&&oSelf.allowBrowserAutocomplete){oSelf._elTextbox.setAttribute("autocomplete","on");}};YAHOO.widget.DataSource=function(){};YAHOO.widget.DataSource.ERROR_DATANULL="Response data was null";YAHOO.widget.DataSource.ERROR_DATAPARSE="Response data could not be parsed";YAHOO.widget.DataSource.prototype.maxCacheEntries=15;YAHOO.widget.DataSource.prototype.queryMatchContains=false;YAHOO.widget.DataSource.prototype.queryMatchSubset=false;YAHOO.widget.DataSource.prototype.queryMatchCase=false;YAHOO.widget.DataSource.prototype.toString=function(){return"DataSource "+this._sName;};YAHOO.widget.DataSource.prototype.getResults=function(oCallbackFn,sQuery,oParent){var aResults=this._doQueryCache(oCallbackFn,sQuery,oParent);if(aResults.length===0){this.queryEvent.fire(this,oParent,sQuery);this.doQuery(oCallbackFn,sQuery,oParent);}};YAHOO.widget.DataSource.prototype.doQuery=function(oCallbackFn,sQuery,oParent){};YAHOO.widget.DataSource.prototype.flushCache=function(){if(this._aCache){this._aCache=[];}
if(this._aCacheHelper){this._aCacheHelper=[];}
this.cacheFlushEvent.fire(this);};YAHOO.widget.DataSource.prototype.queryEvent=null;YAHOO.widget.DataSource.prototype.cacheQueryEvent=null;YAHOO.widget.DataSource.prototype.getResultsEvent=null;YAHOO.widget.DataSource.prototype.getCachedResultsEvent=null;YAHOO.widget.DataSource.prototype.dataErrorEvent=null;YAHOO.widget.DataSource.prototype.cacheFlushEvent=null;YAHOO.widget.DataSource._nIndex=0;YAHOO.widget.DataSource.prototype._sName=null;YAHOO.widget.DataSource.prototype._aCache=null;YAHOO.widget.DataSource.prototype._init=function(){var maxCacheEntries=this.maxCacheEntries;if(!YAHOO.lang.isNumber(maxCacheEntries)||(maxCacheEntries<0)){maxCacheEntries=0;}
if(maxCacheEntries>0&&!this._aCache){this._aCache=[];}
this._sName="instance"+YAHOO.widget.DataSource._nIndex;YAHOO.widget.DataSource._nIndex++;this.queryEvent=new YAHOO.util.CustomEvent("query",this);this.cacheQueryEvent=new YAHOO.util.CustomEvent("cacheQuery",this);this.getResultsEvent=new YAHOO.util.CustomEvent("getResults",this);this.getCachedResultsEvent=new YAHOO.util.CustomEvent("getCachedResults",this);this.dataErrorEvent=new YAHOO.util.CustomEvent("dataError",this);this.cacheFlushEvent=new YAHOO.util.CustomEvent("cacheFlush",this);};YAHOO.widget.DataSource.prototype._addCacheElem=function(oResult){var aCache=this._aCache;if(!aCache||!oResult||!oResult.query||!oResult.results){return;}
if(aCache.length>=this.maxCacheEntries){aCache.shift();}
aCache.push(oResult);};YAHOO.widget.DataSource.prototype._doQueryCache=function(oCallbackFn,sQuery,oParent){var aResults=[];var bMatchFound=false;var aCache=this._aCache;var nCacheLength=(aCache)?aCache.length:0;var bMatchContains=this.queryMatchContains;var sOrigQuery;if((this.maxCacheEntries>0)&&aCache&&(nCacheLength>0)){this.cacheQueryEvent.fire(this,oParent,sQuery);if(!this.queryMatchCase){sOrigQuery=sQuery;sQuery=sQuery.toLowerCase();}
for(var i=nCacheLength-1;i>=0;i--){var resultObj=aCache[i];var aAllResultItems=resultObj.results;var matchKey=(!this.queryMatchCase)?encodeURIComponent(resultObj.query).toLowerCase():encodeURIComponent(resultObj.query);if(matchKey==sQuery){bMatchFound=true;aResults=aAllResultItems;if(i!=nCacheLength-1){aCache.splice(i,1);this._addCacheElem(resultObj);}
break;}
else if(this.queryMatchSubset){for(var j=sQuery.length-1;j>=0;j--){var subQuery=sQuery.substr(0,j);if(matchKey==subQuery){bMatchFound=true;for(var k=aAllResultItems.length-1;k>=0;k--){var aRecord=aAllResultItems[k];var sKeyIndex=(this.queryMatchCase)?encodeURIComponent(aRecord[0]).indexOf(sQuery):encodeURIComponent(aRecord[0]).toLowerCase().indexOf(sQuery);if((!bMatchContains&&(sKeyIndex===0))||(bMatchContains&&(sKeyIndex>-1))){aResults.unshift(aRecord);}}
resultObj={};resultObj.query=sQuery;resultObj.results=aResults;this._addCacheElem(resultObj);break;}}
if(bMatchFound){break;}}}
if(bMatchFound){this.getCachedResultsEvent.fire(this,oParent,sOrigQuery,aResults);oCallbackFn(sOrigQuery,aResults,oParent);}}
return aResults;};YAHOO.widget.DS_XHR=function(sScriptURI,aSchema,oConfigs){if(oConfigs&&(oConfigs.constructor==Object)){for(var sConfig in oConfigs){this[sConfig]=oConfigs[sConfig];}}
if(!YAHOO.lang.isArray(aSchema)||!YAHOO.lang.isString(sScriptURI)){return;}
this.schema=aSchema;this.scriptURI=sScriptURI;this._init();};YAHOO.widget.DS_XHR.prototype=new YAHOO.widget.DataSource();YAHOO.widget.DS_XHR.TYPE_JSON=0;YAHOO.widget.DS_XHR.TYPE_XML=1;YAHOO.widget.DS_XHR.TYPE_FLAT=2;YAHOO.widget.DS_XHR.ERROR_DATAXHR="XHR response failed";YAHOO.widget.DS_XHR.prototype.connMgr=YAHOO.util.Connect;YAHOO.widget.DS_XHR.prototype.connTimeout=0;YAHOO.widget.DS_XHR.prototype.scriptURI=null;YAHOO.widget.DS_XHR.prototype.scriptQueryParam="query";YAHOO.widget.DS_XHR.prototype.scriptQueryAppend="";YAHOO.widget.DS_XHR.prototype.responseType=YAHOO.widget.DS_XHR.TYPE_JSON;YAHOO.widget.DS_XHR.prototype.responseStripAfter="\n<!-";YAHOO.widget.DS_XHR.prototype.doQuery=function(oCallbackFn,sQuery,oParent){var isXML=(this.responseType==YAHOO.widget.DS_XHR.TYPE_XML);var sUri=this.scriptURI+"?"+this.scriptQueryParam+"="+sQuery;if(this.scriptQueryAppend.length>0){sUri+="&"+this.scriptQueryAppend;}
var oResponse=null;var oSelf=this;var responseSuccess=function(oResp){if(!oSelf._oConn||(oResp.tId!=oSelf._oConn.tId)){oSelf.dataErrorEvent.fire(oSelf,oParent,sQuery,YAHOO.widget.DataSource.ERROR_DATANULL);return;}
for(var foo in oResp){}
if(!isXML){oResp=oResp.responseText;}
else{oResp=oResp.responseXML;}
if(oResp===null){oSelf.dataErrorEvent.fire(oSelf,oParent,sQuery,YAHOO.widget.DataSource.ERROR_DATANULL);return;}
var aResults=oSelf.parseResponse(sQuery,oResp,oParent);var resultObj={};resultObj.query=decodeURIComponent(sQuery);resultObj.results=aResults;if(aResults===null){oSelf.dataErrorEvent.fire(oSelf,oParent,sQuery,YAHOO.widget.DataSource.ERROR_DATAPARSE);aResults=[];}
else{oSelf.getResultsEvent.fire(oSelf,oParent,sQuery,aResults);oSelf._addCacheElem(resultObj);}
oCallbackFn(sQuery,aResults,oParent);};var responseFailure=function(oResp){oSelf.dataErrorEvent.fire(oSelf,oParent,sQuery,YAHOO.widget.DS_XHR.ERROR_DATAXHR);return;};var oCallback={success:responseSuccess,failure:responseFailure};if(YAHOO.lang.isNumber(this.connTimeout)&&(this.connTimeout>0)){oCallback.timeout=this.connTimeout;}
if(this._oConn){this.connMgr.abort(this._oConn);}
oSelf._oConn=this.connMgr.asyncRequest("GET",sUri,oCallback,null);};YAHOO.widget.DS_XHR.prototype.parseResponse=function(sQuery,oResponse,oParent){var aSchema=this.schema;var aResults=[];var bError=false;var nEnd=((this.responseStripAfter!=="")&&(oResponse.indexOf))?oResponse.indexOf(this.responseStripAfter):-1;if(nEnd!=-1){oResponse=oResponse.substring(0,nEnd);}
switch(this.responseType){case YAHOO.widget.DS_XHR.TYPE_JSON:var jsonList,jsonObjParsed;if(YAHOO.lang.JSON){jsonObjParsed=YAHOO.lang.JSON.parse(oResponse);if(!jsonObjParsed){bError=true;break;}
else{try{jsonList=eval("jsonObjParsed."+aSchema[0]);}
catch(e){bError=true;break;}}}
else if(oResponse.parseJSON){jsonObjParsed=oResponse.parseJSON();if(!jsonObjParsed){bError=true;}
else{try{jsonList=eval("jsonObjParsed."+aSchema[0]);}
catch(e){bError=true;break;}}}
else if(window.JSON){jsonObjParsed=JSON.parse(oResponse);if(!jsonObjParsed){bError=true;break;}
else{try{jsonList=eval("jsonObjParsed."+aSchema[0]);}
catch(e){bError=true;break;}}}
else{try{while(oResponse.substring(0,1)==" "){oResponse=oResponse.substring(1,oResponse.length);}
if(oResponse.indexOf("{")<0){bError=true;break;}
if(oResponse.indexOf("{}")===0){break;}
var jsonObjRaw=eval("("+oResponse+")");if(!jsonObjRaw){bError=true;break;}
jsonList=eval("(jsonObjRaw."+aSchema[0]+")");}
catch(e){bError=true;break;}}
if(!jsonList){bError=true;break;}
if(!YAHOO.lang.isArray(jsonList)){jsonList=[jsonList];}
for(var i=jsonList.length-1;i>=0;i--){var aResultItem=[];var jsonResult=jsonList[i];for(var j=aSchema.length-1;j>=1;j--){var dataFieldValue=jsonResult[aSchema[j]];if(!dataFieldValue){dataFieldValue="";}
aResultItem.unshift(dataFieldValue);}
if(aResultItem.length==1){aResultItem.push(jsonResult);}
aResults.unshift(aResultItem);}
break;case YAHOO.widget.DS_XHR.TYPE_XML:var xmlList=oResponse.getElementsByTagName(aSchema[0]);if(!xmlList){bError=true;break;}
for(var k=xmlList.length-1;k>=0;k--){var result=xmlList.item(k);var aFieldSet=[];for(var m=aSchema.length-1;m>=1;m--){var sValue=null;var xmlAttr=result.attributes.getNamedItem(aSchema[m]);if(xmlAttr){sValue=xmlAttr.value;}
else{var xmlNode=result.getElementsByTagName(aSchema[m]);if(xmlNode&&xmlNode.item(0)&&xmlNode.item(0).firstChild){sValue=xmlNode.item(0).firstChild.nodeValue;}
else{sValue="";}}
aFieldSet.unshift(sValue);}
aResults.unshift(aFieldSet);}
break;case YAHOO.widget.DS_XHR.TYPE_FLAT:if(oResponse.length>0){var newLength=oResponse.length-aSchema[0].length;if(oResponse.substr(newLength)==aSchema[0]){oResponse=oResponse.substr(0,newLength);}
var aRecords=oResponse.split(aSchema[0]);for(var n=aRecords.length-1;n>=0;n--){aResults[n]=aRecords[n].split(aSchema[1]);}}
break;default:break;}
sQuery=null;oResponse=null;oParent=null;if(bError){return null;}
else{return aResults;}};YAHOO.widget.DS_XHR.prototype._oConn=null;YAHOO.widget.DS_ScriptNode=function(sUri,aSchema,oConfigs){if(oConfigs&&(oConfigs.constructor==Object)){for(var sConfig in oConfigs){this[sConfig]=oConfigs[sConfig];}}
if(!YAHOO.lang.isArray(aSchema)||!YAHOO.lang.isString(sUri)){return;}
this.schema=aSchema;this.scriptURI=sUri;this._init();};YAHOO.widget.DS_ScriptNode.prototype=new YAHOO.widget.DataSource();YAHOO.widget.DS_ScriptNode.prototype.getUtility=YAHOO.util.Get;YAHOO.widget.DS_ScriptNode.prototype.scriptURI=null;YAHOO.widget.DS_ScriptNode.prototype.scriptQueryParam="query";YAHOO.widget.DS_ScriptNode.prototype.asyncMode="allowAll";YAHOO.widget.DS_ScriptNode.prototype.scriptCallbackParam="callback";YAHOO.widget.DS_ScriptNode.callbacks=[];YAHOO.widget.DS_ScriptNode._nId=0;YAHOO.widget.DS_ScriptNode._nPending=0;YAHOO.widget.DS_ScriptNode.prototype.doQuery=function(oCallbackFn,sQuery,oParent){var oSelf=this;if(YAHOO.widget.DS_ScriptNode._nPending===0){YAHOO.widget.DS_ScriptNode.callbacks=[];YAHOO.widget.DS_ScriptNode._nId=0;}
var id=YAHOO.widget.DS_ScriptNode._nId;YAHOO.widget.DS_ScriptNode._nId++;YAHOO.widget.DS_ScriptNode.callbacks[id]=function(oResponse){if((oSelf.asyncMode!=="ignoreStaleResponses")||(id===YAHOO.widget.DS_ScriptNode.callbacks.length-1)){oSelf.handleResponse(oResponse,oCallbackFn,sQuery,oParent);}
else{}
delete YAHOO.widget.DS_ScriptNode.callbacks[id];};YAHOO.widget.DS_ScriptNode._nPending++;var sUri=this.scriptURI+"&"+this.scriptQueryParam+"="+sQuery+"&"+
this.scriptCallbackParam+"=YAHOO.widget.DS_ScriptNode.callbacks["+id+"]";this.getUtility.script(sUri,{autopurge:true,onsuccess:YAHOO.widget.DS_ScriptNode._bumpPendingDown,onfail:YAHOO.widget.DS_ScriptNode._bumpPendingDown});};YAHOO.widget.DS_ScriptNode.prototype.handleResponse=function(oResponse,oCallbackFn,sQuery,oParent){var aSchema=this.schema;var aResults=[];var bError=false;var jsonList,jsonObjParsed;try{jsonList=eval("(oResponse."+aSchema[0]+")");}
catch(e){bError=true;}
if(!jsonList){bError=true;jsonList=[];}
else if(!YAHOO.lang.isArray(jsonList)){jsonList=[jsonList];}
for(var i=jsonList.length-1;i>=0;i--){var aResultItem=[];var jsonResult=jsonList[i];for(var j=aSchema.length-1;j>=1;j--){var dataFieldValue=jsonResult[aSchema[j]];if(!dataFieldValue){dataFieldValue="";}
aResultItem.unshift(dataFieldValue);}
if(aResultItem.length==1){aResultItem.push(jsonResult);}
aResults.unshift(aResultItem);}
if(bError){aResults=null;}
if(aResults===null){this.dataErrorEvent.fire(this,oParent,sQuery,YAHOO.widget.DataSource.ERROR_DATAPARSE);aResults=[];}
else{var resultObj={};resultObj.query=decodeURIComponent(sQuery);resultObj.results=aResults;this._addCacheElem(resultObj);this.getResultsEvent.fire(this,oParent,sQuery,aResults);}
oCallbackFn(sQuery,aResults,oParent);};YAHOO.widget.DS_ScriptNode._bumpPendingDown=function(){YAHOO.widget.DS_ScriptNode._nPending--;};YAHOO.widget.DS_JSFunction=function(oFunction,oConfigs){if(oConfigs&&(oConfigs.constructor==Object)){for(var sConfig in oConfigs){this[sConfig]=oConfigs[sConfig];}}
if(!YAHOO.lang.isFunction(oFunction)){return;}
else{this.dataFunction=oFunction;this._init();}};YAHOO.widget.DS_JSFunction.prototype=new YAHOO.widget.DataSource();YAHOO.widget.DS_JSFunction.prototype.dataFunction=null;YAHOO.widget.DS_JSFunction.prototype.doQuery=function(oCallbackFn,sQuery,oParent){var oFunction=this.dataFunction;var aResults=[];aResults=oFunction(sQuery);if(aResults===null){this.dataErrorEvent.fire(this,oParent,sQuery,YAHOO.widget.DataSource.ERROR_DATANULL);return;}
var resultObj={};resultObj.query=decodeURIComponent(sQuery);resultObj.results=aResults;this._addCacheElem(resultObj);this.getResultsEvent.fire(this,oParent,sQuery,aResults);oCallbackFn(sQuery,aResults,oParent);return;};YAHOO.widget.DS_JSArray=function(aData,oConfigs){if(oConfigs&&(oConfigs.constructor==Object)){for(var sConfig in oConfigs){this[sConfig]=oConfigs[sConfig];}}
if(!YAHOO.lang.isArray(aData)){return;}
else{this.data=aData;this._init();}};YAHOO.widget.DS_JSArray.prototype=new YAHOO.widget.DataSource();YAHOO.widget.DS_JSArray.prototype.data=null;YAHOO.widget.DS_JSArray.prototype.doQuery=function(oCallbackFn,sQuery,oParent){var i;var aData=this.data;var aResults=[];var bMatchFound=false;var bMatchContains=this.queryMatchContains;if(sQuery){if(!this.queryMatchCase){sQuery=sQuery.toLowerCase();}
for(i=aData.length-1;i>=0;i--){var aDataset=[];if(YAHOO.lang.isString(aData[i])){aDataset[0]=aData[i];}
else if(YAHOO.lang.isArray(aData[i])){aDataset=aData[i];}
if(YAHOO.lang.isString(aDataset[0])){var sKeyIndex=(this.queryMatchCase)?encodeURIComponent(aDataset[0]).indexOf(sQuery):encodeURIComponent(aDataset[0]).toLowerCase().indexOf(sQuery);if((!bMatchContains&&(sKeyIndex===0))||(bMatchContains&&(sKeyIndex>-1))){aResults.unshift(aDataset);}}}}
else{for(i=aData.length-1;i>=0;i--){if(YAHOO.lang.isString(aData[i])){aResults.unshift([aData[i]]);}
else if(YAHOO.lang.isArray(aData[i])){aResults.unshift(aData[i]);}}}
this.getResultsEvent.fire(this,oParent,sQuery,aResults);oCallbackFn(sQuery,aResults,oParent);};YAHOO.register("autocomplete",YAHOO.widget.AutoComplete,{version:"2.5.1",build:"984"});CLIPTOO.Sorting=(function(onChangeSortingType,onChangeSortingDirection,sortTypeValue,sortDirectionValue){var sortType=Dom.get("sortType");var sortDirection=Dom.get("sortDirection");var sortTypeArray=["mostRecent","mostRated","mostPopular"];var sortDirectionArray=["asc","desc"];var msgSorting=PoiMsg.js_msg.sorting;var sortTypeTitleArray=[msgSorting.date(),msgSorting.rating(),msgSorting.popularity()];var indexOf=function(array,obj){for(var i=0;i<array.length;i++){if(array[i]==obj){return i;}}
return-1;}
if(!sortTypeValue||indexOf(sortTypeArray,sortTypeValue)==-1){sortType.value=GlobalProperties.DEFAULT_SORTING_TYPE;}else{sortType.value=sortTypeValue;}
if(!sortDirectionValue||indexOf(sortDirectionArray,sortDirectionValue)==-1){sortDirection.value=GlobalProperties.DEFAULT_SORTING_DIRECTION;}else{sortDirection.value=sortDirectionValue;}
var sortTypeMenuRedraw=function(){var sortIndex=indexOf(sortTypeArray,sortType.value);Dom.get("pois_list_sorting_type").innerHTML=sortTypeTitleArray[sortIndex];checkPoisListSortingMenuItem(sortIndex);}
var sortPoisList=function(sortIndex){sortType.value=sortTypeArray[sortIndex];sortTypeMenuRedraw();if(!!onChangeSortingType){onChangeSortingType();}}
var poisListSortingMenu=new YAHOO.widget.Menu("sorting_menu",{position:"dynamic"});poisListSortingMenu.addItems([{text:sortTypeTitleArray[0],onclick:{fn:function(){sortPoisList(0);}},checked:true},{text:sortTypeTitleArray[1],onclick:{fn:function(){sortPoisList(1);}}},{text:sortTypeTitleArray[2],onclick:{fn:function(){sortPoisList(2);}}}]);poisListSortingMenu.render('pois_list_sorting_menu_holder');var checkPoisListSortingMenuItem=function(number){var items=poisListSortingMenu.getItems()
for(var index=0;index<items.length;index++){items[index].cfg.setProperty("checked",false);}
poisListSortingMenu.getItem(number,0).cfg.setProperty("checked",true);};var sortingIcon=Dom.get("pois_list_sorting_icon");sortingIcon.popupStatus=false;sortingIcon.iconStatus=false;var sortingIconClickListener=function(){sortingIcon.iconStatus=!sortingIcon.iconStatus;if(sortingIcon.popupStatus){sortingIcon.popupStatus=false;}else{if(sortingIcon.iconStatus){poisListSortingMenu.cfg.setProperty("context",["pois_list_sorting_menu","tl","bl"]);poisListSortingMenu.show();sortingIcon.popupStatus=true;}}};var sortingIconMouseOverListener=function(){var sortingMenuDiv=document.getElementById("sorting_menu");if(sortingMenuDiv.style.visibility=="visible"){sortingIcon.iconStatus=true;}else{sortingIcon.iconStatus=false;}}
var beforeHide=function(e){sortingIcon.popupStatus=false;};poisListSortingMenu.beforeHideEvent.subscribe(beforeHide);Event.addListener(sortingIcon,"click",sortingIconClickListener);Event.addListener(sortingIcon,"mouseover",sortingIconMouseOverListener);var sortingDirectionIcon=Dom.get("pois_list_sorting_direction_icon");var redrawSortingDirectionIcon=function(){if(sortDirection.value=="desc"){sortingDirectionIcon.className="pois_list_sorting_desc_icon";sortingDirectionIcon.title=PoiMsg.js_msg.sorting.desc();}
else{sortingDirectionIcon.className="pois_list_sorting_asc_icon";sortingDirectionIcon.title=PoiMsg.js_msg.sorting.asc();}}
var onChangeSortingDirectionListener=function(){if(sortingDirectionIcon.className=="pois_list_sorting_asc_icon"){sortDirection.value="desc";}else{sortDirection.value="asc";}
redrawSortingDirectionIcon();if(!!onChangeSortingDirection){onChangeSortingDirection();}};Event.addListener(sortingDirectionIcon,"click",onChangeSortingDirectionListener);sortTypeMenuRedraw();redrawSortingDirectionIcon();var getSortingType=function(){return sortType.value;}
var getSortingDirection=function(){return sortDirection.value;}
var getParametersList=function(){return"sortType="+getSortingType()+"&sortDirection="+getSortingDirection();}
var isAscSortingDirection=function(){return(sortDirection.value=="asc");}
var isDescSortingDirection=function(){return(sortDirection.value=="desc");}
var isMostRecentSotringType=function(){return(sortType.value=="mostRecent")}
var isMostRatedSotringType=function(){return(sortType.value=="mostRated")}
var isMostPopularSotringType=function(){return(sortType.value=="mostPopular")}
var show=function(){Dom.get("pois_list_sorting").style.display="";}
var hide=function(){Dom.get("pois_list_sorting").style.display="none";}
var _public={getParametersList:getParametersList,getSortingType:getSortingType,getSortingDirection:getSortingDirection,isAscSortingDirection:isAscSortingDirection,isDescSortingDirection:isDescSortingDirection,isMostRecentSotringType:isMostRecentSotringType,isMostRatedSotringType:isMostRatedSotringType,isMostPopularSotringType:isMostPopularSotringType,show:show,hide:hide};return _public;});CLIPTOO.InputPromptProvider=(function(element,defaultText,enableStyleFunction,disableStyleFunction){var valueAdapter={getValue:function(){return element.value;},setValue:function(value){element.value=value;},getDefaultText:function(){if(!defaultText){return element.defaultValue;}else{return defaultText;}},getElement:function(){return element;}}
return CLIPTOO.InputPromptProviderBasic(valueAdapter,enableStyleFunction,disableStyleFunction);});CLIPTOO.InputPromptProviderBasic=(function(valueAdapter,enableStyleFunction,disableStyleFunction){var element=valueAdapter.getElement();var defaultValue=valueAdapter.getDefaultText();var someEntered=function(){return(!isEmpty()&&valueAdapter.getValue()!='');}
var isEmpty=function(){return(valueAdapter.getValue()==defaultValue);}
var onElementBlur=function(event){setDefaultIfEmpty();if(!!_public.onBlur){_public.onBlur(event);}}
var setDefaultIfEmpty=function(){if(!someEntered()){setDefaultValue();}}
var setDefaultValue=function(){if(disableStyleFunction){disableStyleFunction(element);}
valueAdapter.setValue(defaultValue);}
var clear=function(){valueAdapter.setValue('');if(enableStyleFunction){enableStyleFunction(element);}}
var getValue=function(){return(isEmpty())?'':valueAdapter.getValue();}
var onElementFocus=function(){if(isEmpty()){clear();}}
var onElementKeyUp=function(event){if(event.keyCode==27){onElementFocus();}
if(isEmpty){if(enableStyleFunction){enableStyleFunction(element);}}else{if(disableStyleFunction){disableStyleFunction(element);}}
if(!!_public.onKeyUp){_public.onKeyUp(event);}}
var setValue=function(value){enableStyleFunction(element);valueAdapter.setValue(value);}
Event.addListener(element,'blur',onElementBlur);Event.addListener(element,'focus',onElementFocus);Event.addListener(element,'keyup',onElementKeyUp);setDefaultIfEmpty();var _public={clear:clear,setDefaultValue:setDefaultValue,someEntered:someEntered,getValue:getValue,setValue:setValue,isEmpty:isEmpty,onKeyUp:null,onBlur:null};return _public;});CLIPTOO.Filter=(function(onFilterAction,config){var searchField=config.inputSearchField;var resetButton=config.inputResetButton;var filterContainer=config.inputFilterContainer;var setFocus=function(){searchField.focus();}
var setSearchValue=function(value){autoFill.setValue(value)
hideResetButton();}
var onSearchKeyUp=function(event){if(event.keyCode==27){onResetClick();}else if(event.keyCode==13){callExternallActions();}else{synchroDisableButton();}}
var synchroDisableButton=function(){if(autoFill.someEntered()){showResetButton();}else{hideResetButton();}}
var onResetClick=function(event){hideResetButton();autoFill.clear();setFocus();callExternallActions(event);}
var callExternallActions=function(event){if(_public.onFilterAction){_public.onFilterAction(event);}}
var show=function(){filterContainer.style.display='';}
var hide=function(){filterContainer.style.display='none';autoFill.setDefaultValue();hideResetButton();}
var showResetButton=function(){resetButton.style.display='block';}
var hideResetButton=function(){resetButton.style.display='none';}
var setSerchFieldEditableStyle=function(element){element.className='builtin-title builtin-title-active';}
var setSerchFieldDisableStyle=function(element){element.className='builtin-title';}
var getParametersList=function(){return'poiNameFilter='+autoFill.getValue();}
var autoFill=CLIPTOO.InputPromptProvider(searchField,null,setSerchFieldEditableStyle,setSerchFieldDisableStyle);autoFill.onKeyUp=onSearchKeyUp;autoFill.onBlur=synchroDisableButton;var _public={onFilterAction:null,getSearchValue:autoFill.getValue,setFocus:setFocus,setSearchValue:setSearchValue,someEntered:autoFill.someEntered,isEmpty:autoFill.isEmpty,hide:hide,show:show,getParametersList:getParametersList,setDefaultValueToField:autoFill.setDefaultValue}
if(onFilterAction){_public.onFilterAction=onFilterAction;}
Event.addListener(resetButton,'click',onResetClick);return _public;});(function(){var Dom=YAHOO.util.Dom,Event=YAHOO.util.Event,Lang=YAHOO.lang;if(YAHOO.widget.Button){YAHOO.widget.ToolbarButtonAdvanced=YAHOO.widget.Button;YAHOO.widget.ToolbarButtonAdvanced.prototype.buttonType='rich';YAHOO.widget.ToolbarButtonAdvanced.prototype.checkValue=function(value){var _menuItems=this.getMenu().getItems();if(_menuItems.length===0){this.getMenu()._onBeforeShow();_menuItems=this.getMenu().getItems();}
for(var i=0;i<_menuItems.length;i++){_menuItems[i].cfg.setProperty('checked',false);if(_menuItems[i].value==value){_menuItems[i].cfg.setProperty('checked',true);}}};}else{YAHOO.widget.ToolbarButtonAdvanced=function(){};}
YAHOO.widget.ToolbarButton=function(el,attrs){if(Lang.isObject(arguments[0])&&!Dom.get(el).nodeType){attrs=el;}
var local_attrs=(attrs||{});var oConfig={element:null,attributes:local_attrs};if(!oConfig.attributes.type){oConfig.attributes.type='push';}
oConfig.element=document.createElement('span');oConfig.element.setAttribute('unselectable','on');oConfig.element.className='yui-button yui-'+oConfig.attributes.type+'-button';oConfig.element.innerHTML='<span class="first-child"><a href="#">LABEL</a></span>';oConfig.element.firstChild.firstChild.tabIndex='-1';oConfig.attributes.id=Dom.generateId();YAHOO.widget.ToolbarButton.superclass.constructor.call(this,oConfig.element,oConfig.attributes);};YAHOO.extend(YAHOO.widget.ToolbarButton,YAHOO.util.Element,{buttonType:'normal',_handleMouseOver:function(){if(!this.get('disabled')){this.addClass('yui-button-hover');this.addClass('yui-'+this.get('type')+'-button-hover');}},_handleMouseOut:function(){this.removeClass('yui-button-hover');this.removeClass('yui-'+this.get('type')+'-button-hover');},checkValue:function(value){if(this.get('type')=='menu'){var opts=this._button.options;for(var i=0;i<opts.length;i++){if(opts[i].value==value){opts.selectedIndex=i;}}}},init:function(p_oElement,p_oAttributes){YAHOO.widget.ToolbarButton.superclass.init.call(this,p_oElement,p_oAttributes);this.on('mouseover',this._handleMouseOver,this,true);this.on('mouseout',this._handleMouseOut,this,true);},initAttributes:function(attr){YAHOO.widget.ToolbarButton.superclass.initAttributes.call(this,attr);this.setAttributeConfig('value',{value:attr.value});this.setAttributeConfig('menu',{value:attr.menu||false});this.setAttributeConfig('type',{value:attr.type,writeOnce:true,method:function(type){var el,opt;if(!this._button){this._button=this.get('element').getElementsByTagName('a')[0];}
switch(type){case'select':case'menu':el=document.createElement('select');var menu=this.get('menu');for(var i=0;i<menu.length;i++){opt=document.createElement('option');opt.innerHTML=menu[i].text;opt.value=menu[i].value;if(menu[i].checked){opt.selected=true;}
el.appendChild(opt);}
this._button.parentNode.replaceChild(el,this._button);Event.on(el,'change',this._handleSelect,this,true);this._button=el;break;}}});this.setAttributeConfig('disabled',{value:attr.disabled||false,method:function(disabled){if(disabled){this.addClass('yui-button-disabled');this.addClass('yui-'+this.get('type')+'-button-disabled');}else{this.removeClass('yui-button-disabled');this.removeClass('yui-'+this.get('type')+'-button-disabled');}
if(this.get('type')=='menu'){this._button.disabled=disabled;}}});this.setAttributeConfig('label',{value:attr.label,method:function(label){if(!this._button){this._button=this.get('element').getElementsByTagName('a')[0];}
if(this.get('type')=='push'){this._button.innerHTML=label;}}});this.setAttributeConfig('title',{value:attr.title});this.setAttributeConfig('container',{value:null,writeOnce:true,method:function(cont){this.appendTo(cont);}});},_handleSelect:function(ev){var tar=Event.getTarget(ev);var value=tar.options[tar.selectedIndex].value;this.fireEvent('change',{type:'change',value:value});},getMenu:function(){return this.get('menu');},destroy:function(){Event.purgeElement(this.get('element'),true);this.get('element').parentNode.removeChild(this.get('element'));for(var i in this){if(Lang.hasOwnProperty(this,i)){this[i]=null;}}},fireEvent:function(p_sType,p_aArgs){if(this.DOM_EVENTS[p_sType]&&this.get('disabled')){return;}
YAHOO.widget.ToolbarButton.superclass.fireEvent.call(this,p_sType,p_aArgs);},toString:function(){return'ToolbarButton ('+this.get('id')+')';}});})();(function(){var Dom=YAHOO.util.Dom,Event=YAHOO.util.Event,Lang=YAHOO.lang;var getButton=function(id){var button=id;if(Lang.isString(id)){button=this.getButtonById(id);}
if(Lang.isNumber(id)){button=this.getButtonByIndex(id);}
if((!(button instanceof YAHOO.widget.ToolbarButton))&&(!(button instanceof YAHOO.widget.ToolbarButtonAdvanced))){button=this.getButtonByValue(id);}
if((button instanceof YAHOO.widget.ToolbarButton)||(button instanceof YAHOO.widget.ToolbarButtonAdvanced)){return button;}
return false;};YAHOO.widget.Toolbar=function(el,attrs){if(Lang.isObject(arguments[0])&&!Dom.get(el).nodeType){attrs=el;}
var local_attrs={};if(attrs){Lang.augmentObject(local_attrs,attrs);}
var oConfig={element:null,attributes:local_attrs};if(Lang.isString(el)&&Dom.get(el)){oConfig.element=Dom.get(el);}else if(Lang.isObject(el)&&Dom.get(el)&&Dom.get(el).nodeType){oConfig.element=Dom.get(el);}
if(!oConfig.element){oConfig.element=document.createElement('DIV');oConfig.element.id=Dom.generateId();if(local_attrs.container&&Dom.get(local_attrs.container)){Dom.get(local_attrs.container).appendChild(oConfig.element);}}
if(!oConfig.element.id){oConfig.element.id=((Lang.isString(el))?el:Dom.generateId());}
var fs=document.createElement('fieldset');var lg=document.createElement('legend');lg.innerHTML='Toolbar';fs.appendChild(lg);var cont=document.createElement('DIV');oConfig.attributes.cont=cont;Dom.addClass(cont,'yui-toolbar-subcont');fs.appendChild(cont);oConfig.element.appendChild(fs);oConfig.element.tabIndex=-1;oConfig.attributes.element=oConfig.element;oConfig.attributes.id=oConfig.element.id;YAHOO.widget.Toolbar.superclass.constructor.call(this,oConfig.element,oConfig.attributes);};YAHOO.extend(YAHOO.widget.Toolbar,YAHOO.util.Element,{_addMenuClasses:function(ev,na,o){Dom.addClass(this.element,'yui-toolbar-'+o.get('value')+'-menu');if(Dom.hasClass(o._button.parentNode.parentNode,'yui-toolbar-select')){Dom.addClass(this.element,'yui-toolbar-select-menu');}
var items=this.getItems();for(var i=0;i<items.length;i++){Dom.addClass(items[i].element,'yui-toolbar-'+o.get('value')+'-'+((items[i].value)?items[i].value.replace(/ /g,'-').toLowerCase():items[i]._oText.nodeValue.replace(/ /g,'-').toLowerCase()));Dom.addClass(items[i].element,'yui-toolbar-'+o.get('value')+'-'+((items[i].value)?items[i].value.replace(/ /g,'-'):items[i]._oText.nodeValue.replace(/ /g,'-')));}},buttonType:YAHOO.widget.ToolbarButton,dd:null,_colorData:{'#111111':'Obsidian','#2D2D2D':'Dark Gray','#434343':'Shale','#5B5B5B':'Flint','#737373':'Gray','#8B8B8B':'Concrete','#A2A2A2':'Gray','#B9B9B9':'Titanium','#000000':'Black','#D0D0D0':'Light Gray','#E6E6E6':'Silver','#FFFFFF':'White','#BFBF00':'Pumpkin','#FFFF00':'Yellow','#FFFF40':'Banana','#FFFF80':'Pale Yellow','#FFFFBF':'Butter','#525330':'Raw Siena','#898A49':'Mildew','#AEA945':'Olive','#7F7F00':'Paprika','#C3BE71':'Earth','#E0DCAA':'Khaki','#FCFAE1':'Cream','#60BF00':'Cactus','#80FF00':'Chartreuse','#A0FF40':'Green','#C0FF80':'Pale Lime','#DFFFBF':'Light Mint','#3B5738':'Green','#668F5A':'Lime Gray','#7F9757':'Yellow','#407F00':'Clover','#8A9B55':'Pistachio','#B7C296':'Light Jade','#E6EBD5':'Breakwater','#00BF00':'Spring Frost','#00FF80':'Pastel Green','#40FFA0':'Light Emerald','#80FFC0':'Sea Foam','#BFFFDF':'Sea Mist','#033D21':'Dark Forrest','#438059':'Moss','#7FA37C':'Medium Green','#007F40':'Pine','#8DAE94':'Yellow Gray Green','#ACC6B5':'Aqua Lung','#DDEBE2':'Sea Vapor','#00BFBF':'Fog','#00FFFF':'Cyan','#40FFFF':'Turquoise Blue','#80FFFF':'Light Aqua','#BFFFFF':'Pale Cyan','#033D3D':'Dark Teal','#347D7E':'Gray Turquoise','#609A9F':'Green Blue','#007F7F':'Seaweed','#96BDC4':'Green Gray','#B5D1D7':'Soapstone','#E2F1F4':'Light Turquoise','#0060BF':'Summer Sky','#0080FF':'Sky Blue','#40A0FF':'Electric Blue','#80C0FF':'Light Azure','#BFDFFF':'Ice Blue','#1B2C48':'Navy','#385376':'Biscay','#57708F':'Dusty Blue','#00407F':'Sea Blue','#7792AC':'Sky Blue Gray','#A8BED1':'Morning Sky','#DEEBF6':'Vapor','#0000BF':'Deep Blue','#0000FF':'Blue','#4040FF':'Cerulean Blue','#8080FF':'Evening Blue','#BFBFFF':'Light Blue','#212143':'Deep Indigo','#373E68':'Sea Blue','#444F75':'Night Blue','#00007F':'Indigo Blue','#585E82':'Dockside','#8687A4':'Blue Gray','#D2D1E1':'Light Blue Gray','#6000BF':'Neon Violet','#8000FF':'Blue Violet','#A040FF':'Violet Purple','#C080FF':'Violet Dusk','#DFBFFF':'Pale Lavender','#302449':'Cool Shale','#54466F':'Dark Indigo','#655A7F':'Dark Violet','#40007F':'Violet','#726284':'Smoky Violet','#9E8FA9':'Slate Gray','#DCD1DF':'Violet White','#BF00BF':'Royal Violet','#FF00FF':'Fuchsia','#FF40FF':'Magenta','#FF80FF':'Orchid','#FFBFFF':'Pale Magenta','#4A234A':'Dark Purple','#794A72':'Medium Purple','#936386':'Cool Granite','#7F007F':'Purple','#9D7292':'Purple Moon','#C0A0B6':'Pale Purple','#ECDAE5':'Pink Cloud','#BF005F':'Hot Pink','#FF007F':'Deep Pink','#FF409F':'Grape','#FF80BF':'Electric Pink','#FFBFDF':'Pink','#451528':'Purple Red','#823857':'Purple Dino','#A94A76':'Purple Gray','#7F003F':'Rose','#BC6F95':'Antique Mauve','#D8A5BB':'Cool Marble','#F7DDE9':'Pink Granite','#C00000':'Apple','#FF0000':'Fire Truck','#FF4040':'Pale Red','#FF8080':'Salmon','#FFC0C0':'Warm Pink','#441415':'Sepia','#82393C':'Rust','#AA4D4E':'Brick','#800000':'Brick Red','#BC6E6E':'Mauve','#D8A3A4':'Shrimp Pink','#F8DDDD':'Shell Pink','#BF5F00':'Dark Orange','#FF7F00':'Orange','#FF9F40':'Grapefruit','#FFBF80':'Canteloupe','#FFDFBF':'Wax','#482C1B':'Dark Brick','#855A40':'Dirt','#B27C51':'Tan','#7F3F00':'Nutmeg','#C49B71':'Mustard','#E1C4A8':'Pale Tan','#FDEEE0':'Marble'},_colorPicker:null,STR_COLLAPSE:'Collapse Toolbar',STR_SPIN_LABEL:'Spin Button with value {VALUE}. Use Control Shift Up Arrow and Control Shift Down arrow keys to increase or decrease the value.',STR_SPIN_UP:'Click to increase the value of this input',STR_SPIN_DOWN:'Click to decrease the value of this input',_titlebar:null,browser:YAHOO.env.ua,_buttonList:null,_buttonGroupList:null,_sep:null,_sepCount:null,_dragHandle:null,_toolbarConfigs:{renderer:true},CLASS_CONTAINER:'yui-toolbar-container',CLASS_DRAGHANDLE:'yui-toolbar-draghandle',CLASS_SEPARATOR:'yui-toolbar-separator',CLASS_DISABLED:'yui-toolbar-disabled',CLASS_PREFIX:'yui-toolbar',init:function(p_oElement,p_oAttributes){YAHOO.widget.Toolbar.superclass.init.call(this,p_oElement,p_oAttributes);},initAttributes:function(attr){YAHOO.widget.Toolbar.superclass.initAttributes.call(this,attr);this.addClass(this.CLASS_CONTAINER);this.setAttributeConfig('buttonType',{value:attr.buttonType||'basic',writeOnce:true,validator:function(type){switch(type){case'advanced':case'basic':return true;}
return false;},method:function(type){if(type=='advanced'){if(YAHOO.widget.Button){this.buttonType=YAHOO.widget.ToolbarButtonAdvanced;}else{this.buttonType=YAHOO.widget.ToolbarButton;}}else{this.buttonType=YAHOO.widget.ToolbarButton;}}});this.setAttributeConfig('buttons',{value:[],writeOnce:true,method:function(data){for(var i in data){if(Lang.hasOwnProperty(data,i)){if(data[i].type=='separator'){this.addSeparator();}else if(data[i].group!==undefined){this.addButtonGroup(data[i]);}else{this.addButton(data[i]);}}}}});this.setAttributeConfig('disabled',{value:false,method:function(disabled){if(this.get('disabled')===disabled){return false;}
if(disabled){this.addClass(this.CLASS_DISABLED);this.set('draggable',false);this.disableAllButtons();}else{this.removeClass(this.CLASS_DISABLED);if(this._configs.draggable._initialConfig.value){this.set('draggable',true);}
this.resetAllButtons();}}});this.setAttributeConfig('cont',{value:attr.cont,readOnly:true});this.setAttributeConfig('grouplabels',{value:((attr.grouplabels===false)?false:true),method:function(grouplabels){if(grouplabels){Dom.removeClass(this.get('cont'),(this.CLASS_PREFIX+'-nogrouplabels'));}else{Dom.addClass(this.get('cont'),(this.CLASS_PREFIX+'-nogrouplabels'));}}});this.setAttributeConfig('titlebar',{value:false,method:function(titlebar){if(titlebar){if(this._titlebar&&this._titlebar.parentNode){this._titlebar.parentNode.removeChild(this._titlebar);}
this._titlebar=document.createElement('DIV');this._titlebar.tabIndex='-1';Event.on(this._titlebar,'focus',function(){this._handleFocus();},this,true);Dom.addClass(this._titlebar,this.CLASS_PREFIX+'-titlebar');if(Lang.isString(titlebar)){var h2=document.createElement('h2');h2.tabIndex='-1';h2.innerHTML='<a href="#" tabIndex="0">'+titlebar+'</a>';this._titlebar.appendChild(h2);Event.on(h2.firstChild,'click',function(ev){Event.stopEvent(ev);});Event.on([h2,h2.firstChild],'focus',function(){this._handleFocus();},this,true);}
if(this.get('firstChild')){this.insertBefore(this._titlebar,this.get('firstChild'));}else{this.appendChild(this._titlebar);}
if(this.get('collapse')){this.set('collapse',true);}}else if(this._titlebar){if(this._titlebar&&this._titlebar.parentNode){this._titlebar.parentNode.removeChild(this._titlebar);}}}});this.setAttributeConfig('collapse',{value:false,method:function(collapse){if(this._titlebar){var collapseEl=null;var el=Dom.getElementsByClassName('collapse','span',this._titlebar);if(collapse){if(el.length>0){return true;}
collapseEl=document.createElement('SPAN');collapseEl.innerHTML='X';collapseEl.title=this.STR_COLLAPSE;Dom.addClass(collapseEl,'collapse');this._titlebar.appendChild(collapseEl);Event.addListener(collapseEl,'click',function(){if(Dom.hasClass(this.get('cont').parentNode,'yui-toolbar-container-collapsed')){this.collapse(false);}else{this.collapse();}},this,true);}else{collapseEl=Dom.getElementsByClassName('collapse','span',this._titlebar);if(collapseEl[0]){if(Dom.hasClass(this.get('cont').parentNode,'yui-toolbar-container-collapsed')){this.collapse(false);}
collapseEl[0].parentNode.removeChild(collapseEl[0]);}}}}});this.setAttributeConfig('draggable',{value:(attr.draggable||false),method:function(draggable){if(draggable&&!this.get('titlebar')){if(!this._dragHandle){this._dragHandle=document.createElement('SPAN');this._dragHandle.innerHTML='|';this._dragHandle.setAttribute('title','Click to drag the toolbar');this._dragHandle.id=this.get('id')+'_draghandle';Dom.addClass(this._dragHandle,this.CLASS_DRAGHANDLE);if(this.get('cont').hasChildNodes()){this.get('cont').insertBefore(this._dragHandle,this.get('cont').firstChild);}else{this.get('cont').appendChild(this._dragHandle);}
this.dd=new YAHOO.util.DD(this.get('id'));this.dd.setHandleElId(this._dragHandle.id);}}else{if(this._dragHandle){this._dragHandle.parentNode.removeChild(this._dragHandle);this._dragHandle=null;this.dd=null;}}
if(this._titlebar){if(draggable){this.dd=new YAHOO.util.DD(this.get('id'));this.dd.setHandleElId(this._titlebar);Dom.addClass(this._titlebar,'draggable');}else{Dom.removeClass(this._titlebar,'draggable');if(this.dd){this.dd.unreg();this.dd=null;}}}},validator:function(value){var ret=true;if(!YAHOO.util.DD){ret=false;}
return ret;}});},addButtonGroup:function(oGroup){if(!this.get('element')){this._queue[this._queue.length]=['addButtonGroup',arguments];return false;}
if(!this.hasClass(this.CLASS_PREFIX+'-grouped')){this.addClass(this.CLASS_PREFIX+'-grouped');}
var div=document.createElement('DIV');Dom.addClass(div,this.CLASS_PREFIX+'-group');Dom.addClass(div,this.CLASS_PREFIX+'-group-'+oGroup.group);if(oGroup.label){var label=document.createElement('h3');label.innerHTML=oGroup.label;div.appendChild(label);}
if(!this.get('grouplabels')){Dom.addClass(this.get('cont'),this.CLASS_PREFIX,'-nogrouplabels');}
this.get('cont').appendChild(div);var ul=document.createElement('ul');div.appendChild(ul);if(!this._buttonGroupList){this._buttonGroupList={};}
this._buttonGroupList[oGroup.group]=ul;for(var i=0;i<oGroup.buttons.length;i++){var li=document.createElement('li');li.className=this.CLASS_PREFIX+'-groupitem';ul.appendChild(li);if((oGroup.buttons[i].type!==undefined)&&oGroup.buttons[i].type=='separator'){this.addSeparator(li);}else{oGroup.buttons[i].container=li;this.addButton(oGroup.buttons[i]);}}},addButtonToGroup:function(oButton,group,after){var groupCont=this._buttonGroupList[group];var li=document.createElement('li');li.className=this.CLASS_PREFIX+'-groupitem';oButton.container=li;this.addButton(oButton,after);groupCont.appendChild(li);},addButton:function(oButton,after){if(!this.get('element')){this._queue[this._queue.length]=['addButton',arguments];return false;}
if(!this._buttonList){this._buttonList=[];}
if(!oButton.container){oButton.container=this.get('cont');}
if((oButton.type=='menu')||(oButton.type=='split')||(oButton.type=='select')){if(Lang.isArray(oButton.menu)){for(var i in oButton.menu){if(Lang.hasOwnProperty(oButton.menu,i)){var funcObject={fn:function(ev,x,oMenu){if(!oButton.menucmd){oButton.menucmd=oButton.value;}
oButton.value=((oMenu.value)?oMenu.value:oMenu._oText.nodeValue);},scope:this};oButton.menu[i].onclick=funcObject;}}}}
var _oButton={},skip=false;for(var o in oButton){if(Lang.hasOwnProperty(oButton,o)){if(!this._toolbarConfigs[o]){_oButton[o]=oButton[o];}}}
if(oButton.type=='select'){_oButton.type='menu';}
if(oButton.type=='spin'){_oButton.type='push';}
if(_oButton.type=='color'){if(YAHOO.widget.Overlay){_oButton=this._makeColorButton(_oButton);}else{skip=true;}}
if(_oButton.menu){if((YAHOO.widget.Overlay)&&(oButton.menu instanceof YAHOO.widget.Overlay)){oButton.menu.showEvent.subscribe(function(){this._button=_oButton;});}else{for(var m=0;m<_oButton.menu.length;m++){if(!_oButton.menu[m].value){_oButton.menu[m].value=_oButton.menu[m].text;}}
if(this.browser.webkit){_oButton.focusmenu=false;}}}
if(skip){oButton=false;}else{this._configs.buttons.value[this._configs.buttons.value.length]=oButton;var tmp=new this.buttonType(_oButton);tmp.get('element').tabIndex='-1';tmp.get('element').setAttribute('role','button');tmp._selected=true;if(this.get('disabled')){tmp.set('disabled',true);}
if(!oButton.id){oButton.id=tmp.get('id');}
if(after){var el=tmp.get('element');var nextSib=null;if(after.get){nextSib=after.get('element').nextSibling;}else if(after.nextSibling){nextSib=after.nextSibling;}
if(nextSib){nextSib.parentNode.insertBefore(el,nextSib);}}
tmp.addClass(this.CLASS_PREFIX+'-'+tmp.get('value'));var icon=document.createElement('span');icon.className=this.CLASS_PREFIX+'-icon';tmp.get('element').insertBefore(icon,tmp.get('firstChild'));if(tmp._button.tagName.toLowerCase()=='button'){tmp.get('element').setAttribute('unselectable','on');var a=document.createElement('a');a.innerHTML=tmp._button.innerHTML;a.href='#';a.tabIndex='-1';Event.on(a,'click',function(ev){Event.stopEvent(ev);});tmp._button.parentNode.replaceChild(a,tmp._button);tmp._button=a;}
if(oButton.type=='select'){if(tmp._button.tagName.toLowerCase()=='select'){icon.parentNode.removeChild(icon);var iel=tmp._button;var parEl=tmp.get('element');parEl.parentNode.replaceChild(iel,parEl);}else{tmp.addClass(this.CLASS_PREFIX+'-select');}}
if(oButton.type=='spin'){if(!Lang.isArray(oButton.range)){oButton.range=[10,100];}
this._makeSpinButton(tmp,oButton);}
tmp.get('element').setAttribute('title',tmp.get('label'));if(oButton.type!='spin'){if((YAHOO.widget.Overlay)&&(_oButton.menu instanceof YAHOO.widget.Overlay)){var showPicker=function(ev){var exec=true;if(ev.keyCode&&(ev.keyCode==9)){exec=false;}
if(exec){if(this._colorPicker){this._colorPicker._button=oButton.value;}
var menuEL=tmp.getMenu().element;if(Dom.getStyle(menuEL,'visibility')=='hidden'){tmp.getMenu().show();}else{tmp.getMenu().hide();}}
YAHOO.util.Event.stopEvent(ev);};tmp.on('mousedown',showPicker,oButton,this);tmp.on('keydown',showPicker,oButton,this);}else if((oButton.type!='menu')&&(oButton.type!='select')){tmp.on('keypress',this._buttonClick,oButton,this);tmp.on('mousedown',function(ev){YAHOO.util.Event.stopEvent(ev);this._buttonClick(ev,oButton);},oButton,this);tmp.on('click',function(ev){YAHOO.util.Event.stopEvent(ev);});}else{tmp.on('mousedown',function(ev){YAHOO.util.Event.stopEvent(ev);});tmp.on('click',function(ev){YAHOO.util.Event.stopEvent(ev);});tmp.on('change',function(ev){if(!oButton.menucmd){oButton.menucmd=oButton.value;}
oButton.value=ev.value;this._buttonClick(ev,oButton);},this,true);var self=this;tmp.on('appendTo',function(){var tmp=this;if(tmp.getMenu()&&tmp.getMenu().mouseDownEvent){tmp.getMenu().mouseDownEvent.subscribe(function(ev,args){var oMenu=args[1];YAHOO.util.Event.stopEvent(args[0]);tmp._onMenuClick(args[0],tmp);if(!oButton.menucmd){oButton.menucmd=oButton.value;}
oButton.value=((oMenu.value)?oMenu.value:oMenu._oText.nodeValue);self._buttonClick.call(self,args[1],oButton);tmp._hideMenu();return false;});tmp.getMenu().clickEvent.subscribe(function(ev,args){YAHOO.util.Event.stopEvent(args[0]);});tmp.getMenu().mouseUpEvent.subscribe(function(ev,args){YAHOO.util.Event.stopEvent(args[0]);});}});}}else{tmp.on('mousedown',function(ev){YAHOO.util.Event.stopEvent(ev);});tmp.on('click',function(ev){YAHOO.util.Event.stopEvent(ev);});}
if(this.browser.ie){}
if(this.browser.webkit){tmp.hasFocus=function(){return true;};}
this._buttonList[this._buttonList.length]=tmp;if((oButton.type=='menu')||(oButton.type=='split')||(oButton.type=='select')){if(Lang.isArray(oButton.menu)){var menu=tmp.getMenu();if(menu&&menu.renderEvent){menu.renderEvent.subscribe(this._addMenuClasses,tmp);if(oButton.renderer){menu.renderEvent.subscribe(oButton.renderer,tmp);}}}}}
return oButton;},addSeparator:function(cont,after){if(!this.get('element')){this._queue[this._queue.length]=['addSeparator',arguments];return false;}
var sepCont=((cont)?cont:this.get('cont'));if(!this.get('element')){this._queue[this._queue.length]=['addSeparator',arguments];return false;}
if(this._sepCount===null){this._sepCount=0;}
if(!this._sep){this._sep=document.createElement('SPAN');Dom.addClass(this._sep,this.CLASS_SEPARATOR);this._sep.innerHTML='|';}
var _sep=this._sep.cloneNode(true);this._sepCount++;Dom.addClass(_sep,this.CLASS_SEPARATOR+'-'+this._sepCount);if(after){var nextSib=null;if(after.get){nextSib=after.get('element').nextSibling;}else if(after.nextSibling){nextSib=after.nextSibling;}else{nextSib=after;}
if(nextSib){if(nextSib==after){nextSib.parentNode.appendChild(_sep);}else{nextSib.parentNode.insertBefore(_sep,nextSib);}}}else{sepCont.appendChild(_sep);}
return _sep;},_createColorPicker:function(id){if(Dom.get(id+'_colors')){Dom.get(id+'_colors').parentNode.removeChild(Dom.get(id+'_colors'));}
var picker=document.createElement('div');picker.className='yui-toolbar-colors';picker.id=id+'_colors';picker.style.display='none';Event.on(window,'load',function(){document.body.appendChild(picker);},this,true);this._colorPicker=picker;var html='';for(var i in this._colorData){if(Lang.hasOwnProperty(this._colorData,i)){html+='<a style="background-color: '+i+'" href="#">'+i.replace('#','')+'</a>';}}
html+='<span><em>X</em><strong></strong></span>';window.setTimeout(function(){picker.innerHTML=html;},0);Event.on(picker,'mouseover',function(ev){var picker=this._colorPicker;var em=picker.getElementsByTagName('em')[0];var strong=picker.getElementsByTagName('strong')[0];var tar=Event.getTarget(ev);if(tar.tagName.toLowerCase()=='a'){em.style.backgroundColor=tar.style.backgroundColor;strong.innerHTML=this._colorData['#'+tar.innerHTML]+'<br>'+tar.innerHTML;}},this,true);Event.on(picker,'focus',function(ev){Event.stopEvent(ev);});Event.on(picker,'click',function(ev){Event.stopEvent(ev);});Event.on(picker,'mousedown',function(ev){Event.stopEvent(ev);var tar=Event.getTarget(ev);if(tar.tagName.toLowerCase()=='a'){var retVal=this.fireEvent('colorPickerClicked',{type:'colorPickerClicked',target:this,button:this._colorPicker._button,color:tar.innerHTML,colorName:this._colorData['#'+tar.innerHTML]});if(retVal!==false){var info={color:tar.innerHTML,colorName:this._colorData['#'+tar.innerHTML],value:this._colorPicker._button};this.fireEvent('buttonClick',{type:'buttonClick',target:this.get('element'),button:info});}
this.getButtonByValue(this._colorPicker._button).getMenu().hide();}},this,true);},_resetColorPicker:function(){var em=this._colorPicker.getElementsByTagName('em')[0];var strong=this._colorPicker.getElementsByTagName('strong')[0];em.style.backgroundColor='transparent';strong.innerHTML='';},_makeColorButton:function(_oButton){if(!this._colorPicker){this._createColorPicker(this.get('id'));}
_oButton.type='color';_oButton.menu=new YAHOO.widget.Overlay(this.get('id')+'_'+_oButton.value+'_menu',{visible:false,position:'absolute',iframe:true});_oButton.menu.setBody('');_oButton.menu.render(this.get('cont'));Dom.addClass(_oButton.menu.element,'yui-button-menu');Dom.addClass(_oButton.menu.element,'yui-color-button-menu');_oButton.menu.beforeShowEvent.subscribe(function(){_oButton.menu.cfg.setProperty('zindex',5);_oButton.menu.cfg.setProperty('context',[this.getButtonById(_oButton.id).get('element'),'tl','bl']);this._resetColorPicker();var _p=this._colorPicker;if(_p.parentNode){_p.parentNode.removeChild(_p);}
_oButton.menu.setBody('');_oButton.menu.appendToBody(_p);this._colorPicker.style.display='block';},this,true);return _oButton;},_makeSpinButton:function(_button,oButton){_button.addClass(this.CLASS_PREFIX+'-spinbutton');var self=this,_par=_button._button.parentNode.parentNode,range=oButton.range,_b1=document.createElement('a'),_b2=document.createElement('a');_b1.href='#';_b2.href='#';_b1.tabIndex='-1';_b2.tabIndex='-1';_b1.className='up';_b1.title=this.STR_SPIN_UP;_b1.innerHTML=this.STR_SPIN_UP;_b2.className='down';_b2.title=this.STR_SPIN_DOWN;_b2.innerHTML=this.STR_SPIN_DOWN;_par.appendChild(_b1);_par.appendChild(_b2);var label=YAHOO.lang.substitute(this.STR_SPIN_LABEL,{VALUE:_button.get('label')});_button.set('title',label);var cleanVal=function(value){value=((value<range[0])?range[0]:value);value=((value>range[1])?range[1]:value);return value;};var br=this.browser;var tbar=false;var strLabel=this.STR_SPIN_LABEL;if(this._titlebar&&this._titlebar.firstChild){tbar=this._titlebar.firstChild;}
var _intUp=function(ev){YAHOO.util.Event.stopEvent(ev);if(!_button.get('disabled')&&(ev.keyCode!=9)){var value=parseInt(_button.get('label'),10);value++;value=cleanVal(value);_button.set('label',''+value);var label=YAHOO.lang.substitute(strLabel,{VALUE:_button.get('label')});_button.set('title',label);if(!br.webkit&&tbar){}
self._buttonClick(ev,oButton);}};var _intDown=function(ev){YAHOO.util.Event.stopEvent(ev);if(!_button.get('disabled')&&(ev.keyCode!=9)){var value=parseInt(_button.get('label'),10);value--;value=cleanVal(value);_button.set('label',''+value);var label=YAHOO.lang.substitute(strLabel,{VALUE:_button.get('label')});_button.set('title',label);if(!br.webkit&&tbar){}
self._buttonClick(ev,oButton);}};var _intKeyUp=function(ev){if(ev.keyCode==38){_intUp(ev);}else if(ev.keyCode==40){_intDown(ev);}else if(ev.keyCode==107&&ev.shiftKey){_intUp(ev);}else if(ev.keyCode==109&&ev.shiftKey){_intDown(ev);}};_button.on('keydown',_intKeyUp,this,true);Event.on(_b1,'mousedown',function(ev){Event.stopEvent(ev);},this,true);Event.on(_b2,'mousedown',function(ev){Event.stopEvent(ev);},this,true);Event.on(_b1,'click',_intUp,this,true);Event.on(_b2,'click',_intDown,this,true);},_buttonClick:function(ev,info){var doEvent=true;if(ev&&ev.type=='keypress'){if(ev.keyCode==9){doEvent=false;}else if((ev.keyCode===13)||(ev.keyCode===0)||(ev.keyCode===32)){}else{doEvent=false;}}
if(doEvent){var fireNextEvent=true,retValue=false;info.isSelected=this.isSelected(info.id);if(info.value){retValue=this.fireEvent(info.value+'Click',{type:info.value+'Click',target:this.get('element'),button:info});if(retValue===false){fireNextEvent=false;}}
if(info.menucmd&&fireNextEvent){retValue=this.fireEvent(info.menucmd+'Click',{type:info.menucmd+'Click',target:this.get('element'),button:info});if(retValue===false){fireNextEvent=false;}}
if(fireNextEvent){this.fireEvent('buttonClick',{type:'buttonClick',target:this.get('element'),button:info});}
if(info.type=='select'){var button=this.getButtonById(info.id);if(button.buttonType=='rich'){var txt=info.value;for(var i=0;i<info.menu.length;i++){if(info.menu[i].value==info.value){txt=info.menu[i].text;break;}}
button.set('label','<span class="yui-toolbar-'+info.menucmd+'-'+(info.value).replace(/ /g,'-').toLowerCase()+'">'+txt+'</span>');var _items=button.getMenu().getItems();for(var m=0;m<_items.length;m++){if(_items[m].value.toLowerCase()==info.value.toLowerCase()){_items[m].cfg.setProperty('checked',true);}else{_items[m].cfg.setProperty('checked',false);}}}}
if(ev){Event.stopEvent(ev);}}},_keyNav:null,_navCounter:null,_navigateButtons:function(ev){switch(ev.keyCode){case 37:case 39:if(ev.keyCode==37){this._navCounter--;}else{this._navCounter++;}
if(this._navCounter>(this._buttonList.length-1)){this._navCounter=0;}
if(this._navCounter<0){this._navCounter=(this._buttonList.length-1);}
if(this._buttonList[this._navCounter]){var el=this._buttonList[this._navCounter].get('element');if(this.browser.ie){el=this._buttonList[this._navCounter].get('element').getElementsByTagName('a')[0];}
if(this._buttonList[this._navCounter].get('disabled')){this._navigateButtons(ev);}else{el.focus();}}
break;}},_handleFocus:function(){if(!this._keyNav){var ev='keypress';if(this.browser.ie){ev='keydown';}
Event.on(this.get('element'),ev,this._navigateButtons,this,true);this._keyNav=true;this._navCounter=-1;}},getButtonById:function(id){var len=this._buttonList.length;for(var i=0;i<len;i++){if(this._buttonList[i]&&this._buttonList[i].get('id')==id){return this._buttonList[i];}}
return false;},getButtonByValue:function(value){var _buttons=this.get('buttons');var len=_buttons.length;for(var i=0;i<len;i++){if(_buttons[i].group!==undefined){for(var m=0;m<_buttons[i].buttons.length;m++){if((_buttons[i].buttons[m].value==value)||(_buttons[i].buttons[m].menucmd==value)){return this.getButtonById(_buttons[i].buttons[m].id);}
if(_buttons[i].buttons[m].menu){for(var s=0;s<_buttons[i].buttons[m].menu.length;s++){if(_buttons[i].buttons[m].menu[s].value==value){return this.getButtonById(_buttons[i].buttons[m].id);}}}}}else{if((_buttons[i].value==value)||(_buttons[i].menucmd==value)){return this.getButtonById(_buttons[i].id);}
if(_buttons[i].menu){for(var j=0;j<_buttons[i].menu.length;j++){if(_buttons[i].menu[j].value==value){return this.getButtonById(_buttons[i].id);}}}}}
return false;},getButtonByIndex:function(index){if(this._buttonList[index]){return this._buttonList[index];}else{return false;}},getButtons:function(){return this._buttonList;},disableButton:function(id){var button=getButton.call(this,id);if(button){button.set('disabled',true);}else{return false;}},enableButton:function(id){if(this.get('disabled')){return false;}
var button=getButton.call(this,id);if(button){if(button.get('disabled')){button.set('disabled',false);}}else{return false;}},isSelected:function(id){var button=getButton.call(this,id);if(button){return button._selected;}
return false;},selectButton:function(id,value){var button=getButton.call(this,id);if(button){button.addClass('yui-button-selected');button.addClass('yui-button-'+button.get('value')+'-selected');button._selected=true;if(value){if(button.buttonType=='rich'){var _items=button.getMenu().getItems();for(var m=0;m<_items.length;m++){if(_items[m].value==value){_items[m].cfg.setProperty('checked',true);button.set('label','<span class="yui-toolbar-'+button.get('value')+'-'+(value).replace(/ /g,'-').toLowerCase()+'">'+_items[m]._oText.nodeValue+'</span>');}else{_items[m].cfg.setProperty('checked',false);}}}}}else{return false;}},deselectButton:function(id){var button=getButton.call(this,id);if(button){button.removeClass('yui-button-selected');button.removeClass('yui-button-'+button.get('value')+'-selected');button.removeClass('yui-button-hover');button._selected=false;}else{return false;}},deselectAllButtons:function(){var len=this._buttonList.length;for(var i=0;i<len;i++){this.deselectButton(this._buttonList[i]);}},disableAllButtons:function(){if(this.get('disabled')){return false;}
var len=this._buttonList.length;for(var i=0;i<len;i++){this.disableButton(this._buttonList[i]);}},enableAllButtons:function(){if(this.get('disabled')){return false;}
var len=this._buttonList.length;for(var i=0;i<len;i++){this.enableButton(this._buttonList[i]);}},resetAllButtons:function(_ex){if(!Lang.isObject(_ex)){_ex={};}
if(this.get('disabled')){return false;}
var len=this._buttonList.length;for(var i=0;i<len;i++){var _button=this._buttonList[i];if(_button){var disabled=_button._configs.disabled._initialConfig.value;if(_ex[_button.get('id')]){this.enableButton(_button);this.selectButton(_button);}else{if(disabled){this.disableButton(_button);}else{this.enableButton(_button);}
this.deselectButton(_button);}}}},destroyButton:function(id){var button=getButton.call(this,id);if(button){var thisID=button.get('id');button.destroy();var len=this._buttonList.length;for(var i=0;i<len;i++){if(this._buttonList[i]&&this._buttonList[i].get('id')==thisID){this._buttonList[i]=null;}}}else{return false;}},destroy:function(){this.get('element').innerHTML='';this.get('element').className='';for(var i in this){if(Lang.hasOwnProperty(this,i)){this[i]=null;}}
return true;},collapse:function(collapse){var el=Dom.getElementsByClassName('collapse','span',this._titlebar);if(collapse===false){Dom.removeClass(this.get('cont').parentNode,'yui-toolbar-container-collapsed');if(el[0]){Dom.removeClass(el[0],'collapsed');}
this.fireEvent('toolbarExpanded',{type:'toolbarExpanded',target:this});}else{if(el[0]){Dom.addClass(el[0],'collapsed');}
Dom.addClass(this.get('cont').parentNode,'yui-toolbar-container-collapsed');this.fireEvent('toolbarCollapsed',{type:'toolbarCollapsed',target:this});}},toString:function(){return'Toolbar (#'+this.get('element').id+') with '+this._buttonList.length+' buttons.';}});})();(function(){var Dom=YAHOO.util.Dom,Event=YAHOO.util.Event,Lang=YAHOO.lang,Toolbar=YAHOO.widget.Toolbar;YAHOO.widget.SimpleEditor=function(el,attrs){var o={};if(Lang.isObject(el)&&(!el.tagName)&&!attrs){Lang.augmentObject(o,el);el=document.createElement('textarea');this.DOMReady=true;if(o.container){var c=Dom.get(o.container);c.appendChild(el);}else{document.body.appendChild(el);}}else{if(attrs){Lang.augmentObject(o,attrs);}}
var oConfig={element:null,attributes:o},id=null;if(Lang.isString(el)){id=el;}else{if(oConfig.attributes.id){id=oConfig.attributes.id;}else{this.DOMReady=true;id=Dom.generateId(el);}}
oConfig.element=el;var element_cont=document.createElement('DIV');oConfig.attributes.element_cont=new YAHOO.util.Element(element_cont,{id:id+'_container'});var div=document.createElement('div');Dom.addClass(div,'first-child');oConfig.attributes.element_cont.appendChild(div);if(!oConfig.attributes.toolbar_cont){oConfig.attributes.toolbar_cont=document.createElement('DIV');oConfig.attributes.toolbar_cont.id=id+'_toolbar';div.appendChild(oConfig.attributes.toolbar_cont);}
var editorWrapper=document.createElement('DIV');div.appendChild(editorWrapper);oConfig.attributes.editor_wrapper=editorWrapper;YAHOO.widget.SimpleEditor.superclass.constructor.call(this,oConfig.element,oConfig.attributes);};YAHOO.extend(YAHOO.widget.SimpleEditor,YAHOO.util.Element,{_resizeConfig:{handles:['br'],autoRatio:true,status:true,proxy:true,useShim:true,setSize:false},_setupResize:function(){if(!YAHOO.util.DD||!YAHOO.util.Resize){return false;}
if(this.get('resize')){var config={};Lang.augmentObject(config,this._resizeConfig);this.resize=new YAHOO.util.Resize(this.get('element_cont').get('element'),config);this.resize.on('resize',function(args){var anim=this.get('animate');this.set('animate',false);this.set('width',args.width+'px');var h=args.height,th=(this.toolbar.get('element').clientHeight+2),dh=0;if(this.dompath){dh=(this.dompath.clientHeight+1);}
var newH=(h-th-dh);this.set('height',newH+'px');this.get('element_cont').setStyle('height','');this.set('animate',anim);},this,true);}},resize:null,_setupDD:function(){if(!YAHOO.util.DD){return false;}
if(this.get('drag')){var d=this.get('drag'),dd=YAHOO.util.DD;if(d==='proxy'){dd=YAHOO.util.DDProxy;}
this.dd=new dd(this.get('element_cont').get('element'));this.toolbar.addClass('draggable');this.dd.setHandleElId(this.toolbar._titlebar);}},dd:null,_lastCommand:null,_undoNodeChange:function(){},_storeUndo:function(){},_checkKey:function(k,e){var ret=false;if((e.keyCode===k.key)){if(k.mods&&(k.mods.length>0)){var val=0;for(var i=0;i<k.mods.length;i++){if(this.browser.mac){if(k.mods[i]=='ctrl'){k.mods[i]='meta';}}
if(e[k.mods[i]+'Key']===true){val++;}}
if(val===k.mods.length){ret=true;}}else{ret=true;}}
return ret;},_keyMap:{SELECT_ALL:{key:65,mods:['ctrl']},CLOSE_WINDOW:{key:87,mods:['shift','ctrl']},FOCUS_TOOLBAR:{key:27,mods:['shift']},FOCUS_AFTER:{key:27},CREATE_LINK:{key:76,mods:['shift','ctrl']},BOLD:{key:66,mods:['shift','ctrl']},ITALIC:{key:73,mods:['shift','ctrl']},UNDERLINE:{key:85,mods:['shift','ctrl']},UNDO:{key:90,mods:['ctrl']},REDO:{key:90,mods:['shift','ctrl']},JUSTIFY_LEFT:{key:219,mods:['shift','ctrl']},JUSTIFY_CENTER:{key:220,mods:['shift','ctrl']},JUSTIFY_RIGHT:{key:221,mods:['shift','ctrl']}},_cleanClassName:function(str){return str.replace(/ /g,'-').toLowerCase();},_textarea:null,_docType:'<!DOCTYPE HTML PUBLIC "-/'+'/W3C/'+'/DTD HTML 4.01/'+'/EN" "http:/'+'/www.w3.org/TR/html4/strict.dtd">',editorDirty:null,_defaultCSS:'html { height: 95%; } body { padding: 7px; background-color: #fff; font:13px/1.22 arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small; } a, a:visited, a:hover { color: blue !important; text-decoration: underline !important; cursor: text !important; } .warning-localfile { border-bottom: 1px dashed red !important; } .yui-busy { cursor: wait !important; } img.selected { border: 2px dotted #808080; } img { cursor: pointer !important; border: none; } body.ptags.webkit div { margin: 11px 0; }',_defaultToolbar:null,_lastButton:null,_baseHREF:function(){var href=document.location.href;if(href.indexOf('?')!==-1){href=href.substring(0,href.indexOf('?'));}
href=href.substring(0,href.lastIndexOf('/'))+'/';return href;}(),_lastImage:null,_blankImageLoaded:null,_fixNodesTimer:null,_nodeChangeTimer:null,_lastNodeChangeEvent:null,_lastNodeChange:0,_rendered:null,DOMReady:null,_selection:null,_mask:null,_showingHiddenElements:null,currentWindow:null,currentEvent:null,operaEvent:null,currentFont:null,currentElement:null,dompath:null,beforeElement:null,afterElement:null,invalidHTML:{form:true,input:true,button:true,select:true,link:true,html:true,body:true,iframe:true,script:true,style:true,textarea:true},toolbar:null,_contentTimer:null,_contentTimerCounter:0,_disabled:['createlink','fontname','fontsize','forecolor','backcolor'],_alwaysDisabled:{undo:true,redo:true},_alwaysEnabled:{},_semantic:{'bold':true,'italic':true,'underline':true},_tag2cmd:{'b':'bold','strong':'bold','i':'italic','em':'italic','u':'underline','sup':'superscript','sub':'subscript','img':'insertimage','a':'createlink','ul':'insertunorderedlist','ol':'insertorderedlist'},_createIframe:function(){var ifrmDom=document.createElement('iframe');ifrmDom.id=this.get('id')+'_editor';var config={border:'0',frameBorder:'0',marginWidth:'0',marginHeight:'0',leftMargin:'0',topMargin:'0',allowTransparency:'true',width:'100%'};if(this.get('autoHeight')){config.scrolling='no';}
for(var i in config){if(Lang.hasOwnProperty(config,i)){ifrmDom.setAttribute(i,config[i]);}}
var isrc='javascript:;';if(this.browser.ie){isrc='javascript:false;';}
ifrmDom.setAttribute('src',isrc);var ifrm=new YAHOO.util.Element(ifrmDom);ifrm.setStyle('visibility','hidden');return ifrm;},_isElement:function(el,tag){if(el&&el.tagName&&(el.tagName.toLowerCase()==tag)){return true;}
if(el&&el.getAttribute&&(el.getAttribute('tag')==tag)){return true;}
return false;},_hasParent:function(el,tag){if(!el||!el.parentNode){return false;}
while(el.parentNode){if(this._isElement(el,tag)){return el;}
if(el.parentNode){el=el.parentNode;}else{return false;}}
return false;},_getDoc:function(){var value=false;if(this.get){if(this.get('iframe')){if(this.get('iframe').get){if(this.get('iframe').get('element')){try{if(this.get('iframe').get('element').contentWindow){if(this.get('iframe').get('element').contentWindow.document){value=this.get('iframe').get('element').contentWindow.document;return value;}}}catch(e){}}}}}
return false;},_getWindow:function(){return this.get('iframe').get('element').contentWindow;},_focusWindow:function(onLoad){if(this.browser.webkit){if(onLoad){this._getSelection().setBaseAndExtent(this._getDoc().body.firstChild,0,this._getDoc().body.firstChild,1);if(this.browser.webkit3){this._getSelection().collapseToStart();}else{this._getSelection().collapse(false);}}else{this._getSelection().setBaseAndExtent(this._getDoc().body,1,this._getDoc().body,1);if(this.browser.webkit3){this._getSelection().collapseToStart();}else{this._getSelection().collapse(false);}}
this._getWindow().focus();}else{this._getWindow().focus();}},_hasSelection:function(){var sel=this._getSelection();var range=this._getRange();var hasSel=false;if(!sel||!range){return hasSel;}
if(this.browser.ie||this.browser.opera){if(range.text){hasSel=true;}
if(range.html){hasSel=true;}}else{if(this.browser.webkit){if(sel+''!==''){hasSel=true;}}else{if(sel&&(sel.toString()!=='')&&(sel!==undefined)){hasSel=true;}}}
return hasSel;},_getSelection:function(){var _sel=null;if(this._getDoc()&&this._getWindow()){if(this._getDoc().selection){_sel=this._getDoc().selection;}else{_sel=this._getWindow().getSelection();}
if(this.browser.webkit){if(_sel.baseNode){this._selection={};this._selection.baseNode=_sel.baseNode;this._selection.baseOffset=_sel.baseOffset;this._selection.extentNode=_sel.extentNode;this._selection.extentOffset=_sel.extentOffset;}else if(this._selection!==null){_sel=this._getWindow().getSelection();_sel.setBaseAndExtent(this._selection.baseNode,this._selection.baseOffset,this._selection.extentNode,this._selection.extentOffset);this._selection=null;}}}
return _sel;},_selectNode:function(node,collapse){if(!node){return false;}
var sel=this._getSelection(),range=null;if(this.browser.ie){try{range=this._getDoc().body.createTextRange();range.moveToElementText(node);range.select();}catch(e){}}else if(this.browser.webkit){if(collapse){sel.setBaseAndExtent(node,1,node,node.innerText.length);}else{sel.setBaseAndExtent(node,0,node,node.innerText.length);}}else if(this.browser.opera){sel=this._getWindow().getSelection();range=this._getDoc().createRange();range.selectNode(node);sel.removeAllRanges();sel.addRange(range);}else{range=this._getDoc().createRange();range.selectNodeContents(node);sel.removeAllRanges();sel.addRange(range);}
this.nodeChange();},_getRange:function(){var sel=this._getSelection();if(sel===null){return null;}
if(this.browser.webkit&&!sel.getRangeAt){var _range=this._getDoc().createRange();try{_range.setStart(sel.anchorNode,sel.anchorOffset);_range.setEnd(sel.focusNode,sel.focusOffset);}catch(e){_range=this._getWindow().getSelection()+'';}
return _range;}
if(this.browser.ie||this.browser.opera){try{return sel.createRange();}catch(e2){return null;}}
if(sel.rangeCount>0){return sel.getRangeAt(0);}
return null;},_setDesignMode:function(state){try{var set=true;if(this.browser.ie&&(state.toLowerCase()=='off')){set=false;}
if(set){this._getDoc().designMode=state;}}catch(e){}},_toggleDesignMode:function(){var _dMode=this._getDoc().designMode.toLowerCase(),_state='on';if(_dMode=='on'){_state='off';}
this._setDesignMode(_state);return _state;},_initEditorEvents:function(){var doc=this._getDoc();Event.on(doc,'mouseup',this._handleMouseUp,this,true);Event.on(doc,'mousedown',this._handleMouseDown,this,true);Event.on(doc,'click',this._handleClick,this,true);Event.on(doc,'dblclick',this._handleDoubleClick,this,true);Event.on(doc,'keypress',this._handleKeyPress,this,true);Event.on(doc,'keyup',this._handleKeyUp,this,true);Event.on(doc,'keydown',this._handleKeyDown,this,true);},_removeEditorEvents:function(){var doc=this._getDoc();Event.removeListener(doc,'mouseup',this._handleMouseUp,this,true);Event.removeListener(doc,'mousedown',this._handleMouseDown,this,true);Event.removeListener(doc,'click',this._handleClick,this,true);Event.removeListener(doc,'dblclick',this._handleDoubleClick,this,true);Event.removeListener(doc,'keypress',this._handleKeyPress,this,true);Event.removeListener(doc,'keyup',this._handleKeyUp,this,true);Event.removeListener(doc,'keydown',this._handleKeyDown,this,true);},_initEditor:function(){if(this.browser.ie){this._getDoc().body.style.margin='0';}
if(!this.get('disabled')){if(this._getDoc().designMode.toLowerCase()!='on'){this._setDesignMode('on');this._contentTimerCounter=0;}}
if(!this._getDoc().body){this._contentTimerCounter=0;this._checkLoaded();return false;}
this.toolbar.on('buttonClick',this._handleToolbarClick,this,true);if(!this.get('disabled')){this._initEditorEvents();this.toolbar.set('disabled',false);}
this.fireEvent('editorContentLoaded',{type:'editorLoaded',target:this});if(this.get('dompath')){var self=this;setTimeout(function(){self._writeDomPath.call(self);self._setupResize.call(self);},150);}
var br=[];for(var i in this.browser){if(this.browser[i]){br.push(i);}}
if(this.get('ptags')){br.push('ptags');}
Dom.addClass(this._getDoc().body,br.join(' '));this.nodeChange(true);},_checkLoaded:function(){this._contentTimerCounter++;if(this._contentTimer){clearTimeout(this._contentTimer);}
if(this._contentTimerCounter>500){return false;}
var init=false;try{if(this._getDoc()&&this._getDoc().body){if(this.browser.ie){if(this._getDoc().body.readyState=='complete'){init=true;}}else{if(this._getDoc().body._rteLoaded===true){init=true;}}}}catch(e){init=false;}
if(init===true){this._initEditor();}else{var self=this;this._contentTimer=setTimeout(function(){self._checkLoaded.call(self);},20);}},_setInitialContent:function(){var value=((this._textarea)?this.get('element').value:this.get('element').innerHTML),doc=null;var html=Lang.substitute(this.get('html'),{TITLE:this.STR_TITLE,CONTENT:this._cleanIncomingHTML(value),CSS:this.get('css'),HIDDEN_CSS:((this.get('hiddencss'))?this.get('hiddencss'):'/* No Hidden CSS */'),EXTRA_CSS:((this.get('extracss'))?this.get('extracss'):'/* No Extra CSS */')}),check=true;if(document.compatMode!='BackCompat'){html=this._docType+"\n"+html;}else{}
if(this.browser.ie||this.browser.webkit||this.browser.opera||(navigator.userAgent.indexOf('Firefox/1.5')!=-1)){try{if(this.browser.air){doc=this._getDoc().implementation.createHTMLDocument();var origDoc=this._getDoc();origDoc.open();origDoc.close();doc.open();doc.write(html);doc.close();var node=origDoc.importNode(doc.getElementsByTagName("html")[0],true);origDoc.replaceChild(node,origDoc.getElementsByTagName("html")[0]);origDoc.body._rteLoaded=true;}else{doc=this._getDoc();doc.open();doc.write(html);doc.close();}}catch(e){check=false;}}else{this.get('iframe').get('element').src='data:text/html;charset=utf-8,'+encodeURIComponent(html);}
this.get('iframe').setStyle('visibility','');if(check){this._checkLoaded();}},_setMarkupType:function(action){switch(this.get('markup')){case'css':this._setEditorStyle(true);break;case'default':this._setEditorStyle(false);break;case'semantic':case'xhtml':if(this._semantic[action]){this._setEditorStyle(false);}else{this._setEditorStyle(true);}
break;}},_setEditorStyle:function(stat){try{this._getDoc().execCommand('useCSS',false,!stat);}catch(ex){}},_getSelectedElement:function(){var doc=this._getDoc(),range=null,sel=null,elm=null,check=true;if(this.browser.ie){this.currentEvent=this._getWindow().event;range=this._getRange();if(range){elm=range.item?range.item(0):range.parentElement();if(this._hasSelection()){}
if(elm===doc.body){elm=null;}}
if((this.currentEvent!==null)&&(this.currentEvent.keyCode===0)){elm=Event.getTarget(this.currentEvent);}}else{sel=this._getSelection();range=this._getRange();if(!sel||!range){return null;}
if(!this._hasSelection()&&this.browser.webkit3){}
if(this.browser.gecko){if(range.startContainer){check=false;if(range.startContainer.nodeType===3){elm=range.startContainer.parentNode;}else if(range.startContainer.nodeType===1){elm=range.startContainer;}else{check=true;}
if(!check){this.currentEvent=null;}}}
if(check){if(sel.anchorNode&&(sel.anchorNode.nodeType==3)){if(sel.anchorNode.parentNode){elm=sel.anchorNode.parentNode;}
if(sel.anchorNode.nextSibling!=sel.focusNode.nextSibling){elm=sel.anchorNode.nextSibling;}}
if(this._isElement(elm,'br')){elm=null;}
if(!elm){elm=range.commonAncestorContainer;if(!range.collapsed){if(range.startContainer==range.endContainer){if(range.startOffset-range.endOffset<2){if(range.startContainer.hasChildNodes()){elm=range.startContainer.childNodes[range.startOffset];}}}}}}}
if(this.currentEvent!==null){try{switch(this.currentEvent.type){case'click':case'mousedown':case'mouseup':if(this.browser.webkit){elm=Event.getTarget(this.currentEvent);}
break;default:break;}}catch(e){}}else if((this.currentElement&&this.currentElement[0])&&(!this.browser.ie)){}
if(this.browser.opera||this.browser.webkit){if(this.currentEvent&&!elm){elm=YAHOO.util.Event.getTarget(this.currentEvent);}}
if(!elm||!elm.tagName){elm=doc.body;}
if(this._isElement(elm,'html')){elm=doc.body;}
if(this._isElement(elm,'body')){elm=doc.body;}
if(elm&&!elm.parentNode){elm=doc.body;}
if(elm===undefined){elm=null;}
return elm;},_getDomPath:function(el){if(!el){el=this._getSelectedElement();}
var domPath=[];while(el!==null){if(el.ownerDocument!=this._getDoc()){el=null;break;}
if(el.nodeName&&el.nodeType&&(el.nodeType==1)){domPath[domPath.length]=el;}
if(this._isElement(el,'body')){break;}
el=el.parentNode;}
if(domPath.length===0){if(this._getDoc()&&this._getDoc().body){domPath[0]=this._getDoc().body;}}
return domPath.reverse();},_writeDomPath:function(){var path=this._getDomPath(),pathArr=[],classPath='',pathStr='';for(var i=0;i<path.length;i++){var tag=path[i].tagName.toLowerCase();if((tag=='ol')&&(path[i].type)){tag+=':'+path[i].type;}
if(Dom.hasClass(path[i],'yui-tag')){tag=path[i].getAttribute('tag');}
if((this.get('markup')=='semantic')||(this.get('markup')=='xhtml')){switch(tag){case'b':tag='strong';break;case'i':tag='em';break;}}
if(!Dom.hasClass(path[i],'yui-non')){if(Dom.hasClass(path[i],'yui-tag')){pathStr=tag;}else{classPath=((path[i].className!=='')?'.'+path[i].className.replace(/ /g,'.'):'');if((classPath.indexOf('yui')!=-1)||(classPath.toLowerCase().indexOf('apple-style-span')!=-1)){classPath='';}
pathStr=tag+((path[i].id)?'#'+path[i].id:'')+classPath;}
switch(tag){case'body':pathStr='body';break;case'a':if(path[i].getAttribute('href',2)){pathStr+=':'+path[i].getAttribute('href',2).replace('mailto:','').replace('http:/'+'/','').replace('https:/'+'/','');}
break;case'img':var h=path[i].height;var w=path[i].width;if(path[i].style.height){h=parseInt(path[i].style.height,10);}
if(path[i].style.width){w=parseInt(path[i].style.width,10);}
pathStr+='('+w+'x'+h+')';break;}
if(pathStr.length>10){pathStr='<span title="'+pathStr+'">'+pathStr.substring(0,10)+'...'+'</span>';}else{pathStr='<span title="'+pathStr+'">'+pathStr+'</span>';}
pathArr[pathArr.length]=pathStr;}}
var str=pathArr.join(' '+this.SEP_DOMPATH+' ');if(this.dompath.innerHTML!=str){this.dompath.innerHTML=str;}},_fixNodes:function(){var doc=this._getDoc(),els=[];for(var v in this.invalidHTML){if(YAHOO.lang.hasOwnProperty(this.invalidHTML,v)){if(v.toLowerCase()!='span'){var tags=doc.body.getElementsByTagName(v);if(tags.length){for(var i=0;i<tags.length;i++){els.push(tags[i]);}}}}}
for(var h=0;h<els.length;h++){if(els[h].parentNode){if(Lang.isObject(this.invalidHTML[els[h].tagName.toLowerCase()])&&this.invalidHTML[els[h].tagName.toLowerCase()].keepContents){this._swapEl(els[h],'span',function(el){el.className='yui-non';});}else{els[h].parentNode.removeChild(els[h]);}}}
var imgs=this._getDoc().getElementsByTagName('img');Dom.addClass(imgs,'yui-img');},_isNonEditable:function(ev){if(this.get('allowNoEdit')){var el=Event.getTarget(ev);if(this._isElement(el,'html')){el=null;}
var path=this._getDomPath(el);for(var i=(path.length-1);i>-1;i--){if(Dom.hasClass(path[i],this.CLASS_NOEDIT)){try{this._getDoc().execCommand('enableObjectResizing',false,'false');}catch(e){}
this.nodeChange();Event.stopEvent(ev);return true;}}
try{this._getDoc().execCommand('enableObjectResizing',false,'true');}catch(e2){}}
return false;},_setCurrentEvent:function(ev){this.currentEvent=ev;},_handleClick:function(ev){var ret=this.fireEvent('beforeEditorClick',{type:'beforeEditorClick',target:this,ev:ev});if(ret===false){return false;}
if(this._isNonEditable(ev)){return false;}
this._setCurrentEvent(ev);if(this.currentWindow){this.closeWindow();}
if(this.currentWindow){this.closeWindow();}
if(this.browser.webkit){var tar=Event.getTarget(ev);if(this._isElement(tar,'a')||this._isElement(tar.parentNode,'a')){Event.stopEvent(ev);this.nodeChange();}}else{this.nodeChange();}
this.fireEvent('editorClick',{type:'editorClick',target:this,ev:ev});},_handleMouseUp:function(ev){var ret=this.fireEvent('beforeEditorMouseUp',{type:'beforeEditorMouseUp',target:this,ev:ev});if(ret===false){return false;}
if(this._isNonEditable(ev)){return false;}
var self=this;if(this.browser.opera){var sel=Event.getTarget(ev);if(this._isElement(sel,'img')){this.nodeChange();if(this.operaEvent){clearTimeout(this.operaEvent);this.operaEvent=null;this._handleDoubleClick(ev);}else{this.operaEvent=window.setTimeout(function(){self.operaEvent=false;},700);}}}
if(this.browser.webkit||this.browser.opera){if(this.browser.webkit){Event.stopEvent(ev);}}
this.nodeChange();this.fireEvent('editorMouseUp',{type:'editorMouseUp',target:this,ev:ev});},_handleMouseDown:function(ev){var ret=this.fireEvent('beforeEditorMouseDown',{type:'beforeEditorMouseDown',target:this,ev:ev});if(ret===false){return false;}
if(this._isNonEditable(ev)){return false;}
this._setCurrentEvent(ev);var sel=Event.getTarget(ev);if(this.browser.webkit&&this._hasSelection()){var _sel=this._getSelection();if(!this.browser.webkit3){_sel.collapse(true);}else{_sel.collapseToStart();}}
if(this.browser.webkit&&this._lastImage){Dom.removeClass(this._lastImage,'selected');this._lastImage=null;}
if(this._isElement(sel,'img')||this._isElement(sel,'a')){if(this.browser.webkit){Event.stopEvent(ev);if(this._isElement(sel,'img')){Dom.addClass(sel,'selected');this._lastImage=sel;}}
if(this.currentWindow){this.closeWindow();}
this.nodeChange();}
this.fireEvent('editorMouseDown',{type:'editorMouseDown',target:this,ev:ev});},_handleDoubleClick:function(ev){var ret=this.fireEvent('beforeEditorDoubleClick',{type:'beforeEditorDoubleClick',target:this,ev:ev});if(ret===false){return false;}
if(this._isNonEditable(ev)){return false;}
this._setCurrentEvent(ev);var sel=Event.getTarget(ev);if(this._isElement(sel,'img')){this.currentElement[0]=sel;this.toolbar.fireEvent('insertimageClick',{type:'insertimageClick',target:this.toolbar});this.fireEvent('afterExecCommand',{type:'afterExecCommand',target:this});}else if(this._hasParent(sel,'a')){this.currentElement[0]=this._hasParent(sel,'a');this.toolbar.fireEvent('createlinkClick',{type:'createlinkClick',target:this.toolbar});this.fireEvent('afterExecCommand',{type:'afterExecCommand',target:this});}
this.nodeChange();this.fireEvent('editorDoubleClick',{type:'editorDoubleClick',target:this,ev:ev});},_handleKeyUp:function(ev){var ret=this.fireEvent('beforeEditorKeyUp',{type:'beforeEditorKeyUp',target:this,ev:ev});if(ret===false){return false;}
if(this._isNonEditable(ev)){return false;}
this._setCurrentEvent(ev);switch(ev.keyCode){case this._keyMap.SELECT_ALL.key:if(this._checkKey(this._keyMap.SELECT_ALL,ev)){this.nodeChange();}
break;case 32:case 35:case 36:case 37:case 38:case 39:case 40:case 46:case 8:case this._keyMap.CLOSE_WINDOW.key:if((ev.keyCode==this._keyMap.CLOSE_WINDOW.key)&&this.currentWindow){if(this._checkKey(this._keyMap.CLOSE_WINDOW,ev)){this.closeWindow();}}else{if(!this.browser.ie){if(this._nodeChangeTimer){clearTimeout(this._nodeChangeTimer);}
var self=this;this._nodeChangeTimer=setTimeout(function(){self._nodeChangeTimer=null;self.nodeChange.call(self);},100);}else{this.nodeChange();}
this.editorDirty=true;}
break;}
this.fireEvent('editorKeyUp',{type:'editorKeyUp',target:this,ev:ev});this._storeUndo();},_handleKeyPress:function(ev){var ret=this.fireEvent('beforeEditorKeyPress',{type:'beforeEditorKeyPress',target:this,ev:ev});if(ret===false){return false;}
if(this.get('allowNoEdit')){if(ev&&ev.keyCode&&(ev.keyCode==63272)){Event.stopEvent(ev);}}
if(this._isNonEditable(ev)){return false;}
this._setCurrentEvent(ev);if(this.browser.opera){if(ev.keyCode===13){var tar=this._getSelectedElement();if(!this._isElement(tar,'li')){this.execCommand('inserthtml','<br>');Event.stopEvent(ev);}}}
if(this.browser.webkit){if(!this.browser.webkit3){if(ev.keyCode&&(ev.keyCode==122)&&(ev.metaKey)){if(this._hasParent(this._getSelectedElement(),'li')){Event.stopEvent(ev);}}}
this._listFix(ev);}
this.fireEvent('editorKeyPress',{type:'editorKeyPress',target:this,ev:ev});},_handleKeyDown:function(ev){var ret=this.fireEvent('beforeEditorKeyDown',{type:'beforeEditorKeyDown',target:this,ev:ev});if(ret===false){return false;}
var tar=null,_range=null;if(this._isNonEditable(ev)){return false;}
this._setCurrentEvent(ev);if(this.currentWindow){this.closeWindow();}
if(this.currentWindow){this.closeWindow();}
var doExec=false,action=null,exec=false;switch(ev.keyCode){case this._keyMap.FOCUS_TOOLBAR.key:if(this._checkKey(this._keyMap.FOCUS_TOOLBAR,ev)){var h=this.toolbar.getElementsByTagName('h2')[0];if(h&&h.firstChild){h.firstChild.focus();}}else if(this._checkKey(this._keyMap.FOCUS_AFTER,ev)){this.afterElement.focus();}
Event.stopEvent(ev);doExec=false;break;case this._keyMap.CREATE_LINK.key:if(this._hasSelection()){if(this._checkKey(this._keyMap.CREATE_LINK,ev)){var makeLink=true;if(this.get('limitCommands')){if(!this.toolbar.getButtonByValue('createlink')){makeLink=false;}}
if(makeLink){this.execCommand('createlink','');this.toolbar.fireEvent('createlinkClick',{type:'createlinkClick',target:this.toolbar});this.fireEvent('afterExecCommand',{type:'afterExecCommand',target:this});doExec=false;}}}
break;case this._keyMap.UNDO.key:case this._keyMap.REDO.key:if(this._checkKey(this._keyMap.REDO,ev)){action='redo';doExec=true;}else if(this._checkKey(this._keyMap.UNDO,ev)){action='undo';doExec=true;}
break;case this._keyMap.BOLD.key:if(this._checkKey(this._keyMap.BOLD,ev)){action='bold';doExec=true;}
break;case this._keyMap.ITALIC.key:if(this._checkKey(this._keyMap.ITALIC,ev)){action='italic';doExec=true;}
break;case this._keyMap.UNDERLINE.key:if(this._checkKey(this._keyMap.UNDERLINE,ev)){action='underline';doExec=true;}
break;case 9:if(this.browser.ie){_range=this._getRange();tar=this._getSelectedElement();if(!this._isElement(tar,'li')){if(_range){_range.pasteHTML('&nbsp;&nbsp;&nbsp;&nbsp;');_range.collapse(false);_range.select();}
Event.stopEvent(ev);}}
if(this.browser.gecko>1.8){tar=this._getSelectedElement();if(this._isElement(tar,'li')){if(ev.shiftKey){this._getDoc().execCommand('outdent',null,'');}else{this._getDoc().execCommand('indent',null,'');}}else if(!this._hasSelection()){this.execCommand('inserthtml','&nbsp;&nbsp;&nbsp;&nbsp;');}
Event.stopEvent(ev);}
break;case 13:if(this.get('ptags')&&!ev.shiftKey){if(this.browser.gecko){tar=this._getSelectedElement();if(!this._isElement(tar,'li')){doExec=true;action='insertparagraph';Event.stopEvent(ev);}}
if(this.browser.webkit){tar=this._getSelectedElement();if(!this._hasParent(tar,'li')){doExec=true;action='insertparagraph';Event.stopEvent(ev);}}}else{if(this.browser.ie){_range=this._getRange();tar=this._getSelectedElement();if(!this._isElement(tar,'li')){if(_range){_range.pasteHTML('<br>');_range.collapse(false);_range.select();}
Event.stopEvent(ev);}}}
break;}
if(this.browser.ie){this._listFix(ev);}
if(doExec&&action){this.execCommand(action,null);Event.stopEvent(ev);this.nodeChange();}
this.fireEvent('editorKeyDown',{type:'editorKeyDown',target:this,ev:ev});},_listFix:function(ev){var testLi=null,par=null,preContent=false,range=null;if(this.browser.webkit){if(ev.keyCode&&(ev.keyCode==13)){if(this._hasParent(this._getSelectedElement(),'li')){var tar=this._hasParent(this._getSelectedElement(),'li');if(tar.previousSibling){if(tar.firstChild&&(tar.firstChild.length==1)){this._selectNode(tar);}}}}}
if(ev.keyCode&&((!this.browser.webkit3&&(ev.keyCode==25))||((this.browser.webkit3||!this.browser.webkit)&&((ev.keyCode==9)&&ev.shiftKey)))){testLi=this._getSelectedElement();if(this._hasParent(testLi,'li')){testLi=this._hasParent(testLi,'li');if(this._hasParent(testLi,'ul')||this._hasParent(testLi,'ol')){par=this._hasParent(testLi,'ul');if(!par){par=this._hasParent(testLi,'ol');}
if(this._isElement(par.previousSibling,'li')){par.removeChild(testLi);par.parentNode.insertBefore(testLi,par.nextSibling);if(this.browser.ie){range=this._getDoc().body.createTextRange();range.moveToElementText(testLi);range.collapse(false);range.select();}
if(this.browser.webkit){this._selectNode(testLi.firstChild);}
Event.stopEvent(ev);}}}}
if(ev.keyCode&&((ev.keyCode==9)&&(!ev.shiftKey))){var preLi=this._getSelectedElement();if(this._hasParent(preLi,'li')){preContent=this._hasParent(preLi,'li').innerHTML;}
if(this.browser.webkit){this._getDoc().execCommand('inserttext',false,'\t');}
testLi=this._getSelectedElement();if(this._hasParent(testLi,'li')){par=this._hasParent(testLi,'li');var newUl=this._getDoc().createElement(par.parentNode.tagName.toLowerCase());if(this.browser.webkit){var span=Dom.getElementsByClassName('Apple-tab-span','span',par);if(span[0]){par.removeChild(span[0]);par.innerHTML=Lang.trim(par.innerHTML);if(preContent){par.innerHTML='<span class="yui-non">'+preContent+'</span>&nbsp;';}else{par.innerHTML='<span class="yui-non">&nbsp;</span>&nbsp;';}}}else{if(preContent){par.innerHTML=preContent+'&nbsp;';}else{par.innerHTML='&nbsp;';}}
par.parentNode.replaceChild(newUl,par);newUl.appendChild(par);if(this.browser.webkit){this._getSelection().setBaseAndExtent(par.firstChild,1,par.firstChild,par.firstChild.innerText.length);if(!this.browser.webkit3){par.parentNode.parentNode.style.display='list-item';setTimeout(function(){par.parentNode.parentNode.style.display='block';},1);}}else if(this.browser.ie){range=this._getDoc().body.createTextRange();range.moveToElementText(par);range.collapse(false);range.select();}else{this._selectNode(par);}
Event.stopEvent(ev);}
if(this.browser.webkit){Event.stopEvent(ev);}
this.nodeChange();}},nodeChange:function(force){var NCself=this;this._storeUndo();if(this.get('nodeChangeDelay')){window.setTimeout(function(){NCself._nodeChange.apply(NCself,arguments);},0);}else{this._nodeChange();}},_nodeChange:function(force){var threshold=parseInt(this.get('nodeChangeThreshold'),10),thisNodeChange=Math.round(new Date().getTime()/1000),self=this;if(force===true){this._lastNodeChange=0;}
if((this._lastNodeChange+threshold)<thisNodeChange){if(this._fixNodesTimer===null){this._fixNodesTimer=window.setTimeout(function(){self._fixNodes.call(self);self._fixNodesTimer=null;},0);}}
this._lastNodeChange=thisNodeChange;if(this.currentEvent){try{this._lastNodeChangeEvent=this.currentEvent.type;}catch(e){}}
var beforeNodeChange=this.fireEvent('beforeNodeChange',{type:'beforeNodeChange',target:this});if(beforeNodeChange===false){return false;}
if(this.get('dompath')){window.setTimeout(function(){self._writeDomPath.call(self);},0);}
if(!this.get('disabled')){if(this.STOP_NODE_CHANGE){this.STOP_NODE_CHANGE=false;return false;}else{var sel=this._getSelection(),range=this._getRange(),el=this._getSelectedElement(),fn_button=this.toolbar.getButtonByValue('fontname'),fs_button=this.toolbar.getButtonByValue('fontsize'),undo_button=this.toolbar.getButtonByValue('undo'),redo_button=this.toolbar.getButtonByValue('redo');var _ex={};if(this._lastButton){_ex[this._lastButton.id]=true;}
if(!this._isElement(el,'body')){if(fn_button){_ex[fn_button.get('id')]=true;}
if(fs_button){_ex[fs_button.get('id')]=true;}}
if(redo_button){delete _ex[redo_button.get('id')];}
this.toolbar.resetAllButtons(_ex);for(var d=0;d<this._disabled.length;d++){var _button=this.toolbar.getButtonByValue(this._disabled[d]);if(_button&&_button.get){if(this._lastButton&&(_button.get('id')===this._lastButton.id)){}else{if(!this._hasSelection()&&!this.get('insert')){switch(this._disabled[d]){case'fontname':case'fontsize':break;default:this.toolbar.disableButton(_button);}}else{if(!this._alwaysDisabled[this._disabled[d]]){this.toolbar.enableButton(_button);}}
if(!this._alwaysEnabled[this._disabled[d]]){this.toolbar.deselectButton(_button);}}}}
var path=this._getDomPath();var tag=null,cmd=null;for(var i=0;i<path.length;i++){tag=path[i].tagName.toLowerCase();if(path[i].getAttribute('tag')){tag=path[i].getAttribute('tag').toLowerCase();}
cmd=this._tag2cmd[tag];if(cmd===undefined){cmd=[];}
if(!Lang.isArray(cmd)){cmd=[cmd];}
if(path[i].style.fontWeight.toLowerCase()=='bold'){cmd[cmd.length]='bold';}
if(path[i].style.fontStyle.toLowerCase()=='italic'){cmd[cmd.length]='italic';}
if(path[i].style.textDecoration.toLowerCase()=='underline'){cmd[cmd.length]='underline';}
if(path[i].style.textDecoration.toLowerCase()=='line-through'){cmd[cmd.length]='strikethrough';}
if(cmd.length>0){for(var j=0;j<cmd.length;j++){this.toolbar.selectButton(cmd[j]);this.toolbar.enableButton(cmd[j]);}}
switch(path[i].style.textAlign.toLowerCase()){case'left':case'right':case'center':case'justify':var alignType=path[i].style.textAlign.toLowerCase();if(path[i].style.textAlign.toLowerCase()=='justify'){alignType='full';}
this.toolbar.selectButton('justify'+alignType);this.toolbar.enableButton('justify'+alignType);break;}}
if(fn_button){var family=fn_button._configs.label._initialConfig.value;fn_button.set('label','<span class="yui-toolbar-fontname-'+this._cleanClassName(family)+'">'+family+'</span>');this._updateMenuChecked('fontname',family);}
if(fs_button){fs_button.set('label',fs_button._configs.label._initialConfig.value);}
var hd_button=this.toolbar.getButtonByValue('heading');if(hd_button){hd_button.set('label',hd_button._configs.label._initialConfig.value);this._updateMenuChecked('heading','none');}
var img_button=this.toolbar.getButtonByValue('insertimage');if(img_button&&this.currentWindow&&(this.currentWindow.name=='insertimage')){this.toolbar.disableButton(img_button);}
if(this._lastButton&&this._lastButton.isSelected){this.toolbar.deselectButton(this._lastButton.id);}
this._undoNodeChange();}}
this.fireEvent('afterNodeChange',{type:'afterNodeChange',target:this});},_updateMenuChecked:function(button,value,tbar){if(!tbar){tbar=this.toolbar;}
var _button=tbar.getButtonByValue(button);_button.checkValue(value);},_handleToolbarClick:function(ev){var value='';var str='';var cmd=ev.button.value;if(ev.button.menucmd){value=cmd;cmd=ev.button.menucmd;}
this._lastButton=ev.button;if(this.STOP_EXEC_COMMAND){this.STOP_EXEC_COMMAND=false;return false;}else{this.execCommand(cmd,value);if(!this.browser.webkit){var Fself=this;setTimeout(function(){Fself._focusWindow.call(Fself);},5);}}
Event.stopEvent(ev);},_setupAfterElement:function(){if(!this.beforeElement){this.beforeElement=document.createElement('h2');this.beforeElement.className='yui-editor-skipheader';this.beforeElement.tabIndex='-1';this.beforeElement.innerHTML=this.STR_BEFORE_EDITOR;this.get('element_cont').get('firstChild').insertBefore(this.beforeElement,this.toolbar.get('nextSibling'));}
if(!this.afterElement){this.afterElement=document.createElement('h2');this.afterElement.className='yui-editor-skipheader';this.afterElement.tabIndex='-1';this.afterElement.innerHTML=this.STR_LEAVE_EDITOR;this.get('element_cont').get('firstChild').appendChild(this.afterElement);}},_disableEditor:function(disabled){if(disabled){this._removeEditorEvents();if(!this._mask){if(!!this.browser.ie){this._setDesignMode('off');}
if(this.toolbar){this.toolbar.set('disabled',true);}
this._mask=document.createElement('DIV');Dom.setStyle(this._mask,'height','100%');Dom.setStyle(this._mask,'width','100%');Dom.setStyle(this._mask,'position','absolute');Dom.setStyle(this._mask,'top','0');Dom.setStyle(this._mask,'left','0');Dom.setStyle(this._mask,'opacity','.5');Dom.addClass(this._mask,'yui-editor-masked');this.get('iframe').get('parentNode').appendChild(this._mask);}}else{this._initEditorEvents();if(this._mask){this._mask.parentNode.removeChild(this._mask);this._mask=null;if(this.toolbar){this.toolbar.set('disabled',false);}
this._setDesignMode('on');this._focusWindow();var self=this;window.setTimeout(function(){self.nodeChange.call(self);},100);}}},SEP_DOMPATH:'<',STR_LEAVE_EDITOR:'You have left the Rich Text Editor.',STR_BEFORE_EDITOR:'This text field can contain stylized text and graphics. To cycle through all formatting options, use the keyboard shortcut Shift + Escape to place focus on the toolbar and navigate between options with your arrow keys. To exit this text editor use the Escape key and continue tabbing. <h4>Common formatting keyboard shortcuts:</h4><ul><li>Control Shift B sets text to bold</li> <li>Control Shift I sets text to italic</li> <li>Control Shift U underlines text</li> <li>Control Shift L adds an HTML link</li></ul>',STR_TITLE:'Rich Text Area.',STR_IMAGE_HERE:'Image URL Here',STR_LINK_URL:'Link URL',STOP_EXEC_COMMAND:false,STOP_NODE_CHANGE:false,CLASS_NOEDIT:'yui-noedit',CLASS_CONTAINER:'yui-editor-container',CLASS_EDITABLE:'yui-editor-editable',CLASS_EDITABLE_CONT:'yui-editor-editable-container',CLASS_PREFIX:'yui-editor',browser:function(){var br=YAHOO.env.ua;if(br.webkit>=420){br.webkit3=br.webkit;}else{br.webkit3=0;}
br.mac=false;if(navigator.userAgent.indexOf('Macintosh')!==-1){br.mac=true;}
return br;}(),init:function(p_oElement,p_oAttributes){if(!this._defaultToolbar){this._defaultToolbar={collapse:true,titlebar:'Text Editing Tools',draggable:false,buttons:[{group:'fontstyle',label:'Font Name and Size',buttons:[{type:'select',label:'Arial',value:'fontname',disabled:true,menu:[{text:'Arial',checked:true},{text:'Arial Black'},{text:'Comic Sans MS'},{text:'Courier New'},{text:'Lucida Console'},{text:'Tahoma'},{text:'Times New Roman'},{text:'Trebuchet MS'},{text:'Verdana'}]},{type:'spin',label:'13',value:'fontsize',range:[9,75],disabled:true}]},{type:'separator'},{group:'textstyle',label:'Font Style',buttons:[{type:'push',label:'Bold CTRL + SHIFT + B',value:'bold'},{type:'push',label:'Italic CTRL + SHIFT + I',value:'italic'},{type:'push',label:'Underline CTRL + SHIFT + U',value:'underline'},{type:'push',label:'Strike Through',value:'strikethrough'},{type:'separator'},{type:'color',label:'Font Color',value:'forecolor',disabled:true},{type:'color',label:'Background Color',value:'backcolor',disabled:true}]},{type:'separator'},{group:'indentlist',label:'Lists',buttons:[{type:'push',label:'Create an Unordered List',value:'insertunorderedlist'},{type:'push',label:'Create an Ordered List',value:'insertorderedlist'}]},{type:'separator'},{group:'insertitem',label:'Insert Item',buttons:[{type:'push',label:'HTML Link CTRL + SHIFT + L',value:'createlink',disabled:true},{type:'push',label:'Insert Image',value:'insertimage'}]}]};}
YAHOO.widget.SimpleEditor.superclass.init.call(this,p_oElement,p_oAttributes);YAHOO.widget.EditorInfo._instances[this.get('id')]=this;this.currentElement=[];this.on('contentReady',function(){this.DOMReady=true;this.fireQueue();},this,true);},initAttributes:function(attr){YAHOO.widget.SimpleEditor.superclass.initAttributes.call(this,attr);var self=this;this.setAttributeConfig('nodeChangeDelay',{value:((attr.nodeChangeDelay===false)?false:true)});this.setAttributeConfig('maxUndo',{writeOnce:true,value:attr.maxUndo||30});this.setAttributeConfig('ptags',{writeOnce:true,value:attr.ptags||false});this.setAttributeConfig('insert',{writeOnce:true,value:attr.insert||false,method:function(insert){if(insert){var buttons={fontname:true,fontsize:true,forecolor:true,backcolor:true};var tmp=this._defaultToolbar.buttons;for(var i=0;i<tmp.length;i++){if(tmp[i].buttons){for(var a=0;a<tmp[i].buttons.length;a++){if(tmp[i].buttons[a].value){if(buttons[tmp[i].buttons[a].value]){delete tmp[i].buttons[a].disabled;}}}}}}}});this.setAttributeConfig('container',{writeOnce:true,value:attr.container||false});this.setAttributeConfig('plainText',{writeOnce:true,value:attr.plainText||false});this.setAttributeConfig('iframe',{value:null});this.setAttributeConfig('textarea',{value:null,writeOnce:true});this.setAttributeConfig('container',{readOnly:true,value:null});this.setAttributeConfig('nodeChangeThreshold',{value:attr.nodeChangeThreshold||3,validator:YAHOO.lang.isNumber});this.setAttributeConfig('allowNoEdit',{value:attr.allowNoEdit||false,validator:YAHOO.lang.isBoolean});this.setAttributeConfig('limitCommands',{value:attr.limitCommands||false,validator:YAHOO.lang.isBoolean});this.setAttributeConfig('element_cont',{value:attr.element_cont});this.setAttributeConfig('editor_wrapper',{value:attr.editor_wrapper||null,writeOnce:true});this.setAttributeConfig('height',{value:attr.height||Dom.getStyle(self.get('element'),'height'),method:function(height){if(this._rendered){if(this.get('animate')){var anim=new YAHOO.util.Anim(this.get('iframe').get('parentNode'),{height:{to:parseInt(height,10)}},0.5);anim.animate();}else{Dom.setStyle(this.get('iframe').get('parentNode'),'height',height);}}}});this.setAttributeConfig('autoHeight',{value:attr.autoHeight||false,method:function(a){if(a){if(this.get('iframe')){this.get('iframe').get('element').setAttribute('scrolling','no');}
this.on('afterNodeChange',this._handleAutoHeight,this,true);this.on('editorKeyDown',this._handleAutoHeight,this,true);this.on('editorKeyPress',this._handleAutoHeight,this,true);}else{if(this.get('iframe')){this.get('iframe').get('element').setAttribute('scrolling','auto');}
this.unsubscribe('afterNodeChange',this._handleAutoHeight);this.unsubscribe('editorKeyDown',this._handleAutoHeight);this.unsubscribe('editorKeyPress',this._handleAutoHeight);}}});this.setAttributeConfig('width',{value:attr.width||Dom.getStyle(this.get('element'),'width'),method:function(width){if(this._rendered){if(this.get('animate')){var anim=new YAHOO.util.Anim(this.get('element_cont').get('element'),{width:{to:parseInt(width,10)}},0.5);anim.animate();}else{this.get('element_cont').setStyle('width',width);}}}});this.setAttributeConfig('blankimage',{value:attr.blankimage||this._getBlankImage()});this.setAttributeConfig('css',{value:attr.css||this._defaultCSS,writeOnce:true});this.setAttributeConfig('html',{value:attr.html||'<html><head><title>{TITLE}</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><base href="'+this._baseHREF+'"><style>{CSS}</style><style>{HIDDEN_CSS}</style><style>{EXTRA_CSS}</style></head><body onload="document.body._rteLoaded = true;">{CONTENT}</body></html>',writeOnce:true});this.setAttributeConfig('extracss',{value:attr.extracss||'',writeOnce:true});this.setAttributeConfig('handleSubmit',{value:attr.handleSubmit||false,method:function(exec){if(this.get('element').form){if(!this._formButtons){this._formButtons=[];}
if(exec){Event.on(this.get('element').form,'submit',this._handleFormSubmit,this,true);var i=this.get('element').form.getElementsByTagName('input');for(var s=0;s<i.length;s++){var type=i[s].getAttribute('type');if(type&&(type.toLowerCase()=='submit')){Event.on(i[s],'click',this._handleFormButtonClick,this,true);this._formButtons[this._formButtons.length]=i[s];}}}else{Event.removeListener(this.get('element').form,'submit',this._handleFormSubmit);if(this._formButtons){Event.removeListener(this._formButtons,'click',this._handleFormButtonClick);}}}}});this.setAttributeConfig('disabled',{value:false,method:function(disabled){if(this._rendered){this._disableEditor(disabled);}}});this.setAttributeConfig('saveEl',{value:this.get('element')});this.setAttributeConfig('toolbar_cont',{value:null,writeOnce:true});this.setAttributeConfig('toolbar',{value:attr.toolbar||this._defaultToolbar,writeOnce:true,method:function(toolbar){if(!toolbar.buttonType){toolbar.buttonType=this._defaultToolbar.buttonType;}
this._defaultToolbar=toolbar;}});this.setAttributeConfig('animate',{value:((attr.animate)?((YAHOO.util.Anim)?true:false):false),validator:function(value){var ret=true;if(!YAHOO.util.Anim){ret=false;}
return ret;}});this.setAttributeConfig('panel',{value:null,writeOnce:true,validator:function(value){var ret=true;if(!YAHOO.widget.Overlay){ret=false;}
return ret;}});this.setAttributeConfig('focusAtStart',{value:attr.focusAtStart||false,writeOnce:true,method:function(fs){if(fs){this.on('editorContentLoaded',function(){var self=this;setTimeout(function(){self._focusWindow.call(self,true);self.editorDirty=false;},400);},this,true);}}});this.setAttributeConfig('dompath',{value:attr.dompath||false,method:function(dompath){if(dompath&&!this.dompath){this.dompath=document.createElement('DIV');this.dompath.id=this.get('id')+'_dompath';Dom.addClass(this.dompath,'dompath');this.get('element_cont').get('firstChild').appendChild(this.dompath);if(this.get('iframe')){this._writeDomPath();}}else if(!dompath&&this.dompath){this.dompath.parentNode.removeChild(this.dompath);this.dompath=null;}}});this.setAttributeConfig('markup',{value:attr.markup||'semantic',validator:function(markup){switch(markup.toLowerCase()){case'semantic':case'css':case'default':case'xhtml':return true;}
return false;}});this.setAttributeConfig('removeLineBreaks',{value:attr.removeLineBreaks||false,validator:YAHOO.lang.isBoolean});this.setAttributeConfig('drag',{writeOnce:true,value:attr.drag||false});this.setAttributeConfig('resize',{writeOnce:true,value:attr.resize||false});},_getBlankImage:function(){if(!this.DOMReady){this._queue[this._queue.length]=['_getBlankImage',arguments];return'';}
var img='';if(!this._blankImageLoaded){if(YAHOO.widget.EditorInfo.blankImage){this.set('blankimage',YAHOO.widget.EditorInfo.blankImage);this._blankImageLoaded=true;}else{var div=document.createElement('div');div.style.position='absolute';div.style.top='-9999px';div.style.left='-9999px';div.className=this.CLASS_PREFIX+'-blankimage';document.body.appendChild(div);img=YAHOO.util.Dom.getStyle(div,'background-image');img=img.replace('url(','').replace(')','').replace(/"/g,'');img=img.replace('app:/','');this.set('blankimage',img);this._blankImageLoaded=true;div.parentNode.removeChild(div);YAHOO.widget.EditorInfo.blankImage=img;}}else{img=this.get('blankimage');}
return img;},_handleAutoHeight:function(){var doc=this._getDoc(),body=doc.body,docEl=doc.documentElement;var height=parseInt(Dom.getStyle(this.get('editor_wrapper'),'height'),10);var newHeight=body.scrollHeight;if(this.browser.webkit){newHeight=docEl.scrollHeight;}
if(newHeight<parseInt(this.get('height'),10)){newHeight=parseInt(this.get('height'),10);}
if((height!=newHeight)&&(newHeight>=parseInt(this.get('height'),10))){Dom.setStyle(this.get('editor_wrapper'),'height',newHeight+'px');if(this.browser.ie){this.get('iframe').setStyle('height','99%');this.get('iframe').setStyle('zoom','1');var self=this;window.setTimeout(function(){self.get('iframe').setStyle('height','100%');},1);}}},_formButtons:null,_formButtonClicked:null,_handleFormButtonClick:function(ev){var tar=Event.getTarget(ev);this._formButtonClicked=tar;},_handleFormSubmit:function(ev){this.saveHTML();var form=this.get('element').form,tar=this._formButtonClicked||false;Event.removeListener(form,'submit',this._handleFormSubmit);if(YAHOO.env.ua.ie){if(tar&&!tar.disabled){tar.click();}}else{if(tar&&!tar.disabled){tar.click();}
var oEvent=document.createEvent("HTMLEvents");oEvent.initEvent("submit",true,true);form.dispatchEvent(oEvent);if(YAHOO.env.ua.webkit){if(YAHOO.lang.isFunction(form.submit)){form.submit();}}}},_handleFontSize:function(o){var button=this.toolbar.getButtonById(o.button.id);var value=button.get('label')+'px';this.execCommand('fontsize',value);this.STOP_EXEC_COMMAND=true;},_handleColorPicker:function(o){var cmd=o.button;var value='#'+o.color;if((cmd=='forecolor')||(cmd=='backcolor')){this.execCommand(cmd,value);}},_handleAlign:function(o){var cmd=null;for(var i=0;i<o.button.menu.length;i++){if(o.button.menu[i].value==o.button.value){cmd=o.button.menu[i].value;}}
var value=this._getSelection();this.execCommand(cmd,value);this.STOP_EXEC_COMMAND=true;},_handleAfterNodeChange:function(){var path=this._getDomPath(),elm=null,family=null,fontsize=null,validFont=false,fn_button=this.toolbar.getButtonByValue('fontname'),fs_button=this.toolbar.getButtonByValue('fontsize'),hd_button=this.toolbar.getButtonByValue('heading');for(var i=0;i<path.length;i++){elm=path[i];var tag=elm.tagName.toLowerCase();if(elm.getAttribute('tag')){tag=elm.getAttribute('tag');}
family=elm.getAttribute('face');if(Dom.getStyle(elm,'font-family')){family=Dom.getStyle(elm,'font-family');family=family.replace(/'/g,'');}
if(tag.substring(0,1)=='h'){if(hd_button){for(var h=0;h<hd_button._configs.menu.value.length;h++){if(hd_button._configs.menu.value[h].value.toLowerCase()==tag){hd_button.set('label',hd_button._configs.menu.value[h].text);}}
this._updateMenuChecked('heading',tag);}}}
if(fn_button){for(var b=0;b<fn_button._configs.menu.value.length;b++){if(family&&fn_button._configs.menu.value[b].text.toLowerCase()==family.toLowerCase()){validFont=true;family=fn_button._configs.menu.value[b].text;}}
if(!validFont){family=fn_button._configs.label._initialConfig.value;}
var familyLabel='<span class="yui-toolbar-fontname-'+this._cleanClassName(family)+'">'+family+'</span>';if(fn_button.get('label')!=familyLabel){fn_button.set('label',familyLabel);this._updateMenuChecked('fontname',family);}}
if(fs_button){fontsize=parseInt(Dom.getStyle(elm,'fontSize'),10);if((fontsize===null)||isNaN(fontsize)){fontsize=fs_button._configs.label._initialConfig.value;}
fs_button.set('label',''+fontsize);}
if(!this._isElement(elm,'body')&&!this._isElement(elm,'img')){this.toolbar.enableButton(fn_button);this.toolbar.enableButton(fs_button);this.toolbar.enableButton('forecolor');this.toolbar.enableButton('backcolor');}
if(this._isElement(elm,'img')){if(YAHOO.widget.Overlay){this.toolbar.enableButton('createlink');}}
if(this._hasParent(elm,'blockquote')){this.toolbar.selectButton('indent');this.toolbar.disableButton('indent');this.toolbar.enableButton('outdent');}
if(this._hasParent(elm,'ol')||this._hasParent(elm,'ul')){this.toolbar.disableButton('indent');}
this._lastButton=null;},_handleInsertImageClick:function(){if(this.get('limitCommands')){if(!this.toolbar.getButtonByValue('insertimage')){return false;}}
this.toolbar.set('disabled',true);this.on('afterExecCommand',function(){var el=this.currentElement[0],src='http://';if(!el){el=this._getSelectedElement();}
if(el){if(el.getAttribute('src')){src=el.getAttribute('src',2);if(src.indexOf(this.get('blankimage'))!=-1){src=this.STR_IMAGE_HERE;}}}
var str=prompt(this.STR_LINK_URL+': ',src);if((str!=='')&&(str!==null)){el.setAttribute('src',str);}else if(str===null){el.parentNode.removeChild(el);this.currentElement=[];this.nodeChange();}
this.closeWindow();this.toolbar.set('disabled',false);},this,true);},_handleInsertImageWindowClose:function(){this.nodeChange();},_isLocalFile:function(url){if((url)&&(url!=='')&&((url.indexOf('file:/')!=-1)||(url.indexOf(':\\')!=-1))){return true;}
return false;},_handleCreateLinkClick:function(){if(this.get('limitCommands')){if(!this.toolbar.getButtonByValue('createlink')){return false;}}
this.toolbar.set('disabled',true);this.on('afterExecCommand',function(){var el=this.currentElement[0],url='';if(el){if(el.getAttribute('href',2)!==null){url=el.getAttribute('href',2);}}
var str=prompt(this.STR_LINK_URL+': ',url);if((str!=='')&&(str!==null)){var urlValue=str;if((urlValue.indexOf(':/'+'/')==-1)&&(urlValue.substring(0,1)!='/')&&(urlValue.substring(0,6).toLowerCase()!='mailto')){if((urlValue.indexOf('@')!=-1)&&(urlValue.substring(0,6).toLowerCase()!='mailto')){urlValue='mailto:'+urlValue;}else{if(urlValue.substring(0,1)!='#'){}}}
el.setAttribute('href',urlValue);}else if(str!==null){var _span=this._getDoc().createElement('span');_span.innerHTML=el.innerHTML;Dom.addClass(_span,'yui-non');el.parentNode.replaceChild(_span,el);}
this.closeWindow();this.toolbar.set('disabled',false);},this);},_handleCreateLinkWindowClose:function(){this.nodeChange();this.currentElement=[];},render:function(){if(this._rendered){return false;}
if(!this.DOMReady){this._queue[this._queue.length]=['render',arguments];return false;}
if(this.get('element')){if(this.get('element').tagName){this._textarea=true;if(this.get('element').tagName.toLowerCase()!=='textarea'){this._textarea=false;}}else{return false;}}else{return false;}
this._rendered=true;var self=this;window.setTimeout(function(){self._render.call(self);},4);},_render:function(){var self=this;this.set('textarea',this.get('element'));this.get('element_cont').setStyle('display','none');this.get('element_cont').addClass(this.CLASS_CONTAINER);this.set('iframe',this._createIframe());window.setTimeout(function(){self._setInitialContent.call(self);},10);this.get('editor_wrapper').appendChild(this.get('iframe').get('element'));if(this.get('disabled')){this._disableEditor(true);}
var tbarConf=this.get('toolbar');if(tbarConf instanceof Toolbar){this.toolbar=tbarConf;this.toolbar.set('disabled',true);}else{tbarConf.disabled=true;this.toolbar=new Toolbar(this.get('toolbar_cont'),tbarConf);}
this.fireEvent('toolbarLoaded',{type:'toolbarLoaded',target:this.toolbar});this.toolbar.on('toolbarCollapsed',function(){if(this.currentWindow){this.moveWindow();}},this,true);this.toolbar.on('toolbarExpanded',function(){if(this.currentWindow){this.moveWindow();}},this,true);this.toolbar.on('fontsizeClick',this._handleFontSize,this,true);this.toolbar.on('colorPickerClicked',function(o){this._handleColorPicker(o);return false;},this,true);this.toolbar.on('alignClick',this._handleAlign,this,true);this.on('afterNodeChange',this._handleAfterNodeChange,this,true);this.toolbar.on('insertimageClick',this._handleInsertImageClick,this,true);this.on('windowinsertimageClose',this._handleInsertImageWindowClose,this,true);this.toolbar.on('createlinkClick',this._handleCreateLinkClick,this,true);this.on('windowcreatelinkClose',this._handleCreateLinkWindowClose,this,true);this.get('parentNode').replaceChild(this.get('element_cont').get('element'),this.get('element'));this.setStyle('visibility','hidden');this.setStyle('position','absolute');this.setStyle('top','-9999px');this.setStyle('left','-9999px');this.get('element_cont').appendChild(this.get('element'));this.get('element_cont').setStyle('display','block');Dom.addClass(this.get('iframe').get('parentNode'),this.CLASS_EDITABLE_CONT);this.get('iframe').addClass(this.CLASS_EDITABLE);this.get('element_cont').setStyle('width',this.get('width'));Dom.setStyle(this.get('iframe').get('parentNode'),'height',this.get('height'));this.get('iframe').setStyle('width','100%');this.get('iframe').setStyle('height','100%');this._setupDD();window.setTimeout(function(){self._setupAfterElement.call(self);},0);this.fireEvent('afterRender',{type:'afterRender',target:this});},execCommand:function(action,value){var beforeExec=this.fireEvent('beforeExecCommand',{type:'beforeExecCommand',target:this,args:arguments});if((beforeExec===false)||(this.STOP_EXEC_COMMAND)){this.STOP_EXEC_COMMAND=false;return false;}
this._lastCommand=action;this._setMarkupType(action);if(this.browser.ie){this._getWindow().focus();}
var exec=true;if(this.get('limitCommands')){if(!this.toolbar.getButtonByValue(action)){exec=false;}}
this.editorDirty=true;if((typeof this['cmd_'+action.toLowerCase()]=='function')&&exec){var retValue=this['cmd_'+action.toLowerCase()](value);exec=retValue[0];if(retValue[1]){action=retValue[1];}
if(retValue[2]){value=retValue[2];}}
if(exec){try{this._getDoc().execCommand(action,false,value);}catch(e){}}else{}
this.on('afterExecCommand',function(){this.unsubscribeAll('afterExecCommand');this.nodeChange();},this,true);this.fireEvent('afterExecCommand',{type:'afterExecCommand',target:this});},cmd_underline:function(value){if(!this.browser.webkit){var el=this._getSelectedElement();if(el&&this._isElement(el,'span')){if(el.style.textDecoration=='underline'){el.style.textDecoration='none';}else{el.style.textDecoration='underline';}
return[false];}}
return[true];},cmd_backcolor:function(value){var exec=true,el=this._getSelectedElement(),action='backcolor';if(this.browser.gecko||this.browser.opera){this._setEditorStyle(true);action='hilitecolor';}
if(!this._isElement(el,'body')&&!this._hasSelection()){Dom.setStyle(el,'background-color',value);this._selectNode(el);exec=false;}else if(!this._isElement(el,'body')&&this._hasSelection()){Dom.setStyle(el,'background-color',value);this._selectNode(el);exec=false;}else{if(this.get('insert')){el=this._createInsertElement({backgroundColor:value});}else{this._createCurrentElement('span',{backgroundColor:value});this._selectNode(this.currentElement[0]);}
exec=false;}
return[exec,action];},cmd_forecolor:function(value){var exec=true,el=this._getSelectedElement();if(!this._isElement(el,'body')&&!this._hasSelection()){Dom.setStyle(el,'color',value);this._selectNode(el);exec=false;}else if(!this._isElement(el,'body')&&this._hasSelection()){Dom.setStyle(el,'color',value);this._selectNode(el);exec=false;}else{if(this.get('insert')){el=this._createInsertElement({color:value});}else{this._createCurrentElement('span',{color:value});this._selectNode(this.currentElement[0]);}
exec=false;}
return[exec];},cmd_unlink:function(value){this._swapEl(this.currentElement[0],'span',function(el){el.className='yui-non';});return[false];},cmd_createlink:function(value){var el=this._getSelectedElement(),_a=null;if(this._hasParent(el,'a')){this.currentElement[0]=this._hasParent(el,'a');}else if(!this._isElement(el,'a')){this._createCurrentElement('a');_a=this._swapEl(this.currentElement[0],'a');this.currentElement[0]=_a;}else{this.currentElement[0]=el;}
return[false];},cmd_insertimage:function(value){var exec=true,_img=null,action='insertimage',el=this._getSelectedElement();if(value===''){value=this.get('blankimage');}
if(this._isElement(el,'img')){this.currentElement[0]=el;exec=false;}else{if(this._getDoc().queryCommandEnabled(action)){this._getDoc().execCommand('insertimage',false,value);var imgs=this._getDoc().getElementsByTagName('img');for(var i=0;i<imgs.length;i++){if(!YAHOO.util.Dom.hasClass(imgs[i],'yui-img')){YAHOO.util.Dom.addClass(imgs[i],'yui-img');this.currentElement[0]=imgs[i];}}
exec=false;}else{if(el==this._getDoc().body){_img=this._getDoc().createElement('img');_img.setAttribute('src',value);YAHOO.util.Dom.addClass(_img,'yui-img');this._getDoc().body.appendChild(_img);}else{this._createCurrentElement('img');_img=this._getDoc().createElement('img');_img.setAttribute('src',value);YAHOO.util.Dom.addClass(_img,'yui-img');this.currentElement[0].parentNode.replaceChild(_img,this.currentElement[0]);}
this.currentElement[0]=_img;exec=false;}}
return[exec];},cmd_inserthtml:function(value){var exec=true,action='inserthtml',_span=null,_range=null;if(this.browser.webkit&&!this._getDoc().queryCommandEnabled(action)){this._createCurrentElement('img');_span=this._getDoc().createElement('span');_span.innerHTML=value;this.currentElement[0].parentNode.replaceChild(_span,this.currentElement[0]);exec=false;}else if(this.browser.ie){_range=this._getRange();if(_range.item){_range.item(0).outerHTML=value;}else{_range.pasteHTML(value);}
exec=false;}
return[exec];},cmd_list:function(tag){var exec=true,list=null,li=0,el=null,str='',selEl=this._getSelectedElement(),action='insertorderedlist';if(tag=='ul'){action='insertunorderedlist';}
if(this.browser.webkit){if(this._isElement(selEl,'li')&&this._isElement(selEl.parentNode,tag)){el=selEl.parentNode;list=this._getDoc().createElement('span');YAHOO.util.Dom.addClass(list,'yui-non');str='';var lis=el.getElementsByTagName('li');for(li=0;li<lis.length;li++){str+='<div>'+lis[li].innerHTML+'</div>';}
list.innerHTML=str;this.currentElement[0]=el;this.currentElement[0].parentNode.replaceChild(list,this.currentElement[0]);}else{this._createCurrentElement(tag.toLowerCase());list=this._getDoc().createElement(tag);for(li=0;li<this.currentElement.length;li++){var newli=this._getDoc().createElement('li');newli.innerHTML=this.currentElement[li].innerHTML+'<span class="yui-non">&nbsp;</span>&nbsp;';list.appendChild(newli);if(li>0){this.currentElement[li].parentNode.removeChild(this.currentElement[li]);}}
this.currentElement[0].parentNode.replaceChild(list,this.currentElement[0]);this.currentElement[0]=list;var _h=this.currentElement[0].firstChild;_h=Dom.getElementsByClassName('yui-non','span',_h)[0];this._getSelection().setBaseAndExtent(_h,1,_h,_h.innerText.length);}
exec=false;}else{el=this._getSelectedElement();if(this._isElement(el,'li')&&this._isElement(el.parentNode,tag)||(this.browser.ie&&this._isElement(this._getRange().parentElement,'li'))||(this.browser.ie&&this._isElement(el,'ul'))||(this.browser.ie&&this._isElement(el,'ol'))){if(this.browser.ie){if((this.browser.ie&&this._isElement(el,'ul'))||(this.browser.ie&&this._isElement(el,'ol'))){el=el.getElementsByTagName('li')[0];}
str='';var lis2=el.parentNode.getElementsByTagName('li');for(var j=0;j<lis2.length;j++){str+=lis2[j].innerHTML+'<br>';}
var newEl=this._getDoc().createElement('span');newEl.innerHTML=str;el.parentNode.parentNode.replaceChild(newEl,el.parentNode);}else{this.nodeChange();this._getDoc().execCommand(action,'',el.parentNode);this.nodeChange();}
exec=false;}
if(this.browser.opera){var self=this;window.setTimeout(function(){var liso=self._getDoc().getElementsByTagName('li');for(var i=0;i<liso.length;i++){if(liso[i].innerHTML.toLowerCase()=='<br>'){liso[i].parentNode.parentNode.removeChild(liso[i].parentNode);}}},30);}
if(this.browser.ie&&exec){var html='';if(this._getRange().html){html='<li>'+this._getRange().html+'</li>';}else{var t=this._getRange().text.split('\n');if(t.length>1){html='';for(var ie=0;ie<t.length;ie++){html+='<li>'+t[ie]+'</li>';}}else{var txt=this._getRange().text;if(txt===''){html='<li id="new_list_item">'+txt+'</li>';}else{html='<li>'+txt+'</li>';}}}
this._getRange().pasteHTML('<'+tag+'>'+html+'</'+tag+'>');var new_item=this._getDoc().getElementById('new_list_item');if(new_item){var range=this._getDoc().body.createTextRange();range.moveToElementText(new_item);range.collapse(false);range.select();new_item.id='';}
exec=false;}}
return exec;},cmd_insertorderedlist:function(value){return[this.cmd_list('ol')];},cmd_insertunorderedlist:function(value){return[this.cmd_list('ul')];},cmd_fontname:function(value){var exec=true,selEl=this._getSelectedElement();this.currentFont=value;if(selEl&&selEl.tagName&&!this._hasSelection()&&!this._isElement(selEl,'body')&&!this.get('insert')){YAHOO.util.Dom.setStyle(selEl,'font-family',value);exec=false;}else if(this.get('insert')&&!this._hasSelection()){var el=this._createInsertElement({fontFamily:value});exec=false;}
return[exec];},cmd_fontsize:function(value){var el=null;if(this.currentElement&&(this.currentElement.length>0)&&(!this._hasSelection())&&(!this.get('insert'))){YAHOO.util.Dom.setStyle(this.currentElement,'fontSize',value);}else if(!this._isElement(this._getSelectedElement(),'body')){el=this._getSelectedElement();YAHOO.util.Dom.setStyle(el,'fontSize',value);if(this.get('insert')&&this.browser.ie){var r=this._getRange();r.collapse(false);r.select();}else{this._selectNode(el);}}else{if(this.get('insert')&&!this._hasSelection()){el=this._createInsertElement({fontSize:value});this.currentElement[0]=el;this._selectNode(this.currentElement[0]);}else{this._createCurrentElement('span',{'fontSize':value});this._selectNode(this.currentElement[0]);}}
return[false];},_swapEl:function(el,tagName,callback){var _el=this._getDoc().createElement(tagName);if(el){_el.innerHTML=el.innerHTML;}
if(typeof callback=='function'){callback.call(this,_el);}
if(el){el.parentNode.replaceChild(_el,el);}
return _el;},_createInsertElement:function(css){this._createCurrentElement('span',css);var el=this.currentElement[0];if(this.browser.webkit){el.innerHTML='<span class="yui-non">&nbsp;</span>';el=el.firstChild;this._getSelection().setBaseAndExtent(el,1,el,el.innerText.length);}else if(this.browser.ie||this.browser.opera){el.innerHTML='&nbsp;';}
this._focusWindow();this._selectNode(el,true);return el;},_createCurrentElement:function(tagName,tagStyle){tagName=((tagName)?tagName:'a');var tar=null,el=[],_doc=this._getDoc();if(this.currentFont){if(!tagStyle){tagStyle={};}
tagStyle.fontFamily=this.currentFont;this.currentFont=null;}
this.currentElement=[];var _elCreate=function(tagName,tagStyle){var el=null;tagName=((tagName)?tagName:'span');tagName=tagName.toLowerCase();switch(tagName){case'h1':case'h2':case'h3':case'h4':case'h5':case'h6':el=_doc.createElement(tagName);break;default:el=_doc.createElement(tagName);if(tagName==='span'){YAHOO.util.Dom.addClass(el,'yui-tag-'+tagName);YAHOO.util.Dom.addClass(el,'yui-tag');el.setAttribute('tag',tagName);}
for(var k in tagStyle){if(YAHOO.lang.hasOwnProperty(tagStyle,k)){el.style[k]=tagStyle[k];}}
break;}
return el;};if(!this._hasSelection()){if(this._getDoc().queryCommandEnabled('insertimage')){this._getDoc().execCommand('insertimage',false,'yui-tmp-img');var imgs=this._getDoc().getElementsByTagName('img');for(var j=0;j<imgs.length;j++){if(imgs[j].getAttribute('src',2)=='yui-tmp-img'){el=_elCreate(tagName,tagStyle);imgs[j].parentNode.replaceChild(el,imgs[j]);this.currentElement[this.currentElement.length]=el;}}}else{if(this.currentEvent){tar=YAHOO.util.Event.getTarget(this.currentEvent);}else{tar=this._getDoc().body;}}
if(tar){el=_elCreate(tagName,tagStyle);if(this._isElement(tar,'body')||this._isElement(tar,'html')){if(this._isElement(tar,'html')){tar=this._getDoc().body;}
tar.appendChild(el);}else if(tar.nextSibling){tar.parentNode.insertBefore(el,tar.nextSibling);}else{tar.parentNode.appendChild(el);}
this.currentElement[this.currentElement.length]=el;this.currentEvent=null;if(this.browser.webkit){this._getSelection().setBaseAndExtent(el,0,el,0);if(this.browser.webkit3){this._getSelection().collapseToStart();}else{this._getSelection().collapse(true);}}}}else{this._setEditorStyle(true);this._getDoc().execCommand('fontname',false,'yui-tmp');var _tmp=[],__tmp,__els=['font','span','i','b','u'];if(!this._isElement(this._getSelectedElement(),'body')){__els[__els.length]=this._getDoc().getElementsByTagName(this._getSelectedElement().tagName);__els[__els.length]=this._getDoc().getElementsByTagName(this._getSelectedElement().parentNode.tagName);}
for(var _els=0;_els<__els.length;_els++){var _tmp1=this._getDoc().getElementsByTagName(__els[_els]);for(var e=0;e<_tmp1.length;e++){_tmp[_tmp.length]=_tmp1[e];}}
for(var i=0;i<_tmp.length;i++){if((YAHOO.util.Dom.getStyle(_tmp[i],'font-family')=='yui-tmp')||(_tmp[i].face&&(_tmp[i].face=='yui-tmp'))){el=_elCreate(tagName,tagStyle);el.innerHTML=_tmp[i].innerHTML;if(this._isElement(_tmp[i],'ol')||(this._isElement(_tmp[i],'ul'))){var fc=_tmp[i].getElementsByTagName('li')[0];_tmp[i].style.fontFamily='inherit';fc.style.fontFamily='inherit';el.innerHTML=fc.innerHTML;fc.innerHTML='';fc.appendChild(el);this.currentElement[this.currentElement.length]=el;}else if(this._isElement(_tmp[i],'li')){_tmp[i].innerHTML='';_tmp[i].appendChild(el);_tmp[i].style.fontFamily='inherit';this.currentElement[this.currentElement.length]=el;}else{if(_tmp[i].parentNode){_tmp[i].parentNode.replaceChild(el,_tmp[i]);this.currentElement[this.currentElement.length]=el;this.currentEvent=null;if(this.browser.webkit){this._getSelection().setBaseAndExtent(el,0,el,0);if(this.browser.webkit3){this._getSelection().collapseToStart();}else{this._getSelection().collapse(true);}}
if(this.browser.ie&&tagStyle&&tagStyle.fontSize){this._getSelection().empty();}
if(this.browser.gecko){this._getSelection().collapseToStart();}}}}}
var len=this.currentElement.length;for(var o=0;o<len;o++){if((o+1)!=len){if(this.currentElement[o]&&this.currentElement[o].nextSibling){if(this._isElement(this.currentElement[o],'br')){this.currentElement[this.currentElement.length]=this.currentElement[o].nextSibling;}}}}}},saveHTML:function(){var html=this.cleanHTML();if(this._textarea){this.get('element').value=html;}else{this.get('element').innerHTML=html;}
if(this.get('saveEl')!==this.get('element')){var out=this.get('saveEl');if(Lang.isString(out)){out=Dom.get(out);}
if(out){if(out.tagName.toLowerCase()==='textarea'){out.value=html;}else{out.innerHTML=html;}}}
return html;},setEditorHTML:function(incomingHTML){var html=this._cleanIncomingHTML(incomingHTML);this._getDoc().body.innerHTML=html;this.nodeChange();},getEditorHTML:function(){var b=this._getDoc().body;if(b===null){return null;}
return this._getDoc().body.innerHTML;},show:function(){if(this.browser.gecko){this._setDesignMode('on');this._focusWindow();}
if(this.browser.webkit){var self=this;window.setTimeout(function(){self._setInitialContent.call(self);},10);}
if(this.currentWindow){this.closeWindow();}
this.get('iframe').setStyle('position','static');this.get('iframe').setStyle('left','');},hide:function(){if(this.currentWindow){this.closeWindow();}
if(this._fixNodesTimer){clearTimeout(this._fixNodesTimer);this._fixNodesTimer=null;}
if(this._nodeChangeTimer){clearTimeout(this._nodeChangeTimer);this._nodeChangeTimer=null;}
this._lastNodeChange=0;this.get('iframe').setStyle('position','absolute');this.get('iframe').setStyle('left','-9999px');},_cleanIncomingHTML:function(html){html=html.replace(/<strong([^>]*)>/gi,'<b$1>');html=html.replace(/<\/strong>/gi,'</b>');html=html.replace(/<embed([^>]*)>/gi,'<YUI_EMBED$1>');html=html.replace(/<\/embed>/gi,'</YUI_EMBED>');html=html.replace(/<em([^>]*)>/gi,'<i$1>');html=html.replace(/<\/em>/gi,'</i>');html=html.replace(/<YUI_EMBED([^>]*)>/gi,'<embed$1>');html=html.replace(/<\/YUI_EMBED>/gi,'</embed>');if(this.get('plainText')){html=html.replace(/\n/g,'<br>').replace(/\r/g,'<br>');html=html.replace(/  /gi,'&nbsp;&nbsp;');html=html.replace(/\t/gi,'&nbsp;&nbsp;&nbsp;&nbsp;');}
html=html.replace(/<script([^>]*)>/gi,'<bad>');html=html.replace(/<\/script([^>]*)>/gi,'</bad>');html=html.replace(/&lt;script([^>]*)&gt;/gi,'<bad>');html=html.replace(/&lt;\/script([^>]*)&gt;/gi,'</bad>');html=html.replace(/\n/g,'<YUI_LF>').replace(/\r/g,'<YUI_LF>');html=html.replace(new RegExp('<bad([^>]*)>(.*?)<\/bad>','gi'),'');html=html.replace(/<YUI_LF>/g,'\n');return html;},cleanHTML:function(html){if(!html){html=this.getEditorHTML();}
var markup=this.get('markup');html=this.pre_filter_linebreaks(html,markup);html=html.replace(/<img([^>]*)\/>/gi,'<YUI_IMG$1>');html=html.replace(/<img([^>]*)>/gi,'<YUI_IMG$1>');html=html.replace(/<input([^>]*)\/>/gi,'<YUI_INPUT$1>');html=html.replace(/<input([^>]*)>/gi,'<YUI_INPUT$1>');html=html.replace(/<ul([^>]*)>/gi,'<YUI_UL$1>');html=html.replace(/<\/ul>/gi,'<\/YUI_UL>');html=html.replace(/<blockquote([^>]*)>/gi,'<YUI_BQ$1>');html=html.replace(/<\/blockquote>/gi,'<\/YUI_BQ>');html=html.replace(/<embed([^>]*)>/gi,'<YUI_EMBED$1>');html=html.replace(/<\/embed>/gi,'<\/YUI_EMBED>');if((markup=='semantic')||(markup=='xhtml')){html=html.replace(/<i(\s+[^>]*)?>/gi,'<em$1>');html=html.replace(/<\/i>/gi,'</em>');html=html.replace(/<b(\s+[^>]*)?>/gi,'<strong$1>');html=html.replace(/<\/b>/gi,'</strong>');}
html=html.replace(/<font/gi,'<font');html=html.replace(/<\/font>/gi,'</font>');html=html.replace(/<span/gi,'<span');html=html.replace(/<\/span>/gi,'</span>');if((markup=='semantic')||(markup=='xhtml')||(markup=='css')){html=html.replace(new RegExp('<font([^>]*)face="([^>]*)">(.*?)<\/font>','gi'),'<span $1 style="font-family: $2;">$3</span>');html=html.replace(/<u/gi,'<span style="text-decoration: underline;"');if(this.browser.webkit){html=html.replace(new RegExp('<span class="Apple-style-span" style="font-weight: bold;">([^>]*)<\/span>','gi'),'<strong>$1</strong>');html=html.replace(new RegExp('<span class="Apple-style-span" style="font-style: italic;">([^>]*)<\/span>','gi'),'<em>$1</em>');}
html=html.replace(/\/u>/gi,'/span>');if(markup=='css'){html=html.replace(/<em([^>]*)>/gi,'<i$1>');html=html.replace(/<\/em>/gi,'</i>');html=html.replace(/<strong([^>]*)>/gi,'<b$1>');html=html.replace(/<\/strong>/gi,'</b>');html=html.replace(/<b/gi,'<span style="font-weight: bold;"');html=html.replace(/\/b>/gi,'/span>');html=html.replace(/<i/gi,'<span style="font-style: italic;"');html=html.replace(/\/i>/gi,'/span>');}
html=html.replace(/  /gi,' ');}else{html=html.replace(/<u/gi,'<u');html=html.replace(/\/u>/gi,'/u>');}
html=html.replace(/<ol([^>]*)>/gi,'<ol$1>');html=html.replace(/\/ol>/gi,'/ol>');html=html.replace(/<li/gi,'<li');html=html.replace(/\/li>/gi,'/li>');html=this.filter_safari(html);html=this.filter_internals(html);html=this.filter_all_rgb(html);html=this.post_filter_linebreaks(html,markup);if(markup=='xhtml'){html=html.replace(/<YUI_IMG([^>]*)>/g,'<img $1 />');html=html.replace(/<YUI_INPUT([^>]*)>/g,'<input $1 />');}else{html=html.replace(/<YUI_IMG([^>]*)>/g,'<img $1>');html=html.replace(/<YUI_INPUT([^>]*)>/g,'<input $1>');}
html=html.replace(/<YUI_UL([^>]*)>/g,'<ul$1>');html=html.replace(/<\/YUI_UL>/g,'<\/ul>');html=this.filter_invalid_lists(html);html=html.replace(/<YUI_BQ([^>]*)>/g,'<blockquote$1>');html=html.replace(/<\/YUI_BQ>/g,'<\/blockquote>');html=html.replace(/<YUI_EMBED([^>]*)>/g,'<embed$1>');html=html.replace(/<\/YUI_EMBED>/g,'<\/embed>');html=html.replace(' &amp; ','YUI_AMP');html=html.replace('&amp;','&');html=html.replace('YUI_AMP','&amp;');html=YAHOO.lang.trim(html);if(this.get('removeLineBreaks')){html=html.replace(/\n/g,'').replace(/\r/g,'');html=html.replace(/  /gi,' ');}
if(html.substring(0,6).toLowerCase()=='<span>'){html=html.substring(6);if(html.substring(html.length-7,html.length).toLowerCase()=='</span>'){html=html.substring(0,html.length-7);}}
for(var v in this.invalidHTML){if(YAHOO.lang.hasOwnProperty(this.invalidHTML,v)){if(Lang.isObject(v)&&v.keepContents){html=html.replace(new RegExp('<'+v+'([^>]*)>(.*?)<\/'+v+'>','gi'),'$1');}else{html=html.replace(new RegExp('<'+v+'([^>]*)>(.*?)<\/'+v+'>','gi'),'');}}}
this.fireEvent('cleanHTML',{type:'cleanHTML',target:this,html:html});return html;},filter_invalid_lists:function(html){html=html.replace(/<\/li>\n/gi,'</li>');html=html.replace(/<\/li><ol>/gi,'</li><li><ol>');html=html.replace(/<\/ol>/gi,'</ol></li>');html=html.replace(/<\/ol><\/li>\n/gi,"</ol>\n");html=html.replace(/<\/li><ul>/gi,'</li><li><ul>');html=html.replace(/<\/ul>/gi,'</ul></li>');html=html.replace(/<\/ul><\/li>\n?/gi,"</ul>\n");html=html.replace(/<\/li>/gi,"</li>\n");html=html.replace(/<\/ol>/gi,"</ol>\n");html=html.replace(/<ol>/gi,"<ol>\n");html=html.replace(/<ul>/gi,"<ul>\n");return html;},filter_safari:function(html){if(this.browser.webkit){html=html.replace(/<span class="Apple-tab-span" style="white-space:pre">([^>])<\/span>/gi,'&nbsp;&nbsp;&nbsp;&nbsp;');html=html.replace(/Apple-style-span/gi,'');html=html.replace(/style="line-height: normal;"/gi,'');html=html.replace(/<li><\/li>/gi,'');html=html.replace(/<li> <\/li>/gi,'');html=html.replace(/<li>  <\/li>/gi,'');if(this.get('ptags')){html=html.replace(/<div([^>]*)>/g,'<p$1>');html=html.replace(/<\/div>/gi,'</p>');}else{html=html.replace(/<div>/gi,'');html=html.replace(/<\/div>/gi,'<br>');}}
return html;},filter_internals:function(html){html=html.replace(/\r/g,'');html=html.replace(/<\/?(body|head|html)[^>]*>/gi,'');html=html.replace(/<YUI_BR><\/li>/gi,'</li>');html=html.replace(/yui-tag-span/gi,'');html=html.replace(/yui-tag/gi,'');html=html.replace(/yui-non/gi,'');html=html.replace(/yui-img/gi,'');html=html.replace(/ tag="span"/gi,'');html=html.replace(/ class=""/gi,'');html=html.replace(/ style=""/gi,'');html=html.replace(/ class=" "/gi,'');html=html.replace(/ class="  "/gi,'');html=html.replace(/ target=""/gi,'');html=html.replace(/ title=""/gi,'');if(this.browser.ie){html=html.replace(/ class= /gi,'');html=html.replace(/ class= >/gi,'');html=html.replace(/_height="([^>])"/gi,'');html=html.replace(/_width="([^>])"/gi,'');}
return html;},filter_all_rgb:function(str){var exp=new RegExp("rgb\\s*?\\(\\s*?([0-9]+).*?,\\s*?([0-9]+).*?,\\s*?([0-9]+).*?\\)","gi");var arr=str.match(exp);if(Lang.isArray(arr)){for(var i=0;i<arr.length;i++){var color=this.filter_rgb(arr[i]);str=str.replace(arr[i].toString(),color);}}
return str;},filter_rgb:function(css){if(css.toLowerCase().indexOf('rgb')!=-1){var exp=new RegExp("(.*?)rgb\\s*?\\(\\s*?([0-9]+).*?,\\s*?([0-9]+).*?,\\s*?([0-9]+).*?\\)(.*?)","gi");var rgb=css.replace(exp,"$1,$2,$3,$4,$5").split(',');if(rgb.length==5){var r=parseInt(rgb[1],10).toString(16);var g=parseInt(rgb[2],10).toString(16);var b=parseInt(rgb[3],10).toString(16);r=r.length==1?'0'+r:r;g=g.length==1?'0'+g:g;b=b.length==1?'0'+b:b;css="#"+r+g+b;}}
return css;},pre_filter_linebreaks:function(html,markup){if(this.browser.webkit){html=html.replace(/<br class="khtml-block-placeholder">/gi,'<YUI_BR>');html=html.replace(/<br class="webkit-block-placeholder">/gi,'<YUI_BR>');}
html=html.replace(/<br>/gi,'<YUI_BR>');html=html.replace(/<br (.*?)>/gi,'<YUI_BR>');html=html.replace(/<br\/>/gi,'<YUI_BR>');html=html.replace(/<br \/>/gi,'<YUI_BR>');html=html.replace(/<div><YUI_BR><\/div>/gi,'<YUI_BR>');html=html.replace(/<p>(&nbsp;|&#160;)<\/p>/g,'<YUI_BR>');html=html.replace(/<p><br>&nbsp;<\/p>/gi,'<YUI_BR>');html=html.replace(/<p>&nbsp;<\/p>/gi,'<YUI_BR>');html=html.replace(/<YUI_BR>$/,'');html=html.replace(/<YUI_BR><\/p>/g,'</p>');if(this.browser.ie){html=html.replace(/&nbsp;&nbsp;&nbsp;&nbsp;/g,'\t');}
return html;},post_filter_linebreaks:function(html,markup){if(markup=='xhtml'){html=html.replace(/<YUI_BR>/g,'<br />');}else{html=html.replace(/<YUI_BR>/g,'<br>');}
return html;},clearEditorDoc:function(){this._getDoc().body.innerHTML='&nbsp;';},openWindow:function(win){},moveWindow:function(){},_closeWindow:function(){},closeWindow:function(){this.toolbar.resetAllButtons();this._focusWindow();},destroy:function(){if(this.resize){this.resize.destroy();}
if(this.dd){this.dd.unreg();}
if(this.get('panel')){this.get('panel').destroy();}
this.saveHTML();this.toolbar.destroy();this.setStyle('visibility','visible');this.setStyle('position','static');this.setStyle('top','');this.setStyle('left','');var textArea=this.get('element');this.get('element_cont').get('parentNode').replaceChild(textArea,this.get('element_cont').get('element'));this.get('element_cont').get('element').innerHTML='';this.set('handleSubmit',false);return true;},toString:function(){var str='SimpleEditor';if(this.get&&this.get('element_cont')){str='SimpleEditor (#'+this.get('element_cont').get('id')+')'+((this.get('disabled')?' Disabled':''));}
return str;}});YAHOO.widget.EditorInfo={_instances:{},blankImage:'',window:{},panel:null,getEditorById:function(id){if(!YAHOO.lang.isString(id)){id=id.id;}
if(this._instances[id]){return this._instances[id];}
return false;},toString:function(){var len=0;for(var i in this._instances){if(Lang.hasOwnProperty(this._instances,i)){len++;}}
return'Editor Info ('+len+' registered intance'+((len>1)?'s':'')+')';}};})();YAHOO.register("simpleeditor",YAHOO.widget.SimpleEditor,{version:"2.6.0",build:"1321"});(function(){var Dom=YAHOO.util.Dom,Event=YAHOO.util.Event,Lang=YAHOO.lang;if(YAHOO.widget.Button){YAHOO.widget.ToolbarButtonAdvanced=YAHOO.widget.Button;YAHOO.widget.ToolbarButtonAdvanced.prototype.buttonType='rich';YAHOO.widget.ToolbarButtonAdvanced.prototype.checkValue=function(value){var _menuItems=this.getMenu().getItems();if(_menuItems.length===0){this.getMenu()._onBeforeShow();_menuItems=this.getMenu().getItems();}
for(var i=0;i<_menuItems.length;i++){_menuItems[i].cfg.setProperty('checked',false);if(_menuItems[i].value==value){_menuItems[i].cfg.setProperty('checked',true);}}};}else{YAHOO.widget.ToolbarButtonAdvanced=function(){};}
YAHOO.widget.ToolbarButton=function(el,attrs){if(Lang.isObject(arguments[0])&&!Dom.get(el).nodeType){attrs=el;}
var local_attrs=(attrs||{});var oConfig={element:null,attributes:local_attrs};if(!oConfig.attributes.type){oConfig.attributes.type='push';}
oConfig.element=document.createElement('span');oConfig.element.setAttribute('unselectable','on');oConfig.element.className='yui-button yui-'+oConfig.attributes.type+'-button';oConfig.element.innerHTML='<span class="first-child"><a href="#">LABEL</a></span>';oConfig.element.firstChild.firstChild.tabIndex='-1';oConfig.attributes.id=Dom.generateId();YAHOO.widget.ToolbarButton.superclass.constructor.call(this,oConfig.element,oConfig.attributes);};YAHOO.extend(YAHOO.widget.ToolbarButton,YAHOO.util.Element,{buttonType:'normal',_handleMouseOver:function(){if(!this.get('disabled')){this.addClass('yui-button-hover');this.addClass('yui-'+this.get('type')+'-button-hover');}},_handleMouseOut:function(){this.removeClass('yui-button-hover');this.removeClass('yui-'+this.get('type')+'-button-hover');},checkValue:function(value){if(this.get('type')=='menu'){var opts=this._button.options;for(var i=0;i<opts.length;i++){if(opts[i].value==value){opts.selectedIndex=i;}}}},init:function(p_oElement,p_oAttributes){YAHOO.widget.ToolbarButton.superclass.init.call(this,p_oElement,p_oAttributes);this.on('mouseover',this._handleMouseOver,this,true);this.on('mouseout',this._handleMouseOut,this,true);},initAttributes:function(attr){YAHOO.widget.ToolbarButton.superclass.initAttributes.call(this,attr);this.setAttributeConfig('value',{value:attr.value});this.setAttributeConfig('menu',{value:attr.menu||false});this.setAttributeConfig('type',{value:attr.type,writeOnce:true,method:function(type){var el,opt;if(!this._button){this._button=this.get('element').getElementsByTagName('a')[0];}
switch(type){case'select':case'menu':el=document.createElement('select');var menu=this.get('menu');for(var i=0;i<menu.length;i++){opt=document.createElement('option');opt.innerHTML=menu[i].text;opt.value=menu[i].value;if(menu[i].checked){opt.selected=true;}
el.appendChild(opt);}
this._button.parentNode.replaceChild(el,this._button);Event.on(el,'change',this._handleSelect,this,true);this._button=el;break;}}});this.setAttributeConfig('disabled',{value:attr.disabled||false,method:function(disabled){if(disabled){this.addClass('yui-button-disabled');this.addClass('yui-'+this.get('type')+'-button-disabled');}else{this.removeClass('yui-button-disabled');this.removeClass('yui-'+this.get('type')+'-button-disabled');}
if(this.get('type')=='menu'){this._button.disabled=disabled;}}});this.setAttributeConfig('label',{value:attr.label,method:function(label){if(!this._button){this._button=this.get('element').getElementsByTagName('a')[0];}
if(this.get('type')=='push'){this._button.innerHTML=label;}}});this.setAttributeConfig('title',{value:attr.title});this.setAttributeConfig('container',{value:null,writeOnce:true,method:function(cont){this.appendTo(cont);}});},_handleSelect:function(ev){var tar=Event.getTarget(ev);var value=tar.options[tar.selectedIndex].value;this.fireEvent('change',{type:'change',value:value});},getMenu:function(){return this.get('menu');},destroy:function(){Event.purgeElement(this.get('element'),true);this.get('element').parentNode.removeChild(this.get('element'));for(var i in this){if(Lang.hasOwnProperty(this,i)){this[i]=null;}}},fireEvent:function(p_sType,p_aArgs){if(this.DOM_EVENTS[p_sType]&&this.get('disabled')){return;}
YAHOO.widget.ToolbarButton.superclass.fireEvent.call(this,p_sType,p_aArgs);},toString:function(){return'ToolbarButton ('+this.get('id')+')';}});})();(function(){var Dom=YAHOO.util.Dom,Event=YAHOO.util.Event,Lang=YAHOO.lang;var getButton=function(id){var button=id;if(Lang.isString(id)){button=this.getButtonById(id);}
if(Lang.isNumber(id)){button=this.getButtonByIndex(id);}
if((!(button instanceof YAHOO.widget.ToolbarButton))&&(!(button instanceof YAHOO.widget.ToolbarButtonAdvanced))){button=this.getButtonByValue(id);}
if((button instanceof YAHOO.widget.ToolbarButton)||(button instanceof YAHOO.widget.ToolbarButtonAdvanced)){return button;}
return false;};YAHOO.widget.Toolbar=function(el,attrs){if(Lang.isObject(arguments[0])&&!Dom.get(el).nodeType){attrs=el;}
var local_attrs={};if(attrs){Lang.augmentObject(local_attrs,attrs);}
var oConfig={element:null,attributes:local_attrs};if(Lang.isString(el)&&Dom.get(el)){oConfig.element=Dom.get(el);}else if(Lang.isObject(el)&&Dom.get(el)&&Dom.get(el).nodeType){oConfig.element=Dom.get(el);}
if(!oConfig.element){oConfig.element=document.createElement('DIV');oConfig.element.id=Dom.generateId();if(local_attrs.container&&Dom.get(local_attrs.container)){Dom.get(local_attrs.container).appendChild(oConfig.element);}}
if(!oConfig.element.id){oConfig.element.id=((Lang.isString(el))?el:Dom.generateId());}
var fs=document.createElement('fieldset');var lg=document.createElement('legend');lg.innerHTML='Toolbar';fs.appendChild(lg);var cont=document.createElement('DIV');oConfig.attributes.cont=cont;Dom.addClass(cont,'yui-toolbar-subcont');fs.appendChild(cont);oConfig.element.appendChild(fs);oConfig.element.tabIndex=-1;oConfig.attributes.element=oConfig.element;oConfig.attributes.id=oConfig.element.id;YAHOO.widget.Toolbar.superclass.constructor.call(this,oConfig.element,oConfig.attributes);};YAHOO.extend(YAHOO.widget.Toolbar,YAHOO.util.Element,{_addMenuClasses:function(ev,na,o){Dom.addClass(this.element,'yui-toolbar-'+o.get('value')+'-menu');if(Dom.hasClass(o._button.parentNode.parentNode,'yui-toolbar-select')){Dom.addClass(this.element,'yui-toolbar-select-menu');}
var items=this.getItems();for(var i=0;i<items.length;i++){Dom.addClass(items[i].element,'yui-toolbar-'+o.get('value')+'-'+((items[i].value)?items[i].value.replace(/ /g,'-').toLowerCase():items[i]._oText.nodeValue.replace(/ /g,'-').toLowerCase()));Dom.addClass(items[i].element,'yui-toolbar-'+o.get('value')+'-'+((items[i].value)?items[i].value.replace(/ /g,'-'):items[i]._oText.nodeValue.replace(/ /g,'-')));}},buttonType:YAHOO.widget.ToolbarButton,dd:null,_colorData:{'#111111':'Obsidian','#2D2D2D':'Dark Gray','#434343':'Shale','#5B5B5B':'Flint','#737373':'Gray','#8B8B8B':'Concrete','#A2A2A2':'Gray','#B9B9B9':'Titanium','#000000':'Black','#D0D0D0':'Light Gray','#E6E6E6':'Silver','#FFFFFF':'White','#BFBF00':'Pumpkin','#FFFF00':'Yellow','#FFFF40':'Banana','#FFFF80':'Pale Yellow','#FFFFBF':'Butter','#525330':'Raw Siena','#898A49':'Mildew','#AEA945':'Olive','#7F7F00':'Paprika','#C3BE71':'Earth','#E0DCAA':'Khaki','#FCFAE1':'Cream','#60BF00':'Cactus','#80FF00':'Chartreuse','#A0FF40':'Green','#C0FF80':'Pale Lime','#DFFFBF':'Light Mint','#3B5738':'Green','#668F5A':'Lime Gray','#7F9757':'Yellow','#407F00':'Clover','#8A9B55':'Pistachio','#B7C296':'Light Jade','#E6EBD5':'Breakwater','#00BF00':'Spring Frost','#00FF80':'Pastel Green','#40FFA0':'Light Emerald','#80FFC0':'Sea Foam','#BFFFDF':'Sea Mist','#033D21':'Dark Forrest','#438059':'Moss','#7FA37C':'Medium Green','#007F40':'Pine','#8DAE94':'Yellow Gray Green','#ACC6B5':'Aqua Lung','#DDEBE2':'Sea Vapor','#00BFBF':'Fog','#00FFFF':'Cyan','#40FFFF':'Turquoise Blue','#80FFFF':'Light Aqua','#BFFFFF':'Pale Cyan','#033D3D':'Dark Teal','#347D7E':'Gray Turquoise','#609A9F':'Green Blue','#007F7F':'Seaweed','#96BDC4':'Green Gray','#B5D1D7':'Soapstone','#E2F1F4':'Light Turquoise','#0060BF':'Summer Sky','#0080FF':'Sky Blue','#40A0FF':'Electric Blue','#80C0FF':'Light Azure','#BFDFFF':'Ice Blue','#1B2C48':'Navy','#385376':'Biscay','#57708F':'Dusty Blue','#00407F':'Sea Blue','#7792AC':'Sky Blue Gray','#A8BED1':'Morning Sky','#DEEBF6':'Vapor','#0000BF':'Deep Blue','#0000FF':'Blue','#4040FF':'Cerulean Blue','#8080FF':'Evening Blue','#BFBFFF':'Light Blue','#212143':'Deep Indigo','#373E68':'Sea Blue','#444F75':'Night Blue','#00007F':'Indigo Blue','#585E82':'Dockside','#8687A4':'Blue Gray','#D2D1E1':'Light Blue Gray','#6000BF':'Neon Violet','#8000FF':'Blue Violet','#A040FF':'Violet Purple','#C080FF':'Violet Dusk','#DFBFFF':'Pale Lavender','#302449':'Cool Shale','#54466F':'Dark Indigo','#655A7F':'Dark Violet','#40007F':'Violet','#726284':'Smoky Violet','#9E8FA9':'Slate Gray','#DCD1DF':'Violet White','#BF00BF':'Royal Violet','#FF00FF':'Fuchsia','#FF40FF':'Magenta','#FF80FF':'Orchid','#FFBFFF':'Pale Magenta','#4A234A':'Dark Purple','#794A72':'Medium Purple','#936386':'Cool Granite','#7F007F':'Purple','#9D7292':'Purple Moon','#C0A0B6':'Pale Purple','#ECDAE5':'Pink Cloud','#BF005F':'Hot Pink','#FF007F':'Deep Pink','#FF409F':'Grape','#FF80BF':'Electric Pink','#FFBFDF':'Pink','#451528':'Purple Red','#823857':'Purple Dino','#A94A76':'Purple Gray','#7F003F':'Rose','#BC6F95':'Antique Mauve','#D8A5BB':'Cool Marble','#F7DDE9':'Pink Granite','#C00000':'Apple','#FF0000':'Fire Truck','#FF4040':'Pale Red','#FF8080':'Salmon','#FFC0C0':'Warm Pink','#441415':'Sepia','#82393C':'Rust','#AA4D4E':'Brick','#800000':'Brick Red','#BC6E6E':'Mauve','#D8A3A4':'Shrimp Pink','#F8DDDD':'Shell Pink','#BF5F00':'Dark Orange','#FF7F00':'Orange','#FF9F40':'Grapefruit','#FFBF80':'Canteloupe','#FFDFBF':'Wax','#482C1B':'Dark Brick','#855A40':'Dirt','#B27C51':'Tan','#7F3F00':'Nutmeg','#C49B71':'Mustard','#E1C4A8':'Pale Tan','#FDEEE0':'Marble'},_colorPicker:null,STR_COLLAPSE:'Collapse Toolbar',STR_SPIN_LABEL:'Spin Button with value {VALUE}. Use Control Shift Up Arrow and Control Shift Down arrow keys to increase or decrease the value.',STR_SPIN_UP:'Click to increase the value of this input',STR_SPIN_DOWN:'Click to decrease the value of this input',_titlebar:null,browser:YAHOO.env.ua,_buttonList:null,_buttonGroupList:null,_sep:null,_sepCount:null,_dragHandle:null,_toolbarConfigs:{renderer:true},CLASS_CONTAINER:'yui-toolbar-container',CLASS_DRAGHANDLE:'yui-toolbar-draghandle',CLASS_SEPARATOR:'yui-toolbar-separator',CLASS_DISABLED:'yui-toolbar-disabled',CLASS_PREFIX:'yui-toolbar',init:function(p_oElement,p_oAttributes){YAHOO.widget.Toolbar.superclass.init.call(this,p_oElement,p_oAttributes);},initAttributes:function(attr){YAHOO.widget.Toolbar.superclass.initAttributes.call(this,attr);this.addClass(this.CLASS_CONTAINER);this.setAttributeConfig('buttonType',{value:attr.buttonType||'basic',writeOnce:true,validator:function(type){switch(type){case'advanced':case'basic':return true;}
return false;},method:function(type){if(type=='advanced'){if(YAHOO.widget.Button){this.buttonType=YAHOO.widget.ToolbarButtonAdvanced;}else{this.buttonType=YAHOO.widget.ToolbarButton;}}else{this.buttonType=YAHOO.widget.ToolbarButton;}}});this.setAttributeConfig('buttons',{value:[],writeOnce:true,method:function(data){for(var i in data){if(Lang.hasOwnProperty(data,i)){if(data[i].type=='separator'){this.addSeparator();}else if(data[i].group!==undefined){this.addButtonGroup(data[i]);}else{this.addButton(data[i]);}}}}});this.setAttributeConfig('disabled',{value:false,method:function(disabled){if(this.get('disabled')===disabled){return false;}
if(disabled){this.addClass(this.CLASS_DISABLED);this.set('draggable',false);this.disableAllButtons();}else{this.removeClass(this.CLASS_DISABLED);if(this._configs.draggable._initialConfig.value){this.set('draggable',true);}
this.resetAllButtons();}}});this.setAttributeConfig('cont',{value:attr.cont,readOnly:true});this.setAttributeConfig('grouplabels',{value:((attr.grouplabels===false)?false:true),method:function(grouplabels){if(grouplabels){Dom.removeClass(this.get('cont'),(this.CLASS_PREFIX+'-nogrouplabels'));}else{Dom.addClass(this.get('cont'),(this.CLASS_PREFIX+'-nogrouplabels'));}}});this.setAttributeConfig('titlebar',{value:false,method:function(titlebar){if(titlebar){if(this._titlebar&&this._titlebar.parentNode){this._titlebar.parentNode.removeChild(this._titlebar);}
this._titlebar=document.createElement('DIV');this._titlebar.tabIndex='-1';Event.on(this._titlebar,'focus',function(){this._handleFocus();},this,true);Dom.addClass(this._titlebar,this.CLASS_PREFIX+'-titlebar');if(Lang.isString(titlebar)){var h2=document.createElement('h2');h2.tabIndex='-1';h2.innerHTML='<a href="#" tabIndex="0">'+titlebar+'</a>';this._titlebar.appendChild(h2);Event.on(h2.firstChild,'click',function(ev){Event.stopEvent(ev);});Event.on([h2,h2.firstChild],'focus',function(){this._handleFocus();},this,true);}
if(this.get('firstChild')){this.insertBefore(this._titlebar,this.get('firstChild'));}else{this.appendChild(this._titlebar);}
if(this.get('collapse')){this.set('collapse',true);}}else if(this._titlebar){if(this._titlebar&&this._titlebar.parentNode){this._titlebar.parentNode.removeChild(this._titlebar);}}}});this.setAttributeConfig('collapse',{value:false,method:function(collapse){if(this._titlebar){var collapseEl=null;var el=Dom.getElementsByClassName('collapse','span',this._titlebar);if(collapse){if(el.length>0){return true;}
collapseEl=document.createElement('SPAN');collapseEl.innerHTML='X';collapseEl.title=this.STR_COLLAPSE;Dom.addClass(collapseEl,'collapse');this._titlebar.appendChild(collapseEl);Event.addListener(collapseEl,'click',function(){if(Dom.hasClass(this.get('cont').parentNode,'yui-toolbar-container-collapsed')){this.collapse(false);}else{this.collapse();}},this,true);}else{collapseEl=Dom.getElementsByClassName('collapse','span',this._titlebar);if(collapseEl[0]){if(Dom.hasClass(this.get('cont').parentNode,'yui-toolbar-container-collapsed')){this.collapse(false);}
collapseEl[0].parentNode.removeChild(collapseEl[0]);}}}}});this.setAttributeConfig('draggable',{value:(attr.draggable||false),method:function(draggable){if(draggable&&!this.get('titlebar')){if(!this._dragHandle){this._dragHandle=document.createElement('SPAN');this._dragHandle.innerHTML='|';this._dragHandle.setAttribute('title','Click to drag the toolbar');this._dragHandle.id=this.get('id')+'_draghandle';Dom.addClass(this._dragHandle,this.CLASS_DRAGHANDLE);if(this.get('cont').hasChildNodes()){this.get('cont').insertBefore(this._dragHandle,this.get('cont').firstChild);}else{this.get('cont').appendChild(this._dragHandle);}
this.dd=new YAHOO.util.DD(this.get('id'));this.dd.setHandleElId(this._dragHandle.id);}}else{if(this._dragHandle){this._dragHandle.parentNode.removeChild(this._dragHandle);this._dragHandle=null;this.dd=null;}}
if(this._titlebar){if(draggable){this.dd=new YAHOO.util.DD(this.get('id'));this.dd.setHandleElId(this._titlebar);Dom.addClass(this._titlebar,'draggable');}else{Dom.removeClass(this._titlebar,'draggable');if(this.dd){this.dd.unreg();this.dd=null;}}}},validator:function(value){var ret=true;if(!YAHOO.util.DD){ret=false;}
return ret;}});},addButtonGroup:function(oGroup){if(!this.get('element')){this._queue[this._queue.length]=['addButtonGroup',arguments];return false;}
if(!this.hasClass(this.CLASS_PREFIX+'-grouped')){this.addClass(this.CLASS_PREFIX+'-grouped');}
var div=document.createElement('DIV');Dom.addClass(div,this.CLASS_PREFIX+'-group');Dom.addClass(div,this.CLASS_PREFIX+'-group-'+oGroup.group);if(oGroup.label){var label=document.createElement('h3');label.innerHTML=oGroup.label;div.appendChild(label);}
if(!this.get('grouplabels')){Dom.addClass(this.get('cont'),this.CLASS_PREFIX,'-nogrouplabels');}
this.get('cont').appendChild(div);var ul=document.createElement('ul');div.appendChild(ul);if(!this._buttonGroupList){this._buttonGroupList={};}
this._buttonGroupList[oGroup.group]=ul;for(var i=0;i<oGroup.buttons.length;i++){var li=document.createElement('li');li.className=this.CLASS_PREFIX+'-groupitem';ul.appendChild(li);if((oGroup.buttons[i].type!==undefined)&&oGroup.buttons[i].type=='separator'){this.addSeparator(li);}else{oGroup.buttons[i].container=li;this.addButton(oGroup.buttons[i]);}}},addButtonToGroup:function(oButton,group,after){var groupCont=this._buttonGroupList[group];var li=document.createElement('li');li.className=this.CLASS_PREFIX+'-groupitem';oButton.container=li;this.addButton(oButton,after);groupCont.appendChild(li);},addButton:function(oButton,after){if(!this.get('element')){this._queue[this._queue.length]=['addButton',arguments];return false;}
if(!this._buttonList){this._buttonList=[];}
if(!oButton.container){oButton.container=this.get('cont');}
if((oButton.type=='menu')||(oButton.type=='split')||(oButton.type=='select')){if(Lang.isArray(oButton.menu)){for(var i in oButton.menu){if(Lang.hasOwnProperty(oButton.menu,i)){var funcObject={fn:function(ev,x,oMenu){if(!oButton.menucmd){oButton.menucmd=oButton.value;}
oButton.value=((oMenu.value)?oMenu.value:oMenu._oText.nodeValue);},scope:this};oButton.menu[i].onclick=funcObject;}}}}
var _oButton={},skip=false;for(var o in oButton){if(Lang.hasOwnProperty(oButton,o)){if(!this._toolbarConfigs[o]){_oButton[o]=oButton[o];}}}
if(oButton.type=='select'){_oButton.type='menu';}
if(oButton.type=='spin'){_oButton.type='push';}
if(_oButton.type=='color'){if(YAHOO.widget.Overlay){_oButton=this._makeColorButton(_oButton);}else{skip=true;}}
if(_oButton.menu){if((YAHOO.widget.Overlay)&&(oButton.menu instanceof YAHOO.widget.Overlay)){oButton.menu.showEvent.subscribe(function(){this._button=_oButton;});}else{for(var m=0;m<_oButton.menu.length;m++){if(!_oButton.menu[m].value){_oButton.menu[m].value=_oButton.menu[m].text;}}
if(this.browser.webkit){_oButton.focusmenu=false;}}}
if(skip){oButton=false;}else{this._configs.buttons.value[this._configs.buttons.value.length]=oButton;var tmp=new this.buttonType(_oButton);tmp.get('element').tabIndex='-1';tmp.get('element').setAttribute('role','button');tmp._selected=true;if(this.get('disabled')){tmp.set('disabled',true);}
if(!oButton.id){oButton.id=tmp.get('id');}
if(after){var el=tmp.get('element');var nextSib=null;if(after.get){nextSib=after.get('element').nextSibling;}else if(after.nextSibling){nextSib=after.nextSibling;}
if(nextSib){nextSib.parentNode.insertBefore(el,nextSib);}}
tmp.addClass(this.CLASS_PREFIX+'-'+tmp.get('value'));var icon=document.createElement('span');icon.className=this.CLASS_PREFIX+'-icon';tmp.get('element').insertBefore(icon,tmp.get('firstChild'));if(tmp._button.tagName.toLowerCase()=='button'){tmp.get('element').setAttribute('unselectable','on');var a=document.createElement('a');a.innerHTML=tmp._button.innerHTML;a.href='#';a.tabIndex='-1';Event.on(a,'click',function(ev){Event.stopEvent(ev);});tmp._button.parentNode.replaceChild(a,tmp._button);tmp._button=a;}
if(oButton.type=='select'){if(tmp._button.tagName.toLowerCase()=='select'){icon.parentNode.removeChild(icon);var iel=tmp._button;var parEl=tmp.get('element');parEl.parentNode.replaceChild(iel,parEl);}else{tmp.addClass(this.CLASS_PREFIX+'-select');}}
if(oButton.type=='spin'){if(!Lang.isArray(oButton.range)){oButton.range=[10,100];}
this._makeSpinButton(tmp,oButton);}
tmp.get('element').setAttribute('title',tmp.get('label'));if(oButton.type!='spin'){if((YAHOO.widget.Overlay)&&(_oButton.menu instanceof YAHOO.widget.Overlay)){var showPicker=function(ev){var exec=true;if(ev.keyCode&&(ev.keyCode==9)){exec=false;}
if(exec){if(this._colorPicker){this._colorPicker._button=oButton.value;}
var menuEL=tmp.getMenu().element;if(Dom.getStyle(menuEL,'visibility')=='hidden'){tmp.getMenu().show();}else{tmp.getMenu().hide();}}
YAHOO.util.Event.stopEvent(ev);};tmp.on('mousedown',showPicker,oButton,this);tmp.on('keydown',showPicker,oButton,this);}else if((oButton.type!='menu')&&(oButton.type!='select')){tmp.on('keypress',this._buttonClick,oButton,this);tmp.on('mousedown',function(ev){YAHOO.util.Event.stopEvent(ev);this._buttonClick(ev,oButton);},oButton,this);tmp.on('click',function(ev){YAHOO.util.Event.stopEvent(ev);});}else{tmp.on('mousedown',function(ev){YAHOO.util.Event.stopEvent(ev);});tmp.on('click',function(ev){YAHOO.util.Event.stopEvent(ev);});tmp.on('change',function(ev){if(!oButton.menucmd){oButton.menucmd=oButton.value;}
oButton.value=ev.value;this._buttonClick(ev,oButton);},this,true);var self=this;tmp.on('appendTo',function(){var tmp=this;if(tmp.getMenu()&&tmp.getMenu().mouseDownEvent){tmp.getMenu().mouseDownEvent.subscribe(function(ev,args){YAHOO.util.Event.stopEvent(args[0]);});tmp.getMenu().clickEvent.subscribe(function(ev,args){YAHOO.util.Event.stopEvent(args[0]);});tmp.getMenu().mouseUpEvent.subscribe(function(ev,args){var oMenu=args[1];YAHOO.util.Event.stopEvent(args[0]);tmp._onMenuClick(args[0],tmp);if(!oButton.menucmd){oButton.menucmd=oButton.value;}
oButton.value=((oMenu.value)?oMenu.value:oMenu._oText.nodeValue);self._buttonClick.call(self,args[1],oButton);tmp._hideMenu();return false;});}});}}else{tmp.on('mousedown',function(ev){YAHOO.util.Event.stopEvent(ev);});tmp.on('click',function(ev){YAHOO.util.Event.stopEvent(ev);});}
if(this.browser.ie){}
if(this.browser.webkit){tmp.hasFocus=function(){return true;};}
this._buttonList[this._buttonList.length]=tmp;if((oButton.type=='menu')||(oButton.type=='split')||(oButton.type=='select')){if(Lang.isArray(oButton.menu)){var menu=tmp.getMenu();if(menu&&menu.renderEvent){menu.renderEvent.subscribe(this._addMenuClasses,tmp);if(oButton.renderer){menu.renderEvent.subscribe(oButton.renderer,tmp);}}}}}
return oButton;},addSeparator:function(cont,after){if(!this.get('element')){this._queue[this._queue.length]=['addSeparator',arguments];return false;}
var sepCont=((cont)?cont:this.get('cont'));if(!this.get('element')){this._queue[this._queue.length]=['addSeparator',arguments];return false;}
if(this._sepCount===null){this._sepCount=0;}
if(!this._sep){this._sep=document.createElement('SPAN');Dom.addClass(this._sep,this.CLASS_SEPARATOR);this._sep.innerHTML='|';}
var _sep=this._sep.cloneNode(true);this._sepCount++;Dom.addClass(_sep,this.CLASS_SEPARATOR+'-'+this._sepCount);if(after){var nextSib=null;if(after.get){nextSib=after.get('element').nextSibling;}else if(after.nextSibling){nextSib=after.nextSibling;}else{nextSib=after;}
if(nextSib){if(nextSib==after){nextSib.parentNode.appendChild(_sep);}else{nextSib.parentNode.insertBefore(_sep,nextSib);}}}else{sepCont.appendChild(_sep);}
return _sep;},_createColorPicker:function(id){if(Dom.get(id+'_colors')){Dom.get(id+'_colors').parentNode.removeChild(Dom.get(id+'_colors'));}
var picker=document.createElement('div');picker.className='yui-toolbar-colors';picker.id=id+'_colors';picker.style.display='none';Event.on(window,'load',function(){document.body.appendChild(picker);},this,true);this._colorPicker=picker;var html='';for(var i in this._colorData){if(Lang.hasOwnProperty(this._colorData,i)){html+='<a style="background-color: '+i+'" href="#">'+i.replace('#','')+'</a>';}}
html+='<span><em>X</em><strong></strong></span>';window.setTimeout(function(){picker.innerHTML=html;},0);Event.on(picker,'mouseover',function(ev){var picker=this._colorPicker;var em=picker.getElementsByTagName('em')[0];var strong=picker.getElementsByTagName('strong')[0];var tar=Event.getTarget(ev);if(tar.tagName.toLowerCase()=='a'){em.style.backgroundColor=tar.style.backgroundColor;strong.innerHTML=this._colorData['#'+tar.innerHTML]+'<br>'+tar.innerHTML;}},this,true);Event.on(picker,'focus',function(ev){Event.stopEvent(ev);});Event.on(picker,'click',function(ev){Event.stopEvent(ev);});Event.on(picker,'mousedown',function(ev){Event.stopEvent(ev);var tar=Event.getTarget(ev);if(tar.tagName.toLowerCase()=='a'){var retVal=this.fireEvent('colorPickerClicked',{type:'colorPickerClicked',target:this,button:this._colorPicker._button,color:tar.innerHTML,colorName:this._colorData['#'+tar.innerHTML]});if(retVal!==false){var info={color:tar.innerHTML,colorName:this._colorData['#'+tar.innerHTML],value:this._colorPicker._button};this.fireEvent('buttonClick',{type:'buttonClick',target:this.get('element'),button:info});}
this.getButtonByValue(this._colorPicker._button).getMenu().hide();}},this,true);},_resetColorPicker:function(){var em=this._colorPicker.getElementsByTagName('em')[0];var strong=this._colorPicker.getElementsByTagName('strong')[0];em.style.backgroundColor='transparent';strong.innerHTML='';},_makeColorButton:function(_oButton){if(!this._colorPicker){this._createColorPicker(this.get('id'));}
_oButton.type='color';_oButton.menu=new YAHOO.widget.Overlay(this.get('id')+'_'+_oButton.value+'_menu',{visible:false,position:'absolute',iframe:true});_oButton.menu.setBody('');_oButton.menu.render(this.get('cont'));Dom.addClass(_oButton.menu.element,'yui-button-menu');Dom.addClass(_oButton.menu.element,'yui-color-button-menu');_oButton.menu.beforeShowEvent.subscribe(function(){_oButton.menu.cfg.setProperty('zindex',5);_oButton.menu.cfg.setProperty('context',[this.getButtonById(_oButton.id).get('element'),'tl','bl']);this._resetColorPicker();var _p=this._colorPicker;if(_p.parentNode){_p.parentNode.removeChild(_p);}
_oButton.menu.setBody('');_oButton.menu.appendToBody(_p);this._colorPicker.style.display='block';},this,true);return _oButton;},_makeSpinButton:function(_button,oButton){_button.addClass(this.CLASS_PREFIX+'-spinbutton');var self=this,_par=_button._button.parentNode.parentNode,range=oButton.range,_b1=document.createElement('a'),_b2=document.createElement('a');_b1.href='#';_b2.href='#';_b1.tabIndex='-1';_b2.tabIndex='-1';_b1.className='up';_b1.title=this.STR_SPIN_UP;_b1.innerHTML=this.STR_SPIN_UP;_b2.className='down';_b2.title=this.STR_SPIN_DOWN;_b2.innerHTML=this.STR_SPIN_DOWN;_par.appendChild(_b1);_par.appendChild(_b2);var label=YAHOO.lang.substitute(this.STR_SPIN_LABEL,{VALUE:_button.get('label')});_button.set('title',label);var cleanVal=function(value){value=((value<range[0])?range[0]:value);value=((value>range[1])?range[1]:value);return value;};var br=this.browser;var tbar=false;var strLabel=this.STR_SPIN_LABEL;if(this._titlebar&&this._titlebar.firstChild){tbar=this._titlebar.firstChild;}
var _intUp=function(ev){YAHOO.util.Event.stopEvent(ev);if(!_button.get('disabled')&&(ev.keyCode!=9)){var value=parseInt(_button.get('label'),10);value++;value=cleanVal(value);_button.set('label',''+value);var label=YAHOO.lang.substitute(strLabel,{VALUE:_button.get('label')});_button.set('title',label);if(!br.webkit&&tbar){}
self._buttonClick(ev,oButton);}};var _intDown=function(ev){YAHOO.util.Event.stopEvent(ev);if(!_button.get('disabled')&&(ev.keyCode!=9)){var value=parseInt(_button.get('label'),10);value--;value=cleanVal(value);_button.set('label',''+value);var label=YAHOO.lang.substitute(strLabel,{VALUE:_button.get('label')});_button.set('title',label);if(!br.webkit&&tbar){}
self._buttonClick(ev,oButton);}};var _intKeyUp=function(ev){if(ev.keyCode==38){_intUp(ev);}else if(ev.keyCode==40){_intDown(ev);}else if(ev.keyCode==107&&ev.shiftKey){_intUp(ev);}else if(ev.keyCode==109&&ev.shiftKey){_intDown(ev);}};_button.on('keydown',_intKeyUp,this,true);Event.on(_b1,'mousedown',function(ev){Event.stopEvent(ev);},this,true);Event.on(_b2,'mousedown',function(ev){Event.stopEvent(ev);},this,true);Event.on(_b1,'click',_intUp,this,true);Event.on(_b2,'click',_intDown,this,true);},_buttonClick:function(ev,info){var doEvent=true;if(ev&&ev.type=='keypress'){if(ev.keyCode==9){doEvent=false;}else if((ev.keyCode===13)||(ev.keyCode===0)||(ev.keyCode===32)){}else{doEvent=false;}}
if(doEvent){var fireNextEvent=true,retValue=false;info.isSelected=this.isSelected(info.id);if(info.value){retValue=this.fireEvent(info.value+'Click',{type:info.value+'Click',target:this.get('element'),button:info});if(retValue===false){fireNextEvent=false;}}
if(info.menucmd&&fireNextEvent){retValue=this.fireEvent(info.menucmd+'Click',{type:info.menucmd+'Click',target:this.get('element'),button:info});if(retValue===false){fireNextEvent=false;}}
if(fireNextEvent){this.fireEvent('buttonClick',{type:'buttonClick',target:this.get('element'),button:info});}
if(info.type=='select'){var button=this.getButtonById(info.id);if(button.buttonType=='rich'){var txt=info.value;for(var i=0;i<info.menu.length;i++){if(info.menu[i].value==info.value){txt=info.menu[i].text;break;}}
button.set('label','<span class="yui-toolbar-'+info.menucmd+'-'+(info.value).replace(/ /g,'-').toLowerCase()+'">'+txt+'</span>');var _items=button.getMenu().getItems();for(var m=0;m<_items.length;m++){if(_items[m].value.toLowerCase()==info.value.toLowerCase()){_items[m].cfg.setProperty('checked',true);}else{_items[m].cfg.setProperty('checked',false);}}}}
if(ev){Event.stopEvent(ev);}}},_keyNav:null,_navCounter:null,_navigateButtons:function(ev){switch(ev.keyCode){case 37:case 39:if(ev.keyCode==37){this._navCounter--;}else{this._navCounter++;}
if(this._navCounter>(this._buttonList.length-1)){this._navCounter=0;}
if(this._navCounter<0){this._navCounter=(this._buttonList.length-1);}
if(this._buttonList[this._navCounter]){var el=this._buttonList[this._navCounter].get('element');if(this.browser.ie){el=this._buttonList[this._navCounter].get('element').getElementsByTagName('a')[0];}
if(this._buttonList[this._navCounter].get('disabled')){this._navigateButtons(ev);}else{el.focus();}}
break;}},_handleFocus:function(){if(!this._keyNav){var ev='keypress';if(this.browser.ie){ev='keydown';}
Event.on(this.get('element'),ev,this._navigateButtons,this,true);this._keyNav=true;this._navCounter=-1;}},getButtonById:function(id){var len=this._buttonList.length;for(var i=0;i<len;i++){if(this._buttonList[i]&&this._buttonList[i].get('id')==id){return this._buttonList[i];}}
return false;},getButtonByValue:function(value){var _buttons=this.get('buttons');var len=_buttons.length;for(var i=0;i<len;i++){if(_buttons[i].group!==undefined){for(var m=0;m<_buttons[i].buttons.length;m++){if((_buttons[i].buttons[m].value==value)||(_buttons[i].buttons[m].menucmd==value)){return this.getButtonById(_buttons[i].buttons[m].id);}
if(_buttons[i].buttons[m].menu){for(var s=0;s<_buttons[i].buttons[m].menu.length;s++){if(_buttons[i].buttons[m].menu[s].value==value){return this.getButtonById(_buttons[i].buttons[m].id);}}}}}else{if((_buttons[i].value==value)||(_buttons[i].menucmd==value)){return this.getButtonById(_buttons[i].id);}
if(_buttons[i].menu){for(var j=0;j<_buttons[i].menu.length;j++){if(_buttons[i].menu[j].value==value){return this.getButtonById(_buttons[i].id);}}}}}
return false;},getButtonByIndex:function(index){if(this._buttonList[index]){return this._buttonList[index];}else{return false;}},getButtons:function(){return this._buttonList;},disableButton:function(id){var button=getButton.call(this,id);if(button){button.set('disabled',true);}else{return false;}},enableButton:function(id){if(this.get('disabled')){return false;}
var button=getButton.call(this,id);if(button){if(button.get('disabled')){button.set('disabled',false);}}else{return false;}},isSelected:function(id){var button=getButton.call(this,id);if(button){return button._selected;}
return false;},selectButton:function(id,value){var button=getButton.call(this,id);if(button){button.addClass('yui-button-selected');button.addClass('yui-button-'+button.get('value')+'-selected');button._selected=true;if(value){if(button.buttonType=='rich'){var _items=button.getMenu().getItems();for(var m=0;m<_items.length;m++){if(_items[m].value==value){_items[m].cfg.setProperty('checked',true);button.set('label','<span class="yui-toolbar-'+button.get('value')+'-'+(value).replace(/ /g,'-').toLowerCase()+'">'+_items[m]._oText.nodeValue+'</span>');}else{_items[m].cfg.setProperty('checked',false);}}}}}else{return false;}},deselectButton:function(id){var button=getButton.call(this,id);if(button){button.removeClass('yui-button-selected');button.removeClass('yui-button-'+button.get('value')+'-selected');button.removeClass('yui-button-hover');button._selected=false;}else{return false;}},deselectAllButtons:function(){var len=this._buttonList.length;for(var i=0;i<len;i++){this.deselectButton(this._buttonList[i]);}},disableAllButtons:function(){if(this.get('disabled')){return false;}
var len=this._buttonList.length;for(var i=0;i<len;i++){this.disableButton(this._buttonList[i]);}},enableAllButtons:function(){if(this.get('disabled')){return false;}
var len=this._buttonList.length;for(var i=0;i<len;i++){this.enableButton(this._buttonList[i]);}},resetAllButtons:function(_ex){if(!Lang.isObject(_ex)){_ex={};}
if(this.get('disabled')){return false;}
var len=this._buttonList.length;for(var i=0;i<len;i++){var _button=this._buttonList[i];if(_button){var disabled=_button._configs.disabled._initialConfig.value;if(_ex[_button.get('id')]){this.enableButton(_button);this.selectButton(_button);}else{if(disabled){this.disableButton(_button);}else{this.enableButton(_button);}
this.deselectButton(_button);}}}},destroyButton:function(id){var button=getButton.call(this,id);if(button){var thisID=button.get('id');button.destroy();var len=this._buttonList.length;for(var i=0;i<len;i++){if(this._buttonList[i]&&this._buttonList[i].get('id')==thisID){this._buttonList[i]=null;}}}else{return false;}},destroy:function(){this.get('element').innerHTML='';this.get('element').className='';for(var i in this){if(Lang.hasOwnProperty(this,i)){this[i]=null;}}
return true;},collapse:function(collapse){var el=Dom.getElementsByClassName('collapse','span',this._titlebar);if(collapse===false){Dom.removeClass(this.get('cont').parentNode,'yui-toolbar-container-collapsed');if(el[0]){Dom.removeClass(el[0],'collapsed');}
this.fireEvent('toolbarExpanded',{type:'toolbarExpanded',target:this});}else{if(el[0]){Dom.addClass(el[0],'collapsed');}
Dom.addClass(this.get('cont').parentNode,'yui-toolbar-container-collapsed');this.fireEvent('toolbarCollapsed',{type:'toolbarCollapsed',target:this});}},toString:function(){return'Toolbar (#'+this.get('element').id+') with '+this._buttonList.length+' buttons.';}});})();(function(){var Dom=YAHOO.util.Dom,Event=YAHOO.util.Event,Lang=YAHOO.lang,Toolbar=YAHOO.widget.Toolbar;YAHOO.widget.SimpleEditor=function(el,attrs){var o={};if(Lang.isObject(el)&&(!el.tagName)&&!attrs){Lang.augmentObject(o,el);el=document.createElement('textarea');this.DOMReady=true;if(o.container){var c=Dom.get(o.container);c.appendChild(el);}else{document.body.appendChild(el);}}else{if(attrs){Lang.augmentObject(o,attrs);}}
var oConfig={element:null,attributes:o},id=null;if(Lang.isString(el)){id=el;}else{if(oConfig.attributes.id){id=oConfig.attributes.id;}else{this.DOMReady=true;id=Dom.generateId(el);}}
oConfig.element=el;var element_cont=document.createElement('DIV');oConfig.attributes.element_cont=new YAHOO.util.Element(element_cont,{id:id+'_container'});var div=document.createElement('div');Dom.addClass(div,'first-child');oConfig.attributes.element_cont.appendChild(div);if(!oConfig.attributes.toolbar_cont){oConfig.attributes.toolbar_cont=document.createElement('DIV');oConfig.attributes.toolbar_cont.id=id+'_toolbar';div.appendChild(oConfig.attributes.toolbar_cont);}
var editorWrapper=document.createElement('DIV');div.appendChild(editorWrapper);oConfig.attributes.editor_wrapper=editorWrapper;YAHOO.widget.SimpleEditor.superclass.constructor.call(this,oConfig.element,oConfig.attributes);};YAHOO.extend(YAHOO.widget.SimpleEditor,YAHOO.util.Element,{_resizeConfig:{handles:['br'],autoRatio:true,status:true,proxy:true,useShim:true,setSize:false},_setupResize:function(){if(!YAHOO.util.DD||!YAHOO.util.Resize){return false;}
if(this.get('resize')){var config={};Lang.augmentObject(config,this._resizeConfig);this.resize=new YAHOO.util.Resize(this.get('element_cont').get('element'),config);this.resize.on('resize',function(args){var anim=this.get('animate');this.set('animate',false);this.set('width',args.width+'px');var h=args.height,th=(this.toolbar.get('element').clientHeight+2),dh=0;if(this.dompath){dh=(this.dompath.clientHeight+1);}
var newH=(h-th-dh);this.set('height',newH+'px');this.get('element_cont').setStyle('height','');this.set('animate',anim);},this,true);}},resize:null,_setupDD:function(){if(!YAHOO.util.DD){return false;}
if(this.get('drag')){var d=this.get('drag'),dd=YAHOO.util.DD;if(d==='proxy'){dd=YAHOO.util.DDProxy;}
this.dd=new dd(this.get('element_cont').get('element'));this.toolbar.addClass('draggable');this.dd.setHandleElId(this.toolbar._titlebar);}},dd:null,_lastCommand:null,_undoNodeChange:function(){},_storeUndo:function(){},_checkKey:function(k,e){var ret=false;if((e.keyCode===k.key)){if(k.mods&&(k.mods.length>0)){var val=0;for(var i=0;i<k.mods.length;i++){if(this.browser.mac){if(k.mods[i]=='ctrl'){k.mods[i]='meta';}}
if(e[k.mods[i]+'Key']===true){val++;}}
if(val===k.mods.length){ret=true;}}else{ret=true;}}
return ret;},_keyMap:{SELECT_ALL:{key:65,mods:['ctrl']},CLOSE_WINDOW:{key:87,mods:['shift','ctrl']},FOCUS_TOOLBAR:{key:27,mods:['shift']},FOCUS_AFTER:{key:27},CREATE_LINK:{key:76,mods:['shift','ctrl']},BOLD:{key:66,mods:['shift','ctrl']},ITALIC:{key:73,mods:['shift','ctrl']},UNDERLINE:{key:85,mods:['shift','ctrl']},UNDO:{key:90,mods:['ctrl']},REDO:{key:90,mods:['shift','ctrl']},JUSTIFY_LEFT:{key:219,mods:['shift','ctrl']},JUSTIFY_CENTER:{key:220,mods:['shift','ctrl']},JUSTIFY_RIGHT:{key:221,mods:['shift','ctrl']}},_cleanClassName:function(str){return str.replace(/ /g,'-').toLowerCase();},_textarea:null,_docType:'<!DOCTYPE HTML PUBLIC "-/'+'/W3C/'+'/DTD HTML 4.01/'+'/EN" "http:/'+'/www.w3.org/TR/html4/strict.dtd">',editorDirty:null,_defaultCSS:'html { height: 95%; } body { padding: 7px; background-color: #fff; font:13px/1.22 arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small; } a, a:visited, a:hover { color: blue !important; text-decoration: underline !important; cursor: text !important; } .warning-localfile { border-bottom: 1px dashed red !important; } .yui-busy { cursor: wait !important; } img.selected { border: 2px dotted #808080; } img { cursor: pointer !important; border: none; } body.ptags.webkit div { margin: 11px 0; }',_defaultToolbar:null,_lastButton:null,_baseHREF:function(){var href=document.location.href;if(href.indexOf('?')!==-1){href=href.substring(0,href.indexOf('?'));}
href=href.substring(0,href.lastIndexOf('/'))+'/';return href;}(),_lastImage:null,_blankImageLoaded:null,_fixNodesTimer:null,_nodeChangeTimer:null,_lastNodeChangeEvent:null,_lastNodeChange:0,_rendered:null,DOMReady:null,_selection:null,_mask:null,_showingHiddenElements:null,currentWindow:null,currentEvent:null,operaEvent:null,currentFont:null,currentElement:null,dompath:null,beforeElement:null,afterElement:null,invalidHTML:{form:true,input:true,button:true,select:true,link:true,html:true,body:true,iframe:true,script:true,style:true,textarea:true},toolbar:null,_contentTimer:null,_contentTimerCounter:0,_disabled:['createlink','fontname','fontsize','forecolor','backcolor'],_alwaysDisabled:{undo:true,redo:true},_alwaysEnabled:{},_semantic:{'bold':true,'italic':true,'underline':true},_tag2cmd:{'b':'bold','strong':'bold','i':'italic','em':'italic','u':'underline','sup':'superscript','sub':'subscript','img':'insertimage','a':'createlink','ul':'insertunorderedlist','ol':'insertorderedlist'},_createIframe:function(){var ifrmDom=document.createElement('iframe');ifrmDom.id=this.get('id')+'_editor';var config={border:'0',frameBorder:'0',marginWidth:'0',marginHeight:'0',leftMargin:'0',topMargin:'0',allowTransparency:'true',width:'100%'};if(this.get('autoHeight')){config.scrolling='no';}
for(var i in config){if(Lang.hasOwnProperty(config,i)){ifrmDom.setAttribute(i,config[i]);}}
var isrc='javascript:;';if(this.browser.ie){isrc='javascript:false;';}
ifrmDom.setAttribute('src',isrc);var ifrm=new YAHOO.util.Element(ifrmDom);ifrm.setStyle('visibility','hidden');return ifrm;},_isElement:function(el,tag){if(el&&el.tagName&&(el.tagName.toLowerCase()==tag)){return true;}
if(el&&el.getAttribute&&(el.getAttribute('tag')==tag)){return true;}
return false;},_hasParent:function(el,tag){if(!el||!el.parentNode){return false;}
while(el.parentNode){if(this._isElement(el,tag)){return el;}
if(el.parentNode){el=el.parentNode;}else{return false;}}
return false;},_getDoc:function(){var value=false;if(this.get){if(this.get('iframe')){if(this.get('iframe').get){if(this.get('iframe').get('element')){try{if(this.get('iframe').get('element').contentWindow){if(this.get('iframe').get('element').contentWindow.document){value=this.get('iframe').get('element').contentWindow.document;return value;}}}catch(e){}}}}}
return false;},_getWindow:function(){return this.get('iframe').get('element').contentWindow;},_focusWindow:function(onLoad){if(this.browser.webkit){if(onLoad){this._getSelection().setBaseAndExtent(this._getDoc().body.firstChild,0,this._getDoc().body.firstChild,1);if(this.browser.webkit3){this._getSelection().collapseToStart();}else{this._getSelection().collapse(false);}}else{this._getSelection().setBaseAndExtent(this._getDoc().body,1,this._getDoc().body,1);if(this.browser.webkit3){this._getSelection().collapseToStart();}else{this._getSelection().collapse(false);}}
this._getWindow().focus();}else{this._getWindow().focus();}},_hasSelection:function(){var sel=this._getSelection();var range=this._getRange();var hasSel=false;if(!sel||!range){return hasSel;}
if(this.browser.ie||this.browser.opera){if(range.text){hasSel=true;}
if(range.html){hasSel=true;}}else{if(this.browser.webkit){if(sel+''!==''){hasSel=true;}}else{if(sel&&(sel.toString()!=='')&&(sel!==undefined)){hasSel=true;}}}
return hasSel;},_getSelection:function(){var _sel=null;if(this._getDoc()&&this._getWindow()){if(this._getDoc().selection){_sel=this._getDoc().selection;}else{_sel=this._getWindow().getSelection();}
if(this.browser.webkit){if(_sel.baseNode){this._selection={};this._selection.baseNode=_sel.baseNode;this._selection.baseOffset=_sel.baseOffset;this._selection.extentNode=_sel.extentNode;this._selection.extentOffset=_sel.extentOffset;}else if(this._selection!==null){_sel=this._getWindow().getSelection();_sel.setBaseAndExtent(this._selection.baseNode,this._selection.baseOffset,this._selection.extentNode,this._selection.extentOffset);this._selection=null;}}}
return _sel;},_selectNode:function(node,collapse){if(!node){return false;}
var sel=this._getSelection(),range=null;if(this.browser.ie){try{range=this._getDoc().body.createTextRange();range.moveToElementText(node);range.select();}catch(e){}}else if(this.browser.webkit){if(collapse){sel.setBaseAndExtent(node,1,node,node.innerText.length);}else{sel.setBaseAndExtent(node,0,node,node.innerText.length);}}else if(this.browser.opera){sel=this._getWindow().getSelection();range=this._getDoc().createRange();range.selectNode(node);sel.removeAllRanges();sel.addRange(range);}else{range=this._getDoc().createRange();range.selectNodeContents(node);sel.removeAllRanges();sel.addRange(range);}
this.nodeChange();},_getRange:function(){var sel=this._getSelection();if(sel===null){return null;}
if(this.browser.webkit&&!sel.getRangeAt){var _range=this._getDoc().createRange();try{_range.setStart(sel.anchorNode,sel.anchorOffset);_range.setEnd(sel.focusNode,sel.focusOffset);}catch(e){_range=this._getWindow().getSelection()+'';}
return _range;}
if(this.browser.ie||this.browser.opera){try{return sel.createRange();}catch(e2){return null;}}
if(sel.rangeCount>0){return sel.getRangeAt(0);}
return null;},_setDesignMode:function(state){try{var set=true;if(this.browser.ie&&(state.toLowerCase()=='off')){set=false;}
if(set){this._getDoc().designMode=state;}}catch(e){}},_toggleDesignMode:function(){var _dMode=this._getDoc().designMode.toLowerCase(),_state='on';if(_dMode=='on'){_state='off';}
this._setDesignMode(_state);return _state;},_initEditorEvents:function(){var doc=this._getDoc();Event.on(doc,'mouseup',this._handleMouseUp,this,true);Event.on(doc,'mousedown',this._handleMouseDown,this,true);Event.on(doc,'click',this._handleClick,this,true);Event.on(doc,'dblclick',this._handleDoubleClick,this,true);Event.on(doc,'keypress',this._handleKeyPress,this,true);Event.on(doc,'keyup',this._handleKeyUp,this,true);Event.on(doc,'keydown',this._handleKeyDown,this,true);},_removeEditorEvents:function(){var doc=this._getDoc();Event.removeListener(doc,'mouseup',this._handleMouseUp,this,true);Event.removeListener(doc,'mousedown',this._handleMouseDown,this,true);Event.removeListener(doc,'click',this._handleClick,this,true);Event.removeListener(doc,'dblclick',this._handleDoubleClick,this,true);Event.removeListener(doc,'keypress',this._handleKeyPress,this,true);Event.removeListener(doc,'keyup',this._handleKeyUp,this,true);Event.removeListener(doc,'keydown',this._handleKeyDown,this,true);},_initEditor:function(){if(this.browser.ie){this._getDoc().body.style.margin='0';}
if(!this.get('disabled')){if(this._getDoc().designMode.toLowerCase()!='on'){this._setDesignMode('on');this._contentTimerCounter=0;}}
if(!this._getDoc().body){this._contentTimerCounter=0;this._checkLoaded();return false;}
this.toolbar.on('buttonClick',this._handleToolbarClick,this,true);if(!this.get('disabled')){this._initEditorEvents();this.toolbar.set('disabled',false);}
this.fireEvent('editorContentLoaded',{type:'editorLoaded',target:this});if(this.get('dompath')){var self=this;setTimeout(function(){self._writeDomPath.call(self);self._setupResize.call(self);},150);}
var br=[];for(var i in this.browser){if(this.browser[i]){br.push(i);}}
if(this.get('ptags')){br.push('ptags');}
Dom.addClass(this._getDoc().body,br.join(' '));this.nodeChange(true);},_checkLoaded:function(){this._contentTimerCounter++;if(this._contentTimer){clearTimeout(this._contentTimer);}
if(this._contentTimerCounter>500){return false;}
var init=false;try{if(this._getDoc()&&this._getDoc().body){if(this.browser.ie){if(this._getDoc().body.readyState=='complete'){init=true;}}else{if(this._getDoc().body._rteLoaded===true){init=true;}}}}catch(e){init=false;}
if(init===true){this._initEditor();}else{var self=this;this._contentTimer=setTimeout(function(){self._checkLoaded.call(self);},20);}},_setInitialContent:function(){var value=((this._textarea)?this.get('element').value:this.get('element').innerHTML),doc=null;var html=Lang.substitute(this.get('html'),{TITLE:this.STR_TITLE,CONTENT:this._cleanIncomingHTML(value),CSS:this.get('css'),HIDDEN_CSS:((this.get('hiddencss'))?this.get('hiddencss'):'/* No Hidden CSS */'),EXTRA_CSS:((this.get('extracss'))?this.get('extracss'):'/* No Extra CSS */')}),check=true;if(document.compatMode!='BackCompat'){html=this._docType+"\n"+html;}else{}
if(this.browser.ie||this.browser.webkit||this.browser.opera||(navigator.userAgent.indexOf('Firefox/1.5')!=-1)){try{if(this.browser.air){doc=this._getDoc().implementation.createHTMLDocument();var origDoc=this._getDoc();origDoc.open();origDoc.close();doc.open();doc.write(html);doc.close();var node=origDoc.importNode(doc.getElementsByTagName("html")[0],true);origDoc.replaceChild(node,origDoc.getElementsByTagName("html")[0]);origDoc.body._rteLoaded=true;}else{doc=this._getDoc();doc.open();doc.write(html);doc.close();}}catch(e){check=false;}}else{this.get('iframe').get('element').src='data:text/html;charset=utf-8,'+encodeURIComponent(html);}
this.get('iframe').setStyle('visibility','');if(check){this._checkLoaded();}},_setMarkupType:function(action){switch(this.get('markup')){case'css':this._setEditorStyle(true);break;case'default':this._setEditorStyle(false);break;case'semantic':case'xhtml':if(this._semantic[action]){this._setEditorStyle(false);}else{this._setEditorStyle(true);}
break;}},_setEditorStyle:function(stat){try{this._getDoc().execCommand('useCSS',false,!stat);}catch(ex){}},_getSelectedElement:function(){var doc=this._getDoc(),range=null,sel=null,elm=null,check=true;if(this.browser.ie){this.currentEvent=this._getWindow().event;range=this._getRange();if(range){elm=range.item?range.item(0):range.parentElement();if(this._hasSelection()){}
if(elm===doc.body){elm=null;}}
if((this.currentEvent!==null)&&(this.currentEvent.keyCode===0)){elm=Event.getTarget(this.currentEvent);}}else{sel=this._getSelection();range=this._getRange();if(!sel||!range){return null;}
if(!this._hasSelection()&&this.browser.webkit3){}
if(this.browser.gecko){if(range.startContainer){check=false;if(range.startContainer.nodeType===3){elm=range.startContainer.parentNode;}else if(range.startContainer.nodeType===1){elm=range.startContainer;}else{check=true;}
if(!check){this.currentEvent=null;}}}
if(check){if(sel.anchorNode&&(sel.anchorNode.nodeType==3)){if(sel.anchorNode.parentNode){elm=sel.anchorNode.parentNode;}
if(sel.anchorNode.nextSibling!=sel.focusNode.nextSibling){elm=sel.anchorNode.nextSibling;}}
if(this._isElement(elm,'br')){elm=null;}
if(!elm){elm=range.commonAncestorContainer;if(!range.collapsed){if(range.startContainer==range.endContainer){if(range.startOffset-range.endOffset<2){if(range.startContainer.hasChildNodes()){elm=range.startContainer.childNodes[range.startOffset];}}}}}}}
if(this.currentEvent!==null){try{switch(this.currentEvent.type){case'click':case'mousedown':case'mouseup':if(this.browser.webkit){elm=Event.getTarget(this.currentEvent);}
break;default:break;}}catch(e){}}else if((this.currentElement&&this.currentElement[0])&&(!this.browser.ie)){}
if(this.browser.opera||this.browser.webkit){if(this.currentEvent&&!elm){elm=YAHOO.util.Event.getTarget(this.currentEvent);}}
if(!elm||!elm.tagName){elm=doc.body;}
if(this._isElement(elm,'html')){elm=doc.body;}
if(this._isElement(elm,'body')){elm=doc.body;}
if(elm&&!elm.parentNode){elm=doc.body;}
if(elm===undefined){elm=null;}
return elm;},_getDomPath:function(el){if(!el){el=this._getSelectedElement();}
var domPath=[];while(el!==null){if(el.ownerDocument!=this._getDoc()){el=null;break;}
if(el.nodeName&&el.nodeType&&(el.nodeType==1)){domPath[domPath.length]=el;}
if(this._isElement(el,'body')){break;}
el=el.parentNode;}
if(domPath.length===0){if(this._getDoc()&&this._getDoc().body){domPath[0]=this._getDoc().body;}}
return domPath.reverse();},_writeDomPath:function(){var path=this._getDomPath(),pathArr=[],classPath='',pathStr='';for(var i=0;i<path.length;i++){var tag=path[i].tagName.toLowerCase();if((tag=='ol')&&(path[i].type)){tag+=':'+path[i].type;}
if(Dom.hasClass(path[i],'yui-tag')){tag=path[i].getAttribute('tag');}
if((this.get('markup')=='semantic')||(this.get('markup')=='xhtml')){switch(tag){case'b':tag='strong';break;case'i':tag='em';break;}}
if(!Dom.hasClass(path[i],'yui-non')){if(Dom.hasClass(path[i],'yui-tag')){pathStr=tag;}else{classPath=((path[i].className!=='')?'.'+path[i].className.replace(/ /g,'.'):'');if((classPath.indexOf('yui')!=-1)||(classPath.toLowerCase().indexOf('apple-style-span')!=-1)){classPath='';}
pathStr=tag+((path[i].id)?'#'+path[i].id:'')+classPath;}
switch(tag){case'body':pathStr='body';break;case'a':if(path[i].getAttribute('href',2)){pathStr+=':'+path[i].getAttribute('href',2).replace('mailto:','').replace('http:/'+'/','').replace('https:/'+'/','');}
break;case'img':var h=path[i].height;var w=path[i].width;if(path[i].style.height){h=parseInt(path[i].style.height,10);}
if(path[i].style.width){w=parseInt(path[i].style.width,10);}
pathStr+='('+w+'x'+h+')';break;}
if(pathStr.length>10){pathStr='<span title="'+pathStr+'">'+pathStr.substring(0,10)+'...'+'</span>';}else{pathStr='<span title="'+pathStr+'">'+pathStr+'</span>';}
pathArr[pathArr.length]=pathStr;}}
var str=pathArr.join(' '+this.SEP_DOMPATH+' ');if(this.dompath.innerHTML!=str){this.dompath.innerHTML=str;}},_fixNodes:function(){var doc=this._getDoc(),els=[];for(var v in this.invalidHTML){if(YAHOO.lang.hasOwnProperty(this.invalidHTML,v)){if(v.toLowerCase()!='span'){var tags=doc.body.getElementsByTagName(v);if(tags.length){for(var i=0;i<tags.length;i++){els.push(tags[i]);}}}}}
for(var h=0;h<els.length;h++){if(els[h].parentNode){if(Lang.isObject(this.invalidHTML[els[h].tagName.toLowerCase()])&&this.invalidHTML[els[h].tagName.toLowerCase()].keepContents){this._swapEl(els[h],'span',function(el){el.className='yui-non';});}else{els[h].parentNode.removeChild(els[h]);}}}
var imgs=this._getDoc().getElementsByTagName('img');Dom.addClass(imgs,'yui-img');},_isNonEditable:function(ev){if(this.get('allowNoEdit')){var el=Event.getTarget(ev);if(this._isElement(el,'html')){el=null;}
var path=this._getDomPath(el);for(var i=(path.length-1);i>-1;i--){if(Dom.hasClass(path[i],this.CLASS_NOEDIT)){try{this._getDoc().execCommand('enableObjectResizing',false,'false');}catch(e){}
this.nodeChange();Event.stopEvent(ev);return true;}}
try{this._getDoc().execCommand('enableObjectResizing',false,'true');}catch(e2){}}
return false;},_setCurrentEvent:function(ev){this.currentEvent=ev;},_handleClick:function(ev){var ret=this.fireEvent('beforeEditorClick',{type:'beforeEditorClick',target:this,ev:ev});if(ret===false){return false;}
if(this._isNonEditable(ev)){return false;}
this._setCurrentEvent(ev);if(this.currentWindow){this.closeWindow();}
if(this.currentWindow){this.closeWindow();}
if(this.browser.webkit){var tar=Event.getTarget(ev);if(this._isElement(tar,'a')||this._isElement(tar.parentNode,'a')){Event.stopEvent(ev);this.nodeChange();}}else{this.nodeChange();}
this.fireEvent('editorClick',{type:'editorClick',target:this,ev:ev});},_handleMouseUp:function(ev){var ret=this.fireEvent('beforeEditorMouseUp',{type:'beforeEditorMouseUp',target:this,ev:ev});if(ret===false){return false;}
if(this._isNonEditable(ev)){return false;}
var self=this;if(this.browser.opera){var sel=Event.getTarget(ev);if(this._isElement(sel,'img')){this.nodeChange();if(this.operaEvent){clearTimeout(this.operaEvent);this.operaEvent=null;this._handleDoubleClick(ev);}else{this.operaEvent=window.setTimeout(function(){self.operaEvent=false;},700);}}}
if(this.browser.webkit||this.browser.opera){if(this.browser.webkit){Event.stopEvent(ev);}}
this.nodeChange();this.fireEvent('editorMouseUp',{type:'editorMouseUp',target:this,ev:ev});},_handleMouseDown:function(ev){var ret=this.fireEvent('beforeEditorMouseDown',{type:'beforeEditorMouseDown',target:this,ev:ev});if(ret===false){return false;}
if(this._isNonEditable(ev)){return false;}
this._setCurrentEvent(ev);var sel=Event.getTarget(ev);if(this.browser.webkit&&this._hasSelection()){var _sel=this._getSelection();if(!this.browser.webkit3){_sel.collapse(true);}else{_sel.collapseToStart();}}
if(this.browser.webkit&&this._lastImage){Dom.removeClass(this._lastImage,'selected');this._lastImage=null;}
if(this._isElement(sel,'img')||this._isElement(sel,'a')){if(this.browser.webkit){Event.stopEvent(ev);if(this._isElement(sel,'img')){Dom.addClass(sel,'selected');this._lastImage=sel;}}
if(this.currentWindow){this.closeWindow();}
this.nodeChange();}
this.fireEvent('editorMouseDown',{type:'editorMouseDown',target:this,ev:ev});},_handleDoubleClick:function(ev){var ret=this.fireEvent('beforeEditorDoubleClick',{type:'beforeEditorDoubleClick',target:this,ev:ev});if(ret===false){return false;}
if(this._isNonEditable(ev)){return false;}
this._setCurrentEvent(ev);var sel=Event.getTarget(ev);if(this._isElement(sel,'img')){this.currentElement[0]=sel;this.toolbar.fireEvent('insertimageClick',{type:'insertimageClick',target:this.toolbar});this.fireEvent('afterExecCommand',{type:'afterExecCommand',target:this});}else if(this._hasParent(sel,'a')){this.currentElement[0]=this._hasParent(sel,'a');this.toolbar.fireEvent('createlinkClick',{type:'createlinkClick',target:this.toolbar});this.fireEvent('afterExecCommand',{type:'afterExecCommand',target:this});}
this.nodeChange();this.fireEvent('editorDoubleClick',{type:'editorDoubleClick',target:this,ev:ev});},_handleKeyUp:function(ev){var ret=this.fireEvent('beforeEditorKeyUp',{type:'beforeEditorKeyUp',target:this,ev:ev});if(ret===false){return false;}
if(this._isNonEditable(ev)){return false;}
this._setCurrentEvent(ev);switch(ev.keyCode){case this._keyMap.SELECT_ALL.key:if(this._checkKey(this._keyMap.SELECT_ALL,ev)){this.nodeChange();}
break;case 32:case 35:case 36:case 37:case 38:case 39:case 40:case 46:case 8:case this._keyMap.CLOSE_WINDOW.key:if((ev.keyCode==this._keyMap.CLOSE_WINDOW.key)&&this.currentWindow){if(this._checkKey(this._keyMap.CLOSE_WINDOW,ev)){this.closeWindow();}}else{if(!this.browser.ie){if(this._nodeChangeTimer){clearTimeout(this._nodeChangeTimer);}
var self=this;this._nodeChangeTimer=setTimeout(function(){self._nodeChangeTimer=null;self.nodeChange.call(self);},100);}else{this.nodeChange();}
this.editorDirty=true;}
break;}
this.fireEvent('editorKeyUp',{type:'editorKeyUp',target:this,ev:ev});this._storeUndo();},_handleKeyPress:function(ev){var ret=this.fireEvent('beforeEditorKeyPress',{type:'beforeEditorKeyPress',target:this,ev:ev});if(ret===false){return false;}
if(this.get('allowNoEdit')){if(ev&&ev.keyCode&&(ev.keyCode==63272)){Event.stopEvent(ev);}}
if(this._isNonEditable(ev)){return false;}
this._setCurrentEvent(ev);if(this.browser.opera){if(ev.keyCode===13){var tar=this._getSelectedElement();if(!this._isElement(tar,'li')){this.execCommand('inserthtml','<br>');Event.stopEvent(ev);}}}
if(this.browser.webkit){if(!this.browser.webkit3){if(ev.keyCode&&(ev.keyCode==122)&&(ev.metaKey)){if(this._hasParent(this._getSelectedElement(),'li')){Event.stopEvent(ev);}}}
this._listFix(ev);}
this.fireEvent('editorKeyPress',{type:'editorKeyPress',target:this,ev:ev});},_handleKeyDown:function(ev){var ret=this.fireEvent('beforeEditorKeyDown',{type:'beforeEditorKeyDown',target:this,ev:ev});if(ret===false){return false;}
var tar=null,_range=null;if(this._isNonEditable(ev)){return false;}
this._setCurrentEvent(ev);if(this.currentWindow){this.closeWindow();}
if(this.currentWindow){this.closeWindow();}
var doExec=false,action=null,exec=false;switch(ev.keyCode){case this._keyMap.FOCUS_TOOLBAR.key:if(this._checkKey(this._keyMap.FOCUS_TOOLBAR,ev)){var h=this.toolbar.getElementsByTagName('h2')[0];if(h&&h.firstChild){h.firstChild.focus();}}else if(this._checkKey(this._keyMap.FOCUS_AFTER,ev)){this.afterElement.focus();}
Event.stopEvent(ev);doExec=false;break;case this._keyMap.CREATE_LINK.key:if(this._hasSelection()){if(this._checkKey(this._keyMap.CREATE_LINK,ev)){var makeLink=true;if(this.get('limitCommands')){if(!this.toolbar.getButtonByValue('createlink')){makeLink=false;}}
if(makeLink){this.execCommand('createlink','');this.toolbar.fireEvent('createlinkClick',{type:'createlinkClick',target:this.toolbar});this.fireEvent('afterExecCommand',{type:'afterExecCommand',target:this});doExec=false;}}}
break;case this._keyMap.UNDO.key:case this._keyMap.REDO.key:if(this._checkKey(this._keyMap.REDO,ev)){action='redo';doExec=true;}else if(this._checkKey(this._keyMap.UNDO,ev)){action='undo';doExec=true;}
break;case this._keyMap.BOLD.key:if(this._checkKey(this._keyMap.BOLD,ev)){action='bold';doExec=true;}
break;case this._keyMap.ITALIC.key:if(this._checkKey(this._keyMap.ITALIC,ev)){action='italic';doExec=true;}
break;case this._keyMap.UNDERLINE.key:if(this._checkKey(this._keyMap.UNDERLINE,ev)){action='underline';doExec=true;}
break;case 9:if(this.browser.ie){_range=this._getRange();tar=this._getSelectedElement();if(!this._isElement(tar,'li')){if(_range){_range.pasteHTML('&nbsp;&nbsp;&nbsp;&nbsp;');_range.collapse(false);_range.select();}
Event.stopEvent(ev);}}
if(this.browser.gecko>1.8){tar=this._getSelectedElement();if(this._isElement(tar,'li')){if(ev.shiftKey){this._getDoc().execCommand('outdent',null,'');}else{this._getDoc().execCommand('indent',null,'');}}else if(!this._hasSelection()){this.execCommand('inserthtml','&nbsp;&nbsp;&nbsp;&nbsp;');}
Event.stopEvent(ev);}
break;case 13:if(this.get('ptags')&&!ev.shiftKey){if(this.browser.gecko){tar=this._getSelectedElement();if(!this._isElement(tar,'li')){doExec=true;action='insertparagraph';Event.stopEvent(ev);}}
if(this.browser.webkit){tar=this._getSelectedElement();if(!this._hasParent(tar,'li')){doExec=true;action='insertparagraph';Event.stopEvent(ev);}}}else{if(this.browser.ie){_range=this._getRange();tar=this._getSelectedElement();if(!this._isElement(tar,'li')){if(_range){_range.pasteHTML('<br>');_range.collapse(false);_range.select();}
Event.stopEvent(ev);}}}
break;}
if(this.browser.ie){this._listFix(ev);}
if(doExec&&action){this.execCommand(action,null);Event.stopEvent(ev);this.nodeChange();}
this.fireEvent('editorKeyDown',{type:'editorKeyDown',target:this,ev:ev});},_listFix:function(ev){var testLi=null,par=null,preContent=false,range=null;if(this.browser.webkit){if(ev.keyCode&&(ev.keyCode==13)){if(this._hasParent(this._getSelectedElement(),'li')){var tar=this._hasParent(this._getSelectedElement(),'li');if(tar.previousSibling){if(tar.firstChild&&(tar.firstChild.length==1)){this._selectNode(tar);}}}}}
if(ev.keyCode&&((!this.browser.webkit3&&(ev.keyCode==25))||((this.browser.webkit3||!this.browser.webkit)&&((ev.keyCode==9)&&ev.shiftKey)))){testLi=this._getSelectedElement();if(this._hasParent(testLi,'li')){testLi=this._hasParent(testLi,'li');if(this._hasParent(testLi,'ul')||this._hasParent(testLi,'ol')){par=this._hasParent(testLi,'ul');if(!par){par=this._hasParent(testLi,'ol');}
if(this._isElement(par.previousSibling,'li')){par.removeChild(testLi);par.parentNode.insertBefore(testLi,par.nextSibling);if(this.browser.ie){range=this._getDoc().body.createTextRange();range.moveToElementText(testLi);range.collapse(false);range.select();}
if(this.browser.webkit){this._selectNode(testLi.firstChild);}
Event.stopEvent(ev);}}}}
if(ev.keyCode&&((ev.keyCode==9)&&(!ev.shiftKey))){var preLi=this._getSelectedElement();if(this._hasParent(preLi,'li')){preContent=this._hasParent(preLi,'li').innerHTML;}
if(this.browser.webkit){this._getDoc().execCommand('inserttext',false,'\t');}
testLi=this._getSelectedElement();if(this._hasParent(testLi,'li')){par=this._hasParent(testLi,'li');var newUl=this._getDoc().createElement(par.parentNode.tagName.toLowerCase());if(this.browser.webkit){var span=Dom.getElementsByClassName('Apple-tab-span','span',par);if(span[0]){par.removeChild(span[0]);par.innerHTML=Lang.trim(par.innerHTML);if(preContent){par.innerHTML='<span class="yui-non">'+preContent+'</span>&nbsp;';}else{par.innerHTML='<span class="yui-non">&nbsp;</span>&nbsp;';}}}else{if(preContent){par.innerHTML=preContent+'&nbsp;';}else{par.innerHTML='&nbsp;';}}
par.parentNode.replaceChild(newUl,par);newUl.appendChild(par);if(this.browser.webkit){this._getSelection().setBaseAndExtent(par.firstChild,1,par.firstChild,par.firstChild.innerText.length);if(!this.browser.webkit3){par.parentNode.parentNode.style.display='list-item';setTimeout(function(){par.parentNode.parentNode.style.display='block';},1);}}else if(this.browser.ie){range=this._getDoc().body.createTextRange();range.moveToElementText(par);range.collapse(false);range.select();}else{this._selectNode(par);}
Event.stopEvent(ev);}
if(this.browser.webkit){Event.stopEvent(ev);}
this.nodeChange();}},nodeChange:function(force){var NCself=this;this._storeUndo();if(this.get('nodeChangeDelay')){window.setTimeout(function(){NCself._nodeChange.apply(NCself,arguments);},0);}else{this._nodeChange();}},_nodeChange:function(force){var threshold=parseInt(this.get('nodeChangeThreshold'),10),thisNodeChange=Math.round(new Date().getTime()/1000),self=this;if(force===true){this._lastNodeChange=0;}
if((this._lastNodeChange+threshold)<thisNodeChange){if(this._fixNodesTimer===null){this._fixNodesTimer=window.setTimeout(function(){self._fixNodes.call(self);self._fixNodesTimer=null;},0);}}
this._lastNodeChange=thisNodeChange;if(this.currentEvent){try{this._lastNodeChangeEvent=this.currentEvent.type;}catch(e){}}
var beforeNodeChange=this.fireEvent('beforeNodeChange',{type:'beforeNodeChange',target:this});if(beforeNodeChange===false){return false;}
if(this.get('dompath')){window.setTimeout(function(){self._writeDomPath.call(self);},0);}
if(!this.get('disabled')){if(this.STOP_NODE_CHANGE){this.STOP_NODE_CHANGE=false;return false;}else{var sel=this._getSelection(),range=this._getRange(),el=this._getSelectedElement(),fn_button=this.toolbar.getButtonByValue('fontname'),fs_button=this.toolbar.getButtonByValue('fontsize'),undo_button=this.toolbar.getButtonByValue('undo'),redo_button=this.toolbar.getButtonByValue('redo');var _ex={};if(this._lastButton){_ex[this._lastButton.id]=true;}
if(!this._isElement(el,'body')){if(fn_button){_ex[fn_button.get('id')]=true;}
if(fs_button){_ex[fs_button.get('id')]=true;}}
if(redo_button){delete _ex[redo_button.get('id')];}
this.toolbar.resetAllButtons(_ex);for(var d=0;d<this._disabled.length;d++){var _button=this.toolbar.getButtonByValue(this._disabled[d]);if(_button&&_button.get){if(this._lastButton&&(_button.get('id')===this._lastButton.id)){}else{if(!this._hasSelection()&&!this.get('insert')){switch(this._disabled[d]){case'fontname':case'fontsize':break;default:this.toolbar.disableButton(_button);}}else{if(!this._alwaysDisabled[this._disabled[d]]){this.toolbar.enableButton(_button);}}
if(!this._alwaysEnabled[this._disabled[d]]){this.toolbar.deselectButton(_button);}}}}
var path=this._getDomPath();var tag=null,cmd=null;for(var i=0;i<path.length;i++){tag=path[i].tagName.toLowerCase();if(path[i].getAttribute('tag')){tag=path[i].getAttribute('tag').toLowerCase();}
cmd=this._tag2cmd[tag];if(cmd===undefined){cmd=[];}
if(!Lang.isArray(cmd)){cmd=[cmd];}
if(path[i].style.fontWeight.toLowerCase()=='bold'){cmd[cmd.length]='bold';}
if(path[i].style.fontStyle.toLowerCase()=='italic'){cmd[cmd.length]='italic';}
if(path[i].style.textDecoration.toLowerCase()=='underline'){cmd[cmd.length]='underline';}
if(path[i].style.textDecoration.toLowerCase()=='line-through'){cmd[cmd.length]='strikethrough';}
if(cmd.length>0){for(var j=0;j<cmd.length;j++){this.toolbar.selectButton(cmd[j]);this.toolbar.enableButton(cmd[j]);}}
switch(path[i].style.textAlign.toLowerCase()){case'left':case'right':case'center':case'justify':var alignType=path[i].style.textAlign.toLowerCase();if(path[i].style.textAlign.toLowerCase()=='justify'){alignType='full';}
this.toolbar.selectButton('justify'+alignType);this.toolbar.enableButton('justify'+alignType);break;}}
if(fn_button){var family=fn_button._configs.label._initialConfig.value;fn_button.set('label','<span class="yui-toolbar-fontname-'+this._cleanClassName(family)+'">'+family+'</span>');this._updateMenuChecked('fontname',family);}
if(fs_button){fs_button.set('label',fs_button._configs.label._initialConfig.value);}
var hd_button=this.toolbar.getButtonByValue('heading');if(hd_button){hd_button.set('label',hd_button._configs.label._initialConfig.value);this._updateMenuChecked('heading','none');}
var img_button=this.toolbar.getButtonByValue('insertimage');if(img_button&&this.currentWindow&&(this.currentWindow.name=='insertimage')){this.toolbar.disableButton(img_button);}
if(this._lastButton&&this._lastButton.isSelected){this.toolbar.deselectButton(this._lastButton.id);}
this._undoNodeChange();}}
this.fireEvent('afterNodeChange',{type:'afterNodeChange',target:this});},_updateMenuChecked:function(button,value,tbar){if(!tbar){tbar=this.toolbar;}
var _button=tbar.getButtonByValue(button);_button.checkValue(value);},_handleToolbarClick:function(ev){var value='';var str='';var cmd=ev.button.value;if(ev.button.menucmd){value=cmd;cmd=ev.button.menucmd;}
this._lastButton=ev.button;if(this.STOP_EXEC_COMMAND){this.STOP_EXEC_COMMAND=false;return false;}else{this.execCommand(cmd,value);if(!this.browser.webkit){var Fself=this;setTimeout(function(){Fself._focusWindow.call(Fself);},5);}}
Event.stopEvent(ev);},_setupAfterElement:function(){if(!this.beforeElement){this.beforeElement=document.createElement('h2');this.beforeElement.className='yui-editor-skipheader';this.beforeElement.tabIndex='-1';this.beforeElement.innerHTML=this.STR_BEFORE_EDITOR;this.get('element_cont').get('firstChild').insertBefore(this.beforeElement,this.toolbar.get('nextSibling'));}
if(!this.afterElement){this.afterElement=document.createElement('h2');this.afterElement.className='yui-editor-skipheader';this.afterElement.tabIndex='-1';this.afterElement.innerHTML=this.STR_LEAVE_EDITOR;this.get('element_cont').get('firstChild').appendChild(this.afterElement);}},_disableEditor:function(disabled){if(disabled){this._removeEditorEvents();if(!this._mask){if(!!this.browser.ie){this._setDesignMode('off');}
if(this.toolbar){this.toolbar.set('disabled',true);}
this._mask=document.createElement('DIV');Dom.setStyle(this._mask,'height','100%');Dom.setStyle(this._mask,'width','100%');Dom.setStyle(this._mask,'position','absolute');Dom.setStyle(this._mask,'top','0');Dom.setStyle(this._mask,'left','0');Dom.setStyle(this._mask,'opacity','.5');Dom.addClass(this._mask,'yui-editor-masked');this.get('iframe').get('parentNode').appendChild(this._mask);}}else{this._initEditorEvents();if(this._mask){this._mask.parentNode.removeChild(this._mask);this._mask=null;if(this.toolbar){this.toolbar.set('disabled',false);}
this._setDesignMode('on');this._focusWindow();var self=this;window.setTimeout(function(){self.nodeChange.call(self);},100);}}},SEP_DOMPATH:'<',STR_LEAVE_EDITOR:'You have left the Rich Text Editor.',STR_BEFORE_EDITOR:'This text field can contain stylized text and graphics. To cycle through all formatting options, use the keyboard shortcut Shift + Escape to place focus on the toolbar and navigate between options with your arrow keys. To exit this text editor use the Escape key and continue tabbing. <h4>Common formatting keyboard shortcuts:</h4><ul><li>Control Shift B sets text to bold</li> <li>Control Shift I sets text to italic</li> <li>Control Shift U underlines text</li> <li>Control Shift L adds an HTML link</li></ul>',STR_TITLE:'Rich Text Area.',STR_IMAGE_HERE:'Image URL Here',STR_LINK_URL:'Link URL',STOP_EXEC_COMMAND:false,STOP_NODE_CHANGE:false,CLASS_NOEDIT:'yui-noedit',CLASS_CONTAINER:'yui-editor-container',CLASS_EDITABLE:'yui-editor-editable',CLASS_EDITABLE_CONT:'yui-editor-editable-container',CLASS_PREFIX:'yui-editor',browser:function(){var br=YAHOO.env.ua;if(br.webkit>=420){br.webkit3=br.webkit;}else{br.webkit3=0;}
br.mac=false;if(navigator.userAgent.indexOf('Macintosh')!==-1){br.mac=true;}
return br;}(),init:function(p_oElement,p_oAttributes){if(!this._defaultToolbar){this._defaultToolbar={collapse:true,titlebar:'Text Editing Tools',draggable:false,buttons:[{group:'fontstyle',label:'Font Name and Size',buttons:[{type:'select',label:'Arial',value:'fontname',disabled:true,menu:[{text:'Arial',checked:true},{text:'Arial Black'},{text:'Comic Sans MS'},{text:'Courier New'},{text:'Lucida Console'},{text:'Tahoma'},{text:'Times New Roman'},{text:'Trebuchet MS'},{text:'Verdana'}]},{type:'spin',label:'13',value:'fontsize',range:[9,75],disabled:true}]},{type:'separator'},{group:'textstyle',label:'Font Style',buttons:[{type:'push',label:'Bold CTRL + SHIFT + B',value:'bold'},{type:'push',label:'Italic CTRL + SHIFT + I',value:'italic'},{type:'push',label:'Underline CTRL + SHIFT + U',value:'underline'},{type:'push',label:'Strike Through',value:'strikethrough'},{type:'separator'},{type:'color',label:'Font Color',value:'forecolor',disabled:true},{type:'color',label:'Background Color',value:'backcolor',disabled:true}]},{type:'separator'},{group:'indentlist',label:'Lists',buttons:[{type:'push',label:'Create an Unordered List',value:'insertunorderedlist'},{type:'push',label:'Create an Ordered List',value:'insertorderedlist'}]},{type:'separator'},{group:'insertitem',label:'Insert Item',buttons:[{type:'push',label:'HTML Link CTRL + SHIFT + L',value:'createlink',disabled:true},{type:'push',label:'Insert Image',value:'insertimage'}]}]};}
YAHOO.widget.SimpleEditor.superclass.init.call(this,p_oElement,p_oAttributes);YAHOO.widget.EditorInfo._instances[this.get('id')]=this;this.currentElement=[];this.on('contentReady',function(){this.DOMReady=true;this.fireQueue();},this,true);},initAttributes:function(attr){YAHOO.widget.SimpleEditor.superclass.initAttributes.call(this,attr);var self=this;this.setAttributeConfig('nodeChangeDelay',{value:((attr.nodeChangeDelay===false)?false:true)});this.setAttributeConfig('maxUndo',{writeOnce:true,value:attr.maxUndo||30});this.setAttributeConfig('ptags',{writeOnce:true,value:attr.ptags||false});this.setAttributeConfig('insert',{writeOnce:true,value:attr.insert||false,method:function(insert){if(insert){var buttons={fontname:true,fontsize:true,forecolor:true,backcolor:true};var tmp=this._defaultToolbar.buttons;for(var i=0;i<tmp.length;i++){if(tmp[i].buttons){for(var a=0;a<tmp[i].buttons.length;a++){if(tmp[i].buttons[a].value){if(buttons[tmp[i].buttons[a].value]){delete tmp[i].buttons[a].disabled;}}}}}}}});this.setAttributeConfig('container',{writeOnce:true,value:attr.container||false});this.setAttributeConfig('plainText',{writeOnce:true,value:attr.plainText||false});this.setAttributeConfig('iframe',{value:null});this.setAttributeConfig('textarea',{value:null,writeOnce:true});this.setAttributeConfig('container',{readOnly:true,value:null});this.setAttributeConfig('nodeChangeThreshold',{value:attr.nodeChangeThreshold||3,validator:YAHOO.lang.isNumber});this.setAttributeConfig('allowNoEdit',{value:attr.allowNoEdit||false,validator:YAHOO.lang.isBoolean});this.setAttributeConfig('limitCommands',{value:attr.limitCommands||false,validator:YAHOO.lang.isBoolean});this.setAttributeConfig('element_cont',{value:attr.element_cont});this.setAttributeConfig('editor_wrapper',{value:attr.editor_wrapper||null,writeOnce:true});this.setAttributeConfig('height',{value:attr.height||Dom.getStyle(self.get('element'),'height'),method:function(height){if(this._rendered){if(this.get('animate')){var anim=new YAHOO.util.Anim(this.get('iframe').get('parentNode'),{height:{to:parseInt(height,10)}},0.5);anim.animate();}else{Dom.setStyle(this.get('iframe').get('parentNode'),'height',height);}}}});this.setAttributeConfig('autoHeight',{value:attr.autoHeight||false,method:function(a){if(a){if(this.get('iframe')){this.get('iframe').get('element').setAttribute('scrolling','no');}
this.on('afterNodeChange',this._handleAutoHeight,this,true);this.on('editorKeyDown',this._handleAutoHeight,this,true);this.on('editorKeyPress',this._handleAutoHeight,this,true);}else{if(this.get('iframe')){this.get('iframe').get('element').setAttribute('scrolling','auto');}
this.unsubscribe('afterNodeChange',this._handleAutoHeight);this.unsubscribe('editorKeyDown',this._handleAutoHeight);this.unsubscribe('editorKeyPress',this._handleAutoHeight);}}});this.setAttributeConfig('width',{value:attr.width||Dom.getStyle(this.get('element'),'width'),method:function(width){if(this._rendered){if(this.get('animate')){var anim=new YAHOO.util.Anim(this.get('element_cont').get('element'),{width:{to:parseInt(width,10)}},0.5);anim.animate();}else{this.get('element_cont').setStyle('width',width);}}}});this.setAttributeConfig('blankimage',{value:attr.blankimage||this._getBlankImage()});this.setAttributeConfig('css',{value:attr.css||this._defaultCSS,writeOnce:true});this.setAttributeConfig('html',{value:attr.html||'<html><head><title>{TITLE}</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><base href="'+this._baseHREF+'"><style>{CSS}</style><style>{HIDDEN_CSS}</style><style>{EXTRA_CSS}</style></head><body onload="document.body._rteLoaded = true;">{CONTENT}</body></html>',writeOnce:true});this.setAttributeConfig('extracss',{value:attr.extracss||'',writeOnce:true});this.setAttributeConfig('handleSubmit',{value:attr.handleSubmit||false,method:function(exec){if(this.get('element').form){if(!this._formButtons){this._formButtons=[];}
if(exec){Event.on(this.get('element').form,'submit',this._handleFormSubmit,this,true);var i=this.get('element').form.getElementsByTagName('input');for(var s=0;s<i.length;s++){var type=i[s].getAttribute('type');if(type&&(type.toLowerCase()=='submit')){Event.on(i[s],'click',this._handleFormButtonClick,this,true);this._formButtons[this._formButtons.length]=i[s];}}}else{Event.removeListener(this.get('element').form,'submit',this._handleFormSubmit);if(this._formButtons){Event.removeListener(this._formButtons,'click',this._handleFormButtonClick);}}}}});this.setAttributeConfig('disabled',{value:false,method:function(disabled){if(this._rendered){this._disableEditor(disabled);}}});this.setAttributeConfig('saveEl',{value:this.get('element')});this.setAttributeConfig('toolbar_cont',{value:null,writeOnce:true});this.setAttributeConfig('toolbar',{value:attr.toolbar||this._defaultToolbar,writeOnce:true,method:function(toolbar){if(!toolbar.buttonType){toolbar.buttonType=this._defaultToolbar.buttonType;}
this._defaultToolbar=toolbar;}});this.setAttributeConfig('animate',{value:((attr.animate)?((YAHOO.util.Anim)?true:false):false),validator:function(value){var ret=true;if(!YAHOO.util.Anim){ret=false;}
return ret;}});this.setAttributeConfig('panel',{value:null,writeOnce:true,validator:function(value){var ret=true;if(!YAHOO.widget.Overlay){ret=false;}
return ret;}});this.setAttributeConfig('focusAtStart',{value:attr.focusAtStart||false,writeOnce:true,method:function(fs){if(fs){this.on('editorContentLoaded',function(){var self=this;setTimeout(function(){self._focusWindow.call(self,true);self.editorDirty=false;},400);},this,true);}}});this.setAttributeConfig('dompath',{value:attr.dompath||false,method:function(dompath){if(dompath&&!this.dompath){this.dompath=document.createElement('DIV');this.dompath.id=this.get('id')+'_dompath';Dom.addClass(this.dompath,'dompath');this.get('element_cont').get('firstChild').appendChild(this.dompath);if(this.get('iframe')){this._writeDomPath();}}else if(!dompath&&this.dompath){this.dompath.parentNode.removeChild(this.dompath);this.dompath=null;}}});this.setAttributeConfig('markup',{value:attr.markup||'semantic',validator:function(markup){switch(markup.toLowerCase()){case'semantic':case'css':case'default':case'xhtml':return true;}
return false;}});this.setAttributeConfig('removeLineBreaks',{value:attr.removeLineBreaks||false,validator:YAHOO.lang.isBoolean});this.setAttributeConfig('drag',{writeOnce:true,value:attr.drag||false});this.setAttributeConfig('resize',{writeOnce:true,value:attr.resize||false});},_getBlankImage:function(){if(!this.DOMReady){this._queue[this._queue.length]=['_getBlankImage',arguments];return'';}
var img='';if(!this._blankImageLoaded){if(YAHOO.widget.EditorInfo.blankImage){this.set('blankimage',YAHOO.widget.EditorInfo.blankImage);this._blankImageLoaded=true;}else{var div=document.createElement('div');div.style.position='absolute';div.style.top='-9999px';div.style.left='-9999px';div.className=this.CLASS_PREFIX+'-blankimage';document.body.appendChild(div);img=YAHOO.util.Dom.getStyle(div,'background-image');img=img.replace('url(','').replace(')','').replace(/"/g,'');img=img.replace('app:/','');this.set('blankimage',img);this._blankImageLoaded=true;div.parentNode.removeChild(div);YAHOO.widget.EditorInfo.blankImage=img;}}else{img=this.get('blankimage');}
return img;},_handleAutoHeight:function(){var doc=this._getDoc(),body=doc.body,docEl=doc.documentElement;var height=parseInt(Dom.getStyle(this.get('editor_wrapper'),'height'),10);var newHeight=body.scrollHeight;if(this.browser.webkit){newHeight=docEl.scrollHeight;}
if(newHeight<parseInt(this.get('height'),10)){newHeight=parseInt(this.get('height'),10);}
if((height!=newHeight)&&(newHeight>=parseInt(this.get('height'),10))){Dom.setStyle(this.get('editor_wrapper'),'height',newHeight+'px');if(this.browser.ie){this.get('iframe').setStyle('height','99%');this.get('iframe').setStyle('zoom','1');var self=this;window.setTimeout(function(){self.get('iframe').setStyle('height','100%');},1);}}},_formButtons:null,_formButtonClicked:null,_handleFormButtonClick:function(ev){var tar=Event.getTarget(ev);this._formButtonClicked=tar;},_handleFormSubmit:function(ev){this.saveHTML();var form=this.get('element').form,tar=this._formButtonClicked||false;Event.removeListener(form,'submit',this._handleFormSubmit);if(YAHOO.env.ua.ie){if(tar&&!tar.disabled){tar.click();}}else{if(tar&&!tar.disabled){tar.click();}
var oEvent=document.createEvent("HTMLEvents");oEvent.initEvent("submit",true,true);form.dispatchEvent(oEvent);if(YAHOO.env.ua.webkit){if(YAHOO.lang.isFunction(form.submit)){form.submit();}}}},_handleFontSize:function(o){var button=this.toolbar.getButtonById(o.button.id);var value=button.get('label')+'px';this.execCommand('fontsize',value);this.STOP_EXEC_COMMAND=true;},_handleColorPicker:function(o){var cmd=o.button;var value='#'+o.color;if((cmd=='forecolor')||(cmd=='backcolor')){this.execCommand(cmd,value);}},_handleAlign:function(o){var cmd=null;for(var i=0;i<o.button.menu.length;i++){if(o.button.menu[i].value==o.button.value){cmd=o.button.menu[i].value;}}
var value=this._getSelection();this.execCommand(cmd,value);this.STOP_EXEC_COMMAND=true;},_handleAfterNodeChange:function(){var path=this._getDomPath(),elm=null,family=null,fontsize=null,validFont=false,fn_button=this.toolbar.getButtonByValue('fontname'),fs_button=this.toolbar.getButtonByValue('fontsize'),hd_button=this.toolbar.getButtonByValue('heading');for(var i=0;i<path.length;i++){elm=path[i];var tag=elm.tagName.toLowerCase();if(elm.getAttribute('tag')){tag=elm.getAttribute('tag');}
family=elm.getAttribute('face');if(Dom.getStyle(elm,'font-family')){family=Dom.getStyle(elm,'font-family');family=family.replace(/'/g,'');}
if(tag.substring(0,1)=='h'){if(hd_button){for(var h=0;h<hd_button._configs.menu.value.length;h++){if(hd_button._configs.menu.value[h].value.toLowerCase()==tag){hd_button.set('label',hd_button._configs.menu.value[h].text);}}
this._updateMenuChecked('heading',tag);}}}
if(fn_button){for(var b=0;b<fn_button._configs.menu.value.length;b++){if(family&&fn_button._configs.menu.value[b].text.toLowerCase()==family.toLowerCase()){validFont=true;family=fn_button._configs.menu.value[b].text;}}
if(!validFont){family=fn_button._configs.label._initialConfig.value;}
var familyLabel='<span class="yui-toolbar-fontname-'+this._cleanClassName(family)+'">'+family+'</span>';if(fn_button.get('label')!=familyLabel){fn_button.set('label',familyLabel);this._updateMenuChecked('fontname',family);}}
if(fs_button){fontsize=parseInt(Dom.getStyle(elm,'fontSize'),10);if((fontsize===null)||isNaN(fontsize)){fontsize=fs_button._configs.label._initialConfig.value;}
fs_button.set('label',''+fontsize);}
if(!this._isElement(elm,'body')&&!this._isElement(elm,'img')){this.toolbar.enableButton(fn_button);this.toolbar.enableButton(fs_button);this.toolbar.enableButton('forecolor');this.toolbar.enableButton('backcolor');}
if(this._isElement(elm,'img')){if(YAHOO.widget.Overlay){this.toolbar.enableButton('createlink');}}
if(this._hasParent(elm,'blockquote')){this.toolbar.selectButton('indent');this.toolbar.disableButton('indent');this.toolbar.enableButton('outdent');}
if(this._hasParent(elm,'ol')||this._hasParent(elm,'ul')){this.toolbar.disableButton('indent');}
this._lastButton=null;},_handleInsertImageClick:function(){if(this.get('limitCommands')){if(!this.toolbar.getButtonByValue('insertimage')){return false;}}
this.toolbar.set('disabled',true);this.on('afterExecCommand',function(){var el=this.currentElement[0],src='http://';if(!el){el=this._getSelectedElement();}
if(el){if(el.getAttribute('src')){src=el.getAttribute('src',2);if(src.indexOf(this.get('blankimage'))!=-1){src=this.STR_IMAGE_HERE;}}}
var str=prompt(this.STR_LINK_URL+': ',src);if((str!=='')&&(str!==null)){el.setAttribute('src',str);}else if(str===null){el.parentNode.removeChild(el);this.currentElement=[];this.nodeChange();}
this.closeWindow();this.toolbar.set('disabled',false);},this,true);},_handleInsertImageWindowClose:function(){this.nodeChange();},_isLocalFile:function(url){if((url)&&(url!=='')&&((url.indexOf('file:/')!=-1)||(url.indexOf(':\\')!=-1))){return true;}
return false;},_handleCreateLinkClick:function(){if(this.get('limitCommands')){if(!this.toolbar.getButtonByValue('createlink')){return false;}}
this.toolbar.set('disabled',true);this.on('afterExecCommand',function(){var el=this.currentElement[0],url='';if(el){if(el.getAttribute('href',2)!==null){url=el.getAttribute('href',2);}}
var str=prompt(this.STR_LINK_URL+': ',url);if((str!=='')&&(str!==null)){var urlValue=str;if((urlValue.indexOf(':/'+'/')==-1)&&(urlValue.substring(0,1)!='/')&&(urlValue.substring(0,6).toLowerCase()!='mailto')){if((urlValue.indexOf('@')!=-1)&&(urlValue.substring(0,6).toLowerCase()!='mailto')){urlValue='mailto:'+urlValue;}else{if(urlValue.substring(0,1)!='#'){}}}
el.setAttribute('href',urlValue);}else if(str!==null){var _span=this._getDoc().createElement('span');_span.innerHTML=el.innerHTML;Dom.addClass(_span,'yui-non');el.parentNode.replaceChild(_span,el);}
this.closeWindow();this.toolbar.set('disabled',false);},this);},_handleCreateLinkWindowClose:function(){this.nodeChange();this.currentElement=[];},render:function(){if(this._rendered){return false;}
if(!this.DOMReady){this._queue[this._queue.length]=['render',arguments];return false;}
if(this.get('element')){if(this.get('element').tagName){this._textarea=true;if(this.get('element').tagName.toLowerCase()!=='textarea'){this._textarea=false;}}else{return false;}}else{return false;}
this._rendered=true;var self=this;window.setTimeout(function(){self._render.call(self);},4);},_render:function(){var self=this;this.set('textarea',this.get('element'));this.get('element_cont').setStyle('display','none');this.get('element_cont').addClass(this.CLASS_CONTAINER);this.set('iframe',this._createIframe());window.setTimeout(function(){self._setInitialContent.call(self);},10);this.get('editor_wrapper').appendChild(this.get('iframe').get('element'));if(this.get('disabled')){this._disableEditor(true);}
var tbarConf=this.get('toolbar');if(tbarConf instanceof Toolbar){this.toolbar=tbarConf;this.toolbar.set('disabled',true);}else{tbarConf.disabled=true;this.toolbar=new Toolbar(this.get('toolbar_cont'),tbarConf);}
this.fireEvent('toolbarLoaded',{type:'toolbarLoaded',target:this.toolbar});this.toolbar.on('toolbarCollapsed',function(){if(this.currentWindow){this.moveWindow();}},this,true);this.toolbar.on('toolbarExpanded',function(){if(this.currentWindow){this.moveWindow();}},this,true);this.toolbar.on('fontsizeClick',this._handleFontSize,this,true);this.toolbar.on('colorPickerClicked',function(o){this._handleColorPicker(o);return false;},this,true);this.toolbar.on('alignClick',this._handleAlign,this,true);this.on('afterNodeChange',this._handleAfterNodeChange,this,true);this.toolbar.on('insertimageClick',this._handleInsertImageClick,this,true);this.on('windowinsertimageClose',this._handleInsertImageWindowClose,this,true);this.toolbar.on('createlinkClick',this._handleCreateLinkClick,this,true);this.on('windowcreatelinkClose',this._handleCreateLinkWindowClose,this,true);this.get('parentNode').replaceChild(this.get('element_cont').get('element'),this.get('element'));this.setStyle('visibility','hidden');this.setStyle('position','absolute');this.setStyle('top','-9999px');this.setStyle('left','-9999px');this.get('element_cont').appendChild(this.get('element'));this.get('element_cont').setStyle('display','block');Dom.addClass(this.get('iframe').get('parentNode'),this.CLASS_EDITABLE_CONT);this.get('iframe').addClass(this.CLASS_EDITABLE);this.get('element_cont').setStyle('width',this.get('width'));Dom.setStyle(this.get('iframe').get('parentNode'),'height',this.get('height'));this.get('iframe').setStyle('width','100%');this.get('iframe').setStyle('height','100%');this._setupDD();window.setTimeout(function(){self._setupAfterElement.call(self);},0);this.fireEvent('afterRender',{type:'afterRender',target:this});},execCommand:function(action,value){var beforeExec=this.fireEvent('beforeExecCommand',{type:'beforeExecCommand',target:this,args:arguments});if((beforeExec===false)||(this.STOP_EXEC_COMMAND)){this.STOP_EXEC_COMMAND=false;return false;}
this._lastCommand=action;this._setMarkupType(action);if(this.browser.ie){this._getWindow().focus();}
var exec=true;if(this.get('limitCommands')){if(!this.toolbar.getButtonByValue(action)){exec=false;}}
this.editorDirty=true;if((typeof this['cmd_'+action.toLowerCase()]=='function')&&exec){var retValue=this['cmd_'+action.toLowerCase()](value);exec=retValue[0];if(retValue[1]){action=retValue[1];}
if(retValue[2]){value=retValue[2];}}
if(exec){try{this._getDoc().execCommand(action,false,value);}catch(e){}}else{}
this.on('afterExecCommand',function(){this.unsubscribeAll('afterExecCommand');this.nodeChange();},this,true);this.fireEvent('afterExecCommand',{type:'afterExecCommand',target:this});},cmd_underline:function(value){if(!this.browser.webkit){var el=this._getSelectedElement();if(el&&this._isElement(el,'span')){if(el.style.textDecoration=='underline'){el.style.textDecoration='none';}else{el.style.textDecoration='underline';}
return[false];}}
return[true];},cmd_backcolor:function(value){var exec=true,el=this._getSelectedElement(),action='backcolor';if(this.browser.gecko||this.browser.opera){this._setEditorStyle(true);action='hilitecolor';}
if(!this._isElement(el,'body')&&!this._hasSelection()){Dom.setStyle(el,'background-color',value);this._selectNode(el);exec=false;}else if(!this._isElement(el,'body')&&this._hasSelection()){Dom.setStyle(el,'background-color',value);this._selectNode(el);exec=false;}else{if(this.get('insert')){el=this._createInsertElement({backgroundColor:value});}else{this._createCurrentElement('span',{backgroundColor:value});this._selectNode(this.currentElement[0]);}
exec=false;}
return[exec,action];},cmd_forecolor:function(value){var exec=true,el=this._getSelectedElement();if(!this._isElement(el,'body')&&!this._hasSelection()){Dom.setStyle(el,'color',value);this._selectNode(el);exec=false;}else if(!this._isElement(el,'body')&&this._hasSelection()){Dom.setStyle(el,'color',value);this._selectNode(el);exec=false;}else{if(this.get('insert')){el=this._createInsertElement({color:value});}else{this._createCurrentElement('span',{color:value});this._selectNode(this.currentElement[0]);}
exec=false;}
return[exec];},cmd_unlink:function(value){this._swapEl(this.currentElement[0],'span',function(el){el.className='yui-non';});return[false];},cmd_createlink:function(value){var el=this._getSelectedElement(),_a=null;if(this._hasParent(el,'a')){this.currentElement[0]=this._hasParent(el,'a');}else if(!this._isElement(el,'a')){this._createCurrentElement('a');_a=this._swapEl(this.currentElement[0],'a');this.currentElement[0]=_a;}else{this.currentElement[0]=el;}
return[false];},cmd_insertimage:function(value){var exec=true,_img=null,action='insertimage',el=this._getSelectedElement();if(value===''){value=this.get('blankimage');}
if(this._isElement(el,'img')){this.currentElement[0]=el;exec=false;}else{if(this._getDoc().queryCommandEnabled(action)){this._getDoc().execCommand('insertimage',false,value);var imgs=this._getDoc().getElementsByTagName('img');for(var i=0;i<imgs.length;i++){if(!YAHOO.util.Dom.hasClass(imgs[i],'yui-img')){YAHOO.util.Dom.addClass(imgs[i],'yui-img');this.currentElement[0]=imgs[i];}}
exec=false;}else{if(el==this._getDoc().body){_img=this._getDoc().createElement('img');_img.setAttribute('src',value);YAHOO.util.Dom.addClass(_img,'yui-img');this._getDoc().body.appendChild(_img);}else{this._createCurrentElement('img');_img=this._getDoc().createElement('img');_img.setAttribute('src',value);YAHOO.util.Dom.addClass(_img,'yui-img');this.currentElement[0].parentNode.replaceChild(_img,this.currentElement[0]);}
this.currentElement[0]=_img;exec=false;}}
return[exec];},cmd_inserthtml:function(value){var exec=true,action='inserthtml',_span=null,_range=null;if(this.browser.webkit&&!this._getDoc().queryCommandEnabled(action)){this._createCurrentElement('img');_span=this._getDoc().createElement('span');_span.innerHTML=value;this.currentElement[0].parentNode.replaceChild(_span,this.currentElement[0]);exec=false;}else if(this.browser.ie){_range=this._getRange();if(_range.item){_range.item(0).outerHTML=value;}else{_range.pasteHTML(value);}
exec=false;}
return[exec];},cmd_list:function(tag){var exec=true,list=null,li=0,el=null,str='',selEl=this._getSelectedElement(),action='insertorderedlist';if(tag=='ul'){action='insertunorderedlist';}
if(this.browser.webkit){if(this._isElement(selEl,'li')&&this._isElement(selEl.parentNode,tag)){el=selEl.parentNode;list=this._getDoc().createElement('span');YAHOO.util.Dom.addClass(list,'yui-non');str='';var lis=el.getElementsByTagName('li');for(li=0;li<lis.length;li++){str+='<div>'+lis[li].innerHTML+'</div>';}
list.innerHTML=str;this.currentElement[0]=el;this.currentElement[0].parentNode.replaceChild(list,this.currentElement[0]);}else{this._createCurrentElement(tag.toLowerCase());list=this._getDoc().createElement(tag);for(li=0;li<this.currentElement.length;li++){var newli=this._getDoc().createElement('li');newli.innerHTML=this.currentElement[li].innerHTML+'<span class="yui-non">&nbsp;</span>&nbsp;';list.appendChild(newli);if(li>0){this.currentElement[li].parentNode.removeChild(this.currentElement[li]);}}
this.currentElement[0].parentNode.replaceChild(list,this.currentElement[0]);this.currentElement[0]=list;var _h=this.currentElement[0].firstChild;_h=Dom.getElementsByClassName('yui-non','span',_h)[0];this._getSelection().setBaseAndExtent(_h,1,_h,_h.innerText.length);}
exec=false;}else{el=this._getSelectedElement();if(this._isElement(el,'li')&&this._isElement(el.parentNode,tag)||(this.browser.ie&&this._isElement(this._getRange().parentElement,'li'))||(this.browser.ie&&this._isElement(el,'ul'))||(this.browser.ie&&this._isElement(el,'ol'))){if(this.browser.ie){if((this.browser.ie&&this._isElement(el,'ul'))||(this.browser.ie&&this._isElement(el,'ol'))){el=el.getElementsByTagName('li')[0];}
str='';var lis2=el.parentNode.getElementsByTagName('li');for(var j=0;j<lis2.length;j++){str+=lis2[j].innerHTML+'<br>';}
var newEl=this._getDoc().createElement('span');newEl.innerHTML=str;el.parentNode.parentNode.replaceChild(newEl,el.parentNode);}else{this.nodeChange();this._getDoc().execCommand(action,'',el.parentNode);this.nodeChange();}
exec=false;}
if(this.browser.opera){var self=this;window.setTimeout(function(){var liso=self._getDoc().getElementsByTagName('li');for(var i=0;i<liso.length;i++){if(liso[i].innerHTML.toLowerCase()=='<br>'){liso[i].parentNode.parentNode.removeChild(liso[i].parentNode);}}},30);}
if(this.browser.ie&&exec){var html='';if(this._getRange().html){html='<li>'+this._getRange().html+'</li>';}else{var t=this._getRange().text.split('\n');if(t.length>1){html='';for(var ie=0;ie<t.length;ie++){html+='<li>'+t[ie]+'</li>';}}else{var txt=this._getRange().text;if(txt===''){html='<li id="new_list_item">'+txt+'</li>';}else{html='<li>'+txt+'</li>';}}}
this._getRange().pasteHTML('<'+tag+'>'+html+'</'+tag+'>');var new_item=this._getDoc().getElementById('new_list_item');if(new_item){var range=this._getDoc().body.createTextRange();range.moveToElementText(new_item);range.collapse(false);range.select();new_item.id='';}
exec=false;}}
return exec;},cmd_insertorderedlist:function(value){return[this.cmd_list('ol')];},cmd_insertunorderedlist:function(value){return[this.cmd_list('ul')];},cmd_fontname:function(value){var exec=true,selEl=this._getSelectedElement();this.currentFont=value;if(selEl&&selEl.tagName&&!this._hasSelection()&&!this._isElement(selEl,'body')&&!this.get('insert')){YAHOO.util.Dom.setStyle(selEl,'font-family',value);exec=false;}else if(this.get('insert')&&!this._hasSelection()){var el=this._createInsertElement({fontFamily:value});exec=false;}
return[exec];},cmd_fontsize:function(value){var el=null;if(this.currentElement&&(this.currentElement.length>0)&&(!this._hasSelection())&&(!this.get('insert'))){YAHOO.util.Dom.setStyle(this.currentElement,'fontSize',value);}else if(!this._isElement(this._getSelectedElement(),'body')){el=this._getSelectedElement();YAHOO.util.Dom.setStyle(el,'fontSize',value);if(this.get('insert')&&this.browser.ie){var r=this._getRange();r.collapse(false);r.select();}else{this._selectNode(el);}}else{if(this.get('insert')&&!this._hasSelection()){el=this._createInsertElement({fontSize:value});this.currentElement[0]=el;this._selectNode(this.currentElement[0]);}else{this._createCurrentElement('span',{'fontSize':value});this._selectNode(this.currentElement[0]);}}
return[false];},_swapEl:function(el,tagName,callback){var _el=this._getDoc().createElement(tagName);if(el){_el.innerHTML=el.innerHTML;}
if(typeof callback=='function'){callback.call(this,_el);}
if(el){el.parentNode.replaceChild(_el,el);}
return _el;},_createInsertElement:function(css){this._createCurrentElement('span',css);var el=this.currentElement[0];if(this.browser.webkit){el.innerHTML='<span class="yui-non">&nbsp;</span>';el=el.firstChild;this._getSelection().setBaseAndExtent(el,1,el,el.innerText.length);}else if(this.browser.ie||this.browser.opera){el.innerHTML='&nbsp;';}
this._focusWindow();this._selectNode(el,true);return el;},_createCurrentElement:function(tagName,tagStyle){tagName=((tagName)?tagName:'a');var tar=null,el=[],_doc=this._getDoc();if(this.currentFont){if(!tagStyle){tagStyle={};}
tagStyle.fontFamily=this.currentFont;this.currentFont=null;}
this.currentElement=[];var _elCreate=function(tagName,tagStyle){var el=null;tagName=((tagName)?tagName:'span');tagName=tagName.toLowerCase();switch(tagName){case'h1':case'h2':case'h3':case'h4':case'h5':case'h6':el=_doc.createElement(tagName);break;default:el=_doc.createElement(tagName);if(tagName==='span'){YAHOO.util.Dom.addClass(el,'yui-tag-'+tagName);YAHOO.util.Dom.addClass(el,'yui-tag');el.setAttribute('tag',tagName);}
for(var k in tagStyle){if(YAHOO.lang.hasOwnProperty(tagStyle,k)){el.style[k]=tagStyle[k];}}
break;}
return el;};if(!this._hasSelection()){if(this._getDoc().queryCommandEnabled('insertimage')){this._getDoc().execCommand('insertimage',false,'yui-tmp-img');var imgs=this._getDoc().getElementsByTagName('img');for(var j=0;j<imgs.length;j++){if(imgs[j].getAttribute('src',2)=='yui-tmp-img'){el=_elCreate(tagName,tagStyle);imgs[j].parentNode.replaceChild(el,imgs[j]);this.currentElement[this.currentElement.length]=el;}}}else{if(this.currentEvent){tar=YAHOO.util.Event.getTarget(this.currentEvent);}else{tar=this._getDoc().body;}}
if(tar){el=_elCreate(tagName,tagStyle);if(this._isElement(tar,'body')||this._isElement(tar,'html')){if(this._isElement(tar,'html')){tar=this._getDoc().body;}
tar.appendChild(el);}else if(tar.nextSibling){tar.parentNode.insertBefore(el,tar.nextSibling);}else{tar.parentNode.appendChild(el);}
this.currentElement[this.currentElement.length]=el;this.currentEvent=null;if(this.browser.webkit){this._getSelection().setBaseAndExtent(el,0,el,0);if(this.browser.webkit3){this._getSelection().collapseToStart();}else{this._getSelection().collapse(true);}}}}else{this._setEditorStyle(true);this._getDoc().execCommand('fontname',false,'yui-tmp');var _tmp=[],__tmp,__els=['font','span','i','b','u'];if(!this._isElement(this._getSelectedElement(),'body')){__els[__els.length]=this._getDoc().getElementsByTagName(this._getSelectedElement().tagName);__els[__els.length]=this._getDoc().getElementsByTagName(this._getSelectedElement().parentNode.tagName);}
for(var _els=0;_els<__els.length;_els++){var _tmp1=this._getDoc().getElementsByTagName(__els[_els]);for(var e=0;e<_tmp1.length;e++){_tmp[_tmp.length]=_tmp1[e];}}
for(var i=0;i<_tmp.length;i++){if((YAHOO.util.Dom.getStyle(_tmp[i],'font-family')=='yui-tmp')||(_tmp[i].face&&(_tmp[i].face=='yui-tmp'))){el=_elCreate(tagName,tagStyle);el.innerHTML=_tmp[i].innerHTML;if(this._isElement(_tmp[i],'ol')||(this._isElement(_tmp[i],'ul'))){var fc=_tmp[i].getElementsByTagName('li')[0];_tmp[i].style.fontFamily='inherit';fc.style.fontFamily='inherit';el.innerHTML=fc.innerHTML;fc.innerHTML='';fc.appendChild(el);this.currentElement[this.currentElement.length]=el;}else if(this._isElement(_tmp[i],'li')){_tmp[i].innerHTML='';_tmp[i].appendChild(el);_tmp[i].style.fontFamily='inherit';this.currentElement[this.currentElement.length]=el;}else{if(_tmp[i].parentNode){_tmp[i].parentNode.replaceChild(el,_tmp[i]);this.currentElement[this.currentElement.length]=el;this.currentEvent=null;if(this.browser.webkit){this._getSelection().setBaseAndExtent(el,0,el,0);if(this.browser.webkit3){this._getSelection().collapseToStart();}else{this._getSelection().collapse(true);}}
if(this.browser.ie&&tagStyle&&tagStyle.fontSize){this._getSelection().empty();}
if(this.browser.gecko){this._getSelection().collapseToStart();}}}}}
var len=this.currentElement.length;for(var o=0;o<len;o++){if((o+1)!=len){if(this.currentElement[o]&&this.currentElement[o].nextSibling){if(this._isElement(this.currentElement[o],'br')){this.currentElement[this.currentElement.length]=this.currentElement[o].nextSibling;}}}}}},saveHTML:function(){var html=this.cleanHTML();if(this._textarea){this.get('element').value=html;}else{this.get('element').innerHTML=html;}
if(this.get('saveEl')!==this.get('element')){var out=this.get('saveEl');if(Lang.isString(out)){out=Dom.get(out);}
if(out){if(out.tagName.toLowerCase()==='textarea'){out.value=html;}else{out.innerHTML=html;}}}
return html;},setEditorHTML:function(incomingHTML){var html=this._cleanIncomingHTML(incomingHTML);this._getDoc().body.innerHTML=html;this.nodeChange();},getEditorHTML:function(){var b=this._getDoc().body;if(b===null){return null;}
return this._getDoc().body.innerHTML;},show:function(){if(this.browser.gecko){this._setDesignMode('on');this._focusWindow();}
if(this.browser.webkit){var self=this;window.setTimeout(function(){self._setInitialContent.call(self);},10);}
if(this.currentWindow){this.closeWindow();}
this.get('iframe').setStyle('position','static');this.get('iframe').setStyle('left','');},hide:function(){if(this.currentWindow){this.closeWindow();}
if(this._fixNodesTimer){clearTimeout(this._fixNodesTimer);this._fixNodesTimer=null;}
if(this._nodeChangeTimer){clearTimeout(this._nodeChangeTimer);this._nodeChangeTimer=null;}
this._lastNodeChange=0;this.get('iframe').setStyle('position','absolute');this.get('iframe').setStyle('left','-9999px');},_cleanIncomingHTML:function(html){html=html.replace(/<strong([^>]*)>/gi,'<b$1>');html=html.replace(/<\/strong>/gi,'</b>');html=html.replace(/<embed([^>]*)>/gi,'<YUI_EMBED$1>');html=html.replace(/<\/embed>/gi,'</YUI_EMBED>');html=html.replace(/<em([^>]*)>/gi,'<i$1>');html=html.replace(/<\/em>/gi,'</i>');html=html.replace(/<YUI_EMBED([^>]*)>/gi,'<embed$1>');html=html.replace(/<\/YUI_EMBED>/gi,'</embed>');if(this.get('plainText')){html=html.replace(/\n/g,'<br>').replace(/\r/g,'<br>');html=html.replace(/  /gi,'&nbsp;&nbsp;');html=html.replace(/\t/gi,'&nbsp;&nbsp;&nbsp;&nbsp;');}
html=html.replace(/<script([^>]*)>/gi,'<bad>');html=html.replace(/<\/script([^>]*)>/gi,'</bad>');html=html.replace(/&lt;script([^>]*)&gt;/gi,'<bad>');html=html.replace(/&lt;\/script([^>]*)&gt;/gi,'</bad>');html=html.replace(/\n/g,'<YUI_LF>').replace(/\r/g,'<YUI_LF>');html=html.replace(new RegExp('<bad([^>]*)>(.*?)<\/bad>','gi'),'');html=html.replace(/<YUI_LF>/g,'\n');return html;},cleanHTML:function(html){if(!html){html=this.getEditorHTML();}
var markup=this.get('markup');html=this.pre_filter_linebreaks(html,markup);html=html.replace(/<img([^>]*)\/>/gi,'<YUI_IMG$1>');html=html.replace(/<img([^>]*)>/gi,'<YUI_IMG$1>');html=html.replace(/<input([^>]*)\/>/gi,'<YUI_INPUT$1>');html=html.replace(/<input([^>]*)>/gi,'<YUI_INPUT$1>');html=html.replace(/<ul([^>]*)>/gi,'<YUI_UL$1>');html=html.replace(/<\/ul>/gi,'<\/YUI_UL>');html=html.replace(/<blockquote([^>]*)>/gi,'<YUI_BQ$1>');html=html.replace(/<\/blockquote>/gi,'<\/YUI_BQ>');html=html.replace(/<embed([^>]*)>/gi,'<YUI_EMBED$1>');html=html.replace(/<\/embed>/gi,'<\/YUI_EMBED>');if((markup=='semantic')||(markup=='xhtml')){html=html.replace(/<i(\s+[^>]*)?>/gi,'<em$1>');html=html.replace(/<\/i>/gi,'</em>');html=html.replace(/<b(\s+[^>]*)?>/gi,'<strong$1>');html=html.replace(/<\/b>/gi,'</strong>');}
html=html.replace(/<font/gi,'<font');html=html.replace(/<\/font>/gi,'</font>');html=html.replace(/<span/gi,'<span');html=html.replace(/<\/span>/gi,'</span>');if((markup=='semantic')||(markup=='xhtml')||(markup=='css')){html=html.replace(new RegExp('<font([^>]*)face="([^>]*)">(.*?)<\/font>','gi'),'<span $1 style="font-family: $2;">$3</span>');html=html.replace(/<u/gi,'<span style="text-decoration: underline;"');if(this.browser.webkit){html=html.replace(new RegExp('<span class="Apple-style-span" style="font-weight: bold;">([^>]*)<\/span>','gi'),'<strong>$1</strong>');html=html.replace(new RegExp('<span class="Apple-style-span" style="font-style: italic;">([^>]*)<\/span>','gi'),'<em>$1</em>');}
html=html.replace(/\/u>/gi,'/span>');if(markup=='css'){html=html.replace(/<em([^>]*)>/gi,'<i$1>');html=html.replace(/<\/em>/gi,'</i>');html=html.replace(/<strong([^>]*)>/gi,'<b$1>');html=html.replace(/<\/strong>/gi,'</b>');html=html.replace(/<b/gi,'<span style="font-weight: bold;"');html=html.replace(/\/b>/gi,'/span>');html=html.replace(/<i/gi,'<span style="font-style: italic;"');html=html.replace(/\/i>/gi,'/span>');}
html=html.replace(/  /gi,' ');}else{html=html.replace(/<u/gi,'<u');html=html.replace(/\/u>/gi,'/u>');}
html=html.replace(/<ol([^>]*)>/gi,'<ol$1>');html=html.replace(/\/ol>/gi,'/ol>');html=html.replace(/<li/gi,'<li');html=html.replace(/\/li>/gi,'/li>');html=this.filter_safari(html);html=this.filter_internals(html);html=this.filter_all_rgb(html);html=this.post_filter_linebreaks(html,markup);if(markup=='xhtml'){html=html.replace(/<YUI_IMG([^>]*)>/g,'<img $1 />');html=html.replace(/<YUI_INPUT([^>]*)>/g,'<input $1 />');}else{html=html.replace(/<YUI_IMG([^>]*)>/g,'<img $1>');html=html.replace(/<YUI_INPUT([^>]*)>/g,'<input $1>');}
html=html.replace(/<YUI_UL([^>]*)>/g,'<ul$1>');html=html.replace(/<\/YUI_UL>/g,'<\/ul>');html=this.filter_invalid_lists(html);html=html.replace(/<YUI_BQ([^>]*)>/g,'<blockquote$1>');html=html.replace(/<\/YUI_BQ>/g,'<\/blockquote>');html=html.replace(/<YUI_EMBED([^>]*)>/g,'<embed$1>');html=html.replace(/<\/YUI_EMBED>/g,'<\/embed>');html=html.replace(' &amp; ','YUI_AMP');html=html.replace('&amp;','&');html=html.replace('YUI_AMP','&amp;');html=YAHOO.lang.trim(html);if(this.get('removeLineBreaks')){html=html.replace(/\n/g,'').replace(/\r/g,'');html=html.replace(/  /gi,' ');}
if(html.substring(0,6).toLowerCase()=='<span>'){html=html.substring(6);if(html.substring(html.length-7,html.length).toLowerCase()=='</span>'){html=html.substring(0,html.length-7);}}
for(var v in this.invalidHTML){if(YAHOO.lang.hasOwnProperty(this.invalidHTML,v)){if(Lang.isObject(v)&&v.keepContents){html=html.replace(new RegExp('<'+v+'([^>]*)>(.*?)<\/'+v+'>','gi'),'$1');}else{html=html.replace(new RegExp('<'+v+'([^>]*)>(.*?)<\/'+v+'>','gi'),'');}}}
this.fireEvent('cleanHTML',{type:'cleanHTML',target:this,html:html});return html;},filter_invalid_lists:function(html){html=html.replace(/<\/li>\n/gi,'</li>');html=html.replace(/<\/li><ol>/gi,'</li><li><ol>');html=html.replace(/<\/ol>/gi,'</ol></li>');html=html.replace(/<\/ol><\/li>\n/gi,"</ol>\n");html=html.replace(/<\/li><ul>/gi,'</li><li><ul>');html=html.replace(/<\/ul>/gi,'</ul></li>');html=html.replace(/<\/ul><\/li>\n?/gi,"</ul>\n");html=html.replace(/<\/li>/gi,"</li>\n");html=html.replace(/<\/ol>/gi,"</ol>\n");html=html.replace(/<ol>/gi,"<ol>\n");html=html.replace(/<ul>/gi,"<ul>\n");return html;},filter_safari:function(html){if(this.browser.webkit){html=html.replace(/<span class="Apple-tab-span" style="white-space:pre">([^>])<\/span>/gi,'&nbsp;&nbsp;&nbsp;&nbsp;');html=html.replace(/Apple-style-span/gi,'');html=html.replace(/style="line-height: normal;"/gi,'');html=html.replace(/<li><\/li>/gi,'');html=html.replace(/<li> <\/li>/gi,'');html=html.replace(/<li>  <\/li>/gi,'');if(this.get('ptags')){html=html.replace(/<div([^>]*)>/g,'<p$1>');html=html.replace(/<\/div>/gi,'</p>');}else{html=html.replace(/<div>/gi,'');html=html.replace(/<\/div>/gi,'<br>');}}
return html;},filter_internals:function(html){html=html.replace(/\r/g,'');html=html.replace(/<\/?(body|head|html)[^>]*>/gi,'');html=html.replace(/<YUI_BR><\/li>/gi,'</li>');html=html.replace(/yui-tag-span/gi,'');html=html.replace(/yui-tag/gi,'');html=html.replace(/yui-non/gi,'');html=html.replace(/yui-img/gi,'');html=html.replace(/ tag="span"/gi,'');html=html.replace(/ class=""/gi,'');html=html.replace(/ style=""/gi,'');html=html.replace(/ class=" "/gi,'');html=html.replace(/ class="  "/gi,'');html=html.replace(/ target=""/gi,'');html=html.replace(/ title=""/gi,'');if(this.browser.ie){html=html.replace(/ class= /gi,'');html=html.replace(/ class= >/gi,'');html=html.replace(/_height="([^>])"/gi,'');html=html.replace(/_width="([^>])"/gi,'');}
return html;},filter_all_rgb:function(str){var exp=new RegExp("rgb\\s*?\\(\\s*?([0-9]+).*?,\\s*?([0-9]+).*?,\\s*?([0-9]+).*?\\)","gi");var arr=str.match(exp);if(Lang.isArray(arr)){for(var i=0;i<arr.length;i++){var color=this.filter_rgb(arr[i]);str=str.replace(arr[i].toString(),color);}}
return str;},filter_rgb:function(css){if(css.toLowerCase().indexOf('rgb')!=-1){var exp=new RegExp("(.*?)rgb\\s*?\\(\\s*?([0-9]+).*?,\\s*?([0-9]+).*?,\\s*?([0-9]+).*?\\)(.*?)","gi");var rgb=css.replace(exp,"$1,$2,$3,$4,$5").split(',');if(rgb.length==5){var r=parseInt(rgb[1],10).toString(16);var g=parseInt(rgb[2],10).toString(16);var b=parseInt(rgb[3],10).toString(16);r=r.length==1?'0'+r:r;g=g.length==1?'0'+g:g;b=b.length==1?'0'+b:b;css="#"+r+g+b;}}
return css;},pre_filter_linebreaks:function(html,markup){if(this.browser.webkit){html=html.replace(/<br class="khtml-block-placeholder">/gi,'<YUI_BR>');html=html.replace(/<br class="webkit-block-placeholder">/gi,'<YUI_BR>');}
html=html.replace(/<br>/gi,'<YUI_BR>');html=html.replace(/<br (.*?)>/gi,'<YUI_BR>');html=html.replace(/<br\/>/gi,'<YUI_BR>');html=html.replace(/<br \/>/gi,'<YUI_BR>');html=html.replace(/<div><YUI_BR><\/div>/gi,'<YUI_BR>');html=html.replace(/<p>(&nbsp;|&#160;)<\/p>/g,'<YUI_BR>');html=html.replace(/<p><br>&nbsp;<\/p>/gi,'<YUI_BR>');html=html.replace(/<p>&nbsp;<\/p>/gi,'<YUI_BR>');html=html.replace(/(<YUI_BR>)*$/,'');html=html.replace(/<YUI_BR><\/p>/g,'</p>');if(this.browser.ie){html=html.replace(/&nbsp;&nbsp;&nbsp;&nbsp;/g,'\t');}
return html;},post_filter_linebreaks:function(html,markup){if(markup=='xhtml'){html=html.replace(/<YUI_BR>/g,'<br />');}else{html=html.replace(/<YUI_BR>/g,'<br>');}
return html;},clearEditorDoc:function(){this._getDoc().body.innerHTML='&nbsp;';},openWindow:function(win){},moveWindow:function(){},_closeWindow:function(){},closeWindow:function(){this.toolbar.resetAllButtons();this._focusWindow();},destroy:function(){if(this.resize){this.resize.destroy();}
if(this.dd){this.dd.unreg();}
if(this.get('panel')){this.get('panel').destroy();}
this.saveHTML();this.toolbar.destroy();this.setStyle('visibility','visible');this.setStyle('position','static');this.setStyle('top','');this.setStyle('left','');var textArea=this.get('element');this.get('element_cont').get('parentNode').replaceChild(textArea,this.get('element_cont').get('element'));this.get('element_cont').get('element').innerHTML='';this.set('handleSubmit',false);return true;},toString:function(){var str='SimpleEditor';if(this.get&&this.get('element_cont')){str='SimpleEditor (#'+this.get('element_cont').get('id')+')'+((this.get('disabled')?' Disabled':''));}
return str;}});YAHOO.widget.EditorInfo={_instances:{},blankImage:'',window:{},panel:null,getEditorById:function(id){if(!YAHOO.lang.isString(id)){id=id.id;}
if(this._instances[id]){return this._instances[id];}
return false;},toString:function(){var len=0;for(var i in this._instances){if(Lang.hasOwnProperty(this._instances,i)){len++;}}
return'Editor Info ('+len+' registered intance'+((len>1)?'s':'')+')';}};})();(function(){var Dom=YAHOO.util.Dom,Event=YAHOO.util.Event,Lang=YAHOO.lang,Toolbar=YAHOO.widget.Toolbar;YAHOO.widget.Editor=function(el,attrs){YAHOO.widget.Editor.superclass.constructor.call(this,el,attrs);};YAHOO.extend(YAHOO.widget.Editor,YAHOO.widget.SimpleEditor,{_undoCache:null,_undoLevel:null,_hasUndoLevel:function(){return(this._undoCache.length&&this._undoLevel);},_undoNodeChange:function(){var undo_button=this.toolbar.getButtonByValue('undo'),redo_button=this.toolbar.getButtonByValue('redo');if(undo_button&&redo_button){if(this._hasUndoLevel()){this.toolbar.enableButton(undo_button);}
if(this._undoLevel<this._undoCache.length){this.toolbar.enableButton(redo_button);}}},_checkUndo:function(){var len=this._undoCache.length,tmp=[];if(len>=this.get('maxUndo')){for(var i=(len-this.get('maxUndo'));i<len;i++){tmp.push(this._undoCache[i]);}
this._undoCache=tmp;}},_putUndo:function(str){this._undoCache.push(str);},_getUndo:function(index){return this._undoCache[index];},_storeUndo:function(){if(this._lastCommand==='undo'||this._lastCommand==='redo'){return false;}
if(!this._undoCache){this._undoCache=[];}
this._checkUndo();var str=this.getEditorHTML();var last=this._undoCache[this._undoCache.length-1];if(last){if(str!==last){this._putUndo(str);}}else{this._putUndo(str);}
this._undoLevel=this._undoCache.length;this._undoNodeChange();},STR_BEFORE_EDITOR:'This text field can contain stylized text and graphics. To cycle through all formatting options, use the keyboard shortcut Control + Shift + T to place focus on the toolbar and navigate between option heading names. <h4>Common formatting keyboard shortcuts:</h4><ul><li>Control Shift B sets text to bold</li> <li>Control Shift I sets text to italic</li> <li>Control Shift U underlines text</li> <li>Control Shift [ aligns text left</li> <li>Control Shift | centers text</li> <li>Control Shift ] aligns text right</li> <li>Control Shift L adds an HTML link</li> <li>To exit this text editor use the keyboard shortcut Control + Shift + ESC.</li></ul>',STR_CLOSE_WINDOW:'Close Window',STR_CLOSE_WINDOW_NOTE:'To close this window use the Control + Shift + W key',STR_IMAGE_PROP_TITLE:PoiMsg.js_msg.richEditor.imageOptions(),STR_IMAGE_URL:PoiMsg.js_msg.richEditor.imageURL(),STR_IMAGE_TITLE:PoiMsg.js_msg.descriptionRichEditor.description(),STR_IMAGE_SIZE:PoiMsg.js_msg.richEditor.size(),STR_IMAGE_ORIG_SIZE:'Original Size',STR_IMAGE_COPY:'<span class="tip"><span class="icon icon-info"></span><strong>Note:</strong>To move this image just highlight it, cut, and paste where ever you\'d like.</span>',STR_IMAGE_PADDING:PoiMsg.js_msg.richEditor.padding(),STR_IMAGE_BORDER:PoiMsg.js_msg.richEditor.border(),STR_IMAGE_BORDER_SIZE:'Border Size',STR_IMAGE_BORDER_TYPE:'Border Type',STR_IMAGE_TEXTFLOW:PoiMsg.js_msg.richEditor.textFlow(),STR_LOCAL_FILE_WARNING:'<span class="tip"><span class="icon icon-warn"></span><strong>Note:</strong>This image/link points to a file on your computer and will not be accessible to others on the internet.</span>',STR_LINK_PROP_TITLE:PoiMsg.js_msg.richEditor.linkOptions(),STR_LINK_PROP_REMOVE:PoiMsg.js_msg.richEditor.removeLinkFromText(),STR_LINK_NEW_WINDOW:PoiMsg.js_msg.richEditor.openNewWindow(),STR_LINK_TITLE:PoiMsg.js_msg.descriptionRichEditor.description(),CLASS_LOCAL_FILE:'warning-localfile',CLASS_HIDDEN:'yui-hidden',init:function(p_oElement,p_oAttributes){this._windows={};this._defaultToolbar={collapse:true,titlebar:'Text Editing Tools',draggable:false,buttonType:'advanced',buttons:[{group:'fontstyle',label:'Font Name and Size',buttons:[{type:'select',label:'Arial',value:'fontname',disabled:true,menu:[{text:'Arial',checked:true},{text:'Arial Black'},{text:'Comic Sans MS'},{text:'Courier New'},{text:'Lucida Console'},{text:'Tahoma'},{text:'Times New Roman'},{text:'Trebuchet MS'},{text:'Verdana'}]},{type:'spin',label:'13',value:'fontsize',range:[9,75],disabled:true}]},{type:'separator'},{group:'textstyle',label:'Font Style',buttons:[{type:'push',label:'Bold CTRL + SHIFT + B',value:'bold'},{type:'push',label:'Italic CTRL + SHIFT + I',value:'italic'},{type:'push',label:'Underline CTRL + SHIFT + U',value:'underline'},{type:'separator'},{type:'push',label:'Subscript',value:'subscript',disabled:true},{type:'push',label:'Superscript',value:'superscript',disabled:true}]},{type:'separator'},{group:'textstyle2',label:'&nbsp;',buttons:[{type:'color',label:'Font Color',value:'forecolor',disabled:true},{type:'color',label:'Background Color',value:'backcolor',disabled:true},{type:'separator'},{type:'push',label:'Remove Formatting',value:'removeformat',disabled:true},{type:'push',label:'Show/Hide Hidden Elements',value:'hiddenelements'}]},{type:'separator'},{group:'undoredo',label:'Undo/Redo',buttons:[{type:'push',label:'Undo',value:'undo',disabled:true},{type:'push',label:'Redo',value:'redo',disabled:true}]},{type:'separator'},{group:'alignment',label:'Alignment',buttons:[{type:'push',label:'Align Left CTRL + SHIFT + [',value:'justifyleft'},{type:'push',label:'Align Center CTRL + SHIFT + |',value:'justifycenter'},{type:'push',label:'Align Right CTRL + SHIFT + ]',value:'justifyright'},{type:'push',label:'Justify',value:'justifyfull'}]},{type:'separator'},{group:'parastyle',label:'Paragraph Style',buttons:[{type:'select',label:'Normal',value:'heading',disabled:true,menu:[{text:'Normal',value:'none',checked:true},{text:'Header 1',value:'h1'},{text:'Header 2',value:'h2'},{text:'Header 3',value:'h3'},{text:'Header 4',value:'h4'},{text:'Header 5',value:'h5'},{text:'Header 6',value:'h6'}]}]},{type:'separator'},{group:'indentlist2',label:'Indenting and Lists',buttons:[{type:'push',label:'Indent',value:'indent',disabled:true},{type:'push',label:'Outdent',value:'outdent',disabled:true},{type:'push',label:'Create an Unordered List',value:'insertunorderedlist'},{type:'push',label:'Create an Ordered List',value:'insertorderedlist'}]},{type:'separator'},{group:'insertitem',label:'Insert Item',buttons:[{type:'push',label:'HTML Link CTRL + SHIFT + L',value:'createlink',disabled:true},{type:'push',label:'Insert Image',value:'insertimage'}]}]};this._defaultImageToolbarConfig={buttonType:this._defaultToolbar.buttonType,buttons:[{group:'textflow',label:this.STR_IMAGE_TEXTFLOW+':',buttons:[{type:'push',label:'Left',value:'left'},{type:'push',label:'Inline',value:'inline'},{type:'push',label:'Block',value:'block'},{type:'push',label:'Right',value:'right'}]},{type:'separator'},{group:'padding',label:this.STR_IMAGE_PADDING+':',buttons:[{type:'spin',label:'0',value:'padding',range:[0,50]}]},{type:'separator'},{group:'border',label:this.STR_IMAGE_BORDER+':',buttons:[{type:'select',label:this.STR_IMAGE_BORDER_SIZE,value:'bordersize',menu:[{text:'none',value:'0',checked:true},{text:'1px',value:'1'},{text:'2px',value:'2'},{text:'3px',value:'3'},{text:'4px',value:'4'},{text:'5px',value:'5'}]},{type:'select',label:this.STR_IMAGE_BORDER_TYPE,value:'bordertype',disabled:true,menu:[{text:'Solid',value:'solid',checked:true},{text:'Dashed',value:'dashed'},{text:'Dotted',value:'dotted'}]},{type:'color',label:'Border Color',value:'bordercolor',disabled:true}]}]};YAHOO.widget.Editor.superclass.init.call(this,p_oElement,p_oAttributes);},_render:function(){YAHOO.widget.Editor.superclass._render.apply(this,arguments);var self=this;window.setTimeout(function(){self._renderPanel.call(self);},800);},initAttributes:function(attr){YAHOO.widget.Editor.superclass.initAttributes.call(this,attr);this.setAttributeConfig('localFileWarning',{value:attr.locaFileWarning||true});this.setAttributeConfig('hiddencss',{value:attr.hiddencss||'.yui-hidden font, .yui-hidden strong, .yui-hidden b, .yui-hidden em, .yui-hidden i, .yui-hidden u, .yui-hidden div,.yui-hidden p,.yui-hidden span,.yui-hidden img, .yui-hidden ul, .yui-hidden ol, .yui-hidden li, .yui-hidden table { border: 1px dotted #ccc; } .yui-hidden .yui-non { border: none; } .yui-hidden img { padding: 2px; }',writeOnce:true});},_windows:null,_defaultImageToolbar:null,_defaultImageToolbarConfig:null,_fixNodes:function(){YAHOO.widget.Editor.superclass._fixNodes.call(this);var url='';var imgs=this._getDoc().getElementsByTagName('img');for(var im=0;im<imgs.length;im++){if(imgs[im].getAttribute('href',2)){url=imgs[im].getAttribute('src',2);if(this._isLocalFile(url)){Dom.addClass(imgs[im],this.CLASS_LOCAL_FILE);}else{Dom.removeClass(imgs[im],this.CLASS_LOCAL_FILE);}}}
var fakeAs=this._getDoc().body.getElementsByTagName('a');for(var a=0;a<fakeAs.length;a++){if(fakeAs[a].getAttribute('href',2)){url=fakeAs[a].getAttribute('href',2);if(this._isLocalFile(url)){Dom.addClass(fakeAs[a],this.CLASS_LOCAL_FILE);}else{Dom.removeClass(fakeAs[a],this.CLASS_LOCAL_FILE);}}}},_disabled:['createlink','forecolor','backcolor','fontname','fontsize','superscript','subscript','removeformat','heading','indent'],_alwaysDisabled:{'outdent':true},_alwaysEnabled:{hiddenelements:true},_handleKeyDown:function(ev){YAHOO.widget.Editor.superclass._handleKeyDown.call(this,ev);var doExec=false,action=null,exec=false;switch(ev.keyCode){case this._keyMap.JUSTIFY_LEFT.key:if(this._checkKey(this._keyMap.JUSTIFY_LEFT,ev)){action='justifyleft';doExec=true;}
break;case this._keyMap.JUSTIFY_CENTER.key:if(this._checkKey(this._keyMap.JUSTIFY_CENTER,ev)){action='justifycenter';doExec=true;}
break;case 221:case this._keyMap.JUSTIFY_RIGHT.key:if(this._checkKey(this._keyMap.JUSTIFY_RIGHT,ev)){action='justifyright';doExec=true;}
break;}
if(doExec&&action){this.execCommand(action,null);Event.stopEvent(ev);this.nodeChange();}},_renderCreateLinkWindow:function(){var str='<label for="'+this.get('id')+'_createlink_url"><strong>'+this.STR_LINK_URL+':</strong> <input type="text" name="'+this.get('id')+'_createlink_url" id="'+this.get('id')+'_createlink_url" value=""></label>';str+='<label for="'+this.get('id')+'_createlink_target"><strong>&nbsp;</strong><input type="checkbox" name="'+this.get('id')+'_createlink_target" id="'+this.get('id')+'_createlink_target" value="_blank" class="createlink_target"> '+this.STR_LINK_NEW_WINDOW+'</label>';str+='<label for="'+this.get('id')+'_createlink_title"><strong>'+this.STR_LINK_TITLE+':</strong> <input type="text" name="'+this.get('id')+'_createlink_title" id="'+this.get('id')+'_createlink_title" value=""></label>';var body=document.createElement('div');body.innerHTML=str;var unlinkCont=document.createElement('div');unlinkCont.className='removeLink';var unlink=document.createElement('a');unlink.href='#';unlink.innerHTML=this.STR_LINK_PROP_REMOVE;unlink.title=this.STR_LINK_PROP_REMOVE;Event.on(unlink,'click',function(ev){Event.stopEvent(ev);this.execCommand('unlink');this.closeWindow();},this,true);unlinkCont.appendChild(unlink);body.appendChild(unlinkCont);this._windows.createlink={};this._windows.createlink.body=body;body.style.display='none';this.get('panel').editor_form.appendChild(body);this.fireEvent('windowCreateLinkRender',{type:'windowCreateLinkRender',panel:this.get('panel'),body:body});return body;},_handleCreateLinkClick:function(){var el=this._getSelectedElement();if(this._isElement(el,'img')){this.STOP_EXEC_COMMAND=true;this.currentElement[0]=el;this.toolbar.fireEvent('insertimageClick',{type:'insertimageClick',target:this.toolbar});this.fireEvent('afterExecCommand',{type:'afterExecCommand',target:this});return false;}
if(this.get('limitCommands')){if(!this.toolbar.getButtonByValue('createlink')){return false;}}
this.on('afterExecCommand',function(){var win=new YAHOO.widget.EditorWindow('createlink',{width:'350px'});var el=this.currentElement[0],url='',title='',target='',localFile=false;if(el){win.el=el;if(el.getAttribute('href',2)!==null){url=el.getAttribute('href',2);if(this._isLocalFile(url)){win.setFooter(this.STR_LOCAL_FILE_WARNING);localFile=true;}else{win.setFooter(' ');}}
if(el.getAttribute('title')!==null){title=el.getAttribute('title');}
if(el.getAttribute('target')!==null){target=el.getAttribute('target');}}
var body=null;if(this._windows.createlink&&this._windows.createlink.body){body=this._windows.createlink.body;}else{body=this._renderCreateLinkWindow();}
win.setHeader(this.STR_LINK_PROP_TITLE);win.setBody(body);Event.purgeElement(this.get('id')+'_createlink_url');Dom.get(this.get('id')+'_createlink_url').value=url;Dom.get(this.get('id')+'_createlink_title').value=title;Dom.get(this.get('id')+'_createlink_target').checked=true;Event.onAvailable(this.get('id')+'_createlink_url',function(){var id=this.get('id');window.setTimeout(function(){try{YAHOO.util.Dom.get(id+'_createlink_url').focus();}catch(e){}},50);if(this._isLocalFile(url)){Dom.addClass(this.get('id')+'_createlink_url','warning');this.get('panel').setFooter(this.STR_LOCAL_FILE_WARNING);}else{Dom.removeClass(this.get('id')+'_createlink_url','warning');this.get('panel').setFooter(' ');}
Event.on(this.get('id')+'_createlink_url','blur',function(){var url=Dom.get(this.get('id')+'_createlink_url');if(this._isLocalFile(url.value)){Dom.addClass(url,'warning');this.get('panel').setFooter(this.STR_LOCAL_FILE_WARNING);}else{Dom.removeClass(url,'warning');this.get('panel').setFooter(' ');}},this,true);},this,true);this.openWindow(win);});},_handleCreateLinkWindowClose:function(){var url=Dom.get(this.get('id')+'_createlink_url'),target=Dom.get(this.get('id')+'_createlink_target'),title=Dom.get(this.get('id')+'_createlink_title'),el=arguments[0].win.el,a=el;if(url&&url.value){var urlValue=url.value;if((urlValue.indexOf(':/'+'/')==-1)&&(urlValue.substring(0,1)!='/')&&(urlValue.substring(0,6).toLowerCase()!='mailto')){if((urlValue.indexOf('@')!=-1)&&(urlValue.substring(0,6).toLowerCase()!='mailto')){urlValue='mailto:'+urlValue;}else{if(urlValue.substring(0,1)!='#'){urlValue='http:/'+'/'+urlValue;}}}
el.setAttribute('href',urlValue);if(target.checked){el.setAttribute('target',target.value);}else{el.setAttribute('target','');}
el.setAttribute('title',((title.value)?title.value:''));}else{var _span=this._getDoc().createElement('span');_span.innerHTML=el.innerHTML;Dom.addClass(_span,'yui-non');el.parentNode.replaceChild(_span,el);}
Dom.removeClass(url,'warning');Dom.get(this.get('id')+'_createlink_url').value='';Dom.get(this.get('id')+'_createlink_title').value='';Dom.get(this.get('id')+'_createlink_target').checked=true;this.nodeChange();this.currentElement=[];},_renderInsertImageWindow:function(){var el=this.currentElement[0];var str='<label for="'+this.get('id')+'_insertimage_url"><strong>'+this.STR_IMAGE_URL+':</strong> <input type="text" id="'+this.get('id')+'_insertimage_url" value="" size="40"></label>';var body=document.createElement('div');body.innerHTML=str;var tbarCont=document.createElement('div');tbarCont.id=this.get('id')+'_img_toolbar';body.appendChild(tbarCont);var str2='<label for="'+this.get('id')+'_insertimage_title"><strong>'+this.STR_IMAGE_TITLE+':</strong> <input type="text" id="'+this.get('id')+'_insertimage_title" value="" size="40"></label>';str2+='<label for="'+this.get('id')+'_insertimage_link"><strong>'+this.STR_LINK_URL+':</strong> <input type="text" name="'+this.get('id')+'_insertimage_link" id="'+this.get('id')+'_insertimage_link" value=""></label>';str2+='<label for="'+this.get('id')+'_insertimage_target"><strong>&nbsp;</strong><input type="checkbox" name="'+this.get('id')+'_insertimage_target_" id="'+this.get('id')+'_insertimage_target" value="_blank" class="insertimage_target"> '+this.STR_LINK_NEW_WINDOW+'</label>';var div=document.createElement('div');div.innerHTML=str2;body.appendChild(div);var o={};Lang.augmentObject(o,this._defaultImageToolbarConfig);var tbar=new YAHOO.widget.Toolbar(tbarCont,o);tbar.editor_el=el;this._defaultImageToolbar=tbar;var cont=tbar.get('cont');var hw=document.createElement('div');hw.className='yui-toolbar-group yui-toolbar-group-height-width height-width';hw.innerHTML='<h3>'+this.STR_IMAGE_SIZE+':</h3>';hw.innerHTML+='<span tabIndex="-1"><input type="text" size="3" value="" id="'+this.get('id')+'_insertimage_width"> x <input type="text" size="3" value="" id="'+this.get('id')+'_insertimage_height"></span>';cont.insertBefore(hw,cont.firstChild);Event.onAvailable(this.get('id')+'_insertimage_width',function(){Event.on(this.get('id')+'_insertimage_width','blur',function(){var value=parseInt(Dom.get(this.get('id')+'_insertimage_width').value,10);if(value>5){this._defaultImageToolbar.editor_el.style.width=value+'px';}},this,true);},this,true);Event.onAvailable(this.get('id')+'_insertimage_height',function(){Event.on(this.get('id')+'_insertimage_height','blur',function(){var value=parseInt(Dom.get(this.get('id')+'_insertimage_height').value,10);if(value>5){this._defaultImageToolbar.editor_el.style.height=value+'px';}},this,true);},this,true);tbar.on('colorPickerClicked',function(o){var size='1',type='solid',color='black',el=this._defaultImageToolbar.editor_el;if(el.style.borderLeftWidth){size=parseInt(el.style.borderLeftWidth,10);}
if(el.style.borderLeftStyle){type=el.style.borderLeftStyle;}
if(el.style.borderLeftColor){color=el.style.borderLeftColor;}
var borderString=size+'px '+type+' #'+o.color;el.style.border=borderString;},this,true);tbar.on('buttonClick',function(o){var value=o.button.value,el=this._defaultImageToolbar.editor_el,borderString='';if(o.button.menucmd){value=o.button.menucmd;}
var size='1',type='solid',color='black';if(el.style.borderLeftWidth){size=parseInt(el.style.borderLeftWidth,10);}
if(el.style.borderLeftStyle){type=el.style.borderLeftStyle;}
if(el.style.borderLeftColor){color=el.style.borderLeftColor;}
switch(value){case'bordersize':if(this.browser.webkit&&this._lastImage){Dom.removeClass(this._lastImage,'selected');this._lastImage=null;}
borderString=parseInt(o.button.value,10)+'px '+type+' '+color;el.style.border=borderString;if(parseInt(o.button.value,10)>0){tbar.enableButton('bordertype');tbar.enableButton('bordercolor');}else{tbar.disableButton('bordertype');tbar.disableButton('bordercolor');}
break;case'bordertype':if(this.browser.webkit&&this._lastImage){Dom.removeClass(this._lastImage,'selected');this._lastImage=null;}
borderString=size+'px '+o.button.value+' '+color;el.style.border=borderString;break;case'right':case'left':tbar.deselectAllButtons();el.style.display='';el.align=o.button.value;break;case'inline':tbar.deselectAllButtons();el.style.display='';el.align='';break;case'block':tbar.deselectAllButtons();el.style.display='block';el.align='center';break;case'padding':var _button=tbar.getButtonById(o.button.id);el.style.margin=_button.get('label')+'px';break;}
tbar.selectButton(o.button.value);if(value!=='padding'){this.moveWindow();}},this,true);if(this.get('localFileWarning')){Event.on(this.get('id')+'_insertimage_link','blur',function(){var url=Dom.get(this.get('id')+'_insertimage_link');if(this._isLocalFile(url.value)){Dom.addClass(url,'warning');this.get('panel').setFooter(this.STR_LOCAL_FILE_WARNING);}else{Dom.removeClass(url,'warning');this.get('panel').setFooter(' ');if((this.browser.webkit&&!this.browser.webkit3||this.browser.air)||this.browser.opera){this.get('panel').setFooter(this.STR_IMAGE_COPY);}}},this,true);}
Event.on(this.get('id')+'_insertimage_url','blur',function(){var url=Dom.get(this.get('id')+'_insertimage_url');if(url.value&&el){if(url.value==el.getAttribute('src',2)){return false;}}
if(this._isLocalFile(url.value)){Dom.addClass(url,'warning');this.get('panel').setFooter(this.STR_LOCAL_FILE_WARNING);}else if(this.currentElement[0]){Dom.removeClass(url,'warning');this.get('panel').setFooter(' ');if((this.browser.webkit&&!this.browser.webkit3||this.browser.air)||this.browser.opera){this.get('panel').setFooter(this.STR_IMAGE_COPY);}
if(url&&url.value&&(url.value!=this.STR_IMAGE_HERE)){this.currentElement[0].setAttribute('src',url.value);var self=this,img=new Image();img.onerror=function(){url.value=self.STR_IMAGE_HERE;img.setAttribute('src',self.get('blankimage'));self.currentElement[0].setAttribute('src',self.get('blankimage'));YAHOO.util.Dom.get(self.get('id')+'_insertimage_height').value=img.height;YAHOO.util.Dom.get(self.get('id')+'_insertimage_width').value=img.width;};var id=this.get('id');window.setTimeout(function(){YAHOO.util.Dom.get(id+'_insertimage_height').value=img.height;YAHOO.util.Dom.get(id+'_insertimage_width').value=img.width;if(self.currentElement&&self.currentElement[0]){if(!self.currentElement[0]._height){self.currentElement[0]._height=img.height;}
if(!self.currentElement[0]._width){self.currentElement[0]._width=img.width;}}},800);if(url.value!=this.STR_IMAGE_HERE){img.src=url.value;}}}},this,true);this._windows.insertimage={};this._windows.insertimage.body=body;body.style.display='none';this.get('panel').editor_form.appendChild(body);this.fireEvent('windowInsertImageRender',{type:'windowInsertImageRender',panel:this.get('panel'),body:body,toolbar:tbar});return body;},_handleInsertImageClick:function(){if(this.get('limitCommands')){if(!this.toolbar.getButtonByValue('insertimage')){return false;}}
this.on('afterExecCommand',function(){var el=this.currentElement[0],body=null,link='',target='',tbar=null,title='',src='',align='',height=75,width=75,padding=0,oheight=0,owidth=0,blankimage=false,win=new YAHOO.widget.EditorWindow('insertimage',{width:'415px'});if(!el){el=this._getSelectedElement();}
if(el){win.el=el;if(el.getAttribute('src')){src=el.getAttribute('src',2);if(src.indexOf(this.get('blankimage'))!=-1){src=this.STR_IMAGE_HERE;blankimage=true;}}
if(el.getAttribute('alt',2)){title=el.getAttribute('alt',2);}
if(el.getAttribute('title',2)){title=el.getAttribute('title',2);}
if(el.parentNode&&this._isElement(el.parentNode,'a')){link=el.parentNode.getAttribute('href',2);if(el.parentNode.getAttribute('target')!==null){target=el.parentNode.getAttribute('target');}}
height=parseInt(el.height,10);width=parseInt(el.width,10);if(el.style.height){height=parseInt(el.style.height,10);}
if(el.style.width){width=parseInt(el.style.width,10);}
if(el.style.margin){padding=parseInt(el.style.margin,10);}
if(!el._height){el._height=height;}
if(!el._width){el._width=width;}
oheight=el._height;owidth=el._width;}
if(this._windows.insertimage&&this._windows.insertimage.body){body=this._windows.insertimage.body;this._defaultImageToolbar.resetAllButtons();}else{body=this._renderInsertImageWindow();}
tbar=this._defaultImageToolbar;tbar.editor_el=el;var bsize='0';var btype='solid';if(el.style.borderLeftWidth){bsize=parseInt(el.style.borderLeftWidth,10);}
if(el.style.borderLeftStyle){btype=el.style.borderLeftStyle;}
var bs_button=tbar.getButtonByValue('bordersize');var bSizeStr=((parseInt(bsize,10)>0)?'':'none');bs_button.set('label','<span class="yui-toolbar-bordersize-'+bsize+'">'+bSizeStr+'</span>');this._updateMenuChecked('bordersize',bsize,tbar);var bt_button=tbar.getButtonByValue('bordertype');bt_button.set('label','<span class="yui-toolbar-bordertype-'+btype+'"></span>');this._updateMenuChecked('bordertype',btype,tbar);if(parseInt(bsize,10)>0){tbar.enableButton(bt_button);tbar.enableButton(bs_button);tbar.enableButton('bordercolor');}
el.align="right";if((el.align=='right')||(el.align=='left')){tbar.selectButton(el.align);}else if(el.style.display=='block'){tbar.selectButton('block');}else{tbar.selectButton('inline');}
if(parseInt(el.style.marginLeft,10)>0){tbar.getButtonByValue('padding').set('label',''+parseInt(el.style.marginLeft,10));}
if(el.style.borderSize){tbar.selectButton('bordersize');tbar.selectButton(parseInt(el.style.borderSize,10));}
tbar.getButtonByValue('padding').set('label',''+padding);win.setHeader(this.STR_IMAGE_PROP_TITLE);win.setBody(body);if((this.browser.webkit&&!this.browser.webkit3||this.browser.air)||this.browser.opera){win.setFooter(this.STR_IMAGE_COPY);}
this.openWindow(win);Dom.get(this.get('id')+'_insertimage_url').value=src;Dom.get(this.get('id')+'_insertimage_title').value=title;Dom.get(this.get('id')+'_insertimage_link').value=link;Dom.get(this.get('id')+'_insertimage_target').checked=((target)?true:false);Dom.get(this.get('id')+'_insertimage_width').value=width;Dom.get(this.get('id')+'_insertimage_height').value=height;var orgSize='';if((height!=oheight)||(width!=owidth)){var s=document.createElement('span');s.className='info';s.innerHTML=this.STR_IMAGE_ORIG_SIZE+': ('+owidth+' x '+oheight+')';if(Dom.get(this.get('id')+'_insertimage_height').nextSibling){var old=Dom.get(this.get('id')+'_insertimage_height').nextSibling;old.parentNode.removeChild(old);}
Dom.get(this.get('id')+'_insertimage_height').parentNode.appendChild(s);}
this.toolbar.selectButton('insertimage');var id=this.get('id');window.setTimeout(function(){try{YAHOO.util.Dom.get(id+'_insertimage_url').focus();if(blankimage){YAHOO.util.Dom.get(id+'_insertimage_url').select();}}catch(e){}},50);});},_handleInsertImageWindowClose:function(){var url=Dom.get(this.get('id')+'_insertimage_url'),title=Dom.get(this.get('id')+'_insertimage_title'),link=Dom.get(this.get('id')+'_insertimage_link'),target=Dom.get(this.get('id')+'_insertimage_target'),el=arguments[0].win.el;if(url&&url.value&&(url.value!=this.STR_IMAGE_HERE)){el.setAttribute('src',url.value);el.setAttribute('title',title.value);el.setAttribute('alt',title.value);var par=el.parentNode;if(link.value){var urlValue=link.value;if((urlValue.indexOf(':/'+'/')==-1)&&(urlValue.substring(0,1)!='/')&&(urlValue.substring(0,6).toLowerCase()!='mailto')){if((urlValue.indexOf('@')!=-1)&&(urlValue.substring(0,6).toLowerCase()!='mailto')){urlValue='mailto:'+urlValue;}else{urlValue='http:/'+'/'+urlValue;}}
if(par&&this._isElement(par,'a')){par.setAttribute('href',urlValue);if(target.checked){par.setAttribute('target',target.value);}else{par.setAttribute('target','');}}else{var _a=this._getDoc().createElement('a');_a.setAttribute('href',urlValue);if(target.checked){_a.setAttribute('target',target.value);}else{_a.setAttribute('target','');}
el.parentNode.replaceChild(_a,el);_a.appendChild(el);}}else{if(par&&this._isElement(par,'a')){par.parentNode.replaceChild(el,par);}}}else{el.parentNode.removeChild(el);}
Dom.get(this.get('id')+'_insertimage_url').value='';Dom.get(this.get('id')+'_insertimage_title').value='';Dom.get(this.get('id')+'_insertimage_link').value='';Dom.get(this.get('id')+'_insertimage_target').checked=false;Dom.get(this.get('id')+'_insertimage_width').value=0;Dom.get(this.get('id')+'_insertimage_height').value=0;this._defaultImageToolbar.resetAllButtons();this.currentElement=[];this.nodeChange();},EDITOR_PANEL_ID:'-panel',_renderPanel:function(){var panel=new YAHOO.widget.Overlay(this.get('id')+this.EDITOR_PANEL_ID,{width:'300px',iframe:true,visible:false,underlay:'none',draggable:false,close:false});this.set('panel',panel);this.get('panel').setBody('---');this.get('panel').setHeader(' ');this.get('panel').setFooter(' ');var body=document.createElement('div');body.className=this.CLASS_PREFIX+'-body-cont';for(var b in this.browser){if(this.browser[b]){Dom.addClass(body,b);break;}}
Dom.addClass(body,((YAHOO.widget.Button&&(this._defaultToolbar.buttonType=='advanced'))?'good-button':'no-button'));var _note=document.createElement('h3');_note.className='yui-editor-skipheader';_note.innerHTML=this.STR_CLOSE_WINDOW_NOTE;body.appendChild(_note);var form=document.createElement('form');form.setAttribute('method','GET');panel.editor_form=form;Event.on(form,'submit',function(ev){Event.stopEvent(ev);},this,true);body.appendChild(form);var _close=document.createElement('span');_close.innerHTML='X';_close.title=this.STR_CLOSE_WINDOW;_close.className='close';Event.on(_close,'click',this.closeWindow,this,true);var _knob=document.createElement('span');_knob.innerHTML='^';_knob.className='knob';panel.editor_knob=_knob;var _header=document.createElement('h3');panel.editor_header=_header;_header.innerHTML='<span></span>';panel.setHeader(' ');panel.appendToHeader(_header);_header.appendChild(_close);_header.appendChild(_knob);panel.setBody(' ');panel.setFooter(' ');panel.appendToBody(body);Event.on(panel.element,'click',function(ev){Event.stopPropagation(ev);});var fireShowEvent=function(){};panel.showEvent.subscribe(fireShowEvent,this,true);panel.renderEvent.subscribe(function(){this._renderInsertImageWindow();this._renderCreateLinkWindow();this.fireEvent('windowRender',{type:'windowRender',panel:panel});},this,true);if(this.DOMReady){this.get('panel').render(document.body);Dom.addClass(this.get('panel').element,'yui-editor-panel');}else{Event.onDOMReady(function(){this.get('panel').render(document.body);Dom.addClass(this.get('panel').element,'yui-editor-panel');},this,true);}
this.get('panel').showEvent.subscribe(function(){YAHOO.util.Dom.setStyle(this.element,'display','block');});return this.get('panel');},openWindow:function(win){var self=this;window.setTimeout(function(){self.toolbar.set('disabled',true);},10);Event.on(document,'keydown',this._closeWindow,this,true);if(this.currentWindow){this.closeWindow();}
var xy=Dom.getXY(this.currentElement[0]),elXY=Dom.getXY(this.get('iframe').get('element')),panel=this.get('panel'),newXY=[(xy[0]+elXY[0]-20),(xy[1]+elXY[1]+10)],wWidth=(parseInt(win.attrs.width,10)/2),align='center',body=null;this.fireEvent('beforeOpenWindow',{type:'beforeOpenWindow',win:win,panel:panel});var form=panel.editor_form;var wins=this._windows;for(var b in wins){if(Lang.hasOwnProperty(wins,b)){if(wins[b]&&wins[b].body){if(b==win.name){Dom.setStyle(wins[b].body,'display','block');}else{Dom.setStyle(wins[b].body,'display','none');}}}}
if(this._windows[win.name].body){Dom.setStyle(this._windows[win.name].body,'display','block');form.appendChild(this._windows[win.name].body);}else{if(Lang.isObject(win.body)){form.appendChild(win.body);}else{var _tmp=document.createElement('div');_tmp.innerHTML=win.body;form.appendChild(_tmp);}}
panel.editor_header.firstChild.innerHTML=win.header;if(win.footer!==null){panel.setFooter(win.footer);Dom.addClass(panel.footer,'open');}else{Dom.removeClass(panel.footer,'open');}
panel.cfg.setProperty('width',win.attrs.width);this.currentWindow=win;this.moveWindow(true);panel.show();this.fireEvent('afterOpenWindow',{type:'afterOpenWindow',win:win,panel:panel});},moveWindow:function(force){if(!this.currentWindow){return false;}
var win=this.currentWindow,xy=Dom.getXY(this.currentElement[0]),elXY=Dom.getXY(this.get('iframe').get('element')),panel=this.get('panel'),newXY=[(xy[0]+elXY[0]),(xy[1]+elXY[1])],wWidth=(parseInt(win.attrs.width,10)/2),align='center',orgXY=panel.cfg.getProperty('xy')||[0,0],_knob=panel.editor_knob,xDiff=0,yDiff=0,anim=false;newXY[0]=((newXY[0]-wWidth)+20);newXY[0]=newXY[0]-Dom.getDocumentScrollLeft(this._getDoc());newXY[1]=newXY[1]-Dom.getDocumentScrollTop(this._getDoc());if(this._isElement(this.currentElement[0],'img')){if(this.currentElement[0].src.indexOf(this.get('blankimage'))!=-1){newXY[0]=(newXY[0]+(75/2));newXY[1]=(newXY[1]+75);}else{var w=parseInt(this.currentElement[0].width,10);var h=parseInt(this.currentElement[0].height,10);newXY[0]=(newXY[0]+(w/2));newXY[1]=(newXY[1]+h);}
newXY[1]=newXY[1]+15;}else{var fs=Dom.getStyle(this.currentElement[0],'fontSize');if(fs&&fs.indexOf&&fs.indexOf('px')!=-1){newXY[1]=newXY[1]+parseInt(Dom.getStyle(this.currentElement[0],'fontSize'),10)+5;}else{newXY[1]=newXY[1]+20;}}
if(newXY[0]<elXY[0]){newXY[0]=elXY[0]+5;align='left';}
if((newXY[0]+(wWidth*2))>(elXY[0]+parseInt(this.get('iframe').get('element').clientWidth,10))){newXY[0]=((elXY[0]+parseInt(this.get('iframe').get('element').clientWidth,10))-(wWidth*2)-5);align='right';}
try{xDiff=(newXY[0]-orgXY[0]);yDiff=(newXY[1]-orgXY[1]);}catch(e){}
if(this.get('autoHeight')===false){var iTop=elXY[1]+parseInt(this.get('height'),10);var iLeft=elXY[0]+parseInt(this.get('width'),10);if(newXY[1]>iTop){newXY[1]=iTop;}
if(newXY[0]>iLeft){newXY[0]=(iLeft/2);}}
xDiff=((xDiff<0)?(xDiff*-1):xDiff);yDiff=((yDiff<0)?(yDiff*-1):yDiff);if(((xDiff>10)||(yDiff>10))||force){var _knobLeft=0,elW=0;if(this.currentElement[0].width){elW=(parseInt(this.currentElement[0].width,10)/2);}
var leftOffset=xy[0]+elXY[0]+elW;_knobLeft=leftOffset-newXY[0];if(_knobLeft>(parseInt(win.attrs.width,10)-1)){_knobLeft=((parseInt(win.attrs.width,10)-30)-1);}else if(_knobLeft<40){_knobLeft=1;}
if(isNaN(_knobLeft)){_knobLeft=1;}
if(force){if(_knob){_knob.style.left=_knobLeft+'px';}
panel.cfg.setProperty('xy',newXY);}else{if(this.get('animate')){anim=new YAHOO.util.Anim(panel.element,{},0.5,YAHOO.util.Easing.easeOut);anim.attributes={top:{to:newXY[1]},left:{to:newXY[0]}};anim.onComplete.subscribe(function(){panel.cfg.setProperty('xy',newXY);});var iframeAnim=new YAHOO.util.Anim(panel.iframe,anim.attributes,0.5,YAHOO.util.Easing.easeOut);var _knobAnim=new YAHOO.util.Anim(_knob,{left:{to:_knobLeft}},0.6,YAHOO.util.Easing.easeOut);anim.animate();iframeAnim.animate();_knobAnim.animate();}else{_knob.style.left=_knobLeft+'px';panel.cfg.setProperty('xy',newXY);}}}},_closeWindow:function(ev){if(this._checkKey(this._keyMap.CLOSE_WINDOW,ev)){if(this.currentWindow){this.closeWindow();}}},closeWindow:function(keepOpen){this.fireEvent('window'+this.currentWindow.name+'Close',{type:'window'+this.currentWindow.name+'Close',win:this.currentWindow,el:this.currentElement[0]});this.fireEvent('closeWindow',{type:'closeWindow',win:this.currentWindow});this.currentWindow=null;this.get('panel').hide();this.get('panel').cfg.setProperty('xy',[-900,-900]);this.get('panel').syncIframe();this.unsubscribeAll('afterExecCommand');this.toolbar.set('disabled',false);this.toolbar.resetAllButtons();this._focusWindow();Event.removeListener(document,'keydown',this._closeWindow);},cmd_undo:function(value){if(this._hasUndoLevel()){if(!this._undoLevel){this._undoLevel=this._undoCache.length;}
this._undoLevel=(this._undoLevel-1);if(this._undoCache[this._undoLevel]){var html=this._getUndo(this._undoLevel);this.setEditorHTML(html);}else{this._undoLevel=null;this.toolbar.disableButton('undo');}}
return[false];},cmd_redo:function(value){this._undoLevel=this._undoLevel+1;if(this._undoLevel>=this._undoCache.length){this._undoLevel=this._undoCache.length;}
if(this._undoCache[this._undoLevel]){var html=this._getUndo(this._undoLevel);this.setEditorHTML(html);}else{this.toolbar.disableButton('redo');}
return[false];},cmd_heading:function(value){var exec=true,el=null,action='heading',_sel=this._getSelection(),_selEl=this._getSelectedElement();if(_selEl){_sel=_selEl;}
if(this.browser.ie){action='formatblock';}
if(value=='none'){if((_sel&&_sel.tagName&&(_sel.tagName.toLowerCase().substring(0,1)=='h'))||(_sel&&_sel.parentNode&&_sel.parentNode.tagName&&(_sel.parentNode.tagName.toLowerCase().substring(0,1)=='h'))){if(_sel.parentNode.tagName.toLowerCase().substring(0,1)=='h'){_sel=_sel.parentNode;}
if(this._isElement(_sel,'html')){return[false];}
el=this._swapEl(_selEl,'span',function(el){el.className='yui-non';});this._selectNode(el);this.currentElement[0]=el;}
exec=false;}else{if(this._isElement(_selEl,'h1')||this._isElement(_selEl,'h2')||this._isElement(_selEl,'h3')||this._isElement(_selEl,'h4')||this._isElement(_selEl,'h5')||this._isElement(_selEl,'h6')){el=this._swapEl(_selEl,value);this._selectNode(el);this.currentElement[0]=el;}else{this._createCurrentElement(value);this._selectNode(this.currentElement[0]);}
exec=false;}
return[exec,action];},cmd_hiddenelements:function(value){if(this._showingHiddenElements){this._lastButton=null;this._showingHiddenElements=false;this.toolbar.deselectButton('hiddenelements');Dom.removeClass(this._getDoc().body,this.CLASS_HIDDEN);}else{this._showingHiddenElements=true;Dom.addClass(this._getDoc().body,this.CLASS_HIDDEN);this.toolbar.selectButton('hiddenelements');}
return[false];},cmd_removeformat:function(value){var exec=true;if(this.browser.webkit&&!this._getDoc().queryCommandEnabled('removeformat')){var _txt=this._getSelection()+'';this._createCurrentElement('span');this.currentElement[0].className='yui-non';this.currentElement[0].innerHTML=_txt;for(var i=1;i<this.currentElement.length;i++){this.currentElement[i].parentNode.removeChild(this.currentElement[i]);}
exec=false;}
return[exec];},cmd_script:function(action,value){var exec=true,tag=action.toLowerCase().substring(0,3),_span=null,_selEl=this._getSelectedElement();if(this.browser.webkit){if(this._isElement(_selEl,tag)){_span=this._swapEl(this.currentElement[0],'span',function(el){el.className='yui-non';});this._selectNode(_span);}else{this._createCurrentElement(tag);var _sub=this._swapEl(this.currentElement[0],tag);this._selectNode(_sub);this.currentElement[0]=_sub;}
exec=false;}
return exec;},cmd_superscript:function(value){return[this.cmd_script('superscript',value)];},cmd_subscript:function(value){return[this.cmd_script('subscript',value)];},cmd_indent:function(value){var exec=true,selEl=this._getSelectedElement(),_bq=null;if(this.browser.ie){if(this._isElement(selEl,'blockquote')){_bq=this._getDoc().createElement('blockquote');_bq.innerHTML=selEl.innerHTML;selEl.innerHTML='';selEl.appendChild(_bq);this._selectNode(_bq);}else{_bq=this._getDoc().createElement('blockquote');var html=this._getRange().htmlText;_bq.innerHTML=html;this._createCurrentElement('blockquote');this.currentElement[0].parentNode.replaceChild(_bq,this.currentElement[0]);this.currentElement[0]=_bq;this._selectNode(this.currentElement[0]);}
exec=false;}else{value='blockquote';}
return[exec,'formatblock',value];},cmd_outdent:function(value){var exec=true,selEl=this._getSelectedElement(),_bq=null,_span=null;if(this.browser.webkit||this.browser.ie){selEl=this._getSelectedElement();if(this._isElement(selEl,'blockquote')){var par=selEl.parentNode;if(this._isElement(selEl.parentNode,'blockquote')){par.innerHTML=selEl.innerHTML;this._selectNode(par);}else{_span=this._getDoc().createElement('span');_span.innerHTML=selEl.innerHTML;YAHOO.util.Dom.addClass(_span,'yui-non');par.replaceChild(_span,selEl);this._selectNode(_span);}}else{}
exec=false;}else{value=false;}
return[exec,'outdent',value];},cmd_justify:function(dir){if(this.browser.ie){if(this._hasSelection()){this._createCurrentElement('span');this._swapEl(this.currentElement[0],'div',function(el){el.style.textAlign=dir;});return[false];}}
return[true,'justify'+dir,''];},cmd_justifycenter:function(){return[this.cmd_justify('center')];},cmd_justifyleft:function(){return[this.cmd_justify('left')];},cmd_justifyright:function(){return[this.cmd_justify('right')];},toString:function(){var str='Editor';if(this.get&&this.get('element_cont')){str='Editor (#'+this.get('element_cont').get('id')+')'+((this.get('disabled')?' Disabled':''));}
return str;}});YAHOO.widget.EditorWindow=function(name,attrs){this.name=name.replace(' ','_');this.attrs=attrs;};YAHOO.widget.EditorWindow.prototype={header:null,body:null,footer:null,setHeader:function(str){this.header=str;},setBody:function(str){this.body=str;},setFooter:function(str){this.footer=str;},toString:function(){return'Editor Window ('+this.name+')';}};})();YAHOO.register("editor",YAHOO.widget.Editor,{version:"2.6.0",build:"1321"});YAHOO.widget.Slider=function(sElementId,sGroup,oThumb,sType){YAHOO.widget.Slider.ANIM_AVAIL=(!YAHOO.lang.isUndefined(YAHOO.util.Anim));if(sElementId){this.init(sElementId,sGroup,true);this.initSlider(sType);this.initThumb(oThumb);}};YAHOO.widget.Slider.getHorizSlider=function(sBGElId,sHandleElId,iLeft,iRight,iTickSize){return new YAHOO.widget.Slider(sBGElId,sBGElId,new YAHOO.widget.SliderThumb(sHandleElId,sBGElId,iLeft,iRight,0,0,iTickSize),"horiz");};YAHOO.widget.Slider.getVertSlider=function(sBGElId,sHandleElId,iUp,iDown,iTickSize){return new YAHOO.widget.Slider(sBGElId,sBGElId,new YAHOO.widget.SliderThumb(sHandleElId,sBGElId,0,0,iUp,iDown,iTickSize),"vert");};YAHOO.widget.Slider.getSliderRegion=function(sBGElId,sHandleElId,iLeft,iRight,iUp,iDown,iTickSize){return new YAHOO.widget.Slider(sBGElId,sBGElId,new YAHOO.widget.SliderThumb(sHandleElId,sBGElId,iLeft,iRight,iUp,iDown,iTickSize),"region");};YAHOO.widget.Slider.ANIM_AVAIL=false;YAHOO.extend(YAHOO.widget.Slider,YAHOO.util.DragDrop,{dragOnly:true,initSlider:function(sType){this.type=sType;this.createEvent("change",this);this.createEvent("slideStart",this);this.createEvent("slideEnd",this);this.isTarget=false;this.animate=YAHOO.widget.Slider.ANIM_AVAIL;this.backgroundEnabled=true;this.tickPause=40;this.enableKeys=true;this.keyIncrement=20;this.moveComplete=true;this.animationDuration=0.2;this.SOURCE_UI_EVENT=1;this.SOURCE_SET_VALUE=2;this.valueChangeSource=0;this._silent=false;this.lastOffset=[0,0];},initThumb:function(t){var self=this;this.thumb=t;t.cacheBetweenDrags=true;if(t._isHoriz&&t.xTicks&&t.xTicks.length){this.tickPause=Math.round(360/t.xTicks.length);}else if(t.yTicks&&t.yTicks.length){this.tickPause=Math.round(360/t.yTicks.length);}
t.onAvailable=function(){return self.setStartSliderState();};t.onMouseDown=function(){return self.focus();};t.startDrag=function(){self._slideStart();};t.onDrag=function(){self.fireEvents(true);};t.onMouseUp=function(){self.thumbMouseUp();};},onAvailable:function(){var Event=YAHOO.util.Event;Event.on(this.id,"keydown",this.handleKeyDown,this,true);Event.on(this.id,"keypress",this.handleKeyPress,this,true);},handleKeyPress:function(e){if(this.enableKeys){var Event=YAHOO.util.Event;var kc=Event.getCharCode(e);switch(kc){case 0x25:case 0x26:case 0x27:case 0x28:case 0x24:case 0x23:Event.preventDefault(e);break;default:}}},handleKeyDown:function(e){if(this.enableKeys){var Event=YAHOO.util.Event;var kc=Event.getCharCode(e),t=this.thumb;var h=this.getXValue(),v=this.getYValue();var horiz=false;var changeValue=true;switch(kc){case 0x25:h-=this.keyIncrement;break;case 0x26:v-=this.keyIncrement;break;case 0x27:h+=this.keyIncrement;break;case 0x28:v+=this.keyIncrement;break;case 0x24:h=t.leftConstraint;v=t.topConstraint;break;case 0x23:h=t.rightConstraint;v=t.bottomConstraint;break;default:changeValue=false;}
if(changeValue){if(t._isRegion){this.setRegionValue(h,v,true);}else{var newVal=(t._isHoriz)?h:v;this.setValue(newVal,true);}
Event.stopEvent(e);}}},setStartSliderState:function(){this.setThumbCenterPoint();this.baselinePos=YAHOO.util.Dom.getXY(this.getEl());this.thumb.startOffset=this.thumb.getOffsetFromParent(this.baselinePos);if(this.thumb._isRegion){if(this.deferredSetRegionValue){this.setRegionValue.apply(this,this.deferredSetRegionValue);this.deferredSetRegionValue=null;}else{this.setRegionValue(0,0,true,true,true);}}else{if(this.deferredSetValue){this.setValue.apply(this,this.deferredSetValue);this.deferredSetValue=null;}else{this.setValue(0,true,true,true);}}},setThumbCenterPoint:function(){var el=this.thumb.getEl();if(el){this.thumbCenterPoint={x:parseInt(el.offsetWidth/2,10),y:parseInt(el.offsetHeight/2,10)};}},lock:function(){this.thumb.lock();this.locked=true;},unlock:function(){this.thumb.unlock();this.locked=false;},thumbMouseUp:function(){if(!this.isLocked()&&!this.moveComplete){this.endMove();}},onMouseUp:function(){if(this.backgroundEnabled&&!this.isLocked()&&!this.moveComplete){this.endMove();}},getThumb:function(){return this.thumb;},focus:function(){this.valueChangeSource=this.SOURCE_UI_EVENT;var el=this.getEl();if(el.focus){try{el.focus();}catch(e){}}
this.verifyOffset();if(this.isLocked()){return false;}else{this._slideStart();return true;}},onChange:function(firstOffset,secondOffset){},onSlideStart:function(){},onSlideEnd:function(){},getValue:function(){return this.thumb.getValue();},getXValue:function(){return this.thumb.getXValue();},getYValue:function(){return this.thumb.getYValue();},handleThumbChange:function(){},setValue:function(newOffset,skipAnim,force,silent){this._silent=silent;this.valueChangeSource=this.SOURCE_SET_VALUE;if(!this.thumb.available){this.deferredSetValue=arguments;return false;}
if(this.isLocked()&&!force){return false;}
if(isNaN(newOffset)){return false;}
var t=this.thumb;t.lastOffset=[newOffset,newOffset];var newX,newY;this.verifyOffset(true);if(t._isRegion){return false;}else if(t._isHoriz){this._slideStart();newX=t.initPageX+newOffset+this.thumbCenterPoint.x;this.moveThumb(newX,t.initPageY,skipAnim);}else{this._slideStart();newY=t.initPageY+newOffset+this.thumbCenterPoint.y;this.moveThumb(t.initPageX,newY,skipAnim);}
return true;},setRegionValue:function(newOffset,newOffset2,skipAnim,force,silent){this._silent=silent;this.valueChangeSource=this.SOURCE_SET_VALUE;if(!this.thumb.available){this.deferredSetRegionValue=arguments;return false;}
if(this.isLocked()&&!force){return false;}
if(isNaN(newOffset)){return false;}
var t=this.thumb;t.lastOffset=[newOffset,newOffset2];this.verifyOffset(true);if(t._isRegion){this._slideStart();var newX=t.initPageX+newOffset+this.thumbCenterPoint.x;var newY=t.initPageY+newOffset2+this.thumbCenterPoint.y;this.moveThumb(newX,newY,skipAnim);return true;}
return false;},verifyOffset:function(checkPos){var xy=YAHOO.util.Dom.getXY(this.getEl()),t=this.thumb;if(xy){if(xy[0]!=this.baselinePos[0]||xy[1]!=this.baselinePos[1]){this.setInitPosition();this.baselinePos=xy;t.initPageX=this.initPageX+t.startOffset[0];t.initPageY=this.initPageY+t.startOffset[1];t.deltaSetXY=null;this.resetThumbConstraints();return false;}}
return true;},moveThumb:function(x,y,skipAnim,midMove){var t=this.thumb;var self=this;if(!t.available){return;}
t.setDelta(this.thumbCenterPoint.x,this.thumbCenterPoint.y);var _p=t.getTargetCoord(x,y);var p=[Math.round(_p.x),Math.round(_p.y)];this._slideStart();if(this.animate&&YAHOO.widget.Slider.ANIM_AVAIL&&t._graduated&&!skipAnim){this.lock();this.curCoord=YAHOO.util.Dom.getXY(this.thumb.getEl());this.curCoord=[Math.round(this.curCoord[0]),Math.round(this.curCoord[1])];setTimeout(function(){self.moveOneTick(p);},this.tickPause);}else if(this.animate&&YAHOO.widget.Slider.ANIM_AVAIL&&!skipAnim){this.lock();var oAnim=new YAHOO.util.Motion(t.id,{points:{to:p}},this.animationDuration,YAHOO.util.Easing.easeOut);oAnim.onComplete.subscribe(function(){self.endMove();});oAnim.animate();}else{t.setDragElPos(x,y);if(!midMove){this.endMove();}}},_slideStart:function(){if(!this._sliding){if(!this._silent){this.onSlideStart();this.fireEvent("slideStart");}
this._sliding=true;}},_slideEnd:function(){if(this._sliding&&this.moveComplete){var silent=this._silent;this._sliding=false;this._silent=false;this.moveComplete=false;if(!silent){this.onSlideEnd();this.fireEvent("slideEnd");}}},moveOneTick:function(finalCoord){var t=this.thumb,tmp;var nextCoord=null,tmpX,tmpY;if(t._isRegion){nextCoord=this._getNextX(this.curCoord,finalCoord);tmpX=(nextCoord!==null)?nextCoord[0]:this.curCoord[0];nextCoord=this._getNextY(this.curCoord,finalCoord);tmpY=(nextCoord!==null)?nextCoord[1]:this.curCoord[1];nextCoord=tmpX!==this.curCoord[0]||tmpY!==this.curCoord[1]?[tmpX,tmpY]:null;}else if(t._isHoriz){nextCoord=this._getNextX(this.curCoord,finalCoord);}else{nextCoord=this._getNextY(this.curCoord,finalCoord);}
if(nextCoord){this.curCoord=nextCoord;this.thumb.alignElWithMouse(t.getEl(),nextCoord[0]+this.thumbCenterPoint.x,nextCoord[1]+this.thumbCenterPoint.y);if(!(nextCoord[0]==finalCoord[0]&&nextCoord[1]==finalCoord[1])){var self=this;setTimeout(function(){self.moveOneTick(finalCoord);},this.tickPause);}else{this.endMove();}}else{this.endMove();}},_getNextX:function(curCoord,finalCoord){var t=this.thumb;var thresh;var tmp=[];var nextCoord=null;if(curCoord[0]>finalCoord[0]){thresh=t.tickSize-this.thumbCenterPoint.x;tmp=t.getTargetCoord(curCoord[0]-thresh,curCoord[1]);nextCoord=[tmp.x,tmp.y];}else if(curCoord[0]<finalCoord[0]){thresh=t.tickSize+this.thumbCenterPoint.x;tmp=t.getTargetCoord(curCoord[0]+thresh,curCoord[1]);nextCoord=[tmp.x,tmp.y];}else{}
return nextCoord;},_getNextY:function(curCoord,finalCoord){var t=this.thumb;var thresh;var tmp=[];var nextCoord=null;if(curCoord[1]>finalCoord[1]){thresh=t.tickSize-this.thumbCenterPoint.y;tmp=t.getTargetCoord(curCoord[0],curCoord[1]-thresh);nextCoord=[tmp.x,tmp.y];}else if(curCoord[1]<finalCoord[1]){thresh=t.tickSize+this.thumbCenterPoint.y;tmp=t.getTargetCoord(curCoord[0],curCoord[1]+thresh);nextCoord=[tmp.x,tmp.y];}else{}
return nextCoord;},b4MouseDown:function(e){if(!this.backgroundEnabled){return false;}
this.thumb.autoOffset();this.resetThumbConstraints();},onMouseDown:function(e){if(!this.backgroundEnabled||this.isLocked()){return false;}
var x=YAHOO.util.Event.getPageX(e);var y=YAHOO.util.Event.getPageY(e);this.focus();this.moveThumb(x,y);},onDrag:function(e){if(this.backgroundEnabled&&!this.isLocked()){var x=YAHOO.util.Event.getPageX(e);var y=YAHOO.util.Event.getPageY(e);this.moveThumb(x,y,true,true);this.fireEvents();}},endMove:function(){this.unlock();this.moveComplete=true;this.fireEvents();},resetThumbConstraints:function(){var t=this.thumb;t.setXConstraint(t.leftConstraint,t.rightConstraint,t.xTickSize);t.setYConstraint(t.topConstraint,t.bottomConstraint,t.xTickSize);},fireEvents:function(thumbEvent){var t=this.thumb;if(!thumbEvent){t.cachePosition();}
if(!this.isLocked()){if(t._isRegion){var newX=t.getXValue();var newY=t.getYValue();if(newX!=this.previousX||newY!=this.previousY){if(!this._silent){this.onChange(newX,newY);this.fireEvent("change",{x:newX,y:newY});}}
this.previousX=newX;this.previousY=newY;}else{var newVal=t.getValue();if(newVal!=this.previousVal){if(!this._silent){this.onChange(newVal);this.fireEvent("change",newVal);}}
this.previousVal=newVal;}
this._slideEnd();}},toString:function(){return("Slider ("+this.type+") "+this.id);}});YAHOO.augment(YAHOO.widget.Slider,YAHOO.util.EventProvider);YAHOO.widget.SliderThumb=function(id,sGroup,iLeft,iRight,iUp,iDown,iTickSize){if(id){YAHOO.widget.SliderThumb.superclass.constructor.call(this,id,sGroup);this.parentElId=sGroup;}
this.isTarget=false;this.tickSize=iTickSize;this.maintainOffset=true;this.initSlider(iLeft,iRight,iUp,iDown,iTickSize);this.scroll=false;};YAHOO.extend(YAHOO.widget.SliderThumb,YAHOO.util.DD,{startOffset:null,dragOnly:true,_isHoriz:false,_prevVal:0,_graduated:false,getOffsetFromParent0:function(parentPos){var myPos=YAHOO.util.Dom.getXY(this.getEl());var ppos=parentPos||YAHOO.util.Dom.getXY(this.parentElId);return[(myPos[0]-ppos[0]),(myPos[1]-ppos[1])];},getOffsetFromParent:function(parentPos){var el=this.getEl(),newOffset;if(!this.deltaOffset){var myPos=YAHOO.util.Dom.getXY(el);var ppos=parentPos||YAHOO.util.Dom.getXY(this.parentElId);newOffset=[(myPos[0]-ppos[0]),(myPos[1]-ppos[1])];var l=parseInt(YAHOO.util.Dom.getStyle(el,"left"),10);var t=parseInt(YAHOO.util.Dom.getStyle(el,"top"),10);var deltaX=l-newOffset[0];var deltaY=t-newOffset[1];if(isNaN(deltaX)||isNaN(deltaY)){}else{this.deltaOffset=[deltaX,deltaY];}}else{var newLeft=parseInt(YAHOO.util.Dom.getStyle(el,"left"),10);var newTop=parseInt(YAHOO.util.Dom.getStyle(el,"top"),10);newOffset=[newLeft+this.deltaOffset[0],newTop+this.deltaOffset[1]];}
return newOffset;},initSlider:function(iLeft,iRight,iUp,iDown,iTickSize){this.initLeft=iLeft;this.initRight=iRight;this.initUp=iUp;this.initDown=iDown;this.setXConstraint(iLeft,iRight,iTickSize);this.setYConstraint(iUp,iDown,iTickSize);if(iTickSize&&iTickSize>1){this._graduated=true;}
this._isHoriz=(iLeft||iRight);this._isVert=(iUp||iDown);this._isRegion=(this._isHoriz&&this._isVert);},clearTicks:function(){YAHOO.widget.SliderThumb.superclass.clearTicks.call(this);this.tickSize=0;this._graduated=false;},getValue:function(){return(this._isHoriz)?this.getXValue():this.getYValue();},getXValue:function(){if(!this.available){return 0;}
var newOffset=this.getOffsetFromParent();if(YAHOO.lang.isNumber(newOffset[0])){this.lastOffset=newOffset;return(newOffset[0]-this.startOffset[0]);}else{return(this.lastOffset[0]-this.startOffset[0]);}},getYValue:function(){if(!this.available){return 0;}
var newOffset=this.getOffsetFromParent();if(YAHOO.lang.isNumber(newOffset[1])){this.lastOffset=newOffset;return(newOffset[1]-this.startOffset[1]);}else{return(this.lastOffset[1]-this.startOffset[1]);}},toString:function(){return"SliderThumb "+this.id;},onChange:function(x,y){}});YAHOO.widget.DualSlider=function(minSlider,maxSlider,range,initVals){var self=this,lang=YAHOO.lang;this.minSlider=minSlider;this.maxSlider=maxSlider;this.activeSlider=minSlider;this.isHoriz=minSlider.thumb._isHoriz;initVals=YAHOO.lang.isArray(initVals)?initVals:[0,range];initVals[0]=Math.min(Math.max(parseInt(initVals[0],10)|0,0),range);initVals[1]=Math.max(Math.min(parseInt(initVals[1],10)|0,range),0);if(initVals[0]>initVals[1]){initVals.splice(0,2,initVals[1],initVals[0]);}
var ready={min:false,max:false};this.minSlider.thumb.onAvailable=function(){minSlider.setStartSliderState();ready.min=true;if(ready.max){minSlider.setValue(initVals[0],true,true,true);maxSlider.setValue(initVals[1],true,true,true);self.updateValue(true);self.fireEvent('ready',self);}};this.maxSlider.thumb.onAvailable=function(){maxSlider.setStartSliderState();ready.max=true;if(ready.min){minSlider.setValue(initVals[0],true,true,true);maxSlider.setValue(initVals[1],true,true,true);self.updateValue(true);self.fireEvent('ready',self);}};minSlider.onMouseDown=function(e){return self._handleMouseDown(e);};maxSlider.onMouseDown=function(e){if(self.minSlider.isLocked()&&!self.minSlider._sliding){return self._handleMouseDown(e);}else{YAHOO.util.Event.stopEvent(e);return false;}};minSlider.onDrag=maxSlider.onDrag=function(e){self._handleDrag(e);};minSlider.subscribe("change",this._handleMinChange,minSlider,this);minSlider.subscribe("slideStart",this._handleSlideStart,minSlider,this);minSlider.subscribe("slideEnd",this._handleSlideEnd,minSlider,this);maxSlider.subscribe("change",this._handleMaxChange,maxSlider,this);maxSlider.subscribe("slideStart",this._handleSlideStart,maxSlider,this);maxSlider.subscribe("slideEnd",this._handleSlideEnd,maxSlider,this);this.createEvent("ready",this);this.createEvent("change",this);this.createEvent("slideStart",this);this.createEvent("slideEnd",this);};YAHOO.widget.DualSlider.prototype={minVal:-1,maxVal:-1,minRange:0,_handleSlideStart:function(data,slider){this.fireEvent("slideStart",slider);},_handleSlideEnd:function(data,slider){this.fireEvent("slideEnd",slider);},_handleDrag:function(e){YAHOO.widget.Slider.prototype.onDrag.call(this.activeSlider,e);},_handleMinChange:function(){this.activeSlider=this.minSlider;this.updateValue();},_handleMaxChange:function(){this.activeSlider=this.maxSlider;this.updateValue();},setValues:function(min,max,skipAnim,force,silent){var mins=this.minSlider,maxs=this.maxSlider,mint=mins.thumb,maxt=maxs.thumb,self=this,done={min:false,max:false};if(mint._isHoriz){mint.setXConstraint(mint.leftConstraint,maxt.rightConstraint,mint.tickSize);maxt.setXConstraint(mint.leftConstraint,maxt.rightConstraint,maxt.tickSize);}else{mint.setYConstraint(mint.topConstraint,maxt.bottomConstraint,mint.tickSize);maxt.setYConstraint(mint.topConstraint,maxt.bottomConstraint,maxt.tickSize);}
this._oneTimeCallback(mins,'slideEnd',function(){done.min=true;if(done.max){self.updateValue(silent);setTimeout(function(){self._cleanEvent(mins,'slideEnd');self._cleanEvent(maxs,'slideEnd');},0);}});this._oneTimeCallback(maxs,'slideEnd',function(){done.max=true;if(done.min){self.updateValue(silent);setTimeout(function(){self._cleanEvent(mins,'slideEnd');self._cleanEvent(maxs,'slideEnd');},0);}});mins.setValue(min,skipAnim,force,false);maxs.setValue(max,skipAnim,force,false);},setMinValue:function(min,skipAnim,force,silent){var mins=this.minSlider;this.activeSlider=mins;var self=this;this._oneTimeCallback(mins,'slideEnd',function(){self.updateValue(silent);setTimeout(function(){self._cleanEvent(mins,'slideEnd');},0);});mins.setValue(min,skipAnim,force,silent);},setMaxValue:function(max,skipAnim,force,silent){var maxs=this.maxSlider;this.activeSlider=maxs;var self=this;this._oneTimeCallback(maxs,'slideEnd',function(){self.updateValue(silent);setTimeout(function(){self._cleanEvent(maxs,'slideEnd');},0);});maxs.setValue(max,skipAnim,force,silent);},updateValue:function(silent){var min=this.minSlider.getValue(),max=this.maxSlider.getValue(),changed=false;if(min!=this.minVal||max!=this.maxVal){changed=true;var mint=this.minSlider.thumb,maxt=this.maxSlider.thumb,dim=this.isHoriz?'x':'y';var thumbInnerWidth=this.minSlider.thumbCenterPoint[dim]+
this.maxSlider.thumbCenterPoint[dim];var minConstraint=Math.max(max-thumbInnerWidth-this.minRange,0);var maxConstraint=Math.min(-min-thumbInnerWidth-this.minRange,0);if(this.isHoriz){minConstraint=Math.min(minConstraint,maxt.rightConstraint);mint.setXConstraint(mint.leftConstraint,minConstraint,mint.tickSize);maxt.setXConstraint(maxConstraint,maxt.rightConstraint,maxt.tickSize);}else{minConstraint=Math.min(minConstraint,maxt.bottomConstraint);mint.setYConstraint(mint.leftConstraint,minConstraint,mint.tickSize);maxt.setYConstraint(maxConstraint,maxt.bottomConstraint,maxt.tickSize);}}
this.minVal=min;this.maxVal=max;if(changed&&!silent){this.fireEvent("change",this);}},selectActiveSlider:function(e){var min=this.minSlider,max=this.maxSlider,minLocked=min.isLocked(),maxLocked=max.isLocked(),Ev=YAHOO.util.Event,d;if(minLocked||maxLocked){this.activeSlider=minLocked?max:min;}else{if(this.isHoriz){d=Ev.getPageX(e)-min.thumb.initPageX-min.thumbCenterPoint.x;}else{d=Ev.getPageY(e)-min.thumb.initPageY-min.thumbCenterPoint.y;}
this.activeSlider=d*2>max.getValue()+min.getValue()?max:min;}},_handleMouseDown:function(e){this.selectActiveSlider(e);YAHOO.widget.Slider.prototype.onMouseDown.call(this.activeSlider,e);},_oneTimeCallback:function(o,evt,fn){o.subscribe(evt,function(){o.unsubscribe(evt,arguments.callee);fn.apply({},[].slice.apply(arguments));});},_cleanEvent:function(o,evt){if(o.__yui_events&&o.events[evt]){var ce,i,len;for(i=o.__yui_events.length;i>=0;--i){if(o.__yui_events[i].type===evt){ce=o.__yui_events[i];break;}}
if(ce){var subs=ce.subscribers,newSubs=[],j=0;for(i=0,len=subs.length;i<len;++i){if(subs[i]){newSubs[j++]=subs[i];}}
ce.subscribers=newSubs;}}}};YAHOO.augment(YAHOO.widget.DualSlider,YAHOO.util.EventProvider);YAHOO.widget.Slider.getHorizDualSlider=function(bg,minthumb,maxthumb,range,iTickSize,initVals){var mint,maxt;var YW=YAHOO.widget,Slider=YW.Slider,Thumb=YW.SliderThumb;mint=new Thumb(minthumb,bg,0,range,0,0,iTickSize);maxt=new Thumb(maxthumb,bg,0,range,0,0,iTickSize);return new YW.DualSlider(new Slider(bg,bg,mint,"horiz"),new Slider(bg,bg,maxt,"horiz"),range,initVals);};YAHOO.widget.Slider.getVertDualSlider=function(bg,minthumb,maxthumb,range,iTickSize,initVals){var mint,maxt;var YW=YAHOO.widget,Slider=YW.Slider,Thumb=YW.SliderThumb;mint=new Thumb(minthumb,bg,0,0,0,range,iTickSize);maxt=new Thumb(maxthumb,bg,0,0,0,range,iTickSize);return new YW.DualSlider(new Slider(bg,bg,mint,"vert"),new Slider(bg,bg,maxt,"vert"),range,initVals);};YAHOO.register("slider",YAHOO.widget.Slider,{version:"2.6.0",build:"1321"});var deconcept=deconcept||{};if(typeof deconcept.util=="undefined"||!deconcept.util)
{deconcept.util={};}
if(typeof deconcept.SWFObjectUtil=="undefined"||!deconcept.SWFObjectUtil)
{deconcept.SWFObjectUtil={};}
deconcept.SWFObject=function(swf,id,w,h,ver,c,quality,xiRedirectUrl,redirectUrl,detectKey)
{if(!document.getElementById){return;}
this.DETECT_KEY=detectKey?detectKey:'detectflash';this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params={};this.variables={};this.attributes=[];if(swf){this.setAttribute('swf',swf);}
if(id){this.setAttribute('id',id);}
if(w){this.setAttribute('width',w);}
if(h){this.setAttribute('height',h);}
if(ver){this.setAttribute('version',new deconcept.PlayerVersion(ver.toString().split(".")));}
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7)
{deconcept.SWFObject.doPrepUnload=true;}
if(c)
{this.addParam('bgcolor',c);}
var q=quality?quality:'high';this.addParam('quality',q);this.setAttribute('useExpressInstall',false);this.setAttribute('doExpressInstall',false);var xir=(xiRedirectUrl)?xiRedirectUrl:window.location;this.setAttribute('xiRedirectUrl',xir);this.setAttribute('redirectUrl','');if(redirectUrl)
{this.setAttribute('redirectUrl',redirectUrl);}};deconcept.SWFObject.prototype={useExpressInstall:function(path)
{this.xiSWFPath=!path?"expressinstall.swf":path;this.setAttribute('useExpressInstall',true);},setAttribute:function(name,value){this.attributes[name]=value;},getAttribute:function(name){return this.attributes[name];},addParam:function(name,value){this.params[name]=value;},getParams:function(){return this.params;},addVariable:function(name,value){this.variables[name]=value;},getVariable:function(name){return this.variables[name];},getVariables:function(){return this.variables;},getVariablePairs:function(){var variablePairs=[];var key;var variables=this.getVariables();for(key in variables)
{if(variables.hasOwnProperty(key))
{variablePairs[variablePairs.length]=key+"="+variables[key];}}
return variablePairs;},getSWFHTML:function(){var swfNode="";var params={};var key="";var pairs="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute('swf',this.xiSWFPath);}
swfNode='<embed type="application/x-shockwave-flash" src="'+this.getAttribute('swf')+'" width="'+this.getAttribute('width')+'" height="'+this.getAttribute('height')+'" style="'+this.getAttribute('style')+'"';swfNode+=' id="'+this.getAttribute('id')+'" name="'+this.getAttribute('id')+'" ';params=this.getParams();for(key in params)
{if(params.hasOwnProperty(key))
{swfNode+=[key]+'="'+params[key]+'" ';}}
pairs=this.getVariablePairs().join("&");if(pairs.length>0){swfNode+='flashvars="'+pairs+'"';}
swfNode+='/>';}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute('swf',this.xiSWFPath);}
swfNode='<object id="'+this.getAttribute('id')+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+this.getAttribute('width')+'" height="'+this.getAttribute('height')+'" style="'+this.getAttribute('style')+'">';swfNode+='<param name="movie" value="'+this.getAttribute('swf')+'" />';params=this.getParams();for(key in params)
{if(params.hasOwnProperty(key))
{swfNode+='<param name="'+key+'" value="'+params[key]+'" />';}}
pairs=this.getVariablePairs().join("&");if(pairs.length>0){swfNode+='<param name="flashvars" value="'+pairs+'" />';}
swfNode+="</object>";}
return swfNode;},write:function(elementId)
{if(this.getAttribute('useExpressInstall')){var expressInstallReqVer=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(expressInstallReqVer)&&!this.installedVer.versionIsValid(this.getAttribute('version'))){this.setAttribute('doExpressInstall',true);this.addVariable("MMredirectURL",escape(this.getAttribute('xiRedirectUrl')));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}
if(this.skipDetect||this.getAttribute('doExpressInstall')||this.installedVer.versionIsValid(this.getAttribute('version')))
{var n=(typeof elementId=='string')?document.getElementById(elementId):elementId;n.innerHTML=this.getSWFHTML();return true;}
else
{if(this.getAttribute('redirectUrl')!=="")
{document.location.replace(this.getAttribute('redirectUrl'));}}
return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function()
{var axo=null;var PlayerVersion=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length)
{var x=navigator.plugins["Shockwave Flash"];if(x&&x.description)
{PlayerVersion=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}
else if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0)
{var counter=3;while(axo)
{try
{counter++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+counter);PlayerVersion=new deconcept.PlayerVersion([counter,0,0]);}
catch(e)
{axo=null;}}}
else
{try
{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}
catch(e)
{try
{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");PlayerVersion=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}
catch(e)
{if(PlayerVersion.major==6)
{return PlayerVersion;}}
try
{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}
catch(e){}}
if(axo!==null)
{PlayerVersion=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}
return PlayerVersion;};deconcept.PlayerVersion=function(arrVersion)
{this.major=arrVersion[0]!==null?parseInt(arrVersion[0],0):0;this.minor=arrVersion[1]!==null?parseInt(arrVersion[1],0):0;this.rev=arrVersion[2]!==null?parseInt(arrVersion[2],0):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv)
{if(this.major<fv.major)
{return false;}
if(this.major>fv.major)
{return true;}
if(this.minor<fv.minor)
{return false;}
if(this.minor>fv.minor)
{return true;}
if(this.rev<fv.rev)
{return false;}
return true;};deconcept.util={getRequestParameter:function(param)
{var q=document.location.search||document.location.hash;if(param===null){return q;}
if(q)
{var pairs=q.substring(1).split("&");for(var i=0;i<pairs.length;i++)
{if(pairs[i].substring(0,pairs[i].indexOf("="))==param)
{return pairs[i].substring((pairs[i].indexOf("=")+1));}}}
return"";}};deconcept.SWFObjectUtil.cleanupSWFs=function()
{var objects=document.getElementsByTagName("OBJECT");for(var i=objects.length-1;i>=0;i--)
{objects[i].style.display='none';for(var x in objects[i])
{if(typeof objects[i][x]=='function')
{objects[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload)
{if(!deconcept.unloadSet)
{deconcept.SWFObjectUtil.prepUnload=function()
{__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}
if(!document.getElementById&&document.all)
{document.getElementById=function(id){return document.all[id];};}
var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;YAHOO.widget.FlashAdapter=function(swfURL,containerID,attributes,buttonSkin)
{this._queue=this._queue||[];this._events=this._events||{};this._configs=this._configs||{};attributes=attributes||{};this._id=attributes.id=attributes.id||YAHOO.util.Dom.generateId(null,"yuigen");attributes.version=attributes.version||"9.0.45";attributes.backgroundColor=attributes.backgroundColor||"#ffffff";this._attributes=attributes;this._swfURL=swfURL;this._containerID=containerID;this._embedSWF(this._swfURL,this._containerID,attributes.id,attributes.version,attributes.backgroundColor,attributes.expressInstall,attributes.wmode,buttonSkin);try
{this.createEvent("contentReady");}
catch(e){}};YAHOO.extend(YAHOO.widget.FlashAdapter,YAHOO.util.AttributeProvider,{_swfURL:null,_containerID:null,_swf:null,_id:null,_initialized:false,_attributes:null,toString:function()
{return"FlashAdapter "+this._id;},destroy:function()
{if(this._swf)
{var container=YAHOO.util.Dom.get(this._containerID);container.removeChild(this._swf);}
var instanceName=this._id;for(var prop in this)
{if(YAHOO.lang.hasOwnProperty(this,prop))
{this[prop]=null;}}},_embedSWF:function(swfURL,containerID,swfID,version,backgroundColor,expressInstall,wmode,buttonSkin)
{var swfObj=new deconcept.SWFObject(swfURL,swfID,"100%","100%",version,backgroundColor);if(expressInstall)
{swfObj.useExpressInstall(expressInstall);}
swfObj.addParam("allowScriptAccess","always");if(wmode)
{swfObj.addParam("wmode",wmode);}
swfObj.addParam("menu","false");swfObj.addVariable("allowedDomain",document.location.hostname);swfObj.addVariable("elementID",swfID);swfObj.addVariable("eventHandler","YAHOO.widget.FlashAdapter.eventHandler");if(buttonSkin){swfObj.addVariable("buttonSkin",buttonSkin);}
var container=YAHOO.util.Dom.get(containerID);var result=swfObj.write(container);if(result)
{this._swf=YAHOO.util.Dom.get(swfID);this._swf.owner=this;}
else
{}},_eventHandler:function(event)
{var type=event.type;switch(type)
{case"swfReady":this._loadHandler();return;case"log":return;}
this.fireEvent(type,event);},_loadHandler:function()
{this._initialized=false;this._initAttributes(this._attributes);this.setAttributes(this._attributes,true);this._initialized=true;this.fireEvent("contentReady");},set:function(name,value)
{this._attributes[name]=value;YAHOO.widget.FlashAdapter.superclass.set.call(this,name,value);},_initAttributes:function(attributes)
{this.getAttributeConfig("altText",{method:this._getAltText});this.setAttributeConfig("altText",{method:this._setAltText});this.getAttributeConfig("swfURL",{method:this._getSWFURL});},_getSWFURL:function()
{return this._swfURL;},_getAltText:function()
{return this._swf.getAltText();},_setAltText:function(value)
{return this._swf.setAltText(value);}});YAHOO.widget.FlashAdapter.eventHandler=function(elementID,event)
{var loadedSWF=YAHOO.util.Dom.get(elementID);if(!loadedSWF.owner)
{setTimeout(function(){YAHOO.widget.FlashAdapter.eventHandler(elementID,event);},0);}
else
{loadedSWF.owner._eventHandler(event);}};YAHOO.widget.FlashAdapter.proxyFunctionCount=0;YAHOO.widget.FlashAdapter.createProxyFunction=function(func)
{var index=YAHOO.widget.FlashAdapter.proxyFunctionCount;YAHOO.widget.FlashAdapter["proxyFunction"+index]=function()
{return func.apply(null,arguments);};YAHOO.widget.FlashAdapter.proxyFunctionCount++;return"YAHOO.widget.FlashAdapter.proxyFunction"+index.toString();};YAHOO.widget.FlashAdapter.removeProxyFunction=function(funcName)
{if(!funcName||funcName.indexOf("YAHOO.widget.FlashAdapter.proxyFunction")<0)
{return;}
funcName=funcName.substr(26);YAHOO.widget.FlashAdapter[funcName]=null;};YAHOO.widget.Uploader=function(containerId,buttonSkin)
{var newWMode="opaque";if(!(buttonSkin)){newWMode="transparent";}
YAHOO.widget.Uploader.superclass.constructor.call(this,YAHOO.widget.Uploader.SWFURL,containerId,{wmode:newWMode},buttonSkin);this._swf.tabIndex="1";this.createEvent("mouseDown");this.createEvent("mouseUp");this.createEvent("rollOver");this.createEvent("rollOut");this.createEvent("click");this.createEvent("fileSelect");this.createEvent("uploadStart");this.createEvent("uploadProgress");this.createEvent("uploadCancel");this.createEvent("uploadComplete");this.createEvent("uploadCompleteData");this.createEvent("uploadError");}
YAHOO.widget.Uploader.SWFURL="assets/uploader.swf";YAHOO.extend(YAHOO.widget.Uploader,YAHOO.widget.FlashAdapter,{upload:function(fileID,uploadScriptPath,method,vars,fieldName)
{this._swf.upload(fileID,uploadScriptPath,method,vars,fieldName);},uploadAll:function(uploadScriptPath,method,vars,fieldName)
{this._swf.uploadAll(uploadScriptPath,method,vars,fieldName);},cancel:function(fileID)
{this._swf.cancel(fileID);},clearFileList:function()
{this._swf.clearFileList();},removeFile:function(fileID)
{this._swf.removeFile(fileID);},setAllowLogging:function(allowLogging)
{this._swf.setAllowLogging(allowLogging);},setSimUploadLimit:function(simUploadLimit)
{this._swf.setSimUploadLimit(simUploadLimit);},setAllowMultipleFiles:function(allowMultipleFiles)
{this._swf.setAllowMultipleFiles(allowMultipleFiles);},setFileFilters:function(fileFilters)
{this._swf.setFileFilters(fileFilters);},enable:function()
{this._swf.enable();},disable:function()
{this._swf.disable();}});YAHOO.register("uploader",YAHOO.widget.Uploader,{version:"2.6.0",build:"1321"});function GMapHandler(){};GMapHandler.prototype.removeOverlays=function(){var map=Poi.getMap();var overlays=map.poaOverlays;this._removeOverlaysFromTheMapIfNeed(overlays);var poaGroundOverlays=map.poaGroundOverlays;this._removeOverlaysFromTheMapIfNeed(poaGroundOverlays);};GMapHandler.prototype._removeOverlaysFromTheMapIfNeed=function(overlays){var map=Poi.getMap();var poas=ctx.getPois();if(poas){var newOverlays=[];if(typeof overlays!='undefined'){var n=overlays.length;for(var i=0;i<n;i++){if(poas[overlays[i].poiId]){newOverlays.push(overlays[i]);}else{map.removeOverlay(overlays[i]);}}
overlays=newOverlays;}}else{map.removePoaOverlays();}};GMapHandler.prototype.removeNewRoute=function(){Poi.getMap().removeRoute(GlobalProperties.NEW_ROUTE_ID);}
GMapHandler.prototype.drawMarkers=function(){var map=Poi.getMap();var zoomLevel=map.getZoom();var pois=ctx.getPois();var markerAlreadyExist=new Array();var newMarkerSet=new Array();var markers=map.getMarkers();for(var index in markers){var marker=markers[index];var poi=pois[marker.poiId];var poiId=marker.poiId;if(poi){marker.updateIcon(ctx.getCategories()[poi.mainCategoryId].code,poi);markerAlreadyExist[poiId]=true;newMarkerSet.push(marker);var isRoute=ctx.getCategories()[poi.mainCategoryId].categoryType==GlobalProperties.ROUTE;if(isRoute&&!routes[poiId]&&zoomLevel>GlobalProperties.START_ZOOM_LEVEL_FOR_ROUTES-1){map.showRoute(poiId,false,poi.layerLink);}
else if(routes[poiId]&&zoomLevel<GlobalProperties.START_ZOOM_LEVEL_FOR_ROUTES){map.removeRoute(poiId);}}
else{if(routes[poiId]){map.removeRoute(poiId);}
map.removeOverlay(marker);}}
map.setMarkers(newMarkerSet);this.removeOverlays();for(var poiId in pois){var poi=pois[poiId];var isPoa=ctx.getCategories()[poi.mainCategoryId].categoryType==GlobalProperties.POA;if(isPoa){map.showPoa(poiId,poi.layerLink);}else if(!markerAlreadyExist[poiId]){gmapHandler.addMapMarker(map,poi);}
if(zoomLevel>GlobalProperties.START_ZOOM_LEVEL_FOR_ROUTES-1&&!isPoa&&!markerAlreadyExist[poiId]){map.showRoute(poiId,false,poi.layerLink);}
var currentPoi=ctx.getPoiById(poiId);}
this.redrawPoiGroups();};GMapHandler.prototype.redrawPoiGroups=function(){var map=Poi.getMap();map.clearPoisAreaOverlays();var rectangles=ctx.getRectangles();var n=rectangles.length;for(var j=0;j<n;j++){var rectangle=rectangles[j];var nearPoisBounds=new GLatLngBounds();var pointA=new GLatLng(rectangle.latA,rectangle.lngA);var pointB=new GLatLng(rectangle.latB,rectangle.lngB);nearPoisBounds.extend(pointA);nearPoisBounds.extend(pointB);var categoryStatistic=[]
if(rectangle.categoryIds){var categoryIds=rectangle.categoryIds.split(',');for(var catIndex in categoryIds){var categoryIdsStat=categoryIds[catIndex].split(':');categoryStatistic[categoryIdsStat[0]]=categoryIdsStat[1];}}
var viewBounds=new GLatLngBounds();var leftTopBorder=new GLatLng(rectangle.topZoomBorder,rectangle.lngA);var rightBottomBorder=new GLatLng(rectangle.bottomZoomBorder,rectangle.rightZoomBorder);viewBounds.extend(leftTopBorder);viewBounds.extend(rightBottomBorder);map.addPoisAreaOverlay(nearPoisBounds,rectangle.countPois,viewBounds,categoryStatistic);}};GMapHandler.prototype._getParamsForFilter=function(rectangle){var searchString='';if(Dom.get("filterField")){searchString=PoiListFilter.getSearchValue();}
var categoriesIds=ctx.getSelectedCategories().join(",");if(!categoriesIds&&searchString==''){categoriesIds='withoutPois';}
else if(!categoriesIds&&searchString!=''){categoriesIds="-1";}
else if(!categoriesIds){categoriesIds="";}
var params='categoriesIds='+categoriesIds;var minLat=rectangle.latA-0.0000000000001;var minLng=rectangle.lngA-0.0000000000001;var maxLat=rectangle.latB;var maxLng=rectangle.lngB;var onlyMy='';if(Dom.get("myPoiTab")&&Dom.get("myPoiTab").className=="active"){onlyMy='onlyMy';}
var minDistance=0;var minimalRectWidth=0;var minLngSide=0;var map=Poi.getMap();var mapWidthPx=map.getSize().width;var mapHeightPx=map.getSize().height;var mapType=(mapHeightPx>mapWidthPx)?GlobalProperties.VERTICAL_MAP:GlobalProperties.HORIZONTAL_MAP;if(!isNaN(minLat)||!isNaN(minLng)||!isNaN(maxLat)||!isNaN(maxLng)){params+="&minLat="+minLat+"&minLng="+minLng+"&maxLat="+maxLat+"&maxLng="+maxLng+"&searchPoiByNameAndDescription="+searchString+"&onlyMy="+onlyMy+"&minDistance="+minDistance+"&minLngSide="+
minLngSide+"&mapType="+mapType+"&withRectangles="+false;params+='&'+PoiListSorting.getParametersList();return params;}
return null;};GMapHandler.prototype.deletePoiFromGroup=function(poi){var latitude=poi.latitude;var longitude=poi.longitude;var rectangles=ctx.getRectangles();for(var index in rectangles){var rectangle=rectangles[index];if(rectangle.latA<=latitude&&latitude<=rectangle.latB&&rectangle.lngA<=longitude&&longitude<=rectangle.lngB){rectangle.countPois--;if(rectangle.countPois==1){var map=Poi.getMap();var params=this._getParamsForFilter(rectangle);UIRequest("loadFilteredPoisWithStat.action",params,function(p_oRequest){var localCtx=ctx;var json=YAHOO.lang.JSON.parse(p_oRequest.responseText);var pois=poisSelector.parsePois(json.poisMap);var poisArea=map.getPoisAreasOverlays();var point=new GLatLng(latitude,longitude);for(var index in poisArea){if(poisArea[index].viewPort_.containsLatLng(point)){map.removeOverlay(poisArea[index]);break;}}
for(var id in pois){localCtx.getPois()[id]=pois[id];gmapHandler.addMapMarker(map,pois[id]);}});rectangles[index]=rectangles[rectangles.length-1];delete rectangles[rectangles.length-1];rectangles.length=rectangles.length-1;}
else{var categoryStatistic=[]
if(rectangle.categoryIds){var categoryIds=rectangle.categoryIds.split(',');for(var catIndex in categoryIds){var categoryIdsStat=categoryIds[catIndex].split(':');categoryStatistic[categoryIdsStat[0]]=categoryIdsStat[1];}}
var categoryIds=poi.categoriesIds;var m=categoryIds.length;for(var i=0;i<m;i++){categoryStatistic[categoryIds[i]]=parseInt(categoryStatistic[categoryIds[i]])-1;}
categoryIds="";for(var catIndex in categoryStatistic){categoryIds+=catIndex+':'+categoryStatistic[catIndex]+',';}
rectangle.categoryIds=categoryIds;}
break;}}};GMapHandler.prototype.groupPoi=function(poi){var pois=ctx.getPois();if(pois&&!pois[poi.id]){return;}
var map=Poi.getMap();var latitude=poi.latitude;var longitude=poi.longitude;var rectangles=ctx.getRectangles();for(var index in rectangles){var rectangle=rectangles[index];if(rectangle.latA<=latitude&&latitude<=rectangle.latB&&rectangle.lngA<=longitude&&longitude<=rectangle.lngB){rectangle.countPois++;var categoryStatistic=[]
if(rectangle.categoryIds){var categoryIds=rectangle.categoryIds.split(',');for(var catIndex in categoryIds){var categoryIdsStat=categoryIds[catIndex].split(':');categoryStatistic[categoryIdsStat[0]]=categoryIdsStat[1];}}
var categoryIds=poi.categoriesIds;var m=categoryIds.length;for(var i=0;i<m;i++){categoryStatistic[categoryIds[i]]=categoryStatistic[categoryIds[i]]?parseInt(categoryStatistic[categoryIds[i]])+1:1;}
categoryIds="";for(var catIndex in categoryStatistic){categoryIds+=catIndex+':'+categoryStatistic[catIndex]+',';}
rectangle.categoryIds=categoryIds;poisSelector.deletePoiById(poi.id);poisSelector.drawPois();break;}}
var pois=ctx.getPois();var markerPosition=map.fromLatLngToContainerPixel(new GLatLng(latitude,longitude));for(var index in pois){var poiToCheck=pois[index];if(poi.id!=poiToCheck.id){var marker2Position=map.fromLatLngToContainerPixel(new GLatLng(poiToCheck.latitude,poiToCheck.longitude));var xDifference=Math.abs(marker2Position.x-markerPosition.x);if(xDifference>GlobalProperties.MINIMAL_DISTANCE_BETWEEN_POIS_IN_PX){break;}
var yDifference=marker2Position.y-markerPosition.y;var distance=Math.sqrt(xDifference*xDifference+yDifference*yDifference);if((distance<GlobalProperties.MINIMAL_DISTANCE_BETWEEN_POIS_IN_PX)){poisSelector.setPoisByCategoriesIdsAndCoordinatBound();break;}}}};GMapHandler.prototype.getMarkerbyPoiId=function(poiId){var markers=Poi.getMap().getMarkers();var size=markers.length;for(var index=0;index<size;index++){if(poiId==markers[index].poiId){return markers[index];}}
return null;};GMapHandler.prototype.addMapMarker=function(map,poi){map.addMarker(new CLIPTOO.map.PoiMarker(poi));};GMapHandler.prototype.showBalloon=function(poi,tab){popupHandler.showPleaseWait();var map=Poi.getMap();map.holdMapWithCursor("default");map.disable();if(poi.editable){ctx.getViewBalloon().close();ctx.getEditBalloon().show(poi,tab);}else{if(ctx.getEditBalloon()){ctx.getEditBalloon().close();}
ctx.getViewBalloon().show(poi,tab);}}
GMapHandler.prototype.showBalloonForNewPoi=function(pointType,point,searchedAddress,link,name){if(pointType&&pointType==GlobalProperties.POI){ctx.getEasyCreatingForm().disable();gmapHandler.createNewMarker(point);}
this._prepareForShowingBalloon();ctx.getEditBalloon().showForNew(pointType,point,searchedAddress,link,name);};GMapHandler.prototype._prepareForShowingBalloon=function(){popupHandler.showPleaseWait();var map=Poi.getMap();map.holdMapWithCursor("default");map.disable();ctx.getViewBalloon().close();}
GMapHandler.prototype.createNewMarker=function(point){var map=Poi.getMap();var marker=new CLIPTOO.map.PoiMarker(null,point);map.temporary=marker;map.addOverlay(marker);};function WidgetWizard(hash){this.i18n=PoiMsg.js_msg.widget;this.widgetWizard=PoiMsg.js_msg.widgetWizard;this.frameId="widgetframedefault";this.searchField="widgetWizardSearchField";this.resetBtn="widgetWizardResetBtn";this.searchListContainer="wizardSearchListContainer";this.searchListScroll="wizardSearchListScroll";this.scrollUp="wizardSearchListUp";this.scrollDown="wizardSearchListDown";this.nothingFoundHint="widgetWizardNothingFound";this.resultHint="widgetWizardResultHint";this.layerSelector="widgetWizardLayer";this.loginFrame="widgetWizardLoginFrame";this.layerSelectorContainer="widgetWizardLayerSelector";this.hash=hash;this.language="";this.searchHint=this.widgetWizard.searchHint();this.clearAllData();var layerText=this.widgetWizard.defaultLayerHint();var propmpts=ctx.getOrganizationPrompts();if(propmpts["toolbar.layer.button"]){layerText=propmpts["toolbar.layer.button"];}
var langElement=Dom.get("lang");if(langElement){this.language=langElement.value
this.currentLngFrameSize=(langElement.value=="nl")?"185px":"200px";}else{this.language='en';this.currentLngFrameSize="200px";}
if(THEME_NAME=="bijteun"){this.currentLngFrameSize="158px";}
var currentLocation=window.location;this.domain=currentLocation.protocol+"//"+currentLocation.host;this.htmlForLoggedInUser='<div class="get_widget_main" id="widgetWizardLeftPanel">\
 <div id="widgetWizardStep0" style="display:none">\
  <div class="category-group">\
   <div class="category-group-left"></div>\
   <div class="category-group-center"><span><span id="widgetWizardStepNumber0"></span>/<span id="widgetWizardCount0"></span> '+this.widgetWizard.loginTitle()+'</span></div>\
   <div class="category-group-right"></div>\
  </div>\
  <div class="get_widget_text">'+this.widgetWizard.loginText()+'</div>\
  <div id="widgetWizardLoginFrame" style="overflow: hidden; position: absolute; left: 0; bottom: -5px;"></div>\
 </div>\
 <div id="widgetWizardStep1" style="display:none">\
  <div class="category-group">\
   <div class="category-group-left"></div>\
   <div class="category-group-center"><span><span id="widgetWizardStepNumber1"></span>/<span id="widgetWizardCount1"></span> '+this.widgetWizard.mapAreaTitle()+'</span></div>\
   <div class="category-group-right"></div>\
  </div>\
  <div class="get_widget_text">'+this.widgetWizard.mapAreaText()+'</div>\
  <div class="easyCreatingFieldContainer widget-wizard-search">\
   <b class="trg"><b></b><i></i><u></u></b>\
    <div class="mrg">\
    <input id="'+this.searchField+'" type="text" value="'+this.searchHint+'">\
    <div class="widget-wizard-magnifier"></div>\
    <div id="'+this.resetBtn+'" class="widget-wizard-reset-btn" style="display: none;"></div>\
    </div>\
   <b class="brg"><u></u><i></i><b></b></b>\
  </div>\
  <div id="'+this.nothingFoundHint+'" style="display:none;">'+PoiMsg.js_msg.search.nothingFound()+'</div>\
  <div id="'+this.resultHint+'" style="display: none;">'+PoiMsg.js_msg.search.specification()+'</div>\
  <div id="wizardInformationBalloonContainer" style="width:240px;">\
   <div id="wizardSearchListUp" class="poi-desc-scroll-up"></div>\
   <div id="wizardSearchListContainer" style="height:117px; overflow:hidden;">\
    <div  id="'+this.searchListScroll+'" style="display:none;"></div>\
   </div>\
   <div id="wizardSearchListDown" class="poi-desc-scroll-down"></div>\
  </div>\
 </div>\
 <div id="widgetWizardStep2" style="display:none">\
  <div class="category-group">\
   <div class="category-group-left"></div>\
   <div class="category-group-center"><span><span id="widgetWizardStepNumber2"></span>/<span id="widgetWizardCount2"></span> '+this.widgetWizard.categoriesTitle()+'</span></div>\
   <div class="category-group-right"></div>\
  </div>\
  <div class="get_widget_text">'+this.widgetWizard.categoriesText()+'</div>\
 </div>\
 <div id="widgetWizardStep3" style="display:none">\
  <div class="category-group">\
   <div class="category-group-left"></div>\
   <div class="category-group-center"><span><span id="widgetWizardStepNumber3"></span>/<span id="widgetWizardCount3"></span> '+this.widgetWizard.locationTitle()+'</span></div>\
   <div class="category-group-right"></div>\
  </div>\
  <div class="get_widget_text">'+this.widgetWizard.locationText()+'</div>\
 </div>\
 <div id="widgetWizardStep4" style="display:none">\
  <div class="category-group">\
   <div class="category-group-left"></div>\
   <div class="category-group-center"><span><span id="widgetWizardStepNumber4"></span>/<span id="widgetWizardCount4"></span> '+this.widgetWizard.sizeTitle()+'</span></div>\
   <div class="category-group-right"></div>\
  </div>\
  <div class="get_widget_text">'+this.widgetWizard.sizeText(layerText)+'</div>\
  <div id="widgetWizardSizeContainer"></div>\
 </div>\
 <div id="widgetWizardStep5" style="display:none">\
  <div class="category-group">\
   <div class="category-group-left"></div>\
   <div class="category-group-center"><span><span id="widgetWizardStepNumber5"></span>/<span id="widgetWizardCount5"></span> '+this.widgetWizard.logoTitle()+'</span></div>\
   <div class="category-group-right"></div>\
  </div>\
  <div class="get_widget_text">'+this.widgetWizard.logoText()+'</div>\
 </div>\
 <div id="widgetWizardStep6" style="display:none">\
  <div class="category-group">\
   <div class="category-group-left"></div>\
   <div class="category-group-center"><span><span id="widgetWizardStepNumber6"></span>/<span id="widgetWizardCount6"></span> '+this.widgetWizard.htmlCodeTitle()+'</span></div>\
   <div class="category-group-right"></div>\
  </div>\
  <div class="get_widget_text">'+this.widgetWizard.htmlCodeText()+'</div>\
  <textarea cols="60" rows="5" readonly="" onclick="this.select()" class="" id="WidgetWizardTexarea" /></textarea>\
 </div>\
 <div class="buttonDiv" id="widgetWizardButtons">\
  <a class="ovalbutton" id="widgetWizardButtonsPrevious"><span>'+this.widgetWizard.previousButton()+'</span></a>\
  <a class="ovalbutton" id="widgetWizardButtonsNext"><span>'+this.widgetWizard.nextButton()+'</span></a></div>\
 </div><div class="get-widget-iframe-container">\
 <iframe scrolling="no" height="400" frameborder="0" width="520" id="'+this.frameId+'" class="get-widget-iframe" src="'+this.domain+'/poiwidget/conf/loadStandalone.action?id='+this.hash+'&amp;lng=nl&pw=t"></iframe>\
 </div>';this.sizeStepString='<div>\
  <div class="widget-wizard-label">'+this.widgetWizard.widthLabel()+'</div>\
  <div class="widget-wizard-field">\
   <input type="text" tabindex="1" name="width" id="widgetWizardWidth" value="'+this.widthHeightLng[0]+'"><span> px</span>\
  </div>\
  <div class="widget-wizard-label">'+this.widgetWizard.heightLabel()+'</div>\
  <div class="widget-wizard-field">\
   <input type="text" tabindex="2" name="height" id="widgetWizardHeight" value="'+this.widthHeightLng[1]+'"><span> px</span>\
  </div>\
  <div class="widget-wizard-separator"></div>\
  <div id="widgetWizardLayerSelector">\
  <div class="widget-wizard-label">'+this.widgetWizard.mapLayer()+'</div>\
  <div class="widget-wizard-field">\
   <select tabindex="3" name="layer" class="widget-wizard-select" id="widgetWizardLayer">\
   </select>\
  </div>\
  </div>\
 </div>';this.logoStepString='<div id="logo" style="background-image: url('+this.domain+'/widget/cliptoo/cliptoo-logo-widget.png);"></div>';this.initWizard();};WidgetWizard.prototype.clearAllData=function(){this.selectedCatsIds=[];this.availableCatsIds=[];this.groupsOrder=[];this.ownPoisIds=[];this.deletedOwnPoisIds=[];this.mapBoundsAndZoom=[];this.widthHeightLng=[];this.widthHeightLng[0]="520";this.widthHeightLng[1]="400";this.logoLink="";this.layerId="";this.resultObject={mapBounds:"",sizeLanguage:"",catsIds:"",groupsOrder:"",ownPoiIds:"",layerId:""};};WidgetWizard.prototype.attachHandlers=function(){popupHandler.showPleaseWait();Event.addListener("widgetWizardLeftPanel","click",this._delegateClickEvent,this,true);Event.addListener(this.scrollUp,"mousedown",this._scrollUpHandler,this,false);Event.addListener(this.scrollDown,"mousedown",this._scrollDownHandler,this,false);Event.addListener(this.scrollUp,"mouseup",this._stopScrollUp,this,true);Event.addListener(this.scrollDown,"mouseup",this._stopScrollDown,this,true);Event.addListener(this.scrollUp,"mouseout",this._stopScrollUp,this,true);Event.addListener(this.scrollDown,"mouseout",this._stopScrollDown,this,true);var searchListContainer=Dom.get(this.searchListContainer);if(searchListContainer.addEventListener){searchListContainer.addEventListener('DOMMouseScroll',this._onMouseWheel,this,false);searchListContainer.addEventListener('mousewheel',this._onMouseWheel,this,false);}
else if(searchListContainer.attachEvent){searchListContainer.attachEvent('onmousewheel',this._onMouseWheel,this,false);}
var addressField=Dom.get(this.searchField);var resetButton=Dom.get(this.resetBtn);var searchHint=this.searchHint;var that=this;var onBlurAddressField=function(event){var text=addressField.value;if(text!=null&&text!=''&&text!=searchHint){resetButton.style.display="block";addressField.style.width="200px";}else{addressField.value=searchHint;}}
var onFocusAddressField=function(event){if(addressField.value==searchHint){addressField.value="";}}
var forceSearchMap=function(event){event=event?event:window.event;if(event.keyCode==13){resetButton.style.display="block";that.gs.execute(addressField.value);}}
Event.addListener(addressField,"keypress",forceSearchMap);Event.addListener(addressField,"blur",onBlurAddressField);Event.addListener(addressField,"focus",onFocusAddressField);this.gs=CLIPTOO.poi.map.types.getCurrentLocalSearch(WidgetWizard.prototype.searchComplete,this);var that=this;Event.addListener(this.frameId,"load",function(){var win=Dom.get(that.frameId).contentWindow;win.POIWidget.components.page.afterLoad=function(){that.initNextStep();popupHandler.hidePleaseWait();};});};WidgetWizard.prototype.initNextStep=function(){this.steps[this.currentStep].init();this.steps[this.currentStep].title.innerHTML=this.currentStep+1;this.steps[this.currentStep].countTitle.innerHTML=this.steps.length;this.steps[this.currentStep].el.style.display="block";this.navigationButtons();popupHandler.hidePleaseWait();};WidgetWizard.prototype._delegateClickEvent=function(ev){var obj=ev.target?ev.target:ev.srcElement;var addressField=Dom.get(this.searchField);var resetButton=Dom.get(this.resetBtn);if(obj.className==="widget-wizard-reset-btn"){addressField.value="";addressField.focus();resetButton.style.display="none";addressField.style.width="210px";Dom.get(this.searchListScroll).style.display="none";Dom.get(this.nothingFoundHint).style.display="none";Dom.get(this.resultHint).style.display="none";Dom.get(this.scrollDown).style.visibility="hidden";Dom.get(this.scrollUp).style.visibility="hidden";}
if(obj.nodeName==="ADDRESS"){var rowId=obj.id;var rowIdNumber=parseInt(rowId);var result=this.gs.results[rowIdNumber];var address=result.addressLines.join(", ");this.actionAfterSearch(address);}
while(obj.id!=="widgetWizardButtonsPrevious"&&obj.id!=="widgetWizardButtonsNext"&&obj.id!=="get_widget_popup"){obj=obj.parentNode;}
if(obj.id==="widgetWizardButtonsPrevious"){this.goPreviousStep()}
if(obj.id==="widgetWizardButtonsNext"){this.goNextStep()}};WidgetWizard.prototype._initSteps=function(){this.steps=[];if(!ctx.getCurrentUserUid()){this.steps[this.steps.length]={parent:this,stepIndex:this.steps.length,el:Dom.get("widgetWizardStep0"),title:Dom.get("widgetWizardStepNumber0"),countTitle:Dom.get("widgetWizardCount0"),init:this.initLoginStep,getData:this.getMapData,revert:this.revertLoginStep};}
this.steps[this.steps.length]={parent:this,stepIndex:this.steps.length,el:Dom.get("widgetWizardStep4"),title:Dom.get("widgetWizardStepNumber4"),countTitle:Dom.get("widgetWizardCount4"),init:this.initSizeStep,getData:this.getSizeData,revert:this.revertSizeStep,cback:this.updateWidgetConfig};this.steps[this.steps.length]={parent:this,stepIndex:this.steps.length,el:Dom.get("widgetWizardStep2"),title:Dom.get("widgetWizardStepNumber2"),countTitle:Dom.get("widgetWizardCount2"),init:this.initCategoriesStep,getData:this.getCategoriesData,revert:this.revertCategoriesStep,cback:this.updateWidgetConfig};if(ctx.getCurrentUserUid()){this.steps[this.steps.length]={parent:this,stepIndex:this.steps.length,el:Dom.get("widgetWizardStep3"),title:Dom.get("widgetWizardStepNumber3"),countTitle:Dom.get("widgetWizardCount3"),init:this.initOwnPoisStep,getData:this.getOwnPoisData,revert:this.revertOwnPoisStep,cback:this.saveOwnPoisIds};}
this.steps[this.steps.length]={parent:this,stepIndex:this.steps.length,el:Dom.get("widgetWizardStep1"),title:Dom.get("widgetWizardStepNumber1"),countTitle:Dom.get("widgetWizardCount1"),init:this.initMapStep,getData:this.getMapData,revert:this.revertMapStep};if(ctx.getCurrentUserUid()){this.steps[this.steps.length]={parent:this,stepIndex:this.steps.length,el:Dom.get("widgetWizardStep5"),title:Dom.get("widgetWizardStepNumber5"),countTitle:Dom.get("widgetWizardCount5"),init:this.initLogoStep,getData:this.getLogoData,revert:this.revertLogoStep};}
this.steps[this.steps.length]={parent:this,stepIndex:this.steps.length,el:Dom.get("widgetWizardStep6"),title:Dom.get("widgetWizardStepNumber6"),countTitle:Dom.get("widgetWizardCount6"),init:this.initGetCodeStep,getData:this.getGetCodeData,revert:this.revertGetCodeStep};this.currentStep=0;this.steps[this.currentStep].title.innerHTML=this.currentStep+1;this.steps[this.currentStep].countTitle.innerHTML=this.steps.length;this.steps[this.currentStep].el.style.display="block";};WidgetWizard.prototype.initWizard=function(){popupHandler.createGetWidgetPopup(this.htmlForLoggedInUser,this.i18n.getWidget());this.attachHandlers();this._initSteps();this.steps[this.currentStep].init();this.navigationButtons();};WidgetWizard.prototype.navigationButtons=function(){var previous=Dom.get("widgetWizardButtonsPrevious");var next=Dom.get("widgetWizardButtonsNext");if(this.currentStep!=0){previous.style.display="block";}else{previous.style.display="none";}
if(this.currentStep!=(this.steps.length-1)){next.style.display="block";}else{next.style.display="none";}};WidgetWizard.prototype.goToFirstStep=function(newHash){this.clearAllData();this.hash=newHash;Dom.get(this.searchField).value=this.searchHint;Dom.get(this.resetBtn).style.display="none";Dom.get(this.searchListScroll).style.display="none";Dom.get(this.nothingFoundHint).style.display="none";Dom.get(this.resultHint).style.display="none";Dom.get(this.scrollDown).style.visibility="hidden";Dom.get(this.scrollUp).style.visibility="hidden";this.steps[this.currentStep].revert();this.steps[this.currentStep].el.style.display="none";this.currentStep=0;this.steps[this.currentStep].init();this.steps[this.currentStep].el.style.display="block";this.navigationButtons();Dom.get(this.frameId).parentNode.innerHTML='<iframe scrolling="no" height="400" frameborder="0" width="520" id="'+this.frameId+'" class="frameForWidget" src="'+this.domain+'/poiwidget/conf/loadStandalone.action?id='+this.hash+'&amp;lng=nl&pw=t"></iframe>';Dom.get(this.loginFrame).innerHTML='<iframe src="/auth/?frame=true&wizard=true&lang='+this.language+'" frameborder="0" style="width: 245px; height: '+this.currentLngFrameSize+'; z-index: 114748367;"></iframe>';};WidgetWizard.prototype.goPreviousStep=function(){if(this.currentStep==0){return;}
this.steps[this.currentStep].revert();this.steps[this.currentStep].el.style.display="none";this.currentStep--;this.steps[this.currentStep].init();this.steps[this.currentStep].el.style.display="block";this.navigationButtons();};WidgetWizard.prototype.goNextStep=function(){if(this.currentStep==(this.steps.length-1)){return;}
this.steps[this.currentStep].getData();this.steps[this.currentStep].el.style.display="none";this.currentStep++;popupHandler.showPleaseWait();if(this.steps[this.currentStep-1].cback){this.steps[this.currentStep-1].cback();}else{this.prepareDataForUrl();}};WidgetWizard.prototype.activateTab=function(elementClassName){var win=Dom.get(this.frameId).contentWindow;var confDialog=win.POIWidget.components.page.configDialog;confDialog.show();confDialog.showTab(elementClassName);};WidgetWizard.prototype.initLoginStep=function(){Dom.get(this.parent.loginFrame).innerHTML='<iframe id="widgetWizardFrameId" src="/auth/?frame=true&wizard=true&lang='+this.parent.language+'" frameborder="0" style="width: 245px; height: '+this.parent.currentLngFrameSize+'; z-index: 114748367;"></iframe>';};WidgetWizard.prototype.getLoginData=function(){};WidgetWizard.prototype.revertLoginStep=function(){};WidgetWizard.prototype.initMapStep=function(){var win=Dom.get(this.parent.frameId).contentWindow;var confDialog=win.POIWidget.components.page.configDialog;confDialog.hide();};WidgetWizard.prototype.getMapData=function(){var win=Dom.get(this.parent.frameId).contentWindow;var map=win.POIWidget.Context.gmap;var southWest=new GLatLng(map.getBounds().getSouthWest().lat(),map.getBounds().getSouthWest().lng());var northEast=new GLatLng(map.getBounds().getNorthEast().lat(),map.getBounds().getNorthEast().lng());var latLngBounds=new GLatLngBounds(southWest,northEast);this.parent.mapBoundsAndZoom[0]=latLngBounds;};WidgetWizard.prototype.revertMapStep=function(){};WidgetWizard.prototype.initCategoriesStep=function(){this.parent.activateTab("category-menu-tab");};WidgetWizard.prototype.getCategoriesData=function(){var win=Dom.get(this.parent.frameId).contentWindow;var catContainer=win.Dom.get("configCategoryContainer");var selectedCatsEls=win.Dom.getElementsByClassName("selected","div",catContainer);var availableCatsEls=win.Dom.getElementsByClassName("available","div",catContainer);this.parent.selectedCatsIds=[];var size=selectedCatsEls.length;for(var i=0;i<size;i++){this.parent.selectedCatsIds[i]=win.Dom.getPreviousSibling(selectedCatsEls[i]).value;}
this.parent.availableCatsIds=[];size=availableCatsEls.length;for(var i=0;i<size;i++){this.parent.availableCatsIds[i]=win.Dom.getPreviousSibling(availableCatsEls[i]).value;}
var groupsEls=win.Dom.getElementsByClassName("categoryGroupContainer","div",catContainer);this.parent.groupsOrder=[];size=groupsEls.length;for(var i=0;i<size;i++){this.parent.groupsOrder[i]=parseInt(groupsEls[i].id.substring(14,groupsEls[i].id.length));}};WidgetWizard.prototype.revertCategoriesStep=function(){var win=Dom.get(this.parent.frameId).contentWindow;win.POIWidget.components.page.configDialog.hide();};WidgetWizard.prototype.initSizeStep=function(){var win=Dom.get(this.parent.frameId).contentWindow;if(!win.POIWidget){return;}
if(win.POIWidget.components.page.configDialog){win.POIWidget.components.page.configDialog.hide();}
Dom.get("widgetWizardSizeContainer").innerHTML=this.parent.sizeStepString;if(this.parent.widthHeightLng[0]){Dom.get("widgetWizardWidth").value=this.parent.widthHeightLng[0];}
if(this.parent.widthHeightLng[1]){Dom.get("widgetWizardHeight").value=this.parent.widthHeightLng[1];}
var map=win.POIWidget.Context.gmap;var southWest=new GLatLng(map.getBounds().getSouthWest().lat(),map.getBounds().getSouthWest().lng());var northEast=new GLatLng(map.getBounds().getNorthEast().lat(),map.getBounds().getNorthEast().lng());var latLngBounds=new GLatLngBounds(southWest,northEast);this.parent.mapBoundsAndZoom[0]=latLngBounds;var bound=this.parent.mapBoundsAndZoom[0];var minPoint=bound.getSouthWest();var minLat=minPoint.lat();var minLng=minPoint.lng();var maxPoint=bound.getNorthEast();var maxLat=maxPoint.lat();var maxLng=maxPoint.lng();var params='';if(!isNaN(minLat)||!isNaN(minLng)||!isNaN(maxLat)||!isNaN(maxLng)){params='minLat='+minLat+'&minLng='+minLng+'&maxLat='+maxLat+'&maxLng='+maxLng;}
popupHandler.showPleaseWait();var that=this.parent;if(params){UIRequest("returnAllLayersByCoordinatBound.action",params,function(result){var json=YAHOO.lang.JSON.parse(result.responseText);if(json.layers.length>0){that.buildLayerList(json.layers);Dom.get(that.layerSelectorContainer).style.display="block";}else{Dom.get(that.layerSelectorContainer).style.display="none";}
popupHandler.hidePleaseWait();});}};WidgetWizard.prototype.getSizeData=function(){this.parent.widthHeightLng[0]=Dom.get("widgetWizardWidth").value;this.parent.widthHeightLng[1]=Dom.get("widgetWizardHeight").value;this.parent.layerId=Dom.get(this.parent.layerSelector).value;};WidgetWizard.prototype.revertSizeStep=function(){};WidgetWizard.prototype.buildLayerList=function(layers){var selectElement=Dom.get(this.layerSelector);var optionsLength=selectElement.options.length;for(var j=optionsLength-1;j>=0;j--){selectElement.remove(j);}
if(layers){var n=layers.length+1;var option=document.createElement('OPTION');selectElement.options.add(option);option.innerHTML="";option.value=0;selectElement.selectedIndex=0;for(var i=1;i<n;i++){var option=document.createElement('OPTION');selectElement.options.add(option);option.innerHTML=layers[i-1].title;option.value=layers[i-1].id;if(this.layerId&&option.value==this.layerId){option.selected=true;}}}};WidgetWizard.prototype.initOwnPoisStep=function(){var win=Dom.get(this.parent.frameId).contentWindow;var confDialog=win.POIWidget.components.page.configDialog;this.parent.activateTab("ownPois-menu-tab");};WidgetWizard.prototype.getOwnPoisData=function(){this.parent.ownPoisIds=[];this.parent.deletedOwnPoisIds=[];var win=Dom.get(this.parent.frameId).contentWindow;var selectedPois=win.POIWidget.components.page.configDialog.ownPoiPicker.returnSelectedPois();for(var index in selectedPois){this.parent.ownPoisIds[this.parent.ownPoisIds.length]=selectedPois[index];}
var unSelectedPois=win.POIWidget.components.page.configDialog.ownPoiPicker.returnUnSelectedPois();for(var index in unSelectedPois){this.parent.deletedOwnPoisIds[this.parent.deletedOwnPoisIds.length]=unSelectedPois[index];}};WidgetWizard.prototype.revertOwnPoisStep=function(){var win=Dom.get(this.parent.frameId).contentWindow;win.POIWidget.components.page.configDialog.hide();};WidgetWizard.prototype.saveOwnPoisIds=function(){var ownPoiIdsStr=this.parent.ownPoisIds.join(',');var deletedOwnPoiIdsStr=this.parent.deletedOwnPoisIds.join(',');var that=this;var params='hash='+this.parent.hash+'&ownPoiIds='+ownPoiIdsStr+'&deletedOwnPoiIds='+deletedOwnPoiIdsStr;UIRequest("saveOwnsPois.action",params,function(data){that.parent.prepareDataForUrl();var win=Dom.get(that.parent.frameId).contentWindow;var seq=win.POIWidget.components.page.configDialog.categoryPicker.getGroupSeq();win.POIWidget.utils.reloadConfig(seq.available,seq.selected,seq.groupSeq);popupHandler.hidePleaseWait();});};WidgetWizard.prototype.initGetCodeStep=function(){var win=Dom.get(this.parent.frameId).contentWindow;var minPoint=this.parent.mapBoundsAndZoom[0].getSouthWest();var minLat=minPoint.lat();var minLng=minPoint.lng();var maxPoint=this.parent.mapBoundsAndZoom[0].getNorthEast();var maxLat=maxPoint.lat();var maxLng=maxPoint.lng();var params1='id='+this.parent.hash+'&w='+this.parent.widthHeightLng[0]+'&h='+this.parent.widthHeightLng[1]+'&lng=nl';var params2='&minLat='+minLat+'&minLon='+minLng+'&maxLat='+maxLat+'&maxLon='+maxLng;var params3_0='&catsIds=';var params3_1=this.parent.selectedCatsIds.join("%2B,");var params3_2=this.parent.availableCatsIds.join(",");params3_1=(params3_1&&params3_1!="")?params3_1+"%2B":params3_1;params3_2=(params3_1&&params3_1!="")?","+params3_2:params3_2;var params3=params3_0+params3_1+params3_2;if(params3==='&catsIds='){params3='';}
var params4='&groupsOrder='+this.parent.groupsOrder.join(",");var params5=(this.parent.layerId)?'&layer='+this.parent.layerId:'';if(this.parent.hash!="default"){var params=params1+params2+params3+params4+params5;popupHandler.showPleaseWait();var that=this;UIRequest("saveUserWidgetEmbeddedCode.action",params,function(data){var json=YAHOO.lang.JSON.parse(data.responseText);var getWidgetLink='<script type="text/javascript" src="'+that.parent.domain+'/poiwidget/conf/load.action?id='+json.hash+'"></script>';Dom.get("WidgetWizardTexarea").value=getWidgetLink;popupHandler.hidePleaseWait();});}else{var allParams=params1+params2+params3+params4+params5;var getWidgetLink='<script type="text/javascript" src="'+this.parent.domain+'/poiwidget/conf/load.action?'+allParams+'&p=t&pw=t"></script>';Dom.get("WidgetWizardTexarea").value=getWidgetLink;}};WidgetWizard.prototype.getGetCodeData=function(){};WidgetWizard.prototype.revertGetCodeStep=function(){Dom.get("WidgetWizardTexarea").value="";};WidgetWizard.prototype.updateWidgetConfig=function(){var that=null;if(this.parent){that=this.parent;}else{that=this;}
var win=Dom.get(that.frameId).contentWindow;var config=win.POIWidget.Context.config;if(that.mapBoundsAndZoom&&that.mapBoundsAndZoom.length>0){var bound=that.mapBoundsAndZoom[0];var minPoint=bound.getSouthWest();var minLat=minPoint.lat();var minLng=minPoint.lng();var maxPoint=bound.getNorthEast();var maxLat=maxPoint.lat();var maxLng=maxPoint.lng();}
that.resultObject.sizeLanguage="";if(that.widthHeightLng&&that.widthHeightLng.length>0){that.resultObject.sizeLanguage='&w='+that.widthHeightLng[0]+'&h='+that.widthHeightLng[1]+'&lng=nl';}
that.resultObject.mapBounds="";if(that.mapBoundsAndZoom&&that.mapBoundsAndZoom.length>0){that.resultObject.mapBounds='&minLat='+minLat+'&minLon='+minLng+'&maxLat='+maxLat+'&maxLon='+maxLng;}
var params3_0='&catsIds=';var params3_1=that.selectedCatsIds.join("%2B,");var params3_2=that.availableCatsIds.join(",");params3_1=(params3_1&&params3_1!="")?params3_1+"%2B":params3_1;params3_2=(params3_1&&params3_1!="")?","+params3_2:params3_2;if(params3_1==""&&params3_2==""){that.resultObject.catsIds="";}else{that.resultObject.catsIds=params3_0+params3_1+params3_2;}
if(that.groupsOrder.length>0){that.resultObject.groupsOrder='&groupsOrder='+that.groupsOrder.join(",");}
if(that.layerId!=""){that.resultObject.layerId='&layer='+that.layerId;}
if(win.POIWidget.components.page.configDialog.categoryPicker){var seq=win.POIWidget.components.page.configDialog.categoryPicker.getGroupSeq();win.POIWidget.utils.reloadConfig(seq.available,seq.selected,seq.groupSeq);}
that.initNextStep();};WidgetWizard.prototype.reloadIFrame=function(){this.parent.updateWidgetConfig();var str=this.parent.domain+'/poiwidget/conf/loadStandalone.action?id='+this.parent.hash+''
+this.parent.resultObject.sizeLanguage+this.parent.resultObject.mapBounds+this.parent.resultObject.catsIds+this.parent.resultObject.groupsOrder+this.parent.resultObject.ownPoiIds+this.parent.resultObject.layerId+"&p=t&pw=t";var frame=Dom.get(this.parent.frameId);popupHandler.showPleaseWait();frame.src=str;};WidgetWizard.prototype.prepareDataForUrl=function(){var win=Dom.get(this.frameId).contentWindow;var config=win.POIWidget.Context.config;if(this.logoLink!=""){config.logoLink=this.logoLink;}
this.initNextStep();popupHandler.hidePleaseWait();};WidgetWizard.prototype.initLogoStep=function(){var win=Dom.get(this.parent.frameId).contentWindow;var confDialog=win.POIWidget.components.page.configDialog;this.parent.activateTab("logo-menu-tab");};WidgetWizard.prototype.getLogoData=function(){};WidgetWizard.prototype.revertLogoStep=function(){var win=Dom.get(this.parent.frameId).contentWindow;win.POIWidget.components.page.configDialog.hide();};WidgetWizard.prototype._scrollSearchListDown=function(scroller){this._stopScrollUp();var wizardScroll=Dom.get(this.searchListScroll);var marginTop=parseInt(wizardScroll.style.marginTop);marginTop=marginTop-3;if(marginTop<wizardScroll.parentNode.offsetHeight-wizardScroll.offsetHeight){marginTop=wizardScroll.parentNode.offsetHeight-wizardScroll.offsetHeight;scroller.style.visibility="hidden";this._stopScrollDown();}
wizardScroll.style.marginTop=marginTop+"px";};WidgetWizard.prototype._scrollSearchListUp=function(scroller){this._stopScrollDown();var wizardScroll=Dom.get(this.searchListScroll);var marginTop=parseInt(wizardScroll.style.marginTop);marginTop=marginTop+3;if(marginTop>0){marginTop=0;scroller.style.visibility="hidden";this._stopScrollUp();}
wizardScroll.style.marginTop=marginTop+"px";};WidgetWizard.prototype._scrollDownHandler=function(ev,viewBalloon){if(viewBalloon.mouseDown==null||typeof viewBalloon.mouseDown=="undefined"){var scroller=this;viewBalloon._scrollSearchListDown(scroller);Dom.get(viewBalloon.scrollUp).style.visibility="visible";viewBalloon.mouseDown=setInterval(function(){viewBalloon._scrollSearchListDown(scroller);},8);}};WidgetWizard.prototype._scrollUpHandler=function(ev,viewBalloon){if(viewBalloon.mouseUp==null||typeof viewBalloon.mouseUp=="undefined"){var scroller=this;viewBalloon._scrollSearchListUp(scroller);Dom.get(viewBalloon.scrollDown).style.visibility="visible";viewBalloon.mouseUp=setInterval(function(){viewBalloon._scrollSearchListUp(scroller);},8);}};WidgetWizard.prototype._stopScrollUp=function(){if(this.mouseUp){clearInterval(this.mouseUp);this.mouseUp=null;}};WidgetWizard.prototype._stopScrollDown=function(){if(this.mouseDown){clearInterval(this.mouseDown);this.mouseDown=null;}};WidgetWizard.prototype._onMouseWheel=function(ev){var wizardScroll=Dom.get("wizardSearchListScroll");if(wizardScroll.parentNode.offsetHeight>wizardScroll.offsetHeight){return;}
var scrolledUp=(ev.type=="DOMMouseScroll"&&ev.detail<0)||(ev.type=="mousewheel"&&ev.wheelDelta>0);var marginTop=parseInt(wizardScroll.style.marginTop);if(scrolledUp){marginTop=marginTop+12;var scroller=Dom.get("wizardSearchListDown");scroller.style.visibility="visible";if(marginTop>0){marginTop=0;var scroller=Dom.get("wizardSearchListUp");scroller.style.visibility="hidden";}}else{marginTop=marginTop-12;var scroller=Dom.get("wizardSearchListUp");scroller.style.visibility="visible";if(marginTop<wizardScroll.parentNode.offsetHeight-wizardScroll.offsetHeight){marginTop=wizardScroll.parentNode.offsetHeight-wizardScroll.offsetHeight;var scroller=Dom.get("wizardSearchListDown");scroller.style.visibility="hidden";}}
wizardScroll.style.marginTop=marginTop+"px";Event.stopEvent(ev);};WidgetWizard.prototype.actionAfterSearch=function(address){popupHandler.showPleaseWait();var callBack=function(bounds){if(!bounds){popupHandler.hidePleaseWait();return;}
var win=Dom.get("widgetframedefault").contentWindow;if(bounds){var llbounds=new win.GLatLngBounds(new win.GLatLng(bounds.south,bounds.west),new win.GLatLng(bounds.north,bounds.east));var map=win.POIWidget.Context.gmap;var bestZoom=map.getZoomLevelForBounds(llbounds);if(map.getCenter()!=llbounds.getCenter()||map.getZoom()!=bestZoom){map.setCenter(llbounds.getCenter(),bestZoom);}
popupHandler.hidePleaseWait();}}
CLIPTOO.poi.map.types.getLocations(address,callBack,this);};WidgetWizard.prototype.searchComplete=function(){var resultList=Dom.get(this.searchListScroll);var nothingFoundHint=Dom.get(this.nothingFoundHint);var resultHint=Dom.get(this.resultHint);var results=this.gs.results;resultList.style.display="none";resultHint.style.display="none";Dom.get(this.scrollDown).style.visibility="hidden";if(results.length==0){nothingFoundHint.style.display="";}else{nothingFoundHint.style.display="none";}
if(results.length==1){this.actionAfterSearch(results[0]);}
if(results.length>1){resultHint.style.display="";resultList.style.display="";nothingFoundHint.style.display="none";resultList.innerHTML="";resultList.style.marginTop="0px";for(var i=0;i<results.length;i++){var address=results[i].addressLines.join(", ");var link=document.createElement("address");link.innerHTML=address;link.id=i+"_widget_address_row";resultList.appendChild(link);}
if(resultList.parentNode.offsetHeight<resultList.offsetHeight){Dom.get(this.scrollDown).style.visibility="visible";}}};(function(){var i18n=PoiMsg.js_msg;var createDomElement=function(tagName,className){var el=document.createElement(tagName);el.className=className||"";return el;}
var INFO_REQUEST_LINK_ID="formLinkInfoRequest";CLIPTOO.InfoRequest=function(){this.mailPopup=null;this._createMailDom();}
CLIPTOO.InfoRequest.prototype._createMailDom=function(){if(this.mailPopup){return;}
var htmlContent='<div class="info-request-content"> \
     <div class="send-email-header-container"> \
      <div class="send-email-header">'+i18n.inforequest.header()+'</div> \
      <div class="send-email-cross" id="sendInfo-cross"></div> \
     </div> \
     <div class="info-request-form-container"> \
      <form id="'+INFO_REQUEST_LINK_ID+'"> \
       <input type="hidden" id="infoPoiLink" name="poiLink" class="info-input info-elements"> \
       <input type="hidden" name="email" id="poiEmail"> \
       <div class="info-request-input-container">\
       <div class="send-email-details">'+i18n.yourName()+'<span class="mandatory-star">'+i18n.poi.list.sendToAFriend.mandatoryStar()+'</span> \
       </div> \
       <input type="text" name="userName" class="info-input info-elements"> \
       <div class="send-email-details">'+i18n.yourEmail()+'<span class="mandatory-star">'+i18n.poi.list.sendToAFriend.mandatoryStar()+'</span> \
       </div> \
       <input type="text" name="userEmail" class="info-input info-elements"> \
       </div> \
       <div class="send-email-message"> '+i18n.text()+'<span class="mandatory-star">'+i18n.poi.list.sendToAFriend.mandatoryStar()+'</span> \
       </div> \
       <textarea cols="30" name="text" class="send-email-textarea info-elements"></textarea> \
        <a id="send-button" class="ovalbutton"><span>'+i18n.send()+'</span></a> \
      </form> \
     </div> \
    </div> \
    <div class="send-email-shadow" id="infoRequestShadow"></div>';var mailOverlay=new YAHOO.widget.Overlay("info-request-container",{modal:true,visible:false,draggable:true,effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.25}});mailOverlay.setBody(htmlContent);mailOverlay.render("popup_holder");mailOverlay.element.style.top="";mailOverlay.element.style.left="";if(THEME_NAME=="chamber"){mailOverlay.cfg.setProperty("xy",CLIPTOO.utils.centerChamberPopups(380,291));}else{mailOverlay.cfg.setProperty("fixedcenter",true);}
Event.addListener("info-request-container","click",this.delegateClickEvent,this,true);this.mailPopup=mailOverlay;}
CLIPTOO.InfoRequest.prototype.delegateClickEvent=function(ev,infoRequest){var target=ev.target?ev.target:ev.srcElement;if(target.className==="send-email-cross"){infoRequest.cancelSending();}
else if(target.tagName=="A"||target.parentNode.tagName=="A"){infoRequest.send();}
Event.preventDefault(ev);Event.stopPropagation(ev);}
CLIPTOO.InfoRequest.prototype.attachMailListener=function(divLinkSendToAFriendIcon,rowIndex){Event.addListener(divLinkSendToAFriendIcon,"click",function(ev,p_oMailOverlay){if(p_oMailOverlay.isShown){return;}
if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/view_balloon/send_info_mail");}
var poi={};poi.id=rowIndex;document.getElementById("infoPoiLink").value=poi.id;document.getElementById("poiEmail").value=document.getElementById("poiEmailSpan").innerHTML;p_oMailOverlay.element.style.visibility="hidden";var linkBounds=null;var shadow=Dom.get('infoRequestShadow');if(shadow){shadow.style.display='block';}
p_oMailOverlay.show();p_oMailOverlay.isShown=true;var inputs=Dom.get(INFO_REQUEST_LINK_ID).getElementsByTagName("input");for(var i=0,n=inputs.length;i<n;i++){if(inputs[i].type=="text"){inputs[i].focus();break;}}},this.mailPopup,true);}
CLIPTOO.InfoRequest.prototype.send=function(){var form=Dom.get(INFO_REQUEST_LINK_ID);if(form!=null&&validator.validateNamesBlock(form,"infoRequestBlock")){popupHandler.showPleaseWait();var textarea=form.getElementsByTagName("textarea")[0];var msgNoHtml=textarea.value.replace(/(<|>)/g,function(strMatch,p1){return(p1=="<")?"&lt;":"&gt;";});textarea.value=msgNoHtml.replace(/\n/g,"<br/>");FormSubmit(INFO_REQUEST_LINK_ID,"mailAction!sendInfoRequest.action",this.onSuccessClickSaveButtonInfoRequest,this);}}
CLIPTOO.InfoRequest.prototype.resetFormFields=function(){var form=Dom.get(INFO_REQUEST_LINK_ID);var inputs=form.getElementsByTagName("input");for(var i=0,n=inputs.length;i<n;i++){if(inputs[i].type=="text"){inputs[i].value="";}}
var textareas=form.getElementsByTagName("textarea");for(var i=0,n=textareas.length;i<n;i++){textareas[i].value="";}}
CLIPTOO.InfoRequest.prototype.cancelSending=function(){this.resetFormFields();this.hideForm();var shadow=Dom.get('infoRequestShadow');if(shadow){shadow.style.display='none';}}
CLIPTOO.InfoRequest.prototype.hideForm=function(){this.mailPopup.hide();this.mailPopup.isShown=false;}
CLIPTOO.InfoRequest.prototype.onSuccessClickSaveButtonInfoRequest=function(object){var infoRequest=object.argument;infoRequest.resetFormFields();infoRequest.hideForm();var shadow=Dom.get('infoRequestShadow');if(shadow){shadow.style.display='none';}
popupHandler.hidePleaseWait();popupHandler.showInformationPopup(PoiMsg.js_msg.balloon.infoRequest.dialogMessage(),function(){this.hide();});}
CLIPTOO.InfoRequest.prototype.destroy=function(){this.mailPopup.destroy();this.mailPopup=null;}})();(function(){var i18n=PoiMsg.js_msg;var createDomElement=function(tagName,className){var el=document.createElement(tagName);el.className=className||"";return el;}
var SEND_TO_FRIEND_LINK_ID="formLinkSendToAFriendId";YAHOO.SendToFriend=function(){this.mailPopup=null;this._createMailDom();}
YAHOO.SendToFriend.prototype._createMailDom=function(){if(this.mailPopup){return;}
var htmlContent='<div class="sendToAFriend-content"> \
     <div class="send-email-header-container"> \
      <div class="send-email-header">'+i18n.header()+'</div> \
      <div class="send-email-cross" id="sendToAFriend-cross"></div> \
     </div> \
     <div class="sendToAFriend-form-container"> \
      <form id="'+SEND_TO_FRIEND_LINK_ID+'"> \
       <input type="hidden" id="stfPoiLink" name="poiLink"> \
       <div class="send-to-friend-input-container">\
       <div class="send-email-details">'+i18n.email()+'<span class="mandatory-star">'+i18n.poi.list.sendToAFriend.mandatoryStar()+'</span> \
       </div> \
       <input type="text" name="email"> \
       <div class="send-email-details">'+i18n.yourName()+'<span class="mandatory-star">'+i18n.poi.list.sendToAFriend.mandatoryStar()+'</span> \
       </div> \
       <input type="text" name="userName"> \
       <div class="send-email-details">'+i18n.yourEmail()+'<span class="mandatory-star">'+i18n.poi.list.sendToAFriend.mandatoryStar()+'</span> \
       </div> \
       <input type="text" name="userEmail"> \
       </div> \
       <div class="send-email-message"> '+i18n.text()+'<span class="mandatory-star">'+i18n.poi.list.sendToAFriend.mandatoryStar()+'</span> \
       </div> \
       <textarea class="send-email-textarea" cols="30" name="text"></textarea> \
        <a id="send-button" class="ovalbutton"><span>'+i18n.send()+'</span></a> \
      </form> \
     </div> \
    </div> \
    <div class="send-email-shadow" id="sendToAFriend-shadow"></div>';var mailOverlay=new YAHOO.widget.Overlay("sendToAFriend-container",{modal:true,visible:false,draggable:true,effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.25}});mailOverlay.setBody(htmlContent);mailOverlay.render("popup_holder");mailOverlay.element.style.top="";mailOverlay.element.style.left="";if(THEME_NAME=="chamber"){mailOverlay.cfg.setProperty("xy",CLIPTOO.utils.centerChamberPopups(380,322));}else{mailOverlay.cfg.setProperty("fixedcenter",true);}
Event.addListener("sendToAFriend-container","click",this.delegateClickEvent,this,true);this.mailPopup=mailOverlay;}
YAHOO.SendToFriend.prototype.delegateClickEvent=function(ev,sendToFriend){var target=ev.target?ev.target:ev.srcElement;if(target.className==="send-email-cross"){sendToFriend.cancelSending();}
else if(target.tagName=="A"||target.parentNode.tagName=="A"){sendToFriend.send();}
Event.preventDefault(ev);Event.stopPropagation(ev);}
YAHOO.SendToFriend.prototype.attachMailListener=function(divLinkSendToAFriendIcon,rowIndex){Event.addListener(divLinkSendToAFriendIcon,"click",function(ev,p_oMailOverlay){if(p_oMailOverlay.isShown){return;}
if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/view_balloon/send_to_friend_mail");}
var poi={};poi.id=rowIndex;var currentLocation=window.location;document.getElementById("stfPoiLink").value=currentLocation.protocol+"//"+currentLocation.host+"/?poi="+poi.id;p_oMailOverlay.element.style.visibility="hidden";var linkBounds=null;var shadow=Dom.get('sendToAFriend-shadow');if(shadow){shadow.style.display='block';}
p_oMailOverlay.show();p_oMailOverlay.isShown=true;var inputs=Dom.get(SEND_TO_FRIEND_LINK_ID).getElementsByTagName("input");for(var i=0,n=inputs.length;i<n;i++){if(inputs[i].type=="text"){inputs[i].focus();break;}}},this.mailPopup,true);}
YAHOO.SendToFriend.prototype.send=function(){var form=Dom.get(SEND_TO_FRIEND_LINK_ID);if(form!=null&&validator.validateNamesBlock(form,"sendToFriendBlock")){popupHandler.showPleaseWait();var textarea=form.getElementsByTagName("textarea")[0];var msgNoHtml=textarea.value.replace(/(<|>)/g,function(strMatch,p1){return(p1=="<")?"&lt;":"&gt;";});textarea.value=msgNoHtml.replace(/\n/g,"<br/>");FormSubmit(SEND_TO_FRIEND_LINK_ID,"mailAction!sendEmailToAFriend.action",this.onSuccessClickSaveButtonSendToAFriend,this);}}
YAHOO.SendToFriend.prototype.resetSendToAFriendFormFields=function(){var form=Dom.get(SEND_TO_FRIEND_LINK_ID);var inputs=form.getElementsByTagName("input");for(var i=0,n=inputs.length;i<n;i++){if(inputs[i].type=="text"){inputs[i].value="";}}
var textareas=form.getElementsByTagName("textarea");for(var i=0,n=textareas.length;i<n;i++){textareas[i].value="";}}
YAHOO.SendToFriend.prototype.cancelSending=function(){this.resetSendToAFriendFormFields();this.hideForm();var shadow=Dom.get('sendToAFriend-shadow');if(shadow){shadow.style.display='none';}}
YAHOO.SendToFriend.prototype.hideForm=function(){this.mailPopup.hide();this.mailPopup.isShown=false;}
YAHOO.SendToFriend.prototype.onSuccessClickSaveButtonSendToAFriend=function(object){var sendToFriend=object.argument;sendToFriend.resetSendToAFriendFormFields();sendToFriend.hideForm();var shadow=Dom.get('sendToAFriend-shadow');if(shadow){shadow.style.display='none';}
popupHandler.hidePleaseWait();popupHandler.showInformationPopup(PoiMsg.js_msg.balloon.sendToFriend.dialogMessage(),function(){this.hide();});}
YAHOO.SendToFriend.prototype.destroy=function(){this.mailPopup.destroy();this.mailPopup=null;}})();CLIPTOO.createPackage('utils.Resize');(function(){CLIPTOO.utils.Resize={getScreenSize:function(){var w;w=(window.innerWidth?window.innerWidth:(document.documentElement.clientWidth?document.documentElement.clientWidth:document.body.offsetWidth));return w;},setViewType:function(p){this.loadType=p;},getViewType:function(){if(!this.loadType){this.loadType='flex';}
return this.loadType;},loadIndexSwitcher:function(){if((this.loadType=='flex')&&(this.getScreenSize()<=1024)){this.loadIndexIn1024();}else if(this.loadType=='fix'){this.loadIndexIn960();}else if(this.loadType=='bikes'){this.loadBikesIndex();}},loadMyPoiSwitcher:function(){if((this.loadType=='flex')&&(this.getScreenSize()<=1024)){this.resizeMyPoiTo1024or1280('small');}else if((this.loadType=='flex')&&(this.getScreenSize()>1024)){this.resizeMyPoiTo1024or1280('big')}else if(this.loadType=='fix'){this.loadMyPoiIn960();}},resizeIndexSwitcher:function(){if((this.getScreenSize()<=1024)&&(alreadyResized!=1)){alreadyResized=1;this.resizeIndexTo1024();}
if((this.getScreenSize()>1024)&&(alreadyResized==1)){alreadyResized=0;this.resizeIndexTo1280();}},resizeMyPoiSwitcher:function(){if((this.getScreenSize()<=1024)&&(alreadyResized!=1)){alreadyResized=1;this.resizeMyPoiTo1024or1280('small');}
if((this.getScreenSize()>1024)&&(alreadyResized==1)){alreadyResized=0;this.resizeMyPoiTo1024or1280('big');}},loadIndexIn1024:function(){Dom.addClass(Dom.get('global_container'),"global_container_1024");this.loadType='flex';},loadIndexIn960:function(){this.loadType='fix';Dom.addClass(Dom.get('global_container'),"global_container_960");},loadMyPoiIn960:function(){},resizeIndexTo1024:function(){Dom.addClass(Dom.get('global_container'),"global_container_1024");this.loadType='flex';},resizeIndexTo1280:function(){Dom.removeClass(Dom.get('global_container'),"global_container_1024");this.loadType='flex';},resizeMyPoiTo1024or1280:function(resizeType){if(resizeType=="big"){Dom.removeClass(document.body,"mypoi_1024");}else{Dom.addClass(document.body,"mypoi_1024");}
this.loadType='flex';},loadBikesIndex:function(){var closeLeftPanelBtn=Dom.get("map_resizer_left_toolbar");if(closeLeftPanelBtn.className==""){Dom.get("container_pois").style.display="block";}
this.loadType='bikes';}}
if(CLIPTOO.utils.Resize.getScreenSize()<=1024){var alreadyResized=1;}else{var alreadyResized=0;}})();CLIPTOO.Paging=(function(pagingContainerId,ELEMNTS_PER_PAGE,PAGES_COUNT,options){if(ELEMNTS_PER_PAGE==0){return;};var navigationBar=null,pagingContainer=Dom.get(pagingContainerId),pager=null;var _createDomElement=function(tagName,className){var el=document.createElement(tagName);el.className=className;return el;};var _createPagingDOM=function(){pagingContainer.style.display="none";var totalInfo=_createDomElement("div","pg-total");pagingContainer.appendChild(totalInfo);navigationBar=_createDomElement("div","pg-nav-div");pagingContainer.appendChild(navigationBar);var firstPageDiv=_createDomElement("div","pg-first-pas");firstPageDiv.title=PoiMsg.js_msg.paging.first();navigationBar.appendChild(firstPageDiv);var prevPageDiv=_createDomElement("div","pg-prev-pas");prevPageDiv.title=PoiMsg.js_msg.paging.previous();navigationBar.appendChild(prevPageDiv);var pagesDiv=_createDomElement("div","pg-nav");navigationBar.appendChild(pagesDiv);var pages=[];for(var i=0;i<PAGES_COUNT;i++){var pageDiv=_createDomElement("span","pg-page-pas");pageDiv._pageIndex=i;pagesDiv.appendChild(pageDiv);pages.push(pageDiv);}
var nextPageDiv=_createDomElement("div","pg-next-pas");nextPageDiv.title=PoiMsg.js_msg.paging.next();navigationBar.appendChild(nextPageDiv);var lastPageDiv=_createDomElement("div","pg-last-pas");lastPageDiv.title=PoiMsg.js_msg.paging.last();navigationBar.appendChild(lastPageDiv);pager={total:totalInfo,pagesDiv:pagesDiv,first:firstPageDiv,prev:prevPageDiv,pages:pages,next:nextPageDiv,last:lastPageDiv,currentPage:1,lastPage:1};};var _formPagesForPager=function(elementsCount){if(elementsCount<=ELEMNTS_PER_PAGE){_public.hide();return;}
_public.show();var currentPage=pager.currentPage;var startPage=currentPage-Math.floor(PAGES_COUNT/2);var pageCount=getPagesCount(elementsCount);if(startPage+PAGES_COUNT-1>pageCount){startPage=pageCount-PAGES_COUNT+1;}
if(startPage<1){startPage=1;}
var n=pager.pages.length;for(var i=0;i<n;i++){var page=pager.pages[i];var pageNumber=startPage+i;if(pageNumber==currentPage){page.className="pg-current-page";}
else{page.className="pg-page";}
if(pageNumber<pageCount+1){page.innerHTML=pageNumber;page.title=PoiMsg.js_msg.paging.pageNumber(pageNumber);page.style.display="";}
else{page.innerHTML="";page.style.display="none";}}
if(currentPage>2?pager.first.className="pg-first-act":pager.first.className="pg-first-pas");if(currentPage>1?pager.prev.className="pg-prev-act":pager.prev.className="pg-prev-pas");if(currentPage<pageCount?pager.next.className="pg-next-act":pager.next.className="pg-next-pas");if(currentPage<pageCount-1?pager.last.className="pg-last-act":pager.last.className="pg-last-pas");pager.lastPage=pageCount;if(!!options&&options.isShowElementsCount){pager.total.innerHTML=elementsCount+" pois";pager.total.style.display="";}else{pager.total.style.display="none";}};var handlePage=function(pageCellNumber){var pageNumber=parseInt(pager.pages[pageCellNumber].innerHTML);if(pageNumber!=_public.getCurrentPage()){_public.changePageToListener(pageNumber);}};var delegateClickEvent=function(ev){var page=ev.target?ev.target:ev.srcElement;if(page.tagName=="SPAN"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/poi_list_paging/"+page._pageIndex);}
handlePage(page._pageIndex);}
else if(page.className=="pg-first-act"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/poi_list_paging/first_page");}
_public.changePageToListener(1);}
else if(page.className=="pg-prev-act"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/poi_list_paging/previous_page");}
_public.changePageToListener(pager.currentPage-1);}
else if(page.className=="pg-next-act"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/poi_list_paging/next_page");}
_public.changePageToListener(pager.currentPage+1);}
else if(page.className=="pg-last-act"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/poi_list_paging/last_page");}
_public.changePageToListener(pager.lastPage);}}
var getPagesCount=function(elementsCount){return Math.ceil(elementsCount/ELEMNTS_PER_PAGE)}
var _public={show:function(){pagingContainer.style.display="";var separator=Dom.get("poisListSeparatorId");if(separator){Dom.get("poisListSeparatorId").style.display="";}},hide:function(){pagingContainer.style.display="none";var separator=Dom.get("poisListSeparatorId");if(separator){Dom.get("poisListSeparatorId").style.display="none";}},formPagesForPager:_formPagesForPager,getCurrentPage:function(){return pager.currentPage;},setCurrentPage:function(currentPage){pager.currentPage=currentPage;},getPagesCount:getPagesCount};_createPagingDOM();Event.addListener(navigationBar,"click",delegateClickEvent);return _public;});CLIPTOO.createPackage("utils");Dom=YAHOO.util.Dom;Event=YAHOO.util.Event;CLIPTOO.utils.getJSONResponseParameter=function(p_oResponse,p_sParameter){if(!p_oResponse||!YAHOO.lang.isString(p_sParameter)){return null;}
var json=null;if(p_oResponse.responseText){json=YAHOO.lang.JSON.parse(p_oResponse.responseText);}else{json=YAHOO.lang.JSON.parse(p_oResponse);}
return eval("json."+p_sParameter);};CLIPTOO.utils.isFlashPlayerCompatible=function(){var playerVersion=swfobject.getFlashPlayerVersion();if(!playerVersion||playerVersion.major<10){return false;}
return true;};CLIPTOO.utils.setFocusLoop=function(firstElementId,lastElementId){Event.onDOMReady(function(){if(Dom.get(firstElementId).style.display==''){Dom.get(firstElementId).focus();}});Event.addListener(Dom.get(lastElementId),"keydown",function(event){if(event.keyCode==9&&!event.shiftKey){Dom.get(firstElementId).focus();Event.stopEvent(event);}});Event.addListener(Dom.get(firstElementId),"keydown",function(event){if(event.keyCode==9&&event.shiftKey){Dom.get(lastElementId).focus();Event.stopEvent(event);}});};CLIPTOO.utils.tryToSendForm=function(formName,actionName,onSubmit){this.validateForm(formName,function(){popupHandler.showPleaseWait();FormSubmit(formName,actionName,onSubmit);});};CLIPTOO.utils.validateForm=function(formName,onSuccess,onFail){var form=Dom.get(formName);if(validator.validateNamesBlock(form,formName)){if(onSuccess){onSuccess();}}else{if(onFail){onFail();}}};CLIPTOO.utils.createDomElement=function(tagName,className){var result=document.createElement(tagName);result.className=className;return result;};CLIPTOO.utils.appendChildCorrectly=function(container,partOfHTML,isWithoutDiv){var div=document.createElement("div");div.innerHTML=partOfHTML;container.innerHTML='';if(isWithoutDiv){container.appendChild(div.firstChild);}else{container.appendChild(div);}};CLIPTOO.utils.shrinkTextByWidth=function(element,width,maxLength){var text=element.innerHTML;if(text.length>maxLength){text=text.slice(0,maxLength);}
var intWidth=parseInt(width);while((element.offsetWidth>intWidth)&&element.innerHTML!="..."){text=text.slice(0,-1);element.innerHTML=text+"...";}};CLIPTOO.utils.shrinkOneRowTextByWidth=function(element,rowHeight,width,maxLength){var text=element.innerHTML;if(text.length>maxLength){text=text.slice(0,maxLength);}
var intWidth=parseInt(width);var intHeight=parseInt(rowHeight);while((element.offsetHeight>intHeight||element.offsetWidth>intWidth)&&element.innerHTML!="..."){text=text.slice(0,-1);element.innerHTML=text+"...";}
return element.innerHTML;};CLIPTOO.utils.shrinkOneRowTextByWidthHeight=function(element,rowHeight,width,maxLength){var text=element.innerHTML;if(text.length>maxLength){text=text.slice(0,maxLength);}
var intWidth=parseInt(width);var intHeight=parseInt(rowHeight);while(element.offsetHeight>intHeight||element.offsetWidth>intWidth){text=text.slice(0,-1);element.innerHTML=text;}
return element.innerHTML=text;};CLIPTOO.utils.shrinkTwoRowsTextByWidthHeight=function(element,rowHeight,width,maxLength){var text=element.innerHTML;var firstShrinkedLine=CLIPTOO.utils.shrinkOneRowTextByWidthHeight(element,rowHeight,width,maxLength);var isTooLongText=firstShrinkedLine.length<text.length;if(!isTooLongText){return false;};var secondLine=text.substring(firstShrinkedLine.length,text.length);element.innerHTML=secondLine;var secondShrinkedLine=CLIPTOO.utils.shrinkOneRowTextByWidth(element,rowHeight,width,maxLength);var shrinkedText=firstShrinkedLine+"\n"+secondShrinkedLine;element.innerHTML=shrinkedText;return true;};CLIPTOO.utils.shrinkTextByHeigth=function(element,height,maxLength){var text=element.innerHTML;if(text.length>maxLength){text=text.slice(0,maxLength);}
var intHeight=parseInt(height);while(element.offsetHeight>intHeight&&element.innerHTML!="..."){text=text.slice(0,-1);element.innerHTML=text+"...";}};CLIPTOO.utils.converDateToString=function(date){var monthNumbers=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];var result='';var dayNumber=date.getDate();if(dayNumber<=9){result=result+'0'+dayNumber+'-';}
else{result=result+date.getDate()+'-';}
var monthNumber=date.getMonth()+1;if(monthNumber<=9){result=result+'0'+monthNumber+'-';}
else{result=result+monthNumber+'-';}
result=result+date.getFullYear();return result;};CLIPTOO.utils.formatPrice=function(value){var decimal_Separator=PoiMsg.js_msg.decimalSeparator();var thousands_Separator=PoiMsg.js_msg.thousandsSeparator();return YAHOO.util.Number.format(Number(value),{prefix:"",decimalSeparator:decimal_Separator,thousandsSeparator:thousands_Separator,decimalPlaces:2});};CLIPTOO.utils.formatJavaDate=function(javaDate){var year=javaDate.substring(0,4);var month=javaDate.substring(5,7);var day=javaDate.substring(8,10);var hours=javaDate.substring(11,13);var minutes=javaDate.substring(14,16);return PoiMsg.js_msg.date.format().replace(/dd/,day).replace(/MM/,month).replace(/yyyy/,year).replace(/hh/,hours).replace(/mm/,minutes);};CLIPTOO.utils.formatDateFromMS=function(ms){var date=new Date(parseInt(ms));var month=((date.getMonth()<8)?"0":"")+(date.getMonth()+1);var hours=((date.getHours().toString().length==1)?"0":"")+date.getHours();var minutes=((date.getMinutes().toString().length==1)?"0":"")+date.getMinutes();return PoiMsg.js_msg.date.format().replace(/dd/,date.getDate()).replace(/MM/,month).replace(/yyyy/,date.getFullYear()).replace(/hh/,hours).replace(/mm/,minutes);};CLIPTOO.utils.parseStringDate=function(dateString){var day=parseInt(dateString.substring(0,2));if(day==0){day=parseInt(dateString.substring(1,2));}
var month=parseInt(dateString.substring(3,5)-1);var year=parseInt(dateString.substring(6,10));return{day:day,month:month,year:year};};CLIPTOO.utils.getCommercialInfoExpiredDate=function(dateString,numberIntervals){var date=CLIPTOO.utils.parseStringDate(dateString);var startDate=new Date(date.year,date.month,date.day);var expiredDate=new Date(startDate);expiredDate.setMonth(date.month+parseInt(numberIntervals));expiredDate.setDate(date.day);return expiredDate;};CLIPTOO.utils.getCommercialInfoExpiredDateMS=function(dateMS,numberIntervals){var startDate=new Date(dateMS);var expiredDate=startDate;expiredDate.setMonth(expiredDate.getMonth()+parseInt(numberIntervals));return expiredDate;};CLIPTOO.utils.getEndDateByWeeksNumber=function(startDateString,numberOfWeeks){var date=CLIPTOO.utils.parseStringDate(startDateString);var startDate=new Date(date.year,date.month,date.day);var expiredDate=new Date(startDate);expiredDate.setDate(startDate.getDate()+numberOfWeeks*7);return expiredDate;}
CLIPTOO.utils.dateDiffWeeks=function(date_from,date_till){var date=CLIPTOO.utils.parseStringDate(date_from);var date1=new Date(date.year,date.month,date.day);date=CLIPTOO.utils.parseStringDate(date_till);var date2=new Date(date.year,date.month,date.day);var timediff=new Date(Math.abs(date1.getTime()-date2.getTime())).getTime();var weeks=Math.floor(timediff/(1000*60*60*24*7));timediff-=weeks*(1000*60*60*24*7);days=Math.floor(timediff/(1000*60*60*24));if(days==7){weeks+=1;}
if(date2.getTime()-date1.getTime()<0)weeks=0;return weeks;}
CLIPTOO.utils.getNextDay=function(date){var newDate=date;return newDate.setDate(date.getDate()+1);}
CLIPTOO.utils.isValidDate=function(dateStr){var datePat=/^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;var matchArray=dateStr.match(datePat);if(matchArray==null){popupHandler.showValidationPopup(dateStr+" "+PoiMsg.js_msg.validation.startDateWrongFormat())
return false;}
return true;}
CLIPTOO.utils.getAppender=(function(inputString){var _public={result:(!!inputString)?inputString:'',addParameter:function(parameterName,parameterValue){var param=((typeof parameterValue=='boolean')||(!!parameterValue&&(parameterValue+'')!=''))?(parameterName+'='+parameterValue):'';var separator=(!!this.result&&!!param)?'&':'';this.result=this.result+separator+param;return this;},addParameters:function(parametersString){var separator=(!!this.result&&!!parametersString)?'&':'';this.result=this.result+separator+parametersString;return this;}}
return _public;});CLIPTOO.utils.setupDivUnFocus=(function(containerDiv){var focusInput=document.createElement('input');focusInput.type="button";focusInput.className='focusInput';focusInput.id='focusInput';focusInput.style.background='black none repeat scroll 0 0';focusInput.style.border='0 none';focusInput.style.height="1pt";focusInput.style.width="1pt";focusInput.style.position='absolute';focusInput.style.top="8px";focusInput.style.left="11px";focusInput.style.outline="none";Dom.get(containerDiv).appendChild(focusInput);Event.addListener(focusInput,'blur',function(){if(!!_public.onHide){_public.onHide();}});var show=function(){focusInput.focus();}
var _public={show:show,onHide:null}
return _public;});CLIPTOO.utils.setCategoryIcon=function(icon,categoryId){var getCategoryIconPosition=function(categoryCode){var xPos=(0-categoryCode%10)*26;var yPos=(0-Math.floor(categoryCode/10))*26;return xPos+"px "+yPos+"px";}
var category=ctx.getCategories()[categoryId];icon.style.backgroundPosition=getCategoryIconPosition(category.code);};CLIPTOO.utils.mapToolbarPopupPosition=function(){var createGeodataBtn=Dom.get("map-create-geodata");if(createGeodataBtn){var poiLeft=createGeodataBtn.offsetLeft;ctx.getEasyCreatingForm().container.style.left=(poiLeft-1)+"px";ctx.getUploadPOAControl().outerContainer.style.left=(poiLeft-1)+"px";ctx.getUploadRouteControl().outerContainer.style.left=(poiLeft-1)+"px";ctx.getMapLayersControl().outerContainer.style.left=(poiLeft-1)+"px";}
CLIPTOO.utils.jumpToPosition();};CLIPTOO.utils.jumpToPosition=function(){var geofilterBtn=Dom.get("geofilterContainer");if(geofilterBtn){Dom.get("jumpToPopup").style.left=(geofilterBtn.offsetLeft-1)+"px";}};CLIPTOO.utils.useDataFromOtherApp=function(){var map=Poi.getMap();if((location.search.indexOf("?poi=")>-1||location.search.indexOf("&poi=")>-1)){var poiId=(Dom.get("poiIdBalloon").value)?(Dom.get("poiIdBalloon").value):(Dom.get("editedPoiId").value);var poiLatitude=(Dom.get("poiLatBalloon").value)?(Dom.get("poiLatBalloon").value):(Dom.get("editedPoiLatitude").value);var poiLangitude=(Dom.get("poiLngBalloon").value)?(Dom.get("poiLngBalloon").value):(Dom.get("editedPoiLongitude").value);if(poiId!=""){var h=457;var h1=36;var w=527;var w1=390;map.holdMapWithCursor("default");map.disable();var c1=map.fromLatLngToDivPixel(new GLatLng(poiLatitude,poiLangitude));var x=c1.x-w1+w/2;var y=c1.y+h1+(h-h1)/2;map.panTo(map.fromDivPixelToLatLng(new GPoint(x,y)));var balloon;if(ctx.getEditBalloon().isShown()){balloon=ctx.getEditBalloon();}
else{balloon=ctx.getViewBalloon();}
balloon.position();poisSelector.getCategoriesIdsWithPoisCount();UIRequest("getPoiPointById.action","id="+poiId,function(p_oRequest){var json=YAHOO.lang.JSON.parse(p_oRequest.responseText);var pois=[];var poiPoint=poisSelector.parsePoi(json.poiPoint);var poiPointId=json.poiPoint.id;pois[poiPointId]=poiPoint;ctx.setPois(pois);ctx.addAdditionalPoi(poiPoint);poisSelector.addInformationAboutFoundPois();poisSelector.drawPois();if(balloon.ratingComponent){balloon.ratingComponent.isEnabledVote=!json.voted;balloon.ratingComponent.setRate(json.averagePoiRating);}
balloon.initInfoForFirstPoi(poiPoint,json);});}}else{var selectedCategoriesStr=CLIPTOO.InitParameters.getSelectedCategories();var selectedCategories=[];if(selectedCategoriesStr=="*"){var categories=ctx.getCategories();for(var index in categories){selectedCategories.push(categories[index].id);}}
else if(selectedCategoriesStr){selectedCategories=selectedCategoriesStr.split(',');}
var onlyMyPois=CLIPTOO.poi.cookie.read("only-my-pois");if(Dom.get("myPoiTab")&&onlyMyPois=="on"){Dom.get("poiListTab").className="";Dom.get("myPoiTab").className="active";}
if(selectedCategories){ctx.getCategoriesListPopup().selectCategories(selectedCategories);ctx.setSelectedCategories(selectedCategories);if(typeof categoriesList2!="undefined"){categoriesList2.selectCategories(selectedCategories);}}
var onAfterLayersLoaded=function(){if(CLIPTOO.isMyPoi){return;}
var selectedLayer=CLIPTOO.InitParameters.getSelectedLayer();if((selectedLayer||selectedLayer!="")&&selectedLayer!="no-layer"){var layer=ctx.getLayerById(selectedLayer);if(layer){if(!CLIPTOO.poi.map.Toolbar.needToDisableLayersMenuItem(layer)){CLIPTOO.poi.map.Toolbar.selectLayer(layer);}}}}
var zoomSliderControl=ctx.getZoomingControl();var zoom=map.getZoom();if(zoomSliderControl){var value=-1*6*(zoom-2);zoomSliderControl.slider.setValue(value,true,false,false);}
poisSelector.setPoisByCategoriesIdsAndCoordinatBound(true);poisSelector.getLayersByCoordinatesBound(onAfterLayersLoaded);}};CLIPTOO.utils.getFileExtension=function(file){var fileExtensions=file.name.split(".");return fileExtensions[fileExtensions.length-1];};CLIPTOO.utils.getFileName=function(file){var fileExtensions=file.name.split(".");var result='';for(var i=0,n=fileExtensions.length-1;i<n;i++){result=result+fileExtensions[i];}
return result;};CLIPTOO.utils.setTooltipTextareaHeight=function(element,linesNumber){element.style.height=(linesNumber*15+1)+"px";};CLIPTOO.utils.trim=function(text){var result=text.replace(/^\s\s*/,'');var ws=/\s/;var i=result.length;while(ws.test(result.charAt(--i)));return result.slice(0,i+1);};CLIPTOO.utils.isEventInContainer=function(ev,cell){var relatedTarget=ev.relatedTarget?ev.relatedTarget:(ev.type=="mouseover"?ev.fromElement:ev.toElement);var inSameContainer=Dom.isAncestor(cell,relatedTarget);return(inSameContainer||cell==relatedTarget);};CLIPTOO.utils.getCellWhichHasClass=function(ev,className,listContainerId){var target=ev.target?ev.target:ev.srcElement;var cell=target;while(!Dom.hasClass(cell,className)&&cell.id!=listContainerId){cell=cell.parentNode;}
var cellIndex=cell._cellIndex||cell._cellIndex;if(typeof cellIndex!=="undefined"){return cell;}else{return null;}};CLIPTOO.utils.escapeHTML=function(text){return text.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");};CLIPTOO.utils.unEscapeHTML=function(text){return text.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">");};roundCorners=function(elm,containerClass){var container=document.createElement("div");container.className=containerClass;var top=document.createElement("b");top.className="trg";top.innerHTML="<b></b><i></i><u></u>"
var middle=document.createElement("div");middle.className="mrg";middle.appendChild(elm);var bottom=document.createElement("b");bottom.className="brg";bottom.innerHTML="<u></u><i></i><b></b>"
container.appendChild(top);container.appendChild(middle);container.appendChild(bottom);return container;};CLIPTOO.utils.centerChamberPopups=function(elWidth,elHeight){var themeWidth=960;var themeHeight=820;var x=parseInt((themeWidth/2)-(elWidth/2));var y=parseInt((themeWidth/2)-(elHeight/2));var xy=[x,y];return xy;};(function(){CLIPTOO.DivNoPois=function(container){var show=function(){emptyListDiv.style.display="";}
var hide=function(){emptyListDiv.style.display="none";}
var emptyListDiv=CLIPTOO.utils.createDomElement("div","poi_list_empty");emptyListDiv.innerHTML=PoiMsg.js_msg.poi.list.noPois();emptyListDiv.style.display="none";container.appendChild(emptyListDiv);return{show:show,hide:hide};}})();(function(){CLIPTOO.IndexPoiCell=function(cellIndex){var container=CLIPTOO.utils.createDomElement("div","poi");container.style.display="none";container._cellIndex=cellIndex;var poiIconDiv=CLIPTOO.utils.createDomElement("div","poi_icon");container.appendChild(poiIconDiv);var poiDiv=CLIPTOO.utils.createDomElement("div","poi_description");container.appendChild(poiDiv);var poiNameDiv=CLIPTOO.utils.createDomElement("div","poi_name");poiDiv.appendChild(poiNameDiv);var poiNameLeft=CLIPTOO.utils.createDomElement("div","poi_name_left");var poiNameItSelf=CLIPTOO.utils.createDomElement("div","poi_name_center ellipsis");var poiNameRight=CLIPTOO.utils.createDomElement("div","poi_name_right");poiNameDiv.appendChild(poiNameLeft);poiNameDiv.appendChild(poiNameItSelf);poiNameDiv.appendChild(poiNameRight);var poiDescriptionDiv=CLIPTOO.utils.createDomElement("div","text");poiDiv.appendChild(poiDescriptionDiv);var deleteDiv=null;deleteDiv=CLIPTOO.utils.createDomElement("div","poi_delete");deleteDiv.title=PoiMsg.js_msg.poi.list.deletePoi();poiDiv.appendChild(deleteDiv);var sharedDiv=null;sharedDiv=CLIPTOO.utils.createDomElement("div","shared-icon");sharedDiv.title=PoiMsg.js_msg.balloon.ownershipPoiListIcon();poiDiv.appendChild(sharedDiv);this.container=container;this.icon=poiIconDiv;this.name=poiNameItSelf;this.description=poiDescriptionDiv;this.deletePoi=deleteDiv;this.sharedDiv=sharedDiv;this.poiId=null;}
CLIPTOO.IndexPoiCell.prototype.getContainer=function(){return this.container;}
CLIPTOO.IndexPoiCell.prototype.fillContentFrom=function(poi){poi.description=poi.description.replace(/<br>/gi,"&nbsp;").replace(/<.*?>/gi,"").replace(/(\t)/g,"");this.unSelect();var category=ctx.getCategories()[poi.mainCategoryId];CLIPTOO.utils.setCategoryIcon(this.icon,poi.mainCategoryId);this.icon.title=category.name;this.name.innerHTML=CLIPTOO.utils.escapeHTML(poi.name);this.name.title=poi.name;this.description.innerHTML="<span>"+poi.description+"</span>";this.container.style.display="";this.poiId=poi.id;this.container.style.visibility="";CLIPTOO.utils.shrinkTextByHeigth(this.description.childNodes[0],40,140);if(poi.shared==true){this.sharedDiv.style.visibility="";this.deletePoi.style.visibility="hidden";}
else if((ctx.getPois()[poi.id]&&ctx.getPois()[poi.id].removable)||(poi.removable)){this.deletePoi.style.visibility="";this.sharedDiv.style.visibility="hidden";}else{this.sharedDiv.style.visibility="hidden";this.deletePoi.style.visibility="hidden";}}
CLIPTOO.IndexPoiCell.prototype.select=function(){Dom.addClass(this.container,'selected');}
CLIPTOO.IndexPoiCell.prototype.isSelected=function(){return Dom.hasClass(this.container,'selected');}
CLIPTOO.IndexPoiCell.prototype.unSelect=function(){Dom.removeClass(this.container,'selected');}
CLIPTOO.IndexPoiCell.prototype.hide=function(){this.container.style.display="none";}
CLIPTOO.IndexPoiCell.prototype.show=function(){this.container.style.display="";}
CLIPTOO.IndexPoiCell.prototype.isHidden=function(){return this.container.style.display=="none";}
CLIPTOO.IndexPoiCell.prototype.markMouseOver=function(){var poiNameContainer=this.name.parentNode;var poiNameParts=poiNameContainer.childNodes;Dom.addClass(poiNameContainer,'poi_name_hover');Dom.addClass(poiNameParts[0],'poi_name_left_hover');Dom.addClass(poiNameParts[1],'poi_name_center_hover');Dom.addClass(poiNameParts[2],'poi_name_right_hover');}
CLIPTOO.IndexPoiCell.prototype.unMarkMouseOver=function(){var poiNameContainer=this.name.parentNode;var poiNameParts=poiNameContainer.childNodes;Dom.removeClass(poiNameContainer,'poi_name_hover');Dom.removeClass(poiNameParts[0],'poi_name_left_hover');Dom.removeClass(poiNameParts[1],'poi_name_center_hover');Dom.removeClass(poiNameParts[2],'poi_name_right_hover');}
CLIPTOO.IndexPoiCell.prototype.getHeight=function(){this.getContainer().style.visibility="hidden";this.show();var result=this.getContainer().getElementsByTagName("div")[1].offsetHeight;this.hide();this.getContainer().style.visibility="";return result;}
CLIPTOO.IndexPoiCell.prototype.fixCursor=function(){this.name.parentNode.style.cursor='pointer';this.icon.style.cursor='pointer';this.details.style.cursor='pointer';for(var index=0;index<this.buttons.lenght;index++){this.buttons[index].style.cursor='pointer';}
this.container.style.cursor='default';}})();(function(){var PAGES_COUNT=5;YAHOO.PoisListTable=function(containerId,pagingContainerId){this.container=Dom.get(containerId);this.poisCells=[];this.selectedPoiId=null;this.emptyList=CLIPTOO.DivNoPois(this.container);this._calculatePoisPerPage();this._createCellsListStructure();this._initPaging(pagingContainerId);this.attachListHandlers();}
YAHOO.PoisListTable.prototype._createCellsListStructure=function(){var cellsCount=this.poisPerPage;for(var index=1;index<cellsCount;index++){this._addPoiCellToList(index);}}
YAHOO.PoisListTable.prototype._calculatePoisPerPage=function(){this._addPoiCellToList(0);var poiCell=this.poisCells[0];var poiCellHeight=poiCell.getHeight();var poisListHeight=this.container.offsetHeight;if(poiCellHeight>0){this.poisPerPage=Math.floor(poisListHeight/poiCellHeight);}
else{this.poisPerPage=7;}}
YAHOO.PoisListTable.prototype._initPaging=function(pagingContainerId){this.paging=CLIPTOO.Paging(pagingContainerId,this.poisPerPage,PAGES_COUNT,{isShowElementsCount:false});var that=this;this.paging.changePageToListener=function(pageNumber){that.redraw(pageNumber);}}
YAHOO.PoisListTable.prototype._addPoiCellToList=function(cellIndex){var poiCell=new CLIPTOO.IndexPoiCell(cellIndex);this.container.appendChild(poiCell.getContainer());this.poisCells.push(poiCell);}
YAHOO.PoisListTable.prototype._getPoiCell=function(poiNumber){if(typeof poiNumber!="undefined"){return this.poisCells[poiNumber];}
else{var countCells=this.poisCells.length;for(var index=0;index<countCells;index++){if(this.poisCells[index].isHidden()){return this.poisCells[index];}}}
return null;}
YAHOO.PoisListTable.prototype._addPoi=function(poi,poiNumber){if(!poi)return;var poiCell=this._getPoiCell(poiNumber);if(!poiCell){return;}
poiCell.fillContentFrom(poi);if(poi.id==this.selectedPoiId){poiCell.select();}}
YAHOO.PoisListTable.prototype.clearList=function(){var n=this.poisCells.length;for(var i=0;i<n;i++){this.poisCells[i].hide();}}
YAHOO.PoisListTable.prototype.redraw=function(pageNumber){if(this._isPoiListAreaVisible()){var poisLength=ctx.getPoisArray().length;var rectangles=ctx.getRectangles();var n=rectangles.length;for(var i=0;i<n;i++){poisLength+=rectangles[i].countPois;}
if(poisLength==0){this.clearList();this.paging.hide();Dom.get("poisListSeparatorId").style.display="none";this.emptyList.show();if(PoiListFilter.isEmpty()||ctx.getSelectedCategories().length==0){PoiListFilter.hide();PoiListSorting.hide();}
return;}else{PoiListFilter.show();PoiListSorting.show();}
popupHandler.showPleaseWait();this.emptyList.hide();if(!pageNumber){pageNumber=1;}
this.paging.setCurrentPage(pageNumber);this.paging.formPagesForPager(poisLength);var that=this;poisSelector.loadPoisPageForPoiList(pageNumber,that.poisPerPage,function(pois){that.loadPage(pois);});popupHandler.hidePleaseWait();}}
YAHOO.PoisListTable.prototype.loadPage=function(inputPois){var n=inputPois.length;for(var i=0;i<n;i++){var poi=inputPois[i];this._addPoi(poi,i);if(poi.id==this.selectedPoiId){var poiCell=this.poisCells[i];poiCell.select();}}
var m=this.poisCells.length;for(var i=n;i<m;i++){this.poisCells[i].hide();}}
YAHOO.PoisListTable.prototype.unSelectAllPois=function(){var n=this.poisCells.length;for(var j=0;j<n;j++){Dom.removeClass(this.poisCells[j].container,'selected');}
this.selectedPoiId=null;}
YAHOO.PoisListTable.prototype._isPoiListAreaVisible=function(){return(Dom.get("poiListArea").style.display!="none");}
YAHOO.PoisListTable.prototype.selectPoi=function(poiId,poiListNumber,forceRedraw){if(this._isPoiListAreaVisible()){this.unSelectAllPois();if(typeof poiListNumber=="undefined"){var that=this;poisSelector.getPageNumberForPoiList(this.poisPerPage,poiId,function(pageNumber){that.selectPoiOnPage(pageNumber,poiId);});}
else{var poiCell=this.poisCells[poiListNumber];this.selectedPoiId=poiId;poiCell.select();}}}
YAHOO.PoisListTable.prototype.selectPoiOnPage=function(pageNumber,selectedPoiId){if(pageNumber==-1){pageNumber=1;}
if(pageNumber!=this.paging.getCurrentPage()){this.selectedPoiId=selectedPoiId;this.redraw(pageNumber);return;}
var n=this.poisCells.length;var poiListNumber;for(var j=0;j<n;j++){if(this.poisCells[j].poiId==selectedPoiId){poiListNumber=j;break;}}
var poiCell=this.poisCells[poiListNumber];this.selectedPoiId=selectedPoiId;poiCell.select();}
YAHOO.PoisListTable.prototype.getPoiByListNumber=function(poiListNumber){var poiId=this.poisCells[poiListNumber].poiId;return ctx.getActivePoi(poiId);}
YAHOO.PoisListTable.prototype.findPoiCell=function(poiId){var cells=this.poisCells;for(var index in cells){if(cells[index].poiId==poiId){return cells[index];}}
return null;}
YAHOO.PoisListTable.prototype.attachListHandlers=function(){var poisList=Dom.get("list_of_pois");Event.addListener(poisList,"click",delegateClickEvent,this,false);Event.addListener(poisList,"mouseover",delegateMouseOverEvent,this,false);Event.addListener(poisList,"mouseout",delegateMouseOutEvent,this,false);}
var handleClickOnPoi=function(poiListNumber,poiList){var poiCell=poiList.poisCells[poiListNumber];var poiId=poiCell.poiId;poiList.selectPoi(poiId,poiListNumber);var poi=ctx.getActivePoi(poiId);if(typeof pageTracker!='undefined'){pageTracker._trackPageview("/pois/"+poi.name+"/"+poi.id);}
if(typeof pageTrackerGeneric!='undefined'){pageTrackerGeneric._trackPageview("/pois/"+poi.name+"/"+poi.id);}
gmapHandler.showBalloon(poi);};var handleDeletePoi=function(poiListNumber,poiList){var poi=poiList.getPoiByListNumber(poiListNumber);if((ctx.getPois()[poi.id]&&ctx.getPois()[poi.id].removable)||(poi.removable)){var id=poi.id;var map=Poi.getMap();popupHandler.showConfirmPopup(PoiMsg.js_msg.balloon.blog.msg.warning(),PoiMsg.js_msg.balloon.blog.msg.deleteItem(poi.name),function(){popupHandler.showPleaseWait();map.closeBalloon();UIRequest("deletePoi.action","id="+id,function(o){poisSelector.changePoiCountInCategories(poi,true);ctx.removeAdditionalPoi(id);var localPoi=ctx.getPois()[id];if(typeof localPoi=="undefined"){gmapHandler.deletePoiFromGroup(poi);}
else{poisSelector.deletePoiById(id);}
poisSelector.drawPois();poisSelector.addInformationAboutFoundPois();popupHandler.hidePleaseWait();});this.hide();});}};var handleOverPoi=function(cellIndex,poiList){var poiCell=poiList.poisCells[cellIndex];var poiId=poiCell.poiId;var poi=ctx.getActivePoi(poiId);var isPoa=ctx.getCategories()[poi.mainCategoryId].categoryType==GlobalProperties.POA;poiCell.markMouseOver();if(isPoa)return;var map=Poi.getMap();var point=new GLatLng(poi.latitude,poi.longitude);var poisAreaOverlays=map.getPoisAreasOverlays();var n=poisAreaOverlays.length;var inCircle=false;for(var i=0;i<n;i++){if(poisAreaOverlays[i].viewPort_.containsLatLng(point)){inCircle=true;poisAreaOverlays[i].hilight();}}
if(!inCircle){ctx.getPoisTooltip().show(poi);}
var poiMarker=gmapHandler.getMarkerbyPoiId(poiId);if(poiMarker){poiMarker.showOnTopLayer();}};var handleOutOfPoi=function(cellIndex,poiList){var map=Poi.getMap();var poisAreaOverlays=map.getPoisAreasOverlays();for(var i=0,n=poisAreaOverlays.length;i<n;i++){poisAreaOverlays[i].dehilight();}
ctx.getPoisTooltip().hide();var poiCell=poiList.poisCells[cellIndex];poiCell.unMarkMouseOver();var poiId=poiCell.poiId;var poiMarker=gmapHandler.getMarkerbyPoiId(poiId);if(poiMarker){poiMarker.showOnDefaultLayer();}};var delegateClickEvent=function(ev,poiList){var cell=CLIPTOO.utils.getCellWhichHasClass(ev,"poi","list_of_pois");if(!cell)return;var target=ev.target?ev.target:ev.srcElement;if(target.className=="poi_delete"){handleDeletePoi(cell._cellIndex,poiList);}else{handleClickOnPoi(cell._cellIndex,poiList);}};var delegateMouseOverEvent=function(ev,poiList){var cell=CLIPTOO.utils.getCellWhichHasClass(ev,"poi","list_of_pois");if(!cell)return;if(CLIPTOO.utils.isEventInContainer(ev,cell))return;handleOverPoi(cell._cellIndex,poiList);};var delegateMouseOutEvent=function(ev,poiList){var cell=CLIPTOO.utils.getCellWhichHasClass(ev,"poi","list_of_pois");if(!cell)return;if(CLIPTOO.utils.isEventInContainer(ev,cell))return;handleOutOfPoi(cell._cellIndex,poiList);};})();RichEditor=function(){};RichEditor.prototype.onStorySaved=function(data){}
RichEditor.prototype.onCanceled=function(){}
RichEditor.prototype.getPoiId=function(){}
RichEditor.prototype._initRichEditor=function(){var poiEditorConfig={height:"",width:"",buttonType:'advanced',css:'html { height: 95%; } body {color:#555b5d; background-color: #fff; font:12px/1.22 arial; } a, a:visited, a:hover { color: blue !important; text-decoration: underline !important; cursor: text !important; } .warning-localfile { border-bottom: 1px dashed red !important; } .yui-busy { cursor: wait !important; } img.selected { border: 2px dotted #808080; } img { cursor: pointer !important; border: none; } body.ptags.webkit div { margin: 11px 0; }',toolbar:{buttons:[{group:'textstyle',label:'',buttons:[{type:'push',label:PoiMsg.js_msg.richEditor.bold(),value:'bold'},{type:'push',label:PoiMsg.js_msg.richEditor.italic(),value:'italic'},{type:'push',label:PoiMsg.js_msg.richEditor.underline(),value:'underline'},{type:'separator'},{type:'color',label:PoiMsg.js_msg.richEditor.fontColor(),value:'forecolor',disabled:true},{type:'color',label:PoiMsg.js_msg.richEditor.bgColor(),value:'backcolor',disabled:true},{type:'separator'},{type:'push',label:PoiMsg.js_msg.richEditor.removeFormating(),value:'removeformat',disabled:true},{type:'separator'},{name:'justifyleft',type:'push',label:PoiMsg.js_msg.richEditor.alignLeft(),value:'justifyleft'},{type:'push',label:PoiMsg.js_msg.richEditor.alignCenter(),value:'justifycenter'},{type:'push',label:PoiMsg.js_msg.richEditor.alignRight(),value:'justifyright'},{type:'push',label:PoiMsg.js_msg.richEditor.justify(),value:'justifyfull'},{type:'separator'},{type:'push',label:PoiMsg.js_msg.richEditor.createUnorderedList(),value:'insertunorderedlist'},{type:'push',label:PoiMsg.js_msg.richEditor.createOrderedList(),value:'insertorderedlist'},{type:'separator'},{type:'push',label:PoiMsg.js_msg.richEditor.link(),value:'createlink',disabled:true},{type:'push',label:PoiMsg.js_msg.richEditor.insertImage(),value:'insertimage'}]}]},handleSubmit:true,extracss:"p {margin: 0}"};var that=this;var editorId=this.storyDescriptionId;this.richEditor=new YAHOO.widget.Editor(editorId,poiEditorConfig);var richEditor=this.richEditor;this.richEditor.moveWindow=function(){var currentEl=this.currentElement[0];var button=null;if(this.currentWindow.name==="insertimage"){button=this._defaultToolbar.buttons[0].buttons[18];}else{button=this._defaultToolbar.buttons[0].buttons[17];}
button=button.container;var panel=this.get('panel');var _knob=panel.editor_knob;_knob.style.left="auto";_knob.style.right="0px";var w=panel.cfg.getProperty("width");var h=panel.cfg.getProperty("height");var buttonXY=Dom.getXY(button);panel.cfg.setProperty('xy',[(buttonXY[0]-parseInt(w)+parseInt(button.clientWidth)),(buttonXY[1]+parseInt(button.clientHeight))]);}
richEditor.on('editorContentLoaded',function(){richEditor.toolbar.on('createlinkClick',function(){var linkWindow=Dom.get(editorId+'_createlink_target');linkWindow.setAttribute('checked','true');linkWindow.setAttribute('disabled','true');});richEditor.toolbar.on('insertimageClick',function(){var currentLocale=Dom.get("lang").value;var panel=editorId+"-panel";if(currentLocale=="nl"){Dom.addClass(panel,"descriptionEditor-nl-prompt-fix");}
descriptionEditorUploadButton=Dom.get("editorUploadBrowseButtonId");if(descriptionEditorUploadButton){if(YAHOO.env.ua.ie>=7){descriptionEditorUploadButton=null;}else{return;}}
var inp=Dom.get(editorId+'_insertimage_url');inp.style.width="245px";var iuc=Dom.get(editorId+'-panel');iuc.style.zIndex="11";var uploadPlaceHolder=document.createElement("DIV");uploadPlaceHolder.className="editorUploadButton";uploadPlaceHolder.id="editorUploadBrowseButtonId";inp.parentNode.parentNode.appendChild(uploadPlaceHolder);var currentLocation=window.location;YAHOO.widget.Uploader.SWFURL=currentLocation.protocol+"//"+currentLocation.host+GlobalProperties.HOST+"js/yui/uploader/assets/uploader.swf";var uploader=new YAHOO.widget.Uploader(uploadPlaceHolder,currentLocation.protocol+"//"+currentLocation.host+GlobalProperties.HOST+"themes/default/img/balloon/upload_button_editor.png");function onFileSelectPoi(event){fileList=event.fileList;if(fileList){for(var i in fileList){if(fileList[i].size>parseInt(PoiMsg.js_msg.upload.maxFileSize())){popupHandler.showErrorPopup(PoiMsg.js_msg.upload.maxSizeError(CLIPTOO.utils.getFileExtension(fileList[i])));return;}
popupHandler.showPleaseWait();uploader.upload(i,GlobalProperties.HOST+"ImageUpload.action","GET",{"userUid":ctx.getCurrentUserUid()});}
uploader.clearFileList();}}
function uploadCompleteData(event){var json=YAHOO.lang.JSON.parse(event.data);inp.value=json.photoLink;popupHandler.hidePleaseWait();}
var onUploaderContentReady=function(){uploader.setAllowMultipleFiles(false);uploader.setFileFilters([{description:"Images",extensions:"*.jpg;*.png"}]);}
uploader.addListener('fileSelect',onFileSelectPoi);uploader.addListener('uploadCompleteData',uploadCompleteData);uploader.addListener('contentReady',onUploaderContentReady);});});richEditor.render(Dom.get(editorId));};RichEditor.prototype.clean=function(editedText){Dom.get(this.storyTitleId).value="";Dom.get(this.entryId).value="";this.richEditor.setEditorHTML("");}
RichEditor.prototype.setEditedText=function(editedText){this.richEditor.setEditorHTML(editedText);}
RichEditor.prototype.setAction=function(newAction){this.action=newAction;}
RichEditor.prototype.savePostEntry=function(){var richEditor=this.richEditor;if(ctx.isAuthenticated()){popupHandler.showPleaseWait();var form=Dom.get(this.storyFormId);richEditor.saveHTML();form.blogEntryDescription.value=richEditor.get('element').value;var that=this;var validateBlogForm=function(){UIRequest("validateCaptchaWord.action","captchaWordVerificationName="+form.captchaWordVerificationName.value,function(data){var json=YAHOO.lang.JSON.parse(data.responseText);if(json.captchaValidationResult){if(validator.validateNamesBlock(form,"EditBlogPostForm")){FormSubmit(that.storyFormId,that.action+"?poiId="+that.getPoiId(),function(data){that.onStorySaved(data);});}
else{popupHandler.hidePleaseWait();}}else{popupHandler.showValidationPopup(PoiMsg.js_msg.balloonCaptchaError());popupHandler.hidePleaseWait();}});};validateBlogForm();return;}}
RichEditor.prototype._initPostEntryButtonOnEditForm=function(){Event.addListener(this.entryPostId,'click',this.savePostEntry,this,true);}
RichEditor.prototype._initCancellButtonOnEditForm=function(){Event.addListener(this.gotoStoriesListId,'click',this.onCanceled,this,true);}
BalloonRichEditor=function(options){var storyTab=options.stories;this.storyDescriptionId=storyTab.storyDescriptionId;this.storyFormId=storyTab.storyFormId;this.storyTitleId=storyTab.storyTitleId;this.entryId=storyTab.entryId;this.gotoStoriesListId=storyTab.gotoStoriesListId;this.entryPostId=storyTab.entryPostId;this.richEditor=null;var that=this;this.onStorySaved=function(data){Dom.get(storyTab.richEditorId).style.display="none";options.buildStoriesList(data);}
this.onCanceled=function(){Dom.get(storyTab.richEditorId).style.display="none";options.showStories();}
this.getPoiId=function(){return document.getElementById(options.poiId).value;}
this._initRichEditor();this._initPostEntryButtonOnEditForm();this._initCancellButtonOnEditForm();};YAHOO.lang.extend(BalloonRichEditor,RichEditor);BalloonDescriptionEditor=function(options){this.descriptionEditorTextarea=options.descriptionEditorTextarea;this._initDescriptionEditor=function(){if(YAHOO.env.ua.ie==8){var paddingFix="padding:0px;"}else{var paddingFix="padding:4px;"}
var poiEditorConfig={height:"90px",width:"377px",buttonType:'advanced',css:'html { height: 95%; } body {color:#555b5d; background-color: #fff; font:12px/1.22 arial; '+paddingFix+'} a, a:visited, a:hover { color: blue !important; text-decoration: underline !important; cursor: text !important; } .warning-localfile { border-bottom: 1px dashed red !important; } .yui-busy { cursor: wait !important; } img.selected { border: 2px dotted #808080; } img { cursor: pointer !important; border: none; } body.ptags.webkit div { margin: 11px 0; }',toolbar:{buttons:[{group:'textstyle',label:'',buttons:[{type:'push',label:PoiMsg.js_msg.richEditor.bold(),value:'bold'},{type:'push',label:PoiMsg.js_msg.richEditor.italic(),value:'italic'},{type:'push',label:PoiMsg.js_msg.richEditor.underline(),value:'underline'},{type:'separator'},{type:'push',label:PoiMsg.js_msg.richEditor.link(),value:'createlink',disabled:true},{type:'push',label:PoiMsg.js_msg.richEditor.insertImage(),value:'insertimage'},{type:'push',label:PoiMsg.js_msg.descriptionRichEditor.title(),value:'insertbutton'}]}]},handleSubmit:true,extracss:"p {margin: 0}"};this.richEditor=new YAHOO.widget.Editor(this.descriptionEditorTextarea,poiEditorConfig);var richEditor=this.richEditor;var initInsertButtonOverlay=function(){var win=new YAHOO.widget.Overlay('insertbutton',{width:'360px',height:'125px',underlay:'none',draggable:false,context:[richEditor.toolbar.getButtonByValue('insertbutton').get('element'),'tl','tr'],position:'absolute',visible:false});var headerString='<h3><span>'+PoiMsg.js_msg.descriptionRichEditor.title()+'</span>\
  <span id="closeInsertButton" title="Close Window" class="close">X</span></h3>';var bodyString='<div style="padding-top:10px; overflow:hidden;">\
  <label for="descriptionEditor_insertbutton_title">\
  <strong>'+PoiMsg.js_msg.descriptionRichEditor.description()+':</strong>\
  <input type="text" size="30" value="" id="descriptionEditor_insertbutton_title">\
  </label>\
  <label for="descriptionEditor_insertbutton_link">\
  <strong>'+PoiMsg.js_msg.descriptionRichEditor.url()+':</strong>\
  <input type="text" value="http://" id="descriptionEditor_insertbutton_link" name="descriptionEditor_insertbutton_link">\
  </label>\
  <div style="float: right; margin: 0px 9px 9px 0pt;">\
  <a class="ovalbutton" id="addInsertButton"><span>'+PoiMsg.js_msg.descriptionRichEditor.btn()+'</span></a>\
  </div></div>';win.setHeader(headerString);win.setBody(bodyString);win.setFooter('');win.render(document.body);Dom.addClass(Dom.get('insertbutton'),"yui-editor-panel");YAHOO.util.Event.on('addInsertButton','click',function(){var currentLocation=window.location;var pdfIconPath=currentLocation.protocol+"//"+currentLocation.host+GlobalProperties.HOST+"themes/default/img/pdf.png";var title=Dom.get('descriptionEditor_insertbutton_title').value;var link=Dom.get('descriptionEditor_insertbutton_link').value;if(link!=""&&link!="http://"){var insertString='<a href="'+link+'">\
    <img title="'+title+'" alt="'+title+'" src="'+pdfIconPath+'" border="0"></a>';richEditor.execCommand('inserthtml',insertString);}
win.hide();});YAHOO.util.Event.on('closeInsertButton','click',function(){win.hide();richEditor.toolbar.deselectButton('insertbutton');});return win;};var that=this;var descriptionEditorId=this.descriptionEditorTextarea.id;richEditor.on('toolbarLoaded',function(){richEditor.toolbar.on('insertbuttonClick',function(ev){if(!Dom.get('insertbutton')){richEditor.insertButtonOverlay=initInsertButtonOverlay();}
richEditor.insertButtonOverlay.show();},richEditor,true);richEditor.toolbar.on('createlinkClick',function(){var linkWindow=Dom.get(that.descriptionEditorTextarea.id+'_createlink_target');linkWindow.setAttribute('checked','true');linkWindow.setAttribute('disabled','true');});richEditor.toolbar.on('insertimageClick',function(){var currentLocale=Dom.get("lang").value;var panel=descriptionEditorId+"-panel";var el1=Dom.get(panel);if(currentLocale=="nl"){Dom.addClass(panel,"descriptionEditor-nl-prompt-fix");}
descriptionEditorUploadButton=Dom.get("descriptionEditorUploadBtnId");if(descriptionEditorUploadButton){if(YAHOO.env.ua.ie>=7){descriptionEditorUploadButton=null;}else{return;}}
var input=Dom.get(descriptionEditorId+'_insertimage_url');input.style.width="245px";var panel=Dom.get(descriptionEditorId+'-panel');panel.style.zIndex="11";var uploadPlaceHolder=document.createElement("DIV");uploadPlaceHolder.className="descriptionEditorUploadBtn";uploadPlaceHolder.id="descriptionEditorUploadBtnId";input.parentNode.parentNode.appendChild(uploadPlaceHolder);var currentLocation=window.location;YAHOO.widget.Uploader.SWFURL=currentLocation.protocol+"//"+currentLocation.host+GlobalProperties.HOST+"js/yui/uploader/assets/uploader.swf";var uploader=new YAHOO.widget.Uploader(uploadPlaceHolder,currentLocation.protocol+"//"+currentLocation.host+GlobalProperties.HOST+"themes/default/img/balloon/upload_button_editor.png");function onFileSelect(event){fileList=event.fileList;if(fileList){for(var i in fileList){if(fileList[i].size>parseInt(PoiMsg.js_msg.upload.maxDescriptionFileSize())){popupHandler.showErrorPopup(PoiMsg.js_msg.upload.maxDescriptionSizeError(CLIPTOO.utils.getFileExtension(fileList[i])));return;}
popupHandler.showPleaseWait();uploader.upload(i,GlobalProperties.HOST+"saveImageForBalloon.action","GET",{"userUid":ctx.getCurrentUserUid()});}
uploader.clearFileList();}};function uploadCompleteData(event){var json=YAHOO.lang.JSON.parse(event.data);input.value=json.photoLink;popupHandler.hidePleaseWait();};var onUploaderContentReady=function(){uploader.setAllowMultipleFiles(false);uploader.setFileFilters([{description:"Images",extensions:"*.jpg;*.png"}]);};uploader.addListener('fileSelect',onFileSelect);uploader.addListener('uploadCompleteData',uploadCompleteData);uploader.addListener('contentReady',onUploaderContentReady);});});richEditor.on('editorContentLoaded',function(){var descriptionEl=Dom.get('poiDescription');if(descriptionEl&&descriptionEl.value!=''){that.setEditedText(descriptionEl.value);}});richEditor.render(this.descriptionEditorTextarea);};this._initDescriptionEditor();};YAHOO.lang.extend(BalloonDescriptionEditor,RichEditor);function PoisSelector(){var startZoomLevelForGroupingPois=ctx.getOrgProperty("startZoomLevelForGroupingPois");if(!startZoomLevelForGroupingPois||startZoomLevelForGroupingPois==''){startZoomLevelForGroupingPois=15;}
this.sortingType=GlobalProperties.DEFAULT_SORTING_DIRECTION;this.addInformationAboutFoundPois=function(){var localCtx=ctx;var rectangles=localCtx.getRectangles();var poisCount=localCtx.getPoisCount();for(var i in rectangles){poisCount+=rectangles[i].countPois;}
var n=0;var selectedCategories=localCtx.getSelectedCategories();var categories=localCtx.getCategories();for(var index in selectedCategories){if(categories[selectedCategories[index]]&&categories[selectedCategories[index]].countPois>0){n++;}}
if(Dom.get("poiListInfo")){var info='';if(poisCount==1){info=info+PoiMsg.js_msg.poi.list.poiInfo(poisCount);}else{info=info+PoiMsg.js_msg.poi.list.poisInfo(poisCount);}
if(n==1){info=info+' '+PoiMsg.js_msg.poi.list.categoryInfo(n);}else{info=info+' '+PoiMsg.js_msg.poi.list.categoriesInfo(n);}
Dom.get("poiListInfo").innerHTML=info;}}
var updatePoiPoints=function(inputPois,sourcePois){var n=inputPois.length;for(var i=0;i<n;i++){var poi=inputPois[i];var poiId=poi.id;var sourcePoi=sourcePois[poiId];sourcePoi=sourcePois[poiId];poi.name=sourcePoi.name;poi.mainCategoryId=sourcePoi.mainCategoryId;}
return inputPois;}
var sortingPoisList=function(inputPois,poiIds){var poisHash=[];var n=inputPois.length;for(var i=0;i<n;i++){var poi=inputPois[i];var poiId=poi.id;poisHash[poiId.toString()]=poi;}
var result=[];for(var i=0;i<n;i++){var foundPoi=poisHash[poiIds[i]];foundPoi=poisHash[poiIds[i]];result.push(foundPoi);}
return result;}
var changeCurrentPoi=function(){var currentPoi=ctx.getCurrentPoi();if(currentPoi){var ctxPois=ctx.getPois();var poi=ctxPois[currentPoi.id];if(poi){poi.latitude=currentPoi.latitude;poi.longitude=currentPoi.longitude;}else{ctxPois[currentPoi.id]=currentPoi;}}}
var getSouthWestPoint=function(latLngBounds){var map=Poi.getMap();var point=latLngBounds.getSouthWest();var pixel=map.fromLatLngToDivPixel(point);pixel.x+=GlobalProperties.DEAD_AREA_SIZE;pixel.y-=GlobalProperties.DEAD_AREA_SIZE;return map.fromDivPixelToLatLng(pixel);}
var getNorthEastPoint=function(latLngBounds){var map=Poi.getMap();var point=latLngBounds.getNorthEast();var pixel=map.fromLatLngToDivPixel(point);pixel.x-=GlobalProperties.DEAD_AREA_SIZE;pixel.y+=GlobalProperties.DEAD_AREA_SIZE+3;return map.fromDivPixelToLatLng(pixel);}
var getSearchString=function(){var searchString='';if(Dom.get("filterField")){searchString=PoiListFilter.getSearchValue();var categoriesIds=ctx.getSelectedCategories().join(",");if(!categoriesIds&&searchString!=''){searchString='';}}
return searchString;}
var getAdditionalPoiIds=function(){var onlyMy=false;if(Dom.get("myPoiTab")&&Dom.get("myPoiTab").className=="active"){onlyMy=true;}
var additionalPois=ctx.getAdditionalPois();var n=additionalPois.length;var additionalPoiIds=[];for(var i=0;i<n;i++){if(!additionalPois[i].removable&&onlyMy){continue;}
additionalPoiIds.push(additionalPois[i].id);}
return additionalPoiIds.join(',');}
var getParamsForFilter=function(){var latLngBounds=Poi.getMap().getBounds();var minPoint=getSouthWestPoint(latLngBounds);var minLat=minPoint.lat();var minLng=minPoint.lng();var maxPoint=getNorthEastPoint(latLngBounds);var maxLat=maxPoint.lat();var maxLng=maxPoint.lng();var onlyMy='';if(Dom.get("myPoiTab")&&Dom.get("myPoiTab").className=="active"){onlyMy='onlyMy';}
var map=Poi.getMap();var minPoint=map.fromDivPixelToLatLng(new GPoint(GlobalProperties.MINIMAL_DISTANCE_BETWEEN_POIS_IN_PX,GlobalProperties.MINIMAL_DISTANCE_BETWEEN_POIS_IN_PX));var zeroPoint=map.fromDivPixelToLatLng(new GPoint(0,0));var minDistance=Math.abs(minPoint.lng()-zeroPoint.lng());if(minDistance>11){minDistance=11;}
var mapWidthPx=map.getSize().width;var mapHeightPx=map.getSize().height;var mapType=(mapHeightPx>mapWidthPx)?GlobalProperties.VERTICAL_MAP:GlobalProperties.HORIZONTAL_MAP;var mapWidth=mapWidthPx-2*GlobalProperties.DEAD_AREA_SIZE;var minimalRectWidth=mapWidth/11;while(mapWidth>minimalRectWidth){mapWidth=mapWidth/2;}
mapWidth=Math.floor(mapWidth*2);minPoint=map.fromDivPixelToLatLng(new GPoint(mapWidth,mapWidth));var minLngSide=Math.abs(minPoint.lng()-zeroPoint.lng())*2;if(minLngSide>41){minLngSide=41;}
var withRectangles=map.getZoom()<startZoomLevelForGroupingPois;if(!isNaN(minLat)||!isNaN(minLng)||!isNaN(maxLat)||!isNaN(maxLng)){var params="&minLat="+minLat+"&minLng="+minLng+"&maxLat="+maxLat+"&maxLng="+maxLng+"&searchPoiByNameAndDescription="+getSearchString()+"&onlyMy="+onlyMy+"&minDistance="+minDistance+"&minLngSide="+
minLngSide+"&mapType="+mapType+"&withRectangles="+withRectangles;if(typeof PoiListSorting!='undefined'){params+='&'+PoiListSorting.getParametersList();}
return params;}
return null;}
this.parsePoi=function(poi){var catIds=poi.categoriesIds.split(',');var categoriesIds=[];for(var i=catIds.length-1;i>-1;i--){categoriesIds[i]=parseInt(catIds[i]);}
poi.categoriesIds=categoriesIds;return poi;}
this.parsePois=function(pois){for(poiId in pois){this.parsePoi(pois[poiId]);}
return pois;}
this.setPoisByCategoriesIdsAndCoordinatBound=function(ignoreTabSwitching){popupHandler.showPleaseWait();var searchString=getSearchString();var categoriesIds=ctx.getSelectedCategories().join(",");if(!categoriesIds&&searchString==''){categoriesIds='withoutPois';}
else if(!categoriesIds&&searchString!=''){searchString="";}
else if(!categoriesIds){categoriesIds="";}
var params='categoriesIds='+categoriesIds+getParamsForFilter();if(params){UIRequest("loadFilteredPoisWithStat.action",params,function(p_oRequest){var localCtx=ctx;var json=YAHOO.lang.JSON.parse(p_oRequest.responseText);var rectangles=json.rectangles;var categoriesWithPoisCount=json.categoryIdsWithFilteredPois;poisSelector.refreshCategoriesWithCountPois(categoriesWithPoisCount);localCtx.setPois(!json.poisMap?[]:poisSelector.parsePois(json.poisMap));localCtx.setRectangles(!json.rectangles?[]:rectangles);changeCurrentPoi();poisSelector.drawPois();poisSelector.addInformationAboutFoundPois();popupHandler.hidePleaseWait();});}else{popupHandler.hidePleaseWait();}}
this.getLayersByCoordinatesBound=function(onAfterLayersLoaded){if(!ctx.getOrgProperty('layersMode')){return;}
popupHandler.showPleaseWait();var latLngBounds=Poi.getMap().getBounds();var minPoint=getSouthWestPoint(latLngBounds);var minLat=minPoint.lat();var minLng=minPoint.lng();var maxPoint=getNorthEastPoint(latLngBounds);var maxLat=maxPoint.lat();var maxLng=maxPoint.lng();var params="minLat="+minLat+"&minLng="+minLng+"&maxLat="+maxLat+"&maxLng="+maxLng;UIRequest("returnAllLayersByCoordinatBound.action",params,function(p_oRequest){var localCtx=ctx;var json=YAHOO.lang.JSON.parse(p_oRequest.responseText);var layers=json.layers;localCtx.setLayers(!layers?[]:layers);var selectedLayerId=CLIPTOO.poi.map.Toolbar.returnIdSelectedLayer();if(selectedLayerId){for(var i=0,n=layers.length;i<n;i++){if(layers[i].id==selectedLayerId&&!layers[i].layerLink){Poi.getMap().showLayer(layers[i],true);}}}
CLIPTOO.poi.map.Toolbar.refreshLayersMenu();if(onAfterLayersLoaded){onAfterLayersLoaded();}
popupHandler.hidePleaseWait();});}
var getNotEmptyCategories=function(){var searchString=getSearchString();var selectedCategories=ctx.getSelectedCategories();var notEmptyCategories=[];for(var index in selectedCategories){var fk=selectedCategories[index];if(ctx.getCategories()[fk]&&ctx.getCategories()[fk].countPois&&ctx.getCategories()[fk].countPois>0){notEmptyCategories.push(fk);}}
var categoriesIds=notEmptyCategories.join(",");if(!categoriesIds&&searchString==''){categoriesIds='withoutPois';}
else if(!categoriesIds){categoriesIds="";}
return categoriesIds;}
this.reloadPois=function(){popupHandler.showPleaseWait();var params='categoriesIds='+getNotEmptyCategories()+getParamsForFilter();if(params){UIRequest("loadFilteredPois.action",params,function(p_oRequest){var localCtx=ctx;var json=YAHOO.lang.JSON.parse(p_oRequest.responseText);var rectangles=json.rectangles;localCtx.setPois(!json.poisMap?[]:poisSelector.parsePois(json.poisMap));localCtx.setRectangles(!json.rectangles?[]:rectangles);changeCurrentPoi();poisSelector.drawPois();poisSelector.addInformationAboutFoundPois();popupHandler.hidePleaseWait();});}else{popupHandler.hidePleaseWait();}}
this.getCategoriesIdsWithPoisCount=function(){popupHandler.showPleaseWait();var params=getParamsForFilter();if(params){UIRequest("getCategoriesIdsWithPoisCount.action",params,function(p_oRequest){var json=YAHOO.lang.JSON.parse(p_oRequest.responseText);var categoriesWithPoisCount=json.categoryIdsWithFilteredPois;poisSelector.refreshCategoriesWithCountPois(categoriesWithPoisCount);poisSelector.refreshCategoryList();popupHandler.hidePleaseWait();});}else{popupHandler.hidePleaseWait();}}
this.getValidPoisIdsPage=function(pageNumber,listSize,poisLength){var isNeedToReverse=(PoiListSorting.getSortingDirection()!=this.sortingType);var lowerLimit=(pageNumber-1)*listSize;if(isNeedToReverse){lowerLimit=poisLength-lowerLimit-listSize;}
var upperLimit=lowerLimit+listSize;if(upperLimit>poisLength){upperLimit=poisLength;}
var result=ctx.getPoisIds(lowerLimit,upperLimit);if(isNeedToReverse){return result.reverse();}
return result;}
this.loadPoisPageForPoiListByIds=function(pageNumber,listSize,poisLength,onPoisLoad){var pois=ctx.getPois();var poiIds=this.getValidPoisIdsPage(pageNumber,listSize,poisLength);UIRequest("getPoisByIds.action","poiIds="+poiIds.join(","),function(data){var json=YAHOO.lang.JSON.parse(data.responseText);var updatedList=updatePoiPoints(json.basicPois,pois);var sortedList=sortingPoisList(updatedList,poiIds);onPoisLoad(sortedList);popupHandler.hidePleaseWait();});}
this.loadPoisPageForPoiList=function(pageNumber,listSize,onPoisLoad){var offset=(pageNumber-1)*listSize;popupHandler.showPleaseWait();var params='categoriesIds='+getNotEmptyCategories()+getParamsForFilter();if(params){var additionalPoiIds=getAdditionalPoiIds();params=params+"&offset="+offset+"&listSize="+listSize+"&additionalPoiIds="+additionalPoiIds;UIRequest("loadPoisForPoiList.action",params,function(data){ctx.setPoisForPoiList([]);var json=YAHOO.lang.JSON.parse(data.responseText);var pois=poisSelector.parsePois(json.pois);ctx.setPoisForPoiList(pois);if(pois){onPoisLoad(pois);}
popupHandler.hidePleaseWait();});}else{popupHandler.hidePleaseWait();}}
this.getPageNumberForPoiList=function(listSize,selectedPoiId,onPageNumberLoad){popupHandler.showPleaseWait();var params='categoriesIds='+getNotEmptyCategories()+getParamsForFilter();if(params&&selectedPoiId){var additionalPoiIds=getAdditionalPoiIds();params=params+"&poiId="+selectedPoiId+"&listSize="+listSize+"&additionalPoiIds="+additionalPoiIds;UIRequest("calculatePageNumberForPoiList.action",params,function(data){var json=YAHOO.lang.JSON.parse(data.responseText);onPageNumberLoad(json.pageNumber);popupHandler.hidePleaseWait();});}else{popupHandler.hidePleaseWait();}}
this.loadLayersForMap=function(){var latLngBounds=Poi.getMap().getBounds();var minPoint=getSouthWestPoint(latLngBounds);var minLat=minPoint.lat();var minLng=minPoint.lng();var maxPoint=getNorthEastPoint(latLngBounds);var maxLat=maxPoint.lat();var maxLng=maxPoint.lng();var params='';if(!isNaN(minLat)||!isNaN(minLng)||!isNaN(maxLat)||!isNaN(maxLng)){params='minLat='+minLat+'&minLng='+minLng+'&maxLat='+maxLat+'&maxLng='+maxLng;}
popupHandler.showPleaseWait();if(params){UIRequest("returnLayersByCoordinatBoundForUser.action",params,function(p_oRequest){var json=YAHOO.lang.JSON.parse(p_oRequest.responseText);ctx.getMapLayersControl().onLoadLayers(json.layers);popupHandler.hidePleaseWait();ctx.getMapLayersControl().setFocus();});}else{popupHandler.hidePleaseWait();ctx.getMapLayersControl().setFocus();}}};PoisSelector.prototype.refreshCategoriesWithCountPois=function(categoryIdsWithFilteredPois){var categories=ctx.getCategories();if(!categoryIdsWithFilteredPois)return;for(var categoryIndex in categories){if(categoryIdsWithFilteredPois[categoryIndex]){categories[categoryIndex].countPois=categoryIdsWithFilteredPois[categoryIndex];}else{categories[categoryIndex].countPois=0;}}}
PoisSelector.prototype.replacePoi=function(poi){var pois=ctx.getPois();if(!poi)return;var poiId=poi.id;if(!pois[poiId])return;var poiBookmarked=pois[poiId].poiBookmarked;var rate=pois[poiId].rate;var countVoters=pois[poiId].countVoters;var voted=pois[poiId].voted;pois[poiId]=poi;pois[poiId].poiBookmarked=poiBookmarked;pois[poiId].rate=rate;pois[poiId].countVoters=countVoters;pois[poiId].voted=voted;}
PoisSelector.prototype.deletePoiById=function(poiId){var pois=ctx.getPois();delete pois[poiId];ctx.setPois(pois);}
PoisSelector.prototype.drawPois=function(pois){if(pois){ctx.setPois(pois);}
poisSelector.refreshCategoryList();poisSelector.refreshPoiListandDrawMarkers(Poi.getMap());}
PoisSelector.prototype.refreshCategoryList=function(){ctx.getCategoriesListPopup().refreshCounts();if(typeof categoriesList2!="undefined"){categoriesList2.refreshCounts();}}
PoisSelector.prototype.refreshPoiListandDrawMarkers=function(map){var poisCount=ctx.getPoisCount();var poiSortingEl=Dom.get("poi_sorting");if(poiSortingEl){if(poisCount<2){poiSortingEl.style.visibility="hidden";}
else{poiSortingEl.style.visibility="visible";}}
gmapHandler.drawMarkers();if(CallbackHandler.isPoiIndex()){var balloon;if(ctx.getEditBalloon().isShown()){balloon=ctx.getEditBalloon();}
else if(ctx.getViewBalloon().isShown()){balloon=ctx.getViewBalloon();}
if(balloon&&balloon.poi){PoisList.selectPoi(balloon.poi.id,undefined,true);}
else{PoisList.redraw();}}}
PoisSelector.prototype.isPoiFilteredByCategories=function(poi){var filtered=false;var poiCategories=poi.categoriesIds;var selectedCategories=ctx.getSelectedCategories();var n=poiCategories.length;var m=selectedCategories.length;for(var i=0;i<n;i++){for(var j=0;j<m;j++){if(poiCategories[i]==selectedCategories[j]){filtered=true;break;}}}
return filtered;}
PoisSelector.prototype.containsInCategory=function(categoryIds,categoryId){var n=categoryIds.length;for(var i=0;i<n;i++){if(categoryIds[i]==categoryId){return true;}}
return false;}
PoisSelector.prototype.changePoiCountInCategories=function(poi,isDelete){var oldPois=ctx.getPois();var poiCategories=poi.categoriesIds;if(oldPois[poi.id]&&!isDelete){var result=[];var oldPoiCategories=oldPois[poi.id].categoriesIds;var k=poiCategories.length;for(var i=0;i<k;i++){if(!this.containsInCategory(oldPoiCategories,poiCategories[i])){result.push(poiCategories[i]);}}
poiCategories=result;}
var categories=ctx.getCategories();var n=poiCategories.length;for(var i=0;i<n;i++){if(!isDelete){categories[poiCategories[i]].countPois=categories[poiCategories[i]].countPois+1;}else{categories[poiCategories[i]].countPois=categories[poiCategories[i]].countPois-1;}}
this.refreshCategoryList();}
PoisSelector.prototype.increasePoiCountInCategoriesIfNeed=function(poi){var poiCategories=poi.categoriesIds;var k=poiCategories.length;var categories=ctx.getCategories();for(var i=0;i<k;i++){if(categories[poiCategories[i]].countPois==0){categories[poiCategories[i]].countPois=1;}}
this.refreshCategoryList();}
PoisSelector.prototype.replacePoiForPoiList=function(poi){if(!poi)return;var poiId=poi.id;var pois=ctx.getPoisForPoiList();var n=pois.length;for(var i=0;i<n;i++){if(pois[i].id==poiId){var poiBookmarked=pois[i].poiBookmarked;var rate=pois[i].rate;var countVoters=pois[i].countVoters;var voted=pois[i].voted;pois[i]=poi;pois[i].poiBookmarked=poiBookmarked;pois[i].rate=rate;pois[i].countVoters=countVoters;pois[i].voted=voted;}}
return;}
AssertParameters=function(args,types,countOfNonOptionalArguments){if(arguments.length<2||arguments.length>3){throw new Error('Wrong parameters count. Must be two or three parameters.');}
if(args.length>types.length){throw new Error('Wrong parameters. Arguments length more than types length.');}
if(arguments.length==3){if(countOfNonOptionalArguments<0){throw new Error('Wrong parameters. Count of non optional arguments less than 0.');}
if(countOfNonOptionalArguments>types.length){throw new Error('Wrong parameters. Count of non optional arguments more than count of types.');}}
for(var index=0;index<types.length;index++){var isArgValid=args[index]!=null&&args[index].constructor==types[index];var isOptionalArgsPresent=(arguments.length==3);var nowOptionalArg=(index>=countOfNonOptionalArguments);var isArgNotValidAndNotOptional=(!isArgValid&&(typeof args[index]!='undefined'));var isArgumentNotValidInOptionMode=((!nowOptionalArg&&!isArgValid)||(nowOptionalArg&&isArgNotValidAndNotOptional));if((isOptionalArgsPresent&&isArgumentNotValidInOptionMode)||(!isOptionalArgsPresent&&!isArgValid)){throw new Error('Wrong parameters type. '+(index+1)+' th parameter have different type.');}}
return;};UIRequest=function(url,data,onSuccess,onFailure,arguments){var pleaseWaitAndOnSuccess=function(o){if(o&&o.getResponseHeader&&o.getResponseHeader.Location&&ctx.isAuthenticated()){location.href=location.reload();return;}
onSuccess(o);}
var callback={success:pleaseWaitAndOnSuccess,failure:(onFailure)?onFailure:errorHandler,argument:arguments}
var request=YAHOO.util.Connect.asyncRequest('POST',GlobalProperties.ACTION_HOST+url,callback,data);return request;};FormSubmit=function(formId,url,onSuccess,arg,onFailure){var callback={success:onSuccess,failure:(onFailure)?onFailure:errorHandler,argument:arg}
YAHOO.util.Connect.setForm(document.getElementById(formId));var request=YAHOO.util.Connect.asyncRequest('POST',GlobalProperties.ACTION_HOST+url,callback);};GetFieldValue=function(fieldId){AssertParameters(arguments,new Array(String));var field=document.getElementById(fieldId);if(field&&field.value&&(field.value!='')){return field.value;}
return null;};GetValidFieldValue=function(fieldId){AssertParameters(arguments,new Array(String));var field=document.getElementById(fieldId);if(field){return field.value;}
throw new Error("Field '"+fieldId+"' not found");};IsEmptyValue=function(value){return((!value)&&(value!='0'));};BuildRequestParameterFromField=function(fieldId,parameterName,existingParams){AssertParameters(arguments,new Array(String,String,String),2);var value=GetFieldValue(fieldId);if(value==null){if(IsEmptyValue(existingParams)){return'';}
return existingParams;}
var paraKeyValue=parameterName+'='+value;if(IsEmptyValue(existingParams)){return paraKeyValue;}else{return existingParams+'&'+paraKeyValue;}};(function(){var selectCategoryEvent=null;var deselectCategoryEvent=null;var expandCategoryGroupEvent=null;var collapseCategoryGroupEvent=null;var selectAllEvent=null;var deselectAllEvent=null;var expandAllCategoriesEvent=null;var collapseAllCategoriesEvent=null;CLIPTOO.AbstractCategoriesList=function(){if(selectCategoryEvent==null){selectCategoryEvent=new YAHOO.util.CustomEvent("onSelectCategory",this);}
this.selectCategory=selectCategoryEvent;if(deselectCategoryEvent==null){deselectCategoryEvent=new YAHOO.util.CustomEvent("onDeselectCategory",this);}
this.deselectCategory=deselectCategoryEvent;if(expandCategoryGroupEvent==null){expandCategoryGroupEvent=new YAHOO.util.CustomEvent("onExpandCategoryGroup",this);}
this.expandCategoryGroup=expandCategoryGroupEvent;if(collapseCategoryGroupEvent==null){collapseCategoryGroupEvent=new YAHOO.util.CustomEvent("onCollapseCategoryGroup",this);}
this.collapseCategoryGroup=collapseCategoryGroupEvent;if(selectAllEvent==null){selectAllEvent=new YAHOO.util.CustomEvent("onSelectAllCategories",this);}
this.selectAll=selectAllEvent;if(deselectAllEvent==null){deselectAllEvent=new YAHOO.util.CustomEvent("onDeselectAllCategories",this);}
this.deselectAll=deselectAllEvent;if(expandAllCategoriesEvent==null){expandAllCategoriesEvent=new YAHOO.util.CustomEvent("onExpandAllCategories",this);}
this.expandAll=expandAllCategoriesEvent;if(collapseAllCategoriesEvent==null){collapseAllCategoriesEvent=new YAHOO.util.CustomEvent("onCollapseAllCategories",this);}
this.collapseAll=collapseAllCategoriesEvent;this.init();this.selectCategory.subscribe(this.selectCategoryRow,this,true);this.deselectCategory.subscribe(this.deselectCategoryRow,this,true);this.expandCategoryGroup.subscribe(this.expandCategoriesGroup,this,true);this.collapseCategoryGroup.subscribe(this.collapseCategoriesGroup,this,true);this.selectAll.subscribe(this.selectAllCategories,this,true);this.deselectAll.subscribe(this.deselectCategories,this,true);this.expandAll.subscribe(this.expandCategories,this,true);this.collapseAll.subscribe(this.collapseCategories,this,true);};CLIPTOO.AbstractCategoriesList.prototype.init=function(){this.showScrollIfNeeded();var table=Dom.get(this.tableId);var rows=table.rows;var n=rows.length;var categoryGroupsCount=0;for(var i=0;i<n;i++){if(rows[i].childNodes.length==1){categoryGroupsCount++;}}
if(categoryGroupsCount>1){Event.addListener(this.collapseId,"click",this.onCollapseCategories,this,true);Event.addListener(this.expandId,"click",this.onExpandCategories,this,true);}
else{this.expandOrCollapseCategoriesGroup(null,0);rows[0].style.cursor="default";}
Event.addListener(this.selectAllId,"click",this.onSelectAllCategories,this,true);Event.addListener(this.deselectAllId,"click",this.onDeselectAllCategories,this,true);Event.addListener(this.tableId,"click",this.delegateClickEvent,categoryGroupsCount,this);Event.addListener(this.scrollerUpId,"mousedown",this.scrollUpEventHandler,this,true);Event.addListener(this.scrollerUpId,"mouseup",this.stopScrollUp,this,true);Event.addListener(this.scrollerDownId,"mousedown",this.scrollDownEventHandler,this,true);Event.addListener(this.scrollerDownId,"mouseup",this.stopScrollDown,this,true);Event.addListener(table,'DOMMouseScroll',this.scrollWheel,this,true);Event.addListener(table,'mousewheel',this.scrollWheel,this,true);this.mouseDown=null;this.mouseUp=null;};CLIPTOO.AbstractCategoriesList.prototype.scrollUp=function(){this.stopScrollDown();var table=Dom.get(this.tableId);var offset=parseInt(Dom.getStyle(table,"margin-top"))+10;if(offset>this.defaultTopMargin){offset=this.defaultTopMargin;}
table.style.marginTop=offset+"px";this.showScrollIfNeeded();};CLIPTOO.AbstractCategoriesList.prototype.scrollUpEventHandler=function(){if(!this.mouseUp){this.scrollUp();var that=this;this.mouseUp=setInterval(function(){that.scrollUp();},8);}};CLIPTOO.AbstractCategoriesList.prototype.scrollDown=function(){this.stopScrollUp();var table=Dom.get(this.tableId);var offset=parseInt(Dom.getStyle(table,"margin-top"))-10;if(offset<table.parentNode.offsetHeight-table.offsetHeight){offset=table.parentNode.offsetHeight-table.offsetHeight;}
table.style.marginTop=offset+"px";this.showScrollIfNeeded();};CLIPTOO.AbstractCategoriesList.prototype.scrollDownEventHandler=function(){if(!this.mouseDown){this.scrollDown();var that=this;this.mouseDown=setInterval(function(){that.scrollDown()},8);}};CLIPTOO.AbstractCategoriesList.prototype.stopScrollUp=function(){if(this.mouseUp){clearInterval(this.mouseUp);this.mouseUp=null;}};CLIPTOO.AbstractCategoriesList.prototype.stopScrollDown=function(){if(this.mouseDown){clearInterval(this.mouseDown);this.mouseDown=null;}};CLIPTOO.AbstractCategoriesList.prototype.scrollWheel=function(evt){this.stopScrollUp();this.stopScrollDown();var table=Dom.get(this.tableId);var scrolledUp=(evt.type=="DOMMouseScroll"&&evt.detail<0)||(evt.type=="mousewheel"&&evt.wheelDelta>0);if(!scrolledUp){if(Dom.get(this.scrollerDownId).style.visibility=="visible"){var offset=parseInt(Dom.getStyle(table,"margin-top"))-15;if(offset<table.parentNode.offsetHeight-table.offsetHeight){offset=table.parentNode.offsetHeight-table.offsetHeight;}}
else{if(table.offsetHeight>table.parentNode.offsetHeight){offset=table.parentNode.offsetHeight-table.offsetHeight;}
else{return;}}}
else{if(Dom.get(this.scrollerUpId).style.visibility=="visible"){var offset=parseInt(Dom.getStyle(table,"margin-top"))+15;if(offset>this.defaultTopMargin){offset=this.defaultTopMargin;}}
else{offset=this.defaultTopMargin;}}
table.style.marginTop=offset+"px";this.showScrollIfNeeded();Event.stopEvent(evt);};CLIPTOO.AbstractCategoriesList.prototype.onSelectCategoryRow=function(ev,categoriesList){var inputs=this.getElementsByTagName("input");var id=inputs[0].value;var name=inputs[1].value;if(typeof pageTracker!='undefined'){pageTracker._trackPageview("/categories/"+name);}
if(typeof pageTrackerGeneric!='undefined'){pageTrackerGeneric._trackPageview("/categories/"+name);}
if(this.className!="selected"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/categories_list/category_name/select");}
categoriesList.selectCategory.fire(id,name);ctx.addSelectedCategory(id);}
else{if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/categories_list/category_name/deselect");}
categoriesList.deselectCategory.fire(id,name);ctx.removeSelectedCategory(id);}
if(!!Dom.get("filterField")&&PoiListFilter.someEntered()){poisSelector.setPoisByCategoriesIdsAndCoordinatBound();}else if(ctx.getCategories()[id].countPois>0){poisSelector.reloadPois();}
CLIPTOO.poi.cookie.create("filter-categories",ctx.getSelectedCategories().join(","));};CLIPTOO.AbstractCategoriesList.prototype.selectCategoryRow=function(ev,arg){var rows=Dom.get(this.tableId).rows;var n=rows.length;for(var i=0;i<n;i++){var row=rows[i];if(row.childNodes.length>1){var categoryId=row.getElementsByTagName("input")[0].value;if(categoryId==arg[0]){row.title=PoiMsg.js_msg.categories.unSelectCategory()+" "+arg[1];row.className="selected";break;}}}};CLIPTOO.AbstractCategoriesList.prototype.deselectCategoryRow=function(ev,arg){var rows=Dom.get(this.tableId).rows;var n=rows.length;for(var i=0;i<n;i++){var row=rows[i];if(row.childNodes.length>1){var categoryId=row.getElementsByTagName("input")[0].value;if(categoryId==arg[0]){row.title=PoiMsg.js_msg.categories.selectCategory()+" "+arg[1];row.className="";break;}}}};CLIPTOO.AbstractCategoriesList.prototype.selectCategories=function(categories){var table=Dom.get(this.tableId);var rows=table.rows;var n=rows.length;var m=categories.length;var currentGrouRow;for(var i=0;i<n;i++){var row=rows[i];if(row.childNodes.length>1){var categoryId=row.getElementsByTagName("input")[0].value;for(var j=0;j<m;j++){if(categoryId==categories[j]){row.title=PoiMsg.js_msg.categories.unSelectCategory()+" "+row.getElementsByTagName("input")[1].value;row.className="selected";if(row.style.display=="none"){this.expandOrCollapseCategoriesGroup(null,currentGrouRow);}
break;}}}
else{currentGrouRow=i;}}};CLIPTOO.AbstractCategoriesList.prototype.onSelectAllCategories=function(){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/categories_list/select_all");}
this.selectAll.fire();var selectedCategories=[];var categories=ctx.getCategories();for(var i in categories){selectedCategories.push(categories[i].id);}
ctx.setSelectedCategories(selectedCategories);CLIPTOO.poi.cookie.create("filter-categories",ctx.getSelectedCategories().join(","));poisSelector.reloadPois();};CLIPTOO.AbstractCategoriesList.prototype.selectAllCategories=function(){var table=Dom.get(this.tableId);var rows=table.rows;var n=rows.length;for(var i=0;i<n;i++){var row=rows[i];if(row.childNodes.length>1){row.className="selected";}else{row.title=PoiMsg.js_msg.categories.unSelectCategoryGroup()+" "+row.getElementsByTagName("input")[0].value;}}};CLIPTOO.AbstractCategoriesList.prototype.onDeselectAllCategories=function(){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/categories_list/deselect_all");}
var map=Poi.getMap();ctx.setPois([]);map.clearMarkers();ctx.setRectangles([]);map.clearPoisAreaOverlays();map.removeRoutes();gmapHandler.removeOverlays();if(CallbackHandler.isPoiIndex()){PoisList.redraw();}
this.deselectAll.fire();ctx.setSelectedCategories([]);poisSelector.addInformationAboutFoundPois();CLIPTOO.poi.cookie.erase("filter-categories");};CLIPTOO.AbstractCategoriesList.prototype.deselectCategories=function(){var table=Dom.get(this.tableId);var rows=table.rows;var n=rows.length;n=rows.length;for(var i=0;i<n;i++){var row=rows[i];if(row.childNodes.length>1){row.className="";}else{row.title=PoiMsg.js_msg.categories.selectCategoryGroup()+" "+row.getElementsByTagName("input")[0].value;}}};CLIPTOO.AbstractCategoriesList.prototype.onCategoryGroupClickToExpandCollapse=function(e,rowNumber,alwaysExpand){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/categories_list/category_group/expand_collapse");}
var table=Dom.get(this.tableId);var group=table.rows[rowNumber];var closeGroup=Dom.getElementsByClassName("category-group-close","div",group)[0];if(closeGroup==null){this.expandCategoryGroup.fire(rowNumber);}
else if(closeGroup!=null&&alwaysExpand!=true){this.collapseCategoryGroup.fire(rowNumber);}};CLIPTOO.AbstractCategoriesList.prototype.expandCategoriesGroup=function(e,rowNumber){rowNumber=parseInt(rowNumber);var table=Dom.get(this.tableId);var group=table.rows[rowNumber];var rows=table.rows;var n=rows.length;var openGroup=Dom.getElementsByClassName("category-group-open","div",group)[0];openGroup.className="category-group-close";openGroup.title=PoiMsg.js_msg.categories.hide()+" "+group.getElementsByTagName("input")[0].value;for(var i=rowNumber+1;i<n;i++){var row=rows[i];if(row.childNodes.length>1){row.style.display="";}
else{break;}}
this.showScrollIfNeeded();};CLIPTOO.AbstractCategoriesList.prototype.collapseCategoriesGroup=function(e,rowNumber){rowNumber=parseInt(rowNumber);var table=Dom.get(this.tableId);var group=table.rows[rowNumber];var rows=table.rows;var n=rows.length;var closeGroup=Dom.getElementsByClassName("category-group-close","div",group)[0];closeGroup.className="category-group-open";closeGroup.title=PoiMsg.js_msg.categories.open()+" "+group.getElementsByTagName("input")[0].value;for(var i=rowNumber+1;i<n;i++){var row=rows[i];if(row.childNodes.length>1){row.style.display="none";}
else{break;}}
this.showScrollIfNeeded();};CLIPTOO.AbstractCategoriesList.prototype.onCategoryGroupClickToSelectDeselect=function(e,rowNumber){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/categories_list/category_group/select_deselect");}
var table=Dom.get(this.tableId);var group=table.rows[rowNumber];var closeGroup=Dom.getElementsByClassName("category-group-close","div",group)[0];if(closeGroup==undefined){this.expandCategoryGroup.fire(rowNumber);}
this.checkSelectionMode(rowNumber,closeGroup);};CLIPTOO.AbstractCategoriesList.prototype.checkSelectionMode=function(rowNumber,closeGroup){rowNumber=parseInt(rowNumber);var table=Dom.get(this.tableId);var rows=table.rows;var n=rows.length;for(var i=rowNumber+1;i<n;i++){var row=rows[i];if(row.childNodes.length>1){if(row.className!="selected"){var action="select";break;}}else if(closeGroup!=undefined){var action="deselect";break;}}
if(i==n){if(closeGroup!=undefined){var action="deselect";}else{var action="select";}}
var poisInGroup=this.selectDeselectAllCategoriesInGroup(rowNumber,rows,action);if(!!Dom.get("filterField")&&PoiListFilter.someEntered()){poisSelector.setPoisByCategoriesIdsAndCoordinatBound();}else if(poisInGroup){poisSelector.reloadPois();}
var group=rows[rowNumber];if(action=="select"){group.title=PoiMsg.js_msg.categories.unSelectCategoryGroup()+" "+group.getElementsByTagName("input")[0].value;}else{group.title=PoiMsg.js_msg.categories.selectCategoryGroup()+" "+group.getElementsByTagName("input")[0].value;}
CLIPTOO.poi.cookie.create("filter-categories",ctx.getSelectedCategories().join(","));this.showScrollIfNeeded();};CLIPTOO.AbstractCategoriesList.prototype.selectDeselectAllCategoriesInGroup=function(rowNumber,rows,action){var n=rows.length;var categories=ctx.getCategories();var poisInGroup=0;var group=rows[rowNumber];for(var i=rowNumber+1;i<n;i++){var row=rows[i];if(row.childNodes.length>1){var inputs=row.getElementsByTagName("input");var id=inputs[0].value;var name=inputs[1].value;poisInGroup+=categories[id].countPois;if(action=="select"){if(row.className!="selected"){this.selectCategory.fire(id,name);ctx.addSelectedCategory(id);this.pageTracker(name);}}else{if(row.className=="selected"){this.deselectCategory.fire(id,name);ctx.removeSelectedCategory(id);this.pageTracker(name);}}}
else{break;}}
return poisInGroup;};CLIPTOO.AbstractCategoriesList.prototype.pageTracker=function(name){if(typeof pageTracker!='undefined'){pageTracker._trackPageview("/categories/"+name);}
if(typeof pageTrackerGeneric!='undefined'){pageTrackerGeneric._trackPageview("/categories/"+name);}};CLIPTOO.AbstractCategoriesList.prototype.expandOrCollapseCategoriesGroup=function(e,rowNumber){var table=Dom.get(this.tableId);var group=table.rows[rowNumber];var rows=table.rows;var n=rows.length;var closeGroup=Dom.getElementsByClassName("category-group-close","div",group)[0];var displayType="";if(closeGroup==null){var openGroup=Dom.getElementsByClassName("category-group-open","div",group)[0];openGroup.className="category-group-close";openGroup.title=PoiMsg.js_msg.categories.hide()+" "+group.getElementsByTagName("input")[0].value;}
else{closeGroup.className="category-group-open";displayType="none"
closeGroup.title=PoiMsg.js_msg.categories.open()+" "+group.getElementsByTagName("input")[0].value;}
for(var i=rowNumber+1;i<n;i++){var row=rows[i];if(row.childNodes.length>1){row.style.display=displayType;}
else{break;}}
this.showScrollIfNeeded();};CLIPTOO.AbstractCategoriesList.prototype.onCollapseCategories=function(){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/categories_list/collapse_all");}
this.collapseAll.fire();}
CLIPTOO.AbstractCategoriesList.prototype.collapseCategories=function(){var table=Dom.get(this.tableId);var rows=table.rows;var n=rows.length;for(var i=0;i<n;i++){var row=rows[i];if(row.childNodes.length>1){row.style.display="none";}
else{var closeGroup=Dom.getElementsByClassName("category-group-close","div",row)[0];if(closeGroup){closeGroup.className="category-group-open";closeGroup.title=PoiMsg.js_msg.categories.open()+" "+row.getElementsByTagName("input")[0].value;}}}
table.style.marginTop=this.defaultTopMargin+"px";this.showScrollIfNeeded();};CLIPTOO.AbstractCategoriesList.prototype.onExpandCategories=function(){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/categories_list/expand_all");}
this.expandAll.fire();};CLIPTOO.AbstractCategoriesList.prototype.expandCategories=function(){var table=Dom.get(this.tableId);var rows=table.rows;var n=rows.length;for(var i=0;i<n;i++){var row=rows[i];if(row.childNodes.length>1){row.style.display="";}else{var openGroup=Dom.getElementsByClassName("category-group-open","div",row)[0];if(openGroup){openGroup.className="category-group-close";openGroup.title=PoiMsg.js_msg.categories.hide()+" "+row.getElementsByTagName("input")[0].value;}}}
this.showScrollIfNeeded();};CLIPTOO.AbstractCategoriesList.prototype.showScrollIfNeeded=function(){var table=Dom.get(this.tableId);if(parseInt(Dom.getStyle(table,"margin-top"))<this.defaultTopMargin){Dom.get(this.scrollerUpId).style.visibility="visible";}
else{Dom.get(this.scrollerUpId).style.visibility="hidden";this.stopScrollUp();}
if(parseInt(Dom.getStyle(table,"margin-top"))>table.parentNode.offsetHeight-table.offsetHeight){Dom.get(this.scrollerDownId).style.visibility="visible";}
else{Dom.get(this.scrollerDownId).style.visibility="hidden";this.stopScrollDown();}};CLIPTOO.AbstractCategoriesList.prototype.refreshCounts=function(){var categories=ctx.getCategories();var table=Dom.get(this.tableId);var rows=table.rows;var n=rows.length-1;var poisInGroup=0;for(var i=n;i>-1;i--){var row=rows[i];var inputs=row.getElementsByTagName("input");if(row.childNodes.length>1){var categoryInfo=row.getElementsByTagName("td")[1];categoryInfo.innerHTML=inputs[1].value+" ("+categories[inputs[0].value].countPois+")";poisInGroup+=categories[inputs[0].value].countPois;}
else{var categoryGroupInfo=row.getElementsByTagName("span")[0];if(poisInGroup<10){var spanWidth=180;}
else if((poisInGroup>9)&&(poisInGroup<100)){spanWidth=170;}
else if((poisInGroup>99)&&(poisInGroup<1000)){spanWidth=169;}
else{spanWidth=163;}
categoryGroupInfo.innerHTML=inputs[0].value;CLIPTOO.utils.shrinkOneRowTextByWidth(categoryGroupInfo,20,spanWidth,50);categoryGroupInfo.innerHTML=categoryGroupInfo.innerHTML+" ("+poisInGroup+")";poisInGroup=0;}}
this.showScrollIfNeeded();};CLIPTOO.AbstractCategoriesList.prototype.delegateClickEvent=function(ev,categoryGroupsCount){var target=ev.target?ev.target:ev.srcElement;var row=target;while(row.className!="categories-list-table"&&row.tagName!="TR"&&row.className!="category-group-close"&&row.className!="category-group-open"){row=row.parentNode;}
if(row.className=="category-group-close"||row.className=="category-group-open"){if(categoryGroupsCount>1){var rowIndex=row.parentNode.parentNode.parentNode.rowIndex;if(rowIndex==undefined){rowIndex=row.parentNode.parentNode.parentNode.parentNode.rowIndex;}
this.onCategoryGroupClickToExpandCollapse(ev,rowIndex);}}
if(row.tagName=="TR"){if(row.childNodes.length>1){this.onSelectCategoryRow.apply(row,[ev,this]);}
else{this.onCategoryGroupClickToSelectDeselect(ev,row.rowIndex);}}}})();CLIPTOO.CategoriesListPopup=function(hideByDefault){this.defaultTopMargin=-10;this.tableId="categoriesList";this.collapseId="categoriesCollapser";this.expandId="categoriesExpander";this.scrollerUpId="categoriesScrollerUp";this.scrollerDownId="categoriesScrollerDown";this.selectAllId="categoriesSelectAll";this.deselectAllId="categoriesDeselectAll";this.constructor.superclass.constructor.apply(this,[]);if(hideByDefault){Dom.get("categoriesListPopup").style.display="none";}};YAHOO.lang.extend(CLIPTOO.CategoriesListPopup,CLIPTOO.AbstractCategoriesList);CLIPTOO.CategoriesList=function(){this.defaultTopMargin=0;this.tableId="categoriesList2";this.collapseId="categoriesCollapser2";this.expandId="categoriesExpander2";this.scrollerUpId="categoriesScrollerUp2";this.scrollerDownId="categoriesScrollerDown2";this.selectAllId="categoriesSelectAll2";this.deselectAllId="categoriesDeselectAll2";this.constructor.superclass.constructor.apply(this,arguments);};YAHOO.lang.extend(CLIPTOO.CategoriesList,CLIPTOO.AbstractCategoriesList);var categoriesList2=new CLIPTOO.CategoriesList();function errorHandler(message,url,lineNumber){popupHandler.showErrorPopup("Server error");return true;};function validationErrorHandler(msg){popupHandler.showErrorPopup(msg);};YAHOO.namespace("YAHOO.scroll");(function(){var Lang=YAHOO.lang;YAHOO.scroll=function(){var _iSpeed=3,_oCrossObj=null,_iTimeout=8;var _moveLeftVar,_moveRightVar;var upScroll=null,downScroll=null,contentScroll=null;var m_scrolls={},_currentScroll=null;function _updateCurrentScroll(p_oThis,p_bIsUpButton){if(p_oThis.tagName){_setScrollObjOfScrollButton(p_oThis,p_bIsUpButton);}}
function _moveLeft(){_updateCurrentScroll(this,true);_clearRightVar();if(parseInt(_oCrossObj.style.marginLeft)<=-1){_oCrossObj.style.marginLeft=parseInt(_oCrossObj.style.marginLeft)+_iSpeed+"px";Dom.removeClass(downScroll,"blocked_down");}else{Dom.addClass(upScroll,"blocked_up");}
_moveLeftVar=setTimeout(_moveLeft,_iTimeout);}
function _moveRight(){_updateCurrentScroll(this,false);_clearLeftVar();if(parseInt(_oCrossObj.style.marginLeft)>=(_oCrossObj.firstChild.offsetWidth*(-1)+_oCrossObj.parentNode.offsetWidth)){_oCrossObj.style.marginLeft=parseInt(_oCrossObj.style.marginLeft)-_iSpeed+"px";Dom.removeClass(upScroll,"blocked_up");}else{Dom.addClass(downScroll,"blocked_down");}
_moveRightVar=setTimeout(_moveRight,_iTimeout);}
function _stopscroll(){if(window.moveupvar)
clearTimeout(moveupvar);if(window.movedownvar)
clearTimeout(movedownvar);}
function _moveleft(){_stopscroll();_oCrossObj.style.marginLeft=1+"px";}
function _getContentHeight(){contentheight=_oCrossObj.offsetHeight;}
function _clearRightVar(){if(_moveRightVar)
clearTimeout(_moveRightVar);}
function _clearLeftVar(){if(_moveLeftVar)
clearTimeout(_moveLeftVar);}
function _createWidget(p_oContainer){var innerContent=p_oContainer.innerHTML;p_oContainer.innerHTML="";upScroll=document.createElement("div");p_oContainer.appendChild(upScroll);var separatorInUpScroll=document.createElement("div");upScroll.appendChild(separatorInUpScroll);contentScroll=document.createElement("div");p_oContainer.appendChild(contentScroll);downScroll=document.createElement("div");p_oContainer.appendChild(downScroll);var separatorInDownScroll=document.createElement("div");downScroll.appendChild(separatorInDownScroll);var widgetContainer=document.createElement("div");contentScroll.appendChild(widgetContainer);Dom.addClass(upScroll,"up_scroll_horizontal");Dom.addClass(contentScroll,"scroll_content_horizontal");Dom.addClass(widgetContainer,"content_horizontal");Dom.addClass(downScroll,"down_scroll_horizontal");Event.addListener(downScroll,'mouseover',_moveRight);Event.addListener(downScroll,'mouseout',_clearRightVar);Event.addListener(upScroll,'mouseover',_moveLeft);Event.addListener(upScroll,'mouseout',_clearLeftVar);widgetContainer.id=p_oContainer.id;widgetContainer.innerHTML=innerContent;p_oContainer.id=p_oContainer.id+"_c";_oCrossObj=widgetContainer;_oCrossObj.style.marginLeft="0px";_oCrossObj.style.marginTop="0px";Dom.addClass(upScroll,"blocked_up");Dom.addClass(downScroll,"blocked_down");_currentScroll={upScroll:upScroll,downScroll:downScroll,crossObect:_oCrossObj};m_scrolls[_oCrossObj.id]=_currentScroll;}
function _setScrollObjOfScrollButton(p_oButton,p_bIsUpButton){var scrollContent;if(p_bIsUpButton){scrollContent=Dom.getNextSibling(p_oButton);}else{scrollContent=Dom.getPreviousSibling(p_oButton);}
_currentScroll=m_scrolls[scrollContent.firstChild.id];_setCurrentScrollParams();}
function _setCurrentScrollParams(){upScroll=_currentScroll.upScroll;downScroll=_currentScroll.downScroll;_oCrossObj=_currentScroll.crossObect;}
function showHideHorScrollsAutomatically(){var marginLeft=parseInt(Dom.getStyle(_oCrossObj,"margin-left"));var listWidth=_oCrossObj.firstChild?_oCrossObj.firstChild.offsetWidth:_oCrossObj.offsetWidth;if(marginLeft==0){Dom.addClass(upScroll,"blocked_up");}
else{Dom.removeClass(upScroll,"blocked_up");}
if(listWidth<=_oCrossObj.parentNode.offsetWidth||!(parseInt(_oCrossObj.style.marginLeft)>=(_oCrossObj.firstChild.offsetWidth*(-1)+_oCrossObj.parentNode.offsetWidth))){Dom.addClass(downScroll,"blocked_down");}
else{Dom.removeClass(downScroll,"blocked_down");}}
return{init:function(p_sElementId){var container=Dom.get(p_sElementId);this.elementId=p_sElementId;if(!container||!container.parentNode){return null;}
_createWidget(container);this.showHorScrollIfNeeded();},showHorScrollIfNeeded:function(){showHideHorScrollsAutomatically();},refresh:function(p_sElementId){p_sElementId=this.elementId;var container=Dom.get(p_sElementId);if(!container){throw new Error('call without el id ',this);return;}
_currentScroll=m_scrolls[p_sElementId];_setCurrentScrollParams();_moveleft();var offsetWidth=(_oCrossObj.firstChild.offsetWidth)?_oCrossObj.firstChild.offsetWidth:_oCrossObj.offsetWidth;if(offsetWidth<=_oCrossObj.parentNode.offsetWidth){Dom.addClass(upScroll,"blocked_up");Dom.addClass(downScroll,"blocked_down");}else{Dom.addClass(upScroll,"blocked_up");Dom.removeClass(downScroll,"blocked_down");}}}}})();YAHOO.extend(YAHOO.scroll,YAHOO.util.Element);CLIPTOO.createPackage('utils.Footer');(function(){CLIPTOO.utils.Footer={initFooterLayout:function(){var i18n=PoiMsg.js_msg.footer;var that=this;Event.addListener("whoweare_link","click",function(){that.contentHandler(i18n.who.we.are(),"whoweare");});Event.addListener("faq_link","click",function(){that.contentHandler(i18n.faq(),"faq");});Event.addListener("disclaimer_link","click",function(){that.contentHandler(i18n.disclaimer(),"disclaimer");});if(Dom.get("registration_link")){Event.addListener("registration_link","click",function(){that.contentHandler(i18n.registration(),"registration");});}
Event.addListener("terms_link","click",function(){that.contentHandler(i18n.terms.conditions(),"terms");});Event.addListener("privacy_link","click",function(){that.contentHandler(i18n.terms.privacyPolicy(),"privacy");});Event.addListener("overheid_help","click",function(){that.contentHandler(PoiMsg.js_msg.overheid.help.popup(),"help");});if(Dom.get("requirements_link")){Event.addListener("requirements_link","click",function(){that.contentHandler(i18n.requirements(),"requirements");});}
if(Dom.get("contest_link")){Event.addListener("contest_link","click",function(){that.contentHandler(i18n.contest(),"contest");});}},contentHandler:function(header,type){popupHandler.showPleaseWait();UIRequest("loadFooterContent.action","contentType="+type,function(o){var content=o.responseText;popupHandler.showFooterContentPopup(header,content);popupHandler.hidePleaseWait();});}}})();(function(){var _map=null;var initUserProfile=function(){var userProfile={isRegionPermission:false,isCategoryPermission:false};var userPermittedRegionWest=Dom.get('userPermittedRegionWest');if(userPermittedRegionWest&&userPermittedRegionWest.value!=''){userProfile.permittedRegionSouth=parseFloat(Dom.get('userPermittedRegionSouth').value);userProfile.permittedRegionWest=parseFloat(Dom.get('userPermittedRegionWest').value);userProfile.permittedRegionNorth=parseFloat(Dom.get('userPermittedRegionNorth').value);userProfile.permittedRegionEast=parseFloat(Dom.get('userPermittedRegionEast').value);userProfile.isRegionPermission=true;var excludedCategoriesEl=Dom.get('userExcludedCategoryIds');if(excludedCategoriesEl&&excludedCategoriesEl.value!=''){userProfile.excludedCategoryIds=excludedCategoriesEl.value;}}else{var permitedCategoriesEl=Dom.get('userPermittedCategoryIds');if(permitedCategoriesEl&&permitedCategoriesEl.value!=''){userProfile.permittedCategoryIds=permitedCategoriesEl.value;userProfile.isCategoryPermission=true;}}
ctx.setUserProfile(userProfile);}
CLIPTOO.poi=function(){ctx.setCategoriesListPopup(new CLIPTOO.CategoriesListPopup(false));SendToFriend=new YAHOO.SendToFriend();InfoRequest=new CLIPTOO.InfoRequest();PoisList=new YAHOO.PoisListTable("list_of_pois","pag");CLIPTOO.Poi.Tabs.initTabs();CLIPTOO.InitParameters.isCategoryListShown();CLIPTOO.InitParameters.isPoiListShown();CLIPTOO.themeSelector();CLIPTOO.utils.Resize.loadIndexSwitcher();Dom.get('global_container').style.visibility="visible";CLIPTOO.utils.Footer.initFooterLayout();initUserProfile();callbackHandler=new CallbackHandler();poisSelector=new PoisSelector();gmapHandler=new GMapHandler();_map=new CLIPTOO.poi.map.PoiMap();_map.initMap();_map.setMapType(_map.CLIPTOO_UKRAINE);var addTileOverlay=function(){var myCopyright=new GCopyrightCollection("� ");myCopyright.addCopyright(new GCopyright('Demo',new GLatLngBounds(new GLatLng(-90,-180),new GLatLng(90,180)),0,'�2010 Google'));var tilelayer=new GTileLayer(myCopyright);tilelayer.getTileUrl=function(gpoint,zoom){};tilelayer.isPng=function(){return true;};tilelayer.getOpacity=function(){return 1.0;}
var myTileLayer=new GTileLayerOverlay(tilelayer);ctx.setTileOverlay(myTileLayer);};addTileOverlay();_map.showPermittedArea();Poi={getMap:function(){return _map;}}
var easyCreatingConfig={disabler:"easyCreatingDisabler",addressField:"easyCreatingSearchMap",resetButton:"easyCreatingResetBtn",searchButton:"easyCreatingSearchBtn",roundPopup:"easyCreatingRound",resultHint:"easyCreatingQuestionHint",resultList:"easyCreatingSearchResultListArea",nothingFoundHint:"easyCreatingNothingFoundHint",outherContainer:"easyCreatingPopup",searchName:PoiMsg.js_msg.search.createPoiTitle(),searchHint:PoiMsg.js_msg.search.hint()}
var jumpToConfig={disabler:"jumpToDisabler",addressField:"jumpToSearchMap",resetButton:"jumpToResetBtn",searchButton:"jumpToSearchBtn",roundPopup:"jumpToRound",resultHint:"jumpToQuestionHint",resultList:"jumpToSearchResultListArea",nothingFoundHint:"jumpToNothingFoundHint",outherContainer:"jumpToPopup",searchName:PoiMsg.js_msg.search.searchAddress(),searchHint:PoiMsg.js_msg.search.searchAddressHint()}
ctx.setEasyCreatingForm(new EasyCreatingControl(easyCreatingConfig));ctx.setMapLayersControl(new MapLayerControl());ctx.setUploadPOAControl(new MapPointOfAreaControl());ctx.setUploadRouteControl(new UploadRouteControl());CLIPTOO.utils.mapToolbarPopupPosition();PoiListSorting=initPoiListSorting();var configFilter={inputSearchField:Dom.get('filterField'),inputResetButton:Dom.get('resetFilter'),inputFilterContainer:Dom.get('filterContainer')}
PoiListFilter=CLIPTOO.Filter(function(){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/poi_list/filter");}
poisSelector.setPoisByCategoriesIdsAndCoordinatBound();},configFilter);var rootCategoryGroupRights=CLIPTOO.accessRightsSystem.rootCategoryGroup;rootCategoryGroupRights.usePoiCommunity=ctx.getOrgProperty('usePoiCommunity');ctx.setViewBalloon(new ViewBalloon());ctx.setEditBalloon(new IndexEditBalloon());CLIPTOO.poi.map.Toolbar.create(_map);CLIPTOO.createPackage("platform.settings");CLIPTOO.utils.useDataFromOtherApp();CLIPTOO.utils.header.runWidgetAfterReload();popupHandler.hidePleaseWait();return{getMap:function(){return _map},loadPoiData:function(poi){gmapHandler.showBalloon(poi);}};}
var initPoiListSorting=function(){return CLIPTOO.Sorting(function(){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/poi_list/sorted_by");}
if(ctx.getPoisCount()<=1&&ctx.getPoisForPoiListCount()<=1)return;PoisList.redraw(1);},function(){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/poi_list/sorting_asc_desc");}
if(ctx.getPoisCount()<=1&&ctx.getPoisForPoiListCount()<=1)return;poisSelector.loadPoisPageForPoiList(PoisList.paging.getCurrentPage(),PoisList.poisPerPage,function(pois){PoisList.loadPage(pois);});});}})();CLIPTOO.createPackage('map');CLIPTOO.map.PoiMarker=function(poi,latlng){opt_opts={icon:this.getPoiIcon_(poi),bouncy:false,bounceGravity:0,draggable:poi?(poi.editable&&!Dom.get('right_recent_stories')):false}
this.opts_=opt_opts;this.clickable_=opt_opts.clickable||true;this.div_=document.createElement("div");this.div_.className="poi-marker";if(poi){this.updateIcon(ctx.getCategories()[poi.mainCategoryId].code,poi);this.poiId=poi.id;}
else{this.div_.style.backgroundPosition="0px 0px";}
if(opt_opts.draggable){GEvent.addListener(this,"dragstart",this.handleOnDragStart_);GEvent.addListener(this,"dragend",this.handleOnDragEnd_);GEvent.addListener(this,"drag",this.handleOnDrag_);}
GEvent.addListener(this,"mouseover",this.handleOnMouseOver_);GEvent.addListener(this,"mouseout",this.handleOnMouseOut_);GEvent.addListener(this,"click",this.handleOnClick_);if(poi){this.poiId=poi.id;latlng=new GLatLng(poi.latitude,poi.longitude);}
this.lastPosition=latlng;GMarker.apply(this,[latlng,opt_opts]);}
CLIPTOO.map.PoiMarker.prototype=new GMarker(new GLatLng(0,0));CLIPTOO.map.PoiMarker.MAP_FOR_SIMPLE_MARKER=[0,6,24,6,24,30,15,30,12,45,9,30,0,30];CLIPTOO.map.PoiMarker.MAP_FOR_MULTI_CAT_MARKER=[0,6,16,6,16,3,27,3,27,14,24,14,24,30,15,30,12,45,9,30,0,30];CLIPTOO.map.PoiMarker.MAP_FOR_MULTI_CAT_AND_ADS_MARKER=[0,6,12,6,12,0,23,0,23,13,27,3,27,14,24,14,24,30,15,30,12,45,9,30,0,30];CLIPTOO.map.PoiMarker.prototype.handleOnClick_=function(){var map=Poi.getMap();var poi=ctx.getPoiById(this.poiId);if(!Dom.get('right_recent_stories')){if(typeof pageTracker!='undefined'){pageTracker._trackPageview("/pois/"+poi.name+"/"+poi.id);}
if(typeof pageTrackerGeneric!='undefined'){pageTrackerGeneric._trackPageview("/pois/"+poi.name+"/"+poi.id);}
gmapHandler.showBalloon(poi);}else{map.panTo(new GLatLng(poi.latitude,poi.longitude));Poi.loadPoiData(poi,this);}};CLIPTOO.map.PoiMarker.prototype.handleOnDrag_=function(point){var poi=ctx.getPoiById(this.poiId);var categoryType=ctx.getCategories()[poi.mainCategoryId].categoryType;if(categoryType==GlobalProperties.ROUTE&&!routes[poi.id]){this.setLatLng(new GLatLng(poi.latitude,poi.longitude));}
else{var map=Poi.getMap();if(map.isPermitedToCreateArea(point)){this.lastPosition=point;}
else{this.setLatLng(this.lastPosition);}}};CLIPTOO.map.PoiMarker.prototype.handleOnDragStart_=function(){var map=Poi.getMap();map.closeBalloon();ctx.getPoisTooltip().hide();};CLIPTOO.map.PoiMarker.prototype.handleOnDragEnd_=function(){var poi=ctx.getPoiById(this.poiId);if(!poi.editable){return;}
var map=Poi.getMap();var categoryType=ctx.getCategories()[poi.mainCategoryId].categoryType;if(categoryType==GlobalProperties.ROUTE&&routes[poi.id]){var nodePoint=map.findClosestRouteNode(poi.id,this.getLatLng());this.setLatLng(nodePoint);}
else if(categoryType==GlobalProperties.ROUTE){popupHandler.hidePleaseWait();popupHandler.showErrorPopup(PoiMsg.js_msg.marker.dragWithoutRoute());return;}
ctx.setCurrentPoi(poi);ctx.getEditBalloon().showForDraggedPoi(poi,this.getLatLng());};CLIPTOO.map.PoiMarker.prototype.handleOnMouseOver_=function(){ctx.getPoisTooltip().setMouseOnMarker(true);var poi=ctx.getPoiById(this.poiId);ctx.getPoisTooltip().show(poi);this.showOnTopLayer();};CLIPTOO.map.PoiMarker.prototype.handleOnMouseOut_=function(){ctx.getPoisTooltip().setMouseOnMarker(false);var poi=ctx.getPoiById(this.poiId);if(poi){if(poi.advertisementBasisCM){setTimeout(function(){ctx.getPoisTooltip().hideIfMouseOutOf();},500);}else{ctx.getPoisTooltip().hide();}}
this.showOnDefaultLayer();};CLIPTOO.map.PoiMarker.prototype.getPoiIcon_=function(poi){var baseIcon=new GIcon(G_DEFAULT_ICON);baseIcon.image=GlobalProperties.HOST+"themes/default/img/transparent.png";baseIcon.iconSize=new GSize(GlobalProperties.MAPS_CATEGORY_ICON_WIDTH,GlobalProperties.MAPS_CATEGORY_ICON_HEIGHT);baseIcon.iconAnchor=new GPoint(GlobalProperties.MAPS_CATEGORY_ANCHOR_X,GlobalProperties.MAPS_CATEGORY_ANCHOR_Y);baseIcon.infoWindowAnchor=new GPoint(GlobalProperties.POI_INFO_WINDOW_ANCHOR_X,GlobalProperties.POI_INFO_WINDOW_ANCHOR_Y);if(THEME_NAME=="chamber"||THEME_NAME=="overheid"){baseIcon.shadow=GlobalProperties.HOST+"themes/chamber/img/sprites/shadow.png";}else{baseIcon.shadow=GlobalProperties.HOST+"themes/default/img/poi/shadow.png";}
baseIcon.shadowSize=new GSize(GlobalProperties.MAPS_CATEGORY_SHADOW_WIDTH,GlobalProperties.MAPS_CATEGORY_SHADOW_HEIGHT);var isWithAds=poi?(poi.advertisementBasisCM!=null):false;var isMultyCat=poi?(poi.categoriesIds.length>1):false;if(isWithAds&&isMultyCat){baseIcon.imageMap=CLIPTOO.map.PoiMarker.MAP_FOR_MULTI_CAT_AND_ADS_MARKER;}
else if(isWithAds||isMultyCat){baseIcon.imageMap=CLIPTOO.map.PoiMarker.MAP_FOR_MULTI_CAT_MARKER;}
else{baseIcon.imageMap=CLIPTOO.map.PoiMarker.MAP_FOR_SIMPLE_MARKER;}
return baseIcon;};CLIPTOO.map.PoiMarker.prototype.initialize=function(map){GMarker.prototype.initialize.apply(this,arguments);this.map_=map;map.getPane(G_MAP_MARKER_PANE).appendChild(this.div_);if(this.clickable_){var eventPassthrus=['click','dblclick','mousedown','mouseup','mouseover','mouseout'];for(var i=0;i<eventPassthrus.length;i++){var name=eventPassthrus[i];GEvent.addDomListener(this.div_,name,GEvent.callback(GEvent,GEvent.trigger,this,name,this.getLatLng()));}}};CLIPTOO.map.PoiMarker.prototype.redraw=function(force){GMarker.prototype.redraw.apply(this,arguments);this.redrawIcon_();};CLIPTOO.map.PoiMarker.prototype.updateIcon=function(categoryCode,poi){var xPos=(0-categoryCode%10)*(GlobalProperties.MAPS_CATEGORY_ICON_WIDTH-1);var yPos=(0-Math.floor(categoryCode/10))*GlobalProperties.MAPS_CATEGORY_ICON_HEIGHT;this.div_.style.backgroundPosition=xPos+"px "+yPos+"px";this.deleteIcon_("advertisement-marker-position");this.deleteIcon_("advertisement-second-marker-position");this.deleteIcon_("multicategories-marker");this.deleteIcon_("multicategories-second-marker");var isWithAds=(poi.advertisementBasisCM!=null);if(poi.categoriesIds.length>1){var newMultyCatMarker=document.createElement('div');newMultyCatMarker.className=isWithAds?"multicategories-second-marker":"multicategories-marker";this.div_.appendChild(newMultyCatMarker);}
if(isWithAds){var adsMarker=document.createElement('div');if(!poi.advertisementBasisCM.expired&&poi.advertisementBasisCM.payd){adsMarker.className="advertisement-marker";}
if(!poi.advertisementBasisCM.payd){adsMarker.className="advertisement-expired-poi-marker";}
adsMarkerPositionClassName=(poi.categoriesIds.length>1)?"advertisement-second-marker-position":"advertisement-marker-position";Dom.addClass(adsMarker,adsMarkerPositionClassName);this.div_.appendChild(adsMarker);}};CLIPTOO.map.PoiMarker.prototype.deleteIcon_=function(className){var oldIcon=Dom.getElementsByClassName(className,"div",this.div_);if(oldIcon.length>0){this.div_.removeChild(oldIcon[0]);}};CLIPTOO.map.PoiMarker.prototype.redrawIcon_=function(){var p=this.map_.fromLatLngToDivPixel(this.getLatLng());var z=GOverlay.getZIndex(this.getLatLng().lat());var draggingCorrection=this.dragging()?14:0;this.div_.style.left=(p.x-GlobalProperties.MAPS_CATEGORY_ANCHOR_X)+"px";this.div_.style.top=(p.y-GlobalProperties.MAPS_CATEGORY_ANCHOR_Y-draggingCorrection)+"px";this.div_.style.zIndex=z;};CLIPTOO.map.PoiMarker.prototype.remove=function(){var n=this.div_.childNodes.length;for(var i=0;i<n;i++){GEvent.clearInstanceListeners(this.div_.childNodes[i]);}
GEvent.clearInstanceListeners(this.div_);if(this.div_.outerHTML){this.div_.outerHTML="";}
if(this.div_.parentNode){this.div_.parentNode.removeChild(this.div_);}
this.div_=null;GMarker.prototype.remove.apply(this,arguments);};CLIPTOO.map.PoiMarker.prototype.copy=function(){var newMarker=new CLIPTOO.map.PoiMarker(this.getLatLng(),this.opts_);return newMarker;};CLIPTOO.map.PoiMarker.prototype.showOnTopLayer=function(){this.zIndex=parseInt(this.V[0].style.zIndex);this.V[0].style.zIndex=1;};CLIPTOO.map.PoiMarker.prototype.showOnDefaultLayer=function(){this.V[0].style.zIndex=this.zIndex;};CLIPTOO.createPackage("poi.map");(function(){var _selectedAreaDiv=null,poisAreaTooltip,markers,poisAreaOverlays,mapDisabler,initializedRouteEventHandle,restrictedRouteEventHandle,cleanRouteEvents=function(){GEvent.removeListener(restrictedRouteEventHandle);GEvent.removeListener(initializedRouteEventHandle);},firstLoading=true;CLIPTOO.poi.map.Map=function(){var getProperty=ctx.getOrgProperty;var userPermittedRegionWest=Dom.get('userPermittedRegionWest');var userProfile=ctx.getUserProfile();if(userProfile.isRegionPermission){var southWest=new GLatLng(userProfile.permittedRegionSouth,userProfile.permittedRegionWest);var northEast=new GLatLng(userProfile.permittedRegionNorth,userProfile.permittedRegionEast);this.permittedBounds=new GLatLngBounds(southWest,northEast);}else{if(userProfile.isCategoryPermission){this.permittedArea=null;this.permittedBounds=null;}else{var permittedRegionCoordinates=getProperty("permittedRegionCoordinates");if(permittedRegionCoordinates!=null&&permittedRegionCoordinates!=""&&permittedRegionCoordinates!='null'){this.permittedArea=[];var coords=permittedRegionCoordinates.split('&');var n=coords.length;for(var i=0;i<n;i++){var pointCoords=coords[i].split(',');this.permittedArea.push(new GLatLng(parseFloat(pointCoords[0]),parseFloat(pointCoords[1])));}}
else{this.permittedArea=null;}
if(getProperty("permittedRegionEast")!=null&&getProperty("permittedRegionEast")!=""){var southWest=new GLatLng(parseFloat(getProperty("permittedRegionSouth")),parseFloat(getProperty("permittedRegionWest")));var northEast=new GLatLng(parseFloat(getProperty("permittedRegionNorth")),parseFloat(getProperty("permittedRegionEast")));this.permittedBounds=new GLatLngBounds(southWest,northEast);}
else{this.permittedBounds=null;}}}
var mapContainer=document.getElementById(GlobalProperties.MAIN_GOOGLE_MAP_ID);this.constructor.superclass.constructor.superclass.constructor.apply(this,[mapContainer,{mapTypes:CLIPTOO.poi.map.types.getMapTypes()}]);mapContainer.style.position="absolute";this.enableContinuousZoom();this.disableInfoWindow();mapDisabler=document.createElement("div");mapDisabler.id="mapDisabler";Dom.get(GlobalProperties.MAIN_GOOGLE_MAP_ID).getElementsByTagName("div")[0].getElementsByTagName("div")[0].appendChild(mapDisabler);mapDisabler.style.display="none";poisAreaTooltip=new CLIPTOO.poi.map.PoisAreaTooltip(this);ctx.setPoisTooltip(new CLIPTOO.poi.map.PoisInformationTooltip(this));this.mode=this.MAP_VIEWING;markers=[];poisAreaOverlays=[];this.poaOverlays=[];this.groundOverlays=[];this.layerOverlays=[];this.poaGroundOverlays=[];this.tileOverlays=[];attachHandlers(this);}
YAHOO.lang.extend(CLIPTOO.poi.map.Map,GMap2);CLIPTOO.poi.map.Map.prototype.MAP_VIEWING=0;CLIPTOO.poi.map.Map.prototype.MAP_POI_CREATING=1;CLIPTOO.poi.map.Map.prototype.MAP_ZOOMIN_IN=2;CLIPTOO.poi.map.Map.prototype.MAP_ZOOMIN_OUT=3;CLIPTOO.poi.map.Map.prototype.initMap=function(){var defaultMapTypeCode=CLIPTOO.poi.cookie.read("map-type");if(!defaultMapTypeCode){defaultMapTypeCode=ctx.getOrgProperty("defaultMapView");}
var defaultMapType=CLIPTOO.poi.map.types.getMapTypeByCode(defaultMapTypeCode);this.setMapType(defaultMapType);this.initMapPosition();this.positionLicence();}
CLIPTOO.poi.map.Map.prototype.initMapPosition=function(){firstLoading=true;}
CLIPTOO.poi.map.Map.prototype.showPermittedArea=function(){if(this.permittedArea){var points=this.permittedArea;var polylineOuter=new GPolyline(points,'#8394a6',9,0.5);var polylineInner=new GPolyline(points,'#5a5a65',3,1);this.addOverlay(polylineOuter);this.addOverlay(polylineInner);}}
CLIPTOO.poi.map.Map.prototype.position=function(centerX,centerY,zoom){if(!isNaN(zoom)&&!isNaN(centerX)&&!isNaN(centerY)){this.setCenter(new GLatLng(centerY,centerX),zoom)}
else{this.setCenter(new GLatLng(50.41551870402677,6.4665524661540985),6);}
firstLoading=false;}
CLIPTOO.poi.map.Map.prototype.positionLicence=function(){var mapContainer=document.getElementById('google_map_main');mapContainer.childNodes[1].style.bottom="12px";mapContainer.childNodes[1].style.right="12px";mapContainer.childNodes[2].style.bottom="12px";mapContainer.childNodes[2].style.left="12px";}
CLIPTOO.poi.map.Map.prototype.savePosition=function(){}
function attachHandlers(map){GEvent.addListener(map,"load",function(){new CLIPTOO.poi.map.PoiGMapHistory({next:"map_poi_map_next_toolbar",back:"map_poi_map_back_toolbar",map:map});var deadAreaControl=new DeadAreaControl();ctx.setDeadAreaControl(deadAreaControl);map.addControl(deadAreaControl);var zoomingControl=new ZoomingControl(map);ctx.setZoomingControl(zoomingControl);});GEvent.addListener(map,"mousemove",function(latlng){if(map.mode==map.MAP_POI_CREATING){var div=Dom.get(GlobalProperties.MAIN_GOOGLE_MAP_ID).getElementsByTagName("div")[0].getElementsByTagName("div")[0];if(!map.isPermitedToCreateArea(latlng)){div.style.cursor="not-allowed";}
else{var cursorProvider=Dom.get("newPoiCursorProvider");var cursor=Dom.getStyle(cursorProvider,"cursor");div.style.cursor=cursor;}}});GEvent.addListener(map,"moveend",function(){ctx.getPoisTooltip().hide();var mapLayerControl=ctx.getMapLayersControl();if(mapLayerControl){}
map.savePosition();if(!firstLoading){poisSelector.setPoisByCategoriesIdsAndCoordinatBound();poisSelector.getLayersByCoordinatesBound();}});GEvent.addListener(map,"zoomend",function(prevLevel,nextLevel){map.clearPoisAreaOverlays();map.hidePoisAreaTooltip();if(map.currentCursor){map.holdMapWithCursor(map.currentCursor);map.mode=map.MAP_ZOOMIN_OUT;map.disable();}
var zoomSliderControl=ctx.getZoomingControl();var zoom=map.getZoom();if(zoomSliderControl){var value=-1*6*(zoom-2);var disabled=zoomSliderControl.isDisabled;if(disabled){zoomSliderControl.enable();}
zoomSliderControl.slider.setValue(value,true,false,false);if(disabled){zoomSliderControl.disable();}}
CLIPTOO.poi.map.Toolbar.refreshLayersMenu();var selectedLayerId=CLIPTOO.poi.map.Toolbar.returnIdSelectedLayer();var layers=ctx.getLayers();var layer=null;for(var i=0,n=layers.length;i<n;i++){if(layers[i].id==selectedLayerId){layer=layers[i];break;}}
if(CLIPTOO.poi.map.Toolbar.needToDisableLayersMenuItem(layer)){CLIPTOO.poi.map.Toolbar.uncheckAllItemsInLayersMenu();}});var cleanAreaZoomTo=function(){for(var index=0;index<mapDisabler.childNodes.length;index++){mapDisabler.removeChild(mapDisabler.childNodes[index]);}
delete _selectedAreaDiv;_selectedAreaDiv=null;}
GEvent.addListener(map,"click",function(overlay,point){if(map.mode==map.MAP_POI_CREATING){}
else
if(map.mode==map.MAP_ZOOMIN_IN){if((!_selectedAreaDiv||(_selectedAreaDiv.style&&_selectedAreaDiv.style.display=="none"))&&map.getZoom()<GlobalProperties.MAXIMAL_ZOOM_LEVEL){map.zoomIn(point,true,true);}
cleanAreaZoomTo();}
else
if(map.mode==map.MAP_ZOOMIN_OUT&&map.getZoom()>GlobalProperties.MINIMAL_ZOOM_LEVEL){map.zoomOut(point,true);}});var zoomMouseDownX=0;var zoomMouseDownY=0;Event.addListener(mapDisabler,"mousedown",function(event){cleanAreaZoomTo();if(map.mode==map.MAP_ZOOMIN_IN&&map.getZoom()<17){_selectedAreaDiv=document.createElement("div");_selectedAreaDiv.className="zooming-area";var mapAbsoluteOffset=Dom.getRegion(map.getContainer());zoomMouseDownX=event.clientX-mapAbsoluteOffset.left;zoomMouseDownY=event.clientY-mapAbsoluteOffset.top;zoomMouseDownY+=Math.max(document.documentElement.scrollTop,document.body.scrollTop);_selectedAreaDiv.style.top=zoomMouseDownY+"px";_selectedAreaDiv.style.left=zoomMouseDownX+"px";_selectedAreaDiv.style.width="0px";_selectedAreaDiv.style.height="0px";_selectedAreaDiv.style.display="none";mapDisabler.appendChild(_selectedAreaDiv);}});Event.addListener(mapDisabler,"mousemove",function(event){if(_selectedAreaDiv&&_selectedAreaDiv.style&&map.mode==map.MAP_ZOOMIN_IN){var mapAbsoluteOffset=Dom.getRegion(map.getContainer());newX=event.clientX-mapAbsoluteOffset.left;newY=event.clientY-mapAbsoluteOffset.top;newY+=Math.max(document.documentElement.scrollTop,document.body.scrollTop);if(newX>zoomMouseDownX){_selectedAreaDiv.style.width=(newX-zoomMouseDownX)+"px";_selectedAreaDiv.style.left=zoomMouseDownX+"px";}
else{_selectedAreaDiv.style.width=(-newX+zoomMouseDownX)+"px";_selectedAreaDiv.style.left=newX+"px";}
if(newY>zoomMouseDownY){_selectedAreaDiv.style.height=(newY-zoomMouseDownY)+"px";_selectedAreaDiv.style.top=zoomMouseDownY+"px";}
else{_selectedAreaDiv.style.height=(-newY+zoomMouseDownY)+"px";_selectedAreaDiv.style.top=newY+"px";}
_selectedAreaDiv.style.display="";}});Event.addListener(mapDisabler,"mouseup",function(){if(map.mode==map.MAP_ZOOMIN_IN&&_selectedAreaDiv&&_selectedAreaDiv.style&&_selectedAreaDiv.style.display!="none"){var x=parseInt(_selectedAreaDiv.style.left)+parseInt(_selectedAreaDiv.style.width)/2;var y=parseInt(_selectedAreaDiv.style.top)+parseInt(_selectedAreaDiv.style.height)/2;var center=new GPoint(x,y);var latLngCenter=map.fromContainerPixelToLatLng(center);var zoomLevel=map.getZoomLevelForBox(parseInt(_selectedAreaDiv.style.width),parseInt(_selectedAreaDiv.style.height));map.setCenter(latLngCenter,zoomLevel);cleanAreaZoomTo();_selectedAreaDiv=document.createElement("div");}});document.onkeyup=function(event){var isAvoided=(ctx.getZoomingControl()&&ctx.getZoomingControl().isDisabled);event=event?event:window.event;if(event.altKey&&event.keyCode==107&&!isAvoided){if(map.getZoom()<GlobalProperties.MAXIMAL_ZOOM_LEVEL){map.zoomIn(map.getCenter(),true,true);}}
else
if(event.altKey&&event.keyCode==109&&!isAvoided){if(map.getZoom()>GlobalProperties.MINIMAL_ZOOM_LEVEL){map.zoomOut(map.getCenter(),true);}}
else
if(event.keyCode==27){cleanAreaZoomTo();_selectedAreaDiv="avoid zooming";popupHandler.hideGetWidgetPopup();map.closeBalloon();}};}
CLIPTOO.poi.map.Map.prototype.setMarkers=function(newMarkers){markers=newMarkers;}
CLIPTOO.poi.map.Map.prototype.getMarkers=function(){return markers;}
CLIPTOO.poi.map.Map.prototype.clearMarkers=function(){for(var index in markers){var marker=markers[index];this.removeOverlay(marker);}
markers=[];}
CLIPTOO.poi.map.Map.prototype.addMarker=function(newMarker){markers.push(newMarker);this.addOverlay(newMarker);}
CLIPTOO.poi.map.Map.prototype.setPoisAreasOverlays=function(newPoisAreaOverlays){poisAreaOverlays=newPoisAreaOverlays;}
CLIPTOO.poi.map.Map.prototype.getPoisAreasOverlays=function(){return poisAreaOverlays;}
CLIPTOO.poi.map.Map.prototype.clearPoisAreaOverlays=function(){for(var index in poisAreaOverlays){this.removeOverlay(poisAreaOverlays[index]);}
poisAreaOverlays=[];}
CLIPTOO.poi.map.Map.prototype.addPoisAreaOverlay=function(oViewPort,oCount,oPoisBounds,oCategoriesStat){var poisAreaOverlay=new CLIPTOO.poi.map.PoisArea(oViewPort,oCount,oPoisBounds,oCategoriesStat);poisAreaOverlays.push(poisAreaOverlay);this.addOverlay(poisAreaOverlay);}
CLIPTOO.poi.map.Map.prototype.isPermitedToCreateArea=function(location){if(this.permittedArea){var x=location.lng();var y=location.lat();var points=this.permittedArea;var n=points.length-1;var j=n-1;var isPermitted=false;for(i=0;i<n;i++){if((((points[i].lat()<=y)&&(y<points[j].lat()))||((points[j].lat()<=y)&&(y<points[i].lat())))&&(x>(points[j].lng()-points[i].lng())*(y-points[i].lat())/(points[j].lat()-points[i].lat())+points[i].lng())){isPermitted=!isPermitted;}
j=i;}
return isPermitted;}
if(this.permittedBounds){if(location instanceof GLatLng&&!this.permittedBounds.containsLatLng(location)){return false;}
if(location instanceof GLatLngBounds&&!this.permittedBounds.containsBounds(location)){return false;}}
return true;}
CLIPTOO.poi.map.Map.prototype.getZoomLevelForBox=function(width,height,forZoom){var mapWidth=this.getSize().width-2*GlobalProperties.DEAD_AREA_SIZE;var mapHeight=this.getSize().height-2*GlobalProperties.DEAD_AREA_SIZE-3;var zoomLevel=forZoom?forZoom:this.getZoom();if(mapWidth>width&&mapHeight>height){var widthToMap=mapWidth/width;var heightToMap=mapHeight/height;var correlation=Math.floor(Math.min(widthToMap,heightToMap));if(correlation==Number.POSITIVE_INFINITY||correlation==Number.NEGATIVE_INFINITY){return GlobalProperties.MAXIMAL_ZOOM_LEVEL;}
while(correlation>=2){correlation=correlation/2;zoomLevel++;}
if(zoomLevel>GlobalProperties.MAXIMAL_ZOOM_LEVEL){zoomLevel=GlobalProperties.MAXIMAL_ZOOM_LEVEL;}}
else{var widthToMap=width/mapWidth;var heightToMap=height/mapHeight;var correlation=Math.ceil(Math.max(widthToMap,heightToMap));while(correlation>1){correlation=correlation/2;zoomLevel--;}
if(zoomLevel<GlobalProperties.MINIMAL_ZOOM_LEVEL){zoomLevel=GlobalProperties.MINIMAL_ZOOM_LEVEL;}}
return zoomLevel;}
CLIPTOO.poi.map.Map.prototype.getZoomLevelForBounds=function(bounds){var size1=this.latLngToXY(bounds.getNorthEast(),GlobalProperties.MAXIMAL_ZOOM_LEVEL);var size2=this.latLngToXY(bounds.getSouthWest(),GlobalProperties.MAXIMAL_ZOOM_LEVEL);var height=Math.abs(size1.y-size2.y);var width=Math.abs(size1.x-size2.x);return this.getZoomLevelForBox(width,height,GlobalProperties.MAXIMAL_ZOOM_LEVEL);}
CLIPTOO.poi.map.Map.prototype.latLngToXY=function(point,zoom){var offset=268435456;var radius=offset/Math.PI;var xForLng=Math.round(offset+radius*point.lng()*Math.PI/180);var yForLat=Math.round(offset-radius*Math.log((1+Math.sin(point.lat()*Math.PI/180))/(1-Math.sin(point.lat()*Math.PI/180)))/2);return{x:(xForLng-offset)>>(21-zoom),y:(yForLat-offset)>>(21-zoom)};}
CLIPTOO.poi.map.Map.prototype.XYTolatLng=function(point,zoom){var offset=268435456;var radius=offset/Math.PI;var lngForX=((Math.round(offset+(point.x<<(21-zoom)))-offset)/radius)*(180/Math.PI);var latForY=(Math.PI/2-2*Math.atan(Math.exp((Math.round(offset+(point.y<<(21-zoom)))-offset)/radius)))*180/Math.PI;return{lng:lngForX,lat:latForY};}
CLIPTOO.poi.map.Map.prototype.removeTemporary=function(){if(this.temporary){this.removeOverlay(this.temporary);}
this.temporary=null;}
CLIPTOO.poi.map.Map.prototype.closeBalloon=function(){if(ctx.getViewBalloon()){ctx.getViewBalloon().close();}
if(ctx.getEditBalloon()){ctx.getEditBalloon().close();}};CLIPTOO.poi.map.Map.prototype.showPoisAreaTooltip=function(poisArea){poisAreaTooltip.show(poisArea);}
CLIPTOO.poi.map.Map.prototype.hidePoisAreaTooltip=function(){poisAreaTooltip.hide();}
CLIPTOO.poi.map.Map.prototype.holdMapWithCursor=function(cursor){this.disableDragging();if(cursor.indexOf('zoom-cursor-out')!=-1){this.currentCursor=cursor;}
else{this.currentCursor=null;}
var div=Dom.get(GlobalProperties.MAIN_GOOGLE_MAP_ID).getElementsByTagName("div")[0].getElementsByTagName("div")[0];div.style.cursor=cursor;}
CLIPTOO.poi.map.Map.prototype.serfMapWithHand=function(){this.enableDragging();var div=Dom.get(GlobalProperties.MAIN_GOOGLE_MAP_ID).getElementsByTagName("div")[0].getElementsByTagName("div")[0];div.style.cursor="url(http://maps.google.com/intl/en_ALL/mapfiles/openhand.cur), default";}
CLIPTOO.poi.map.Map.prototype.disable=function(){mapDisabler.style.display="";var mapContainer=mapDisabler.parentNode;mapDisabler.style.top=(-1*mapContainer.offsetTop)+"px";mapDisabler.style.left=(-1*mapContainer.offsetLeft)+"px";mapDisabler.style.bottom=(mapContainer.offsetTop)+"px";mapDisabler.style.right=(mapContainer.offsetLeft)+"px";}
CLIPTOO.poi.map.Map.prototype.enable=function(){mapDisabler.style.display="none";}
CLIPTOO.poi.map.Map.prototype.updateMarkerPosition=function(poiId,newPoint){if(poiId){var poi=ctx.getActivePoi(poiId);if(poi){poi.latitude=newPoint.lat();poi.longitude=newPoint.lng();var marker=this.getMarkerForPoi(poiId);if(marker){marker.setLatLng(newPoint);}}}
else
if(this.temporary){this.temporary.setLatLng(newPoint);}}
CLIPTOO.poi.map.Map.prototype.getMarkerForPoi=function(poiId){var mapMarkers=this.getMarkers();var marker;var n=mapMarkers.length;for(var i=0;i<n;i++){marker=mapMarkers[i];if(marker.poiId==poiId){return marker;}}}
CLIPTOO.poi.map.Map.prototype.balloonClose=function(){if(this.mode==this.MAP_POI_CREATING){var cursorProvider=Dom.get("newPoiCursorProvider");var cursor=Dom.getStyle(cursorProvider,"cursor");this.holdMapWithCursor(cursor);this.disable();}
else{this.serfMapWithHand();this.enable();}
ctx.getZoomingControl().enable();}
CLIPTOO.poi.map.Map.prototype.removePoaOverlays=function(){var overlays=this.poaOverlays;for(var i=0,n=overlays.length;i<n;i++){this.removeOverlay(overlays[i]);}
this.poaOverlays=[];var groundOverlays=this.poaGroundOverlays;for(var i=0,n=groundOverlays.length;i<n;i++){this.removeOverlay(groundOverlays[i]);}
this.poaGroundOverlays=[];}
CLIPTOO.poi.map.Map.prototype.removeOverlayForPoa=function(poaId){var overlays=this.poaOverlays;var newOverlays=[];for(var i=0,n=overlays.length;i<n;i++){if(overlays[i].poiId==poaId){this.removeOverlay(overlays[i]);}
else{newOverlays.push(overlays[i]);}}
this.poaOverlays=newOverlays;var groundOverlays=this.poaGroundOverlays;var newGroundOverlays=[];for(var i=0,n=groundOverlays.length;i<n;i++){if(groundOverlays[i].poiId==poaId){this.removeOverlay(groundOverlays[i]);}
else{newGroundOverlays.push(groundOverlays[i]);}}
this.poaGroundOverlays=newGroundOverlays;}
CLIPTOO.poi.map.Map.prototype.updateOverlayForNewPoa=function(poaId){var overlays=this.poaOverlays;for(var i=0,n=overlays.length;i<n;i++){if(overlays[i].poiId==GlobalProperties.NEW_POA_ID){overlays[i].poiId=poaId;}}
var groundOverlays=this.poaGroundOverlays;for(var i=0,n=groundOverlays.length;i<n;i++){if(groundOverlays[i].poiId==GlobalProperties.NEW_POA_ID){groundOverlays[i].poiId=poaId;}}}
CLIPTOO.poi.map.Map.prototype.showPoa=function(poaId,layerLink,poaName){if(!layerLink){return;}
var poa=this.getGeoXmlObject(layerLink);poa.poiId=poaId;var that=this;GEvent.addListener(poa,"load",function(){if(poa.hasLoaded()){var poaCenter=poa.getDefaultCenter();if(poaCenter&&poaId&&poaId==GlobalProperties.NEW_POA_ID){gmapHandler.showBalloonForNewPoi(GlobalProperties.POA,poaCenter,null,layerLink,poaName);}
that._showGroundOverlays(poa,that.poaGroundOverlays,that.poaOverlays);}});}
CLIPTOO.poi.map.Map.prototype.showRoute=function(routeId,updatingRoute,routeLink,routeName){if(routeLink==null||typeof routeLink=="undefined"||routeLink==""){return;}
var markerShown=(routeId!=GlobalProperties.NEW_ROUTE_ID);var markerShownCopy=markerShown;var startPoint=null;var map=this;if(!routes[routeId]||(routes[routeId]&&updatingRoute)){routes[routeId]=new GeoXml("routes['"+routeId+"']",this,routeLink,{createmarker:function(point){if(!markerShown){map.removeTemporary();var latlng=new GLatLng(point.lat(),point.lng());gmapHandler.createNewMarker(latlng);markerShown=true;if(!ctx.getEditBalloon().isShown()){gmapHandler.showBalloonForNewPoi(GlobalProperties.ROUTE,point,null,routeLink,routeName);}}
else
if(startPoint==null){startPoint=point;}},nozoom:!updatingRoute,style:{width:2,opacity:1,fillopacity:0.4,color:"#F30101",fillcolor:"#F30101"}});routes[routeId].mb.style.display="none";if(markerShownCopy&&updatingRoute){var map=this;var poi=ctx.getPoiById(routeId);ctx.setCurrentPoi(poi);var eventHandle=GEvent.addListener(routes[routeId],"initialized",function(){GEvent.removeListener(eventHandle);var latlng=new GLatLng(poi.latitude,poi.longitude);var newPosition=null;if(startPoint!=null){newPosition=startPoint;}
else{var nodePoint=map.findClosestRouteNode(routeId,latlng);if(nodePoint.distanceFrom(latlng)!=0){newPosition=nodePoint;}}
if(newPosition){map.updateMarkerPosition(routeId,newPosition);Dom.get("editedPoiLatitude").value=newPosition.lat();Dom.get("editedPoiLongitude").value=newPosition.lng();ctx.getEditBalloon()._initAddress();}});}
var editable=(typeof poi=="undefined")?true:poi.editable;restrictedRouteEventHandle=GEvent.addListener(routes[routeId],"restricted",function(){cleanRouteEvents();if(editable&&ctx.getEditBalloon()&&ctx.getEditBalloon().isShown()){ctx.getEditBalloon().revertRoute();}});initializedRouteEventHandle=GEvent.addListener(routes[routeId],"initialized",function(){cleanRouteEvents();if(editable&&ctx.getEditBalloon()&&ctx.getEditBalloon().isShown()){ctx.getEditBalloon().updateRoute(routeId);}});try{routes[routeId].parse();}
catch(e){}}}
CLIPTOO.poi.map.Map.prototype.removeRoute=function(routeId){if(routes[routeId]){routes[routeId].clear();delete routes[routeId];}}
CLIPTOO.poi.map.Map.prototype.removeRoutes=function(){for(var index in routes){if(routes[index]){routes[index].clear();}}
routes=[];}
CLIPTOO.poi.map.Map.prototype.findClosestRouteNode=function(routeId,latlng){var closestPoint=null;var minDistance=Number.MAX_VALUE;var polylines=routes[routeId].polylines;for(var i=0,n=polylines.length;i<n;i++){var lines=polylines[i].lines;for(var j=0,m=lines.length;j<m;j++){var points=lines[j];for(var k=0,l=points.length;k<l;k++){var distance=points[k].distanceFrom(latlng);if(minDistance>distance){minDistance=distance;closestPoint=points[k];}}}}
return closestPoint;}
CLIPTOO.poi.map.Map.prototype.showLayer=function(layer,notRemove){if(!notRemove){this.removeLayers();}
var that=this;if(layer.layerLink){var layerOverlay=that.getGeoXmlObject(layer.layerLink);layerOverlay.layerId=layer.id;GEvent.addListener(layerOverlay,"load",function(){var bounds=null;if(layerOverlay.hasLoaded()){that._showGroundOverlays(layerOverlay,that.groundOverlays,null,that.layerOverlays);}});var params="layerId="+layer.id;UIRequest("returnLayerLegendsForLayer.action",params,function(p_oRequest){var json=YAHOO.lang.JSON.parse(p_oRequest.responseText);var layerLegends=(json.layerLegends)?json.layerLegends:[];that._showLayerLegend(layer,layerLegends);var mapLayersControl=ctx.getMapLayersControl();if(mapLayersControl&&mapLayersControl.isShown){mapLayersControl._showLegends(layerLegends);}});}
else{var latLngBounds=that.getBounds();var minPoint=latLngBounds.getSouthWest();var minLat=minPoint.lat();var minLng=minPoint.lng();var maxPoint=latLngBounds.getNorthEast();var maxLat=maxPoint.lat();var maxLng=maxPoint.lng();var params="layerId="+layer.id+"&minLat="+minLat+"&minLng="+minLng+"&maxLat="+maxLat+"&maxLng="+maxLng;UIRequest("returnLayerTilesForLayerByBox.action",params,function(p_oRequest){var json=YAHOO.lang.JSON.parse(p_oRequest.responseText);var layerTiles=json.layerTiles;for(var i=0,n=layerTiles.length;i<n;i++){if(!that._isMapContainsLayerTile(layerTiles[i])){var layerTileOverlay=that.getGeoXmlObject(layerTiles[i].tileLink);layerTileOverlay.layerId=layerTiles[i].layerId;layerTileOverlay.layerTileId=layerTiles[i].id;that._showLayerOnTheMap(layerTileOverlay);}}
that._showTileOverlays(layer);var layerLegends=(json.layerLegends)?json.layerLegends:[];that._showLayerLegend(layer,layerLegends);});}
CLIPTOO.poi.cookie.create("selected-layer",layer.id);popupHandler.hidePleaseWait();}
CLIPTOO.poi.map.Map.prototype._showTileOverlays=function(layer){var tileOverlays=this.tileOverlays;for(var i=0,n=tileOverlays.length;i<n;i++){if(tileOverlays[i].layerId==layer.id){return;}}
var currentTileOverlay=ctx.getTileOverlay();var tilelayer=currentTileOverlay.getTileLayer();tilelayer.getTileUrl=function(gpoint,zoom){var currentLocation=window.location;var params="?x="+gpoint.x+"&y="+gpoint.y+"&z="+zoom+"&layerId="+layer.id;return currentLocation.protocol+"//"+currentLocation.host+"/MapTiles/MapTiles"+params;};currentTileOverlay.layerId=layer.id;this.addOverlay(currentTileOverlay);this.tileOverlays.push(currentTileOverlay);}
CLIPTOO.poi.map.Map.prototype._isMapContainsLayerTile=function(layerTile){var layerOverlays=this.layerOverlays;for(var i=0,n=layerOverlays.length;i<n;i++){if(layerOverlays[i].layerId==layerTile.layerId&&layerOverlays[i].layerTileId==layerTile.id){return true;}}
return false;}
CLIPTOO.poi.map.Map.prototype._showLayerOnTheMap=function(layerTileOverlay){var that=this;GEvent.addListener(layerTileOverlay,"load",function(){var bounds=null;if(layerTileOverlay.hasLoaded()){that._showGroundOverlays(layerTileOverlay,that.groundOverlays,null,that.layerOverlays);}});}
CLIPTOO.poi.map.Map.prototype.showLayerAndFetchBound=function(layer){this.removeLayers();var layerOverlay=this.getGeoXmlObject(layer.layerLink);layerOverlay.layerId=layer.id;var that=this;GEvent.addListener(layerOverlay,"load",function(){var bounds=null;if(layerOverlay.hasLoaded()){var bounds=layerOverlay.getDefaultBounds();if(bounds){var zoomLevel=that.getBoundsZoomLevel(bounds);that.setCenter(bounds.getCenter(),zoomLevel);ctx.getMapLayersControl().setCurrentBound(bounds,layer.legends);that._showGroundOverlays(layerOverlay,that.groundOverlays,null,that.layerOverlays);}}
if(!layerOverlay.hasLoaded()||!bounds){popupHandler.showValidationPopup(PoiMsg.js_msg.uploadKmlError());popupHandler.hidePleaseWait();}});}
CLIPTOO.poi.map.Map.prototype._showGroundOverlays=function(layerOverlay,groundOverlays,overlays,layerOverlays){if(this.isGeoObjectWithGroundOverlays(layerOverlay)){var poaId=layerOverlay.poiId;var gr=layerOverlay.ia.groundOverlays;var n=gr.length;for(var i=0;i<n;i++){var oldmap=this._addGroundOverlay(gr[i],poaId);groundOverlays.push(oldmap);}}
else{if(!layerOverlay.isLoaded){layerOverlay.isLoaded=true;this.addOverlay(layerOverlay);if(overlays){overlays.push(layerOverlay);}
if(layerOverlays){layerOverlays.push(layerOverlay);}
if(layerOverlay.fc){var polygons=layerOverlay.fc;var that=this;for(var i=0,n=polygons.length;i<n;i++){GEvent.addListener(polygons[i],"mouseover",function(){that.getPane(G_MAP_OVERLAY_LAYER_PANE).style.cursor='pointer';});GEvent.addListener(polygons[i],"mouseout",function(){that.getPane(G_MAP_OVERLAY_LAYER_PANE).style.cursor='inherit';});}}}}
popupHandler.hidePleaseWait();}
CLIPTOO.poi.map.Map.prototype._addGroundOverlay=function(groundOverlay,poaId){var minLat=groundOverlay.latlngbox.south;var minLng=groundOverlay.latlngbox.west;var maxLat=groundOverlay.latlngbox.north;var maxLng=groundOverlay.latlngbox.east;var boundaries=new GLatLngBounds(new GLatLng(minLat,minLng),new GLatLng(maxLat,maxLng));var href='http://maps.google.com'+groundOverlay.icon.href;var oldmap=new GGroundOverlay(href,boundaries);if(poaId){oldmap.poiId=poaId;}
this.addOverlay(oldmap);return oldmap;}
CLIPTOO.poi.map.Map.prototype._showLayerLegend=function(layer,legends){var legendContainer=Dom.get("layer-legend");if(legendContainer){var n=legends.length;var colon=(n>0)?":":"";legendContainer.innerHTML="<span class='map-legend-span'>"+PoiMsg.js_msg.map.legend.layer.title()+" <b>"+layer.title+"</b>"+colon+"</span>"
var readyLegends=legendContainer.childNodes.length-1;for(var i=readyLegends;i<n;i++){var legendCell=document.createElement("div");legendContainer.appendChild(legendCell);var colorDiv=document.createElement("div");colorDiv.className="legend-color";legendCell.appendChild(colorDiv);var legendSpan=document.createElement("div");legendSpan.className="map-legend-div";legendCell.appendChild(legendSpan);}
for(var i=0;i<n;i++){var legendCell=legendContainer.childNodes[i+1];legendCell.style.display="";var colorDiv=legendCell.childNodes[0];colorDiv.className="legend-color";colorDiv.style.backgroundColor=legends[i].color;var legendSpan=legendCell.childNodes[1];legendSpan.className="map-legend-div";legendSpan.innerHTML=legends[i].legend;}
for(var i=n;i<readyLegends;i++){legendContainer.childNodes[i].display="none";}
legendContainer.style.display="";}}
CLIPTOO.poi.map.Map.prototype.removeLayers=function(){this.removeTileOverlays();var layerOverlays=this.layerOverlays;for(var i=0,n=layerOverlays.length;i<n;i++){this.removeOverlay(layerOverlays[i]);}
this.layerOverlays=[];var groundOverlays=this.groundOverlays;for(var i=0,n=groundOverlays.length;i<n;i++){this.removeOverlay(groundOverlays[i]);}
this.groundOverlays=[];Dom.get("layer-legend").style.display="none";}
CLIPTOO.poi.map.Map.prototype.isGeoObjectWithGroundOverlays=function(layerOverlay){return layerOverlay&&layerOverlay.ia&&layerOverlay.ia.groundOverlays;}
CLIPTOO.poi.map.Map.prototype.getGeoXmlObject=function(link){var currentLocation=window.location;var path=currentLocation.protocol+"//"+currentLocation.host+link;return new GGeoXml(path);}
CLIPTOO.poi.map.Map.prototype.removeTileOverlays=function(){var tileIverlays=this.tileOverlays;for(var i=0,n=tileIverlays.length;i<n;i++){this.removeOverlay(tileIverlays[i]);}
this.tileOverlays=[];}
CLIPTOO.poi.map.Map.prototype.move=function(verticalFactor,horizontalFactor){this.disableContinuousZoom();var width=this.getSize().width;var height=this.getSize().height;var center=this.fromLatLngToContainerPixel(this.getCenter());center.y=center.y+verticalFactor*height;center.x=center.x+horizontalFactor*width;var newCenter=this.fromContainerPixelToLatLng(center);this.setCenter(newCenter);this.enableContinuousZoom();}
CLIPTOO.poi.map.Map.prototype.moveLeftUp=function(){this.move(-1,-1);}
CLIPTOO.poi.map.Map.prototype.moveUp=function(){this.move(-1,0);}
CLIPTOO.poi.map.Map.prototype.moveRightUp=function(){this.move(-1,1);}
CLIPTOO.poi.map.Map.prototype.moveLeft=function(){this.move(0,-1);}
CLIPTOO.poi.map.Map.prototype.moveRight=function(){this.move(0,1);}
CLIPTOO.poi.map.Map.prototype.moveLeftDown=function(){this.move(1,-1);}
CLIPTOO.poi.map.Map.prototype.moveDown=function(){this.move(1,0);}
CLIPTOO.poi.map.Map.prototype.moveRightDown=function(){this.move(1,1);}
CLIPTOO.poi.map.Map.prototype.destroy=function(){this.removeControl(ctx.getDeadAreaControl());this.clearMarkers();this.clearPoisAreaOverlays();this.removePoaOverlays()
if(YAHOO.env.ua.gecko){mapDisabler.parentNode.removeChild(mapDisabler);}
mapDisabler=null;poisAreaTooltip.destroy();ctx.getPoisTooltip().destroy();GUnload();}})();(function(){function singleClickHandler(point){if(typeof point=="undefined"){return;}
var map=Poi.getMap();if(!ctx.getEditBalloon().isShown()){map.removeTemporary();if(map.mode==map.MAP_POI_CREATING&&ctx.isAuthenticated()){gmapHandler.showBalloonForNewPoi(GlobalProperties.POI,point);}}}
function overlaySingleClick(poiId){var poi=ctx.getPoiById(poiId);if(!Dom.get('right_recent_stories')&&poi){if(typeof pageTracker!='undefined'){pageTracker._trackPageview("/pois/"+poi.name+"/"+poi.id);}
if(typeof pageTrackerGeneric!='undefined'){pageTrackerGeneric._trackPageview("/pois/"+poi.name+"/"+poi.id);}
var balloon=ctx.getEditBalloon();if(balloon.isShown()&&balloon.pointType!=GlobalProperties.POA){return;}
var viewBalloon=ctx.getViewBalloon();if(viewBalloon.isShown()&&viewBalloon.pointType!=GlobalProperties.POA){return;}
gmapHandler.showBalloon(poi);}}
function getOverlayForPoint(point,overlays){if(point){var map=Poi.getMap();var n=overlays.length;for(var i=0;i<n;i++){if((overlays[i].getDefaultBounds&&overlays[i].getDefaultBounds()&&overlays[i].getDefaultBounds().containsLatLng(point))||(overlays[i].getBounds&&overlays[i].getBounds()&&overlays[i].getBounds().containsLatLng(point))){return overlays[i];}}}
return null;}
CLIPTOO.poi.map.PoiMap=function(){this.constructor.superclass.constructor.call(this);var that=this;GEvent.addListener(this,"click",function(overlay,point){if(overlay){if(overlay.parentGeoXml){overlaySingleClick(overlay.parentGeoXml.poiId);}}else{singleClickHandler(point);}});}
YAHOO.lang.extend(CLIPTOO.poi.map.PoiMap,CLIPTOO.poi.map.Map);CLIPTOO.poi.map.PoiMap.prototype.checkResize=function(){this.constructor.superclass.checkResize.apply(this,arguments);if(ctx.getViewBalloon().isShown()){ctx.getViewBalloon().position();}
else if(ctx.getEditBalloon().isShown()){ctx.getEditBalloon().position();}
ctx.getDeadAreaControl().refresh(this);}
CLIPTOO.poi.map.PoiMap.prototype.initMapPosition=function(){this.constructor.superclass.initMapPosition.call(this);if(location.href.indexOf("poiId")>-1){this.position(parseFloat(Dom.get("myPoiLongitude").value),parseFloat(Dom.get("myPoiLatitude").value),parseInt(Dom.get("myPoiZoom").value));}
var getOrgProperty=ctx.getOrgProperty;if(CLIPTOO.InitParameters.getMapZoom()){var position=CLIPTOO.InitParameters.getMapPosition();this.position(position.x,position.y,CLIPTOO.InitParameters.getMapZoom());}
else if(getOrgProperty("startRegion")!=null&&getOrgProperty("startRegion")!=""){var startRegion=getOrgProperty("startRegion").split(",");var southWest=new GLatLng(parseFloat(startRegion[3]),parseFloat(startRegion[1]));var northEast=new GLatLng(parseFloat(startRegion[2]),parseFloat(startRegion[0]));if(location.href.indexOf("poiId")==-1){var zoom=this.getBoundsZoomLevel(new GLatLngBounds(southWest,northEast));var swPoint=this.latLngToXY(southWest,zoom);var nePoint=this.latLngToXY(northEast,zoom);var width=Math.abs(swPoint.x-nePoint.x)+2*GlobalProperties.DEAD_AREA_SIZE;var height=Math.abs(swPoint.y-nePoint.y)+2*GlobalProperties.DEAD_AREA_SIZE;if(width>this.getSize().width||height>this.getSize().height){zoom--;}
this.position((southWest.x+northEast.x)/2,(southWest.y+northEast.y)/2,zoom);}}
else{this.position();}}
CLIPTOO.poi.map.PoiMap.prototype.savePosition=function(){CLIPTOO.poi.cookie.create("map-center-x",this.getCenter().x);CLIPTOO.poi.cookie.create("map-center-y",this.getCenter().y);CLIPTOO.poi.cookie.create("map-zoom",this.getZoom());}
CLIPTOO.poi.map.PoiMap.prototype.initMap=function(){var scaleControl=new GScaleControl();ctx.setScaleControl(scaleControl);this.addControl(scaleControl);this.constructor.superclass.initMap.call(this);}
CLIPTOO.poi.map.PoiMap.prototype.positionLicence=function(){this.constructor.superclass.positionLicence.call(this);var mapContainer=Dom.get('google_map_main');mapContainer.childNodes[3].style.bottom="17px";mapContainer.childNodes[3].style.left="76px";}
CLIPTOO.poi.map.PoiMap.prototype.destroy=function(){Poi.getMap().removeControl(ctx.getScaleControl());this.removeLayers();this.removeTileOverlays();this.constructor.superclass.destroy.call(this);}})();(function(){CLIPTOO.poi.map.PoisArea=function(oViewPort,iNumber,oZoomView,oCategoriesStat){this.number_=iNumber;this.viewPort_=oViewPort;this.zoomView_=oZoomView;this.point_=oViewPort.getCenter();this.categoriesStat=oCategoriesStat;this.center=null;}
CLIPTOO.poi.map.PoisArea.prototype=new GOverlay();var proto=CLIPTOO.poi.map.PoisArea.prototype;var getDigitsCount=function(number){var count=0;while(number>1){number=number/10;count++;}
if(number==1){count++;}
return count;}
var stopPropagation=function(e){Event.stopEvent(e);};var handleInnerDivMouseOver=function(event,overlay){overlay.map_.showPoisAreaTooltip(overlay);Dom.addClass(this.parentNode,"highlightedPoisArea");}
var handleInnerDivMouseOut=function(event,overlay){overlay.map_.hidePoisAreaTooltip();Dom.removeClass(this.parentNode,"highlightedPoisArea");}
var handleInnerDivClick=function(event,overlay){var map=overlay.map_;map.closeBalloon();var zoomLevel=GlobalProperties.MAXIMAL_ZOOM_LEVEL;if(!overlay.zoomView_.getNorthEast().equals(overlay.zoomView_.getSouthWest())){var zoomLevel=map.getZoomLevelForBounds(overlay.zoomView_);}
var xyNorthEast=map.latLngToXY(overlay.zoomView_.getNorthEast(),zoomLevel);xyNorthEast.y=xyNorthEast.y-4;var northEast=map.XYTolatLng(xyNorthEast,zoomLevel);overlay.zoomView_.extend(new GLatLng(northEast.lat,northEast.lng));overlay.map_.setCenter(overlay.zoomView_.getCenter(),zoomLevel);}
proto.initialize=function(map){var div=document.createElement("div");div.style.display="none";div.className="poisArea";var size1=map.fromLatLngToDivPixel(this.viewPort_.getNorthEast());var size2=map.fromLatLngToDivPixel(this.viewPort_.getSouthWest());div.style.height=Math.abs(size1.y-size2.y)+"px";div.style.width=Math.abs(size1.x-size2.x)+"px";map.getPane(G_MAP_MARKER_PANE).appendChild(div);var innerDiv=document.createElement("div");innerDiv.className="circle"+getDigitsCount(this.number_);innerDiv.innerHTML="<div>"+this.number_+"</div>";div.appendChild(innerDiv);this.map_=map;this.div_=div;var stealEvents=['mousedown','dblclick','click'];for(var i=0;i<stealEvents.length;i++){Event.addListener(innerDiv,stealEvents[i],stopPropagation);}
Event.addListener(innerDiv,"mouseover",handleInnerDivMouseOver,this);Event.addListener(innerDiv,"mouseout",handleInnerDivMouseOut,this);Event.addListener(innerDiv,"click",handleInnerDivClick,this);}
proto.remove=function(){Event.removeListener(this.div_.firstChild);Event.removeListener(this.div_);this.div_.parentNode.removeChild(this.div_);this.div_=null;}
proto.copy=function(){return new PoisArea();}
proto.hilight=function(){Dom.addClass(this.div_.firstChild,"hilight");Dom.addClass(this.div_,"highlightedPoisArea");}
proto.dehilight=function(){Dom.removeClass(this.div_.firstChild,"hilight");Dom.removeClass(this.div_,"highlightedPoisArea");}
proto.redraw=function(force){if(!force)
return;var div=this.div_;var container={height:parseInt(div.style.height),width:parseInt(div.style.width),borderY:parseInt(Dom.getStyle(div,"border-top-width")),borderX:parseInt(Dom.getStyle(div,"border-left-width"))}
var c1=this.map_.fromLatLngToDivPixel(this.viewPort_.getNorthEast());c1.x=c1.x-container.borderX;c1.y=c1.y-container.borderY;var c2={x:c1.x-container.width,y:c1.y+container.height}
div.style.left=c2.x+"px";div.style.top=c1.y+"px";div.style.display='block';var innerDiv=div.firstChild;var radius=parseInt(Dom.getStyle(innerDiv,"height"));var realNE=this.map_.fromLatLngToDivPixel(this.zoomView_.getNorthEast());var realSW=this.map_.fromLatLngToDivPixel(this.zoomView_.getSouthWest());var deltaX=(realSW.x-realNE.x+radius)/2;var deltaY=(realNE.y-realSW.y+radius)/2;realNE.x=realNE.x+deltaX;realSW.x=realSW.x-deltaX;realNE.y=realNE.y-deltaY;realSW.y=realSW.y+deltaY;if(realNE.x>c1.x){realNE.x=c1.x;realSW.x=realNE.x-radius;}
else if(realSW.x<c2.x){realSW.x=c2.x;realNE.x=realSW.x+radius;}
if(realNE.y<c1.y){realNE.y=c1.y;realSW.y=realNE.y+radius;}
else if(realSW.y>c2.y){realSW.y=c2.y;realNE.y=realSW.y-radius;}
innerDiv.style.left=(realSW.x-c2.x)+"px";innerDiv.style.top=(realNE.y-c1.y)+"px";}})();CLIPTOO.poi.map.PoisAreaTooltip=function(oMap){var tooltipContainer=document.createElement("div");tooltipContainer.className="psTooltip";tooltipContainer.style.visibility="hidden";tooltipContainer.id="pa-tooltip";tooltipContainer.innerHTML='<div class="poi-tooltip-wrapper" id="tooltipCircleWrapper"> \
   <div class="poi-tooltip-top"> \
    <div class="poi-tooltip-left-top-corner"></div> \
    <div class="poi-tooltip-top-center"></div> \
    <div class="poi-tooltip-right-top-corner"></div> \
   </div> \
   <div class="poi-tooltip-title"><span id="tooltipPrompt"></span></div> \
   <div class="poi-tooltip-bottom"> \
    <div class="poi-tooltip-left-bottom-corner"></div> \
    <div class="poi-tooltip-bottom-center"></div> \
    <div class="poi-tooltip-right-bottom-corner"></div> \
   </div> \
   <div id="tooltipTailCircle"></div> \
  </div>';Dom.get(GlobalProperties.CONTAINER_MAP_ID).appendChild(tooltipContainer);var tooltipTextContainer=Dom.get("tooltipPrompt");this.show=function(poisArea){var content="";tooltipTextContainer.innerHTML=PoiMsg.js_msg.circle.tooltip.explanation();var c1=poisArea.map_.fromLatLngToContainerPixel(poisArea.viewPort_.getNorthEast());var left=(c1.x-parseInt(poisArea.div_.style.width)-parseInt(Dom.getStyle(poisArea.div_,"border-left-width")));var top=(c1.y-parseInt(Dom.getStyle(poisArea.div_,"border-top-width")));var mapElm=Dom.get(GlobalProperties.MAIN_GOOGLE_MAP_ID);var circleDiv=poisArea.div_.firstChild;var radius=circleDiv.clientWidth/2;var center={x:(left+mapElm.offsetLeft+1+parseFloat(Dom.getStyle(poisArea.div_,"border-left-width"))+parseFloat(circleDiv.style.left)+radius),y:(top+mapElm.offsetTop+1+parseFloat(Dom.getStyle(poisArea.div_,"border-top-width"))+parseFloat(circleDiv.style.top)+radius)};var latLngBounds=oMap.getBounds();var maxLat=latLngBounds.getNorthEast().lat();var maxLng=latLngBounds.getNorthEast().lng();var maxPoint=new GLatLng(maxLat,maxLng);var minLat=latLngBounds.getSouthWest().lat();var minLng=latLngBounds.getSouthWest().lng();var minPoint=new GLatLng(minLat,minLng);var maxCenter=oMap.fromLatLngToContainerPixel(maxPoint);var minCenter=oMap.fromLatLngToContainerPixel(minPoint);var coords=YAHOO.util.Region.getRegion(tooltipContainer);var tailHeight=9;var height=coords.bottom-coords.top+tailHeight;var width=coords.right-coords.left;var containerOffset=parseFloat(oMap.getContainer().offsetTop);var yCorectionForTopPosition=containerOffset;var yCorectionForBottomPosition=containerOffset-tailHeight;var xCorrection=10;var lup={x:center.x-width,y:center.y-height-radius-yCorectionForTopPosition};var ldp={x:center.x-width,y:center.y+height};var rup={x:center.x+width-xCorrection,y:center.y-height-radius-yCorectionForTopPosition};var rdp={x:center.x+width-xCorrection,y:center.y+height};var x=parseFloat(center.x)+parseFloat(oMap.getContainer().offsetLeft);var y=parseFloat(center.y)+parseFloat(oMap.getContainer().offsetTop);if(rup.x<maxCenter.x&&rup.y>maxCenter.y){x=x-12;y=y-height-radius-yCorectionForTopPosition;tooltipContainer.firstChild.className='poi-tooltip-wrapper poi-tooltip-left-down-tail';}else if(lup.x>minCenter.x&&lup.y>maxCenter.y){x=x-width+12;y=y-height-radius-yCorectionForTopPosition;tooltipContainer.firstChild.className='poi-tooltip-wrapper poi-tooltip-right-down-tail';}else if(rdp.x<maxCenter.x&&rdp.y<minCenter.y){x=x-12;y=y+radius-yCorectionForBottomPosition;tooltipContainer.firstChild.className='poi-tooltip-wrapper poi-tooltip-left-up-tail';}else{x=x-width+12;y=y+radius-yCorectionForBottomPosition;tooltipContainer.firstChild.className='poi-tooltip-wrapper poi-tooltip-right-up-tail';}
if(y+height>minCenter.y||x+width-xCorrection>maxCenter.x){return;}
tooltipContainer.style.top=y+"px";tooltipContainer.style.left=x+"px";tooltipContainer.style.visibility="visible";}
this.hide=function(){tooltipContainer.style.visibility="hidden";}
this.destroy=function(){if(YAHOO.env.ua.gecko){tooltipTextContainer.parentNode.removeChild(tooltipTextContainer);tooltipContainer.parentNode.removeChild(tooltipContainer);}
tooltipTextContainer=null;tooltipContainer=null;}};function EasyCreatingControl(config){this.template='<div class="easyCreatingContainer">\
   <span style="font-weight: bold;">'+config.searchName+'</span>\
   <span>'+config.searchHint+'</span>\
   <div class="easyCreatingFieldContainer">\
    <b class="trg"><b></b><i></i><u></u></b>\
    <div class="mrg">\
     <input id="'+config.addressField+'"><div id="'+config.resetButton+'" class="easyCreatingFieldResetButton" style="display: none;"></div>\
    </div>\
    <b class="brg"><u></u><i></i><b></b></b>\
   </div>\
   <div class="easyCreatingBtnContainer">\
    <b class="trg"><b></b><i></i><u></u></b>\
     <div class="mrg">\
      <div id="'+config.searchButton+'" class="easyCreatingBtn">'+PoiMsg.js_msg.search.search()+'</div>\
     </div>\
    <b class="brg"><u></u><i></i><b></b></b>\
   </div>\
   <div id="'+config.nothingFoundHint+'" style="display: none;">'+PoiMsg.js_msg.search.nothingFound()+'</div>\
   <div id="'+config.resultHint+'" style="display: none;">'+PoiMsg.js_msg.search.specification()+'</div>\
   <span id="'+config.resultList+'" style="display: none;"></span>\
   <div id="'+config.disabler+'" class="easyCreatingDisabler" style="display: none;"></div>\
  </div>\
  <div id="'+config.roundPopup+'" class="round-easy-creating-popup">\
   <div class="left-corner-easy-creating-popup"></div>\
   <div class="middle-easy-creating-popup"></div>\
   <div class="right-corner-easy-creating-popup"></div>\
  </div>';this.config=config;this.initialize();this.attachHandlers();};EasyCreatingControl.prototype._delegateClickEvent=function(ev){var obj=ev.target?ev.target:ev.srcElement;var addressField=Dom.get(this.config.addressField);var resetButton=Dom.get(this.config.resetButton);if(obj.className==="easyCreatingBtn"){if(this.enabled){this.gs.execute(addressField.value);}}else if(obj.className==="easyCreatingFieldResetButton"){addressField.value="";addressField.focus();resetButton.style.display="none";addressField.style.width="168px";}else if(obj.nodeName==="ADDRESS"){var rowId=obj.id;var rowIdNumber=parseInt(rowId);var result=this.gs.results[rowIdNumber];var address=result.addressLines.join(", ");this.actionAfterSearch(address,result);}};EasyCreatingControl.prototype.attachHandlers=function(){Event.addListener(this.config.outherContainer,"click",this._delegateClickEvent,this,true);};EasyCreatingControl.prototype.initialize=function(){this.gs=CLIPTOO.poi.map.types.getCurrentLocalSearch(EasyCreatingControl.prototype.searchComplete,this);var that=this;var onBlurAddressField=function(event){var text=addressField.value;if(text!=null&&text!=''){resetButton.style.display="block";addressField.style.width="151px";}}
var forceSearchMap=function(event){event=event?event:window.event;if(event.keyCode==13){resetButton.style.display="block";addressField.style.width="151px";if(that.enabled){that.gs.execute(addressField.value);}}}
var config=this.config;var outerContainer=Dom.get(config.outherContainer);outerContainer.innerHTML=this.template;var addressField=Dom.get(config.addressField);var resetButton=Dom.get(config.resetButton);GEvent.addDomListener(addressField,"keypress",forceSearchMap);GEvent.addDomListener(addressField,"blur",onBlurAddressField);this.container=outerContainer;this.address=addressField;this.resetButton=resetButton;this.roundPopup=Dom.get(config.roundPopup);this.disabler=Dom.get(config.disabler);this.resultHint=Dom.get(config.resultHint);this.resultList=Dom.get(config.resultList);this.nothingFoundHint=Dom.get(config.nothingFoundHint);this.enable();};EasyCreatingControl.prototype.searchComplete=function(){var results=this.gs.results;this.resultHint.style.display="none";this.resultList.style.display="none";if(results.length==0){this.nothingFoundHint.style.display="";}else{this.nothingFoundHint.style.display="none";}
this.buildSearchList();};EasyCreatingControl.prototype.buildSearchList=function(){var results=this.gs.results;if(results.length>0){this.resultHint.style.display="";this.resultList.style.display="";this.nothingFoundHint.style.display="none";this.resultList.innerHTML="";for(var i=0;i<results.length;i++){var address=results[i].addressLines.join(", ");var link=document.createElement("address");link.innerHTML=address;link.id=i+"_address_row";this.resultList.appendChild(link);}}};EasyCreatingControl.prototype.actionAfterSearch=function(address,result){if(this.enabled){gmapHandler.showBalloonForNewPoi(GlobalProperties.POI,new GLatLng(result.lat,result.lng),result);}};EasyCreatingControl.prototype.show=function(){this.nothingFoundHint.style.display="none";this.resultHint.style.display="none";this.resultList.style.display="none";this.resetButton.style.display="none";this.address.value='';this.container.style.display="";this.enable();this.setFocus();};EasyCreatingControl.prototype.hide=function(){this.container.style.display="none";this.disable();};EasyCreatingControl.prototype.disable=function(){this.enabled=false;this.disabler.style.height=(this.container.offsetHeight+this.roundPopup.offsetHeight)+"px";this.disabler.style.width=(this.container.offsetWidth)+"px";this.disabler.style.display="";};EasyCreatingControl.prototype.enable=function(){this.enabled=true;this.container.style.height="";this.disabler.style.display="none";};EasyCreatingControl.prototype.setFocus=function(){if(YAHOO.env.ua.webkit){this.address.focus();}
this.address.select();};function MapLayerControl(){this.initialize();}
MapLayerControl.prototype.initialize=function(){this.currentLayer={id:0,title:'',layerLink:''};this.layers=[];this.isShown=false;var outerContainer=document.createElement("div");outerContainer.className="map-layer-outer-container";outerContainer.style.display="none";this.outerContainer=outerContainer;var container=document.createElement("div");container.className="map-layer-container";var createLayerTitle=document.createElement("span");createLayerTitle.innerHTML=PoiMsg.js_msg.layerPopup.createLayerTitle();createLayerTitle.style.fontWeight="bold";container.appendChild(createLayerTitle);var hintArea=document.createElement("span");hintArea.innerHTML=PoiMsg.js_msg.layerPopup.hint();container.appendChild(hintArea);var fileNameField=document.createElement("input");fileNameField.id="layerFileName";fileNameField.maxLength=64;var fieldContainer=roundCorners(fileNameField,"map-layer-field-container");container.appendChild(fieldContainer);var uploadBtn=document.createElement("div");uploadBtn.id="map-layer-btn";uploadBtn.className="map-layer-btn-upload";this.button=uploadBtn;container.appendChild(this.button);var selectContainer=document.createElement("div");selectContainer.className='map-layer-select-container';var hintSelectArea=document.createElement("span");hintSelectArea.innerHTML=PoiMsg.js_msg.layerPopup.hintSelect();selectContainer.appendChild(hintSelectArea);var select=document.createElement("select");select.id='selectLayerId';select.className='map-layer-select';selectContainer.appendChild(select);this.select=select;container.appendChild(selectContainer);var legendsContainer=document.createElement("div");legendsContainer.className="map-layer-legends-container";legendsContainer.style.display="none";var deleteLayerContainer=document.createElement("div");deleteLayerContainer.className="map-layer-delete-container";deleteLayerContainer.style.display="none";deleteLayerContainer.id="deleteLayerContainer";var deleteLayerName=document.createElement("span");deleteLayerName.id="deleteLayerName";deleteLayerName.style.fontWeight="bold";var deleteLayerBtn=document.createElement("div");deleteLayerBtn.className="map-layer-delete-link";deleteLayerBtn.id="deleteLayerBtn";deleteLayerBtn.innerHTML=PoiMsg.js_msg.map.layer.deleteItem();deleteLayerBtn.title=PoiMsg.js_msg.map.layer.deleteHint();legendsContainer.appendChild(deleteLayerContainer);deleteLayerContainer.appendChild(deleteLayerName);deleteLayerContainer.appendChild(deleteLayerBtn);var legendHint=document.createElement("span");legendHint.innerHTML=PoiMsg.js_msg.layerPopup.addLayerLegendTitle();legendHint.style.fontWeight="bold";var addLegendBtn=document.createElement("div");addLegendBtn.className='map-layer-add-legend';addLegendBtn.title=PoiMsg.js_msg.legend.add();var addBtnText=document.createElement("span");addBtnText.innerHTML=PoiMsg.js_msg.legend.add();addLegendBtn.appendChild(addBtnText);var addBtnIcon=document.createElement("div");addLegendBtn.appendChild(addBtnIcon);var addLegendContainer=document.createElement("div");addLegendContainer.style.width="250px";addLegendContainer.appendChild(legendHint);addLegendContainer.appendChild(addLegendBtn);legendsContainer.appendChild(addLegendContainer);container.appendChild(legendsContainer);this.legendsContainer=legendsContainer;var createBtn=document.createElement("div");createBtn.innerHTML=PoiMsg.js_msg.layerPopup.saveLegends();createBtn.id="map-layer-create-btn";createBtn.className="map-layer-btn";this.createBtn=roundCorners(createBtn,"map-layer-btn-container");container.appendChild(this.createBtn);this.createBtn.style.display="none";var roundPopup=document.createElement("div");roundPopup.className="round-easy-creating-popup";var leftCorner=document.createElement("div");leftCorner.className="left-corner-easy-creating-popup";var middleDiv=document.createElement("div");middleDiv.className="middle-easy-creating-popup";var rightCorner=document.createElement("div");rightCorner.className="right-corner-easy-creating-popup";roundPopup.appendChild(leftCorner);roundPopup.appendChild(middleDiv);roundPopup.appendChild(rightCorner);outerContainer.appendChild(container);outerContainer.appendChild(roundPopup);Dom.get(GlobalProperties.CONTAINER_MAP_ID).appendChild(outerContainer);this._confLayerUploader();this.addListeners();}
MapLayerControl.prototype.addListeners=function(){var that=this;Event.addListener(this.createBtn,'click',function(){that.saveLayer();});Event.addListener(Dom.get("deleteLayerBtn"),"click",this.deleteLayer,this,true);this.select.onchange=function(){var chosenoption=this.options[this.selectedIndex];if(chosenoption.value!="nothing"){CLIPTOO.poi.map.Toolbar.uncheckAllItemsInLayersMenu();that._openLayer(chosenoption.value);}}
Event.addListener(this.legendsContainer,"click",function(e){var elm=e.target||e.srcElement;if(elm.className=='map-layer-add-legend'||elm.parentNode.className=='map-layer-add-legend'){that.addLegend({id:0,color:'',legend:''},true);}
else if(elm.className=='map-layer-delete-legend'){popupHandler.showConfirmPopup(PoiMsg.js_msg.balloon.blog.msg.warning(),PoiMsg.js_msg.legend.confirmRemoving(),function(){that.legendsContainer.removeChild(elm.parentNode);this.hide();},function(){this.hide();});}});}
MapLayerControl.prototype.show=function(){poisSelector.loadLayersForMap();var map=Poi.getMap();map.serfMapWithHand();map.mode=map.MAP_VIEWING;map.enable();this.outerContainer.style.display="";this.isShown=true;}
MapLayerControl.prototype.setFocus=function(){if(YAHOO.env.ua.webkit){Dom.get("layerFileName").focus();}
Dom.get("layerFileName").select();};MapLayerControl.prototype.hide=function(){this.outerContainer.style.display="none";if(this.currentLayer.layerLink!=''){Poi.getMap().removeLayers();}
this._clean();this.isShown=false;}
MapLayerControl.prototype._confLayerUploader=function(){if(!CLIPTOO.utils.isFlashPlayerCompatible()){return;}
var currentLocation=window.location;var path="themes/default/img/layers/upload-button.png";YAHOO.widget.Uploader.SWFURL=currentLocation.protocol+"//"+currentLocation.host+GlobalProperties.HOST+"js/yui/uploader/assets/uploader.swf";var uploader=new YAHOO.widget.Uploader("map-layer-btn",currentLocation.protocol+"//"+currentLocation.host+GlobalProperties.HOST+path);var onUploaderContentReady=function(){uploader.setAllowMultipleFiles(false);uploader.setFileFilters([{description:"Layers",extensions:"*.kml;*.kmz"}]);};uploader.addListener('contentReady',onUploaderContentReady);var currentLocation=window.location;var rootHost=currentLocation.protocol+"//"+currentLocation.host;var that=this;var layerLink=null;var kml=null;var title=null;function onFileSelectPoi(event){fileList=event.fileList;if(fileList){for(var i in fileList){if(fileList[i].size>parseInt(PoiMsg.js_msg.upload.maxFileSize())){popupHandler.showErrorPopup(PoiMsg.js_msg.upload.maxSizeError(CLIPTOO.utils.getFileExtension(fileList[i])));return;}
popupHandler.showPleaseWait();uploader.upload(i,GlobalProperties.HOST+"uploadLayer.action","GET",{"userUid":ctx.getCurrentUserUid()});}
uploader.clearFileList();}}
function uploadCompleteData(event){CLIPTOO.poi.map.Toolbar.uncheckAllItemsInLayersMenu();var jsonWithLink=YAHOO.lang.JSON.parse(event.data);var layerLegends=jsonWithLink.layerLegends;that.currentLayer.legends=layerLegends;that.currentLayer.layerLink=jsonWithLink.layerLink;Poi.getMap().showLayerAndFetchBound(that.currentLayer);}
function uploadError(event){if(event.status==500){popupHandler.showErrorPopup("Server error");}
popupHandler.hidePleaseWait();}
var onUploaderContentReady=function(){if(YAHOO.env.ua.webkit){Dom.get("layerFileName").focus();}
Dom.get("layerFileName").select();};uploader.addListener('contentReady',onUploaderContentReady);uploader.addListener('fileSelect',onFileSelectPoi);uploader.addListener('uploadCompleteData',uploadCompleteData);uploader.addListener('uploadError',uploadError);}
MapLayerControl.prototype.setCurrentBound=function(defaultBound,layerLegends){if(defaultBound){this.currentLayer.minLat=defaultBound.getSouthWest().lat;this.currentLayer.minLng=defaultBound.getSouthWest().lng;this.currentLayer.maxLat=defaultBound.getNorthEast().lat;this.currentLayer.maxLng=defaultBound.getNorthEast().lng;}
else{this.currentLayer.minLat=null;this.currentLayer.minLng=null;this.currentLayer.maxLat=null;this.currentLayer.maxLng=null;}
this._showLegends(layerLegends);popupHandler.hidePleaseWait();}
MapLayerControl.prototype._showLegends=function(layerLegends){var container=this.legendsContainer;var legendDivs=Dom.getElementsByClassName('map-layer-legend','div',container);var m=legendDivs.length;for(var i=m-1;i>=0;i--){container.removeChild(legendDivs[i]);}
if(typeof layerLegends=="undefined"||layerLegends==null){layerLegends=[];}
var n=layerLegends.length;for(var i=0;i<n;i++){this.addLegend(layerLegends[i],(i==n-1));}
if(n==0){this.addLegend({id:0,color:'',legend:''},true);}
this.legendsContainer.style.display='';this.layerLegends=layerLegends;this.createBtn.style.display='';}
MapLayerControl.prototype.addLegend=function(legend){var container=this.legendsContainer;var legendDiv=document.createElement("div");legendDiv.className='map-layer-legend';var colorDiv=document.createElement("div");colorDiv.className='map-layer-legend-color';var color=legend.color;var colorInnerDiv=document.createElement("div");colorInnerDiv.className='map-layer-legend-color-inner';colorInnerDiv.style.backgroundColor=(color=='')?'#fff':color;colorDiv.appendChild(colorInnerDiv);legendDiv.appendChild(colorDiv);var fieldDiv=document.createElement("div");fieldDiv.className='map-layer-legend-name';var legendId=document.createElement("input");legendId.type="hidden";legendId.value=legend.id;legendId.className="hidden-element";fieldDiv.appendChild(legendId);var legendHexColor=document.createElement("input");legendHexColor.className='map-layer-legend-hex-color';legendHexColor.maxLength=8;if(legend.color==''){legendHexColor.className=legendHexColor.className+' legend-field-hint';legendHexColor.value=PoiMsg.js_msg.legend.hexCode();}
else{if(color.length==4){color="#"+color.charAt(1)+color.charAt(1)+color.charAt(2)+color.charAt(2)+color.charAt(3)+color.charAt(3);}
legendHexColor.value=color;}
fieldDiv.appendChild(legendHexColor);var legendNameField=document.createElement("input");legendNameField.className='map-layer-legend-field-name';legendNameField.maxLength=256;if(legend.legend==''){legendNameField.className=legendNameField.className+' legend-field-hint';legendNameField.value=PoiMsg.js_msg.legend.name();}
else{legendNameField.value=legend.legend;}
fieldDiv.appendChild(legendNameField);legendDiv.appendChild(fieldDiv);var buttonDiv=document.createElement("div");buttonDiv.className='map-layer-delete-legend';buttonDiv.title=PoiMsg.js_msg.legend.remove();legendDiv.appendChild(buttonDiv);container.appendChild(legendDiv);Event.addListener(legendHexColor,"focus",MapLayerControl._focusLegendField);Event.addListener(legendHexColor,"blur",MapLayerControl._blurLegendColor,[PoiMsg.js_msg.legend.hexCode(),colorInnerDiv]);Event.addListener(legendNameField,"focus",MapLayerControl._focusLegendField);Event.addListener(legendNameField,"blur",MapLayerControl._blurLegendField,PoiMsg.js_msg.legend.name());}
MapLayerControl._focusLegendField=function(){if(Dom.hasClass(this,'legend-field-hint')){Dom.removeClass(this,'legend-field-hint');this.value="";}}
MapLayerControl._blurLegendField=function(e,text){if(this.value==""){Dom.addClass(this,'legend-field-hint');this.value=text;}}
MapLayerControl._blurLegendColor=function(e,args){MapLayerControl._blurLegendField.apply(this,[e,args[0]]);if(!Dom.hasClass(this,'legend-field-hint')){args[1].style.backgroundColor=this.value;}}
MapLayerControl.prototype.saveLayer=function(){if(Dom.get('layerFileName').value==''){popupHandler.showValidationPopup(PoiMsg.js_msg.layerPopup.validationLegendName());return;}
var legendIds=Dom.getElementsByClassName('hidden-element','input',this.legendsContainer);var legendFields=Dom.getElementsByClassName('map-layer-legend-field-name','input',this.legendsContainer);var legendColors=Dom.getElementsByClassName('map-layer-legend-hex-color','input',this.legendsContainer);var xmlString='<layer>';if(this.currentLayer.id){xmlString=xmlString+'<id>'+this.currentLayer.id+'</id>';}
if(Dom.get('layerFileName')){xmlString=xmlString+'<title>'+Dom.get('layerFileName').value+'</title>';}
if(this.currentLayer.layerLink){xmlString=xmlString+'<layerLink>'+this.currentLayer.layerLink+'</layerLink>';}
xmlString=xmlString+'<legends>';var n=legendFields.length;for(var i=0;i<n;i++){if(legendColors[i].value==PoiMsg.js_msg.legend.hexCode()){continue;}
if(!legendColors[i].value.match('(#)([0-9a-fA-F]{3})([0-9a-fA-F]{3})')){popupHandler.showValidationPopup(PoiMsg.js_msg.layerPopup.legendHexColor());return;}
xmlString=xmlString+'<layerLegend>';xmlString=xmlString+'<id>'+legendIds[i].value+'</id>';xmlString=xmlString+'<color>'+legendColors[i].value+'</color>';if(legendFields[i].value!=PoiMsg.js_msg.legend.name()){xmlString=xmlString+'<legend>'+legendFields[i].value+'</legend>';}
else{xmlString=xmlString+'<legend></legend>';}
xmlString=xmlString+'</layerLegend>';}
xmlString=xmlString+'</legends>';xmlString=xmlString+'</layer>';var params='layerXML='+xmlString;var that=this;UIRequest("saveLayer.action",params,function(p_oRequest){var json=YAHOO.lang.JSON.parse(p_oRequest.responseText);that.onSaveLayer(json.layer);popupHandler.hidePleaseWait();});}
MapLayerControl.prototype.deleteLayer=function(){var layerId=this.currentLayer.id;var params='layerId='+layerId+'&layerLink='+this.currentLayer.layerLink;var that=this;popupHandler.showConfirmPopup("",PoiMsg.js_msg.map.layer.deleteLayerWarning(this.currentLayer.title),function(){UIRequest("deleteLayer.action",params,function(p_oRequest){that.onDeleteLayer(layerId);popupHandler.hidePleaseWait();});this.hide();});}
MapLayerControl.prototype.onSaveLayer=function(layer){if(layer){this.replaceLayer(layer);this._clean();ctx.addLayer(layer);CLIPTOO.poi.map.Toolbar.refreshLayersMenu();Poi.getMap().removeLayers();}}
MapLayerControl.prototype.onDeleteLayer=function(layerId){if(layerId){this.removeLayerFromList(layerId);this._clean();Poi.getMap().removeLayers();ctx.removeLayerById(layerId);CLIPTOO.poi.map.Toolbar.refreshLayersMenu();}}
MapLayerControl.prototype.removeLayerFromList=function(layerId){var newLayers=[];var layers=this.layers;var n=layers.length;for(var i=0;i<n;i++){if(layers[i].id!=layerId){newLayers.push(layers[i]);}}
this.layers=newLayers;this.onLoadLayers(newLayers);}
MapLayerControl.prototype._clean=function(){this.select.selectedIndex=-1;var layerFileName=Dom.get('layerFileName');var deleteLayerName=Dom.get('deleteLayerName');var deleteLayerContainer=Dom.get('deleteLayerContainer');if(layerFileName){layerFileName.value='';}
this.legendsContainer.style.display='none';this.createBtn.style.display='none';deleteLayerName.innerHTML="";deleteLayerContainer.style.display="none";this.currentLayer={id:0,title:'',layerLink:''};}
MapLayerControl.prototype.replaceLayer=function(layer){var layers=this.layers;var n=layers.length;var isFound=false;for(var i=0;i<n;i++){if(layers[i].id==layer.id){isFound=true;layers[i]=layer;break;}}
if(!isFound){layers.push(layer);}
this.layers=layers;this.onLoadLayers(layers);}
MapLayerControl.prototype.onLoadLayers=function(layers){this.layers=layers;var optionsLength=this.select.options.length;for(var j=optionsLength-1;j>=0;j--){this.select.remove(j);}
if(layers){var n=layers.length+1;var option=document.createElement('OPTION');this.select.options.add(option);option.innerHTML='';option.value=-1;for(var i=1;i<n;i++){var option=document.createElement('OPTION');this.select.options.add(option);option.innerHTML=layers[i-1].title;option.value=layers[i-1].id;}
this.select.selectedIndex=-1;}}
MapLayerControl.prototype._openLayer=function(layerId){var layer=ctx.getLayerById(layerId);var layerFileName=Dom.get('layerFileName');var deleteLayerName=Dom.get('deleteLayerName');var deleteLayerContainer=Dom.get('deleteLayerContainer');if(layer){this.currentLayer=layer;if(layerFileName){layerFileName.value=layer.title;}
deleteLayerName.innerHTML=layer.title;deleteLayerContainer.style.display="block";Poi.getMap().showLayer(layer);}else{this._clean();Poi.getMap().removeLayers();}}
function UploadControl(){this.createTitle='';this.popupHint='';this.fileExtentions=[];this.initialize();};UploadControl.prototype.setOptions=function(){}
UploadControl.prototype.initialize=function(){this.setOptions();var outerContainer=document.createElement("div");outerContainer.className="map-poa-outer-container";outerContainer.style.display="none";this.outerContainer=outerContainer;var container=document.createElement("div");container.className="map-poa-container";var createLayerTitle=document.createElement("span");createLayerTitle.innerHTML=this.createTitle;createLayerTitle.style.fontWeight="bold";container.appendChild(createLayerTitle);var hintArea=document.createElement("span");hintArea.innerHTML=this.popupHint;container.appendChild(hintArea);var fileNameField=document.createElement("input");fileNameField.id=this.nameFieldId;var fieldContainer=roundCorners(fileNameField,"map-poa-field-container");container.appendChild(fieldContainer);var uploadBtn=document.createElement("div");uploadBtn.id=this.uploadBtn;uploadBtn.className="map-poa-btn-upload";uploadBtn.title=this.uploadBtnTitle;this.button=uploadBtn;container.appendChild(this.button);var roundPopup=document.createElement("div");roundPopup.className="round-easy-creating-popup";var leftCorner=document.createElement("div");leftCorner.className="left-corner-easy-creating-popup";var middleDiv=document.createElement("div");middleDiv.className="middle-easy-creating-popup";var rightCorner=document.createElement("div");rightCorner.className="right-corner-easy-creating-popup";roundPopup.appendChild(leftCorner);roundPopup.appendChild(middleDiv);roundPopup.appendChild(rightCorner);outerContainer.appendChild(container);outerContainer.appendChild(roundPopup);Dom.get(GlobalProperties.CONTAINER_MAP_ID).appendChild(outerContainer);this._confPoaUploader();};UploadControl.prototype.show=function(){this.outerContainer.style.display="";var map=Poi.getMap();map.serfMapWithHand();map.mode=map.MAP_VIEWING;map.enable();if(YAHOO.env.ua.webkit){Dom.get(this.nameFieldId).focus();}
Dom.get(this.nameFieldId).select();};UploadControl.prototype.hide=function(){this.outerContainer.style.display="none";Dom.get(this.nameFieldId).value='';};UploadControl.prototype._confPoaUploader=function(){if(!CLIPTOO.utils.isFlashPlayerCompatible()){return;}
var currentLocation=window.location;var path="themes/default/img/layers/upload-button.png";var fileExtentions=this.fileExtentions;YAHOO.widget.Uploader.SWFURL=currentLocation.protocol+"//"+currentLocation.host+GlobalProperties.HOST+"js/yui/uploader/assets/uploader.swf";var uploader=new YAHOO.widget.Uploader(this.uploadBtn,currentLocation.protocol+"//"+currentLocation.host+GlobalProperties.HOST+path);var onUploaderContentReady=function(){uploader.setAllowMultipleFiles(false);uploader.setFileFilters(fileExtentions);};uploader.addListener('contentReady',onUploaderContentReady);var currentLocation=window.location;var rootHost=currentLocation.protocol+"//"+currentLocation.host;var that=this;var fileExtention=null;function onFileSelectPoi(event){fileList=event.fileList;if(fileList){var map=Poi.getMap();map.removeTemporary();var newRouteId=GlobalProperties.NEW_ROUTE_ID;if(routes[newRouteId]){map.removeRoute(newRouteId);}
for(var i in fileList){fileExtention=CLIPTOO.utils.getFileExtension(fileList[i]);var fileName=CLIPTOO.utils.getFileName(fileList[i]);if(fileList[i].size>parseInt(PoiMsg.js_msg.upload.maxFileSize())){popupHandler.showErrorPopup(PoiMsg.js_msg.upload.maxSizeError(fileExtention));return;}
if(fileName.length>parseInt(PoiMsg.js_msg.upload.maxFileNameLength())){popupHandler.showErrorPopup(PoiMsg.js_msg.upload.maxSizeFileNameError());return;}
popupHandler.showPleaseWait();uploader.upload(i,GlobalProperties.HOST+"uploadPointOfArea.action","GET",{"userUid":ctx.getCurrentUserUid()});}
uploader.clearFileList();}}
function uploadCompleteData(event){var jsonWithLink=YAHOO.lang.JSON.parse(event.data);var layerLink=jsonWithLink.layerLink;Dom.get("poiLayerLink").value=layerLink;var poaName='';if(Dom.get(this.nameFieldId)){poaName=Dom.get(this.nameFieldId).value;}
that._onLoaded(layerLink,poaName);}
uploader.addListener('fileSelect',onFileSelectPoi);uploader.addListener('uploadCompleteData',uploadCompleteData);};function MapPointOfAreaControl(){this.nameFieldId="poa-file-name";this.uploadBtn="map-poa-btn";this.constructor.superclass.constructor.call(this);};YAHOO.lang.extend(MapPointOfAreaControl,UploadControl);MapPointOfAreaControl.prototype.setOptions=function(){this.createTitle=PoiMsg.js_msg.poaPopup.createPoaTitle();;this.popupHint=PoiMsg.js_msg.poaPopup.poaHint();this.uploadBtnTitle=PoiMsg.js_msg.poaPopup.poaBtnHint();this.fileExtentions.push({description:PoiMsg.js_msg.upload.poa(),extensions:"*.kml;*.kmz"});}
MapPointOfAreaControl.prototype._onLoaded=function(layerLink,poaName){Poi.getMap().showPoa(GlobalProperties.NEW_POA_ID,layerLink,poaName);};function UploadRouteControl(){this.nameFieldId="route-file-name";this.uploadBtn="map-route-btn";this.constructor.superclass.constructor.call(this);};YAHOO.lang.extend(UploadRouteControl,UploadControl);UploadRouteControl.prototype.setOptions=function(){this.createTitle=PoiMsg.js_msg.poaPopup.createRouteTitle();;this.popupHint=PoiMsg.js_msg.poaPopup.routeHint();this.uploadBtnTitle=PoiMsg.js_msg.poaPopup.routeBtnHint();this.fileExtentions.push({description:PoiMsg.js_msg.upload.route(),extensions:"*.gpx"});}
UploadRouteControl.prototype._onLoaded=function(routeLink,routeName){Poi.getMap().showRoute(GlobalProperties.NEW_ROUTE_ID,true,routeLink,routeName);popupHandler.hidePleaseWait();};(function(){DeadAreaControl=function(){}
DeadAreaControl.prototype=new GControl();var delegateClickEvent=function(ev){var target=ev.target?ev.target:ev.srcElement;var direction=target;if(direction.id=="deadAreaContainer"){return;}
while(direction.parentNode.id!="deadAreaContainer"){direction=direction.parentNode;}
var map=Poi.getMap();if(direction.className=="leftTopToDeadArea"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/dead_area/left_top");}
map.moveLeftUp();}
if(direction.className=="centerTopToDeadArea"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/dead_area/center_top");}
map.moveUp();}
if(direction.className=="rightTopToDeadArea"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/dead_area/right_top");}
map.moveRightUp();}
if(direction.className=="leftMiddleToDeadArea"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/dead_area/middle");}
map.moveLeft();}
if(direction.className=="rightMiddleToDeadArea"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/dead_area/right_middle");}
map.moveRight();}
if(direction.className=="leftBottomToDeadArea"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/dead_area/left_bottom");}
map.moveLeftDown();}
if(direction.className=="centerBottomToDeadArea"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/dead_area/center_bottom");}
map.moveDown();}
if(direction.className=="rightBottomToDeadArea"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/dead_area/right_bottom");}
map.moveRightDown();}}
DeadAreaControl.prototype.initialize=function(map){var that=this;var width=map.getSize().width;var height=map.getSize().height;var mapContainer=document.getElementById('google_map_main');var container=document.createElement("div");container.id='deadAreaContainer';container.className='deadAreaContainer';mapContainer.appendChild(container);var leftTopDiv=document.createElement("div");leftTopDiv.className='leftTopToDeadArea';leftTopDiv.title=PoiMsg.js_msg.map.deadArea.northWest();container.appendChild(leftTopDiv);var leftTopArrowDiv=document.createElement("div");leftTopArrowDiv.className='leftTopToDeadArea_arrow';leftTopArrowDiv.title=PoiMsg.js_msg.map.deadArea.northWest();leftTopDiv.appendChild(leftTopArrowDiv);var centerTopDiv=document.createElement("div");centerTopDiv.className='centerTopToDeadArea';centerTopDiv.title=PoiMsg.js_msg.map.deadArea.north();centerTopDiv.style.left=GlobalProperties.DEAD_AREA_SIZE+"px";centerTopDiv.style.width=""+(width-2*GlobalProperties.DEAD_AREA_SIZE-2)+"px";container.appendChild(centerTopDiv);var centerTopArrowDiv=document.createElement("div");centerTopArrowDiv.className='centerTopToDeadArea_arrow';centerTopArrowDiv.title=PoiMsg.js_msg.map.deadArea.north();centerTopArrowDiv.style.width=""+(width-2*GlobalProperties.DEAD_AREA_SIZE-2)+"px";centerTopDiv.appendChild(centerTopArrowDiv);var rightTopDiv=document.createElement("div");rightTopDiv.className='rightTopToDeadArea';rightTopDiv.title=PoiMsg.js_msg.map.deadArea.northEast();container.appendChild(rightTopDiv);var rightTopArrowDiv=document.createElement("div");rightTopArrowDiv.className='rightTopToDeadArea_arrow';rightTopArrowDiv.title=PoiMsg.js_msg.map.deadArea.northEast();rightTopDiv.appendChild(rightTopArrowDiv);var leftMiddleDiv=document.createElement("div");leftMiddleDiv.className='leftMiddleToDeadArea';leftMiddleDiv.title=PoiMsg.js_msg.map.deadArea.west();leftMiddleDiv.style.top=GlobalProperties.DEAD_AREA_SIZE+"px";leftMiddleDiv.style.height=""+(height-2*GlobalProperties.DEAD_AREA_SIZE-2)+"px";container.appendChild(leftMiddleDiv);var leftMiddleArrowDiv=document.createElement("div");leftMiddleArrowDiv.className='leftMiddleToDeadArea_arrow';leftMiddleArrowDiv.title=PoiMsg.js_msg.map.deadArea.west();leftMiddleArrowDiv.style.height=""+(height-2*GlobalProperties.DEAD_AREA_SIZE-2)+"px";leftMiddleDiv.appendChild(leftMiddleArrowDiv);var rightMiddleDiv=document.createElement("div");rightMiddleDiv.className='rightMiddleToDeadArea';rightMiddleDiv.title=PoiMsg.js_msg.map.deadArea.east();rightMiddleDiv.style.top=GlobalProperties.DEAD_AREA_SIZE+"px";rightMiddleDiv.style.height=""+(height-2*GlobalProperties.DEAD_AREA_SIZE-2)+"px";container.appendChild(rightMiddleDiv);var rightMiddleArrowDiv=document.createElement("div");rightMiddleArrowDiv.className='rightMiddleToDeadArea_arrow';rightMiddleArrowDiv.title=PoiMsg.js_msg.map.deadArea.east();rightMiddleArrowDiv.style.height=""+(height-2*GlobalProperties.DEAD_AREA_SIZE-2)+"px";rightMiddleDiv.appendChild(rightMiddleArrowDiv);var leftBottomDiv=document.createElement("div");leftBottomDiv.className='leftBottomToDeadArea';leftBottomDiv.title=PoiMsg.js_msg.map.deadArea.southWest();leftBottomDiv.style.top=""+(height-GlobalProperties.DEAD_AREA_SIZE-2)+"px";container.appendChild(leftBottomDiv);var leftBottomArrowDiv=document.createElement("div");leftBottomArrowDiv.className='leftBottomToDeadArea_arrow';leftBottomArrowDiv.title=PoiMsg.js_msg.map.deadArea.southWest();leftBottomDiv.appendChild(leftBottomArrowDiv);var centerBottomDiv=document.createElement("div");centerBottomDiv.className='centerBottomToDeadArea';centerBottomDiv.title=PoiMsg.js_msg.map.deadArea.south();centerBottomDiv.style.left=GlobalProperties.DEAD_AREA_SIZE+"px";centerBottomDiv.style.top=""+(height-GlobalProperties.DEAD_AREA_SIZE-2)+"px";centerBottomDiv.style.width=""+(width-2*GlobalProperties.DEAD_AREA_SIZE-2)+"px";container.appendChild(centerBottomDiv);var centerBottomArrowDiv=document.createElement("div");centerBottomArrowDiv.className='centerBottomToDeadArea_arrow';centerBottomArrowDiv.title=PoiMsg.js_msg.map.deadArea.south();centerBottomArrowDiv.style.width=""+(width-2*GlobalProperties.DEAD_AREA_SIZE-2)+"px";centerBottomDiv.appendChild(centerBottomArrowDiv);var rightBottomDiv=document.createElement("div");rightBottomDiv.className='rightBottomToDeadArea';rightBottomDiv.title=PoiMsg.js_msg.map.deadArea.southEast();rightBottomDiv.style.top=""+(height-GlobalProperties.DEAD_AREA_SIZE-2)+"px";container.appendChild(rightBottomDiv);var rightBottomArrowDiv=document.createElement("div");rightBottomArrowDiv.className='rightBottomToDeadArea_arrow';rightBottomArrowDiv.title=PoiMsg.js_msg.map.deadArea.southEast();rightBottomDiv.appendChild(rightBottomArrowDiv);Event.addListener("deadAreaContainer","click",delegateClickEvent);return container;};DeadAreaControl.prototype.getDefaultPosition=function(){return null;};DeadAreaControl.prototype.refresh=function(map){if(!map){map=Poi.getMap();}
if(map){var width=map.getSize().width;var height=map.getSize().height;var container=document.getElementById('deadAreaContainer');container.childNodes[1].style.width=""+(width-2*GlobalProperties.DEAD_AREA_SIZE-2)+"px";container.childNodes[1].firstChild.style.width=""+(width-2*GlobalProperties.DEAD_AREA_SIZE-2)+"px";container.childNodes[3].style.height=""+(height-2*GlobalProperties.DEAD_AREA_SIZE-2)+"px";container.childNodes[4].style.height=""+(height-2*GlobalProperties.DEAD_AREA_SIZE-2)+"px";container.childNodes[5].style.top=""+(height-GlobalProperties.DEAD_AREA_SIZE-2)+"px";container.childNodes[6].style.top=""+(height-GlobalProperties.DEAD_AREA_SIZE-2)+"px";container.childNodes[6].style.width=""+(width-2*GlobalProperties.DEAD_AREA_SIZE-2)+"px";container.childNodes[6].firstChild.style.width=""+(width-2*GlobalProperties.DEAD_AREA_SIZE-2)+"px";container.childNodes[7].style.top=""+(height-GlobalProperties.DEAD_AREA_SIZE-2)+"px";}}})();(function(){var map=null;var toolbar=null;var setMapModeByCursorProvider=function(cursorProviderDomId,mode){var cursorProvider=Dom.get(cursorProviderDomId);var cursor=Dom.getStyle(cursorProvider,"cursor");map.holdMapWithCursor(cursor);map.mode=mode;map.disable();}
var selectHandButton=function(){map.currentCursor=null;toolbar.selectHandButton();}
ZoomingControl=function(map){this.initialize(map);}
ZoomingControl.prototype.initialize=function(googleMap){map=googleMap;toolbar=CLIPTOO.poi.map.Toolbar;var container=document.getElementById('zoomingContainerId');var moveMapHandler=document.getElementById('moveMapHandlerId');this.moveMapHandler=moveMapHandler;var that=this;this.zoomIn=Dom.get("zoomIn");this.zoomOut=Dom.get("zoomOut");this.zoomOutTool=Dom.get("zoomOutTool");this.zoomInTool=Dom.get("zoomInTool");this.isDisabled=false;Event.addListener(moveMapHandler,'click',function(event){if(that.isDisabled){return;}
var side=15;if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/zooming_tool/shift_map");}
var deadArea=ctx.getDeadAreaControl();var isIE=YAHOO.env.ua.ie;var clientX=(isIE)?event.x:event.layerX;var clientY=(isIE)?event.y:event.layerY;var sideX=Math.floor(clientX/side);var sideY=Math.floor(clientY/side);if(sideX<1&&sideY<1){map.moveLeftUp();}
if(sideX>=1&&sideX<2&&sideY<1){map.moveUp();}
if(sideX>=2&&sideX<=3&&sideY<1){map.moveRightUp();}
if(sideX<1&&sideY>=1&&sideY>=1&&sideY<2){map.moveLeft();}
if(sideX>=2&&sideX<=3&&sideY>=1&&sideY<2){map.moveRight();}
if(sideX<1&&sideY>=2&&sideY<=3){map.moveLeftDown();}
if(sideX>=1&&sideX<2&&sideY>=2&&sideY<=3){map.moveDown();}
if(sideX>=2&&sideX<=3&&sideY>=2&&sideY<=3){map.moveRightDown();}});Event.addListener(this.zoomInTool,"click",function(){if(that.isDisabled){return;}
if(that.zoomInTool.className=='zoomInTool'){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/zoom_in_tool/using_tool");}
that.zoomInTool.className='zoomInToolPressed';setMapModeByCursorProvider("zoomInCursorProvider",map.MAP_ZOOMIN_IN);that.zoomInOn=true;toolbar.unSelectButtons();}else if(that.zoomInTool.className=='zoomInToolPressed'){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/zoom_in_tool/leave_tool");}
that.zoomInTool.className='zoomInTool';selectHandButton();that.zoomInOn=false;}
if(that.zoomOutTool.className!='zoomOutToolDisabled'){that.zoomOutTool.className='zoomOutTool';}});Event.addListener(this.zoomOutTool,"click",function(){if(that.isDisabled){return;}
if(that.zoomOutTool.className=='zoomOutTool'){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/zoom_out_tool/using_tool");}
that.zoomOutTool.className='zoomOutToolPressed';setMapModeByCursorProvider("zoomOutCursorProvider",map.MAP_ZOOMIN_OUT);that.zoomOutOn=true;toolbar.unSelectButtons();}else if(that.zoomOutTool.className=='zoomOutToolPressed'){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/zoom_out_tool/leave_tool");}
that.zoomOutTool.className='zoomOutTool';selectHandButton();that.zoomOutOn=false;}
if(that.zoomInTool.className!='zoomInToolDisabled'){that.zoomInTool.className='zoomInTool';}});var zoomSliderDiv=document.getElementById('poiZoomSlider');var upLimit=90;var downLimit=0;var tickSize=6;var changeZoomOnMap=function(){var newZoom=Math.round(Math.abs(slider.getValue()/tickSize)+2);var oldZoom=map.getZoom();if(newZoom>1&&newZoom<18){if(oldZoom!=newZoom){map.setZoom(newZoom);}
if(newZoom==GlobalProperties.MINIMAL_ZOOM_LEVEL){that.zoomOutTool.className='zoomOutToolDisabled';}else{if(that.zoomOutTool.className=='zoomOutToolDisabled'&&!that.zoomOutOn){that.zoomOutTool.className='zoomOutTool';}else if(that.zoomOutTool.className=='zoomOutToolDisabled'&&that.zoomOutOn){that.zoomOutTool.className='zoomOutToolPressed';}}
if(newZoom==GlobalProperties.MAXIMAL_ZOOM_LEVEL){that.zoomInTool.className='zoomInToolDisabled';}else{if(that.zoomInTool.className=='zoomInToolDisabled'&&!that.zoomInOn){that.zoomInTool.className='zoomInTool';}else if(that.zoomInTool.className=='zoomInToolDisabled'&&that.zoomInOn){that.zoomInTool.className='zoomInToolPressed';}}}};var slider=new YAHOO.widget.Slider.getVertSlider(zoomSliderDiv,'thumb',upLimit,downLimit,tickSize);slider.subscribe('slideEnd',changeZoomOnMap);this.slider=slider;this.thumb=Dom.get('thumb');Event.addListener(this.zoomIn,"click",function(){var zoom=map.getZoom();if(slider){var value=-1*6*(zoom+1-2);slider.setValue(value,true,false,false);}});Event.addListener(this.zoomOut,"click",function(){var zoom=map.getZoom();if(slider){var value=-1*6*(zoom-1-2);slider.setValue(value,true,false,false);}});var zoomOuterDiv=document.getElementById('zoomOuterDiv');this.outerContainer=zoomOuterDiv;zoomOuterDiv.style.visibility='hidden';return container;}
ZoomingControl.prototype.show=function(){var zoomingContainer=this.outerContainer;if(zoomingContainer.style.visibility=='hidden'){zoomingContainer.style.visibility='';var zoom=map.getZoom();var value=-1*6*(zoom-2);this.slider.setValue(value,true,false,false);}}
ZoomingControl.prototype.hide=function(){this.zoomToolsRefresh();selectHandButton();this.outerContainer.style.visibility='hidden';}
ZoomingControl.prototype.zoomToolsRefresh=function(){if(this.zoomInTool.className!='zoomInToolDisabled'){this.zoomInTool.className='zoomInTool';}
if(this.zoomOutTool.className!='zoomOutToolDisabled'){this.zoomOutTool.className='zoomOutTool';}}
ZoomingControl.prototype.disable=function(){this.slider.lock();this.zoomOutTool.className='zoomOutTool';this.zoomInTool.className='zoomInTool';Dom.addClass(this.moveMapHandler,'zoom-disabled');Dom.addClass(this.zoomIn,'zoom-disabled');Dom.addClass(this.zoomOut,'zoom-disabled');Dom.addClass(this.zoomInTool,'zoom-disabled');Dom.addClass(this.zoomOutTool,'zoom-disabled');this.isDisabled=true;if(this.thumb){this.thumb.className='zoom-thumb-disabled';}}
ZoomingControl.prototype.enable=function(){this.slider.unlock();Dom.removeClass(this.moveMapHandler,'zoom-disabled');Dom.removeClass(this.zoomIn,'zoom-disabled');Dom.removeClass(this.zoomOut,'zoom-disabled');Dom.removeClass(this.zoomInTool,'zoom-disabled');Dom.removeClass(this.zoomOutTool,'zoom-disabled');this.isDisabled=false;if(this.thumb){this.thumb.className='zoom-thumb';}}})();CLIPTOO.createPackage("poi.cookie");CLIPTOO.poi.cookie.create=function(name,value,days){if(!days){days=2;}
if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}
else var expires="";document.cookie=name+"="+value+expires+"; path=/";};CLIPTOO.poi.cookie.read=function(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}
return null;};CLIPTOO.poi.cookie.erase=function(name){CLIPTOO.poi.cookie.create(name,"",-1);};CLIPTOO.createPackage("InitParameters");CLIPTOO.InitParameters.getSelectedCategories=function(){var selectedCategoriesStr;var url=location.search;var CATEGORIES_KEY_LENGTH=12;var start=url.indexOf("?categories=");if(start==-1){start=url.indexOf("&categories=");}
if(start>-1){start=start+CATEGORIES_KEY_LENGTH;var end=url.indexOf("&",start+1);if(end==-1){selectedCategoriesStr=url.slice(start);}
else{selectedCategoriesStr=url.substring(start,end);}
CLIPTOO.poi.cookie.create("filter-categories",selectedCategoriesStr);}
else{selectedCategoriesStr=CLIPTOO.poi.cookie.read("filter-categories");}
if(selectedCategoriesStr==""||selectedCategoriesStr==null){selectedCategoriesStr=ctx.getOrgProperty("defaultSelectedCategories");CLIPTOO.poi.cookie.create("filter-categories",selectedCategoriesStr);}
return selectedCategoriesStr;};CLIPTOO.InitParameters.getMapZoom=function(){var zoom;var url=location.search;var ZOOM_KEY_LENGTH=9;var start=url.indexOf("?mapzoom=");if(start==-1){start=url.indexOf("&mapzoom=");}
if(start>-1){start=start+ZOOM_KEY_LENGTH;var end=url.indexOf("&",start+1);if(end==-1){zoom=url.slice(start);}
else{zoom=url.substring(start,end);}
CLIPTOO.poi.cookie.create("map-zoom",zoom);}
else{zoom=CLIPTOO.poi.cookie.read("map-zoom");}
return parseInt(zoom);};CLIPTOO.InitParameters.getMapPosition=function(){var position;var url=location.search;var POSITION_KEY_LENGTH=11;var start=url.indexOf("?mapcenter=");if(start==-1){start=url.indexOf("&mapcenter=");}
if(start>-1){start=start+POSITION_KEY_LENGTH;var end=url.indexOf("&",start+1);var serializedPosition;if(end==-1){serializedPosition=url.slice(start);}
else{serializedPosition=url.substring(start,end);}
var dividerPosition=serializedPosition.indexOf(",");position={x:parseFloat(serializedPosition.substring(0,dividerPosition)),y:parseFloat(serializedPosition.slice(dividerPosition+1))}
CLIPTOO.poi.cookie.create("map-center-x",position.x);CLIPTOO.poi.cookie.create("map-center-y",position.y);}
else{position={x:parseFloat(CLIPTOO.poi.cookie.read("map-center-x")),y:parseFloat(CLIPTOO.poi.cookie.read("map-center-y"))}}
return position;};CLIPTOO.InitParameters.isPoiListShown=function(){var shown;var url=location.search;var SHOWN_KEY_LENGTH=9;var start=url.indexOf("?poilist=");if(start==-1){start=url.indexOf("&poilist=");}
if(start>-1){start=start+SHOWN_KEY_LENGTH;var end=url.indexOf("&",start+1);if(end==-1){shown=(url.slice(start)=="show");}
else{shown=(url.substring(start,end)=="show");}
CLIPTOO.poi.cookie.create("right-collapse",shown?"0":"1");}
else{var cookieValue=CLIPTOO.poi.cookie.read("right-collapse");if(cookieValue==null){cookieValue=Dom.get("poiListArea").style.display=="none"?"1":"0";CLIPTOO.poi.cookie.create("right-collapse",cookieValue);}
shown=(cookieValue=="0");}
return shown;};CLIPTOO.InitParameters.isCategoryListShown=function(){var shown;var url=location.search;var SHOWN_KEY_LENGTH=9;var start=url.indexOf("?catlist=");if(start==-1){start=url.indexOf("&catlist=");}
if(start>-1){start=start+SHOWN_KEY_LENGTH;var end=url.indexOf("&",start+1);if(end==-1){shown=(url.slice(start)=="show");}
else{shown=(url.substring(start,end)=="show");}
CLIPTOO.poi.cookie.create("left-collapse",shown?"0":"1");}
else{var cookieValue=CLIPTOO.poi.cookie.read("left-collapse");if(cookieValue==null){cookieValue=Dom.get("categoriesListArea").style.display=="none"?"1":"0";CLIPTOO.poi.cookie.create("left-collapse",cookieValue);}
shown=(cookieValue=="0");}
return shown;};CLIPTOO.InitParameters.getSelectedLayer=function(){var selectedLayer;var url=location.search;var ZOOM_KEY_LENGTH=7;var start=url.indexOf("?layer=");if(start==-1){start=url.indexOf("&layer=");}
if(start>-1){start=start+ZOOM_KEY_LENGTH;var end=url.indexOf("&",start+1);if(end==-1){selectedLayer=url.slice(start);}
else{selectedLayer=url.substring(start,end);}
CLIPTOO.poi.cookie.create("selected-layer",selectedLayer);}
else{selectedLayer=CLIPTOO.poi.cookie.read("selected-layer");}
if((!selectedLayer||selectedLayer=="")&&selectedLayer!="no-layer"){selectedLayer=ctx.getOrgProperty("defaultSelectedLayer");}
return selectedLayer;};(function(){CLIPTOO.poi.map.PoisInformationTooltip=function(oMap){var _isMouseOnMarker=false;var _isMouseOnTooltip=false;var tooltipContainer=document.createElement("div");tooltipContainer.className="psTooltip";tooltipContainer.style.visibility="hidden";tooltipContainer.id="divInformationTooltipId";tooltipContainer.innerHTML='<div class="poi-tooltip-wrapper" id="tooltipPoiWrapper"> \
   <div class="poi-tooltip-top"> \
    <div class="poi-tooltip-left-top-corner"></div> \
    <div class="poi-tooltip-top-center" id="tooltipTopSize"></div> \
    <div class="poi-tooltip-right-top-corner"></div> \
   </div> \
   <div class="poi-tooltip-title"><span id="tooltipPoiName"></span></div> \
   <div class="poi-tooltip-center"> \
    <div id="toolltipPoiAdv" class="poi-tooltip-center-borders"> \
    <div class="poi-tooltip-center-corner"></div> \
     <div id="toolltipPoiAdvTitle" class="poi-tooltip-center-title"></div>\
     <textarea readonly="readonly" class="poi-tooltip-textarea" name="tooltipText" id="toolltipPoiAdvText"></textarea> \
     <div class="url-we-show-text"> \
      <a href="#" id="toolltipPoiAdvLink" target="blank"></a> \
     </div> \
    </div> \
    <div id="toolltipPoiMulticats" class="poi-tooltip-center-cats"></div> \
   </div> \
   <div class="poi-tooltip-bottom"> \
    <div class="poi-tooltip-left-bottom-corner"></div> \
    <div class="poi-tooltip-bottom-center" id="tooltipBottomSize"></div> \
    <div class="poi-tooltip-right-bottom-corner"></div> \
   </div> \
   <div id="tooltipTail"></div> \
  </div>';Event.addListener("toolltipPoiAdvText","focus",function(){this.blur();});Dom.get(GlobalProperties.CONTAINER_MAP_ID).appendChild(tooltipContainer);Event.addListener('divInformationTooltipId',"mouseover",function(){_isMouseOnTooltip=true;});Event.addListener('divInformationTooltipId',"mouseout",function(){_isMouseOnTooltip=false;setTimeout(function(){that.hideIfMouseOutOf();},500);});this.show=function(poi){if(!poi){return;}
var advertisement=false;var multiCats=false;var toolltipPoiAdv=Dom.get("toolltipPoiAdv");toolltipPoiAdv.style.display="none";if((poi.advertisementBasisCM!=null)&&(poi.advertisementBasisCM.line!=null)&&!(poi.advertisementBasisCM.payd&&poi.advertisementBasisCM.expired)){toolltipPoiAdv.style.display="";var toolltipPoiAdvTitle=Dom.get("toolltipPoiAdvTitle");var toolltipPoiAdvText=Dom.get("toolltipPoiAdvText");var toolltipPoiAdvLink=Dom.get("toolltipPoiAdvLink");var linesNumber=poi.advertisementBasisCM.countLines;CLIPTOO.utils.setTooltipTextareaHeight(toolltipPoiAdvText,linesNumber);toolltipPoiAdvTitle.innerHTML=poi.advertisementBasisCM.headName;toolltipPoiAdvText.innerHTML=poi.advertisementBasisCM.line;if(!!poi.advertisementBasisCM.urlName){toolltipPoiAdvLink.href='http://'+poi.advertisementBasisCM.goUrl;toolltipPoiAdvLink.innerHTML=poi.advertisementBasisCM.urlName;}else{toolltipPoiAdvLink.innerHTML="";}
advertisement=true;}
var catsIds=poi.categoriesIds;var multiCatsContainer=Dom.get("toolltipPoiMulticats");multiCatsContainer.innerHTML="";multiCatsContainer.style.display="";var multicategories_width;if(catsIds&&catsIds.length>1){var size=catsIds.length;var iconWidth=35;var maxCatIconsPerRow=5;if(size>maxCatIconsPerRow){multicategories_width=(iconWidth*maxCatIconsPerRow);}else{multicategories_width=(iconWidth*size);}
multiCatsContainer.style.width=multicategories_width+"px";var markerWidth=29;for(var i=0;i<size;i++){var categoryId=catsIds[i];var category=ctx.getCategories()[categoryId];var categoryCode=category.code;var divPoiIcon=document.createElement("div");multiCatsContainer.appendChild(divPoiIcon);divPoiIcon.className="tooltip_category_icon";var xPos=(0-categoryCode%10)*markerWidth;var yPos=(0-Math.floor(categoryCode/10))*markerWidth;divPoiIcon.style.backgroundPosition=xPos+"px "+yPos+"px";}
multiCatsContainer.style.display="block";multiCats=true;}else{multiCatsContainer.style.width=0+"px";multiCatsContainer.style.display="none";}
if((multiCats||advertisement)&&(YAHOO.env.ua.ie==7)){multiCatsContainer.parentNode.style.overflow="";}else{multiCatsContainer.parentNode.style.overflow="hidden";}
var poiName=Dom.get("tooltipPoiName");poiName.innerHTML=CLIPTOO.utils.escapeHTML(poi.name);var fixSize=CLIPTOO.utils.shrinkTwoRowsTextByWidthHeight(poiName,17,232,150);var latLngBounds=oMap.getBounds();var maxLat=latLngBounds.getNorthEast().lat();var maxLng=latLngBounds.getNorthEast().lng();var maxPoint=new GLatLng(maxLat,maxLng);var minLat=latLngBounds.getSouthWest().lat();var minLng=latLngBounds.getSouthWest().lng();var minPoint=new GLatLng(minLat,minLng);var point=new GLatLng(poi.latitude,poi.longitude);var maxCenter=oMap.fromLatLngToContainerPixel(maxPoint);var center=oMap.fromLatLngToContainerPixel(point);var minCenter=oMap.fromLatLngToContainerPixel(minPoint);var coords=YAHOO.util.Region.getRegion(tooltipContainer);var height=coords.bottom-coords.top;var width=coords.right-coords.left;if(width<multicategories_width){width=multicategories_width;}
var markerTopHeight=13;var markerBottomHeight=20;var yCorrection=35;var xCorrection=10;var lup={x:center.x-width,y:center.y-height-markerTopHeight-yCorrection};var ldp={x:center.x-width,y:center.y+height+markerBottomHeight};var rup={x:center.x+width-xCorrection,y:center.y-height-markerTopHeight-yCorrection};var rdp={x:center.x+width-xCorrection,y:center.y+height+markerBottomHeight};var x=parseFloat(center.x)+parseFloat(oMap.getContainer().offsetLeft);var y=parseFloat(center.y)+parseFloat(oMap.getContainer().offsetTop);if(rup.x<maxCenter.x&&rup.y>maxCenter.y){x=x-11;y=y-GlobalProperties.MAPS_CATEGORY_ICON_HEIGHT-height-2;tooltipContainer.firstChild.className='poi-tooltip-wrapper poi-tooltip-left-down-tail';}else if(lup.x>minCenter.x&&lup.y>maxCenter.y){x=x-width+13;y=y-GlobalProperties.MAPS_CATEGORY_ICON_HEIGHT-height-2;tooltipContainer.firstChild.className='poi-tooltip-wrapper poi-tooltip-right-down-tail';}else if(rdp.x<maxCenter.x&&rdp.y<minCenter.y){x=x-12;y=y+9;tooltipContainer.firstChild.className='poi-tooltip-wrapper poi-tooltip-left-up-tail';}else{x=x-width+13;y=y+9;tooltipContainer.firstChild.className='poi-tooltip-wrapper poi-tooltip-right-up-tail';}
if(y+height>minCenter.y||x+width-xCorrection>maxCenter.x){return;}
tooltipContainer.style.top=y+"px";tooltipContainer.style.left=x+"px";tooltipContainer.style.visibility="visible";};this.hide=function(){tooltipContainer.style.visibility="hidden";}
this.hideIfMouseOutOf=function(){if(!this.isMouseOnMarker()&&!this.isMouseOnTooltip()){this.hide();}}
this.isMouseOnMarker=function(){return _isMouseOnMarker;}
this.isMouseOnTooltip=function(){return _isMouseOnTooltip;}
this.setMouseOnMarker=function(isBoolean){_isMouseOnMarker=isBoolean;}
this.setMouseOnTooltip=function(isBoolean){_isMouseOnTooltip=isBoolean;}
var that=this;GEvent.addListener(oMap,"zoomend",function(prevLevel,nextLevel){that.hide();});this.destroy=function(){if(YAHOO.env.ua.gecko){tooltipContainer.parentNode.removeChild(tooltipContainer);}
tooltipContainer=null;}}})();function JumpToControl(jumpToConfig){this.constructor.superclass.constructor.call(this,jumpToConfig);};YAHOO.lang.extend(JumpToControl,EasyCreatingControl);JumpToControl.prototype.buildSearchList=function(){var results=this.gs.results;if(results.length==1){var address=results[0].addressLines.join(", ");this.actionAfterSearch(address);}
if(results.length>1){this.resultHint.style.display="";this.resultList.style.display="";this.nothingFoundHint.style.display="none";this.resultList.innerHTML="";for(var i=0;i<results.length;i++){var address=results[i].addressLines.join(", ");var link=document.createElement("address");link.innerHTML=address;link.id=i+"_address_row";this.resultList.appendChild(link);}}};JumpToControl.prototype.actionAfterSearch=function(address){popupHandler.showPleaseWait();CLIPTOO.poi.map.types.getLocations(address,function(bounds){if(!bounds){popupHandler.hidePleaseWait();return;}
if(bounds){var llbounds=new GLatLngBounds(new GLatLng(bounds.south,bounds.west),new GLatLng(bounds.north,bounds.east));var map=Poi.getMap();var bestZoom=map.getZoomLevelForBounds(llbounds);if(map.getCenter()!=llbounds.getCenter()||map.getZoom()!=bestZoom){map.setCenter(llbounds.getCenter(),bestZoom);}
popupHandler.hidePleaseWait();}},this);};function RatingComponent(balloon){this.parent=balloon;this.itemsPerPage=3;this.poiIdFromBallon=null;this.isPagingBuild=false;this.ratingCount=0;this.writeContainer=Dom.get("ratingWriteContainer");this.writeContainerAddRate=Dom.get("ratingWriteContainerAddRate");this.commentsListContainer=Dom.get("ratingWriteCommentsListWrapper");this.pagingContainer="ratingWritePagingWrapper";this.displayInfoRate=Dom.get("poiWriteRatingInfoRate");this.ratingCountContainer=Dom.get("ratingWriteTotalCount");this.noRatingContainer=Dom.get("ratingWriteContainerNoRate");this.ratingImgCaptchaId="ratingWriteCaptcha";this.ratingWordCaptchaInputId="ratingWriteCaptchaWordVerificationId";this.ratingRefrshCaptchaButtonId="ratingWriteCaptchaGetNewImage";this.userName=Dom.get("ratingWriteUserName");this.comment=Dom.get("ratingWriteComment");this.rate1=Dom.get("rateWriteButton1");this.rate2=Dom.get("rateWriteButton2");this.isEnabledVote=false;this.attachHandlers();};RatingComponent.prototype._delegateClickEvent=function(ev){var obj=ev.target?ev.target:ev.srcElement;};RatingComponent.prototype.attachHandlers=function(){Event.addListener("ratingWriteBalloonTab","click",this._delegateClickEvent,this,true);};RatingComponent.prototype.initRatingTab=function(poiId,callback){popupHandler.showPleaseWait();this.poiIdFromBallon=poiId;this.commentsListContainer.innerHTML="";this.writeContainerAddRate.style.display="none";var that=this;UIRequest("returnRatingFirstPage.action","poiId="+this.poiIdFromBallon+"&commentPerPage="+this.itemsPerPage+"&offset=0",function(data){var json=YAHOO.lang.JSON.parse(data.responseText);if(json.ratingListFirstPage.ratings.length>0){that.buildRatingFirstPage(json);}else{that.showNoRatingHint();that.ratingCount=0;}
popupHandler.hidePleaseWait();if(callback=="addRating"){that.addRating();}});};RatingComponent.prototype.updateRatingTab=function(poiId,callback){popupHandler.showPleaseWait();this.poiIdFromBallon=poiId;this.commentsListContainer.innerHTML="";this.writeContainerAddRate.style.display="none";var that=this;UIRequest("returnRatingFirstPage.action","poiId="+this.poiIdFromBallon+"&commentPerPage="+this.itemsPerPage+"&offset=0",function(data){var json=YAHOO.lang.JSON.parse(data.responseText);if(json.ratingListFirstPage.ratings.length>0){that.buildRatingFirstPage(json);}else{that.showNoRatingHint();}
popupHandler.hidePleaseWait();if(callback=="addRating"){that.addRating();}});};RatingComponent.prototype.setRate=function(averageRating){var icon=Dom.getNextSibling(this.displayInfoRate);if(averageRating>0){var averageRatingStr="+"+averageRating;icon.className="rating-info-rate-icon-up";}
if(averageRating==0){var averageRatingStr="0";icon.className="rating-info-rate-icon-up";}
if(averageRating<0){var averageRatingStr="-"+Math.abs(averageRating);icon.className="rating-info-rate-icon-down";}
if((averageRatingStr)&&(averageRatingStr!="")){this.displayInfoRate.innerHTML=averageRatingStr;}else{this.displayInfoRate.innerHTML="";icon.className="rating-info-rate-icon";}
var isUserLoggedIn=ctx.getCurrentUserUid()&&ctx.getCurrentUserUid()!='';var voteEl=this.displayInfoRate.parentNode;if(isUserLoggedIn&&this.isEnabledVote&&Dom.hasClass(voteEl,"disabled")){Dom.removeClass(voteEl,"disabled");voteEl.title="";}
if((!this.isEnabledVote&&!Dom.hasClass(voteEl,"disabled"))){Dom.addClass(voteEl,"disabled");if(isUserLoggedIn){Dom.get('poiRatingInfoWrapper').title=PoiMsg.js_msg.balloon.votedPoi();}}};RatingComponent.prototype.buildRatingFirstPage=function(resultData){this.ratingCount=resultData.ratingListFirstPage.ratingCount;var averageRating=resultData.ratingListFirstPage.averageRating;this.closeAddRating();this.setRate(averageRating);if(typeof(this.ratingCount)!="undefined"){this.ratingCountContainer.innerHTML=PoiMsg.js_msg.balloon.ratingTotalComments()+" ("+this.ratingCount+")";}
var result=this.createHtmlForRating(resultData.ratingListFirstPage.ratings);this.commentsListContainer.innerHTML=result;if(this.isPagingBuild==false){this.buildPaging();this.isPagingBuild=true;}
var pageNumber=1;this.paging.setCurrentPage(pageNumber);this.paging.formPagesForPager(this.ratingCount);};RatingComponent.prototype.buildRatingPage=function(resultData,pageNumber){this.paging.setCurrentPage(pageNumber);this.paging.formPagesForPager(this.ratingCount);var result=this.createHtmlForRating(resultData.ratingListPage);this.commentsListContainer.innerHTML=result;popupHandler.hidePleaseWait();};RatingComponent.prototype.createHtmlForRating=function(ratingList){var template='<div class="rating-list-item">\
 <div class="rating-list-name">$name</div> <div class="rating-list-time">($time)</div>\
 <div class="rating-list-rate $rate"></div>\
 <div class="rating-list-comment">$comment</div>\
 <div class="rating-list-separator"></div>\
 </div>',result="";var size=ratingList.length;for(var i=0;i<size;i++){var userName=ratingList[i].userName,commentTime=ratingList[i].commentTime,comment=ratingList[i].comment,rate=ratingList[i].rate;result+=template.replace(/\$name/g,userName).replace(/\$time/g,commentTime).replace(/\$comment/g,comment).replace(/\$rate/,rate?"rating-info-rate-icon-up":"rating-info-rate-icon-down");}
return result;};RatingComponent.prototype.buildPaging=function(){this.paging=CLIPTOO.Paging(this.pagingContainer,this.itemsPerPage,5,{isShowElementsCount:false});var that=this;this.paging.changePageToListener=function(pageNumber){popupHandler.showPleaseWait();var offset=(that.itemsPerPage*pageNumber)-that.itemsPerPage;UIRequest("returnRatingPage.action","poiId="+that.poiIdFromBallon+"&commentPerPage="+that.itemsPerPage+"&offset="+offset,function(data){var json=YAHOO.lang.JSON.parse(data.responseText);that.buildRatingPage(json,pageNumber);});}};RatingComponent.prototype.addRating=function(){if(!this.isEnabledVote){return;}
ctx.getViewBalloon().activeContent.style.visibility="hidden";this.writeContainer.style.display="none";this.writeContainerAddRate.style.display="block";this.noRatingContainer.style.display="none";this.initCaptcha();};RatingComponent.prototype.closeAddRating=function(action){if(this.ratingCount>0){this.writeContainer.style.display="block";this.noRatingContainer.style.display="none";}else{this.writeContainer.style.display="none";this.noRatingContainer.style.display="block";}
this.writeContainerAddRate.style.display="none";if(!!Dom.get("ratingUserName"))Dom.get("ratingUserName").value="";if(!!Dom.get("ratingComment"))Dom.get("ratingComment").value="";if(!!Dom.get("rateButton1"))Dom.get('rateButton1').checked=false;if(!!Dom.get("rateButton2"))Dom.get('rateButton2').checked=false;if(this.parent&&this.parent.activeContent){this.parent.activeContent.style.visibility="";}};RatingComponent.prototype.showNoRatingHint=function(){this.noRatingContainer.style.display="block";this.writeContainerAddRate.style.display="none";this.writeContainer.style.display="none";};RatingComponent.prototype.initCaptcha=function(){var imgCaptcha=Dom.get(this.ratingImgCaptchaId);var wordCaptchaInput=Dom.get(this.ratingWordCaptchaInputId);var themeSelectror=function(){imgCaptcha.src=GlobalProperties.HOST+'kaptcha_balloon_rating2.jpg?'+Math.floor(Math.random()*100);wordCaptchaInput.value="";if((THEME_NAME=="landleven")||(THEME_NAME=="healthcare")||(THEME_NAME=="omroepbrabant")){imgCaptcha.src=GlobalProperties.HOST+'kaptcha_balloon_rating.jpg?'+Math.floor(Math.random()*100);}};themeSelectror();Event.addListener(Dom.get(this.ratingRefrshCaptchaButtonId),"click",themeSelectror);};RatingComponent.prototype.saveRatingTab=function(){popupHandler.showPleaseWait();var userName=this.userName.value;var comment=this.comment.value;var rate1=(this.rate1.checked==true)?true:false;var rate2=(this.rate2.checked==true)?true:false;var rate=(rate1==true)?true:false;var wordCaptchaInput=Dom.get(this.ratingWordCaptchaInputId);if(comment&&CLIPTOO.utils.trim(comment).length>0){if(comment.length>300){comment=comment.substr(0,300)+"...";}}
if((!userName||userName=="")||(!comment||comment=="")||(rate1==false&&rate2==false)){popupHandler.showValidationPopup(PoiMsg.js_msg.balloon.audioMandatory());popupHandler.hidePleaseWait();return;}
var that=this;UIRequest("validateRatingCaptchaWord.action","captchaWordVerificationNameRating="+wordCaptchaInput.value,function(data){var json=YAHOO.lang.JSON.parse(data.responseText);if(json.captchaRatingValidationResult){var param="";if(ctx.getViewBalloon().poi){param+="poiId="+ctx.getViewBalloon().poi.id;}
if(userName){param+="&userName="+userName;}
if(comment){param+="&comment="+comment;}
if(rate){param+="&rate="+rate;}
if(wordCaptchaInput.value){param+="&verificationWord="+wordCaptchaInput.value;}
UIRequest("addRating.action",param,function(data){popupHandler.hidePleaseWait();that.isEnabledVote=false;var json=YAHOO.lang.JSON.parse(data.responseText);var averageRating=json.averageRating;if(averageRating){that.setRate(averageRating);}
that.closeAddRating();if(that.parent.activeTab.id=="ratingReadMenuTabId"){that.updateRatingTab(that.parent.poi.id);}});}else{popupHandler.showValidationPopup(PoiMsg.js_msg.balloonCaptchaError());popupHandler.hidePleaseWait();}});};function ViewRatingComponent(balloon){this.parent=balloon;this.itemsPerPage=3;this.poiIdFromBallon=null;this.isPagingBuild=false;this.ratingCount=0;this.writeContainer=Dom.get("ratingContainer");this.writeContainerAddRate=Dom.get("ratingContainerAddRate");this.commentsListContainer=Dom.get("ratingCommentsListWrapper");this.pagingContainer="ratingPagingWrapper";this.displayInfoRate=Dom.get("poiRatingInfoRate");this.ratingCountContainer=Dom.get("ratingTotalCount");this.noRatingContainer=Dom.get("ratingContainerNoRate");this.ratingImgCaptchaId="ratingCaptcha";this.ratingWordCaptchaInputId="ratingCaptchaWordVerificationId";this.ratingRefrshCaptchaButtonId="ratingCaptchaGetNewImage";this.userName=Dom.get("ratingUserName");this.comment=Dom.get("ratingComment");this.rate1=Dom.get("rateButton1");this.rate2=Dom.get("rateButton2");this.attachHandlers();};YAHOO.lang.extend(ViewRatingComponent,RatingComponent);ViewRatingComponent.prototype._delegateClickEvent=function(ev){var obj=ev.target?ev.target:ev.srcElement;var closeButton=obj;while(closeButton.id!=="ratingCancelButton"&&closeButton.id!=="ratingContainerAddRate"){closeButton=closeButton.parentNode;}
if(closeButton.id==="ratingCancelButton"){this.closeAddRating();}
var saveButton=obj;while(saveButton.id!=="ratingPostButton"&&saveButton.id!=="ratingContainerAddRate"){saveButton=saveButton.parentNode;}
if(saveButton.id==="ratingPostButton"){this.saveRatingTab();}};ViewRatingComponent.prototype.attachHandlers=function(){Event.addListener("ratingContainerAddRate","click",this._delegateClickEvent,this,true);};(function(){var map=null;var gmapHistory=new Array();var nextHistory=new Array();var historyPosition=0;var lastCenter;var zoomEndListener,dragEndListener;var nextDiv,backDiv;function notEqualHistoryElements(a,b){return(a.zoom!=b.zoom)||(a.center.lat()!=b.center.lat())||(a.center.lng()!=b.center.lng());}
function saveCurrentPosition(){var curr={zoom:map.getZoom(),center:map.getCenter()}
if(!gmapHistory.length){gmapHistory.push(curr);}else{var last=gmapHistory[gmapHistory.length-1];if(notEqualHistoryElements(last,curr)){gmapHistory.push(curr);}}}
function enableBackButton(){backDiv.className="back";}
function disableNextButton(){nextDiv.className="next0";}
function handleBackClick(){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/maptoolbar/history_back");}
if((gmapHistory.length-1)!=0){nextHistory.push(gmapHistory.pop());var lastMapPosition=gmapHistory[gmapHistory.length-1];nextDiv.className="next";if(gmapHistory.length==1){backDiv.className="back0";}
map.setCenter(lastMapPosition.center,lastMapPosition.zoom);}}
function handleBackMouseOver(){GEvent.removeListener(zoomEndListener);GEvent.removeListener(dragEndListener);}
function handleBackMouseOut(){zoomEndListener=GEvent.addListener(map,"zoomend",saveHistory);dragEndListener=GEvent.addListener(map,"dragend",saveHistory);}
function handleNextClick(){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/maptoolbar/history_next");}
if(nextHistory.length!=0){var lastMapPosition=nextHistory.pop();gmapHistory.push(lastMapPosition);enableBackButton();if(nextHistory.length==0){disableNextButton();}
map.setCenter(lastMapPosition.center,lastMapPosition.zoom);}}
function handleNextMouseOver(){GEvent.removeListener(zoomEndListener);GEvent.removeListener(dragEndListener);}
function handleNextMouseOut(){zoomEndListener=GEvent.addListener(map,"zoomend",saveHistory);dragEndListener=GEvent.addListener(map,"dragend",saveHistory);}
function saveHistory(){nextHistory=new Array();disableNextButton();if(gmapHistory.length-1==0){enableBackButton();}
saveCurrentPosition();}
CLIPTOO.poi.map.PoiGMapHistory=function(oOptions){map=oOptions.map;nextDiv=Dom.get(oOptions.next);backDiv=Dom.get(oOptions.back);backDiv.className="back0";nextDiv.className="next0";saveCurrentPosition();zoomEndListener=GEvent.addListener(map,"zoomend",saveHistory);dragEndListener=GEvent.addListener(map,"dragend",saveHistory);GEvent.addDomListener(backDiv,"click",handleBackClick);GEvent.addDomListener(backDiv,"mouseover",handleBackMouseOver);GEvent.addDomListener(backDiv,"mouseout",handleBackMouseOut);GEvent.addDomListener(nextDiv,"click",handleNextClick);GEvent.addDomListener(nextDiv,"mouseover",handleNextMouseOver);GEvent.addDomListener(nextDiv,"mouseout",handleNextMouseOut);};})();Array.remove=function(array,from,to){var rest=array.slice((to||from)+1||array.length);array.length=from<0?array.length+from:from;return array.push.apply(array,rest);};CLIPTOO.createPackage('widget.CategoryList');CLIPTOO.widget.CategoryList=function(categoriesCollection,containerId,pickerContainerId,onMainCategoryChanged){this.categoriesCollection=categoriesCollection;this.containerId=containerId;this.pickerContainerId=pickerContainerId;this.createDom();this.createCategoryPicker();this.categories=null;this.otherCategoriesPrice=ctx.getOrgProperty("priceForSecondCategory");if(this.otherCategoriesPrice===""){this.otherCategoriesPrice="0";}
this.onMainCategoryChanged=onMainCategoryChanged;this.priceForFirstCategory=0;this.attachHandlers();}
CLIPTOO.widget.CategoryList.CATEGORIES_COUNT=6;CLIPTOO.widget.CategoryList.prototype.attachHandlers=function(){Event.addListener("categoryPicker","click",this._delegateCategoriesListClick,this,true);Event.addListener("carouselContainer","click",this._delegateSelectedCategoriesClick,this,true);};CLIPTOO.widget.CategoryList.prototype._delegateCategoriesListClick=function(ev){var obj=ev.target?ev.target:ev.srcElement;if(obj.className=="col-category-icon"){this._onSelectHandler(obj);}};CLIPTOO.widget.CategoryList.prototype._delegateSelectedCategoriesClick=function(ev){var obj=ev.target?ev.target:ev.srcElement;if(obj.className=="category-icon"){this._onIconClick(parseInt(obj.parentNode.id));}
if(obj.className=="delete-category-btn"){this._onDeleteHandler(parseInt(obj.parentNode.id));}
if(obj.className=="categories-left-scroll"){this._scrollLeftHandler();}
if(obj.className=="categories-right-scroll"){this._scrollRightHandler();}
if(obj.className=="main-category-scroll-left"){this._scrollMainCatLeft();}
if(obj.className=="main-category-scroll-right"){this._scrollMainCatRight();}};CLIPTOO.widget.CategoryList.prototype.createDom=function(){var container=document.getElementById(this.containerId);var mainCategoryWrapper=document.createElement("div");mainCategoryWrapper.className="main-category-wrapper no-category";container.appendChild(mainCategoryWrapper);var mainCategoryLeftScroller=document.createElement("div");mainCategoryLeftScroller.className="main-category-scroll-left";mainCategoryWrapper.appendChild(mainCategoryLeftScroller);var mainCategory=document.createElement("div");mainCategory.className="main-category";mainCategoryWrapper.appendChild(mainCategory);var mainCategoryRightScroller=document.createElement("div");mainCategoryRightScroller.className="main-category-scroll-right";mainCategoryWrapper.appendChild(mainCategoryRightScroller);var mainCategoryTitle=document.createTextNode(PoiMsg.js_msg.category.picker.main());mainCategoryWrapper.appendChild(mainCategoryTitle);var noCategoriesHint=document.createElement("div");noCategoriesHint.className="no-categories";noCategoriesHint.id="noCategoriesHintId";noCategoriesHint.innerHTML=PoiMsg.js_msg.category.picker.noCategories();container.appendChild(noCategoriesHint);var allCategories=document.createElement("div");allCategories.className="all-categories";allCategories.id="allCategoriesId";allCategories.style.display="none";container.appendChild(allCategories);var leftScroll=document.createElement("div");leftScroll.className="categories-left-scroll";leftScroll.id="categoriesLeftScrollId";allCategories.appendChild(leftScroll);var template='<div class="category-wrapper" id="$index">\
  <div class="category-icon"><div class="commercial-category-marker" title="'+PoiMsg.js_msg.balloon.commercialCategory.iconTooltip()+'"></div>\
  </div>\
  <div class="delete-category-btn" title="'+PoiMsg.js_msg.category.picker.remove()+'"></div>\
 </div>';var category,categoryIcon,deleteCategory,commercialCategoryMarkerTop;var categoriesSnippet='';for(var i=0;i<CLIPTOO.widget.CategoryList.CATEGORIES_COUNT;i++){categoriesSnippet+=template.replace(/\$index/g,i+'_category_index');}
allCategories.innerHTML+=categoriesSnippet;var rightScroll=document.createElement("div");rightScroll.className="categories-right-scroll";rightScroll.id="categoriesRightScrollId";allCategories.appendChild(rightScroll);this.mouseLeft=null;this.mouseRight=null;this.firstCategoryShownIndex=0;this.mainCategoryIndex=0;}
CLIPTOO.widget.CategoryList.prototype._getCategoryIconElements=function(){var container=document.getElementById(this.containerId);return Dom.getElementsByClassName("category-icon","div",container);}
CLIPTOO.widget.CategoryList.prototype._scrollLeftHandler=function(){var categoryIcons=this._getCategoryIconElements();this.firstCategoryShownIndex=this.firstCategoryShownIndex-1;var lastIndex=this.firstCategoryShownIndex+categoryIcons.length;if(this.firstCategoryShownIndex<=0){this.firstCategoryShownIndex=0;var leftScroller=Dom.get("categoriesLeftScrollId");leftScroller.style.visibility="hidden";}
var categories=this.categories;if(categories.length>lastIndex){Dom.get("categoriesRightScrollId").style.visibility="visible";}
var xPos,yPos;for(var i=this.firstCategoryShownIndex;i<lastIndex;i++){var categoryCode=ctx.getCategories()[categories[i]].code;xPos=(0-categoryCode%10)*29;yPos=(0-Math.floor(categoryCode/10))*29;categoryIcons[i-this.firstCategoryShownIndex].style.backgroundPosition=xPos+"px "+yPos+"px";categoryIcons[i-this.firstCategoryShownIndex].title=this._getCategoryName(categories[i]);categoryIcons[i-this.firstCategoryShownIndex].parentNode.style.visibility="visible";Dom.getNextSibling(categoryIcons[i-this.firstCategoryShownIndex]).style.visibility="visible";if(i==this.mainCategoryIndex){categoryIcons[i-this.firstCategoryShownIndex].parentNode.className="selected-category-wrapper";}else{categoryIcons[i-this.firstCategoryShownIndex].parentNode.className="category-wrapper";}
var price=ctx.getCategories()[categories[i]].price;if(price!=null){categoryIcons[i-this.firstCategoryShownIndex].firstChild.style.visibility="visible";}else{categoryIcons[i-this.firstCategoryShownIndex].firstChild.style.visibility="hidden";}}}
CLIPTOO.widget.CategoryList.prototype._scrollRightHandler=function(){var categories=this.categories;var categoryIcons=this._getCategoryIconElements();this.firstCategoryShownIndex=this.firstCategoryShownIndex+1;var lastIndex=this.firstCategoryShownIndex+categoryIcons.length;if(lastIndex>=categories.length){lastIndex=categories.length;var rightScroller=Dom.get("categoriesRightScrollId");rightScroller.style.visibility="hidden";}
var leftScroller=Dom.get("categoriesLeftScrollId");leftScroller.style.visibility="visible";var xPos,yPos;for(var i=this.firstCategoryShownIndex;i<lastIndex;i++){var categoryCode=ctx.getCategories()[categories[i]].code;xPos=(0-categoryCode%10)*29;yPos=(0-Math.floor(categoryCode/10))*29;categoryIcons[i-this.firstCategoryShownIndex].style.backgroundPosition=xPos+"px "+yPos+"px";categoryIcons[i-this.firstCategoryShownIndex].title=this._getCategoryName(categories[i]);if(i==this.mainCategoryIndex){categoryIcons[i-this.firstCategoryShownIndex].parentNode.className="selected-category-wrapper";}else{categoryIcons[i-this.firstCategoryShownIndex].parentNode.className="category-wrapper";}
var price=ctx.getCategories()[categories[i]].price;if(price!=null){categoryIcons[i-this.firstCategoryShownIndex].firstChild.style.visibility="visible";}else{categoryIcons[i-this.firstCategoryShownIndex].firstChild.style.visibility="hidden";}}
var n=categoryIcons.length;for(var i=lastIndex-this.firstCategoryShownIndex;i<n;i++){categoryIcons[i].parentNode.style.visibility="hidden";}}
CLIPTOO.widget.CategoryList.prototype.getCategories=function(){return this.categories;}
CLIPTOO.widget.CategoryList.prototype.setCategories=function(mainCategory,categories){categories=(typeof categories=="undefined"||categories==null)?[]:categories;var balloon=ctx.getEditBalloon();var copiedCategories=[];this.numberOfCommercialCategories=0;this.numberOfAllCommercialCategories=0;var n=categories.length;for(var i=0;i<n;i++){copiedCategories.push(categories[i]);var catPrice=ctx.getCategories()[categories[i]].price;if(catPrice!=null&&catPrice>0){this.numberOfCommercialCategories++;}
if(catPrice!=null){this.numberOfAllCommercialCategories++;}}
this.categories=copiedCategories;this.firstCategoryShownIndex=0;Dom.get("categoriesLeftScrollId").style.visibility="hidden";Dom.get("categoriesRightScrollId").style.visibility="hidden";if(mainCategory){Dom.get("noCategoriesHintId").style.display="none";Dom.get("allCategoriesId").style.display="block";for(var i=0;i<n;i++){if(copiedCategories[i]==mainCategory){this.mainCategoryIndex=i;break;}}
if(i==n&&mainCategory){copiedCategories.unshift(mainCategory);this.mainCategoryIndex=0;}}else{this.mainCategoryIndex=-1;Dom.get("allCategoriesId").style.display="none";Dom.get("noCategoriesHintId").style.display="block";}
this.setMainCategory(this.mainCategoryIndex);var categoryIcons=this._getCategoryIconElements();var length=Math.min(categoryIcons.length,n);var xPos,yPos;for(var i=0;i<length;i++){var categoryCode=ctx.getCategories()[copiedCategories[i]].code;xPos=(0-categoryCode%10)*29;yPos=(0-Math.floor(categoryCode/10))*29;categoryIcons[i].style.backgroundPosition=xPos+"px "+yPos+"px";categoryIcons[i].parentNode.style.display="block";categoryIcons[i].parentNode.style.visibility="visible";categoryIcons[i].parentNode.className=(i==this.mainCategoryIndex)?"selected-category-wrapper":"category-wrapper";categoryIcons[i].title=this._getCategoryName(copiedCategories[i]);var price=ctx.getCategories()[copiedCategories[i]].price;if(price!=null){categoryIcons[i].firstChild.style.visibility="visible";Dom.getNextSibling(categoryIcons[i]).style.visibility="visible";}
else{categoryIcons[i].firstChild.style.visibility="hidden";}}
var j=categoryIcons.length;if(length<j){for(var i=length;i<j;i++){categoryIcons[i].parentNode.style.display="none";categoryIcons[i].parentNode.style.visibility="hidden";categoryIcons[i].firstChild.style.visibility="hidden";}}
if(n>j){Dom.get("categoriesRightScrollId").style.visibility="visible";}
this._showTotalPriceInBaloon();this.showAllCategoriesExceptFor(copiedCategories);}
CLIPTOO.widget.CategoryList.prototype.addCategory=function(categoryId){Dom.get("noCategoriesHintId").style.display="none";Dom.get("allCategoriesId").style.display="block";var price=ctx.getCategories()[categoryId].price;if(price!=null&&price>0){this.numberOfCommercialCategories++;}
if(price!=null){this.numberOfAllCommercialCategories++;}
var categoryIcons=this._getCategoryIconElements();var n=this.categories.length-this.firstCategoryShownIndex;var xPos,yPos;if(n<categoryIcons.length){var categoryCode=ctx.getCategories()[categoryId].code;xPos=(0-categoryCode%10)*29;yPos=(0-Math.floor(categoryCode/10))*29;categoryIcons[n].style.backgroundPosition=xPos+"px "+yPos+"px";categoryIcons[n].parentNode.style.display="block";categoryIcons[n].title=this._getCategoryName(categoryId);categoryIcons[n].parentNode.style.visibility="visible";}else{var rightScroller=Dom.get("categoriesRightScrollId");rightScroller.style.visibility="visible";}
this.categories.push(parseInt(categoryId));if(Dom.getNextSibling(categoryIcons[n])){if(price!=null){categoryIcons[n].firstChild.style.visibility="visible";Dom.getNextSibling(categoryIcons[n]).style.visibility="visible";}
else{Dom.getNextSibling(categoryIcons[n]).style.visibility="visible";}}
if(this.categories.length==1){this.setMainCategory(0);}else{var container=document.getElementById(this.containerId);container.firstChild.childNodes[2].style.visibility="visible";}
this._showTotalPriceInBaloon();}
CLIPTOO.widget.CategoryList.prototype._scrollMainCatLeft=function(){this.setMainCategory(this.mainCategoryIndex-1);this._showTotalPriceInBaloon();}
CLIPTOO.widget.CategoryList.prototype._scrollMainCatRight=function(){this.setMainCategory(this.mainCategoryIndex+1);this._showTotalPriceInBaloon();}
CLIPTOO.widget.CategoryList.prototype._deselectMainCategory=function(){var index=this.mainCategoryIndex;var categoryIcons=this._getCategoryIconElements();if(this.firstCategoryShownIndex<=index&&index<this.firstCategoryShownIndex+categoryIcons.length){categoryIcons[index-this.firstCategoryShownIndex].parentNode.className="category-wrapper";}}
CLIPTOO.widget.CategoryList.prototype._onIconClick=function(iconIndex){this.setMainCategory(this.firstCategoryShownIndex+iconIndex);this._showTotalPriceInBaloon();}
CLIPTOO.widget.CategoryList.prototype.getMainCategory=function(){return this.categories[this.mainCategoryIndex];}
CLIPTOO.widget.CategoryList.prototype.setMainCategory=function(index){this._deselectMainCategory();var container=document.getElementById(this.containerId);var categoryIcons=this._getCategoryIconElements();if(this.firstCategoryShownIndex<=index&&index<this.firstCategoryShownIndex+categoryIcons.length){categoryIcons[index-this.firstCategoryShownIndex].parentNode.className="selected-category-wrapper";}
var mainCategory=container.firstChild.childNodes[1];if(this.categories.length>0){Dom.removeClass(container.firstChild,"no-category");var category=ctx.getCategories()[this.categories[index]];var xPos=(0-category.code%10)*29;var yPos=(0-Math.floor(category.code/10))*29;mainCategory.style.backgroundPosition=xPos+"px "+yPos+"px";mainCategory.title=this._getCategoryName(this.categories[index]);mainCategory.style.visibility="visible";var catPrice=ctx.getCategories()[category.id].price;if(catPrice!=null&&catPrice>0){this.priceForFirstCategory=this._getCategoryPrice(category.id);}
if(catPrice!=null&&catPrice==0){this.priceForFirstCategory=0;}}
else{Dom.addClass(container.firstChild,"no-category");mainCategory.style.visibility="hidden";}
var leftScroller=container.firstChild.firstChild;if(index<1){leftScroller.style.visibility="hidden";}
else{leftScroller.style.visibility="visible";}
if(index>-1&&index<this.categories.length-1){leftScroller.nextSibling.nextSibling.style.visibility="visible";}
else{leftScroller.nextSibling.nextSibling.style.visibility="hidden";}
this.mainCategoryIndex=index;if(this.onMainCategoryChanged&&this.mainCategoryIndex!=-1){this.onMainCategoryChanged(this.categories[this.mainCategoryIndex]);}}
CLIPTOO.widget.CategoryList.prototype._onDeleteHandler=function(index){var categoryIcons=this._getCategoryIconElements();var i=index;var realIndex=this.firstCategoryShownIndex+index;var price=ctx.getCategories()[this.categories[realIndex]].price;if(price!=null&&price>0){this.numberOfCommercialCategories--;}
if(price!=null){this.numberOfAllCommercialCategories--;}
this.showCategoryInList(this.categories[realIndex]);Array.remove(this.categories,realIndex,realIndex);var catLength=this.categories.length;if(catLength==0){Dom.get("allCategoriesId").style.display="none";Dom.get("noCategoriesHintId").style.display="block";}
var xPos,yPos;var n=categoryIcons.length;for(j=index;j<n;j++){i=this.firstCategoryShownIndex+j;if(i>=this.categories.length){break;}
var categoryCode=ctx.getCategories()[this.categories[i]].code;xPos=(0-categoryCode%10)*29;yPos=(0-Math.floor(categoryCode/10))*29;categoryIcons[j].style.backgroundPosition=xPos+"px "+yPos+"px";categoryIcons[j].parentNode.style.display="block";categoryIcons[j].title=this._getCategoryName(this.categories[i]);categoryIcons[j].parentNode.style.visibility="visible";var price=ctx.getCategories()[this.categories[i]].price;if(this.isCommercialCategoriesBlocked&&price){categoryIcons[j].firstChild.style.visibility="visible";Dom.getNextSibling(categoryIcons[j]).style.visibility="hidden";}else if(price!=null){categoryIcons[j].firstChild.style.visibility="visible";Dom.getNextSibling(categoryIcons[j]).style.visibility="visible";}else{Dom.getNextSibling(categoryIcons[j]).style.visibility="visible";categoryIcons[j].firstChild.style.visibility="hidden";}}
for(var i=j;i<n;i++){categoryIcons[i].parentNode.style.visibility="hidden";categoryIcons[i].firstChild.style.visibility="hidden";Dom.getNextSibling(categoryIcons[i]).style.visibility="hidden";}
if(catLength<=n){var rightScroller=Dom.get("categoriesRightScrollId");rightScroller.style.visibility="hidden";}
if(this.firstCategoryShownIndex>0){this._scrollLeftHandler();}
if(this.mainCategoryIndex>index){this.setMainCategory(this.mainCategoryIndex-1);}
if(this.categories.length==this.mainCategoryIndex){this.setMainCategory(this.mainCategoryIndex-1);}else{this.setMainCategory(this.mainCategoryIndex);}
this._showTotalPriceInBaloon();}
CLIPTOO.widget.CategoryList.prototype._scrollCategoriesDown=function(scroller){this._stopScrollUp();var categoriesList=scroller.previousSibling;var marginTop=parseInt(categoriesList.firstChild.style.marginTop);marginTop=marginTop-3;if(marginTop<categoriesList.offsetHeight-categoriesList.firstChild.offsetHeight){marginTop=categoriesList.offsetHeight-categoriesList.firstChild.offsetHeight;scroller.style.visibility="hidden";this._stopScrollDown();}
categoriesList.firstChild.style.marginTop=marginTop+"px";}
CLIPTOO.widget.CategoryList.prototype._scrollCategoriesUp=function(scroller){this._stopScrollDown();var categoriesList=scroller.nextSibling.firstChild;var marginTop=parseInt(categoriesList.style.marginTop);marginTop=marginTop+3;if(marginTop>0){marginTop=0;scroller.style.visibility="hidden";this._stopScrollUp();}
categoriesList.style.marginTop=marginTop+"px";}
CLIPTOO.widget.CategoryList.prototype._scrollDownHandler=function(ev,categoryList){if(categoryList.mouseDown==null||typeof categoryList.mouseDown=="undefined"){var scroller=this;categoryList._scrollCategoriesDown(scroller);scroller.previousSibling.previousSibling.style.visibility="visible";categoryList.mouseDown=setInterval(function(){categoryList._scrollCategoriesDown(scroller);},8);}}
CLIPTOO.widget.CategoryList.prototype._scrollUpHandler=function(ev,categoryList){if(categoryList.mouseUp==null||typeof categoryList.mouseUp=="undefined"){var scroller=this;categoryList._scrollCategoriesUp(scroller);scroller.nextSibling.nextSibling.style.visibility="visible";categoryList.mouseUp=setInterval(function(){categoryList._scrollCategoriesUp(scroller);},8);}}
CLIPTOO.widget.CategoryList.prototype._stopScrollUp=function(){if(this.mouseUp){clearInterval(this.mouseUp);this.mouseUp=null;}};CLIPTOO.widget.CategoryList.prototype._stopScrollDown=function(){if(this.mouseDown){clearInterval(this.mouseDown);this.mouseDown=null;}};CLIPTOO.widget.CategoryList.prototype._onMouseWheel=function(ev){var categoriesList=(ev.target)?ev.target:ev.srcElement;while(categoriesList.className!="col-categories-container"){categoriesList=categoriesList.parentNode;}
categoriesList=categoriesList.firstChild;if(categoriesList.parentNode.offsetHeight>categoriesList.offsetHeight){return;}
var scrolledUp=(ev.type=="DOMMouseScroll"&&ev.detail<0)||(ev.type=="mousewheel"&&ev.wheelDelta>0);var marginTop=parseInt(categoriesList.style.marginTop);if(scrolledUp){marginTop=marginTop+9;var scroller=document.getElementById("colCategoriesDownScrollId");scroller.style.visibility="visible";if(marginTop>0){marginTop=0;document.getElementById("colCategoriesUpScrollId").style.visibility="hidden";}}
else{marginTop=marginTop-9;var scroller=document.getElementById("colCategoriesUpScrollId");scroller.style.visibility="visible";if(marginTop<categoriesList.parentNode.offsetHeight-categoriesList.offsetHeight){marginTop=categoriesList.parentNode.offsetHeight-categoriesList.offsetHeight;document.getElementById("colCategoriesDownScrollId").style.visibility="hidden";}}
categoriesList.style.marginTop=marginTop+"px";Event.stopEvent(ev);}
CLIPTOO.widget.CategoryList.prototype._onSelectHandler=function(element){if(this.categories.length==10){return;}
element.style.display="none";this.addCategory(element.id);};CLIPTOO.widget.CategoryList.prototype.showAllCategoriesExceptFor=function(categories){var container=document.getElementById(this.pickerContainerId);var categoryGroups=Dom.getElementsByClassName("col-category-group","div",container);categoryGroups[0].parentNode.style.marginTop="0px";container.childNodes[1].style.visibility="hidden";var n=categoryGroups.length;var m=categories.length;var catGroupSelector=Dom.get("shownCategoryGroupId");var catGroupName=catGroupSelector.options[catGroupSelector.selectedIndex].text;var pointType=ctx.getEditBalloon().pointType;if(!pointType){var mainCatId=ctx.getEditBalloon().poi.mainCategoryId;pointType=ctx.getCategories()[mainCatId].categoryType;}
for(var i=0;i<n;i++){var categoriesIcon=Dom.getElementsByClassName("col-category-icon","div",categoryGroups[i]);var catCount=categoriesIcon.length;var hiddenCount=0;for(var j=0;j<catCount;j++){var exception=false;if(m>0){for(var k=0;k<m;k++){if(this.isCategoryExcepted(categoriesIcon[j],categories[k],pointType)){exception=true;hiddenCount++;break;}}}else{if(this.isCategoryExcepted(categoriesIcon[j],0,pointType)){exception=true;hiddenCount++;}}
categoriesIcon[j].style.display=exception?"none":"block";}
if((hiddenCount==catCount&&hiddenCount!=0)||(catGroupSelector.value!=-1&&categoryGroups[i].firstChild.title!=catGroupName)){categoryGroups[i].style.display="none";}
else{categoryGroups[i].style.display="block";}}
if(container.childNodes[3]){container.childNodes[3].style.visibility=(container.childNodes[2].offsetHeight>container.childNodes[2].firstChild.offsetHeight)?"hidden":"visible";}}
CLIPTOO.widget.CategoryList.prototype.isCategoryExcepted=function(catIcon,exceptedCat,pointType){var ctxCategories=ctx.getCategories();return(parseInt(catIcon.id)==parseInt(exceptedCat)||ctxCategories[parseInt(catIcon.id)].categoryType!=pointType);}
CLIPTOO.widget.CategoryList.prototype.showCategoryGroup=function(ev,groupSelect){var container=document.getElementById(this.pickerContainerId);var categoryGroups=Dom.getElementsByClassName("col-category-group","div",container);categoryGroups[0].parentNode.style.marginTop="0px";container.childNodes[1].style.visibility="hidden";var n=categoryGroups.length;if(parseInt(groupSelect.value)==-1){for(var i=0;i<n;i++){var groupCategories=categoryGroups[i].childNodes[1].childNodes;var m=groupCategories.length;var hiddenCount=0;for(var j=0;j<m;j++){if(groupCategories[j].style.display=="none"){hiddenCount++;}}
if(hiddenCount<m){categoryGroups[i].style.display="block";}
else{categoryGroups[i].style.display="none";}}}
else{var groupName=ctx.getCategoryGroups()[groupSelect.value].name;for(var i=0;i<n;i++){var name=Dom.getElementsByClassName("col-category-group-name","div",categoryGroups[i])[0];categoryGroups[i].style.display=(name.title==groupName)?"block":"none";}}
if(container.childNodes[2].offsetHeight>container.childNodes[2].firstChild.offsetHeight){container.childNodes[3].style.visibility="hidden";}
else{container.childNodes[3].style.visibility="visible";}}
CLIPTOO.widget.CategoryList.prototype.showCategoryInList=function(categoryId){var container=document.getElementById(this.pickerContainerId);var categoriesIcons=Dom.getElementsByClassName("col-category-icon","div",container);var n=categoriesIcons.length;for(var i=0;i<n;i++){if(categoriesIcons[i].id==categoryId){categoriesIcons[i].style.display="block";categoriesIcons[i].parentNode.parentNode.style.display="block";break;}}}
CLIPTOO.widget.CategoryList.prototype.createCategoryPicker=function(){var fragment=document.createDocumentFragment();this.mouseUp=null;this.mouseDown=null;var categoriesGroups=ctx.getCategoryGroups();var categories=ctx.getCategoriesList();var fieldsContainer=document.createElement("div");fragment.appendChild(fieldsContainer);var filterName=document.createElement("label");filterName.innerHTML=PoiMsg.js_msg.category.picker.filterName()
fieldsContainer.appendChild(filterName);var selectGroupWrapper=document.createElement("div");selectGroupWrapper.className="select-wrapper";fieldsContainer.appendChild(selectGroupWrapper);var selectGroup=document.createElement("select");selectGroup.id="shownCategoryGroupId";selectGroupWrapper.appendChild(selectGroup);selectGroup.options[0]=new Option(PoiMsg.js_msg.category.picker.allGroups(),-1);var j=1;for(var id in categoriesGroups){selectGroup.options[j++]=new Option(categoriesGroups[id].name,id);}
if(j==2){selectGroupWrapper.style.display="none";}
else{Event.addListener(selectGroup,"change",this.showCategoryGroup,selectGroup,this);}
var filter=document.createElement("input");var roundFilter=roundCorners(filter,"filterContainer");fieldsContainer.appendChild(roundFilter);filter.className="default-input-title";filter.value=PoiMsg.js_msg.category.picker.filter();filter.id="catFilterId";var filterIcon=document.createElement("div");filterIcon.className="cat-filter-icon";roundFilter.appendChild(filterIcon);var filterClean=document.createElement("div");filterClean.className="cat-filter-clean";filterClean.style.visibility="hidden";filterClean.id="filterCleanId";roundFilter.appendChild(filterClean);var scrollUp=document.createElement("div");scrollUp.className="col-categories-up-scroll";scrollUp.id="colCategoriesUpScrollId";scrollUp.style.visibility="hidden";fragment.appendChild(scrollUp);var scrollUpArrow=document.createElement("div");scrollUp.appendChild(scrollUpArrow);var categoriesWindow=document.createElement("div");categoriesWindow.className="col-categories-container";fragment.appendChild(categoriesWindow);var categoriesContainer=document.createElement("div");categoriesContainer.style.marginTop="0px";categoriesWindow.appendChild(categoriesContainer);var n=categories.length;var categoryGroup=-1;var groupContainer,groupName,groupCategoriesContainer,category;var xPos,yPos;var spanToShrink=document.createElement("span");spanToShrink.style.visiblity="hidden";document.body.appendChild(spanToShrink);for(var i=0;i<n;i++){if(!this._isPermited(categories[i].id)){continue;}
if(categories[i].categoryGroupId!=categoryGroup){categoryGroup=categories[i].categoryGroupId;groupContainer=document.createElement("div");groupContainer.className="col-category-group";categoriesContainer.appendChild(groupContainer);categoriesContainer.appendChild(groupContainer);groupName=document.createElement("div");groupName.className="col-category-group-name";groupName.title=categoriesGroups[categoryGroup].name;groupContainer.appendChild(groupName);var width=85;spanToShrink.innerHTML=categoriesGroups[categoryGroup].name;var text=spanToShrink.innerHTML;if(text.length>100){text=text.slice(0,maxLength);}
while(spanToShrink.offsetWidth>width&&spanToShrink.offsetWidth>0){text=text.slice(0,-1);spanToShrink.innerHTML=text+"...";}
groupName.innerHTML=spanToShrink.innerHTML;groupCategoriesContainer=document.createElement("div");groupCategoriesContainer.className="col-categories";groupContainer.appendChild(groupCategoriesContainer);}
xPos=(0-parseInt(categories[i].code)%10)*29;yPos=(0-Math.floor(parseInt(categories[i].code)/10))*29;category=document.createElement("div");category.className="col-category-icon";category.style.backgroundPosition=xPos+"px "+yPos+"px";category.title=categories[i].name;category.id=categories[i].id;var price=categories[i].price;if(price!=null){var commercialCategoryMarker=document.createElement("div");commercialCategoryMarker.title=PoiMsg.js_msg.balloon.commercialCategory.iconTooltip();commercialCategoryMarker.className="commercial-category-marker";commercialCategoryMarker.style.visibility="visible";category.appendChild(commercialCategoryMarker);}
groupCategoriesContainer.appendChild(category);}
document.body.removeChild(spanToShrink);var scrollDown=document.createElement("div");scrollDown.className="col-categories-down-scroll";scrollDown.id="colCategoriesDownScrollId";fragment.appendChild(scrollDown);var scrollDownArrow=document.createElement("div");scrollDown.appendChild(scrollDownArrow);document.getElementById(this.pickerContainerId).appendChild(fragment);Event.addListener(scrollUp,"mousedown",this._scrollUpHandler,this,false);Event.addListener(scrollDown,"mousedown",this._scrollDownHandler,this,false);Event.addListener(scrollUp,"mouseup",this._stopScrollUp,this,true);Event.addListener(scrollDown,"mouseup",this._stopScrollDown,this,true);Event.addListener(scrollUp,"mouseout",this._stopScrollUp,this,true);Event.addListener(scrollDown,"mouseout",this._stopScrollDown,this,true);Event.addListener(filter,"keyup",this._onFilterCategoriesHandler,this,true);Event.addListener(filter,"focus",this._onFilterFocusHandler,this,true);Event.addListener(filter,"blur",this._onFilterBlurHandler,this,true);Event.addListener(filterClean,"click",this._onFilterCleanHandler,this,true);if(categoriesContainer.addEventListener){categoriesContainer.addEventListener('DOMMouseScroll',this._onMouseWheel,false);categoriesContainer.addEventListener('mousewheel',this._onMouseWheel,false);}
else if(categoriesContainer.attachEvent){categoriesContainer.attachEvent('onmousewheel',this._onMouseWheel);}}
CLIPTOO.widget.CategoryList.prototype.showCategoryPicker=function(){var picker=Dom.get("categoryPicker");var catWindow=picker.childNodes[2];picker.style.display="block";if(catWindow.offsetHeight>=catWindow.firstChild.offsetHeight){Dom.get("colCategoriesUpScrollId").style.visibility="hidden";Dom.get("colCategoriesDownScrollId").style.visibility="hidden";}
else{Dom.get("colCategoriesDownScrollId").style.visibility="visible";}}
CLIPTOO.widget.CategoryList.prototype._onFilterFocusHandler=function(){var filterElm=Dom.get("catFilterId");if(filterElm.className=="default-input-title"){filterElm.value="";filterElm.className="";}}
CLIPTOO.widget.CategoryList.prototype._onFilterBlurHandler=function(){var filterElm=Dom.get("catFilterId");if(filterElm.value==""){filterElm.className="default-input-title";filterElm.value=PoiMsg.js_msg.category.picker.filter();}}
CLIPTOO.widget.CategoryList.prototype._onFilterCategoriesHandler=function(){var filterElm=Dom.get("catFilterId");var filterText=filterElm.value;filterElm.className="";var exceptions=[];var categories=ctx.getCategoriesList();var n=categories.length;for(var i=0;i<n;i++){if(categories[i].name.toLowerCase().indexOf(filterText.toLowerCase())==-1){exceptions.push(categories[i].id);}}
Dom.get("filterCleanId").style.visibility=(filterText=="")?"hidden":"visible";this.showAllCategoriesExceptFor(exceptions.concat(this.categories));}
CLIPTOO.widget.CategoryList.prototype._onFilterCleanHandler=function(ev){var filter=Dom.get("catFilterId");filter.value="";var filterClean=ev.target?ev.target:ev.srcElement;filterClean.style.visibility="hidden";this._onFilterCategoriesHandler();filter.focus();}
CLIPTOO.widget.CategoryList.prototype._getCategoryName=function(categoryId){return ctx.getCategories()[categoryId].name;}
CLIPTOO.widget.CategoryList.prototype._getCategoryPrice=function(categoryId){var price=ctx.getCategories()[categoryId].price;return(price)?price:0;}
CLIPTOO.widget.CategoryList.prototype.setOtherCategoriesPrice=function(price){this.otherCategoriesPrice=price;}
CLIPTOO.widget.CategoryList.prototype._calculateTotalPrice=function(){return CLIPTOO.utils.formatPrice(this._calculateCurrentTotalPrice());}
CLIPTOO.widget.CategoryList.prototype._calculateCurrentTotalPrice=function(){var secondaryCommercialCategoryCount=this.numberOfAllCommercialCategories-1;var mainCategoryId=this.categories[this.mainCategoryIndex];if(mainCategoryId){var mainCategoryPrice=ctx.getCategories()[mainCategoryId].price;if(mainCategoryPrice==null){secondaryCommercialCategoryCount++;}}
var tabPrice=ctx.getEditBalloon().getCheckedBalloonCheckboxPrice();return this.priceForFirstCategory+(this.otherCategoriesPrice*secondaryCommercialCategoryCount)+tabPrice;}
CLIPTOO.widget.CategoryList.prototype.hasCommertialCategories=function(){var number=this.numberOfCommercialCategories;if(number>0){return true;}
return false;}
CLIPTOO.widget.CategoryList.prototype._showTotalPriceInBaloon=function(){var number=this.numberOfAllCommercialCategories;var balloon=ctx.getEditBalloon();var commercialFields=balloon.commercialFields;if(number>0){if(balloon.isCommercialFieldsMode){Dom.addClass(commercialFields.phone,"poi-input-border-price");Dom.addClass(commercialFields.email,"poi-input-border-price");Dom.addClass(commercialFields.mobile,"poi-input-border-price");Dom.addClass(commercialFields.url,"poi-input-border-price");commercialFields.phoneIcon.style.visibility="visible";commercialFields.emailIcon.style.visibility="visible";commercialFields.mobileIcon.style.visibility="visible";commercialFields.urlIcon.style.visibility="visible";}else{balloon.showBalloonCheckbox();}
Dom.get("poiPriceWrapper").style.display="block";if(Dom.get("poiPriceAmount").style.display!='none'){var isCommercialFieldsMode=(ctx.getOrgProperty('eshopCommercialFields')=='on')?true:false;var promptPrefix=PoiMsg.js_msg.balloon.commercialCategory.locationIs();if(isCommercialFieldsMode){promptPrefix=PoiMsg.js_msg.balloon.commercialCategory.conactDetailsAre();}
Dom.get("poiPriceAmount").innerHTML=this._calculateTotalPrice();Dom.get("payment_info").innerHTML=promptPrefix+PoiMsg.js_msg.balloon.commercialCategory.baloonBottom();}}else{Dom.get("poiPriceWrapper").style.display="none";if(balloon.isCommercialFieldsMode){Dom.removeClass(commercialFields.phone,"poi-input-border-price");Dom.removeClass(commercialFields.email,"poi-input-border-price");Dom.removeClass(commercialFields.mobile,"poi-input-border-price");Dom.removeClass(commercialFields.url,"poi-input-border-price");commercialFields.phoneIcon.style.visibility="hidden";commercialFields.emailIcon.style.visibility="hidden";commercialFields.mobileIcon.style.visibility="hidden";commercialFields.urlIcon.style.visibility="hidden";}else{balloon.hideBalloonCheckbox();}}}
CLIPTOO.widget.CategoryList.prototype._isPermited=function(categoryId){var categories=this.categoriesCollection;var n=categories.length;for(var i=0;i<n;i++){if(parseInt(categories[i])==parseInt(categoryId)){return true;}}
return false;}
ViewVideoComponent=function(){this.youTubeContainerId="youtubeVideoContainer";this.youTubePlayerId="ytplayer";this.noVideoMsgId="noVideoMsg";this.videoListId="videoList";this.usernameId="username";this.obtainVideoBtnId="obtainVideos";this.videoScroll=new YAHOO.scroll();this.videoScroll.init(this.videoListId);this.commercialTabHeightCorrection=null;this.attachHandlers();}
ViewVideoComponent.prototype.attachHandlers=function(){Event.addListener(this.videoListId,"click",this._delegateClickEvent,this,true);};ViewVideoComponent.prototype._delegateClickEvent=function(ev){var video=ev.target?ev.target:ev.srcElement;while(!Dom.hasClass(video,"videolist-thumbnail-container")&&video.id!==this.photoListId){video=video.parentNode;}
if(Dom.hasClass(video,"videolist-thumbnail-container")){ViewVideoComponent._onSelectVideoToPlay(video,this);}};ViewVideoComponent._onSelectVideoToPlay=function(videoContainer,videoComponent){var elmContainer=Dom.get(videoComponent.videoListId);ViewVideoComponent._selectThumbnail("selectedVideo",videoContainer,elmContainer);videoComponent.playYouTubeVideo(videoContainer.firstChild.videoCode);};ViewVideoComponent._onImageLoaded=function(){this.style.visibility="visible";};ViewVideoComponent._onImageError=function(e,obj){this.parentNode.style.display="none";this.videoCode="";this.parentNode.className="";var imagesContainer=this.parentNode.parentNode.parentNode;var images=imagesContainer.getElementsByTagName("img");var n=images.length;var hiddenElmsCount=0;for(var i=0;i<n;i++){if(images[i].parentNode.style.display=="none"){hiddenElmsCount++;}}
if(hiddenElmsCount==n){Dom.get(obj.player).style.display="none";Dom.get(obj.carousel).style.display="none";Dom.get(obj.noMsg).style.display="block";}};ViewVideoComponent.prototype.cleanNullObjects=function(videoCodes){var n=videoCodes.length;var cleanedVideos=[];var j=0;for(var i=0;i<n;i++){if(videoCodes[i]&&videoCodes[i]!=="null"){cleanedVideos[j++]=videoCodes[i];}}
return cleanedVideos;};ViewVideoComponent.prototype.createVideoThumbnail=function(){var imageContainer=document.createElement("div");imageContainer.className="videolist-thumbnail-container";var img=document.createElement("img");Event.addListener(img,"load",ViewVideoComponent._onImageLoaded);Event.addListener(img,"error",ViewVideoComponent._onImageError,{noMsg:this.noVideoMsgId,player:this.youTubeContainerId,carousel:this.videoListId});imageContainer.appendChild(img);return imageContainer;};ViewVideoComponent.prototype.addVideoThumbnails=function(from,till){var imgs=Dom.get(this.videoListId).getElementsByTagName("img");var imgsSize=imgs.length;videoRow=Dom.get(this.videoListId).getElementsByTagName("tr")[0];for(var i=imgsSize-from;i<till;i++){var imageContainer=this.createVideoThumbnail();var listElement=document.createElement("td");listElement.appendChild(imageContainer);videoRow.appendChild(listElement);imgs[imgs.length]=imageContainer.getElementsByTagName("img")[0];}
return imgs;};ViewVideoComponent.prototype.insertVideosAndPlayFirst=function(shift,videos,imgs){var videoContainer=Dom.get(this.videoListId);var videosSize=videos.length;for(var i=0;i<videosSize;i++){var img=imgs[i+shift];var videoCode=videos[i];img.style.visibility="hidden";img.src="http://i.ytimg.com/vi/"+videoCode+"/default.jpg";img.videoCode=videoCode;img.parentNode.className="videolist-thumbnail-container";img.parentNode.style.display="";}
Dom.addClass(imgs[shift].parentNode,"selectedVideo");this.cueYouTubeVideo(videos[0]);};ViewVideoComponent._selectThumbnail=function(cssClass,videoContainer,elsContainer){var activeElms=Dom.getElementsByClassName(cssClass,"div",elsContainer);var n=activeElms.length;for(var i=0;i<n;i++){activeElms[i].className="videolist-thumbnail-container";}
Dom.addClass(videoContainer,"selectedVideo");};ViewVideoComponent.prototype.embedYouTubePlayer=function(vCode){popupHandler.showPleaseWait();swfobject.embedSWF("http://www.youtube.com/v/"+vCode+"&fs=1&rel=0&enablejsapi=1&playerapiid="+this.youTubePlayerId,this.youTubePlayerId,GlobalProperties.YOUTUBE_PLAYER_WIDTH,(this.commercialTabHeightCorrection)?(parseInt(GlobalProperties.YOUTUBE_PLAYER_HEIGHT)+this.commercialTabHeightCorrection):GlobalProperties.YOUTUBE_PLAYER_HEIGHT,GlobalProperties.FLASH_PLAYER_VERSION,null,null,{allowScriptAccess:"always",allowFullScreen:true,wmode:'opaque'},{wmode:'opaque',id:this.youTubePlayerId});};ViewVideoComponent.prototype.getPlayer=function(){return this.youTubePlayer;};ViewVideoComponent.prototype.playYouTubeVideo=function(vCode){if(!CLIPTOO.utils.isFlashPlayerCompatible()){popupHandler.hidePleaseWait();return null;}
if(this.getPlayer()==null||this.getPlayer().loadVideoById==null){this.embedYouTubePlayer(vCode);}
else{this.getPlayer().loadVideoById(vCode);}};ViewVideoComponent.prototype.cueYouTubeVideo=function(vCode){if(!CLIPTOO.utils.isFlashPlayerCompatible()){popupHandler.hidePleaseWait();return null;}
this.embedYouTubePlayer(vCode);popupHandler.hidePleaseWait();};function onYouTubePlayerReady(playerId){var player=document.getElementById(playerId);if(playerId=="ytplayer"){ctx.getViewBalloon().videoComponent.setYouTubePlayer(player);}
else{ctx.getEditBalloon().videoComponent.setYouTubePlayer(player);}
popupHandler.hidePleaseWait();};ViewVideoComponent.prototype.showYouTubePlayer=function(player){Dom.get(this.noVideoMsgId).style.display="none";Dom.get(this.videoListId).style.display="block";Dom.get(this.youTubeContainerId).style.display="block";};ViewVideoComponent.prototype.hideYouTubePlayer=function(player){if(this.youTubePlayer&&this.youTubePlayer.stopVideo){this.youTubePlayer.stopVideo();this.youTubePlayer.clearVideo();}
Dom.get(this.videoListId).style.display="none";Dom.get(this.youTubeContainerId).style.display="none";Dom.get(this.noVideoMsgId).style.display="block";};ViewVideoComponent.prototype.setYouTubePlayer=function(player){this.youTubePlayer=player;};ViewVideoComponent.prototype.initVideos=function(poiId){this.poiId=poiId;var videoContainer=Dom.get(this.videoListId);var noVideoDiv=Dom.get(this.noVideoMsgId);var yuoTubePlayerContainer=Dom.get(this.youTubeContainerId);noVideoDiv.style.display="block";videoContainer.style.display="none";yuoTubePlayerContainer.style.display="none";if(Dom.get("username2")){Dom.get("username2").value="";}
Dom.get(this.videoListId).style.marginLeft="0px";var _oVideoRow=Dom.get(this.videoListId).getElementsByTagName("tr")[0];var imgs=Dom.get(this.videoListId).getElementsByTagName("img");var imgsSize=imgs.length;for(var i=0;i<imgsSize;i++){var img=imgs[i];img.parentNode.style.display="none";img.src="";img.videoCode="";}
var that=this;UIRequest("allPoiVideos.action","poiId="+poiId,function(data){that.showVideos(data);});}
ViewVideoComponent.prototype.showVideos=function(data){var objects=CLIPTOO.utils.getJSONResponseParameter(data,"videoCodes");var objects=this.cleanNullObjects(objects);if(objects&&objects.length>0){var imgs=this.addVideoThumbnails(0,objects.length);this.insertVideosAndPlayFirst(0,objects,imgs);this.showYouTubePlayer();}
else{this.hideYouTubePlayer();}
this.videoScroll.showHorScrollIfNeeded();popupHandler.hidePleaseWait();};EditVideoComponent=function(){this.youTubeContainerId="youtubeVideoContainer2";this.youTubePlayerId="ytplayer2";this.noVideoMsgId="noVideoMsg2";this.videoListId="videoList2";this.usernameId="username2";this.videoScroll=new YAHOO.scroll();this.videoScroll.init(this.videoListId);this.attachHandlers();}
YAHOO.lang.extend(EditVideoComponent,ViewVideoComponent);EditVideoComponent.prototype._delegateClickEvent=function(ev){var target=ev.target?ev.target:ev.srcElement,video=target;while(!Dom.hasClass(video,"videolist-thumbnail-container")&&video.id!==this.photoListId){video=video.parentNode;}
if(target.className==="deleteVideoDiv"){this.saveVideo(target);}
else if(target.className==="videoCheckbox"){this.saveVideo();}
else if(Dom.hasClass(video,"videolist-thumbnail-container")){ViewVideoComponent._onSelectVideoToPlay(video,this);}
Event.stopPropagation(ev);Event.preventDefault(ev);}
EditVideoComponent.prototype.filterShownVideos=function(videos){var objects=[];var imgs=Dom.get(this.videoListId).getElementsByTagName("img");var rest=[];var imgsSize=imgs.length;for(var i=0;i<imgsSize;i++){if(imgs[i].parentNode.lastChild.style.display=='none'){rest.push(imgs[i].videoCode);}}
this.initImages(rest);var n=videos?videos.length:0;for(var i=0;i<n;i++){var notFound=true;for(var j=0;j<imgsSize;j++){if(imgs[j].videoCode==videos[i]){notFound=false;break;}}
if(notFound){objects[objects.length]=videos[i];}}
return objects;};EditVideoComponent.prototype._onObtainedVideoCome=function(){var links=searchVideo.results;var data=[];if(links){var size=links.length;for(var i=0;i<size;i++){var link=links[i];if("YouTube"===link.videoType){data.push(link.tbUrl.match(/[\w-]+/g)[5]);}}}
var videos=this.filterShownVideos(data);var videosSize=videos.length;var poiVideosSize=this.videoCount;if(videos&&videos.length>0){var _oVideoRow=Dom.get(this.videoListId).getElementsByTagName("tr")[0];var widthBefore=_oVideoRow.offsetWidth;var visibleWidth=Dom.get(this.videoListId).parentNode.offsetWidth;var imgs=this.addVideoThumbnails(poiVideosSize,videosSize);var deleteBtns=Dom.getElementsByClassName("deleteVideoDiv","div",_oVideoRow);var checkBtns=Dom.getElementsByClassName("videoCheckbox","input",_oVideoRow);var imgsSize=imgs.length;for(var i=0;i<videosSize;i++){deleteBtns[i+poiVideosSize].style.display="none";checkBtns[i+poiVideosSize].style.display="";checkBtns[i+poiVideosSize].checked=false;}
this.insertVideosAndPlayFirst(poiVideosSize,videos,imgs);var newMarginLeft;if(visibleWidth>0){if(_oVideoRow.offsetWidth>0&&_oVideoRow.offsetWidth-widthBefore<visibleWidth){newMarginLeft=-1*(_oVideoRow.offsetWidth-visibleWidth+2);}
else{newMarginLeft=-1*widthBefore;}
Dom.get(this.videoListId).style.marginLeft=newMarginLeft+"px";}
this.showYouTubePlayer();}
else if(poiVideosSize==0){this.hideYouTubePlayer();}
this.videoScroll.showHorScrollIfNeeded();this.videoCount=videosSize+poiVideosSize;popupHandler.hidePleaseWait();};EditVideoComponent.prototype._onObtaineVideo=function(){popupHandler.showPleaseWait();var username=Dom.get(this.usernameId);var that=this;searchVideo.setSearchCompleteCallback(this,function(){that._onObtainedVideoCome();},[null]);if(username&&username.value!==""){searchVideo.execute(username.value);}else{popupHandler.hidePleaseWait();}};EditVideoComponent.prototype._loadOnEnter=function(e){if(e.keyCode==13){this._onObtaineVideo();}};EditVideoComponent.prototype.attachHandlers=function(){Event.addListener(this.usernameId,"keypress",this._loadOnEnter,this,true);Event.addListener(this.videoListId,"click",this._delegateClickEvent,this,true);};EditVideoComponent.prototype.createVideoThumbnail=function(){var imageContainer=this.constructor.superclass.createVideoThumbnail.apply(this,arguments);var deleteDiv=document.createElement("div");deleteDiv.className="deleteVideoDiv";imageContainer.appendChild(deleteDiv);var checkBox=document.createElement("input");checkBox.type="checkbox";checkBox.className="videoCheckbox";imageContainer.appendChild(checkBox);return imageContainer;};EditVideoComponent.prototype.showVideos=function(data){var objects=CLIPTOO.utils.getJSONResponseParameter(data,"videoCodes");objects=this.cleanNullObjects(objects);this.initImages(objects);this.videoScroll.showHorScrollIfNeeded();ctx.setElementToFocus(Dom.get(this.usernameId));popupHandler.hidePleaseWait();};EditVideoComponent.prototype.initImages=function(objects){if(objects&&objects.length>0){var videosSize=objects.length;this.videoCount=videosSize;var imgs=this.addVideoThumbnails(0,videosSize);var videoList=Dom.get(this.videoListId);var deleteBtns=Dom.getElementsByClassName("deleteVideoDiv","div",videoList);var checkBtns=Dom.getElementsByClassName("videoCheckbox","input",videoList);for(var i=0;i<deleteBtns.length;i++){deleteBtns[i].style.display="";checkBtns[i].style.display="none";checkBtns[i].checked=false;}
this.insertVideosAndPlayFirst(0,objects,imgs);this.showYouTubePlayer();}
else{this.videoCount=0;this.hideYouTubePlayer();}};EditVideoComponent.prototype.saveVideo=function(divToHide){popupHandler.showPleaseWait();var poiId=this.poiId;var activePoi=ctx.getActivePoi(poiId);if(activePoi.editable){var videosForSave=[];var videosForSaveLength=0;var _oContainer=Dom.get(this.videoListId);var codes=_oContainer.getElementsByTagName("input");var n=codes.length;var saved=null;for(var i=0;i<n;i++){if(codes[i].checked){videosForSave[videosForSaveLength++]=codes[i].parentNode.firstChild.videoCode;saved=codes[i];}}
var codesToDelete=Dom.getElementsByClassName("deleteVideoDiv","div",_oContainer);var m=codesToDelete.length;for(var i=0;i<m;i++){if(codesToDelete[i].style.display!="none"&&codesToDelete[i]!=divToHide){videosForSave[videosForSaveLength++]=Dom.getPreviousSibling(codesToDelete[i]).videoCode;}}
var that=this;UIRequest("updateVideos.action","poiId="+poiId+"&codes="+videosForSave,function(data){that._onVideoSaved(data,saved,divToHide);});}
else{popupHandler.hidePleaseWait();}};EditVideoComponent.prototype._onVideoSaved=function(data,saved,divToHide){var json=YAHOO.lang.JSON.parse(data.responseText);var videos=this.cleanNullObjects(json.videoCodes);this.videoCount=videos.length;if(saved&&videos.length>0){saved.checked=false;saved.style.display="none";Dom.getPreviousSibling(saved).style.display="";}
else if(!saved){var checkbox=divToHide.parentNode.lastChild;checkbox.style.display="";divToHide.style.display="none";checkbox.style.display="";}
this.videoScroll.showHorScrollIfNeeded();popupHandler.hidePleaseWait();};ViewPhotoComponent=function(){this.photoContainerId="photoContainer";this.photoPlayerId="imgPreview";this.noPhotoMsgId="noPhotoMsg";this.photoListId="photoList";this.host="http://"+window.location.host;this.photoScroll=new YAHOO.scroll();this.photoScroll.init(this.photoListId);this.commercialTabHeightCorrection=null;this.attachHandlers();}
ViewPhotoComponent.loadPhotoTimeout=null;ViewPhotoComponent.loadSmallPhotoTimeout=null;ViewPhotoComponent.fisrtPhotoLoadTimeout=null;ViewPhotoComponent.loadedPhotos=0;ViewPhotoComponent.photosQuantity=null;ViewPhotoComponent.prototype.attachHandlers=function(){Event.addListener(this.photoPlayerId,"load",ViewPhotoComponent._onPhotoForPlayerLoad,this,true);Event.addListener(this.photoListId,"click",this._delegateClickEvent,this,true);};ViewPhotoComponent.prototype._delegateClickEvent=function(ev){var photo=ev.target?ev.target:ev.srcElement;while(!Dom.hasClass(photo,"photolist-thumbnail-container")&&photo.id!==this.photoListId){photo=photo.parentNode;}
if(Dom.hasClass(photo,"photolist-thumbnail-container")){ViewPhotoComponent._onSelectPhotoToView(photo.firstChild,this);}};ViewPhotoComponent._previewContainer=new YAHOO.widget.Panel("preview_image_holder",{fixedcenter:true,close:true,draggable:false,zindex:114748365,modal:true,visible:false});ViewPhotoComponent._openPreviewImage=function(ev,obj){var img=Dom.get(obj.elem);var windowHeight=(window.innerHeight?window.innerHeight:(document.documentElement.clientHeight?document.documentElement.clientHeight:document.body.offsetHeight));var windowWidth=(window.innerWidth?window.innerWidth:(document.documentElement.clientWidth?document.documentElement.clientWidth:document.body.offsetWidth));if((obj.prevWidth>windowWidth)||(obj.prevHeight>windowHeight)){if(obj.prevWidth/windowWidth>obj.prevHeight/windowHeight){var previewImageWidth='width = "'+(windowWidth-50)+'"';var previewImageHeight='';}
else if(obj.prevHeight>windowHeight){var previewImageHeight='height = "'+(windowHeight-50)+'"';var previewImageWidth='';}}
ViewPhotoComponent._previewContainer.setHeader("");ViewPhotoComponent._previewContainer.setBody('<img src="'+img.src+'" '+previewImageWidth+previewImageHeight+' />');ViewPhotoComponent._previewContainer.render();ViewPhotoComponent._previewContainer.center();ViewPhotoComponent._previewContainer.show();};ViewPhotoComponent._onPhotoForPlayerLoad=function(ev,obj){var el=Dom.get(obj.photoPlayerId);Event.removeListener(el,"click");el.style.width="auto";el.style.height="auto";var previousWidth=el.offsetWidth;var previousHeight=el.offsetHeight;var standardWidth=GlobalProperties.PHOTO_PLAYER_WIDTH;var standardHeight=(this.commercialTabHeightCorrection)?(GlobalProperties.PHOTO_PLAYER_HEIGHT+this.commercialTabHeightCorrection):GlobalProperties.PHOTO_PLAYER_HEIGHT;var checkImageSize=function(){if(el.offsetWidth==0&&el.offsetHeight==0){ViewPhotoComponent.loadPhotoTimeout=setTimeout(checkImageSize,100);return;}
if((el.offsetWidth>standardWidth)||(el.offsetHeight>standardHeight)){if(el.offsetWidth/standardWidth>el.offsetHeight/standardHeight){el.style.width=standardWidth+"px";el.style.height="auto";}else{el.style.height=standardHeight+"px";el.style.width="auto";}
Event.addListener(el,"click",ViewPhotoComponent._openPreviewImage,{elem:el,prevWidth:previousWidth,prevHeight:previousHeight});el.style.cursor="pointer";}else{el.style.cursor="default";}
el.style.marginTop=((el.parentNode.offsetHeight-el.offsetHeight)/2)+"px";Dom.removeClass(el.parentNode,"photo-player-loading");el.style.visibility="visible";clearTimeout(ViewPhotoComponent.loadPhotoTimeout);ViewPhotoComponent.loadPhotoTimeout=null;}
checkImageSize();};ViewPhotoComponent._onImageLoad=function(event,balloon){var imgElement=null;if(YAHOO.env.ua.ie>=7){imgElement=(event)?event.srcElement:null;}else{imgElement=(event)?event.target:null;}
balloon._checkImageSizeInCarousel(imgElement);this.parentNode.style.visibility="visible";ViewPhotoComponent.loadedPhotos++;};ViewPhotoComponent.prototype._checkImageSizeInCarousel=function(imgElement){if(imgElement){var height=imgElement.offsetHeight;var width=imgElement.offsetWidth;if(width==0&&height==0){var that=this;ViewPhotoComponent.loadSmallPhotoTimeout=setTimeout(function(){that._checkImageSizeInCarousel(imgElement);},100);return;}
if(height>width){var minHeight=(height>54)?54:height;imgElement.style.height=minHeight+'px';}else{var minWidth=(width>78)?78:width;imgElement.style.width=minWidth+'px';}
ViewPhotoComponent.loadSmallPhotoTimeout=null;}}
ViewPhotoComponent.prototype.showFirstPhoto=function(balloon){var photosContainer=Dom.get(balloon.photoListId);var images=Dom.getElementsByClassName("photolist-thumbnail","img",photosContainer);var photoPlayer=Dom.get(balloon.photoPlayerId);var loadPhoto=function(){if(ViewPhotoComponent.loadedPhotos!==ViewPhotoComponent.photosQuantity){ViewPhotoComponent.fisrtPhotoLoadTimeout=setTimeout(loadPhoto,500);return;}
var n=ViewPhotoComponent.photosQuantity;var firstPhoto=null;for(var i=0;i<n;i++){if(images[i].parentNode.style.visibility!="hidden"){images[i].parentNode.style.display="";if(firstPhoto===null){firstPhoto=images[i];}}}
if(firstPhoto!==null){Dom.get(balloon.photoPlayerId).style.visibility="hidden";Dom.addClass(Dom.get(balloon.photoContainerId),"photo-player-loading");photoPlayer.src=balloon._changePhotoLink(firstPhoto.name);ViewPhotoComponent._selectThumbnail("selectedPhoto",firstPhoto,firstPhoto.parentNode);clearTimeout(ViewPhotoComponent.fisrtPhotoLoadTimeout);ViewPhotoComponent.fisrtPhotoLoadTimeout=null;}}
if(images){loadPhoto();}};ViewPhotoComponent._onImageError=function(e,obj){this.parentNode.style.visibility="hidden";this.videoCode="";ViewPhotoComponent.loadedPhotos++;var imagesContainer=this.parentNode.parentNode.parentNode;var images=Dom.getElementsByClassName("photolist-thumbnail","img",imagesContainer);var n=images.length;var hiddenElmsCount=0;for(var i=0;i<n;i++){if(images[i].parentNode.style.visibility=="hidden"){hiddenElmsCount++;}}
if(hiddenElmsCount==n){Dom.get(obj.player).style.display="none";Dom.get(obj.carousel).style.display="none";Dom.get(obj.noMsg).style.display="block";}};ViewPhotoComponent.prototype.cleanNullObjects=function(videoCodes){var n=videoCodes.length;var cleanedVideos=[];var j=0;for(var i=0;i<n;i++){if(videoCodes[i]&&videoCodes[i]!=="null"){cleanedVideos[j++]=videoCodes[i];}}
return cleanedVideos;};ViewPhotoComponent._selectThumbnail=function(cssClass,el,elsContainer){var activeElms=Dom.getElementsByClassName(cssClass,"div",elsContainer);var n=activeElms.length;for(var i=0;i<n;i++){Dom.removeClass(activeElms[i],cssClass);}
Dom.addClass(el.parentNode,cssClass);};ViewPhotoComponent.prototype.showPhotoPlayer=function(){Dom.get(this.noPhotoMsgId).style.display="none";Dom.get(this.photoContainerId).style.display="block";Dom.get(this.photoListId).style.display="block";};ViewPhotoComponent.prototype.hidePhotoPlayer=function(){Dom.get(this.photoContainerId).style.display="none";Dom.get(this.photoListId).style.display="none";Dom.get(this.noPhotoMsgId).style.display="block";};ViewPhotoComponent._onSelectPhotoToView=function(photo,photoComponent){var img=Dom.get(photoComponent.photoPlayerId);Dom.get(photoComponent.photoPlayerId).style.visibility="hidden";Dom.addClass(Dom.get(photoComponent.photoContainerId),"photo-player-loading");img.src=photo.name;var photoContainer=Dom.get(photoComponent.photoListId);ViewPhotoComponent._selectThumbnail("selectedPhoto",photo,photoContainer);};ViewPhotoComponent.prototype.createPhotoThumbnail=function(){var imageContainer=document.createElement("div");imageContainer.style.display="none";Dom.addClass(imageContainer,"photolist-thumbnail-container");var img=document.createElement("img");Dom.addClass(img,"photolist-thumbnail");Event.addListener(img,"error",ViewPhotoComponent._onImageError,{noMsg:this.noPhotoMsgId,player:this.photoContainerId,carousel:this.photoListId});imageContainer.appendChild(img);return imageContainer;};ViewPhotoComponent.prototype.showPhotos=function(data){var objects=CLIPTOO.utils.getJSONResponseParameter(data,"photoLinks");objects=this.cleanNullObjects(objects);var photoPlayer=Dom.get(this.photoPlayerId);photoPlayer.style.visibility="hidden";photoPlayer.src="";if(objects&&objects.length>0){var photosContainer=Dom.get(this.photoListId);var _oPhotoRow=photosContainer.getElementsByTagName("tr")[0];var imgs=Dom.getElementsByClassName("photolist-thumbnail","img",photosContainer);var imgsSize=imgs.length;var photoSize=objects.length;for(var i=imgsSize;i<photoSize;i++){var imageContainer=this.createPhotoThumbnail();var listElement=document.createElement("td");listElement.setAttribute('valign','center');listElement.appendChild(imageContainer);_oPhotoRow.appendChild(listElement);imgs[imgs.length]=imageContainer.firstChild;}
ViewPhotoComponent.loadedPhotos=0;ViewPhotoComponent.photosQuantity=photoSize;for(var i=0;i<photoSize;i++){imgs[i].parentNode.style.visibility="";Event.addListener(imgs[i],"load",ViewPhotoComponent._onImageLoad,this);imgs[i].src=this._changePhotoLink(objects[i],".thumbnail.jpg");imgs[i].name=objects[i];imgs[i].parentNode.style.display="none";}
this.showFirstPhoto(this);this.showPhotoPlayer();this.photoScroll.showHorScrollIfNeeded();}else{this.hidePhotoPlayer();}
popupHandler.hidePleaseWait();};ViewPhotoComponent.prototype._changePhotoLink=function(photoLink,squeezedParam){if(photoLink.indexOf('/content/')==0){return this.host+photoLink+((squeezedParam)?squeezedParam:'');}
return photoLink;};ViewPhotoComponent.prototype.initPhotos=function(poiId){this.poiId=poiId;Dom.addClass(Dom.get(this.photoContainerId),"photo-player-loading");var imgs=Dom.getElementsByClassName("photolist-thumbnail","img",this.photoListId);var imgsSize=imgs.length;for(var i=0;i<imgsSize;i++){Event.removeListener(imgs[i],"load");imgs[i].parentNode.style.display="none";imgs[i].parentNode.style.visibility="";imgs[i].src="";imgs[i].name="";imgs[i].parentNode.className="photolist-thumbnail-container";}
ViewPhotoComponent.loadedPhotos=0;var that=this;UIRequest("allPoiPhotos.action","poiId="+poiId,function(data){that.showPhotos(data);});};EditPhotoComponent=function(){this.photoContainerId="photoContainer2";this.photoPlayerId="imgPreview2";this.photoListId="photoList2";this.noPhotoMsgId="noPhotoMsg2";this.photoHint="photoHint2";this.browseBtnId="uploaderPlaceHolder2";this.host="http://"+window.location.host;this.photoScroll=new YAHOO.scroll();this.photoScroll.init(this.photoListId);this.createPhotoUploader();this.attachHandlers();}
YAHOO.lang.extend(EditPhotoComponent,ViewPhotoComponent);EditPhotoComponent.prototype._delegateClickEvent=function(ev){var target=ev.target?ev.target:ev.srcElement,photo=target;while(!Dom.hasClass(photo,"photolist-thumbnail-container")&&photo.id!==this.photoListId){photo=photo.parentNode;}
if(target.className==="deletePhotoDiv"){this.deletePhoto(photo);}
else if(Dom.hasClass(photo,"photolist-thumbnail-container")){ViewPhotoComponent._onSelectPhotoToView(photo.firstChild,this);}
Event.stopPropagation(ev);Event.preventDefault(ev);}
EditPhotoComponent.prototype._onPhotoBound=function(data){var json=YAHOO.lang.JSON.parse(data.responseText);var photoLink=json.photoLink;if(photoLink){var photosContainer=Dom.get(this.photoListId);var imgs=Dom.getElementsByClassName("photolist-thumbnail","img",photosContainer);var imgsSize=imgs.length;for(var i=0;i<imgsSize;i++){if(imgs[i].parentNode.style.display=="none"){var img=imgs[i];break;}}
if(!img){_oPhotoRow=Dom.get(this.photoListId).getElementsByTagName("tr")[0];var imageContainer=this.createPhotoThumbnail();var listElement=document.createElement("td");listElement.setAttribute('valign','center');listElement.appendChild(imageContainer);_oPhotoRow.appendChild(listElement);var newImgsSize=imgs.length;imgs[newImgsSize]=imageContainer.firstChild;var img=imgs[newImgsSize];Event.addListener(imageContainer.firstChild,"load",ViewPhotoComponent._onImageLoad,this);}
img.src=this.host+photoLink+".thumbnail.jpg";img.parentNode.style.display="";img.parentNode.style.visibility="";img.name=photoLink;this.photoCount++;var photoPlayer=Dom.get(this.photoPlayerId);photoPlayer.style.visibility="hidden";photoPlayer.src=photoLink;ViewPhotoComponent._selectThumbnail("selectedPhoto",img,photosContainer);this.showPhotoPlayer();this.photoScroll.showHorScrollIfNeeded();}
popupHandler.hidePleaseWait();};EditPhotoComponent.prototype._confPhotoUploader=function(){var currentLocation=window.location;YAHOO.widget.Uploader.SWFURL=currentLocation.protocol+"//"+currentLocation.host+GlobalProperties.HOST+"js/yui/uploader/assets/uploader.swf";var path="themes/default/img/balloon/upload_button.png";if(THEME_NAME=="landleven"){path="themes/landleven/img/balloon/upload_button.png";}
if(THEME_NAME=="healthcare"){path="themes/healthcare/img/upload_button.png";}
if(THEME_NAME=="brabant"){path="themes/brabant/img/upload_button.png";}
if(THEME_NAME=="omroepbrabant"){path="themes/omroepbrabant/img/upload_button.png";}
if(THEME_NAME=="chamber"){path="themes/chamber/img/upload_button.png";}
if(THEME_NAME=="overheid"){path="themes/overheid/img/upload_button.png";}
var uploader=new YAHOO.widget.Uploader(this.browseBtnId,currentLocation.protocol+"//"+currentLocation.host+GlobalProperties.HOST+path,true);var onUploaderContentReady=function(){uploader.setAllowMultipleFiles(false);uploader.setFileFilters([{description:"Images",extensions:"*.jpg;*.png"}]);};uploader.addListener('contentReady',onUploaderContentReady);return uploader;}
EditPhotoComponent.prototype.createPhotoUploader=function(){if(!CLIPTOO.utils.isFlashPlayerCompatible()){return null;}
var that=this;function onFileSelectPoi(event){var poiId=that.poiId;var activePoi=ctx.getActivePoi(poiId);if(activePoi.editable){fileList=event.fileList;if(fileList){for(var i in fileList){if(fileList[i].size>parseInt(PoiMsg.js_msg.upload.maxFileSize())){popupHandler.showErrorPopup(PoiMsg.js_msg.upload.maxSizeError(CLIPTOO.utils.getFileExtension(fileList[i])));return;}
popupHandler.showPleaseWait();uploader.upload(i,GlobalProperties.HOST+"FileUpload.action","GET",{"poiId":poiId,"userUid":ctx.getCurrentUserUid()});}
uploader.clearFileList();}}}
function uploadCompleteData(event){var jsonWithLink=YAHOO.lang.JSON.parse(event.data);var params="photoLink="+jsonWithLink.photoLink+"&poiId="+jsonWithLink.poiId;UIRequest("bindPhotoToPoi.action",params,function(data){that._onPhotoBound(data);});}
var uploader=this._confPhotoUploader();uploader.addListener('fileSelect',onFileSelectPoi);uploader.addListener('uploadCompleteData',uploadCompleteData);};EditPhotoComponent.prototype.createPhotoThumbnail=function(){var imageContainer=this.constructor.superclass.createPhotoThumbnail.apply(this,arguments);var deleteDiv=document.createElement("div");deleteDiv.className="deletePhotoDiv";imageContainer.appendChild(deleteDiv);return imageContainer;};EditPhotoComponent.prototype.showPhotos=function(data){var objects=CLIPTOO.utils.getJSONResponseParameter(data,"photoLinks");objects=this.cleanNullObjects(objects);if(objects&&objects.length>0){this.photoCount=objects.length;}else{this.photoCount=0;}
this.checkFlashPlayer();this.constructor.superclass.showPhotos.apply(this,arguments);};EditPhotoComponent.prototype.checkFlashPlayer=function(){if(!CLIPTOO.utils.isFlashPlayerCompatible()){Dom.get(this.photoHint).innerHTML=PoiMsg.js_msg.balloon.video.unsupported();}};EditPhotoComponent.prototype._onPhotoDeleted=function(divToHide){var photoCount=this.photoCount-1;this.photoCount=photoCount;divToHide.style.display="none";var noPhotoDiv=Dom.get(this.noPhotoMsgId);var photoPlayerContainer=Dom.get(this.photoContainerId);if(photoCount==0){this.hidePhotoPlayer();}else{var photosContainer=Dom.get(this.photoListId);var imgs=Dom.getElementsByClassName("photolist-thumbnail","img",photosContainer);var activeElms=Dom.getElementsByClassName("selectedPhoto","img",photosContainer);for(var i=0;i<activeElms.length;i++){Dom.removeClass(activeElms[i],"selectedPhoto");}
var imgsSize=imgs.length;for(var i=0;i<imgsSize;i++){if(imgs[i].parentNode.style.display!="none"){var photoPlayer=Dom.get(this.photoPlayerId);photoPlayer.style.visibility="hidden";photoPlayer.src=imgs[i].name;var container=imgs[i].parentNode;Dom.addClass(container,"selectedPhoto");break;}}
var marginLeft=parseInt(Dom.getStyle(photosContainer,"margin-left"));var listWidth=photosContainer.firstChild.offsetWidth;if(photosContainer.parentNode.offsetWidth>listWidth+marginLeft){marginLeft=photosContainer.parentNode.offsetWidth-listWidth-3;if(marginLeft>0){marginLeft=0;}
photosContainer.style.marginLeft=marginLeft+"px";}
this.photoScroll.showHorScrollIfNeeded();}
popupHandler.hidePleaseWait();};EditPhotoComponent.prototype.deletePhoto=function(divToHide){popupHandler.showPleaseWait();var poiId=this.poiId;var activePoi=ctx.getActivePoi(poiId);if(activePoi.editable){var imgUrl=divToHide.firstChild.name;var params="poiId="+poiId+"&photoLink="+imgUrl;var that=this;UIRequest("removePhotoFromPoi.action",params,function(){that._onPhotoDeleted(divToHide);});}
else{popupHandler.hidePleaseWait();}};AbstractEmbeddedObjectComponent=function(){this.widgetObject=null;this.rssObject=null;this.poiIdFromBallon=null;this.canBeDeleted=false;};AbstractEmbeddedObjectComponent.prototype.initWidgetTab=function(){popupHandler.showPleaseWait();this.widgetElements.iframeContainer.src="";var that=this;UIRequest("returnEmbeddedObject.action","poiId="+this.poiIdFromBallon+"&embeddedObjectType=1",function(data){that.editOrShowWidgetTab(data);});};AbstractEmbeddedObjectComponent.prototype.editOrShowWidgetTab=function(args){var json=YAHOO.lang.JSON.parse(args.responseText);this.widgetObject=json.embeddedObject;if(this.widgetObject!=null){this.showWidgetTab();}else{popupHandler.hidePleaseWait();}};AbstractEmbeddedObjectComponent.prototype.showWidgetTab=function(){var currentLocation=window.location;if(this.widgetElements.iframeContainer.contentDocument){this.widgetElements.iframeContainer.contentDocument.location=currentLocation.protocol+"//"+currentLocation.host+GlobalProperties.ACTION_HOST+"returnHTMLForWidget.action?poiId="+this.poiIdFromBallon;}else{this.widgetElements.iframeContainer.src=currentLocation.protocol+"//"+currentLocation.host+GlobalProperties.ACTION_HOST+"returnHTMLForWidget.action?poiId="+this.poiIdFromBallon;}
popupHandler.hidePleaseWait();};AbstractEmbeddedObjectComponent.prototype.initRssTab=function(){popupHandler.showPleaseWait();this.rssElements.viewContainer.innerHTML="";Dom.removeClass(this.rssElements.viewContainer,"baloon-rss-noRss");var that=this;UIRequest("returnEmbeddedObject.action","poiId="+this.poiIdFromBallon+"&embeddedObjectType=2",function(data){that.canBeDeleted=true;that.editOrShowRssTab(data);});};AbstractEmbeddedObjectComponent.prototype.editOrShowRssTab=function(args){var json=YAHOO.lang.JSON.parse(args.responseText);this.rssObject=json.embeddedObject;if(this.rssObject!=null){this.getRssObject();}else{popupHandler.hidePleaseWait();}};AbstractEmbeddedObjectComponent.prototype.getRssObject=function(){var feed=new google.feeds.Feed(this.rssObject.code);var that=this;feed.load(function(result){that.buildRssTab(result);});};AbstractEmbeddedObjectComponent.prototype.showRssTab=function(){popupHandler.hidePleaseWait();};AbstractEmbeddedObjectComponent.prototype.buildRssTab=function(result){this.rssElements.viewContainer.innerHTML="";var itemsOnPage=3;if(result.feed.entries.length>itemsOnPage){var showItems=itemsOnPage;}else{var showItems=result.feed.entries.length;}
for(var i=0;i<showItems;i++){var rssItemTitle=CLIPTOO.utils.createDomElement("div","rss-item-title");var rssItemDate=CLIPTOO.utils.createDomElement("div","rss-item-date");var rssItemSnippet=CLIPTOO.utils.createDomElement("div","rss-item-snippet");var rssItemLinkHolder=CLIPTOO.utils.createDomElement("div","rss-item-link-holder");var rssItemLink=CLIPTOO.utils.createDomElement("a","rss-item-link");var publishedDate=new Date(result.feed.entries[i].publishedDate);var dateString=PoiMsg.js_msg.balloon.blog.postedOn()+" "+publishedDate.getFullYear();dateString=dateString+"-"+publishedDate.getMonth();dateString=dateString+"-"+publishedDate.getDate();rssItemTitle.innerHTML=result.feed.entries[i].title;rssItemDate.innerHTML=dateString;rssItemSnippet.innerHTML=result.feed.entries[i].contentSnippet;rssItemLink.innerHTML=PoiMsg.js_msg.balloon.rssReadMore();rssItemLink.setAttribute('target','_blank');rssItemLink.setAttribute('href',result.feed.entries[i].link);this.rssElements.viewContainer.appendChild(rssItemTitle);this.rssElements.viewContainer.appendChild(rssItemDate);this.rssElements.viewContainer.appendChild(rssItemSnippet);this.rssElements.viewContainer.appendChild(rssItemLinkHolder);rssItemLinkHolder.appendChild(rssItemLink);}};ViewEmbeddedObjectComponent=function(){var iframe=null;if(YAHOO.env.ua.ie>=7){iframe=document.createElement('<iframe frameborder="0">');}else{iframe=document.createElement('iframe');}
iframe.id="widgetBalloonIframe";iframe.className="balloon-widget-iframe";Dom.get("widgetBalloonContent").appendChild(iframe);this.widgetElements={viewContainer:Dom.get("widgetBalloonContent"),iframeContainer:Dom.get('widgetBalloonIframe')}
this.rssElements={viewContainer:Dom.get("rssBalloonContent"),titleText:Dom.get("rssBalloonTitle")}
this.constructor.superclass.constructor.apply(this,arguments);};YAHOO.lang.extend(ViewEmbeddedObjectComponent,AbstractEmbeddedObjectComponent);ViewEmbeddedObjectComponent.prototype.initWidgetTab=function(poiId){this.poiIdFromBallon=poiId;this.constructor.superclass.initWidgetTab.apply(this,[]);};ViewEmbeddedObjectComponent.prototype.editOrShowWidgetTab=function(data){var args=[];args[0]=data;this.constructor.superclass.editOrShowWidgetTab.apply(this,args);};ViewEmbeddedObjectComponent.prototype.showWidgetTab=function(){this.constructor.superclass.showWidgetTab.apply(this,[]);};ViewEmbeddedObjectComponent.prototype.initRssTab=function(poiId){this.poiIdFromBallon=poiId;this.constructor.superclass.initRssTab.apply(this,[]);};ViewEmbeddedObjectComponent.prototype.editOrShowRssTab=function(data){var args=[];args[0]=data;this.constructor.superclass.editOrShowRssTab.apply(this,args);};ViewEmbeddedObjectComponent.prototype.getRssObject=function(){this.constructor.superclass.getRssObject.apply(this,[]);};ViewEmbeddedObjectComponent.prototype.buildRssTab=function(result){var args=[];args[0]=result;if((!result.error)&&(result.feed.entries.length>0)){this.constructor.superclass.buildRssTab.apply(this,args);this.showRssTab();}else{Dom.addClass(this.rssElements.viewContainer,"baloon-rss-noRss");this.rssElements.viewContainer.innerHTML=PoiMsg.js_msg.balloon.noRssViewMode();popupHandler.hidePleaseWait();}};ViewEmbeddedObjectComponent.prototype.showRssTab=function(){if(this.rssObject.contentTitle){this.rssElements.titleText.firstChild.innerHTML=this.rssObject.contentTitle;}else{this.rssElements.titleText.firstChild.innerHTML="";}
CLIPTOO.utils.shrinkOneRowTextByWidth(this.rssElements.titleText.firstChild,18,450,60);this.constructor.superclass.showRssTab.apply(this,[]);};EditEmbeddedObjectComponent=function(){var iframe=null;if(YAHOO.env.ua.ie>=7){iframe=document.createElement('<iframe frameborder="0">');}else{iframe=document.createElement('iframe');}
iframe.id="widgetWriteBalloonIframe";iframe.className="balloon-widget-edit-iframe";Dom.get("widgetWriteBalloonContent").appendChild(iframe);this.widgetElements={viewContainer:Dom.get("widgetWriteBalloonContent"),postBtn:Dom.get("widgetWriteBalloonPost"),editBtn:Dom.get("widgetWriteBalloonEdit"),editContainer:Dom.get("widgetWriteBalloonEditable"),textarea:Dom.get("widgetWriteBalloonTextarea"),title:Dom.get("widgetWriteBalloonTitle"),iframeContainer:Dom.get('widgetWriteBalloonIframe')}
this.rssElements={viewContainer:Dom.get("rssWriteBalloonContent"),editContainer:Dom.get("rssWriteBalloonEditable"),input:Dom.get("rssWriteBalloonInput"),postBtn:Dom.get("rssWriteBalloonPost"),editBtn:Dom.get("rssWriteBalloonEdit"),deleteBtn:Dom.get("rssWriteBalloonDelete"),titleInput:Dom.get("rssTitle"),contentTitleInput:Dom.get("rssContentTitle"),titleText:Dom.get("rssWriteBalloonTitle")}
this.attachHandlers();this.constructor.superclass.constructor.apply(this,arguments);};YAHOO.lang.extend(EditEmbeddedObjectComponent,AbstractEmbeddedObjectComponent);EditEmbeddedObjectComponent.prototype.attachHandlers=function(){Event.addListener(this.widgetElements.postBtn,"click",this.saveWidgetTab,this,true);Event.addListener(this.widgetElements.editBtn,"click",this.editWidgetTab,this,true);Event.addListener(this.rssElements.postBtn,"click",this.checkDataBeforeSaveRssTab,this,true);Event.addListener(this.rssElements.editBtn,"click",this.editRssTab,this,true);Event.addListener(this.rssElements.deleteBtn,"click",this.deleteRssTab,this,true);}
EditEmbeddedObjectComponent.prototype.initWidgetTab=function(poiId){this.poiIdFromBallon=poiId;this.widgetElements.textarea.value="";this.widgetElements.viewContainer.style.display="none";this.widgetElements.editContainer.style.display="none";this.widgetElements.title.style.display="none";this.widgetElements.editBtn.style.display="none";this.widgetElements.postBtn.style.display="none";this.constructor.superclass.initWidgetTab.apply(this,[]);};EditEmbeddedObjectComponent.prototype.editOrShowWidgetTab=function(data){var args=[];args[0]=data;this.constructor.superclass.editOrShowWidgetTab.apply(this,args);if(this.widgetObject==null){this.createNewWidgetObject();this.editWidgetTab();}};EditEmbeddedObjectComponent.prototype.showWidgetTab=function(){this.widgetElements.editBtn.style.display="block";this.widgetElements.title.style.display="none";this.widgetElements.postBtn.style.display="none";this.widgetElements.viewContainer.style.display="block";this.widgetElements.editContainer.style.display="none";this.constructor.superclass.showWidgetTab.apply(this,[]);};EditEmbeddedObjectComponent.prototype.createNewWidgetObject=function(){this.widgetObject={poiId:this.poiIdFromBallon}};EditEmbeddedObjectComponent.prototype.editWidgetTab=function(){if(this.widgetObject.code){this.widgetElements.textarea.value=this.widgetObject.code.replace(/^\s+/,'').replace(/\s+$/,'');}
if(this.widgetObject.title){this.widgetElements.title.value=this.widgetObject.title;}else{this.widgetElements.title.value="";}
this.widgetElements.editBtn.style.display="none";this.widgetElements.title.style.display="block";this.widgetElements.postBtn.style.display="block";this.widgetElements.viewContainer.style.display="none";this.widgetElements.editContainer.style.display="block";popupHandler.hidePleaseWait();};EditEmbeddedObjectComponent.prototype.saveWidgetTab=function(){popupHandler.showPleaseWait();this.widgetObject.code=this.widgetElements.textarea.value;this.widgetObject.title=CLIPTOO.utils.trim(this.widgetElements.title.value);var that=this;var param="";if(this.widgetObject.poiId){param=param+"poiId="+this.widgetObject.poiId;}
if(this.widgetObject.id){param=param+"&id="+this.widgetObject.id;}
if(this.widgetObject.title){param=param+"&title="+this.widgetObject.title;}
if(this.widgetObject.settingsString){param=param+"&settingsString="+this.widgetObject.settingsString;}
if(this.widgetObject.code){param=param+"&code="+escape(this.widgetObject.code);}
if(this.widgetObject.code!=""){var actionString="saveBalloonWidgetCode.action";UIRequest(actionString,param,function(data){var json=YAHOO.lang.JSON.parse(data.responseText);that.widgetObject=json.embeddedObject;that.showWidgetTab();});}else{var actionString="deleteEmbeddedObject.action";UIRequest(actionString,param+"&embeddedObjectType=1",function(){popupHandler.showValidationPopup(PoiMsg.js_msg.balloon.widgetCodeDeleted());that.editWidgetTab();});}
var balloon=ctx.getEditBalloon();var organizationPrompts=ctx.getOrganizationPrompts();if(this.widgetObject.title&&this.widgetObject.title!=''){balloon.tabs.widgetTabPrompt.innerHTML=this.widgetObject.title;balloon.tabs.widgetTabPrompt.title=this.widgetObject.title;}else if(organizationPrompts['balloon.widget.title']){balloon.tabs.widgetTabPrompt.innerHTML=organizationPrompts['balloon.widget.title'];balloon.tabs.widgetTabPrompt.title=organizationPrompts['balloon.widget.title'];}else{balloon.tabs.widgetTabPrompt.innerHTML=PoiMsg.js_msg.balloon.widget();balloon.tabs.widgetTabPrompt.title=PoiMsg.js_msg.balloon.widget();}
CLIPTOO.utils.shrinkOneRowTextByWidth(balloon.tabs.widgetTabPrompt,18,50,70);};EditEmbeddedObjectComponent.prototype.initRssTab=function(poiId){this.poiIdFromBallon=poiId;this.rssElements.input.value="";this.rssElements.editBtn.style.display="none";this.rssElements.postBtn.style.display="none";this.rssElements.viewContainer.style.display="none";this.rssElements.editContainer.style.display="none";this.constructor.superclass.initRssTab.apply(this,[]);};EditEmbeddedObjectComponent.prototype.editOrShowRssTab=function(data){var args=[];args[0]=data;this.constructor.superclass.editOrShowRssTab.apply(this,args);if(this.rssObject==null){this.createNewRssObject();this.editRssTab();}};EditEmbeddedObjectComponent.prototype.getRssObject=function(){this.constructor.superclass.getRssObject.apply(this,[]);};EditEmbeddedObjectComponent.prototype.buildRssTab=function(result){var args=[];args[0]=result;if((!result.error)&&(result.feed.entries.length>0)){this.constructor.superclass.buildRssTab.apply(this,args);if(this.saveMode==true){this.saveRssTab();}else{this.showRssTab();}}else{popupHandler.showValidationPopup(PoiMsg.js_msg.balloon.noRss());popupHandler.hidePleaseWait();this.editRssTab();}};EditEmbeddedObjectComponent.prototype.showRssTab=function(){if(this.rssObject.contentTitle){this.rssElements.titleText.firstChild.innerHTML=this.rssObject.contentTitle;}else{this.rssElements.titleText.firstChild.innerHTML="";}
this.rssElements.titleText.style.display="block";CLIPTOO.utils.shrinkOneRowTextByWidth(this.rssElements.titleText.firstChild,18,450,60);this.rssElements.editBtn.style.display="block";this.rssElements.titleInput.style.display="none";this.rssElements.postBtn.style.display="none";if(this.canBeDeleted==false){this.rssElements.deleteBtn.style.display="none";}else{this.rssElements.deleteBtn.style.display="block";}
this.rssElements.viewContainer.style.display="block";this.rssElements.editContainer.style.display="none";this.constructor.superclass.showRssTab.apply(this,[]);};EditEmbeddedObjectComponent.prototype.createNewRssObject=function(){this.rssObject={poiId:this.poiIdFromBallon}
this.canBeDeleted=false;};EditEmbeddedObjectComponent.prototype.editRssTab=function(){if(this.rssObject.code){this.rssElements.input.value=this.rssObject.code.replace(/^\s+/,'').replace(/\s+$/,'');}
if(this.rssObject.title){this.rssElements.titleInput.value=this.rssObject.title;}else{this.rssElements.titleInput.value="";}
if(this.rssObject.contentTitle){this.rssElements.contentTitleInput.value=this.rssObject.contentTitle;}else{this.rssElements.contentTitleInput.value="";}
this.rssElements.editBtn.style.display="none";this.rssElements.titleInput.style.display="block";this.rssElements.contentTitleInput.style.display="block";this.rssElements.titleText.style.display="none";this.rssElements.postBtn.style.display="block";if(this.canBeDeleted==false){this.rssElements.deleteBtn.style.display="none";this.rssElements.input.style.width="460px";}else{this.rssElements.deleteBtn.style.display="block";this.rssElements.input.style.width="";}
this.rssElements.viewContainer.style.display="none";this.rssElements.editContainer.style.display="block";popupHandler.hidePleaseWait();};EditEmbeddedObjectComponent.prototype.checkDataBeforeSaveRssTab=function(){popupHandler.showPleaseWait();this.rssObject.code=this.rssElements.input.value;this.rssObject.title=this.rssElements.titleInput.value;this.rssObject.contentTitle=this.rssElements.contentTitleInput.value;this.rssElements.titleText.firstChild.innerHTML=this.rssObject.title;CLIPTOO.utils.shrinkOneRowTextByWidth(this.rssElements.titleText.firstChild,18,450,60);this.rssObject.code=YAHOO.lang.trim(this.rssObject.code);if(this.rssObject.code.length==0){this.rssObject.code=null;}
this.saveMode=true;this.getRssObject();};EditEmbeddedObjectComponent.prototype.deleteRssTab=function(){var that=this;var param="";if(this.rssObject.poiId){param=param+"poiId="+this.rssObject.poiId;}
if(this.rssObject.id){param=param+"&id="+this.rssObject.id;}
if(this.rssObject.title){param=param+"&title="+this.rssObject.title;}
if(this.rssObject.settingsString){param=param+"&settingsString="+this.rssObject.settingsString;}
if(this.rssObject.code){param=param+"&code="+escape(this.rssObject.code);}
var actionString="deleteEmbeddedObject.action";UIRequest(actionString,param+"&embeddedObjectType=2",function(){popupHandler.showValidationPopup(PoiMsg.js_msg.balloon.rssDeleted());that.canBeDeleted=false;that.rssElements.input.value='';that.rssElements.contentTitleInput.value='';that.rssObject.code='';that.rssObject.title='';that.rssObject.contentTitle=null;that.changeRssTabPrompt();that.editRssTab();});};EditEmbeddedObjectComponent.prototype.saveRssTab=function(){var that=this;var param="";if(this.rssObject.poiId){param=param+"poiId="+this.rssObject.poiId;}
if(this.rssObject.id){param=param+"&id="+this.rssObject.id;}
if(this.rssObject.title){param=param+"&title="+this.rssObject.title;}
if(this.rssObject.contentTitle){param=param+"&contentTitle="+this.rssObject.contentTitle;}
if(this.rssObject.settingsString){param=param+"&settingsString="+this.rssObject.settingsString;}
if(this.rssObject.code){param=param+"&code="+escape(this.rssObject.code);}
this.saveMode=false;var actionString="saveBalloonRssLink.action";UIRequest(actionString,param,function(data){var json=YAHOO.lang.JSON.parse(data.responseText);that.rssObject=json.embeddedObject;that.changeRssTabPrompt();that.canBeDeleted=true;that.showRssTab();});};EditEmbeddedObjectComponent.prototype.changeRssTabPrompt=function(){var balloon=ctx.getEditBalloon();if(this.rssObject.title&&this.rssObject.title!=''){balloon.tabs.rssTabPrompt.innerHTML=this.rssObject.title;balloon.tabs.rssTabPrompt.title=this.rssObject.title;}else{balloon.tabs.rssTabPrompt.innerHTML=PoiMsg.js_msg.balloon.rss();balloon.tabs.rssTabPrompt.title=PoiMsg.js_msg.balloon.rss();}
CLIPTOO.utils.shrinkOneRowTextByWidth(balloon.tabs.rssTabPrompt,18,50,70);};function SharingOwnershipComponent(){this.userPerPage=10;this.poiIdFromBallon=null;this.usersListObject=new Object();this.usersListObject.allUsers=null;this.usersListObject.grantedUsers=null;this.usersListObject.grantedUsersResult=new Array;this.isNextPage=false;this.isPreviousPage=false;this.ownerUserList=Dom.get("ownerUserList");this.ownerPostBtn=Dom.get("ownerWriteBalloonPost");this.ownerPagingContainer=Dom.get("ownerPagingContainer");this.ownerPreviousBtn=Dom.get("ownerPreviousButton");this.ownerPreviousBtnDisabled=Dom.get("ownerPreviousButtonHide");this.ownerNextBtn=Dom.get("ownerNextButton");this.ownerNextBtnDisabled=Dom.get("ownerNextButtonHide");this.listMode=null;var configFilter={inputSearchField:Dom.get('ownerFilterField'),inputResetButton:Dom.get('ownerResetFilter'),inputFilterContainer:Dom.get('ownerFilterContainer')}
var that=this;this.filter=CLIPTOO.Filter(function(event){var buttonName=null;if(YAHOO.env.ua.ie>=7){buttonName=(event)?event.srcElement.id:"";}else{buttonName=(event)?event.target.id:"";}
if((buttonName!="ownerResetFilter")&&(that.listMode==true)){var isChanged=that.checkForChange();if(isChanged==true){that.confirmPopup(that,PoiMsg.js_msg.balloon.information.informationBeforeChangeTab());}else{that.getFirstPageAfterSearching();}
that.listMode=false;}else{that.getFirstPageAfterSearching();that.listMode=true;}},configFilter);this.attachHandlers();};SharingOwnershipComponent.prototype.checkForChange=function(){var originalList=this.usersListObject.grantedUsers;var modifiedList=this.usersListObject.grantedUsersResult;if(originalList!=null&&modifiedList!=null){if(originalList.length!=modifiedList.length){return true;}
for(var i=0;i<modifiedList.length;i++){var elem=modifiedList[i];for(var j=0;j<originalList.length;j++){var isMatch=false;if(elem==originalList[j].uid){isMatch=true;break;}}
if(isMatch==false){return true;}}
return false;}else{return false;}};SharingOwnershipComponent.prototype._delegateClickEvent=function(ev){var obj=ev.target?ev.target:ev.srcElement;if(obj.type==="checkbox"){this.checkboxHandler(obj);}
else if(obj.id==="ownerPreviousButton"&&obj.className==="balloon-owner-paging"){this.goPreviousPage();}
else if(obj.id==="ownerNextButton"&&obj.className==="balloon-owner-paging"){this.goNextPage();}
else{}};SharingOwnershipComponent.prototype.attachHandlers=function(){Event.addListener("ownerWriteBalloonTab","click",this._delegateClickEvent,this,true);Event.addListener("addUserButton","click",this._showRegistrationForm,this,true);Event.addListener("createUserButton","click",this._submitRegistrationForm,this,true);Event.addListener("cancelUserButton","click",this._hideRegistrationForm,this,true);};SharingOwnershipComponent.prototype.initOwnerTab=function(poiId){popupHandler.showPleaseWait();this.listMode=true;this.poiIdFromBallon=poiId;this.ownerUserList.innerHTML="";this.filter.setDefaultValueToField();this.usersListObject.grantedUsersResult=[];if(ctx.getHasUserRights()=="true"){Dom.get("addUserButton").style.display="";}
var that=this;UIRequest("allPoiUsers.action","poiId="+this.poiIdFromBallon,function(data){that.getDataForFirstLoad(data);});};SharingOwnershipComponent.prototype.getDataForFirstLoad=function(data){var json=YAHOO.lang.JSON.parse(data.responseText);this.usersListObject.allUsers=[];this.usersListObject.allUsers=json.allUsers;this.usersListObject.grantedUsers=json.grantedUsers;for(var i=0;i<this.usersListObject.grantedUsers.length;i++){this.usersListObject.grantedUsersResult.push(this.usersListObject.grantedUsers[i].uid);}
this.isNextPage=json.nextPage;this.isPreviousPage=json.previousPage;this.buildUsersList();};SharingOwnershipComponent.prototype.getDataForPaging=function(data){var json=YAHOO.lang.JSON.parse(data.responseText);this.usersListObject.allUsers=[];this.usersListObject.allUsers=json.allUsers;this.isNextPage=json.nextPage;this.isPreviousPage=json.previousPage;if(json.allUsers.length>0){this.buildUsersList();}else{this.showNoResults();}};SharingOwnershipComponent.prototype.showNoResults=function(){var noResult=CLIPTOO.utils.createDomElement("div","balloon-owner-no-result");noResult.innerHTML=PoiMsg.js_msg.balloon.ownershipNoResults();this.ownerUserList.appendChild(noResult);this.ownerPagingContainer.style.display="none";popupHandler.hidePleaseWait();};SharingOwnershipComponent.prototype.buildUsersList=function(){if((this.isPreviousPage==false)&&(this.isNextPage==false)){this.ownerPagingContainer.style.display="none";}else{if(this.isPreviousPage==true){this.ownerPreviousBtnDisabled.style.display="none";this.ownerPreviousBtn.style.display="block";}else{this.ownerPreviousBtnDisabled.style.display="block";this.ownerPreviousBtn.style.display="none";}
if(this.isNextPage==true){this.ownerNextBtnDisabled.style.display="none";this.ownerNextBtn.style.display="block";}else{this.ownerNextBtnDisabled.style.display="block";this.ownerNextBtn.style.display="none";}
this.ownerPagingContainer.style.display="block";}
var template='<div class="balloon-owner-item-container"><div class="balloon-owner-icon"></div><div class="balloon-owner-name ellipsis" title="$name">$name</div><input type="checkbox" $disabled class="balloon-owner-checkbox" name="$uid" $checked/></div>',result="",users=this.usersListObject.allUsers;for(var i=0,n=users.length;i<n;i++){var user=users[i],userId=user.uid,ownerName=user.displayName+" ("+userId+")";var checkResultDataForGranted=this.checkResultDataForGranted(userId);result+=template.replace(/\$name/g,ownerName).replace(/\$uid/,userId).replace(/\$disabled/,user.owner?"disabled=\"true\"":"").replace(/\$checked/,checkResultDataForGranted?"checked":"");if(checkResultDataForGranted){this.makeResultGrantedArray(userId,"add");}}
this.ownerUserList.innerHTML=result;popupHandler.hidePleaseWait();};SharingOwnershipComponent.prototype.saveOwnerTab=function(afterSavingCallback){popupHandler.showPleaseWait();var grantedUserList=this.usersListObject.grantedUsersResult.join(",");var that=this;UIRequest("savePoiGrantedUsers.action","poiId="+this.poiIdFromBallon+"&grantedUserList="+grantedUserList,function(data){popupHandler.hidePleaseWait();if(afterSavingCallback){afterSavingCallback();}});};SharingOwnershipComponent.prototype.confirmPopup=function(that,message){popupHandler.showConfirmPopup(PoiMsg.js_msg.balloon.blog.msg.warning(),message,function(){this.hide();that.saveOwnerTab();that.getFirstPageAfterSearching();},function(){this.hide();that.getFirstPageAfterSearching();});};SharingOwnershipComponent.prototype.confirmAndGoAnotherTab=function(that,message,afterSavingCallback){popupHandler.showConfirmPopup(PoiMsg.js_msg.balloon.blog.msg.warning(),message,function(){that.saveOwnerTab();that.clearOnClose();this.hide();if(afterSavingCallback){afterSavingCallback();}},function(){that.clearOnClose();this.hide();if(afterSavingCallback){afterSavingCallback();}});};SharingOwnershipComponent.prototype.clearOnClose=function(){this.usersListObject.grantedUsers=null;this.usersListObject.grantedUsersResult=null;}
SharingOwnershipComponent.prototype.goPreviousPage=function(){var params=this.getParams('previous');this.getPage(params);};SharingOwnershipComponent.prototype.goNextPage=function(){var params=this.getParams('next');this.getPage(params);};SharingOwnershipComponent.prototype.getFirstPageAfterSearching=function(){var params=this.getParams();this.getPage(params);};SharingOwnershipComponent.prototype.getPage=function(params){popupHandler.showPleaseWait();this.ownerUserList.innerHTML="";var that=this;UIRequest("allPoiUsersPage.action",params,function(data){that.getDataForPaging(data);});};SharingOwnershipComponent.prototype.getParams=function(page){var params="poiId="+this.poiIdFromBallon;if(page){params=params+"&page="+page;}
if(Dom.get("ownerFilterField")){params=params+"&filter="+this.filter.getSearchValue();}
return params;};SharingOwnershipComponent.prototype.checkResultDataForGranted=function(uid){var grantedUsersResultArray=this.usersListObject.grantedUsersResult;for(var i=0;i<grantedUsersResultArray.length;i++){if(uid==grantedUsersResultArray[i]){return true;}}
return false;};SharingOwnershipComponent.prototype.checkboxHandler=function(checkboxElement){var isChecked=checkboxElement.getAttribute('checked');if(isChecked=='false'){checkboxElement.setAttribute('checked','true');var getUid=checkboxElement.getAttribute('name');this.makeResultGrantedArray(getUid,"add");}else{checkboxElement.removeAttribute('checked');var getUid=checkboxElement.getAttribute('name');this.makeResultGrantedArray(getUid,"remove");}};SharingOwnershipComponent.prototype.makeResultGrantedArray=function(uid,type){var grantedUsersResultArray=this.usersListObject.grantedUsersResult;for(var i=0;i<grantedUsersResultArray.length;i++){if((uid==grantedUsersResultArray[i])&&(type=="add")){return false;}else if((uid==grantedUsersResultArray[i])&&(type=="remove")){this.usersListObject.grantedUsersResult.splice(i,1);return false;}}
this.usersListObject.grantedUsersResult.push(uid);};SharingOwnershipComponent.prototype._showRegistrationForm=function(){Dom.get("ownerWriteBalloonContent").style.display="none";Dom.get("registrationFormContent").style.display="";}
SharingOwnershipComponent.prototype._submitRegistrationForm=function(){var form=Dom.get('quickRegistrationForm');var that=this;if(validator.validateNamesBlock(form,"easyRegistrationFormBlock")){popupHandler.showPleaseWait();FormSubmit('quickRegistrationForm',"easyCreateUser.action",function(data){var json=YAHOO.lang.JSON.parse(data.responseText);if(json.successfullUserName!=''&&json.createdUserName==''){popupHandler.showErrorPopup(PoiMsg.js_msg.easyregistration.userexists(json.successfullUserName));}
if(json.unsuccessfullUserName!=''){popupHandler.showErrorPopup(PoiMsg.js_msg.easyregistration.usernotcreated(json.unsuccessfullUserName));}
if(json.createdUserName!=''){that._hideRegistrationForm();that.makeResultGrantedArray(json.createdUserName,"add");that.saveOwnerTab();that.initOwnerTab(ctx.getEditBalloon().poi.id);}
popupHandler.hidePleaseWait();});}}
SharingOwnershipComponent.prototype._hideRegistrationForm=function(){Dom.get("registrationFormContent").style.display="none";Dom.get("ownerWriteBalloonContent").style.display="";Dom.get('quickRegistrationForm').reset();}
PoiType=function(){};PoiType.RICH_EDITOR_SIMPLE_HEIGHT=88;PoiType.RICH_EDITOR_COMPLEX_HEIGHT=165;PoiType.prototype.show=function(){var balloon=ctx.getEditBalloon();balloon.poiInfoFields.style.display="";if(!balloon.isBigEditorMode){Dom.get("poiInfoContainer").style.display="";}
balloon.editorSimpleSize=PoiType.RICH_EDITOR_SIMPLE_HEIGHT;balloon.editorComplexSize=PoiType.RICH_EDITOR_COMPLEX_HEIGHT;};PoaType=function(){};PoaType.RICH_EDITOR_SIMPLE_HEIGHT=178;PoaType.RICH_EDITOR_COMPLEX_HEIGHT=147;PoaType.prototype.show=function(){var balloon=ctx.getEditBalloon();Dom.get("balloon-label-area").style.display="";Dom.get("poi-route-uploader").style.display="";balloon.layerFile.style.display="";balloon.layerUploaderHolder.style.display="";var layerLink=Dom.get("poiLayerLink").value;if(layerLink){var layerDownloader=Dom.get("poi-layer-file");layerDownloader.href=layerLink;layerDownloader.innerHTML=layerLink.substring(layerLink.lastIndexOf("/")+1,layerLink.length);}
balloon.editorSimpleSize=PoaType.RICH_EDITOR_SIMPLE_HEIGHT;balloon.editorComplexSize=PoaType.RICH_EDITOR_COMPLEX_HEIGHT;};RouteType=function(){};RouteType.RICH_EDITOR_SIMPLE_HEIGHT=64;RouteType.RICH_EDITOR_COMPLEX_HEIGHT=141;RouteType.prototype.show=function(){var balloon=ctx.getEditBalloon();this.showUploadedRoute(balloon);balloon.poiInfoFields.style.display="";if(!balloon.isBigEditorMode){Dom.get("poiInfoContainer").style.display="";}
balloon.editorSimpleSize=RouteType.RICH_EDITOR_SIMPLE_HEIGHT;balloon.editorComplexSize=RouteType.RICH_EDITOR_COMPLEX_HEIGHT;};RouteType.prototype.showUploadedRoute=function(balloon){Dom.get("balloon-label-route").style.display="";balloon.layerUploader.style.display="";balloon.layerFile.style.display="";balloon.layerUploaderHolder.style.display="";};PoiTypeHandlerComponent=function(){this.poiType=new PoiType();this.poaType=new PoaType();this.routeType=new RouteType();this.currentType=this.poiType;};PoiTypeHandlerComponent.prototype.showCurrent=function(balloon){this.currentType.show();balloon._setCurrentEditorHeight();};PoiTypeHandlerComponent.prototype.onBeforeOpenInfoTab=function(){var balloon=ctx.getEditBalloon();var mainCategoryId=balloon.poi.mainCategoryId;if(!balloon.poi||!mainCategoryId){return;}
this.hideAll();var type=ctx.getCategories()[mainCategoryId].categoryType;this.changeType(type);this.showCurrent(balloon);};PoiTypeHandlerComponent.prototype.onChangeType=function(){var balloon=ctx.getEditBalloon();var mainCategoryId=balloon.categoriesList.categories[balloon.categoriesList.mainCategoryIndex];if(!mainCategoryId){balloon.poiTypeHandlerComponent.showCurrent(balloon);return;}
var type=ctx.getCategories()[mainCategoryId].categoryType;balloon.poiTypeHandlerComponent.hideAll();balloon.poiTypeHandlerComponent.changeType(type,balloon.poiTypeHandlerComponent);balloon.poiTypeHandlerComponent.showCurrent(balloon);};PoiTypeHandlerComponent.prototype.changeType=function(type,that){if(!that){that=this;}
switch(type){case GlobalProperties.ROUTE:that.currentType=that.routeType;break;case GlobalProperties.POA:that.currentType=that.poaType;break;default:that.currentType=that.poiType;};};PoiTypeHandlerComponent.prototype.onBeforeOpenCreateBalloon=function(){var balloon=ctx.getEditBalloon();this.hideAll();this.changeType(balloon.pointType);this.showCurrent(balloon);};PoiTypeHandlerComponent.prototype.hideAll=function(){var balloon=ctx.getEditBalloon();Dom.get("balloon-label-area").style.display="none";balloon.layerUploader.style.display="none";balloon.layerFile.style.display="none";balloon.layerUploaderHolder.style.display="none";Dom.get("poi-layer-upload-message-route").style.display="none";Dom.get("balloon-label-route").style.display="none";balloon.layerUploader.style.display="none";Dom.get("poi-route-uploader").style.display="none";balloon.layerFile.style.display="none";balloon.layerUploaderHolder.style.display="none";balloon.poiInfoFields.style.display="none";Dom.get("poiInfoContainer").style.display="none";};PoiTypeHandlerComponent.prototype.onBeforeOpenViewBalloon=function(){var balloon=ctx.getViewBalloon();var mainCategoryId=balloon.poi.mainCategoryId;if(!balloon.poi||!mainCategoryId){return;}
var type=ctx.getCategories()[mainCategoryId].categoryType;this.changeType(type);};function Balloon(){if(this.tabs.story){this.blogEditor=new BalloonRichEditor(this);this.attachStoryTabHandlers();}
this.activeTab=null;this.activeContent=null;this.youTubePlayer=null;this.point=null;this.pointType=null;this.attachHandlers();};Balloon.INFO_TAB=1;Balloon.VIDEO_TAB=2;Balloon.PHOTO_TAB=3;Balloon.STORY_TAB=4;Balloon.ADVERTISEMENT_TAB=5;Balloon.WIDGET_TAB=6;Balloon.RSS_TAB=7;Balloon.OWNER_TAB=8;Balloon.AUDIO_TAB=9;Balloon.RATING_TAB=10;Balloon.prototype.delegateClickEvent=function(ev,balloon){var target=ev.target?ev.target:ev.srcElement;if(target.id===balloon.closeBalloonId){balloon.close();return;}
var menu=target;while(menu.parentNode.className!="balloon-menu"&&menu.parentNode.className!="newBalloon"){menu=menu.parentNode;}
if(menu.className=="info-menu-tab"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/balloon/info_tab_click");}
balloon.showInfoTab();}
else if(menu.className=="video-menu-tab"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/balloon/video_tab_click");}
balloon.showVideoTab();}
else if(menu.className=="photo-menu-tab"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/balloon/photo_tab_click");}
balloon.showPhotoTab();}
else if(menu.className=="review-menu-tab"&&balloon.tabs.story){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/balloon/review_tab_click");}
balloon.showStoryTab();}
else if(menu.className=="extendedinfo-menu-tab"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/balloon/extended_tab_click");}
balloon.goToExtended();}
else if(menu.className=="ads-menu-tab"&&balloon.tabs.advertisement){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/balloon/advertisement_tab_click");}
balloon.showAdvertisementTab();}
else if(menu.className=="widget-menu-tab"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/balloon/widget_tab_click");}
balloon.showWidgetTab();}
else if(menu.className=="rss-menu-tab"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/balloon/rss_tab_click");}
balloon.showRssTab();}
else if(menu.className=="owner-menu-tab"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/balloon/owner_tab_click");}
balloon.showOwnerTab();}
else if(menu.className=="audio-menu-tab"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/balloon/audio_tab_click");}
balloon.showAudioTab();}
else if(menu.className=="rating-menu-tab"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/balloon/rating_tab_click");}
balloon.showRatingTab();}
Event.preventDefault(ev);Event.stopPropagation(ev);}
Balloon.prototype.getTabIndex=function(activeTab){if(activeTab==this.tabs.info){return Balloon.INFO_TAB;}
if(activeTab==this.tabs.video){return Balloon.VIDEO_TAB;}
if(activeTab==this.tabs.photo){return Balloon.PHOTO_TAB;}
if(activeTab==this.tabs.story){return Balloon.STORY_TAB;}
if(activeTab==this.tabs.advertisement){return Balloon.ADVERTISEMENT_TAB;}
if(activeTab==this.tabs.widget){return Balloon.WIDGET_TAB;}
if(activeTab==this.tabs.rss){return Balloon.RSS_TAB;}
if(activeTab==this.tabs.audio){return Balloon.AUDIO_TAB;}
if(activeTab==this.tabs.rating){return Balloon.RATING_TAB;}}
Balloon.prototype.attachHandlers=function(){Event.addListener(this.menuId,"click",this.delegateClickEvent,this,false);if(this.tabs.story){Event.addListener(this.wordCaptchaInputId,"keypress",this._submitPost,this,true);}};Balloon.prototype._submitPost=function(e){if(e.keyCode==13){this.blogEditor.savePostEntry();}};Balloon.prototype.showInfoTab=function(poi){if(Dom.get(this.poiId).value==""){if(poi&&poi.id){this.initInfoForPoi(poi);}
else{var poi=ctx.getActivePoi(this.poi.id);if(poi){this.initInfoForPoi(poi);}
else{popupHandler.hidePleaseWait();}}}
this.activateTab(this.tabs.info,this.tabs.infoBody);};Balloon.prototype.showWidgetTab=function(){this.embeddedObjectComponent.initWidgetTab(this.poi.id);this.activateTab(this.tabs.widget,this.tabs.widgetBody);};Balloon.prototype.showVideoTab=function(){popupHandler.showPleaseWait();this.videoComponent.initVideos(this.poi.id);this.activateTab(this.tabs.video,this.tabs.videoBody);};Balloon.prototype.showPhotoTab=function(){popupHandler.showPleaseWait();var poiId=this.poi.id;this.photoComponent.initPhotos(poiId);this.activateTab(this.tabs.photo,this.tabs.photoBody);};Balloon.prototype.showStoryTab=function(addStory){if(Dom.get(this.stories.richEditorId).style.display=="none"){this.showStories(addStory);}
this.activateTab(this.tabs.story,this.tabs.storyBody);};Balloon.prototype.showRssTab=function(){this.embeddedObjectComponent.initRssTab(this.poi.id);this.activateTab(this.tabs.rss,this.tabs.rssBody);};Balloon.prototype.showOwnerTab=function(){this.sharingOwnershipComponent.initOwnerTab(this.poi.id);this.activateTab(this.tabs.owner,this.tabs.ownerBody);};Balloon.prototype.showAudioTab=function(){this.audioComponent.initAudioTab(this.poi.id);this.activateTab(this.tabs.audio,this.tabs.audioBody);};Balloon.prototype.showRatingTab=function(callback){this.ratingComponent.initRatingTab(this.poi.id,callback);this.activateTab(this.tabs.rating,this.tabs.ratingBody);}
Balloon.prototype.showAdvertisementTab=function(){this.activateTab(this.tabs.advertisement,this.tabs.advertisementBody);var poi=ctx.getActivePoi(this.poi.id);var publishedAdvertisement=!!poi.advertisementBasisCM&&poi.advertisementBasisCM.payd&&!poi.advertisementBasisCM.expired;if(poi.balloonTabsInfo==-1&&!publishedAdvertisement){this.advertisementContainer.innerHTML="<div class='noAdvertisement'>"+
PoiMsg.js_msg.advertisementTab.no_advertisement()+"</div><div class='noAdvertisementText'>"+
PoiMsg.js_msg.balloon.no_advertisement.commercial_poi()+"</div>";return;}
if(poi&&poi.advertisementBasisCM&&!(poi.advertisementBasisCM.payd&&poi.advertisementBasisCM.expired)){this.advertisementContainer.innerHTML="<div id='advertisementWriteBalloonContent' class='baloon-adv-content'></div>\
            <div class='buttonAdvDiv'>\
            <a id='advBtnId' class='ovalbutton'>\
            <span>"+PoiMsg.js_msg.balloon.advertisement.edit.exist()+"</span>\
            </a>\
            </div>";this.advertisementBalloonContent=Dom.get("advertisementWriteBalloonContent");if(poi.advertisementBasisCM.balloonContent){this.advertisementBalloonContent.innerHTML=poi.advertisementBasisCM.balloonContent;}
var button=Dom.get("advBtnId");button.href=GlobalProperties.CART_HOST+"?selectedPoi="+this.poi.id;return;}
this.advertisementContainer.innerHTML="<div class='noAdvertisement'>"+PoiMsg.js_msg.advertisementTab.no_advertisement()+"</div>\
           <div class='noAdvertisementText'>"+PoiMsg.js_msg.advertisementTab.no_advertisement.text()+"</div>\
           <div class='buttonAdvDiv'>\
           <a id='advBtnId' class='ovalbutton'>\
           <span>"+PoiMsg.js_msg.balloon.advertisement.add_new()+"</span>\
           </a>\
           </div>";Dom.get("advBtnId").href=GlobalProperties.CART_HOST+"?selectedPoi="+this.poi.id;};Balloon.prototype.deleteStory=function(ev,story){if(story.removable){var that=this;var poiId=this.poi.id;popupHandler.showConfirmPopup(PoiMsg.js_msg.balloon.blog.msg.warning(),PoiMsg.js_msg.balloon.blog.msg.deleteWarning(),function(){popupHandler.showPleaseWait();UIRequest('deleteBalloonBlogEntry.action',"poiId="+poiId+"&entryId="+story.storyId,function(data){that.buildStoriesList(data);});this.hide();});}};Balloon.showCaptcha=function(that){var imgCaptcha=Dom.get(that.imgCaptchaId);var wordCaptchaInput=Dom.get(that.wordCaptchaInputId);var themeSelectror=function(){imgCaptcha.src=GlobalProperties.HOST+'captcha-balloon.jpg?'+Math.floor(Math.random()*100);wordCaptchaInput.value="";if((THEME_NAME=="landleven")||(THEME_NAME=="healthcare")||(THEME_NAME=="omroepbrabant")){imgCaptcha.src=GlobalProperties.HOST+'kaptcha_balloon.jpg?'+Math.floor(Math.random()*100);}};themeSelectror();Event.addListener(Dom.get(that.refrshCaptchaButtonId),"click",themeSelectror);};Balloon._onEditStory=function(data,entryId,balloon){var json=YAHOO.lang.JSON.parse(data.responseText);var storyTab=balloon.stories;Dom.get(storyTab.storyTitleId).value=json.blogEntry.title;Dom.get(storyTab.entryId).value=entryId;balloon.blogEditor.setEditedText(json.blogEntry.description);balloon.blogEditor.setAction('editBalloonBlogEntry.action');storyTab.container.style.display="none";storyTab.noStory.style.display="none";storyTab.addStoryBtn.style.display="none";storyTab.goToBlog.style.display="none";Dom.get(storyTab.richEditorId).style.display="";Balloon.showCaptcha(balloon);popupHandler.hidePleaseWait();Dom.get(storyTab.storyTitleId).select();};Balloon.editStory=function(ev,obj){var story=obj.story;if(story.editable){popupHandler.showPleaseWait();var poiId=obj.that.poi.id;var entryId=story.storyId;UIRequest('getBlogEntry.action',"poiId="+poiId+"&entryId="+entryId,function(data){Balloon._onEditStory(data,entryId,obj.that);});}};Balloon.prototype._onAddStory=function(){if(!ctx.isAuthenticated()){if(THEME_NAME=="landleven")return;popupHandler.showLoginMyPoiPopup("poi="+this.poi.id);return;}
this.blogEditor.clean();this.blogEditor.setAction('addNewBlogEntry.action');var storyTab=this.stories;storyTab.container.style.display="none";Dom.get(storyTab.richEditorId).style.display="";storyTab.noStory.style.display="none";storyTab.addStoryBtn.style.display="none";storyTab.goToBlog.style.display="none";Balloon.showCaptcha(this);Dom.get(storyTab.storyTitleId).select();};Balloon.prototype.attachStoryTabHandlers=function(){Event.addListener(this.stories.addStoryBtn,"click",this._onAddStory,this,true);Event.addListener(this.stories.deleteBtn,"click",this.deleteStory,this.stories,this);Event.addListener(this.stories.editBtn,"click",Balloon.editStory,{story:this.stories,that:this});};Balloon.prototype._initReadStoryLink=function(currentZoom){if(typeof currentZoom=='undefined'){currentZoom=1;}
var storyTab=this.stories;var params="uid="+storyTab.userUid+"&poiId="+this.poi.id+"&zoom="+currentZoom+"&index="+storyTab.storyId;storyTab.readMore.href=((ctx.getCurrentUserUid()!=null)?"/auth":"")+GlobalProperties.MY_POI_HOST+"?"+params;};Balloon.prototype._initGotoStoriesLink=function(currentZoom){var poiId=this.poi.id;var activePoi=ctx.getActivePoi(poiId);if(typeof currentZoom=='undefined'){var currentZoom=1;}
var params="uid="+activePoi.userUid+"&poiId="+poiId+"&zoom="+currentZoom;this.stories.goToBlog.href=((ctx.getCurrentUserUid()!=null)?"/auth":"")+GlobalProperties.MY_POI_HOST+"?"+params;};Balloon.prototype.buildStoriesList=function(data){var json=YAHOO.lang.JSON.parse(data.responseText);var blogEntry=json.blogEntry;var storyTab=this.stories;if(blogEntry==null){this.hideStories();}
else{storyTab.container.style.display="";storyTab.name.innerHTML=blogEntry.title;storyTab.name.title=blogEntry.title;storyTab.date.innerHTML=PoiMsg.js_msg.balloon.blog.postedOn()+" "+blogEntry.created;var span=storyTab.content.firstChild;shrinkTextForDescription(span,blogEntry.description,260);storyTab.storyId=blogEntry.id;storyTab.userUid=blogEntry.userUid;storyTab.editable=blogEntry.editable;storyTab.removable=blogEntry.removable;if(blogEntry.editable){storyTab.editBtn.style.display="";}else{storyTab.editBtn.style.display="none";}
if(blogEntry.removable){storyTab.deleteBtn.style.display="";}else{storyTab.deleteBtn.style.display="none";}
storyTab.noStory.style.display="none";this._initReadStoryLink();}
storyTab.goToBlog.firstChild.innerHTML=PoiMsg.js_msg.balloon.blog.goToStories(json.poiBlogEntriesQuantity);storyTab.goToBlog.style.display="";if(!ctx.isAuthenticated()&&THEME_NAME=="landleven"){storyTab.addStoryBtn.style.display="none";}else{storyTab.addStoryBtn.style.display="";}
popupHandler.hidePleaseWait();};Balloon.prototype.showStories=function(addStory){popupHandler.showPleaseWait();this.stories.addStoryBtn.style.display="none";var poiId=this.poi.id;var that=this;UIRequest('getLatestReviewToPreview.action',"poiId="+poiId,function(data){that.buildStoriesList(data);if(addStory){that._onAddStory();}});this._initGotoStoriesLink();};Balloon.prototype.hideStories=function(){if(this.tabs.story){var storyTab=this.stories;storyTab.container.style.display="none";storyTab.noStory.style.display="block";storyTab.readMore.href="#";}};Balloon.prototype.hideBlogEditor=function(){if(this.tabs.story){Dom.get(this.stories.richEditorId).style.display="none";}};Balloon.prototype.close=function(){if(!this.container||!this.isShown()){return;}
SendToFriend.hideForm();this.videoComponent.hideYouTubePlayer();this.photoComponent.hidePhotoPlayer();this.hideStories();this.hideBlogEditor();this.audioComponent.stopPlayers();if(this.tabs.story){this.tabs.story.style.display="none";this.tabs.story.nextSibling.style.display="none";}
this.tabs.video.style.display="none";this.tabs.video.nextSibling.style.display="none";this.tabs.photo.style.display="none";this.tabs.photo.nextSibling.style.display="none";this.hideAdvMenuTab();this.tabs.widget.style.display="none";this.tabs.widget.nextSibling.style.display="none";this.container.style.display="none";};Balloon.prototype.position=function(){this.positionFor(Poi.getMap().getSize());};Balloon.prototype.positionFor=function(size){var balloonHeight=457;var pointerHeight=36;var balloonWidth=527;var pointerHorizontalShift=390;var container=this.container;container.style.top=(size.height/2-balloonHeight/2+8)+"px";container.style.left=(size.width/2-balloonWidth/2+18)+"px";};Balloon.prototype.show=function(poi,tab){if(!this.container){popupHandler.hidePleaseWait();return;}
var mapLayerControl=ctx.getMapLayersControl();if(mapLayerControl){mapLayerControl.hide();}
this.applyOrganizationPrompts();this.showAdsIfExist(poi.advertisementBasisCM);Dom.get(this.poiId).value="";var poiId=poi.id;PoisList.selectPoi(poiId);this.poi={id:poiId,latitude:poi.latitude,longitude:poi.longitude,categoriesIds:poi.categoriesIds.join(",")};if(!tab||tab==Balloon.INFO_TAB){this.activateTab(this.tabs.info,this.tabs.infoBody);this.showInfoTab(poi);}else{return;}
this.position();this.container.style.display="";};Balloon.prototype.showTab=function(tab,addStory,vote){this.activateTab(this.tabs.info,this.tabs.infoBody);if(tab==Balloon.STORY_TAB){this.activateTab(this.tabs.story,this.tabs.storyBody);if("true"==addStory){this.showStoryTab(true);}else{this.showStoryTab(false);}}
if(tab==Balloon.RATING_TAB){this.activateTab(this.tabs.rating,this.tabs.ratingBody);this.showRatingTab();}
if(tab==Balloon.VIDEO_TAB){this.activateTab(this.tabs.video,this.tabs.videoBody);this.showVideoTab();}
if(tab==Balloon.PHOTO_TAB){this.activateTab(this.tabs.photo,this.tabs.photoBody);this.showPhotoTab();}
if(tab==Balloon.ADVERTISEMENT_TAB){this.activateTab(this.tabs.advertisement,this.tabs.advertisementBody);this.showAdvertisementTab();}
if(tab==Balloon.WIDGET_TAB){this.activateTab(this.tabs.widget,this.tabs.widgetBody);this.showWidgetTab();}
if(tab==Balloon.RSS_TAB){this.activateTab(this.tabs.rss,this.tabs.rssBody);this.showRssTab();}
if(tab==Balloon.AUDIO_TAB){this.activateTab(this.tabs.audio,this.tabs.audioBody);this.showAudioTab();}
if("true"==vote&&this.ratingComponent){this.ratingComponent.addRating();}};Balloon.prototype.isShown=function(){if(this.container){return this.container.style.display=="";}
return false;};Balloon.prototype.activateTab=function(tab,content){this.videoComponent.hideYouTubePlayer();this.photoComponent.hidePhotoPlayer();this.hideStories();this.audioComponent.stopPlayers();var tabs=this.tabs;Dom.removeClass(tabs.info,'active');tabs.infoBody.style.display="none";Dom.removeClass(tabs.video,'active');tabs.videoBody.style.display="none";Dom.removeClass(tabs.photo,'active');tabs.photoBody.style.display="none";Dom.removeClass(tabs.widget,'active');tabs.widgetBody.style.display="none";Dom.removeClass(tabs.rss,'active');tabs.rssBody.style.display="none";if(this.tabs.owner){Dom.removeClass(tabs.owner,'active');tabs.ownerBody.style.display="none";}
if(this.tabs.story){Dom.removeClass(tabs.story,'active');tabs.storyBody.style.display="none";}
if(this.tabs.advertisement){Dom.removeClass(tabs.advertisement,'active');tabs.advertisementBody.style.display="none";}
if(this.tabs.audio){Dom.removeClass(tabs.audio,'active');tabs.audioBody.style.display="none";}
if(this.tabs.rating){Dom.removeClass(tabs.rating,'active');tabs.ratingBody.style.display="none";}
Dom.addClass(tab,'active');content.style.display="";if(this.ratingComponent){this.ratingComponent.closeAddRating();}
this.activeTab=tab;this.activeContent=content;};Balloon.prototype.showAdsIfExist=function(){this.showAdvMenuTab();};Balloon.prototype.showAdvMenuTab=function(){if(this.tabs.advertisement){this.tabs.advertisement.style.display="";this.tabs.advertisement.nextSibling.style.display="";}};Balloon.prototype.hideAdvMenuTab=function(){if(this.tabs.advertisement){this.tabs.advertisement.style.display="none";this.tabs.advertisement.nextSibling.style.display="none";}};Balloon.prototype.transformAddressString=function(inputAddressString){if(!inputAddressString||inputAddressString==''){return'';}
var fullAddress='';var regions=inputAddressString.split(",");var n=regions.length;fullAddress=fullAddress+regions[n-1]+' (';for(var i=1;i<n-1;i++){fullAddress=fullAddress+regions[i];if(i!=n-2)fullAddress=fullAddress+', ';}
fullAddress=fullAddress+'), '+regions[0];return fullAddress;};Balloon.prototype.hideTabs=function(){this.hideAdvMenuTab();};Balloon.prototype.applyOrganizationPrompts=function(){var organizationPrompts=ctx.getOrganizationPrompts();if(organizationPrompts['balloon.widget.title']){this.tabs.widgetTabPrompt.innerHTML=organizationPrompts['balloon.widget.title'];this.tabs.widgetTabPrompt.title=organizationPrompts['balloon.widget.title'];}else{this.tabs.widgetTabPrompt.innerHTML=PoiMsg.js_msg.balloon.widget();this.tabs.widgetTabPrompt.title=PoiMsg.js_msg.balloon.widget();}};function shrinkTextForDescription(span,text,intHeight){var noImg=text.replace(/<img(.*?)>/g,"");text=noImg.replace(/\n/g,"<br/>");span.innerHTML=text;var length=text.length/Math.floor(span.offsetHeight/intHeight);text=text.substring(0,length);span.innerHTML=text;var n=1/16;var text2=text;while(span.offsetHeight>intHeight&&span.innerHTML!="..."){text=text2;text2=text.slice(0,-1*text.length*n);span.innerHTML=text2+"...";}
span.innerHTML=text;while(span.offsetHeight>intHeight&&span.innerHTML!="..."){text=text.slice(0,-1);span.innerHTML=text+"...";}};function ViewBalloon(){this.container=Dom.get("balloonReadContainer");this.imgCaptchaId="balloonCaptcha";this.wordCaptchaInputId="balloonCaptchaWordVerificationId";this.refrshCaptchaButtonId="balloonReviewCaptchaGetNewImage";var container=this.container;this.extendedInfoId="extendedInfoReadMenuTabId";this.tabs={info:Dom.get("infoReadMenuTabId"),infoBody:Dom.get("infoBalloonTab"),video:Dom.get("videoReadMenuTabId"),videoBody:Dom.get("videoBalloonTab"),photo:Dom.get("photoReadMenuTabId"),photoBody:Dom.get("photoBalloonTab"),story:Dom.get("reviewReadMenuTabId"),storyBody:Dom.get("storyBalloonTab"),storyTabPrompt:Dom.get("storyReedTabPrompt"),advertisement:Dom.get("adsReadMenuTabId"),advertisementBody:Dom.get("advertisementBalloonTab"),widget:Dom.get("widgetReadMenuTabId"),widgetBody:Dom.get("widgetBalloonTab"),widgetTabPrompt:Dom.get("widgetReedTabPrompt"),rss:Dom.get("rssReadMenuTabId"),rssBody:Dom.get("rssBalloonTab"),rssTabPrompt:Dom.get("rssReedTabPrompt"),audio:Dom.get("audioReadMenuTabId"),audioBody:Dom.get("audioBalloonTab"),rating:Dom.get("ratingReadMenuTabId"),ratingBody:Dom.get("ratingBalloonTab")};this.menuId="view-balloon-menu";this.mainCategoryIcon=Dom.get("poiMainCategory");this.poiName=Dom.get("poiNameBalloon").firstChild;this.categoriesContainer=Dom.get("categoriesIcons");this.descriptionContainer=Dom.get("poiInformationBalloon");this.description=Dom.get("poiDescriptionScroll");this.description.style.marginTop="0px";this.scrollUp=Dom.get("poiDescriptionScrollUp");this.scrollDown=Dom.get("poiDescriptionScrollDown");this.poiRoute=Dom.get("view-balloon-route-holder");this.poiCountryRegionCity=Dom.get("poiAddressId");this.poiPhone=Dom.get("poiPhoneId");this.poiMobile=Dom.get("poiMobileId");this.poiEmail=Dom.get("poiEmailId");this.poiUrl=Dom.get("poiUrlId");this.closeBalloonId="readBalloonCloseBtn";if(this.tabs.story){var storyContainer=Dom.get("poiBlog");this.stories={container:storyContainer,name:storyContainer.getElementsByTagName("div")[1],date:storyContainer.getElementsByTagName("div")[2],editBtn:storyContainer.getElementsByTagName("div")[3],deleteBtn:storyContainer.getElementsByTagName("div")[4],content:storyContainer.getElementsByTagName("div")[5],entryId:null,noStory:Dom.get("noStoriesMsg"),addStoryBtn:Dom.get("addNewStoryLink"),goToBlog:Dom.get("gotoStoryLink"),richEditorId:"storyRichEditor",storyDescriptionId:"blogEntryDescription",storyFormId:"EditBlogPostForm",storyTitleId:"blogEntryTitle",gotoStoriesListId:"gotoEntriesList",entryPostId:"entryPost",entryId:"entryId"};this.stories.readMore=this.stories.content.getElementsByTagName("a")[0];}
this.poiId="poiIdBalloon";this.advertisementContainer=Dom.get("advertisementContainer");this.advertisementBalloonContent=Dom.get("advertisementBalloonContent");this.infoRequestButtonsContainer=Dom.get('info_request_buttons');this.infoRequestButtonsContainer.title=PoiMsg.js_msg.balloon.infoRequestLink();this.infoButtonsContainer=Dom.get('info_buttons');this.infoButtonsContainer.title=PoiMsg.js_msg.poi.list.sendToAFriend();this.linkButtonsContainer=Dom.get('poi_link_buttons');this.linkButtonsContainer.title=PoiMsg.js_msg.balloon.copyLink();this.pdfButtonsContainer=Dom.get('poi_pdf_buttons');this.pdfButtonsContainer.title=PoiMsg.js_msg.balloon.getPDF();this.videoComponent=new ViewVideoComponent();this.photoComponent=new ViewPhotoComponent();this.embeddedObjectComponent=new ViewEmbeddedObjectComponent();this.audioComponent=new ViewAudioComponent();this.ratingComponent=new ViewRatingComponent(this);this.beforeOpenViewBalloon=new YAHOO.util.CustomEvent("onBeforeOpenViewBalloon",this);this.poiTypeHandlerComponent=new PoiTypeHandlerComponent();this.beforeOpenViewBalloon.subscribe(this.poiTypeHandlerComponent.onBeforeOpenViewBalloon,this.poiTypeHandlerComponent,true);this.constructor.superclass.constructor.apply(this,arguments);};YAHOO.lang.extend(ViewBalloon,Balloon);ViewBalloon.prototype.attachHandlers=function(){this.constructor.superclass.attachHandlers.apply(this,arguments);Event.addListener(this.scrollUp,"mousedown",this._scrollUpHandler,this,false);Event.addListener(this.scrollDown,"mousedown",this._scrollDownHandler,this,false);Event.addListener(this.scrollUp,"mouseup",this._stopScrollUp,this,true);Event.addListener(this.scrollDown,"mouseup",this._stopScrollDown,this,true);Event.addListener(this.scrollUp,"mouseout",this._stopScrollUp,this,true);Event.addListener(this.scrollDown,"mouseout",this._stopScrollDown,this,true);if(this.descriptionContainer.addEventListener){this.descriptionContainer.addEventListener('DOMMouseScroll',this._onMouseWheel,this,false);this.descriptionContainer.addEventListener('mousewheel',this._onMouseWheel,this,false);}
else if(this.descriptionContainer.attachEvent){this.descriptionContainer.attachEvent('onmousewheel',this._onMouseWheel,this,false);}
var that=this;Event.addListener(this.linkButtonsContainer,"click",function(){var poiId=that.poi.id;var link='poi='+poiId;if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/view_balloon/link_button");}
popupHandler.showGetUrlPopup(PoiMsg.js_msg.balloon.link.header(),PoiMsg.js_msg.balloon.link.message(),link);});Event.addListener(this.pdfButtonsContainer,"click",function(){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/view_balloon/print_button");}
var poiId=that.poi.id;var lat=that.poi.latitude;var lng=that.poi.longitude;var zoom=Poi.getMap().getZoom();var params='poiId='+poiId+'&centerLat='+lat+'&centerLng='+lng+'&zoom='+zoom;var poiPdfLink=Dom.get('poiPdfLink');var currentLocation=window.location;poiPdfLink.href=currentLocation.protocol+"//"+currentLocation.host+GlobalProperties.HOST+"poi.pdf?"+params;});if(ctx.getCurrentUserUid()&&ctx.getCurrentUserUid()!=''){Event.addListener("poiRatingInfoWrapper","click",function(){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/view_balloon/poi_rating_button");}
that.ratingComponent.addRating();});Dom.get('poiRatingInfoRateHint').style.display='';}else{if(THEME_NAME!="landleven"){Event.addListener("poiRatingInfoWrapper","click",function(){var tabIndex=that.getTabIndex(that.activeTab);if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/view_balloon/poi_rating_button");}
popupHandler.showLoginRatingPopup("poi="+that.poi.id+"&tab="+tabIndex);});}else{var voteEl=this.ratingComponent.displayInfoRate.parentNode;if((!Dom.hasClass(voteEl,"disabled"))){Dom.addClass(voteEl,"disabled");Dom.get('poiRatingInfoWrapper').title='';}}}};ViewBalloon.prototype._scrollDescriptionDown=function(scroller){this._stopScrollUp();var descriptionScroll=this.description;var marginTop=parseInt(descriptionScroll.style.marginTop);marginTop=marginTop-3;if(marginTop<descriptionScroll.parentNode.offsetHeight-descriptionScroll.offsetHeight){marginTop=descriptionScroll.parentNode.offsetHeight-descriptionScroll.offsetHeight;scroller.style.visibility="hidden";this._stopScrollDown();}
descriptionScroll.style.marginTop=marginTop+"px";};ViewBalloon.prototype._scrollDescriptionUp=function(scroller){this._stopScrollDown();var descriptionScroll=this.description;var marginTop=parseInt(descriptionScroll.style.marginTop);marginTop=marginTop+3;if(marginTop>0){marginTop=0;scroller.style.visibility="hidden";this._stopScrollUp();}
descriptionScroll.style.marginTop=marginTop+"px";};ViewBalloon.prototype._scrollDownHandler=function(ev,viewBalloon){if(viewBalloon.mouseDown==null||typeof viewBalloon.mouseDown=="undefined"){var scroller=this;viewBalloon._scrollDescriptionDown(scroller);viewBalloon.scrollUp.style.visibility="visible";viewBalloon.mouseDown=setInterval(function(){viewBalloon._scrollDescriptionDown(scroller);},8);}};ViewBalloon.prototype._scrollUpHandler=function(ev,viewBalloon){if(viewBalloon.mouseUp==null||typeof viewBalloon.mouseUp=="undefined"){var scroller=this;viewBalloon._scrollDescriptionUp(scroller);viewBalloon.scrollDown.style.visibility="visible";viewBalloon.mouseUp=setInterval(function(){viewBalloon._scrollDescriptionUp(scroller);},8);}};ViewBalloon.prototype._stopScrollUp=function(){if(this.mouseUp){clearInterval(this.mouseUp);this.mouseUp=null;}};ViewBalloon.prototype._stopScrollDown=function(){if(this.mouseDown){clearInterval(this.mouseDown);this.mouseDown=null;}};ViewBalloon.prototype._onMouseWheel=function(ev){var descriptionScroll=Dom.get("poiDescriptionScroll");if(descriptionScroll.parentNode.offsetHeight>descriptionScroll.offsetHeight){return;}
var scrolledUp=(ev.type=="DOMMouseScroll"&&ev.detail<0)||(ev.type=="mousewheel"&&ev.wheelDelta>0);var marginTop=parseInt(descriptionScroll.style.marginTop);if(scrolledUp){marginTop=marginTop+12;var scroller=Dom.get("poiDescriptionScrollDown");scroller.style.visibility="visible";if(marginTop>0){marginTop=0;var scroller=Dom.get("poiDescriptionScrollUp");scroller.style.visibility="hidden";}}else{marginTop=marginTop-12;var scroller=Dom.get("poiDescriptionScrollUp");scroller.style.visibility="visible";if(marginTop<descriptionScroll.parentNode.offsetHeight-descriptionScroll.offsetHeight){marginTop=descriptionScroll.parentNode.offsetHeight-descriptionScroll.offsetHeight;var scroller=Dom.get("poiDescriptionScrollDown");scroller.style.visibility="hidden";}}
descriptionScroll.style.marginTop=marginTop+"px";Event.stopEvent(ev);};ViewBalloon.prototype.close=function(){this.constructor.superclass.close.apply(this,arguments);document.title=ctx.getOriginalTitle();Poi.getMap().balloonClose();PoisList.unSelectAllPois();};ViewBalloon.prototype.goToExtended=function(){};ViewBalloon.prototype._showPoiPointInfo=function(poi){this.balloonTabsInfo=poi.balloonTabsInfo;var mainCatId=poi.mainCategoryId;CLIPTOO.utils.setCategoryIcon(this.mainCategoryIcon,mainCatId);this.mainCategoryIcon.style.display="";this.mainCategoryIcon.title=ctx.getCategories()[mainCatId].name;var categoriesContainer=this.categoriesContainer;categoriesContainer.style.display="none";var n=poi.categoriesIds.length;var m=categoriesContainer.childNodes.length;for(var i=m;i<n-1;i++){var catIcon=document.createElement("div");catIcon.className="baloon_category_icon";categoriesContainer.appendChild(catIcon);}
for(var i=n-1;i<m;i++){categoriesContainer.childNodes[i].style.display="none";}
var catId,iconIndex=0;for(var i=0;i<n;i++){catId=parseInt(poi.categoriesIds[i]);if(catId==mainCatId){continue;}
var catIcon=categoriesContainer.childNodes[iconIndex];CLIPTOO.utils.setCategoryIcon(catIcon,catId);catIcon.style.display="";catIcon.title=ctx.getCategories()[catId].name;iconIndex++;}
if(n>1){categoriesContainer.style.display="";}else{categoriesContainer.style.display="none";}
this.tabs.widgetTabPrompt.title=CLIPTOO.utils.trim(this.tabs.widgetTabPrompt.innerHTML);CLIPTOO.utils.shrinkOneRowTextByWidth(this.tabs.widgetTabPrompt,18,45,15);this.tabs.rssTabPrompt.title=CLIPTOO.utils.trim(this.tabs.rssTabPrompt.innerHTML);CLIPTOO.utils.shrinkOneRowTextByWidth(this.tabs.rssTabPrompt,18,45,15);};ViewBalloon.prototype.initInfoForFirstPoi=function(point,json){var poiId=Dom.get(this.poiId).value;this.initSendToAFriend(poiId);this.initInfoRequest(poiId);var poi=ctx.getActivePoi(poiId);ctx.fixOriginalTitle(poi.name);this.poi={id:poiId,categoriesIds:poi.categoriesIds.join(","),latitude:poi.latitude,longitude:poi.longitude};var descriptionSizeCounter=0;if(Dom.get("poiPhoneSpan").innerHTML!=""){descriptionSizeCounter++}
if(Dom.get("poiUrlSpan").innerHTML!=""){descriptionSizeCounter++}
if(Dom.get("poiMobileSpan").innerHTML!=""){descriptionSizeCounter++}
if(Dom.get("poiZipSpan").innerHTML!=""){descriptionSizeCounter++}
if(Dom.get("poiEmailSpan").innerHTML!=""){descriptionSizeCounter++}
if(Dom.get("view-balloon-route-file").innerHTML!=""){descriptionSizeCounter++}
var catCount;if(this.poi.categoriesIds.split){catCount=this.poi.categoriesIds.split(",");}
var addSize;(catCount.length>1)?addSize=0:addSize=33;this.fixViewDescriptionSize(addSize,descriptionSizeCounter);if(Dom.get("poiDescriptionScroll").parentNode.offsetHeight<Dom.get("poiDescriptionScroll").offsetHeight){Dom.get("poiDescriptionScrollDown").style.visibility="visible";}else{Dom.get("poiDescriptionScrollDown").style.visibility="hidden";}
Dom.get("poiDescriptionScrollUp").style.visibility="hidden";this._showPoiPointInfo(poi);this.showAdsIfExist(poi.advertisementBasisCM);if(this.ratingComponent){this.ratingComponent.isEnabledVote=!json.voted;this.ratingComponent.setRate(json.averagePoiRating);}
var tabView=Dom.get("tabViewPar");var addStory=Dom.get("addStoryPar");var vote=Dom.get("votePar");this.showTab((tabView)?tabView.value:null,(addStory)?addStory.value:null,(vote)?vote.value:null);};ViewBalloon.prototype._onGeneralInfoCome=function(data){var json=YAHOO.lang.JSON.parse(data.responseText);var poiGeneralInfo=json.poiGeneralInfo;var poi=this.poi;poi.videosPresent=poiGeneralInfo.videosPresent;poi.photosPresent=poiGeneralInfo.photosPresent;poi.viewsPresent=poiGeneralInfo.viewsPresent;poi.widgetCodePresent=poiGeneralInfo.widgetCodePresent;poi.rssLinkPresent=poiGeneralInfo.rssLinkPresent;poi.audiosPresent=poiGeneralInfo.audiosPresent;var commercialTabs=ctx.getBalloonTabsPrices();if(commercialTabs&&(this.balloonTabsInfo>0)){for(var index in commercialTabs){if((this.balloonTabsInfo>>(16-index)&1)!=1){switch(parseInt(index)){case Balloon.VIDEO_TAB:poi.videosPresent=false;break;case Balloon.PHOTO_TAB:poi.photosPresent=false;break;case Balloon.STORY_TAB:poi.viewsPresent=false;break;case Balloon.WIDGET_TAB:poi.widgetCodePresent=false;break;case Balloon.RSS_TAB:poi.rssLinkPresent=false;break;case Balloon.AUDIO_TAB:poi.audiosPresent=false;}}}}
if(poiGeneralInfo.widgetTabTitle&&poiGeneralInfo.widgetTabTitle!=''){this.tabs.widgetTabPrompt.innerHTML=poiGeneralInfo.widgetTabTitle;CLIPTOO.utils.shrinkOneRowTextByWidth(this.tabs.widgetTabPrompt,18,45,15);this.tabs.widgetTabPrompt.title=poiGeneralInfo.widgetTabTitle;}
if(poiGeneralInfo.rssTabTitle&&poiGeneralInfo.rssTabTitle!=''){this.tabs.rssTabPrompt.innerHTML=poiGeneralInfo.rssTabTitle;CLIPTOO.utils.shrinkOneRowTextByWidth(this.tabs.rssTabPrompt,18,45,15);this.tabs.rssTabPrompt.title=poiGeneralInfo.rssTabTitle;}
document.title=poiGeneralInfo.name+" - "+ctx.getOriginalTitle();var formattedDescription=poiGeneralInfo.description.replace(/(\n|\r\n)/g,"<br/>");this.description.innerHTML=formattedDescription;if(this.description.parentNode.offsetHeight<this.description.offsetHeight){this.scrollDown.style.visibility="visible";}
if(this.ratingComponent){this.ratingComponent.isEnabledVote=!poiGeneralInfo.voted;this.ratingComponent.setRate(poiGeneralInfo.rate);}
var addressArray=[];if(poiGeneralInfo.address&&poiGeneralInfo.address!=''){addressArray[addressArray.length]=poiGeneralInfo.address;}
if(poiGeneralInfo.additionalAddress&&poiGeneralInfo.additionalAddress!=""){addressArray[addressArray.length]=poiGeneralInfo.additionalAddress;}
var fullAddress=addressArray.join(" ");if(poiGeneralInfo.location&&poiGeneralInfo.location!=""){fullAddress=(fullAddress&&fullAddress!="")?(fullAddress+", "+poiGeneralInfo.location):(poiGeneralInfo.location);}
if(fullAddress&&fullAddress!=""){this.poiCountryRegionCity.style.display="block";Dom.get("poiAddressSpan").innerHTML=fullAddress;Dom.get("poiAddressSpan").title=fullAddress;CLIPTOO.utils.shrinkOneRowTextByWidth(Dom.get("poiAddressSpan"),15,420,160);}else{this.poiCountryRegionCity.style.display="none";}
var descriptionSizeCounter=0;if(json.zipCode&&json.zipCode!=''){Dom.get("poiZipId").style.display="block";Dom.get("poiZipSpan").innerHTML=json.zipCode;descriptionSizeCounter++;}else{Dom.get("poiZipSpan").innerHTML="";}
if(json.phone&&json.phone!=''){this.poiPhone.style.display="block";Dom.get("poiPhoneSpan").innerHTML=json.phone;descriptionSizeCounter++;}else{Dom.get("poiPhoneSpan").innerHTML="";}
if(json.mobile&&json.mobile!=''){this.poiMobile.style.display="block";Dom.get("poiMobileSpan").innerHTML=json.mobile;descriptionSizeCounter++;}else{Dom.get("poiMobileSpan").innerHTML="";}
if(json.email&&json.email!=''){this.poiEmail.style.display="block";Dom.get("poiEmailSpan").innerHTML=json.email;Dom.get("poiEmailSpan").parentNode.href="mailto:"+json.email;descriptionSizeCounter++;}else{Dom.get("poiEmailSpan").innerHTML="";Dom.get("poiEmailSpan").parentNode.href="";}
if(json.url&&json.url!=''){this.poiUrl.style.display="block";Dom.get("poiUrlSpan").innerHTML=json.url;Dom.get("poiUrlSpan").parentNode.href="http://"+json.url;Dom.get("poiUrlSpan").title="http://"+json.url;CLIPTOO.utils.shrinkOneRowTextByWidth(Dom.get("poiUrlSpan"),15,400,205);descriptionSizeCounter++;}else{Dom.get("poiUrlSpan").innerHTML="";Dom.get("poiUrlSpan").parentNode.href="";Dom.get("poiUrlSpan").title="";}
if(this.pointType==GlobalProperties.ROUTE&&poiGeneralInfo.layerLink){this.poiRoute.style.display="block";var link=Dom.get("view-balloon-route-file");var segments=poiGeneralInfo.layerLink.split("/");if(segments.length>0){link.innerHTML=segments[segments.length-1];}
link.href=poiGeneralInfo.layerLink;descriptionSizeCounter++;}else{this.poiRoute.style.display="none";}
var catCount;if(poi.categoriesIds.split){catCount=poi.categoriesIds.split(",");}
var addSize;(catCount.length>1)?addSize=0:addSize=33;this.fixViewDescriptionSize(addSize,descriptionSizeCounter);this.checkTabsVisibility(this.poi);this.initInfoRequest(poiId);popupHandler.hidePleaseWait();}
ViewBalloon.prototype.initInfoForPoi=function(poi){poiId=poi.id;this.initSendToAFriend(poiId);var pdfButton=Dom.get('poiPdfLink');if(this.pointType==4&&pdfButton){pdfButton.style.display='none';}else{pdfButton.style.display='';}
Dom.get(this.poiId).value=poiId;Dom.get("poiLatBalloon").value=poi.latitude;Dom.get("poiLngBalloon").value=poi.longitude;this.poiName.innerHTML=poi.name;this.poiName.title=poi.name;this.description.innerHTML="";this.poiCountryRegionCity.style.display="none";Dom.get("poiZipId").style.display="none";this.poiPhone.style.display="none";this.poiMobile.style.display="none";this.poiEmail.style.display="none";this.poiUrl.style.display="none";this._showPoiPointInfo(poi);var that=this;UIRequest("getPoiGeneralInfo.action","id="+poiId,function(data){that._onGeneralInfoCome(data);});};ViewBalloon.prototype.initSendToAFriend=function(poiId){if(this.poiTypeHandlerComponent.currentType==this.poiTypeHandlerComponent.poaType){this.infoButtonsContainer.style.display="none";this.linkButtonsContainer.style.display="none";return;}else{this.linkButtonsContainer.style.display="";}
Dom.get('info_buttons').style.display="";if(poiId){this.infoButtonsContainer.style.display="block";Event.purgeElement(this.infoButtonsContainer,true,"click");SendToFriend.attachMailListener(this.infoButtonsContainer,poiId);}else{this.infoButtonsContainer.style.display="none";}};ViewBalloon.prototype.initInfoRequest=function(poiId){if(this.poiTypeHandlerComponent.currentType==this.poiTypeHandlerComponent.poaType){this.infoRequestButtonsContainer.style.display="none";this.linkButtonsContainer.style.display="none";return;}else{this.linkButtonsContainer.style.display="";}
var poiEmail=Dom.get("poiEmailSpan").innerHTML;Dom.get('info_request_buttons').style.display="";if(poiId&&poiEmail!=""){this.infoRequestButtonsContainer.style.display="block";Event.purgeElement(this.infoRequestButtonsContainer,true,"click");InfoRequest.attachMailListener(this.infoRequestButtonsContainer,poiId);}else{this.infoRequestButtonsContainer.style.display="none";}};ViewBalloon.prototype.showAdsIfExist=function(ad){if(ad!=null&&ad.balloonContent!=null){this.showAdvMenuTab();}else{this.hideAdvMenuTab();}};ViewBalloon.prototype.checkTabsVisibility=function(poi){if(this.tabs.story){this.tabs.story.style.display="block";this.tabs.story.nextSibling.style.display="block";}
if(this.tabs.video){if(poi.videosPresent){this.tabs.video.style.display="block";this.tabs.video.nextSibling.style.display="block";}else{this.tabs.video.style.display="none";this.tabs.video.nextSibling.style.display="none";}}
if(this.tabs.photo){if(poi.photosPresent){this.tabs.photo.style.display="block";this.tabs.photo.nextSibling.style.display="block";}else{this.tabs.photo.style.display="none";this.tabs.photo.nextSibling.style.display="none";}}
if(this.tabs.widget){var balloonInstance=this;if(poi.widgetCodePresent){this.tabs.widget.style.display="block";this.tabs.widget.nextSibling.style.display="block";CLIPTOO.utils.shrinkOneRowTextByWidth(balloonInstance.tabs.widgetTabPrompt,18,50,70);}else{this.tabs.widget.style.display="none";this.tabs.widget.nextSibling.style.display="none";}}
if(this.tabs.rss){if(poi.rssLinkPresent){this.tabs.rss.style.display="block";this.tabs.rss.nextSibling.style.display="block";CLIPTOO.utils.shrinkOneRowTextByWidth(balloonInstance.tabs.rssTabPrompt,18,50,70);}else{this.tabs.rss.style.display="none";this.tabs.rss.nextSibling.style.display="none";}}
if(this.tabs.audio){if(poi.audiosPresent){this.tabs.audio.style.display="block";this.tabs.audio.nextSibling.style.display="block";}else{this.tabs.audio.style.display="none";this.tabs.audio.nextSibling.style.display="none";}}
if(this.tabs.rating){var ratingPresent=true;if(ratingPresent){this.tabs.rating.style.display="block";this.tabs.rating.nextSibling.style.display="block";}else{this.tabs.rating.style.display="none";this.tabs.rating.nextSibling.style.display="none";}}};ViewBalloon.prototype.show=function(poi,tab){if(poi&&poi.id!=0&&poi.mainCategoryId&&ctx.getCategories()[poi.mainCategoryId]){this.pointType=ctx.getCategories()[poi.mainCategoryId].categoryType;}
this.poi=poi;this.beforeOpenViewBalloon.fire();this.constructor.superclass.show.apply(this,arguments);this.description.style.marginTop="0px";this.scrollUp.style.visibility="hidden";this.scrollDown.style.visibility="hidden";CLIPTOO.utils.shrinkOneRowTextByWidth(this.poiName,30,435,64);ctx.getZoomingControl().disable();};ViewBalloon.prototype._initGotoStoriesLink=function(){var currentZoom=Poi.getMap().getZoom();if(currentZoom<10){currentZoom=10;}
this.constructor.superclass._initGotoStoriesLink.apply(this,[currentZoom]);};ViewBalloon.prototype._initReadStoryLink=function(){var currentZoom=Poi.getMap().getZoom();if(currentZoom<10){currentZoom=10;}
this.constructor.superclass._initReadStoryLink.apply(this,[currentZoom]);};ViewBalloon.prototype.showAdvertisementTab=function(){this.constructor.superclass.showAdvertisementTab.apply(this,arguments);if(!!Dom.get("advBtnId")){Dom.get("advBtnId").style.display='none';}};ViewBalloon.prototype.fixViewDescriptionSize=function(addSize,descriptionSizeCounter){switch(descriptionSizeCounter){case 0:this.description.parentNode.style.height=(227+addSize)+"px";break;case 1:this.description.parentNode.style.height=(210+addSize)+"px";break;case 2:this.description.parentNode.style.height=(195+addSize)+"px";break;case 3:this.description.parentNode.style.height=(179+addSize)+"px";break;case 4:this.description.parentNode.style.height=(162+addSize)+"px";break;case 5:this.description.parentNode.style.height=(147+addSize)+"px";break;case 6:this.description.parentNode.style.height=(138+addSize)+"px";break;default:}};CLIPTOO.createPackage("confirmPopup");Dom=YAHOO.util.Dom;Event=YAHOO.util.Event;confirmPopup=CLIPTOO.confirmPopup;CLIPTOO.confirmPopup.showPopupForSavePoi=function(that,showPaymentMessage,isAdvertisementPaid){var message=PoiMsg.js_msg.balloon.information.informationBeforeChangeTab();if(showPaymentMessage){if(isAdvertisementPaid){message=PoiMsg.js_msg.balloon.commercialCategoryPlusAdv.popupMessage()+"<br><br>"+message+"<br><br>";}else{var amount=Dom.get("poiPriceAmount").innerHTML;message=PoiMsg.js_msg.balloon.commercialCategory.popupMessage(amount)+"<br><br>";}
if(Dom.get("pageName").value=="POICartPage"){confirmPopup.confirmPopup(that,message);}else{confirmPopup.confirmPopupCommercial(that,message);}}else{confirmPopup.confirmPopup(that,message);}};CLIPTOO.confirmPopup.showPopupWithSharedOwner=function(that,afterSavingCallback,showPaymentMessage){var message=PoiMsg.js_msg.balloon.information.informationBeforeChangeTab();if(showPaymentMessage){var amount=Dom.get("poiPriceAmount").innerHTML;message=PoiMsg.js_msg.balloon.commercialCategory.popupMessage(amount)+"<br><br>"+message+"<br><br>";if(Dom.get("pageName").value=="POICartPage"){confirmPopup.confirmSharedOwner(that,message,afterSavingCallback);}else{confirmPopup.confirmSharedOwnerCommercial(that,message,afterSavingCallback);}}else{var message=PoiMsg.js_msg.balloon.information.informationBeforeChangeTab();confirmPopup.confirmSharedOwner(that,message,afterSavingCallback);}}
CLIPTOO.confirmPopup.showPopupWithBalloonTabs=function(that,afterSavingCallback,showPaymentMessage){var message=PoiMsg.js_msg.balloon.information.informationBeforeChangeTab();var amount=Dom.get("poiPriceAmount").innerHTML;message=PoiMsg.js_msg.balloon.commercialCategory.popupMessage(amount)+"<br><br>"+message+"<br><br>";if(Dom.get("pageName").value=="POICartPage"){confirmPopup.confirmBalloonTabs(that,message,afterSavingCallback);}else{confirmPopup.confirmBalloonTabsCommercial(that,message,afterSavingCallback);}};CLIPTOO.confirmPopup.showPopupForSavePoiWithAdvertisement=function(isAdvertisementPaid,balloon,showTabCallback){var message=PoiMsg.js_msg.balloon.information.informationBeforeChangeTab();var amount=Dom.get("poiPriceAmount").innerHTML;if(isAdvertisementPaid){message=PoiMsg.js_msg.balloon.commercialCategoryPlusAdv.popupMessage()+"<br><br>"+message+"<br><br>";}
else{message=PoiMsg.js_msg.balloon.commercialCategory.popupMessage(amount)+"<br><br>"+message+"<br><br>";}
confirmPopup.confirmPopupCommercialWithAdvertisement(message,balloon,showTabCallback);};CLIPTOO.confirmPopup.confirmPopup=function(that,message){popupHandler.showConfirmPopup(PoiMsg.js_msg.balloon.blog.msg.warning(),message,function(){that.saveAfterClose();this.hide();},function(){that.doNotSaveAfterClose();this.hide();});}
CLIPTOO.confirmPopup.confirmPopupCommercial=function(that,message){popupHandler.showConfirmPopup(PoiMsg.js_msg.balloon.blog.msg.warning(),message,function(){that._onPoiSaved=function(data,afterSavingCallback){location.href=GlobalProperties.CART_HOST+"?commercialPoisIds="+that.poi.id;}
that.saveAfterClose();this.hide();},function(){that.saveAfterClose();this.hide();},PoiMsg.js_msg.msg.checkout(),PoiMsg.js_msg.msg.checkoutLater());};CLIPTOO.confirmPopup.confirmSharedOwner=function(that,message,afterSavingCallback){popupHandler.showConfirmPopup(PoiMsg.js_msg.balloon.blog.msg.warning(),message,function(){that.saveOwnerTab();that.clearOnClose();this.hide();if(afterSavingCallback){afterSavingCallback();}},function(){that.clearOnClose();this.hide();if(afterSavingCallback){afterSavingCallback();}});};CLIPTOO.confirmPopup.confirmSharedOwnerCommercial=function(that,message,afterSavingCallback){popupHandler.showConfirmPopup(PoiMsg.js_msg.balloon.blog.msg.warning(),message,function(){that.saveOwnerTab(function(){location.href=GlobalProperties.CART_HOST+"?commercialPoisIds="+that.poi.id;});this.hide();},function(){that.saveOwnerTab();that.clearOnClose();this.hide();if(afterSavingCallback){afterSavingCallback();}},PoiMsg.js_msg.msg.checkout(),PoiMsg.js_msg.msg.checkoutLater());};CLIPTOO.confirmPopup.confirmBalloonTabs=function(that,message,afterSavingCallback){popupHandler.showConfirmPopup(PoiMsg.js_msg.balloon.blog.msg.warning(),message,function(){that.updateBalloonTabs();this.hide();if(afterSavingCallback){afterSavingCallback();}},function(){this.hide();if(afterSavingCallback){afterSavingCallback();}});};CLIPTOO.confirmPopup.confirmBalloonTabsCommercial=function(that,message,afterSavingCallback){popupHandler.showConfirmPopup(PoiMsg.js_msg.balloon.blog.msg.warning(),message,function(){that.updateBalloonTabs(function(){location.href=GlobalProperties.CART_HOST+"?commercialPoisIds="+that.poi.id;});this.hide();},function(){that.updateBalloonTabs();this.hide();if(afterSavingCallback){afterSavingCallback();}},PoiMsg.js_msg.msg.checkout(),PoiMsg.js_msg.msg.checkoutLater());};CLIPTOO.confirmPopup.confirmPopupCommercialWithAdvertisement=function(message,balloon,callback){popupHandler.showConfirmPopup(PoiMsg.js_msg.balloon.blog.msg.warning(),message,function(){balloon.savePoi(callback);this.hide();},function(){this.hide();return false;});};CLIPTOO.createPackage("savePopup");savePopup=CLIPTOO.savePopup;CLIPTOO.savePopup.confirmPopup=function(message,callBack){popupHandler.showConfirmPopup(PoiMsg.js_msg.balloon.blog.msg.warning(),message,function(){callBack.yesCallBack();this.hide();},function(){callBack.noCallBack();this.hide();});}
CLIPTOO.savePopup.confirmPopupCommercial=function(message,callBack){popupHandler.showConfirmPopup(PoiMsg.js_msg.balloon.blog.msg.warning(),message,function(){callBack.checkoutCallBack();this.hide();},function(){callBack.yesCallBack();this.hide();},PoiMsg.js_msg.msg.checkout(),PoiMsg.js_msg.msg.checkoutLater());};CLIPTOO.savePopup.infoPopupCommercial=function(message,callBack){popupHandler.showInformationPopup(message,function(){callBack.yesCallBack();this.hide();});}
function EditBalloon(){this.container=Dom.get("balloonWriteContainer");this.oldPrice=0;this.imgCaptchaId="balloonCaptcha2";this.wordCaptchaInputId="balloonCaptchaWordVerificationId2";this.refrshCaptchaButtonId="balloonReviewCaptchaGetNewImage2";var container=this.container;if(!container){return;}
this.counterTimeout=null;var storiesTab=Dom.get("storyWriteBalloonTab");this.extendedInfoId="extendedInfoMenuTabId";this.tabs={info:Dom.get("infoMenuTabId"),infoBody:Dom.get("infoWriteBalloonTab"),video:Dom.get("videoMenuTabId"),videoBody:Dom.get("videoWriteBalloonTab"),photo:Dom.get("photoMenuTabId"),photoBody:Dom.get("photoWriteBalloonTab"),story:storiesTab?Dom.get("reviewMenuTabId"):null,storyBody:storiesTab,storyTabPrompt:Dom.get("storyTabPrompt"),advertisement:Dom.get("adsMenuTabId"),advertisementBody:Dom.get("advertisementWriteBalloonTab"),widget:Dom.get("widgetMenuTabId"),widgetBody:Dom.get("widgetWriteBalloonTab"),widgetTabPrompt:Dom.get("widgetTabPrompt"),rss:Dom.get("rssMenuTabId"),rssBody:Dom.get("rssWriteBalloonTab"),rssTabPrompt:Dom.get("rssTabPrompt"),owner:Dom.get("ownerMenuTabId"),ownerBody:Dom.get("ownerWriteBalloonTab"),audio:Dom.get("audioMenuTabId"),audioBody:Dom.get("audioWriteBalloonTab"),rating:Dom.get("ratingMenuTabId"),ratingBody:Dom.get("ratingWriteBalloonTab")};this.isCommercialFieldsMode=(ctx.getOrgProperty('eshopCommercialFields')=='on')?true:false;this.commercialFields={email:Dom.get("poiEMail"),emailIcon:Dom.get("poiEmailPriceIcon"),phone:Dom.get("poiTel"),phoneIcon:Dom.get("poiTelPriceIcon"),mobile:Dom.get("poiMobile"),mobileIcon:Dom.get("poiMobilePriceIcon"),url:Dom.get("poiUrl"),urlIcon:Dom.get("poiUrlPriceIcon")};var videoCheckbox=Dom.get("video-checkbox");var photoCheckbox=Dom.get("photo-checkbox");var widgetCheckbox=Dom.get("widget-checkbox");var rssCheckbox=Dom.get("rss-checkbox");var audioCheckbox=Dom.get("audio-checkbox");videoCheckbox.code=Balloon.VIDEO_TAB;photoCheckbox.code=Balloon.PHOTO_TAB;widgetCheckbox.code=Balloon.WIDGET_TAB;rssCheckbox.code=Balloon.RSS_TAB;audioCheckbox.code=Balloon.AUDIO_TAB;this.commercialTabsMap={2:{tab:videoCheckbox,price:null,label:Dom.getNextSibling(videoCheckbox),tabName:PoiMsg.js_msg.balloon.video.label()},3:{tab:photoCheckbox,price:null,label:Dom.getNextSibling(photoCheckbox),tabName:PoiMsg.js_msg.balloon.photo.label()},6:{tab:widgetCheckbox,price:null,label:Dom.getNextSibling(widgetCheckbox),tabName:CLIPTOO.utils.trim(Dom.get("widgetTabPrompt").innerHTML)},7:{tab:rssCheckbox,price:null,label:Dom.getNextSibling(rssCheckbox),tabName:CLIPTOO.utils.trim(Dom.get("rssTabPrompt").innerHTML)},9:{tab:audioCheckbox,price:null,label:Dom.getNextSibling(audioCheckbox),tabName:PoiMsg.js_msg.balloon.audioTabName()}};this.isCheckboxesShown=false;Event.addListener(videoCheckbox,"click",this.onClickBalloonCheckbox,this,true);Event.addListener(photoCheckbox,"click",this.onClickBalloonCheckbox,this,true);Event.addListener(widgetCheckbox,"click",this.onClickBalloonCheckbox,this,true);Event.addListener(rssCheckbox,"click",this.onClickBalloonCheckbox,this,true);Event.addListener(audioCheckbox,"click",this.onClickBalloonCheckbox,this,true);this.menuId="edit-balloon-menu";this.name=Dom.get("poiName");this.description=Dom.get("poiDescription");this.descriptionContainer=Dom.get("poiInfoDescriptionContainer");this.fieldsContainer=Dom.get("poiInfoFieldsContainer");this.descriptionEditorContainer=Dom.get("descriptionEditor");this.descriptionEditorTextarea=Dom.get("descriptionEditorTextarea");this.descriptionEditorCollapser=Dom.get("poiDescriptionEditorCollapser");this.descriptionEditorCollapserSpan=Dom.get("poiDescriptionEditorCollapserSpan");this.address=Dom.get("poiAddress");this.additionalAddress=Dom.get("additionalAddress");this.locationId="poiLocation";this.phone=Dom.get("poiTel");this.mobile=Dom.get("poiMobile");this.url=Dom.get("poiUrl");this.email=Dom.get("poiEMail");this.closeBalloonId="writeBalloonCloseBtn";if(this.tabs.story){var storyContainer=Dom.get("poiStory");this.stories={container:storyContainer,name:storyContainer.getElementsByTagName("div")[1],date:storyContainer.getElementsByTagName("div")[2],editBtn:storyContainer.getElementsByTagName("div")[3],deleteBtn:storyContainer.getElementsByTagName("div")[4],content:storyContainer.getElementsByTagName("div")[5],entryId:null,noStory:Dom.get("noStoriesMsg2"),addStoryBtn:Dom.get("addNewStoryLink2"),goToBlog:Dom.get("gotoStoryLink2"),richEditorId:"storyRichEditor2",storyDescriptionId:"blogEntryDescription2",storyFormId:"EditBlogPostForm2",storyTitleId:"blogEntryTitle2",gotoStoriesListId:"gotoEntriesList2",entryPostId:"entryPost2",entryId:"entryId2"};this.stories.readMore=this.stories.content.getElementsByTagName("a")[0];}
this.poiId="editedPoiId";this.advertisementContainer=Dom.get("advertisementWriteContainer");this.poi=null;this.poiMoved=false;this.maxDscriptionLength=2500;this.videoComponent=new EditVideoComponent();this.photoComponent=new EditPhotoComponent();this.embeddedObjectComponent=new EditEmbeddedObjectComponent();this.sharingOwnershipComponent=new SharingOwnershipComponent();this.audioComponent=new EditAudioComponent();this.ratingComponent=new RatingComponent(this);this.descriptionEditor=new BalloonDescriptionEditor(this);this.descriptionEditor.richEditor.subscribe('beforeEditorKeyPress',this.onKeyPressTextCounter,this,true);this.descriptionEditor.richEditor.subscribe('beforeEditorKeyUp',this.onKeyUpTextCounter,this,true);this.descriptionEditor.richEditor.subscribe('editorMouseDown',this.onMouseClickTextCounter,this,true);this.isBigEditorMode=null;this.editorSimpleSize=null;this.editorComplexSize=null;this.beforeOpenCreateBalloon=new YAHOO.util.CustomEvent("onBeforeOpenCreateBalloon",this);this.beforeShowInfoTab=new YAHOO.util.CustomEvent("onBeforeShowInfoTab",this);this.fileLayerUploadComplete=new YAHOO.util.CustomEvent("onFileLayerUploadComplete",this);this.poiTypeHandlerComponent=new PoiTypeHandlerComponent();this.beforeOpenCreateBalloon.subscribe(this.poiTypeHandlerComponent.onBeforeOpenCreateBalloon,this.poiTypeHandlerComponent,true);this.beforeShowInfoTab.subscribe(this.poiTypeHandlerComponent.onBeforeOpenInfoTab,this.poiTypeHandlerComponent,true);this.fileLayerUploadComplete.subscribe(this.poiTypeHandlerComponent.onChangeType,this.poiTypeHandlerComponent,true);this._confLayerUploader();this.oldRoute=null;this.routeUploader=null;this.layerUploader=Dom.get("poi-route-uploader");this.layerFile=Dom.get("poi-layer-file");this.layerUploaderHolder=Dom.get("poi-layer-uploader-holder");this.poiInfoFields=Dom.get("poiInfoFieldsContainer");this.confirmPopup=CLIPTOO.confirmPopup;this.constructor.superclass.constructor.superclass.constructor.apply(this,arguments);};YAHOO.lang.extend(EditBalloon,Balloon);EditBalloon.prototype.attachHandlers=function(){this.constructor.superclass.constructor.superclass.attachHandlers.apply(this,arguments);Event.addListener("catOpenBtnId","click",this._showHideCategoryPicker,this,true);Event.addListener(this.descriptionEditorCollapserSpan,"click",this._showSimpleEditor,this,true);Event.addListener("poiUrl","keydown",this._focusRichEditorAfterPoiUrl,this,true);Event.addListener("poiName","keydown",this._focusRichEditorAfterPoiName,this,true);};EditBalloon.prototype._showCategoryPicker=function(){var btn=Dom.get("catOpenBtnId");Dom.get("generalPoiInfo").style.display="none";this.categoriesList.showCategoryPicker();Dom.get("catPickerHint").style.display="";btn.firstChild.innerHTML=PoiMsg.js_msg.category.picker.close();};EditBalloon.prototype._hideCategoryPicker=function(){var btn=Dom.get("catOpenBtnId");Dom.get("categoryPicker").style.display="none";Dom.get("generalPoiInfo").style.display="";Dom.get("catPickerHint").style.display="none";btn.firstChild.innerHTML=PoiMsg.js_msg.category.picker.open();};EditBalloon.prototype._showHideCategoryPicker=function(){if(Dom.get("generalPoiInfo").style.display=="none"){this._hideCategoryPicker();}
else{this._showCategoryPicker();}};EditBalloon.prototype._focusRichEditorAfterPoiUrl=function(event){if(event.keyCode==9&&this.pointType==GlobalProperties.POI){Event.preventDefault(event);Event.stopPropagation(event);this.descriptionEditor.richEditor._focusWindow();}};EditBalloon.prototype._focusRichEditorAfterPoiName=function(event){if(event.keyCode==9&&(this.pointType==GlobalProperties.ROUTE||this.pointType==GlobalProperties.POA)){Event.preventDefault(event);Event.stopPropagation(event);this.descriptionEditor.richEditor._focusWindow();}};EditBalloon.prototype._showSimpleEditor=function(){if(this.descriptionEditorCollapser.className=="poi-collapse-editor-button"){Dom.get('poiInfoContainer').style.display="none";this.isBigEditorMode=true;this.descriptionEditor.richEditor.setAttributes({height:this.editorComplexSize+"px"});this.descriptionEditor.richEditor.toolbar.collapse(false);this.descriptionEditorCollapserSpan.innerHTML=PoiMsg.js_msg.balloon.disableFormatting();Dom.addClass(this.descriptionEditorCollapser,"description-editor-mode");}
else{this.isBigEditorMode=false;Dom.get('poiInfoContainer').style.display="";this.descriptionEditor.richEditor.setAttributes({height:this.editorSimpleSize+"px"});this.descriptionEditor.richEditor.toolbar.collapse();this.descriptionEditorCollapserSpan.innerHTML=PoiMsg.js_msg.balloon.enableFormatting();Dom.removeClass(this.descriptionEditorCollapser,"description-editor-mode");}};EditBalloon.prototype._setCurrentEditorHeight=function(){if(this.isBigEditorMode){this.descriptionEditor.richEditor.setAttributes({height:this.editorComplexSize+"px"});}
else{this.descriptionEditor.richEditor.setAttributes({height:this.editorSimpleSize+"px"});}};EditBalloon.prototype._confLayerUploader=function(){if(!CLIPTOO.utils.isFlashPlayerCompatible()){return;}
var currentLocation=window.location;YAHOO.widget.Uploader.SWFURL=currentLocation.protocol+"//"+currentLocation.host+GlobalProperties.HOST+"js/yui/uploader/assets/uploader.swf";var uploader=new YAHOO.widget.Uploader("poi-route-uploader");var that=this;var onUploaderContentReady=function(){var filesExtentions=[];if(that.pointType==GlobalProperties.POA){filesExtentions.push({description:"Area",extensions:"*.kml;*.kmz"});}
if(that.pointType==GlobalProperties.ROUTE){filesExtentions.push({description:"Routes",extensions:"*.gpx"});}
uploader.setAllowMultipleFiles(false);uploader.setFileFilters(filesExtentions);};uploader.addListener('contentReady',onUploaderContentReady);var currentLocation=window.location;var rootHost=currentLocation.protocol+"//"+currentLocation.host;function onFileSelectCallback(fileList){if(fileList){for(var i in fileList){var fileName=CLIPTOO.utils.getFileName(fileList[i]);if(fileList[i].size>parseInt(PoiMsg.js_msg.upload.maxFileSize())){popupHandler.showErrorPopup(PoiMsg.js_msg.upload.maxSizeError(CLIPTOO.utils.getFileExtension(fileList[i])));return;}
if(fileName.length>parseInt(PoiMsg.js_msg.upload.maxFileNameLength())){popupHandler.showErrorPopup(PoiMsg.js_msg.upload.maxSizeFileNameError());return;}
popupHandler.showPleaseWait();uploader.upload(i,GlobalProperties.HOST+"uploadPointOfArea.action","GET",{"userUid":ctx.getCurrentUserUid()});}
uploader.clearFileList();}};function onFileSelectPoa(event){var fileList=event.fileList;if(that.pointType==GlobalProperties.ROUTE){popupHandler.showConfirmPopup(PoiMsg.js_msg.balloon.blog.msg.warning(),PoiMsg.js_msg.balloon.gi.route.movemessage(),function(){onFileSelectCallback(fileList);this.hide();},function(){this.hide();});}
else{onFileSelectCallback(fileList);}};function uploadPoaCompleteData(event){var jsonWithLink=YAHOO.lang.JSON.parse(event.data);var layerLink=jsonWithLink.layerLink;if(that.pointType==GlobalProperties.POA){Dom.get("poiLayerLink").value=layerLink;that._onLayerLoad(layerLink);}
if(that.pointType==GlobalProperties.ROUTE){ctx.addAdditionalPoi(that.poi);that._onRouteLoad(layerLink);}
that.fileLayerUploadComplete.fire();};uploader.subscribe('fileSelect',onFileSelectPoa);uploader.subscribe('uploadCompleteData',uploadPoaCompleteData);};EditBalloon.prototype.revertRoute=function(){if(this.oldRoute){var poiId=(typeof this.poi.id=="undefined"||this.poi.id==null)?GlobalProperties.NEW_ROUTE_ID:this.poi.id;routes[poiId]=this.oldRoute;}};EditBalloon.prototype.updateRoute=function(poiId){if(this.oldRoute){this.oldRoute.clear();this.oldRoute=null;}
var route=routes[poiId];var routeLink=route.url;var layerDownloader=Dom.get("poi-layer-file");layerDownloader.href=routeLink;layerDownloader.innerHTML=routeLink.substring(routeLink.lastIndexOf("/")+1,routeLink.length);if(this.name.value==""&&route.name){this.name.value=route.name;}
if(this.description.value==""&&route.description){var description=route.description;this.description.value=description;this.descriptionEditor.setEditedText(description);}
Dom.get("poiLayerLink").value=routeLink.substring((routeLink.indexOf("content")-1),routeLink.length);};EditBalloon.prototype._onRouteLoad=function(layerLink){var currentLocation=window.location;var routeLink=currentLocation.protocol+"//"+currentLocation.host+layerLink;var poiId=(typeof this.poi.id=="undefined"||this.poi.id==null)?GlobalProperties.NEW_ROUTE_ID:this.poi.id;if(routes[poiId]){this.oldRoute=routes[poiId];}
Poi.getMap().showRoute(poiId,true,routeLink);popupHandler.hidePleaseWait();};EditBalloon.prototype._onLayerLoad=function(layerLink){var map=Poi.getMap();var poaId=(this.poi.id)?this.poi.id:GlobalProperties.NEW_POA_ID;map.removeOverlayForPoa(poaId);map.showPoa(poaId,layerLink);this.fileLayerUploadComplete.fire();popupHandler.hidePleaseWait();};EditBalloon.prototype._onPoiInfoCome=function(data,poi,newPoint){var json=YAHOO.lang.JSON.parse(data.responseText);var poiGeneralInfo=json.poiGeneralInfo;if(poi&&typeof poi.categoriesIds!="object"){poi=poisSelector.parsePoi(poi);}
var expiredDate=null;var isExpired=false;if(!newPoint){this.selectCheckedBalloonCheckbox(poiGeneralInfo);var address=poiGeneralInfo.location.split(',');if(address&&address.length>0&&address!=""){Dom.get("poiCity").value=address[address.length-1];}else{Dom.get("poiCity").value='';}
Dom.get("additionalAddress").value=poiGeneralInfo.additionalAddress||"";Dom.get("poiAddress").value=poiGeneralInfo.address;Dom.get("poiZipCode").value=json.zipCode||"";if(poiGeneralInfo.widgetTabTitle&&poiGeneralInfo.widgetTabTitle!=''){this.tabs.widgetTabPrompt.innerHTML=poiGeneralInfo.widgetTabTitle;CLIPTOO.utils.shrinkOneRowTextByWidth(this.tabs.widgetTabPrompt,18,45,15);this.tabs.widgetTabPrompt.title=poiGeneralInfo.widgetTabTitle;}
if(poiGeneralInfo.rssTabTitle&&poiGeneralInfo.rssTabTitle!=''){this.tabs.rssTabPrompt.innerHTML=poiGeneralInfo.rssTabTitle;CLIPTOO.utils.shrinkOneRowTextByWidth(this.tabs.rssTabPrompt,18,45,15);this.tabs.rssTabPrompt.title=poiGeneralInfo.rssTabTitle;}
document.title=poiGeneralInfo.name+" - "+ctx.getOriginalTitle();if(this.ratingComponent){this.ratingComponent.isEnabledVote=false;this.ratingComponent.setRate(poiGeneralInfo.rate);}}
Dom.get("poiTel").value=json.phone||"";Dom.get("poiMobile").value=json.mobile||"";Dom.get("poiEMail").value=json.email||"";Dom.get("poiUrl").value=json.url||"";Dom.get("poiLayerLink").value=poiGeneralInfo.layerLink;var isPaid=!!poiGeneralInfo.endDate&&(poiGeneralInfo.notPaidCatIds!=null||poiGeneralInfo.notPaidCatIds!='');if(isPaid){expiredDate=new Date(poiGeneralInfo.endDate);isExpired=expiredDate<new Date();}
if(isPaid&&!isExpired){var promptPrefix=PoiMsg.js_msg.balloon.commercialCategory.location();if(this.isCommercialFieldsMode){promptPrefix=PoiMsg.js_msg.balloon.commercialCategory.conactDetails();}
Dom.get("payment_info").innerHTML=promptPrefix+PoiMsg.js_msg.balloon.commercialCategory.publishTill(CLIPTOO.utils.converDateToString(expiredDate));Dom.get("euroSign").style.display="none";Dom.get("poiPriceAmount").style.display="none";}else{var promptPrefix=PoiMsg.js_msg.balloon.commercialCategory.locationIs();if(this.isCommercialFieldsMode){promptPrefix=PoiMsg.js_msg.balloon.commercialCategory.conactDetailsAre();}
Dom.get("euroSign").style.display="block";Dom.get("poiPriceAmount").style.display="block";Dom.get("payment_info").innerHTML=promptPrefix+PoiMsg.js_msg.balloon.commercialCategory.baloonBottom();}
this.poi={id:poi.id,editable:poi.editable,latitude:poi.latitude,longitude:poi.longitude,name:poi.name,description:poiGeneralInfo.description,address:poiGeneralInfo.address,additionalAddress:poiGeneralInfo.additionalAddress,location:poiGeneralInfo.location,categoriesIds:poi.categoriesIds.join(","),mainCategoryId:poi.mainCategoryId,layerLink:poiGeneralInfo.layerLink,advertisementBasisCM:poi.advertisementBasisCM,phone:json.phone||"",url:json.url||"",mobile:json.mobile||"",zipCode:json.zipCode||"",email:json.email||"",isPaid:isPaid,isExpired:isExpired,expiredDate:expiredDate,balloonTabsInfo:poi.balloonTabsInfo,balloonCheckedTabsInfo:poiGeneralInfo.balloonCheckedTabsInfo,ownerShipNeeded:poiGeneralInfo.ownerShipNeeded,notPaidCatIds:poiGeneralInfo.notPaidCatIds};this.categoriesList.setCategories(poi.mainCategoryId,poi.categoriesIds);if(this.categoriesList.hasCommertialCategories()){this.oldPrice=parseFloat(this.categoriesList._calculateTotalPrice());}
else{this.oldPrice=0;}
if(this.poi.notPaidCatIds&&this.poi.notPaidCatIds!=''){var idx=this.poi.notPaidCatIds.indexOf(',',0);this.categoriesList.setCategories((idx==-1)?this.poi.notPaidCatIds:this.poi.notPaidCatIds.substr(0,idx),this.poi.notPaidCatIds.split(','));}
this.descriptionEditor.setEditedText(poiGeneralInfo.description);this.description.value=poiGeneralInfo.description;this.checkTabsVisibility();popupHandler.hidePleaseWait();};EditBalloon.prototype.initInfoForPoi=function(poi,newPoint){var poiId=poi.id;this.name.value=poi.name;this.description.value="";this.isBigEditorMode=false;this.descriptionEditorCollapser.className="poi-collapse-editor-button";this.descriptionEditorContainer.style.display="block";this.descriptionEditor.richEditor.toolbar.collapse();Dom.get("poiDescriptionCount").innerHTML="";Dom.get("poiDescriptionMax").innerHTML="";this.resetBalloonCheckbox();Dom.get(this.poiId).value=poiId;if(!newPoint){Dom.get("editedPoiLatitude").value=poi.latitude;Dom.get("editedPoiLongitude").value=poi.longitude;this.selectCheckedBalloonCheckbox(poi);}
else{Dom.get("editedPoiLatitude").value=newPoint.lat();Dom.get("editedPoiLongitude").value=newPoint.lng();this._initAddress();}
ctx.setElementToFocus(this.name);var that=this;UIRequest("getPoiGeneralInfo.action","id="+poiId,function(data){that._onPoiInfoCome(data,poi,newPoint);});};EditBalloon.prototype._movePoiMarker=function(point){if(point){ctx.getEditBalloon().changeLatLng(point);}};EditBalloon.prototype._onAddressChanged=function(){var address=Dom.get("poiCity").value+", "+Dom.get("poiAddress").value;CLIPTOO.poi.map.types.getLatLng(address,this._movePoiMarker,this);};EditBalloon.prototype._initAddressCallback=function(geodata){Dom.get(this.locationId).value=geodata.address;var address=geodata.address.split(',');if(address&&address.length>0){Dom.get("poiCity").value=address[address.length-1];}
Dom.get("poiAddress").value=geodata.street;Dom.get("poiZipCode").value=geodata.zipCode;popupHandler.hidePleaseWait();}
EditBalloon.prototype._initAddress=function(searchedAddress){popupHandler.showPleaseWait();CLIPTOO.poi.map.types.geocode(new GLatLng(Dom.get('editedPoiLatitude').value,Dom.get('editedPoiLongitude').value),searchedAddress,this._initAddressCallback,this);};EditBalloon.prototype.isAutosaveNeeded=function(balloon,showTabCallback){var canChangeTab=true;if(balloon.isNeededToSavePoi()){balloon.savePoi(showTabCallback);canChangeTab=false;return;}
var sharedComponent=balloon.sharingOwnershipComponent;if(sharedComponent.checkForChange()==true){sharedComponent.confirmAndGoAnotherTab(sharedComponent,PoiMsg.js_msg.balloon.information.informationBeforeChangeTab(),showTabCallback);canChangeTab=false;return;}
if(!balloon.isCommercialFieldsMode&&balloon.isNeededToSaveCommercialTabs()){this.updateBalloonTabs(showTabCallback);canChangeTab=false;return;}
if(canChangeTab){showTabCallback();}};EditBalloon.prototype.onUpdateTabs=null;EditBalloon.prototype.updateBalloonTabs=function(showTabCallback){var checkedTabs=this.getCheckedBalloonCheckbox();var poiId=this.poi.id;var that=this;UIRequest("updateBalloonTabsInfo.action","&id="+poiId+((checkedTabs)?"&balloonCheckedTabsInfo="+checkedTabs:""),function(data){var json=YAHOO.lang.JSON.parse(data.responseText);if(json.tabsUpdated){that.poi.balloonCheckedTabsInfo=that.getCheckedBalloonCheckbox();}
if(showTabCallback){showTabCallback();}
if(that.onUpdateTabs){that.onUpdateTabs(that.poi);}});};EditBalloon.prototype.showInfoTab=function(poi){this.beforeShowInfoTab.fire();var canChangeTab=true;var that=this;var sharedComponent=this.sharingOwnershipComponent;if(sharedComponent.checkForChange()==true){sharedComponent.confirmAndGoAnotherTab(sharedComponent,PoiMsg.js_msg.balloon.ownershipConfirm(),function(){that.constructor.superclass.constructor.superclass.showInfoTab.apply(that,arguments);});canChangeTab=false;}
if(!this.isCommercialFieldsMode&&this.isNeededToSaveCommercialTabs(poi)&&arguments.callee.caller==this.delegateClickEvent){this.updateBalloonTabs(function(){that.constructor.superclass.constructor.superclass.showInfoTab.apply(that,arguments);});canChangeTab=false;}
if(canChangeTab){this.constructor.superclass.constructor.superclass.showInfoTab.apply(this,arguments);this.name.select();}};EditBalloon.prototype.showPhotoTab=function(){var balloon=this;if(this.isCheckboxesShown){this.photoComponent.commercialTabHeightCorrection=GlobalProperties.COMMERCIAL_PHOTO_PLAYER_HEIGHT_CORRECTION;Dom.addClass(this.tabs.photoBody,"commercial-tab");}
else{this.photoComponent.commercialTabHeightCorrection=0;Dom.removeClass(this.tabs.photoBody,"commercial-tab");}
this.isAutosaveNeeded(balloon,function(){balloon.constructor.superclass.constructor.superclass.showPhotoTab.apply(balloon,[]);});};EditBalloon.prototype.showVideoTab=function(){var balloon=this;if(this.isCheckboxesShown){this.videoComponent.commercialTabHeightCorrection=GlobalProperties.COMMERCIAL_YOUTUBE_PLAYER_HEIGHT_CORRECTION;Dom.addClass(this.tabs.videoBody,"commercial-tab");}
else{this.videoComponent.commercialTabHeightCorrection=0;Dom.removeClass(this.tabs.videoBody,"commercial-tab");}
this.isAutosaveNeeded(balloon,function(){balloon.constructor.superclass.constructor.superclass.showVideoTab.apply(balloon,arguments);});};EditBalloon.prototype.showAdvertisementTab=function(){var balloon=this;this.isAutosaveNeeded(balloon,function(){balloon.constructor.superclass.constructor.superclass.showAdvertisementTab.apply(balloon,arguments);});};EditBalloon.prototype.showStoryTab=function(addStory){var balloon=this;this.isAutosaveNeeded(balloon,function(){balloon.constructor.superclass.constructor.superclass.showStoryTab.apply(balloon,[addStory]);});};EditBalloon.prototype.showWidgetTab=function(){var balloon=this;this.isAutosaveNeeded(balloon,function(){balloon.constructor.superclass.constructor.superclass.showWidgetTab.apply(balloon,arguments);});};EditBalloon.prototype.showRssTab=function(){var balloon=this;this.isAutosaveNeeded(balloon,function(){balloon.constructor.superclass.constructor.superclass.showRssTab.apply(balloon,arguments);});};EditBalloon.prototype.showAudioTab=function(){var balloon=this;this.isAutosaveNeeded(balloon,function(){balloon.constructor.superclass.constructor.superclass.showAudioTab.apply(balloon,arguments);});};EditBalloon.prototype.showRatingTab=function(callback){var balloon=this;this.isAutosaveNeeded(balloon,function(){balloon.constructor.superclass.constructor.superclass.showRatingTab.apply(balloon,arguments);});}
EditBalloon.prototype.showOwnerTab=function(){var canChangeTab=true;var that=this;if(this.isNeededToSavePoi()){this.savePoi(function(){that.constructor.superclass.constructor.superclass.showOwnerTab.apply(that,[]);});canChangeTab=false;}
if(!this.isCommercialFieldsMode&&this.isNeededToSaveCommercialTabs()){this.updateBalloonTabs(function(){that.constructor.superclass.constructor.superclass.showOwnerTab.apply(that,[]);});canChangeTab=false;}
if(canChangeTab){this.constructor.superclass.constructor.superclass.showOwnerTab.apply(this,arguments);}};EditBalloon.prototype.onClose=null;EditBalloon.prototype._onCloseHanler=function(){document.title=ctx.getOriginalTitle();this.categoriesList.setCategories();this._hideCategoryPicker();this.balloonWidgetCode="";this.tabs.rssTabPrompt.innerHTML=PoiMsg.js_msg.balloon.rss();this.tabs.rssTabPrompt.title=PoiMsg.js_msg.balloon.rss();if(!!this.onClose){this.onClose();}};EditBalloon.prototype.doNotSaveAfterClose=function(){this._onCloseHanler();};EditBalloon.prototype.saveAfterClose=function(){var that=this;this.savePoi(function(){that._onCloseHanler();});};EditBalloon.prototype.close=function(){if(!this.container||!this.isShown()){return;}
var that=this;var poiId=this.poi.id;var checkPrices=function(withoutConfirm){UIRequest("checkPrices.action","id="+poiId,function(data){if(withoutConfirm){UIRequest("updatePoiCommercialData.action","id="+poiId,function(data){if(that.onPoiSaved){that.onPoiSaved();}
that._onCloseHanler();return;});return;}
var callBacks={yesCallBack:function(){UIRequest("updatePoiCommercialData.action","id="+poiId,function(data){if(that.onPoiSaved){that.onPoiSaved();}
that._onCloseHanler();return;});},noCallBack:function(){UIRequest("cancelUpdateCommercialData.action","id="+poiId,function(data){if(that.onPoiSaved){that.onPoiSaved();}
that._onCloseHanler();return;});},checkoutCallBack:function(){UIRequest("updatePoiCommercialData.action","id="+poiId,function(data){location.href=GlobalProperties.CART_HOST+"?commercialPoisIds="+that.poi.id;});}}
var json=YAHOO.lang.JSON.parse(data.responseText);var forPay=json.priceDifference.forPay;if(forPay==0)
callBacks.yesCallBack();if(forPay<0){savePopup.confirmPopup(PoiMsg.js_msg.balloon.commercialCategory.notRefunded(),callBacks);}
if(forPay>0){var message=PoiMsg.js_msg.balloon.commercialCategory.additionalPayment(CLIPTOO.utils.formatPrice(forPay));if(Dom.get("pageName").value=="POICartPage"){savePopup.infoPopupCommercial(message,callBacks);}else{savePopup.confirmPopupCommercial(message,callBacks);}}
return;});}
var isPaidUpdate=this.categoriesList.hasCommertialCategories()&&this.poi.balloonTabsInfo>0;if(isPaidUpdate){if(this.isNeededToSavePoi()){var callBacks={yesCallBack:function(){that.savePoi(checkPrices);},noCallBack:function(){that._onCloseHanler();}}
savePopup.confirmPopup(PoiMsg.js_msg.balloon.information.informationBeforeChangeTab(),callBacks);return;}
if(this.isNeededToSaveCommercialTabs()){var callBacks={yesCallBack:function(){that.updateBalloonTabs(checkPrices);},noCallBack:function(){that._onCloseHanler();}}
savePopup.confirmPopup(PoiMsg.js_msg.balloon.information.informationBeforeChangeTab(),callBacks);return;}
if(this.sharingOwnershipComponent.checkForChange()==true){var callBacks={yesCallBack:function(){that.sharingOwnershipComponent.saveOwnerTab(checkPrices);},noCallBack:function(){that._onCloseHanler();}}
savePopup.confirmPopup(PoiMsg.js_msg.balloon.information.informationBeforeChangeTab(),callBacks);return;}
checkPrices(true);return;}
var showPaymentMessage=(!this.poi.isPaid||this.poi.isExpired)&&(this.categoriesList.hasCommertialCategories()||this.categoriesList._calculateCurrentTotalPrice()>0);var isAdvertisementPaid=this.poi.advertisementBasisCM&&this.poi.advertisementBasisCM.payd&&(!this.poi.advertisementBasisCM.expired);if(this.isNeededToSavePoi()){if(this.poi.balloonTabsInfo>0&&!this.categoriesList.hasCommertialCategories()){var callBacks={yesCallBack:function(){that.savePoi();that._onCloseHanler();},noCallBack:function(){that._onCloseHanler();}}
savePopup.confirmPopup(PoiMsg.js_msg.balloon.commercialCategory.notRefunded(),callBacks);}else{this.confirmPopup.showPopupForSavePoi(that,showPaymentMessage,isAdvertisementPaid);}}
else{if(this.sharingOwnershipComponent.checkForChange()==true){this.confirmPopup.showPopupWithSharedOwner(this.sharingOwnershipComponent,function(){that._onCloseHanler();},showPaymentMessage);}
else
if(this.categoriesList.hasCommertialCategories()&&!this.isCommercialFieldsMode&&this.isNeededToSaveCommercialTabs()){this.confirmPopup.showPopupWithBalloonTabs(this,function(){that._onCloseHanler();},showPaymentMessage);}
else{that._onCloseHanler();}}};EditBalloon.prototype.isNeededToSaveCommercialTabs=function(){if(this.poi.id&&this.poi.id>0&&this.poi.balloonCheckedTabsInfo!=this.getCheckedBalloonCheckbox()){return true;}
return false;};EditBalloon.prototype.isNeededToSavePoi=function(){if(this.activeTab!=this.tabs.info){return false;}
if(Dom.get("editedPoiId").value==''){return true;}
var poi=this.poi;var categories1=this.categoriesList.getCategories();var categories2;if(!!poi.notPaidCatIds&&poi.notPaidCatIds!=''){categories2=poi.notPaidCatIds.split(",");}
else{categories2=poi.categoriesIds.split(",");}
var n=categories1.length;var m=categories2.length;if(n!=m){return true;}
for(var i=0;i<n;i++){var matched=false;for(var j=0;j<m;j++){if(categories2[j]==categories1[i]){matched=true;break;}}
if(!matched){return true;}}
if((Dom.get("poiName").value!=poi.name)||(Dom.get("poiAddress").value!=poi.address)||(Dom.get("additionalAddress").value!=poi.additionalAddress)||(Dom.get("poiCity").value!=poi.location)||(!!this.oldPoint&&(this.oldPoint.lat()!=poi.latitude||this.oldPoint.lng()!=poi.longitude))||(this.descriptionEditor.richEditor.saveHTML()!=poi.description)||(this.categoriesList.getMainCategory()!=poi.mainCategoryId)||((Dom.get("poiLayerLink").value!=poi.layerLink)&&(poi.layerLink!=null))||(Dom.get("poiTel").value!=poi.phone)||(Dom.get("poiMobile").value!=poi.mobile)||(Dom.get("poiZipCode").value!=poi.zipCode)||(Dom.get("poiEMail").value!=poi.email)||(Dom.get("poiUrl").value!=poi.url)){return true;}
if(poi.balloonCheckedTabsInfo!=this.getCheckedBalloonCheckbox()){return true;}
return false;};EditBalloon.prototype.onPoiSaved=null;EditBalloon.prototype._onPoiSaved=function(data,afterSavingCallback){var json=YAHOO.lang.JSON.parse(data.responseText);var poi=poisSelector.parsePoi(json.poi);var poiId=poi.id;if(routes[0]){routes[poiId]=routes[0];routes[0]=null;}
var balloonsPoi=this.poi;if(balloonsPoi.latitude!=poi.latitude||balloonsPoi.longitude!=poi.longitude){this.poiMoved=true;}
this.poi={id:poiId,latitude:poi.latitude,editable:poi.editable,longitude:poi.longitude,name:poi.name,description:poi.description,address:poi.address,additionalAddress:poi.additionalAddress,location:json.city,categoriesIds:poi.categoriesIds.join(","),mainCategoryId:poi.mainCategoryId,layerLink:poi.layerLink,balloonTabsInfo:poi.balloonTabsInfo,balloonCheckedTabsInfo:poi.balloonCheckedTabsInfo,advertisementBasisCM:balloonsPoi.advertisementBasisCM,notPaidCatIds:poi.notPaidCatIds,phone:Dom.get("poiTel").value,url:Dom.get("poiUrl").value,mobile:Dom.get("poiMobile").value,zipCode:Dom.get("poiZipCode").value,email:Dom.get("poiEMail").value};if(afterSavingCallback){afterSavingCallback();}
if(this.onPoiSaved){this.onPoiSaved(this.poi);}
popupHandler.hidePleaseWait();};EditBalloon.prototype.savePoi=function(afterSavingCallback){var poi=this.poi;var that=this;if((Dom.get("poiAddress").value!=poi.address&&Dom.get("poiAddress").value!='')||(Dom.get("poiCity").value!=poi.location&&Dom.get("poiCity").value!='')){var address=Dom.get("poiCity").value+", "+Dom.get("poiAddress").value;CLIPTOO.poi.map.types.getLatLng(address,function(point){if(point){that.changeLatLng(point);}
that.sendPoiForSaving(afterSavingCallback);},this);}else{that.sendPoiForSaving(afterSavingCallback);}}
EditBalloon.prototype.sendPoiForSaving=function(afterSavingCallback){var poiCommercial=this.categoriesList.hasCommertialCategories()||this.categoriesList._calculateCurrentTotalPrice()>0;Dom.get('poiCommercial').value=poiCommercial;popupHandler.showPleaseWait();Dom.get("poiMainCategoryId").value=this.categoriesList.getMainCategory();Dom.get("poiCategoryId").value=this.categoriesList.getCategories();var form=Dom.get('PoiForm');var descriptionImageList=this.descriptionEditor.richEditor._getDoc().getElementsByTagName("img");var n=descriptionImageList.length;for(var i=0;i<n;i++){var width=descriptionImageList[i].offsetWidth;var height=descriptionImageList[i].offsetHeight;var maxwidth=250
var maxheight=250;if(width>height){if(width>maxwidth){descriptionImageList[i].style.width=maxwidth+"px";descriptionImageList[i].style.height=parseInt((maxwidth*height)/width)+"px";}}else if(width<height){if(height>maxheight){descriptionImageList[i].style.width=parseInt((maxheight*width)/height)+"px";descriptionImageList[i].style.height=maxheight+"px";}}else{descriptionImageList[i].style.width=maxwidth+"px";descriptionImageList[i].style.height=maxheight+"px";}}
var fullText=this.descriptionEditor.richEditor.saveHTML();var currentLocation=window.location;var currentHostName=currentLocation.protocol+"//"+currentLocation.host;fullText=fullText.replace(/src=\"\/content\/photo/gi,'src="'+currentHostName+'/content/photo');fullText=fullText.replace(new RegExp('<span([^>]*)style="([^>]*)font-family:(.*?);([^>]*)">([\\s\\S]*?)<\/span>','gi'),'<span$1style="$2font-family:arial;$4">$5</span>');fullText=fullText.replace(new RegExp('<span([^>]*)style="([^>]*)font-size:(.*?);([^>]*)">([\\s\\S]*?)<\/span>','gi'),'<span$1style="$2font-size:12px;$4">$5</span>');var clearHTMLText=fullText.replace(/<(?!(img|em|a|span|strong|br)|(\/a|\/em|\/span|\/strong)>)[^>]*>/gi,"").replace(/(\t)/g,"").replace(/&(\w*?);/gi,"");this.descriptionEditor.setEditedText(clearHTMLText.replace(/(\n|\r\n)/g,"<br/>"));var noHTMLText=clearHTMLText.replace(/<.*?>/gi,"");var currentLength=noHTMLText.length;if(currentLength>this.maxDscriptionLength){popupHandler.hidePleaseWait();popupHandler.showValidationPopup(PoiMsg.js_msg.balloon.generalInfo.descriptionWarning());return false;}
this.description.value=clearHTMLText;if(validator.validateNamesBlock(form,'PoiCreateUpdate')){var that=this;form.description.value=clearHTMLText;if(!this.isCommercialFieldsMode&&(this.categoriesList.hasCommertialCategories()||this.categoriesList._calculateCurrentTotalPrice()>0)){Dom.get('balloonCheckedTabsInfo').value=this.getCheckedBalloonCheckbox();}
else{Dom.get('balloonCheckedTabsInfo').value=0;}
FormSubmit('PoiForm','savePoi.action',function(data){that._onPoiSaved(data,afterSavingCallback);});return true;}
else{popupHandler.hidePleaseWait();return false;}};EditBalloon.prototype.initCarousel=function(){if(!this.container){return;}
if(ctx.getOrgProperty("permitedCategories")){var userProfile=ctx.getUserProfile();var permitedCategoriesStr=(userProfile.isCategoryPermission)?userProfile.permittedCategoryIds:ctx.getOrgProperty("permitedCategories");var permittedCategoriesIds=permitedCategoriesStr.split(',');if(userProfile.isRegionPermission&&userProfile.excludedCategoryIds){var excludedCategoryIds=userProfile.excludedCategoryIds.split(',');var result=[];var n=permittedCategoriesIds.length;var m=excludedCategoryIds.length;for(var i=0;i<n;i++){var found=false;for(var j=0;j<m;j++){if(permittedCategoriesIds[i]==excludedCategoryIds[j]){found=true;break;}}
if(!found){result.push(permittedCategoriesIds[i]);}}
permittedCategoriesIds=result;}
this.categoriesList=new CLIPTOO.widget.CategoryList(permittedCategoriesIds,"carouselContainer","categoryPicker",this.poiTypeHandlerComponent.onChangeType);}};EditBalloon.prototype.makeVisible=function(){this.container.style.display="";CLIPTOO.utils.shrinkOneRowTextByWidth(this.tabs.widgetTabPrompt,18,45,15);};EditBalloon.prototype.changeLatLng=function(newPoint){if(!newPoint){return;}
Dom.get("editedPoiLatitude").value=newPoint.lat();Dom.get("editedPoiLongitude").value=newPoint.lng();};EditBalloon.prototype.checkTabsVisibility=function(){if(this.tabs.story){this.tabs.story.style.display="block";this.tabs.story.nextSibling.style.display="block";}
this.tabs.video.style.display="block";this.tabs.video.nextSibling.style.display="block";this.tabs.photo.style.display="block";this.tabs.photo.nextSibling.style.display="block";this.tabs.widget.style.display="block";this.tabs.widget.nextSibling.style.display="block";CLIPTOO.utils.shrinkOneRowTextByWidth(this.tabs.widgetTabPrompt,18,45,15);this.tabs.rss.style.display="block";this.tabs.rss.nextSibling.style.display="block";CLIPTOO.utils.shrinkOneRowTextByWidth(this.tabs.rssTabPrompt,18,45,15);if((typeof this.poi.ownerShipNeeded!='undefined'&&this.poi.ownerShipNeeded==false)||THEME_NAME=="landleven"){this.tabs.owner.style.display="none";this.tabs.owner.nextSibling.style.display="none";}
else{this.tabs.owner.style.display="block";this.tabs.owner.nextSibling.style.display="block";}
this.tabs.audio.style.display="block";this.tabs.audio.nextSibling.style.display="block";this.tabs.rating.style.display="block";this.tabs.rating.nextSibling.style.display="block";};EditBalloon.prototype.clearAndCountText=function(){var fullText=this.descriptionEditor.richEditor.saveHTML();var clearHTMLText=fullText;var fontFamilyReplacePattern=new RegExp('<span([^>]*)style="([^>]*)font-family:(.*?);([^>]*)">([\\s\\S]*?)<\/span>','gi');var fontSizeReplacePattern=new RegExp('<span([^>]*)style="([^>]*)font-size:(.*?);([^>]*)">([\\s\\S]*?)<\/span>','gi');clearHTMLText=clearHTMLText.replace(fontSizeReplacePattern,'<span$1style="$2font-size: 12px;$4">$5</span>');clearHTMLText=clearHTMLText.replace(fontFamilyReplacePattern,'<span$1style="$2font-family: arial;$4">$5</span>');var noHTMLText="";if(clearHTMLText.match(/<(?!(img|em|a|span|strong|br)|(\/a|\/em|\/span|\/strong)>)[^>]*>/gi)){clearHTMLText=clearHTMLText.replace(/<(?!(em|a|span|strong|br)|(\/a|\/em|\/span|\/strong)>)[^>]*>/gi,"").replace(/(\t)/g,"").replace(/&(\w*?);/gi,"");noHTMLText=clearHTMLText.replace(/<.*?>/gi,"");}
else{noHTMLText=clearHTMLText.replace(/<.*?>/gi,"").replace(/(\t)/g,"").replace(/&(\w*?);/gi,"");}
if(clearHTMLText!=fullText){this.descriptionEditor.setEditedText(clearHTMLText.replace(/(\n|\r\n)/g,"<br/>"));}
return noHTMLText.length;};EditBalloon.prototype.onKeyUpTextCounter=function(event){event=event.ev;if((event.keyCode!=8)&&(event.keyCode!=46)){return;}
var currentLength=this.clearAndCountText();this.putCountInHTML(this,currentLength);};EditBalloon.prototype.onMouseClickTextCounter=function(){var currentLength=this.clearAndCountText();this.putCountInHTML(this,currentLength);};EditBalloon.prototype.onKeyPressTextCounter=function(event){event=event.ev;if(YAHOO.env.ua.ie>=7&&(event.keyCode==8||event.keyCode==46)){return;}
else
if(YAHOO.env.ua.ie==0&&!event.charCode){return;}
var currentLength=this.clearAndCountText();currentLength++;if((currentLength)>this.maxDscriptionLength){Event.preventDefault(event);Event.stopPropagation(event);popupHandler.showValidationPopup(PoiMsg.js_msg.balloon.generalInfo.descriptionWarning());currentLength--;}
var that=this;var count=function(){that.putCountInHTML(that,currentLength);clearTimeout(that.counterTimeout);that.counterTimeout=null;}
if(!this.counterTimeout){this.counterTimeout=setTimeout(count,200);}
else{clearTimeout(this.counterTimeout);this.counterTimeout=setTimeout(count,200);}};EditBalloon.prototype.putCountInHTML=function(balloon,currentLength){var i18n=PoiMsg.js_msg.balloon.generalInfo;var maxLimit=balloon.maxDscriptionLength;var poiDescriptionMax=Dom.get("poiDescriptionMax");var poiDescriptionCount=Dom.get("poiDescriptionCount");poiDescriptionMax.innerHTML="&nbsp;"+i18n.of()+"&nbsp;"+maxLimit;poiDescriptionCount.innerHTML=maxLimit-currentLength;};EditBalloon.prototype.showBalloonCheckbox=function(checkBox){var checkBoxesToShow=ctx.getBalloonTabsPrices();if(!checkBoxesToShow){this.hideBalloonCheckbox();return;}
var paidTabs=this.poi.balloonTabsInfo;for(var index in checkBoxesToShow){this.commercialTabsMap[index].tab.style.visibility="visible";this.commercialTabsMap[index].label.style.visibility="visible";if((paidTabs!=-1)&&(paidTabs>>(16-index)&1)==1){this.commercialTabsMap[index].label.innerHTML=this.commercialTabsMap[index].tabName+" "+
PoiMsg.js_msg.balloon.commercialCategory.publishTill(CLIPTOO.utils.converDateToString(this.poi.expiredDate));}else{this.commercialTabsMap[index].price=checkBoxesToShow[index];this.commercialTabsMap[index].label.innerHTML=this.commercialTabsMap[index].tabName+" "+
PoiMsg.js_msg.balloon.commercialCategory.baloonBottomTabs()+"<span name='check-box-price'>"+" &euro;"+CLIPTOO.utils.formatPrice(checkBoxesToShow[index])+"</span>";}}
this.isCheckboxesShown=true;};EditBalloon.prototype.selectCheckedBalloonCheckbox=function(poi){if(poi.balloonCheckedTabsInfo==0){return;}
var checkedTabs=poi.balloonCheckedTabsInfo;for(var index in this.commercialTabsMap){if((checkedTabs>>(16-index)&1)==1){Dom.addClass(this.commercialTabsMap[index].tab,"active-balloon-checkbox");}}};EditBalloon.prototype.getCheckedBalloonCheckboxPrice=function(){var price=0;for(var index in this.commercialTabsMap){if(Dom.hasClass(this.commercialTabsMap[index].tab,"active-balloon-checkbox")){price+=this.commercialTabsMap[index].price;}}
return price;};EditBalloon.prototype.getCheckedBalloonCheckbox=function(){var code=1<<15;for(var index in this.commercialTabsMap){if(Dom.hasClass(this.commercialTabsMap[index].tab,"active-balloon-checkbox")){code=code+(1<<(16-index));}}
if(code==1<<15){return 0;}
return code;};EditBalloon.prototype.hideBalloonCheckbox=function(checkBox){for(var index in this.commercialTabsMap){this.commercialTabsMap[index].tab.style.visibility="hidden";this.commercialTabsMap[index].label.style.visibility="hidden";}
this.isCheckboxesShown=false;};EditBalloon.prototype.resetBalloonCheckbox=function(checkBox){for(var index in this.commercialTabsMap){Dom.removeClass(this.commercialTabsMap[index].tab,"active-balloon-checkbox");}};EditBalloon.prototype.onClickBalloonCheckbox=function(event){var checkBox=(event.target)?event.target:event.srcElement;var price=parseFloat(Dom.get("poiPriceAmount").innerHTML);if(Dom.hasClass(checkBox,"active-balloon-checkbox")){Dom.removeClass(checkBox,"active-balloon-checkbox");price-=this.commercialTabsMap[checkBox.code].price;}
else{Dom.addClass(checkBox,"active-balloon-checkbox");price+=this.commercialTabsMap[checkBox.code].price;}
Dom.get("poiPriceAmount").innerHTML=CLIPTOO.utils.formatPrice(price);};function IndexEditBalloon(){this.constructor.superclass.constructor.apply(this,arguments);this.initCarousel();};YAHOO.lang.extend(IndexEditBalloon,EditBalloon);IndexEditBalloon.prototype.goToExtended=function(){};IndexEditBalloon.prototype._onCloseHanler=function(){this.constructor.superclass.constructor.superclass.close.apply(this,arguments);var poi=this.poi;Poi.getMap().balloonClose();PoisList.unSelectAllPois();this.constructor.superclass._onCloseHanler.apply(this,arguments);var map=Poi.getMap();if(map.mode==map.MAP_POI_CREATING){ctx.getEasyCreatingForm().enable();}
var poiLatLng=new GLatLng(poi.latitude,poi.longitude);if(this.poiMoved&&!map.getBounds().containsLatLng(poiLatLng)){map.panTo(poiLatLng);}
ctx.setCurrentPoi(null);this.poiMoved=false;ctx.clearElementToFocus();};IndexEditBalloon.prototype.doNotSaveAfterClose=function(){var map=Poi.getMap();map.removeTemporary();this.constructor.superclass.doNotSaveAfterClose.apply(this,arguments);var poi=this.poi;if(this.oldPoint){poi.latitude=this.oldPoint.lat();poi.longitude=this.oldPoint.lng();this.oldPoint=null;}
var poiLatLng=new GLatLng(poi.latitude,poi.longitude);this.changeLatLng(poiLatLng);var mapBounds=Poi.getMap().getBounds();if(this.pointType==GlobalProperties.POA){var poaId=(poi.id)?poi.id:GlobalProperties.NEW_POA_ID;map.removeOverlayForPoa(poaId);if(poi.id){map.showPoa(poi.id,poi.layerLink);}}
else if(this.pointType==GlobalProperties.ROUTE){if(poi.id){map.removeRoute(poi.id);}
else{map.removeRoute(GlobalProperties.NEW_ROUTE_ID);}
if(poi.id&&poi.id!=GlobalProperties.NEW_ROUTE_ID&&mapBounds.containsLatLng(poiLatLng)){map.showRoute(poi.id,false,poi.layerLink);}}
if(!mapBounds.containsLatLng(poiLatLng)){poisSelector.deletePoiById(poi.id);PoisList.redraw();}};IndexEditBalloon.prototype._onPoiSaved=function(data,afterSavingCallback){var json=YAHOO.lang.JSON.parse(data.responseText);var poi=poisSelector.parsePoi(json.poi);var poiId=poi.id;var map=Poi.getMap();var filtered=poisSelector.isPoiFilteredByCategories(poi);poisSelector.changePoiCountInCategories(poi,false);poi.advertisementBasisCM=this.poi.advertisementBasisCM;if(this.poi.id!=null){poisSelector.replacePoi(poi);poisSelector.replacePoiForPoiList(poi);if(!filtered){ctx.addAdditionalPoi(poi);}
else{ctx.removeAdditionalPoi(poi.id);}
var marker=map.getMarkerForPoi(poiId);if(marker){marker.updateIcon(ctx.getCategories()[poi.mainCategoryId].code,poi);}
if(this.pointType==GlobalProperties.ROUTE){poisSelector.increasePoiCountInCategoriesIfNeed(poi);}}
else{ctx.addPoiWithSorting(poi);if(!filtered){ctx.addAdditionalPoi(poi);}
Dom.get(this.poiId).value=poiId;map.removeTemporary();if(this.pointType!=GlobalProperties.POA){gmapHandler.addMapMarker(map,poi);}else{map.updateOverlayForNewPoa(poi.id);}
poisSelector.addInformationAboutFoundPois();}
this.oldPoint=null;PoisList.redraw();this.constructor.superclass._onPoiSaved.apply(this,arguments);};IndexEditBalloon.prototype.savePoi=function(afterSavingCallback){if((this.poi.latitude!=null&&this.poi.longitude!=null)&&!Poi.getMap().isPermitedToCreateArea(new GLatLng(parseFloat(Dom.get("editedPoiLatitude").value),parseFloat(Dom.get("editedPoiLongitude").value)))){if(this.pointType==GlobalProperties.ROUTE){popupHandler.showErrorPopup(PoiMsg.js_msg.permissionDenied.route());}
else{popupHandler.showErrorPopup(PoiMsg.js_msg.permissionDenied.region());}
return false;}
this.constructor.superclass.savePoi.apply(this,arguments);};IndexEditBalloon.prototype._setDefaultValuesInCategoryPicker=function(){var filterElm=Dom.get("catFilterId");filterElm.className="default-input-title";filterElm.value=PoiMsg.js_msg.category.picker.filter();Dom.get("filterCleanId").style.visibility="hidden";var catGroupSelector=Dom.get("shownCategoryGroupId");catGroupSelector.value='-1';};IndexEditBalloon.prototype.showForNew=function(pointType,point,searchedAddress,link,name){this.pointType=pointType;var map=Poi.getMap();if(!map.isPermitedToCreateArea(point)&&this.pointType==GlobalProperties.POI){var mail=ctx.getOrgProperty('companyMail');var message;if(mail!==""){message=PoiMsg.js_msg.balloon.outofarea()+"<a href='mailto:"+mail+"'>"+mail+"</a>";}else{message=PoiMsg.js_msg.balloon.outofarea_s();}
popupHandler.showErrorPopup(message);map.removeTemporary();ctx.getEasyCreatingForm().enable();popupHandler.hidePleaseWait();return;}
this.initInfoForNewPoi(point,searchedAddress,link,name);this._prepareForNew();this.makeVisible();popupHandler.hidePleaseWait();};IndexEditBalloon.prototype._changeMapState=function(){var mapLayerControl=ctx.getMapLayersControl();if(mapLayerControl){mapLayerControl.hide();}
ctx.getZoomingControl().disable();var map=Poi.getMap();map.holdMapWithCursor("default");map.disable();}
IndexEditBalloon.prototype._prepareForNew=function(){this.beforeOpenCreateBalloon.fire();this.resetBalloonCheckbox();this.hideBalloonCheckbox();this.hideTabs();this.applyOrganizationPrompts();this.position();this._hideCategoryPicker();this._setDefaultValuesInCategoryPicker();var map=Poi.getMap();if(!this.container){map.removeTemporary();ctx.getEasyCreatingForm().enable();popupHandler.hidePleaseWait();return;}
this.showAdsIfExist(null);this._changeMapState();this.activateTab(this.tabs.info,this.tabs.infoBody);}
IndexEditBalloon.prototype.changeLatLng=function(newPoint){this.constructor.superclass.changeLatLng.apply(this,arguments);Poi.getMap().updateMarkerPosition(this.poi.id,newPoint);};IndexEditBalloon.prototype.showForDraggedPoi=function(poi,newPoint){if(!this.container){popupHandler.hidePleaseWait();return;}
this.point=poi;this.hideTabs();this.position();this._hideCategoryPicker();this._setDefaultValuesInCategoryPicker();this._hideCategoryPicker();this.showAdsIfExist(poi.advertisementBasisCM);Dom.get(this.poiId).value="";var poiId=poi.id;PoisList.selectPoi(poiId);this.poi={id:poiId};this.oldPoint=new GLatLng(poi.latitude,poi.longitude);poi.latitude=newPoint.lat();poi.longitude=newPoint.lng();this.activateTab(this.tabs.info,this.tabs.infoBody);this.initInfoForPoi(poi,newPoint);this.position();this.makeVisible();};IndexEditBalloon.prototype.initInfoForFirstPoi=function(poiPoint){var poiId=Dom.get(this.poiId).value;if(!poiId){poiId=this.poi.id;}
var poi=ctx.getActivePoi(poiId);if(poi&&poi.id!=0&&poi.mainCategoryId&&ctx.getCategories()[poi.mainCategoryId]){this.pointType=ctx.getCategories()[poi.mainCategoryId].categoryType;}
ctx.fixOriginalTitle(poi.name);this.showAdsIfExist(poi.advertisementBasisCM);this.isBigEditorMode=false;this.descriptionEditorCollapser.className="poi-collapse-editor-button";this.descriptionEditor.richEditor.setAttributes({height:"90px"});this.descriptionEditor.richEditor.toolbar.collapse();this.descriptionEditorContainer.style.display="block";this.poi={id:poiId,latitude:poi.latitude,longitude:poi.longitude,name:poi.name,description:Dom.get("poiDescription").value,address:Dom.get("poiAddress").value,additionalAddress:Dom.get("additionalAddress").value,location:Dom.get("poiCity").value,categoriesIds:poi.categoriesIds.join(","),mainCategoryId:poi.mainCategoryId,layerLink:poi.layerLink,advertisementBasisCM:poi.advertisementBasisCM,phone:Dom.get("poiTel").value,url:Dom.get("poiUrl").value,mobile:Dom.get("poiMobile").value,zipCode:Dom.get("poiZipCode").value,email:Dom.get("poiEMail").value,ownerShipNeeded:(this.tabs.owner.style.display!='none'),balloonCheckedTabsInfo:Dom.get("balloonCheckedTabsInfo").value};Dom.get('poiLocation').value=this.poi.location;this.categoriesList.setCategories(poi.mainCategoryId,poi.categoriesIds);this.initLayerDownloader(poi);this.activateTab(this.tabs.info,this.tabs.infoBody);ctx.setElementToFocus(this.name);this.checkTabsVisibility();var that=this;this.descriptionEditor.richEditor.on('editorContentLoaded',function(){var tabView=Dom.get("tabWritePar");var addStory=Dom.get("addStoryWritePar");that.showTab((tabView)?tabView.value:null,(addStory)?addStory.value:null,null);});};IndexEditBalloon.prototype.initLayerDownloader=function(poi){if(ctx.getCategories()[poi.mainCategoryId].categoryType==3){var layerDownloader=Dom.get("poi-layer-file");var layerLink=poi.layerLink;layerDownloader.href=layerLink;layerDownloader.innerHTML=layerLink.substring(layerLink.lastIndexOf("/")+1,layerLink.length);layerDownloader.style.display="";}};IndexEditBalloon.prototype.show=function(poi,tab){if(!Poi.getMap().isPermitedToCreateArea(new GLatLng(poi.latitude,poi.longitude))){popupHandler.showErrorPopup(PoiMsg.js_msg.permissionDenied.region());popupHandler.hidePleaseWait();return;}
this.point=poi;this._hideCategoryPicker();this._setDefaultValuesInCategoryPicker();if(poi&&poi.id!=0&&poi.mainCategoryId&&ctx.getCategories()[poi.mainCategoryId]){this.pointType=ctx.getCategories()[poi.mainCategoryId].categoryType;}
this._changeMapState();this.constructor.superclass.constructor.superclass.show.apply(this,arguments);this.poiTypeHandlerComponent.onBeforeOpenCreateBalloon();this.initLayerDownloader(poi);};IndexEditBalloon.prototype.initInfoForNewPoi=function(point,searchedAddress,link,name){Dom.get(this.poiId).value="";this.name.value=(name)?name:"";this.description.value="";this.isBigEditorMode=false;this.descriptionEditorCollapser.className="poi-collapse-editor-button";this.descriptionEditor.richEditor.setAttributes({height:"90px"});this.descriptionEditorContainer.style.display="block";this.descriptionEditor.richEditor.toolbar.collapse();this.descriptionEditor.setEditedText("");Dom.get("poiDescriptionCount").innerHTML="";Dom.get("poiDescriptionMax").innerHTML="";Dom.get("editedPoiLatitude").value=point.lat();Dom.get("editedPoiLongitude").value=point.lng();this.address.value="";Dom.get(this.locationId).value="";if(this.pointType!=GlobalProperties.POA){this._initAddress(searchedAddress);}
Dom.get("additionalAddress").value="";this.categoriesList.setCategories();Dom.get("poiLayerLink").value=(link)?link:"";Dom.get("poiTel").value="";Dom.get("poiMobile").value="";Dom.get("poiZipCode").value="";Dom.get("poiEMail").value="";Dom.get("poiUrl").value="";this.poi={id:null,latitude:point.lat(),longitude:point.lng(),name:"",description:"",address:"",additionalAddress:"",location:"",categoriesIds:"",mainCategoryId:"",layerLink:"",phone:"",url:"",mobile:"",zipCode:"",email:""};ctx.setElementToFocus(this.name);this.checkTabsVisibility();};IndexEditBalloon.prototype._initGotoStoriesLink=function(){var currentZoom=Poi.getMap().getZoom();if(currentZoom<10){currentZoom=10;}
this.constructor.superclass.constructor.superclass._initGotoStoriesLink.apply(this,[currentZoom]);}
IndexEditBalloon.prototype._initReadStoryLink=function(){var currentZoom=Poi.getMap().getZoom();if(currentZoom<10){currentZoom=10;}
this.constructor.superclass.constructor.superclass._initReadStoryLink.apply(this,[currentZoom]);}
CLIPTOO.createPackage('Poi.Tabs');CLIPTOO.Poi.Tabs.initTabs=function(){var myPoiTab=Dom.get("myPoiTab");Event.addListener("poiListTab","click",function(){if(myPoiTab==null){return;}
Dom.get("myPoiTab").className="";Dom.addClass("poiListTab","active");CLIPTOO.poi.cookie.create("only-my-pois","off");Dom.get("container_pois").style.visibility="visible";poisSelector.setPoisByCategoriesIdsAndCoordinatBound();});var myPoiTab=Dom.get("myPoiTab");if(myPoiTab){Event.addListener("myPoiTab","click",function(){Dom.removeClass("poiListTab","active");Dom.get("myPoiTab").className="active";CLIPTOO.poi.cookie.create("only-my-pois","on");Dom.get("container_pois").style.visibility="visible";poisSelector.setPoisByCategoriesIdsAndCoordinatBound(true);});}}
function CallbackHandler(){};CallbackHandler.isPoiIndex=function(){return Dom.get('container_pois');};(function(){var defaultMapType=ctx.getOrgProperty("defaultMapView");var CLIPTOO_UKRAINE;if(defaultMapType=="Ukraine"){CLIPTOO_UKRAINE=(function(){var copyCollection=new GCopyrightCollection('Візіком');var copyright=new GCopyright(1,new GLatLngBounds(new GLatLng(-90,-180),new GLatLng(90,180)),0,"©2010 Maps.Visicom.ua");copyCollection.addCopyright(copyright);var tilelayers=[new GTileLayer(copyCollection,3,17)];tilelayers[0].getTileUrl=function(gpoint,zoom){var y=Math.pow(2,zoom)-gpoint.y-1;var w=((gpoint.x+gpoint.y)%3)+1;return"http://tms"+w+".visicom.ua/1.0.3/world_ua/"+zoom+"/"+gpoint.x+"/"+y+".png";}
return new GMapType(tilelayers,new GMercatorProjection(18),"Візіком",{errorMessage:"No Visicom data available"});})();}
var supportedMaps=[];var labels=[];if(defaultMapType=="Ukraine"){supportedMaps.push({type:CLIPTOO_UKRAINE,label:PoiMsg.js_msg.map.mode.ukraine()})}
supportedMaps.push({type:G_NORMAL_MAP,label:PoiMsg.js_msg.map.mode.map()})
supportedMaps.push({type:G_SATELLITE_MAP,label:PoiMsg.js_msg.map.mode.satellite()})
supportedMaps.push({type:G_HYBRID_MAP,label:PoiMsg.js_msg.map.mode.hybrid()})
supportedMaps.push({type:G_PHYSICAL_MAP,label:PoiMsg.js_msg.map.mode.terrain()})
var googleGeocoder={geocode:function(point,searchedAddress,callback,scope){var result="";var street="";var zipCode="";geocoder.getLocations(point,function(location){if(location.Status.code==200){var region;var lastRegion='';var countRegions=0;if(location.Placemark[0].AddressDetails.Accuracy==5&&location.Placemark[1]){region=location.Placemark[0].AddressDetails.Country;if(region.AdministrativeArea){region=region.AdministrativeArea;}
if(region.SubAdministrativeArea){region=region.SubAdministrativeArea;}
if(region.Locality){region=region.Locality;}
if(region.DependentLocality){region=region.DependentLocality;}
if(region.PostalCode){zipCode=region.PostalCode.PostalCodeNumber;}
region=location.Placemark[1].AddressDetails.Country;}
else{region=location.Placemark[0].AddressDetails.Country;}
result=region.CountryName;if(region.AdministrativeArea){region=region.AdministrativeArea;result+=","+region.AdministrativeAreaName;lastRegion=region.AdministrativeAreaName;countRegions++;}
if(region.SubAdministrativeArea){region=region.SubAdministrativeArea;result+=","+region.SubAdministrativeAreaName;if(region.SubAdministrativeAreaName==lastRegion){countRegions++;}else{countRegions=0;}
lastRegion=region.SubAdministrativeAreaName;}
if(region.Locality){region=region.Locality;if(region.LocalityName==lastRegion){countRegions++;}else{countRegions=0;}
lastRegion=region.LocalityName;if(countRegions<=2){result+=","+region.LocalityName;}}
if(region.DependentLocality){region=region.DependentLocality;if(region.DependentLocalityName==lastRegion){countRegions++;}else{countRegions=0;}
lastRegion=region.DependentLocalityName;if(countRegions<=2){result+=","+region.DependentLocalityName;}}
if(searchedAddress){if(searchedAddress.streetAddress.length>0&&searchedAddress.streetAddress.indexOf(searchedAddress.addressLines[0])==0){street=searchedAddress.addressLines[0];}
else{street=searchedAddress.streetAddress;}}
else if(region.Thoroughfare){street+=region.Thoroughfare.ThoroughfareName;}
if(region.PostalCode){zipCode=region.PostalCode.PostalCodeNumber;}}
callback.apply(scope,[{address:result,street:street,zipCode:zipCode}]);popupHandler.hidePleaseWait();});},getLocations:function(result,callback,scope){var bounds={};var searchedAddress=result.addressLines.join(", ");geocoder.getLocations(searchedAddress,function(location){if(!location.Placemark){popupHandler.hidePleaseWait();return;}
var exData=location.Placemark[0].ExtendedData;bounds=exData?exData.LatLonBox:undefined;callback.apply(scope,[bounds]);});},getLatLng:function(searchedAddress,callback,scope){geocoder.getLatLng(searchedAddress,function(point){callback.apply(scope,[point]);});}}
var visicomGeocoder={geocode:function(point,searchedAddress,callback,scope){params="lat="+point.lat()+"&lng="+point.lng();UIRequest("visicomgeo.action",params,function(p_oRequest){var json=YAHOO.lang.JSON.parse(p_oRequest.responseText);callback.apply(scope,[{address:json.address,street:json.street.replace(/^\s+|\s+$/g,''),zipCode:""}]);});},getLocations:function(result,callback,scope){callback.apply(scope,[result.bounds]);},getLatLng:function(searchedAddress,callback,scope){params="searchStr="+searchedAddress.replace(',',"").replace(' вул.',"");UIRequest("visicomsearch.action",params,function(p_oRequest){var json=YAHOO.lang.JSON.parse(p_oRequest.responseText);var results=json.results;var point=null;if(results.length>0){point=new GLatLng(results[0].lat,results[0].lng);}
callback.apply(scope,[point]);});}}
CLIPTOO.poi.map.types={supported:supportedMaps,labels:labels,getMapTypes:function(){var mt=[];for(var i=0,n=supportedMaps.length;i<n;i++){mt.push(supportedMaps[i].type);}
return mt;},getMapTypeByCode:function(code){if(code=="Ukraine"){return CLIPTOO_UKRAINE};if(code=="Normal"){return G_NORMAL_MAP};if(code=="Satellite"){return G_SATELLITE_MAP};if(code=="Hybrid"){return G_HYBRID_MAP};if(code=="Terrain"){return G_PHYSICAL_MAP};return supportedMaps[0].type;},getMapTypeCodeByType:function(type){if(CLIPTOO_UKRAINE&&type==CLIPTOO_UKRAINE){return"Ukraine"};if(type==G_NORMAL_MAP){return"Normal"};if(type==G_SATELLITE_MAP){return"Satellite"};if(type==G_HYBRID_MAP){return"Hybrid"};if(type==G_PHYSICAL_MAP){return"Terrain"};return"Normal";},getMapTypeNumber:function(type){for(var i=0,n=supportedMaps.length;i<n;i++){if(supportedMaps[i].type==type){return i;}}},geocode:function(point,searchedAddress,callback,scope){var mapType=Poi.getMap().getCurrentMapType();if(mapType==CLIPTOO_UKRAINE){return visicomGeocoder.geocode(point,searchedAddress,callback,scope);}
return googleGeocoder.geocode(point,searchedAddress,callback,scope);},getLocations:function(searchedAddress,callback,scope){var mapType=Poi.getMap().getCurrentMapType();if(mapType==CLIPTOO_UKRAINE){return visicomGeocoder.getLocations(searchedAddress,callback,scope);}
return googleGeocoder.getLocations(searchedAddress,callback,scope);},getLatLng:function(searchedAddress,callback,scope){var mapType=Poi.getMap().getCurrentMapType();if(mapType==CLIPTOO_UKRAINE){return visicomGeocoder.getLatLng(searchedAddress,callback,scope);}
return googleGeocoder.getLatLng(searchedAddress,callback,scope);},getCurrentLocalSearch:function(callback,scope){var defaultMapTypeCode=CLIPTOO.poi.cookie.read("map-type");if(!defaultMapTypeCode){defaultMapTypeCode=ctx.getOrgProperty("defaultMapView");}
var mapType=CLIPTOO.poi.map.types.getMapTypeByCode(defaultMapTypeCode);if(mapType==CLIPTOO_UKRAINE){var visicomLocalSearch={scope:scope,callback:callback,execute:function(searchedAddress){var that=this;params="searchStr="+searchedAddress;UIRequest("visicomsearch.action",params,function(p_oRequest){var json=YAHOO.lang.JSON.parse(p_oRequest.responseText);that.results=json.results;if(that.callback){that.callback.apply(that.scope);}});}}
return visicomLocalSearch;}
var googleSearch=new google.search.LocalSearch();googleSearch.setResultSetSize(GSearch.LARGE_RESULTSET);googleSearch.setCenterPoint(new GLatLng(52.12337138625385,5.240478515625));googleSearch.setSearchCompleteCallback(scope,callback,[null]);return googleSearch;}}})();MapGeoFilter=function(){if(!Dom.get('geofilterContainer')){return false;}
this.roundPopup="jumpToRound";this.resultHint="jumpToQuestionHint";this.resultList="jumpToSearchResultListArea";this.nothingFoundHint="jumpToNothingFoundHint";this.disabler="jumpToDisabler";this.template='<div class="easyCreatingContainer">\
   <div id="jumpToNothingFoundHint" style="display: none;">'+PoiMsg.js_msg.search.nothingFound()+'</div>\
   <div id="jumpToQuestionHint" style="display: none;">'+PoiMsg.js_msg.search.specification()+'</div>\
   <span id="jumpToSearchResultListArea" style="display: none;"></span>\
   <div id="jumpToDisabler" class="easyCreatingDisabler" style="display: none;"></div>\
  </div>\
  <div id="jumpToRound" class="round-easy-creating-popup">\
   <div class="left-corner-easy-creating-popup"></div>\
   <div class="middle-easy-creating-popup"></div>\
   <div class="right-corner-easy-creating-popup"></div>\
  </div>';Dom.get('jumpToPopup').innerHTML=this.template;var configFilter={inputSearchField:Dom.get('geofilterField'),inputResetButton:Dom.get('georesetFilter'),inputFilterContainer:Dom.get('geofilterContainer')};this.gs=CLIPTOO.poi.map.types.getCurrentLocalSearch(this.googleSearchCallBack,this);var that=this;this.filter=CLIPTOO.Filter(function(event){var buttonName=null;if(YAHOO.env.ua.ie>=7){buttonName=(event)?event.srcElement.id:"";}else{buttonName=(event)?event.target.id:"";}
if((buttonName!="georesetFilter")){var isChanged=that.checkForChange();if(isChanged==true){that.confirmPopup(that,PoiMsg.js_msg.balloon.information.informationBeforeChangeTab());}else{if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/maptoolbar/geofilter_start_search");}
that.gs.execute(this.getSearchValue());}}else{that.hide();}},configFilter);this.attachHandlers();};MapGeoFilter.prototype.show=function(){Dom.get("jumpToPopup").style.display="";};MapGeoFilter.prototype.hide=function(){Dom.get("jumpToPopup").style.display="none";};MapGeoFilter.prototype._delegateClickEvent=function(ev){var obj=ev.target?ev.target:ev.srcElement;var addressField=Dom.get(Dom.get('geofilterField'));var resetButton=Dom.get(Dom.get('georesetFilter'));if(obj.className==="easyCreatingFieldResetButton"){addressField.value="";addressField.focus();resetButton.style.display="none";addressField.style.width="168px";this.hide();}else if(obj.nodeName==="ADDRESS"){var rowId=obj.id;var rowIdNumber=parseInt(rowId);var result=this.gs.results[rowIdNumber];this.openLocation(result);this.hide();}};MapGeoFilter.prototype.attachHandlers=function(){Event.addListener(Dom.get('jumpToPopup'),"click",this._delegateClickEvent,this,true);};MapGeoFilter.prototype.googleSearchCallBack=function(){var results=this.gs.results;if(results.length==1){this.openLocation(results[0]);this.hide();}
if(results.length>1){Dom.get(this.resultHint).style.display="";Dom.get(this.resultList).style.display="";Dom.get(this.nothingFoundHint).style.display="none";Dom.get(this.resultList).innerHTML="";for(var i=0;i<results.length;i++){var address=results[i].addressLines.join(", ");var link=document.createElement("address");link.innerHTML=address;link.id=i+"_address_row";Dom.get(this.resultList).appendChild(link);}
this.show();}
if(results.length==0){Dom.get(this.resultHint).style.display="none";Dom.get(this.resultList).style.display="none";Dom.get(this.nothingFoundHint).style.display="";this.show();}};MapGeoFilter.prototype.openLocation=function(address){CLIPTOO.poi.map.types.getLocations(address,function(bounds){if(!bounds){popupHandler.hidePleaseWait();return;}
if(bounds){var llbounds=new GLatLngBounds(new GLatLng(bounds.south,bounds.west),new GLatLng(bounds.north,bounds.east));var map=Poi.getMap();var bestZoom=map.getZoomLevelForBounds(llbounds);if(map.getCenter()!=llbounds.getCenter()||map.getZoom()!=bestZoom){map.setCenter(llbounds.getCenter(),bestZoom);}
popupHandler.hidePleaseWait();}},this);};MapGeoFilter.prototype.checkForChange=function(){};(function(){var selectedLayerId=null,mapLayerMenu=null,mapLayerButton=null,mapLayerMenuShown=false,mapModeMenu=null,mapModeMenuShown=false,mapGeodataMenu=null,mapGeodataMenuShown=false,map=null;var selectButton=function(id){if(ctx.getEasyCreatingForm()){ctx.getEasyCreatingForm().hide();}
if(Dom.get("map_poi_hand_toolbar").className!="disabled"){Dom.get("map_poi_hand_toolbar").className="";}
Dom.get(id).className="active";ctx.getZoomingControl().zoomToolsRefresh();};var checkMapModeMenuItem=function(number){var items=mapModeMenu.getItems()
for(var index=0,n=items.length;index<n;index++){items[index].cfg.setProperty("checked",false);}
mapModeMenu.getItem(number,0).cfg.setProperty("checked",true);};var showLayer=function(eventName,event,number){var items=mapLayerMenu.getItems();if(mapLayerMenu.getItem(number,0).cfg.getProperty("checked")==true){mapLayerMenu.getItem(number,0).cfg.setProperty("checked",false);map.removeLayers();selectedLayerId=null;CLIPTOO.poi.cookie.create("selected-layer","no-layer");}
else{for(var index=0,n=items.length;index<n;index++){items[index].cfg.setProperty("checked",false);}
mapLayerMenu.getItem(number,0).cfg.setProperty("checked",true);selectedLayerId=ctx.getLayers()[number].id;popupHandler.showPleaseWait();map.showLayer(ctx.getLayers()[number]);}};var isLayerChecked=function(id){return(id===selectedLayerId);};var changeMap=function(evType,evInfo,newType){map.setMapType(newType);CLIPTOO.poi.cookie.create("map-type",CLIPTOO.poi.map.types.getMapTypeCodeByType(newType));if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/maptoolbar/change_map_mode/"+CLIPTOO.poi.map.types.getMapTypeCodeByType(newType));}
checkMapModeMenuItem(CLIPTOO.poi.map.types.getMapTypeNumber(newType));}
var handleZoomIn=function(menuBtn){if(menuBtn.className==""){menuBtn.className="active";ctx.getZoomingControl().show();}else{ctx.getZoomingControl().hide();menuBtn.className="";}};var handleHand=function(menuBtn){if(menuBtn.className==""){CLIPTOO.poi.map.Toolbar.selectHandButton();}};var handleRightResizing=function(menuBtn){if(menuBtn.className==""){menuBtn.className="back";menuBtn.title=PoiMsg.js_msg.map.toolbar.showPoiList();Dom.get("poiListArea").style.display="none";CLIPTOO.poi.cookie.create("right-collapse","1");}
else{menuBtn.className="";menuBtn.title=PoiMsg.js_msg.map.toolbar.closePoiList();Dom.get("poiListArea").style.display="";CLIPTOO.poi.cookie.create("right-collapse","0");}
map.checkResize();ctx.getDeadAreaControl().refresh(map);poisSelector.setPoisByCategoriesIdsAndCoordinatBound();poisSelector.getLayersByCoordinatesBound();if(mapModeMenu){mapModeMenu.cfg.setProperty("context",["map_poi_map_mode_toolbar_btn","tl","bl"]);}};var handleLeftResizing=function(menuBtn){var mapWidth=map.getSize().width;var pixel=map.fromLatLngToDivPixel(map.getCenter());var categoriesBtn=Dom.get("categories_btn");categoriesBtn.className="";if(menuBtn.className==""){menuBtn.className="back";menuBtn.title=PoiMsg.js_msg.map.toolbar.showCategories();categoriesBtn.style.display="";categoriesBtn.title=PoiMsg.js_msg.map.toolbar.showCategoriesPopup();Dom.get("categoriesListArea").style.display="none";CLIPTOO.poi.cookie.create("left-collapse","1");CLIPTOO.utils.mapToolbarPopupPosition();}
else{menuBtn.className="";menuBtn.title=PoiMsg.js_msg.map.toolbar.hideCategories();Dom.get("categoriesListPopup").style.display="none";categoriesBtn.style.display="none";Dom.get("categoriesListArea").style.display="";CLIPTOO.poi.cookie.create("left-collapse","0");CLIPTOO.utils.mapToolbarPopupPosition();}
map.checkResize();var newMapWidth=map.getSize().width;var shift=newMapWidth-mapWidth;if(shift%2!=0&&newMapWidth%2==0){pixel.x=pixel.x-Math.ceil(shift/2);}
else{pixel.x=pixel.x-Math.floor(shift/2);}
ctx.getDeadAreaControl().refresh(map);var newCenter=map.fromDivPixelToLatLng(pixel);map.setCenter(newCenter);if(mapLayerMenu){mapLayerMenu.cfg.setProperty("context",["map-poi-layer-toolbar-btn","tl","bl"]);}
if(mapGeodataMenu){mapGeodataMenu.cfg.setProperty("context",["map-create-geodata","tl","bl"]);}};var handleMapRefreshing=function(){poisSelector.setPoisByCategoriesIdsAndCoordinatBound();poisSelector.getLayersByCoordinatesBound();};var handleCategoriesPopup=function(menuBtn){if(menuBtn.className=="disabled"){return;}
if(menuBtn.className==''){menuBtn.className='active';Dom.get("categoriesListPopup").style.display="";ctx.getCategoriesListPopup().showScrollIfNeeded();ctx.getCategoriesListPopup().refreshCounts();menuBtn.title=PoiMsg.js_msg.map.toolbar.hideCategoriesPopup();}
else{menuBtn.className='';Dom.get("categoriesListPopup").style.display="none";menuBtn.title=PoiMsg.js_msg.map.toolbar.showCategoriesPopup();}};var handleGeofilter=function(menuBtn){if(menuBtn.className==''){menuBtn.className='active';ctx.getJumpToForm().show();}
else{menuBtn.className='';ctx.getJumpToForm().hide();}};var handleMapMode=function(){if(mapModeMenuShown){mapModeMenu.show();}
mapModeMenuShown=!mapModeMenuShown;};var handleLayerButton=function(menuBtn){if(mapLayerMenuShown){hideAllGeodataPopups();deselectGeodataMenuItems();mapLayerMenu.show();menuBtn.className="active";}
else{menuBtn.className="";}
mapLayerMenuShown=!mapLayerMenuShown;};var handleGeodataButton=function(menuBtn){if(ctx.getEditBalloon()&&ctx.getEditBalloon().isShown())return;if(mapGeodataMenuShown){mapGeodataMenu.show();menuBtn.className="active";}
else{menuBtn.className="";}
mapGeodataMenuShown=!mapGeodataMenuShown;};var delegateClickEvent=function(ev){var menu=ev.target?ev.target:ev.srcElement;if(menu.id=="map-toolbar"){return;}
while(menu.parentNode.id!="map-toolbar"){menu=menu.parentNode;}
Poi.getMap().currentCursor=null;if(menu.id=="map_resizer_right_toolbar"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/maptoolbar/poi_list_show_hide");}
handleRightResizing(menu);}
else if(menu.id=="map_resizer_left_toolbar"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/maptoolbar/categories_list_show_hide");}
handleLeftResizing(menu);}
else if(menu.id=="map_poi_zoom_in_toolbar"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/maptoolbar/show_hide_zoom_in_toolbar");}
handleZoomIn(menu);}
else if(menu.id=="map_poi_hand_toolbar"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/maptoolbar/hand_toolbar");}
handleHand(menu);}
else if(menu.id=="map_poi_map_refresh_btn"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/maptoolbar/refresh_map_data");}
handleMapRefreshing();}
else if(menu.id=="categories_btn"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/maptoolbar/show_hide_categories_popup");}
handleCategoriesPopup(menu);}
else if(menu.id=="map_poi_map_mode_toolbar_btn"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/maptoolbar/map_mode_toolbar");}
handleMapMode();}
else if(menu.id=="map-poi-layer-toolbar-btn"){if(typeof currentOurTracker!='undefined'){currentOurTracker._trackPageview("/maptoolbar/select_layer");}
handleLayerButton(menu);}
else if(menu.id=="map-create-geodata"){handleGeodataButton(menu);}};var hideAllGeodataPopups=function(){if(Dom.get("map_poi_hand_toolbar").className!="disabled"){Dom.get("map_poi_hand_toolbar").className="";}
ctx.getUploadPOAControl().hide();ctx.getUploadRouteControl().hide();ctx.getMapLayersControl().hide();ctx.getEasyCreatingForm().hide();};var geodataMenu=(function(){var a=[];var geodataHolder=Dom.get("geodata_holder");if(geodataHolder){var menuItems=geodataHolder.getElementsByTagName("li");var type;for(var i=0,n=menuItems.length;i<n;i++){if(Dom.hasClass(menuItems[i],"create-poi")){type="create-poi";}
else if(Dom.hasClass(menuItems[i],"create-poa")){type="create-poa";}
else if(Dom.hasClass(menuItems[i],"create-route")){type="create-route";}
else if(Dom.hasClass(menuItems[i],"create-layer")){type="create-layer";}
a[type]=i;}}
return function(type){return a[type]};})();var handleNewPoi=function(){var cursor=Dom.getStyle("newPoiCursorProvider","cursor");map.holdMapWithCursor(cursor);map.mode=map.MAP_POI_CREATING;ctx.getEasyCreatingForm().show();map.disable();};var selectHandButton=function(){selectButton("map_poi_hand_toolbar");map.serfMapWithHand();map.mode=map.MAP_VIEWING;map.enable();};var deselectGeodataMenuItems=function(){if(mapGeodataMenu){hideAllGeodataPopups();var items=mapGeodataMenu.getItems();for(var index=0,n=items.length;index<n;index++){items[index].cfg.setProperty("checked",false);}}};var selectGeodataItemIfNeeded=function(itemCode,selectItem,context){itemNumber=geodataMenu(itemCode);if(context){selectItem.apply(context,[]);}
else{selectItem();}
mapGeodataMenu.getItem(itemNumber,0).cfg.setProperty("checked",true);};var delegateGeodataClickEvent=function(ev){var menu=ev.target?ev.target:ev.srcElement;while(menu.tagName!="LI"){menu=menu.parentNode;}
ctx.getZoomingControl().zoomToolsRefresh();var alreadyChecked=Dom.hasClass(menu,"yuimenuitem-checked");if(!alreadyChecked){deselectGeodataMenuItems();map.serfMapWithHand();if(Dom.hasClass(menu,"create-poi")){selectGeodataItemIfNeeded("create-poi",handleNewPoi);}
else if(Dom.hasClass(menu,"create-poa")){selectGeodataItemIfNeeded("create-poa",ctx.getUploadPOAControl().show,ctx.getUploadPOAControl());}
else if(Dom.hasClass(menu,"create-route")){selectGeodataItemIfNeeded("create-route",ctx.getUploadRouteControl().show,ctx.getUploadRouteControl());}
else if(Dom.hasClass(menu,"create-layer")){selectGeodataItemIfNeeded("create-layer",ctx.getMapLayersControl().show,ctx.getMapLayersControl());}}
else{CLIPTOO.poi.map.Toolbar.selectHandButton();}
mapGeodataMenu.hide();};CLIPTOO.poi.map.Toolbar=function(){};if(Dom.get('jumpToPopup')){CLIPTOO.poi.map.Toolbar.geoFilter=new MapGeoFilter();}
CLIPTOO.poi.map.Toolbar.selectHandButton=function(){deselectGeodataMenuItems();ctx.getZoomingControl().zoomToolsRefresh();selectHandButton();};CLIPTOO.poi.map.Toolbar.unSelectButtons=function(){deselectGeodataMenuItems();if(Dom.get("map_poi_hand_toolbar").className!="disabled"){Dom.get("map_poi_hand_toolbar").className="";}};CLIPTOO.poi.map.Toolbar.uncheckAllItemsInLayersMenu=function(){var items=mapLayerMenu.getItems();for(var index=0,n=items.length;index<n;index++){items[index].cfg.setProperty("checked",false);}
map.removeLayers();selectedLayerId=null;};CLIPTOO.poi.map.Toolbar.needToDisableLayersMenuItem=function(layer){if(layer){var layerBounds=new GLatLngBounds();var pointMin=new GLatLng(layer.minLat,layer.minLng);var pointMax=new GLatLng(layer.maxLat,layer.maxLng);layerBounds.extend(pointMin);layerBounds.extend(pointMax);var map=Poi.getMap();var neededZoom=map.getZoomLevelForBounds(layerBounds);var currentZoom=map.getZoom();return currentZoom<=neededZoom&&!layer.layerLink;}
return false;};CLIPTOO.poi.map.Toolbar.refreshLayersMenu=function(){if(mapLayerButton){mapLayerMenu.clearContent();var layers=ctx.getLayers(),n=layers.length;mapLayerButton.style.display=(n==0)?"none":"";for(var i=0;i<n;i++){var layer=layers[i];if(this.needToDisableLayersMenuItem(layer)){mapLayerMenu.addItem({text:layer.title,onclick:{fn:{},obj:i},"checked":false});var items=mapLayerMenu.getItems();var textEl=items[i].element.firstChild;textEl.style.color='#B0B0B0';textEl.title=PoiMsg.js_msg.toolbar.layerMenu.disable();}else{mapLayerMenu.addItem({text:layer.title,onclick:{fn:showLayer,obj:i},"checked":isLayerChecked(layer.id)});}}
mapLayerMenu.render('layermenu_holder');mapLayerMenu.cfg.setProperty("context",["map-poi-layer-toolbar-btn","tl","bl"]);CLIPTOO.utils.jumpToPosition();}};CLIPTOO.poi.map.Toolbar.selectLayer=function(layer){selectedLayerId=layer.id;this.refreshLayersMenu();map.showLayer(layer);};CLIPTOO.poi.map.Toolbar.returnIdSelectedLayer=function(){return selectedLayerId;}
CLIPTOO.poi.map.Toolbar.create=function(_map){map=_map;var zoomSliderControl=ctx.getZoomingControl();Dom.get("map_poi_zoom_in_toolbar").className="active";zoomSliderControl.show();mapModeMenu=new YAHOO.widget.Menu("mapmenu",{zIndex:4,context:["map_poi_map_mode_toolbar_btn","tl","bl"]});var defaultMapTypeCode=CLIPTOO.poi.cookie.read("map-type");if(!defaultMapTypeCode){defaultMapTypeCode=ctx.getOrgProperty("defaultMapView");}
var defaultMapType=CLIPTOO.poi.map.types.getMapTypeByCode(defaultMapTypeCode);var mapTypes=CLIPTOO.poi.map.types.supported;for(var i=0,n=mapTypes.length;i<n;i++){var mapType=mapTypes[i];mapModeMenu.addItem({text:mapType.label,onclick:{fn:changeMap,obj:mapType.type},checked:defaultMapType==mapType.type});}
mapModeMenu.render('mapmenu_holder');mapModeMenu.hideEvent.subscribe(function(){mapModeMenuShown=false;});Event.addListener("map_poi_map_mode_toolbar_btn","mouseover",function(){mapModeMenuShown=true;});mapLayerButton=Dom.get("map-poi-layer-toolbar-btn");if(mapLayerButton){mapLayerMenu=new YAHOO.widget.Menu("layermenu",{zIndex:8});mapLayerMenu.hideEvent.subscribe(function(){mapLayerMenuShown=false;mapLayerButton.className="";});Event.addListener(mapLayerButton,"mouseover",function(){mapLayerMenuShown=true;});mapLayerMenu.render('layermenu_holder');}
var mapGeodataButton=Dom.get("map-create-geodata");if(mapGeodataButton){mapGeodataMenu=new YAHOO.widget.Menu("geodata",{zIndex:4,context:["map-create-geodata","tl","bl"]});mapGeodataMenu.hideEvent.subscribe(function(){mapGeodataMenuShown=false;mapGeodataButton.className="";});Event.addListener("map-create-geodata","mouseover",function(){mapGeodataMenuShown=true;});mapGeodataMenu.render();Event.addListener("geodata","click",delegateGeodataClickEvent);}
Event.addListener("map-toolbar","click",delegateClickEvent);};})();function KMLObj(title,desc,op,fid){this.title=title;this.description=escape(desc);this.marks=[];this.folders=[];this.groundOverlays=[];this.open=op;this.folderid=fid;};function Lance$(mid){return document.getElementById(mid);};var topwin=self;function GeoXml(myvar,map,url,opts){this.myvar=myvar;this.opts=opts||{};this.mb=new MessageBox(map,this,"mb",this.opts.messagebox);this.map=map;this.url=url;if(typeof url=="string"){this.urls=[url];}
else{this.urls=url;};this.mb.style=this.opts.messagestyle||{backgroundColor:"silver"};this.alwayspop=this.opts.alwaysinfopop||false;this.quiet=this.opts.quiet||false;this.titlestyle=this.opts.titlestyle||'style = "font-family: arial, sans-serif;font-size: medium;font-weight:bold;font-size: 100%;"';this.descstyle=this.opts.descstyle||'style = "font-family: arial, sans-serif;font-size: small;padding-bottom:.7em;"';this.directionstyle=this.opts.directionstyle||'style="font-family: arial, sans-serif;font-size: small;padding-left: 1px;padding-top: 1px;padding-right: 4px;"';this.sidebarfn=this.opts.sidebarfn||GeoXml.addSidebar;this.pointlabelopacity=this.opts.pointlabelopacity||100;this.polylabelopacity=this.opts.polylabelopacity||100;this.hilite=this.opts.hilite||{color:"#aaffff",opacity:0.3,textcolor:"#000000"};this.latestsidebar="";this.forcefoldersopen=false;if(typeof this.opts.allfoldersopen!="undefined"){this.forcefoldersopen=this.opts.allfoldersopen;};this.clickablepolys=true;if(typeof this.opts.clickablepolys=="boolean"){this.clickablepolys=this.opts.clickablepolys;};this.clickablemarkers=true;if(typeof this.opts.clickablemarkers=="boolean"){this.clickablemarkers=this.opts.clickablemarkers;};this.clickablelines=true;if(typeof this.opts.clickablelines=="boolean"){this.clickablelines=this.opts.clickablelines;};if(typeof this.opts.nolegend!="undefined"){this.nolegend=true;};if(typeof this.opts.preloadHTML=="undefined"){this.opts.preloadHTML=true;};this.hideall=false;if(typeof proxy!="undefined"){this.proxy=proxy;};if(!this.proxy&&typeof getcapproxy!="undefined"){if(fixUrlEnd){getcapproxy=fixUrlEnd(getcapproxy);}};if(this.opts.hideall){this.hideall=this.opts.hideall;};try{if(top.publishdirectory){this.publishdirectory=top.publishdirectory;}
else{this.publishdirectory="http://www.dyasdesigns.com/tntmap/";};topwin=top;}
catch(err){topwin=self;}
if(topwin.standalone){this.publishdirectory="";};this.kmlicon=this.publishdirectory+"images/ge.png";this.docicon=this.publishdirectory+"images/ge.png";this.foldericon=this.publishdirectory+"images/folder.png";this.gmlicon=this.publishdirectory+"images/geo.gif";this.rssicon=this.publishdirectory+"images/rssb.png";this.globalicon=this.publishdirectory+"images/geo.gif";this.WMSICON="<img src=\""+this.publishdirectory+"images/geo.gif\" style=\"border:none\" />";GeoXml.WMSICON=this.WMSICON;this.baseLayers=[];this.bounds=new GLatLngBounds();this.style=this.opts.style||{width:2,opacity:0.75,fillopacity:0.4};this.style.color=(this.opts.style&&this.opts.style.color)||this.randomColor();this.style.fillcolor=(this.opts.style&&this.opts.style.fillcolor)||this.randomColor();this.iwwidth=this.opts.iwwidth||400;this.lastmarker={};this.verySmall=0.0000001;this.progress=0;this.ZoomFactor=2;this.NumLevels=18;this.maxtitlewidth=0;this.styles=[];this.jsdocs=[];this.jsonmarks=[];this.polyset=[];this.polygons=[];this.polylines=[];this.multibounds=[];this.overlayman=new Clusterer(map,this);this.overlayman.rowHeight=20;if(this.opts.sidebarid){this.basesidebar=this.opts.sidebarid;};this.kml=[new KMLObj("GeoXML","",true,0)];this.overlayman.folders.push([]);this.overlayman.subfolders.push([]);this.overlayman.folderhtml.push([]);this.overlayman.folderhtmlast.push(0);this.overlayman.folderBounds.push(new GLatLngBounds());this.wmscount=0;this.labels=new GTileLayerOverlay(G_HYBRID_MAP.getTileLayers()[1]);this.unnamedpath="un-named path";this.unnamedplace="un-named place";this.unnamedarea="un-named area";};GeoXml.prototype.showIt=function(str,h,w){var features="status=yes,resizable=yes,toolbar=0,height="+h+",width="+h+",scrollbars=yes";var myWin;if(topwin.widget){alert(str);this.mb.showMess(str);}
else{myWin=window.open("","_blank",features);myWin.document.open("text/xml");myWin.document.write(str);myWin.document.close();}};GeoXml.prototype.clear=function(idx){for(var m=0;m<this.overlayman.markers.length;m++){this.overlayman.RemoveMarker(this.overlayman.markers[m]);};this.kml=[new KMLObj("GeoXML","",true,0)];this.maxtitlewidth=0;this.styles=[];this.jsdocs=[];this.jsonmarks=[];this.polyset=[];this.polylines=[];this.multibounds=[];this.bounds=new GLatLngBounds();this.overlayman=new Clusterer(this.map,this);this.overlayman.rowHeight=20;if(typeof this.basesidebar!="undefined"&&this.basesidebar!=""){Lance$(this.basesidebar).innerHTML="";};this.overlayman.folders.push([]);this.overlayman.subfolders.push([]);this.overlayman.folderhtml.push([]);this.overlayman.folderhtmlast.push(0);this.overlayman.byname=[];this.overlayman.byid=[];this.overlayman.folderBounds.push(new GLatLngBounds());this.wmscount=0;};GeoXml.prototype.createMarkerJSON=function(item,idx){var that=this;var style=that.makeIcon(style,item.href);var point=new GLatLng(item.y,item.x);that.overlayman.folderBounds[idx].extend(point);that.bounds.extend(point);if(item.shadow){style.shadow=item.shadow;}
else{style.shadow=null;};if(!!that.opts.createmarker){that.opts.createmarker(point,item.title,unescape(item.description),null,idx,style,item.visibility,item.id);}
else{that.createMarker(point,item.title,unescape(item.description),null,idx,style,item.visibility,item.id);}};GeoXml.prototype.createMarker=function(point,name,desc,style,idx,instyle,visible,kml_id){var myvar=this.myvar;var icon;var bicon=new GIcon();if(this.opts.baseicon){bicon.iconSize=this.opts.baseicon.iconSize;bicon.iconAnchor=this.opts.baseicon.iconAnchor;bicon.shadowSize=this.opts.baseicon.shadowSize;bicon.infoWindowAnchor=this.opts.baseicon.infoWindowAnchor;}
else{bicon.infoWindowAnchor=new GPoint(16,0);bicon.iconSize=new GSize(32,32);bicon.shadowSize=new GSize(32,32);bicon.iconAnchor=new GPoint(16,32);};var shadow;var href;if(this.opts.iconFromDescription){var text=desc;var pattern=new RegExp("<\\s*img","ig");var result;var pattern2=/src\s*=\s*[\'\"]/;var pattern3=/[\'\"]/;while((result=pattern.exec(text))!=null){var stuff=text.substr(result.index);var result2=pattern2.exec(stuff);if(result2!=null){stuff=stuff.substr(result2.index+result2[0].length);var result3=pattern3.exec(stuff);if(result3!=null){var imageUrl=stuff.substr(0,result3.index);href=imageUrl;}}}
shadow=null;if(!href){href="http://maps.google.com/mapfiles/kml/pal3/icon40.png";}
icon=new GIcon(bicon,href,null,shadow);}
else{href="http://maps.google.com/mapfiles/kml/pal3/icon40";if(instyle==null||typeof instyle=="undefined"){shadow=href+"s.png";href+=".png";if(this.opts.baseicon){href=this.opts.baseicon.image;shadow=this.opts.baseicon.shadow;}}
else{if(instyle.href){href=instyle.href;}
if(instyle.shadow){shadow=instyle.shadow;}}
icon=new GIcon(bicon,href,null,shadow);}
var iwoptions=this.opts.iwoptions||{};var markeroptions=this.opts.markeroptions||{};var icontype=this.opts.icontype||"style";if(icontype=="style"){if(!!this.styles[style]){icon=new GIcon(bicon,this.styles[style].href,null,this.styles[style].shadow);icon.src=this.styles[style].href;href=this.styles[style].href;}}
if(!markeroptions.icon){markeroptions.icon=icon;}
markeroptions.title=name;var m=new GMarker(point,markeroptions);m.title=name;m.id=kml_id;var obj={"type":"point","title":name,"description":escape(desc),"href":href,"shadow":shadow,"visibility":visible,"x":point.x,"y":point.y,"id":m.id};this.kml[idx].marks.push(obj);if(this.opts.pointlabelclass){var l=new ELabel(point,name,this.opts.pointlabelclass,this.opts.pointlabeloffset,this.pointlabelopacity,true);m.label=l;this.map.addOverlay(l);}
var html,html1,html2,html3,html4;var awidth=this.iwwidth;if(desc.length*8<awidth){awidth=desc.length*8;}
if(awidth<name.length*10){awidth=name.length*10;}
html="<div style = 'width:"+awidth+"px'>"+"<h1 "+this.titlestyle+">"+name+"</h1>"+"<div "+this.descstyle+">"+desc+"</div>";if(this.opts.directions){html1=html+'<div '+this.directionstyle+'>'+'Get Directions: <a href="#" onclick="GEvent.trigger('+this.myvar+'.lastmarker,\'click2\');return false;">To Here</a> - '+'<a href="#" onclick="GEvent.trigger('+this.myvar+'.lastmarker,\'click3\');return false;">From Here</a><br>'+'<a href="#" onclick="GEvent.trigger('+this.myvar+'.lastmarker,\'click4\');return false;">Search nearby</a></div>';html2=html+'<div '+this.directionstyle+'>'+'Get Directions: To here - '+'<a href="#" onclick="GEvent.trigger('+this.myvar+'.lastmarker,\'click3\');return false;">From Here</a><br>'+'Start address:<form action="http://maps.google.com/maps" method="get" target="_blank">'+'<input type="text" SIZE=35 MAXLENGTH=80 name="saddr" id="saddr" value="" />'+'<INPUT value="Go" TYPE="SUBMIT">'+'<input type="hidden" name="daddr" value="'+point.lat()+','+point.lng()+"("+name+")"+'"/>'+'<br><a href="# onclick="GEvent.trigger('+this.myvar+'.lastmarker,\'click\');return false;">&#171; Back</a></div>';html3=html+'<div '+this.directionstyle+'>'+'Get Directions: <a href="#" onclick="GEvent.trigger('+this.myvar+'.lastmarker,\'click2\');return false;">To Here</a> - '+'From Here<br>'+'End address:<form action="http://maps.google.com/maps" method="get"" target="_blank">'+'<input type="text" SIZE=35 MAXLENGTH=80 name="daddr" id="daddr" value="" />'+'<INPUT value="Go" TYPE="SUBMIT">'+'<input type="hidden" name="saddr" value="'+point.lat()+','+point.lng()+"("+name+")"+'"/>'+'<br><a href="#" onclick="GEvent.trigger('+this.myvar+'.lastmarker,\'click\');return false;">&#171; Back</a></div>';html4=html+'<div '+this.directionstyle+'>'+'Search nearby: e.g. "pizza"<br>'+'<form action="http://maps.google.com/maps" method="get"" target="_blank">'+'<input type="text" SIZE=35 MAXLENGTH=80 name="q" id="q" value="" />'+'<INPUT value="Go" TYPE="SUBMIT">'+'<input type="hidden" name="near" value="'+name+' @'+point.lat()+','+point.lng()+'"/>'+'<br><a href="# onclick="GEvent.trigger('+this.myvar+'.lastmarker,\'click\');return false;">&#171; Back</a></div>';GEvent.addListener(m,"click2",function(){m.openInfoWindowHtml(html2+"</div>",iwoptions);});GEvent.addListener(m,"click3",function(){m.openInfoWindowHtml(html3+"</div>",iwoptions);});GEvent.addListener(m,"click4",function(){m.openInfoWindowHtml(html4+"</div>",iwoptions);});}
else{html1=html;}
if(this.clickablemarkers){GEvent.addListener(m,"click",function(){eval(myvar+".lastmarker = m");m.openInfoWindowHtml(html1+"</div>",iwoptions);});}
if(this.opts.domouseover){m.mess=html1+"</div>";m.geoxml=this;GEvent.addListener(m,"mouseover",function(point){if(!point){point=m.getPoint();}
m.geoxml.mb.showMess(m.mess,5000);});}
var nhtml="";var parm;if(this.opts.sidebarid){var folderid=this.myvar+"_folder"+idx;var n=this.overlayman.markers.length;var blob="&nbsp;<img style=\"vertical-align:text-top;padding:0;margin:0\" height=\"16\" border=\"0\" src=\""+href+"\">&nbsp;";parm=this.myvar+"$$$"+name+"$$$marker$$$"+n+"$$$"+blob+"$$$"+visible+"$$$null";m.sidebarid=this.myvar+"sb"+n;m.hilite=this.hilite;m.geoxml=this;GEvent.addListener(m,"mouseover",function(){var bar=Lance$(this.sidebarid);if(bar&&typeof bar!="undefined"){bar.style.backgroundColor=this.hilite.color;bar.style.color=this.hilite.textcolor;}});GEvent.addListener(m,"mouseout",function(){var bar=Lance$(this.sidebarid);if(bar&&typeof bar!="undefined"){bar.style.background="none";bar.style.color="";}});}
if(!!this.opts.addmarker){this.opts.addmarker(m,name,idx,parm,visible);}
else{this.overlayman.AddMarker(m,name,idx,parm,visible);}};GeoXml.getDescription=function(node){var sub="";var n=0;var cn;if(document.all){for(;n<node.childNodes.length;n++){cn=node.childNodes.item(n);sub+=cn.xml;}}
else{var serializer=new XMLSerializer();for(;n<node.childNodes.length;n++){cn=serializer.serializeToString(node.childNodes.item(n));sub+=cn;}}
var s=sub.replace("<![CDATA[","");var u=s.replace("]]>","");u=u.replace(/\&/g,"&");u=u.replace(/\</g,"<");u=u.replace(/\"/g,'"');u=u.replace(/\'/g,"'");u=u.replace(/\>/g,">");return u;};GeoXml.prototype.processLine=function(pnum,lnum,idx){var that=this;var op=this.polylines[pnum];var line=op.lines[lnum];var obj;var p;if(!line){return;}
var thismap=this.map;var iwoptions=this.opts.iwoptions||{};var polylineEncoder=new PolylineEncoder(this.NumLevels,this.ZoomFactor,this.verySmall,true);if(line.length>2){var result=polylineEncoder.dpEncode(line);obj={points:result.encodedPoints,levels:result.encodedLevels,color:op.color,weight:op.width,opacity:op.opacity,clickable:op.clickablepolys,zoomFactor:this.ZoomFactor,numLevels:this.NumLevels,type:"polyline"};p=new GPolyline.fromEncoded(obj);}
else{obj={points:line,color:op.color,weight:op.width,opacity:op.opacity,type:"line",id:op.id};p=new GPolyline(line,op.color,op.width,op.opacity);}
p.bounds=op.pbounds;p.id=op.id;var nhtml="";var n=this.overlayman.markers.length;this.polylines[pnum].lineidx.push(n);var parm;var awidth=this.iwwidth;var desc=op.description;if(desc.length*8<awidth){awidth=desc.length*8;}
if(awidth<op.name.length*12){awidth=op.name.length*12;}
var html="<div style='font-weight: bold; font-size: medium; margin-bottom: 0em;'>"+op.name;html+="</div>"+"<div style='font-family: Arial, sans-serif;font-size: small;width:"+awidth+"px;'>"+desc+"</div>";if(lnum==0){if(this.opts.sidebarid){var blob='&nbsp;&nbsp;<span style=";border-left:'+op.width+'px solid '+op.color+';">&nbsp;</span> ';parm=this.myvar+"$$$"+op.name+"$$$polyline$$$"+n+"$$$"+blob+"$$$"+op.visibility+"$$$"+pnum+"$$$";this.latestsidebar=this.myvar+"sb"+n;}}
if(lnum<line.length){setTimeout(this.myvar+".processLine("+pnum+","+(lnum+1)+",'"+idx+"');",15);if(this.opts.sidebarid){p.sidebar=this.latestsidebar;}}
if(this.opts.domouseover){p.mess=html;}
p.title=op.name;p.geoxml=this;p.strokeColor=op.color;p.strokeWeight=op.width;p.strokeOpacity=op.opacity;p.hilite=this.hilite;p.mytitle=p.title;p.map=this.map;p.idx=pnum;p.onOver=function(){var pline=this.geoxml.polylines[this.idx];for(var l=0;l<pline.lineidx.length;l++){var mark=this.geoxml.overlayman.markers[pline.lineidx[l]];mark.realColor=mark.strokeColor;mark.setStrokeStyle({color:this.hilite.color});mark.redraw(true);}
if(this.sidebar){Lance$(this.sidebar).style.backgroundColor=this.hilite.color;Lance$(this.sidebar).style.color=this.hilite.textcolor;}
if(this.mess){this.geoxml.mb.showMess(this.mess,5000);}
else{this.title="Click for more information about "+this.mytitle;}};p.onOut=function(){var pline=this.geoxml.polylines[this.idx];for(var l=0;l<pline.lineidx.length;l++){var mark=this.geoxml.overlayman.markers[pline.lineidx[l]];mark.setStrokeStyle({color:this.realColor});mark.redraw(true);}
this.geoxml.mb.hideMess();if(this.sidebar){Lance$(this.sidebar).style.background="none";Lance$(this.sidebar).style.color="";}};GEvent.addListener(p,"click",function(point){var doit=false;if(!point){point=this.getPoint();doit=true;}
if(this.geoxml.clickablelines||doit){this.map.openInfoWindowHtml(point,html,iwoptions);}});obj.name=op.name;obj.description=escape(op.description);if(that.hideall){op.visibility=false;}
obj.visibility=op.visibility;this.kml[idx].marks.push(obj);this.overlayman.AddMarker(p,op.name,idx,parm,op.visibility);};GeoXml.prototype.createPolyline=function(lines,color,width,opacity,pbounds,name,desc,idx,visible,kml_id){var p={};if(!color){p.color=this.randomColor();}
else{p.color=color;}
if(!opacity){p.opacity=0.45;}
else{p.opacity=opacity;}
if(!width){p.width=2;}
else{p.width=width;}
p.idx=idx;p.visibility=visible;if(this.hideall){p.visibility=false;}
p.name=name;p.description=desc;p.lines=lines;p.lineidx=[];p.id=kml_id;this.polylines.push(p);setTimeout(this.myvar+".processLine("+(this.polylines.length-1)+",0,'"+idx+"');",15);};GeoXml.prototype.processPLine=function(pnum,linenum,idx){var p=this.polyset[pnum];var line=p.lines[linenum];var obj={};if(line&&line.length){var polylineEncoder=new PolylineEncoder(18,2,0.00001,true);var result=polylineEncoder.dpEncode(line);obj={};obj.points=result.encodedPoints;obj.levels=result.encodedLevels;obj.color=p.color;obj.weight=p.weight;obj.numLevels=18;obj.zoomFactor=2;obj.opacity=p.opacity;p.obj.polylines.push(obj);}
if(linenum==p.lines.length-1){this.finishPolygon(p.obj,idx);}
else{setTimeout(this.myvar+".processPLine("+pnum+","+(linenum+1)+",'"+idx+"');",5);}};GeoXml.prototype.finishPolygon=function(op,idx){op.type="polygon";this.finishPolygonJSON(op,idx,false);};GeoXml.prototype.finishPolygonJSON=function(op,idx,updatebound,lastpoly){var that=this;var iwoptions=that.opts.iwoptions||{};if(typeof op.visibility=="undefined"){op.visibility=true;}
if(that.hideall){op.visibility=false;}
var desc=unescape(op.description);op.opacity=op.fillOpacity;var p=new GPolygon.fromEncoded(op);var html="<div style='font-weight: bold; font-size: medium; margin-bottom: 0em;'>"+op.name+"</div>"+"<div style='font-family: Arial, sans-serif;font-size: small;width:"+this.iwwidth+"px'>"+desc+"</div>";var newgeom=(lastpoly!="p_"+op.name);if(newgeom&&this.opts.sidebarid){this.latestsidebar=that.myvar+"sb"+this.overlayman.markers.length;}
else{this.latestsidebar="";}
if(that.opts.domouseover){p.mess=html;}
p.strokeColor=op.polylines[0].color;p.mb=that.mb;p.hilite=that.hilite;p.strokeOpacity=op.polylines[0].opacity;p.fillOpacity=op.opacity;p.fillColor=op.color;if(!op.fill){p.fillOpacity=0.0;}
if(that.domouseover){p.mess=html;}
p.geoxml=that;p.title=op.name;p.id=op.id;var n=this.overlayman.markers.length;if(newgeom){that.multibounds.push(new GLatLngBounds());that.polygons.push([]);}
var len=that.multibounds.length-1;that.multibounds[len].extend(p.getBounds().getSouthWest());that.multibounds[len].extend(p.getBounds().getNorthEast());that.polygons[that.polygons.length-1].push(n);p.polyindex=that.polygons.length-1;p.geomindex=len;p.sidebarid=this.latestsidebar;p.onOver=function(){if(this.sidebarid){var bar=Lance$(this.sidebarid);if(!!bar){bar.style.backgroundColor=this.hilite.color;bar.style.color=this.hilite.textcolor;}}
if(this.geoxml.clickablepolys){var poly=this.geoxml.polygons[this.polyindex];if(poly){for(var pg=0;pg<poly.length;pg++){var mark=this.geoxml.overlayman.markers[poly[pg]];mark.realColor=mark.fillColor;mark.setFillStyle({color:this.hilite.color});mark.redraw(true);}}}
if(this.mess){p.geoxml.mb.showMess(this.mess,5000);}};p.onOut=function(){if(this.sidebarid){var bar=Lance$(this.sidebarid);if(!!bar){bar.style.background="none";bar.style.color="";}}
var poly;if(this.geoxml.clickablepolys){poly=this.geoxml.polygons[this.polyindex];}
if(poly){for(var pg=0;pg<poly.length;pg++){var mark=this.geoxml.overlayman.markers[poly[pg]];mark.setFillStyle({color:mark.realColor});mark.redraw(true);}}};GEvent.addListener(p,"mouseout",p.onOut);GEvent.addListener(p,"mouseover",p.onOver);op.description=escape(desc);this.kml[idx].marks.push(op);p.map=this.map;var bounds;GEvent.addListener(p,"click",function(point,overlay){if(!point&&this.geoxml.alwayspop){bounds=this.geoxml.multibounds[this.geomindex];this.map.setCenter(bounds.getCenter(),this.map.getBoundsZoomLevel(bounds));point=bounds.getCenter();}
if(!point){this.geoxml.mb.showMess("Zooming to "+p.title,3000);bounds=this.geoxml.multibounds[this.geomindex];this.map.setZoom(this.map.getBoundsZoomLevel(bounds));this.map.panTo(bounds.getCenter());}
else{if(this.geoxml.clickablepolys){this.map.openInfoWindowHtml(point,html,iwoptions);}}});if(this.opts.polylabelclass&&newgeom){var epoint=p.getBounds().getCenter();var off=this.opts.polylabeloffset;if(!off){off=new GSize(0,0);}
off.x=-(op.name.length*6);var l=new ELabel(epoint," "+op.name+" ",this.opts.polylabelclass,off,this.polylabelopacity,true);p.label=l;this.map.addOverlay(l);}
var nhtml="";var parm;if(this.basesidebar&&newgeom){var folderid=this.myvar+"_folder"+idx;var blob="<span style=\"background-color:"+op.color+";border:2px solid "+p.strokeColor+";\">&nbsp;&nbsp;&nbsp;&nbsp;</span> ";parm=this.myvar+"$$$"+op.name+"$$$polygon$$$"+n+"$$$"+blob+"$$$"+op.visibility+"$$$null";}
if(updatebound){var ne=p.getBounds().getNorthEast();var sw=p.getBounds().getSouthWest();this.bounds.extend(ne);this.bounds.extend(sw);this.overlayman.folderBounds[idx].extend(sw);this.overlayman.folderBounds[idx].extend(ne);}
this.overlayman.AddMarker(p,op.name,idx,parm,op.visibility);return op.name;};GeoXml.prototype.finishLineJSON=function(po,idx,lastlinename){var m;var that=this;var thismap=this.map;if(po.type=="line"){m=new GPolyline(po.points,po.color,po.weight,po.opacity);}
else{m=new GPolyline.fromEncoded(po);}
m.mytitle=po.name;m.title=po.name;m.geoxml=this;m.strokeColor=po.color;m.strokeWeight=po.weight;m.strokeOpacity=po.opacity;m.hilite=this.hilite;var n=that.overlayman.markers.length;var lineisnew=false;var pnum;if(("l_"+po.name)!=lastlinename){lineisnew=true;that.polylines.push(po);pnum=that.polylines.length-1;that.polylines[pnum].lineidx=[];that.latestsidebar=that.myvar+"sb"+n;}
else{pnum=that.polylines.length-1;that.polylines[pnum].lineidx.push(n);}
if(this.opts.basesidebar){m.sidebarid=that.latestsidebar;}
m.onOver=function(){if(!!this.sidebarid){var bar=Lance$(this.sidebarid);if(bar&&typeof bar!="undefined"){bar.style.backgroundColor=this.hilite.color;}}
this.realColor=this.strokeColor;if(mark&&typeof mark!="undefined"){mark.setStrokeStyle({color:this.hilite.color});}
this.redraw(true);if(this.mess){this.geoxml.mb.showMess(this.mess,5000);}
else{this.title="Click for more information about "+this.mytitle;}};m.onOut=function(){if(!!this.sidebarid){var bar=Lance$(this.sidebarid);if(bar&&typeof bar!="undefined"){bar.style.background="none";}}
if(mark&&typeof mark!="undefined")mark.setStrokeStyle({color:this.realColor});this.redraw(true);if(this.mess){this.geoxml.mb.hideMess();}};GEvent.addListener(m,"mouseover",m.onOver);GEvent.addListener(m,"mouseover",m.onOut);var parm="";that.kml[idx].marks.push(po);var desc=unescape(po.description);var awidth=this.iwwidth;if(desc.length*8<awidth){awidth=desc.length*8;}
if(awidth<po.name.length*12){awidth=po.name.length*12;}
var html="<div style='font-weight: bold; font-size: medium; margin-bottom: 0em;'>"+po.name;html+="</div><div style='font-family: Arial, sans-serif;font-size: small;width:"+awidth+"px'>"+desc+"</div>";m.map=this.map;if(this.clickablelines){GEvent.addListener(m,"click",function(point){if(!point){point=m.getPoint();}
this.map.openInfoWindowHtml(point,html,that.opts.iwoptions);});}
if(that.basesidebar&&lineisnew){var blob='&nbsp;&nbsp;<span style=";border-left:'+po.weight+'px solid '+po.color+';">&nbsp;</span> ';if(typeof po.visibility=="undefined"){po.visibility=true;}
parm=that.myvar+"$$$"+po.name+"$$$polyline$$$"+n+"$$$"+blob+"$$$"+po.visibility+"$$$"+(that.polylines.length-1)+"$$$";}
var ne=m.getBounds().getNorthEast();var sw=m.getBounds().getSouthWest();that.bounds.extend(ne);that.bounds.extend(sw);that.overlayman.folderBounds[idx].extend(sw);that.overlayman.folderBounds[idx].extend(ne);that.overlayman.AddMarker(m,po.name,idx,parm,po.visibility);return(po.name);};GeoXml.prototype.handlePlaceObj=function(num,max,idx,lastlinename,depth){var that=this;var po=that.jsonmarks[num];var name=po.name;if(po.title){name=po.title;}
if(name.length+depth>that.maxtitlewidth){that.maxtitlewidth=name.length+depth;}
switch(po.type){case"polygon":lastlinename="p_"+that.finishPolygonJSON(po,idx,true,lastlinename);break;case"line":case"polyline":lastlinename="l_"+that.finishLineJSON(po,idx,lastlinename);break;case"point":that.createMarkerJSON(po,idx);lastlinename="";break;}
if(num<max-1){var act=that.myvar+".handlePlaceObj("+(num+1)+","+max+","+idx+",\""+lastlinename+"\","+depth+");";document.status="processing "+name;setTimeout(act,1);}
else{lastlinename="";if(num==that.jsonmarks.length-1){that.progress--;if(that.progress<=0){if(!that.opts.nozoom){that.map.setCenter(that.bounds.getCenter(),that.map.getBoundsZoomLevel(that.bounds));}
GEvent.trigger(that,"parsed");that.setFolders();if(!that.opts.sidebarid){that.mb.showMess("Finished Parsing",1000);that.ParseURL();}}}}};GeoXml.prototype.parseJSON=function(doc,title,latlon,desc,sbid){var that=this;that.overlayman.miStart=new Date();that.jsdocs=eval('('+doc+')');var bar=Lance$(that.basesidebar);if(bar){bar.style.display="";}
that.recurseJSON(that.jsdocs[0],title,desc,that.basesidebar,0);};GeoXml.prototype.setFolders=function(){var that=this;var len=that.kml.length;for(var i=0;i<len;i++){var fid=that.kml[i].folderid;var fob=Lance$(fid);if(fob!==null&&fid!=that.opts.sidebarid){if(!!that.kml[i].open){fob.style.display='block';}
else{fob.style.display='none';}}}};GeoXml.prototype.recurseJSON=function(doc,title,desc,sbid,depth){var that=this;var polys=doc.marks;var name=doc.title;if(!sbid){sbid=0;}
var description=unescape(doc.description);if(!description&&desc){description=desc;}
var keepopen=that.forcefoldersopen;if(doc.open){keepopen=true;}
var visible=true;if(typeof doc.visibility!="undefined"&&doc.visibility){visible=true;}
if(that.hideall){visible=false;}
var snippet=doc.snippet;var idx=that.overlayman.folders.length;if(!description){description=name;}
var folderid;var icon;that.overlayman.folders.push([]);that.overlayman.subfolders.push([]);that.overlayman.folderhtml.push([]);that.overlayman.folderhtmlast.push(0);that.overlayman.folderBounds.push(new GLatLngBounds());that.kml.push(new KMLObj(title,description,keepopen));if((!depth&&(doc.folders&&doc.folders.length>1))||doc.marks.length){if(depth<2||doc.marks.length<1){icon=that.globalicon;}
else{icon=that.foldericon;}
folderid=that.createFolder(idx,name,sbid,icon,description,snippet,keepopen,visible);}
else{folderid=sbid;}
var parm,blob;var nhtml="";var html;var m;var num=that.jsonmarks.length;var max=num+polys.length;for(var p=0;p<polys.length;p++){var po=polys[p];that.jsonmarks.push(po);desc=unescape(po.description);m=null;if(that.opts.preloadHTML&&desc&&desc.match(/<(\s)*img/i)){var preload=document.createElement("span");preload.style.visibility="visible";preload.style.position="absolute";preload.style.left="-1200px";preload.style.top="-1200px";preload.style.zIndex=this.overlayman.markers.length;document.body.appendChild(preload);preload.innerHTML=desc;}}
if(that.groundOverlays){}
if(polys.length){that.handlePlaceObj(num,max,idx,null,depth);}
var fc=0;var fid=0;if(typeof doc.folders!="undefined"){fc=doc.folders.lenth;for(var f=0;f<doc.folders.length;++f){var nextdoc=that.jsdocs[doc.folders[f]];fid=that.recurseJSON(nextdoc,nextdoc.title,nextdoc.description,folderid,(depth+1));that.overlayman.subfolders[idx].push(fid);that.overlayman.folderBounds[idx].extend(that.overlayman.folderBounds[fid].getSouthWest());that.overlayman.folderBounds[idx].extend(that.overlayman.folderBounds[fid].getNorthEast());if(fid!=idx){that.kml[idx].folders.push(fid);}}}
if(fc||polys.length){that.bounds.extend(that.overlayman.folderBounds[idx].getSouthWest());that.bounds.extend(that.overlayman.folderBounds[idx].getNorthEast());}
return idx;};GeoXml.prototype.createPolygon=function(lines,color,width,opacity,fillcolor,fillOpacity,pbounds,name,desc,folderid,visible,fill,outline,kml_id){var thismap=this.map;var p={};p.obj={"description":desc,"name":name};p.obj.polylines=[];p.obj.id=kml_id;p.obj.visibility=visible;p.obj.fill=fill;p.obj.outline=outline;p.fillcolor=fillcolor;p.obj.strokecolor=color;if(!color){p.color=this.style.color;}
else{p.color=color;}
if(!fillcolor){p.obj.color=this.randomColor();}
else{p.obj.color=fillcolor;}
if(!opacity){p.obj.opacity=this.style.opacity;}
else{p.obj.opacity=opacity;}
if(typeof fillOpacity=="undefined"){p.obj.fillOpacity=this.style.fillOpacity;}
else{p.obj.fillOpacity=fillOpacity;}
if(!width){p.weight=this.style.width;}
else{p.weight=width;}
p.bounds=pbounds;p.lines=lines;p.sidebarid=this.opts.sidebarid;this.polyset.push(p);document.status="processing poly "+name;setTimeout(this.myvar+".processPLine("+(this.polyset.length-1)+",0,'"+folderid+"')",5);};GeoXml.prototype.toggleFolder=function(i){var f=Lance$(this.myvar+"_folder"+i);var tb=Lance$(this.myvar+"TB"+i);if(f.style.display=="none"){f.style.display="";if(tb){tb.style.fontWeight="normal";}}
else{f.style.display="none";if(tb){tb.style.fontWeight="bold";}}};GeoXml.prototype.saveJSON=function(){if(topwin.standalone){var fpath=browseForSave("Select a directory to place your json file","JSON Data Files (*.js)|*.js|All Files (*.*)|*.*","JSON-DATA");if(typeof fpath!="undefined"){var jsonstr=JSON.stringify(this.kml);saveLocalFile(fpath+".js",jsonstr);}
return;}
if(typeof JSON!="undefined"){var jsonstr=JSON.stringify(this.kml);if(typeof serverBlessJSON!="undefined"){serverBlessJSON(escape(jsonstr),"MyKJSON");}
else{this.showIt(jsonstr);}}
else{alert("No JSON methods currently available");}};GeoXml.prototype.hide=function(){this.toggleContents(1,false);};GeoXml.prototype.show=function(){this.toggleContents(1,true);};GeoXml.prototype.toggleContents=function(i,show){var f=this.overlayman.folders[i];var cb;var j;var m;if(typeof f=="undefined"){this.mb.showMess("folder "+f+" not defined");return;}
if(show){for(j=0;j<f.length;j++){m=this.overlayman.markers[f[j]];m.hidden=false;if(this.basesidebar){cb=Lance$(this.myvar+''+f[j]+'CB');if(cb&&typeof cb!="undefined"){cb.checked=true;}}
if(m.hide){m.show();}
else{this.map.addOverlay(m);}
if(!!m.label){m.label.show();}}}
else{for(j=0;j<f.length;j++){m=this.overlayman.markers[f[j]];m.hidden=true;if(this.basesidebar){cb=Lance$(this.myvar+''+f[j]+'CB');if(cb&&typeof cb!="undefined"){cb.checked=false;}}
if(m.hide){m.hide();}
else{this.map.removeOverlay(m);}
if(!!m.label){m.label.hide();}}}
var sf=this.overlayman.subfolders[i];if(typeof sf!="undefined"){for(j=0;j<sf.length;j++){if(sf[j]!=i){if(this.basesidebar){cb=Lance$(this.myvar+''+sf[j]+'FCB');if(cb&&typeof cb!="undefined"){cb.checked=(!!show);}}
this.toggleContents(sf[j],show);}}}};GeoXml.prototype.showHide=function(a,show,p){var m,i;if(a!=null){if(show){this.overlayman.markers[a].show();this.overlayman.markers[a].hidden=false;if(!!this.overlayman.markers[a].label){this.overlayman.markers[a].label.show();}}
else{this.overlayman.markers[a].hide();this.overlayman.markers[a].hidden=true;if(!!this.overlayman.markers[a].label){this.overlayman.markers[a].label.hide();}}}
else{var ms=this.polylines[p];if(show){for(i=0;i<ms.lineidx.length;i++){m=this.overlayman.markers[ms.lineidx[i]];m.hidden=false;if(m.hide){m.show();}
else{this.map.addOverlay(m);}
if(!!m.label){m.show();}}}
else{for(i=0;i<ms.lineidx.length;i++){m=this.overlayman.markers[ms.lineidx[i]];m.hidden=true;if(m.hide){m.hide();}
else{this.map.removeOverlay(m);}
if(!!m.label){m.hide();}}}}};GeoXml.prototype.toggleOff=function(a,show){if(show){this.map.addOverlay(this.overlayman.markers[a]);this.overlayman.markers[a].hidden=false;}
else{this.map.removeOverlay(this.overlayman.markers[a]);this.overlayman.markers[a].hidden=true;}
if(this.labels.onMap){this.map.removeOverlay(this.labels);this.map.addOverlay(this.labels);}};GeoXml.addSidebar=function(myvar,name,type,e,graphic,ckd,i){var check="checked";if(ckd=="false"){check="";}
var h="";var mid=myvar+"sb"+e;switch(type){case"marker":h='<li id="'+mid+'" onmouseout="GEvent.trigger('+myvar+'.overlayman.markers['+e+'],\'mouseout\');" onmouseover="GEvent.trigger('+myvar+'.overlayman.markers['+e+'],\'mouseover\');" ><input id="'+myvar+''+e+'CB" type="checkbox" style="vertical-align:middle" '+check+' onclick="'+myvar+'.showHide('+e+',this.checked)"><a href="#" onclick="GEvent.trigger('+myvar+'.overlayman.markers['+e+'],\'click\');return false;">'+graphic+name+'</a></li>';break;case"polyline":h='<li id="'+mid+'" onmouseout="'+myvar+'.overlayman.markers['+e+'].onOut();" onmouseover="'+myvar+'.overlayman.markers['+e+'].onOver();" ><input id="'+myvar+''+e+'CB" type="checkbox" '+check+' onclick="'+myvar+'.showHide(null,this.checked,'+i+')"><span style="margin-top:6px;"><a href="#" onclick="GEvent.trigger('+myvar+'.overlayman.markers['+e+'],\'click\');return false;">&nbsp;'+graphic+name+'</a></span></li>';break;case"polygon":h='<li id="'+mid+'" onmouseout="'+myvar+'.overlayman.markers['+e+'].onOut();" onmouseover="'+myvar+'.overlayman.markers['+e+'].onOver();" ><input id="'+myvar+''+e+'CB" type="checkbox" '+check+' onclick="'+myvar+'.showHide('+e+',this.checked)"><span style="margin-top:6px;"><a href="#" onclick="GEvent.trigger('+myvar+'.overlayman.markers['+e+'],\'click\');return false;">&nbsp;'+graphic+name+'</a></span></nobr></li>';break;case"groundoverlay":h='<li id="'+mid+'"><input id="'+myvar+''+e+'CB" type="checkbox" '+check+' onclick="'+myvar+'.showHide('+e+',this.checked)"><span style="margin-top:6px;"><a href="#" onclick="GEvent.trigger('+myvar+'.overlayman.markers['+e+'],\'zoomto\');return false;">&nbsp;'+graphic+name+'</a></span></li>';break;case"tiledoverlay":h='<li id="'+mid+'"><nobr><input id="'+myvar+''+e+'CB" type="checkbox" '+check+' onclick="'+myvar+'.toggleOff('+e+',this.checked)"><span style="margin-top:6px;"><a href="#" oncontextMenu="'+myvar+'.upgradeLayer('+i+');return false;" onclick="GEvent.trigger('+myvar+'.overlayman.markers['+e+'],\'zoomto\');return false;">'+GeoXml.WMSICON+'&nbsp;'+name+'</a><br />'+graphic+'</span></li>';break;}
return h;};GeoXml.addDropdown=function(myvar,name,type,i,graphic){return'<option value="'+i+'">'+name+'</option>';};GeoXml.prototype.parse=function(titles){var that=this;var names=[];if(typeof titles!="undefined"){if(typeof titles!="string"){names=titles;}
else{names=titles.split(",");}}
that.progress+=that.urls.length;for(var u=0;u<that.urls.length;u++){var title=names[u];if(typeof title=="undefined"||!title||title=="null"){var segs=that.urls[u].split("/");title=segs[segs.length-1];}
that.mb.showMess("Loading "+title);var re=/\.js$/i;if(that.urls[u].search(re)!=-1){that.loadJSONUrl(this.urls[u],title);}
else{that.loadXMLUrl(this.urls[u],title);}}};GeoXml.prototype.parseString=function(doc,titles,latlon){var names=[];if(titles){names=titles.split(",");}
if(typeof doc=="string"){this.docs=[doc];}
else{this.docs=doc;}
this.progress+=this.docs.length;for(var u=0;u<this.docs.length;u++){this.mb.showMess("Processing "+names[u]);this.processing(GXml.parse(this.docs[u]),names[u],latlon);}};GeoXml.prototype.parseXML=function(doc,titles,latlon){var names=[];if(typeof titles!="undefined"){if(typeof titles=="string"){names=titles.split(",");}
else{names=titles;}}
if(typeof doc=="array"){this.docs=doc;}
else{this.docs=[doc];}
this.progress+=this.docs.length;for(var u=0;u<this.docs.length;u++){this.mb.showMess("Processing "+names[u]);this.processing(this.docs[u],names[u],latlon);}};var currdeschead="";GeoXml.prototype.makeDescription=function(elem,title,depth){var d="";var len=elem.childNodes.length;var ln=0;var val;while(len--){var subelem=elem.childNodes.item(ln);var nn=subelem.nodeName;var sec=nn.split(":");var base="";if(sec.length>1){base=sec[1];}
else{base=nn;}
if(base.match(/^(visible|visibility|boundedBy|StyleMap|styleUrl|posList|coordinates|Style|Polygon|LineString|Point|LookAt|Envelope|Box|MultiPolygon|where)/)){currdeschead="";}
else{if(base.match(/#text|the_geom|SchemaData|ExtendedData|#cdata-section/)){}else{if(base.match(/Snippet/i)){}else{if(base.match(/SimpleData/)){base=subelem.getAttribute("name");}
currdeschead="<b>&nbsp;"+base+"&nbsp;</b> :";}}
val=subelem.nodeValue;if(nn=="link"){var href=subelem.getAttribute("href");if(href){val='<a href="'+href+'">'+href+'</a>';}}
if(base.match(/(\S)*(name|title)(\S)*/i)){if(!val){val=GXml.value(subelem);}
title=val;if(val&&typeof title!="undefined"&&title.length>this.maxtitlewidth){this.maxtitlewidth=title.length;}
currdeschead="";}
else{if(val&&val.match(/(\S)+/)){if(val.match(/^http:\/\/|^https:\/\//i)){val=''+val+' ';}else{if(!title||title==""){title=val;if(val&&typeof title!="undefined"&&title.length>this.maxtitlewidth){this.maxtitlewidth=title.length;}}}}if(val&&(val.match(/(\s)*/)!=true)){d+=currdeschead+"<span>"+val+"</span><br />";currdeschead="";}if(subelem.childNodes.length){var con=this.makeDescription(subelem,title,depth+1);if(con){d+=con.desc;if(typeof con.title!="undefined"&&con.title){title=con.title;if(title.length>this.maxtitlewidth){this.maxtitlewidth=title.length+depth;}}}}}}ln++;}var dc={};dc.desc=d;dc.title=title;return dc;};GeoXml.prototype.randomColor=function(){var color="#";for(var i=0;i<6;i++){var idx=parseInt(Math.random()*16,10)+1;color+=idx.toString(16);}return color;};GeoXml.prototype.handleGeomark=function(mark,idx,trans){var that=this;var desc,title,name,style;title="";desc="";var styleid=0;var lat,lon;var visible=true;if(this.hideall){visible=false;}var fill=true;var outline=true;var width,color,opacity,fillOpacity,fillColor;var cor=[];var node,nv,cm;var coords="";var poslist=[];var point_count=0;var box_count=0;var line_count=0;var poly_count=0;var p;var points=[];var cc,l;var pbounds=new GLatLngBounds();var coordset=mark.getElementsByTagName("coordinates");if(coordset.length<1){coordset=mark.getElementsByTagName("gml:coordinates");}if(coordset.length<1){coordset=[];poslist=mark.getElementsByTagName("gml:posList");if(poslist.length<1){poslist=mark.getElementsByTagName("posList");}for(l=0;l<poslist.length;l++){coords=" ";cor=GXml.value(poslist.item(l)).split(' ');if(that.isWFS){for(cc=0;cc<(cor.length-1);cc++){if(cor[cc]&&cor[cc]!=" "&&!isNaN(parseFloat(cor[cc]))){coords+=""+parseFloat(cor[cc])+","+parseFloat(cor[cc+1]);coords+=" ";cc++;}}}else{for(cc=0;cc<(cor.length-1);cc++){if(cor[cc]&&cor[cc]!=" "&&!isNaN(parseFloat(cor[cc]))){coords+=""+parseFloat(cor[cc+1])+","+parseFloat(cor[cc]);coords+=" ";cc++;}}}if(coords){if(poslist.item(l).parentNode&&(poslist.item(l).parentNode.nodeName=="gml:LineString")){line_count++;}else{poly_count++;}cm="<coordinates>"+coords+"</coordinates>";node=GXml.parse(cm);if(coordset.push){coordset.push(node);}}}var pos=mark.getElementsByTagName("gml:pos");if(pos.length<1){pos=mark.getElementsByTagName("gml:pos");}if(pos.length){for(p=0;p<pos.length;p++){nv=GXml.value(pos.item(p));cor=nv.split(" ");if(!that.isWFS){node=GXml.parse("<coordinates>"+cor[1]+","+cor[0]+"</coordinates>");}else{node=GXml.parse("<coordinates>"+cor[0]+","+cor[1]+"</coordinates>");}if(coordset.push){coordset.push(node);}}}}var newcoords=false;point_count=0;box_count=0;line_count=0;poly_count=0;var dc=that.makeDescription(mark,"");desc="<ul>"+dc.desc+"</ul>";if(!name&&dc.title){name=dc.title;if(name.length>this.maxtitlewidth){this.maxtitlewidth=name.length;}}if(newcoords&&typeof lat!="undefined"){coordset.push(""+lon+","+lat);}var lines=[];var point;var skiprender;var bits;for(var c=0;c<coordset.length;c++){skiprender=false;if(coordset[c].parentNode&&(coordset[c].parentNode.nodeName=="gml:Box"||coordset[c].parentNode.nodeName=="gml:Envelope")){skiprender=true;}coords=GXml.value(coordset[c]);coords+=" ";coords=coords.replace(/\s+/g," ");coords=coords.replace(/^ /,"");coords=coords.replace(/, /,",");var path=coords.split(" ");if(path.length==1||path[1]==""){bits=path[0].split(",");point=new GLatLng(parseFloat(bits[1])/trans.ys-trans.y,parseFloat(bits[0])/trans.xs-trans.x);that.bounds.extend(point);if(!skiprender){if(typeof name=="undefined"){name=that.unnamedplace;}if(!!that.opts.createmarker){that.opts.createmarker(point,name,desc,styleid,idx,null,visible);}else{that.createMarker(point,name,desc,styleid,idx,null,visible);}}}else{for(p=0;p<path.length-1;p++){bits=path[p].split(",");point=new GLatLng(parseFloat(bits[1])/trans.ys-trans.y,parseFloat(bits[0])/trans.xs-trans.x);points.push(point);pbounds.extend(point);}that.bounds.extend(pbounds.getNorthEast());that.bounds.extend(pbounds.getSouthWest());if(!skiprender){lines.push(points);}}}if(!lines||lines.length<1){return;}var linestring=mark.getElementsByTagName("LineString");if(linestring.length<1){linestring=mark.getElementsByTagName("gml:LineString");}if(linestring.length||line_count>0){if(!!style){width=style.width;color=style.color;opacity=style.opacity;}else{width=this.style.width;color=this.style.color;opacity=this.style.opacity;}if(typeof name=="undefined"){name=that.unnamedpath;}if(!!that.opts.createpolyline){that.opts.createpolyline(lines,color,width,opacity,pbounds,name,desc,idx,visible);}else{that.createPolyline(lines,color,width,opacity,pbounds,name,desc,idx,visible);}}var polygons=mark.getElementsByTagName("Polygon");if(polygons.length<1){polygons=mark.getElementsByTagName("gml:Polygon");}if(polygons.length||poly_count>0){if(!!style){width=style.width;color=style.color;opacity=style.opacity;fillOpacity=style.fillOpacity;fillColor=style.fillColor;fill=style.file;outline=style.outline;}fillColor=this.randomColor();color=this.randomColor();fill=1;outline=1;if(typeof name=="undefined"){name=that.unnamedarea;}if(!!that.opts.createpolygon){that.opts.createpolygon(lines,color,width,opacity,fillColor,fillOpacity,pbounds,name,desc,idx,visible,fill,outline);}else{that.createPolygon(lines,color,width,opacity,fillColor,fillOpacity,pbounds,name,desc,idx,visible,fill,outline);}}};GeoXml.prototype.handlePlacemark=function(mark,idx,depth,fullstyle){var that=this;var desc,title,name,style;title="";desc="";var styleid=0;var lat,lon;var visible=true;if(this.hideall){visible=false;}var newcoords=false;var outline;var opacity;var fillcolor;var fillOpacity;var color;var width;var pbounds;var fill;var points=[];var lines=[];var bits=[];var point;var cor,node,cm,nv;var l,pos,p,j,k,cc;var kml_id=mark.getAttribute("id");var point_count=0;var box_count=0;var line_count=0;var poly_count=0;var coords="";l=mark.getAttribute("lat");if(typeof l!="undefined"){lat=l;}l=mark.getAttribute("lon");if(typeof l!="undefined"){newcoords=true;lon=l;}l=0;var coordset=mark.getElementsByTagName("coordinates");if(coordset.length<1){coordset=mark.getElementsByTagName("gml:coordinates");}if(coordset.length<1){coordset=[];var poslist=mark.getElementsByTagName("gml:posList");if(!poslist.length){poslist=mark.getElementsByTagName("posList");}for(l=0;l<poslist.length;l++){coords=" ";var plitem=GXml.value(poslist.item(l))+" ";plitem=plitem.replace(/(\s)+/g,' ');cor=plitem.split(' ');if(that.isWFS){for(cc=0;cc<(cor.length-1);cc++){if(!isNaN(parseFloat(cor[cc]))&&!isNaN(parseFloat(cor[cc+1]))){coords+=""+parseFloat(cor[cc])+","+parseFloat(cor[cc+1]);coords+=" ";cc++;}}}else{for(cc=0;cc<(cor.length-1);cc++){if(!isNaN(parseFloat(cor[cc]))&&!isNaN(parseFloat(cor[cc+1]))){coords+=""+parseFloat(cor[cc+1])+","+parseFloat(cor[cc]);coords+=" ";cc++;}}}if(coords){if(poslist.item(l).parentNode&&(poslist.item(l).parentNode.nodeName=="gml:LineString")){line_count++;}else{poly_count++;}cm="<coordinates>"+coords+"</coordinates>";node=GXml.parse(cm);if(coordset.push){coordset.push(node);}}}pos=mark.getElementsByTagName("gml:pos");if(pos.length<1){pos=mark.getElementsByTagName("gml:pos");}if(pos.length){for(p=0;p<pos.length;p++){nv=GXml.value(pos.item(p))+" ";cor=nv.split(' ');if(!that.isWFS){node=GXml.parse("<coordinates>"+cor[1]+","+cor[0]+"</coordinates>");}else{node=GXml.parse("<coordinates>"+cor[0]+","+cor[1]+"</coordinates>");}if(coordset.push){coordset.push(node);}}}}for(var ln=0;ln<mark.childNodes.length;ln++){var nn=mark.childNodes.item(ln).nodeName;nv=GXml.value(mark.childNodes.item(ln));var ns=nn.split(":");var base;if(ns.length>1){base=ns[1].toLowerCase();}else{base=ns[0].toLowerCase();}var processme=false;switch(base){case"name":name=nv;if(name.length+depth>this.maxtitlewidth){this.maxtitlewidth=name.length+depth;}break;case"title":title=nv;if(title.length+depth>this.maxtitlewidth){this.maxtitlewidth=title.length+depth;}break;case"desc":case"description":desc=GeoXml.getDescription(mark.childNodes.item(ln));if(!desc){desc=nv;}if(that.opts.preloadHTML&&desc&&desc.match(/<(\s)*img/i)){var preload=document.createElement("span");preload.style.visibility="visible";preload.style.position="absolute";preload.style.left="-1200px";preload.style.top="-1200px";preload.style.zIndex=this.overlayman.markers.length;document.body.appendChild(preload);preload.innerHTML=desc;}if(desc.match(/^http:\/\//i)){var flink=desc.split(/(\s)+/);if(flink.length>1){desc="<a href=\""+flink[0]+"\">"+flink[0]+"</a>";for(var i=1;i<flink.length;i++){desc+=flink[i];}}else{desc="<a href=\""+desc+"\">"+desc+"</a>";}}break;case"visibility":if(nv=="0"){visible=false;}break;case"href":case"link":if(nv){desc+="<p><a target='_blank' href='"+nv+"'>link</a></p>";}else{var href=mark.childNodes.item(ln).getAttribute("href");if(href){var imtype=mark.childNodes.item(ln).getAttribute("type");if(imtype&&imtype.match(/image/)){desc+="<img style=\"width:256px\" src='"+href+"' />";}}}break;case"author":desc+="<p><b>author:</b>"+nv+"</p>";break;case"time":desc+="<p><b>time:</b>"+nv+"</p>";break;case"lat":lat=nv;break;case"long":lon=nv;newcoords=true;break;case"point":point_count++;processme=true;break;case"line":line_count++;processme=true;break;case"box":box_count++;processme=true;break;case"polygon":poly_count++;processme=true;break;case"styleurl":styleid=nv;break;case"stylemap":var found=false;node=mark.childNodes.item(ln);for(j=0;(j<node.childNodes.length&&!found);j++){var pair=node.childNodes[j];for(k=0;(k<pair.childNodes.length&&!found);k++){var pn=pair.childNodes[k].nodeName;if(pn=="Style"){style=this.handleStyle(pair.childNodes[k]);found=true;}}}break;case"Style":case"style":style=this.handleStyle(mark.childNodes.item(ln));break;}if(processme){cor=nv.split(' ');coords="";for(cc=0;cc<(cor.length-1);cc++){if(!isNaN(parseFloat(cor[cc]))&&!isNaN(parseFloat(cor[cc+1]))){coords+=""+parseFloat(cor[cc+1])+","+parseFloat(cor[cc]);coords+=" ";cc++;}}if(coords!=""){node=GXml.parse("<coordinates>"+coords+"</coordinates>");if(coordset.push){coordset.push(node);}}}}if(!name&&title){name=title;}if(fullstyle){style=fullstyle;}if(styleid){style=this.styles[styleid];}if(typeof desc=="undefined"||!desc){var dc=that.makeDescription(mark,"");desc="<ul>"+dc.desc+"</ul>";if(!name&&dc.title){name=dc.title;if((name.length+depth)>this.maxtitlewidth){this.maxtitlewidth=name.length+depth;}}}if(newcoords&&typeof lat!="undefined"){if(lat){var cs=""+lon+","+lat+" ";node=GXml.parse("<coordinates>"+cs+"</coordinates>");coordset.push(node);}}for(var c=0;c<coordset.length;c++){var skiprender=false;if(coordset[c].parentNode&&(coordset[c].parentNode.nodeName.match(/^(gml:Box|gml:Envelope)/i))){skiprender=true;}coords=GXml.value(coordset[c]);coords+=" ";coords=coords.replace(/(\s)+/g," ");coords=coords.replace(/^ /,"");coords=coords.replace(/, /,",");var path=coords.split(" ");if(path.length==1||path[1]==""){bits=path[0].split(",");point=new GLatLng(parseFloat(bits[1]),parseFloat(bits[0]));this.overlayman.folderBounds[idx].extend(point);if(!skiprender){if(typeof name=="undefined"){name=that.unnamedplace;}if(!!that.opts.createmarker){that.opts.createmarker(point,name,desc,styleid,idx,style,visible,kml_id);}else{that.createMarker(point,name,desc,styleid,idx,style,visible,kml_id);}}}else{points=[];pbounds=new GLatLngBounds();for(p=0;p<path.length-1;p++){bits=path[p].split(",");point=new GLatLng(parseFloat(bits[1]),parseFloat(bits[0]));points.push(point);pbounds.extend(point);}this.overlayman.folderBounds[idx].extend(pbounds.getSouthWest());this.overlayman.folderBounds[idx].extend(pbounds.getNorthEast());this.bounds.extend(pbounds.getSouthWest());this.bounds.extend(pbounds.getNorthEast());if(!skiprender){lines.push(points);}}}if(!lines||lines.length<1){return;}var linestring=mark.getElementsByTagName("LineString");if(linestring.length<1){linestring=mark.getElementsByTagName("gml:LineString");}if(linestring.length||line_count>0){if(!!style){width=style.width;color=style.color;opacity=style.opacity;}else{width=this.style.width;color=this.style.color;opacity=this.style.opacity;}if(typeof name=="undefined"){name=unnamedpath;}if(!!that.opts.createpolyline){that.opts.createpolyline(lines,color,width,opacity,pbounds,name,desc,idx,visible,kml_id);}else{that.createPolyline(lines,color,width,opacity,pbounds,name,desc,idx,visible,kml_id);}}var polygons=mark.getElementsByTagName("Polygon");if(polygons.length<1){polygons=mark.getElementsByTagName("gml:Polygon");}if(polygons.length||poly_count>0){if(!!style){width=style.width;color=style.color;opacity=style.opacity;fillOpacity=style.fillOpacity;fillcolor=style.fillcolor;fill=style.fill;outline=style.outline;}if(typeof fill=="undefined"){fill=1;}if(typeof color=="undefined"){color=this.style.color;}if(typeof fillcolor=="undefined"){fillcolor=this.randomColor();}if(typeof name=="undefined"){name=that.unnamedarea;}if(!!that.opts.createpolygon){that.opts.createpolygon(lines,color,width,opacity,fillcolor,fillOpacity,pbounds,name,desc,idx,visible,fill,outline,kml_id);}else{that.createPolygon(lines,color,width,opacity,fillcolor,fillOpacity,pbounds,name,desc,idx,visible,fill,outline,kml_id);}}};GeoXml.prototype.makeIcon=function(tempstyle,href){if(!!href){if(!!this.opts.baseicon){tempstyle=new GIcon(this.opts.baseicon,href);tempstyle.href=href;}else{tempstyle=new GIcon(G_DEFAULT_ICON,href);tempstyle.iconSize=new GSize(32,32);tempstyle.shadowSize=new GSize(59,32);tempstyle.dragCrossAnchor=new GPoint(2,8);tempstyle.iconAnchor=new GPoint(16,32);tempstyle.href=href;if(this.opts.printgif){var bits=href.split("/");var gif=bits[bits.length-1];gif=this.opts.printgifpath+gif.replace(/.png/i,".gif");tempstyle.printImage=gif;tempstyle.mozPrintImage=gif;}if(!!this.opts.noshadow){tempstyle.shadow="";}else{if(href.indexOf("/red.png")>-1||href.indexOf("/blue.png")>-1||href.indexOf("/green.png")>-1||href.indexOf("/yellow.png")>-1||href.indexOf("/lightblue.png")>-1||href.indexOf("/purple.png")>-1||href.indexOf("/orange.png")>-1||href.indexOf("/pink.png")>-1||href.indexOf("-dot.png")>-1){tempstyle.shadow="http://maps.google.com/mapfiles/ms/icons/msmarker.shadow.png";}else if(href.indexOf("-pushpin.png")>-1||href.indexOf("/pause.png")>-1||href.indexOf("/go.png")>-1||href.indexOf("/stop.png")>-1){tempstyle.shadow="http://maps.google.com/mapfiles/ms/icons/pushpin_shadow.png";}else{var shadow=href.replace(".png",".shadow.png");if(shadow.indexOf(".jpg")){shadow="";}tempstyle.shadow=shadow;}}}}if(this.opts.noshadow){tempstyle.shadow="";}return tempstyle;};GeoXml.prototype.handleStyle=function(style,sid){var icons=style.getElementsByTagName("Icon");var tempstyle,opacity;var aa,bb,gg,rr;var fill,href,color,colormode,outline;if(icons.length>0){href=GXml.value(icons[0].getElementsByTagName("href")[0]);tempstyle=this.makeIcon(tempstyle,href);}var linestyles=style.getElementsByTagName("LineStyle");if(linestyles.length>0){var width=parseInt(GXml.value(linestyles[0].getElementsByTagName("width")[0]),10);if(width<1){width=5;}color=GXml.value(linestyles[0].getElementsByTagName("color")[0]);aa=color.substr(0,2);bb=color.substr(2,2);gg=color.substr(4,2);rr=color.substr(6,2);color="#"+rr+gg+bb;opacity=parseInt(aa,16)/256;if(!tempstyle){tempstyle={};}tempstyle.color=color;tempstyle.width=width;tempstyle.opacity=opacity;}var polystyles=style.getElementsByTagName("PolyStyle");if(polystyles.length>0){fill=parseInt(GXml.value(polystyles[0].getElementsByTagName("fill")[0]),10);outline=parseInt(GXml.value(polystyles[0].getElementsByTagName("outline")[0]),10);color=GXml.value(polystyles[0].getElementsByTagName("color")[0]);colormode=GXml.value(polystyles[0].getElementsByTagName("colorMode")[0]);if(polystyles[0].getElementsByTagName("fill").length==0){fill=1;}if(polystyles[0].getElementsByTagName("outline").length==0){outline=1;}aa=color.substr(0,2);bb=color.substr(2,2);gg=color.substr(4,2);rr=color.substr(6,2);color="#"+rr+gg+bb;opacity=parseInt(aa,16)/256;if(!tempstyle){tempstyle={};}tempstyle.fill=fill;tempstyle.outline=outline;if(colormode!="random"){tempstyle.fillcolor=color;}else{tempstyle.colortint=color;}tempstyle.fillOpacity=opacity;if(!fill){tempstyle.fillOpacity=0;}if(!outline){tempstyle.opacity=0;}}if(sid){this.styles["#"+sid]=tempstyle;}return tempstyle;};GeoXml.prototype.processKML=function(node,marks,title,sbid,depth,paren){var that=this;var thismap=this.map;var icon;var grouptitle;var keepopen=this.forcefoldersopen;if(node.nodeName=="kml"){icon=this.docicon;}if(node.nodeName=="Document"){icon=this.kmlicon;}if(node.nodeName=="Folder"){icon=this.foldericon;grouptitle=title;}var pm=[];var sf=[];var desc="";var snip="";var i;var visible=false;if(!this.hideall){visible=true;}var boundsmodified=false;var networklink=false;var url;var ground=null;var opacity=1.0;var wmsbounds;var makewms=false;var wmslist=[];var mytitle;var color;var ol;var n,ne,sw,se;var html;var kml_id=node.getAttribute("id");for(var ln=0;ln<node.childNodes.length;ln++){var nextn=node.childNodes.item(ln);var nn=nextn.nodeName;var nv=nextn.nodeValue;switch(nn){case"name":case"title":title=GXml.value(nextn);if(title.length+depth>this.maxtitlewidth){this.maxtitlewidth=title.length+depth;}break;case"Folder":case"Document":sf.push(nextn);break;case"GroundOverlay":url=GXml.value(nextn.getElementsByTagName("href")[0]);var north=parseFloat(GXml.value(nextn.getElementsByTagName("north")[0]));var south=parseFloat(GXml.value(nextn.getElementsByTagName("south")[0]));var east=parseFloat(GXml.value(nextn.getElementsByTagName("east")[0]));var west=parseFloat(GXml.value(nextn.getElementsByTagName("west")[0]));var attr=GXml.value(nextn.getElementsByTagName("attribution")[0]);sw=new GLatLng(south,west);ne=new GLatLng(north,east);this.bounds.extend(sw);this.bounds.extend(ne);color=GXml.value(nextn.getElementsByTagName("color")[0]);opacity=parseInt(color.substring(1,3),16)/256;mytitle=GXml.value(nextn.getElementsByTagName("name")[0]);var arcims=/arcimsproxy/i;if(url.match(arcims)){url+="&bbox="+west+","+south+","+east+","+north+"&response=img";wmsbounds=new GLatLngBounds(sw,ne);makewms=true;ol=this.makeWMSTileLayer(url,visible,mytitle,opacity,attr,title,wmsbounds);if(ol){ol.bounds=wmsbounds;ol.title=mytitle;ol.opacity=opacity;ol.visible=visible;ol.url=url;if(!this.quiet){this.mb.showMess("Adding Tiled ArcIms Overlay "+title,1000);}wmslist.push(ol);}}else{var rs=/request=getmap/i;if(url.match(rs)){url+="&bbox="+west+","+south+","+east+","+north;wmsbounds=new GLatLngBounds(sw,ne);makewms=true;ol=this.makeWMSTileLayer(url,visible,mytitle,opacity,attr,title,wmsbounds);if(ol){ol.bounds=wmsbounds;ol.title=mytitle;ol.opacity=opacity;ol.visible=visible;ol.url=url;if(!this.quiet){this.mb.showMess("Adding Tiled WMS Overlay "+title,1000);}wmslist.push(ol);}}else{wmsbounds=new GLatLngBounds(sw,ne);ground=new GGroundOverlay(url,wmsbounds);ground.bounds=wmsbounds;ground.getBounds=function(){return this.bounds;};boundsmodified=true;makewms=false;}}break;case"NetworkLink":url=GXml.value(nextn.getElementsByTagName("href")[0]);networklink=true;break;case"description":case"Description":desc=GeoXml.getDescription(nextn);break;case"open":if(GXml.value(nextn)=="1"){keepopen=true;}if(GXml.value(nextn)=="0"){keepopen=this.forcefoldersopen;}break;case"visibility":if(GXml.value(nextn)=="0"){visible=false;}break;case"snippet":snip=GXml.value(nextn);break;default:for(var k=0;k<marks.length;k++){if(nn==marks[k]){pm.push(nextn);}}}}var folderid;var idx=this.overlayman.folders.length;var me=paren;if(sf.length>1||pm.length||ground||makewms){this.overlayman.folders.push([]);this.overlayman.subfolders.push([]);this.overlayman.folderhtml.push([]);this.overlayman.folderhtmlast.push(0);this.overlayman.folderBounds.push(new GLatLngBounds());this.kml.push(new KMLObj(title,desc,false,idx));me=this.kml.length-1;folderid=this.createFolder(idx,title,sbid,icon,desc,snip,true,visible);}else{folderid=sbid;}if(node.nodeName=="Folder"||node.nodeName=="Document"){this.kml[me].open=keepopen;this.kml[me].folderid=folderid;}if(ground||makewms){this.kml[this.kml.length-1].visibility=visible;this.kml[this.kml.length-1].groundOverlays.push({"url":url,"bounds":wmsbounds});}if(networklink){var re=/&amp;/g;url=url.replace(re,"&");var nl=/\n/g;url=url.replace(nl,"");this.progress++;if(!topwin.standalone){if(typeof this.proxy!="undefined"){url=this.proxy+escape(url);}}var comm=this.myvar+".loadXMLUrl('"+url+"','"+title+"',null,null,'"+sbid+"');";setTimeout(comm,1000);return;}if(makewms&&wmslist.length){for(var wo=0;wo<wmslist.length;wo++){var ol=wmslist[wo];var blob="";if(this.basesidebar){var n=this.overlayman.markers.length;if(!this.nolegend){var myurl=ol.url.replace(/height=(\d)+/i,"height=100");myurl=myurl.replace(/width=(\d)+/i,"width=100");blob=' < img src = "'+myurl+'" style = "width:100px" />';}}
parm=this.myvar+"$$$"+ol.title+"$$$tiledoverlay$$$"+n+"$$$"+blob+"$$$"+ol.visible+"$$$"+(this.baseLayers.length-1);var html=ol.desc;var thismap=this.map;GEvent.addListener(ol,"zoomto",function(){thismap.setZoom(thismap.getBoundsZoomLevel(this.getBounds()));thismap.panTo(this.getBounds().getCenter());});this.overlayman.AddMarker(ol,title,idx,parm,true,true);}}
if(ground){if(this.basesidebar){var n=this.overlayman.markers.length;var blob='<span style="background-color:black;border:2px solid brown;">&nbsp;&nbsp;&nbsp;&nbsp;</span> ';parm=this.myvar+"$$$"+title+"$$$polygon$$$"+n+"$$$"+blob+"$$$"+visible+"$$$null";var html=desc;var thismap=this.map;GEvent.addListener(ground,"zoomto",function(){thismap.setZoom(thismap.getBoundsZoomLevel(ground.getBounds()));thismap.panTo(ground.getBounds().getCenter());});this.overlayman.folderBounds[idx].extend(ground.getBounds().getSouthWest());this.overlayman.folderBounds[idx].extend(ground.getBounds().getNorthEast());boundsmodified=true;this.overlayman.AddMarker(ground,title,idx,parm,visible);}
this.map.addOverlay(ground);}
for(i=0;i<pm.length;i++){this.handlePlacemark(pm[i],idx,depth+1);}
var fc=0;for(i=0;i<sf.length;i++){var fid=this.processKML(sf[i],marks,title,folderid,depth+1,me);if(typeof fid=="number"&&fid!=idx){var sub=this.overlayman.folderBounds[fid];if(!sub){this.overlayman.folderBounds[fid]=new GLatLngBounds();}
else{var sw=this.overlayman.folderBounds[fid].getSouthWest();var ne=this.overlayman.folderBounds[fid].getNorthEast();this.overlayman.folderBounds[idx].extend(sw);this.overlayman.folderBounds[idx].extend(ne);}
this.overlayman.subfolders[idx].push(fid);if(fid!=idx){this.kml[idx].folders.push(fid);}
fc++;}}
if(fc||pm.length||boundsmodified){this.bounds.extend(this.overlayman.folderBounds[idx].getSouthWest());this.bounds.extend(this.overlayman.folderBounds[idx].getNorthEast());}
if(sf.length==0&&pm.length==0&&!this.opts.basesidebar){this.ParseURL();}
return idx;};GeoXml.prototype.processGPX=function(node,title,sbid,depth){var icon;if(node.nodeName=="gpx"){icon=this.gmlicon;}
if(node.nodeName=="rte"||node.nodeName=="trk"||node.nodeName=="trkseg"){icon=this.foldericon;}
var pm=[];var sf=[];var desc="";var snip="";var i,lon,lat,l;var open=this.forcefoldersopen;var coords="";var visible=true;for(var ln=0;ln<node.childNodes.length;ln++){var nextn=node.childNodes.item(ln);var nn=nextn.nodeName;if(nn=="name"||nn=="title"){title=GXml.value(nextn);if(title.length+depth>this.maxtitlewidth){this.maxtitlewidth=title.length+depth;}}
if(nn=="bounds"){var gpxBound=GXml.value(nextn);var attributes=nextn.attributes;var minlon=parseFloat(attributes.getNamedItem("minlon").value);var minlat=parseFloat(attributes.getNamedItem("minlat").value);var maxlon=parseFloat(attributes.getNamedItem("maxlon").value);var maxlat=parseFloat(attributes.getNamedItem("maxlat").value);var gpxBound=new GLatLngBounds();gpxBound.extend(new GLatLng(minlat,minlon));gpxBound.extend(new GLatLng(maxlat,maxlon));if(!this.map.isPermitedToCreateArea(gpxBound)){return-1;}}
if(nn=="name"&&node.nodeName=="trk"){this.name=GXml.value(nextn);}
else if(nn=="desc"&&node.nodeName=="trk"){this.description=GXml.value(nextn);}
if(nn=="rte"){sf.push(nextn);}
if(nn=="trk"){sf.push(nextn);}
if(nn=="trkseg"){sf.push(nextn);}
if(nn=="trkpt"){pm.push(nextn);l=nextn.getAttribute("lat");if(typeof l!="undefined"){lat=l;}
l=nextn.getAttribute("lon");if(typeof l!="undefined"){lon=l;coords+=lon+","+lat+" ";}}
if(nn=="rtept"){pm.push(nextn);l=nextn.getAttribute("lat");if(typeof l!="undefined"){lat=l;}
l=nextn.getAttribute("lon");if(typeof l!="undefined"){lon=l;coords+=lon+","+lat+" ";}}
if(nn=="wpt"){pm.push(nextn);}
if(nn=="description"||nn=="desc"){desc=GXml.value(nextn);}}
if(coords.length){var nc="<?xml version=\"1.0\"?><Placemark><name>"+title+"</name><description>"+desc+"</description><LineString><coordinates>"+coords+"</coordinates></LineString></Placemark>";var pathnode=GXml.parse(nc).documentElement;pm.push(pathnode);}
var folderid;var idx=this.overlayman.folders.length;if(pm.length||node.nodeName=="gpx"){this.overlayman.folders.push([]);this.overlayman.subfolders.push([]);this.overlayman.folderhtml.push([]);this.overlayman.folderhtmlast.push(0);this.overlayman.folderBounds.push(new GLatLngBounds());this.kml.push(new KMLObj(title,desc,open,idx));folderid=this.createFolder(idx,title,sbid,icon,desc,snip,true,visible);}
else{folderid=sbid;}
for(i=0;i<pm.length;i++){this.handlePlacemark(pm[i],idx,depth+1);}
for(i=0;i<sf.length;i++){var fid=this.processGPX(sf[i],title,folderid,depth+1);this.overlayman.subfolders[idx].push(fid);this.overlayman.folderBounds[idx].extend(this.overlayman.folderBounds[fid].getSouthWest());this.overlayman.folderBounds[idx].extend(this.overlayman.folderBounds[fid].getNorthEast());}
if(this.overlayman.folderBounds[idx]){this.bounds.extend(this.overlayman.folderBounds[idx].getSouthWest());this.bounds.extend(this.overlayman.folderBounds[idx].getNorthEast());}
return idx;};GeoXml.prototype.ParseURL=function(){var query=topwin.location.search.substring(1);var pairs=query.split("&");var marks=this.overlayman.markers;for(var i=0;i<pairs.length;i++){var pos=pairs[i].indexOf("=");var argname=pairs[i].substring(0,pos).toLowerCase();var val=unescape(pairs[i].substring(pos+1));var m=0;var nae;if(val){switch(argname){case"openbyid":for(m=0;m<marks.length;m++){nae=marks[m].id;if(nae==val){this.overlayman.markers[m].show();this.overlayman.markers[m].hidden=false;GEvent.trigger(this.overlayman.markers[m],"click");break;}}
break;case"kml":case"url":case"src":case"geoxml":this.urls.push(val);this.parse();break;case"openbyname":for(m=0;m<marks.length;m++){nae=marks[m].title;if(nae==val){this.overlayman.markers[m].show();this.overlayman.markers[m].hidden=false;GEvent.trigger(this.overlayman.markers[m],"click");break;}}
break;}}}};GeoXml.prototype.processing=function(xmlDoc,title,latlon,desc,sbid){this.overlayman.miStart=new Date();if(!desc){desc=title;}
var that=this;if(!sbid){sbid=0;}
var shadow;var idx;var root=xmlDoc.documentElement;if(!root){return 0;}
var placemarks=[];var name;var pname;var styles;var basename=root.nodeName;var keepopen=that.forcefoldersopen;var bases=basename.split(":");if(bases.length>1){basename=bases[1];}
var bar,sid,i;that.wfs=false;if(basename=="FeatureCollection"){bar=Lance$(that.basesidebar);if(!title){title=name;}
if(typeof title=="undefined"){title="Un-named GML";}
that.isWFS=true;if(title.length>that.maxtitlewidth){that.maxtitlewidth=title.length;}
if(bar){bar.style.display="";}
idx=that.overlayman.folders.length;that.processGML(root,title,latlon,desc,(that.kml.length-1));that.kml[0].folders.push(idx);}
if(basename=="gpx"){if(!title){title=name;}
if(typeof title=="undefined"){title="Un-named GPX";}
that.title=title;if(title.length>that.maxtitlewidth){that.maxtitlewidth=title.length;}
bar=Lance$(that.basesidebar);if(bar){bar.style.display="";}
idx=that.overlayman.folders.length;var flag=that.processGPX(root,title,that.basesidebar,sbid);if(flag==-1){popupHandler.showErrorPopup(PoiMsg.js_msg.permissionDenied.route());GEvent.trigger(that,"restricted");return 0;}
that.kml[0].folders.push(idx);}
else{if(basename=="kml"){styles=root.getElementsByTagName("Style");for(i=0;i<styles.length;i++){sid=styles[i].getAttribute("id");if(sid){that.handleStyle(styles[i],sid);}}
styles=root.getElementsByTagName("StyleMap");for(i=0;i<styles.length;i++){sid=styles[i].getAttribute("id");if(sid){var found=false;var node=styles[i];for(var j=0;(j<node.childNodes.length&&!found);j++){var pair=node.childNodes[j];for(var k=0;(k<pair.childNodes.length&&!found);k++){var pn=pair.childNodes[k].nodeName;if(pn=="styleUrl"){var pid=GXml.value(pair.childNodes[k]);that.styles["#"+sid]=that.styles[pid];found=true;}
if(pn=="Style"){that.handleStyle(pair.childNodes[k],sid);found=true;}}}}}
if(!title){title=name;}
if(typeof title=="undefined"){title="KML Document";}
that.title=title;if(title.length>that.maxtitlewidth){that.maxtitlewidth=title.length;}
var marknames=["Placemark"];var schema=root.getElementsByTagName("Schema");for(var s=0;s<schema.length;s++){pname=schema[s].getAttribute("parent");if(pname=="Placemark"){pname=schema[s].getAttribute("name");marknames.push(pname);}}
bar=Lance$(that.basesidebar);if(bar){bar.style.display="";}
idx=that.overlayman.folders.length;var paren=that.kml.length-1;var fid=that.processKML(root,marknames,title,that.basesidebar,idx,paren);that.kml[paren].folders.push(idx);}
else{placemarks=root.getElementsByTagName("item");if(placemarks.length<1){placemarks=root.getElementsByTagName("atom");}
if(placemarks.length<1){placemarks=root.getElementsByTagName("entry");}
if(!title){title=name;}
if(typeof title=="undefined"){title="News Feed";}
that.title=title;if(title.length>that.maxtitlewidth){that.maxtitlewidth=title.length;}
var style;if(that.opts.baseicon){style=that.opts.baseicon;style.href=style.image;}
else{style=new GIcon(G_DEFAULT_ICON,that.rssicon);style.iconSize=new GSize(32,32);style.shadowSize=new GSize(59,32);style.dragCrossAnchor=new GPoint(2,8);style.iconAnchor=new GPoint(16,32);style.href=that.rssicon;shadow=that.rssicon.replace(".png",".shadow.png");style.shadow=shadow+"_shadow.png";}
style.color="#00FFFF";style.width="3";style.opacity=0.50;if(!desc){desc="RSS feed";}
that.kml[0].folders.push(that.overlayman.folders.length);if(placemarks.length){bar=Lance$(that.basesidebar);if(bar){bar.style.display="";}
that.overlayman.folders.push([]);that.overlayman.folderhtml.push([]);that.overlayman.folderhtmlast.push(0);that.overlayman.folderBounds.push(new GLatLngBounds());idx=that.overlayman.folders.length-1;that.kml.push(new KMLObj(title,desc,keepopen,idx));that.kml[that.kml.length-1].open=keepopen;if(that.basesidebar){var visible=true;if(that.hideall){visible=false;}
var folderid=that.createFolder(idx,title,that.basesidebar,that.globalicon,desc,null,keepopen,visible);}
for(i=0;i<placemarks.length;i++){that.handlePlacemark(placemarks[i],idx,sbid,style);}}}}
that.progress--;if(that.progress==0){GEvent.trigger(that,"initialized");if(!that.opts.sidebarid){that.mb.showMess("Finished Parsing",1000);}
if(!that.opts.nozoom&&!that.basesidebar){that.map.setCenter(that.bounds.getCenter(),that.map.getBoundsZoomLevel(that.bounds));}}};GeoXml.prototype.createFolder=function(idx,title,sbid,icon,desc,snippet,keepopen,visible){var sb=Lance$(sbid);keepopen=true;var folderid=this.myvar+'_folder'+idx;var checked="";if(visible){checked=" checked ";}
this.overlayman.folderhtml[folderid]="";var disp="display:block";var fw="font-weight:normal";if(typeof keepopen=="undefined"||!keepopen){disp="display:none";fw="font-weight:bold";}
if(!desc||desc==""){desc=title;}
desc=escape(desc);var htm='<ul><input type="checkbox" id="'+this.myvar+''+idx+'FCB" style="vertical-align:middle" ';htm+=checked;htm+='onclick="'+this.myvar+'.toggleContents('+idx+',this.checked)">';htm+='&nbsp;<span title="'+snippet+'" id="'+this.myvar+'TB'+idx+'" oncontextmenu=\"'+this.myvar+'.saveJSON('+idx+');\" onclick="'+this.myvar+'.toggleFolder('+idx+')" style=\"'+fw+'\">';htm+='<img style=\"vertical-align:text-top;padding:0;margin:0\" height=\"16\" border=\"0\" src="'+icon+'" /></span>&nbsp;';htm+='<a href="#" onclick="'+this.myvar+'.overlayman.zoomToFolder('+idx+');'+this.myvar+'.mb.showMess(\''+desc+'\',3000);return false;">'+title+'</a><br><div id=\"'+folderid+'\" style="'+disp+'"></div></ul>';if(sb){sb.innerHTML=sb.innerHTML+htm;}
return folderid;};GeoXml.prototype.processGML=function(root,title,latlon,desc,me){var that=this;var isWFS=false;var placemarks=[];var srsName;var isLatLon=false;var xmin=0;var ymin=0;var xscale=1;var yscale=1;var points,pt,pts;var coor,coorstr;var x,y,k,i;var name=title;var visible=true;if(this.hideall){visible=false;}
var keepopen=that.allfoldersopen;var pt1,pt2,box;for(var ln=0;ln<root.childNodes.length;ln++){var kid=root.childNodes.item(ln).nodeName;var n=root.childNodes.item(ln);if(kid=="gml:boundedBy"||kid=="boundedBy"){for(var j=0;j<n.childNodes.length;j++){var nn=n.childNodes.item(j).nodeName;var llre=/CRS:84|(4326|4269)$/i;if(nn=="Box"||nn=="gml:Box"){box=n.childNodes.item(j);srsName=n.childNodes.item(j).getAttribute("srsName");if(srsName.match(llre)){isLatLon=true;}
else{alert("SRSname ="+srsName+"; attempting to create transform");for(k=0;k<box.childNodes.length;k++){coor=box.childNodes.item(k);if(coor.nodeName=="gml:coordinates"||coor.nodeName=="coordinates"){coorstr=GXml.value(coor);pts=coorstr.split(" ");pt1=pts[0].split(",");pt2=pts[1].split(",");xscale=(parseFloat(pt2[0])-parseFloat(pt1[0]))/(latlon.xmax-latlon.xmin);yscale=(parseFloat(pt2[1])-parseFloat(pt1[1]))/(latlon.ymax-latlon.ymin);xmin=pt1[0]/xscale-latlon.xmin;ymin=pt1[1]/yscale-latlon.ymin;}}}
break;}
if(nn=="Envelope"||nn=="gml:Envelope"){box=n.childNodes.item(j);srsName=n.childNodes.item(j).getAttribute("srsName");if(srsName.match(llre)){isLatLon=true;}
else{alert("SRSname ="+srsName+"; attempting to create transform");for(k=0;k<box.childNodes.length;k++){coor=box.childNodes.item(k);if(coor.nodeName=="gml:coordinates"||coor.nodeName=="coordinates"){pts=coor.split(" ");var b={"xmin":100000000,"ymin":100000000,"xmax":-100000000,"ymax":-100000000};for(var m=0;m<pts.length-1;m++){pt=pts[m].split(",");x=parseFloat(pt[0]);y=parseFloat(pt[1]);if(x<b.xmin){b.xmin=x;}
if(y<b.ymin){b.ymin=y;}
if(x>b.xmax){b.xmax=x;}
if(y>b.ymax){b.ymax=y;}}
xscale=(b.xmax-b.xmin)/(latlon.xmax-latlon.xmin);yscale=(b.ymax-b.ymin)/(latlon.ymax-latlon.ymin);xmin=b.xmin/xscale-latlon.xmin;ymin=b.ymin/yscale-latlon.ymin;}}}}
break;}}
if(kid=="gml:featureMember"||kid=="featureMember"){placemarks.push(n);}}
var folderid;if(!title){title=name;}
this.title=title;if(placemarks.length<1){alert("No features found in "+title);this.mb.showMess("No features found in "+title,3000);}
else{this.mb.showMess("Adding "+placemarks.length+" features found in "+title);this.overlayman.folders.push([]);this.overlayman.folderhtml.push([]);this.overlayman.folderhtmlast.push(0);this.overlayman.folderBounds.push(new GLatLngBounds());var idx=this.overlayman.folders.length-1;if(this.basesidebar){folderid=this.createFolder(idx,title,this.basesidebar,this.gmlicon,desc,null,keepopen,visible);}
this.kml.push(new KMLObj(title,desc,true,idx));this.kml[me].open=that.opts.allfoldersopen;this.kml[me].folderid=folderid;if(isLatLon){for(i=0;i<placemarks.length;i++){this.handlePlacemark(placemarks[i],idx,0);}}
else{var trans={"xs":xscale,"ys":yscale,"x":xmin,"y":ymin};for(i=0;i<placemarks.length;i++){this.handleGeomark(placemarks[i],idx,trans,0);}}}};PolylineEncoder=function(numLevels,zoomFactor,verySmall,forceEndpoints){var i;if(!numLevels){numLevels=18;}
if(!zoomFactor){zoomFactor=2;}
if(!verySmall){verySmall=0.0000001;}
if(!forceEndpoints){forceEndpoints=true;}
this.numLevels=numLevels;this.zoomFactor=zoomFactor;this.verySmall=verySmall;this.veryTiny=verySmall*verySmall;this.forceEndpoints=forceEndpoints;this.zoomLevelBreaks=[];for(i=0;i<numLevels;i++){this.zoomLevelBreaks[i]=verySmall*Math.pow(zoomFactor,numLevels-i-1);this.zoomLevelBreaks[i]*=this.zoomLevelBreaks[i];}};PolylineEncoder.prototype.dpEncode=function(points){var absMaxDist=0;var stack=[];var dists=[];var maxDist,maxLoc,temp,first,last,current;var i,encodedPoints,encodedLevels;var segmentLength;stack.push([0,points.length-1]);while(stack.length>0){current=stack.pop();maxDist=0;segmentLength=Math.pow(points[current[1]].lat()-points[current[0]].lat(),2)+Math.pow(points[current[1]].lng()-points[current[0]].lng(),2);for(i=current[0]+1;i<current[1];i++){temp=this.distance(points[i],points[current[0]],points[current[1]],segmentLength);if(temp>maxDist){maxDist=temp;maxLoc=i;if(maxDist>absMaxDist){absMaxDist=maxDist;}}}
if(maxDist>this.veryTiny){dists[maxLoc]=maxDist;stack.push([current[0],maxLoc]);stack.push([maxLoc,current[1]]);}}
encodedPoints=this.createEncodings(points,dists);encodedLevels=this.encodeLevels(points,dists,absMaxDist);return{encodedPoints:encodedPoints,encodedLevels:encodedLevels,encodedPointsLiteral:encodedPoints.replace(/\\/g,"\\\\")};};PolylineEncoder.prototype.dpEncodeToJSON=function(points,color,weight,opacity){var result;result=this.dpEncode(points);return{color:color,weight:weight,opacity:opacity,points:result.encodedPoints,levels:result.encodedLevels,numLevels:this.numLevels,zoomFactor:this.zoomFactor,literals:result.encodePointsLiteral};};PolylineEncoder.prototype.dpEncodeToGPolyline=function(points,color,weight,opacity){return new GPolyline.fromEncoded(this.dpEncodeToJSON(points,color,weight,opacity));};PolylineEncoder.prototype.dpEncodeToGPolygon=function(pointsArray,boundaryColor,boundaryWeight,boundaryOpacity,fillColor,fillOpacity,fill,outline){var i,boundaries;boundaries=[];for(i=0;i<pointsArray.length;i++){boundaries.push(this.dpEncodeToJSON(pointsArray[i],boundaryColor,boundaryWeight,boundaryOpacity));}
return new GPolygon.fromEncoded({polylines:boundaries,color:fillColor,opacity:fillOpacity,fill:fill,outline:outline});};PolylineEncoder.prototype.distance=function(p0,p1,p2,segLength){var u,out;var dlat2=p2.lat()-p1.lat();var dlong1=p2.lng()-p1.lng();if(dlat2==0&&dlong1==0){out=Math.pow(p2.lat()-p0.lat(),2)+Math.pow(p2.lng()-p0.lng(),2);}
else{var dlat0=p0.lat()-p1.lat();var dlong0=p0.lng()-p1.lng();u=((dlat0)*(dlat2)+(dlong0)*(dlong1))/segLength;if(u<=0){out=Math.pow(dlat0,2)+Math.pow(dlong0,2);}
if(u>=1){out=Math.pow(p0.lat()-p2.lat(),2)+Math.pow(p0.lng()-p2.lng(),2);}
if(0<u&&u<1){out=Math.pow(dlat0-u*(dlat2),2)+Math.pow(dlong0-u*(dlong1),2);}}
return out;};PolylineEncoder.prototype.createEncodings=function(points,dists){var i;var j;var floor=Math.floor;var len=points.length-2;var late5;var lnge5;var dlat=floor(points[0].lat()*1e5);var dlng=floor(points[0].lng()*1e5);var plat=dlat;var plng=dlng;var encoded_points=this.encodeSignedNumber(dlat)+this.encodeSignedNumber(dlng);for(j=len;j>0;j--){i=len-j+1;if(dists[i]!=undefined){late5=floor(points[i].lat()*1e5);lnge5=floor(points[i].lng()*1e5);dlat=late5-plat;dlng=lnge5-plng;plat=late5;plng=lnge5;encoded_points+=this.encodeSignedNumber(dlat)+this.encodeSignedNumber(dlng);}}
dlat=floor(points[len+1].lat()*1e5)-plat;dlng=floor(points[len+1].lng()*1e5)-plng;encoded_points+=this.encodeSignedNumber(dlat)+this.encodeSignedNumber(dlng);return encoded_points;};PolylineEncoder.prototype.computeLevel=function(dd){var lev;if(dd>this.veryTiny){lev=0;while(dd<this.zoomLevelBreaks[lev]){lev++;}
return lev;}};PolylineEncoder.prototype.encodeLevels=function(points,dists,absMaxDist){var i;var encoded_levels="";if(this.forceEndpoints){encoded_levels+=this.encodeNumber(this.numLevels-1);}
else{encoded_levels+=this.encodeNumber(this.numLevels-this.computeLevel(absMaxDist)-1);}
for(i=1;i<points.length-1;i++){if(dists[i]!=undefined){encoded_levels+=this.encodeNumber(this.numLevels-this.computeLevel(dists[i])-1);}}
if(this.forceEndpoints){encoded_levels+=this.encodeNumber(this.numLevels-1);}
else{encoded_levels+=this.encodeNumber(this.numLevels-this.computeLevel(absMaxDist)-1);}
return encoded_levels;};PolylineEncoder.prototype.encodeNumber=function(num){var encodeString="";var nextValue,finalValue;while(num>=0x20){nextValue=(0x20|(num&0x1f))+63;encodeString+=(String.fromCharCode(nextValue));num>>=5;}
finalValue=num+63;encodeString+=(String.fromCharCode(finalValue));return encodeString;};PolylineEncoder.prototype.encodeSignedNumber=function(num){var sgn_num=num<<1;if(num<0){sgn_num=~(sgn_num);}
return(this.encodeNumber(sgn_num));};PolylineEncoder.latLng=function(y,x){this.y=y;this.x=x;};PolylineEncoder.latLng.prototype.lat=function(){return this.y;};PolylineEncoder.latLng.prototype.lng=function(){return this.x;};PolylineEncoder.pointsToLatLngs=function(points){var i,latLngs;latLngs=[];for(i=0;i<points.length;i++){latLngs.push(new PolylineEncoder.latLng(points[i][0],points[i][1]));}
return latLngs;};PolylineEncoder.pointsToGLatLngs=function(points){var i,gLatLngs;gLatLngs=[];for(i=0;i<points.length;i++){gLatLngs.push(new GLatLng(points[i][0],points[i][1]));}
return gLatLngs;};GPolyline.prototype.getPoint=function(){return(this.getVertex(Math.round(this.getVertexCount()/2)));};GPolyline.prototype.computeBounds=function(){var bounds=new GLatLngBounds();for(var i=0;i<this.getVertexCount();i++){var v=this.getVertex(i);if(v){bounds.extend(v);}}
this.bounds=bounds;return bounds;};GTileLayerOverlay.prototype.getBounds=function(){return this.bounds;};GPolyline.prototype.getBounds=function(){if(typeof this.bounds!="undefined"){return this.bounds;}
else{return(this.computeBounds());}};GTileLayer.prototype.getBounds=function(){return this.bounds;};GPolygon.prototype.getPoint=function(){return(this.getBounds().getCenter());};Clusterer=function(map,paren){this.myvar=paren.myvar;this.paren=paren;this.map=map;this.markers=[];this.byid=[];this.byname=[];this.clusters=[];this.timeout=null;this.folders=[];this.folderBounds=[];this.folderhtml=[];this.folderhtmlast=[];this.subfolders=[];this.currentZoomLevel=map.getZoom();this.isParsed=false;this.maxVisibleMarkers=Clusterer.defaultMaxVisibleMarkers;this.gridSize=Clusterer.defaultGridSize;this.minMarkersPerCluster=Clusterer.defaultMinMarkersPerCluster;this.maxLinesPerInfoBox=Clusterer.defaultMaxLinesPerInfoBox;this.icon=Clusterer.defaultIcon;GEvent.addListener(map,'zoomend',Clusterer.MakeCaller(Clusterer.Display,this));GEvent.addListener(map,'moveend',Clusterer.MakeCaller(Clusterer.Display,this));GEvent.addListener(map,'infowindowclose',Clusterer.MakeCaller(Clusterer.PopDown,this));};Clusterer.defaultMaxVisibleMarkers=650;Clusterer.defaultGridSize=15;Clusterer.defaultMinMarkersPerCluster=5;Clusterer.defaultMaxLinesPerInfoBox=15;Clusterer.defaultIcon=new GIcon();Clusterer.defaultIcon.image='http://www.acme.com/resources/images/markers/blue_large.PNG';Clusterer.defaultIcon.shadow='http://www.acme.com/resources/images/markers/shadow_large.PNG';Clusterer.defaultIcon.iconSize=new GSize(30,51);Clusterer.defaultIcon.shadowSize=new GSize(56,51);Clusterer.defaultIcon.iconAnchor=new GPoint(13,34);Clusterer.defaultIcon.infoWindowAnchor=new GPoint(13,3);Clusterer.defaultIcon.infoShadowAnchor=new GPoint(27,37);Clusterer.prototype.SetIcon=function(icon){this.icon=icon;};Clusterer.prototype.SetMaxVisibleMarkers=function(n){this.maxVisibleMarkers=n;};Clusterer.prototype.SetMinMarkersPerCluster=function(n){this.minMarkersPerCluster=n;};Clusterer.prototype.SetMaxLinesPerInfoBox=function(n){this.maxLinesPerInfoBox=n;};Clusterer.prototype.AddMarker=function(marker,title,idx,sidebar,visible,forcevisible){if(marker.setMap!=null){marker.setMap(this.map);}
marker.hidden=false;if(visible!=true){marker.hidden=true;}
if(this.paren.hideall){marker.hidden=true;}
marker.title=title;this.folders[idx].push(this.markers.length);var bounds=this.map.getBounds();var vis=false;if(typeof marker.getBounds=="undefined"){if(bounds.contains(marker.getPoint())){vis=true;}}
else{var b=marker.getBounds();if(!b.isEmpty()){if(bounds.intersects(b)){vis=true;}}}
if(forcevisible){vis=true;}
this.markers.push(marker);if(vis){marker.onMap=true;this.map.addOverlay(marker);if(marker.hidden){marker.hide();if(!!marker.label){marker.label.hide();}}}
this.DisplayLater();if(sidebar){this.folderhtml[idx].push(sidebar);}};Clusterer.prototype.zoomToFolder=function(idx){var bounds=this.folderBounds[idx];this.map.setZoom(this.map.getBoundsZoomLevel(bounds));this.map.panTo(bounds.getCenter());};Clusterer.prototype.RemoveMarker=function(marker){for(var i=0;i<this.markers.length;++i){if(this.markers[i]==marker){if(marker.onMap){this.map.removeOverlay(marker);}
if(!!marker.label){this.map.removeOverlay(marker.label);}
for(var j=0;j<this.clusters.length;++j){var cluster=this.clusters[j];if(cluster!=null){for(var k=0;k<cluster.markers.length;++k){if(cluster.markers[k]==marker){cluster.markers[k]=null;--cluster.markerCount;break;}}
if(cluster.markerCount==0){this.ClearCluster(cluster);this.clusters[j]=null;}
else{if(cluster==this.poppedUpCluster){Clusterer.RePop(this);}}}}
this.markers[i]=null;break;}}
this.DisplayLater();};Clusterer.prototype.DisplayLater=function(){if(this.timeout!=null){clearTimeout(this.timeout);}
this.timeout=setTimeout(Clusterer.MakeCaller(Clusterer.Display,this),50);};Clusterer.Display=function(clusterer){var i,j,k,marker,cluster,l;clearTimeout(clusterer.timeout);var update_side=false;var count=0;var clon,bits;var vis;var content;if(clusterer.paren.basesidebar){for(k=0;k<clusterer.folderhtml.length;k++){var curlen=clusterer.folderhtml[k].length;var con=clusterer.folderhtmlast[k];if(con<curlen){var destid=clusterer.paren.myvar+"_folder"+k;var dest=Lance$(destid);if(dest){if(clusterer.paren.opts.sortbyname){content=dest.innerHTML;clon=clusterer.folderhtml[k].sort();for(l=0;l<curlen;l++){bits=clon[l].split("$$$",7);content+=clusterer.paren.sidebarfn(bits[0],bits[1],bits[2],bits[3],bits[4],bits[5],bits[6]);}}
else{content=dest.innerHTML;clon=clusterer.folderhtml[k];for(l=con;l<curlen;l++){bits=clon[l].split("$$$",7);content+=clusterer.paren.sidebarfn(bits[0],bits[1],bits[2],bits[3],bits[4],bits[5],bits[6]);}}
clusterer.folderhtmlast[k]=curlen;dest.innerHTML=content;if(clusterer.paren.forcefoldersopen){dest.style.display="block";}
update_side=true;count=curlen;}
else{}}}}
if(update_side&&count>0){if(clusterer.paren.progress==0){clusterer.paren.setFolders();GEvent.trigger(clusterer.paren,"parsed");if(!clusterer.paren.opts.sidebarid){clusterer.paren.mb.showMess("Finished Parsing",1000);}
var mifinish=new Date();var sec=((mifinish-clusterer.miStart)/1000+" seconds");clusterer.paren.mb.showMess("Loaded "+count+" GeoXML elements in "+sec,5000);clusterer.paren.ParseURL();if(!clusterer.paren.opts.nozoom){clusterer.paren.map.setCenter(clusterer.paren.bounds.getCenter(),clusterer.paren.map.getBoundsZoomLevel(clusterer.paren.bounds));}}}
if(update_side&&typeof resizeKML!="undefined"){resizeKML();}
var bounds,sw,ne,dx,dy;var newZoomLevel=clusterer.map.getZoom();if(newZoomLevel!=clusterer.currentZoomLevel){for(i=0;i<clusterer.clusters.length;++i){if(clusterer.clusters[i]!=null){clusterer.ClearCluster(clusterer.clusters[i]);clusterer.clusters[i]=null;}}
clusterer.clusters.length=0;clusterer.currentZoomLevel=newZoomLevel;}
bounds=clusterer.map.getBounds();sw=bounds.getSouthWest();ne=bounds.getNorthEast();dx=ne.lng()-sw.lng();dy=ne.lat()-sw.lat();if(dx<300&&dy<150){dx*=0.05;dy*=0.05;bounds=new GLatLngBounds(new GLatLng(sw.lat()-dy,sw.lng()-dx),new GLatLng(ne.lat()+dy,ne.lng()+dx));}
var visibleMarkers=[];var nonvisibleMarkers=[];var viscount=0;for(i=0;i<clusterer.markers.length;++i){marker=clusterer.markers[i];vis=false;if(marker!=null){var mid=clusterer.paren.myvar+"sb"+i;if(typeof marker.getBounds=="undefined"){if(bounds.contains(marker.getPoint())){vis=true;if(Lance$(mid)){Lance$(mid).className="inView";}
viscount++;}
else{if(Lance$(mid)){Lance$(mid).className="outView";}}}
else{var b=marker.getBounds();if(Lance$(mid)){if(bounds.intersects(b)){Lance$(mid).className="inView";}
else{Lance$(mid).className="outView";}}
vis=true;}
if(vis){visibleMarkers.push(i);}
else{nonvisibleMarkers.push(i);}}}
for(i=0;i<nonvisibleMarkers.length;++i){marker=clusterer.markers[nonvisibleMarkers[i]];if(marker.onMap){if(!!marker.label){marker.label.hide();}
clusterer.map.removeOverlay(marker);marker.onMap=false;}}
for(i=0;i<clusterer.clusters.length;++i){cluster=clusterer.clusters[i];if(cluster!=null&&cluster.marker){vis=false;if(typeof cluster.marker.getBounds=="undefined"){if(bounds.contains(cluster.marker.getPoint())){vis=true;}}
else{vis=true;}
if(!vis&&cluster.onMap){clusterer.map.removeOverlay(cluster.marker);cluster.onMap=false;}}}
if(viscount>clusterer.maxVisibleMarkers){if(!update_side){clusterer.paren.mb.showMess("Clustering on "+viscount+" GeoXML elements");}
var latRange=bounds.getNorthEast().lat()-bounds.getSouthWest().lat();var latInc=latRange/clusterer.gridSize;var lngInc=latInc/Math.cos((bounds.getNorthEast().lat()+bounds.getSouthWest().lat())/2.0*Math.PI/180.0);for(var lat=bounds.getSouthWest().lat();lat<=bounds.getNorthEast().lat();lat+=latInc){for(var lng=bounds.getSouthWest().lng();lng<=bounds.getNorthEast().lng();lng+=lngInc){cluster={};cluster.clusterer=clusterer;cluster.bounds=new GLatLngBounds(new GLatLng(lat,lng),new GLatLng(lat+latInc,lng+lngInc));cluster.markers=[];cluster.markerCount=0;cluster.onMap=false;cluster.marker=null;clusterer.clusters.push(cluster);}}
for(i=0;i<visibleMarkers.length;++i){marker=clusterer.markers[visibleMarkers[i]];if(marker!=null&&!marker.inCluster){for(j=0;j<clusterer.clusters.length;++j){cluster=clusterer.clusters[j];if(cluster!=null){vis=false;if(typeof marker.getBounds=="undefined"){if(cluster.bounds.contains(marker.getPoint())){vis=true;}}
if(vis){marker.inCluster=true;clusterer.clusters[j].markers.push(marker);++clusterer.clusters[j].markerCount;}}}}}
for(i=0;i<clusterer.clusters.length;++i){if(clusterer.clusters[i]!=null&&clusterer.clusters[i].markerCount<clusterer.minMarkersPerCluster){clusterer.ClearCluster(clusterer.clusters[i]);clusterer.clusters[i]=null;}}
for(i=clusterer.clusters.length-1;i>=0;--i){if(clusterer.clusters[i]!=null){break;}
else{--clusterer.clusters.length;}}
for(i=0;i<clusterer.clusters.length;++i){cluster=clusterer.clusters[i];if(cluster!=null){for(j=0;j<cluster.markers.length;++j){marker=cluster.markers[j];if(marker!=null&&marker.onMap){clusterer.map.removeOverlay(marker);marker.onMap=false;if(!!marker.label){marker.label.hide();}}}}}
for(i=0;i<clusterer.clusters.length;++i){cluster=clusterer.clusters[i];if(cluster!=null&&cluster.marker==null){var xTotal=0.0;var yTotal=0.0;for(j=0;j<cluster.markers.length;++j){marker=cluster.markers[j];if(marker!=null){xTotal+=(+marker.getPoint().lng());yTotal+=(+marker.getPoint().lat());}}
var location=new GLatLng(yTotal/cluster.markerCount,xTotal/cluster.markerCount);marker=new GMarker(location,{icon:clusterer.icon});cluster.marker=marker;GEvent.addListener(marker,'click',Clusterer.MakeCaller(Clusterer.PopUp,cluster));}}}
if(!update_side&&viscount&&(clusterer.paren.quiet!=true)){clusterer.paren.mb.showMess("Showing "+viscount+" GeoXML elements",500);}
for(i=0;i<visibleMarkers.length;++i){marker=clusterer.markers[visibleMarkers[i]];if(marker!=null&&!marker.onMap&&!marker.inCluster){if(marker.addedToMap!=null){marker.addedToMap();}
if(marker.hidden){if(marker.hide){clusterer.map.addOverlay(marker);marker.hide();if(!!marker.label){marker.label.hide();}}}
else{clusterer.map.addOverlay(marker);if(!!marker.label){marker.label.show();}}
marker.onMap=true;}}
for(i=0;i<clusterer.clusters.length;++i){cluster=clusterer.clusters[i];if(cluster!=null&&cluster.marker){vis=false;if(typeof marker.getPoint!="undefined"){if(bounds.contains(cluster.marker.getPoint())){vis=true;}}
else{if(bounds.intersects(cluster.marker.getBounds())){vis=true;}}
if(!cluster.onMap&&vis){clusterer.map.addOverlay(cluster.marker);cluster.onMap=true;}}}
Clusterer.RePop(clusterer);};Clusterer.PopUp=function(cluster){var clusterer=cluster.clusterer;var html='<table width="300">';var n=0;for(var i=0;i<cluster.markers.length;++i){var marker=cluster.markers[i];if(marker!=null){++n;html+='<tr><td>';if(typeof marker.getIcon!="undefined"&&marker.getIcon().smallImage!=null){html+='<img src="'+marker.getIcon().smallImage+'">';}
else{html+='<img src="'+marker.getIcon().image+'" width="'+(marker.getIcon().iconSize.width/2)+'" height="'+(marker.getIcon().iconSize.height/2)+'">';}
html+='</td><td>'+marker.title+'</td></tr>';if(n==clusterer.maxLinesPerInfoBox-1&&cluster.markerCount>clusterer.maxLinesPerInfoBox){html+='<tr><td colspan="2">...and '+(cluster.markerCount-n)+' more</td></tr>';break;}}}
html+='</table>';clusterer.map.closeInfoWindow();cluster.marker.openInfoWindowHtml(html);clusterer.poppedUpCluster=cluster;};Clusterer.RePop=function(clusterer){if(clusterer.poppedUpCluster!=null){Clusterer.PopUp(clusterer.poppedUpCluster);}};Clusterer.PopDown=function(clusterer){clusterer.poppedUpCluster=null;};Clusterer.prototype.ClearCluster=function(cluster){var i,marker;for(i=0;i<cluster.markers.length;++i){if(cluster.markers[i]!=null){cluster.markers[i].inCluster=false;cluster.markers[i]=null;}}
cluster.markers.length=0;cluster.markerCount=0;if(cluster==this.poppedUpCluster){this.map.closeInfoWindow();}
if(cluster.onMap){this.map.removeOverlay(cluster.marker);cluster.onMap=false;}};Clusterer.MakeCaller=function(func,arg){return function(){func(arg);};};GMarker.prototype.setMap=function(map){this.map=map;};GMarker.prototype.addedToMap=function(){this.map=null;};GMarker.prototype.origOpenInfoWindow=GMarker.prototype.openInfoWindow;GMarker.prototype.openInfoWindow=function(node,opts){if(this.map!=null){return this.map.openInfoWindow(this.getPoint(),node,opts);}
else{return this.origOpenInfoWindow(node,opts);}};GMarker.prototype.origOpenInfoWindowHtml=GMarker.prototype.openInfoWindowHtml;GMarker.prototype.openInfoWindowHtml=function(html,opts){if(this.map!=null){return this.map.openInfoWindowHtml(this.getPoint(),html,opts);}
else{return this.origOpenInfoWindowHtml(html,opts);}};GMarker.prototype.origOpenInfoWindowTabs=GMarker.prototype.openInfoWindowTabs;GMarker.prototype.openInfoWindowTabs=function(tabNodes,opts){if(this.map!=null){return this.map.openInfoWindowTabs(this.getPoint(),tabNodes,opts);}
else{return this.origOpenInfoWindowTabs(tabNodes,opts);}};GMarker.prototype.origOpenInfoWindowTabsHtml=GMarker.prototype.openInfoWindowTabsHtml;GMarker.prototype.openInfoWindowTabsHtml=function(tabHtmls,opts){if(this.map!=null){return this.map.openInfoWindowTabsHtml(this.getPoint(),tabHtmls,opts);}
else{return this.origOpenInfoWindowTabsHtml(tabHtmls,opts);}};GMarker.prototype.origShowMapBlowup=GMarker.prototype.showMapBlowup;GMarker.prototype.showMapBlowup=function(opts){if(this.map!=null){return this.map.showMapBlowup(this.getPoint(),opts);}
else{return this.origShowMapBlowup(opts);}};MessageBox=function(map,paren,myvar,mb){this.map=map;this.paren=paren;this.myvar=paren.myvar+"."+myvar;this.eraseMess=null;this.centerMe=null;this.mb=null;if(mb){this.mb=mb;}
this.id=this.myvar+"_message";};MessageBox.prototype.hideMess=function(){this.mb.style.visiblity="hidden";this.mb.style.left="-1200px";this.mb.style.top="-1200px";};MessageBox.prototype.centerThis=function(){var c=this.map.getObjCenter();if(!this.mb){this.mb=Lance$(this.id);}
if(this.centerMe){clearTimeout(this.centerMe);}
if(this.mb){var nw=this.mb.clientWidth;if(nw>this.map.getSize().width){nw=parseInt(2*this.map.getSize().width/3,10);this.mb.style.width=nw+"px";this.centerMe=setTimeout(this.myvar+".centerThis()",5);return;}
this.mb.style.left=(c.x-(nw/2))+"px";this.mb.style.top=(c.y-20-(this.mb.clientHeight/2))+"px";}
else{this.centerMe=setTimeout(this.myvar+".centerThis()",10);}};MessageBox.prototype.showMess=function(val,temp){if(!this.mb&&this.style&&this.style.display=="none"||this.mb&&this.mb.style.display=="none"){return;}
val=unescape(val);if(this.eraseMess){clearTimeout(this.eraseMess);}
if(!this.mb){this.mb=Lance$(this.id);}
if(this.mb){this.mb.innerHTML="<span>"+val+"</span>";if(temp){this.eraseMess=setTimeout(this.myvar+".hideMess();",temp);}
this.mb.style.left="-1200px";this.mb.style.top="-1200px";this.mb.style.width="";this.mb.style.height="";this.centerMe=setTimeout(this.myvar+".centerThis()",5);this.mb.style.visibility="visible";}
else{var d=document.createElement("div");d.innerHTML=val;d.id=this.myvar+"_message";d.style.position="absolute";d.style.backgroundColor=this.style.backgroundColor||"silver";d.style.opacity=this.style.opacity||0.80;d.style.filter="alpha(opacity="+parseInt(d.style.opacity*100,10)+")";d.style.color=this.style.color||"black";d.style.padding=this.style.padding||"6px";d.style.borderWidth=this.style.borderWidth||"3px";d.style.borderColor=this.style.borderColor||"";d.style.backgroundImage=this.style.backgroundImage||"";d.style.borderStyle=this.style.borderStyle||"outset";d.style.visibility="visible";d.style.left="-1200px";d.style.top="-1200px";this.centerMe=setTimeout(this.myvar+".centerThis()",5);d.style.zIndex=1000;document.body.appendChild(d);}};GMap2.prototype.getObjCenter=function(){var obj=this.getContainer();var container=obj;var y=0;var x=0;if(obj.offsetParent){x=obj.offsetLeft;y=obj.offsetTop;obj=obj.offsetParent;while(obj){x+=obj.offsetLeft;y+=obj.offsetTop;obj=obj.offsetParent;}
return new GPoint(x+parseInt(this.getSize().width,10)/2,y+parseInt(this.getSize().height,10)/2);}};GeoXml.prototype.loadJSONUrl=function(url,title,latlon,desc,idx){var that=this;GDownloadUrl(url,function(doc){that.parseJSON(doc,title,latlon,desc,idx);});};GeoXml.prototype.loadXMLUrl=function(url,title,latlon,desc,idx){var that=this;that.DownloadURL(url,function(doc){that.processing(GXml.parse(doc),title,latlon,desc,idx)},title);};GeoXml.prototype.upgradeLayer=function(n){var mt=this.map.getMapTypes();var found=false;for(var i=0;i<mt.length;i++){if(mt[i]==this.baseLayers[n]){found=true;this.map.removeMapType(this.baseLayers[n]);}}
if(!found){this.map.addMapType(this.baseLayers[n]);}};GeoXml.prototype.makeWMSTileLayer=function(getmapstring,on,title,opac,attr,grouptitle,wmsbounds){var that=this;gmapstring=new String(getmapstring);getmapstring=gmapstring.replace("&amp;","&");var args=getmapstring.split("?");var baseurl=args[0]+"?";baseurl=baseurl.replace(/&request=getmap/i,"");baseurl=baseurl.replace(/&service=wms/i,"");var version="1.1.0";var format="image/png";var styles="";var layers="";var queryable=false;var opacity=1.0;if(typeof opac!="undefined"){opacity=opac;}
var bbox="-180,-90,180,90";var pairs=args[1].split("&");var sld="";var servicename="";var atlasname="";var gmcrs="";var epsg;for(var i=0;i<pairs.length;i++){var dstr=pairs[i];var duo=pairs[i].split("=");var dl=duo[0].toLowerCase();switch(dl){case"version":version=duo[1];break;case"bbox":bbox=duo[1];break;case"width":case"height":break;case"service":break;case"servicename":servicename=duo[1];break;case"atlasname":atlasname=duo[1];break;case"styles":styles=duo[1];break;case"layers":layers=duo[1];break;case"format":format=duo[1];break;case"opacity":opacity=parseFloat(duo[1]);break;case"crs":case"srs":epsg=duo[1];break;case"gmcrs":gmcrs=duo[1];break;case"queryable":queryable=duo[1];break;case"getmap":break;case"service":break;default:if(duo[0]){baseurl+="&"+pairs[i];}
break;}}
if(gmcrs){epsg=gmcrs;}
var bbn=bbox.split(",");var bb={"w":parseFloat(bbn[0]),"s":parseFloat(bbn[1]),"e":parseFloat(bbn[2]),"n":parseFloat(bbn[3])};var lon=(bb.n-bb.s);var z=0;var ex=180;while(ex>=lon){ex=ex/2;z++;}
z--;if(z<1){z=1;}
if(!attr){attr="Base Map from OGC WMS";}
var cr0=new GCopyright(1,new GLatLngBounds(new GLatLng(bb.s,bb.w),new GLatLng(bb.n,bb.e)),0,attr);var cc0=new GCopyrightCollection("");cc0.addCopyright(cr0);var twms=new GTileLayer(cc0,z,19);twms.s=bb.s;twms.n=bb.n;twms.e=bb.e;twms.w=bb.w;twms.myBaseURL=baseurl;if(servicename){twms.servicename=servicename;}
if(atlasname){twms.atlasname=atlasname;}
twms.publishdirectory=this.publishdirectory;twms.epsg=epsg;twms.getTileUrl=function(a,b,c){if(typeof(this.myStyles)=="undefined"){this.myStyles="";}
var lULP=new GPoint(a.x*256,(a.y+1)*256);var lLRP=new GPoint((a.x+1)*256,a.y*256);var lUL=G_NORMAL_MAP.getProjection().fromPixelToLatLng(lULP,b,c);var lLR=G_NORMAL_MAP.getProjection().fromPixelToLatLng(lLRP,b,c);var west=lUL.x;var east=lLR.x;var north=lUL.y;var south=lLR.y;var ge=east;var gw=west;var gs=south;var gn=north;if(gn<gs){gs=gn;gn=south;}
if(this.epsg!="EPSG:4326"&&this.epsg!="CRS:84"&&this.epsg!="4326"){west=GeoXml.merc2Lon(west);north=GeoXml.merc2Lat(north);east=GeoXml.merc2Lon(east);south=GeoXml.merc2Lat(south);}
var w=Math.abs(east-west);var h=Math.abs(north-south);var s=h/w;h=Math.round((256.0*s)+0.5);w=256;var sud=south;if(north<south){south=north;north=sud;}
if(gs>(this.n)||ge<(this.w)||gn<(this.s)||gw>(this.e)){var retstr=this.publishdirectory+"black.gif";}
var lBbox=west+","+south+","+east+","+north;var lSRS="EPSG:41001";if(typeof this.epsg!="undefined"||this.srs=="4326"){lSRS=this.epsg;}
var lURL=this.myBaseURL;if(typeof this.myVersion=="undefined"){this.myVersion="1.1.1";}
var ver=parseFloat(this.myVersion);var arcims=/arcimsproxy/i;if(!this.myBaseURL.match(arcims)){lURL+="&SERVICE=WMS";if(this.myVersion!="1.0.0"){var gmap=/request=getmap/i;if(!lURL.match(gmap)){lURL+="&REQUEST=GetMap";}}
else{lURL+="&REQUEST=Map";}}
if(this.servicename){lURL+="?ServiceName="+this.servicename;}
if(this.atlasname){lURL+="&AtlasName="+this.servicename;}
lURL+="&VERSION="+this.myVersion;if(this.myLayers){lURL+="&LAYERS="+this.myLayers;lURL+="&STYLES="+this.myStyles;}
if(this.mySLD){lURL+="&SLD="+this.mySLD;}
lURL+="&FORMAT="+this.myFormat;lURL+="&BGCOLOR=0x000000";lURL+="&TRANSPARENT=TRUE";if(this.myVersion=="1.1.1"||ver<1.3){lURL+="&SRS="+lSRS;}
else{lURL+="&CRS="+lSRS;}
lURL+="&WIDTH="+w;lURL+="&HEIGHT="+h;lURL+="&BBOX="+lBbox;this.requestCount++;return lURL;};twms.myFormat=format;twms.myVersion=version;twms.myExtents=bbox;twms.queryable=queryable;twms.opacity=opacity;twms.getOpacity=function(){return this.opacity;};if(sld){twms.mySLD=sld;}
else{twms.myLayers=layers;twms.myStyles=styles;}
var ol=new GTileLayerOverlay(twms);ol.bounds=new GLatLngBounds();ol.bounds.extend(new GLatLng(bb.n,bb.e));ol.bounds.extend(new GLatLng(bb.s,bb.w));this.wmscount++;if(this.opts.doMapTypes){var twms2=new GTileLayer(cc0,z,19);twms2.s=bb.s;twms2.n=bb.n;twms2.e=bb.e;twms2.w=bb.w;twms2.myBaseURL=baseurl;twms2.servicename=servicename;twms2.publishdirectory=this.publishdirectory;twms2.getTileUrl=twms.getTileUrl;twms2.myFormat=twms.myFormat;twms2.myVersion=version;twms2.opacity=1.0;twms2.title=title;if(attr){twms2.attribution=attr;}
twms2.getOpacity=function(){return this.opacity;};if(sld){twms2.mySLD=sld;}
else{twms2.myLayers=layers;twms2.myStyles=styles;}
twms2.epsg=epsg;var base=new GTileLayer(cc0,z,19);base.s=bb.s;base.n=bb.n;base.e=bb.e;base.w=bb.w;base.dir=this.publishdirectory;base.getTileUrl=function(){return(this.dir+"black.gif");};base.opacity=1.0;base.title=title;if(attr){base.attribution=attr;}
base.getOpacity=function(){return this.opacity;};var layer=[twms2,G_HYBRID_MAP.getTileLayers()[1]];var cmap=new GMapType(layer,G_HYBRID_MAP.getProjection(),""+title+"",G_HYBRID_MAP);cmap.bounds=new GLatLngBounds(new GLatLng(bb.s,bb.w),new GLatLng(bb.n,bb.e));if(grouptitle){cmap.grouptitle=grouptitle;}
that.baseLayers.push(cmap);that.map.addMapType(cmap);return null;}
else{return ol;}};GeoXml.SEMI_MAJOR_AXIS=6378137.0;GeoXml.ECCENTRICITY=0.0818191913108718138;GeoXml.DEG2RAD=180.0/(Math.PI);GeoXml.merc2Lon=function(lon){return(lon*GeoXml.DEG2RAD)*GeoXml.SEMI_MAJOR_AXIS;};GeoXml.merc2Lat=function(lat){var rad=lat*GeoXml.DEG2RAD;var sinrad=Math.sin(rad);return(GeoXml.SEMI_MAJOR_AXIS*Math.log(Math.tan((rad+Math.PI/2)/2)*Math.pow(((1-GeoXml.ECCENTRICITY*sinrad)/(1+GeoXml.ECCENTRICITY*sinrad)),(GeoXml.ECCENTRICITY/2))));};GeoXml.prototype.toggleLabels=function(on){if(!on){this.removeLabels();}
else{this.addLabels();}};GeoXml.prototype.addLabels=function(){this.labels.onMap=true;this.map.addOverlay(this.labels);};GeoXml.prototype.removeLabels=function(){this.labels.onMap=false;this.map.removeOverlay(this.labels);};var useLegacyLocalLoad=true;GeoXml.prototype.DownloadURL=function(fpath,callback,title){if(!fpath){return;}
var xmlDoc;var that=this;var cmlurl=fpath;if(!topwin.standalone&&this.proxy){cmlurl=this.proxy+"url="+escape(cmlurl);}
if(topwin.standalone||useLegacyLocalLoad){if(cmlurl.substring(2,3)==":"){xmlDoc=new ActiveXObject("Msxml2.DOMDocument.4.0");xmlDoc.validateOnParse=false;xmlDoc.async=true;xmlDoc.load(cmlurl);if(xmlDoc.parseError.errorCode!=0){var myErr=xmlDoc.parseError;alert("GeoXml file appears incorrect\n"+myErr.reason+" at line:"+myErr.line);}
else{callback(xmlDoc.doc);}
return;}}
var cmlreq;if(!cmlreq&&typeof XMLHttpRequest!='undefined'){cmlreq=new XMLHttpRequest();}
else{if(typeof ActiveXObject!="undefined"){cmlreq=new ActiveXObject("Microsoft.XMLHTTP");}}
var here=cmlurl;if(cmlreq.overrideMimeType){cmlreq.overrideMimeType("text/xml");}
cmlreq.open("GET",here,true);cmlreq.onreadystatechange=function(){switch(cmlreq.readyState){case 4:that.mb.showMess(title+" received",2000);if(typeof ActiveXObject!="undefined"){xmlDoc=new ActiveXObject("Microsoft.XMLDOM");xmlDoc.async="false";var response=cmlreq.responseText;callback(response);}
else{if(cmlreq.responseXML){that.mb.showMess(title+" received",2000);callback(cmlreq.responseText);}
else{if(cmlreq.status==200){var resp=cmlreq.responseText;var sresp=resp.substring(0,400);var isXML=resp.substring(0,5);if(isXML=="<?xml"&&sresp.indexOf("kml")!=-1){that.mb.showMess(title+" response received",2000);callback(resp.responseText);}
else{that.mb.showMess("File does not appear to be a valid GeoData"+resp,6000);}}}}
break;case 3:that.mb.showMess("Receiving "+title+"...");break;case 2:that.mb.showMess("Waiting for "+title,2000);break;case 1:that.mb.showMess("Sent request for "+title,2000);break;}};try{cmlreq.send(null);}
catch(err){if(cmlurl.substring(2,3)==":"&&!useLegacyLocalLoad){useLegacyLocalLoad=true;this.DownloadURL(cmlurl);}}};var AudioPlayer=function(){var instances=[];var activePlayerID;var playerURL="";var defaultOptions={};var currentVolume=-1;var playerReady=false;function getPlayer(playerID){if(document.all&&!window[playerID]){for(var i=0;i<document.forms.length;i++){if(document.forms[i][playerID]){return document.forms[i][playerID];break;}}}
return document.all?window[playerID]:document[playerID];}
function addListener(playerID,type,func){getPlayer(playerID).addListener(type,func);}
return{setup:function(url,options){playerURL=url;defaultOptions=options;},getPlayer:function(playerID){return getPlayer(playerID);},addListener:function(playerID,type,func){addListener(playerID,type,func);},embed:function(elementID,options){var instanceOptions={};var key;var so;var bgcolor;var wmode;var flashParams={};var flashVars={};var flashAttributes={};for(key in defaultOptions){instanceOptions[key]=defaultOptions[key];}
for(key in options){instanceOptions[key]=options[key];}
if(instanceOptions.transparentpagebg=="yes"){flashParams.bgcolor="#FFFFFF";flashParams.wmode="transparent";}else{if(instanceOptions.pagebg){flashParams.bgcolor="#"+instanceOptions.pagebg;}
flashParams.wmode="opaque";}
flashParams.menu="false";for(key in instanceOptions){if(key=="pagebg"||key=="width"||key=="transparentpagebg"){continue;}
flashVars[key]=instanceOptions[key];}
flashAttributes.name=elementID;flashAttributes.style="outline: none";flashVars.playerID=elementID;swfobject.embedSWF(playerURL,elementID,instanceOptions.width.toString(),"24","9",false,flashVars,flashParams,flashAttributes);instances.push(elementID);playerReady=true;},syncVolumes:function(playerID,volume){currentVolume=volume;for(var i=0;i<instances.length;i++){if(instances[i]!=playerID){getPlayer(instances[i]).setVolume(currentVolume);}}},activate:function(playerID,info){if(activePlayerID&&activePlayerID!=playerID){getPlayer(activePlayerID).close();}
activePlayerID=playerID;},load:function(playerID,soundFile,titles,artists){getPlayer(playerID).load(soundFile,titles,artists);},close:function(playerID){getPlayer(playerID).close();if(playerID==activePlayerID){activePlayerID=null;}},open:function(playerID,index){if(index==undefined){index=1;}
getPlayer(playerID).open(index==undefined?0:index-1);},getVolume:function(playerID){return currentVolume;},isPlayerReady:function(){return playerReady;},destroy:function(playerID,WMAplayerID){if(document.getElementById(playerID)){var parentElement=document.getElementById(playerID).parentNode;var newPlayer='<div id="'+playerID+'"></div>\
        <div id="'+playerID+'WMA"></div>';if(swfobject){swfobject.removeSWF(playerID);}
var wmaPlayer=Dom.get("WMAplayerID");if(wmaPlayer){if(YAHOO.env.ua.ie>=7){wmaPlayer.outerHTML="";wmaPlayer=null;}else{wmaPlayer.parentNode.removeChild(wmaPlayer);}}
parentElement.innerHTML=newPlayer;}}}}();function AudioComponent(){this.fileList=[];this.fileListSize=0;this.poiIdFromBallon=0;this.currentAudio=null;this.template='<div class="balloon-audio-item-container $grayStyle" id="$id_audio_row">\
  <div class="balloon-audio-number">$number</div>\
  <div class="balloon-audio-name ellipsis" title="$name">$name</div>\
  <div class="balloon-audio-delelte"></div>\
 </div>';this.template2='<div class="balloon-audio-item-container $grayStyle" id="$id_audio_row">\
  <div class="balloon-link-audio-number">$number</div>\
  <a target="_blank" href="$link" class="balloon-link-audio-name ellipsis" title="$name">$name</a>\
  <div class="balloon-audio-delelte"></div>\
 </div>';this.mediaPlayerString='<object id="MediaPlayer" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" \
  codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" \
  standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject" \
  width="465" height="70">\
  <param name="FileName" value="$link">\
  <param name="AutoStart" value="1">\
  <param name="ShowControls" value="1">\
  <PARAM NAME="ShowStatusBar" VALUE="1">\
  <PARAM NAME="ShowGoToBar" VALUE="0">\
  <PARAM NAME="ShowPositionControls" VALUE="0">\
  <PARAM NAME="ShowDisplay" VALUE="0">\
  <PARAM NAME="ShowTracker" VALUE="1">\
  <param name="Volume" value="-1000">\
  <embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/windows/windowsmedia/" \
  filename="$link" src="$link" \
  name="MediaPlayer" showcontrols="1" ShowPositionControls="0" ShowGoToBar="0" showdisplay="0" \
  AutoStart="1" ShowTracker="1" showstatusbar="1" width="465" height="70" invokeurls="1"></embed>\
 </object>';this.attachHandlers();};AudioComponent.prototype.attachHandlers=function(){Event.addListener(this.audioBalloonTab,"click",this._delegateClickEvent,this,true);Event.addListener(this.audioListScrollUp,"mousedown",this._scrollUpHandler,this,false);Event.addListener(this.audioListScrollDown,"mousedown",this._scrollDownHandler,this,false);Event.addListener(this.audioListScrollUp,"mouseup",this._stopScrollUp,this,true);Event.addListener(this.audioListScrollDown,"mouseup",this._stopScrollDown,this,true);Event.addListener(this.audioListScrollUp,"mouseout",this._stopScrollUp,this,true);Event.addListener(this.audioListScrollDown,"mouseout",this._stopScrollDown,this,true);if(this.audioListScrollContainer.addEventListener){this.audioListScrollContainer.addEventListener('DOMMouseScroll',this._onMouseWheel,this,false);this.audioListScrollContainer.addEventListener('mousewheel',this._onMouseWheel,this,false);}
else if(this.audioListScrollContainer.attachEvent){this.audioListScrollContainer.attachEvent('onmousewheel',this._onMouseWheel,this,false);}};AudioComponent.prototype.initAudioTab=function(poiId){popupHandler.showPleaseWait();this.poiIdFromBallon=poiId;var currentLocation=window.location;AudioPlayer.setup(currentLocation.protocol+"//"+currentLocation.host+GlobalProperties.HOST+"js/yukon/poi/audioComponent/player.swf",{width:465,animation:"no",buffer:15});this.audioListScroll.innerHTML="";var that=this;UIRequest("returnFileList.action","poiId="+this.poiIdFromBallon,function(data){that.getData(data);popupHandler.hidePleaseWait();});};AudioComponent.prototype.getData=function(data){var json=YAHOO.lang.JSON.parse(data.responseText);this.fileList=json.fileList;this.buildAudioTab();};AudioComponent.prototype.buildAudioTab=function(){var fileListString="";var titlesListString="";var fileList=this.fileList;var result="",addClass="";for(var i=0,n=fileList.length;i<n;i++){if(fileList[i].link.search(/\.mp3$/i)!=-1){fileListString+=fileList[i].link+",";titlesListString+=fileList[i].title+",";}
var rowId=i,title=fileList[i].title,link=fileList[i].link;if(i%2==0){addClass="audio-gray-bg"}else{addClass=""};result+=this.template.replace(/\$name/g,title).replace(/\$id/g,rowId).replace(/\$number/g,(i+1)).replace(/\$grayStyle/g,addClass);}
this.audioListScroll.innerHTML=result;if(fileList.length>0){fileListString=fileListString.slice(0,-1);titlesListString=titlesListString.slice(0,-1);this.playerSelector(fileList[0].link,fileListString,titlesListString);}else{this.stopPlayers();Dom.get(this.audioPlayer).style.display="none";}
this.audioListScroll.style.marginTop="0px";this.audioListScrollUp.style.visibility="hidden";this.audioListScrollDown.style.visibility="hidden";if(this.audioListScroll.parentNode.offsetHeight<this.audioListScroll.offsetHeight){this.audioListScrollDown.style.visibility="visible";}};AudioComponent.prototype.playCurrentSong=function(obj){obj=obj.parentNode;var rowId=obj.id;var rowIdNumber=parseInt(rowId);var fileListString=this.fileList[rowIdNumber].link;var titlesListString=this.fileList[rowIdNumber].title;this.playerSelector(fileListString,fileListString,titlesListString);};AudioComponent.prototype.playerSelector=function(fileLink,fileListString,titlesListString){var audioMediaPlayer=Dom.get(this.audioMediaPlayer);if(fileLink.search(/\.mp3$/i)==-1){audioMediaPlayer.innerHTML=this.mediaPlayerString.replace(/\$link/g,fileLink);this.stopMp3Player();Dom.addClass(this.audioBalloonTab,"audio-tab-wma-mode");}else{AudioPlayer.embed(this.audioPlayer,{soundFile:fileListString,titles:titlesListString});this.stopWMAPlayer();Dom.removeClass(this.audioBalloonTab,"audio-tab-wma-mode");}};AudioComponent.prototype.stopPlayers=function(){this.stopMp3Player();this.stopWMAPlayer();Dom.removeClass(this.audioBalloonTab,"audio-tab-wma-mode");};AudioComponent.prototype.stopMp3Player=function(asd){var audioPlayer=Dom.get(this.audioPlayer);if(AudioPlayer.isPlayerReady()){AudioPlayer.embed(this.audioPlayer,{soundFile:"",titles:""});}};AudioComponent.prototype.stopWMAPlayer=function(){var audioMediaPlayer=Dom.get(this.audioMediaPlayer);if(audioMediaPlayer.firstChild&&(YAHOO.env.ua.ie>=7)){audioMediaPlayer.firstChild.object.Stop();}};AudioComponent.prototype._scrollDescriptionDown=function(scroller){this._stopScrollUp();var descriptionScroll=this.audioListScroll;var marginTop=parseInt(descriptionScroll.style.marginTop);marginTop=marginTop-3;if(marginTop<descriptionScroll.parentNode.offsetHeight-descriptionScroll.offsetHeight){marginTop=descriptionScroll.parentNode.offsetHeight-descriptionScroll.offsetHeight;scroller.style.visibility="hidden";this._stopScrollDown();}
descriptionScroll.style.marginTop=marginTop+"px";};AudioComponent.prototype._scrollDescriptionUp=function(scroller){this._stopScrollDown();var descriptionScroll=this.audioListScroll;var marginTop=parseInt(descriptionScroll.style.marginTop);marginTop=marginTop+3;if(marginTop>0){marginTop=0;scroller.style.visibility="hidden";this._stopScrollUp();}
descriptionScroll.style.marginTop=marginTop+"px";};AudioComponent.prototype._scrollDownHandler=function(audioInstance){if(audioInstance.mouseDown==null||typeof audioInstance.mouseDown=="undefined"){var scroller=this;audioInstance._scrollDescriptionDown(scroller);audioInstance.audioListScrollUp.style.visibility="visible";audioInstance.mouseDown=setInterval(function(){audioInstance._scrollDescriptionDown(scroller);},8);}};AudioComponent.prototype._scrollUpHandler=function(audioInstance){if(audioInstance.mouseUp==null||typeof audioInstance.mouseUp=="undefined"){var scroller=this;audioInstance._scrollDescriptionUp(scroller);audioInstance.audioListScrollDown.style.visibility="visible";audioInstance.mouseUp=setInterval(function(){audioInstance._scrollDescriptionUp(scroller);},8);}};AudioComponent.prototype._stopScrollUp=function(){if(this.mouseUp){clearInterval(this.mouseUp);this.mouseUp=null;}};AudioComponent.prototype._stopScrollDown=function(){if(this.mouseDown){clearInterval(this.mouseDown);this.mouseDown=null;}};AudioComponent.prototype._onMouseWheel=function(ev,audioListScroll,audioScrollDown,audioScrollUp){var descriptionScroll=Dom.get(audioListScroll);if(descriptionScroll.parentNode.offsetHeight>descriptionScroll.offsetHeight){return;}
var scrolledUp=(ev.type=="DOMMouseScroll"&&ev.detail<0)||(ev.type=="mousewheel"&&ev.wheelDelta>0);var marginTop=parseInt(descriptionScroll.style.marginTop);if(scrolledUp){marginTop=marginTop+12;var scroller=Dom.get(audioScrollDown);scroller.style.visibility="visible";if(marginTop>0){marginTop=0;var scroller=Dom.get(audioScrollUp);scroller.style.visibility="hidden";}}else{marginTop=marginTop-12;var scroller=Dom.get(audioScrollUp);scroller.style.visibility="visible";if(marginTop<descriptionScroll.parentNode.offsetHeight-descriptionScroll.offsetHeight){marginTop=descriptionScroll.parentNode.offsetHeight-descriptionScroll.offsetHeight;var scroller=Dom.get(audioScrollDown);scroller.style.visibility="hidden";}}
descriptionScroll.style.marginTop=marginTop+"px";Event.stopEvent(ev);};function EditAudioComponent(){this.audioListScrollContainer=Dom.get("audioWriteListScrollContainer");this.audioListScroll=Dom.get("audioWriteListScroll");this.audioListScrollUp=Dom.get("audioWriteScrollUp");this.audioListScrollDown=Dom.get("audioWriteScrollDown");this.audioBalloonTab=Dom.get("audioWriteBalloonTab");this.audioPostBtn=Dom.get("audioWriteBalloonPost");this.audioPlayer="audioWriteBalloonPlayer";this.audioMediaPlayer="audioWriteBalloonPlayerWMA";this.constructor.superclass.constructor.apply(this,[]);};YAHOO.lang.extend(EditAudioComponent,AudioComponent);EditAudioComponent.prototype.attachHandlers=function(){this.constructor.superclass.attachHandlers.apply(this,[]);};EditAudioComponent.prototype._delegateClickEvent=function(ev){var obj=ev.target?ev.target:ev.srcElement;if(obj.className==="balloon-audio-delelte"){this.deleteAudio(obj);}
else if((obj.className==="balloon-audio-name ellipsis")||(obj.className==="balloon-audio-number")){this.playCurrentSong(obj);}
else if((obj.className==="balloon-link-audio-name ellipsis")||(obj.className==="balloon-link-audio-number")){}
else{var button=obj;while(button.className!=="buttonDiv"&&button.id!=="audioWriteBalloonTab"){button=button.parentNode;}
if(button.className==="buttonDiv"){this.addAudio();}}};EditAudioComponent.prototype.initAudioTab=function(poiId){var args=[];args[0]=poiId;this.constructor.superclass.initAudioTab.apply(this,args);};EditAudioComponent.prototype.getData=function(data){var args=[];args[0]=data;this.constructor.superclass.getData.apply(this,args);};EditAudioComponent.prototype.buildAudioTab=function(){this.constructor.superclass.buildAudioTab.apply(this,[]);};EditAudioComponent.prototype.addAudio=function(){this.currentAudio={poiId:this.poiIdFromBallon,link:encodeURIComponent(CLIPTOO.utils.trim(Dom.get('audioLink').value)),title:encodeURIComponent(CLIPTOO.utils.trim(Dom.get('audioTitle').value))};if((!this.currentAudio.title||this.currentAudio.title=="")||(!this.currentAudio.link||this.currentAudio.link=="")){popupHandler.showValidationPopup(PoiMsg.js_msg.balloon.audioMandatory());return;}
if((Dom.get('audioLink').value.search('^(http[s]?:\/\/)'))==-1){popupHandler.showValidationPopup(PoiMsg.js_msg.balloon.hyperLinkMask());return;}
var fileListSize=this.fileList.length;var fileList=this.fileList;for(var i=0,n=fileListSize;i<n;i++){if((fileList[i].link==this.currentAudio.link)&&(fileList[i].url==this.currentAudio.url)){popupHandler.showValidationPopup(PoiMsg.js_msg.balloon.audioFileExists());return;}}
popupHandler.showPleaseWait();var that=this;var param="";if(this.currentAudio.poiId){param+="poiId="+this.currentAudio.poiId;}
if(this.currentAudio.link){param+="&link="+this.currentAudio.link;}
if(this.currentAudio.title){param+="&title="+this.currentAudio.title;}
UIRequest("addUpdateAudio.action",param,function(data){var json=YAHOO.lang.JSON.parse(data.responseText);that.currentAudio=json.audioComponent;that.addAudioInList();popupHandler.hidePleaseWait();});};EditAudioComponent.prototype.addAudioInList=function(){Dom.get('audioLink').value="";Dom.get('audioTitle').value="";var fileListSize=this.fileList.length;this.fileList[fileListSize]=this.currentAudio;this.buildAudioTab();};EditAudioComponent.prototype.deleteAudio=function(obj){obj=obj.parentNode;var rowId=obj.id;var rowIdNumber=parseInt(rowId);var that=this;popupHandler.showConfirmPopup(PoiMsg.js_msg.balloon.blog.msg.warning(),PoiMsg.js_msg.balloon.audioDeleteWarning(this.fileList[rowIdNumber].title),function(){that._deleteAudioHandler(this,rowIdNumber);});};EditAudioComponent.prototype._deleteAudioHandler=function(confirmPopup,rowIdNumber){popupHandler.showPleaseWait();this.currentAudio={poiId:this.fileList[rowIdNumber].poiId,link:this.fileList[rowIdNumber].link,id:this.fileList[rowIdNumber].id};var param="";if(this.currentAudio.poiId){param+="poiId="+this.currentAudio.poiId;}
if(this.currentAudio.id){param+="&id="+this.currentAudio.id;}
var that=this;UIRequest("deleteAudio.action",param,function(data){that.removeAudioFromList(rowIdNumber);});popupHandler.hidePleaseWait();confirmPopup.hide();};EditAudioComponent.prototype.removeAudioFromList=function(rowIdNumber){var newList=[];for(var i=0,n=this.fileList.length;i<n;i++){if(i!=rowIdNumber){newList.push(this.fileList[i]);}}
this.fileList=newList;this.buildAudioTab();};EditAudioComponent.prototype.playCurrentSong=function(obj){var args=[];args[0]=obj;this.constructor.superclass.playCurrentSong.apply(this,args);};EditAudioComponent.prototype._scrollDescriptionDown=function(scroller){var args=[];args[0]=scroller;this.constructor.superclass._scrollDescriptionDown.apply(this,args);};EditAudioComponent.prototype._scrollDescriptionUp=function(scroller){var args=[];args[0]=scroller;this.constructor.superclass._scrollDescriptionUp.apply(this,args);};EditAudioComponent.prototype._scrollDownHandler=function(ev,audioInstance){var args=[];args[0]=audioInstance;audioInstance.constructor.superclass._scrollDownHandler.apply(this,args);};EditAudioComponent.prototype._scrollUpHandler=function(ev,audioInstance){var args=[];args[0]=audioInstance;audioInstance.constructor.superclass._scrollUpHandler.apply(this,args);};EditAudioComponent.prototype._stopScrollUp=function(){if(this.mouseUp){clearInterval(this.mouseUp);this.mouseUp=null;}};EditAudioComponent.prototype._stopScrollDown=function(){if(this.mouseDown){clearInterval(this.mouseDown);this.mouseDown=null;}};EditAudioComponent.prototype._onMouseWheel=function(ev){var descriptionScroll=Dom.get("audioWriteListScroll");if(descriptionScroll.parentNode.offsetHeight>descriptionScroll.offsetHeight){return;}
var scrolledUp=(ev.type=="DOMMouseScroll"&&ev.detail<0)||(ev.type=="mousewheel"&&ev.wheelDelta>0);var marginTop=parseInt(descriptionScroll.style.marginTop);if(scrolledUp){marginTop=marginTop+12;var scroller=Dom.get("audioWriteScrollDown");scroller.style.visibility="visible";if(marginTop>0){marginTop=0;var scroller=Dom.get("audioWriteScrollUp");scroller.style.visibility="hidden";}}else{marginTop=marginTop-12;var scroller=Dom.get("audioWriteScrollUp");scroller.style.visibility="visible";if(marginTop<descriptionScroll.parentNode.offsetHeight-descriptionScroll.offsetHeight){marginTop=descriptionScroll.parentNode.offsetHeight-descriptionScroll.offsetHeight;var scroller=Dom.get("audioWriteScrollDown");scroller.style.visibility="hidden";}}
descriptionScroll.style.marginTop=marginTop+"px";Event.stopEvent(ev);};function ViewAudioComponent(){this.audioListScrollContainer=Dom.get("audioListScrollContainer");this.audioListScroll=Dom.get("audioListScroll");this.audioListScrollUp=Dom.get("audioScrollUp");this.audioListScrollDown=Dom.get("audioScrollDown");this.audioBalloonTab=Dom.get("audioBalloonTab");this.audioPostBtn=Dom.get("audioBalloonPost");this.audioPlayer="audioBalloonPlayer";this.audioMediaPlayer="audioBalloonPlayerWMA";this.constructor.superclass.constructor.apply(this,[]);};YAHOO.lang.extend(ViewAudioComponent,AudioComponent);ViewAudioComponent.prototype.attachHandlers=function(){this.constructor.superclass.attachHandlers.apply(this,[]);};ViewAudioComponent.prototype._delegateClickEvent=function(ev){var obj=ev.target?ev.target:ev.srcElement;if(obj.className==="balloon-audio-name ellipsis"){this.playCurrentSong(obj);}};ViewAudioComponent.prototype.initAudioTab=function(poiId){var args=[];args[0]=poiId;this.constructor.superclass.initAudioTab.apply(this,args);};ViewAudioComponent.prototype.getData=function(data){var args=[];args[0]=data;this.constructor.superclass.getData.apply(this,args);};ViewAudioComponent.prototype.buildAudioTab=function(){this.constructor.superclass.buildAudioTab.apply(this,[]);};ViewAudioComponent.prototype.playCurrentSong=function(obj){var args=[];args[0]=obj;this.constructor.superclass.playCurrentSong.apply(this,args);};ViewAudioComponent.prototype._scrollDescriptionDown=function(scroller){var args=[];args[0]=scroller;this.constructor.superclass._scrollDescriptionDown.apply(this,args);};ViewAudioComponent.prototype._scrollDescriptionUp=function(scroller){var args=[];args[0]=scroller;this.constructor.superclass._scrollDescriptionUp.apply(this,args);};ViewAudioComponent.prototype._scrollDownHandler=function(ev,audioInstance){var args=[];args[0]=audioInstance;this.constructor.superclass._scrollDownHandler.apply(this,args);};ViewAudioComponent.prototype._scrollUpHandler=function(ev,audioInstance){var args=[];args[0]=audioInstance;this.constructor.superclass._scrollUpHandler.apply(this,args);};ViewAudioComponent.prototype._stopScrollUp=function(){if(this.mouseUp){clearInterval(this.mouseUp);this.mouseUp=null;}};ViewAudioComponent.prototype._stopScrollDown=function(){if(this.mouseDown){clearInterval(this.mouseDown);this.mouseDown=null;}};ViewAudioComponent.prototype._onMouseWheel=function(ev){var descriptionScroll=Dom.get("audioListScroll");if(descriptionScroll.parentNode.offsetHeight>descriptionScroll.offsetHeight){return;}
var scrolledUp=(ev.type=="DOMMouseScroll"&&ev.detail<0)||(ev.type=="mousewheel"&&ev.wheelDelta>0);var marginTop=parseInt(descriptionScroll.style.marginTop);if(scrolledUp){marginTop=marginTop+12;var scroller=Dom.get("audioScrollDown");scroller.style.visibility="visible";if(marginTop>0){marginTop=0;var scroller=Dom.get("audioScrollUp");scroller.style.visibility="hidden";}}else{marginTop=marginTop-12;var scroller=Dom.get("audioScrollUp");scroller.style.visibility="visible";if(marginTop<descriptionScroll.parentNode.offsetHeight-descriptionScroll.offsetHeight){marginTop=descriptionScroll.parentNode.offsetHeight-descriptionScroll.offsetHeight;var scroller=Dom.get("audioScrollDown");scroller.style.visibility="hidden";}}
descriptionScroll.style.marginTop=marginTop+"px";Event.stopEvent(ev);};