/*
//////////////////////////////////////////////////////////////////////
//																	//
//		ver:0.2														//
//		dte:01/19/2007												//
//																	//
//////////////////////////////////////////////////////////////////////
*/

//5、定义通用类创建对象
var Class = {
	create: function() {
			return function() {
				return this.initialize.apply(this, arguments);//强制类声明时初始化
			}
	}
}

//6、对象原型扩展
Object.extend = function(destination, source) {
  for (property in source) {
    destination[property] = source[property];
  }
  return destination;
}

//11、获得浏览器信息
//	在程序的任何地方，使用navigator.B得到浏览器名称，navigator.V得到浏览器主版本
//	B的可能值（字符类型）如下：
//	IE - Internet Explorer
//	FF - FireFox
//	OP - Opear
//	NS - Netscap
//	UN - 未知的浏览器


var sys=new GetBrowserInfo();
Object.extend(navigator,{
	B:sys[0],
	V:sys[1]

});
var sys=null;

function GetBrowserInfo(){
	var uA=navigator.userAgent;
	var BVer=0;
	var SVer=0;
	var sys=new Array();
	if (uA.indexOf('Netscape') != -1) {
		sys[0]='NS';
		BVer=parseFloat(uA.substring(uA.indexOf('Netscape')+9,uA.length));
		sys[1]=BVer;
		return sys;
	}
	else if (uA.indexOf('Opera') != -1) {
	    sys[0]='OP';
	    BVer=parseFloat(uA.substring(uA.indexOf('Opera')+6,uA.length));
	    sys[1]=BVer;
	    return sys;
	}
    else if (uA.indexOf('Firefox') != -1) {
        sys[0]='FF';
        BVer=parseFloat(uA.substring(uA.indexOf('Firefox')+8,uA.length));
        sys[1]=BVer;
        return sys;
    }
    else if (uA.indexOf('Chrome') != -1) {
        sys[0]='CH';
        BVer=2;
        sys[1]=BVer;
        return sys;
    }
    else if (uA.indexOf('MSIE') != -1) {
        sys[0]='IE';
        BVer=parseFloat(uA.substring(uA.indexOf('MSIE')+4,uA.length));
        sys[1]=BVer;
        return sys;
    }
    else {
        sys[0]='UN';
        sys[1]=-1;
        alert(navigator.userAgent);
        return sys;
	}
	return false;
}
//绑定事件监听方法
function $attachEventListener(obj,eventName,oListener){
    if(obj.attachEvent){
        obj.attachEvent(eventName,oListener);
    }
    else if(obj.addEventListener){
        obj.addEventListener(eventName,oListener, false);
    }
    else{
        return false;
    }
}

//删除事件监听方法
function $detachEventListener(obj,eventName,oListener){
    if(obj.detachEvent){
        obj.detachEvent(eventName,oListener);
    }
    else if(obj.removeEventListener){
        obj.removeEventListener(eventName,oListener, true);
    }
    else{
        return false;
    }
}


var $EventName=new function(){
    this.onload   = navigator.B=='IE'?'onload': 'load';
    this.mousemove   = navigator.B=='IE'?'onmousemove': 'mousemove';
    this.mouseover   = navigator.B=='IE'?'onmouseover': 'mouseover';
    this.mouseout    = navigator.B=='IE'?'onmouseout': 'mouseout';
    this.mouseup     = navigator.B=='IE'?'onmouseup': 'mouseup';
    this.mousedown   = navigator.B=='IE'?'onmousedown': 'mousedown';
    this.click       = navigator.B=='IE'?'onclick': 'click';
    this.dblclick    = navigator.B=='IE'?'ondblclick': 'dblclick';
    this.mousewheel  = navigator.B=='IE'?'onmousewheel': 'DOMMouseScroll';
    this.keydown     = navigator.B=='IE'?'onkeydown': 'keydown';
    this.keypress    = navigator.B=='IE'?'onkeypress': 'keypress';
    this.keyup       = navigator.B=='IE'?'onkeyup': 'keyup';
    this.focusin     = navigator.B=='IE'?'onfocusin': 'focusin';
    this.onfocusout  = navigator.B=='IE'?'ononfocusout': 'onfocusout';
    this.onfocus     = navigator.B=='IE'?'ononfocus': 'onfocus';
    this.contextmenu = navigator.B=='IE'?'oncontextmenu': 'contextmenu';
}

//1、通过ID得到文档对象引用，多个ID逗号分割得到文档对象数组。
function $() 
{
	var objElements = new Array();
	var i;
	for (i=0;i< arguments.length;i++)
	{
		var objEle = arguments[i];
		if(typeof arguments[i] == 'string')
		{
			objEle = document.getElementById(arguments[i]);
		}
		objElements.push(objEle);
	}
	if(arguments.length==1)
	{
		return objEle;
	}
	else
	{
		return objElements;
	}
}
var $A = Array.from = function(iterable) {
  if (!iterable) return [];
  if (iterable.toArray) {
    return iterable.toArray();
  } else {
    var results = [];
    for (var i = 0, length = iterable.length; i < length; i++)
      results.push(iterable[i]);
    return results;
  }
}

//2、创建一个页面元素tag
function $C(tag)
{
	return document.createElement(tag);
}

//3、把o添加到p对象中
function $To(o,p)
{
	if(o&&p){
		p.appendChild(o);
		return o;
	}
	else{
		return false;
	}
}

//3、创建一个超级随机整数字符flg随机数量级
function $Rnd(flg)
{
	var d, s = '';
	if(!flg)flg=100000;
	d = new Date();
	s += d.getHours();
	s += d.getMinutes();
	s += d.getSeconds();
	s += d.getMilliseconds();
	return Math.round(Math.random()*flg).toString()+s.toString();
}

//4、数值比较
function $Max()//返回最大的数值
{
	var i;
	var max
	if(arguments.length==0) return false;
	max = arguments[0];
	for (i=0;i< arguments.length;i++)
	{
		max = Math.max(max,arguments[i]);
	}
	return max;
	
}
function $Min()//返回最小的数值
{
	var i;
	var min
	if(arguments.length==0) return false;
	min = arguments[0];
	for (i=0;i< arguments.length;i++)
	{
		min = Math.min(min,arguments[i]);
	}
	return min;
}

//7、给基类添加反射继承
/*
Object.extend(Function.prototype,{
		inherit:function(source){
			var proto;
			for(proto in source.prototype)
			{
				this.prototype[proto]=source.prototype[proto];
			}
			return this;
		}
});
*/

//8、、扩展：去除字符串空格
Object.extend(String.prototype,{
	ltrim:function(){//去除左边空格
		var whitespace = new String(" \t\n\r");
		var s = new String(this);
		if (whitespace.indexOf(s.charAt(0)) != -1)
		{
			var j=0, i = s.length;
			while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
			{
				j++;
			}
			s = s.substring(j, i);
		}
		return s;
	},
	rtrim:function(){//去除右边空格
		var whitespace = new String(" \t\n\r");
		var s = new String(this);
		if (whitespace.indexOf(s.charAt(s.length-1)) != -1)
		{
			var i = s.length - 1;
			while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
			{
				i--;
			}
			s = s.substring(0, i+1);
		}
		return s;
	
	},
	trim:function(){//去除两边空格
		var s = new String(this);
		s = s.ltrim().rtrim();
		return s;
	},
	Int:function(){//转成整数
		return parseInt(this);
	},
	Float:function(){//转成浮点数
		return parseFloat(this);
	}

});

Function.prototype.bind = function() {
  var __method = this, args = $A(arguments), object = args.shift();
  return function() {
    return __method.apply(object, args.concat($A(arguments)));
  }
}

Function.prototype.bindAsEventListener = function(object) {
  var __method = this, args = $A(arguments), object = args.shift();
  return function(event) {
    return __method.apply(object, [( event || window.event)].concat(args).concat($A(arguments)));
  }
}

//9
Object.extend(Number.prototype,{
		Round:function(){
			return Math.round(this);
		},
		Floor:function(){
			return Math.floor(this);
		},
		Abs:function(){
			return Math.abs(this);
		}
});

//10、判断值是不是数字，返回true 表示是否则返回false
function isNumber(v)
{
	if(!v)return false;
	if (isNaN(v))
	{
		return false;
	}
	else
	{
		return true;
	}
}



//创建Flash对象
//IE中有不足，为了让Flash影片正常播放，在New对象的时候Flash对象已经添加到document中，即已经实例化
function alaFlash(src,width,height){
	var flash;
	if(navigator.B=='IE' ||  navigator.B=='OP'){
		flash = document.createElement('object');
		flash.setAttribute('classid', 'clsid:D27CDB6E-AE6D-11CF-96B8-444553540000');
		if(width)flash.setAttribute('width', width);
		if(height)flash.setAttribute('height', height);
		flash.setAttribute('wmode','transparent');
		document.body.appendChild(flash);
		flash.setAttribute('movie',src);
	}
	else if(navigator.B=='FF' || navigator.B=='NS'){
		flash = document.createElement('embed');
		flash.setAttribute('src',src);
		flash.setAttribute('type','application/x-shockwave-flash');
		if(width)flash.setAttribute('width', width);
		if(height)flash.setAttribute('height', height);
		flash.setAttribute('wmode','transparent');
	}
	else{
		flash = null;
	}
	return flash;
}

//释放内存
function alaMemGarbage(){
	if(navigator.B=='IE')CollectGarbage();
}
/*********************************************************************
 Model:eCityMapKernel(a)-index file
 Ver:2.3
 Copyright(c) 2007 edushi.com //xxx
**********************************************************************/

/*-----------------------------------------------
|           地图图层类型对象类定义              |
-----------------------------------------------*/
var eCityMapMapLayerProperty =Class.create();
eCityMapMapLayerProperty.prototype = {
	initialize		: function(){},
    body    : null,                     //图层对象
    id      : '',                       //图层ID
    zIndex  : 0,                        //图层Z轴索引
    GetPicFileName : function(a,b,z){}  //图片路径
}

/*-----------------------------------------------
|           eCityMapProperty类定义              |
-----------------------------------------------*/
var eCityMapProperty=Class.create();
eCityMapProperty.prototype={
	initialize		: function(){
		this.MapID = 'eCityMap07'+$Rnd();
		this.ZoomPer = new Array(1,1/2,1/4,1/8);    //各级别缩放比例
        this.SignStyles = [];                       //SignStyles的每个元素的类型为eCityMapSignStyle
        this.MapLayerPropertys = [];                //地图图层对象配置集合,
        //this.flgShowSigns = {};                     //分类图标的显示
        //this.flgShowPlots = {};                     //分类广告的显示
        this.SignsVisible={};                       //图标分组显示状态
        this.PlotsVisible={};                       //图标分组显示状态
        this.PlotBasePaths={};                      //Plot文件的相对位置，通过SortKey来区分各组
        this.ContextMenuItems=[];                   //右键菜单集合
	},
	GetSpotDataFileName: function(a,b,z){},         //定义加载热区数据的文件名构造函数（script的文件名）
	appendMapLayer  : function(layer){
	    if(layer instanceof eCityMapMapLayerProperty){
	        this.MapLayerPropertys[this.MapLayerPropertys.length]=layer;
	        return true;
	    }
	    else{
	        return false;
	    }
	},
	appendMenuItem  : function(item){
        this.ContextMenuItems[this.ContextMenuItems.length]=item;
        return true;
	},
	MapID			: 'eCityMap'+$Rnd(),
	MapWidth		: 200,                              //地图的宽和高
	MapHeight		: 200,
	MapCellWidth	: 256,                              //栅格图片尺寸(单位像素)
	MapCellHeight	: 256,
	DataCellWidth	: 256,                              //栅格数据尺寸，也就是XML数据文件的坐标跨度(单位像素)
	DataCellHeight	: 256,
    DragPrecision   : 10,                               //鼠标拖动灵敏度
	CenterX			: 0,                                //窗口中心点的地图坐标系坐标
	CenterY			: 0,
    MenuItemHeight  : 18,                               //右键菜单Item的高度
    MenuWidth       : 150,                              //右键菜单的宽度
    flgContextMenu  : false,                            //是否显示右键菜单（需要给eCityMap加载eCityMapMenu对象）
	flgLoadData		: true,                             //是否加载热区数据
	flgShowLabel	: false,                            //是否显示标签
	flgShowTip		: true,                             //是否显示实体Tip
	flgShowHotArea	: true,                             //是否构造热区
	flgShowSpotShape: false,                            //是否显示实体轮廓、边框
	flgCanDrag		: true,                             //是否地图当前是否可以拖动
	flgShowSign     : true,                             //是否加载Sign标签
	flgShowPlot     : true,                             //是否加载Plot标签
    PlotBasePaths   : null,                             //Plot文件的相对位置，类似PlotBasePaths['ad']='ad.edushi.com/sh/'
    SignsVisible    : null,                             //Sign标签分类显示，类似SignsVisible['bus']=true,SignsVisible['road']=false
    PlotsVisible    : null,                             //Plot标签分类显示，类似PlotsVisible['ad']=true,PlotsVisible['flag']=false
	Zoom			: 0,                                //当前地图级别
	ZoomPer			: null,                             //各级别缩放比例//由于JS数组是从0开始，也就是说从地图意义讲我们的数组是从0开始有意义的。
	WheelZoom       : true,                             //用户在使用鼠标滚轮时时候进行级别切换。
	SpotImagePath	: 'system/map.gif',                 //透明热区图片位置
	ErrImagePath	: 'system/map.gif',                 //如果加载失败则使用默认图片
    DiffSpotHeight  : 200,                              //透明热区图片的边缘尺寸
    DiffSpotWidth   : 200,
	ScaleImage		: 'system/flag.gif|16|28|0|28', 	//测量使用的图片位置：宽：高：exX：exY
	EditModeSelectShapeImage : 'system/c0.gif|8|8|4|4', //选中Shape使用的图片位置：宽：高：exX：exY
	EditModeNewShapeImage : 'system/c1.gif|8|8|4|4|system/c2.gif', //新建Shape的图片位置：宽：高：exX：exY：高亮图片
	//EditModeEndShapeImage : 'system/c2.gif|8|8|4|4', //最后点高亮图片：宽：高：exX：exY
	GetCoordsTip    : '左键取点，右键撤销，双击结束',//取点的Tip
	GetCoordsLine   : '#FF0000|2|',	    //取点线的样式  颜色|线宽|透明度
	ScaleTip		: '左键测量，双击结束测量。',	    //测量使用的图片位置：宽：高：exX：exY
	ScaleLine		: '#FFFF00|2',	                    //测量线的样式  颜色：线宽
	CosAlpha		: 0.707,                            //三维变形参数：旋转角度的Cos值，默认为cos45
	SinAlpha		: 0.707,                            //三维变形参数：旋转角度的Sin值，默认为sin45
	DistortionX		: 1,                                //三维变形参数：水平方向缩放比
	DistortionY		: 0.6,                              //三维变形参数：竖直方向缩放比
	Scale			: 0.48828125,                       //三维变形参数：比例尺 平面像素：实际米Scale
    PanelTip        : '鼠标左键在地图上拖动，松开左键结束拉框选择。',
	CurNormal		: 'default',                        //普通模式
	CurDrag			: 'move',                           //拖动地图时的光标
	CurHover		: navigator.B=='IE'&&navigator.V<6?'hand':'pointer',    //鼠标悬停热区或热点
    SignStyles      : null,                             //Sign标签的样式列表:
        /*
        SignStyles[0] = {
            html:'<div style="background-color:#FF0000;font-size:12px;width:14px;">{Title}</div>',
            exX:0,
            exY:0
        }
        */
	StyleSpotShape	: '#FFFFFF|1|#FFFF00|0.5',
    CSSMenu         : '.ItemActive{font-size:12px;background-color: #DBDBDB}.Menu{cursor:hand;border-style: ridge; border-width: 1px; padding-left: 4px; padding-right: 4px; padding-top: 4px; padding-bottom: 3px; background-color: #C0C0C0}.Item{font-size:12px;}',
	CSSTip			: 'font-size:12px;height:16px;white-space: nowrap; position: absolute; border: 1px solid #333333; padding: 2px; background-color: #ffffcc',
	CSSLabel		: 'font-size:12px;height:16px;white-space: nowrap; position: absolute; border: 1px solid #333333; padding: 2px; background-color: #008000',
	CSSPane			: 'font-size:1px;border: 3px dotted   #FFFF00; ',//拉框的时候的边框的样式表
	CSSDialog		: 'font-size:14px;border-width: 1px;background-color:#FFFFFF',//对话框样式表
	CSSScaleLabel	: 'font-size:12px;height:12px;white-space: nowrap; position: absolute;  border: 1px solid #333333; padding: 1px; background-color: #ffffff;font-color:#FFFF00',//测量时距离标签的样式表单
	SVGNameSpace    : 'http://www.w3.org/2000/svg',
	KernelPath      : 'JSLibrary/eCityMapKernel2.3b.js',//核心文件位置  
	EditMode        : false//是否编辑热区状态  
};
/*-----------------------------------------------
|		        eCityMap类定义        			|
-----------------------------------------------*/
var eCityMapKernel = Class.create();
eCityMapKernel.prototype = {
//1、初始化地图对象
	initialize              : function(pro,pDiv){//绑定eCityMap基本属性、方法(pDiv=承载地图的div)
	    //1)初始参数判断与赋值
	    if(pro instanceof eCityMapProperty){//如果指定Property则以Property为主，否则按照参数输入分别调整Property各值
		    this.Property=pro;
	    }
	    else{
		    this.Property= new eCityMapProperty();
	    }
	    //2)判断是否有载体元素，如果没有插到文档中
	    if(typeof(pDiv) != 'undefined'){
	        pDiv.innerHTML = '<iframe frameBorder="0" name="'+this.Property.MapID+'" id="'+this.Property.MapID+'" width="'+this.Property.MapWidth+'px" height="'+this.Property.MapHeight+'px" scrolling="no" style="width:'+this.Property.MapWidth+'px;height:'+this.Property.MapHeight+'px;position:relative;z-index:1;"></iframe>';
	    }
	    else{
	        window.document.write('<iframe frameBorder="0" name="'+this.Property.MapID+'" id="'+this.Property.MapID+'" width="'+this.Property.MapWidth+'px" height="'+this.Property.MapHeight+'px" scrolling="no" style="width:'+this.Property.MapWidth+'px;height:'+this.Property.MapHeight+'px;position:relative;z-index:1;"></iframe>');
	    }

	    //3)获得地图对象
	    this.Body = window.frames[this.Property.MapID];
	    //4)构造地图框架页面
        this.Body.document.open();
        this.Body.document.write('<html  xmlns:v="urn:schemas-microsoft-com:vml" xmlns:svg="'+ this.Property.SVGNameSpace +'" xmlns="http://www.w3.org/1999/xhtml">');
        this.Body.document.write('<head>');
        this.Body.document.write('<meta http-equiv="content-type" content="text/html; charset=utf-8" />');
        this.Body.document.write('<title>eCityMap 2.3</title>');
        if(navigator.B=='IE'){
            this.Body.document.write('<style>v\\:*{behavior:url(#default#VML);}</style>');
        }
        this.Body.document.write('</head>');
        this.Body.document.write('<NOSCRIPT>');
        this.Body.document.write('<meta http-equiv="refresh" content="0; URL=about:No Script"/>');
        this.Body.document.write('</NOSCRIPT>');
        this.Body.document.write('<body style="margin-left:0px;margin-right:0px;margin-top:0px;margin-bottom:0px;background-color:#FFFFFF;">');
        if(this.Property.flgContextMenu){//构造菜单
            this.Body.document.write('<iframe frameBorder="0" name="'+(this.Property.MapID)+'Menu" id="'+(this.Property.MapID)+'Menu" width="'+this.Property.MenuWidth+'px" height="1px" scrolling="no" style="display:none;position:absolute;width:'+this.Property.MenuWidth+'px;height:1px;position:relative;z-index:999999;"></iframe>');
        }
        this.Body.document.write('</body>');
        this.Body.document.write('</html>');
        this.Body.document.close();
        //构造框架内地图对象引用
        this.Body.window.eCityMap = this;
        //加载核心脚本
        this._s =this.Body.document.createElement('script');
        this._s.charset = 'utf-8';
        this._s.src=this.Property.KernelPath;
        this.Body.document.getElementsByTagName('head')[0].appendChild(this._s);
        this._s = null;delete this._s;
	    return this;
    },
//属性方法接口    
    Show                    : function(){return this.Body._Show();},
    MapWidth                : function(v,flg){                          //返回或设置地图的宽（flg=true表示不刷新地图）
        if(v!=undefined){
   	        this.Body.MapWidth = v;
	        this.Body.frameElement.width = v;
	        this.Body.frameElement.style.width = v + 'px';
            this.Body.ChangeMapWidth(v,flg);
        }
        return this.Body.MapWidth;
    },
    MapHeight               : function(v,flg){                          //返回或设置地图的高（flg=true表示不刷新地图）
        if(v!=undefined){
   	        this.Body.MapHeight = v;
	        this.Body.frameElement.height = v;
	        this.Body.frameElement.style.height = v + 'px';
            this.Body.ChangeMapHeight(v,flg);
        }
        return this.Body.MapHeight;
    },
    PointerX                : function(){return this.Body.PointerX;},   //得到鼠标在地图上的位置（地图坐标）
    PointerY                : function(){return this.Body.PointerY;},
    CenterX                 : function(){return this.Body.CenterX;},    //得到当前地图的中心点（地图坐标）
    CenterY                 : function(){return this.Body.CenterY;},
    Zoom                    : function(v){                              //返回或设置地图的当前级别
        if(v!=undefined){
            this.Body.ChangeZoom(v);
        }
        return this.Body.Zoom;
    },
    FlatZoom                : function(v){return this.Body.FlatZoom(v);},//平滑缩放，多用在滑杆操作上v是小数在0-3之间
    MoveTo                  : function(x,y,flg){
        if(flg){//平滑移动
            return this.Body.FlatMoveTo(x,y);
        }
        else{//快速定位
            return this.Body.Center(x,y);
        }
    },
    LayerMoveTo             : function(x,y){return this.Body.LayerMoveTo(x,y);},
    ViewEditMode            : function(flg){return this.Body.ViewEditMode(flg);},//开关编辑状态
    ViewLabels              : function(flg){return this.Body.ViewLabels(flg);},
    ViewSpotAreas           : function(flg){return this.Body.ViewSpotAreas(flg);},
    ViewSigns               : function(flg,sortkey){return this.Body.ViewSigns(flg,sortkey);},//如果指定sortkey，则只控制分组，否则全部
    ViewPlots               : function(flg,sortkey){return this.Body.ViewPlots(flg,sortkey);},
    ViewSysMapLayer         : function(id,flg){return this.Body.ViewSysMapLayer(id,flg);},
    GetWinPos               : function(v){return this.Body.GetWinPos(v);},
    GetMapPos               : function(v){return this.Body.GetMapPos(v);},
    ChangeCoords            : function(coords,per,flg){return this.Body.ChangeCoords(coords,per,flg);},
    NewMapLayer             : function(id,z,pLayer){
        if(pLayer==undefined){
            return this.Body.NewMapLayer(id,z,this.Body.SysLayerTop);
        }
        else{
            if(pLayer==0){
                return this.Body.NewMapLayer(id,z,this.Body.SysLayerTop);
            }
            else{
                return this.Body.NewMapLayer(id,z,this.Body.SysLayerBottom);
            }
        }
    },
    StartPane               : function(){return this.Body.StartPane();},
    StopPane                : function(){return this.Body.StopPane();},
    StartScale              : function(){return this.Body.StartScale();},
    StopScale               : function(){return this.Body.StopScale();},
    StartGetCoords          : function(){return this.Body.StartGetCoords();},
    StopGetCoords           : function(){return this.Body.StopGetCoords();},
    GetSelectSpot           : function(){return this.Body.GetSelectSpot();},
    AppendSpot              : function(spot,zoom,flgLabel,flgShape){return this.Body.AppendSpot(spot,zoom,flgLabel,flgShape);},
    DeleteSpot              : function(spot,zoom){
        if(zoom==undefined){
            for(var i=0;i<this.Body.ZoomPer.length;i++){
                return this.Body.DeleteSpot(spot,i);
            }
        }
        else{
            return this.Body.DeleteSpot(spot,zoom);
        }
    },
    AppendSign              : function(sign,zoom,flgShow){return this.Body.AppendSign(sign,zoom,flgShow);},
    AppendPlot              : function(plot,zoom,flgShow){return this.Body.AppendPlot(plot,zoom,flgShow);},
    appendEntity            : function(o,layer,autoresize,x,y,w,h,exX,exY,candrag){return this.Body.appendEntity(o,layer,autoresize,x,y,w,h,exX,exY,candrag);},
    moveEntity              : function(id,x,y){return this.Body.moveEntity(id,x,y);},
    getEntityInfo           : function(id){return this.Body.getEntityInfo(id);},
    DrawDot                 : function(pDiv,x,y,size,color,opacity){return this.Body.DrawDot(pDiv,x,y,size,color,opacity);},
    DrawLine                : function(pDiv,x1,y1,x2,y2,size,color,opacity){return this.Body.DrawLine(pDiv,x1,y1,x2,y2,size,color,opacity);},
    DrawPolyLine            : function(pDiv,coords,size,color,opacity){return this.Body.DrawPolyLine(pDiv,coords,size,color,opacity);},
    DrawPoly                : function(pDiv,coords,size,fillcolor,strokecolor,opacity){return this.Body.DrawPoly(pDiv,coords,size,fillcolor,strokecolor,opacity);},
    DrawCircle              : function(pDiv,x,y,r1,r2,size,fillcolor,strokecolor,opacity){return this.Body.DrawCircle(pDiv,x,y,r1,r2,size,fillcolor,strokecolor,opacity);},
    DrawTextPath            : function(){return this.Body.DrawTextPath();},//暂时未实现
    ShowPointerTip          : function(tipHtml,diffX,diffY){return this.Body.ShowPointerTip(tipHtml,diffX,diffY);},
    HidePointerTip          : function(){return this.Body.HidePointerTip();},
    CoordTransform3DToPlane : function(x,y){return this.Body.CoordTransform3DToPlane(x,y);},
    CoordTransformPlaneTo3D : function(x,y){return this.Body.CoordTransformPlaneTo3D(x,y);},
    $                       : function(v){return this.Body.$(v);},
    $C                      : function(tag){return this.Body.$C(tag);},

//事件接口 
    onContextMenuClick      : function(key,wx,wy,mx,my,spot){},     //点击右键菜单，key=点击的项目，mx，my为菜单出现时地图坐标位置,spot如果当前鼠标选中了spot则返回   
    onContextMenuShow       : function(wX,wY,mX,mY,srcSpot,srcElm,srcEntity){},         //显示右键菜单，mx，my为菜单出现时地图坐标位置,spot如果当前鼠标选中了spot则返回
    onContextMenuHide       : function(wX,wY,mX,mY){},              //右键菜单隐藏，mx，my为菜单当时地图坐标位置   
	onSignClick             : function(sign){},                     //点击标识
	onSignMouseOver     	: function(sign){},                     //鼠标移动到标识
	onSignMouseOut          : function(sign){},                     //鼠标移出标识
	onPlotClick             : function(plot){},                     //点击Plot
	onPlotMouseOver     	: function(plot){},                     //鼠标移动到Plot
	onPlotMouseOut          : function(plot){},                     //鼠标移出Plot
	onMapInitialize         : function(){},                         //地图构造完毕
	onMapMove				: function(x,y,flg){},                  //地图移动（中心点坐标在变化，flg为激发原因）
	onMapMoveEnd			: function(x,y,flg){},                  //地图移动结束（中心点坐标在变化，flg为激发原因）
	onMapLayerMove			: function(x,y){},                      //地图图层移动（中心点坐标在变化，常用来监测鹰眼）
	onMapZoomChange			: function(z){},                        //地图显示后发生，z返回上一级别
	onMapMouseMove			: function(e){},                        //鼠标在地图上移动,可以通过PointerX,Y返回鼠标位置
	onMapMouseDown			: function(e){},                        //鼠标按下,可以通过PointerX,Y返回鼠标位置
	onMapMouseUp			: function(e){},                        //鼠标松开
	onMapMouseOut			: function(e){},                        //鼠标移动出地图
	onMapClick  			: function(e){},                        //鼠标在地图上点击
	onMapDblClick			: function(e){},                        //鼠标在地图上双击
	onMapMouseWheel			: function(e){},                        //鼠标滚轮
	onSpotLabelClick		: function(spot){},                     //点击热点标签
	onSpotLabelDblClick		: function(spot){},                     //双击热点标签
	onSpotLabelMouseOver	: function(spot){},                     //鼠标移动到热点标签
	onSpotLabelMouseOut		: function(spot){},                     //鼠标移出热点标签
	onSpotDblClick			: function(spot){},                     //双击热点
	onSpotClick				: function(spot){},                     //点击热点
	onSpotMouseOver			: function(spot){},                     //鼠标移动到热点区域
	onSpotMouseOut			: function(spot){},                     //鼠标移出热点区域
	onSpotMouseMove			: function(spot){},                     //鼠标在地图热区上移动
	onEntityClick           : function(Entity){},                   //用户点击Entity
	onEntityMouseMove       : function(Entity){},                   //用户鼠标在Entity上移动
	onEntityMouseDown       : function(Entity){},                   //用户鼠标在Entity按下
	onEntityMouseUp         : function(Entity){},                   //用户鼠标在Entity松开
	onEntityMouseOver       : function(Entity){},                   //用户鼠标移动到Entity上
	onEntityMouseOut        : function(Entity){},                   //用户鼠标移出Entity
	onEntityDragEnd         : function(Entity){},                   //用户拖动Entity结束
	onPaneEnd				: function(x1,y1,x2,y2,flg){},          //拉框结束flg=0用户拉框结束；=1StopPane引发
	onScaleEnd				: function(flg){},                      //测量结束flg=0用户测量结束；为了兼容老版本，一直返回0
	onGetCoordsEnd          : function(coords,flg){},               //取点结束flg=0用户测量结束；=1StopGetCoords引发  coords返回一维数组
    Suolan                  : 'love helen'    
};

  var PageLoaded = false;
	var _sSpotDataFileName	= 'www.shuzijj.com/cityresource2';
	var _sMapPicFileName = 'www.shuzijj.com/cityresource2';
  var _sMap2PicFileName = 'www.shuzijj.com/cityresource2';
  var _vLanguage = 'zh-chs';
  var _vCountry='cn';
  var vProvince='jiujiang'
  var ecmPro=new eCityMapProperty();
  ecmPro.CityCode='jiujiang';
  ecmPro.MapWidth = '1020';
  ecmPro.MapHeight = '500';
  ecmPro.MapCellWidth = 256;
  ecmPro.MapCellHeight = 256;
  ecmPro.DataCellWidth = 512;
  ecmPro.DataCellHeight = 512;
  ecmPro.DragPrecision = 50;
  ecmPro.CenterX = 12472;
  ecmPro.CenterY = 23064;
  ecmPro.PointerX=0;
  ecmPro.PointerY=0;
  ecmPro.MenuItemHeight=20;
  ecmPro.MenuWidth=150;
  ecmPro.CSSMenu=' .ItemActive{font-size:12px;background-color: #C0C0C0}.Menu{cursor:hand;border-style: ridge; border-width: 1px; padding-left: 4px; padding-right: 4px; padding-top: 4px; padding-bottom: 3px; background-color: #FFFFFF}.Item{font-size:12px;}';
  ecmPro.CSSTip='font-size:12px;height:16px;white-space: nowrap; position: absolute; border: 1px solid #333333; padding: 2px; background-color: #ffffcc';
  ecmPro.CSSLabel='font-size:12px;height:16px;white-space: nowrap; position: absolute; border: 1px solid #b3b7b3; padding: 2px; background-color: #e1e1e1';
  ecmPro.CSSPane='font-size:1px;border: 3px dotted   #FFFF00; ';
  ecmPro.CSSDialog='font-size:14px;border-width: 1px;background-color:#FFFFFF';
  ecmPro.CSSScaleLabel='font-size:12px;height:12px;white-space: nowrap; position: absolute;  border: 1px solid #333333; padding: 1px; background-color: #ffffff;font-color:#FFFF00';
  ecmPro.flgLoadData=true;
  ecmPro.flgShowLabel=false;
  ecmPro.flgShowTip=true;
  ecmPro.flgShowHotArea=true;
  ecmPro.flgShowSpotShape=false;
  ecmPro.flgCanDrag=true;
  ecmPro.Zoom=1;
  ecmPro.ZoomPer=[1,1/2,1/4,1/8];
  ecmPro.DiffSpotHeight=200;
  ecmPro.DiffSpotWidth=200;
  ecmPro.ScaleTip='左键测量，双击结束测量';
  ecmPro.ScaleImage='http://www.shuzijj.com/api2/system/flag.gif|16|28|0|28';
  ecmPro.ScaleLine='#FFFF00|3';
  ecmPro.SignsVisible={'bus':true,'road':true,'park':true,'way':true,'subway':true,'vir':true};
  ecmPro.flgShowSign=true;
  ecmPro.PlotsVisible={'ad':true,'FLAG':true};
  ecmPro.flgContextMenu = true;
  ecmPro.KernelPath='http://www.shuzijj.com/api2/JSLibrary/eCityMapKernel2.3b.js';
  ecmPro.SpotImagePath='http://www.shuzijj.com/api2/system/map.gif';
  ecmPro.ErrImagePath='http://www.shuzijj.com/api2/System/ErrImage.gif';
    //设置数据加载
    
    _3D = 3;
    ecmPro.GetSpotDataFileName= function(a,b,z){
    var url = 'http://'+_sSpotDataFileName +'/'+_vCountry+'/'+ecmPro.CityCode+'/'+_vLanguage+'/mapjs/'+z+'/'+a+','+b+'.js';
    //var url = 'http://'+ _sSpotDataFileName +'/'+_vCountry+'/'+ecmPro.CityCode+'/'+_vLanguage+'/mapjs/'+z+'/'+a+','+b+'.js';
    return url;
    };
    var layerPro = new eCityMapMapLayerProperty();
    v3DEdushiMap=layerPro;
    layerPro.id='Map3D';
    layerPro.zIndex=10;
    layerPro.visible = true;
    layerPro.GetPicFileName=function(a,b,z){
    var url='http://'+_sMapPicFileName+'/'+_vCountry+'/'+ecmPro.CityCode+'/'+_vLanguage+'/mappic/png'+z+'/'+a+','+b+'.png';
    return url;
    };
    ecmPro.appendMapLayer(layerPro);
    layerPro = null;
    //2D
    v2DEdushiMap=new eCityMapMapLayerProperty();
    layerPro=v2DEdushiMap;
    layerPro.id='Map2D';
    layerPro.zIndex=15;
    layerPro.visible = false;
    layerPro.GetPicFileName=function(a,b,z){
    //var url = 'http://'+_sMap2PicFileName+'/'+_vCountry+'/'+vProvince+'/'+ecmPro.CityCode+'/'+z+'/'+a+','+b+'.jpg';
    var url = 'http://'+_sMap2PicFileName+'/'+_vCountry+'/'+ecmPro.CityCode+'/'+_vLanguage+'/mappic/2png'+z+'/'+a+','+b+'.png';
    return url;
    };
    ecmPro.appendMapLayer(layerPro);
    layerPro = null;
    
  var eyePro=new eCityMapProperty();
  eyePro.WheelZoom=false;
  eyePro.MapWidth = 190;
  eyePro.MapHeight = 145;
  eyePro.CenterX = ecmPro.CenterX;
  eyePro.CenterY = ecmPro.CenterY;
  eyePro.Zoom = 1;
  eyePro.ZoomPer = [1/16,1/32,1/64,1/128];
  eyePro.KernelPath='http://www.shuzijj.com/api2/JSLibrary/eCityMapKernel2.3b.js';
  eyePro.SpotImagePath='http://www.shuzijj.com/api2/system/map.gif';
  eyePro.ErrImagePath='http://www.shuzijj.com/api2/System/ErrImage.gif';
    //1、鹰眼
    var eyeLayerPro = new eCityMapMapLayerProperty();
    eyeLayerPro.id='Eye';
    eyeLayerPro.zIndex=10;
    eyeLayerPro.visible=true;
    eyeLayerPro.GetPicFileName=function(a,b,z){
    return url='http://'+_sMapPicFileName+'/'+_vCountry+'/'+ecmPro.CityCode+'/'+_vLanguage+'/mappic/eye'+(z)+'/'+a+','+b+'.png?t=3';
    };
    eyePro.appendMapLayer(eyeLayerPro);
    eyeLayerPro=null;
  
  ecmPro.SignStyles[0]={
  html:'<img src="http://www.shuzijj.com/cityresource2/cn/jiujiang/zh-chs/pubpic/BUSSTOP.gif" border="0" alt="{Title}"/>',
  exX:10,
  exY:44
  };
 
  ecmPro.SignStyles[1]={
  html:'<img src="http://www.shuzijj.com/cityresource2/cn/jiujiang/zh-chs/pubpic/BUS.gif" border="0" alt="{Title}"/>',
  exX:10,
  exY:44
  };
 
  ecmPro.SignStyles[2]={
  html:'<img src="http://www.shuzijj.com/cityresource2/cn/jiujiang/zh-chs/pubpic/DiTie.gif" border="0" alt="{Title}"/>',
  exX:10,
  exY:44
  };
 
  ecmPro.SignStyles[3]={
  html:'<img src="http://www.shuzijj.com/cityresource2/cn/jiujiang/zh-chs/pubpic/BUSSTOP.gif" border="0" alt="{Title}"/>',
  exX:10,
  exY:44
  };
 
  ecmPro.SignStyles[4]={
  html:'<div style="height:28px;z-index:1;min-width:10px;width:auto !important;width:10"><div style="height:19px; padding-top:2px; padding-left:5px; padding-right:5px; white-space:nowrap;border:1px #e3e3e3 solid;background-color:ff7000;color:#1A70C7; font-size:12px;font-weight:bolder"><a href="{Url}" style="color:#FFFFFF; font-size:12px; text-decoration:none;" target="{Target}">{Title}</a></div><div style="float:left; margin-left:0px;margin-top:-2px; font-size:10px; width:1px; height:10px;z-index:2"><img src="http://www.shuzijj.com/api2/System/left3.gif" border="0"></div></div>',
  exX:0,
  exY:28
  };
 
  ecmPro.SignStyles[5]={
  html:'<div style="width:27px; height:32px;"><img src="http://www.shuzijj.com/api2/System/vir.gif"/></div>',
  exX:0,
  exY:28
  };
 
  ecmPro.PlotsVisible={'ad':true,'FLAG':true}; 
	ecmPro.PlotBasePaths={'ad':'http://www.shuzijj.com/cityresource2/cn/jiujiang/zh-chs/mapdiv/2/','FLAG':''};
    
    var MenuItem=Class.create();
    MenuItem.prototype={
    initialize		: function(){},
    Key 	: "",
    Caption : "",
    icon 	: "",
    visible : false,
    onClick : function(){},
    ff:null
    };
	
	    var item0 = new MenuItem();
    item0.key="spot";
    item0.Caption = "当前选中";
    item0.visible = false;
    ecmPro.appendMenuItem(item0);

    iteml8 = new MenuItem();
    iteml8.key="line08";
    iteml8.Caption = "-";
    iteml8.visible = false;
    ecmPro.appendMenuItem(iteml8);

    item01 = new MenuItem();
    item01.key='end';
    item01.Caption='如何到达这里';
    item01.visible=true;
    ecmPro.appendMenuItem(item01);

    item02=new MenuItem();
    item02.key='start';
    item02.Caption='从这里出发';
    item02.visible=true;
    ecmPro.appendMenuItem(item02);

    item03=new MenuItem();
    item03.key='cirsearch';
    item03.Caption='查找周边';
    item03.visible=true;
    ecmPro.appendMenuItem(item03);

    item04=new MenuItem();
    item04.key='cirbus';
    item04.Caption='周边公交';
    item04.visible=true;
    ecmPro.appendMenuItem(item04);

    item2 = new MenuItem();
    item2.key="center";
    item2.Caption = '当前位置居中';
    item2.visible = true;
    ecmPro.appendMenuItem(item2);

    iteml = new MenuItem();
    iteml.key="line01";
    iteml.Caption = "-";
    iteml.visible = true;
    ecmPro.appendMenuItem(iteml);

    item05=new MenuItem();
    item05.key='sign';
    item05.Caption='标记该位';
    item05.icon='http://www.shuzijj.com/api2/system/m1.gif',
    item05.visible=true;
    ecmPro.appendMenuItem(item05);

    item06=new MenuItem();
    item06.key='errors';
    item06.Caption='纠错';
    item06.icon='http://www.shuzijj.com/api2/system/m2.gif',
	item06.visible=true;
    ecmPro.appendMenuItem(item06);

  item3 = new MenuItem();
  item3.key="zoomin";
  item3.Caption = "放大";
  item3.icon='http://www.shuzijj.com/api2/system/m3.gif',
  item3.visible = true;
  ecmPro.appendMenuItem(item3);

  item4 = new MenuItem();
  item4.key="zoomout";
  item4.Caption = "缩小";
  item4.icon='http://www.shuzijj.com/api2/system/m4.gif',
  item4.visible = true;
  ecmPro.appendMenuItem(item4);

  item5 = new MenuItem();
  item5.key="line";
  item5.Caption = "-";
  item5.visible = true;
  ecmPro.appendMenuItem(item5);

  item6 = new MenuItem();
  item6.key="about";
  item6.Caption = "关于eCityMap...";
  item6.visible = true;
  ecmPro.appendMenuItem(item6);
	
  vEdushiMap=new eCityMapKernel(ecmPro,$('EdushiMap'));
    
    veyeEdushiMap=new eCityMapKernel(eyePro,$('eyeEdushiMap'));
    oEyeApiMap = veyeEdushiMap;
    
    oApiMap = vEdushiMap;
    //2、菜单显示的时候控制各个项
    oApiMap.onContextMenuShow = function(wx,wy,mx,my,spot,srcElm,srcEntity){
    oApiMap.Body.MenuContextMenu.Items['zoomin'].style.display='block';
    oApiMap.Body.MenuContextMenu.Items['zoomout'].style.display='block';
    if(oApiMap.Zoom()==0){
    oApiMap.Body.MenuContextMenu.Items['zoomin'].style.display='none';
    }
    else if(oApiMap.Zoom()==3){
    oApiMap.Body.MenuContextMenu.Items['zoomout'].style.display='none';
    }
    if(spot){
    oApiMap.Body.MenuContextMenu.Items['spot'].SetCaption(spot.Title);
    oApiMap.Body.MenuContextMenu.Items['spot'].style.display='block';
    oApiMap.Body.MenuContextMenu.Items['line08'].style.display='block';
    }
    else{
    oApiMap.Body.MenuContextMenu.Items['spot'].style.display='none';
    oApiMap.Body.MenuContextMenu.Items['line08'].style.display='none';
    }
    }
    
        function IniMap(){
        window.setTimeout(function(){
        oEyeApiMap.onMapMoveEnd = function(x,y,flg){
        if(flg==0){oApiMap.MoveTo(x,y,true);}
        }
        //地图移动
        oApiMap.onMapMoveEnd = function(x,y,flg){
        if(flg==0){oEyeApiMap.MoveTo(x,y,true);}
        }
        },500);
        }
      
    $attachEventListener(document.body,$EventName.onload,IniMap);
    function ShowLabels(){
    oApiMap.Body.ViewLabels(!oApiMap.Body.flgShowLabel);
    return oApiMap.Body.flgShowLabel
    }
    //开关热
    function ShowSpotArea(){
    oApiMap.ViewSpotAreas(!oApiMap.Body.flgShowHotArea);
    return oApiMap.Body.flgShowHotArea;
    }
    //轮廓开
    function ShowSpotShape(){
    oApiMap.Body.flgShowSpotShape=!oApiMap.Body.flgShowSpotShape;
    return oApiMap.Body.flgShowSpotShape;
    }
    //Tip开
    function ShowTip(){
    oApiMap.Body.flgShowTip=!oApiMap.Body.flgShowTip;
    return oApiMap.Body.flgShowTip;
    }
    vEdushiMap.Switch23D=function(s)
    {
    _3D=!_3D;
    oApiMap.ViewSysMapLayer("Map3D",_3D==true ? true:false);
    oApiMap.ViewSysMapLayer("Map2D",_3D==false ? true:false);
    ShowSpotArea();
    return _3D;
    }
    oApiMap.Body.document.body.style.background='url(http://www.shuzijj.com/api2/System/waterbg.gif)';

    oEyeApiMap.Body.document.body.style.background='url(http://www.shuzijj.com/api2/System/waterbg.gif)';

    PageLoaded = true;
   
  