var old_centerX;var old_centerY;function RefreshLayers(){hideObjectLayer(true);hideSrcObjectLayer(true);clearPath();showSrcObjectLayerOnMap();showObjectLayer();paintPath();try{if(showGsOnMap==true)PaintLines();}catch(ex){}}function zoom(iZoom,startX,startY,offsetX,offsetY){this.zoom=aZoom[iZoom][0];this.matrixX=aZoom[iZoom][1];this.matrixY=aZoom[iZoom][2];this.matrixViewX=aZoom[iZoom][3];this.matrixViewY=aZoom[iZoom][4];this.cellWidth=aZoom[iZoom][5];this.cellHeight=aZoom[iZoom][6];this.maxX=aZoom[iZoom][7];this.maxY=aZoom[iZoom][8];this.mPerPX=aZoom[iZoom][9];this.deltaX=startX;this.deltaY=startY;this.offsetX=offsetX;this.offsetY=offsetY;}function FindCurrentCenterOnMiniMap(){var x=getLeftInMeter()+getWidthInMeter()/2;var y=getTopInMeter()+getHeightInMeter()/2;positionMiniMap(x,y);}function FindCurrentCenter(){old_centerX=getLeftInMeter()+getWidthInMeter()/2;old_centerY=getTopInMeter()+getHeightInMeter()/2;}function FindCurrentCenterX(){return getLeftInMeter()+getWidthInMeter()/2;}function FindCurrentCenterY(){return getTopInMeter()+getHeightInMeter()/2;}function positionMiniMap(locObjX,locObjY){try{locX=parseInt((locObjX-offsetXcode)/miniMapMperPX);locY=parseInt((locObjY-offsetYcode)/miniMapMperPX);if(!IsFullMap()){locX+=167*z.mPerPX/miniMapMperPX;}setStyleLeft(mMapC,75-locX);setStyleTop(mMapC,75-locY);SetMapCookiePosition();}catch(ex){}}function positionMap(locObjX,locObjY){try{locX=parseInt(Math.floor(locObjX/z.cellWidth/z.mPerPX));locY=parseInt(Math.floor(locObjY/z.cellHeight/z.mPerPX));if(locX>=0)locOffX=parseInt(z.cellWidth/2-(locObjX/z.mPerPX)%z.cellWidth);else locOffX=-parseInt(z.cellWidth/2+(locObjX/z.mPerPX)%z.cellWidth);if(locY>=0)locOffY=parseInt(z.cellHeight/2-(locObjY/z.mPerPX)%z.cellHeight);else locOffY=-parseInt(z.cellHeight/2+(locObjY/z.mPerPX)%z.cellHeight);z=new zoom(z.zoom,locX,locY,locOffX,locOffY);setMatrixAndLoad();SetZoomControl(z.zoom);positionMiniMap(locObjX,locObjY);FindCurrentCenter();SetMapCookiePosition();}catch(ex){}}function locateObject(locObjX,locObjY,mmap){try{locX=parseInt(Math.floor(locObjX/z.cellWidth/z.mPerPX));locY=parseInt(Math.floor(locObjY/z.cellHeight/z.mPerPX));if(locX>=0)locOffX=parseInt(z.cellWidth/2-(locObjX/z.mPerPX)%z.cellWidth);else locOffX=-parseInt(z.cellWidth/2+(locObjX/z.mPerPX)%z.cellWidth);if(locY>=0)locOffY=parseInt(z.cellHeight/2-(locObjY/z.mPerPX)%z.cellHeight);else locOffY=-parseInt(z.cellHeight/2+(locObjY/z.mPerPX)%z.cellHeight);z=new zoom(z.zoom,locX,locY,locOffX,locOffY);setMatrixAndLoad();SetZoomControl(z.zoom);RefreshLayers();FindCurrentCenter();if(!mmap)positionMiniMap(locObjX,locObjY);SetMapCookiePosition();}catch(ex){reportError("web_mapFunctions_locateObject",ex.message);}}function locateObjects(objMaxX,objMaxY,objMinX,objMinY){try{hideMenu2();var mPP;var w=getStyleWidth(mapContainer)-20;if(!IsFullMap())w-=340;mPP1=Math.abs((objMaxX-objMinX)/w);mPP2=Math.abs((objMaxY-objMinY)/(mapContainer.clientHeight-20));if(mPP1>mPP2){mPP=mPP1}else{mPP=mPP2}i=11;if(mPP<1024){while(mPP<aZoom[i][9]&&i>1){i--;}i=i+1;}changeZoom(i);SetZoomControl(i);centarX=Math.round(objMaxX-(objMaxX-objMinX)/2)-170*z.mPerPX;centarY=Math.round(objMaxY-(objMaxY-objMinY)/2);positionMap(centarX,centarY);RefreshLayers();positionMiniMap(centarX,centarY);FindCurrentCenter();SetMapCookiePosition();}catch(ex){}}function IsFullMap(){var prognozaVisible=false;try{if(prognoza.style.visibility=="visible")prognozaVisible=true;}catch(ex){}var poiVisible=false;try{if(poidiv.style.visibility=="visible")poiVisible=true;}catch(ex){}var promoVisible=false;try{if(promodiv.style.visibility=="visible")promoVisible=true;}catch(ex){}var gsVisible=false;try{if(gsdiv.style.visibility=="visible")gsVisible=true;}catch(ex){}if(pretraga.style.visibility=="visible"||put.style.visibility=="visible"||prognozaVisible||poiVisible||promoVisible||gsVisible){return false;}else{return true;}}function changeZoom(newZoom){if(newZoom>=1&&newZoom<=aZoom.length-1){var centerMetX=getLeftInMeter()+getWidthInMeter()/2;var centerMetY=getTopInMeter()+getHeightInMeter()/2;if(!IsFullMap()){if(newZoom>z.zoom)centerMetX-=167*z.mPerPX;else centerMetX+=84*z.mPerPX;}locX=parseInt(Math.floor(centerMetX/z.cellWidth/z.mPerPX));locY=parseInt(Math.floor(centerMetY/z.cellHeight/z.mPerPX));if(locX>=0)locOffX=parseInt(z.cellWidth/2-(centerMetX/z.mPerPX)%z.cellWidth);else locOffX=-parseInt(z.cellWidth/2+(centerMetX/z.mPerPX)%z.cellWidth);if(locY>=0)locOffY=parseInt(z.cellHeight/2-(centerMetY/z.mPerPX)%z.cellHeight);else locOffY=-parseInt(z.cellHeight/2+(centerMetY/z.mPerPX)%z.cellHeight);z=new zoom(newZoom,locX,locY,locOffX,locOffY);locateObject(centerMetX,centerMetY);SetMapCookiePosition();}}function changeZoomAtPoint(newZoom){if(newZoom>=1&&newZoom<=aZoom.length-1){if(objectClicked){var centerMetX=clickedObjectPoint.x;var centerMetY=clickedObjectPoint.y;}else{var centerMetX=getClickedLeftInMeter(clickedPoint.x);var centerMetY=getClickedTopInMeter(clickedPoint.y);}if(centerMetX>=offsetX&&centerMetX<=offsetXRight&&centerMetY>=offsetY&&centerMetY<=offsetYBottom){locX=parseInt(Math.floor(centerMetX/z.cellWidth/z.mPerPX));locY=parseInt(Math.floor(centerMetY/z.cellHeight/z.mPerPX));if(locX>=0)locOffX=parseInt(z.cellWidth/2-(centerMetX/z.mPerPX)%z.cellWidth);else locOffX=-parseInt(z.cellWidth/2+(centerMetX/z.mPerPX)%z.cellWidth);if(locY>=0)locOffY=parseInt(z.cellHeight/2-(centerMetY/z.mPerPX)%z.cellHeight);else locOffY=-parseInt(z.cellHeight/2+(centerMetY/z.mPerPX)%z.cellHeight);z=new zoom(newZoom,locX,locY,locOffX,locOffY);if(!IsFullMap()){centerMetX-=167*z.mPerPX;}locateObject(centerMetX,centerMetY);SetMapCookiePosition();}}hideMenu();hideMenu2();}function getLeftInMeter(){var leftPX=(z.deltaX-centerPomX)*z.cellWidth-getStyleLeft(mainContainer);return leftPX*z.mPerPX;}function getTopInMeter(){var topPX=(z.deltaY-centerPomY)*z.cellHeight-getStyleTop(mainContainer);return topPX*z.mPerPX;}function getWidthInMeter(){return mapContainer.clientWidth*z.mPerPX;}function getHeightInMeter(){return mapContainer.clientHeight*z.mPerPX;}function getClickedLeftInMeter(x){var leftPX=(z.deltaX-centerPomX)*z.cellWidth-getStyleLeft(mainContainer);leftPX+=x-5;return leftPX*z.mPerPX;}function getClickedTopInMeter(y){var topPX=(z.deltaY-centerPomY)*z.cellHeight-getStyleTop(mainContainer);topPX+=y-122;return topPX*z.mPerPX;}function setMatrixAndLoad(){try{setElementStyle(mainContainer,"width",z.matrixX*z.cellWidth);setElementStyle(mainContainer,"height",z.matrixY*z.cellHeight);if(z.matrixX%2==1)setStyleLeft(mainContainer,-(mainContainer.clientWidth-mapContainer.clientWidth)/2+z.offsetX);else setStyleLeft(mainContainer,-(mainContainer.clientWidth-mapContainer.clientWidth)/2+z.cellWidth/2+z.offsetX);if(z.matrixY%2==1)setStyleTop(mainContainer,-(mainContainer.clientHeight-mapContainer.clientHeight)/2+z.offsetY);else setStyleTop(mainContainer,-(mainContainer.clientHeight-mapContainer.clientHeight)/2+z.cellHeight/2+z.offsetY);centerPomX=Math.round(z.matrixX/2)-1;centerPomY=Math.round(z.matrixY/2)-1;var initMoveX=-z.cellWidth;var initMoveY=-z.cellHeight;loadImages(true);mainContainerDefaultLeft=-z.cellWidth;mainContainerDefaultTop=-z.cellHeight;}catch(ex){reportError("web_mapFunctions_setMatrixAndLoad",ex.message);}}function arrangeMatrix(where){if(where.indexOf("+x")!=-1){z.deltaX+=1;deleteColumn(1);changeIndexAndPosition(-1);addColumn(z.matrixX);}if(where.indexOf("-x")!=-1){z.deltaX-=1;deleteColumn(z.matrixX);changeIndexAndPosition(1);addColumn(1);}if(where.indexOf("+y")!=-1){z.deltaY+=1;deleteRow(1);changeIndexAndPosition(-z.matrixX);addRow(z.matrixY);}if(where.indexOf("-y")!=-1){z.deltaY-=1;deleteRow(z.matrixY);changeIndexAndPosition(z.matrixX);addRow(1);}}function deleteColumn(column){var cells=mainContainer.childNodes;for(var i=cells.length-1;i>=0;i--){if(parseInt(cells[i].getAttribute("index"))%z.matrixX==column%z.matrixX){mainContainer.removeChild(cells[i]);}}}function addColumn(column){for(var i=0;i<z.matrixY;i++){index=(i*z.matrixX)+column;newCell=createNewCell(index,getSrc(index));mainContainer.appendChild(newCell);}}function deleteRow(row){var cells=mainContainer.childNodes;for(var i=cells.length-1;i>=0;i--){if(parseInt((parseInt(cells[i].getAttribute("index"))-1)/z.matrixX)==(row-1)){mainContainer.removeChild(cells[i]);}}}function addRow(row){for(var i=0;i<z.matrixX;i++){index=(row-1)*z.matrixX+i+1;newCell=createNewCell(index,getSrc(index));mainContainer.appendChild(newCell);}}function changeIndexAndPosition(delta){var cells=mainContainer.childNodes;for(var i=cells.length-1;i>=0;i--){var index=parseInt(cells[i].getAttribute("index"))+delta;cells[i].setAttribute("index",index);cells[i].style.left=((index-1)%z.matrixX)*z.cellWidth;cells[i].style.top=parseInt((index-1)/z.matrixX)*z.cellHeight;}}function getSrc(index){var x=(z.deltaX-centerPomX)+(index-1)%z.matrixX;var y=(z.deltaY-centerPomY)+parseInt((index-1)/z.matrixX);var src="";if(orto==true){if(porto==true)src="Services/getimage.aspx?zoom="+z.zoom+"&y="+y+"&x="+x+"&orto=1&porto=1";else src="Services/getimage.aspx?zoom="+z.zoom+"&y="+y+"&x="+x+"&orto=1&porto=0";}else{src="Services/getimage.aspx?zoom="+z.zoom+"&y="+y+"&x="+x+"&orto=0&porto=0";}return src;}function createNewCell(i,src){var newCell=document.createElement("div");newCell.className="matrixCell";newCell.setAttribute("index",i);newCell.style.left=((index-1)%z.matrixX)*z.cellWidth;newCell.style.top=parseInt((index-1)/z.matrixX)*z.cellHeight;newCell.innerHTML='<img src="'+src+'"/>';return newCell;}function upStory(){var leftPX=z.deltaX*z.cellWidth-(getStyleLeft(mainContainer)-mainContainerDefaultLeft);var topPX=z.deltaY*z.cellHeight-(getStyleTop(mainContainer)-mainContainerDefaultTop);}function loadImages(all){try{var html="";var cells=mainContainer.childNodes;if(mainContainer){var currentX;var currentY;var currentIndex;var startX=z.deltaX-centerPomX;var startY=z.deltaY-centerPomY;for(var j=0;j<z.matrixY;j++){for(var i=0;i<z.matrixX;i++){currentX=i+startX;currentY=j+startY;currentIndex=j*z.matrixX+i+1;var src="";if(!isNaN(currentX)&&!isNaN(currentY)){if(orto==true){if(porto==true)src="Services/getimage.aspx?zoom="+z.zoom+"&x="+currentX+"&y="+currentY+"&orto=1&porto=1";else src="Services/getimage.aspx?zoom="+z.zoom+"&x="+currentX+"&y="+currentY+"&orto=1&porto=0";}else{src="Services/getimage.aspx?zoom="+z.zoom+"&x="+currentX+"&y="+currentY+"&orto=0&porto=0";}}else src="Cached_images/blank.jpg";if(all){html+='<DIV index="'+currentIndex+'" style="left:'+(i*z.cellWidth)+'; top:'+(j*z.cellHeight)+';" class="matrixCell"><img id="img'+currentIndex+'" src="'+src+'" GALLERYIMG="no"/></DIV>';}}}}if(all){mainContainer.innerHTML=html;}}catch(ex){reportError("web_mapFunctions_loadImages",ex.message);}}function reLoadImages(){try{var currentX;var currentY;var currentIndex;var startX=z.deltaX-centerPomX;if(startX<0)startX=0;var startY=z.deltaY-centerPomY;if(startY<0)startY=0;for(var j=0;j<z.matrixY;j++){for(var i=0;i<z.matrixX;i++){currentX=i+startX;currentY=j+startY;currentIndex=j*z.matrixX+i+1;var now=new Date();var ran=""+now.getTime();try{var img=gi("img"+currentIndex);var src="";if(orto==true&&z.zoom<3)src="Services/getimage.aspx?zoom="+z.zoom+"&x="+currentX+"&y="+currentY+"&orto=1"+"&rnd="+ran;else src="Services/getimage.aspx?zoom="+z.zoom+"&x="+currentX+"&y="+currentY+"&orto=0"+"&rnd="+ran;if(!isImageOk(img)){img.src=src;}}catch(ex){}}}}catch(ex){reportError("web_mapFunctions_reLoadImages",ex.message);}}function yPoint(x,y){this.x=x;this.y=y;}