window.arivis=window.arivis||{};window.arivis.webview=window.arivis.webview||{};arivis.Webview=function(){this.yahooLibDir="js/yui_2.5.1/";this.yahooScripts=["connection/connection-min.js","menu/menu-min.js","resize/resize-beta-min.js","dragdrop/dragdrop-min.js","container/container-min.js","slider/slider-min.js","element/element-beta-min.js","button/button-min.js","animation/animation-min.js"];this.arivisLibDir="js/arivis/";this.arivisScripts=["Application.js","ImageConf.js","_unformed.js","Navigator.js","MoveTool.js","LoaderStatus.js","AnimationTool.js","Animation.js","LayerContainer.js","Layer.js","ImageLayer.js","LightningLayer.js","ImageLoader.js","Api.js","AppStatus.js","GeoCalc.js","ServerPull.js","Message.js","HomeDisplay.js"];this.eventNames=["endmove","drag","startdrag","enddrag","shortClick","longClick","dblClick","delayClickDown","shortLeftClick","longLeftClick","dblLeftClick","delayLeftClickDown","shortRightClick","longRightClick","dblRightClick","delayRightClickDown","shortMiddleClick","longMiddleClick","dblMiddleClick","delayMiddleClickDown","navigate","click","wheel","dblContextClick","applicationPrepared","applicationRun","applicationStop","applicationRestart","imageBeforeChange","imageChange","imageChangeDefault","zoomChange","viewBeforeChange","viewAfterChange","layerNewList","layerActivate","layerDeactivate","contextClick","serverUpdate","serverUnavailable","error"];};arivis.Webview.prototype={init:function(callback){this.callback=(callback)?callback:null;this.createEvents();this.callback();return;this.loadLib(this.yahooScripts,this.yahooLibDir);var instance=this;this.loadLib(this.arivisScripts,this.arivisLibDir,function(){instance.handleLoadingSuccess();});},handleLoadingSuccess:function(){this.createEvents();this.callback();},createEvents:function(){arivis.webview.event=new YAHOO.util.EventProvider;for(var id in this.eventNames){arivis.webview.event.createEvent(this.eventNames[id]);}},loadLib:function(script,dir,callback){param=(callback)?{onSuccess:callback}:{};if(typeof script=="object"){for(var id in script){script[id]=dir+script[id];}
YAHOO.util.Get.script(script,param);}
else{YAHOO.util.Get.script(dir+script,param);}},initialize:function(){arivis.webview.error=new arivis.webview.Error();arivis.webview.application=new arivis.webview.Application();arivis.webview.serverPull=new arivis.webview.ServerPull();arivis.webview.serverSession=new arivis.webview.ServerSession();arivis.webview.viewport=document.getElementById("viewport");arivis.webview.navigator=new arivis.webview.Navigator("navigator");arivis.webview.moveTool=new arivis.webview.Move("overflow","movebleMap",["navigator"]);arivis.webview.loadingLayer=new arivis.webview.LoadingLayer("loadingLayer",document.getElementById("movebleMap"));arivis.webview.layerContainer=new arivis.webview.LayerContainer("viewport","movebleMap");arivis.webview.layerUrl=new arivis.webview.LayerUrl();arivis.webview.imageLoader=new arivis.webview.ImageLoader();arivis.webview.appStatus=new arivis.webview.AppStatus();arivis.webview.wheelControl=new arivis.webview.WheelControl("viewport");arivis.webview.clickControl=new arivis.webview.ClickControl("movebleMap",true);arivis.webview.application.run();}};window.arivis.webview=new window.arivis.Webview();arivis.webview.Application=function(){var instance=this;};arivis.webview.Application.prototype={conf:null,active:null,isFreez:false,registry:[],appControl:null,isRunning:false,isRestart:false,timeout:10000,defaultImages:[],document:null,title:"arivis Webview",locked:false,mode:"normal",toString:function(){return"arivis.webview.Application";},loadDocument:function(o){var registry=new Array();var xmlDocument=o.responseXML;if(!xmlDocument||!xmlDocument.documentElement){return false;}
this.document=xmlDocument.documentElement;var documentElement=xmlDocument.documentElement;var baseElements=documentElement.getElementsByTagName("base");var baseConf=new Array();for(var i=0;i<baseElements.length;i++){var id=baseElements[i].getAttribute("id");baseConf[id]=baseElements[i];}
var images=documentElement.getElementsByTagName("image");for(var i=0;i<images.length;i++){var baseid=images[i].getAttribute("base");if(baseid&&baseConf[baseid]){var base=new arivis.webview.ImageConf(baseConf[baseid]);}
var imageConf=(base)?new arivis.webview.ImageConf(images[i],base):new arivis.webview.ImageConf(images[i]);registry.push(imageConf);}
return registry;},setConfigurationVar:function(o){var xmlDocument=o.responseXML;if(!xmlDocument||!xmlDocument.documentElement){return false;}
this.document=xmlDocument.documentElement;var documentElement=xmlDocument.documentElement;var applicationElem=documentElement.getElementsByTagName("application")[0];if(applicationElem){if(applicationElem.getAttribute("title")){this.title=applicationElem.getAttribute("title");}
if(applicationElem.getAttribute("mode")){this.mode=applicationElem.getAttribute("mode");}
if(applicationElem.getAttribute("locked")=="true"){this.locked=true;}}},getImages:function(){return(this.isRunning==true)?this.registry:false;},getImage:function(id,index){for(var i=0;i<this.registry.length;i++){if(this.registry[i].id==id){return(index)?i:this.registry[i];}}
return false;},getActiveImage:function(){return this.active;},setActiveImage:function(){this.active=this.registry;},registerImage:function(xmlNode){var image=new arivis.webview.Image(xmlNode);this.registry.push(image);return image;},run:function(){var queryParam=query2array(window.location.search);var url=(queryParam["conf"])?queryParam["conf"]:"webview.php";var callback={success:this.handleSuccess,failure:this.handleFailure,timeout:this.timeout,scope:this,argument:{url:url}};YAHOO.util.Connect.asyncRequest("GET",url,callback);},stop:function(){this.active=null;this.isRunning=false;this.isRestart=false;arivis.webview.event.fireEvent("applicationStop");},restart:function(){var queryParam=query2array(window.location.search);var url=(queryParam["conf"])?queryParam["conf"]:"webview.php";var callback={success:this.handleRestartSuccess,failure:this.handleRestartFailure,timeout:this.timeout,scope:this,argument:{url:url}};YAHOO.util.Connect.asyncRequest("GET",url,callback);},handleSuccess:function(o){this.setConfigurationVar(o);if(this.locked)
return this.handleLocked();arivis.webview.event.fireEvent("applicationPrepared",o.responseXML);var registry=this.loadDocument(o);if(!this.checkRegistry(o,registry))
return;this.registry=registry;this.isRunning=true;arivis.webview.event.fireEvent("applicationRun",o.responseXML);if(!this.active){this.selectImage(this.registry[0].id);}},handleRestartSuccess:function(o){this.setConfigurationVar(o);if(this.locked)
return this.handleLocked();arivis.webview.event.fireEvent("applicationPrepared",o.responseXML);var status=arivis.webview.appStatus.getStatus();var registry=this.loadDocument(o);if(!this.checkRegistry(o,registry))
return;this.isRestart=true;arivis.webview.event.fireEvent("applicationStop");this.isRunning=false;this.active=null;this.registry=registry;this.isRunning=true;arivis.webview.appStatus.setStatus(status);arivis.webview.event.fireEvent("applicationRestart",o.responseXML);if(!this.active){this.selectImage(this.registry[0].id);}
this.isRestart=false;},handleLocked:function(){this.stop();arivis.webview.event.fireEvent("message","application locked");return;},checkRegistry:function(o,registry){if(!registry){arivis.webview.event.fireEvent("message","configuration failure");arivis.webview.event.fireEvent("error","error configuration is empty [url: "+o.argument.url+", status: "+o.status+"]");return false;}
if(!registry.length){arivis.webview.event.fireEvent("message","configuration failure");arivis.webview.event.fireEvent("error","error configuration not images [url: "+o.argument.url+", status: "+o.status+"]");return false;}
return true;},handleFailure:function(o){this.stop();arivis.webview.event.fireEvent("message","configuration failure");arivis.webview.event.fireEvent("error","error configuration load [url: "+o.argument.url+", status: "+o.status+"]");},handleRestartFailure:function(o){arivis.webview.event.fireEvent("message","configuration reload failure");arivis.webview.event.fireEvent("error","error configuration load [url: "+o.argument.url+", status: "+o.status+"]");},selectImage:function(imageId,zoom,x,y){var image=this.getImage(imageId);if(!image){return false;}
if(image===this.active){return image;}
if(image.def){var extendImage=new arivis.webview.Image(this.defaultImages[image.def]);image.extendImageConf(extendImage);}
return this.setImage(image,zoom,x,y);},setImage:function(image,zoom,x,y){var isDefault=(!this.active)?true:false;var arg={image:image,zoom:zoom,x:x,y:y};arivis.webview.event.fireEvent("imageBeforeChange",arg);this.active=image;if(isDefault&&!this.isRestart)
arivis.webview.event.fireEvent("imageChangeDefault",arg);arivis.webview.event.fireEvent("imageChange",arg);return image;}};arivis.webview.Layer=function(map,container,active,conf,image,urlParamCallback,hidden){this.conf=conf;this.map=document.getElementById(map)||this.createLayer(map,container,conf,urlParamCallback,hidden);this.active=this.setActive(active);this.image=(image)?image:null;this.urlParamCallback=(urlParamCallback)?urlParamCallback:null;this.mapOffsetX=0;this.mapOffsetY=0;this.cache=[];this.prefetch={left:0,right:0,top:0,bottom:0};this.tileHeight=512;this.tileWidth=512;this.zoom=1;};arivis.webview.Layer.prototype.createLayer=function(map,container,conf,urlParamCallback,hidden){var element=document.createElement('div');element.setAttribute('id',map);YAHOO.util.Dom.addClass(element,'layer');if(hidden)
YAHOO.util.Dom.addClass(element,'hiddenLayer');if(conf&&conf.htmlClass){YAHOO.util.Dom.addClass(element,conf.htmlClass);}
container.appendChild(element);return element;};arivis.webview.Layer.prototype.getConf=function(xml){var conf={id:xml.getAttribute("id"),type:xml.getAttribute("type"),name:xml.getAttribute("name"),url:xml.getAttribute("url"),useid:xml.getAttribute("useid")};var param=xml.getElementsByTagName("param");conf.param=[];for(var i=0;i<param[0].attributes.length;i++){conf.param[param[0].attributes[i].nodeName]=param[0].attributes[i].nodeValue;}
return conf;};arivis.webview.Layer.prototype.init=function(map,layer,active){this.setActive(activ);this.layer=layer||this.layer;this.map=document.getElementById(map);};arivis.webview.Layer.prototype.toString=function(){return"arivis.webview.Layer";};arivis.webview.Layer.prototype.removeLayer=function(){var elem=this.map;var parentElem=elem.parentNode;parentElem.removeChild(elem);};arivis.webview.Layer.prototype.setActive=function(active){if(active){this.active=true;arivis.webview.event.fireEvent("layerActivate",this.conf.layerid);}
else{this.active=false;arivis.webview.event.fireEvent("layerDeactivate",this.conf.layerid);}
return this.active;};arivis.webview.Layer.prototype.activate=function(){if(this.isactive())
return this.active;this.setActive(true);this.buildCache();return this.active;};arivis.webview.Layer.prototype.deactivate=function(){if(!this.isactive())
return this.active;this.setActive(false);this.clearCache();return this.active;};arivis.webview.Layer.prototype.isactive=function(){return this.active;};arivis.webview.Layer.prototype.handleImageChange=function(image,zoom,x,y){this.clearCache();this.image=image;this.zoom=zoom;this.moveTo(x,y);};arivis.webview.Layer.prototype.changeView=function(zoomValue,startX,startY,isNewMap){var mapPos=this.getPosition();if((!isNewMap||isNewMap!=true)&&this.zoom==zoomValue&&startX==mapPos.x&&startY==mapPos.y){return false;}
this.zoom=zoomValue;this.moveTo(startX,startY);return true;};arivis.webview.Layer.prototype.getPosition=function(){var x=0-this.map.offsetLeft-this.mapOffsetX;var y=0-this.map.offsetTop-this.mapOffsetY;return{x:x,y:y};};arivis.webview.Layer.prototype.moveTo=function(x,y){this.resetPosition(x,y);if(this.buildCache)this.buildCache();};arivis.webview.Layer.prototype.resetPosition=function(x,y){this.mapOffsetX=0-x;this.mapOffsetY=0-y;this.map.style.left=0+"px";this.map.style.top=0+"px";};arivis.webview.Layer.prototype.resetTiles=function(){var left=this.mapOffsetX;var top=this.mapOffsetY;var x,y,row,tile;for(y=0;y<this.cache.length;y++){row=this.cache[y];for(x=0;x<row.length;x++){tile=row[x];tile.style.left=(tile.offsetLeft+left)+"px";tile.style.top=(tile.offsetTop+top)+"px";}}};arivis.webview.Animation=function(param){this.ready=false;this.container=[];this.currentFrame=0;this.countFrame=0;this.frameTime=100;this.frameList=new Array();this.timeID=0;this.loop=false;this.changeHandler=null;this.conditionalChangeHandler=null;this.nullTime=3000;if(param){this.setting(param);this.rewind();}};arivis.webview.Animation.prototype={toString:function(){return"arivis.webview.Animation";},setting:function(param){if(param.frames&&typeof(param.frames)=="object"&&param.frames.length){this.frameList=param.frames;}
else if(param.frameid&&typeof(param.frameid)=="object"&&param.frameid.length){for(var i in param.frameid){this.frameList[i]=[];if(typeof(param.frameid)!="string"&&param.frameid[i].length){for(var j in param.frameid[i]){this.frameList[i].push(document.getElementById(param.frameid[i][j]));}}
else{this.frameList.push(document.getElementById(param.frameid[i]));}}}
else if(param.container){if(typeof(param.container)=="object"){this.container=param.container;}
else if(document.getElementById(param.container)){this.container=document.getElementById(param.container);}}
else return false;this.countFrame=this.frameList.length;this.currentFrame=0;if(!isNaN(parseInt(param.time))){this.frameTime=parseInt(param.time);}
if(param.loop===true||param.loop===false){this.loop=param.loop;}
if(param.conditionalChangeHandler){this.conditionalChangeHandler=param.conditionalChangeHandler;}
if(param.changeHandler){this.changeHandler=param.changeHandler;}
if(param.nullTime){this.nullTime=param.nullTime;}
return true;},start:function(isBack){var self=this;self.timeID=window.setTimeout(function(){self.run(isBack);},this.frameTime);},stop:function(){window.clearTimeout(this.timeID);this.timeID=0;},step:function(newFrame,isAbsolute){newFrame=parseInt(newFrame);if(isNaN(newFrame)){return;}
this.stop();this.hideFrame(this.frameList[this.currentFrame]);this.currentFrame=(isAbsolute)?newFrame%this.countFrame:(this.currentFrame+this.countFrame+newFrame)%this.countFrame;this.showFrame(this.frameList[this.currentFrame]);this.change();return this.currentFrame;},rewind:function(){for(var i in this.frameList){this.hideFrame(this.frameList[i]);}
this.currentFrame=0;this.showFrame(this.frameList[this.currentFrame]);this.change();},toggle:function(){if(this.timeID>0){this.stop();return false;}
else{this.start();return true;}},run:function(isBack){window.clearTimeout(this.timeID);if(this.currentFrame==0&&this.loop!==true){return this.stop();}
var step=(isBack)?-1:+1;var nextFrame=(this.currentFrame+this.countFrame+step)%this.countFrame;var self=this;if(this.conditionalChangeHandler&&this.conditionalChangeHandler(nextFrame)!=true){this.timeID=window.setTimeout(function(){self.run(isBack);},this.frameTime);return;}
this.hideFrame(this.frameList[this.currentFrame]);this.currentFrame=nextFrame;this.showFrame(this.frameList[this.currentFrame]);var lastStep=(isBack)?0:this.countFrame-1;this.timeID=(this.currentFrame==lastStep&&this.nullTime)?window.setTimeout(function(){self.run(isBack);},this.nullTime):window.setTimeout(function(){self.run(isBack);},this.frameTime);this.change();},change:function(){if(this.changeHandler){this.changeHandler(this.currentFrame);}},showFrame:function(frame){if(frame&&frame.length){for(var i=0;i<frame.length;i++){frame[i].style.visibility="visible";}}
else if(frame&&frame.style){frame.style.visibility="visible";}},hideFrame:function(frame){if(frame&&frame.length){for(var i=0;i<frame.length;i++){frame[i].style.visibility="hidden";}}
else if(frame&&frame.style){frame.style.visibility="hidden";}}};arivis.webview.AnimationTool=function(){this.animation=null;this.isLoaded=false;this.images=null
this.frameid=[];this.staticLayerId=[];};arivis.webview.AnimationTool.prototype={toString:function(){return"arivis.webview.AnimationTool";},load:function(images,timer,frameChangeCallback,funcAnimationConditionalChangeFrame,nullTime){if(!images)return;var frameid=[];var doc=arivis.webview.application.document;var animXML=doc.getElementsByTagName("animation")[0];var imageConf=new arivis.webview.ImageConf(animXML);if(!nullTime&&imageConf["animSleep"])
nullTime=imageConf["animSleep"];if(!timer&&imageConf["animSpeed"])
timer=imageConf["animSpeed"];this.staticLayerId=[];var staticLayer=[];var dynamicLayer=[];var deleteLayer={};for(var i in imageConf.layer){var meteoLayer=imageConf.layer[i].meteo;var meteoLayerContainList=meteoLayer.split(",");if(meteoLayerContainList.length>1){dynamicLayer.push(imageConf.layer[i]);}
else{var meteo=arivis.webview.layerUrl.meteo;if(meteo[meteoLayerContainList[0]].dynamic)
dynamicLayer.push(imageConf.layer[i]);else{staticLayer.push(imageConf.layer[i]);this.staticLayerId.push(imageConf.layer[i].id);}}}
for(var i=0;i<images.length;i++){frameid[i]=[];for(var j=0;j<dynamicLayer.length;j++){var framelayerid=dynamicLayer[j].layerid+"_"+images[i];var layerByImage=api.getLayerByImage(images[i]);if(dynamicLayer[j].id==dynamicLayer[j].layerid&&(dynamicLayer[j].info||array_contains(layerByImage,dynamicLayer[j].layerid))){imageConf.layer[framelayerid]=clone(dynamicLayer[j]);imageConf.layer[framelayerid].id=framelayerid;imageConf.layer[framelayerid].imageid=images[i];frameid[i].push(framelayerid);}
else if(dynamicLayer[j].id==framelayerid){imageConf.layer[framelayerid]=dynamicLayer[j];frameid[i].push(framelayerid);}
deleteLayer[dynamicLayer[j].layerid]=1;}}
for(var delId in deleteLayer){delete imageConf.layer[delId];}
this.images=images;this.frameid=frameid;this.staticLayer=staticLayer;this.isLoaded=true;var zoom=arivis.webview.layerContainer.zoom;var pos=arivis.webview.layerContainer.getPosition();arivis.webview.application.setImage(imageConf,zoom,pos.x,pos.y);this.animation=new arivis.webview.Animation({frameid:frameid,time:(timer)?timer:500,nullTime:(nullTime)?nullTime:3000,loop:true,changeHandler:(frameChangeCallback)?frameChangeCallback:null,conditionalChangeHandler:(funcAnimationConditionalChangeFrame)?funcAnimationConditionalChangeFrame:null});},unload:function(){this.isLoaded=false;this.frameid=[];if(this.animation){this.animation.stop();delete this.animation;}},getFrame2Layer:function(frame){if(this.frameid[frame])
return this.frameid[frame];else
return this.frameid;},getStaticLayer:function(){return this.staticLayerId;},toggle:function(){if(!this.isLoaded){this.load();}
this.animation.toggle();},step:function(relPos){if(!this.isLoaded){this.load();}
return this.animation.step(relPos);},toggleLayer:function(layerid){return this.layerFunction(function(layerid){return arivis.webview.layerContainer.toggle(layerid);},layerid);},activateLayer:function(layerid){return this.layerFunction(function(layerid){return arivis.webview.layerContainer.activate(layerid);},layerid);},deactivateLayer:function(layerid){return this.layerFunction(function(layerid){return arivis.webview.layerContainer.deactivate(layerid);},layerid);},isactiveLayer:function(layerid){return this.layerFunction(function(layerid){return arivis.webview.layerContainer.isactive(layerid);},layerid);},isexistLayer:function(layerid){return this.layerFunction(layerid);},layerFunction:function(func,layerid){var ret=false;var constLayId=layerid;if(!this.isLoaded){return;}
layerid=constLayId;ret=func(layerid);if(ret)return ret;for(var i in this.images){layerid=constLayId+"_"+this.images[i];var step=func(layerid);ret=(step||ret);}
return ret;}};arivis.webview.Api=function(){this.event=arivis.webview.event;this.event.createEvent("message");this.loaderStatus=null;this.animationTool=null;this.init();this.imageChangeFunction=null;this.imageChangeFunctionId=0;};arivis.webview.Api.prototype={layerUrl:null,init:function(){},toString:function(){return"arivis.webview.Api";},initApplication:function(){if(!arivis.webview.application){arivis.webview.initialize();}
if(arivis.webview.layerUrl)
this.layerUrl=arivis.webview.layerUrl;return(arivis.webview.application)?arivis.webview.application.isRunning:false;},unloadApplication:function(){var layerId=this.getLayer();for(var id in layerId){this.deactivateLayer(layerId[id]);}},restartApplication:function(){arivis.webview.application.restart();},getZoom:function(){return arivis.webview.layerContainer.zoom;},setZoom:function(zoomValue){arivis.webview.layerContainer.setZoom(zoomValue);return arivis.webview.layerContainer.zoom;},getImages:function(){return arivis.webview.application.getImages();},getZoomLevel:function(imageId){var image=this.getImageConf(imageId);return(image)?image.zoom.level:null;},getImageConf:function(imageId){var imageConf=(imageId)?arivis.webview.application.getImage(imageId):(arivis.webview.application.active||null);return imageConf;},setImage:function(imageId,zoom,x,y){if(!imageId)
imageId=arivis.webview.application.active.id;if(!zoom)
zoom=arivis.webview.layerContainer.zoom;if(typeof x=="undefined"||typeof y=="undefined"){var pos=arivis.webview.layerContainer.getPosition();x=pos.x;y=pos.y;}
arivis.webview.application.selectImage(imageId,zoom,x,y);},changeImage:function(imageId,zoom,x,y){clearTimeout(this.imageChangeFunctionId);var first=(this.imageChangeFunction)?false:true;if(!zoom)
zoom=this.getZoom();var offset=arivis.webview.layerContainer.getPosition();if(typeof x=="undefined")
x=offset.x;if(typeof y=="undefined")
y=offset.y;this.imageChangeFunction=function(){arivis.webview.application.selectImage(imageId,zoom,x,y);};if(first)
arivis.webview.application.selectImage(imageId,zoom,x,y);else
this.imageChangeFunctionId=setTimeout(this.imageChangeFunction,200);return true;},getTimeOffset:function(imageId){var imageConf=this.getImageConf(imageId);return(imageConf)?{"timeZone":imageConf["timezone"],"timeOffset":imageConf["diff"]}:null;},getLayer:function(){return arivis.webview.layerContainer.getLayerIDs();},toggleLayer:function(meteoId,imageId){var active=this.isactiveLayer(meteoId);(active)?this.deactivateLayer(meteoId,imageId):this.activateLayer(meteoId,imageId);},activateLayer:function(meteoId){if(typeof meteoId!="string")
return;meteoId=meteoId.replace(/^layer_/,"");arivis.webview.layerUrl.activateMeteo(meteoId);return arivis.webview.layerUrl.isMeteoActive(meteoId);},deactivateLayer:function(meteoId){if(typeof meteoId!="string")
return;meteoId=meteoId.replace(/^layer_/,"");arivis.webview.layerUrl.deactivateMeteo(meteoId);return arivis.webview.layerUrl.isMeteoActive(meteoId);},isactiveLayer:function(meteoId,imageId){if(typeof meteoId!="string")
return;meteoId=meteoId.replace(/^layer_/,"");return arivis.webview.layerUrl.isMeteoActive(meteoId);},isLayerImage:function(layer,imageId){if(!imageId)return true;return(layer.conf.imageid==imageId)?true:false;},isexistLayer:function(meteoId,imageId){var prop=this.getLayerProp(meteoId,imageId);return prop.exists;},getLayerProp:function(meteoId,imageId){if(typeof meteoId!="string")
return;meteoId=meteoId.replace(/^layer_/,"");var layerProp={"exists":false,"alter":false,"active":false};if(!imageId)
imageId=arivis.webview.application.active.id;if(arivis.webview.layerUrl.isMeteo(meteoId,imageId))
layerProp["exists"]=true;if(arivis.webview.layerUrl.isMeteoActive(meteoId))
layerProp["active"]=true;if(arivis.webview.layerUrl.isMeteoAlterable(meteoId))
layerProp["alter"]=true;return layerProp;},getLayerStatus:function(layerId,imageId){return this.getLayerProp(layerId,imageId);},getLayerByImage:function(imageId){var retLayer=new Array();var imageConf=this.getImageConf(imageId);if(!imageConf)
return false;var layer=imageConf.layer;for(var id in layer){retLayer.push(id);var info=(layer[id].info)?layer[id].info.split(","):new Array();for(var jd in info){retLayer.push(info[jd]);}}
1;return retLayer;},setLoader:function(fnBegin,fnChange,fnEnd){this.loaderStatus=new arivis.webview.LoaderStatus(fnBegin,fnChange,fnEnd);},lockDrag:function(){arivis.webview.moveTool.lock();},unlockDrag:function(){arivis.webview.moveTool.unlock();},getStatusURL:function(asHash){return arivis.webview.appStatus.getStatusURL(asHash);},setStatusURL:function(url){return arivis.webview.appStatus.setStatusURL(url);},getImagePosition:function(x,y){var offset=arivis.webview.layerContainer.getPosition();var zoom=this.getZoom();var posX=(parseInt(x))?offset.x+x:offset.x;var posY=(parseInt(y))?offset.y+y:offset.y;var absX=Math.round(posX/zoom);var absY=Math.round(posY/zoom);return{x:absX,y:absY};},center2offset:function(centerXY){return arivis.webview.layerContainer.center2offset(centerXY);},moveMapBy:function(x,y){return arivis.webview.layerContainer.moveMapBy(x,y);},changeView:function(zoomValue,startX,startY,newLayerList,mousePos){return arivis.webview.layerContainer.changeView(zoomValue,startX,startY,newLayerList,mousePos);},setPanningFactor:function(panningFactor){if(arivis.webview.navigateControl){arivis.webview.navigateControl.setPanningFactor(panningFactor);return true;}
return false;},animationLoadingStatus:null,frameLoaded:new Array,frameLoadedAll:false,isAnimation:function(){var doc=arivis.webview.application.document;return(doc.getElementsByTagName("animation")[0])?true:false;},loadAnimation:function(images,timer,frameChangeCallback,nullTime){this.unloadAnimation();var funcAnimationLayerLoaded=(function(object){return function(stat,id){object.animationLayerLoaded(stat,id);};})(this);if(this.animationLoadingStatus)
this.animationLoadingStatus.init(null,funcAnimationLayerLoaded,funcAnimationLayerLoaded,true);else
this.animationLoadingStatus=new arivis.webview.LoaderStatus(null,funcAnimationLayerLoaded,funcAnimationLayerLoaded,true);var funcAnimationConditionalChangeFrame=(function(object){return function(frame){return object.animationConditionalChangeFrame(frame);};})(this);var funcAnimationChangeFrame=(function(object,func){return function(frame){object.animationChangeFrame(frame);func(frame);};})(this,frameChangeCallback);this.animationTool=new arivis.webview.AnimationTool();this.animationTool.load(images,timer,funcAnimationChangeFrame,funcAnimationConditionalChangeFrame,nullTime);return this.animationTool.animation;},unloadAnimation:function(){this.frameLoaded=new Array;this.frameLoadedAll=false;if(this.animationLoadingStatus)
this.animationLoadingStatus.stop();if(this.animationTool)
this.animationTool.unload();return null;},animationLayerLoaded:function(stat,id){if(id){this.frameLoaded[id]=(stat==1)?true:false;}
else{this.frameLoadedAll=(stat==1)?true:false;}},animationChangeFrame:function(frame){var rangedLayer=new Array();var staticLayer=this.animationTool.getStaticLayer();for(var iStatic in staticLayer)
rangedLayer.push(staticLayer[iStatic]);var layerInFrames=this.animationTool.getFrame2Layer();var endFor=frame+layerInFrames.length;for(var iFrame=frame;iFrame<endFor;iFrame++){var iFrameNo=iFrame%layerInFrames.length;for(var iLayer in layerInFrames[iFrameNo])
rangedLayer.push(layerInFrames[iFrameNo][iLayer]);}
arivis.webview.imageLoader.setLayerRange(rangedLayer);},animationConditionalChangeFrame:function(frame){if(this.frameLoadedAll)
return true;else{var layerInFrame=this.animationTool.getFrame2Layer(frame);for(i in layerInFrame){if(!this.frameLoaded[layerInFrame[i]])
return false;}
return true;}},map2zoom:function(mapValue,imageConf){if(!imageConf)
imageConf=this.getImageConf();var paramValueZoom=imageConf.zoom.paramValue;var zoomLevel=imageConf.zoom.level;var zoomIndex=-1;for(var i in paramValueZoom){if(paramValueZoom[i]==mapValue){zoomIndex=i;break;}}
if(zoomIndex==-1)
return false;return(zoomLevel[zoomIndex])?zoomLevel[zoomIndex]:imageConf.zoom.def;},zoom2map:function(zoomValue,imageConf){var paramValueZoom=imageConf.zoom.paramValue;var zoomLevel=imageConf.zoom.level;var defaultZoom=imageConf.zoom.def;for(var i in zoomLevel){if(zoomLevel[i]==zoomValue){var zoomIndex=i;}
if(zoomLevel[i]==defaultZoom){var zoomIndexDefault=i;}}
return(paramValueZoom[zoomIndex])?paramValueZoom[zoomIndex]:paramValueZoom[zoomIndexDefault];},getScreenshotURL:function(){var area=arivis.webview.layerContainer.getViewArea();if(area.x<0){area.w=area.w+area.x;area.x=0;}
if(area.y<0){area.h=area.h+area.y;area.y=0;}
var param=new Array();param["x"]=area.x;param["y"]=area.y;param["w"]=area.w;param["h"]=area.h;param["s"]=this.zoom2map(arivis.webview.layerContainer.zoom,arivis.webview.application.active);param["id"]=arivis.webview.application.active.id;param["download"]="";arivis.webview.layerUrl.handleScreenParam(param["id"],param);var url=composeURL("overlay",param);return url;},getServerStatus:function(){arivis.webview.serverPull.run();return true;}};arivis.webview.AppStatus=function(conf){this.conf={defaultParam:{timestamp:false,Zlat:50.738120,Zlon:7.103140,offsetX:0,offsetY:0,M:3,zoom:0.166666,S:1,R:1,B:1,G:1,F:1,C:1,H:0,live:false},autoSetURL:true,meteoParam:["S","R","B","F","G","C"]};overrideConf(this.conf,conf);this.init();};arivis.webview.AppStatus.prototype={lastStatus:null,homeDisplay:null,init:function(){if(this.conf.autoSetURL){arivis.webview.event.subscribe("applicationRun",this.setStatusURL,this,true);}},toString:function(){return"arivis.webview.AppStatus";},checkParamZoom:function(zoom){if(parseInt(zoom)!=zoom||parseInt(zoom)<1||parseInt(zoom)>4)
return false;return true;},getStatus:function(){var api=new arivis.webview.Api();var meteo={};for(var i=0;i<=this.conf.meteoParam.length;i++)
meteo[this.conf.meteoParam[i]]=api.isactiveLayer(this.conf.meteoParam[i])
return{offsetX:arivis.webview.layerContainer.mapOffsetX,offsetY:arivis.webview.layerContainer.mapOffsetY,zoomValue:arivis.webview.layerContainer.zoom,id:(arivis.webview.application.active)?arivis.webview.application.active.id:0,layer:meteo}},setStatus:function(status){arivis.webview.layerContainer.changeView(status.zoomValue,-status.offsetX,-status.offsetY);var api=new arivis.webview.Api();if(status.id)
api.changeImage(status.id);for(var i=0;i<this.conf.meteoParam.length;i++)
if(status.layer[this.conf.meteoParam[i]])
api.activateLayer(this.conf.meteoParam[i]);},getStatusURL:function(asHash){var param=this.getStatusParam();var array=location.href.split(/[\?\#]/);this.lastStatus=composeURL(array[0],param);return(asHash)?composeURL(array[0],null,param):this.lastStatus;},writeStatusInUrlHash:function(hash){var param=this.getStatusParam();window.location.hash=composeURL("",null,param);},getStatusParam:function(){var param=new Array();var image=arivis.webview.application.active;var zoomValue=arivis.webview.layerContainer.zoom;var api=new arivis.webview.Api();param["M"]=api.zoom2map(zoomValue,image);var offsetX=-arivis.webview.layerContainer.mapOffsetX;var offsetY=-arivis.webview.layerContainer.mapOffsetY;var centerXY=arivis.webview.layerContainer.offset2center({x:offsetX,y:offsetY});var geoCalc=new arivis.webview.GeoCalc(35,62,-11,25,image.size.width,image.size.height);var geoXY=geoCalc.px2geo(centerXY.x,centerXY.y,zoomValue);param["Zlat"]=geoXY.lat.toFixed(2);param["Zlon"]=geoXY.lon.toFixed(2);for(var i=0;i<this.conf.meteoParam.length;i++)
if(!api.isactiveLayer(this.conf.meteoParam[i]))
param[this.conf.meteoParam[i]]="0";return param;},setStatusURL:function(url){this.handleChangeDefault();if(typeof url=="string"){var queryParam=query2array(url);var hashParam=hash2array(url);}
else{var queryParam=query2array(window.location.search);var hashParam=hash2array(window.location.hash);}
var param=new Array();for(var id in this.conf.defaultParam){param[id]=(isdefined(queryParam,id))?queryParam[id]:this.conf.defaultParam[id];}
overrideConf(param,hashParam);var api=new arivis.webview.Api();var imageConf=api.getImageConf(param["timestamp"]);if(!imageConf){if(param["timestamp"])
var message="timestamp not available";imageConf=arivis.webview.application.registry[0];}
if(!imageConf){arivis.webview.event.fireEvent("message","not images available");return;}
if(message)
arivis.webview.event.fireEvent("message",message);var zoomValue=api.map2zoom(param["M"],imageConf);if(zoomValue==false){zoomValue=api.map2zoom(this.conf.defaultParam.M,imageConf);arivis.webview.event.fireEvent("message","zoom parameter out of range");}
var lat=parseFloat(param["Zlat"]);var lon=parseFloat(param["Zlon"]);var geoCalc=new arivis.webview.GeoCalc(35,62,-11,25,imageConf.size.width,imageConf.size.height);var geoXY=geoCalc.geo2px(lat,lon,zoomValue);if(!geoXY){geoXY=geoCalc.geo2px(this.conf.defaultParam.Zlat,this.conf.defaultParam.Zlon,zoomValue);arivis.webview.event.fireEvent("message","geo parameters out of range");}
var offsetXY=arivis.webview.layerContainer.center2offset(geoXY);if(param["H"]=="1"){var latlon=geoCalc.px2geo(geoXY.x,geoXY.y,zoomValue);var absXY=geoCalc.geo2px(latlon.lat,latlon.lon,1);this.homeDisplay=new arivis.webview.HomeDisplay(absXY.x,absXY.y);}
var image=api.changeImage(imageConf.id,zoomValue,offsetXY["x"],offsetXY["y"]);if(param["timestamp"]&&!image)
arivis.webview.event.fireEvent("message","timestamp not available");},setDefaultParam:function(param){for(var id in param){if(this.conf.defaultParam[id]){this.conf.defaultParam[id]=param[id];}}},handleChangeDefault:function(){var param=query2array(window.location.search);var lay=new Array();for(var i=0;i<this.conf.meteoParam.length;i++){var meteo=this.conf.meteoParam[i];if(param[meteo]&&param[meteo]!="0"&&param[meteo]!="1")
arivis.webview.event.fireEvent("message","layer parameter "+meteo+" not evaluate");lay[this.conf.meteoParam[i]]=(param[meteo]!="0")?true:false;}
var api=new arivis.webview.Api();for(var id in lay){if(!lay[id])
api.deactivateLayer(id);}
if(this.homeDisplay){this.homeDisplay.setPosition();}}};arivis.webview.ClickControl=function(elem,isBlockContext){this.init(elem,isBlockContext);};arivis.webview.ClickControl.prototype={isWindowFocus:false,focusId:0,elem:null,decisionId:0,decisionTime:300,decision:"",init:function(elem,isBlockContext){this.windowFocus();if(document.all&&!window.opera){YAHOO.util.Event.addListener(document,"focusin",this.windowFocus,this,true);YAHOO.util.Event.addListener(document,"focusout",this.windowBlur,this,true);}
else{YAHOO.util.Event.addListener(window,"focus",this.windowFocus,this,true);YAHOO.util.Event.addListener(window,"blur",this.windowBlur,this,true);}
this.elem=document.getElementById(elem);arivis.webview.event.subscribe("drag",function(){this.decision="long";},this,true);YAHOO.util.Event.addListener(this.elem,"mousedown",this.handleDown,this,true);YAHOO.util.Event.addListener(this.elem,"mouseup",this.handleUp,this,true);if(isBlockContext)YAHOO.util.Event.addListener(this.elem,"contextmenu",this.stopEvent,this,true);},toString:function(){return"arivis.webview.ClickControl";},windowFocus:function(){window.clearTimeout(this.focusId);var self=this;this.focusId=window.setTimeout(function(){self.isWindowFocus=true;},200);},windowBlur:function(){window.clearTimeout(this.focusId);var self=this;this.focusId=window.setTimeout(function(){self.isWindowFocus=false;},200);},handleUp:function(e){if(this.isWindowFocus==false)
return;if(this.decisionId){if(this.decision=="short"){this.decision="dbl";this.endDecisionPhase(e,true);}
else if(this.decision!="long"){this.decision="short";}}
else{this.endDecisionPhase(e,true);}},handleDown:function(e){if(this.decisionId){this.decision="dbl";this.endDecisionPhase(e,true);}
else{var self=this;e=this._getConsistentEvent(e);this.decision="delay";this.decisionId=window.setTimeout(function(){self.endDecisionPhase(e);},this.decisionTime);}},endDecisionPhase:function(e,output){window.clearTimeout(this.decisionId);this.decisionId=0;if(this.decision=="delay"){this.delayAction(e);this.decision="long";}
else if(this.decision=="short"){this.clickAction(e,this.decision);this.decision="";}
else if(this.decision&&output){this.clickAction(e,this.decision);this.decision="";}},stopEvent:function(e){YAHOO.util.Event.stopEvent(e);},clickAction:function(e,type){arivis.webview.event.fireEvent(type+"Click",e);var key=this.getKey(e);if(key)arivis.webview.event.fireEvent(type+key+"Click",e);},delayAction:function(e){var xy=YAHOO.util.Event.getXY(e);arivis.webview.event.fireEvent("delayClickDown",xy);var key=this.getKey(e);if(key)arivis.webview.event.fireEvent("delay"+key+"ClickDown",xy);},getKey:function(e){var key="";if(window.opera){if(e.shiftKey==true)
key="Right";else
key="Left";}
else if(e.button){if(e.button==1)
key="Left";else if(e.button==2)
key="Right";else if(e.button==4)
key="Middle";}
else if(e.which){if(e.which==1)
key="Left";else if(e.which==3)
key="Right";else if(e.which==2)
key="Middle";}
return key;},_getConsistentEvent:function(e){if(document.all){var eventClone=new Object;for(var id in e)
eventClone[id]=e[id];e=eventClone;}
return e;}};arivis.webview.Error=function(){this.serverMessageURL="message.php";this.init();};arivis.webview.Error.prototype={init:function(){arivis.webview.event.subscribe("error",this.handleError,this,true);},handleError:function(id){this.serverMessage(id);},serverMessage:function(id){var id=(id)?id:"undefined message";var param=new Array();param["id"]=id;param["url"]=location.href;var url=composeURL(this.serverMessageURL,param);var callback={success:function(arg){this.handleSuccess(arg,id);},failure:function(arg){this.handleFailure(arg,id);},scope:this};YAHOO.util.Connect.asyncRequest("GET",url,callback);},handleSuccess:function(argument,id){var text=argument.responseText;if(text=="1")
arivis.webview.event.fireEvent("message","server message ok");else
arivis.webview.event.fireEvent("message","server message failure");return;},handleFailure:function(argument,id){arivis.webview.event.fireEvent("message","server message failure");}};arivis.webview.GeoCalc=function(latBegin,latEnd,lonBegin,lonEnd,imageWidth,imageHeight){this.latBegin=parseFloat(latBegin);this.latEnd=parseFloat(latEnd);this.lonBegin=parseFloat(lonBegin);this.lonEnd=parseFloat(lonEnd);this.imageWidth=parseInt(imageWidth);this.imageHeight=parseInt(imageHeight);};arivis.webview.GeoCalc.prototype={px2geo:function(x,y,zoom){zoom=parseFloat(zoom);x=parseInt(x);y=parseInt(y);var lon=this.lonBegin+(x*(this.lonEnd-this.lonBegin)/(this.imageWidth*zoom));var lat=this.latEnd-(y*(this.latEnd-this.latBegin)/(this.imageHeight*zoom));return{lon:lon,lat:lat};},geo2px:function(lat,lon,zoom){zoom=parseFloat(zoom);lon=parseFloat(lon);lat=parseFloat(lat);if(lat<this.latBegin||lat>this.latEnd||lon<this.lonBegin||lon>this.lonEnd){return false;}
var x=Math.round(this.imageWidth*zoom*(lon-this.lonBegin)/(this.lonEnd-this.lonBegin));var y=Math.round(this.imageHeight*zoom*(this.latEnd-lat)/(this.latEnd-this.latBegin));return{x:x,y:y};}};arivis.webview.HomeDisplay=function(x,y){this.posX=parseInt(x);this.posY=parseInt(y);this.element=null;arivis.webview.event.subscribe("enddrag",this.setPosition,this,true);arivis.webview.event.subscribe("endmove",this.setPosition,this,true);arivis.webview.event.subscribe("zoomChange",this.setPosition,this,true);arivis.webview.event.subscribe("navigate",this.setPosition,this,true);YAHOO.util.Event.addListener(window,"resize",this.setPosition,this,true);this.init();};arivis.webview.HomeDisplay.prototype={toString:function(){return"arivis.webview.HomeDisplay";},init:function(){var container=document.getElementById("movebleMap");var element=document.createElement('div');element.setAttribute('id',"homepoint");YAHOO.util.Dom.addClass(element,'layer');container.appendChild(element);this.element=element;this.setPosition();},handleImageChange:function(image,zoom,x,y){this.zoom=zoom;this.setPosition(x,y);},setPosition:function(){var zoom=arivis.webview.layerContainer.zoom;var pos=arivis.webview.layerContainer.getPosition();var relHomeX=parseInt(this.posX*zoom)-pos.x;var relHomeY=parseInt(this.posY*zoom)-pos.y;this.element.style.left=relHomeX+"px";this.element.style.top=relHomeY+"px";}};arivis.webview.DefaultImageConf=function(){};arivis.webview.DefaultImageConf.prototype={id:"",name:"",description:null,previewImage:null,annotations:0,urlPrefix:null,size:{x:0,y:0,width:null,height:null,planes:null,filesize:null},zoom:{min:null,max:null,def:null,paramName:null,paramValue:null,level:null}};arivis.webview.DefaultLayerConf=function(){};arivis.webview.DefaultLayerConf.prototype={id:"",imageid:"",layerid:"",name:"",type:"",url:"",useid:"true",info:"",param:{}};arivis.webview.ImageConf=function(xml,baseConf){if(xml){var conf=(baseConf)?baseConf:new arivis.webview.DefaultImageConf();return this.getConf(xml,conf);}};arivis.webview.ImageConf.prototype={getConf:function(xml,baseConf){var conf=this.getAttrConf(xml,baseConf);timezone=getMEZ_MESZ(conf.id);conf.diff=(timezone=="MESZ")?"02:00":"01:00";var descrElement=xml.getElementsByTagName("description")[0];if(descrElement)
conf.description=descrElement.firstChild.nodeValue;var sizeElement=xml.getElementsByTagName("size")[0];if(sizeElement)
conf.size=this.getAttrConf(sizeElement,conf.size);var zoomElement=xml.getElementsByTagName("zoom")[0];if(zoomElement){conf.zoom=this.getAttrConf(zoomElement,conf.zoom);if(zoomElement.firstChild)
conf.zoom.level=zoomElement.firstChild.nodeValue.split(",");if(conf.zoom.paramValue)
conf.zoom.paramValue=conf.zoom.paramValue.split(",");}
var meteoConfig=xml.getElementsByTagName("meteoconfig")[0];var meteoElements=xml.getElementsByTagName("meteo");conf.meteo={};if(meteoElements.length){for(var i=0;i<meteoElements.length;i++){var id=meteoElements[i].getAttribute("id");conf.meteo[id]=this.getAttrConf(meteoElements);}}
var layerElements=xml.getElementsByTagName("layer");if(layerElements.length){conf.layer={};for(var i=0;i<layerElements.length;i++){var id=layerElements[i].getAttribute("id");conf.layer[id]=this.getLayerConf(layerElements[i]);}}
if(conf.layer){for(var id in conf.layer){var layerconf=conf.layer[id];if(!layerconf.imageid&&xml.nodeName!="base")
layerconf.imageid=conf.id;if(!layerconf.layerid)
if(layerconf.id)
layerconf.layerid=layerconf.id;else
layerconf.layerid=id;}}
return conf;},getLayerConf:function(xml,baseConf){var conf=(baseConf)?baseConf:new arivis.webview.DefaultLayerConf;conf=this.getAttrConf(xml,conf);var paramElement=xml.getElementsByTagName("param")[0];if(paramElement)
conf.param=this.getAttrConf(paramElement);return conf;},getAttrConf:function(xml,baseConf){var conf=(baseConf)?baseConf:{};for(var i=0;i<xml.attributes.length;i++){conf[xml.attributes[i].nodeName]=xml.attributes[i].nodeValue;}
return conf;},toString:function(){return"arivis.webview.ImageConf";}};arivis.webview.ImageLayer=function(map,layer,active,xml,image,urlCallback){arivis.webview.ImageLayer.superclass.constructor.apply(this,arguments);this.imageLoader=arivis.webview.imageLoader;this.tileType="img";this.tileHeight=this.tileHeight;this.tileWidth=this.tileWidth;this.blankImgSrc="/images/transparent.png";this.init(map,layer,active,xml);};YAHOO.lang.extend(arivis.webview.ImageLayer,arivis.webview.Layer);arivis.webview.ImageLayer.prototype.toString=function(){return"arivis.webview.ImageLayer";};arivis.webview.ImageLayer.prototype.init=function(){if(this.conf&&this.conf.param.w)
this.tileWidth=parseInt(this.conf.param.w);if(this.conf&&this.conf.param.h)
this.tileHeight=parseInt(this.conf.param.h);};arivis.webview.ImageLayer.prototype.clearCache=function(){while(this.map.hasChildNodes()){this.map.removeChild(this.map.firstChild);}
this.cache.splice(0,this.cache.length);var loaderCategory=this.getCategory();this.imageLoader.clear(loaderCategory);};arivis.webview.ImageLayer.prototype.freezeLayer=function(){var elem=this.map;elem.setAttribute("id","__"+elem.getAttribute("id"));};arivis.webview.ImageLayer.prototype.removeLayer=function(delaytime){var loaderCategory=this.getCategory();this.imageLoader.clear(loaderCategory);var elem=this.map;var parentElem=elem.parentNode;if(!parentElem){return;}
if(parseInt(delaytime)>=0){window.setTimeout(function(){parentElem.removeChild(elem);},parseInt(delaytime));}
else{parentElem.removeChild(elem);}};arivis.webview.ImageLayer.prototype.buildCache=function(){if(this.active!==true){return;}
this.clearCache();var mapPos=arivis.webview.layerContainer.getPosition();var startX=mapPos.x;var startY=mapPos.y;var endX=startX+getViewportWidth();var endY=startY+getViewportHeight();startX-=this.prefetch.left*this.tileWidth;startY-=this.prefetch.top*this.tileHeight;endX+=this.prefetch.right*this.tileWidth;endY+=this.prefetch.bottom*this.tileHeight;startX=Math.floor(startX/this.tileWidth)*this.tileWidth;endX=Math.ceil(endX/this.tileWidth)*this.tileWidth;startY=Math.floor(startY/this.tileHeight)*this.tileHeight;endY=Math.ceil(endY/this.tileHeight)*this.tileHeight;var x=startX;var y=startY;var tileRow=null;var x=startX;var y=startY;var tileRow=null;while(y<endY){tileRow=[];x=startX;while(x<endX){var tt=this.createTile(x,y);tileRow.push(tt);x+=this.tileWidth;}
this.cache.push(tileRow);y+=this.tileHeight;}
this.updateAllTiles();};arivis.webview.ImageLayer.prototype.updateAllTiles=function(){var loaderCategory=this.getCategory();this.imageLoader.clear(loaderCategory);if(this.cache.length===0){return;}
var startY=Math.floor(this.prefetch.top);var endY=this.cache.length-Math.floor(this.prefetch.bottom);var startX=Math.floor(this.prefetch.left);var endX=this.cache[0].length-Math.floor(this.prefetch.right);var x,y,tileRow;for(y=startY;y<endY;y++){tileRow=this.cache[y];for(x=startX;x<endX;x++){this.updateTile(tileRow[x]);}}
for(y=0;y<this.cache.length;y++){tileRow=this.cache[y];for(x=0;x<tileRow.length;x++){if(x<startX||x>=endX||y<startY||y>=endY){this.updateTile(tileRow[x]);}}}};arivis.webview.ImageLayer.prototype.loadTile=function(tile,url){var loaderCategory=this.getCategory();this.imageLoader.requestImage(tile,url,loaderCategory);};arivis.webview.ImageLayer.prototype.removeTile=function(tile){if(!arivis.webview.application.isFreez){this.imageLoader.cancleRequest(this.map.removeChild(tile));}};arivis.webview.ImageLayer.prototype.createTile=function(x,y){if(arivis.webview.application.isFreez===true){return null;}
var tile=document.createElement(this.tileType);tile.tk_x=x;tile.tk_y=y;tile.style.position="absolute";tile.src=this.blankImgSrc;this.map.appendChild(tile);return tile;};arivis.webview.ImageLayer.prototype.updateTile=function(tile){if(!tile)return;tile.style.left=(tile.tk_x+this.mapOffsetX)+"px";tile.style.top=(tile.tk_y+this.mapOffsetY)+"px";var minX=this.image.size.x*this.zoom;var minY=this.image.size.y*this.zoom;var maxX=Math.round((this.image.size.x+this.image.size.width)*this.zoom);var maxY=Math.round((this.image.size.y+this.image.size.height)*this.zoom);if(tile.tk_x+this.tileWidth<=minX||tile.tk_y+this.tileHeight<=minY||tile.tk_x>=maxX||tile.tk_y>=maxY){tile.style.background="";tile.style.height=this.tileHeight+"px";tile.style.width=this.tileWidth+"px";}else{var height=(tile.tk_y+this.tileHeight>maxY)?(maxY-tile.tk_y):this.tileHeight;var width=(tile.tk_x+this.tileWidth>maxX)?(maxX-tile.tk_x):this.tileWidth;var param=[];for(var i in this.conf.param){param[i]=this.conf.param[i];}
param["x"]=tile.tk_x;param["y"]=tile.tk_y;param["w"]=width;param["h"]=height;if(this.image.zoom.paramName){var paramNameZoom=this.image.zoom.paramName;var paramValueZoom=this.zoom;if(this.image.zoom.paramValue){for(var j=0;j<=this.image.zoom.level.length;j++){if(this.zoom==(this.image.zoom.level[j])){paramValueZoom=this.image.zoom.paramValue[j];}}}
param[paramNameZoom]=paramValueZoom;}
else
param["z"]=this.zoom;if(this.urlParamCallback&&this.urlParamCallback(this.conf,param)==false){tile.src=this.blankImgSrc;return false;}
var url=composeURL(this.conf.url,param);tile.style.height=height+"px";tile.style.width=width+"px";if(this.active===true&&arivis.webview.application.isFreez!==true){this.loadTile(tile,url);}}};arivis.webview.ImageLayer.prototype.setPrefetch=function(value){this.prefetch.left=value;this.prefetch.top=value;this.prefetch.right=value;this.prefetch.bottom=value;this.update(this.map.offsetLeft,this.map.offsetRight);};arivis.webview.ImageLayer.prototype.getPrefetch=function(){return this.prefetch.left;};arivis.webview.ImageLayer.prototype.update=function(x,y){if(this.active!==true){return;}
this.updateTop(x,y);this.updateBottom(x,y);this.updateLeft(x,y);this.updateRight(x,y);};arivis.webview.ImageLayer.prototype.updateTop=function(newXpos,newYpos){var imageLeft=this.cache[0][0].tk_x;var imageCount=this.cache[0].length;var targetY=Math.floor(newYpos-this.prefetch.top*this.tileHeight);var imageY=this.cache[0][0].tk_y;var i,row,newY,tile;while(imageY>targetY){row=[];newY=imageY-this.tileHeight;for(i=0;i<imageCount;i++){tile=this.createTile(imageLeft+i*this.tileWidth,newY);this.updateTile(tile);row.push(tile);}
this.cache.unshift(row);imageY=newY;}
while(imageY+this.tileHeight<targetY){row=this.cache.shift();for(i=0;i<row.length;i++){tile=row[i];this.removeTile(tile);}
imageY+=this.tileWidth;}};arivis.webview.ImageLayer.prototype.updateBottom=function(newXpos,newYpos){var imageLeft=this.cache[0][0].tk_x;var imageCount=this.cache[0].length;var targetY=Math.ceil(newYpos+getViewportHeight()+this.prefetch.bottom*this.tileHeight-this.tileHeight);var imageY=this.cache[this.cache.length-1][0].tk_y;var i,newY,row,tile;while(imageY<targetY){row=[];newY=imageY+this.tileHeight;for(i=0;i<imageCount;i++){tile=this.createTile(imageLeft+i*this.tileWidth,newY);this.updateTile(tile);row[i]=tile;}
this.cache.push(row);imageY=newY;}
while(imageY>targetY+this.tileHeight){row=this.cache.pop();for(i=0;i<row.length;i++){tile=row[i];this.removeTile(tile);}
imageY-=this.tileWidth;}};arivis.webview.ImageLayer.prototype.updateLeft=function(newXpos,newYpos){var imageTop=this.cache[0][0].tk_y;var targetX=Math.floor(newXpos-this.prefetch.left*this.tileWidth);var imageX=this.cache[0][0].tk_x;var newX,i,tile;while(imageX>targetX){newX=imageX-this.tileWidth;for(i=0;i<this.cache.length;i++){tile=this.createTile(newX,imageTop+i*this.tileHeight);this.updateTile(tile);this.cache[i].unshift(tile);}
imageX=newX;}
while(imageX+this.tileWidth<targetX){for(i=0;i<this.cache.length;i++){tile=this.cache[i].shift();this.removeTile(tile);}
imageX+=this.tileWidth;}};arivis.webview.ImageLayer.prototype.updateRight=function(newXpos,newYpos){var imageTop=this.cache[0][0].tk_y;var imageX=this.cache[0][this.cache[0].length-1].tk_x;var targetX=Math.ceil(newXpos+getViewportWidth()+this.prefetch.right*this.tileWidth-this.tileWidth);var newX,i,tile;while(imageX<targetX){newX=imageX+this.tileWidth;for(i=0;i<this.cache.length;i++){tile=this.createTile(newX,imageTop+i*this.tileHeight);this.updateTile(tile);this.cache[i].push(tile);}
imageX=newX;}
while(imageX>targetX+this.tileWidth){for(i=0;i<this.cache.length;i++){tile=this.cache[i].pop();this.removeTile(tile);}
imageX-=this.tileWidth;}};arivis.webview.ImageLayer.prototype.getLoadCondition=function(){var countTiles=this.getCountTiles();if(countTiles<=0)return 1;var loaderCategory=this.getCategory();var loading=this.imageLoader.getLoadingCount(loaderCategory);if(countTiles<=loading)return 0;return(countTiles-loading)/countTiles;};arivis.webview.ImageLayer.prototype.getCountTiles=function(){var count=0;for(var i in this.cache)
count+=this.cache[i].length;return count;};arivis.webview.ImageLayer.prototype.getCategory=function(){return this.map.id;};arivis.webview.ImageLoader=function(){arivis.webview.event.subscribe("applicationRun",this.applicationRunHandler,this,true);arivis.webview.event.subscribe("applicationRestart",this.applicationRunHandler,this,true);arivis.webview.event.subscribe("viewAfterChange",this.limitCache,this,true);arivis.webview.event.subscribe("enddrag",this.limitCache,this,true);}
arivis.webview.ImageLoader.prototype={requestList:[],loadList:[],maxLoad:10,isRunning:0,useDirectMode:false,timer:100,startTimer:0,timeout:20,cacheFlag:true,cacheCount:100,cache:[],rangedLayer:null,sortedByLayer:false,applicationRunHandler:function(xmlDocument){var documentElement=xmlDocument.documentElement;var elem=documentElement.getElementsByTagName("modImageLoader");if(!elem||!elem.length)return;var cacheCount=elem[0].getAttribute("cacheCount");if(parseInt(cacheCount)||cacheCount==0)
this.cacheCount=parseInt(cacheCount);},clear:function(category){var instance=this;count1=instance.clearByCategory(instance.requestList,category);count2=instance.clearByCategory(instance.loadList,category);},clearByCategory:function(list,category){var count=0;for(var i=(list.length-1);i>=0;i--){if(list[i].category==category){arivis.webview.loadingLayer.clearElement(list[i].element.loadingElem);list.splice(i,1);count++;}}
return count;},requestImage:function(element,url,category,method,scope){var instance=this;var request={element:element,url:url,category:category,loaded:false,method:method,scope:scope};if(instance.useDirectMode){instance.applyImage(request);return;}
instance.requestList.push(request);request.element.loadingElem=arivis.webview.loadingLayer.loading(element);if(this.rangedLayer)
this.setNotSorted();if(!instance.isRunning){if(parseInt(instance.startTimer)>=0)
instance.isRunning=window.setTimeout(function(){instance.run();},parseInt(instance.startTimer));else{instance.run();instance.isRunning=1;}}},cancleRequest:function(element){element.cancel=true;arivis.webview.loadingLayer.clearElement(element.loadingElem);element.loadingElem=null;},applyImage:function(request){if(!request.method){request.element.src=request.url;arivis.webview.loadingLayer.clearElement(request.element.loadingElem);}else{if(request.scope){request.method.call(request.scope,request.element,request.url);}else{request.method(request.element,request.url);}}
if(this.cacheFlag==false)
return;var now=new Date();request.element.cacheRange=now.getTime();this.cache[request.element.src]=request.element;request.loaded=true;},limitCache:function(){var indexCache=this.getIndexCache();for(var i=this.cacheCount;i<indexCache.length;i++){delete this.cache[indexCache[i].src];}},setNotSorted:function(rangedLayer){this.sortedByLayer=false;},setLayerRange:function(rangedLayer){this.rangedLayer=rangedLayer;this.sortedByLayer=false;},unsetLayerRange:function(rangedLayer){this.rangedLayer=null;},sortRequestByLayer:function(){if(!this.requestList.length||!this.rangedLayer)
return;var rangedLayer=this.rangedLayer;var newPartList=new Array();for(var j=0;j<rangedLayer.length;j++){newPartList[rangedLayer[j]]=new Array();}
newPartList["0"]=new Array();for(var i=0;i<this.requestList.length;i++){if(newPartList[this.requestList[i].category])
newPartList[this.requestList[i].category].push(this.requestList[i]);else
newPartList["0"].push(this.requestList[i]);}
var newRequestList=new Array();for(var j=0;j<rangedLayer.length;j++){newRequestList=newRequestList.concat(newPartList[rangedLayer[j]]);}
newRequestList=newRequestList.concat(newPartList["0"]);this.requestList=newRequestList;this.sortedByLayer=true;},getIndexCache:function(){var indexCache=[];for(var id in this.cache){indexCache.push(this.cache[id]);}
indexCache.sort(function(a,b){return b.cacheRange-a.cacheRange;});return indexCache;},getCacheCount:function(){var i=0;for(var id in this.cache){i++;}
return i;},getLoadingCount:function(category){var loading=0;var list=this.requestList.concat(this.loadList);for(var i=(list.length-1);i>=0;i--){if(!category||list[i].category==category){if(list[i].loaded!=true&&list[i].element.cancel!=true){loading++;}}}
return loading;},run:function(){var instance=this;var timestamp=new Date().getTime()/1000;clearTimeout(instance.isRunning);var i=0;var request;while(i<instance.loadList.length){request=instance.loadList[i];if(request.image.complete||request.timeout<timestamp){instance.applyImage(request);instance.loadList.splice(i,1);}else{i++;}}
if(this.requestList.length>0&&!this.sortedByLayer&&this.rangedLayer)
this.sortRequestByLayer();var requested=0;while(instance.requestList.length>0&&instance.loadList.length<instance.maxLoad){request=instance.requestList.shift();var cancel=(request.element.cancel&&request.element.cancel===true)?true:false;if(cancel===false){request.image=new Image();request.image.src=request.url;request.timeout=timestamp+instance.timeout;if(request.image.complete){instance.applyImage(request);}else{instance.loadList.push(request);}
requested++;}}
if(instance.requestList.length==0&&instance.loadList.length==0){instance.isRunning=0;arivis.webview.loadingLayer.clearAll();}
else{instance.isRunning=window.setTimeout(function(){instance.run();},instance.timer);}},stop:function(){window.clearTimeout(this.isRunning);}};arivis.webview.LayerContainer=function(viewport,map){this.init(viewport,map);};arivis.webview.LayerContainer.prototype={viewport:null,image:null,map:null,mapOffsetX:0,mapOffsetY:0,centerXY:null,zoom:0,layer:{},layerRange:null,navigateFunktion:null,updateTimer:300,updateTimerId:0,lastUpdate:0,updateX:0,updateY:0,urlParamCallback:null,iLayer:0,delayNewLayerVisibility:181,init:function(viewport,map){this.viewport=document.getElementById(viewport);this.map=document.getElementById(map);this.centerXY=this.offset2center({x:-this.mapOffsetX,y:-this.mapOffsetY});arivis.webview.event.subscribe("navigate",function(arg){var self=this;this.navigateFunktion=function(){self.changeView(self.zoom,arg.x,arg.y);};setTimeout(this.navigateFunktion,200);},this,true);arivis.webview.event.subscribe("drag",this.update,this,true);arivis.webview.event.subscribe("enddrag",function(){this._updateLayer();this.resetPosition();},this,true);arivis.webview.event.subscribe("imageChange",this.handleImageChange,this,true);arivis.webview.event.subscribe("wheel",this.wheelZoom,this,true);arivis.webview.event.subscribe("dblLeftClick",function(e){this.clickZoom(e);},this,true);arivis.webview.event.subscribe("dblRightClick",function(e){this.clickZoom(e,true);},this,true);YAHOO.util.Event.addListener(window,"resize",this.handleResize,this,true);},toString:function(){return"arivis.webview.LayerContainer";},setUrlParamCallback:function(urlParamCallback){if(typeof urlParamCallback=="function")
this.urlParamCallback=urlParamCallback;},wheelZoom:function(param){var oldZoom=this.zoom;var zoomValue=(param.delta<0)?this.prevZoom():this.nextZoom();if(!zoomValue)zoomValue=this.zoom;if(oldZoom==zoomValue)
return;var absX=param.x-this.mapOffsetX;var absY=param.y-this.mapOffsetY;var newXY=this.getPositionInZoom(absX,absY,zoomValue,oldZoom);if(newXY){var offsetX=newXY.x-param.x;var offsetY=newXY.y-param.y;this.changeView(zoomValue,offsetX,offsetY);}},getPositionInZoom:function(x,y,zoom,zoomXY){zoomXY=(zoomXY)?zoomXY:1;if(parseInt(x)&&parseInt(y)){var zoomFactor=zoom/zoomXY;var newX=x*zoomFactor;var newY=y*zoomFactor;return{x:Math.round(newX),y:Math.round(newY)};}
return;},clickZoom:function(e,zoomout){var oAbsPosViewport=getAbsPosition(this.viewport);var nRelPosClickInViewportX=e.clientX-oAbsPosViewport.left;var nRelPosClickInViewportY=e.clientY-oAbsPosViewport.top;var nDeltaX=nRelPosClickInViewportX-this.viewport.offsetWidth/2;var nDeltaY=nRelPosClickInViewportY-this.viewport.offsetHeight/2;var oMapPos=this.getPosition();var nNewAbsX=Math.floor(oMapPos.x+nDeltaX);var nNewAbsY=Math.floor(oMapPos.y+nDeltaY);var zoomValue=(e.ctrlKey||zoomout===true)?this.prevZoom():this.nextZoom();if(!zoomValue)zoomValue=this.zoom;this.setZoom(zoomValue,{x:nNewAbsX,y:nNewAbsY});},prevZoom:function(){var zoomLevel=this.image.zoom.level;var zoomValue=this.image.zoom.min;for(var i in zoomLevel){if(zoomLevel[i]<this.zoom){zoomValue=zoomLevel[i];break;}}
return(zoomValue!=this.zoom)?zoomValue:false;},nextZoom:function(){var zoomLevel=this.image.zoom.level;var zoomValue=this.image.zoom.max;for(var i in zoomLevel){if(zoomLevel[i]>this.zoom){zoomValue=zoomLevel[i];}
else{break;}}
return(zoomValue!=this.zoom)?zoomValue:false;},getZoomLevelSorted:function(reverse){var zoomLevel=((new Array()).concat(this.image.zoom.level));return(reverse)?zoomLevel.sort(function(a,b){return b-a;}):zoomLevel.sort(function(a,b){return a-b;});},setZoomLevel:function(zoomValue){zoomValue=Math.abs(parseFloat(zoomValue));if(!zoomValue){zoomValue=this.image.zoom.def;}
var zoomLevel=this.image.zoom.level.sort(function(a,b){return Math.abs(a-zoomValue)-Math.abs(b-zoomValue);});if(zoomLevel[0]!=this.zoom){this.setZoom(zoomLevel[0]);}
else return false;return zoomLevel[0];},addLayer:function(id,layer){this.layer[id]=layer;},getLayerCount:function(){var i=0;for(var id in this.layer)i++;return i;},getLayer:function(){return this.layer;},getLayerIDs:function(){var layer=[];for(var id in this.layer){layer.push(id);}
return layer;},toggle:function(id){if(!this.layer[id])
return;return(this.layer[id].isactive())?this.layer[id].deactivate():this.layer[id].activate();},activate:function(id){if(!this.layer[id])
return;return this.layer[id].activate();},deactivate:function(id){if(!this.layer[id])
return;return this.layer[id].deactivate();},isactive:function(id){if(!this.layer[id])
return;return(this.layer[id].isactive());},isexist:function(id){if(typeof(this.layer[id])=="object"){return true;}
for(var id in this.layer){if(this.layer[id].conf.layerid==id){return true;}}
return false;},handleImageChange:function(arg){var x=parseInt(arg.x)||-this.mapOffsetX;var y=parseInt(arg.y)||-this.mapOffsetY;this.layerRange=null;this.image=arg.image;this.zoom=(parseFloat(arg.zoom))?parseFloat(arg.zoom):(this.zoom)?this.zoom:image.zoom.def;var layerId=objProp(objMerge(this.layer,this.image.layer));var changeProperty={delete_:{},conserve:{},change:{},create:{},new_:{}};for(var i in layerId){var id=layerId[i];if(this.layer[id]&&this.image.layer[id])
if(this.layer[id].conf.useid=="true"){changeProperty["change"][id]=true;changeProperty["create"][id]=true;}
else
changeProperty["conserve"][id]=true;else if(!this.image.layer[id])
changeProperty["delete_"][id]=true;else{changeProperty["new_"][id]=true;changeProperty["create"][id]=true;}}
var freezedLayer=this.freezeLayer(changeProperty["change"]);for(var id in changeProperty["create"]){var active=(this.layer[id]&&this.layer[id].isactive==false)?false:true;var hidden=(changeProperty["new_"][id])?false:true;var newLayer=new arivis.webview[this.image.layer[id].type](id,this.map,active,this.image.layer[id],this.image,this.urlParamCallback,hidden);this.addLayer(id,newLayer);}
this.changeView(this.zoom,x,y,changeProperty["create"]);if(this.delayNewLayerVisibility&&changeProperty["change"]){var self=this;window.setTimeout(function(){var changeList=changeProperty["change"];self.changeLayer(changeList,freezedLayer);},this.delayNewLayerVisibility);}
else{this.changeLayer(changeProperty["change"],freezedLayer);}
this.delLayer(changeProperty["delete_"],this.layer);var layerContent=this.getLayerContent();arivis.webview.event.fireEvent("layerNewList",layerContent);},changeLayer:function(layerId,oldLayerObj){for(var id in layerId){newLayer=this.layer[id];this.unhideLayer(newLayer)
oldLayer=oldLayerObj[id];this.hideLayer(oldLayer)}
this.delLayer(layerId,oldLayerObj);},hideLayer:function(layer){if(layer){var element=layer.map;YAHOO.util.Dom.addClass(element,'hiddenLayer');}},unhideLayer:function(layer){if(layer){var element=layer.map;YAHOO.util.Dom.removeClass(element,'hiddenLayer');}},freezeLayer:function(layer){var freezedLayer={};for(var id in layer){if(this.layer[id]){this.layer[id].freezeLayer();freezedLayer[id]=this.layer[id];delete this.layer[id];}}
return freezedLayer;},delLayer:function(layerId,layer){if(!layer)
layer=this.layer;for(var id in layerId){if(layerId[id]&&layer[id]){layer[id].removeLayer();}}},getLayerContent:function(){var contentObject={};var layerContent=new Array();for(var id in this.layer){if(this.layer[id].conf.info){var content=this.layer[id].conf.info.split(",");for(var j=0;j<content.length;j++)
contentObject[content[j]]=1;}
else
contentObject[this.layer[id].conf.layerid]=1;}
for(var id in contentObject)
layerContent.push(id);return layerContent;},setZoom:function(zoomValue,offset){var offset=this.getZoomOffset(zoomValue,offset);this.zoom=zoomValue;this.changeView(zoomValue,offset.x,offset.y);arivis.webview.event.fireEvent("zoomChange",this.zoom);},getZoomOffset:function(zoomValue,offset){if(!this.image)return;var factor=zoomValue/this.zoom;var center=(offset&&parseInt(offset.x)&&parseInt(offset.y))?this.offset2center(offset):this.getCenterPosition();center.x=center.x*factor;center.y=center.y*factor;var newOffset=this.center2offset(center);var clipPos=this.clipPosition(newOffset.x,newOffset.y,zoomValue);return{x:clipPos.x,y:clipPos.y};},clipPosition:function(x,y,zoom,image){if(!image){image=this.image;}
if(!zoom){zoom=this.zoom;}
var imageX=this.image.size.x;var imageY=this.image.size.y;var imageW=this.image.size.width;var imageH=this.image.size.height;var bounds={};bounds.left=Math.floor(imageX*zoom);bounds.top=Math.floor(imageY*zoom);bounds.bottom=Math.ceil((imageY+imageH)*zoom);bounds.right=Math.ceil((imageX+imageW)*zoom);bounds.width=bounds.right-bounds.left;bounds.height=bounds.bottom-bounds.top;var viewport=getViewportSize();if(viewport.width>bounds.width){x=Math.max(x,bounds.width-viewport.width);x=Math.min(x,0);}
else{x=Math.min(x,bounds.right-viewport.width);x=Math.max(x,bounds.left);}
if(viewport.height>bounds.height){y=Math.max(y,bounds.height-viewport.height);y=Math.min(y,0);}
else{y=Math.min(y,bounds.bottom-viewport.height);y=Math.max(y,bounds.top);}
return{x:x,y:y};},changeView:function(zoomValue,startX,startY,newLayerList){arivis.webview.event.fireEvent("viewBeforeChange");this.zoom=zoomValue;arivis.webview.event.fireEvent("zoomChange",this.zoom);var imageWidth=this.image.size.width*this.zoom;var imageHeight=this.image.size.height*this.zoom;var viewHeight=getViewportHeight();var viewWidth=getViewportWidth();if(viewWidth>imageWidth){if(startX>0)
startX=0;if(imageWidth-startX>viewWidth)
startX=imageWidth-viewWidth;}else{if(startX>imageWidth-viewWidth)
startX=imageWidth-viewWidth;if(startX<0)
startX=0;}
if(viewHeight>imageHeight){if(startY>0)
startY=0;if(imageHeight-startY>viewHeight)
startY=imageHeight-viewHeight;}else{if(startY>imageHeight-viewHeight)
startY=imageHeight-viewHeight;if(startY<0)
startY=0;}
this.moveTo(startX,startY);if(this.layerRange){for(var i in this.layerRange){var id=this.layerRange[i];(newLayerList&&newLayerList[id])?this.layer[id].changeView(zoomValue,startX,startY,true):this.layer[id].changeView(zoomValue,startX,startY);}}
else{for(var id in this.layer){(newLayerList&&newLayerList[id])?this.layer[id].changeView(zoomValue,startX,startY,true):this.layer[id].changeView(zoomValue,startX,startY);}}
arivis.webview.loadingLayer.moveTo(startX,startY);arivis.webview.event.fireEvent("viewAfterChange");},setLayerRange:function(layer){this.layerRange=layer;},moveTo:function(x,y){this.mapOffsetX=0-x;this.mapOffsetY=0-y;this.map.style.left=0+"px";this.map.style.top=0+"px";this.centerXY=this.offset2center({x:-this.mapOffsetX,y:-this.mapOffsetY});arivis.webview.event.fireEvent("endmove");},updateAll:function(){for(var id in this.layer){this.layer[id].updateAllTiles();}},update:function(x,y,isDirect){this.updateX=x;this.updateY=y;clearTimeout(this.updateTimerId);var now=new Date();var appTime=now.getTime();if(isDirect||appTime>this.lastUpdate+this.updateTimer){this._updateLayer();}else{self=this;this.updateTimerId=setTimeout(function(){self._updateLayer();},this.updateTimer);}},_updateLayer:function(){var x=this.updateX;var y=this.updateY;var pos=(x>=0&&y>=0)?{x:x,y:y}:this.getPosition();if(this.layerRange){for(var i in this.layerRange){var id=this.layerRange[i];this.layer[id].update(pos.x,pos.y);}}
else{for(var id in this.layer){this.layer[id].update(pos.x,pos.y);}}
this.centerXY=this.offset2center({x:-this.mapOffsetX,y:-this.mapOffsetY});var now=new Date();this.lastUpdate=now.getTime();},center2offset:function(centerXY){var centerX=parseInt(centerXY["x"]);var centerY=parseInt(centerXY["y"]);var offsetX=centerX-this.viewport.offsetWidth/2+0.1;var offsetY=centerY-this.viewport.offsetHeight/2+0.1;return{x:Math.round(offsetX),y:Math.round(offsetY)};},offset2center:function(offsetXY){var offsetX=parseInt(offsetXY["x"]);var offsetY=parseInt(offsetXY["y"]);var centerX=offsetX+this.viewport.offsetWidth/2-0.1;var centerY=offsetY+this.viewport.offsetHeight/2-0.1;return{x:Math.round(centerX),y:Math.round(centerY)};},getPosition:function(){var x=0-this.map.offsetLeft-this.mapOffsetX;var y=0-this.map.offsetTop-this.mapOffsetY;return{x:x,y:y};},getViewArea:function(){var area=this.getPosition();var viewportWidth=getViewportWidth();var viewportHeight=getViewportHeight();var imageWidth=Math.round(this.zoom*this.image.size.width)-area.x;var imageHeight=Math.round(this.zoom*this.image.size.height)-area.y;area.w=Math.min(imageWidth,viewportWidth);area.h=Math.min(imageHeight,viewportHeight);return area;},getCenterPosition:function(){var width=getViewportWidth();var height=getViewportHeight();var pos=this.getPosition();var centerX=pos.x+(width/2);var centerY=pos.y+(height/2);return{x:centerX,y:centerY};},resetPosition:function(){var left=this.map.offsetLeft;var top=this.map.offsetTop;this.mapOffsetX+=left;this.mapOffsetY+=top;this.map.style.left="0px";this.map.style.top="0px";for(var id in this.layer){this.layer[id].map.style.left=(this.layer[id].map.offsetLeft+left)+"px";this.layer[id].map.style.top=(this.layer[id].map.offsetTop+top)+"px";}
arivis.webview.loadingLayer.map.style.left=(arivis.webview.loadingLayer.map.offsetLeft+left)+"px";arivis.webview.loadingLayer.map.style.top=(arivis.webview.loadingLayer.map.offsetTop+top)+"px";this.centerXY=this.offset2center({x:-this.mapOffsetX,y:-this.mapOffsetY});},handleResize:function(){if(arivis.webview.application.isRunning){var offsetXY=this.center2offset(this.centerXY);this.changeView(this.zoom,offsetXY["x"],offsetXY["y"]);this.centerXY=this.offset2center({x:-this.mapOffsetX,y:-this.mapOffsetY});}},setZoomRegion:function(x,y,width,height){if(!this.image){return;}
var mapPos=this.getPosition();var viewportWidth=getViewportWidth();var viewportHeight=getViewportHeight();var h_factor=viewportWidth/width;var v_factor=viewportHeight/height;var factor=Math.min(h_factor,v_factor);if(this.zoom*factor>this.image.zoom.max){factor=this.image.zoom.max/this.zoom;}
var centerX=mapPos.x+x+(width/2);var centerY=mapPos.y+y+(height/2);centerX=centerX*factor;centerY=centerY*factor;var startX=Math.round(centerX-(viewportWidth/2));var startY=Math.round(centerY-(viewportHeight/2));this.zoom=this.zoom*factor;var clipPos=this.clipPosition(startX,startY);startX=clipPos.x;startY=clipPos.y;this.changeView(zoomValue,startX,startY);},setZoomFit:function(){if(!this.image){return;}
var imageX=this.image.size.x;var imageY=this.image.size.y;var imageW=this.image.size.width;var imageH=this.image.size.height;var h_factor=getViewportWidth()/imageW;var v_factor=getViewportHeight()/imageH;var factor=Math.min(h_factor,v_factor);this.zoom=factor;this.changeView(zoomValue,imageX,this.image.y);}};arivis.webview.LayerUrl=function(){this.configurationRoot=null;this.meteo=[];this.baseElem=null;this.activeMeteo=[];this.imageConf=[];this.imageParam=null;this.imageMeteo=null;this.currentLayerParam=0;this.currentLayer=[];this.init=function(){var self=this;var callback=function(a,b){return self.handleParam(a,b);};arivis.webview.layerContainer.setUrlParamCallback(callback);arivis.webview.event.subscribe("applicationPrepared",this.prepareConfiguration,this,true);};this.prepareConfiguration=function(xmlDocument){this.configurationRoot=xmlDocument.documentElement;this.parseMeteo();this.baseElem=this.getBase();this.activeMeteo=array_id(this.meteo);this.parseConfiguration();this.extendConfiguration();};this.parseMeteo=function(){var meteo=[];var meteoconfig=this.configurationRoot.getElementsByTagName("meteoconfig")[0];var meteoElem=meteoconfig.getElementsByTagName("meteo");for(var i=0;i<meteoElem.length;i++){meteo[meteoElem[i].getAttribute("id")]={"code":meteoElem[i].getAttribute("code"),"dynamic":(meteoElem[i].getAttribute("dynamic")=="true")?true:false,"alter":(meteoElem[i].getAttribute("alter")=="true")?true:false,"name":meteoElem[i].getAttribute("name")}
if(meteoElem[i].getAttribute("countValidImages"))
meteo[meteoElem[i].getAttribute("id")]["countValidImages"]=meteoElem[i].getAttribute("countValidImages");}
this.meteo=meteo;};this.parseConfiguration=function(){this.imageConf=[];this.imageMeteo=[];this.imageParam=[];var allElem=this.getImagesAndAnimation();for(var i=0;i<allElem.length;i++){var iImageElem=allElem[i];var imageId=iImageElem.getAttribute("id");var version=iImageElem.getAttribute("version");this.imageConf[imageId]=iImageElem;var layerElem=this.getLayer(iImageElem);var meteoImageContainList=this.getMeteoList(iImageElem.getAttribute("meteo_contain"));this.imageMeteo[imageId]=[];this.imageParam[imageId]=[];var screenParam={"l":0,"id":imageId};for(var j=0;j<layerElem.length;j++){var meteoLayerContainList=this.getMeteoList(layerElem[j].getAttribute("meteo"));var param={"l":0,"id":"","version":version};var dynamic=false;for(var k=0;k<meteoLayerContainList.length;k++){var meteoIdInLayer=meteoLayerContainList[k];if(this.meteo[meteoIdInLayer].dynamic){var dynamic=true;param["id"]=imageId;}
if(array_contains(meteoImageContainList,meteoIdInLayer)||this.meteo[meteoIdInLayer].dynamic!=true){this.imageMeteo[imageId].push(meteoIdInLayer);if(array_contains(this.activeMeteo,meteoIdInLayer))
param["l"]+=parseInt(this.meteo[meteoIdInLayer].code);}
else if(this.meteo[meteoIdInLayer].dynamic){var oldCount=parseInt(this.meteo[meteoIdInLayer].countValidImages);if(!oldCount)
continue;for(var l=1;l<=oldCount;l++){var iOld=i+l;if(iOld>allElem.length)
break;if(allElem[iOld]&&allElem[iOld].nodeName!="animation"){var imageIdOld=allElem[iOld].getAttribute("id");var meteoImageContainListOld=this.getMeteoList(allElem[iOld].getAttribute("meteo_contain"));;if(array_contains(meteoImageContainListOld,meteoIdInLayer)){this.imageMeteo[imageId].push(meteoIdInLayer);if(!array_contains(this.activeMeteo,meteoIdInLayer))
continue;if(meteoLayerContainList.length==1){param["l"]=parseInt(this.meteo[meteoIdInLayer].code);param["id"]=imageIdOld;}
else{param["l"]+=parseInt(this.meteo[meteoIdInLayer].code);param["id"+parseInt(this.meteo[meteoIdInLayer].code)]=imageIdOld;}
screenParam["id"+parseInt(this.meteo[meteoIdInLayer].code)]=imageIdOld;break;}}}}}
this.imageParam[imageId][layerElem[j].getAttribute("id")]={param:param,dynamic:dynamic};}
for(var id in this.imageMeteo[imageId]){if(!array_contains(this.activeMeteo,this.imageMeteo[imageId][id]))
continue;screenParam["l"]+=parseInt(this.meteo[this.imageMeteo[imageId][id]].code);}
this.imageParam[imageId]["screenParam"]=screenParam;}
1;};this.extendConfiguration=function(){var allElem=this.getImagesAndAnimation();for(var i=0;i<allElem.length;i++){var iImageElem=allElem[i];var imageId=iImageElem.getAttribute("id");var layerElem=this.getLayer(iImageElem);for(var j=0;j<layerElem.length;j++){var layerId=layerElem[j].getAttribute("id");if(this.isLayerDynamic(imageId,layerId))
layerElem[j].setAttribute("useid","true");else
layerElem[j].setAttribute("useid","false");}}};this.getImagesAndAnimation=function(){var imageElem=this.configurationRoot.getElementsByTagName("image");var allElem=[];for(var i=0;i<imageElem.length;i++)
allElem.push(imageElem[i]);allElem.push(this.configurationRoot.getElementsByTagName("animation")[0]);return allElem;};this.getLayer=function(iImageElem){var base=this.baseElem;var layerElem=[];if(iImageElem.getElementsByTagName("layer")&&iImageElem.getElementsByTagName("layer").length)
layerElem=iImageElem.getElementsByTagName("layer");else if(base[iImageElem.getAttribute("base")]){baseElem=base[iImageElem.getAttribute("base")];layerElem=baseElem.getElementsByTagName("layer");}
return layerElem;};this.getBase=function(){var base=[];baseElem=this.configurationRoot.getElementsByTagName("base");for(var i=0;i<baseElem.length;i++){base[baseElem[i].getAttribute("id")]=baseElem[i];}
return base;};this.getMeteoList=function(meteo){return returnList=(typeof meteo=="string")?meteo.split(","):[];};this.activateMeteo=function(meteoId){if(this.isMeteoActive(meteoId))
return false;var oldActive=this.isMeteoActive(meteoId);if(oldActive===true)
return;this.activeMeteo.push(meteoId);this.parseConfiguration();arivis.webview.layerContainer.updateAll();};this.deactivateMeteo=function(meteoId){var pos=array_contains(this.activeMeteo,meteoId,true);if(pos==-1)
return false;this.activeMeteo.splice(pos,1);this.parseConfiguration();arivis.webview.layerContainer.updateAll();};this.isMeteo=function(meteoId,imageId){if(array_contains(this.imageMeteo[imageId],meteoId))
return true;return false;};this.isMeteoActive=function(meteoId){if(array_contains(this.activeMeteo,meteoId))
return true;return false;};this.isMeteoAlterable=function(meteoId){if(this.meteo[meteoId])
return this.meteo[meteoId]["alter"];return false};this.isLayerDynamic=function(imageId,layerId){if(this.imageParam&&this.imageParam[imageId]&&this.imageParam[imageId][layerId])
return this.imageParam[imageId][layerId]["dynamic"];return false;};this.handleScreenParam=function(imageId,param){if(this.imageParam&&this.imageParam[imageId]&&this.imageParam[imageId]["screenParam"]){for(var i in this.imageParam[imageId]["screenParam"]){if(this.imageParam[imageId]["screenParam"][i])
param[i]=this.imageParam[imageId]["screenParam"][i];}}
return param;};this.handleParam=function(conf,param){var imageId=conf.imageid;var layerId=conf.layerid;if(this.imageParam&&this.imageParam[imageId]&&this.imageParam[imageId][layerId]){if(!parseInt(this.imageParam[imageId][layerId]["param"]["l"]))
return false;for(var i in this.imageParam[imageId][layerId]["param"]){if(this.imageParam[imageId][layerId]["param"][i])
param[i]=this.imageParam[imageId][layerId]["param"][i];}}
return true;};this.init();};arivis.webview.LightningLayer=function(map,layer,active,xml){this.constructor.superclass.constructor.apply(this,arguments);this.tileType="div";this.loaded=false;var objects=null;this.init();};YAHOO.extend(arivis.webview.LightningLayer,arivis.webview.Layer);arivis.webview.LightningLayer.prototype.prefetchBorder=50;arivis.webview.LightningLayer.prototype.toString=function(){return"arivis.webview.LightningLayer";};arivis.webview.LightningLayer.prototype.init=function(){arivis.webview.event.subscribe("viewBeforeChange",this.clearCache,this,true);arivis.webview.event.subscribe("enddrag",this.buildCache,this,true);};arivis.webview.LightningLayer.prototype.removeLayer=function(){arivis.webview.LightningLayer.superclass.removeLayer.call(this);arivis.webview.event.unsubscribe("viewBeforeChange",this.clearCache,this);arivis.webview.event.unsubscribe("enddrag",this.buildCache,this);};arivis.webview.LightningLayer.prototype.handleImageChange=function(image,zoom,x,y){};arivis.webview.LightningLayer.prototype.changeView=function(zoomValue,startX,startY){this.zoom=zoomValue;this.loadLightning();this.moveTo(startX,startY);};arivis.webview.LightningLayer.prototype.moveTo=function(x,y){this.resetPosition(x,y);};arivis.webview.LightningLayer.prototype.clearCache=function(){while(this.map.firstChild){this.map.removeChild(this.map.firstChild);}};arivis.webview.LightningLayer.prototype.buildCache=function(){if(this.active!==true){return;}
this.clearCache();if(!this.objects)
return;var objects=this.objects;var mapPos=arivis.webview.layerContainer.getPosition();var viewportWidth=getViewportWidth();var viewportHeight=getViewportHeight();var minX=mapPos.x-this.prefetchBorder;var minY=mapPos.y-this.prefetchBorder;var maxX=viewportWidth+mapPos.x+this.prefetchBorder;var maxY=viewportHeight+mapPos.y+this.prefetchBorder;for(var i=0;i<objects.length;i++){var x=objects[i].getAttribute("i");var y=objects[i].getAttribute("j");if(x<minX||x>maxX||y<minY||y>maxY)
continue;var relX=Math.floor(parseInt(x)-parseInt(mapPos.x)+0.5-parseInt(this.map.style.left));var relY=Math.floor(parseInt(y)-parseInt(mapPos.y)+0.5-parseInt(this.map.style.top));var viewElement=this.createElement(objects[i],relX,relY);}};arivis.webview.LightningLayer.prototype.createElement=function(object,relX,relY){var viewElement=document.createElement("div");var type=object.getAttribute("icon");var className=(object.getAttribute("class"))?object.getAttribute("class"):(type)?"B_type"+type:"";if(className){YAHOO.util.Dom.addClass(viewElement,className);}
viewElement.style.top=relY+"px";viewElement.style.left=relX+"px";this.map.appendChild(viewElement);return viewElement;};arivis.webview.LightningLayer.prototype.update=function(){return;};arivis.webview.LightningLayer.prototype.loadLightning=function(){this.loaded=false;var api=new arivis.webview.Api();var zoomValue=api.getZoom();var zoomLevel=api.zoom2map(zoomValue,this.image);var imageid=(this.conf.param.id)?this.conf.param.id:this.conf.imageid;var callback={success:this.handleSuccess,failure:this.handleFailure,timeout:5000,scope:this,argument:{imageid:this.conf.imageid,zoomLevel:zoomLevel}};var url="lightning/lightning_"+imageid+"_m"+zoomLevel+".xml";YAHOO.util.Connect.asyncRequest("GET",url,callback);};arivis.webview.LightningLayer.prototype.handleSuccess=function(o){var xmlDocument=o.responseXML.documentElement;this.objects=xmlDocument.getElementsByTagName("lightning");this.buildCache();this.loaded=true;};arivis.webview.LightningLayer.prototype.handleFailure=function(o){this.deactivate();};arivis.webview.LightningLayer.prototype.getLoadCondition=function(){return(this.loaded)?1:0;};arivis.webview.LoaderStatus=function(loadingAction,loadingStart,loadingEnd,isLayerByStep){this.init(loadingAction,loadingStart,loadingEnd,isLayerByStep);}
arivis.webview.LoaderStatus.prototype={loaderList:[],timer:100,timeid:0,oldLoadingStatus:null,isLayerByStep:false,loadingAction:null,loadingStart:null,loadingEnd:null,init:function(loadingAction,loadingStart,loadingEnd,isLayerByStep){if(isLayerByStep)
this.isLayerByStep=true;this.loadingAction=(loadingAction)?loadingAction:null;this.loadingStart=(loadingStart)?loadingStart:null;this.loadingEnd=(loadingEnd)?loadingEnd:null;this.start(true);},handleImageChange:function(image){this.loaderList=arivis.webview.layerContainer.layer;this.oldLoadingStatus=new Array();for(var i in this.loaderList){this.oldLoadingStatus[i]=0;}
this.oldLoadingStatus["_"]=0;this.run();},getLoadCondition:function(){var sum=0;var count=0;for(var i in this.loaderList){var layerCondition=this.getLoadConditionLayer(i);if(layerCondition!==false){sum+=layerCondition;count++;}}
return(count)?sum/count:0;},getLoadConditionLayer:function(id){var ret=false;if(this.loaderList[id].isactive()==true){var ret=this.loaderList[id].getLoadCondition();}
return ret;},start:function(isOnImageChange){this.stop();arivis.webview.event.subscribe("imageChange",this.handleImageChange,this,true);if(!isOnImageChange)
this.handleImageChange();},stop:function(){arivis.webview.event.unsubscribe("imageChange",this.handleImageChange);window.clearTimeout(this.timeid);},run:function(){window.clearTimeout(this.timeid);if(this.isLayerByStep){var sum=0;var count=0;for(var i in this.loaderList){var layerLoadingStatus=this.getLoadConditionLayer(i);if(layerLoadingStatus!==false){sum+=layerLoadingStatus;count++;if(layerLoadingStatus!=1&&this.oldLoadingStatus[i]==1&&this.loadingStart!=null)
this.loadingStart(layerLoadingStatus,i);if(this.oldLoadingStatus[i]!=layerLoadingStatus&&this.loadingAction!=null)
this.loadingAction(layerLoadingStatus,i);if(layerLoadingStatus==1&&this.oldLoadingStatus[i]!=1&&this.loadingEnd!=null)
this.loadingEnd(layerLoadingStatus,i);}
this.oldLoadingStatus[i]=layerLoadingStatus;}
var loadingStatus=(count)?sum/count:0;}
else{var loadingStatus=this.getLoadCondition();}
if(loadingStatus!=1&&this.oldLoadingStatus["_"]==1&&this.loadingStart!=null)
this.loadingStart(loadingStatus);if(this.oldLoadingStatus["_"]!=loadingStatus&&this.loadingAction!=null)
this.loadingAction(loadingStatus);if(loadingStatus==1&&this.oldLoadingStatus["_"]!=1&&this.loadingEnd!=null)
this.loadingEnd(loadingStatus);this.oldLoadingStatus["_"]=loadingStatus;var instance=this;this.timeid=window.setTimeout(function(){instance.run();},this.timer);}};arivis.webview.LoadingLayer=function(map,container){this.map=document.getElementById(map)||this.createLayer(map,container);this.mapOffsetX=0;this.mapOffsetY=0;this.blankImgSrc="/images/transparent.png";this.delay=101;this.init();};with(arivis.webview.LoadingLayer){prototype.init=function(){};prototype.toString=function(){return"arivis.webview.LoadingLayer";};prototype.createLayer=function(map,container,htmlClass){var element=document.createElement('div');element.setAttribute('id',map);YAHOO.util.Dom.addClass(element,'layer');if(htmlClass){YAHOO.util.Dom.addClass(element,htmlClass);}
container.appendChild(element);return element;};prototype.clearAll=function(){while(this.map.firstChild)
this.map.removeChild(this.map.firstChild);};prototype.clearElement=function(element){if(element&&element.parentNode==this.map)
this.map.removeChild(element);};prototype.loading=function(element){var loadingElem=element.cloneNode(true);loadingElem.src=this.blankImgSrc;if(parseInt(this.delay)>=0)
window.setTimeout(function(){YAHOO.util.Dom.addClass(loadingElem,"loading");},parseInt(this.delay));else
YAHOO.util.Dom.addClass(loadingElem,"loading");this.map.appendChild(loadingElem);return loadingElem;};prototype.moveTo=function(x,y){this.mapOffsetX=0-x;this.mapOffsetY=0-y;this.map.style.left=0+"px";this.map.style.top=0+"px";};}arivis.webview.Message=function(){this.messages=new Array();this.messages["undefined message"]=1;this.messages["application is running"]=1002;this.messages["ajax failure"]=1100;this.messages["ajax loading failure"]=1101;this.messages["timestamp not available"]=1103;this.messages["server message failure"]=1104;this.messages["not images available"]=2000;};arivis.webview.Message.prototype={urlPrefix:null,get:function(name,asNumber){var returnName="undefined Message";if(this.messages[name])
returnName=name;return(asNumber)?this.messages[returnName]:returnName;}};arivis.webview.Move=function(handle,dragElement,invalidElements){if(handle){this.init(handle);this.setDragElId(dragElement);for(var i in invalidElements){this.addInvalidHandleId(invalidElements[i]);}}};YAHOO.extend(arivis.webview.Move,YAHOO.util.DD);arivis.webview.Move.prototype.onDrag=function(e){setCursor(getViewport(),"move");arivis.webview.event.fireEvent("drag");};arivis.webview.Move.prototype.startDrag=function(x,y){arivis.webview.event.fireEvent("startdrag");};arivis.webview.Move.prototype.endDrag=function(e){arivis.webview.event.fireEvent("enddrag");};arivis.webview.Move.prototype.onMouseMove=function(e){};arivis.webview.Move.prototype.onMouseDown=function(e){var pagePosEvent=YAHOO.util.Event.getXY(e);var pagePosViewPort=YAHOO.util.Dom.getXY(this.getEl());var imageWidth=arivis.webview.layerContainer.image.size.width*arivis.webview.layerContainer.zoom;var imageHeight=arivis.webview.layerContainer.image.size.height*arivis.webview.layerContainer.zoom;var viewHeight=getViewportHeight();var viewWidth=getViewportWidth();var position=arivis.webview.layerContainer.getPosition();this.constrainX=true;if(viewWidth>imageWidth){this.minX=YAHOO.util.Dom.getX(this.getDragEl())+position.x;this.maxX=this.minX+viewWidth-imageWidth;}else{this.maxX=YAHOO.util.Dom.getX(this.getDragEl())+position.x;this.minX=this.maxX+viewWidth-imageWidth;}
this.constrainY=true;if(viewHeight>imageHeight){this.minY=YAHOO.util.Dom.getY(this.getDragEl())+position.y;this.maxY=this.minY+viewHeight-imageHeight;}else{this.maxY=YAHOO.util.Dom.getY(this.getDragEl())+position.y;this.minY=this.maxY+viewHeight-imageHeight;}};arivis.webview.Move.prototype.onMouseUp=function(e){setCursor(getViewport(),"pointer");};arivis.webview.Move.prototype.setStartPosition=function(pos){var p=pos||YAHOO.util.Dom.getXY(this.getDragEl());this.deltaSetXY=null;this.startPageX=p[0];this.startPageY=p[1];};arivis.webview.Move.prototype.register=function(toolbar){var section=toolbar.getSection("Tools");var button=toolbar.createButton("images/move.png","images/move_highlight.png",this.enable,this);toolbar.addToSection(section,button);toolbar.setTooltip(button,"move the viewport using the left mouse button");toolbar.setButtonGroup(button,"default");toolbar.doClick(button);};arivis.webview.Move.prototype.enable=function(button,enabled){if(enabled){this.unlock();setCursor(getViewport(),"pointer");YAHOO.util.Event.addListener(getViewport(),"dblclick",this.handleDblClick,this,true);}else{this.lock();YAHOO.util.Event.removeListener(getViewport(),"dblclick",this.handleDblClick);}};arivis.webview.Move.prototype.handleDblClick=function(e){};arivis.webview.NavDrag=function(handle,dragElement,imagePanel){if(handle){this.init(handle);this.setDragElId(dragElement);this.imagePanel=imagePanel;}};YAHOO.extend(arivis.webview.NavDrag,YAHOO.util.DD);arivis.webview.NavDrag.prototype.onMouseDown=function(e){var borderWidth=2;var cursorPanel=this.getEl();var dragPanel=this.getDragEl();dragPanel.style.left=cursorPanel.offsetLeft+"px";dragPanel.style.top=cursorPanel.offsetTop+"px";dragPanel.style.width=(cursorPanel.offsetWidth-2*borderWidth)+"px";dragPanel.style.height=(cursorPanel.offsetHeight-2*borderWidth)+"px";YAHOO.util.Dom.setStyle(dragPanel,"display","block");};arivis.webview.NavDrag.prototype.updateConstraints=function(){var cursorPanel=this.getEl();var borderWidth=2;var dragWidth=cursorPanel.offsetWidth-2*borderWidth;var dragHeight=cursorPanel.offsetHeight-2*borderWidth;this.constrainX=true;this.constrainY=true;if(this.imagePanel.offsetWidth>dragWidth){this.minX=YAHOO.util.Dom.getX(this.imagePanel)-borderWidth;this.maxX=this.minX+this.imagePanel.offsetWidth-dragWidth;}else{this.maxX=YAHOO.util.Dom.getX(this.imagePanel)-borderWidth;this.minX=this.maxX+this.imagePanel.offsetWidth-dragWidth;}
if(this.imagePanel.offsetHeight>dragHeight){this.minY=YAHOO.util.Dom.getY(this.imagePanel)-borderWidth;this.maxY=this.minY+this.imagePanel.offsetHeight-dragHeight;}else{this.maxY=YAHOO.util.Dom.getY(this.imagePanel)-borderWidth;this.minY=this.maxY+this.imagePanel.offsetHeight-dragHeight;}};arivis.webview.NavDrag.prototype.endDrag=function(e){var cursorPanel=this.getEl();var dragPanel=this.getDragEl();cursorPanel.style.left=dragPanel.offsetLeft+"px";cursorPanel.style.top=dragPanel.offsetTop+"px";cursorPanel.style.width=(dragPanel.offsetWidth-4)+"px";cursorPanel.style.height=(dragPanel.offsetHeight-4)+"px";this.applyPosition();};arivis.webview.NavDrag.prototype.applyPosition=function(){var cursorPanel=this.getEl();var effectiveZoom=this.imagePanel.zoom/arivis.webview.layerContainer.zoom;var newX=Math.round((cursorPanel.offsetLeft-this.imagePanel.offsetLeft+2)/effectiveZoom);var newY=Math.round((cursorPanel.offsetTop-this.imagePanel.offsetTop+2)/effectiveZoom);var currentImage=arivis.webview.layerContainer.image;var currentZoom=arivis.webview.layerContainer.zoom;var viewportWidth=getViewportWidth();var viewportHeight=getViewportHeight();if(currentImage.width*currentZoom>viewportWidth){var maxX=Math.round((currentImage.x+currentImage.width)*currentZoom-viewportWidth);var minX=Math.round(currentImage.x*currentZoom);newX=Math.min(newX,maxX);newX=Math.max(newX,minX);}
if(currentImage.height*currentZoom>viewportHeight){var maxY=Math.round((currentImage.y+currentImage.height)*currentZoom-viewportHeight);var minY=Math.round(currentImage.y*currentZoom);newY=Math.min(newY,maxY);newY=Math.max(newY,minY);}
arivis.webview.event.fireEvent("navigate",{x:newX,y:newY});};arivis.webview.NavDrag.prototype.onMouseUp=function(e){YAHOO.util.Dom.setStyle(this.getDragEl(),"display","none");};arivis.webview.NavDrag.prototype.toString=function(){return"arivis.webview.NavDrag";};arivis.webview.Navigator=function(containerId){this.init(containerId);};arivis.webview.Navigator.prototype={rootPanel:null,imagePanel:null,cursorPanel:null,dragPanel:null,imageSize:null,dragHandler:null,borderWidth:2,toString:function(){return"arivis.webview.Navigator";},init:function(containerId){arivis.webview.event.subscribe("endmove",this.handleZoomChange,this,true);arivis.webview.event.subscribe("drag",this.updatePosition,this,true);arivis.webview.event.subscribe("imageChange",this.handleImageChange,this,true);this.createHTML(containerId);this.dragHandler=new arivis.webview.NavDrag(this.cursorPanel,this.dragPanel,this.imagePanel);YAHOO.util.Event.addListener(this.imagePanel,"click",this.handleNavigatorClick,this,true);},createHTML:function(containerId){this.rootPanel=document.getElementById(containerId);this.imagePanel=document.createElement("div");this.imagePanel.id="navContent";this.rootPanel.appendChild(this.imagePanel);this.cursorPanel=document.createElement("div");this.cursorPanel.id="navOverlay";this.rootPanel.appendChild(this.cursorPanel);setCursor(this.cursorPanel,"pointer");this.cursorPanel.innerHTML="";this.dragPanel=document.createElement("div");this.dragPanel.id="navDrag";this.rootPanel.appendChild(this.dragPanel);setCursor(this.dragPanel,"pointer");},switchNavigator:function(){arivis.webview.palette.switchPalette("nav");this.handleResize();},getNavigatorSize:function(){return{width:this.rootPanel.offsetWidth,height:this.rootPanel.offsetHeight};},handleNavigatorClick:function(event){var eventPos=YAHOO.util.Event.getXY(event);eventPos[0]=eventPos[0]-Math.round(this.cursorPanel.offsetWidth/2)+1;eventPos[1]=eventPos[1]-Math.round(this.cursorPanel.offsetHeight/2)+1;eventPos[0]=Math.min(eventPos[0],this.dragHandler.maxX);eventPos[0]=Math.max(eventPos[0],this.dragHandler.minX);eventPos[1]=Math.min(eventPos[1],this.dragHandler.maxY);eventPos[1]=Math.max(eventPos[1],this.dragHandler.minY);var elementPos=YAHOO.util.Dom.getXY(this.imagePanel);var x=eventPos[0]-elementPos[0]+this.imagePanel.offsetLeft;var y=eventPos[1]-elementPos[1]+this.imagePanel.offsetTop;this.cursorPanel.style.left=x+"px";this.cursorPanel.style.top=y+"px";this.dragHandler.applyPosition();},handleImageChange:function(arg){var image=arg.image;this.imageSize=[image.size.width,image.size.height];var navSize=[this.rootPanel.offsetWidth,this.rootPanel.offsetHeight];var h_factor=navSize[0]/this.imageSize[0];var v_factor=navSize[1]/this.imageSize[1];var factor=Math.min(h_factor,v_factor);var x=Math.floor(image.size.x*factor);var y=Math.floor(image.size.y*factor);var width=Math.ceil(this.imageSize[0]*factor);var height=Math.ceil(this.imageSize[1]*factor);x=Math.round((navSize[0]-width)/2);y=Math.round((navSize[1]-height)/2);this.imagePanel.style.left=x+"px";this.imagePanel.style.top=y+"px";this.imagePanel.style.width=width+"px";this.imagePanel.style.height=height+"px";this.imagePanel.zoom=factor;this.updatePosition();this.dragHandler.updateConstraints();},handleZoomChange:function(zoom){this.updatePosition();this.dragHandler.updateConstraints();},handlePlaneChange:function(plane){this.handleImageChange(arivis.webview.layerContainer.image);},updatePosition:function(){var pos=arivis.webview.layerContainer.getPosition();var zoom=arivis.webview.layerContainer.zoom;if(!zoom)return;var x=pos.x/zoom;var y=pos.y/zoom;var width=getViewportWidth()/zoom;var height=getViewportHeight()/zoom;var overlay_x=Math.round(x*this.imagePanel.offsetWidth/this.imageSize[0])+this.imagePanel.offsetLeft;var overlay_y=Math.round(y*this.imagePanel.offsetHeight/this.imageSize[1])+this.imagePanel.offsetTop;var overlay_width=Math.round(width*this.imagePanel.offsetWidth/this.imageSize[0]);var overlay_height=Math.round(height*this.imagePanel.offsetHeight/this.imageSize[1]);var locationText="x:"+Math.round(x)+"<br/>y:"+Math.round(y)
+"<br/>width:"+Math.round(width)+"<br/>heigth:"+Math.round(height);this.cursorPanel.style.left=(overlay_x-this.borderWidth)+"px";this.cursorPanel.style.top=(overlay_y-this.borderWidth)+"px";this.cursorPanel.style.width=(overlay_width)+"px";this.cursorPanel.style.height=(overlay_height)+"px";},handleImageLoaded:function(element,url){element.style.background="url("+url+") no-repeat";}};arivis.webview.ServerPull=function(){this.init();};arivis.webview.ServerPull.prototype={stat:false,_timerID:0,timer:0,url:"",isStarted:false,failureSensor:2,maxFailureSensor:10,requestTimeoutSec:10,anavailableStatus:false,init:function(){var instance=this;arivis.webview.event.subscribe("applicationRun",function(xml){instance.start(xml);});arivis.webview.event.subscribe("applicationStop",instance.stop);arivis.webview.event.subscribe("applicationRestart",function(xml){instance.start(xml);});},toString:function(){return"ServerPull";},start:function(xmlDocument){var documentElement=xmlDocument.documentElement;var timestamp=documentElement.getElementsByTagName("timestamp");if(!timestamp)return;this.stat=timestamp[0].getAttribute("id")||false;this.url=timestamp[0].getAttribute("url");this.timer=parseInt(timestamp[0].getAttribute("timer"))*1000||600000;if(this.url&&this.stat){var instance=this;this._timerID=window.setTimeout(function(){instance.run();},instance.timer);}
this.isStarted=true;},run:function(){if(this._timerID){window.clearTimeout(this._timerID);}
if(!this.isStarted)
return;var callback={success:function(o){this.handleSuccess(o);},failure:this.handleFailure,timeout:(this.requestTimeoutSec*1000),scope:this};var url=this.url+"?t="+this.stat+"&a="+this._timerID;YAHOO.util.Connect.asyncRequest("GET",url,callback);},stop:function(){this.isStarted=false;},handleSuccess:function(o){this.decreaseFailureSensor();if(o&&o.status==200){var content=o.responseText;if(content!=this.stat){arivis.webview.event.fireEvent("serverUpdate");}}
var instance=this;this._timerID=window.setTimeout(function(){instance.run();},instance.timer);},handleFailure:function(){this.increaseFailureSensor();if(this.failureSensor>=this.maxFailureSensor){if(!this.anavailableStatus){this.anavailableStatus=true;arivis.webview.event.fireEvent("serverUnavailable",this.url);}}
else
this.anavailableStatus=false;var instance=this;this._timerID=window.setTimeout(function(){instance.run();},instance.timer);arivis.webview.event.fireEvent("message","ajax loading failure");},increaseFailureSensor:function(){this.failureSensor=Math.min(this.maxFailureSensor,this.failureSensor+1);},decreaseFailureSensor:function(){this.anavailableStatus=false;this.failureSensor=Math.max(2,this.failureSensor/2);}};arivis.webview.ServerSession=function(){this.init();};arivis.webview.ServerSession.prototype={_timerID:0,timer:60,url:"",isStarted:false,failureSensor:2,maxFailureSensor:20,requestTimeoutSec:10,init:function(){var instance=this;arivis.webview.event.subscribe("applicationRun",function(xml){instance.start(xml,true);});},toString:function(){return"ServerSession";},start:function(xmlDocument,isFirst){var documentElement=xmlDocument.documentElement;var session=documentElement.getElementsByTagName("session")[0];if(!session)return;this.url=session.getAttribute("url");this.timer=parseInt(session.getAttribute("timer"))*1000;if(!this.url||!this.timer)return;if(this.url){this.isStarted=true;this.run(isFirst);}},run:function(isFirst){window.clearTimeout(this._timerID);if(!this.isStarted)
return;var callback={success:function(o){this.handleSuccess(o);},failure:function(o){this.handleFailure(o);},scope:this,timeout:(this.requestTimeoutSec*1000),argument:{isFirst:isFirst}};var url=this.url+"?a="+this._timerID;YAHOO.util.Connect.asyncRequest("GET",url,callback);},stop:function(){this.isStarted=false;},handleSuccess:function(o){var instance=this;this._timerID=window.setTimeout(function(){instance.run();},instance.timer);},handleFailure:function(o){var xheader=(o&&o.getResponseHeader&&o.getResponseHeader["X-WOM-Cookie"])?YAHOO.lang.trim(o.getResponseHeader["X-WOM-Cookie"]):''
if(o&&o.status==403){if(xheader=="invalid"){(o.argument.isFirst)?arivis.webview.event.fireEvent("message","session invalid first"):arivis.webview.event.fireEvent("message","session invalid");}
else if(xheader=="expired"){(o.argument.isFirst)?arivis.webview.event.fireEvent("message","session expired first"):arivis.webview.event.fireEvent("message","session expired");}
else
arivis.webview.event.fireEvent("message","session invalid");}
else{var instance=this;this._timerID=window.setTimeout(function(){instance.run();},instance.timer);arivis.webview.event.fireEvent("message","ajax loading failure");}},increaseFailureSensor:function(){this.failureSensor=Math.min(this.maxFailureSensor,this.failureSensor*2);},decreaseFailureSensor:function(){this.failureSensor=Math.max(2,this.failureSensor-1);},makeCookie:function(){var url=arivis.webview.appStatus.getStatusURL();encodedURL=encodeURIComponent(url);var date=new Date();var expirydate=new Date(0);var cookie="WOM-Session=DPLINK%3D"+encodedURL+";expires="+expirydate.toGMTString()+";path=/;domain=wetteronline.de";document.cookie=cookie;}};arivis.webview.WheelControl=function(controlId){this.init(controlId);};arivis.webview.WheelControl.prototype={domElement:null,init:function(controlId){this.domElement=document.getElementById(controlId);var self=this;YAHOO.util.Event.addListener(this.domElement,"mousewheel",function(e){self.wheel(e);});YAHOO.util.Event.addListener(this.domElement,"DOMMouseScroll",function(e){self.wheel(e);});},wheel:function(event){var delta=0;if(!event)
event=window.event;if(event.wheelDelta){delta=event.wheelDelta/120;if(window.opera){var version=window.opera.version().split(".");if(version[0]>=9&&version[1].charAt[0]<"2")
delta=-delta*3/4;}}else if(event.detail){delta=-event.detail/4;}
var oAbsPos=getAbsPosition(this.domElement);var nRelPosClickX=event.clientX-oAbsPos.left;var nRelPosClickY=event.clientY-oAbsPos.top;if(delta)
arivis.webview.event.fireEvent("wheel",{delta:delta,x:nRelPosClickX,y:nRelPosClickY});if(event.preventDefault)
event.preventDefault();event.returnValue=false;}};function overrideConf(conf,override,mustSet){for(var id in override){if(mustSet||isdefined(conf,id)){conf[id]=override[id];}}
return conf;}
function isdefined(object,variable){return(typeof(eval(object)[variable])!='undefined');}
function moveChilds(sourceNode,targetNode){if(!sourceNode||!targetNode)
return;while(sourceNode.firstChild){targetNode.appendChild(sourceNode.removeChild(sourceNode.firstChild));}}
function clone(obj){if(obj==null||typeof(obj)!='object'){return obj;}
var cloneObj=new obj.constructor();for(var key in obj){cloneObj[key]=clone(obj[key]);}
return cloneObj;}
function array_contains(array,obj,getPosition){var i;var listed=(getPosition)?-1:false;for(i=0;i<array.length;i++){if(array[i]===obj){listed=(getPosition)?i:true;break;}}
return listed;}
function array_id(obj){if(typeof obj!="object")
return false;ret=new Array();for(var id in obj)
ret.push(id);return ret;}
function objMerge(obj1,obj2){if(typeof obj1!="object")
return false;if(typeof obj2!="object")
return obj1;var ret={};for(var id in obj1)
ret[id]=obj1[id];for(var jd in obj2)
ret[jd]=obj2[jd];return ret;}
function objProp(obj){if(typeof obj!="object")
return false;ret=new Array();for(var id in obj)
ret.push(id);return ret;}
function getCursor(container){return container.style.cursor;}
function setCursor(container,cursor){try{container.style.cursor=cursor;}
catch(c){if(cursor=="pointer"){setCursor("hand");}}}
function getElementWidth(elementId){var elem=(typeof elementId=="object")?elementId:document.getElementById(elementId)
if(elem&&elem.style.display!='none'){return elem.offsetWidth;}else{return 0;}}
function getElementHeight(elementId){var elem=(typeof elementId=="object")?elementId:document.getElementById(elementId)
if(elem&&elem.style.display!='none'){return elem.offsetHeight;}else{return 0;}}
function setElementWidth(sID,iWidth){if(document.getElementById(sID)&&iWidth>=0){document.getElementById(sID).style.width=iWidth+'px';}}
function setElementHeight(sID,iHeight){if(document.getElementById(sID)&&iHeight>=0){document.getElementById(sID).style.height=iHeight+'px';}}
function setElementTop(sID,iTop){if(document.getElementById(sID)){document.getElementById(sID).style.top=iTop+'px';}}
function setElementLeft(sID,iLeft){if(document.getElementById(sID)){document.getElementById(sID).style.left=iLeft+'px';}}
function getViewport(){return arivis.webview.viewport;}
function getViewportSize(){return{width:getViewportWidth(),height:getViewportHeight()};}
function getViewportWidth(){var width=arivis.webview.viewport.offsetWidth;return width;}
function getViewportHeight(){var height=arivis.webview.viewport.offsetHeight;return height;}
function getClientSize(){var width,height;if(window.innerHeight){width=window.innerWidth;height=window.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){width=document.documentElement.clientWidth;height=document.documentElement.clientHeight;}else if(document.body){width=document.body.clientWidth;height=document.body.clientHeight;}
return{width:width,height:height};}
function getInnerSize(){var width,height;if(YAHOO.util.Dom){width=YAHOO.util.Dom.getViewportWidth();height=YAHOO.util.Dom.getViewportHeight();}else if(window.innerHeight){width=window.innerWidth;height=window.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){width=document.documentElement.clientWidth;height=document.documentElement.clientHeight;}else if(document.body){width=document.body.clientWidth;height=document.body.clientHeight;}
if(window.opera&&navigator.appVersion.search(/^9\.[0-7]/)>=0&&window.innerWidth){width=window.innerWidth;height=window.innerHeight;}
return{innerWidth:width,innerHeight:height};}
function composeURL(core,param,hash,isIso){if(typeof param=="object"){var query=[];for(var i in param){(isIso)?query.push(escape(i)+"="+escape(param[i])):query.push(encodeURIComponent(i)+"="+encodeURIComponent(param[i]));}
var querystring=query.join("&");}
else{var querystring=(param)?param:"";}
if(typeof hash=="object"){var hasharray=[];for(var i in hash){(isIso)?hasharray.push(escape(i)+"="+escape(hash[i])):hasharray.push(encodeURIComponent(i)+"="+encodeURIComponent(hash[i]));}
var hashstring=hasharray.join("&");}
else{var hashstring=(hash)?hash:"";}
return core+
((querystring)?"?"+querystring:"")+
((hashstring)?"#"+hashstring:"");}
function hash2array(qstring){var array=qstring.split("#",2);return(array.length>1)?uriPart2array(array[1]):uriPart2array(array[0]);}
function query2array(qstring){var array=qstring.split("?",2);if(array.length>1)
array=array[1].split("#",2);return uriPart2array(array[0]);}
function uriPart2array(string){var param=new Array();var paramscraplist=string.split("&");for(var i in paramscraplist){var paramscrap=paramscraplist[i].split("=");var name=decodeURIComponent(paramscrap[0]);param[name]=decodeURIComponent(paramscrap[1]);}
return param;}
function getAbsPosition(El){var left=0;var top=0;var oEl=(typeof(El)=="object")?El:document.getElementById(El);if(!oEl)return false;if(oEl.offsetParent){do{left+=oEl.offsetLeft;top+=oEl.offsetTop;}while(oEl=oEl.offsetParent);}
return{top:top,left:left};}
function getRelMousePos(e,elem){if(!e||!elem)return[0,0];var elemPos=YAHOO.util.Dom.getXY(elem);var mousePos=YAHOO.util.Event.getXY(e);return[mousePos[0]-elemPos[0],mousePos[1]-elemPos[1]];}
function dragRegionElem(dd,dragElem,regionElem){if(typeof dragElem=="String")
dragElem=document.getElementById(dragElem);if(typeof regionElem=="String")
regionElem=document.getElementById(regionElem);var region=YAHOO.util.Dom.getRegion(regionElem);var dragEl=YAHOO.util.Dom.getRegion(dragElem);var left=dragEl.left-region.left;var right=region.right-dragEl.right;var top=dragEl.top-region.top;var bottom=region.bottom-dragEl.bottom;dd.setXConstraint(parseInt(left),parseInt(right));dd.setYConstraint(parseInt(top),parseInt(bottom));}
function dragRegionElem(dd,dragElem,regionElem){if(typeof dragElem=="string")
dragElem=document.getElementById(dragElem);var region=YAHOO.util.Dom.getRegion(regionElem);var dragEl=YAHOO.util.Dom.getRegion(dragElem);var constraint={left:parseInt(dragEl.left-region.left),right:parseInt(region.right-dragEl.right),top:parseInt(dragEl.top-region.top),bottom:parseInt(region.bottom-dragEl.bottom)};dd.resetConstraints();dd.setXConstraint(constraint.left,constraint.right);dd.setYConstraint(constraint.top,constraint.bottom);}
var outputFormat=[['pm',1000000],['nm',1000],['&#181;m',1],['mm',0.001],['m',0.000001],['km',0.000000001],]
function getOutputFormat(value,precision){if(!precision)
precision=3;var iValue;for(var i in outputFormat){iValue=value*outputFormat[i][1];if(iValue>=1){iValue=parseFloat(iValue.toPrecision(precision)+"");outputValue=iValue+" "+outputFormat[i][0];if(iValue<1000){break;}}}
return outputValue;}
var _debugString="";now=new Date();appTime=now.getTime();function __debug(message){var now=new Date();var time=now.getTime();var relTime=time-appTime;var debugMessage=relTime+": "+message+"\n";_debugString+=debugMessage;var output=document.getElementById("debug");if(output)
output.value=debugMessage+output.value;}
function getMEZ_MESZ(time){var regex=/([0-9]{4})([0-9]{2})([0-9]{2})-([0-9]{2})([0-9]{2})/;if(!regex.exec(time))
return;var utc=Date.UTC(RegExp.$1,(parseInt(RegExp.$2,10)-1),RegExp.$3,RegExp.$4,RegExp.$5,0);var date=new Date(utc);var timezone="MEZ";if(date.getMonth()>(3-1)&&date.getMonth()<(10-1))
timezone="MESZ";else if(date.getMonth()==(3-1)){var utcLastSunday=Date.UTC(RegExp.$1,(3-1),31,1,0,0);var dateLastSunday=new Date(utcLastSunday);if(dateLastSunday.getDay()>0)
utcLastSunday=utcLastSunday-dateLastSunday.getDay()*24*60*60*1000;if(utc>=utcLastSunday){timezone="MESZ";}}
else if(date.getMonth()==(10-1)){var utcLastSunday=Date.UTC(RegExp.$1,(10-1),31,1,0,0);var dateLastSunday=new Date(utcLastSunday);if(dateLastSunday.getDay()>0)
utcLastSunday=utcLastSunday-dateLastSunday.getDay()*24*60*60*1000;if(utc<utcLastSunday){timezone="MESZ";}}
return timezone;}
sprintfWrapper={init:function(){if(typeof arguments=="undefined"){return null;}
if(arguments.length<1){return null;}
if(typeof arguments[0]!="string"){return null;}
if(typeof RegExp=="undefined"){return null;}
var string=arguments[0];var exp=new RegExp(/(%([%]|(\-)?(\+|\x20)?(0)?(\d+)?(\.(\d)?)?([bcdfosxX])))/g);var matches=new Array();var strings=new Array();var convCount=0;var stringPosStart=0;var stringPosEnd=0;var matchPosEnd=0;var newString='';var match=null;while(match=exp.exec(string)){if(match[9]){convCount+=1;}
stringPosStart=matchPosEnd;stringPosEnd=exp.lastIndex-match[0].length;strings[strings.length]=string.substring(stringPosStart,stringPosEnd);matchPosEnd=exp.lastIndex;matches[matches.length]={match:match[0],left:match[3]?true:false,sign:match[4]||'',pad:match[5]||' ',min:match[6]||0,precision:match[8],code:match[9]||'%',negative:parseInt(arguments[convCount])<0?true:false,argument:String(arguments[convCount])};}
strings[strings.length]=string.substring(matchPosEnd);if(matches.length==0){return string;}
if((arguments.length-1)<convCount){return null;}
var code=null;var match=null;var i=null;for(i=0;i<matches.length;i++){if(matches[i].code=='%'){substitution='%'}
else if(matches[i].code=='b'){matches[i].argument=String(Math.abs(parseInt(matches[i].argument)).toString(2));substitution=sprintfWrapper.convert(matches[i],true);}
else if(matches[i].code=='c'){matches[i].argument=String(String.fromCharCode(parseInt(Math.abs(parseInt(matches[i].argument)))));substitution=sprintfWrapper.convert(matches[i],true);}
else if(matches[i].code=='d'){matches[i].argument=String(Math.abs(parseInt(matches[i].argument)));substitution=sprintfWrapper.convert(matches[i]);}
else if(matches[i].code=='f'){matches[i].argument=String(Math.abs(parseFloat(matches[i].argument)).toFixed(matches[i].precision?matches[i].precision:6));substitution=sprintfWrapper.convert(matches[i]);}
else if(matches[i].code=='o'){matches[i].argument=String(Math.abs(parseInt(matches[i].argument)).toString(8));substitution=sprintfWrapper.convert(matches[i]);}
else if(matches[i].code=='s'){matches[i].argument=matches[i].argument.substring(0,matches[i].precision?matches[i].precision:matches[i].argument.length)
substitution=sprintfWrapper.convert(matches[i],true);}
else if(matches[i].code=='x'){matches[i].argument=String(Math.abs(parseInt(matches[i].argument)).toString(16));substitution=sprintfWrapper.convert(matches[i]);}
else if(matches[i].code=='X'){matches[i].argument=String(Math.abs(parseInt(matches[i].argument)).toString(16));substitution=sprintfWrapper.convert(matches[i]).toUpperCase();}
else{substitution=matches[i].match;}
newString+=strings[i];newString+=substitution;}
newString+=strings[i];return newString;},convert:function(match,nosign){if(nosign){match.sign='';}else{match.sign=match.negative?'-':match.sign;}
var l=match.min-match.argument.length+1-match.sign.length;var pad=new Array(l<0?0:l).join(match.pad);if(!match.left){if(match.pad=="0"||nosign){return match.sign+pad+match.argument;}else{return pad+match.sign+match.argument;}}else{if(match.pad=="0"||nosign){return match.sign+match.argument+pad.replace(/0/g,' ');}else{return match.sign+match.argument+pad;}}}}
sprintf=sprintfWrapper.init;
