var CONST_IMG_PATH='http://map.hongkonghomes.com/map_lib_svg/';
var CONST_ZOOM_P1=eval({"lg1_per_px":"0.0000000000","la1_per_px":"0.0000000000","glg1_per_px":"2.34375","gla1_per_px":"3.3125","la":"848000","ln":"800000","total_y_meter":"3000","total_y_px":"1280","total_x_meter":"3750","total_x_px":"1600"});
var CONST_ZOOM_P2=[{"level":"0","id":"11"},{"level":"1","id":"10"},{"level":"2","id":"9"},{"level":"3","id":"8"},{"level":"4","id":"7"},{"level":"5","id":"6"},{"level":"6","id":"3"},{"level":"7","id":"2"},{"level":"8","id":"1"}];
var CONST_ALL_ZOOM=[{"id":"11","level":"0","lg1_per_px":"0.0000000000","la1_per_px":"0.0000000000","glg1_per_px":"0.29296875","gla1_per_px":"0.4165625","la":"848000","ln":"800000","total_y_meter":"3000","total_y_px":"10240","total_x_meter":"3750","total_x_px":"12800"},{"id":"10","level":"1","lg1_per_px":"0.0000000000","la1_per_px":"0.0000000000","glg1_per_px":"0.5859375","gla1_per_px":"0.833125","la":"848000","ln":"800000","total_y_meter":"3000","total_y_px":"5120","total_x_meter":"3750","total_x_px":"6400"},{"id":"9","level":"2","lg1_per_px":"0.0000000000","la1_per_px":"0.0000000000","glg1_per_px":"1.171875","gla1_per_px":"1.66625","la":"848000","ln":"800000","total_y_meter":"3000","total_y_px":"2560","total_x_meter":"3750","total_x_px":"3200"},{"id":"8","level":"3","lg1_per_px":"0.0000000000","la1_per_px":"0.0000000000","glg1_per_px":"2.34375","gla1_per_px":"3.3125","la":"848000","ln":"800000","total_y_meter":"3000","total_y_px":"1280","total_x_meter":"3750","total_x_px":"1600"},{"id":"7","level":"4","lg1_per_px":"0.0000000000","la1_per_px":"0.0000000000","glg1_per_px":"4.6875","gla1_per_px":"6.625","la":"848000","ln":"800000","total_y_meter":"3000","total_y_px":"640","total_x_meter":"3750","total_x_px":"800"},{"id":"6","level":"5","lg1_per_px":"0.0000000000","la1_per_px":"0.0000000000","glg1_per_px":"9.375","gla1_per_px":"13.25","la":"848000","ln":"800000","total_y_meter":"3000","total_y_px":"320","total_x_meter":"3750","total_x_px":"400"},{"id":"3","level":"6","lg1_per_px":"0.0000000000","la1_per_px":"0.0000000000","glg1_per_px":"18.75","gla1_per_px":"26.5","la":"848000","ln":"800000","total_y_meter":"3000","total_y_px":"160","total_x_meter":"3750","total_x_px":"200"},{"id":"2","level":"7","lg1_per_px":"0.0000000000","la1_per_px":"0.0000000000","glg1_per_px":"37.5","gla1_per_px":"53","la":"848000","ln":"800000","total_y_meter":"3000","total_y_px":"80","total_x_meter":"3750","total_x_px":"100"},{"id":"1","level":"8","lg1_per_px":"0.0000000000","la1_per_px":"0.0000000000","glg1_per_px":"75","gla1_per_px":"106","la":"848000","ln":"800000","total_y_meter":"3000","total_y_px":"40","total_x_meter":"3750","total_x_px":"50"},{"id":"4","level":"9","lg1_per_px":"0.0000000000","la1_per_px":"0.0000000000","glg1_per_px":"150","gla1_per_px":"212","la":"848000","ln":"800000","total_y_meter":"3000","total_y_px":"20","total_x_meter":"3750","total_x_px":"25"},{"id":"5","level":"10","lg1_per_px":"0.0000000000","la1_per_px":"0.0000000000","glg1_per_px":"300","gla1_per_px":"424","la":"848000","ln":"800000","total_y_meter":"3000","total_y_px":"10","total_x_meter":"3750","total_x_px":"12"}];
var CONST_DEFAULT_ZOOM=3;
var CONST_DEFAULT_LN=834262;
var CONST_DEFAULT_LA=815940;
function debug(msg){
var debugArea=$('debug-area')
if(debugArea==null){
debugArea=document.createElement("div");
debugArea.id="debug-area";
debugArea.style.top="0px"
debugArea.style.right="0px"
debugArea.style.width="200px"
debugArea.style.height="800px"
debugArea.style.position="absolute"
debugArea.style.border="1px solid #000"
debugArea.style.overflow="auto"
debugArea.style.background="#FFF"
debugArea.style.zIndex=100000;
document.body.appendChild(debugArea);}
debugArea.innerHTML=msg+"<br/>"+debugArea.innerHTML;}
if(typeof console=="undefined"){
console=function(){
return{
log:function(msg){
debug(msg);}}}();}
if(Prototype.Browser.WebKit){
var array=navigator.userAgent.match(new RegExp(/AppleWebKit\/([\d\.\+]*)/));
Prototype.Browser.WebKitVersion=parseFloat(array[1]);}
function degToRad(value){
return value/180*Math.PI;}
function radToDeg(value){
return value/Math.PI*180;}
function computeAngle(x1,y1,x2,y2,radian){
var dx=x2-x1;
var dy=y1-y2;
if(radian)
var angle=dx!=0?Math.atan(dy/ dx):-Math.PI/2;
else
var angle=dx!=0?radToDeg(Math.atan(dy/dx)):90;
if(dx<0&&dy<0)
angle=angle-(radian?Math.PI:180);
if(dx<0&&dy>0)
angle=(radian?Math.PI:180)+angle;
return angle}
function disableSelection(){
document.body.ondrag=function(){return false;};
document.body.onselectstart=function(){return false;};}
function enableSelection(){
document.body.ondrag=null;
document.body.onselectstart=null;}
String.prototype.parseColor=function(){
var color='#';
if(this.slice(0,4)=='rgb('){
var cols=this.slice(4,this.length-1).split(',');
var i=0;do{color+=parseInt(cols[i]).toColorPart()}while(++i<3);}else{
if(this.slice(0,1)=='#'){
if(this.length==4)for(var i=1;i<4;i++)color+=(this.charAt(i)+this.charAt(i)).toLowerCase();
if(this.length==7)color=this.toLowerCase();}}
return(color.length==7?color:(arguments[0]||this));}
function getWindowScroll(w){
var T,L,W,H;
with(w.document){
if(w.document.documentElement&&documentElement.scrollTop){
T=documentElement.scrollTop;
L=documentElement.scrollLeft;}else if(w.document.body){
T=body.scrollTop;
L=body.scrollLeft;}
if(w.innerWidth){
W=w.innerWidth;
H=w.innerHeight;}else if(w.document.documentElement&&documentElement.clientWidth){
W=documentElement.clientWidth;
H=documentElement.clientHeight;}else{
W=body.offsetWidth;
H=body.offsetHeight}}
return{top:T,left:L,width:W,height:H};}
function pickPoly(points,x,y){
var nbPt=points.length;
var c=false;
for(var i=0,j=nbPt-1;i<nbPt;j=i++){
if((((points[i].y<=y)&&(y<points[j].y))||((points[j].y<=y)&&(y<points[i].y)))&&(x<(points[j].x-points[i].x)*(y-points[i].y)/(points[j].y-points[i].y)+points[i].x)){
c=!c;}}
return c;}
EventNotifier={
observers:new Array(),
addObserver:function(observer,sender){
sender=sender||null;
this.removeObserver(observer);
this.observers.push({observer:observer,sender:sender});},
removeObserver:function(observer){
this.observers=this.observers.reject(function(o){return o.observer==observer});},
send:function(sender,eventName,options){
options=options||null;
this.observers.each(function(o){
if((o.sender==null||o.sender==sender)&&o.observer[eventName])
o.observer[eventName](sender,options);});}}
Graphic=Class.create();
Object.extend(Graphic,{
functionMustBeOverriden:{
name:'functionMustBeOverriden',
message:'This function is an abstract function and must be overriden'},
rendererSupported:function(name){
switch(name){
case "VML":
return Prototype.Browser.IE;
case "SVG":
return !(Prototype.Browser.IE||Prototype.Browser.WebKitVersion<420);
case "Canvas":
try{
return document.createElement("canvas").getContext("2d")!=null;}
catch(e){
return false;}
default:
throw "Renderer "+name+" not supported"
return null;}}});
Matrix=Class.create();
Object.extend(Matrix,{
multiply:function(left,right){
var matrices;
if(left instanceof Array)
matrices=left;
else
matrices=[left,right];
var matrix=matrices[0];
for(var i=1;i<matrices.length;++i){
var left=matrix;
var right=matrices[i];
matrix=new Matrix();
matrix.xx=left.xx*right.xx+left.xy*right.yx;
matrix.xy=left.xx*right.xy+left.xy*right.yy;
matrix.yx=left.yx*right.xx+left.yy*right.yx;
matrix.yy=left.yx*right.xy+left.yy*right.yy;
matrix.dx=left.xx*right.dx+left.xy*right.dy+left.dx;
matrix.dy=left.yx*right.dx+left.yy*right.dy+left.dy;}
return matrix;},
translate:function(x,y){
return new Matrix({dx:x,dy:y});},
rotate:function(angle){
var c=Math.cos(degToRad(angle));
var s=Math.sin(degToRad(angle));
return new Matrix({xx:c,xy:s,yx:-s,yy:c});},
scale:function(sx,sy){
sy=sy||sx;
return new Matrix({xx:sx,yy:sy});},
skewX:function(angle){
return new Matrix({xy:Math.tan(degToRad(angle))});},
skewY:function(angle){
return new Matrix({yx:Math.tan(-degToRad(angle))});},
rotateAt:function(angle,x,y){
return Matrix.multiply([Matrix.translate(x,y),Matrix.rotate(angle),Matrix.translate(-x,-y)])},
scaleAt:function(sx,sy,x,y){
return Matrix.multiply([Matrix.translate(x,y),Matrix.scale(sx,sy),Matrix.translate(-x,-y)])},
invert:function(matrix){
var m=matrix;
var D=m.xx*m.yy-m.xy*m.yx;
return new Matrix({xx:m.yy/D, xy: -m.xy/D,yx:-m.yx/D, yy: m.xx/D,dx:(m.yx*m.dy-m.yy*m.dx)/D,dy:(m.xy*m.dx-m.xx*m.dy)/D});}})
Object.extend(Matrix.prototype,{
initialize:function(values){
Object.extend(Object.extend(this,{xx:1,xy:0,yx:0,yy:1,dx:0,dy:0}),values||{});
return this;},
multiplyRight:function(matrix){
var matrix=Matrix.multiply(this,matrix);
this._affectValues(matrix);
return this;},
multiplyLeft:function(matrix){
var matrix=Matrix.multiply(matrix,this);
this._affectValues(matrix);
return this;},
multiplyPoint:function(x,y){
return{x:this.xx*x+this.xy*y+this.dx,y:this.yx*x+this.yy*y+this.dy};},
multiplyBounds:function(bounds){
var pt1=this.multiplyPoint(bounds.x,bounds.y);
var pt2=this.multiplyPoint(bounds.x+bounds.w,bounds.y);
var pt3=this.multiplyPoint(bounds.x,bounds.y+bounds.h);
var pt4=this.multiplyPoint(bounds.x+bounds.w,bounds.y+bounds.h);
var xmin=Math.min(Math.min(pt1.x,pt2.x),Math.min(pt3.x,pt4.x));
var ymin=Math.min(Math.min(pt1.y,pt2.y),Math.min(pt3.y,pt4.y));
var xmax=Math.max(Math.max(pt1.x,pt2.x),Math.max(pt3.x,pt4.x));
var ymax=Math.max(Math.max(pt1.y,pt2.y),Math.max(pt3.y,pt4.y));
return{x:xmin,y:ymin,w:xmax-xmin,h:ymax-ymin};},
values:function(){
return $A([this.xx,this.yx,this.xy,this.yy,this.dx,this.dy]);},
setValues:function(array){
this.xx=parseFloat(array[0]);
this.yx=parseFloat(array[1]);
this.xy=parseFloat(array[2]);
this.yy=parseFloat(array[3]);
this.dx=parseFloat(array[4]);
this.dy=parseFloat(array[5]);
return this;},
hashValues:function(){
return $H({xx:this.xx,xy:this.xy,yx:this.yx,yy:this.yy,dx:this.dx,dy:this.dy});},
toString:function(){
return Object.inspect(this.hashValues());},
toJSON:function(){
return this.hashValues().toJSON();},
_affectValues:function(matrix){
Object.extend(this,matrix);
return this;}});
Graphic.AbstractRender=Class.create();
Graphic.AbstractRender.prototype={
initialize:function(element){
var dimension=$(element).getDimensions();
this.viewing={tx:0,ty:0,sx:1,sy:1,cx:dimension.width/2, cy: dimension.height/2};
this._setViewMatrix();
this.bounds={x:0,y:0,w:dimension.width,h:dimension.height};
return this;},
pan:function(x,y){
this.viewing.tx=x;
this.viewing.ty=y;
this._setViewMatrix();
this._setViewing();
return this;},
zoom:function(sx,sy,cx,cy){
this.viewing.sx=sx;
this.viewing.sy=sy;
this.viewing.cx=cx||this.bounds.w/2;
this.viewing.cy=cy||this.bounds.h/2;
this._setViewMatrix();
this._setViewing();
return this;},
getViewing:function(){
return this.viewing;},
setViewing:function(viewing){
this.viewing=Object.extend(this.viewing,viewing);
this._setViewMatrix();
this._setViewing();
return this;},
_setViewMatrix:function(){
this.viewingMatrix=Matrix.translate(this.viewing.tx,this.viewing.ty).multiplyLeft(Matrix.scaleAt(1/this.viewing.sx, 1/this.viewing.sy,this.viewing.cx,this.viewing.cy));},
setSize:function(width,height){
this.bounds.w=width;
this.bounds.h=height;
return this;},
getSize:function(){
return{width:this.bounds.w,height:this.bounds.h};},
destroy:function(){console.log("Graphic.AbstractRender:destroy")},
createShape:function(type){console.log("Graphic.AbstractRender:createShape")},
add:function(shape,parent){console.log("Graphic.AbstractRender:add")},
remove:function(shape,parent){console.log("Graphic.AbstractRender:remove")},
get:function(id){console.log("Graphic.AbstractRender:get")},
shapes:function(id){console.log("Graphic.AbstractRender:shapes")},
clear:function(){console.log("Graphic.AbstractRender:clear")},
updateAttributes:function(shape,attributes){console.log("Graphic.AbstractRender:update")},
updateTransform:function(shape){console.log("Graphic.AbstractRender:updateTransform")},
nbShapes:function(){console.log("Graphic.AbstractRender:nbShapes")},
show:function(shape){console.log("Graphic.AbstractRender:show")},
hide:function(shape){console.log("Graphic.AbstractRender:hide")},
moveToFront:function(shape){console.log("Graphic.AbstractRender:moveToFront")},
draw:function(){console.log("Graphic.AbstractRender:draw")},
position:function(){console.log("Graphic.AbstractRender:position")},
pick:function(event){console.log("Graphic.AbstractRender:pick")},
addComment:function(shape,text){},
addText:function(shape,text){console.log("Graphic.AbstractRender:addText")},
_setViewing:function(){console.log("Graphic.AbstractRender:_setViewing")}}
Graphic.CanvasRenderer=Class.create();
Object.extend(Graphic.CanvasRenderer.prototype,Graphic.AbstractRender.prototype);
Graphic.CanvasRenderer.prototype._parentInitialize=Graphic.AbstractRender.prototype.initialize;
Graphic.CanvasRenderer.prototype._parentSetSize=Graphic.AbstractRender.prototype.setSize;
Object.extend(Graphic.CanvasRenderer.prototype,{
initialize:function(element){
this._parentInitialize(element);
this.element=document.createElement("canvas");
this.element.setAttribute("width",this.bounds.w);
this.element.setAttribute("height",this.bounds.h);
this.element.shape=this;
$(element).appendChild(this.element);
this.context=this.element.getContext("2d");
this.nodes=new Array();
this.offset=Position.cumulativeOffset(this.element.parentNode);},
destroy:function(){
this.nodes.clear();
this.element.parentNode.removeChild(this.element);},
setSize:function(width,height){
this._parentSetSize(width,height);
this.element.setAttribute("width",this.bounds.w);
this.element.setAttribute("height",this.bounds.h);
this.zoom(this.viewing.sx,this.viewing.sy)},
add:function(shape,parent){
if(parent!=null)
console.log("CanvasRenderer:add inside another shape (parent != null) not yet implemented")
if(shape.element)
this.nodes.push(shape);},
shapes:function(){
return this.nodes;},
updateAttributes:function(shape,attributes){},
updateTransform:function(shape){},
createShape:function(shape){
var canvasShape=null;
switch(shape.nodeName){
case "rect":
canvasShape=new CanvasRect(shape);
break;
case "ellipse":
canvasShape=new CanvasEllipse(shape);
break;
case "circle":
canvasShape=new CanvasCircle(shape);
break;
case "polygon":
canvasShape=new CanvasPolygon(shape,true);
break;
case "polyline":
canvasShape=new CanvasPolygon(shape,false);
break;
case "line":
canvasShape=new CanvasLine(shape);
break;
case "image":
canvasShape=new CanvasImage(shape);
break;
default:
console.log("shape "+shape.nodeName+" not yet implemented for canvas renderer");
break;}
return canvasShape;},
draw:function(){
var context=this.context;
context.clearRect(this.bounds.x,this.bounds.y,this.bounds.w,this.bounds.h);
context.save();
context.translate(-this.viewing.tx,-this.viewing.ty);
context.translate(this.viewing.cx,this.viewing.cy);
context.scale(this.viewing.sx,this.viewing.sy);
context.translate(-this.viewing.cx,-this.viewing.cy);
this.nodes.each(function(n){if(n.element)n.element.draw(this)}.bind(this))
context.restore();},
pick:function(event){
var pt=this.viewingMatrix.multiplyPoint(Event.pointerX(event)-this.offset[0],Event.pointerY(event)-this.offset[1]);
var element=null;
for(var i=this.nodes.length-1;i>=0;i--){
if(this.nodes[i].element.pick(pt.x,pt.y))
break;}
return(i<0?null:this.nodes[i]);},
moveToFront:function(shape){
var node=this.nodes.find(function(s){if(s==shape)return true});
this.nodes=this.nodes.without(node);
this.nodes.push(node);},
_setViewing:function(){
this.draw();},
fill:function(attributes){
if(attributes.fill&&attributes.fill!="none"){
this.context.fillStyle=attributes.fill;
this.context.globalAlpha=attributes["fill-opacity"];
this.context.fill();}},
stroke:function(attributes){
this.context.strokeStyle=attributes.stroke;
this.context.lineWidth=attributes["stroke-width"]
this.context.globalAlpha=attributes["stroke-opacity"];
this.context.stroke();},
moveTo:function(matrix,x,y){
var p=matrix.multiplyPoint(x,y);
this.context.moveTo(p.x,p.y);},
lineTo:function(matrix,x,y){
var p=matrix.multiplyPoint(x,y);
this.context.lineTo(p.x,p.y);},
bezierCurveTo:function(matrix,cp1x,cp1y,cp2x,cp2y,x,y){
var cp1=matrix.multiplyPoint(cp1x,cp1y);
var cp2=matrix.multiplyPoint(cp2x,cp2y);
var p=matrix.multiplyPoint(x,y);
this.context.bezierCurveTo(cp1.x,cp1.y,cp2.x,cp2.y,p.x,p.y);}});
CanvasRect=Class.create();
CanvasRect.prototype={
initialize:function(shape){
this.shape=shape;},
draw:function(renderer){
var context=renderer.context;
var matrix=this.shape.getMatrix();
context.save();
with(this.shape){
context.beginPath();
renderer.moveTo(matrix,attributes.x,attributes.y);
renderer.lineTo(matrix,attributes.x+attributes.width,attributes.y);
renderer.lineTo(matrix,attributes.x+attributes.width,attributes.y+attributes.height);
renderer.lineTo(matrix,attributes.x,attributes.y+attributes.height);
context.closePath();
renderer.fill(attributes);
renderer.stroke(attributes);}
context.restore();},
pick:function(x,y){
var pt=this.shape.getInverseMatrix().multiplyPoint(x,y);
var a=this.shape.attributes;
return a.x<=pt.x&&pt.x<=a.x+a.width&&a.y<=pt.y&&pt.y<=a.y+a.height;}}
CanvasEllipse=Class.create();
CanvasEllipse.prototype={
initialize:function(shape){
this.shape=shape;},
draw:function(renderer){
var context=renderer.context;
var matrix=this.shape.getMatrix();
context.save();
with(this.shape){
var KAPPA=4*((Math.sqrt(2)-1)/3);
var rx=attributes.rx;
var ry=attributes.ry;
var cx=attributes.cx;
var cy=attributes.cy;
context.beginPath();
renderer.moveTo(matrix,cx,cy-ry);
renderer.bezierCurveTo(matrix,cx+(KAPPA*rx),cy-ry,cx+rx,cy-(KAPPA*ry),cx+rx,cy);
renderer.bezierCurveTo(matrix,cx+rx,cy+(KAPPA*ry),cx+(KAPPA*rx),cy+ry,cx,cy+ry);
renderer.bezierCurveTo(matrix,cx-(KAPPA*rx),cy+ry,cx-rx,cy+(KAPPA*ry),cx-rx,cy);
renderer.bezierCurveTo(matrix,cx-rx,cy-(KAPPA*ry),cx-(KAPPA*rx),cy-ry,cx,cy-ry);
context.closePath();
renderer.fill(attributes);
renderer.stroke(attributes);}
context.restore();},
pick:function(x,y){
return false;}}
CanvasCircle=Class.create();
CanvasCircle.prototype={
initialize:function(shape){
this.shape=shape;},
draw:function(renderer){
var context=renderer.context;
var matrix=this.shape.getMatrix();
context.save();
with(this.shape){
context.beginPath();
var c=matrix.multiplyPoint(attributes.cx,attributes.cy);
context.arc(c.x,c.y,attributes.r,0,Math.PI*2,1)
context.closePath();
renderer.fill(attributes);
renderer.stroke(attributes);}
context.restore();},
pick:function(x,y){
return false;}}
CanvasPolygon=Class.create();
CanvasPolygon.prototype={
initialize:function(shape,closed){
this.shape=shape;
this.closed=closed;},
draw:function(renderer){
if(this.shape.getPoints().length==0)
return;
var context=renderer.context;
var matrix=this.shape.getMatrix();
context.save();
with(this.shape){
context.beginPath();
var first=getPoints()[0];
renderer.moveTo(matrix,first[0],first[1]);
getPoints().each(function(point){
renderer.lineTo(matrix,point[0],point[1]);});
if(this.closed)
context.closePath();
renderer.fill(attributes);
renderer.stroke(attributes);}
context.restore();},
pick:function(x,y){
return false;}}
CanvasLine=Class.create();
CanvasLine.prototype={
initialize:function(shape){
this.shape=shape;},
draw:function(renderer){
var context=renderer.context;
var matrix=this.shape.getMatrix();
context.save();
with(this.shape){
context.beginPath();
renderer.moveTo(matrix,attributes.x1,attributes.y1);
renderer.lineTo(matrix,attributes.x2,attributes.y2);
renderer.stroke(attributes);}
context.restore();},
pick:function(x,y){
return false;}}
CanvasImage=Class.create();
CanvasImage.prototype={
initialize:function(shape){
this.shape=shape;
this.loaded=false;},
draw:function(renderer){
var context=renderer.context;
var matrix=this.shape.getMatrix();
context.save();
with(this.shape){
if(image){
var p=matrix.multiplyPoint(attributes.x,attributes.y);
if(!this.loaded)
Event.observe(image,"load",function(){
context.drawImage(image,p.x,p.y);
this.loaded=true;}.bind(this));
else
context.drawImage(image,p.x,p.y);}}
context.restore();},
pick:function(x,y){
return false;}}
Graphic.VMLRenderer=Class.create();
Object.extend(Graphic.VMLRenderer,{
init:false,
createNode:function(nodeName){
return document.createElement(nodeName);;},
initBrowser:function(){
if(!Graphic.VMLRenderer.init&&document.readyState=="complete"){
if(!document.namespaces["v"]){
document.namespaces.add("v","urn:schemas-microsoft-com:vml");}
var ss=document.createStyleSheet();
ss.cssText="v\\:* {behavior:url(#default#VML);}";
Graphic.VMLRenderer.init=true;}}})
Object.extend(Graphic.VMLRenderer.prototype,Graphic.AbstractRender.prototype);
Graphic.VMLRenderer.prototype._parentInitialize=Graphic.AbstractRender.prototype.initialize;
Graphic.VMLRenderer.prototype._parentSetSize=Graphic.AbstractRender.prototype.setSize;
Object.extend(Graphic.VMLRenderer.prototype,{
initialize:function(element){
Graphic.VMLRenderer.initBrowser();
this._parentInitialize(element);
this.element=Graphic.VMLRenderer.createNode("v:group");
this.element.style.height=this.bounds.h+"px";
this.element.style.width=this.bounds.w+"px";
this._setViewing();
this.element.graphicNode=this;
this.element=$(element);},
destroy:function(){
$A(this.element.childNodes).each(function(node){
if(node.shape){
node.shape.destroy();}else{
node.parentNode.removeChild(node);}})
this.element.parentNode.removeChild(this.element);},
setSize:function(width,height){
this._parentSetSize(width,height);
this.element.style.height=this.bounds.h+"px";
this.element.style.width=this.bounds.w+"px";
this.zoom(this.viewing.sx,this.viewing.sy)},
createShape:function(shape){
var node=null;
switch(shape.nodeName){
case "rect":
node=Graphic.VMLRenderer.createNode("v:roundrect");
node.arcsize=0;
break;
case "ellipse":
case "circle":
node=Graphic.VMLRenderer.createNode("v:oval");
break;
case "polygon":
case "polyline":
node=Graphic.VMLRenderer.createNode("v:shape");
node.style.height=this.bounds.h+"px";
node.style.width=this.bounds.w+"px";
node.coordsize=this.bounds.w+", "+this.bounds.h;
node.coordorigin="0, 0";
node.unselectable="on";
node.filled="false";
break;
case "line":
node=Graphic.VMLRenderer.createNode("v:line");
break;
case "g":
node=Graphic.VMLRenderer.createNode("v:group");
node.stroked="false";
node.filled="false";
node.style.height=this.bounds.w+"px";
node.style.width=this.bounds.h+"px";
node.coordsize=this.bounds.w+", "+this.bounds.h;
node.coordorigin="0, 0";
break;
default:
break;}
if(!node)
return null;
if(shape.nodeName!="g"&&shape.nodeName!="image"){
var fill=Graphic.VMLRenderer.createNode("v:fill");
fill.on="false";
if(shape.nodeName!="polyline")
node.appendChild(fill);
node.fill=fill;
var stroke=Graphic.VMLRenderer.createNode("v:stroke");
stroke.on="false";
stroke.joinstyle="round";
stroke.endcap="round";
node.appendChild(stroke);
node.stroke=stroke;
var skew=Graphic.VMLRenderer.createNode("v:skew");
skew.on="true";
node.appendChild(skew);
node.skew=skew;}
return node;},
add:function(shape){
if(shape.parent){
shape.parent.getRendererObject().appendChild(shape.getRendererObject());
this.updateAttributes(shape,shape.attributes);}
else{
if(shape&&shape.getRendererObject())
this.element.appendChild(shape.getRendererObject());}},
remove:function(shape){
if(shape.parent)
shape.parent.getRendererObject().removeChild(shape.getRendererObject());
else
this.element.removeChild(shape.getRendererObject());},
get:function(id){
var element=$(id)
return element&&element.shape?element.shape:null;},
shapes:function(){
return $A(this.element.childNodes).collect(function(element){return element.shape});},
clear:function(){
$A(this.element.childNodes).each(function(element){
element.shape.destroy();})},
updateAttributes:function(shape,attributes){
var element=shape.element;
if(!element)
return;
$H(attributes).keys().each(function(key){
switch(key){
case "width":
case "height":
element.style[key]=attributes[key]+"px";
break;
case "cx":
case "cy":
case "rx":
case "ry":
case "r":
if(element.nodeName!="roundrect"){
var rx=typeof shape.attributes.rx!="undefined"?shape.attributes.rx:shape.attributes.r;
var ry=typeof shape.attributes.ry!="undefined"?shape.attributes.ry:shape.attributes.r;
element.style.left=(shape.attributes.cx-rx).toFixed();
element.style.top=(shape.attributes.cy-ry).toFixed();
element.style.width=(rx*2).toFixed();
element.style.height=(ry*2).toFixed();}
break;
case "x":
element.style["left"]=attributes[key]+"px";
break;
case "y":
element.style["top"]=attributes[key]+"px";
break;
case "fill":
if(element.fill){
element.fill.color=attributes[key].parseColor();
element.fill.on="true";}
break;
case "fill-opacity":
if(element.fill){
if(attributes[key]=="none"){
element.fill.on="false";}
else{
element.fill.opacity=attributes[key];
element.fill.on="true";}}
break;
case "stroke":
if(element.stroke){
if(attributes[key]=="none"){
element.stroke.on="false";}
else{
element.stroke.color=attributes[key].parseColor();
element.stroke.on="true";}}
break;
case "stroke-opacity":
if(element.stroke){
element.stroke.opacity=attributes[key];
element.stroke.on="true";}
break;
case "stroke-width":
if(element.stroke){
element.stroke.weight=attributes[key]+"px";
element.stroke.on="true";}
break;
case "points":
var p=shape.getPoints();
var attr=[];
if(p.length>0){
attr.push("m");
attr.push(p[0][0].toFixed());
attr.push(p[0][1].toFixed());
if(p.length>1){
attr.push("l");
for(var i=1;i<p.length;++i){
attr.push(p[i][0].toFixed());
attr.push(p[i][1].toFixed());}}}
if(shape.getType()=="polygon")
attr.push("x");
else
attr.push("e");
element.path=attr.join(" ");
break;
case "x1":
element.from=shape.attributes.x1.toFixed()+" "+shape.attributes.y1.toFixed();
element.to=shape.attributes.x2.toFixed()+" "+shape.attributes.y2.toFixed();
break
case "id":
element.id=attributes[key]
break;
case "class":
element.id=attributes[key]
break;
case "href":
element.firstChild.src=attributes[key]
break;
default:
break;}});},
updateTransform:function(shape){
if(!shape.element)
return;
var matrix=shape.getMatrix();
if(shape instanceof Graphic.Group&&shape.children){
shape.children.each(function(s){
var m=s.getMatrix()
this._updateSkew(s,Matrix.multiply(matrix,m))}.bind(this))}
else if(shape instanceof Graphic.Image){}
else{
this._updateSkew(shape,matrix);}},
_updateSkew:function(shape,matrix){
if(!shape.element.skew)
return;
var bounds=shape.getBounds();
shape.element.skew.on="false";
shape.element.skew.matrix=matrix.xx.toFixed(8)+" "+matrix.xy.toFixed(8)+" "+matrix.yx.toFixed(8)+" "+matrix.yy.toFixed(8)+" 0 0";
pt={x:matrix.dx,y:matrix.dy}
shape.element.skew.offset=Math.floor(pt.x).toFixed()+"px "+Math.floor(pt.y).toFixed()+"px";
shape.element.skew.origin=((bounds.w!=0?-bounds.x/ bounds.w: 1)- 0.5).toFixed(8)+ " "+((bounds.h!= 0?-bounds.y/ bounds.h:1)-0.5).toFixed(8);
shape.element.skew.on="true";},
nbShapes:function(){
return this.element.childNodes.length;},
moveToFront:function(node){
if(this.nbShapes()>0){
this.element.appendChild(node.element);}},
show:function(shape){
shape.element.style.display="block";},
hide:function(shape){
shape.element.style.display="none";},
draw:function(){},
pick:function(event){
var element=Event.element(event);
return element==this.element.parent?null:element.shape;},
position:function(){
if(this.offset==null)
this.offset=Position.cumulativeOffset(this.element.parentNode);
return this.offset;},
addComment:function(shape,text){
shape.element.appendChild(document.createComment(text));},
addText:function(shape,text){},
_setViewing:function(){
var bounds=this.viewingMatrix.multiplyBounds(this.bounds);
this.element.coordsize=bounds.w+", "+bounds.h;
this.element.coordorigin=bounds.x+", "+bounds.y;}});
Graphic.SVGRenderer=Class.create();
Object.extend(Graphic.SVGRenderer,{
xmlns:{
svg:"http://www.w3.org/2000/svg",
xlink:"http://www.w3.org/1999/xlink"},
createNode:function(nodeName){
return document.createElementNS(Graphic.SVGRenderer.xmlns.svg,nodeName);;}})
Object.extend(Graphic.SVGRenderer.prototype,Graphic.AbstractRender.prototype);
Graphic.SVGRenderer.prototype._parentInitialize=Graphic.AbstractRender.prototype.initialize;
Graphic.SVGRenderer.prototype._parentSetSize=Graphic.AbstractRender.prototype.setSize;
Object.extend(Graphic.SVGRenderer.prototype,{
initialize:function(element){
this._parentInitialize(element);
this.element=Graphic.SVGRenderer.createNode("svg");
this.element.setAttribute("width",this.bounds.w);
this.element.setAttribute("height",this.bounds.h);
this.element.setAttribute("preserveAspectRatio","none");
this._setViewing();
this.element.shape=this;
$(element).appendChild(this.element);},
destroy:function(){
$A(this.element.childNodes).each(function(node){
if(node.shape){
node.shape.destroy();}else{
node.parentNode.removeChild(node);}})
this.element.parentNode.removeChild(this.element);},
setSize:function(width,height){
this._parentSetSize(width,height);
this.element.setAttribute("width",this.bounds.w);
this.element.setAttribute("height",this.bounds.h);
this.zoom(this.viewing.sx,this.viewing.sy)},
createShape:function(shape){
return Graphic.SVGRenderer.createNode(shape.nodeName);},
add:function(shape){
if(shape.parent)
shape.parent.getRendererObject().appendChild(shape.getRendererObject());
else
this.element.appendChild(shape.getRendererObject());},
remove:function(shape){
if(shape.parent)
shape.parent.getRendererObject().removeChild(shape.getRendererObject());
else
this.element.removeChild(shape.getRendererObject());},
get:function(id){
var element=$(id)
return element&&element.shape?element.shape:null;},
shapes:function(){
return $A(this.element.childNodes).collect(function(element){return element.shape});},
clear:function(){
$A(this.element.childNodes).each(function(element){
element.shape.destroy();})},
updateAttributes:function(shape,attributes){
$H(attributes).keys().each(function(key){
if(key=="href")
shape.element.setAttributeNS(Graphic.SVGRenderer.xmlns.xlink,"href",attributes[key]);
else
shape.element.setAttribute(key,attributes[key])});},
updateTransform:function(shape){
if(shape.nodeName!="g")
shape.element.setAttribute("transform","matrix("+shape.getMatrix().values().join(",")+")");},
nbShapes:function(){
return this.element.childNodes.length;},
moveToFront:function(node){
if(this.nbShapes()>0){
this.element.appendChild(node.element);}},
show:function(shape){
shape.element.style.display="block";},
hide:function(shape){
shape.element.style.display="none";},
draw:function(){},
pick:function(event){
var element=Event.element(event);
return element==this.element?null:element.shape;},
position:function(){
if(this.offset==null)
this.offset=Position.cumulativeOffset(this.element.parentNode);
return this.offset;},
addComment:function(shape,text){
shape.element.appendChild(document.createComment(text));},
addText:function(shape,text){
shape.element.appendChild(document.createTextNode(text));},
_setViewing:function(){
var bounds=this.viewingMatrix.multiplyBounds(this.bounds);
this.element.setAttribute("viewBox",bounds.x+" "+bounds.y+" "+bounds.w+" "+bounds.h);}});
Graphic.Shape=Class.create();
Object.extend(Graphic.Shape.prototype,{
initialize:function(renderer,nodeName){
this.attributes={};
this.renderer=renderer;
this.nodeName=nodeName;
this.element=renderer.createShape(this);
if(this.element)
this.element.shape=this;
this.setMatrix(new Matrix());
this.setStroke(null);
this.setFill(null);
return this;},
destroy:function(){
this.renderer.remove(this);},
getType:function(){
return this.nodeName;},
setID:function(id){
this._setAttribute("id",id,true);
return this;},
getID:function(){
return this.attributes.id;},
setClassName:function(className){
this._setAttribute("class",className,true);
return this;},
getClassName:function(){
return this.attributes["class"];},
show:function(){
this.renderer.show(this);
return this;},
hide:function(){
this.renderer.hide(this);
return this;},
setFill:function(attributes){
if(!attributes||attributes.fill=="none"){
this._setAttribute("fill","none");
this._setAttribute("fill-opacity",0);}
else if(typeof attributes.r!="undefined"){
this._setAttribute("fill","rgb("+parseInt(attributes.r)+","+parseInt(attributes.g)+","+parseInt(attributes.b)+")");
this._setAttribute("fill-opacity",(attributes.a||255)/255.0);}
return this;},
getFill:function(){
return this.attributes.fill;},
getFillOpacity:function(){
return this.attributes["fill-opacity"];},
setFillOpacity:function(a){
this._setAttribute("fill-opacity",(a||255)/255.0);
return this;},
setFillColor:function(r,g,b){
this._setAttribute("fill","rgb("+parseInt(r)+","+parseInt(g)+","+parseInt(b)+")");
return this;},
setStroke:function(attributes){
if(!attributes||attributes.stroke=="none"){
this._setAttribute("stroke","none");
this._setAttribute("stroke-opacity",0);
this._setAttribute("stroke-width",0);}
else if(typeof attributes.r!="undefined"){
this._setAttribute("stroke","rgb("+parseInt(attributes.r)+","+parseInt(attributes.g)+","+parseInt(attributes.b)+")");
this._setAttribute("stroke-opacity",(attributes.a||255)/255.0);
this._setAttribute("stroke-width",(attributes.w||1));}
return this;},
setStrokeWidth:function(w){
this._setAttribute("stroke-width",(w||1));
return this;},
setStrokeOpacity:function(a){
this._setAttribute("stroke-opacity",(a||255)/255.0);
return this;},
setStrokeColor:function(r,g,b){
this._setAttribute("stroke","rgb("+parseInt(r)+","+parseInt(g)+","+parseInt(b)+")");
return this;},
getStroke:function(){
return this.attributes.stroke;},
getStrokeOpacity:function(){
return this.attributes["stroke-opacity"];},
getStrokeWidth:function(){
return this.attributes["stroke-width"];},
setAntialiasing:function(on){
if(on)
this._setAttribute("shape-rendering","auto");
else
this._setAttribute("shape-rendering","crispEdges");
return this;},
getAntialiasing:function(){
return this.attributes["shape-rendering"]=="auto";},
setBounds:function(x,y,w,h){
this.setLocation(x,y);
this.setSize(w,h);
return this;},
getBounds:function(){
return Object.extend(this.getSize(),this.getLocation());},
moveToFront:function(){
if(this.renderer)
this.renderer.moveToFront(this);
return this;},
rotate:function(angle,rx,ry){
var bounds=this.getBounds();
if(typeof rx=="undefined")
rx=bounds.x+(bounds.w/2);
if(typeof ry=="undefined")
ry=bounds.y+(bounds.h/2);
this.postTransform(Matrix.translate(rx,ry));
this.postTransform(Matrix.rotate(angle));
this.postTransform(Matrix.translate(-rx,-ry));
return this;},
translate:function(tx,ty){
return this.postTransform(Matrix.translate(tx,ty));},
scale:function(sx,sy,cx,cy){
if(cx)
this.postTransform(Matrix.translate(cx,cy));
this.postTransform(Matrix.scale(sx,sy));
if(cx)
this.postTransform(Matrix.translate(-cx,-cy));
return this},
postTransform:function(matrix){
this.matrix.multiplyRight(matrix)
this.inverseMatrix.multiplyLeft(Matrix.invert(matrix));
this._updateTransform();
return this;},
preTransform:function(matrix){
this.matrix.multiplyLeft(matrix)
this.inverseMatrix.multiplyRight(Matrix.invert(matrix));
this._updateTransform();
return this;},
setMatrix:function(matrix,inverse){
this.matrix=new Matrix(matrix);
this.inverseMatrix=inverse||Matrix.invert(this.matrix);
this._updateTransform();
return this;},
getMatrix:function(){
return this.matrix;},
getInverseMatrix:function(){
return this.inverseMatrix;},
getRendererObject:function(){
return this.element;},
getSize:function(){
console.log("getSize")
throw Graphic.functionMustBeOverriden;},
setSize:function(width,height){
console.log("setSize")
throw Graphic.functionMustBeOverriden;},
getLocation:function(){
console.log("getLocation")
throw Graphic.functionMustBeOverriden;},
setLocation:function(x,y){
console.log("setLocation")
throw Graphic.functionMustBeOverriden;},
addComment:function(commentText){
var commentNode=this.renderer.addComment(this,commentText);
return this;},
_setAttributes:function(attributes){
this.attributes=Object.extend(this.attributes,attributes||{});
this.renderer.updateAttributes(this,attributes);
return this;},
_setAttribute:function(name,value){
var hash={}
hash[name]=value;
this._setAttributes(hash);
return this;},
_updateTransform:function(){
this._setAttributes({matrix:this.matrix.values().join(","),invmatrix:this.inverseMatrix.values().join(",")});
this.renderer.updateTransform(this);}})
Graphic.Rectangle=Class.create();
Object.extend(Graphic.Rectangle.prototype,Graphic.Shape.prototype);
Graphic.Rectangle.prototype._shapeInitialize=Graphic.Shape.prototype.initialize;
Object.extend(Graphic.Rectangle.prototype,{
initialize:function(renderer){
this._shapeInitialize(renderer,"rect");
Object.extend(this.attributes,{x:0,y:0,w:0,h:0,rx:0,ry:0});
return this;},
getSize:function(){
return{w:this.attributes.width,h:this.attributes.height}},
setSize:function(width,height){
this._setAttributes({width:width,height:height});
return this;},
getLocation:function(){
return{x:this.attributes.x,y:this.attributes.y}},
setLocation:function(x,y){
this._setAttributes({x:x,y:y});
return this;},
setRoundCorner:function(rx,ry){
rx=Math.max(0,rx);
ry=Math.max(0,ry);
if(!ry)
ry=rx;
this._setAttributes({rx:rx,ry:ry});
return this;},
getRoundCorner:function(rx,ry){
return{rx:this.attributes.rx,ry:this.attributes.ry}}})
Graphic.Ellipse=Class.create();
Object.extend(Graphic.Ellipse.prototype,Graphic.Shape.prototype);
Graphic.Ellipse.prototype._shapeInitialize=Graphic.Shape.prototype.initialize;
Object.extend(Graphic.Ellipse.prototype,{
initialize:function(renderer){
this._shapeInitialize(renderer,"ellipse");
Object.extend(this.attributes,{cx:0,cy:0,rx:0,ry:0})
return this;},
getSize:function(){
return{w:2*this.attributes.rx,h:2*this.attributes.ry}},
setSize:function(width,height){
var location=this.getLocation();
this._setAttributes({rx:width/2, ry: height/2});
this.setLocation(location.x,location.y);
return this;},
getLocation:function(){
return{x:this.attributes.cx-this.attributes.rx,y:this.attributes.cy-this.attributes.ry}},
setLocation:function(x,y){
this._setAttributes({cx:x+this.attributes.rx,cy:y+this.attributes.ry});
return this;}})
Graphic.Circle=Class.create();
Object.extend(Graphic.Circle.prototype,Graphic.Shape.prototype);
Graphic.Circle.prototype._parentInitialize=Graphic.Shape.prototype.initialize;
Object.extend(Graphic.Circle.prototype,{
initialize:function(renderer){
this._parentInitialize(renderer,"circle");
Object.extend(this.attributes,{cx:0,cy:0,r:0})
return this;},
getSize:function(){
return{w:2*this.attributes.r,h:2*this.attributes.r}},
setSize:function(width,height){
var location=this.getLocation();
this._setAttributes({r:Math.max(width,height)/2});
this.setLocation(location.x,location.y);
return this;},
getLocation:function(){
return{x:this.attributes.cx-this.attributes.r,y:this.attributes.cy-this.attributes.r}},
setLocation:function(x,y){
this._setAttributes({cx:x+this.attributes.r,cy:y+this.attributes.r});
return this;},
setCenter:function(cx,cy){
this._setAttributes({cx:cx,cy:cy});
return this;},
getCenter:function(){
return{cx:this.attributes.cx,cy:this.attributes.cy};},
setRadius:function(r){
this._setAttributes({r:r});
return this;},
getRadius:function(){
return this.attributes.r;}})
Graphic.Polyline=Class.create();
Object.extend(Graphic.Polyline.prototype,Graphic.Shape.prototype);
Graphic.Polyline.prototype._parentInitialize=Graphic.Shape.prototype.initialize;
Object.extend(Graphic.Polyline.prototype,{
initialize:function(renderer,type){
this._parentInitialize(renderer,type||"polyline");
Object.extend(this.attributes,{x:0,y:0,w:0,h:0});
this.points=new Array();
return this;},
addPoints:function(points){
points.each(function(p){this.points.push([p[0],p[1]])}.bind(this));
this._updatePath();
return this;},
setPoints:function(points){
this.points.clear();
this.addPoints(points)
return this;},
setPoint:function(x,y,index){
if(index<this.points.length){
this.points[index][0]=x;
this.points[index][1]=y;
this._updatePath();}
return this;},
addPoint:function(x,y,index){
if(index!=null&&!isNaN(index)&&index>=0&&index<this.points.length)
this.points.splice(index,0,[x,y]);
else
this.points.push([x,y]);
this._updatePath();
return this;},
getPoints:function(){
return this.points;},
getPoint:function(index){
return{x:this.points[index][0],y:this.points[index][1]};},
getNbPoints:function(){
return this.points.length;},
setSize:function(width,height){
var x0=this.x;
var y0=this.y;
var fx=width/this.w;
var fy=height/this.h;
this.points.each(function(p){
p[0]=(p[0]-this.x)*fx+this.x;
p[1]=(p[1]-this.y)*fy+this.y;}.bind(this));
this._updatePath();
return this;},
getSize:function(){
return{w:this.w,h:this.h}},
setLocation:function(x,y){
var dx=x-this.x;
var dy=y-this.y;
this.points.each(function(p){
p[0]+=dx;
p[1]+=dy;});
this._updatePath();
return this;},
getLocation:function(){
return{x:this.x,y:this.y}},
_updateBounds:function(){
var xmin=0,ymin=0,xmax=0,ymax=0;
if(this.points.length>0){
var xmin=parseFloat(this.points[0][0]),ymin=parseFloat(this.points[0][1]),
xmax=parseFloat(this.points[0][0]),ymax=parseFloat(this.points[0][1]);
xmin=parseFloat(xmin);
this.points.each(function(p){
p[0]=parseFloat(p[0]);
p[1]=parseFloat(p[1]);
if(p[0]<xmin)xmin=p[0];
if(p[0]>xmax)xmax=p[0];
if(p[1]<ymin)ymin=p[1];
if(p[1]>ymax)ymax=p[1];});
this.x=xmin;
this.y=ymin;
this.w=xmax-xmin;
this.h=ymax-ymin;}
else{
this.x=0;
this.y=0;
this.w=0;
this.h=0;};},
_updatePath:function(){
var path="";
this.points.each(function(p){path+=p[0]+" "+p[1]+","});
path=path.slice(0,path.length-1);
this._updateBounds();
this._setAttribute("points",path);}})
Graphic.Polygon=Class.create();
Object.extend(Graphic.Polygon.prototype,Graphic.Polyline.prototype);
Graphic.Polygon.prototype._polylineInitialize=Graphic.Polyline.prototype.initialize;
Object.extend(Graphic.Polygon.prototype,{
initialize:function(renderer){
this._polylineInitialize(renderer,"polygon");
return this;}})
Graphic.Line=Class.create();
Object.extend(Graphic.Line.prototype,Graphic.Shape.prototype);
Graphic.Line.prototype._parentInitialize=Graphic.Shape.prototype.initialize;
Object.extend(Graphic.Line.prototype,{
initialize:function(renderer){
this._parentInitialize(renderer,"line");
return this;},
getSize:function(){
return{w:Math.abs(this.attributes.x1-this.attributes.x2),h:Math.abs(this.attributes.y1-this.attributes.y2)}},
setSize:function(width,height){
return this;},
getLocation:function(){
return{x:Math.min(this.attributes.x1,this.attributes.x2),y:Math.min(this.attributes.y1,this.attributes.y2)}},
setLocation:function(x,y){
return this;},
setPoints:function(x1,y1,x2,y2){
this._setAttributes({x1:x1,y1:y1,x2:x2,y2:y2})
return this;},
getPoint:function(index){
if(index==0)
return{x:this.attributes.x1,y:this.attributes.y1}
else
return{x:this.attributes.x2,y:this.attributes.y2}}})
Graphic.Group=Class.create();
Object.extend(Graphic.Group.prototype,Graphic.Shape.prototype);
Graphic.Group.prototype._parentInitialize=Graphic.Shape.prototype.initialize;
Graphic.Group.prototype._parentPostTransform=Graphic.Shape.prototype.postTransform;
Graphic.Group.prototype._parentPreTransform=Graphic.Shape.prototype.preTransform;
Object.extend(Graphic.Group.prototype,{
initialize:function(renderer){
this._parentInitialize(renderer,"g");
this.children=new Array();
return this;},
destroy:function(){
this.children.each(function(e){
e.destroy();});
this.children.clear();
this.renderer.remove(this);},
add:function(shape){
var hasShape=this.children.find(function(s){return s==shape});
if(!hasShape){
this.children.push(shape);
shape.parent=this;
shape.originalMatrix=shape.matrix;
this.renderer.add(shape,this);}},
remove:function(shape){
var hasShape=this.children.find(function(s){return s==shape});
if(hasShape){
this.children=this.children.reject(function(s){return s==shape});
this.renderer.remove(shape);
shape.parent=null;}},
get:function(index){
return(index>=0&&index<this.children.length?this.children[index]:null);},
getNbELements:function(){
return this.children.length;},
getSize:function(){
if(this.getNbELements()==0)
return{w:0,h:0};
var first=this.children.first()
var bounds=(first.getBounds());
var xmin=bounds.x;
var ymin=bounds.y;
var xmax=bounds.x+bounds.w;
var ymax=bounds.y+bounds.h;
this.children.each(function(shape){
var bounds=(shape.getBounds());
xmin=Math.min(xmin,bounds.x);
xmax=Math.max(xmax,bounds.x+bounds.w);
ymin=Math.min(ymin,bounds.y);
ymax=Math.max(ymax,bounds.y+bounds.h);});
return{w:xmax-xmin,h:ymax-ymin};},
getLocation:function(){
if(this.getNbELements()==0)
return{x:0,y:0};
var first=this.children.first()
var bounds=(first.getBounds());
var xmin=bounds.x;
var ymin=bounds.y;
this.children.each(function(shape){
var bounds=(shape.getBounds());
xmin=Math.min(xmin,bounds.x);
ymin=Math.min(ymin,bounds.y);});
return{x:xmin,y:ymin};},
postTransform:function(matrix){
this._parentPostTransform(matrix);
this.children.each(function(shape){
shape.postTransform(matrix);});
return this;},
preTransform:function(matrix){
this._parentPreTransform(matrix);
this.children.each(function(shape){
shape.preTransform(matrix);});
return this;},
find:function(shapeId){
return this.children.find(function(s){return s.getID()==shapeId});},
findAll:function(shapeType){
return this.children.findAll(function(s){return s.getType()==shapeType});}})
Graphic.Text=Class.create();
Object.extend(Graphic.Text.prototype,Graphic.Shape.prototype);
Graphic.Text.prototype._parentInitialize=Graphic.Shape.prototype.initialize;
Object.extend(Graphic.Text.prototype,{
initialize:function(renderer){
this._parentInitialize(renderer,"text");
Object.extend(this.attributes,{x:0,y:0,'font-size':'10','font-family':'Veranda','font-weight':'normal'});
return this;},
getSize:function(){
return{fontSize:this.attributes['font-size'],fontWeight:this.attributes['font-weight']};},
setSize:function(fontSize,fontWeight){
this._setAttributes({'font-size':fontSize,'font-weight':fontWeight});
return this;},
getLocation:function(){
return{x:this.attributes.x,y:this.attributes.y}},
setLocation:function(x,y){
this._setAttributes({x:x,y:y});
return this;},
getFont:function(){
return{fontSize:this.attributes['font-size'],fontFamily:this.attributes['font-family'],fontWeight:this.attributes['font-weight']};},
setFont:function(size,family,weight){
if(size){
this._setAttribute('font-size',size);}
if(family){
this._setAttribute('font-family',family);}
if(weight){
this._setAttribute('font-weight',weight);}
return this;},
setTextValue:function(textValue){
this.renderer.addText(this,textValue);
return this;}})
Graphic.Image=Class.create();
Object.extend(Graphic.Image.prototype,Graphic.Rectangle.prototype);
Graphic.Image.prototype._shapeInitialize=Graphic.Shape.prototype.initialize;
Object.extend(Graphic.Image.prototype,{
initialize:function(renderer,image){
this._shapeInitialize(renderer,"image");
Object.extend(this.attributes,{x:0,y:0,width:0,height:0});
return this;},
setSource:function(url,autoSize){
if(autoSize){
this.image=new Image();
this.image.src=url;
Event.observe(this.image,"load",function(){
this.setSize(this.image.width,this.image.height);
this._setAttribute('href',url);}.bind(this));}
else
this._setAttribute('href',url);
return this;}});
Graphic.Tool=Class.create();
Graphic.Tool.prototype={
activate:function(manager){},
unactivate:function(manager){},
clear:function(manager){},
initDrag:function(x,y,event){},
drag:function(x,y,dx,dy,ddx,ddy,event){},
endDrag:function(x,y,event){},
mouseMove:function(x,y,event){},
click:function(x,y,event){},
doubleClick:function(x,y,event){},
keyUp:function(keyCode,event){},
keyDown:function(keyCode,event){},
mouseOver:function(x,y,event){},
mouseOut:function(event){}}
Graphic.ToolManager=Class.create();
Graphic.ToolManager.prototype={
initialize:function(renderer){
this.renderer=renderer;
this.element=renderer.element.parentNode;
this.currentTool=null;
this.eventMappings=$A([[this.element,"mousedown",this.mouseDown],[this.element,"click",this.click],[this.element,"dblclick",this.doubleClick],[document,"mousemove",this.mouseMove],[document,"mouseup",this.mouseUp],[document,"keyup",this.keyUp],[document,"keydown",this.keyDown],[this.element,"mouseover",this.mouseOver],[this.element,"mouseout",this.mouseOut]]);
this.eventMappings.each(function(eventMap){
eventMap.push(eventMap[2].bindAsEventListener(this))
Event.observe($(eventMap[0]),eventMap[1],eventMap[3]);}.bind(this));
this.offset=Position.cumulativeOffset(this.element);
this.dimension=$(this.element).getDimensions();},
destroy:function(){
this.currentTool.unactivate();
this.currentTool=null;
this.eventMappings.each(function(eventMap){
Event.stopObserving($(eventMap[0]),eventMap[1],eventMap[3]);});
this.eventMappings.clear();},
setRenderer:function(renderer){
this.renderer=renderer;
this.setTool(this.currentTool);},
setTool:function(tool){
if(this.currentTool&&this.currentTool.unactivate)
this.currentTool.unactivate(this);
this.currentTool=tool;
if(this.currentTool&&this.currentTool.activate)
this.currentTool.activate(this);},
getTool:function(){
return this.currentTool;},
doubleClick:function(event){
if(this.currentTool==null)
return;
this.offset=Position.page(this.element);
var x=this._getX(event);
var y=this._getY(event);
this.currentTool.doubleClick(x,y,event);
Event.stop(event);},
click:function(event){
if(this.currentTool==null)
return;
this.offset=Position.page(this.element);
var x=this._getX(event);
var y=this._getY(event);
this.currentTool.click(x,y,event);
Event.stop(event);},
mouseDown:function(event){
if(this.currentTool==null)
return;
if(!Event.isLeftClick(event))
return;
this.offset=Position.page(this.element);
this.xi=this._getX(event);
this.yi=this._getY(event);
this.xlast=this.xi;
this.ylast=this.yi;
this.currentTool.initDrag(this.xi,this.yi,event);
this.isDragging=true;
disableSelection();
Event.stop(event);},
mouseMove:function(event){
if(this.currentTool==null)
return;
var x=this._getX(event);
var y=this._getY(event);
if(this.isDragging){
var dx=x-this.xi;
var dy=y-this.yi;
var ddx=x-this.xlast;
var ddy=y-this.ylast;
var org=this.renderer.viewingMatrix.multiplyPoint(0,0);
var pt=this.renderer.viewingMatrix.multiplyPoint(ddx,ddy);
ddx=pt.x-org.x;
ddy=pt.y-org.y;
var pt=this.renderer.viewingMatrix.multiplyPoint(dx,dy);
dx=pt.x-org.x;
dy=pt.y-org.y;
this.xlast=x;
this.ylast=y;
this.currentTool.drag(x,y,dx,dy,ddx,ddy,event);}
else
if(this.currentTool.mouseMove)
this.currentTool.mouseMove(x,y,event);
Event.stop(event);},
mouseUp:function(event){
if(this.currentTool==null)
return;
if(!this.isDragging)
return false;
var x=this._getX(event);
var y=this._getY(event);
this.isDragging=false;
this.currentTool.endDrag(x,y,event);
enableSelection();
Event.stop(event);},
keyUp:function(event){
if(this.currentTool==null)
return;
var keyCode=event.keyCode||event.which
if(this.currentTool.keyUp(keyCode,event))
Event.stop(event);},
keyDown:function(event){
if(this.currentTool==null)
return;
var keyCode=event.keyCode||event.which
if(this.currentTool.keyDown(keyCode,event))
Event.stop(event);},
mouseOver:function(event){
if(this.currentTool==null)
return;
var x=this._getX(event);
var y=this._getY(event);
this.currentTool.mouseOver(x,y,event);
Event.stop(event);},
mouseOut:function(event){
if(this.currentTool==null)
return;
this.currentTool.mouseOut(event);
Event.stop(event);},
scrollX:function(){
var page=Position.page(this.element);
var offset=Position.cumulativeOffset(this.element);
return offset[0]-page[0];},
scrollY:function(){
var page=Position.page(this.element);
var offset=Position.cumulativeOffset(this.element);
return offset[1]-page[1];},
_getX:function(event){
this.dimension=$(this.element).getDimensions();
var scroll=getWindowScroll(window);
var x=Event.pointerX(event)-this.offset[0]-scroll.left;
if(x<0)
x=0;
if(x>this.dimension.width)
x=this.dimension.width;
return x;},
_getY:function(event){
this.dimension=$(this.element).getDimensions();
var scroll=getWindowScroll(window);
var y=Event.pointerY(event)-this.offset[1]-scroll.top;
if(y<0)
y=0;
if(y>this.dimension.height)
y=this.dimension.height;
return y;}}
Graphic.SelectTool=Class.create();
Object.extend(Graphic.SelectTool.prototype,Graphic.Tool.prototype);
Object.extend(Graphic.SelectTool.prototype,{
initialize:function(){
this.renderer=null;
this.shape=null;},
activate:function(manager){
this.renderer=manager.renderer;},
unactivate:function(manager){
this.renderer=null;},
initDrag:function(x,y,event){
this.shape=this.renderer.pick(event);
if(this.shape&&this.shape.notSelectable)
this.shape=null;
if(this.shape){
this.shape.moveToFront();
this.x=x;
this.y=y;
this.renderer.draw();}},
drag:function(x,y,dx,dy,ddx,ddy,event){
if(this.shape){
this.shape.preTransform(Matrix.translate(ddx,ddy));
this.renderer.draw();}},
endDrag:function(x,y,event){
if(this.shape){
EventNotifier.send(this,"shapeHasBeenMoved",{shape:this.shape,dx:x-this.x,dy:y-this.y});
this.shape=null;}},
mouseMove:function(x,y,event){}});
Graphic.DrawingTool=Class.create();
Object.extend(Graphic.DrawingTool.prototype,Graphic.Tool.prototype);
Object.extend(Graphic.DrawingTool.prototype,{
initialize:function(){
this.renderer=null;
this.shape=null;},
activate:function(manager){
this.renderer=manager.renderer;},
unactivate:function(manager){
this.renderer=null;},
initDrag:function(x,y,event){
this.polyline=new Graphic.Polyline(this.renderer);
this.polyline.setStroke(this._randomStroke());
this.polyline.addPoint(x,y);
this.renderer.add(this.polyline)
this.renderer.draw();},
drag:function(x,y,dx,dy,ddx,ddy,event){
if(this.polyline){
this.polyline.addPoint(x,y);
this.renderer.draw();}},
endDrag:function(x,y,event){
if(this.polyline){
this.polyline=null;}},
mouseMove:function(x,y,event){},
_randomStroke:function(){
var r=Math.floor(255*Math.random());
var g=Math.floor(255*Math.random());
var b=Math.floor(255*Math.random());
var a=128+Math.floor(128*Math.random());
var w=5+Math.floor(5*Math.random());
return{r:r,g:g,b:b,a:a,w:w}}});
Graphic.HighlightTool=Class.create();
Object.extend(Graphic.HighlightTool.prototype,Graphic.Tool.prototype);
Object.extend(Graphic.HighlightTool.prototype,{
initialize:function(groupId){
this.renderer=null;
this.shape=null;
this.groupId=groupId;},
activate:function(manager){
this.renderer=manager.renderer;},
unactivate:function(manager){
this.renderer=null;},
click:function(x,y,event){
this.shape=this.renderer.pick(event);
if(this.shape){
if(!this.groupId||$A($(this.groupId).childNodes).indexOf(this.shape.element)!=-1){
EventNotifier.send(this,"shapeHasBeenClicked",{shape:this.shape,x:Event.pointerX(event),y:Event.pointerY(event)});}}},
doubleClick:function(x,y,event){
this.shape=this.renderer.pick(event);
if(this.shape){
if(!this.groupId||$A($(this.groupId).childNodes).indexOf(this.shape.element)!=-1){
EventNotifier.send(this,"shapeHasBeenDoubleClicked",{shape:this.shape,x:Event.pointerX(event),y:Event.pointerY(event)});}}},
mouseOver:function(x,y,event){
this.shape=this.renderer.pick(event);
if(this.shape){
if(!this.groupId||$A($(this.groupId).childNodes).indexOf(this.shape.element)!=-1){
switch(this.shape.element.nodeName){
case 'line':
case 'polyline':
case 'shape':
case 'text':
var originalItemColor=this.shape.getStroke();
break;
default:
var originalItemColor=this.shape.getFill();}
if(originalItemColor.indexOf("rgb")==0){
originalItemColor=originalItemColor.substring(4,originalItemColor.length-1);
originalItemColor=originalItemColor.split(',');
originalItemColor={r:originalItemColor[0],g:originalItemColor[1],b:originalItemColor[2]};
originalItemColor.a=(this.shape.getFillOpacity()*255);
originalItemColor.w=(this.shape.getStrokeWidth());
Graphic.HighlightTool.highlightColor.w=this.shape.getStrokeWidth();}
this.shape.originalItemColor=originalItemColor;
switch(this.shape.element.nodeName){
case 'line':
case 'polyline':
case 'shape':
case 'text':
this.shape.setStroke(Graphic.HighlightTool.highlightColor);
break;
default:
this.shape.setFill(Graphic.HighlightTool.highlightColor);}
this.renderer.draw();
EventNotifier.send(this,"shapeHasBeenHighlighted",{shape:this.shape,x:Event.pointerX(event),y:Event.pointerY(event)});}}},
mouseOut:function(event){
this.shape=this.renderer.pick(event);
if(this.shape){
if(!this.groupId||$A($(this.groupId).childNodes).indexOf(this.shape.element)!=-1){
switch(this.shape.element.nodeName){
case 'line':
case 'polyline':
case 'shape':
case 'text':
this.shape.setStroke(this.shape.originalItemColor);
break;
default:
this.shape.setFill(this.shape.originalItemColor);}
this.renderer.draw();
EventNotifier.send(this,"shapeHasBeenUnHighlighted",{shape:this.shape});}}}});
Graphic.HighlightTool.highlightColor={r:204,g:227,b:255,a:0};
var agt=navigator.userAgent.toLowerCase();
var is_major=parseInt(navigator.appVersion);
var is_minor=parseFloat(navigator.appVersion);
var is_nav=((agt.indexOf('mozilla')!=-1)&&(agt.indexOf('spoofer')==-1)&&(agt.indexOf('compatible')==-1)&&(agt.indexOf('opera')==-1)&&(agt.indexOf('webtv')==-1)&&(agt.indexOf('hotjava')==-1));
var is_nav2=(is_nav&&(is_major==2));
var is_nav3=(is_nav&&(is_major==3));
var is_nav4=(is_nav&&(is_major==4));
var is_nav4up=(is_nav&&(is_major>=4));
var is_navonly=(is_nav&&((agt.indexOf(";nav")!=-1)||(agt.indexOf("; nav")!=-1)));
var is_nav6=(is_nav&&(is_major==5));
var is_nav6up=(is_nav&&(is_major>=5));
var is_gecko=(agt.indexOf('gecko')!=-1);
var is_ie=((agt.indexOf("msie")!=-1)&&(agt.indexOf("opera")==-1));
var ie=((agt.indexOf("msie")!=-1)&&(agt.indexOf("opera")==-1));
var is_ie3=(is_ie&&(is_major<4));
var is_ie4=(is_ie&&(is_major==4)&&(agt.indexOf("msie 4")!=-1));
var is_ie4up=(is_ie&&(is_major>=4));
var is_ie5=(is_ie&&(is_major==4)&&(agt.indexOf("msie 5.0")!=-1));
var is_ie5_5=(is_ie&&(is_major==4)&&(agt.indexOf("msie 5.5")!=-1));
var is_ie5up=(is_ie&&!is_ie3&&!is_ie4);
var is_ie5_5up=(is_ie&&!is_ie3&&!is_ie4&&!is_ie5);
var is_ie6=(is_ie&&(is_major==4)&&(agt.indexOf("msie 6.")!=-1));
var is_ie6up=(is_ie&&!is_ie3&&!is_ie4&&!is_ie5&&!is_ie5_5);
var is_ie7=(is_ie&&(is_major==4)&&(agt.indexOf("msie 7.")!=-1));
var is_aol=(agt.indexOf("aol")!=-1);
var is_aol3=(is_aol&&is_ie3);
var is_aol4=(is_aol&&is_ie4);
var is_aol5=(agt.indexOf("aol 5")!=-1);
var is_aol6=(agt.indexOf("aol 6")!=-1);
var is_opera=(agt.indexOf("opera")!=-1);
var is_opera2=(agt.indexOf("opera 2")!=-1||agt.indexOf("opera/2")!=-1);
var is_opera3=(agt.indexOf("opera 3")!=-1||agt.indexOf("opera/3")!=-1);
var is_opera4=(agt.indexOf("opera 4")!=-1||agt.indexOf("opera/4")!=-1);
var is_opera5=(agt.indexOf("opera 5")!=-1||agt.indexOf("opera/5")!=-1);
var is_opera5up=(is_opera&&!is_opera2&&!is_opera3&&!is_opera4);
var is_webtv=(agt.indexOf("webtv")!=-1);
var is_TVNavigator=((agt.indexOf("navio")!=-1)||(agt.indexOf("navio_aoltv")!=-1));
var is_AOLTV=is_TVNavigator;
var is_hotjava=(agt.indexOf("hotjava")!=-1);
var is_hotjava3=(is_hotjava&&(is_major==3));
var is_hotjava3up=(is_hotjava&&(is_major>=3));
function setCookie(_1,_2,_3,_4,_5,_6){
document.cookie=_1+"="+escape(_2)+((_3)?"; expires="+_3.toGMTString():"")+((_4)?"; path="+_4:"")+((_5)?"; domain="+_5:"")+((_6)?"; secure":"");}
function getCookie(_7){
var dc=document.cookie;
var _9=_7+"=";
var _a=dc.indexOf("; "+_9);
if(_a==-1){
_a=dc.indexOf(_9);
if(_a!=0){
return null;}}else{
_a+=2;}
var _b=document.cookie.indexOf(";",_a);
if(_b==-1){
_b=dc.length;}
return unescape(dc.substring(_a+_9.length,_b));}
function deleteCookie(_c,_d,_e){
if(getCookie(_c)){
document.cookie=_c+"="+((_d)?"; path="+_d:"")+((_e)?"; domain="+_e:"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT";}}
function testGetDNS(){
cookieDomain=document.location.hostname;}
function testGetCookie(){
var _f="varCook";
if(document.cookie.indexOf(_f)==-1){
return false;}else{
cookieStart=document.cookie.indexOf(_f);
cookieValStart=(document.cookie.indexOf("=",cookieStart)+1);
cookieValEnd=document.cookie.indexOf(";",cookieStart);
if(cookieValEnd==-1){
cookieValEnd=document.cookie.length;}
cookieValue=document.cookie.substring(cookieValStart,cookieValEnd);}
if(cookieValue="True"){
return("True");}}
function testSetCookie(_10,_11,_12,_13,_14,_15){
var _16=testGetDNS();
document.cookie=_10+"="+escape(_11)+((_12)?";expires="+_12.toGMTString()+1000*60*20:"")+((_13)?";path="+_13:"")+((_14)?";domain="+_16:"")+((_15)?";secure":"");
return true;}
function CheckCookiesEnabled(){
testSetCookie("varCook","True","","/","","");
if(testGetCookie()=="True"){
return true;}else{
return false;}}
var Drag={enable:true,obj:null,init:function(o,_18,_19,_1a,_1b,_1c,_1d,_1e,_1f,_20){
o.onmousedown=Drag.start;
o.hmode=_1d?false:true;
o.vmode=_1e?false:true;
o.root=_18&&_18!=null?_18:o;
if(o.hmode&&isNaN(parseInt(o.root.style.left))){
o.root.style.left="0px";}
if(o.vmode&&isNaN(parseInt(o.root.style.top))){
o.root.style.top="0px";}
if(!o.hmode&&isNaN(parseInt(o.root.style.right))){
o.root.style.right="0px";}
if(!o.vmode&&isNaN(parseInt(o.root.style.bottom))){
o.root.style.bottom="0px";}
o.minX=typeof _19!="undefined"?_19:null;
o.minY=typeof _1b!="undefined"?_1b:null;
o.maxX=typeof _1a!="undefined"?_1a:null;
o.maxY=typeof _1c!="undefined"?_1c:null;
o.xMapper=_1f?_1f:null;
o.yMapper=_20?_20:null;
o.root.onDragStart=new Function();
o.root.onDragEnd=new Function();
o.root.onDrag=new Function();},start:function(e){
var o=Drag.obj=this;
e=Drag.fixE(e);
var y=parseInt(o.root.offsetTop);
var x=parseInt(o.root.offsetLeft);
o.root.onDragStart(e,x,y);
o.lastMouseX=e.clientX;
o.lastMouseY=e.clientY;
document.onmousemove=Drag.drag;
document.onmouseup=Drag.end;
var evt=e?e:window.event;
var src=(evt.target)?evt.target:evt.srcElement;
o.drag_src=src;
if(is_ie)
return false;
else{
if(o.drag_src.tagName=="INPUT"||o.drag_src.tagName=="TEXTAREA")
return;
else
return false;}},drag:function(e){
try{
e=Drag.fixE(e);
var o=Drag.obj;
var ey=e.clientY;
var ex=e.clientX;
var y=parseInt(o.root.offsetTop);
var x=parseInt(o.root.offsetLeft);
var nx,ny;
nx=x+(ex-o.lastMouseX);
ny=y+(ey-o.lastMouseY);
Drag.obj.root.style.left=nx+"px";
Drag.obj.root.style.top=ny+"px";
Drag.obj.lastMouseX=ex;
Drag.obj.lastMouseY=ey;
Drag.obj.root.onDrag(e,nx,ny);
return false;
if(is_ie)
return false;
else{
if(o.drag_src.tagName=="INPUT"||o.drag_src.tagName=="TEXTAREA")
return;
else
return false;}}
catch(e){}},end:function(){
try{
document.onmousemove=null;
document.onmouseup=null;
Drag.obj.root.onDragEnd(parseInt(Drag.obj.root.style[Drag.obj.hmode?"left":"right"]),parseInt(Drag.obj.root.style[Drag.obj.vmode?"top":"bottom"]));
Drag.obj=null;}
catch(e){}},fixE:function(evt){
var e=evt?evt:window.event;
return e;}};
var Drag2={obj:null,init:function(o,_2f,_30,_31,_32,_33,_34,_35,_36,_37){
o.onmousedown=Drag2.start;
o.hmode=_34?false:true;
o.vmode=_35?false:true;
o.root=_2f&&_2f!=null?_2f:o;
if(o.hmode&&isNaN(parseInt(o.root.style.left))){
o.root.style.left="0px";}
if(o.vmode&&isNaN(parseInt(o.root.style.top))){
o.root.style.top="0px";}
if(!o.hmode&&isNaN(parseInt(o.root.style.right))){
o.root.style.right="0px";}
if(!o.vmode&&isNaN(parseInt(o.root.style.bottom))){
o.root.style.bottom="0px";}
o.minX=typeof _30!="undefined"?_30:null;
o.minY=typeof _32!="undefined"?_32:null;
o.maxX=typeof _31!="undefined"?_31:null;
o.maxY=typeof _33!="undefined"?_33:null;
o.xMapper=_36?_36:null;
o.yMapper=_37?_37:null;
o.root.onDragStart=new Function();
o.root.onDragEnd=new Function();
o.root.onDrag=new Function();},start:function(e){
var o=Drag2.obj=this;
e=Drag2.fixE(e);
var y=parseInt(o.vmode?o.root.style.top:o.root.style.bottom);
var x=parseInt(o.hmode?o.root.style.left:o.root.style.right);
o.root.onDragStart(e,x,y);
o.lastMouseX=e.clientX;
o.lastMouseY=e.clientY;
if(o.hmode){
if(o.minX!=null){
o.minMouseX=e.clientX-x+o.minX;}
if(o.maxX!=null){
o.maxMouseX=o.minMouseX+o.maxX-o.minX;}}else{
if(o.minX!=null){
o.maxMouseX=-o.minX+e.clientX+x;}
if(o.maxX!=null){
o.minMouseX=-o.maxX+e.clientX+x;}}
if(o.vmode){
if(o.minY!=null){
o.minMouseY=e.clientY-y+o.minY;}
if(o.maxY!=null){
o.maxMouseY=o.minMouseY+o.maxY-o.minY;}}else{
if(o.minY!=null){
o.maxMouseY=-o.minY+e.clientY+y;}
if(o.maxY!=null){
o.minMouseY=-o.maxY+e.clientY+y;}}
document.onmousemove=Drag2.drag;
document.onmouseup=Drag2.end;
return false;},drag:function(e){
e=Drag2.fixE(e);
var o=Drag2.obj;
var ey=e.clientY;
var ex=e.clientX;
var y=parseInt(o.vmode?o.root.style.top:o.root.style.bottom);
var x=parseInt(o.hmode?o.root.style.left:o.root.style.right);
var nx,ny;
if(o.minX!=null){
ex=o.hmode?Math.max(ex,o.minMouseX):Math.min(ex,o.maxMouseX);}
if(o.maxX!=null){
ex=o.hmode?Math.min(ex,o.maxMouseX):Math.max(ex,o.minMouseX);}
if(o.minY!=null){
ey=o.vmode?Math.max(ey,o.minMouseY):Math.min(ey,o.maxMouseY);}
if(o.maxY!=null){
ey=o.vmode?Math.min(ey,o.maxMouseY):Math.max(ey,o.minMouseY);}
nx=x+((ex-o.lastMouseX)*(o.hmode?1:-1));
ny=y+((ey-o.lastMouseY)*(o.vmode?1:-1));
if(o.xMapper){
nx=o.xMapper(y);}else{
if(o.yMapper){
ny=o.yMapper(x);}}
Drag2.obj.root.style[o.hmode?"left":"right"]=nx+"px";
Drag2.obj.root.style[o.vmode?"top":"bottom"]=ny+"px";
Drag2.obj.lastMouseX=ex;
Drag2.obj.lastMouseY=ey;
Drag2.obj.root.onDrag(e,nx,ny);
return false;},end:function(){
document.onmousemove=null;
document.onmouseup=null;
Drag2.obj.root.onDragEnd(parseInt(Drag2.obj.root.style[Drag2.obj.hmode?"left":"right"]),parseInt(Drag2.obj.root.style[Drag2.obj.vmode?"top":"bottom"]));
Drag2.obj=null;},fixE:function(e){
if(typeof e=="undefined"){
e=window.event;}
if(typeof e.layerX=="undefined"){
e.layerX=e.offsetX;}
if(typeof e.layerY=="undefined"){
e.layerY=e.offsetY;}
return e;}};
function enable_select(){
if(!ie){
var _44=["input","textarea","select"];
_44=_44.join("|");
function disableselect(e){
if(_44.indexOf(e.target.tagName.toLowerCase())==-1){
return false;}}
function reEnable(){
return true;}
if(typeof document.onselectstart!="undefined"){
document.onselectstart=new Function("return true");}else{
document.onmousedown=reEnable;
document.onmouseup=reEnable;}}else{
document.body.onselectstart=function(){
return true;};}}
function disable_select(){
if(!ie){
var _46=["input","textarea","select"];
_46=_46.join("|");
function disableselect(e){
if(_46.indexOf(e.target.tagName.toLowerCase())==-1){
return false;}}
function reEnable(){
return true;}
if(typeof document.onselectstart!="undefined"){
document.onselectstart=new Function("return false");}else{
document.onmousedown=disableselect;
document.onmouseup=reEnable;}}else{
document.body.onselectstart=function(){
return false;};}}
var skin1={"Drager":["images/dicon.gif","19","18"],"toRight":["images/to_right2.gif","24","19"],"toLeft":["images/to_left2.gif","24","19"],"DragBackground":["#CCCCCC","color"]};
var skin2={"Drager":["images/skin2drager.gif","22","19"],"toRight":["images/to_right2.gif","24","19"],"toLeft":["images/to_left2.gif","24","19"],"DragBackground":["images/skin2bg.gif","gif"]};
var SliderX=Class.create();
SliderX.prototype={id:"",out_obj:null,action:"",is_ie:false,tx:0,ty:0,draw_htm:"",slider_width:150,slider_height:150,with_slide_but:true,init_left:0,max_val:100,min_val:0,current_val:0,interval:1,max_x:0,max_y:0,min_x:0,min_y:0,slider_tbl:null,slider_obj:null,skin:skin2,target_layer:"",drag_obj:null,draging:false,timeout:null,slider_cur_inst:null,getEvt:function(evt){
var e=evt?evt:window.event;
var src=((ie)?e.srcElement:e.target);
return[e,src];},getOffset:function(obj,_4c){
var _4d=0;
while(obj!=null){
_4d+=obj["offset"+(_4c?"Left":"Top")];
obj=obj.offsetParent;}
return _4d;},initialize:function(_4e,_4f,_50,_51,_52,_53,_54){
this.transform_timeout=null;
this.img_plus=new Image(21,20);
this.img_plus.src="images/slider_img/z_b.gif";
this.img_minus=new Image(21,20);
this.img_minus.src="images/slider_img/z_t.gif";
this.parent=_4f;
this.margin_left=this.getOffset(this.parent.parent.container,true);
this.margin_top=this.getOffset(this.parent.parent.container,false);
this.target_layer=_4e;
this.is_ie=ie;
if(_51!=null){
this.max_val=_51;}
if(_52!=null){
this.min_val=_52;}
if(this.max_val<this.min_val){
var t_v=this.max_val;
this.max_val=this.min_val;
this.min_val=t_v;}
this.slider_height=_50;
this.draw();
this.slider_tbl=$(this.target_layer.id+"_drag_container");
this.slider_obj=$(this.target_layer.id+"_drag_icon");
this.tx=this.getOffset(this.slider_tbl,true)-this.margin_left;
this.ty=this.getOffset(this.slider_tbl,false)-this.margin_top;
this.min_x=this.tx+2;
this.min_y=this.ty+8;
this.max_x=this.tx+2;
this.max_y=this.ty+parseInt(this.slider_tbl.offsetHeight)-parseInt(this.slider_obj.offsetHeight)-8;
Drag2.init(this.slider_obj,null,this.min_x,this.max_x,this.min_y,this.max_y);
this.slider_obj.onDragStart=this.onDragStartEvent.bind(this);
this.slider_obj.onDrag=this.onDragEvent.bind(this);
this.slider_obj.onDragEnd=this.onDragEndEvent.bind(this);
this.set_val(_54);},onDragStartEvent:function(evt,ex,ey){
this.draging=true;
var e=this.getEvt(evt);},onDragEvent:function(evt,ex,ey){
this.get_val();},onDragEndEvent:function(ex,ey){
this.set_val(this.current_val);
this.parent.mapChangeZoomLevel(this.current_val);},get_val:function(){
var l=this.getOffset(this.slider_obj,true)-this.margin_left;
var t=this.getOffset(this.slider_obj,false)-6-this.margin_top;
if(t>this.min_y){
var p1=((t-this.min_y)/(this.max_y-this.min_y));}else{
var p1=0;}
var p2=(this.max_val-this.min_val)*(p1);
var p3=this.min_val+p2;
if(p3%this.interval!=0){
this.current_val=p3+(this.interval-(p3%this.interval));}else{
this.current_val=p3;}},afterSetVal:function(){
if((this.tmp_new_top+this.drag_icon_obj.offsetHeight)>(this.getOffset(this.parent.parent.container)+this.parent.parent.container.offsetHeight)){
this.drag_icon_obj.style.visibility="hidden";}else{
this.drag_icon_obj.style.visibility="visible";}},set_val:function(val,_65){
var tv=parseInt(val);
if(tv<this.min_val){
tv=this.min_val;}
if(tv>this.max_val){
tv=this.max_val;}
var p1=(tv-this.min_val)/(this.max_val-this.min_val);
var p2=(this.max_y-this.min_y)*p1;
var p3=Math.floor(p2)+this.min_y;
this.tmp_new_top=p3;
this.current_val=tv;
this.transformLayer(this.getOffset(this.slider_obj,true),(this.tmp_new_top),this.slider_obj,10,10);},reset_drager:function(){
this.margin_left=this.getOffset(this.parent.parent.container,true);
this.margin_top=this.getOffset(this.parent.parent.container,false);
$(this.target_layer.id+"_drag_icon").style.left=(this.getOffset($(this.target_layer.id+"_drag_container"),true)+2-this.margin_left)+"px";
$(this.target_layer.id+"_drag_icon").style.top=(this.getOffset($(this.target_layer.id+"_drag_container"),false)-this.margin_top)+"px";
this.set_val(this.current_val);
this.tx=this.getOffset(this.slider_tbl,true)-this.margin_left;
this.ty=this.getOffset(this.slider_tbl,false)-this.margin_top;
this.min_x=this.tx+2;
this.min_y=this.ty+8;
this.max_x=this.tx+2;
this.max_y=this.ty+parseInt(this.slider_tbl.offsetHeight)-parseInt(this.slider_obj.offsetHeight)-8;
this.slider_obj.minX=this.min_x;
this.slider_obj.minY=this.min_y;
this.slider_obj.maxX=this.max_x;
this.slider_obj.maxY=this.max_y;},zoom_in:function(){
this.set_val(this.current_val+1);
this.parent.mapChangeZoomLevel(this.current_val);},zoom_out:function(){
this.set_val(this.current_val-1);
this.parent.mapChangeZoomLevel(this.current_val);},refreshPos:function(){
if(this.tout!=null){
clearTimeout(this.tout);}
this.reset_drager();},draw:function(){
if(typeof(this.target_layer)=="undefined"||this.target_layer==null){
return;}
var str="";
var _6b=this.slider_height;
if(this.with_slide_but){
_6b=_6b+40;}
str+="<table id=\""+this.target_layer.id+"_drag_table\" width=\"21\" height=\""+_6b+"\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
str+="  <tr>";
str+="    <td height=\"20px\"><img id=\""+this.target_layer.id+"_zoom_out\" src=\""+this.img_minus.src+"\" width=\"21\" height=\"20\"></td>";
str+="  </tr>";
str+="  <tr>";
str+="    <td height=\""+(_6b-40)+"px\" id=\""+this.target_layer.id+"_drag_container\" align=\"center\" valign=\"middle\" style=\"border:1px #999999 solid;background-color:#FFFFFF;padding-top:5px;padding-bottom:5px\">";
str+="\t<div style=\"background-color:#999999;width:25%;height:100%\">&nbsp;</div>";
str+="\t</td>";
str+="  </tr>";
str+="  <tr>";
str+="    <td height=\"20\"><img id=\""+this.target_layer.id+"_zoom_in\" src=\""+this.img_plus.src+"\" width=\"21\" height=\"20\"></td>";
str+="  </tr>";
str+="</table>";
this.draw_htm=str;
this.target_layer.innerHTML=str;
$(this.target_layer.id+"_zoom_out").onclick=this.zoom_out.bindAsEventListener(this);
$(this.target_layer.id+"_zoom_out").style.cursor="pointer";
$(this.target_layer.id+"_zoom_in").onclick=this.zoom_in.bindAsEventListener(this);
$(this.target_layer.id+"_zoom_in").style.cursor="pointer";
$(this.target_layer.id+"_drag_container").onclick=this.getClickAction.bindAsEventListener(this);
$(this.target_layer.id+"_drag_container").style.cursor="pointer";
this.drag_icon_obj=document.createElement("div");
this.drag_icon_obj.id=this.target_layer.id+"_drag_icon";
this.drag_icon_obj.style.position="absolute";
this.drag_icon_obj.style.cursor="pointer";
this.drag_icon_obj.style.overflow="hidden";
if(this.is_ie){
this.drag_icon_obj.style.width=(21-4)+"px";}else{
this.drag_icon_obj.style.width=(21-6)+"px";}
this.drag_icon_obj.style.height="10px";
this.drag_icon_obj.style.border="1px #999999 solid";
this.drag_icon_obj.style.zIndex="15000";
this.drag_icon_obj.style.backgroundColor="#FFD966";
this.drag_icon_obj.style.left=(this.getOffset($(this.target_layer.id+"_drag_container"),true)-this.margin_left+2)+"px";
this.drag_icon_obj.style.top="0px";
this.parent.parent.container.appendChild(this.drag_icon_obj);},getClickAction:function(evt){
e=this.getEvt(evt);
var l=parseInt(e[0].clientX)-this.margin_left;
var t=parseInt(e[0].clientY)-6-this.margin_top;
if(t>this.min_y){
var p1=((t-this.min_y)/(this.max_y-this.min_y));}else{
var p1=0;}
var p2=(this.max_val-this.min_val)*(p1);
var p3=this.min_val+p2;
var _72=-100;
if(p3%this.interval!=0){
_72=p3+(this.interval-(p3%this.interval));}else{
_72=p3;}
this.set_val(_72,true);
this.parent.mapChangeZoomLevel(this.current_val);},transformLayer:function(x,y,obj,_76,_77){
if(this.transform_timeout!=null){
clearTimeout(this.transform_timeout);}
this.x1=obj.offsetLeft;
this.y1=obj.offsetTop;
this.x2=(this.x1+parseInt(obj.offsetWidth));
this.y2=(this.y1+parseInt(obj.offsetHeight));
stepDuration=Math.round(_76/_77);
tx1=this.x1;
ty1=this.y1;
x=(x)?x:tx1;
y=(y)?y:ty1;
difX=(x-tx1)/_77;
difY=(y-ty1)/_77;
tx1+=difX;
ty1+=difY;
if(!isNaN(tx1)&&!isNaN(ty1)&&tx1!="Infinity"&&ty1!="Infinity"&&tx1!="-Infinity"&&ty1!="-Infinity"){
obj.style.top=ty1+"px";}
_76=(_76-stepDuration);
_77--;
if(_77>=0){
this.transform_timeout=setTimeout((function(){
this.transformLayer(x,y,obj,_76,_77);}).bind(this),stepDuration);}else{
if(this.transform_timeout!=null){
clearTimeout(this.transform_timeout);}
this.afterSetVal(this.tmp_new_top);}
return true;}};
var CONST_MAP_TILE_LIB=["http://map.hongkonghomes.com/map2/util/get_tile_test.php"];
var DEFAULT_MAP_ICON_IMG=new Image(22,22);
DEFAULT_MAP_ICON_IMG.src=CONST_IMG_PATH+"images/default_map_point.gif";
Array.prototype.sum=function(){
for(var i=0,sum=0;i<this.length;sum+=this[i++]);
return sum;}
Array.prototype.max=function(){
return Math.max.apply({},this)}
Array.prototype.min=function(){
return Math.min.apply({},this)}
function __set_obj_status(obj){
try{
obj.blur();
obj.focus();}catch(e){}}
var OverlayInfoWindowTab=Class.create();
OverlayInfoWindowTab.prototype={
header:null,
content:null,
initialize:function(header,content){
if(header==null||header==""||content==null)
return false;
this.header=header;
this.content=content;
this.content_div=document.createElement("DIV");
this.content_div.style.overflow="visible";
this.content_div.style.display="none";
this.content_div.innerHTML=content;
this.content_div.draggable=false;},
setContent:function(content){
this.content=content;
this.content_div.innerHTML=this.content;},
setHeader:function(header){
this.header=header;}}
var OverlayInfoWindow=Class.create();
OverlayInfoWindow.prototype={
div:null,
tabs:null,
initialize:function(width,height,map_obj,opt){
try{
this.initialized=false;
this.show_tab=true;
this.map=null;
this.auto_focus=true;
this.opt=null;
if(opt!=null)
this.opt=opt;
if(typeof(map)!="undefined"&&map instanceof Map2)
this.map=map;
if(map_obj instanceof Map2)
this.map=map_obj;
this.tabs=[];
this.current_tab=-1;
this.overlay=null;
this.min_width=150;
this.min_height=150;
this.max_width=600;
this.max_height=600;
this.iframe_listener_added=false;
if(width!=null&&!isNaN(width))
this.width=width;
else
this.width=250;
if(height!=null&&!isNaN(height))
this.height=height;
else
this.height=250;
if(this.width>this.max_width)
this.width=this.max_width;
if(this.width<this.min_width)
this.width=this.min_width;
if(this.height>this.max_height)
this.height=this.max_height;
if(this.height<this.min_height)
this.height=this.min_height;
this.tpl=document.createElement("IMG");
this.tpl.src=CONST_IMG_PATH+"images/info_window_tpl.gif";
if(this.opt!=null&&this.opt.background!=null)
this.tpl.src=this.opt.background;
this.div=document.createElement("DIV");
this.div.style.cursor="default";
this.div.style.overflow="visible";
this.div.style.position="absolute";
this.div.style.left="0px";
this.div.style.top="0px";
this.div.style.zIndex="900";
this.div.style.display="block";
this.sub_div=[];
this.sub_div[0]=document.createElement("DIV");
this.sub_div[0].style.width="25px";
this.sub_div[0].style.height="25px";
this.sub_div[0].style.left="0px";
this.sub_div[0].style.top="0px";
this.sub_div[0].style.overflow="hidden";
this.sub_div[0].style.position="absolute";
this.sub_div[0].innerHTML='<img src="'+this.tpl.src+'" style="left:0px;top:0px;position:absolute;">';
this.sub_div[1]=document.createElement("DIV");
this.sub_div[1].style.width=this.width+"px";
this.sub_div[1].style.height="25px";
this.sub_div[1].style.overflow="hidden";
this.sub_div[1].style.position="absolute";
this.sub_div[1].style.left="25px";
this.sub_div[1].style.top="0px";
this.sub_div[1].style.borderTop="1px solid rgb(171, 171, 171)";
this.sub_div[1].style.backgroundColor="#FFFFFF";
this.sub_div[2]=document.createElement("DIV");
this.sub_div[2].style.width="25px";
this.sub_div[2].style.height="25px";
this.sub_div[2].style.overflow="hidden";
this.sub_div[2].style.position="absolute";
this.sub_div[2].style.left=(this.width+25)+"px";
this.sub_div[2].style.top="0px";
this.sub_div[2].innerHTML='<img src="'+this.tpl.src+'" style="left:-665px;top:0px;position:absolute;">';
this.sub_div[3]=document.createElement("DIV");
this.sub_div[3].style.width="25px";
this.sub_div[3].style.height=this.height+"px";
this.sub_div[3].style.overflow="hidden";
this.sub_div[3].style.position="absolute";
this.sub_div[3].style.left="0px";
this.sub_div[3].style.top="25px";
this.sub_div[3].style.borderLeft="1px solid rgb(171, 171, 171)";
this.sub_div[3].style.backgroundColor="#FFFFFF";
this.sub_div[4]=document.createElement("DIV");
this.sub_div[4].style.overflow="visible";
this.sub_div[4].style.position="absolute";
this.sub_div[4].style.left="25px";
this.sub_div[4].style.top="25px";
this.sub_div[4].draggable=false;
this.sub_div[4].style.backgroundColor="#FFFFFF";
this.sub_div[5]=document.createElement("DIV");
if(is_ie)
this.sub_div[5].style.width="24px";
else
this.sub_div[5].style.width="24px";
this.sub_div[5].style.height=this.height+"px";
this.sub_div[5].style.overflow="hidden";
this.sub_div[5].style.position="absolute";
this.sub_div[5].style.left=(this.width+25)+"px";
this.sub_div[5].style.top="25px";
this.sub_div[5].style.borderRight="1px solid rgb(171, 171, 171)";
this.sub_div[5].style.backgroundColor="#FFFFFF";
this.sub_div[6]=document.createElement("DIV");
this.sub_div[6].style.width="25px";
this.sub_div[6].style.height="25px";
this.sub_div[6].style.overflow="hidden";
this.sub_div[6].style.position="absolute";
this.sub_div[6].style.left="0px";
this.sub_div[6].style.top=(25+this.height)+"px";
this.sub_div[6].innerHTML='<img src="'+this.tpl.src+'" style="left:0px;top:-665px;position:absolute;">';
this.sub_div[7]=document.createElement("DIV");
this.sub_div[7].style.width=this.width+"px";
if(is_ie)
this.sub_div[7].style.height="25px";
else
this.sub_div[7].style.height="24px";
this.sub_div[7].style.overflow="hidden";
this.sub_div[7].style.position="absolute";
this.sub_div[7].style.left="25px";
this.sub_div[7].style.top=(25+this.height)+"px";
this.sub_div[7].style.borderBottom="1px solid rgb(171, 171, 171)";
this.sub_div[7].style.backgroundColor="#FFFFFF";
this.sub_div[8]=document.createElement("DIV");
this.sub_div[8].style.width="25px";
this.sub_div[8].style.height="25px";
this.sub_div[8].style.overflow="hidden";
this.sub_div[8].style.position="absolute";
this.sub_div[8].style.left=(this.width+25)+"px";
this.sub_div[8].style.top=(25+this.height)+"px";
this.sub_div[8].innerHTML='<img src="'+this.tpl.src+'" style="left:-665px;top:-665px;position:absolute;">';
this.sub_div[9]=document.createElement("DIV");
this.sub_div[9].style.width="98px";
this.sub_div[9].style.height="96px";
this.sub_div[9].style.overflow="hidden";
this.sub_div[9].style.position="absolute";
this.sub_div[9].style.left=((this.width/2))+"px";
this.sub_div[9].style.top=(25+this.height)+"px";
this.sub_div[9].innerHTML='<img src="'+this.tpl.src+'" style="left:0px;top:-690px;position:absolute;">';
if(is_ie)
var sheight=23;
else
var sheight=22;
this.sub_div[10]=document.createElement("DIV");
this.sub_div[10].innerHTML='<div style="position:absolute;left:15px;top:5px;font-size:11px;color:rgb(171, 171, 171);">Close</div>';
this.sub_div[10].style.width="50px";
this.sub_div[10].style.height="22px";
this.sub_div[10].style.overflow="hidden";
this.sub_div[10].style.position="absolute";
this.sub_div[10].style.left=(this.width)+"px";
this.sub_div[10].style.top="0px";
this.sub_div[10].style.cursor="pointer";
this.sub_div[10].onclick=this.hide.bindAsEventListener(this);
this.sub_div[11]=document.createElement("DIV");
this.sub_div[11].style.height="30px";
this.sub_div[11].style.left="0px";
this.sub_div[11].style.top="-25px";
this.sub_div[11].style.overflow="hidden";
this.sub_div[11].style.position="absolute";
this.sub_div[11].style.display="none";
this.sub_div[11].innerHTML="";
for(var i=0;i<this.sub_div.length;i++){
this.div.appendChild(this.sub_div[i]);}
this.last_tab=-1;
this.current_tab=0;
this.div.style.display="none";
this.flag=false;
this.initialized=true;}catch(e){}},
setTabPosition:function(){
var zIndex=65;
var width_margin=(this.tabs.length*102)-(this.sub_div[11].offsetWidth);
if(width_margin>0){
var width_ratio=Math.floor(width_margin/(this.tabs.length-1));
for(var i=0;i<this.tabs.length;i++){
if(i>0)
this.tabs[i].div.style.left=(this.tabs[i-1].div.offsetLeft+(102-width_ratio))+"px";
else
this.tabs[i].div.style.left="0px";
if(this.current_tab==i){
this.tabs[i].div.style.zIndex="68";}
else{
this.tabs[i].div.style.zIndex=zIndex;
if(this.current_tab==0)
zIndex--
else
zIndex++;}}}
else{
for(var i=0;i<this.tabs.length;i++){
this.tabs[i].div.style.left=(i*102)+"px";
this.tabs[i].div.style.zIndex=zIndex;
if(this.current_tab==i){
this.tabs[i].div.style.zIndex="69";}
else{
this.tabs[i].div.style.zIndex=zIndex;
if(this.current_tab==0)
zIndex--
else
zIndex++;}}}},
setShowTab:function(bool){
this.show_tab=bool;},
addTab:function(header,content){
try{
if(this.overlay==null)
return false;
if(header==null||header==""||content==null||this.tabs.length>2)
return false;
var tmp_tab=new OverlayInfoWindowTab(header,content);
if(tmp_tab.content_div.childNodes.length>0&&typeof(tmp_tab.content_div.childNodes[0])=="object"){
try{
tmp_tab.content_div.childNodes[0].bubble_obj=this;
tmp_tab.content_div.childNodes[0].tab_position=this.tabs.length;}
catch(e){}}
if(!is_ie){
var inputs=tmp_tab.content_div.getElementsByTagName("INPUT");
for(var i=0;i<inputs.length;i++){
inputs[i].draggable=false;
if(inputs[i].type=="text"){
Event.observe(inputs[i],"click",__set_obj_status.bind(null,inputs[i]));}}
var inputs=tmp_tab.content_div.getElementsByTagName("TEXTAREA");
for(var i=0;i<inputs.length;i++){
inputs[i].draggable=false;
Event.observe(inputs[i],"click",__set_obj_status.bind(null,inputs[i]));}}
this.tabs[this.tabs.length]=tmp_tab;
while(this.sub_div[11].childNodes.length>0)
this.sub_div[11].removeChild(this.sub_div[11].childNodes[0]);
for(var i=0;i<this.tabs.length;i++){
if(this.tabs[i].div==null){
this.tabs[i].div=document.createElement("DIV");
this.tabs[i].div.style.width="102px";
this.tabs[i].div.style.height="25px";
this.tabs[i].div.style.overflow="hidden";
this.tabs[i].div.style.position="absolute";
this.tabs[i].div.style.cursor="pointer";
this.tabs[i].div.onclick=this.switchTab.bind(this,i);
this.tabs[i].div.style.top="0px";
this.tabs[i].div.innerHTML='<img src="'+this.tpl.src+'" style="left:-200px;top:-690px;position:absolute;">';
this.tabs[i].header_div=document.createElement("DIV");
this.tabs[i].header_div.style.width="102px";
this.tabs[i].header_div.style.height="22px";
this.tabs[i].header_div.style.overflow="hidden";
this.tabs[i].header_div.style.position="absolute";
this.tabs[i].header_div.style.left="0px";
this.tabs[i].header_div.style.top="5px";
this.tabs[i].header_div.align="center";
this.tabs[i].header_div.style.fontSize="11px";
this.tabs[i].header_div.style.color="#333333";
this.tabs[i].header_div.innerHTML=this.tabs[i].header;
this.tabs[i].div.title=this.tabs[i].header;
this.tabs[i].div.appendChild(this.tabs[i].header_div);}
else{
this.tabs[i].header_div.innerHTML=this.tabs[i].header;}
this.sub_div[11].appendChild(this.tabs[i].div);}
if(is_gecko!=null&&is_gecko){
if(this.tabs[(this.tabs.length-1)].content.indexOf("<iframe")!=-1){
if(!this.iframe_listener_added){
if(this.overlay.map!=null){
this.overlay.map.addOnDragStartListener(this.onDragStartListener.bind(this));
this.overlay.map.addOnDragEndListener(this.onDragEndListener.bind(this));}
this.iframe_listener_added=true;}}}}
catch(e){}},
switchTab:function(pos,check){
if(pos>=this.tabs.length)
return;
this.current_tab=pos;
var old_width=this.sub_div[4].offsetWidth;
while(this.sub_div[4].childNodes.length>0){
this.sub_div[4].removeChild(this.sub_div[4].childNodes[0]);}
var zIndex="65";
for(var i=0;i<this.tabs.length;i++){
if(i==pos){
this.sub_div[4].appendChild(this.tabs[i].content_div);
this.tabs[i].content_div.style.display="block";
this.tabs[i].div.style.zIndex="68";
this.tabs[i].div.childNodes[0].style.left="-100px";}
else{
this.tabs[i].content_div.style.display="none";
this.tabs[i].div.style.zIndex=zIndex;
this.tabs[i].div.childNodes[0].style.left="-200px";
if(pos==0)
zIndex--
else
zIndex++;}}
this.setComponentPosition();
if(old_width!=this.sub_div[4].offsetWidth){
this.setTabPosition();}
if(this.overlay!=null&&this.overlay.auto_focus&&(check!=null&&check))
this.checkEdge();},
setOverlay:function(overlay){
if(overlay!=null){
this.overlay=overlay;}},
onDragStartListener:function(){
if(this.div.style.display=="none")
return;
var iframe=this.div.getElementsByTagName("iframe");
for(var i=0;i<iframe.length;i++){
iframe[i].style.visibility="hidden";}},
onDragEndListener:function(){
if(this.div.style.display=="none")
return;
var iframe=this.div.getElementsByTagName("iframe");
for(var i=0;i<iframe.length;i++){
iframe[i].style.visibility="visible";}},
setComponentPosition:function(){
var margin_top=0;
if(this.tabs.length>0&&this.show_tab){
this.sub_div[11].style.display="block";
if(this.sub_div[4].childNodes.length>0)
this.sub_div[11].style.width=this.sub_div[4].childNodes[0].offsetWidth+"px";
else
this.sub_div[11].style.width=this.sub_div[4].offsetWidth+"px";
this.sub_div[11].style.left="25px";
this.sub_div[11].style.top="0px";
margin_top=24;}
else
this.sub_div[11].style.display="none";
this.sub_div[0].style.top=(0)+"px";
this.sub_div[1].style.top=(0)+"px";
this.sub_div[2].style.top=(0)+"px";
this.sub_div[3].style.top=(25)+"px";
this.sub_div[4].style.top=(25)+"px";
this.sub_div[5].style.top=(25)+"px";
this.sub_div[10].style.top=(1)+"px";
this.sub_div[3].style.height=this.sub_div[4].offsetHeight+"px";
this.sub_div[5].style.height=this.sub_div[4].offsetHeight+"px";
if(this.sub_div[4].childNodes.length>0&&typeof(this.sub_div[4].childNodes[0])=="object"){
this.sub_div[3].style.height=this.sub_div[4].childNodes[0].offsetHeight+"px";
this.sub_div[5].style.height=this.sub_div[4].childNodes[0].offsetHeight+"px";}
this.sub_div[6].style.top=(25+this.sub_div[4].offsetHeight)+"px";
this.sub_div[7].style.top=(25+this.sub_div[4].offsetHeight)+"px";
this.sub_div[8].style.top=(25+this.sub_div[4].offsetHeight)+"px";
this.sub_div[9].style.top=(25+this.sub_div[4].offsetHeight)+"px";
this.sub_div[1].style.width=(this.sub_div[4].offsetWidth)+"px";
this.sub_div[7].style.width=(this.sub_div[4].offsetWidth)+"px";
this.sub_div[2].style.left=(25+this.sub_div[4].offsetWidth)+"px";
this.sub_div[5].style.left=(25+this.sub_div[4].offsetWidth)+"px";
this.sub_div[8].style.left=(25+this.sub_div[4].offsetWidth)+"px";
this.sub_div[10].style.left=(this.sub_div[4].offsetWidth)+"px";
this.sub_div[3].style.height=this.sub_div[4].offsetHeight+"px";
this.sub_div[5].style.height=this.sub_div[4].offsetHeight+"px";
if(margin_top>0){
for(var i=0;i<this.sub_div.length-1;i++){
this.sub_div[i].style.top=(this.sub_div[i].offsetTop+margin_top)+"px";}}
this.div.style.left=(((this.sub_div[4].offsetWidth/2)-10)*(-1))+"px";
this.sub_div[9].style.left=((this.sub_div[4].offsetWidth/2))+"px";
var top=((this.sub_div[4].offsetHeight+25+this.sub_div[9].offsetHeight)*(-1));
if(margin_top>0){
top-=(margin_top-2);}
this.div.style.top=(top)+"px";},
checkEdge:function(){
var left_margin=(this.overlay.map.__getOffset(this.overlay.map.container,true)-this.overlay.map.__getOffset(this.div,true));
var top_pos=this.overlay.map.__getOffset(this.div,false);
var map_top_pos=this.overlay.map.__getOffset(this.overlay.map.container,false);
var bottom_pos=this.overlay.map.__getOffset(this.overlay.div,false);
var map_bottom_pos=map_top_pos+this.overlay.map.container.offsetHeight;
var bottom_margin=Math.abs(bottom_pos-map_bottom_pos);
if(map_bottom_pos>bottom_pos)
bottom_margin=0;
var top_margin=Math.abs(top_pos-map_top_pos);
if(top_pos>=map_top_pos)
top_margin=0;
var left_margin2=((this.overlay.map.__getOffset(this.overlay.map.container,true)+this.overlay.map.div.offsetWidth)-(this.overlay.map.__getOffset(this.div,true)+(this.sub_div[0].offsetWidth+this.sub_div[1].offsetWidth+this.sub_div[2].offsetWidth)));
var move_x=0;
var move_y=0;
if(left_margin>0){
var move_x=left_margin+10;}
else if(left_margin2<0){
var move_x=left_margin2-10;}
if(top_margin>0){
var move_y=top_margin+10;}
if(bottom_margin>0){
var move_y=(bottom_margin+25)*(-1);}
this.overlay.map.moveToByXY(move_x,move_y);},
show:function(){
if(this.overlay==null)
return false;
this.overlay.div.style.zIndex="60";
this.div.style.display="block";
this.div.style.top="-1000px";
this.switchTab(this.current_tab,false);
if(this.sub_div[4].childNodes.length>0&&this.sub_div[4].childNodes[0].offsetWidth<this.min_width)
this.sub_div[4].childNodes[0].style.width=this.min_width+"px";
else
this.sub_div[4].childNodes[0].style.width=this.sub_div[4].childNodes[0].offsetWidth+"px";
this.setComponentPosition();
this.setTabPosition();
if(this.overlay!=null&&this.overlay.auto_focus)
this.checkEdge();},
update:function(){
this.hide();
this.show();},
hide:function(){
if(this.overlay==null)
return false;
this.div.style.display="none";},
toJSON:function(){
var obj={};
obj.width=this.width;
obj.height=this.height;
var tab_json=[];
for(var i=0;i<this.tabs.length;i++){
tab_json[i]=this.tabs[i];}
obj.tab_list=tab_json;
return Object.toJSON(obj);}}
var MapPointIcon=Class.create();
MapPointIcon.prototype={
image:null,
width:null,
height:null,
initialize:function(img_src,width,height){
if(typeof(img_src)=="undefined"||img_src==null)
return false;
this.margin=0;
this.image=document.createElement("IMG");
this.image.onload=this.imageOnload.bindAsEventListener(this);
this.image.src=img_src;
if(width!=null&&!isNaN(width)&&width!=0)
this.image.style.width=width+"px";
if(height!=null&&!isNaN(height)&&height!=0)
this.image.style.height=height+"px";},
setMargin:function(v){
if(isNaN(v))
return;
this.margin=v;},
imageOnload:function(){
this.width=this.image.offsetWidth;
this.height=this.image.offsetHeight;}}
var MapPoint2=Class.create();
MapPoint2.prototype={
initialized:false,
topping:null,
coor:null,
div:null,
move_margin_x:1,
move_margin_y:10,
move_adjust_x:1,
move_adjust_y:1,
no_reset:false,
after_click_action:null,
initialize:function(map,ln,la,title,point_img_obj,point_shad_img_obj,topping_layer_obj,topping_shad_img_obj,topping_display_property){
if(map==null||ln==null||la==null)
return;
this.parent=map;
this.ln=ln;
this.la=la;
this.left_adj=0;
this.top_adj=0;
this.title=title;
this.topping=topping_layer_obj;
this.topping_shad=topping_shad_img_obj;
this.topping_display=topping_display_property;
this.div=document.createElement("div");
this.div.style.position="absolute";
this.div.title=this.title;
this.div.style.zIndex="900";
if(point_img_obj!=null){
if(typeof(point_img_obj)=="string")
this.div.innerHTML=point_img_obj;
else
this.div.appendChild(point_img_obj);
if(this.div.childNodes.length>0){
this.div.style.width=this.div.childNodes[0].offsetWidth+"px";
this.div.style.height=this.div.childNodes[0].offsetHeight+"px";}}
else{
var img_htm="<img src='images/point1.gif' width='15px' height='15px'>";
this.div.innerHTML=htm;
this.div.style.width="15px";
this.div.style.height="15px";}
if(this.div.childNodes.length>0){
this.div.childNodes[0].onclick=this.pointClick.bindAsEventListener(this);}
this.div.onmouseover=this.mouseOverAction.bindAsEventListener(this);
this.div.onmouseout=this.mouseOutAction.bindAsEventListener(this);
this.last_zoom=100;
this.cln=0;
this.cla=0;
this.div_shadow_height=0;
this.div_shadow_width=0;
this.div_shadow=null;
if(point_shad_img_obj!=null){
this.div_shadow=point_shad_img_obj;
this.div_shadow.id="point_shadow_"+title;
this.div_shadow.style.position="absolute";
this.div_shadow.style.overflow="visible";
this.div_shadow.style.zIndex="890";
this.div_shadow.style.display="none";
this.div_shadow.className="opac5";
this.parent.map_tile_container.div.appendChild(this.div_shadow);}
this.topping_appended=false;
this.div_topping_shad=null;
this.div.style.zIndex="900";},
getToppingStatus:function(){
if(this.topping.style.display=="none")
return false;
else
return true;},
setPosition:function(force){
var f=false;
if(force!=null&&force)
f=true;
if(this.parent.zoom!=this.last_zoom||f){
var tmp_arr=this.parent.calClnClaByCoor(this.ln,this.la);
this.cln=tmp_arr[0];
this.cla=tmp_arr[1];
this.last_zoom=this.parent.zoom;}
y_pos=Math.floor(this.cla);
y_margin=Math.round((this.cla-y_pos)*this.parent.tile_height);
x_pos=Math.floor(this.cln);
x_margin=Math.round((this.cln-x_pos)*this.parent.tile_width);
if(isNaN(y_pos)||isNaN(y_margin)||isNaN(x_pos)||isNaN(x_margin)){
return;}
this.tile_obj=$("tile_"+x_pos+"_"+y_pos+"_"+this.parent.zoom+"_"+this.parent.map_id);
this.x_margin=x_margin;
this.y_margin=y_margin;
if(this.tile_obj!=null){
this.div.style.display="";
l=(this.tile_obj.offsetLeft+x_margin+this.left_adj);
t=(this.tile_obj.offsetTop+y_margin+this.top_adj);
this.div.style.left=(l)+"px";
this.top_adjustment=0;
if(this.div.childNodes.length>0)
this.top_adjustment=this.div.childNodes[0].offsetHeight;
this.div.style.top=(t-this.top_adjustment)+"px";
if(this.div_shadow!=null){
this.div_shadow.style.display="";
var sl=l;
if(this.topping_display.pt_shad_left!=null&&!isNaN(parseInt(this.topping_display.pt_shad_left)))
sl=sl+parseInt(this.topping_display.pt_shad_left);
var st=(t-this.div_shadow.offsetHeight);
if(this.topping_display.pt_shad_top!=null&&!isNaN(parseInt(this.topping_display.pt_shad_top)))
st=st+parseInt(this.topping_display.pt_shad_top);
this.div_shadow.style.left=(sl)+"px";
this.div_shadow.style.top=(st)+"px";
this.div_shadow_height=this.div_shadow.offsetHeight;
this.div_shadow_width=this.div_shadow.offsetWidth;}
if(this.topping!=null&&this.topping.style.display!="none"){
this.setToppingPosition();}}
else{
this.div.style.display="none";
if(this.div_shadow!=null){
this.div_shadow.style.display="none";}
if(this.div_topping_shad!=null){
this.div_topping_shad.style.display="none";}}
tmp_arr=null;
y_pos=null;
y_margin=null;
x_pos=null;
x_margin=null;},
isInSight:function(){
if(this.div.offsetLeft>0&&this.div.offsetTop>0)
return true;
else
return false;},
isInSight2:function(){
var tw=this.div.offsetWidth;
var th=this.div.offsetHeight;
var tx=this.parent.getOffset(this.div,true);
var ty=this.parent.getOffset(this.div,false);
var cx=this.parent.getOffset(this.parent.container,true);
var cy=this.parent.getOffset(this.parent.container,false);
if(tx>cx&&ty>cy&&(tx+tw)<(cx+this.parent.container.offsetWidth)&&(ty+th)<(cy+this.parent.container.offsetHeight))
return true;
else
return false;},
mouseOverAction:function(){
this.div.style.zIndex="1500";},
mouseOutAction:function(){
if(this.topping!=null&&this.topping.style.display=="")
this.div.style.zIndex="1000";
else
this.div.style.zIndex="900";},
preTransform:function(){
this.parent.map_tile_container.preTransformDblclick();},
fetchContent:function(){
if(this.use_content_url!=null&&this.use_content_url&&this.content_url!=null&&this.content_url!=""){
this.use_content_url=false;
this.content_ajax=new Ajax.Request(
this.content_url,{
method:'get',
onComplete:this.parseContent.bind(this)});}else{
this.setToppingPosition();
if(this.fitscreen==null)
this.fitToScreen();
else{
if(this.fitscreen)
this.fitToScreen();}}},
afterTransform:function(){
if(this.parent.map_tile_container!=null)
this.parent.map_tile_container.afterTransformDblclick();},
fitToScreen:function(){
if(this.topping!=null){
offset_y=parseInt(this.parent.getOffset(this.topping,false))-this.parent.container_top-this.move_margin_y;
offset_x=parseInt(this.parent.getOffset(this.topping,true))-this.parent.container_left-this.move_margin_x;
move_y=false;
move_x=false;
container_x2=this.parent.container_left+parseInt(this.parent.container.offsetWidth);
div2_x2=parseInt(this.parent.getOffset(this.topping,true))+parseInt(this.topping.offsetWidth)+this.move_margin_x;
if(offset_y<0){
top_final=this.parent.map_tile_container.div.offsetTop-offset_y+this.move_adjust_y;
move_x=true;}
else
top_final=this.parent.map_tile_container.div.offsetTop;
if(div2_x2>container_x2){
left_final=this.parent.map_tile_container.div.offsetLeft-(div2_x2-container_x2)-this.move_adjust_x;
move_x=true;}
else if(offset_x<0){
left_final=this.parent.map_tile_container.div.offsetLeft-offset_x+this.move_adjust_x;
move_x=true;}
else
left_final=this.parent.map_tile_container.div.offsetLeft;
if(move_y||move_x){
if(this.parent.map_tile_container.transforming){
while(!this.parent.map_tile_container.transforming){
this.parent.map_tile_container.interrupt=true;}
this.parent.map_tile_container.interrupt=false;}
this.parent.map_tile_container.transformLayer(left_final,top_final,this.parent.map_tile_container.div,this.parent.map_tile_container.trans_duration,this.parent.map_tile_container.trans_step,this.afterTransform.bind(this),this.preTransform.bind(this));}}},
pointClick:function(){
this.toggleContent(true);
if(this.after_click_action!=null){
this.after_click_action(this);}},
toppingOpenDiv:function(){
var on_off=1;
this.div.style.zIndex="1500";
this.topping.style.display="";
if(this.div_topping_shad!=null)
this.div_topping_shad.style.display="";
return on_off;},
toppingCloseDiv:function(){
var on_off=0;
this.div.style.zIndex="900";
this.topping.style.display="none";
if(this.div_topping_shad!=null)
this.div_topping_shad.style.display="none";
return on_off;},
hideContent:function(){
if(this.topping!=null){
var on_off=this.toppingCloseDiv();
this.div.style.zIndex="900";}
else{
var on_off=0;
this.div.style.zIndex="900";}
return on_off;},
resetContent:function(){
var d=this.topping.getElementsByTagName("div");
for(var i=0;i<d.length;i++){
if(d[i].id!=null&&d[i].id.indexOf("content")!=-1){
d[i].innerHTML="";
break;}}},
parseContent:function(req){
var htm=req.responseText;
var d=this.topping.getElementsByTagName("div");
for(var i=0;i<d.length;i++){
if(d[i].id!=null&&d[i].id.indexOf("content")!=-1){
d[i].innerHTML=htm;
this.setToppingPosition();
if(this.fitscreen==null)
this.fitToScreen();
else{
if(this.fitscreen)
this.fitToScreen();}
break;}}},
toppingToggleDiv:function(){
if(this.topping!=null&&this.topping_appended==false){
this.topping.style.display="none";
this.topping.style.position="absolute";
this.topping.style.overflow="visible";
this.div.appendChild(this.topping);
if(this.topping_shad!=null){
this.div_topping_shad=this.topping_shad;
this.div_topping_shad.id="content_shadow_"+this.title;
this.div_topping_shad.style.position="absolute";
this.div_topping_shad.style.overflow="visible";
this.div_topping_shad.style.zIndex="890";
this.div_topping_shad.style.display="none";
this.div_topping_shad.className="opac4";
this.parent.map_tile_container.div.appendChild(this.div_topping_shad);}
this.topping_appended=true;}
var on_off=0;
if(this.topping.style.display=="none"){
on_off=1;
this.div.style.zIndex="1500";
this.topping.style.display="";
if(this.div_topping_shad!=null)
this.div_topping_shad.style.display="";
this.setToppingPosition();}
else{
on_off=0;
this.div.style.zIndex="900";
this.topping.style.display="none";
if(this.div_topping_shad!=null)
this.div_topping_shad.style.display="none";}
return on_off;},
toggleContentSimple:function(){
if(this.topping!=null){
var on_off=this.toppingToggleDiv();
if(on_off){
this.div.style.zIndex="1500";}
else{
this.div.style.zIndex="900";}}
return on_off;},
highlight_on:function(){},
highlight_off:function(){},
setToppingPosition:function(){
var l=0;
if(this.topping_display!=null&&this.topping_display.left_px!=null){
l=parseInt(this.topping_display.left_px);
this.topping.style.left=l+"px";}
if(this.topping_display!=null&&this.topping_display.align!=null){
switch(this.topping_display.align){
case "left":
l+=(parseInt(this.topping.offsetWidth))*(-1);
this.topping.style.left=(l)+"px";
break;
case "right":
l+=0;
this.topping.style.left=(l)+"px";
break;
case "center":
l+=(Math.ceil(parseInt(this.topping.offsetWidth)/2)*(-1)+Math.ceil(this.div.childNodes[0].offsetWidth/2));
this.topping.style.left=(l)+"px";
break;
case "map_point_center":
l+=Math.ceil(this.div.childNodes[0].offsetWidth/2)*(-1);
this.topping.style.left=(l)+"px";
break;
default:
l=0;
this.topping.style.left="0px";
break;}}
else{
l=0;
this.topping.style.left="0px";}
if(ie)
var t=(parseInt(this.topping.offsetHeight))*(-1);
else
var t=(parseInt(this.topping.childNodes[0].offsetHeight))*(-1);
this.topping.style.top=(t)+"px";
if(this.div_topping_shad){
this.div_topping_shad.style.display="";
this.div_topping_shad.style.visibility="visible";
var tmp_l=0;
if(this.topping_display.left_px!=null){
tmp_l=parseInt(this.topping_display.left_px);
if(tmp_l<0){
tmp_l=tmp_l*(-1);}}
this.div_topping_shad.style.left=(parseInt(this.tile_obj.offsetLeft)+this.x_margin+this.left_adj+this.div_shadow_width-tmp_l)+"px";
this.div_topping_shad.style.top=(parseInt(this.tile_obj.offsetTop)+this.y_margin+this.top_adj-this.div_topping_shad.offsetHeight-this.div_shadow_height)+"px";
tmp_l=null;}
l=null;
t=null;},
toggleContent:function(fitscreen){
if(this.topping!=null){
var on_off=this.toppingToggleDiv();
if(on_off){
this.div.style.zIndex="1500";
this.fitscreen=fitscreen;
this.fetchContent();}
else{
this.div.style.zIndex="900";}}
else{
if(this.div.childNodes[0].tagName=="IMG"){
if(this.div.childNodes[0].src.indexOf("_on")!=-1){
on_off=0;
this.div.style.zIndex="900";}
else{
on_off=1;
this.div.style.zIndex="1500";}}}
return on_off;},
getCoor:function(){
return new Array(this.ln,this.la);},
setCoorByVal:function(la,ln,gla,gln){
if(gln!=null)
this.ln=gln;
if(gla!=null)
this.la=gla;},
setTitle:function(title){
this.title=title;},
hide:function(){
this.div.style.display="none";
if(this.div_shadow!=null)
this.div_shadow.style.display="none";},
show:function(){
this.div.style.display="";}}
var MapPoint=Class.create();
MapPoint.prototype={
initialize:function(ln,la,opt){
this.enable=true;
this.auto_focus=true;
this.bounce=0;
this.first_set_pos=true;
this.added=false;
this.initialized=false;
this.initialized_obj=false;
this.draggable=false;
this.enable_drag_before=false;
this.opt=null;
this.ln=null;
this.la=null;
this.external_onclick_listener=[];
this.external_ondragend_listener=[];
if(ln==null||la==null)
return false;
this.ln=ln;
this.la=la;
if(typeof(opt)=="undefined"||opt==null)
this.opt={};
else
this.opt=opt;
if(typeof(this.opt.icon)=="undefined"||!(this.opt.icon instanceof MapPointIcon)){
this.opt.icon=new MapPointIcon(DEFAULT_MAP_ICON_IMG.src,22,22);
if(typeof(this.opt.title)!="undefined"){
this.opt.icon.image.title=this.opt.title;}}
this.drag_cross=document.createElement("IMG");
if(is_ie)
this.drag_cross.src=CONST_IMG_PATH+"images/drag_cross.gif";
else
this.drag_cross.src=CONST_IMG_PATH+"images/drag_cross.png";
this.drag_cross.width="16";
this.drag_cross.height="16";
this.drag_cross.style.width="16px";
this.drag_cross.style.height="16px";
this.drag_cross.style.position="relative";
this.drag_cross.style.display="none";
this.standard_zIndex=55;
this.top_zIndex=56;
this.tmp=0;
this.dragging=false;
this.initialized=true;
this.initializeObject();},
initializeObject:function(){
this.div=document.createElement("DIV");
this.div.className="map_overlay";
this.opt.icon.image.style.position="relative";
this.opt.icon.image.style.left="0px";
if(this.opt.icon.margin!=null&&!(isNaN(this.opt.icon.margin))){
this.opt.icon.image.style.left=this.opt.icon.margin+"px";}
this.div.appendChild(this.opt.icon.image);
if(this.opt.icon.width!=null&&this.opt.icon.height!=null){
this.div.style.width=this.opt.icon.width+"px";
this.div.style.height=this.opt.icon.height+"px";}
this.div.style.left="-1000px";
this.div.style.position="absolute";
this.div.style.zIndex=this.standard_zIndex;
this.div.style.cursor="pointer";
this.div.appendChild(this.drag_cross);
this.div.onmouseover=this.mouseoverListener.bindAsEventListener(this);
this.div.onmouseout=this.mouseoutListener.bindAsEventListener(this);
this.div.onclick=this.clickListener.bindAsEventListener(this);
this.div.ondblclick=this.dblClickListener.bindAsEventListener(this);
this.initialized_obj=true;},
addOnDragEndListener:function(f){
if(typeof(f)!="function")
return false;
this.external_ondragend_listener.push(f);},
removeOnDragEndListener:function(f){
if(typeof(f)!="function")
return false;
var pos=-1;
for(var i=0;i<this.external_ondragend_listener.length;i++){
if(f==this.external_ondragend_listener[i]){
pos=i;
break;}}
if(pos!=-1){
this.external_ondragend_listener.splice(pos,1);}},
addOnClickListener:function(f){
if(typeof(f)!="function")
return false;
this.external_onclick_listener.push(f);},
removeOnClickListener:function(f){
if(typeof(f)!="function")
return false;
var pos=-1;
for(var i=0;i<this.external_onclick_listener.length;i++){
if(f==this.external_onclick_listener[i]){
pos=i;
break;}}
if(pos!=-1){
this.external_onclick_listener.splice(pos,1);}},
mouseoverListener:function(){
this.div.style.zIndex=this.top_zIndex;
if(this.opt.info_bubble!=null&&this.opt.info_bubble instanceof OverlayInfoWindow&&this.opt.info_bubble.div.style.display!="none"){
this.div.style.zIndex=60;}},
mouseoutListener:function(){
this.div.style.zIndex=this.standard_zIndex;
if(this.opt.info_bubble!=null&&this.opt.info_bubble instanceof OverlayInfoWindow&&this.opt.info_bubble.div.style.display!="none"){
this.div.style.zIndex=60;}},
clickListener:function(evt){
if(this.map==null)
return false;
var e=this.map.__getEvt(evt);
if(e[1]!=this.opt.icon.image)
return false;
if(this.dragging){
this.dragging=false;
return false;}
this.toggleInfoBubble();
for(var i=0;i<this.external_onclick_listener.length;i++){
this.external_onclick_listener[i](evt);}
this.tmp++;},
dblClickListener:function(){
this.tmp++;},
enableDrag:function(){
if(this.draggable||this.div==null)
return false;
this.standard_zIndex+=2;
this.top_zIndex+=2;
if(!this.enable_drag_before){
Drag.init($(this.opt.icon.image),$(this.div));
this.div.onDragStart=this.onDragStartListener.bind(this);
this.div.onDrag=this.onDragListener.bind(this);
this.div.onDragEnd=this.onDragEndListener.bind(this);
this.enable_drag_before=true;}
else{
$(this.opt.icon.image).onmousedown=Drag.start;}
this.draggable=true;},
disableDrag:function(){
this.standard_zIndex-=2;
this.top_zIndex-=2;
this.draggable=false;
if(this.enable_drag_before){
$(this.opt.icon.image).onmousedown=function(){};}},
onDragStartListener:function(){
try{
if(this.map==null||!this.draggable)
return false;
if(this.veffect!=null){
this.veffect.cancel();
this.veffect=null;
this.opt.icon.image.style.top="0px";}
this.drag_init=false;
this.map.disableDrag();}catch(e){}},
onDragListener:function(){
try{
if(!this.draggable)
return false;
if(!this.drag_init){
this.drag_cross.style.display="block";
if(this.veffect!=null){
this.veffect.cancel();
this.veffect=null;}
this.veffect=new Effect.Move(this.opt.icon.image,{x:this.opt.icon.margin,y:-15,mode:'absolute',duration:0.2});
this.drag_cross.style.left=Math.ceil((this.opt.icon.image.width/2)-(8))+"px";
this.drag_cross.style.top=(-10)+"px";
this.opt.icon.image.style.left=this.opt.icon.margin+"px";
this.hideInfoBubble();
this.drag_init=true;}
this.dragging=true;}catch(e){}},
startBounce:function(){
try{
if(this.veffect!=null){
this.veffect.cancel();
this.veffect=null;}
this.opt.icon.image.style.top="-15px";
this.opt.icon.image.style.left=this.opt.icon.margin+"px";
this.veffect=new Effect.Move(this.opt.icon.image,{x:this.opt.icon.margin,y:0,mode:'absolute',duration:0.5,transition:Effect.Transitions.Bounce,afterFinish:this.afterBounce.bind(this)});}catch(e){}},
afterBounce:function(){
this.veffect=null;},
onDragEndListener:function(){
try{
if(!this.draggable)
return false;
if(this.veffect!=null){
this.veffect.cancel();
this.veffect=null;
this.opt.icon.image.style.top="-15px";
this.opt.icon.image.style.left=this.opt.icon.margin+"px";}
this.drag_cross.style.display="none";
this.veffect=new Effect.Move(this.opt.icon.image,{x:this.opt.icon.margin,y:0,mode:'absolute',duration:1.5,transition:Effect.Transitions.Bounce,afterFinish:this.afterBouncing.bind(this)});
this.map.enableDrag();}catch(e){}},
afterBouncing:function(){
this.veffect=null;
var left=this.map.__getOffset(this.opt.icon.image,true);
var top=this.map.__getOffset(this.opt.icon.image,false)+(this.opt.icon.image.height);
var coor=this.map.__getCoorByClientXY2(left,top);
for(var i=0;i<coor.length;i++)
coor[i]=Math.floor(coor[i]);
var changed=false;
this.prev_ln=this.ln;
this.prev_la=this.la;
if(Math.abs(this.ln-Math.floor(coor[0]))>parseFloat(this.map.current_zoom_obj.glg1_per_px)&&Math.abs(this.la-Math.floor(coor[1]))>parseFloat(this.map.current_zoom_obj.gla1_per_px))
changed=true;
this.ln=coor[0];
this.la=coor[1];
for(var i=0;i<this.external_ondragend_listener.length;i++){
this.external_ondragend_listener[i](this,changed);}
this.dragging=false;},
restorePositon:function(){
if(this.prev_ln!=null&&this.prev_la!=null){
this.ln=this.prev_ln;
this.la=this.prev_la;
this.setPosition();}},
setPosition:function(){
if(this.map==null)
return false;
this.ln=Math.floor(this.ln);
this.la=Math.floor(this.la);
var pos=this.map.__getClientXYByCoor(this.ln,this.la);
var left=Math.floor(pos[0])-Math.floor(this.opt.icon.image.width/2);
var top=Math.floor(pos[1])-(this.opt.icon.image.height);
if(this.first_set_pos&&this.bounce>0){
this.div.style.left=Math.floor(left)+"px";
this.div.style.top=(Math.floor(top)-200)+"px";
this.veffect=new Effect.Move(this.div,{x:left,y:top,mode:'absolute',duration:this.bounce,transition:Effect.Transitions.Bounce});}
else{
this.div.style.left=Math.floor(left)+"px";
this.div.style.top=Math.floor(top)+"px";}
this.first_set_pos=false;},
show:function(){
this.div.style.display="block";},
hide:function(){
this.div.style.display="none";},
__export:function(){
return false;},
__import:function(){
return false;},
setIcon:function(icon){
return true;},
addBubbleTab:function(header,content){
if(this.opt.info_bubble!=null)
this.opt.info_bubble.addTab(header,content);},
addInfoBubbleWithWidthHeight:function(width,height,opt){
var tmp=new OverlayInfoWindow(width,height,null,opt);
this.setInfoBubble(tmp);},
setInfoBubble:function(info_bubble){
if(typeof(info_bubble)!="undefined"&&typeof(info_bubble.setOverlay)=="function"){
this.opt.info_bubble=info_bubble;
this.opt.info_bubble.setOverlay(this);
this.div.appendChild(this.opt.info_bubble.div);}},
setShowTab:function(bool){
if(typeof(this.opt.info_bubble)!="undefined"&&this.opt.info_bubble instanceof OverlayInfoWindow){
this.opt.info_bubble.setShowTab(bool);}},
showInfoBubble:function(){
if(typeof(this.opt.info_bubble)!="undefined"&&this.opt.info_bubble instanceof OverlayInfoWindow){
this.div.style.zIndex="900";
this.opt.info_bubble.show();}},
hideInfoBubble:function(){
if(typeof(this.opt.info_bubble)!="undefined"&&this.opt.info_bubble instanceof OverlayInfoWindow){
this.div.style.zIndex=this.standard_zIndex;
this.opt.info_bubble.hide();}},
toggleInfoBubble:function(){
if(typeof(this.opt.info_bubble)!="undefined"&&this.opt.info_bubble instanceof OverlayInfoWindow){
if(this.opt.info_bubble.div.style.display=="none")
this.showInfoBubble();
else
this.hideInfoBubble();}},
toJSON:function(){
var obj={};
obj.ln=this.ln;
obj.la=this.la;
obj.icon=this.opt.icon.image.src;
obj.icon_width=this.opt.icon.width;
obj.icon_height=this.opt.icon.height;
if(this.draggable)
obj.draggable=1;
else
obj.draggable=0;
obj.bounce=this.bounce;
obj.tabs=this.opt.info_bubble;
return Object.toJSON(obj);},
getSnap:function(){
return this.toJSON();},
parseSnap:function(str){
var obj=null;
eval("obj = "+str);
var tab_obj=null;
eval("tab_obj = "+obj.tabs);
this.ln=obj.ln;
this.la=obj.la;
this.opt.icon.image.src=obj.icon;
if(obj.icon_width!=null&&obj.icon_height!=null){
this.opt.icon.image.width=obj.icon_width;
this.opt.icon.image.height=obj.icon_height;}
if(tab_obj!=null&&tab_obj.width!=null&&tab_obj.height!=null){
var info_bubble=new OverlayInfoWindow(tab_obj.width,tab_obj.height);
this.setInfoBubble(info_bubble);
var tmp=null;
for(var i=0;i<tab_obj.tabs.length;i++){
eval("tmp = "+tab_obj.tabs[i]);
info_bubble.addTab(tmp.header,tmp.content);}}}}
var MapPolyline=Class.create();
MapPolyline.prototype={
initialized:false,
initialize:function(opt){
this.opt=opt;
this.group="default";
if(opt!=null&&opt.group!=null){
this.group=opt.group;}
this.addNode=this.addPoint;
this.arr_pos_arr=[];
this.post_edit_listener=null;},
addPostEditListener:function(func){
if(typeof(func)!="function"){
return false;}
this.post_edit_listener=func;
return true;},
__onZoomListener:function(){
this.onAfterZoomUpdate();},
__initializeObject:function(map_drawing){
if(map_drawing==null||!(map_drawing instanceof MapDrawing))
return false;
this.map_drawing=map_drawing;
this.renderer=this.map_drawing.getRender();
this.tmp_id=this.__getTmpId();
this.stroke={};
this.fill={};
this.obj=this.__createSVGComponentObj();
this.renderer.add(this.obj);
this.setStroke(0,0,255,0.5,5);
this.points=[];
this.point_x=[];
this.point_y=[];
this.coors=[];
this.create=this.__create.bind(this);
this.end=this.__end.bind(this);
this.bubble_show_listener=[];
this.bubble_hide_listener=[];
this.ext_click_listener=[];
this.click_listener=this.__click.bindAsEventListener(this);
this.move_listener=this.__move.bindAsEventListener(this);
this.dblclick_listener=this.__dblclick.bindAsEventListener(this);
this.mouseover_listener=this.__mouseover.bindAsEventListener(this);
this.mouseout_listener=this.__mouseout.bindAsEventListener(this);
this.onzoom_listener=this.__onZoomListener.bindAsEventListener(this);
this.is_mousedown=false;
this.is_moved=false;
this.current_point=null;
this.current_coor=null;
this.first_point=null;
this.mappoint=null;
this.editing=false;
this.changed_zoom=false;
this.__create();
this.edit_div=null;
this.editable=false;
if(Graphic.rendererSupported("VML")){
this.obj.element.style.position="absolute";}
else{
this.renderer.element.style.position="absolute";
this.renderer.element.style.overflow="visible";}
this.renderer.element.style.zIndex="54";
this.obj.element.style.zIndex="54";
this.enableStrokeEdit();
this.enableFillEdit();
this.path_editable=false;
this.edit_div_children=[];
this.finished=false;
this.current_left=0;
this.current_top=0;
this.edit_dragging=false;
this.edit_over=false;
this.close_set=false;
this.initialized=true;},
__getTmpId:function(){
return this.map_drawing.polyline_lib.length;},
__createSVGComponentObj:function(){
return new Graphic.Polyline(this.renderer);},
__endParent:function(){
this.map_drawing.endOfAddPolyline();},
destory:function(){
if(Graphic.rendererSupported("VML")){
this.map_drawing.controller.map.tile_controller.div.removeChild(this.obj.element);}
else{
this.map_drawing.controller.map.tile_controller.div.removeChild(this.renderer.element);}
if(this.mappoint!=null)
this.map_drawing.controller.map.removeMapPoint(this.mappoint);
if(this.edit_div!=null)
this.map_drawing.controller.map.tile_controller.div.removeChild(this.edit_div);
return true;},
getCoor:function(){
return this.coors;},
setCoor:function(coor_arr){
if(coor_arr==null)
return;},
__updateCoor:function(){},
enableStrokeEdit:function(){
this.stoke_editable=true;},
disableStrokeEdit:function(){
this.stoke_editable=false;},
enableFillEdit:function(){
this.fill_editable=true;},
disableFillEdit:function(){
this.fill_editable=false;},
enablePathEdit:function(){
this.path_editable=true;
this.map_drawing.controller.map.addOnZoomListener(this.onzoom_listener);
if(this.edit_div==null){
this.edit_div=document.createElement("DIV");
this.edit_div.style.display="none";
this.edit_div.style.position="absolute";
this.edit_div.style.overflow="visible";
this.edit_div.style.left="0px";
this.edit_div.style.top="0px";
this.edit_div.style.zIndex="2000";
this.map_drawing.controller.map.tile_controller.div.appendChild(this.edit_div);
for(var i=0;i<this.obj.points.length;i++){
this.edit_div_children[i]=document.createElement("DIV");
this.edit_div_children[i].style.position="absolute";
this.edit_div_children[i].style.left="0px";
this.edit_div_children[i].style.top="0px";
this.edit_div_children[i].style.fontSize="1%";
this.edit_div_children[i].style.width="10px";
this.edit_div_children[i].style.display="none";
this.edit_div_children[i].style.height="10px";
this.edit_div_children[i].style.border="1px rgb(0,0,255) solid";
this.edit_div_children[i].style.backgroundImage="url("+CONST_IMG_PATH+"images/nbsp.gif)";
this.edit_div_children[i].style.zIndex="2000";
this.edit_div.appendChild(this.edit_div_children[i]);}}},
disablePathEdit:function(){
this.path_editable=false;
if(this.edit_div!=null){
var children=this.edit_div.getElementsByTagName("DIV");
for(var i=0;i<children.length;i++){
children[i].style.display="none";}}},
setStrokeColor:function(rv,gv,bv){
if(rv<0||rv>255||gv<0||gv>255||bv<0||bv>255){
return false;}
if(this.stroke==null)
this.stroke={r:rv,g:gv,b:bv};
else{
this.stroke.r=rv;
this.stroke.g=gv;
this.stroke.b=bv;}
this.obj.setStrokeColor(rv,gv,bv);},
setStrokeWidth:function(wv){
if(wv<0||wv>10)
return false;
if(this.stroke==null)
this.stroke={w:wv};
else
this.stroke.w=wv;
this.obj.setStrokeWidth(wv);},
setStrokeOpacity:function(ov){
if(ov>1||ov<0)
return false;
if(this.stroke==null)
this.stroke={a:ov};
else
this.stroke.a=ov;
if(this.stroke==null)
this.stroke={a:ov};
else
this.stroke.a=ov;
this.obj.setStrokeOpacity(Math.ceil(ov*255));},
setStroke:function(rv,gv,bv,ov,wv){
if(rv<0||rv>255||gv<0||gv>255||bv<0||bv>255)
return false;
if(ov==null)
ov=0.5;
if(ov>1||ov<0)
return false;
if(wv==null)
wv=5;
this.stroke={r:rv,g:gv,b:bv,a:ov,w:wv};
this.obj.setStroke({r:rv,g:gv,b:bv,a:Math.ceil(ov*255),w:wv});},
setFillColor:function(rv,gv,bv){
if(rv<0||rv>255||gv<0||gv>255||bv<0||bv>255){
return false;}
if(this.fill==null)
this.fill={r:rv,g:gv,b:bv};
else{
this.fill.r=rv;
this.fill.g=gv;
this.fill.b=bv;}
this.obj.setFillColor(rv,gv,bv);},
setFillOpacity:function(ov){
if(ov>1||ov<0)
return false;
if(this.fill==null){
this.fill={a:ov};}
else
this.fill.a=ov;
this.obj.setFillOpacity(Math.ceil(ov*255));},
setFill:function(rv,gv,bv,ov){
if(rv<0||rv>255||gv<0||gv>255||bv<0||bv>255)
return false;
if(ov>1||ov<0)
return false;
this.fill={r:rv,g:gv,b:bv,a:ov};
this.obj.setFill({r:rv,g:gv,b:bv,a:Math.ceil(ov*255)});},
removeFillColor:function(){
this.obj.setFill({});},
removeFill:function(){
this.obj.setFill({});},
__mouseover:function(evt){
if(!this.path_editable)
return;
if(this.edit_dragging)
return;
this.edit_div.style.display="block";
this.edit_div.xtype="ok"
for(var i=0;i<this.obj.points.length;i++){
this.edit_div.childNodes[i].pos=i;
this.edit_div.childNodes[i].style.display="block";
var xy=this.map_drawing.controller.map.__getClientXYByCoor(this.coors[i][0],this.coors[i][1]);
this.edit_div.childNodes[i].style.left=(xy[0]-5)+"px";
this.edit_div.childNodes[i].style.top=(xy[1]-5)+"px";}},
__mouseout:function(evt){
if(!this.path_editable)
return;
var e=this.map_drawing.controller.map.__getEvt(evt);
if(e[1].tagName=="polyline"||e[1].tagName=="shape"||e[1].tagName=="polygon")
return;
if(this.edit_dragging)
return;
if(this.edit_over)
return;
this.edit_div.style.display="none";
for(var i=0;i<this.edit_div.childNodes.length;i++){
this.edit_div.childNodes[i].style.display="none";}},
__create:function(){
this.editing=true;
this.map_drawing.controller.map.disableDoubleClick();
Event.observe(this.map_drawing.controller.map.div,"click",this.click_listener);
Event.observe(this.map_drawing.controller.map.div,"dblclick",this.dblclick_listener);
Event.observe(this.map_drawing.controller.map.div,"mousemove",this.move_listener);},
__end:function(){
Event.stopObserving(this.map_drawing.controller.map.div,"click",this.click_listener);
Event.stopObserving(this.map_drawing.controller.map.div,"dblclick",this.dblclick_listener);
Event.stopObserving(this.map_drawing.controller.map.div,"mousemove",this.move_listener);
Event.observe(this.obj.element,"mouseover",this.mouseover_listener);
Event.observe(this.renderer.element,"mouseout",this.mouseout_listener);
this.map_drawing.controller.map.removeOnZoomListener(this.onzoom_listener);
this.map_drawing.controller.map.enableDoubleClick();
if(this.post_edit_listener!=null&&typeof(this.post_edit_listener)=="function")
this.post_edit_listener(this,0);},
__addPoint:function(x,y,index){
var margin_x=this.map_drawing.controller.map.__getOffset(this.map_drawing.controller.div,true);
var margin_y=this.map_drawing.controller.map.__getOffset(this.map_drawing.controller.div,false);
var new_x=x-margin_x;
var new_y=y-margin_y;
if(index!=null&&!isNaN(index)&&index>=0&&index<this.coors.length){
this.point_x.splice(index,0,new_x);
this.point_y.splice(index,0,new_y);
this.coors.splice(index,0,this.map_drawing.controller.map.__getCoorByClientXY2(x,y));
this.points.splice(index,0,[x,y]);
this.obj.addPoint(new_x,new_y,index);}
else{
this.point_x.push(new_x);
this.point_y.push(new_y);
this.coors.push(this.map_drawing.controller.map.__getCoorByClientXY2(x,y));
this.points.push([x,y]);
this.obj.addPoint(new_x,new_y);}
if(this.obj.points.length>this.edit_div_children.length&&this.path_editable){
var tmp=document.createElement("DIV");
tmp.style.position="absolute";
tmp.style.left="0px";
tmp.style.top="0px";
tmp.style.fontSize="1%";
tmp.style.display="none";
tmp.style.width="10px";
tmp.style.height="10px";
tmp.style.border="1px #333333 solid";
tmp.style.backgroundColor="#333333";
tmp.style.cursor="pointer";
tmp.style.backgroundImage="url("+CONST_IMG_PATH+"images/nbsp.gif)";
tmp.onmouseover=this.__editOver.bind(this);
tmp.onmouseout=this.__editOut.bind(this);
Drag2.init(tmp,null);
tmp.onDragStart=this.__editDragStart.bind(this);
tmp.onDragEnd=this.__editDragEnd.bind(this);
tmp.onDrag=this.__editDrag.bindAsEventListener(this);
this.edit_div.appendChild(tmp);
this.edit_div_children.push(tmp);}},
__editOver:function(){
this.edit_over=true;},
__editOut:function(){
this.edit_over=false;},
__editDrag:function(evt){
if(Drag2.obj.pos==null)
return;
var e=this.map_drawing.controller.map.__getEvt(evt);
var pos2=parseInt(Drag2.obj.pos);
var pos1=pos2-1;
var pos3=pos2+1;
this.arr_pos_arr=[];
this.pos_arr=[];
if(pos1>=0){
this.pos_arr.push([this.map_drawing.controller.map.__getOffset(this.edit_div_children[pos1],true),this.map_drawing.controller.map.__getOffset(this.edit_div_children[pos1],false)]);}
this.pos_arr.push([e[0].clientX,e[0].clientY]);
this.arr_pos_arr.push(pos2,[e[0].clientX,e[0].clientY]);
if(pos3<this.obj.points.length){
this.pos_arr.push([this.map_drawing.controller.map.__getOffset(this.edit_div_children[pos3],true),this.map_drawing.controller.map.__getOffset(this.edit_div_children[pos3],false)]);}
this.map_drawing.setDot(this.pos_arr);},
__editDragStart:function(evt){
this.edit_dragging=true;
this.map_drawing.controller.map.disableDrag();
var e=this.map_drawing.controller.map.__getEvt(evt);
this.init_x=e[0].clientX;
this.init_y=e[0].clientY;},
__editDragEnd:function(){
this.edit_dragging=false;
this.map_drawing.cleanDot();
try{
var coor=this.map_drawing.controller.map.__getCoorByClientXY(this.arr_pos_arr[1][0],this.arr_pos_arr[1][1]);
this.coors[this.arr_pos_arr[0]]=coor;}catch(e){}
this.onAfterZoomUpdate();
this.map_drawing.controller.map.enableDrag();
if(this.post_edit_listener!=null&&typeof(this.post_edit_listener)=="function")
this.post_edit_listener(this,1);},
__setPoint:function(x,y,index){
var new_x=x;
var new_y=y;
this.point_x[index]=new_x;
this.point_y[index]=new_y;
this.obj.setPoint(new_x,new_y,index);},
__click:function(evt){
if(evt.target.tagName=="IMG"&&evt.target.className!="maptile")
return;
if(this.is_moved){
this.is_moved=false;
return;}
var e=this.map_drawing.controller.map.__getEvt(evt);
var FixedClientX=e[0].clientX+document.body.scrollLeft;
var FixedClientY=e[0].clientY+document.body.scrollTop;
this.last_point=this.current_point;
this.current_point=[FixedClientX,FixedClientY];
this.current_coor=this.map_drawing.controller.map.__getCoorByClientXY(FixedClientX,FixedClientY);
this.__addPoint(this.current_point[0],this.current_point[1]);
this.redraw();},
__move:function(evt){
if(this.map_drawing.dragged){
this.is_moved=true;
return;}
if(this.obj.points.length>0){
var e=this.map_drawing.controller.map.__getEvt(evt);
var FixedClientX=e[0].clientX+document.body.scrollLeft;
var FixedClientY=e[0].clientY+document.body.scrollTop;
if(this.changed_zoom){
var xy=this.map_drawing.controller.map.__getClientXYByCoor(this.coors[this.coors.length-1][0],this.coors[this.coors.length-1][1]);
var x=xy[0]+this.map_drawing.controller.map.__getOffset(this.map_drawing.controller.div,true);
var y=xy[1]+this.map_drawing.controller.map.__getOffset(this.map_drawing.controller.div,false);}
else{
var x=this.obj.points[this.obj.points.length-1][0]+this.map_drawing.controller.map.__getOffset(this.map_drawing.controller.div,true);
var y=this.obj.points[this.obj.points.length-1][1]+this.map_drawing.controller.map.__getOffset(this.map_drawing.controller.div,false);}
this.map_drawing.setDot([[x,y],[FixedClientX,FixedClientY]]);}},
objElementClick:function(e){
for(var i=0;i<this.ext_click_listener.length;i++)
this.ext_click_listener[i](e,this);},
postDblClickAction:function(){
this.map_drawing.cleanDot();
this.__end();
this.__endParent();
this.redraw();
this.object_click_listener=this.objElementClick.bind(this);
Event.observe(this.obj.element,"click",this.object_click_listener);
this.editing=false;},
__dblclick:function(evt){
if(typeof(evt)!="undefined"&&evt!=null&&evt.target.tagName=="IMG"&&evt.target.className!="maptile")
return;
try{
if(
this.obj.points[this.obj.points.length-1][0]==this.obj.points[this.obj.points.length-2][0]&&
this.obj.points[this.obj.points.length-1][1]==this.obj.points[this.obj.points.length-2][1]){
this.point_x.pop();
this.point_y.pop();
this.coors.pop();
this.points.pop();
this.obj.points.pop();
this.edit_div_children.pop();
this.obj._updatePath();}}catch(e){}
this.postDblClickAction();},
__mapPointClickListener:function(){},
redraw:function(finish){
if(!this.finished){
if(finish!=null&&finish)
this.finished=true;
else
this.finished=false;}
if(this.point_x.length<1||this.point_y.length<1)
return false;
var margin=10;
if(is_ie)
margin=0;
var min_ln=null;
var min_la=null;
var max_ln=null;
var max_la=null;
for(var i=0;i<this.coors.length;i++){
if(min_ln==null||this.coors[i][0]<min_ln)
min_ln=this.coors[i][0];
if(min_la==null||this.coors[i][1]>min_la)
min_la=this.coors[i][1];
if(max_ln==null||this.coors[i][0]>max_ln)
max_ln=this.coors[i][0];
if(max_la==null||this.coors[i][1]<max_la)
max_la=this.coors[i][1];}
var min_xy=this.map_drawing.controller.map.__getClientXYByCoor(min_ln,min_la);
var max_xy=this.map_drawing.controller.map.__getClientXYByCoor(max_ln,max_la);
var min_x=min_xy[0]-margin;
var max_x=max_xy[0]+margin;
var min_y=min_xy[1]-margin;
var max_y=max_xy[1]+margin;
if(Graphic.rendererSupported("VML")){
this.obj.element.style.width=(max_x-min_x)+"px";
this.obj.element.style.height=(max_y-min_y)+"px";
this.obj.element.setAttribute("coordsize",((max_x-min_x)+", "+(max_y-min_y)));
this.obj.element.setAttribute("coordorigin","0,0");
if(finish!=null&&finish){
for(var i=0;i<this.obj.points.length;i++){
this.obj.points[i][0]-=min_x;
this.obj.points[i][1]-=min_y;}
this.obj._updatePath();
this.obj.element.style.left=(min_x)+"px";
this.obj.element.style.top=(min_y)+"px";}
else{
this.obj.element.style.left=(0)+"px";
this.obj.element.style.top=(0)+"px";
if(this.changed_zoom){
for(var i=0;i<this.obj.points.length;i++){
this.obj.points[i]=this.map_drawing.controller.map.__getClientXYByCoor(this.coors[i][0],this.coors[i][1]);}
this.obj._updatePath();
this.changed_zoom=false;}}}
else{
this.renderer.element.setAttribute("width",(max_x-min_x)+"px");
this.renderer.element.setAttribute("height",(max_y-min_y)+"px");
this.renderer.element.setAttribute("viewBox",(min_x)+" "+min_y+" "+(max_x-min_x)+" "+(max_y-min_y));
if(finish!=null&&finish){
this.renderer.element.style.left=(min_x)+"px";
this.renderer.element.style.top=(min_y)+"px";
for(var i=0;i<this.obj.points.length;i++){
this.obj.points[i][0]-=min_x;
this.obj.points[i][1]-=min_y;}
this.obj._updatePath();
this.renderer.element.setAttribute("viewBox","0 0 "+(max_x-min_x)+" "+(max_y-min_y));}
else{
if(this.changed_zoom){
for(var i=0;i<this.obj.points.length;i++){
this.obj.points[i]=this.map_drawing.controller.map.__getClientXYByCoor(this.coors[i][0],this.coors[i][1]);}
this.obj._updatePath();
this.changed_zoom=false;}
this.renderer.element.style.left=(min_x)+"px";
this.renderer.element.style.top=(min_y)+"px";
if(agt.indexOf("safari")!=-1){
this.map_drawing.controller.map.moveToByXYs(1,1);
this.map_drawing.controller.map.moveToByXYs(-1,-1);
this.renderer.element.setAttribute("width",(max_x-min_x+min_x)+"px");
this.renderer.element.setAttribute("height",(max_y-min_y+min_y)+"px");
this.renderer.element.setAttribute("viewBox","0 0 "+(max_x-min_x)+" "+(max_y-min_y));
this.renderer.element.style.left=(min_x-this.renderer.element.offsetLeft)+"px";
this.renderer.element.style.top=(min_y-this.renderer.element.offsetTop)+"px";}}}
this.current_left=min_x;
this.current_top=min_y;
this.renderer.draw();},
onAfterZoomUpdate:function(){
var min_ln=null;
var min_la=null;
var max_ln=null;
var max_la=null;
for(var i=0;i<this.coors.length;i++){
if(min_ln==null||this.coors[i][0]<min_ln)
min_ln=this.coors[i][0];
if(min_la==null||this.coors[i][1]>min_la)
min_la=this.coors[i][1];
if(max_ln==null||this.coors[i][0]>max_ln)
max_ln=this.coors[i][0];
if(max_la==null||this.coors[i][1]<max_la)
max_la=this.coors[i][1];}
var min_xy=this.map_drawing.controller.map.__getClientXYByCoor(min_ln,min_la);
var max_xy=this.map_drawing.controller.map.__getClientXYByCoor(max_ln,max_la);
if(Graphic.rendererSupported("VML")){
this.obj.element.style.left=(min_xy[0])+"px";
this.obj.element.style.top=(min_xy[1])+"px";
this.obj.element.style.width=(max_xy[0]-min_xy[0])+"px";
this.obj.element.style.height=(max_xy[1]-min_xy[1])+"px";
this.obj.element.setAttribute("coordsize",((max_xy[0]-min_xy[0])+", "+(max_xy[1]-min_xy[1])));}
else{
this.renderer.element.style.left=(min_xy[0]-10)+"px";
this.renderer.element.style.top=(min_xy[1]-10)+"px";
this.renderer.element.setAttribute("width",(max_xy[0]-min_xy[0]+20)+"px");
this.renderer.element.setAttribute("height",(max_xy[1]-min_xy[1]+20)+"px");
this.renderer.element.setAttribute("viewBox","0 0 "+(max_xy[0]-min_xy[0]+20)+" "+(max_xy[1]-min_xy[1]+20));}
var ln_rate=null;
var la_rate=null;
var tmp_x=null;
var tmp_y=null;
for(var i=0;i<this.coors.length;i++){
ln_rate=(this.coors[i][0]-min_ln)/(max_ln-min_ln);
la_rate=(min_la-this.coors[i][1])/(min_la-max_la);
tmp_x=Math.round((max_xy[0]-min_xy[0])*ln_rate);
tmp_y=Math.round((max_xy[1]-min_xy[1])*la_rate);
if(!Graphic.rendererSupported("VML")){
tmp_x+=10;
tmp_y+=10;}
this.obj.points[i][0]=tmp_x;
this.obj.points[i][1]=tmp_y;}
this.obj._updatePath();
if(this.edit_div!=null)
this.edit_div.style.display="none";
if(this.editing){
this.changed_zoom=true;}},
toJSON:function(){
var obj={};
obj.coor=this.coors;
obj.stroke=this.stroke;
obj.fill=this.fill;
return Object.toJSON(obj);},
getSnap:function(){
return this.toJSON();},
parseSnap:function(str){
if(str==null||str=="")
return false;
var obj=null;
eval("obj = "+str);
if(obj.coor==null)
return;
var margin_x=this.map_drawing.controller.map.__getOffset(this.map_drawing.controller.div,true);
var margin_y=this.map_drawing.controller.map.__getOffset(this.map_drawing.controller.div,false);
for(var i=0;i<obj.coor.length;i++){
var xy=this.map_drawing.controller.map.__getClientXYByCoor(obj.coor[i][0],obj.coor[i][1]);
this.__addPoint(xy[0]+margin_x,xy[1]+margin_y);
this.redraw();}
this.__dblclick();
if(obj.stroke!=null){
if(obj.stroke.r!=null&&obj.stroke.g!=null&&obj.stroke.b!=null)
this.setStrokeColor(obj.stroke.r,obj.stroke.g,obj.stroke.b);
if(obj.stroke.a!=null)
this.setStrokeOpacity(obj.stroke.a);
if(obj.stroke.w!=null)
this.setStrokeWidth(obj.stroke.w);}
if(obj.fill!=null){
if(obj.fill.r!=null&&obj.fill.g!=null&&obj.fill.b!=null)
this.setFillColor(obj.fill.r,obj.fill.g,obj.fill.b);
if(obj.fill.a!=null)
this.setFillOpacity(obj.fill.a);
if(obj.fill.w!=null)
this.setFillWidth(obj.fill.w);}},
addPointByCoor:function(ln,la,index){
if(isNaN(ln)||isNaN(la))
return false;
var margin_x=this.map_drawing.controller.map.__getOffset(this.map_drawing.controller.div,true);
var margin_y=this.map_drawing.controller.map.__getOffset(this.map_drawing.controller.div,false);
var xy=this.map_drawing.controller.map.__getClientXYByCoor(ln,la);
this.__addPoint(xy[0]+margin_x,xy[1]+margin_y,index);
this.redraw(false);},
finishEdit:function(){
this.__dblclick();},
addPoint:function(pos,type,ln,la){
if(isNaN(pos)||pos>=this.coors.length||pos<0)
return false;
if(isNaN(type)||type>1||type<0)
return false;
var pos_a=-1;
var pos_b=-1;
if(type==0){
pos_b=pos;
pos_a=pos-1;}
else{
pos_a=pos;
pos_b=pos+1;}
if(pos_a>=this.coors.length||pos_a<0||pos_b>=this.coors.length||pos_b<0)
return false;
var point_a=[];var point_b=[];var point_c=[];
if(!isNaN(ln)&&!isNaN(la)){
point_c[0]=ln;point_c[1]=la;}
else{
point_a=this.coors[pos_a];
point_b=this.coors[pos_b];
if(point_a[0]>point_b[0])
point_c[0]=point_a[0]-(Math.abs((point_b[0]-point_a[0]))/2);
else
point_c[0]=point_a[0]+(Math.abs((point_b[0]-point_a[0]))/2);
if(point_b[1]>point_a[1])
point_c[1]=point_a[1]+(Math.abs((point_a[1]-point_b[1]))/2);
else
point_c[1]=point_a[1]-(Math.abs((point_a[1]-point_b[1]))/2);}
this.addPointByCoor(point_c[0],point_c[1],pos_b);},
addExternalClickListener:function(func){
if(typeof(func)!="function")
return false;
for(var i=0;i<this.ext_click_listener.length;i++){
if(this.ext_click_listener[i]==func)
return false;}
this.ext_click_listener.push(func);},
removeExternalClickListener:function(func){
if(typeof(func)!="function"||this.bubble==null)
return false;
var pos=-1;
for(var i=0;i<this.ext_click_listener.length;i++){
if(this.ext_click_listener[i]==func){
pos=i;
break;}}
if(pos!=-1){
this.ext_click_listener.splice(pos,1);
return true;}
else{
return false;}},
__bubble_click_listener:function(e){
var tmp_x=this.map_drawing.controller.map.__getOffset(this.map_drawing.controller.map.tile_controller.div,true);
var tmp_y=this.map_drawing.controller.map.__getOffset(this.map_drawing.controller.map.tile_controller.div,false);
this.showInfoBubble((e.clientX-tmp_x),(e.clientY-tmp_y));},
showInfoBubbleByEvent:function(e){
this.bubble.showByEvent(e);},
setInfoBubble:function(bubble){
try{
if(!(bubble instanceof MapBubble))
return false;
if(typeof(bubble.detach)!="function"||typeof(bubble.attachToObject)!="function")
return false;
this.bubble=bubble;
this.bubble.attachToObject(this.div);}
catch(e){
alert(e.message);}
return true;},
removeInfoBubble:function(){
if(this.bubble==null&&typeof(this.bubble.detach)!="function")
return false;
this.bubble.detach();
this.bubble=null;
this.div.bubble=null;
return true;},
showInfoBubble:function(x,y){
if(this.bubble==null&&typeof(this.bubble.show)!="function")
return false;
if(x!=null&&y!=null&&!isNaN(x)&&!isNaN(y))
this.bubble.show(x,y);
else
this.bubble.show();
return true;},
disableInfoBubble:function(bool){
if(bool)
this.bubble_disabled=true;
else
this.bubble_disabled=false;},
showInfoBubbleAtPoint:function(index){
if(index==null||isNaN(index)||index<0||index>=this.coors.length)
return false;
if(this.bubble==null||typeof(this.bubble.show)!="function")
return false;
var xy=this.map_drawing.controller.map.__getClientXYByCoor(this.coors[index][0],this.coors[index][1]);
this.bubble.show(xy[0],xy[1]);
return true;},
hideInfoBubble:function(){
if(this.bubble==null&&typeof(this.bubble.hide)!="function")
return false;
this.bubble.hide();
return true;}}
var MapPolygon=Class.create();
Object.extend(Object.extend(MapPolygon.prototype,MapPolyline.prototype),{
__createSVGComponentObj:function(){
return new Graphic.Polygon(this.renderer);},
__getTmpId:function(){
return this.map_drawing.polygon_lib.length;},
__endParent:function(){
this.map_drawing.endOfAddPolygon();},
__editDrag:function(evt){
try{
if(Drag2.obj.pos==null)
return;
var e=this.map_drawing.controller.map.__getEvt(evt);
var pos2=parseInt(Drag2.obj.pos);
var pos1=pos2-1;
var pos3=pos2+1;
this.arr_pos_arr=[];
this.pos_arr=[];
if(pos1>=0){
this.pos_arr.push([this.map_drawing.controller.map.__getOffset(this.edit_div_children[pos1],true),this.map_drawing.controller.map.__getOffset(this.edit_div_children[pos1],false)]);}
else{
this.pos_arr.push([this.map_drawing.controller.map.__getOffset(this.edit_div_children[this.edit_div_children.length-1],true),this.map_drawing.controller.map.__getOffset(this.edit_div_children[this.edit_div_children.length-1],false)]);}
this.pos_arr.push([e[0].clientX,e[0].clientY]);
this.arr_pos_arr.push(pos2,[e[0].clientX,e[0].clientY]);
if(pos3<this.obj.points.length){
this.pos_arr.push([this.map_drawing.controller.map.__getOffset(this.edit_div_children[pos3],true),this.map_drawing.controller.map.__getOffset(this.edit_div_children[pos3],false)]);}
else{
this.pos_arr.push([this.map_drawing.controller.map.__getOffset(this.edit_div_children[0],true),this.map_drawing.controller.map.__getOffset(this.edit_div_children[0],false)]);}
this.map_drawing.setDot(this.pos_arr);}catch(e){}}});
var MapCircle=Class.create();
MapCircle.prototype={
initialized:false,
initialize:function(opt){
this.opt=opt;
if(opt==null)
this.opt={};
this.group="default";
if(opt!=null&&opt.group!=null){
this.group=opt.group;}
this.ln=0;
if(opt!=null&&opt.ln!=null){
this.ln=opt.ln;}
this.la=0;
if(opt!=null&&opt.la!=null){
this.la=opt.la;}
this.radius=10;
if(opt!=null&&opt.radius!=null){
this.radius=opt.radius;}
this.opacity=0.5;
if(opt!=null&&opt.opacity!=null){
this.opacity=opt.opacity;}},
__initializeObject:function(map_drawing){
if(map_drawing==null||!(map_drawing instanceof MapDrawing))
return false;
this.map_drawing=map_drawing;
this.renderer=this.map_drawing.getRender();
this.tmp_id=this.__getTmpId();
this.obj=new Graphic.Circle(this.renderer);
this.obj.setRadius(this.radius);
this.obj.setLocation(this.radius,this.radius);
this.obj.setBounds(0,0,this.radius,this.radius);
this.setStrokeWidth(0);
this.setFill(0,0,0,this.opacity);
if(Graphic.rendererSupported("VML")){
this.obj.element.style.position="absolute";}
else{
this.renderer.element.style.position="absolute";
this.renderer.element.style.overflow="visible";}
this.renderer.element.style.zIndex="54";
this.obj.element.style.zIndex="54";
this.renderer.add(this.obj);
this.draw();},
destory:function(){
if(Graphic.rendererSupported("VML")){
this.map_drawing.controller.map.tile_controller.div.removeChild(this.obj.element);}
else{
this.map_drawing.controller.map.tile_controller.div.removeChild(this.renderer.element);}
return true;},
__getTmpId:function(){
return this.map_drawing.circle_lib.length;},
setStrokeColor:function(rv,gv,bv){
if(rv<0||rv>255||gv<0||gv>255||bv<0||bv>255){
return false;}
this.obj.setStroke({r:rv,g:gv,b:bv});},
setStrokeWidth:function(wv){
if(wv<0||wv>10)
return false;
this.obj.setStroke({w:wv});},
setStrokeOpacity:function(ov){
if(ov>1||ov<0)
return false;
this.obj.setStroke({a:Math.ceil(ov*255)});},
setStroke:function(rv,gv,bv,ov,wv){
if(rv<0||rv>255||gv<0||gv>255||bv<0||bv>255)
return false;
if(ov==null)
ov=0.5;
if(ov>1||ov<0)
return false;
if(wv==null)
wv=5;
this.obj.setStroke({r:rv,g:gv,b:bv,a:Math.ceil(ov*255),w:wv});},
setFillColor:function(rv,gv,bv){
if(rv<0||rv>255||gv<0||gv>255||bv<0||bv>255){
return false;}
this.obj.setFill({r:rv,g:gv,b:bv});},
setFillOpacity:function(ov){
if(ov>1||ov<0)
return false;
this.obj.setFill({a:Math.ceil(ov*255)});},
setFill:function(rv,gv,bv,ov){
if(rv<0||rv>255||gv<0||gv>255||bv<0||bv>255)
return false;
if(ov>1||ov<0)
return false;
this.obj.setFill({r:rv,g:gv,b:bv,a:Math.ceil(ov*255)});},
removeFillColor:function(){
this.obj.setFill({});},
removeFill:function(){
this.obj.setFill({});},
draw:function(){
var xy=this.map_drawing.controller.map.__getClientXYByCoor(this.ln,this.la);
if(Graphic.rendererSupported("VML")){
this.obj.element.style.left=(xy[0]-Math.floor(this.radius/2))+"px";
this.obj.element.style.top=(xy[1]-Math.floor(this.radius/2))+"px";
this.obj.element.style.width=(this.radius)+"px";
this.obj.element.style.height=(this.radius)+"px";
this.obj.element.setAttribute("coordsize","21600,21600");}
else{
this.renderer.element.style.left=(xy[0]-10)+"px";
this.renderer.element.style.top=(xy[1]-10)+"px";
this.renderer.element.setAttribute("width",(this.radius*2)+"px");
this.renderer.element.setAttribute("height",(this.radius*2)+"px");
this.renderer.element.setAttribute("viewBox","0 0 "+(this.radius*2)+" "+(this.radius*2));}},
onAfterZoomUpdate:function(){
this.draw();}}
var MapDrawing=Class.create();
MapDrawing.prototype={
initialized:false,
initialize:function(controller){
if(controller==null||!(controller instanceof OverlayController))
return false;
this.controller=controller;
this.current_working_obj=null;
this.polyline_lib=[];
this.polygon_lib=[];
this.circle_lib=[];
this.drawing_point_lib=[];
this.dot_div=document.createElement("DIV");
this.controller.div.appendChild(this.dot_div);
this.dot_div.style.position="absolute";
this.dot_div.style.display="block";
this.dragged=false;
this.controller.map.addPolyline=this.addPolyline.bind(this);
this.controller.map.removePolyline=this.removePolyline.bind(this);
this.controller.map.addCircle=this.addCircle.bind(this);
this.controller.map.removeCircle=this.removeCircle.bind(this);
this.controller.map.addPolygon=this.addPolygon.bind(this);
this.controller.map.removePolygon=this.removePolygon.bind(this);
this.controller.map.addOnDragStartListener(this.dragStartListener.bind(this));
this.controller.map.addOnDragEndListener(this.dragEndListener.bind(this));
this.controller.map.addOnZoomListener(this.zoomListener.bind(this));
this.initialized=true;},
zoomListener:function(){
for(var i=0;i<this.polyline_lib.length;i++){
this.polyline_lib[i].onAfterZoomUpdate();}
for(var i=0;i<this.polygon_lib.length;i++){
this.polygon_lib[i].onAfterZoomUpdate();}
for(var i=0;i<this.circle_lib.length;i++){
this.circle_lib[i].onAfterZoomUpdate();}},
dragStartListener:function(){
this.cleanDot();
this.dragged=true;},
dragEndListener:function(){
this.dragged=false;},
getRender:function(){
var tmp=null;
if(Graphic.rendererSupported("VML"))
tmp=new Graphic.VMLRenderer(this.controller.map.tile_controller.div);
else if(Graphic.rendererSupported("SVG"))
tmp=new Graphic.SVGRenderer(this.controller.map.tile_controller.div);
else if(Graphic.rendererSupported("Canvas"))
tmp=new Graphic.CanvasRenderer(this.controller.map.tile_controller.div);
return tmp;},
addDrawingPoint:function(){},
addCircle:function(circle){
if(circle==null||!(circle instanceof MapCircle)||typeof(circle.__initializeObject)!="function")
return false;
circle.__initializeObject(this);
this.circle_lib.push(circle);
this.current_working_obj=this.circle_lib[this.circle_lib.length-1];
return this.circle_lib[this.circle_lib.length-1];},
removeCircle:function(circle){
if(circle.tmp_id==null||circle.tmp_id>this.circle_lib.length)
return false;
this.circle_lib[circle.tmp_id].destory();
this.circle_lib.splice(circle.tmp_id,1);},
addPolyline:function(polyline){
if(polyline==null||!(polyline instanceof MapPolyline)||typeof(polyline.__initializeObject)!="function")
return false;
polyline.__initializeObject(this);
this.polyline_lib.push(polyline);
this.current_working_obj=this.polyline_lib[this.polyline_lib.length-1];
return this.polyline_lib[this.polyline_lib.length-1];},
endOfAddPolyline:function(){
this.current_working_obj=null;},
removePolylineByGroup:function(name){},
removePolyline:function(polyline){
var pos=-1;
for(var i=0;i<this.polyline_lib.length;i++){
if(this.polyline_lib[i]==polyline){
pos=i;}}
if(pos==-1)
return false;
this.polyline_lib[pos].destory();
this.polyline_lib.splice(pos,1);
return true;},
addPolygon:function(polygon){
if(polygon==null||!(polygon instanceof MapPolygon)||typeof(polygon.__initializeObject)!="function")
return false;
polygon.__initializeObject(this);
this.polygon_lib.push(polygon);
this.current_working_obj=this.polygon_lib[this.polygon_lib.length-1];
return this.polygon_lib[this.polygon_lib.length-1];},
endOfAddPolygon:function(){
this.current_working_obj=null;},
removePolygon:function(polygon){
if(polygon.tmp_id==null||polygon.tmp_id>this.polygon_lib.length)
return false;
this.polygon_lib[polygon.tmp_id].destory();
this.polygon_lib.splice(polygon.tmp_id,1);},
setDot:function(points){
if(points==null)
return;
var x1=this.controller.map.__getOffset(this.controller.map.div,true);
var x2=x1+this.controller.map.div.offsetWidth;
var xdiff=Math.abs(x2-x1);
var divide=5;
var divide_set=false;
var points_added=0;
var dots=this.dot_div.getElementsByTagName("DIV");
for(var i=0;i<(points.length-1);i++){
var length=Math.sqrt((Math.pow((points[i+1][0]-points[i][0]),2)+Math.pow((points[i+1][1]-points[i][1]),2)));
if((length/xdiff)>1){
if(!divide_set){
divide=Math.round(divide*(length/xdiff));
if(divide>50)
divide=50;}}
var num_of_dot=((length/divide)/4);
var with_end_dot=false;
if(i==(points.length-2)){
with_end_dot=true;
num_of_dot++;}
var angle=Math.atan(Math.abs(points[i+1][1]-points[i][1])/Math.abs(points[i+1][0]-points[i][0]));
var angle2=1;
if(points[i+1][0]<points[i][0]){
angle2=-1;}
if(points[i+1][1]<points[i][1]){
angle=angle*(-1);}
var pos=0;
var left_pos=null;
var top_pos=null;
for(var x=0;x<num_of_dot;x++){
if(points_added>=(dots.length-1)){
var e=document.createElement("DIV");
e.style.position="absolute";
e.style.width="5px";
e.style.height="5px";
e.style.fontSize="1%";
e.style.backgroundColor="#333333";
this.dot_div.appendChild(e);
dots=this.dot_div.getElementsByTagName("DIV");}
left_pos=null;
top_pos=null;
if(with_end_dot&&x==0){
left_pos=parseInt(points[i+1][0]-this.controller.map.__getOffset(this.dot_div,true));
top_pos=parseInt(points[i+1][1]-this.controller.map.__getOffset(this.dot_div,false));}
else{
left_pos=parseInt(((Math.cos(angle)*pos*angle2)+points[i][0])-this.controller.map.__getOffset(this.dot_div,true));
top_pos=parseInt(((Math.sin(angle)*pos)+points[i][1])-this.controller.map.__getOffset(this.dot_div,false));
pos+=(divide*4);}
if(left_pos!=null&&!isNaN(left_pos)&&top_pos!=null&&!isNaN(top_pos)){
dots[points_added].style.left=(left_pos)+"px";
dots[points_added].style.top=(top_pos)+"px";
dots[points_added].style.display="block";}
points_added++;}}
for(var i=points_added;i<dots.length;i++){
dots[i].style.display="none";}},
cleanDot:function(){
var dots=this.dot_div.getElementsByTagName("DIV");
for(var i=0;i<dots.length;i++){
dots[i].style.display="none";}}}
var OverlayController=Class.create();
OverlayController.prototype={
initialized:false,
map_point_set:null,
map_point_set_count:0,
map_point_set_arr:null,
map_point_set_timer:null,
add_map_point_set_timer:null,
map_point_message_panel:null,
polyline_set:null,
polyline_set_count:0,
polyline_set_arr:null,
polyline_set_timer:null,
polygon_set:null,
polygon_set_count:0,
polygon_set_arr:null,
polygon_set_timer:null,
initialize:function(map){
if(map==null||this.initialized)
return false;
this.map=map;
this.div=document.createElement("DIV");
this.div.style.position="absolute";
this.div.style.left="0px";
this.div.style.top="0px";
this.div.style.zIndex="56";
this.map.tile_controller.div.appendChild(this.div);
this.map.addMapPoint=this.addMapPoint.bind(this);
this.map.removeMapPoint=this.removeMapPoint.bind(this);
this.map.addMapPointSet=this.addMapPointSet.bind(this);
this.map.removeAllMapPoint=this.removeAllMapPoint.bind(this);
this.map.removeMapPointByGroupName=this.removeMapPointByGroupName.bind(this);
this.map.addPolyline=this.addPolyline.bind(this);
this.map.addPolylineSet=this.addPolylineSet.bind(this);
this.map.addPolygon=this.addPolygon.bind(this);
this.map.addPolygonSet=this.addPolygonSet.bind(this);
this.map_point_unique_id=0;
this.map_point_set=[];
this.polyline_unique_id=0;
this.polyline_set=[];
this.polygon_unique_id=0;
this.polygon_set=[];
this.map.addOnZoomListener(this.onZoomChangeListener.bind(this));
this.map_point_message_panel=document.createElement("DIV");
this.map_point_message_panel.style.display="none";
this.map_point_message_panel.className="map_msg_panel";
this.map.div.appendChild(this.map_point_message_panel);
this.drawing=new MapDrawing(this);
this.map_point_id=0;},
getMapPointByUniqueId:function(id){
var left=-1;
var right=this.map_point_set.length;
var mid;
while(right-left>1){
mid=(left+right)>>>1;
if(this.map_point_set[mid].unique_id<id)
left=mid;
else
right=mid;}
if(this.map_point_set[right].unique_id!=id)
return -(right+1);
return this.map_point_set[right];},
addMapPoint:function(obj){
if(obj instanceof MapPoint){
if(typeof(obj.group)=="undefined"||obj.group==null)
obj.group="default";
obj.map=this.map;
obj.unique_id=this.map_point_unique_id;
this.map_point_unique_id++;
this.div.appendChild(obj.div);
obj.setPosition();
obj.show();
obj.map_point_id=this.map_point_id;
this.map_point_id++;
this.map_point_set.push(obj);}},
removeAllMapPoint:function(){
for(var i=0;i<this.map_point_set.length;i++){
this.div.removeChild(this.map_point_set[i].div);}
this.map_point_set=[];},
removeMapPointByGroupName:function(name){
var new_arr=[];
for(var i=0;i<this.map_point_set.length;i++){
if(this.map_point_set[i].opt.group!=null&&this.map_point_set[i].opt.group==name){
this.div.removeChild(this.map_point_set[i].div);}
else{
new_arr.push(this.map_point_set[i]);}}
this.map_point_set=[];
for(var i=0;i<new_arr.length;i++){
this.map_point_set.push(new_arr[i]);}},
removeMapPoint:function(obj){
var new_arr=[];
for(var i=0;i<this.map_point_set.length;i++){
if(obj==this.map_point_set[i]){
this.div.removeChild(obj.div);}
else{
new_arr.push(this.map_point_set[i]);}}
this.map_point_set=[];
for(var i=0;i<new_arr.length;i++){
this.map_point_set.push(new_arr[i]);}},
addPolyline:function(obj){},
removePolyline:function(obj){},
addPolygon:function(obj){},
removePolygon:function(obj){},
addMapPointSetAction:function(){},
addMapPointSet:function(obj_arr){
if(this.map_point_set_arr==null){
this.map_point_set_arr=obj_arr;
this.map_point_set_count=0;
this.map_point_message_panel.innerHTML="Adding Map Point <span id='add_map_point_counter"+this.map.map_id+"'>000</span> / "+this.map_point_set_arr.length;;
this.map_point_message_panel.style.display="block";
this.map_point_message_panel.style.zIndex="1000";
this.map_point_message_panel.style.position="absolute";
this.map_point_message_panel.style.left="0px";
this.map_point_message_panel.style.top="0px";
this.map_point_message_panel.style.left=((this.map.div.offsetWidth/2)-(this.map_point_message_panel.offsetWidth/2))+"px";
this.map_point_message_panel_counter=$('add_map_point_counter'+this.map.map_id);
this.add_map_point_set_timer=new PeriodicalExecuter(this.addMapPointSetAction.bind(this),0.001);
return true;}
else{
return false;}},
addMapPointSetAction:function(){
this.addMapPoint(this.map_point_set_arr[this.map_point_set_count]);
this.map_point_set_count++;
this.map_point_message_panel_counter.innerHTML=this.map_point_set_count;
if(this.map_point_set_count>this.map_point_set_arr.length-1){
this.cancelMapPointSetAction()}},
cancelMapPointSetAction:function(){
this.map_point_message_panel.style.display="none";
this.add_map_point_set_timer.stop();
this.add_map_point_set_timer=null;
this.map_point_set_arr=null;},
addPolylineSet:function(obj_arr){},
addPolygonSet:function(obj_arr){},
onZoomChangeTimerAction:function(){
this.map_point_set[this.map_point_set_count].setPosition();
this.map_point_set[this.map_point_set_count].show();
this.map_point_set_count++;
if(this.map_point_set_count>this.map_point_set.length-1){
this.map_point_set_timer.stop();
this.map_point_set_timer=null;}},
onZoomChangeListener:function(){
this.div.style.display="none";
for(var i=0;i<this.map_point_set.length;i++){
this.map_point_set[i].setPosition();}
this.div.style.display="";},
toJSON:function(){
var obj={};
obj.points=[];
for(var i=0;i<this.map_point_set.length;i++){
obj.points.push(this.map_point_set[i]);}
return Object.toJSON(obj);},
getSnap:function(){
return this.toJSON();},
setSnap:function(){}}
var MapGridHandler=Class.create();
MapGridHandler.prototype={
response_function:null,
initialized:false,
initialized_layout:false,
initialize:function(map){
if(typeof(map)=="undefined"||map==null)
return false;
this.map=map;
this.div=document.createElement("DIV");
this.div.style.width=this.map.div.offsetWidth+"px";
this.div.style.height=this.map.div.offsetHeight+"px";
this.div.style.position="absolute";
this.div.style.left="0px";
this.div.style.top="0px";
this.div.style.display="none";
this.div.style.zIndex="1000";
this.map.moving_panel.appendChild(this.div);
this.initialized=true;},
setResponseFunction:function(func){
if(typeof(func)!="function"||func==null||!this.initialized)
return false;
this.response_function=func;
this.map.addOnDragEndListener(this.response_function);},
setGridLayout:function(x,y){
if(x==null||isNaN(x)||y==null||isNaN(y)||!this.initialized)
return false;
while(this.div.childNodes.length>0)
this.div.removeChild(this.div.childNodes[0]);
this.num_of_x=x;
this.num_of_y=y;
this.num_of_px_per_xtile=Math.ceil(this.map.div.offsetWidth/this.num_of_x);
this.num_of_px_per_ytile=Math.ceil(this.map.div.offsetHeight/this.num_of_y);
var tmp=null;
for(var y=0;y<this.num_of_y;y++){
var y_px=y*this.num_of_px_per_ytile;
for(var x=0;x<this.num_of_x;x++){
var x_px=x*this.num_of_px_per_xtile;
tmp=document.createElement("DIV");
tmp.id="__map_grid_layer_"+x+"_"+y;
tmp.style.position="absolute";
tmp.style.left=(x_px)+"px";
tmp.style.top=(y_px)+"px";
tmp.style.width=this.num_of_px_per_xtile+"px";
tmp.style.height=this.num_of_px_per_ytile+"px";
this.div.appendChild(tmp);}}
this.initialized_layout=true;},
show:function(){
this.div.style.display="";},
hide:function(){
this.div.style.display="none";}}
var TileLayer=Class.create();
TileLayer.prototype={
name:"",
tiles:[],
opt:null,
tile_lib:CONST_MAP_TILE_LIB,
controller:null,
initialized:false,
initialized_tile:false,
opacity:1,
default_layer:null,
initialize:function(controller){
if(controller==null)
return false;
this.controller=controller;
this.opt={};
this.div=document.createElement("DIV");
this.div.style.position="absolute";
this.div.style.left="0px";
this.div.style.top="0px";
this.controller.div.appendChild(this.div);
this.initialized=true;},
initializeTiles:function(){
if(!this.initialized){
return;}
var clncla_arr=this.controller.map.__getTilePosByLnLa();
var current_x=Math.floor(clncla_arr[0])-Math.floor(this.controller.map.num_of_tile_x/2);
var current_y=Math.floor(clncla_arr[1])-Math.floor(this.controller.map.num_of_tile_y/2);
var y_tile_pos=current_y;
var x_tile_pos=current_x;
var margin_x_px=(clncla_arr[0]-Math.floor(clncla_arr[0]))*this.controller.map.tile_width;
var margin_y_px=(clncla_arr[1]-Math.floor(clncla_arr[1]))*this.controller.map.tile_height;
var margin_left=this.controller.map.__getOffset(this.controller.map.container,true)-this.controller.map.__getOffset(this.div,true);
var margin_top=this.controller.map.__getOffset(this.controller.map.container,false)-this.controller.map.__getOffset(this.div,false);
var center_x_px=parseInt((this.controller.map.div.offsetWidth/2)-margin_x_px-this.controller.map.__getOffset(this.controller.div,true));
var center_x_px=parseInt((this.controller.map.div.offsetWidth/2)-margin_x_px+margin_left);
var center_y_px=parseInt((this.controller.map.div.offsetHeight/2)-margin_y_px-this.controller.map.__getOffset(this.controller.div,false));
var center_y_px=parseInt((this.controller.map.div.offsetHeight/2)-margin_y_px+margin_top);
var l=0;
var t=0;
var map_lib_pos=0;
this.tiles=[];
while(this.div.childNodes.length>0){
this.div.removeChild(this.div.childNodes[0]);}
for(var x=0;x<this.controller.map.num_of_tile_x;x++){
this.tiles[x]=[];
y_tile_pos=current_y;
for(var y=0;y<this.controller.map.num_of_tile_y;y++){
map_lib_pos=Math.round((this.tile_lib.length-1)*Math.random());
this.tiles[x][y]=new Tile(this.controller.map,this.tile_lib[map_lib_pos],x_tile_pos,y_tile_pos,this.controller.map.current_zoom_level,this.controller.map.tile_width,this.controller.map.tile_height,this.opt);
this.div.appendChild(this.tiles[x][y].image);
if(this.opacity!=1){
Element.setOpacity($(this.tiles[x][y].image),this.opacity);}
l=(this.controller.map.tile_width*(x_tile_pos-Math.floor(clncla_arr[0])))+center_x_px;
t=(this.controller.map.tile_height*(y_tile_pos-Math.floor(clncla_arr[1])))+center_y_px;
this.tiles[x][y].setLeftTop(l,t);
y_tile_pos++;}
x_tile_pos++;}
this.tile_initialized=true;},
updateTiles:function(){
var clncla_arr=this.controller.map.__getTilePosByLnLa();
var current_x=Math.floor(clncla_arr[0])-Math.floor(this.controller.map.num_of_tile_x/2);
var current_y=Math.floor(clncla_arr[1])-Math.floor(this.controller.map.num_of_tile_y/2);
var y_tile_pos=current_y;
var x_tile_pos=current_x;
var margin_x_px=(clncla_arr[0]-Math.floor(clncla_arr[0]))*this.controller.map.tile_width;
var margin_y_px=(clncla_arr[1]-Math.floor(clncla_arr[1]))*this.controller.map.tile_height;
var margin_left=this.controller.map.__getOffset(this.controller.map.container,true)-this.controller.map.__getOffset(this.div,true);
var margin_top=this.controller.map.__getOffset(this.controller.map.container,false)-this.controller.map.__getOffset(this.div,false);
var center_x_px=parseInt((this.controller.map.div.offsetWidth/2)-margin_x_px-this.controller.map.__getOffset(this.controller.div,true));
var center_x_px=parseInt((this.controller.map.div.offsetWidth/2)-margin_x_px+margin_left);
var center_y_px=parseInt((this.controller.map.div.offsetHeight/2)-margin_y_px-this.controller.map.__getOffset(this.controller.div,false));
var center_y_px=parseInt((this.controller.map.div.offsetHeight/2)-margin_y_px+margin_top);
var l=0;
var t=0;
var map_lib_pos=0;
for(var x=0;x<this.controller.map.num_of_tile_x;x++){
y_tile_pos=current_y;
for(var y=0;y<this.controller.map.num_of_tile_y;y++){
this.tiles[x][y].resetProperties(this.tiles[x][y].src,x_tile_pos,y_tile_pos,this.controller.map.current_zoom_level,this.controller.map.tile_width,this.controller.map.tile_height,this.opt);
l=(this.controller.map.tile_width*(x_tile_pos-Math.floor(clncla_arr[0])))+center_x_px;
t=(this.controller.map.tile_height*(y_tile_pos-Math.floor(clncla_arr[1])))+center_y_px;
this.tiles[x][y].setLeftTop(l,t);
if(this.opacity!=1&&Element.getOpacity($(this.tiles[x][y].image))!=this.opacity){
Element.setOpacity($(this.tiles[x][y].image),this.opacity);}
y_tile_pos++;}
x_tile_pos++;}},
setName:function(val){
this.name=val;},
setZIndex:function(val){
this.div.style.zIndex=val;
for(var x=0;x<this.controller.map.num_of_tile_x;x++){
for(var y=0;y<this.controller.map.num_of_tile_y;y++){
this.tiles[x][y].image.style.zIndex=val;}}},
setOpacity:function(val){
this.opacity=val;
for(var x=0;x<this.controller.map.num_of_tile_x;x++){
for(var y=0;y<this.controller.map.num_of_tile_y;y++){
Element.setOpacity($(this.tiles[x][y].image),val);}}}}
var TileLayerController=Class.create();
TileLayerController.prototype={
div:null,
layers:null,
zoom_layer:null,
initialized:false,
default_tile_layer_added:false,
zoom_tile_layer_added:false,
initialize:function(map){
if(map==null)
return false;
this.with_smooth_zoom=false;
this.layers=[];
this.draggable=true;
this.map=map;
this.div=document.createElement("DIV");
this.div.style.position="absolute";
this.div.style.left="0px";
this.div.style.top="0px";
if(is_ie){
this.grab_cursor="http://map.hongkonghomes.com/map_lib/cursor/grab.cur";
this.rest_cursor="http://map.hongkonghomes.com/map_lib/cursor/rest.cur";
this.div.style.cursor="url('"+this.rest_cursor+"')";}
else{
this.grab_cursor="-moz-grabbing";
this.rest_cursor="-moz-grab";
this.div.style.cursor=this.rest_cursor;}
this.map.div.appendChild(this.div);
this.map.drag.init(this.div,null);
this.div.onDragStart=this.map.divOnDragStartListener.bind(this.map);
this.div.onDrag=this.map.divOnDragListener.bind(this.map);
this.div.onDragEnd=this.map.divOnDragEndListener.bind(this.map);
this.map.enableDrag=this.enableDrag.bind(this);
this.map.disableDrag=this.disableDrag.bind(this);
this.initialized=true;
if(this.map.map_id==1){
this.style_sheet=this.map.__addStyleClass(".zoom_tile2 {width:200px;height:200px;} ");}
return true;},
setGrab:function(){
this.div.style.cursor=this.grab_cursor;},
setRest:function(){
this.div.style.cursor=this.rest_cursor;},
disableDrag:function(){
this.draggable=false;
this.map.drag=null;
this.div.onmousedown=null;
this.div.onmouseup=null;
this.div.onmousemove=null;
this.div.onDragStart=null;
this.div.onDrag=null;
this.div.onDragEnd=null;},
enableDrag:function(){
this.draggable=true;
this.map.drag=Drag;
this.map.drag.init(this.div,null);
this.div.onDragStart=this.map.divOnDragStartListener.bind(this.map);
this.div.onDrag=this.map.divOnDragListener.bind(this.map);
this.div.onDragEnd=this.map.divOnDragEndListener.bind(this.map);},
updateTileLayers2:function(){
var clncla_arr=this.map.__getTilePosByLnLa();
var current_x=Math.floor(clncla_arr[0])-Math.floor(this.map.num_of_tile_x/2);
var current_y=Math.floor(clncla_arr[1])-Math.floor(this.map.num_of_tile_y/2);
var y_tile_pos=current_y;
var x_tile_pos=current_x;
var margin_x_px=(clncla_arr[0]-Math.floor(clncla_arr[0]))*this.map.tile_width;
var margin_y_px=(clncla_arr[1]-Math.floor(clncla_arr[1]))*this.map.tile_height;
var margin_left=this.map.__getOffset(this.map.container,true)-this.map.__getOffset(this.div,true);
var margin_top=this.map.__getOffset(this.map.container,false)-this.map.__getOffset(this.div,false);
var center_x_px=parseInt((this.map.div.offsetWidth/2)-margin_x_px-this.map.__getOffset(this.div,true));
var center_x_px=parseInt((this.map.div.offsetWidth/2)-margin_x_px+margin_left);
var center_y_px=parseInt((this.map.div.offsetHeight/2)-margin_y_px-this.map.__getOffset(this.div,false));
var center_y_px=parseInt((this.map.div.offsetHeight/2)-margin_y_px+margin_top);
var left=0;
var top=0;
var map_lib_pos=0;
for(var x=0;x<this.map.num_of_tile_x;x++){
y_tile_pos=current_y;
for(var y=0;y<this.map.num_of_tile_y;y++){
for(var l=0;l<this.layers.length;l++){
this.layers[l].tiles[x][y].resetProperties(this.layers[l].tiles[x][y].src,x_tile_pos,y_tile_pos,this.map.current_zoom_level,this.map.tile_width,this.map.tile_height,this.layers[l].opt);
left=(this.map.tile_width*(x_tile_pos-Math.floor(clncla_arr[0])))+center_x_px;
top=(this.map.tile_height*(y_tile_pos-Math.floor(clncla_arr[1])))+center_y_px;
this.layers[l].tiles[x][y].setLeftTop(left,top);
if(this.layers[l].opacity!=1&&Element.getOpacity($(this.layers[l].tiles[x][y].image))!=this.layers[l].opacity){
Element.setOpacity($(this.layers[l].tiles[x][y].image),this.layers[l].opacity);}}
y_tile_pos++;}
x_tile_pos++;}},
updateTileLayers:function(){
for(var l=0;l<this.layers.length;l++){
this.layers[l].updateTiles();}},
addDefaultTileLayer:function(){
if(this.default_tile_layer_added)
return false;
var default_tile_layer=new TileLayer(this);
default_tile_layer.setName("default");
default_tile_layer.initializeTiles();
default_tile_layer.setZIndex(50);
this.layers.push(default_tile_layer);
this.default_layer=this.layers[0];
this.default_tile_layer_added=true;},
addZoomTileLayer:function(){
if(this.zoom_tile_layer_added||!this.default_tile_layer_added)
return false;
this.zoom_layer=document.createElement("DIV");
this.zoom_layer.id="zoom_layer";
this.zoom_layer.style.position="absolute";
this.zoom_layer.style.display="none";
this.zoom_layer.style.overflow="visible";
this.zoom_layer.style.left=this.default_layer.tiles[0][0].image.offsetLeft+"px";
this.zoom_layer.style.top=this.default_layer.tiles[0][0].image.offsetTop+"px";
this.zoom_layer.style.width=((this.map.num_of_tile_x*this.map.tile_width))+"px";
this.zoom_layer.style.height=((this.map.num_of_tile_y*this.map.tile_height))+"px";
this.zoom_layer.style.zIndex="40";
this.div.appendChild(this.zoom_layer);
this.setZoomTile();},
setZoomTile:function(){
while(this.zoom_layer.childNodes.length>0)
this.zoom_layer.removeChild(this.zoom_layer.childNodes[0]);
var tmp_img=null;
for(var y=0;y<this.map.num_of_tile_y;y++){
for(var x=0;x<this.map.num_of_tile_x;x++){
tmp_img=document.createElement("IMG");
tmp_img.className="zoom_tile2";
tmp_img.id="zoom_"+x+"_"+y+"_"+this.map.map_id;
tmp_img.src=this.default_layer.tiles[x][y].image.src;
this.zoom_layer.appendChild(tmp_img);}
tmp_img=document.createElement("BR");
this.zoom_layer.appendChild(tmp_img);}
tmp_img=null;
this.zoom_tile_layer_added=true;},
standardInitZoomLayer:function(){
if(this.visual_effect_obj!=null)
this.visual_effect_obj.cancel();
this.setZoomLayerPosition();
this.setZoomLayerImage();
this.showZoomLayer();},
setZoomLayerPosition:function(){
this.zoom_layer.style.left=this.default_layer.tiles[0][0].image.offsetLeft+"px";
this.zoom_layer.style.top=this.default_layer.tiles[0][0].image.offsetTop+"px";},
showZoomLayer:function(){
this.zoom_layer.style.zIndex="60";
this.zoom_layer.style.display="";},
hideZoomLayer:function(){
this.zoom_layer.style.zIndex="40";
this.zoom_layer.style.display="none";},
setZoomLayerImage:function(){
for(var y=0;y<this.map.num_of_tile_y;y++){
for(var x=0;x<this.map.num_of_tile_x;x++){
$("zoom_"+x+"_"+y+"_"+this.map.map_id).src=this.default_layer.tiles[x][y].image.src;}}
var css_obj=this.map.__getStyleClass("zoom_tile2");
css_obj.style.width=200;
css_obj.style.height=200;},
zoomLayerAction:function(ratio,x,y){
var width=this.map.num_of_tile_x*this.map.tile_width;
var height=this.map.num_of_tile_y*this.map.tile_height;
var zoom_layer_left=this.map.__getOffset(this.zoom_layer,true);
var zoom_layer_top=this.map.__getOffset(this.zoom_layer,false);
var css=this.map.__getStyleClass("zoom_tile2");
if(x==null)
x=(this.map.div.offsetWidth/2)+this.map.__getOffset(this.map.div,true);
if(y==null)
y=(this.map.div.offsetHeight/2)+this.map.__getOffset(this.map.div,false);
if(ratio>0){
var rate=Math.pow(2,ratio);
var final_width=(width*rate);
var final_height=(height*rate);
this.zoom_layer.style.width=final_width+"px";
this.zoom_layer.style.height=final_height+"px"
var zoom_rate=0;
for(var r=0;r<ratio;r++){
zoom_rate=zoom_rate+Math.pow(2,r);}
zoom_layer_left=zoom_layer_left-((x-zoom_layer_left)*(zoom_rate));
zoom_layer_top=zoom_layer_top-((y-zoom_layer_top)*(zoom_rate));
var final_left=zoom_layer_left-this.div.offsetLeft;
var final_top=zoom_layer_top-this.div.offsetTop;
this.visual_effect_obj=new Effect.Parallel([
new Effect.Morph(this.zoom_layer,{style:'left:'+(final_left-this.map.__getOffset(this.map.div,true))+'px; top:'+(final_top-this.map.__getOffset(this.map.div,false))+'px'}),
new Effect.Morph2(css,{style:'width:'+(final_width/this.map.num_of_tile_x)+'px;height:'+(final_height/this.map.num_of_tile_y)+'px'})],{duration:1,
afterFinish:this.zoomLayerActionFinish.bind(this)});}
else{
var rate=0;
var amount=1;
for(var i=0;i<Math.abs(ratio);i++){
var tmp=amount/2;
amount=tmp;
rate+=amount;
zoom_layer_left=((x-zoom_layer_left)/2)+zoom_layer_left;
zoom_layer_top=((y-zoom_layer_top)/2)+zoom_layer_top;}
var final_left=zoom_layer_left-this.div.offsetLeft;
var final_top=zoom_layer_top-this.div.offsetTop;
var final_width=width-(width*rate);
var final_height=height-(height*rate);
this.visual_effect_obj=new Effect.Parallel([
new Effect.Morph(this.zoom_layer,{style:'left:'+(final_left-this.map.__getOffset(this.map.div,true))+'px; top:'+(final_top-this.map.__getOffset(this.map.div,false))+'px'}),
new Effect.Morph2(css,{style:'width:'+(final_width/this.map.num_of_tile_x)+'px;height:'+(final_height/this.map.num_of_tile_y)+'px'})],{duration:1,
afterFinish:this.zoomLayerActionFinish.bind(this)});}},
zoomLayerActionFinish:function(){
this.visual_effect_obj=null;
this.hideZoomLayer();
this.map.__afterChangeZoom();},
checkEdge:function(){
var edge_margin=this.map.__getLeftTopEdgeMargin();
while(edge_margin[0]>0){
this.moveLeft();
edge_margin=this.map.__getLeftTopEdgeMargin();}
while(edge_margin[1]<0){
this.moveRight();
edge_margin=this.map.__getLeftTopEdgeMargin();}
while(edge_margin[2]>0){
this.moveTop();
edge_margin=this.map.__getLeftTopEdgeMargin();}
while(edge_margin[3]<0){
this.moveBottom();
edge_margin=this.map.__getLeftTopEdgeMargin();}},
moveLeft:function(){
var new_left=this.default_layer.tiles[0][0].image.offsetLeft-this.map.tile_width;
var new_x=this.default_layer.tiles[0][0].x-1;
for(var l=0;l<this.layers.length;l++){
var o=this.layers[l].tiles.pop();
this.layers[l].tiles.unshift(o);
for(var i=0;i<o.length;i++){
o[i].updatePos(new_x,o[i].y,this.map.current_zoom_level,this.layers[l].opt);
o[i].image.style.left=new_left+"px";}}},
moveRight:function(){
var new_left=this.default_layer.tiles[this.default_layer.tiles.length-1][0].image.offsetLeft+this.map.tile_width;
var new_x=this.default_layer.tiles[this.default_layer.tiles.length-1][0].x+1;
for(var l=0;l<this.layers.length;l++){
var o=this.layers[l].tiles.shift();
this.layers[l].tiles.push(o);
for(var i=0;i<o.length;i++){
o[i].updatePos(new_x,o[i].y,this.map.current_zoom_level,this.layers[l].opt);
o[i].image.style.left=new_left+"px";}}},
moveTop:function(){
var new_top=this.default_layer.tiles[0][0].image.offsetTop-this.map.tile_height;
var new_y=this.default_layer.tiles[0][0].y-1;
for(var l=0;l<this.layers.length;l++){
for(var i=0;i<this.layers[l].tiles.length;i++){
var o=this.layers[l].tiles[i].pop();
this.layers[l].tiles[i].unshift(o);
o.updatePos(o.x,new_y,this.map.current_zoom_level,this.layers[l].opt);
o.image.style.top=new_top+"px";}}},
moveBottom:function(){
var new_top=this.default_layer.tiles[0][this.default_layer.tiles[0].length-1].image.offsetTop+this.map.tile_height;
var new_y=this.default_layer.tiles[0][this.default_layer.tiles[0].length-1].y+1;
for(var l=0;l<this.layers.length;l++){
for(var i=0;i<this.layers[l].tiles.length;i++){
var o=this.layers[l].tiles[i].shift();
this.layers[l].tiles[i].push(o);
o.updatePos(o.x,new_y,this.map.current_zoom_level,this.layers[l].opt);
o.image.style.top=new_top+"px";}}},
getLayerByName:function(name){
for(var l=0;l<this.layers.length;l++){
if(this.layers[l].name==name){
return this.layers[l];}}
return null;}}
var Map2=Class.create();
Map2.prototype={
drag:Drag,
hit_counter:0,
hit_counter_dop:0,
container:null,
tile_mode:0,
zoom:3,
map_id:1,
copyright_text:"&copy;2008&nbsp;Survey&nbsp;and&nbsp;Mapping&nbsp;Office,&nbsp;Lands&nbsp;Department<br>Copyright&nbsp;reserved&nbsp;-&nbsp;reproduction&nbsp;by&nbsp;permission&nbsp;only.",
thumbnail_zoom_level:4,
default_tile_width:200,
default_tile_height:200,
tile_width:200,
tile_height:200,
zooming_layer:null,
zooming_effect:null,
zooming_value:null,
on_drag_external_listener:null,
on_zoom_external_listener:null,
on_drag_start_external_listener:null,
on_drag_end_external_listener:null,
scroll_wheel_zoom_enable:true,
draggable:true,
dblclick_zoom:true,
dblclick_action:true,
dblclick_enable:true,
tile_controller:null,
check_edge_timeout:null,
mouse_wheel_checker:null,
mouse_wheel_zoom_level:null,
mouse_wheel_action_count:null,
mouse_wheel_action_count_history:null,
mouse_wheel_xy:null,
client_x:null,
client_y:null,
map_moving:false,
map_overview:null,
map_control:null,
initialize:function(container,opt){
if(typeof(CONST_ZOOM_P1)=="undefined"||typeof(CONST_ZOOM_P2)=="undefined")
return false;
if(container.tagName.toLowerCase()!="div")
return false;
this.container=container;
var tmp_c_left=this.__getOffset(this.container,true);
var tmp_c_top=this.__getOffset(this.container,false);
this.container.style.overflow="hidden";
this.container.style.position="absolute";
if(opt!=null&&opt.map_left!=null&&!isNaN(opt.map_left))
this.container.style.left=opt.map_left+"px";
else
this.container.style.left=tmp_c_left+"px";
if(opt!=null&&opt.map_top!=null&&!isNaN(opt.map_top))
this.container.style.top=opt.map_top+"px";
else
this.container.style.top=tmp_c_top+"px";
this.map_id=1;
if(opt!=null&&opt.map_id!=null&&!isNaN(opt.map_id))
this.map_id=opt.map_id;
while(typeof($("__map_panel_"+this.map_id))=="undefined"){
this.map_id++;}
this.on_drag_external_listener=[];
this.on_zoom_external_listener=[];
this.on_drag_start_external_listener=[];
this.on_drag_end_external_listener=[];
this.div=document.createElement("DIV");
this.div.className="map";
this.div.id="__map_panel_"+this.map_id;
this.div.style.overflow="hidden";
this.div.style.position="relative";
this.div.style.left="0px";
this.div.style.top="0px";
var tmp_width=(this.container.offsetWidth-parseInt((this.container.style.borderLeftWidth!=null)?this.container.style.borderLeftWidth:0)-parseInt((this.container.style.borderRightWidth!=null)?this.container.style.borderRightWidth:0)+1);
var tmp_height=(this.container.offsetHeight-parseInt((this.container.style.borderTopWidth!=null)?this.container.style.borderTopWidth:0)-parseInt((this.container.style.borderBottomWidth!=null)?this.container.style.borderBottomWidth:0)+1);
if(tmp_width<0)
tmp_width=1;
if(tmp_height<0)
tmp_height=1;
this.div.style.width=tmp_width+"px";
this.div.style.height=tmp_height+"px";
this.container.appendChild(this.div);
this.num_of_tile_x=Math.round(parseInt(this.container.offsetWidth)/this.tile_width)+2;
this.num_of_tile_y=Math.round(parseInt(this.container.offsetHeight)/this.tile_height)+2;
this.min_zoom=null;
this.max_zoom=null;
for(var i=0;i<CONST_ALL_ZOOM.length;i++){
var zoom_level=parseInt(CONST_ALL_ZOOM[i].level);
if(this.min_zoom==null||zoom_level<this.min_zoom)
this.min_zoom=zoom_level;
if(this.max_val==null||zoom_level>this.max_zoom)
this.max_zoom=zoom_level;}
if(this.map_id==1){
this.max_zoom-=2;}
this.current_zoom_level=CONST_DEFAULT_ZOOM;
this.current_zoom_obj=CONST_ZOOM_P1;
this.current_center_ln=CONST_DEFAULT_LN;
this.current_center_la=CONST_DEFAULT_LA;
this.tile_controller=new TileLayerController(this);
this.tile_controller.addDefaultTileLayer();
this.tile_controller.addZoomTileLayer();
this.tile_controller.div.ondblclick=this.__mapDblClickEventListener.bindAsEventListener(this);
this.moving_panel=this.tile_controller.div;
this.overlay_controller=new OverlayController(this);
if(window.addEventListener){
this.div.addEventListener('DOMMouseScroll',this.__mouseWheelCaptureNonIE.bindAsEventListener(this),false);
Event.observe(window,"mousemove",this.__mapMouseMoveEventListener.bindAsEventListener(this));}
this.div.onmousewheel=this.__mouseWheelCapture.bindAsEventListener(this);
this.map_point_id=0;},
divOnDragStartListener:function(evt){
this.dragging=true;
if(this.check_edge_timeout!=null)
this.check_edge_timeout.stop();
this.tile_controller.setGrab();
if(!this.tile_controller.draggable)
this.drag.end();
var e=this.__getEvt(evt);
if(e[1].getAttribute("draggable")=="0"||e[1].getAttribute("draggable")=="false"){
this.drag.end();}
this.check_edge_timeout=new PeriodicalExecuter(this.__dragTrackingAction.bind(this),0.2);
for(var i=0;i<this.on_drag_start_external_listener.length;i++){
this.on_drag_start_external_listener[i]();}},
divOnDragListener:function(){
this.tile_controller.setGrab();},
divOnDragEndListener:function(){
this.tile_controller.setRest();
if(this.tile_mode==0)
this.hit_counter++;
else
this.hit_counter_dop++;
this.dragging=false;
if(this.check_edge_timeout!=null)
this.check_edge_timeout.stop();
this.__dragTrackingAction();
for(var i=0;i<this.on_drag_end_external_listener.length;i++){
this.on_drag_end_external_listener[i]();}},
__mapMouseMoveEventListener:function(evt){
var e=evt?evt:window.event;
this.client_x=e.clientX;
this.client_y=e.clientY;},
__mapDblClickEventListener:function(evt){
if(!this.dblclick_enable)
return;
if(this.map_moving)
return;
this.map_moving=false;
var e=this.__getEvt(evt);
if(e[1].className!="maptile")
return;
var center=this.__getCenterPosition();
var map_center_left=center[0]+parseInt(this.container.style.borderLeftWidth);
var map_center_top=center[1]+parseInt(this.container.style.borderTopWidth);
new Effect.Move(this.tile_controller.div,{x:parseInt(map_center_left-e[0].clientX-document.body.scrollLeft),y:parseInt(map_center_top-e[0].clientY-document.body.scrollTop),mode:'relative',duration:0.2,afterFinish:this.__moveFinishedAction.bind(this,true)});},
__mouseWheelCaptureNonIE:function(evt){
try{
var e=this.__getEvt(evt);
if(this.scroll_wheel_zoom_enable){
if(evt.detail>0){
this.__mouseWheeling(e,1);}
else{
this.__mouseWheeling(e,-1);}}}
catch(e){}},
__mouseWheelCapture:function(evt){
try{
var e=this.__getEvt(evt);
if(this.scroll_wheel_zoom_enable){
if(e[0].wheelDelta<0){
if(is_ie||agt.indexOf("safari")!=-1)
this.__mouseWheeling(e,1);
else{
this.__mouseWheeling(e,-1);}}
else{
if(is_ie||agt.indexOf("safari")!=-1)
this.__mouseWheeling(e,-1);
else
this.__mouseWheeling(e,1);}}}catch(e){}},
__getCenterPosition:function(){
var center_left=(Math.ceil(this.div.offsetWidth/2)+this.__getOffset(this.div,true));
var center_top=(Math.ceil(this.div.offsetHeight/2)+this.__getOffset(this.div,false));
return[center_left,center_top];},
__mouseWheelStart:function(e){
this.mouse_wheel_zoom_level=0;
if(e!=null){
if(this.client_x!=null&&this.client_y!=null)
this.mouse_wheel_xy=[this.client_x+document.body.scrollLeft,this.client_y+document.body.scrollTop];
else
this.mouse_wheel_xy=[e[0].clientX+document.body.scrollLeft,e[0].clientY+document.body.scrollTop];}},
__mouseWheeling:function(e,direction){
if(this.mouse_wheel_action_count==null){
this.mouse_wheel_action_count=0;
this.__mouseWheelStart(e);}
if(direction>0){
this.mouse_wheel_zoom_level++;}
else{
this.mouse_wheel_zoom_level--;}
this.mouse_wheel__obj=e[1];
this.mouse_wheel_action_count++;
if(this.mouse_wheel_checker!=null)
this.mouse_wheel_checker.stop();
this.mouse_wheel_checker=new PeriodicalExecuter(this.__mouseWheelCheck.bind(this),0.01);},
__mouseWheelEnd:function(){
this.mouse_wheel_zoom_level=null;
this.mouse_wheel_action_count=null;},
__mouseWheelCheck:function(){
if(this.mouse_wheel_action_count_history==this.mouse_wheel_action_count){
if(this.mouse_wheel_checker!=null)
this.mouse_wheel_checker.stop();
var zoom_amount=0;
if(this.mouse_wheel_zoom_level>0){
zoom_amount=Math.ceil(this.mouse_wheel_zoom_level/7);}
else{
zoom_amount=(Math.ceil(Math.abs(this.mouse_wheel_zoom_level)/7))*-1;}
var loop_times=Math.abs(zoom_amount);
this.setZoomLevel(this.current_zoom_level+zoom_amount,this.mouse_wheel_xy[0],this.mouse_wheel_xy[1]);
this.mouse_wheel_action_count=null;
this.mouse_wheel_zoom_level=null;
this.mouse_wheel_xy=null;}
else{
this.mouse_wheel_action_count_history=this.mouse_wheel_action_count;}},
__dragTrackingAction:function(){
this.tile_controller.checkEdge();
this.__setCurrentCenterCoor();},
__void:function(){
return false;},
__addStyleClass:function(css){
var head,style;
head=document.getElementsByTagName('head')[0];
var style=document.createElement("style");
style.setAttribute("type","text/css");
if(style.styleSheet){
style.styleSheet.cssText=css;}
else{
var cssText=document.createTextNode(css);
style.appendChild(cssText);}
head.appendChild(style);
return style;},
__getStyleClass:function(className){
for(var s=0;s<document.styleSheets.length;s++){
try{
if(document.styleSheets[s].rules){
for(var r=0;r<document.styleSheets[s].rules.length;r++){
if(document.styleSheets[s].rules[r].selectorText=='.'+className){
return document.styleSheets[s].rules[r];}}}
else if(document.styleSheets[s].cssRules){
for(var r=0;r<document.styleSheets[s].cssRules.length;r++){
if(document.styleSheets[s].cssRules[r].selectorText=='.'+className)
return document.styleSheets[s].cssRules[r];}}}catch(e){}}
return null;},
__getTilePosByLnLa:function(ln,la,zoom){
if(ln==null)
var ln=this.current_center_ln;
if(la==null)
var la=this.current_center_la;
var zoom_property=this.current_zoom_obj;
if(zoom!=null)
zoom_property=zoom;
var y2=(parseInt(zoom_property["la"])-parseInt(la))/parseFloat(zoom_property["total_y_meter"]);
var y3=y2*parseFloat(zoom_property["total_y_px"]);
var cla=y3/this.default_tile_height;
var x2=(parseInt(ln)-parseInt(zoom_property["ln"]))/parseFloat(zoom_property["total_x_meter"]);
var x3=x2*parseFloat(zoom_property["total_x_px"]);
var cln=x3/this.default_tile_width;
return[cln,cla];},
__getEvt:function(evt){
var e=evt?evt:window.event;
var src=((ie)?e.srcElement:e.target);
return[e,src];},
__getOffset:function(obj,bool){
var total=0;
while(obj!=null){
total+=obj["offset"+(bool?"Left":"Top")];
obj=obj.offsetParent;}
return total;},
__getMapDivLeftTop:function(){
var l=this.__getOffset(this.container,true);
var t=this.__getOffset(this.container,false);
return[l,t];},
__getLeftTopEdgeMargin:function(){
var map_div_pos=this.__getMapDivLeftTop();
var v1=(parseInt(this.__getOffset(this.tile_controller.default_layer.tiles[0][0].image,true))-map_div_pos[0]);
var v2=parseInt(this.__getOffset(this.tile_controller.default_layer.tiles[0][0].image,true))+(this.num_of_tile_x*this.tile_width)-(map_div_pos[0]+this.div.offsetWidth);
var v3=(parseInt(this.__getOffset(this.tile_controller.default_layer.tiles[0][0].image,false))-map_div_pos[1]);
var v4=parseInt(this.__getOffset(this.tile_controller.default_layer.tiles[0][0].image,false))+(this.num_of_tile_y*this.tile_height)-(map_div_pos[1]+this.div.offsetHeight);
return[v1,v2,v3,v4];},
__getCoorByClientXY2:function(x,y){
var center=this.__getCenterPosition();
var center_left=center[0];
var center_top=center[1];
var center_obj=this.__getCenterObjAndMargin();
var diff_x=((x-center_left)/this.tile_width);
var diff_y=((y-center_top)/this.tile_height);
var pos_x=center_obj[0].x+(diff_x);
var pos_y=center_obj[0].y+(diff_y);
var coor=this.__getCoorByObjPosAndMargin(Math.floor(pos_x),Math.floor(pos_y),Math.floor(((pos_x-Math.floor(pos_x)))*200)+center_obj[1],Math.floor(((pos_y-Math.floor(pos_y)))*200)+center_obj[2]);
if(coor==null||coor.length!=2)
return false;
else
return[coor[0],coor[1]];},
__getClientXYByCoor:function(ln,la){
var center=this.__getCenterPosition();
var clncla=this.__getTilePosByLnLa(Math.floor(ln),Math.floor(la));
var center_clncla=this.__getTilePosByLnLa();
var obj=$("tile_"+Math.floor(clncla[0])+"_"+Math.floor(clncla[1])+"_"+this.current_zoom_level+"_"+this.map_id);
if(obj!=null){
var final_left=this.__getOffset(obj,true)+Math.floor((clncla[0]-Math.floor(clncla[0]))*this.tile_width);
var final_top=this.__getOffset(obj,false)+Math.floor((clncla[1]-Math.floor(clncla[1]))*this.tile_height);}
else{
var final_left=Math.ceil(center[0])-Math.ceil((center_clncla[0]-clncla[0])*this.tile_width);
var final_top=Math.ceil(center[1])-Math.ceil((center_clncla[1]-clncla[1])*this.tile_height);}
final_left=final_left-this.__getOffset(this.div,true)-this.tile_controller.div.offsetLeft;
final_top=final_top-this.__getOffset(this.div,false)-this.tile_controller.div.offsetTop
return[final_left,final_top];},
__getCoorByClientXY:function(x,y){
if(x==null||y==null)
return false;
var target_tile=null;
var tl=x;
var tt=y;
for(var x=0;x<this.num_of_tile_x;x++){
for(var y=0;y<this.num_of_tile_y;y++){
var l1=this.__getOffset(this.tile_controller.default_layer.tiles[x][y].image,true);
var t1=this.__getOffset(this.tile_controller.default_layer.tiles[x][y].image,false);
var l2=l1+this.tile_width;
var t2=t1+this.tile_height;
if(l1<=tl&&t1<=tt&&l2>=tl&&t2>=tt){
target_tile=this.tile_controller.default_layer.tiles[x][y];
break;}}
if(target_tile!=null)
break;}
if(target_tile==null)
return null;
var obj_x=tl-parseInt(this.__getOffset(target_tile.image,true));
var obj_y=tt-parseInt(this.__getOffset(target_tile.image,false));
try{
return this.__getCoorByObjAndMargin(target_tile,obj_x,obj_y);}catch(e){
return null;}},
__getCenterObjAndMargin:function(){
var target_tile=null;
var center=this.__getCenterPosition();
var tl=center[0];
var tt=center[1];
for(var x=0;x<this.num_of_tile_x;x++){
for(var y=0;y<this.num_of_tile_y;y++){
var l1=this.__getOffset(this.tile_controller.default_layer.tiles[x][y].image,true);
var t1=this.__getOffset(this.tile_controller.default_layer.tiles[x][y].image,false);
var l2=l1+this.tile_width;
var t2=t1+this.tile_height;
if(l1<=tl&&t1<=tt&&l2>=tl&&t2>=tt){
target_tile=this.tile_controller.default_layer.tiles[x][y];
break;}}
if(target_tile!=null)
break;}
if(target_tile==null)
return false;
obj_x=tl-parseInt(this.__getOffset(target_tile.image,true));
obj_y=tt-parseInt(this.__getOffset(target_tile.image,false));
return[target_tile,obj_x,obj_y];},
__getCoorByObjPosAndMargin:function(pos_x,pos_y,margin_x,margin_y){
var glat=((((
parseInt(pos_y))*this.tile_height)+margin_y)/this.current_zoom_obj["total_y_px"])*this.current_zoom_obj["total_y_meter"];
glat=Math.floor(this.current_zoom_obj["la"])-glat;
var glng=((((
parseInt(pos_x))*this.tile_width)+margin_x)/this.current_zoom_obj["total_x_px"])*this.current_zoom_obj["total_x_meter"];
glng=glng+Math.floor(this.current_zoom_obj["ln"]);
return[glng,glat];},
__getCoorByObjAndMargin:function(obj,margin_x,margin_y){
var id_arr=obj.image.id.split("_");
return this.__getCoorByObjPosAndMargin(id_arr[1],id_arr[2],margin_x,margin_y);},
__setCurrentCenterCoor:function(){
var tmp=this.__getCenterObjAndMargin();
var tmp2=this.__getCoorByObjAndMargin(tmp[0],tmp[1],tmp[2]);
this.current_center_ln=tmp2[0];
this.current_center_la=tmp2[1];},
__moveFinishedAction:function(with_zoom){
this.tile_controller.checkEdge();
this.__setCurrentCenterCoor();
if(typeof(with_zoom)!="undefined"&&with_zoom===true)
this.zoomIn();
if(this.map_overview!=null){
this.map_overview.onDragEndListener();}
this.map_moving=false;},
__getZoomInConfig:function(){
var tmp_zoom_val=this.current_zoom_level;
this.current_zoom_level--;
if(this.current_zoom_level<this.min_zoom)
this.current_zoom_level=this.min_zoom;
var tmp_zoom_level=this.current_zoom_level;
if(this.current_zoom_level==tmp_zoom_val)
return false;
var tmp_zoom_obj=null;
for(var i=0;i<CONST_ALL_ZOOM.length;i++){
if(CONST_ALL_ZOOM[i].level==tmp_zoom_level){
tmp_zoom_obj=CONST_ALL_ZOOM[i];}}
if(tmp_zoom_obj==null){
return false;}
else
this.current_zoom_obj=tmp_zoom_obj;},
__getZoomOutConfig:function(){
var tmp_zoom_val=this.current_zoom_level;
this.current_zoom_level++;
if(this.current_zoom_level>this.max_zoom)
this.current_zoom_level=this.max_zoom;
if(this.current_zoom_level<this.min_zoom){
var margin=Math.abs(this.min_zoom-this.current_zoom_level);
this.tile_width=this.default_tile_width+(margin*200);
this.tile_height=this.default_tile_width+(margin*200);}
if(this.current_zoom_level==tmp_zoom_val)
return false;
var tmp_zoom_obj=null;
for(var i=0;i<CONST_ALL_ZOOM.length;i++){
if(CONST_ALL_ZOOM[i].level==this.current_zoom_level){
tmp_zoom_obj=CONST_ALL_ZOOM[i];}}
if(tmp_zoom_obj==null)
return false;
else
this.current_zoom_obj=tmp_zoom_obj;},
__afterChangeZoom:function(){
for(var i=0;i<this.on_zoom_external_listener.length;i++){
this.on_zoom_external_listener[i]();}},
setSmoothZoom:function(bool){
if(this.tile_controller!=null&&this.tile_controller instanceof TileLayerController){
this.tile_controller.with_smooth_zoom=bool;}},
getOptimizeMapCenterAndZoomLevelByMaxMinCoor:function(min_ln,max_ln,min_la,max_la){
try{
if(min_ln!=null&&max_ln!=null&&min_la!=null&&max_la!=null){
var center_ln=Math.floor((max_ln-min_ln)/2);
var center_la=Math.floor((max_la-min_la)/2);
var ln_margin=(max_ln-min_ln);
var la_margin=(max_la-min_la);
var zoom_case=0;
var ln_ratio=ln_margin/this.container.offsetWidth;
var la_ratio=la_margin/this.container.offsetHeight;
if(ln_margin>la_margin)
zoom_case=1;
else if(la_margin>ln_margin)
zoom_case=2;
var possible_level=[];
var possible_rate=[];
var rate=1;
for(var i=0;i<CONST_ALL_ZOOM.length;i++){
switch(zoom_case){
case 1:
case 0:
if(parseFloat(CONST_ALL_ZOOM[i].glg1_per_px)>ln_ratio){
possible_level.push(parseInt(CONST_ALL_ZOOM[i].level));
possible_rate.push(parseFloat(CONST_ALL_ZOOM[i].glg1_per_px));
rate=ln_ratio;}
break;
case 2:
if(parseFloat(CONST_ALL_ZOOM[i].gla1_per_px)>la_ratio){
possible_level.push(parseInt(CONST_ALL_ZOOM[i].level));
possible_rate.push(parseFloat(CONST_ALL_ZOOM[i].gla1_per_px));
rate=la_ratio;}
break;}}
var min_zoom=0;
var pos=-1;
var plus=0;
if(possible_level.length>0){
min_zoom=100;
for(var i=0;i<possible_level.length;i++){
if(possible_level[i]<min_zoom){
min_zoom=possible_level[i];
pos=i;}}}
if((rate/possible_rate[pos])>0.6)
plus=1;
return[(min_zoom+plus),(min_ln+center_ln),(max_la-center_la)];}}
catch(e){
return false;}},
optimizeMapCenterAndZoomLevel:function(map_points){
var min_ln=null;
var max_ln=null;
var min_la=null;
var min_la=null;
var return_center_ln=null;
var return_center_la=null;
var return_zoom_level=null;
for(var i=0;i<map_points.length;i++){
if(map_points[i].ln==null||map_points[i].la==null)
continue;
if(map_points[i].ln>max_ln)
max_ln=map_points[i].ln;
else if(map_points[i].ln<min_ln)
min_ln=map_points[i].ln;
if(map_points[i].la>max_la)
max_la=map_points[i].la;
else if(map_points[i].la<min_la)
min_la=map_points[i].la;}
return this.getOptimizeMapCenterAndZoomLevelByMaxMinCoor(min_ln,max_ln,min_la,max_la);},
resize:function(width,height){
if(width==null||height==null||this.map_moving)
return false;
this.container.style.width=width+"px";
this.container.style.height=height+"px";
this.div.style.width=(this.container.offsetWidth-parseInt((this.container.style.borderLeftWidth!=null)?this.container.style.borderLeftWidth:0)-parseInt((this.container.style.borderRightWidth!=null)?this.container.style.borderRightWidth:0)+1)+"px";
this.div.style.height=(this.container.offsetHeight-parseInt((this.container.style.borderTopWidth!=null)?this.container.style.borderTopWidth:0)-parseInt((this.container.style.borderBottomWidth!=null)?this.container.style.borderBottomWidth:0)+1)+"px";
var num_x=Math.round(parseInt(this.container.offsetWidth)/this.tile_width)+2;
var num_y=Math.round(parseInt(this.container.offsetHeight)/this.tile_height)+2;
if(num_x>this.num_of_tile_x||num_y>this.num_of_tile_y){
this.num_of_tile_x=num_x;
this.num_of_tile_y=num_y;
for(var i=0;i<this.tile_controller.layers.length;i++){
this.tile_controller.layers[i].initializeTiles();}}
this.tile_controller.setZoomTile();
this.tile_controller.checkEdge();
this.setCenter();
if(this.map_overview!=null){
this.map_overview.onDragEndListener();
if(typeof(this.map_overview.setPosition)=="function")
this.map_overview.setPosition();}
if(this.map_control!=null&&typeof(this.map_control.setPosition)=="function"){
this.map_control.setPosition();}},
addMapControl:function(){
try{
if(this.map_control!=null)
this.div.removeChild(this.map_control.div);
this.map_control=new MapControlStandard(this);}catch(e){alert(e.message);}},
addMapControlMini:function(){
if(this.map_control!=null)
this.div.removeChild(this.map_control.div);
this.map_control=new MapControlMini(this);},
addMapOverview:function(){
this.map_overview=new MapOverview(this);},
switchMapMode:function(mode){
if(isNaN(mode))
return false;
this.tile_mode=mode;
if(this.tile_controller.layers.length>0){
this.tile_controller.default_layer.opt={"dop":mode};
this.tile_controller.default_layer.updateTiles();}
if(this.map_overview!=null){
this.map_overview.overview_map.switchMapMode(mode);}
return true;},
moveToEast:function(pixal){
if(this.map_moving||this.dragging)
return;
this.map_moving=true;
if(pixal==null||isNaN(pixal))
var pixal=400;
new Effect.Move(this.tile_controller.div,{x:(Math.abs(pixal)*(-1)),y:0,mode:'relative',duration:0.5,afterFinish:this.__moveFinishedAction.bind(this)});},
moveToSouth:function(pixal){
if(this.map_moving||this.dragging)
return;
this.map_moving=true;
if(pixal==null||isNaN(pixal))
var pixal=400;
new Effect.Move(this.tile_controller.div,{x:0,y:(Math.abs(pixal)*(-1)),mode:'relative',duration:0.5,afterFinish:this.__moveFinishedAction.bind(this)});},
moveToWest:function(pixal){
if(this.map_moving||this.dragging)
return;
this.map_moving=true;
if(pixal==null||isNaN(pixal))
var pixal=400;
new Effect.Move(this.tile_controller.div,{x:Math.abs(pixal),y:0,mode:'relative',duration:0.5,afterFinish:this.__moveFinishedAction.bind(this)});},
moveToNorth:function(pixal){
if(this.map_moving||this.dragging)
return;
this.map_moving=true;
if(pixal==null||isNaN(pixal))
var pixal=400;
new Effect.Move(this.tile_controller.div,{x:0,y:Math.abs(pixal),mode:'relative',duration:0.5,afterFinish:this.__moveFinishedAction.bind(this)});},
moveToNorthEast:function(x,y){
if(this.map_moving||this.dragging)
return;
this.map_moving=true;
if(x==null||isNaN(x)||x>400)
var x=400;
if(y==null||isNaN(y)||y>400)
var y=400;
new Effect.Move(this.tile_controller.div,{x:(Math.abs(x)*(-1)),y:Math.abs(y),mode:'relative',afterFinish:this.__moveFinishedAction.bind(this),duration:0.5});},
moveToSouthEast:function(x,y){
if(this.map_moving||this.dragging)
return;
this.map_moving=true;
if(x==null||isNaN(x)||x>400)
var x=400;
if(y==null||isNaN(y)||y>400)
var y=400;
new Effect.Move(this.tile_controller.div,{x:(Math.abs(x)*(-1)),y:(Math.abs(y)*(-1)),mode:'relative',afterFinish:this.__moveFinishedAction.bind(this),duration:0.5});},
moveToSouthWest:function(x,y){
if(this.map_moving||this.dragging)
return;
this.map_moving=true;
if(x==null||isNaN(x)||x>400)
var x=400;
if(y==null||isNaN(y)||y>400)
var y=400;
new Effect.Move(this.tile_controller.div,{x:Math.abs(x),y:(Math.abs(y)*(-1)),mode:'relative',afterFinish:this.__moveFinishedAction.bind(this),duration:0.5});},
moveToNorthWest:function(x,y){
if(this.map_moving||this.dragging)
return;
this.map_moving=true;
if(x==null||isNaN(x)||x>400)
var x=400;
if(y==null||isNaN(y)||y>400)
var y=400;
new Effect.Move(this.tile_controller.div,{x:Math.abs(x),y:Math.abs(y),mode:'relative',afterFinish:this.__moveFinishedAction.bind(this),duration:0.5});},
moveToByXY:function(x,y,func){
if(this.map_moving||this.dragging)
return;
if(x==null||isNaN(x))
return false;
if(y==null||isNaN(y))
return false;
this.map_moving=true;
if(x>0&&x>400)
x=400;
if(x<0&&x<-400)
x=-400;
if(y>0&&y>400)
y=400;
if(y<0&&y<-400)
y=-400;
new Effect.Move(this.tile_controller.div,{x:x,y:y,mode:'relative',afterFinish:((func!=null&&typeof(func)=="function")?func:this.__moveFinishedAction.bind(this)),duration:0.5});},
moveToByXYs:function(x,y){
if(this.map_moving||this.dragging)
return;
if(x==null||isNaN(x))
return false;
if(y==null||isNaN(y))
return false;
this.tile_controller.div.style.left=(this.tile_controller.div.offsetLeft+x)+"px";},
setZoomLevel:function(val,x,y,opt){
if(this.tile_controller.visual_effect_obj!=null)
return false;
if(isNaN(val))
return false;
if(val<this.min_zoom){
val=this.min_zoom;}
if(val>this.max_zoom){
val=this.max_zoom;}
if(this.current_zoom_level==val)
return false;
var ratio=this.current_zoom_level-val;
if(x!=null&&y!=null){
var mxx=parseInt((this.container.style.borderLeftWidth!=null)?this.container.style.borderLeftWidth:0);
var myy=parseInt((this.container.style.borderTopWidth!=null)?this.container.style.borderTopWidth:0);
x=x-mxx;
y=y-myy;
var center=this.__getCenterPosition();
var map_center_left=center[0];
var map_center_top=center[1];
var margin_times=Math.abs(this.current_zoom_level-val);
var margin_left=null;
var margin_top=null;
var final_left=map_center_left;
var final_top=map_center_top;
for(var m=0;m<margin_times;m++){
if(val>this.current_zoom_level){
margin_left=(x-map_center_left);
margin_top=(y-map_center_top);
final_left=(final_left-margin_left);
final_top=(final_top-margin_top);}
else{
margin_left=(x-map_center_left)/2;
margin_top=(y-map_center_top)/2;
final_left=Math.abs(final_left+margin_left);
final_top=Math.abs(final_top+margin_top);}
map_center_left=final_left;
map_center_top=final_top;}
var center_coor=this.__getCoorByClientXY2(final_left,final_top);
if(center_coor===false)
return false;
if(center_coor!=null&&center_coor.length==2){
this.current_center_ln=center_coor[0];
this.current_center_la=center_coor[1];}}
this.current_zoom_level=val;
var tmp_zoom_obj=null;
for(var i=0;i<CONST_ALL_ZOOM.length;i++){
if(CONST_ALL_ZOOM[i].level==this.current_zoom_level){
tmp_zoom_obj=CONST_ALL_ZOOM[i];}}
if(tmp_zoom_obj==null)
return false;
else
this.current_zoom_obj=tmp_zoom_obj;
if((opt!=null&&opt.no_smooth_zoom!=null&&opt.no_smooth_zoom)||!this.tile_controller.with_smooth_zoom){
this.tile_controller.updateTileLayers2();
this.__afterChangeZoom();}
else{
if(ratio<0){
this.tile_controller.standardInitZoomLayer();
this.tile_controller.updateTileLayers2();
this.tile_controller.zoomLayerAction(ratio,x,y);}
else{
this.tile_controller.standardInitZoomLayer();
this.tile_controller.updateTileLayers2();
this.tile_controller.zoomLayerAction(ratio,x,y);}}
return true;},
zoomIn:function(x,y){
if(this.tile_controller.visual_effect_obj!=null)
return false;
if(x!=null&&y!=null){
var center=this.__getCenterPosition();
var map_center_left=center[0];
var map_center_top=center[1];
var margin_left=(x-map_center_left)/2;
var margin_top=(y-map_center_top)/2;
var final_left=Math.ceil(Math.abs(map_center_left+margin_left));
var final_top=Math.ceil(Math.abs(map_center_top+margin_top));
var center_coor=this.__getCoorByClientXY(final_left,final_top);
if(center_coor!=null&&center_coor.length==2){
this.current_center_ln=center_coor[0];
this.current_center_la=center_coor[1];}}
var tmp=this.__getZoomInConfig();
if(tmp===false)
return false;
this.tile_controller.updateTileLayers2();
this.__afterChangeZoom();
return true;},
zoomOut:function(x,y){
if(this.tile_controller.visual_effect_obj!=null)
return false;
if(x!=null&&y!=null){
var center=this.__getCenterPosition();
var map_center_left=center[0];
var map_center_top=center[1];
var margin_left=(x-map_center_left);
var margin_top=(y-map_center_top);
var final_left=Math.ceil(Math.abs(map_center_left-margin_left));
var final_top=Math.ceil(Math.abs(map_center_top-margin_top));
var center_coor=this.__getCoorByClientXY(final_left,final_top);
if(center_coor!=null&&center_coor.length==2){
this.current_center_ln=center_coor[0];
this.current_center_la=center_coor[1];}}
var tmp=this.__getZoomOutConfig();
if(tmp===false)
return false;
this.tile_controller.updateTileLayers2();
this.__afterChangeZoom();
return true;},
getCenterCoor:function(){
var center=this.__getCenterPosition();
var map_center_left=center[0];
var map_center_top=center[1];
var center_coor=this.__getCoorByClientXY2(map_center_left,map_center_top);
return center_coor;},
getBoundaryCoor:function(){
var left=this.__getOffset(this.div,true);
var top=this.__getOffset(this.div,false);
var lt_coor=this.__getCoorByClientXY2(left,top);
var left=(Math.ceil(this.div.offsetWidth)+this.__getOffset(this.div,true));
var top=(Math.ceil(this.div.offsetHeight)+this.__getOffset(this.div,false));
var rb_coor=this.__getCoorByClientXY2(left,top);
return[lt_coor,rb_coor];},
setCenter:function(ln,la,smooth){
if(ln==null||la==null){
var ln=this.current_center_ln;
var la=this.current_center_la;}
if(smooth==null||!smooth){
this.current_center_ln=ln;
this.current_center_la=la;
this.tile_controller.updateTileLayers2();
this.overlay_controller.onZoomChangeListener();
this.divOnDragEndListener();}
else{
var xy1=this.__getClientXYByCoor(this.current_center_ln,this.current_center_la);
var xy2=this.__getClientXYByCoor(ln,la);
this.current_center_ln=ln;
this.current_center_la=la;
var mx=xy1[0]-xy2[0];
var my=xy1[1]-xy2[1];
this.map_moving=true;
new Effect.Move(this.tile_controller.div,{x:mx,y:my,mode:'relative',afterFinish:this.afterSmoothSetCenter.bind(this),duration:0.5});}},
afterSmoothSetCenter:function(){
this.tile_controller.checkEdge();
this.__setCurrentCenterCoor();
this.overlay_controller.onZoomChangeListener();
this.map_moving=false;
this.divOnDragEndListener();},
addOnDragListener:function(f){
if(typeof(f)!="function")
return false;
this.on_drag_external_listener.push(f);},
removeOnDragListener:function(f){
if(typeof(f)!="function")
return false;
var pos=-1;
for(var i=0;i<this.on_drag_external_listener.length;i++){
if(f==this.on_drag_external_listener[i]){
pos=i;
break;}}
if(pos!=-1){
this.on_drag_external_listener.splice(pos,1);}},
addOnDragStartListener:function(f){
if(typeof(f)!="function")
return false;
this.on_drag_start_external_listener.push(f);},
removeOnDragStartListener:function(f){
if(typeof(f)!="function")
return false;
var pos=-1;
for(var i=0;i<this.on_drag_start_external_listener.length;i++){
if(f==this.on_drag_start_external_listener[i]){
pos=i;
break;}}
if(pos!=-1){
this.on_drag_start_external_listener.splice(pos,1);}},
addOnDragEndListener:function(f){
if(typeof(f)!="function")
return false;
this.on_drag_end_external_listener.push(f);},
removeOnDragEndListener:function(f){
if(typeof(f)!="function")
return false;
var pos=-1;
for(var i=0;i<this.on_drag_end_external_listener.length;i++){
if(f==this.on_drag_end_external_listener[i]){
pos=i;
break;}}
if(pos!=-1){
this.on_drag_end_external_listener.splice(pos,1);}},
addOnZoomListener:function(f){
if(typeof(f)!="function")
return false;
this.on_zoom_external_listener.push(f);},
removeOnZoomListener:function(f){
if(typeof(f)!="function")
return false;
var pos=-1;
for(var i=0;i<this.on_zoom_external_listener.length;i++){
if(f==this.on_zoom_external_listener[i]){
pos=i;
break;}}
if(pos!=-1){
this.on_zoom_external_listener.splice(pos,1);}},
enableScrollWheelZoom:function(){
this.scroll_wheel_zoom_enable=true;},
disableScrollWheelZoom:function(){
this.scroll_wheel_zoom_enable=false;},
enableDrag:function(){
this.draggable=true;},
disableDrag:function(){
this.draggable=false;},
enableDoubleClick:function(){
this.dblclick_enable=true;},
disableDoubleClick:function(){
this.dblclick_enable=false;},
setCopyrightText:function(val){
if(val==null)
return false;
this.copyright_text=val;
this.attachCopyrightText();},
resetCopyrightText:function(){
if(this.copyright_text==null)
return false;
this.copyright_text_div.style.left="3px";
this.copyright_text_div.style.top=(parseInt(this.container.offsetHeight)-parseInt(this.copyright_text_div.offsetHeight)-3)+"px";},
attachCopyrightText:function(){
if(this.copyright_text==null)
return false;
if(this.copyright_text_div==null){
this.copyright_text_div=window.document.createElement("div");
this.copyright_text_div.style.zIndex="1500";
this.copyright_text_div.style.position="absolute";
this.container.appendChild(this.copyright_text_div);}
this.copyright_text_div.innerHTML=this.copyright_text;
this.copyright_text_div.className="copyrighttext";
this.copyright_text_div.style.left="3px";
this.copyright_text_div.style.top=(parseInt(this.container.offsetHeight)-parseInt(this.copyright_text_div.offsetHeight)-3)+"px";},
detachCopyrightText:function(){
if(this.copyright_text_div!=null){
try{
this.container.removeChild(this.copyright_text_div);}
catch(e){}}},
toJSON:function(){
var obj={};
obj.center_ln=this.current_center_ln;
obj.center_la=this.current_center_la;
obj.zoom_level=this.current_zoom_level;
obj.tile_mode=this.tile_mode;
return Object.toJSON(obj);},
getSnap:function(){
return this.toJSON();},
parseSnap:function(str){
var obj=null;
eval("obj = "+str);
if(obj.center_ln!=null&&obj.center_la!=null){
this.setCenter(obj.center_ln,obj.center_la);
if(this.map_overview!=null){
this.map_overview.onDragEndListener();}}
if(obj.zoom_level!=null)
this.setZoomLevel(obj.zoom_level);
if(obj.tile_mode!=null)
this.switchMapMode(obj.tile_mode);}}
var MapZoom=Class.create();
MapZoom.prototype={
properties:null,
initialize:function(p,root){
if(p!=null){
this.parent=p;}
if(root!=null){
this.root=root;}
else{
this.root="";}},
setProperties:function(properties){
this.properties=((properties==null)?null:properties);},
getProperties:function(){
if(typeof(this.parent)=="undefined")
return false;
url=this.root+"xml/zoom_properties.php?z="+this.parent.zoom;
this.ajax_request=new Ajax.Request(
url,{
method:'get',
onComplete:this.getPropertiesRespone.bind(this)});},
getPropertiesRespone:function(req){
var xml=req.responseXML;
var data=xml.getElementsByTagName("item");
if(data.length>0){
this.properties=null;
eval(" this.properties = "+data[0].firstChild.nodeValue);}}}
var MapLatLng=Class.create();
MapLatLng.prototype={
latlng:null,
initialize:function(properties){
if(properties!=null){
var r=this.setLatLng(properties);}},
setLatLng:function(properties){
if(properties["lat"]!=null&&properties["lng"]!=null&&properties["gov_lat"]!=null&&properties["gov_lng"]!=null){
this.latlng=properties;
return true;}
else{
return false;}},
getLatLng:function(){
return this.latlng;}}
var MapLatLngBound=Class.create();
MapLatLngBound.prototype={
latlng_bound:null,
initialize:function(ll1,ll2){
var r=this.setLatLngVound(ll1,ll2)},
getLatLngBound:function(){
return this.latlng_bound;},
setLatLngBound:function(ll1,ll2){
latlng1=new MapLatLng(ll1);
latlng2=new MapLatLng(ll2);
if(latlng1.getLatLng()!=null&&latlng2.getLatLng()!=null){
this.latlng_bound=new Array();
this.latlng_bound.push(latlng1);
this.latlng_bound.push(latlng2);
return true;}
else{
return false;}}}
var Tile=Class.create();
Tile.prototype={
image:null,
coor:null,
initialize:function(p,src,x,y,z,w,h,opt){
this.parent=p;
this.x=x;
this.y=y;
this.z=z;
this.image=document.createElement("IMG");
this.image.id="tile_"+x+"_"+y+"_"+z+"_"+this.parent.map_id;
this.image.style.width=w+"px";
this.image.style.height=h+"px";
this.image.className="maptile";
this.image.style.position="absolute";
this.image.galleryimg="no";
this.left=0;
this.top=0;
this.image.style.left="0px";
this.image.style.top="0px";
this.image.style.display="";
this.tmp_image=new Image(this.parent.tile_width,this.parent.tile_height);
this.src=src;
var src=this.src+"?x="+this.x+"&y="+this.y+"&z="+this.z;
if(opt!=null&&typeof(opt)=="object"){
var h=$H(opt);
src=src+"&"+h.toQueryString();}
this.image.src=src;},
tmpImageOnLoad:function(){
this.image.src=this.tmp_image.src;},
getImage:function(){
return this.image;},
resetProperties:function(src,x,y,z,w,h,opt){
this.x=x;
this.y=y;
this.z=z;
this.image.id="tile_"+x+"_"+y+"_"+z+"_"+this.parent.map_id;
this.image.style.width=w+"px";
this.image.style.height=h+"px";
this.src=src;
this.updateSrc(opt);},
setImage:function(image_object){
this.image=image_object;},
setImageSrc:function(src){
if(this.image.tagName=="IMG"){
this.image.src=src;
return true;}
return false;},
setLeftTop:function(left,top){
this.left=left;
this.top=top;
this.image.style.left=left+"px";
this.image.style.top=top+"px";},
updateSrc:function(opt){
this.image.id="tile_"+this.x+"_"+this.y+"_"+this.z+"_"+this.parent.map_id;
var src=this.src+"?x="+this.x+"&y="+this.y+"&z="+this.z;
if(opt!=null&&typeof(opt)=="object"){
var h=$H(opt);
src=src+"&"+h.toQueryString();}
this.image.src=src;},
updatePos:function(x,y,z,opt){
this.x=x;
this.y=y;
this.z=z;
this.updateSrc(opt);}}
var MapGrid=Class.create();
MapGrid.prototype={
grid_item_width:100,
grid_item_height:50,
initialize:function(p){
this.parent=p;
this.num_x=Math.ceil(parseInt(this.parent.map_tile_container.div.offsetWidth)/this.grid_item_width);
this.num_y=Math.ceil(parseInt(this.parent.map_tile_container.div.offsetHeight)/this.grid_item_height);},
getGridObj:function(){
this.div=window.document.createElement("DIV");
w=this.num_x*this.grid_item_width+this.num_x;
h=this.num_y*this.grid_item_height+this.num_y;
this.div.style.width=w+"px";
this.div.style.height=h+"px";
this.div.style.position="absolute";
this.div.style.left="0px";
this.div.style.top="0px";
this.div.style.zIndex="1000";
this.div.id="grid_master";
this.html="";
l=0;
t=0;
for(var y=0;y<this.num_y;y++){
for(var x=0;x<this.num_x;x++){
l=x*this.grid_item_width;
div_l=window.document.createElement("DIV");
div_l.style.left=l+"px";
div_l.style.top=t+"px";
div_l.style.position="absolute";
div_l.style.width=this.grid_item_width+"px";
div_l.style.height=this.grid_item_height+"px";
div_l.style.border="1px #DDDDDD solid";
div_l.id="grid_"+x+"_"+y;
div_l.className="test";
div_l.style.display="none";
this.div.appendChild(div_l);}
t=t+this.grid_item_height;}
return this.div;}}
var MapContextMenu=Class.create();
MapContextMenu.prototype={
items:null,
initialize:function(){
this.items=new Array();
this.parent=null;
this.initDiv();},
initDiv:function(){
this.div=window.document.createElement("div");
this.div.style.position="absolute";
this.div.style.left="0px";
this.div.style.top="0px";
this.div.style.width="180px";
this.div.style.height="100px";
this.div.style.zIndex="2000";
this.div.style.display="none";
this.div.id="context_menu_div";
htm='<table width="180" border="0" cellpadding="2" cellspacing="1" bgcolor="#CCCCCC">';
htm+='  <tr>';
htm+='    <td bgcolor="#FFFFFF" id="context_menu_item_list">--</td>';
htm+='  </tr>';
htm+='</table>';
this.div.innerHTML=htm;
this.div_shad=window.document.createElement("div");
this.div_shad.style.position="absolute";
this.div_shad.style.left="8px";
this.div_shad.style.top="8px";
this.div_shad.style.width="180px";
this.div_shad.style.height="100px";
this.div_shad.style.display="none";
this.div_shad.style.zIndex="1900";
this.div_shad.style.backgroundColor="#999999";
this.div_shad.id="context_menu_shad";
this.div_shad.className="msgshad";
htm="&nbsp;";
this.div_shad.innerHTML=htm;},
searchGroup:function(g_name){
for(var i=0;i<this.items.length;i++){
if(this.items[i][0]!=null&&this.items[i][0]==gname)
return this.items[i];}
return null;},
deleteItemByObject:function(obj){
for(var i=0;i<this.items.length;i++){
if(this.items[i][0]!=null&&this.items[i][0]==obj.group){
var pos=-1;
for(var y=0;y<this.items[i].arr.length;y++){
if(this.items[i][1][y]==obj){
pos=y;
break;}}
if(pos!=-1){
return this.items[i][1].splice(pos,1);}}}
return null;},
sortItems:function(a,b){
if(a.k>b.k)
return 1
if(a.k<b.k)
return -1
return 0},
addItem:function(obj){
if(obj.text!=null&&obj.action!=null&&obj.group!=null){
obj.text.replace("<img","<img width='20px' height='20px'");
this.items.push({"k":obj.group,"o":obj});
this.items.sort(this.sortItems);}},
displayItems:function(){
var obj=$("context_menu_item_list");
obj.innerHTML="";
if(this.items.length==0)
obj.innerHTML="&nbsp;";
var last_k="";
for(var i=0;i<this.items.length;i++){
var tmp_o=document.createElement("div");
tmp_o.className="context_header_text";
if(this.items[i].k!=last_k){
if(i!=0){
xx=document.createElement("hr");
obj.appendChild(xx);}
tmp_o.innerHTML=this.items[i].k;}
obj.appendChild(tmp_o);
this.items[i].o.layer=document.createElement("a");
this.items[i].o.layer.className="context_item_text";
this.items[i].o.layer.innerHTML=this.items[i].o.text;
this.items[i].o.layer.href="javascript:a()";
this.items[i].o.layer.onclick=this.items[i].o.action;
obj.appendChild(this.items[i].o.layer);
last_k=this.items[i].k;}},
showMenu:function(obj,x,y){
this.parent.context_menu_x=x;
this.parent.context_menu_x=y;
var tmp=this.parent.calCoorByObj(obj,x,y);
this.parent.context_menu_ln=tmp[0];
this.parent.context_menu_la=tmp[1];
this.displayItems();
this.div.style.display="";
this.div.style.left=(x-this.parent.getOffset(this.parent.container,true))+"px";
this.div.style.top=(y-this.parent.getOffset(this.parent.container,false))+"px";
this.div.style.height=this.div.childNodes[0].offsetHeight+"px";
this.div_shad.style.display="";
this.div_shad.style.left=(x-this.parent.getOffset(this.parent.container,true)+5)+"px";
this.div_shad.style.top=(y-this.parent.getOffset(this.parent.container,false)+5)+"px";
this.div_shad.style.height=this.div.childNodes[0].offsetHeight+"px";},
hideMenu:function(){
this.div.style.display="none";
this.div_shad.style.display="none";}}
var MapOverview=Class.create();
MapOverview.prototype={
initialize:function(map){
if(map==null||!(map instanceof Map2))
return false;
this.map=map;
this.frame_div=document.createElement("DIV");
this.frame_div=document.createElement("DIV");
this.frame_div.style.position="absolute";
this.frame_div.style.backgroundColor="#FFFFFF";
this.frame_div.style.width="152px";
this.frame_div.style.height="152px";
this.frame_div.style.border="1px #333333 solid";
this.frame_div.style.left=(this.map.div.offsetWidth-152)+"px";
this.frame_div.style.top=(this.map.div.offsetHeight-152)+"px";
this.frame_div.style.zIndex="102";
this.map.div.appendChild(this.frame_div);
this.div=document.createElement("DIV");
this.div.style.position="absolute";
this.div.style.backgroundColor="#FFFFFF";
this.div.style.width="150px";
this.div.style.height="150px";
this.div.style.border="0px #333333 solid";
this.div.style.left=(this.map.div.offsetWidth-150)+"px";
this.div.style.top=(this.map.div.offsetHeight-150)+"px";
this.div.style.zIndex="102";
this.map.div.appendChild(this.div);
this.switch_div=document.createElement("DIV");
this.switch_div.style.position="absolute";
this.switch_div.style.backgroundColor="#FFFFFF";
this.switch_div.style.width="21px";
this.switch_div.style.height="21px";
this.switch_div.style.cursor="pointer";
this.switch_div.style.border="0px #333333 solid";
this.switch_div.style.left=(this.map.div.offsetWidth-21)+"px";
this.switch_div.style.top=(this.map.div.offsetHeight-21)+"px";
this.switch_div.innerHTML="<img src='"+CONST_IMG_PATH+"images/close_map_overview.gif'>";
this.switch_div.onclick=this.switchMapClick.bindAsEventListener(this);
this.switch_div.style.zIndex="103";
this.map.div.appendChild(this.switch_div);
this.boundary_div=document.createElement("DIV");
this.boundary_div.style.position="absolute";
this.boundary_div.style.backgroundImage="url("+CONST_IMG_PATH+"images/nbsp.gif)";
this.boundary_div.style.zIndex="5005";
this.boundary_div.style.display="none";
this.boundary_div.style.border="2px #333333 solid";
this.boundary_div.style.backgroundColor="#A6DBFF";
this.boundary_div.style.cursor="pointer";
this.div.appendChild(this.boundary_div);
Element.setOpacity($(this.boundary_div),0.3);
this.shield=document.createElement("DIV");
this.shield.style.position="absolute";
this.shield.style.backgroundImage="url("+CONST_IMG_PATH+"images/nbsp.gif)";
this.shield.style.width="150px";
this.shield.style.height="150px";
this.shield.style.left=(0)+"px";
this.shield.style.top=(0)+"px";
this.shield.style.zIndex="5004";
this.div.appendChild(this.shield);
Drag.init(this.boundary_div,null);
this.boundary_div.onDragEnd=this.onBoundaryDragEndListener.bind(this);
this.overview_map=new Map2(this.div,{map_id:2});
this.div.style.left=(this.map.div.offsetWidth-150)+"px";
this.div.style.top=(this.map.div.offsetHeight-150)+"px";
this.overview_map.dblclick_enable=false;
this.overview_map.setZoomLevel(this.map.current_zoom_level+4,null,null,{no_smooth_zoom:true});
this.overview_map.disableDrag();
this.map.addOnZoomListener(this.onZoomListener.bind(this));
this.map.addOnDragEndListener(this.onDragEndListener.bind(this));
this.setBoundaryLayer();
this.map.setMapOverviewPosition=this.setPosition.bind(this);
this.moving=0;},
setPosition:function(){
if(this.switch_div.childNodes[0].src.indexOf("open_")!=-1){
this.div.style.left=(this.map.div.offsetWidth)+"px";
this.div.style.top=(this.map.div.offsetHeight)+"px";
this.frame_div.style.left=(this.map.div.offsetWidth)+"px";
this.frame_div.style.top=(this.map.div.offsetHeight)+"px";}
else{
this.div.style.left=(this.map.div.offsetWidth-150)+"px";
this.div.style.top=(this.map.div.offsetHeight-150)+"px";
this.frame_div.style.left=(this.map.div.offsetWidth-152)+"px";
this.frame_div.style.top=(this.map.div.offsetHeight-152)+"px";}
this.switch_div.style.left=(this.map.div.offsetWidth-21)+"px";
this.switch_div.style.top=(this.map.div.offsetHeight-21)+"px";
this.setBoundaryLayer();},
show:function(){
this.moving=1;
this.div.style.display="block";
this.frame_div.style.display="block";
this.div.style.left=(parseInt(this.map.div.offsetWidth)-150)+"px";
this.div.style.top=(parseInt(this.map.div.offsetHeight)-150)+"px";
this.frame_div.style.left=(parseInt(this.map.div.offsetWidth)-152)+"px";
this.frame_div.style.top=(parseInt(this.map.div.offsetHeight)-152)+"px";
this.overview_map.setCenter(this.map.current_center_ln,this.map.current_center_la);
this.overview_map.setZoomLevel(this.map.current_zoom_level+4,null,null,{no_smooth_zoom:true});
this.setBoundaryLayer();
this.switch_div.childNodes[0].src=CONST_IMG_PATH+"images/close_map_overview.gif";
return;
new Effect.Parallel([
new Effect.Move(this.div,{x:(this.map.div.offsetWidth-150),y:(this.map.div.offsetHeight-150),mode:'absolube'}),
new Effect.Move(this.frame_div,{x:(this.map.div.offsetWidth-152),y:(this.map.div.offsetHeight-152),mode:'absolute'})],{
duration:0.5});},
hide:function(){
this.moving=2;
this.div.style.display="none";
this.frame_div.style.display="none";
this.switch_div.childNodes[0].src=CONST_IMG_PATH+"images/open_map_overview.gif";
return;
new Effect.Parallel([
new Effect.Move(this.div,{x:(this.map.div.offsetWidth),y:(this.map.div.offsetHeight),mode:'absolute'}),
new Effect.Move(this.frame_div,{x:(this.map.div.offsetWidth),y:(this.map.div.offsetHeight),mode:'absolute'})],{
duration:0.5});},
toggle:function(){
if(this.moving!=0)
return;
switch(this.moving){
case 1:
this.hide();
break;
case 2:
this.show();
break;}},
afterMoving:function(){
this.moving=false;},
switchMapClick:function(){
if(this.switch_div.childNodes[0].src.indexOf("close_")!=-1){
this.hide();}
else{
this.show();}},
onZoomListener:function(){
Element.setOpacity($(this.overview_map.div),0);
if(this.veffects!=null)
this.veffects.cancel();
this.veffects=new Effect.Opacity($(this.overview_map.div),{duration:1.5,from:0.0,to:1.0});
this.overview_map.setCenter(this.map.current_center_ln,this.map.current_center_la);
this.overview_map.setZoomLevel(this.map.current_zoom_level+4,null,null,{no_smooth_zoom:true});
this.setBoundaryLayer();},
onDragEndListener:function(){
this.overview_map.setCenter(this.map.current_center_ln,this.map.current_center_la);},
setBoundaryLayer:function(){
try{
if(this.div.style.display=="none")
return false;
var x1=this.map.__getOffset(this.map.div,true);
var y1=this.map.__getOffset(this.map.div,false);
var x2=x1+this.map.div.offsetWidth;
var y2=y1+this.map.div.offsetHeight;
var left_top=this.map.__getCoorByClientXY2(x1,y1);
var right_bottom=this.map.__getCoorByClientXY2(x2,y2);
var xy1=this.overview_map.__getClientXYByCoor(left_top[0],left_top[1]);
var xy2=this.overview_map.__getClientXYByCoor(right_bottom[0],right_bottom[1]);
var width=xy2[0]-xy1[0];
var height=xy2[1]-xy1[1];
this.boundary_left=(this.div.offsetWidth/2)-(width/2);
this.boundary_top=(this.div.offsetHeight/2)-(height/2);
this.boundary_div.style.left=(this.boundary_left-1)+"px";
this.boundary_div.style.top=(this.boundary_top-1)+"px";
this.boundary_div.style.width=(width+2)+"px";
this.boundary_div.style.height=(height+2)+"px";
this.boundary_div.style.display="block";}
catch(e){}},
onBoundaryDragEndListener:function(){
var x1=this.map.__getOffset(this.boundary_div,true)+(this.boundary_div.offsetWidth/2);
var y1=this.map.__getOffset(this.boundary_div,false)+(this.boundary_div.offsetHeight/2);
var coor=this.overview_map.__getCoorByClientXY2(x1,y1);
var margin_x=this.boundary_left-this.boundary_div.offsetLeft;
var margin_y=this.boundary_top-this.boundary_div.offsetTop;
this.map.setCenter(coor[0],coor[1],true);
this.overview_map.moveToByXY(margin_x,margin_y);
new Effect.Move(this.boundary_div,{x:this.boundary_left,y:this.boundary_top,mode:'absolute',duration:0.2});},
afterBoundaryMove:function(){}}
var MapControlStandard=Class.create();
MapControlStandard.prototype={
initialize:function(map){
if(map==null)
return false;
this.map=map;
this.div=document.createElement("DIV");
this.div.style.position="absolute";
this.div.style.width="64px";
this.div.style.height="300px";
this.map.div.appendChild(this.div);
this.div.style.top="10px";
this.div.style.left=(this.map.div.offsetWidth-74)+"px";
this.div.style.zIndex="101";
this.move_top=document.createElement("DIV");
this.move_top.style.position="absolute";
this.move_top.style.width="21px";
this.move_top.style.height="21px";
this.move_top.style.top="0px";
this.move_top.style.left="21px";
this.move_top.style.cursor="pointer";
this.move_top.onclick=this.map.moveToNorth.bind(this.map);
this.move_top.innerHTML="<img src='"+CONST_IMG_PATH+"images/dir_n.gif' width='21' height='21' >";
this.div.appendChild(this.move_top);
this.move_right=document.createElement("DIV");
this.move_right.style.position="absolute";
this.move_right.style.width="21px";
this.move_right.style.height="21px";
this.move_right.style.top="21px";
this.move_right.style.left="42px";
this.move_right.style.cursor="pointer";
this.move_right.onclick=this.map.moveToEast.bind(this.map);
this.move_right.innerHTML="<img src='"+CONST_IMG_PATH+"images/dir_e.gif' width='21' height='21' >";
this.div.appendChild(this.move_right);
this.move_bottom=document.createElement("DIV");
this.move_bottom.style.position="absolute";
this.move_bottom.style.width="21px";
this.move_bottom.style.height="21px";
this.move_bottom.style.top="42px";
this.move_bottom.style.left="21px";
this.move_bottom.style.cursor="pointer";
this.move_bottom.onclick=this.map.moveToSouth.bind(this.map);
this.move_bottom.innerHTML="<img src='"+CONST_IMG_PATH+"images/dir_s.gif' width='21' height='21' >";
this.div.appendChild(this.move_bottom);
this.move_left=document.createElement("DIV");
this.move_left.style.position="absolute";
this.move_left.style.width="21px";
this.move_left.style.height="21px";
this.move_left.style.top="21px";
this.move_left.style.left="0px";
this.move_left.style.cursor="pointer";
this.move_left.onclick=this.map.moveToWest.bind(this.map);
this.move_left.innerHTML="<img src='"+CONST_IMG_PATH+"images/dir_w.gif' width='21' height='21' >";
this.div.appendChild(this.move_left);
this.slider_top=document.createElement("DIV");
this.slider_top.style.position="absolute";
this.slider_top.style.width="21px";
this.slider_top.style.height="20px";
this.slider_top.style.left="21px";
this.slider_top.style.top="70px";
this.slider_top.innerHTML="<img src='"+CONST_IMG_PATH+"images/z_t.gif' width='21' height='20'>";
this.div.appendChild(this.slider_top);
this.slider_middle=document.createElement("DIV");
this.slider_middle.style.position="absolute";
this.slider_middle.style.width="19px";
if(is_ie)
this.slider_middle.style.width="21px";
this.slider_middle.style.height="130px";
this.slider_middle.style.left="21px";
this.slider_middle.style.top="90px";
this.slider_middle.style.border="1px #888888 solid";
this.slider_middle.style.backgroundColor="#EEEEEE";
this.slider_middle.style.fontSize="2px";
this.div.appendChild(this.slider_middle);
this.slider_bottom=document.createElement("DIV");
this.slider_bottom.style.position="absolute";
this.slider_bottom.style.width="21px";
this.slider_bottom.style.height="20px";
this.slider_bottom.style.left="21px";
this.slider_bottom.style.top="222px";
if(is_ie)
this.slider_bottom.style.top="220px";
this.slider_bottom.innerHTML="<img src='"+CONST_IMG_PATH+"images/z_b.gif' width='21' height='20'>";
this.div.appendChild(this.slider_bottom);
this.zooms=[];
var num_zoom=(this.map.max_zoom-this.map.min_zoom)+1;
var start_top=this.slider_middle.offsetTop+5;
var end_top=(this.slider_middle.offsetTop+this.slider_middle.offsetHeight)-10;
var height_margin=(end_top-start_top)/num_zoom;
var pos_cnt=0;
for(var i=this.map.min_zoom;i<=this.map.max_zoom;i++){
var tmp=document.createElement("DIV");
tmp.style.position="absolute";
tmp.style.fontSize="1px";
tmp.style.width="15px";
tmp.style.height="1px";
this.zooms[i]=Math.ceil(start_top+(pos_cnt*height_margin)+(height_margin/2));
tmp.style.left=(this.slider_middle.offsetLeft+3)+"px";
tmp.style.top=this.zooms[i]+"px";
if(is_ie)
tmp.style.borderTop="1px #CCCCCC solid";
else
tmp.style.backgroundColor="#CCCCCC";
this.div.appendChild(tmp);
pos_cnt++;}
tmp=document.createElement("DIV");
tmp.style.position="absolute";
tmp.style.fontSize="1px";
tmp.style.width="1px";
tmp.style.height=(end_top-start_top)+"px";
tmp.style.top=(start_top+2)+"px";
tmp.style.left=(this.slider_middle.offsetLeft+(this.slider_middle.offsetWidth/2)-((is_ie)?0:1))+"px";
tmp.style.backgroundColor="#CCCCCC";
this.div.appendChild(tmp);
this.dragger=document.createElement("DIV");
this.dragger.style.position="absolute";
this.dragger.style.width="15px";
this.dragger.style.height="12px";
this.dragger.style.left="26px";
this.dragger.style.top=(this.zooms[this.map.current_zoom_level]-4)+"px";
this.dragger.style.cursor="pointer";
this.dragger.innerHTML="<img src='"+CONST_IMG_PATH+"images/pointer.gif' width='15' height='12'>";
this.div.appendChild(this.dragger);
Drag2.init(this.dragger,null,26,26,(start_top-5),Math.ceil(start_top+((num_zoom-1)*height_margin)+(height_margin/2)-6));
this.dragger.onDragEnd=this.onDragEndListener.bindAsEventListener(this);
this.map.addOnZoomListener(this.setZoomLevel.bind(this));
this.switch_div=document.createElement("DIV");
this.switch_div.style.position="absolute";
this.switch_div.style.width="21px";
this.switch_div.style.height="21px";
this.switch_div.innerHTML="<img src='"+CONST_IMG_PATH+"images/close_map_control.gif' width='21' height='21'>";
this.map.div.appendChild(this.switch_div);
this.switch_div.style.left=(this.map.div.offsetWidth-21)+"px";
this.switch_div.style.backgroundColor="#FFFFFF";
this.switch_div.style.top="0px";
this.switch_div.style.zIndex="1002";
this.switch_div.style.cursor="pointer";
this.switch_div.onclick=this.toggle.bind(this);
this.map.setMapControlPosition=this.setPosition.bind(this);},
setPosition:function(){
if(this.switch_div.childNodes[0].src.indexOf("open_")!=-1){
this.div.style.top=(this.div.offsetHeight*-1)+"px";
this.div.style.left=(this.map.div.offsetWidth)+"px";}
else{
this.div.style.top="10px";
this.div.style.left=(this.map.div.offsetWidth-74)+"px";}
this.switch_div.style.left=(this.map.div.offsetWidth-21)+"px";
this.switch_div.style.top="0px";},
show:function(){
this.switch_div.childNodes[0].src=CONST_IMG_PATH+"images/close_map_control.gif";
new Effect.Move(this.div,{x:(this.map.div.offsetWidth-74),y:(10),mode:'absolute',duration:0.5});},
hide:function(){
this.switch_div.childNodes[0].src=CONST_IMG_PATH+"images/open_map_control.gif";
new Effect.Move(this.div,{x:(this.map.div.offsetWidth),y:(this.div.offsetHeight*-1),mode:'absolute',duration:0.5});},
toggle:function(){
if(this.switch_div.childNodes[0].src.indexOf("close_")!=-1){
this.hide();}
else{
this.show();}},
onDragEndListener:function(){
var margin=[];
var min=10000;
var min_val=null;
for(var i=0;i<this.zooms.length;i++){
var tmp=Math.abs(this.zooms[i]-this.dragger.offsetTop);
if(i==0||i==1){}
if(tmp<min){
min=tmp;
min_val=i;}}
this.dragger.style.top=(this.zooms[min_val]-5)+"px";
this.map.setZoomLevel(min_val);},
setZoomLevel:function(){
this.dragger.style.top=(this.zooms[(this.map.current_zoom_level)]-5)+"px";}}
var MapControlMini=Class.create();
MapControlMini.prototype={
initialize:function(map){
if(map==null)
return false;
this.map=map;
this.div=document.createElement("DIV");
this.div.style.position="absolute";
this.div.style.width="64px";
this.div.style.height="100px";
this.map.div.appendChild(this.div);
this.div.style.top="10px";
this.div.style.left=(this.map.div.offsetWidth-74)+"px";
this.div.style.zIndex="101";
this.move_top=document.createElement("DIV");
this.move_top.style.position="absolute";
this.move_top.style.width="21px";
this.move_top.style.height="21px";
this.move_top.style.top="0px";
this.move_top.style.left="21px";
this.move_top.style.cursor="pointer";
this.move_top.onclick=this.map.moveToNorth.bind(this.map);
this.move_top.innerHTML="<img src='"+CONST_IMG_PATH+"images/dir_n.gif' width='21' height='21' >";
this.div.appendChild(this.move_top);
this.move_right=document.createElement("DIV");
this.move_right.style.position="absolute";
this.move_right.style.width="21px";
this.move_right.style.height="21px";
this.move_right.style.top="21px";
this.move_right.style.left="42px";
this.move_right.style.cursor="pointer";
this.move_right.onclick=this.map.moveToEast.bind(this.map);
this.move_right.innerHTML="<img src='"+CONST_IMG_PATH+"images/dir_e.gif' width='21' height='21' >";
this.div.appendChild(this.move_right);
this.move_bottom=document.createElement("DIV");
this.move_bottom.style.position="absolute";
this.move_bottom.style.width="21px";
this.move_bottom.style.height="21px";
this.move_bottom.style.top="42px";
this.move_bottom.style.left="21px";
this.move_bottom.style.cursor="pointer";
this.move_bottom.onclick=this.map.moveToSouth.bind(this.map);
this.move_bottom.innerHTML="<img src='"+CONST_IMG_PATH+"images/dir_s.gif' width='21' height='21' >";
this.div.appendChild(this.move_bottom);
this.move_left=document.createElement("DIV");
this.move_left.style.position="absolute";
this.move_left.style.width="21px";
this.move_left.style.height="21px";
this.move_left.style.top="21px";
this.move_left.style.left="0px";
this.move_left.style.cursor="pointer";
this.move_left.onclick=this.map.moveToWest.bind(this.map);
this.move_left.innerHTML="<img src='"+CONST_IMG_PATH+"images/dir_w.gif' width='21' height='21' >";
this.div.appendChild(this.move_left);
this.slider_top=document.createElement("DIV");
this.slider_top.style.position="absolute";
this.slider_top.style.width="21px";
this.slider_top.style.height="20px";
this.slider_top.style.left="21px";
this.slider_top.style.top="70px";
this.slider_top.innerHTML="<img src='"+CONST_IMG_PATH+"images/z_t.gif' width='21' height='20'>";
this.slider_top.onclick=this.zoomIn.bind(this);
this.slider_top.style.cursor="pointer";
this.div.appendChild(this.slider_top);
this.slider_bottom=document.createElement("DIV");
this.slider_bottom.style.position="absolute";
this.slider_bottom.style.width="21px";
this.slider_bottom.style.height="20px";
this.slider_bottom.style.left="21px";
this.slider_bottom.style.top="90px";
this.slider_bottom.onclick=this.zoomOut.bind(this);
this.slider_bottom.style.cursor="pointer";
this.slider_bottom.innerHTML="<img src='"+CONST_IMG_PATH+"images/z_b.gif' width='21' height='20'>";
this.div.appendChild(this.slider_bottom);
this.zooms=[];
var num_zoom=(this.map.max_zoom-this.map.min_zoom);
this.switch_div=document.createElement("DIV");
this.switch_div.style.position="absolute";
this.switch_div.style.width="21px";
this.switch_div.style.height="21px";
this.switch_div.innerHTML="<img src='"+CONST_IMG_PATH+"images/close_map_control.gif' width='21' height='21'>";
this.map.div.appendChild(this.switch_div);
this.switch_div.style.left=(this.map.div.offsetWidth-21)+"px";
this.switch_div.style.backgroundColor="#FFFFFF";
this.switch_div.style.top="0px";
this.switch_div.style.zIndex="1002";
this.switch_div.style.cursor="pointer";
this.switch_div.onclick=this.toggle.bind(this);
this.map.setMapControlPosition=this.setPosition.bind(this);},
setPosition:function(){
if(this.switch_div.childNodes[0].src.indexOf("open_")!=-1){
this.div.style.top=(this.div.offsetHeight*-1)+"px";
this.div.style.left=(this.map.div.offsetWidth)+"px";}
else{
this.div.style.top="10px";
this.div.style.left=(this.map.div.offsetWidth-74)+"px";}
this.switch_div.style.left=(this.map.div.offsetWidth-21)+"px";
this.switch_div.style.top="0px";},
show:function(){
this.switch_div.childNodes[0].src=CONST_IMG_PATH+"images/close_map_control.gif";
new Effect.Move(this.div,{x:(this.map.div.offsetWidth-74),y:(10),mode:'absolute',duration:0.5});},
hide:function(){
this.switch_div.childNodes[0].src=CONST_IMG_PATH+"images/open_map_control.gif";
new Effect.Move(this.div,{x:(this.map.div.offsetWidth),y:(this.div.offsetHeight*-1),mode:'absolute',duration:0.5});},
toggle:function(){
if(this.switch_div.childNodes[0].src.indexOf("close_")!=-1){
this.hide();}
else{
this.show();}},
onDragEndListener:function(){
var margin=[];
var min=10000;
var min_val=null;
for(var i=0;i<this.zooms.length;i++){
var tmp=Math.abs(this.zooms[i]-this.dragger.offsetTop);
if(tmp<min){
min=tmp;
min_val=i;}}
this.dragger.style.top=(this.zooms[min_val]-5)+"px";
this.map.setZoomLevel(min_val+1);},
setZoomLevel:function(){
this.dragger.style.top=(this.zooms[(this.map.current_zoom_level-1)]-5)+"px";},
zoomIn:function(){
this.map.setZoomLevel(this.map.current_zoom_level-1);},
zoomOut:function(){
this.map.setZoomLevel(this.map.current_zoom_level+1);}}
var MapSnap=Class.create();
MapSnap.prototype={
initialized:false,
initialize:function(map,opt){
if(map!=null&&!(map instanceof Map2))
return;
this.map=map;
this.opt={};
if(opt!=null&&typeof(opt)=="object")
this.opt=opt;
this.initialized=true;},
getSnap:function(){
if(!this.initialized)
return false;
var obj={};
obj.map=this.map.getSnap();
obj.overlay=this.map.overlay_controller.getSnap();
return Object.toJSON(obj);},
restoreSnap:function(str){
if(!this.initialized)
return false;
var obj=null;
eval("obj = "+str);
this.map.parseSnap(obj.map);
var overlay=null;
eval("overlay = "+obj.overlay);
if(overlay.points!=null&&overlay.points.length>0){
var points=[];
if(this.map.overlay_controller.add_map_point_set_timer!=null){
this.map.overlay_controller.cancelMapPointSetAction();}
this.map.removeAllMapPoint();
for(var i=0;i<overlay.points.length;i++){
var tmp_icon=null;
if(overlay.points[i].icon!=null){
tmp_icon=new MapPointIcon(overlay.points[i].icon,overlay.points[i].icon_width,overlay.points[i].icon_height)}
var tmp=new MapPoint(overlay.points[i].ln,overlay.points[i].la,{icon:tmp_icon});
if(overlay.points[i].tabs!=null&&overlay.points[i].tabs.tab_list!=null){
tmp.setInfoBubble(new OverlayInfoWindow(overlay.points[i].tabs.width,overlay.points[i].tabs.height));
for(var j=0;j<overlay.points[i].tabs.tab_list.length;j++)
tmp.opt.info_bubble.addTab(overlay.points[i].tabs.tab_list[j].header,overlay.points[i].tabs.tab_list[j].content);}
if(overlay.points[i].draggable!=null&&overlay.points[i].draggable==1){
tmp.enableDrag();}
if(overlay.points[i].bounce!=null){
tmp.bounce=overlay.points[i].bounce;}
points.push(tmp);}
this.map.addMapPointSet(points);}
if(overlay.svg!=null&&overlay.svg.length>0){}}}

