﻿// JScript source code
var host = 'http://125.64.92.79/cityresource2/cn/deyang/zh-chs/';
//var host = 'http://192.168.1.112/images/';
var __svg_namespace = 'http://www.w3.org/2000/svg';


var EYE3D_DeYang_3D_MAP={
    id: "eye",
    ns: 'eyeview',
    imagePath: host + "mappic/eye"
};

var isIE = (document.all) ? true : false;
var mousewheel = (document.all) ? "mousewheel" : "DOMMouseScroll";  
var Class = {
    create: function() {
        return function() { this.initialize.apply(this, arguments); }
    }
};
var Extend = function(destination, source) {
    for (var property in source) {
        destination[property] = source[property];
    }
};
var Bind = function(object, fun) {
    return function() {
        return fun.apply(object, arguments);
    }
};
var BindAsEventListener = function(object, fun) {
    return function(event) {
        return fun.call(object, (event || window.event));
    }
};
var addEventHandler  = function(oTarget, sEventType, fnHandler) {
    if (oTarget.addEventListener) {
        oTarget.addEventListener(sEventType, fnHandler, false);
    } else if (oTarget.attachEvent) {
        oTarget.attachEvent("on" + sEventType, fnHandler);
    } else {
        oTarget["on" + sEventType] = fnHandler;
    }
};
var removeEventHandler = function(oTarget, sEventType, fnHandler) {
    if (oTarget.removeEventListener) {
        oTarget.removeEventListener(sEventType, fnHandler, false);
    } else if (oTarget.detachEvent) {
        oTarget.detachEvent("on" + sEventType, fnHandler);
    } else { 
        oTarget["on" + sEventType] = null;
    }
};
//--------------------------------------------------
//给数组增加一个max方法和min方法
//--------------------------------------------------
if (typeof Array.prototype['max'] == 'undefined'&&typeof Array.prototype['min'] == 'undefined') {
    Array.prototype.max = function() {  
        var max = this[0];
        var len = this.length; 
        for (var i = 1; i < len; i++){   
            if (parseInt(this[i]) > parseInt(max))max = this[i];   
        }   
        return max;
    };
    Array.prototype.min = function() {
        var min = this[0];
        var len = this.length;
        for (var i = 1; i < len; i++){
            if (parseInt(this[i]) < parseInt(min))min = this[i];
        }
     
        return min;
    };
};
//给函数加一个梆定参数的方法
Function.prototype.binding = function() {
    var args = [];
    for (i = 1; i < arguments.length; i++) {
        args.push(arguments[i]);
    }
    var method = this;
    var thisObj = arguments[0];
    return function() {
        return method.apply(thisObj, args);
    }
};
//统一鼠标键
var ehtButtonLeft      = 0;
var ehtButtonRight     = 2;
var ehtButtonMiddle    = 1;
if (jQuery.browser.msie) {
    ehtButtonLeft      = 1;
    ehtMButtonRight     = 2;
    ehtMButtonMiddle    = 4;
}else if(jQuery.browser.mozilla){
    ehtMButtonLeft      = 0;
    ehtMButtonRight     = 2;
    ehtMButtonMiddle    = 1;
} else {
    ehtButtonLeft      = 0;
    ehtButtonRight     = 2;
    ehtButtonMiddle    = 4;
}

var RangingCoords = [];  //存储测距旗子的坐标点
var RangingDistance;    //点与点之间的总距离
var RangingDistanceArray; //记录点与点之间的分段距离
var CosAlpha		= 0.707;                            //三维变形参数：旋转角度的Cos值，默认为cos45
var SinAlpha		= 0.707;                            //三维变形参数：旋转角度的Sin值，默认为sin45
var DistortionX		= 1;                                //三维变形参数：水平方向缩放比
var DistortionY		= 0.6;                              //三维变形参数：竖直方向缩放比
var Scale           = 0.227;
var CSSScaleLabel	= 'font-size:12px;height:30px;white-space: nowrap; position: absolute;  border: 1px solid #333333; padding: 1px; background-color: #fcf3cc;font-color:#FFFF00';
var PopLayerMoveTo;


var EHOOTU_iframe = Class.create();

EHOOTU_iframe.prototype  = {
    initialize : function(map){
        this.map = map; 
        this.level = map.defaultlevel;
        this.levels = map.levels;
        this.slicesize = map.sliceSize;
        this.imagepath = map.imagePath;
        this.imagetype = map.imageType;
        this.eyealts = EYE3D_DeYang_3D_MAP;
        this.eyeimagepath = this.eyealts.imagePath;
        this.proportional = map.proportional;
        this.dmap = '3d';
        this.FlagImage    = 'http://125.64.92.79/interface/system/flag.gif|16|28|0|28';
        this.FlagLine    = '#FFFF00|2';
        this.FlagImageId = 'Flagflag';
        //移动距离
        this.distanceX = 0;
        this.distanceY = 0;
        
        //地图的各种状态
        this.markMouseDown = false;
        this.markMouseMoving = false;
        this.markRanging = false;
        
        //记录当前点中的实体泡泡中心点
        this.currentSpot;
        //标签提示图层
        this.spot_tip;
		
		//标签状态数组
		this.spot_tip_flag = {'bus':true,'hospital':false,'school':false,'trip':false,'hotel':false,'gov':false,'stop':false,'wc':false,'police':false,'jiazheng':false};
		
        
        //设置地图中心点，以零级地图为标准，转换到当前级别地图上的中心点
        this.center = {
            Mx : map.defaultCoordinate[0]*this.levels[this.level],
            My : map.defaultCoordinate[1]*this.levels[this.level]
        };
    	this.eyecenter = {
    		Mx : Math.round(this.center.Mx/this.getProportional()),
    		My : Math.round(this.center.My/this.getProportional())
       	};
        //this.Tempcenter = this.center;
        //this.eyeTempcenter = this.eyecenter;
        this.Tempcenter = {};
        this.Tempcenter.Mx = this.center.Mx;
        this.Tempcenter.My = this.center.My;
        
        this.eyeTempcenter = {};
        this.eyeTempcenter.Mx = this.eyecenter.Mx;
        this.eyeTempcenter.My = this.eyecenter.My;
        
        //设置map层样式，并取得显示区域大小
        this.parentlayer = document.getElementById('map');
        this.width = map.mapWidth ? map.mapWidth : parseInt(this.parentlayer.style.width);
        this.height = map.mapHeight ? map.mapHeight : parseInt(this.parentlayer.style.height);
        this.halfWidth = Math.round(this.width/2);
        this.halfHeight = Math.round(this.height/2);
        this.parentlayer.style.width = this.width+'px';
        this.parentlayer.style.height = this.height+'px';  
        /*
            鹰眼图
        **/
        
        this.halfeyewidth = 91;
        this.halfeyeheight = 84;
        
        this.eyeview = document.createElement("div");
        this.eyeview.style.width = 2*this.halfeyewidth + 'px';
        this.eyeview.style.height = 2*this.halfeyeheight +'px';
        //this.eyeview.style.top = this.height - 2*this.halfeyeheight + 'px';
        //this.eyeview.style.left = this.width - 2*this.halfeyewidth + 'px';
        this.eyeview.style.position = 'absolute';
        this.eyeview.style.overflow = 'hidden';
        this.eyeview.style.zIndex = 200;
        document.getElementById('eyeesMap').appendChild(this.eyeview);
        
        this.eyeimglayer = new Image();
        this.eyeimglayer.style.width = 2*this.halfeyewidth + 'px';
        this.eyeimglayer.style.height = 2*this.halfeyeheight + 'px';
        this.eyeimglayer.style.top = '0px';
        this.eyeimglayer.style.left = '0px';
        this.eyeimglayer.style.border = 'none';
        this.eyeimglayer.style.cursor = 'default';
        this.eyeimglayer.style.position = 'absolute';
        this.eyeimglayer.src = 'http://125.64.92.79/interface/system/map.gif';
        this.eyeimglayer.style.zIndex = 3;
        this.eyeview.appendChild(this.eyeimglayer);               
        
        this.eyeviewlayer = document.createElement("div");
        this.eyeviewlayer.id = this.eyealts.ns;
        this.eyeviewlayer.style.position = 'absolute';
        this.eyeviewlayer.style.top = this.halfeyeheight + 'px';
        this.eyeviewlayer.style.left = this.halfeyewidth +'px';
        this.eyeviewlayer.style.zIndex = 1;
        this.eyeview.appendChild(this.eyeviewlayer);
        
        this.halfeyeminiwidth = 20;
        this.halfeyeminiheight = 15;
        this.eyemini = document.createElement("div");
        this.eyemini.id = 'eyemini';
        this.eyemini.style.position = 'absolute';
        this.eyemini.style.zIndex = 2;
        this.eyemini.style.width = this.halfeyeminiwidth*2 + 'px';
        this.eyemini.style.height = this.halfeyeminiheight*2 + 'px';
        this.eyemini.style.top = this.halfeyeheight - this.halfeyeminiheight + 'px';
        this.eyemini.style.left = this.halfeyewidth - this.halfeyeminiwidth + 'px';
        this.eyemini.style.border = '2px solid #ff0000';
        this.eyeview.appendChild(this.eyemini);
              
        /*
          创建mapview层添加到map层里面，mapview层的起点(左上角)在显示区域中心点
          mapview层下包括几个图层，3d，2d，img层
        **/
        this.mapviewlayer = document.createElement("div");
        this.mapviewlayer.id = map.ns;
        this.mapviewlayer.style.top = this.halfHeight+'px';
        this.mapviewlayer.style.left = this.halfWidth+'px';
        this.mapviewlayer.style.position = 'absolute';
        this.mapviewlayer.style.zIndex = 50;
        this.parentlayer.appendChild(this.mapviewlayer);
        
        //创建3d图层
        this.map3dlayer = document.createElement("div");
        this.map3dlayer.id = map.id;
        this.map3dlayer.style.position = 'absolute';
        this.map3dlayer.style.left = '0px';;
        this.map3dlayer.style.top = '0px';
        this.map3dlayer.style.zIndex = 1;
        this.mapviewlayer.appendChild(this.map3dlayer);
        //创建2d图层
        this.map2dlayer = document.createElement("div");
        this.map2dlayer.id ='map2d';
        this.map2dlayer.style.position = 'absolute';
        this.map2dlayer.style.left = '0px';;
        this.map2dlayer.style.top = '0px';
        this.map2dlayer.style.zIndex = 1;
        this.mapviewlayer.appendChild(this.map2dlayer);
		//创建地图修饰图层，里面放上对地图的修饰。并没有事件。
		this.mapFlashlayer = document.createElement("div");
        this.mapFlashlayer.style.position = 'absolute';
        this.mapFlashlayer.style.left = '0px';;
        this.mapFlashlayer.style.top = '0px';
        this.mapFlashlayer.style.zIndex = 1;
        this.mapviewlayer.appendChild(this.mapFlashlayer);
       
        
        //增加一个map层用于放area热区
        this.map_area = document.createElement('map');
        this.map_area.name = 'spot_map';
        this.map_area.id = 'spot_map';
        this.parentlayer.appendChild(this.map_area);
        
        //创建img图层，截获鼠标事件
        this.imglayer = new Image();
        this.imglayer.style.width = this.width+'px';
        this.imglayer.style.height = this.height+'px';
        this.imglayer.style.top = '0px';
        this.imglayer.style.left = '0px';
        this.imglayer.style.border = 'none';
        this.imglayer.style.cursor = 'default';
        this.imglayer.src = 'http://125.64.92.79/interface/system/map.gif';
        this.imglayer.width = this.width;
        this.imglayer.height = this.height;
        //和area关系起来
        this.imglayer.useMap = '#spot_map';
        this.imglayer.style.position = 'absolute';
        this.imglayer.style.zIndex = 100;
        this.parentlayer.appendChild(this.imglayer);
        $(this.imglayer).bind('mousedown',{container : 'main', map:this},this.mouseDown);
        $(this.imglayer).bind('dblclick', {map:this}, this.mapDblclick);
        $(this.imglayer).bind(mousewheel, {map:this}, this.mouseWheel);
        $(this.eyeimglayer).bind('mousedown',{container : 'eye', map:this},this.mouseDown);
        
        
        //地图标签容器层图层
        this.containerLayer = document.createElement('div');
        this.containerLayer.style.position = 'absolute';
        this.containerLayer.style.top = this.halfHeight+'px';
        this.containerLayer.style.left = this.halfWidth+'px';
        this.containerLayer.style.zIndex = 150;
        this.parentlayer.appendChild(this.containerLayer);
           
        //地图放大缩小功能
        var arrayZooms = ['Max','0','1','2','3','4','5','Min'];
        for(var i = 0; i<arrayZooms.length; i++){
            $('#Ezoom'+arrayZooms[i]).bind('click', {i : arrayZooms[i], map : this},this.levelChange);
        }        
        
        //已加载js数据的历史数据
        this.script_data_array = new Array(); 
        //已加载的热区数据
        this.append_spot_data = new Array();
        //已加载的标签数据
        this.append_sign_data = new Array();
        
        //加载地图
        this.mapcurview = this.map3dlayer;
        
        this.setSliderPosition(this.level);  
        this.loadEyeMap();
        this.LoadMap();
        this.display_map_data();
    },

    levelChange : function(obj){
    	var i = obj.data.i;
		var map = obj.data.map;
    	
    	//暂时清空busline的数据，没有找到好的方法
		if(map.busLayer) map.busLayer.innerHTML = '';	
		if(map.signLayer) map.signLayer.innerHTML = '';
        map.hidden_svg_vml();
		
		if (map.level == i) {return;}		
		if (i == 'Max') {
		    if (map.level > 0) {
		        i = parseInt(map.level) - 1;
		    } else {
		        return;
		    }
		}
		if (i == 'Min') {
		    if (map.level < 5) {
		        i = parseInt(map.level) + 1;
		    } else {
		        return;
		    }
		}

		map.mapcurview.innerHTML = '';
		map.eyeviewlayer.innerHTML = '';
		map.mapviewlayer.style.left = map.halfWidth + 'px';
		map.mapviewlayer.style.top = map.halfHeight + 'px';
		map.eyeviewlayer.style.left = map.halfeyewidth + 'px';
		map.eyeviewlayer.style.top = map.halfeyeheight + 'px';
		map.containerLayer.style.left =  map.halfWidth +'px';
        map.containerLayer.style.top =  map.halfHeight +'px';
        
		map.Tempcenter.Mx = Math.round(map.Tempcenter.Mx*(map.levels[i]/map.levels[map.level]));
		map.Tempcenter.My = Math.round(map.Tempcenter.My*(map.levels[i]/map.levels[map.level]));
		map.level = i;
		
		map.distanceX = map.Tempcenter.Mx - map.center.Mx;
		map.distanceY = map.Tempcenter.My - map.center.My;
		
		//map.center = map.Tempcenter;
		map.center.Mx = map.Tempcenter.Mx;
		map.center.My = map.Tempcenter.My;
	    map.eyeTempcenter = {
    		Mx : Math.round(map.center.Mx/map.getProportional()),
    		My : Math.round(map.center.My/map.getProportional())
   	    };
        //map.eyecenter = map.eyeTempcenter;
        map.eyecenter.Mx = map.eyeTempcenter.Mx;
        map.eyecenter.My = map.eyeTempcenter.My;
		map.setSliderPosition(i);
		map.displayMap();
		if(map.FlagLayer && map.markRanging){
		    Flag = null;
		    map.FlagLayer.innerHTML = '';
            map.reRangingDrawLine();
		}		

		//改变当前点中的实体泡泡中心点坐标和bus泡泡的中心点
		if(typeof(map.currentSpot) == 'object'&& map.spotDivIframe.style.display=='block'){map.spot_mouse_click(map.currentSpot);}
		if(typeof(map.currentBusSign) == 'object'&& map.BusSignDivIframe.style.display=='block'){map.busSignClick(map.currentBusSign);}
		
		//map.mapFlashlayer.innerHTML = '';
		if(!map.pingmian){
			MapAdFlash();
		}

						
    },
    getProportional : function(){
    	 var level = this.level;
    	 var proportional = this.proportional;
    	 if (this.level == 4) {
    	 	 	proportional = this.proportional / 2;
    	 } else if(this.level == 5){
    	 		proportional = this.proportional / 4;
    	 }
    	 return proportional;
    },
		
    displayMap : function(){
        var cur_width = this.mapWidth ? this.mapWidth : parseInt(this.parentlayer.style.width);
        var cur_height = this.mapHeight ? this.mapHeight : parseInt(this.parentlayer.style.height);
        var resize_x = cur_width - this.width;
        var resize_y = cur_height - this.height;
        
        this.width = cur_width;
        this.height = cur_height;
        
        this.mapviewlayer.style.left = parseInt(this.mapviewlayer.style.left) + Math.round(resize_x/2) + 'px';
        this.mapviewlayer.style.top = parseInt(this.mapviewlayer.style.top) + Math.round(resize_y/2) + 'px';
				this.containerLayer.style.left =  parseInt(this.containerLayer.style.left)+ Math.round(resize_x/2) +'px';
        this.containerLayer.style.top =  parseInt(this.containerLayer.style.top) + Math.round(resize_y/2) +'px';
        this.halfWidth = Math.round(this.width/2);
        this.halfHeight = Math.round(this.height/2);
        this.parentlayer.style.width = this.width+'px';
        this.parentlayer.style.height = this.height+'px';
        this.imglayer.style.width = this.width+'px';
        this.imglayer.style.height = this.height+'px';
        
    	this.loadEyeMap();
		this.LoadMap();
		if (!this.pingmian){
			this.display_map_data();
		}
    },
    displayEysMap : function(width,height){
    	
    	this.eyeviewlayer.style.top = height/2-this.halfeyeheight + parseInt(this.eyeviewlayer.style.top) + 'px';
        this.eyeviewlayer.style.left = width/2-this.halfeyewidth + parseInt(this.eyeviewlayer.style.left) + 'px';
        this.eyemini.style.top = Math.round(height/2) - this.halfeyeminiheight + 'px';
        this.eyemini.style.left = Math.round(width/2) - this.halfeyeminiwidth + 'px';
    	
    	this.halfeyewidth = width/2;
        this.halfeyeheight = height/2;
        
    	this.eyeview.style.width = width + 'px';
        this.eyeview.style.height = height +'px';
        this.eyeimglayer.style.width = width + 'px'; 
        this.eyeimglayer.style.height = height +'px';
        this.loadEyeMap();
    },
    mapMoveTo : function(x, y){
    	if ((this.spot_centerX && this.spot_centerX == x) && (this.spot_centerY && this.spot_centerY == y)) {
    		if(typeof(this.currentSpot) == 'object'&& this.spotDivIframe.style.display=='none'){this.spotDivIframe.style.display=='block';}
			if(typeof(this.currentBusSign) == 'object'&& this.BusSignDivIframe.style.display=='none'){ this.BusSignDivIframe.style.display=='block';}
    		return;
    	} else {
    		this.spot_centerX = x;
    		this.spot_centerY = y;
    	}
    	
        var step = 10;
        
        this.distanceX = this.Tempcenter.Mx - Math.round(x*this.levels[this.level]);
        this.distanceY = this.Tempcenter.My - Math.round(y*this.levels[this.level]);
        
        if (PopLayerMoveTo) {
            window.clearInterval(PopLayerMoveTo);
        }
        var sx = Math.floor(this.distanceX / step);
        var sy = Math.floor(this.distanceY / step);
        var px = Math.abs(this.distanceX % step);
        var py = Math.abs(this.distanceY % step);
        
        if (px != 0)sx = (sx < 0) ? sx : sx + 1;
        if (py != 0)sy = (sy < 0) ? sy : sy + 1;
        var stepnum = 0;
        PopLayerMoveTo = window.setInterval(function(){
            if (px != 0 && stepnum == px)sx = (sx < 0) ? sx + 1: sx - 1;
            if (py != 0 && stepnum == py)sy = (sy < 0) ? sy + 1: sy - 1;
         
            this.containerLayer.style.left = (parseInt(this.mapviewlayer.style.left) + sx) + 'px';
            this.containerLayer.style.top = (parseInt(this.mapviewlayer.style.top) + sy) + 'px';
            
            this.mapviewlayer.style.left = (parseInt(this.mapviewlayer.style.left) + sx) + 'px';
            this.mapviewlayer.style.top = (parseInt(this.mapviewlayer.style.top) + sy) + 'px';
            
            this.eyeviewlayer.style.left = (parseInt(this.eyeviewlayer.style.left) + Math.round(sx/this.getProportional())) + 'px';
            this.eyeviewlayer.style.top = (parseInt(this.eyeviewlayer.style.top) + Math.round(sy/this.getProportional())) + 'px';
            
            if (stepnum++ == step - 1)
            {
                window.clearInterval(PopLayerMoveTo);
                PopLayerMoveTo == null;
                this.Tempcenter.Mx = x*this.levels[this.level];
                this.Tempcenter.My = y*this.levels[this.level];
                this.eyeTempcenter.Mx = Math.round(this.Tempcenter.Mx/this.getProportional());
                this.eyeTempcenter.My = Math.round(this.Tempcenter.My/this.getProportional());
                this.removeMapImg(this);
                this.moveimg(this);
                this.removeEyeMapImg(this);
                this.eyemoveimg(this);
                this.display_map_data();
            }
        }.binding(this),10);
    },    
    mouseDown : function(obj){
        var map = obj.data.map;
        var container = obj.data.container;

        map.markMouseDown = true;
        map.clientX = obj.clientX;
        map.clientY = obj.clientY;
        map.left = parseInt(map.mapviewlayer.style.left);
        map.top = parseInt(map.mapviewlayer.style.top);


        map.eyeleft = parseInt(map.eyeviewlayer.style.left);
        map.eyetop = parseInt(map.eyeviewlayer.style.top);

        $(document).bind('mouseup',{container : container , map : map},map.mouseUp);
        $(document).bind('mousemove',{container : container , map : map},map.mouseMove);
        

 
//        if(!isIE){
//          //焦点丢失
//          addEventHandler(document, "losecapture", Bind(this,this.mouseUp));
//          //设置鼠标捕获
//          //this.imglayer.setCapture();
//        }else{
//          //焦点丢失
//          addEventHandler(window, "blur", Bind(this,this.mouseUp));
//          //阻止默认动作
//          e.preventDefault();
//        }
        
        return false;
    },
    
    mouseUp : function(obj){
        var map = obj.data.map;
        var container = obj.data.container;
        map.imglayer.style.cursor = 'default';
        map.eyeimglayer.style.cursor = 'default';
        $(document).unbind('mouseup', map.mouseUp);
        $(document).unbind('mousemove', map.mouseMove);
        //----------------------------------------------------------------------------
        //加载数据(移动的过程中加载图片，移动结束加载数据，这样减少加快网路传输速度)
        //----------------------------------------------------------------------------
        //地图是处于拖动的状态则加载数据
        if(map.markMouseMoving){
            if (!map.pingmian){
	            //清空signview下的数据，以便重新加载
	            map.signLayer.innerHTML = "";
	            //加载地图信息
	            map.display_map_data();
        	}
            //--------------------------------------
            //取消热区显示
            //--------------------------------------
            map.hidden_svg_vml();
        }
        if (map.markRanging && !map.markMouseMoving && container == 'main') {
            if (obj.button == ehtButtonLeft){
                map.putFlag(obj);
            }
        }
        //alert(map.center.Mx+'//'+map.Tempcenter.Mx);
        map.markMouseDown = false;
        map.markMouseMoving = false;
        map.removeMapImg(map);
        map.removeEyeMapImg(map);
/*         
        if(isIE){
          removeEventHandler(this.imglayer, "losecapture", Bind(this,this.mouseUp));
          this.imglayer.releaseCapture();
        }else{
          removeEventHandler(window, "blur", Bind(this,this.mouseUp));
        };
**/
        return true;        
    },                       
                             
    mouseMove : function(obj){ 
        var map = obj.data.map;
        var container = obj.data.container;
        if (map.markRanging){
            map.showRangingFlag(obj);
        }
        if(map.markMouseDown){
            map.markMouseMoving = true;
            //清空map下area数据，以便重新加载
            map.map_area.innerHTML = "";
            
            window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty();
            if(container == 'eye'){
                map.eyeimglayer.style.cursor = 'move';
                map.eyedistanceX = obj.clientX - map.clientX;
                map.eyedistanceY = obj.clientY - map.clientY;
                map.distanceX = map.eyedistanceX*map.getProportional();
                map.distanceY = map.eyedistanceY*map.getProportional();
            } else {    //main

                map.imglayer.style.cursor = 'move'; 
                map.distanceX = obj.clientX - map.clientX;
                map.distanceY = obj.clientY - map.clientY;
                map.eyedistanceX = Math.round(map.distanceX/map.getProportional());
                map.eyedistanceY = Math.round(map.distanceY/map.getProportional());                    
            }
            if(Math.abs(map.distanceX) < 10&&Math.abs(map.distanceY)<10){return false;}
            map.mapviewlayer.style.left = map.left+map.distanceX+'px';
            map.mapviewlayer.style.top = map.top+map.distanceY+'px';
            
            //标志图层
            map.containerLayer.style.left =  map.left+map.distanceX+'px';
            map.containerLayer.style.top =  map.top+map.distanceY+'px';
            
            //鹰眼图层
            map.eyedistanceX = Math.round(map.distanceX/map.getProportional());
            map.eyedistanceY = Math.round(map.distanceY/map.getProportional());
            
            map.eyeviewlayer.style.left = map.eyeleft + map.eyedistanceX +'px';
            map.eyeviewlayer.style.top = map.eyetop + map.eyedistanceY +'px';
            
            //当前地图中心点的位置
            map.Tempcenter = {
        		Mx : map.center.Mx-(parseInt(map.mapviewlayer.style.left)-map.halfWidth),
        		My : map.center.My-(parseInt(map.mapviewlayer.style.top)-map.halfHeight)
           	};
           	map.eyeTempcenter = {
        		Mx : map.eyecenter.Mx-(parseInt(map.eyeviewlayer.style.left)-map.halfeyewidth),
        		My : map.eyecenter.My-(parseInt(map.eyeviewlayer.style.top)-map.halfeyeheight)
           	};

			map.moveimg(map);
			map.eyemoveimg(map);
	      }
        return false;
    },
    mapDblclick : function(obj){
        var map = obj.data.map;
        if (map.markRanging){
            map.markRanging = false;
            RangingCoords = [];
            RangingDistance = null;
            RangingDistanceArray = null;
            Flag = null;
            map.FlagLayer.innerHTML = '';
            map.imglayer.useMap = '#spot_map';
        } else {
            if (map.level == 0) {
                return;
            } else {
                map.Tempcenter.Mx = map.Tempcenter.Mx - (map.halfWidth - (obj.pageX - map.parentlayer.offsetLeft));
                map.Tempcenter.My = map.Tempcenter.My - (map.halfHeight - (obj.pageY - map.parentlayer.offsetTop));
                var i = map.level - 1;
                map.levelChange({data : {i : i, map : map}});
            }
        }
    },
    mouseWheel : function(obj){
    	var map = obj.data.map;
    	var _level = map.level;
		if (obj.wheelDelta >0 || obj.detail<0){
			if(_level == 0)return;
			_level--;
        } else {
        	if(_level == 5)return;
        	_level++;
        }
        map.levelChange({data : {i : _level, map : map}});
    },
    moveimg : function(map){
        //var topY = map.H1*map.slicesize + map.Tempcenter.My - map.center.My;
        var topY = map.H1*map.slicesize - map.Tempcenter.My + map.halfHeight;
        var leftX = map.L1*map.slicesize - map.Tempcenter.Mx + map.halfWidth;
        var rightX = (map.L2+1)*map.slicesize-map.halfWidth - map.Tempcenter.Mx;
        //原始表达式var rightX = ((map.L2+1)*map.slicesize-map.center.Mx-Math.floor(map.width/2)) - (Math.floor(map.widht/2) - map.Tempcenter.Mx);
        var bottomY = (map.H2+1)*map.slicesize-map.halfHeight - map.Tempcenter.My;
        //原始表达式var bottomY = ((map.H2+1)*map.slicesize-map.center.My-Math.floor(map.height/2)) - (Math.floor(map.height/2) - map.Tempcenter.My);

        if(map.distanceY > 0){
            var tn = Math.ceil(topY/map.slicesize);
            map.H1 = map.H1 - tn;
                              
            if (map.distanceX > 0){
                var tn = Math.ceil(leftX/map.slicesize);
                map.L1 = map.L1 - tn;
                //alert(map.L1+'//'+map.center.Mx);
                for (var i = map.L1; i <= map.L2; i++) {
                    for (var j = map.H1; j <= map.H2; j++) {
                        map.LoadMapImg(i,j);
                    }
                }
             } else {
                var tn = Math.floor(rightX/map.slicesize);
                map.L2 = map.L2 - tn;
                for (var i = map.L1; i <= map.L2; i++) {
                    for (var j = map.H1; j <= map.H2; j++) {
                        map.LoadMapImg(i,j);
                    }
                }
            }
       } else {
            var tn = Math.floor(bottomY/map.slicesize);
            map.H2 = map.H2 - tn;
                
            if (map.distanceX > 0){
                var tn = Math.ceil(leftX/map.slicesize);
                map.L1 = map.L1 - tn;
                for (var i = map.L1; i <= map.L2; i++) {
                    for (var j = map.H1; j <= map.H2; j++) {
                        map.LoadMapImg(i,j);
                    }
                }
            } else {
                var tn = Math.floor(rightX/map.slicesize);
                map.L2 = map.L2 - tn;
                for (var i = map.L1; i <= map.L2; i++) {
                    for (var j = map.H1; j <= map.H2; j++) {
                        map.LoadMapImg(i,j);
                    }
                }
            }
        }
    },
    eyemoveimg : function(map){
       	var eyeleftX = map.eyeRowMin*map.slicesize - map.eyeTempcenter.Mx + map.halfeyewidth;
        var eyerightX = (map.eyeRowMax+1)*map.slicesize-map.halfeyewidth - map.eyeTempcenter.Mx;
        var eyetopY = map.eyeColumnMin*map.slicesize - map.eyeTempcenter.My + map.halfeyeheight;
        var eyebottomY = (map.eyeColumnMax+1)*map.slicesize-map.halfeyeheight - map.eyeTempcenter.My;
        if(map.distanceY > 0){
            var tn = Math.ceil(eyetopY/map.slicesize);
            map.eyeColumnMin = map.eyeColumnMin - tn;
            if (map.distanceX > 0){
                var tn = Math.ceil(eyeleftX/map.slicesize);
                map.eyeRowMin = map.eyeRowMin - tn;
                for (var i = map.eyeRowMin; i <= map.eyeRowMax; i++) {
                    for (var j = map.eyeColumnMin; j <= map.eyeColumnMax; j++) {
                        map.loadEyeMapImg(i, j);
                    }
                }
            } else {
                var tn = Math.floor(eyerightX/map.slicesize);
                map.eyeRowMax = map.eyeRowMax - tn;
                for (var i = map.eyeRowMin; i <= map.eyeRowMax; i++) {
                    for (var j = map.eyeColumnMin; j <= map.eyeColumnMax; j++) {
                        map.loadEyeMapImg(i, j);
                    }
                }
            }
       } else {
            var tn = Math.floor(eyebottomY/map.slicesize);
            map.eyeColumnMax = map.eyeColumnMax - tn;
                if (map.distanceX > 0){
                    var tn = Math.ceil(eyeleftX/map.slicesize);
                    map.eyeRowMin = map.eyeRowMin - tn;
                    for (var i = map.eyeRowMin; i <= map.eyeRowMax; i++) {
                        for (var j = map.eyeColumnMin; j <= map.eyeColumnMax; j++) {
                            map.loadEyeMapImg(i, j);
                        }
                    }
                } else {
                    var tn = Math.floor(eyerightX/map.slicesize);
                    map.eyeRowMax = map.eyeRowMax - tn;
                    for (var i = map.eyeRowMin; i <= map.eyeRowMax; i++) {
                        for (var j = map.eyeColumnMin; j <= map.eyeColumnMax; j++) {
                            map.loadEyeMapImg(i, j);
                        }
                    }
                }               
        }
    },    
    LoadMapImg : function(i,j){
        if(document.getElementById(this.dmap + '_' +i+'_'+j)){return;}
        var src = this.imagepath+this.level+'/'+i+','+j+this.imagetype;
        var mapdiv = document.createElement("div");
        mapdiv.style.left = i*this.slicesize-this.center.Mx+'px';
        mapdiv.style.top = j*this.slicesize-this.center.My+'px';
        mapdiv.style.width = this.slicesize+'px';
        mapdiv.style.height = this.slicesize+'px';
        mapdiv.style.backgroundRepeta = 'no-repeat';
        mapdiv.style.backgroundImage = 'url('+src+')';
        mapdiv.style.position = 'absolute';
        mapdiv.style.display = 'block';
        mapdiv.setAttribute('id', this.dmap+'_'+i+'_'+j);
        this.mapcurview.appendChild(mapdiv);
    },
    loadEyeMapImg : function(i, j){
		if(document.getElementById('eye_'+i+'_'+j)){return;}
	    var src = this.eyeimagepath+this.level+'/'+i+','+j+this.imagetype;
        var mapdiv = document.createElement("div");
        mapdiv.style.left = i*this.slicesize - this.eyecenter.Mx+'px';
        mapdiv.style.top = j*this.slicesize - this.eyecenter.My+'px';
        mapdiv.style.width = this.slicesize+'px';
        mapdiv.style.height = this.slicesize+'px';
        mapdiv.style.backgroundRepeta = 'no-repeat';
        mapdiv.style.backgroundImage = 'url('+src+')';
        mapdiv.style.position = 'absolute';
        mapdiv.style.display = 'block';
        mapdiv.style.zIndex = '1';
        mapdiv.setAttribute('id','eye_'+i+'_'+j);
        this.eyeviewlayer.appendChild(mapdiv);
    },
    
    loadEyeMap : function(){
        this.eyeRowMin = Math.floor((this.eyecenter.Mx-this.halfeyewidth)/this.slicesize);
        this.eyeRowMax = Math.floor((this.eyecenter.Mx+this.halfeyewidth)/this.slicesize);
        this.eyeColumnMin = Math.floor((this.eyecenter.My-this.halfeyeheight)/this.slicesize);
        this.eyeColumnMax = Math.floor((this.eyecenter.My+this.halfeyeheight)/this.slicesize);
        for(var j = this.eyeColumnMin; j <= this.eyeColumnMax; j++)
        {
            for(var i = this.eyeRowMin; i <= this.eyeRowMax; i++)
            {
		        if(document.getElementById('eye_'+i+'_'+j)){return;}
		        var src = this.eyeimagepath+this.level+'/'+i+','+j+this.imagetype;
		        var mapdiv = document.createElement("div");
		        mapdiv.style.left = i*this.slicesize-this.eyecenter.Mx+'px';
		        mapdiv.style.top = j*this.slicesize-this.eyecenter.My+'px';
		        mapdiv.style.width = this.slicesize+'px';
		        mapdiv.style.height = this.slicesize+'px';
		        mapdiv.style.backgroundRepeta = 'no-repeat';
		        mapdiv.style.backgroundImage = 'url('+src+')';
		        mapdiv.style.position = 'absolute';
		        mapdiv.style.display = 'block';
		        mapdiv.setAttribute('id','eye_'+i+'_'+j);
		        this.eyeviewlayer.appendChild(mapdiv);
            }
        }
    },
   
    LoadMap : function(){
        var i,j;
        var L1,L2;
        var H1,H2;
        var layer;
        
        this.L1 = Math.floor((this.center.Mx-this.halfWidth)/this.slicesize);
        this.H1 = Math.floor((this.center.My-this.halfHeight)/this.slicesize);
        this.L2 = Math.floor((this.center.Mx+this.halfWidth)/this.slicesize);
        this.H2 = Math.floor((this.center.My+this.halfHeight)/this.slicesize);
        //alert(this.L1+'//'+this.L2+'//'+this.H1+'//'+this.H2+'//'+this.center.Mx);
        for(j=this.H1;j<=this.H2;j++)
        {
            for(i=this.L1;i<=this.L2;i++)
            {
                this.LoadMapImg(i,j);
            }
        }
    },
    removeMapImg : function(map){
                for (var i = map.L1; i < map.L2; i++) {
                        var temprightX = -((i+1)*map.slicesize - map.Tempcenter.Mx + map.halfWidth);
                        if (temprightX > 0) {
                                for (var j = map.H1; j<=map.H2; j++){
                                        $('#'+map.dmap+'_'+i+'_'+j).remove();
                                }
                                map.L1 += 1;
                        } else {
                                break;
                        }
                }
                
                //删除超出显示区域右边的图片
                for (var i = map.L2; i > map.L1; i--) {
                        var templeftX = i*map.slicesize-map.halfWidth - map.Tempcenter.Mx;
                        if (templeftX > 0) {
                                for (var j = map.H1; j<=map.H2; j++){
                                        $('#'+map.dmap+'_'+i+'_'+j).remove();
                                }
                                map.L2 -= 1;
                        } else {
                                break;
                        }
                }
                
                //删除超过显示区域下面的图
        for (var j = map.H2; j > map.H1; j--) {
            var tempbottomY = map.H2*map.slicesize-map.halfHeight - map.Tempcenter.My;
            if (tempbottomY > 0) {
                for (var i = map.L1; i<=map.L2; i++){
                    $('#'+map.dmap+'_'+i+'_'+j).remove();
                }
                map.H2 -= 1;
            } else {
                break;
            }
        }
        //删除超过显示区域上面的图
        for (var j = map.H1; j < map.H2; j++) {
                var temptopY = -((map.H1+1)*map.slicesize - map.Tempcenter.My + map.halfHeight);
                if (temptopY > 0) {
                    for (var i = map.L1; i<=map.L2; i++){
                            $('#'+map.dmap+'_'+i+'_'+j).remove();
                    }
                    map.H1 += 1;
            } else {
                    break;
            }
        }
    },
    removeEyeMapImg : function(map){
        for (var i = map.eyeRowMin; i < map.eyeRowMax; i++) {
                var eyetemprightX = -((i+1)*map.slicesize - map.eyeTempcenter.Mx + map.halfeyewidth);
                if (eyetemprightX > 0) {
                        for (var j = map.eyeColumnMin; j<=map.eyeColumnMax; j++){
                                $('#eye_'+i+'_'+j).remove();
                        }
                        map.eyeRowMin += 1;
                } else {
                        break;
                }
        }
        
        //删除超出显示区域右边的图片
        for (var i = map.eyeRowMax; i > map.eyeRowMin; i--) {
                var eyetempleftX = i*map.slicesize-map.halfeyewidth - map.eyeTempcenter.Mx;
                if (eyetempleftX > 0) {
                        for (var j = map.eyeColumnMin; j<=map.eyeColumnMax; j++){
                                $('#eye_'+i+'_'+j).remove();
                        }
                        map.eyeRowMax -= 1;
                } else {
                        break;
                }
        }
                
                //删除超过显示区域下面的图
        for (var j = map.eyeColumnMax; j > map.eyeColumnMin; j--) {
            var eyetempbottomY = map.eyeColumnMax*map.slicesize-map.halfeyeheight - map.eyeTempcenter.My;
            if (eyetempbottomY > 0) {
                for (var i = map.eyeRowMin; i<=map.eyeColumnMax; i++){
                    $('#eye_'+i+'_'+j).remove();
                }
                map.eyeColumnMax -= 1;
            } else {
                break;
            }
        }
        //删除超过显示区域上面的图
        for (var j = map.eyeColumnMin; j < map.eyeColumnMax; j++) {
                var eyetemptopY = -((map.eyeColumnMin+1)*map.slicesize - map.eyeTempcenter.My + map.halfeyeheight);
                if (eyetemptopY > 0) {
                    for (var i = map.eyeRowMin; i<=map.eyeRowMax; i++){
                            $('#eye_'+i+'_'+j).remove();
                    }
                    map.eyeColumnMin += 1;
            } else {
                    break;
            }
        }        
    },

    Conversion : function (dmap){
        //this.center = this.Tempcenter;
        this.center.Mx = this.Tempcenter.Mx;
        this.center.My = this.Tempcenter.My;
        this.mapviewlayer.style.left = this.halfWidth + 'px';
        this.mapviewlayer.style.top = this.halfHeight + 'px';
        this.containerLayer.style.left = this.halfWidth + 'px';
        this.containerLayer.style.top = this.halfHeight + 'px';
        
		if (dmap) {
	        this.map3dlayer.innerHTML = '';
	        this.imagepath = this.map.imagePath2D;
	        this.mapcurview = this.map2dlayer;
	        this.dmap = '2d';
	        this.imglayer.useMap = '';
	        if(typeof(this.spotDivIframe) == 'object'){this.spotDivIframe.style.display='none';}
			if(typeof(this.BusSignDivIframe) == 'object'){this.BusSignDivIframe.style.display='none';}
			this.mapFlashlayer.innerHTML = '';
			this.containerLayer.innerHTML = '';
			
		} else {
	        this.map2dlayer.innerHTML = '';
	        this.imagepath = this.map.imagePath;
	        this.mapcurview = this.map3dlayer;
	        this.dmap = '3d';
			if (!this.markRanging){
				this.imglayer.useMap = '#spot_map';
			}
	        MapAdFlash();
		}
		if(this.FlagLayer && this.markRanging){
			Flag = null;
			this.FlagLayer.innerHTML = '';
			this.reRangingDrawLine();
		}
		
        this.LoadMap();
        
    },
    Ranging : function(){
      this.markRanging = true;
      $(this.imglayer).bind('mouseup',{container : 'main', map:this},this.mouseUp);
      $(this.imglayer).bind('mousemove',{map:this},this.mouseMove);
      //测距开始，不显示热区
      this.imglayer.useMap = '';
    },
    showRangingFlag : function(obj){
        var Flag = document.getElementById(this.FlagImageId);
        var flagimg = this.FlagImage.split('|');
        if (!this.FlagLayer){
                this.FlagLayer = document.createElement('div');
                this.FlagLayer.style.position = 'absolute';
                this.FlagLayer.style.top = '0px';
                this.FlagLayer.style.left = '0px';
                this.FlagLayer.style.zIndex = '3';
                this.mapviewlayer.appendChild(this.FlagLayer);        
        }
        if(Flag){
                Flag.style.left = (obj.pageX - parseInt(this.mapviewlayer.style.left) - this.parentlayer.offsetLeft) + 'px';
                Flag.style.top = (obj.pageY - parseInt(this.mapviewlayer.style.top) - this.parentlayer.offsetTop  - parseInt(flagimg[2])) + 'px';
                Flag.style.zIndex = '9999';
                Flag.style.display = 'block';
        } else {
                Flag = document.createElement("img");
                Flag.style.left = (obj.pageX - parseInt(this.mapviewlayer.style.left) - this.parentlayer.offsetLeft) + 'px';
                Flag.style.top = (obj.pageY - parseInt(this.mapviewlayer.style.top) - this.parentlayer.offsetTop - parseInt(flagimg[2])) + 'px';
                Flag.style.width = parseInt(flagimg[1]) + 'px';
                Flag.style.height = parseInt(flagimg[2]) + 'px';
                Flag.style.position = 'absolute';
                Flag.style.display = 'none';
                Flag.setAttribute('src', flagimg[0]);
                Flag.setAttribute('id', this.FlagImageId);
                this.FlagLayer.appendChild(Flag);
        }
    },
    putFlag : function(obj){
        var map = obj.data.map;
        var flagimg = this.FlagImage.split('|');
        var ehtFlag = $("<img />");
        var putFlag = document.createElement("img");
        putFlag.style.left = (obj.pageX - parseInt(this.mapviewlayer.style.left) - this.parentlayer.offsetLeft) + 'px';
        putFlag.style.top = (obj.pageY - parseInt(this.mapviewlayer.style.top) - this.parentlayer.offsetTop - parseInt(flagimg[2])) + 'px';
        putFlag.style.width = parseInt(flagimg[1]) + 'px';
        putFlag.style.height = parseInt(flagimg[2]) + 'px';
        putFlag.style.position = 'absolute';
        putFlag.setAttribute('src', flagimg[0]);
        this.FlagLayer.appendChild(putFlag);
        ehtFlag = null;
        flagimg = null;
        if(!RangingCoords){RangingCoords = [];}
        if(!RangingDistanceArray){RangingDistanceArray = [];}
        var mapCoords = map.getMapCoords(obj.pageX, obj.pageY);
        var RClength = RangingCoords.length;
        RangingCoords[RClength] = mapCoords.x;
        RangingCoords[RClength+1] = mapCoords.y;
        RClength = RangingCoords.length;
        //alert(RangingCoords.length);
        var RClayer = document.createElement('div');
        if (RClength >= 4){
            var Coords = RangingCoords.slice(RClength - 4);
            map.RangingDrawLine(Coords);        //画线
            
            if(!RangingDistance){RangingDistance = 0;}
            RangingDistance += map.getRangingDistance(Coords);
            var distance = RangingDistance;
    	    if(distance>1000){
    		    distance = distance/1000;
    		    distance = distance*100;
    		    distance = Math.round(distance);
    		    distance = distance/100;
    		    distance = distance+'km';
    	    } else {
    		    distance = distance*100;
    		    distance = Math.round(distance);
    		    distance = distance/100;
    		    distance = distance+'m';
    	    }
    	    RangingDistanceArray[RClength/2-1]=distance;
            RClayer.style.cssText = CSSScaleLabel;
            RClayer.style.position = 'absolute';
            RClayer.style.left = (obj.pageX - parseInt(this.mapviewlayer.style.left) - this.parentlayer.offsetLeft) + 'px';
            RClayer.style.top = (obj.pageY - parseInt(this.mapviewlayer.style.top) - this.parentlayer.offsetTop) + 'px';
            RClayer.innerHTML = distance + '<br />仅供参考';

        } else {
            RClayer.style.cssText = CSSScaleLabel;
            RClayer.style.position = 'absolute';
            RClayer.style.left = (obj.pageX - parseInt(this.mapviewlayer.style.left) - this.parentlayer.offsetLeft) + 'px';
            RClayer.style.top = (obj.pageY - parseInt(this.mapviewlayer.style.top) - this.parentlayer.offsetTop) + 'px';
            RClayer.innerHTML = '0<br />仅供参考';
            RangingDistanceArray[0] = 0;
        }
        this.FlagLayer.appendChild(RClayer);

    },
    RangingDrawLine : function(coords){
        var RangingLineStyle = this.FlagLine.split('|');
        var RangingLine;
        if (isIE) {
            RangingLine = document.createElement("<v:line />");
            RangingLine.setAttribute('strokecolor', RangingLineStyle[0]);
            RangingLine.setAttribute('strokeweight', RangingLineStyle[1]);
            RangingLine.setAttribute('from',(coords[0]*this.levels[this.level]-this.center.Mx) + ','+(coords[1]*this.levels[this.level]-this.center.My));
            RangingLine.setAttribute('to',(coords[2]*this.levels[this.level]-this.center.Mx) + ','+(coords[3]*this.levels[this.level]-this.center.My));
            RangingLine.setAttribute('position', 'absolute');
            this.FlagLayer.appendChild(RangingLine);

        } else {
            var _temp_svg = this.get_coords_xy_maxmin(coords.toString());
            Ranging_svg = document.createElementNS(__svg_namespace,'svg');
            Ranging_svg.setAttribute('overflow','visible');
            Ranging_svg.setAttribute('width', ((_temp_svg.x.max - _temp_svg.x.min)*this.levels[this.level]));
            Ranging_svg.setAttribute('height', (_temp_svg.y.max - _temp_svg.y.min)*this.levels[this.level]);
            Ranging_svg.style.display = 'block';
            Ranging_svg.style.position = 'absolute';
            Ranging_svg.style.zIndex = '100';
            Ranging_svg.style.left = ((_temp_svg.x.min)*this.levels[this.level] -this.center.Mx) + 'px';
            Ranging_svg.style.top = ((_temp_svg.y.min)*this.levels[this.level]-this.center.My) + 'px';
            this.FlagLayer.appendChild(Ranging_svg);
            
            var svg_rangingline = document.createElementNS(__svg_namespace,'line');
            svg_rangingline.setAttribute('x1', (coords[0] - _temp_svg.x.min)*this.levels[this.level]);
            svg_rangingline.setAttribute('y1', (coords[1] - _temp_svg.y.min)*this.levels[this.level]);
            svg_rangingline.setAttribute('x2', (_temp_svg.x.max - coords[0])*this.levels[this.level]);
            svg_rangingline.setAttribute('y2', (_temp_svg.y.max - coords[1])*this.levels[this.level]);
            svg_rangingline.setAttribute('stroke', RangingLineStyle[0]);
            svg_rangingline.setAttribute('stroke-width', RangingLineStyle[1]);
            Ranging_svg.appendChild(svg_rangingline);
            //alert('1');
        }
    },
    getMapCoords : function(pageX, pageY){
        return {
            x : (this.Tempcenter.Mx - (this.halfWidth - (pageX - this.parentlayer.offsetLeft)))/this.levels[this.level],
            y : (this.Tempcenter.My - (this.halfHeight - (pageY - this.parentlayer.offsetTop)))/this.levels[this.level]
        };
    },
    getRangingDistance : function(coords){
         var X1 = coords[0];
         var Y1 = coords[1];
         var X2 = coords[2];
         var Y2 = coords[3];
        return Math.sqrt((X1-X2)*(X1-X2)+(Y1-Y2)*(Y1-Y2))*Scale;
    },

    reRangingDrawLine : function(){
        var RangingLineStyle = this.FlagLine.split('|');
        var flagimg = this.FlagImage.split('|');
        var _rc_length = RangingCoords.length;
        var _sum = 0;
        var reRangingLine;
        var RClayer;
        var putFlag;
        if (_rc_length == 2){
            putFlag = document.createElement("img");
            putFlag.style.left = (RangingCoords[0]*this.levels[this.level]- this.Tempcenter.Mx) + 'px';
            putFlag.style.top = (RangingCoords[1]*this.levels[this.level]- this.Tempcenter.My - parseInt(flagimg[2])) + 'px';
            putFlag.style.width = parseInt(flagimg[1]) + 'px';
            putFlag.style.height = parseInt(flagimg[2]) + 'px';
            putFlag.style.position = 'absolute';
            putFlag.setAttribute('src', flagimg[0]);
            this.FlagLayer.appendChild(putFlag);
            
            RClayer = document.createElement('div');
            RClayer.style.cssText = CSSScaleLabel;
            RClayer.style.position = 'absolute';
            RClayer.style.left = (RangingCoords[0]*this.levels[this.level]- this.Tempcenter.Mx) + 'px';
            RClayer.style.top = (RangingCoords[1]*this.levels[this.level]- this.Tempcenter.My) + 'px';
            RClayer.innerHTML = RangingDistanceArray[0] + '<br />仅供参考';
            this.FlagLayer.appendChild(RClayer);
        } else if(_rc_length > 2){
            for (var i = 0; i < (_rc_length/2 - 1); i++){
                var _X1 = RangingCoords[_sum];
                var _Y1 = RangingCoords[_sum + 1];
                var _X2 = RangingCoords[_sum + 2];
                var _Y2 = RangingCoords[_sum + 3];
                this.RangingDrawLine([_X1,_Y1,_X2,_Y2]);
                _sum += 2;
            }
            var _sum_div = 0;
            for (var i = 0; i < _rc_length/2; i++){
                putFlag = document.createElement("img");
                putFlag.style.left = (RangingCoords[_sum_div]*this.levels[this.level]- this.Tempcenter.Mx) + 'px';
                putFlag.style.top = (RangingCoords[_sum_div + 1]*this.levels[this.level]- this.Tempcenter.My - parseInt(flagimg[2])) + 'px';
                putFlag.style.width = parseInt(flagimg[1]) + 'px';
                putFlag.style.height = parseInt(flagimg[2]) + 'px';
                putFlag.style.position = 'absolute';
                putFlag.setAttribute('src', flagimg[0]);
                this.FlagLayer.appendChild(putFlag);
            
                RClayer = document.createElement('div');
                RClayer.style.cssText = CSSScaleLabel;
                RClayer.style.position = 'absolute';
                RClayer.style.left = (RangingCoords[_sum_div]*this.levels[this.level]-this.Tempcenter.Mx) + 'px';
                RClayer.style.top = (RangingCoords[_sum_div + 1]*this.levels[this.level]-this.Tempcenter.My) + 'px';
                RClayer.innerHTML = RangingDistanceArray[i] + '<br />仅供参考';
                this.FlagLayer.appendChild(RClayer);
                _sum_div += 2;
            }
        }
    },  
    
   //-------------------------------------------------------------
   //加载地图数据，在载入图片的时候一起加载地图数据，根据地图的
   //坐标来载入，图片载入后根据数据画入热区
   //---------------------------------------- --------------------
  load_js_data : function(){	
	var html_head = document.getElementsByTagName('head')[0];
	var __script_data_string = '';
	var js_H1 = Math.floor(this.H1/2);
	var js_H2 = Math.floor(this.H2/2);
	var js_L1 = Math.floor(this.L1/2);
	var js_L2 = Math.floor(this.L2/2);
	//循环加载地图中的数据script_data_array 记录已加载的数据，避免重复地加载数据
	for(var j = js_H1; j <= js_H2; j++){
		for(var i = js_L1; i <= js_L2; i++){
			__script_data_string = '__script_'+ this.level + + i + '_' + j;
			//如果没有加载则加载数据，如果加载了就不用再加载数据
			if(this.script_data_array[__script_data_string]==undefined){ 
				var __script_obj = document.createElement('script');
				__script_obj.src = this.map.js_data_path + this.level + '/' + i + "," + j + ".js";
				__script_obj.className = 'ehootu_js';
				__script_obj.charset = 'utf-8';
				html_head.appendChild(__script_obj);
				//把已加载的数据加入到历史加载数据中
				this.script_data_array[__script_data_string] = __script_data_string;
			}
		}
	}
  },
  load_js_obj_data : function(){
  	this.map_area.innerHTML = "";
    var js_H1 = Math.floor(this.H1/2);
    var js_H2 = Math.floor(this.H2/2);
    var js_L1 = Math.floor(this.L1/2);
    var js_L2 = Math.floor(this.L2/2);
  	for(var j = js_H1; j <= js_H2; j++){
		for(var i = js_L1; i <= js_L2; i++){
			//加载热区数据
			__script_spot_data_string = 'ehootu_spot_'+ this.level +'_' + i + '_' + j;						
			if(this.append_spot_data[__script_spot_data_string]){
				for(var k = 0; k < this.append_spot_data[__script_spot_data_string].length; k++){
					//判断中心点是否在显示屏幕上
					if(this.checkCenterIn(this.append_spot_data[__script_spot_data_string][k].CenterX,this.append_spot_data[__script_spot_data_string][k].CenterY)){	
						 this.draw_spot(this.append_spot_data[__script_spot_data_string][k]);
					}
					
				}
			}
			//加载标签数据
			if (this.level < 4) {
					__script_sign_data_string = 'ehootu_sign_'+ this.level +'_' + i + '_' + j;
					if(this.append_sign_data[__script_sign_data_string]){
							for(var k = 0; k < this.append_sign_data[__script_sign_data_string].length; k++){
								this.draw_sign(this.append_sign_data[__script_sign_data_string][k]);
							}
					}
			}
		}
	}
  },
  checkCenterIn : function(x,y){
  	x = x * this.levels[this.level];
  	y = y * this.levels[this.level];
  	if((x>(this.Tempcenter.Mx-this.halfWidth)&&x<(this.Tempcenter.Mx+this.halfWidth))&&(y>(this.Tempcenter.My-this.halfHeight)&&y<(this.Tempcenter.My+this.halfHeight))){	
		return true;
	}else{
		return false;
	}
  },
   /// <summary>
   /// 显示地图
   /// </summary>
   /// <paramname=""></param>
   /// <returns></returns>
   display_map_data : function(){
        //地图标签图层
		if (!this.signLayer) {
			this.signLayer = document.createElement('div');
		}
        this.signLayer.style.position = 'absolute';
        this.signLayer.style.top = '0px';
        this.signLayer.style.left = '0px';
        this.containerLayer.appendChild(this.signLayer);
           //1:加载js，这时不会把数据显示出来，只是把数据加载进来，然后把数据加入到对像中
        this.load_js_data();
        //2:加载数据,把对象中的数据显示到屏幕中
        this.load_js_obj_data();
   },
  //--------------------------------------------------------------
  //增加热区信息到系统中
  //--------------------------------------------------------------
  append_spot : function(_spot,_zoom,_flgLabel,_flgShape){
      var append_spot_data_str = 'ehootu_spot_' + _zoom + '_' +  Math.floor((_spot.CenterX/(this.slicesize/this.levels[_zoom]))/2) + "_" + Math.floor((_spot.CenterY/(this.slicesize/this.levels[_zoom]))/2);
      //把热区数据放到热区数据中去
      if(!this.append_spot_data[append_spot_data_str]){
        this.append_spot_data[append_spot_data_str] = new Array();
    }
    //把热区数据放到加载中的热区中去
    this.append_spot_data[append_spot_data_str][this.append_spot_data[append_spot_data_str].length] = _spot;
    if(this.checkCenterIn(_spot.CenterX,_spot.CenterY)){
    	this.draw_spot(_spot);
    }
  },
   /// <summary>
   /// 增加地图中的标签
   /// </summary>
   /// <paramname="_sign_obj">地图标签对像</param>
   /// <paramname="level">地图等级</param>
   /// <paramname="flg">是否显示标志</param>
   /// <returns></returns>
  append_sign : function(_sign_obj,_zoom,flg){
      var append_sign_data_str = 'ehootu_sign_' + _zoom + '_' +  Math.floor((_sign_obj.X/(this.slicesize/this.levels[_zoom]))/2) + "_" + Math.floor((_sign_obj.Y/(this.slicesize/this.levels[_zoom]))/2);
      //把热区数据放到热区数据中去
      if(!this.append_sign_data[append_sign_data_str]){
        this.append_sign_data[append_sign_data_str] = new Array();
    } 
    //把热区数据放到加载中的热区中去
    this.append_sign_data[append_sign_data_str][this.append_sign_data[append_sign_data_str].length] = _sign_obj;
    if(this.checkCenterIn(_sign_obj.X,_sign_obj.Y)){
    	this.draw_sign(_sign_obj);
    }
  },
     /// <summary>
   /// 画热区到地图上
   /// </summary>
   /// <paramname="_spot">热区对像</param>
   /// <returns></returns>
  draw_spot : function(_spot){
      //----------------------------------------
      //创建area对像到map中去
      //----------------------------------------
      var map_area_obj = document.createElement('area');
      map_area_obj.shape = 'poly';      
	  
      map_area_obj.coords = this.coords_change_relative(_spot.Coords);
      //map_area_obj.href = 'javascript:;';
      map_area_obj.style.cursor = 'pointer';
      
      
      //firefox要注册移动事件
      if(!isIE) $(map_area_obj).bind('mousedown',{container : 'main', map:this},this.mouseDown);
      
      //-----------------------------------------
      //热区鼠标移过事件
      //-----------------------------------------
      addEventHandler(map_area_obj,'mouseover',this.spot_mouse_over.binding(this,_spot));
      //-----------------------------------------
      //鼠标移出事件
      //-----------------------------------------
      addEventHandler(map_area_obj,'mouseout',Bind(this,this.spot_mouse_out));
      //-----------------------------------------
      //鼠标移动事件
      //-----------------------------------------
      addEventHandler(map_area_obj,'mousemove',BindAsEventListener(this,this.spot_mouse_move));
      //-----------------------------------------
      //招标点击热区事件
      //-----------------------------------------
      addEventHandler(map_area_obj,'mouseup',this.spot_mouse_click.binding(this,_spot));
      map_area_obj.onclick = function(){return false;};

      this.map_area.appendChild(map_area_obj);
      //-----------------------------------------
      //失去焦点
      //-----------------------------------------
      map_area_obj.onfocus = function(){
        this.blur();
        return false;
      };
      return false;
  },
   /// <summary>
   /// 画地图中的标签
   /// </summary>
   /// <paramname=""></param>
   /// <returns></returns>
  draw_sign : function(_sign_obj){
      var __sign_obj_image = new Image();
      __sign_obj_image.style.width = '30px';
      __sign_obj_image.style.height = '59px';
      __sign_obj_image.style.cursor = 'pointer';  
      __sign_obj_image.style.position = 'absolute';
      __sign_obj_image.style.top = Math.round(_sign_obj.Y * this.levels[this.level]) - this.center.My - 59 + 'px';
      __sign_obj_image.style.left = Math.round(_sign_obj.X * this.levels[this.level]) -this.center.Mx - 30  + 'px';
      __sign_obj_image.setAttribute('alt',_sign_obj.Title);
      __sign_obj_image.setAttribute('title',_sign_obj.Title);
      switch(_sign_obj.SortKey){
          case 'bus':
          	__sign_obj_image.src = './images/BUS.png';
          	this.spot_tip_flag['bus']? __sign_obj_image.style.display = 'block':__sign_obj_image.style.display = 'none';
          	__sign_obj_image.setAttribute('class','signbus pngfix');
          	//给bus泡泡点击事件
          	// addEventHandler(map_area_obj,'mouseup',this.spot_mouse_click.binding(this,_spot));
          	__sign_obj_image.onclick = this.busSignClick.binding(this,_sign_obj);
          	break;
          case 'hospital':
          	__sign_obj_image.src = './images/hospital.png';
          	this.spot_tip_flag['hospital']? __sign_obj_image.style.display = 'block':__sign_obj_image.style.display = 'none';
          	__sign_obj_image.setAttribute('class','signhospital');
          	break;
          case 'police':
          	__sign_obj_image.src = './images/police.png';
          	this.spot_tip_flag['police']? __sign_obj_image.style.display = 'block':__sign_obj_image.style.display = 'none';
          	__sign_obj_image.setAttribute('class','signpolice');
          	break;
          case 'forbidden':
          	__sign_obj_image.src = './images/forbidden.png';
          	this.spot_tip_flag['forbidden']? __sign_obj_image.style.display = 'block':__sign_obj_image.style.display = 'none';
          	__sign_obj_image.setAttribute('class','signforbidden');
          	break;
          case 'gov':
          	__sign_obj_image.src = './images/gov.png';
          	this.spot_tip_flag['gov']? __sign_obj_image.style.display = 'block':__sign_obj_image.style.display = 'none';
          	__sign_obj_image.setAttribute('class','signgov');
          	break;
          case 'wc':
          	__sign_obj_image.src = './images/wc.png';
	        this.spot_tip_flag['wc']? __sign_obj_image.style.display = 'block':__sign_obj_image.style.display = 'none';
	        __sign_obj_image.setAttribute('class','signwc');
	        break;
          case 'school':
          	__sign_obj_image.src = './images/school.png';
          	this.spot_tip_flag['school']? __sign_obj_image.style.display = 'block':__sign_obj_image.style.display = 'none';
          	__sign_obj_image.setAttribute('class','signschool');
          	break;
          case 'stop':
          	__sign_obj_image.src = './images/stop.png';
          	this.spot_tip_flag['stop']? __sign_obj_image.style.display = 'block':__sign_obj_image.style.display = 'none';
          	__sign_obj_image.setAttribute('class','signstop');
          	break;
          case 'trip':
          	__sign_obj_image.src = './images/trip.png';
          	this.spot_tip_flag['trip']? __sign_obj_image.style.display = 'block':__sign_obj_image.style.display = 'none';
          	__sign_obj_image.setAttribute('class','signtrip');
          	break;
          case 'hotel':
          	__sign_obj_image.src = './images/hotel.png';
          	this.spot_tip_flag['hotel']? __sign_obj_image.style.display = 'block':__sign_obj_image.style.display = 'none';
          	__sign_obj_image.setAttribute('class','signhotel');
          	break;
          case 'jiazheng':
          	__sign_obj_image = null;
          	break;
          default: break;    
      }
      
      this.signLayer.appendChild(__sign_obj_image);
  },
   /// <summary>
   /// 鼠标移入热区事件
   /// </summary>
   /// <paramname="event_para">鼠标事件参数</param>
   /// <returns></returns>
  spot_mouse_over: function(_spot){
      //-----------------------------------
      //svg 画图
      //-----------------------------------
      this.drag_svg_vml(_spot.Coords);
      //-----------------------------------
      //显示标签
      //-----------------------------------
      if(!this.spot_tip){
          this.spot_tip = document.createElement('div');
          this.spot_tip.style.position = 'absolute';
          this.spot_tip.style.zIndex = 99999;
          this.spot_tip.style.width = '500px';
          this.mapviewlayer.appendChild(this.spot_tip);
      }
      this.spot_tip.style.display = 'block';
      this.spot_tip.innerHTML = '<div class="pngfix" style="width:26px; height:22px; background:url(./images/tip-left.png) no-repeat scroll; float:left;"></div><div style="float:left;  height:22px; background:url(./images/tip-center.png) repeat-x scroll; font-size:12px; padding-top:4px;">'+_spot.Title+'</div><div class="pngfix" style="width:3px; height:22px; background:url(./images/tip-right.png) no-repeat scroll; float:left;"></div>';
  },
   /// <summary>
   /// 热区上鼠标移动事件
   /// </summary>
   /// <paramname=""></param>
   /// <returns></returns>
  spot_mouse_move : function(e){
      if(!e)e = window.event;
    if(e.pageX== undefined){e.pageX = e.clientX+document.body.scrollLeft;}
    if(e.pageY== undefined){e.pageY = e.clientY+document.body.scrollTop;}
    if(this.spot_tip){
        this.spot_tip.style.left = (e.pageX - parseInt(this.mapviewlayer.style.left) - this.parentlayer.offsetLeft + 15) + 'px';
        this.spot_tip.style.top = (e.pageY - parseInt(this.mapviewlayer.style.top) - this.parentlayer.offsetTop) + 'px';
      }
      
  },
   /// <summary>
   /// 鼠标移出热区事件
   /// </summary>
   /// <paramname="event_para">鼠标事件参数</param>
   /// <returns></returns>
    spot_mouse_out : function(){
        //--------------------------------------
        //取消热区显示
        //--------------------------------------
        this.hidden_svg_vml();
        if(this.spot_tip){
            this.spot_tip.style.display = 'none';
      }
    },
    /// <summary>
    /// 鼠标点击热区事件，弹出泡泡
    /// </summary>
    /// <paramname=""></param>
    /// <returns></returns>
    spot_mouse_click : function(){
    	//先关闭bus的面板
    	if(this.BusSignDivIframe)this.BusSignDivIframe.style.display = 'none';
    	//方法重载，一个参数为显示实体，三个参数为显示公司。
    	var _spot,showType;
    	if(arguments.length==1){
    		showType = 0;
    		_spot = arguments[0];
    		_spot.showType = _spot.showType|showType;
    	}else{
    		showType = 1;
    		_spot = {ID:arguments[0],CenterX:arguments[1],CenterY:arguments[2],showType:showType};
    	}
        this.mapMoveTo(_spot.CenterX + 400, _spot.CenterY);
    	
    	//记录下当前点中的泡泡，以便在放大缩小时用
    	this.currentSpot = _spot;
    	
    	//创建一个层来存放泡泡的iframe
    	if(!this.spotDiv){
    		this.spotDiv = document.createElement('div');
    		this.spotDiv.style.position = 'absolute';
    		this.spotDiv.style.overflow = 'hidden';
    		this.spotDiv.style.zIndex = '100';
    	}
    	this.spotDiv.style.top = (_spot.CenterY * this.levels[this.level] - this.center.My - 140) + 'px';
    	this.spotDiv.style.left = (_spot.CenterX * this.levels[this.level] - this.center.Mx) + 'px';
    	if(!this.spotDivIframe){
    		this.spotDivIframe = document.createElement('iframe');
    		this.spotDivIframe.frameBorder = 0;    		
    		this.spotDivIframe.allowTransparency = 'true';
    		this.spotDivIframe.style.overflow = 'hidden';
    		this.spotDivIframe.style.width = '355px';
    		this.spotDivIframe.style.height = '310px';
    	}
    	this.spotDivIframe.style.display = 'block';
	
    	this.spotDivIframe.src = './panel/entity.aspx?id='+this.currentSpot.ID + "&type="+this.currentSpot.showType;
    	
    	this.spotDiv.appendChild(this.spotDivIframe);
    	this.containerLayer.appendChild(this.spotDiv);
    },
   /// <summary>
   /// 根据浏览器画图
   /// </summary>
   /// <paramname="_coords">原坐标点</param>
   /// <returns></returns>
   drag_svg_vml : function(_coords){
      _coords = this.coords_change(_coords,this.levels[this.level]);
      //----------------------------------------------------
      //获得热区xy的最大值和最小值，用于计算svg,vml图画的定位
      //----------------------------------------------------
      var svg_xy = this.get_coords_xy_maxmin(_coords);
      _coords = this.get_relative_coords(_coords,svg_xy.x.min,svg_xy.y.min);
      //------------------------------------
      //ie用vml画图其它用svg画图
      //------------------------------------
      if(isIE){
          //创建vml
          if(!this.svg_vml_obj){
			  this.svg_vml_obj = document.createElement('v:polyline');
              this.svg_vml_obj.setAttribute('points',_coords);
              this.svg_vml_obj.setAttribute('filled','T');
	          this.svg_vml_obj.setAttribute('fillcolor','#ffffff');
	          this.svg_vml_obj.setAttribute('strokecolor','#03C1FD');
	          this.svg_vml_obj.setAttribute('strokeweight','1.5');
	          var fill_tmp = document.createElement('v:fill');
	          fill_tmp.setAttribute('opacity','0.5');
	          fill_tmp.setAttribute('endcap','round');
	          this.svg_vml_obj.appendChild(fill_tmp);
          }
          
          //----------------------------------------------------
          //vml的css属性，绝对定位，top和left为xy轴最小值
          //----------------------------------------------------
          this.svg_vml_obj.style.position = 'absolute';
          this.svg_vml_obj.style.top = parseInt(svg_xy.y.min) + 'px';
          this.svg_vml_obj.style.left = parseInt(svg_xy.x.min) + 'px';
          this.svg_vml_obj.style.display = 'block';
          this.svg_vml_obj.style.zIndex = '9999';
          this.svg_vml_obj.points.value = _coords; 

          this.mapviewlayer.appendChild(this.svg_vml_obj);
      }else{
          //创建svg
          if(!this.svg_vml_obj){
            this.svg_vml_obj = document.createElementNS(__svg_namespace,'svg');
          }
          //----------------------------------------------------
          //svg的css属性，绝对定位，top和left为xy轴最小值 
          //----------------------------------------------------
          this.svg_vml_obj.style.position = 'absolute';
          this.svg_vml_obj.style.top = parseInt(svg_xy.y.min) + 'px';
          this.svg_vml_obj.style.left = parseInt(svg_xy.x.min) + 'px';
          this.svg_vml_obj.setAttribute('width',svg_xy.x.max - svg_xy.x.min);
          this.svg_vml_obj.setAttribute('height',svg_xy.y.max - svg_xy.y.min);
          this.svg_vml_obj.setAttribute('overflow','visible');
          this.svg_vml_obj.style.display = 'block';
          this.svg_vml_obj.style.zIndex = '100';
          if(!this.svg_polyline)this.svg_polyline = document.createElementNS(__svg_namespace,'polyline');
          this.svg_polyline.setAttribute('points',_coords);
          this.svg_polyline.style.cssText = 'fill:#ffffff; stroke:#03C1FD; stroke-width:1.5px; display:block;';
          this.svg_polyline.setAttribute('fill-opacity',0.5);
          this.svg_vml_obj.appendChild(this.svg_polyline);
          this.map3dlayer.appendChild(this.svg_vml_obj);    
      }
   },
   /// <summary>
   /// 隐藏热区
   /// </summary>
   /// <paramname="_coords"></param>
   /// <returns></returns>
   hidden_svg_vml : function(){
   		if(this.svg_vml_obj) this.svg_vml_obj.style.display	= 'none';
   		//如果是ie则把 points 属性设为空，避免重影
   		if(isIE&&this.svg_vml_obj)this.svg_vml_obj.points.value = '';
   },
   /// <summary>
   /// 获得相对的地图坐标，用于area
   /// </summary>
   /// <paramname="_coords">热区坐标串</param>
   /// <paramname="_zoom_level">转化地图的等级</param>
   /// <returns>相对热区坐标串</returns>
   coords_change_relative:function(_coords,_zoom_level){
    var _coords_array = _coords.split(',');
    //设置等级和移动距离的默认值
    _zoom_level = _zoom_level||this.levels[this.level];
    for(var i = 0;i<_coords_array.length;i+=2){
      _coords_array[i] = Math.round((_coords_array[i]*_zoom_level) + this.halfWidth - this.Tempcenter.Mx);
    }
    
    for(var i = 1;i<_coords_array.length;i+=2){
      _coords_array[i] = Math.round((_coords_array[i]*_zoom_level) + this.halfHeight  - this.Tempcenter.My);
    }
    var _coords_string = _coords_array.toString();
    //释放一些变量
    _coords = null; delete _coords;
    _coords_array = null;delete _coords_array;
    _zoom_level = null; delete _zoom_level;
    return _coords_string;
  },
  //---------------------------------------------------------------
  //根据坐标比例转化坐标点。
  //---------------------------------------------------------------
  coords_change:function(_coords,_zoom_level){
    var _coords_array = _coords.split(',');
    var _coords_array_length = _coords_array.length;
    _zoom_level = _zoom_level||this.levels[this.level];
    for(var i = 0; i<_coords_array_length; i++){
        if(i%2==0)    _coords_array[i] = parseInt(_coords_array[i]*_zoom_level) - this.center.Mx;
      else _coords_array[i] = parseInt(_coords_array[i]*_zoom_level) - this.center.My;
    }
    var _coords_string = _coords_array.toString()+','+_coords_array[0]+','+_coords_array[1];
    _coords = null; delete _coords;
    _coords_array = null;delete _coords_array;
    _zoom_level = null; delete _zoom_level;
    return _coords_string;
  },
  /// <summary>
   /// 根据坐标获得X,Y轴的最大值和最小值
   /// 注意：area的coords的排列方法 -155,728,-155,723,-145,716 偶数是x轴，奇数是y轴
   /// </summary>
   /// <paramname="_coords">原坐标点</param>
   /// <returns>object 调用方法 x.max x.min y.max y.min</returns>
   get_coords_xy_maxmin : function(_coords){
      var _coords_array = _coords.split(',');
      var _x_coords_array = [];
      var _y_coords_array = [];
      var _coords_array_length = _coords_array.length;
      for(var i=0;i<_coords_array_length;i++){
        if(i%2 == 0){
            _x_coords_array[i/2] = _coords_array[i];
        }
        else{
            _y_coords_array[Math.round(i/2)-1] = _coords_array[i];
        }
      }
      _coords_array = null; delete _coords_array;
      return {'x':{'max':_x_coords_array.max(),'min':_x_coords_array.min()},'y':{'max':_y_coords_array.max(),'min':_y_coords_array.min()}};
   },
   /// <summary>
   /// 获得相对的点
   /// </summary>
   /// <paramname="_coords">热区坐标串</param>
   /// <paramname="_relative_x">原点x</param>
    /// <paramname="_relative_y">原点y</param>
   /// <returns>相对热区坐标串</returns>
   get_relative_coords : function(_coords,_relative_x,_relative_y){
      var _coords_array  = _coords.split(',');
      var _coords_array_length = _coords_array.length;
      var _coords_array_temp = [];
      for(var i = 0; i < _coords_array_length ; i++){
        if(i % 2 == 0) _coords_array_temp[i] = _coords_array[i] - _relative_x;
        else _coords_array_temp[i] = _coords_array[i] - _relative_y;
      }
      _coords = null;delete _coords;
      _relative_x = null; delete _relative_x;
      _relative_y = null; delete _relative_y;
      _coords_array = null; delete _coords_array;
      _coords_array_length = null; delete _coords_array_length;
      
      return _coords_array_temp.toString();
   },
    /// <summary>
   /// 设置滑杆高度
   /// </summary>
   /// <paramname=""></param>
   /// <returns></returns>
   setSliderPosition : function(level){
		document.getElementById('MapSilder').style.top = 20*level+29 + 'px';			
   },
   busSignClick : function(_sign_obj){
   		this.mapMoveTo(_sign_obj.X + 200,_sign_obj.Y - 140);
   		//如果有实体面板则先取消
   		if(this.spotDivIframe)this.spotDivIframe.style.display = 'none';
   		
   		//记录下当前点中的泡泡，以便在放大缩小时用
    	this.currentBusSign = _sign_obj;
    	//创建一个层来存放泡泡的iframe
    	if(!this.BusSignDiv){
    		this.BusSignDiv = document.createElement('div');
    		this.BusSignDiv.style.position = 'absolute';
    		this.BusSignDiv.style.overflow = 'hidden';
    	}
    	this.BusSignDiv.style.top = (_sign_obj.Y * this.levels[this.level] - this.center.My - 200) + 'px';
    	this.BusSignDiv.style.left = (_sign_obj.X * this.levels[this.level] - this.center.Mx - 5) + 'px';
    	if(!this.BusSignDivIframe){
    		this.BusSignDivIframe = document.createElement('iframe');
    		this.BusSignDivIframe.frameBorder = 0;    		
    		this.BusSignDivIframe.allowTransparency = 'true';
    		this.BusSignDivIframe.style.overflow = 'hidden';
    		this.BusSignDivIframe.style.width = '355px';
    		this.BusSignDivIframe.style.height = '310px';
    	}
    	this.BusSignDivIframe.style.display = 'block';
	
    	this.BusSignDivIframe.src = './panel/buspanel.aspx?id='+_sign_obj.ID;
    	
    	this.BusSignDiv.appendChild(this.BusSignDivIframe);
    	this.containerLayer.appendChild(this.BusSignDiv);		
   }
};

var deyang = null;
//获得屏幕的高和宽
var  windowH, windowW;

window.onload = function(){
	getWindowSize();
	pageInit();
	mapInit(windowW - 295,windowH - 85);
	MapAdFlash();
	showNav();
};

//function sliderClose(sliderHeight){
//	var sliderDiv = document.getElementById('Eye');
//	if(sliderHeight > 192){
//		sliderDiv.className = 'close';
//		window.clearTimeout(sliderTime);
//		return;	
//	}
//	var sliderPerHeight = isIE?10:5;
//	
//	sliderHeight +=sliderPerHeight;
//	
//	sliderDiv.style.clip = 'rect(auto, auto, auto, '+sliderHeight+'px)';
//	
//	sliderTime = window.setTimeout('sliderClose('+sliderHeight+');',10);
//}
//
//function sliderOpen(sliderHeight){
//	var sliderDiv = document.getElementById('Eye');
//	if(sliderHeight < 0){
//		sliderDiv.className = 'open';
//		window.clearTimeout(sliderTime);
//		return;	
//	}
//	var sliderPerHeight = isIE?10:5;
//	
//	sliderHeight -=sliderPerHeight;
//	
//	sliderDiv.style.clip = 'rect(auto, auto, auto, '+sliderHeight+'px)';
//	
//	
//		
//	sliderTime = window.setTimeout('sliderOpen('+sliderHeight+');',10);
//}

//兼容以前代码的变量
var flgShowLabel = true;
var flgShowSpotShape = true;
var flgShowSign = true;
var SignsVisible = new Array();
var AppendSpot = function(_spot,_zoom,_flgLabel,_flgShape){
  deyang.append_spot(_spot,_zoom,_flgLabel,_flgShape);
};
var AppendSign = function(_sign_obj,level,flg){
    deyang.append_sign(_sign_obj,level,flg);
};

function mapInit(w,h){
	document.getElementById('map').innerHTML = "";
	document.getElementById('eyeesMap').innerHTML = "";
	var x = 0;var y = 0;
	if(deyang){x = deyang.Tempcenter.Mx/deyang.levels[deyang.level]; y = deyang.Tempcenter.My/deyang.levels[deyang.level];}
	var MAP3D_DeYang_3D_MAP={
	    id: "map3d",
	    ns:'mapview',
	    imagePath: host + "mappic/Zoom",
	    imagePath2D : host + "mappic/2Zoom",
	    styleType: 3,
	    scale: [50,100,500,1200],
	    levels: [1,1/2,1/4,1/8,1/16,1/32],
	    sliceSize: 256,
	    sizeUnit: "px", 
	    imageType: ".jpg",
	    defaultCoordinate: [x,y],
	    defaultlevel:1,
	    mapWidth:w,
	    mapHeight:h,
	    proportional : 16,
	    js_data_path : 'http://125.64.92.79/cityresource2/cn/deyang/zh-chs/mapJs/'
	};
	if(deyang){deyang = null; delete deyang;}
	deyang = new  EHOOTU_iframe(MAP3D_DeYang_3D_MAP);
	x = null; delete x;
	y = null; delete y;
	MAP3D_DeYang_3D_MAP = null; delete MAP3D_DeYang_3D_MAP;
}




//页面的js源码
function pageInit(){
	//设置中间栏的高度
	document.getElementById('main-frame-center-c').style.height = (windowH-131)+'px';
	window.onresize=function(){
		getWindowSize();
		if(deyang){			
		    //全屏状态
		    if(document.getElementById('tool-button-7').attributes['status'].nodeValue == 'full-screen'){
		    	//-------------------------------
				//设置左边中间栏的高度
				//-------------------------------
				document.getElementById('body-content-right-iframe').style.height = windowH-20 + 'px';
				document.getElementById('main-frame-center-c').style.height = windowH-60 + 'px';
		    	document.getElementById('map').style.height = windowH-14 + 'px';
		    	document.getElementById('map').style.width = windowW + 'px';
		   	//右边栏收进去的状态
		    }else if(document.getElementById('main-frame-center-r-button-on').style.display == 'none'){
		    	//-------------------------------
				//设置左边中间栏的高度
				//-------------------------------
				document.getElementById('body-content-right-iframe').style.height=(windowH-101)+'px';
				document.getElementById('main-frame-center-c').style.height = (windowH-131)+'px';
				document.getElementById('map').style.width = windowW + 'px';
				document.getElementById('map').style.height = windowH-84 + 'px';
			//普通状态
			}else{
				if(isIE){
					document.getElementById('main-frame-footer-r').style.right='-1px';
				}
				//-------------------------------
				//设置左边中间栏的高度
				//-------------------------------
				//document.getElementById('body-content-right-iframe').style.height=(windowH-101)+'px';
				document.getElementById('main-frame-center-c').style.height = (windowH-131)+'px';
				document.getElementById('map').style.width = windowW - 295 + 'px';
				document.getElementById('map').style.height = windowH - 85 + 'px';
			}
			deyang.displayMap();
		}
	};
	//setTimeout('window.onresize()', 100);
	var IsActive = "nav-header";
	var NavHeader = /nav-header-select/g;  
	var NavCenter = /nav-center-select/g;  
	var NavBottom = /nav-bottom-select/g;
	//你好德阳
	document.getElementById('nav-header').onclick=function(){
		document.getElementById(IsActive).className = document.getElementById(IsActive).className.replace(NavHeader, "");
		document.getElementById(IsActive).className = document.getElementById(IsActive).className.replace(NavCenter, "");
		document.getElementById(IsActive).className = document.getElementById(IsActive).className.replace(NavBottom, "");
		document.getElementById("nav-header").className = document.getElementById('nav-header').className+" nav-header-select";
		IsActive="nav-header";
	};
	//安居德阳
	document.getElementById('nav-center-1').onclick=function(){
		document.getElementById(IsActive).className = document.getElementById(IsActive).className.replace(NavHeader, "");
		document.getElementById(IsActive).className = document.getElementById(IsActive).className.replace(NavCenter, "");
		document.getElementById(IsActive).className = document.getElementById(IsActive).className.replace(NavBottom, "");
		document.getElementById("nav-center-1").className = document.getElementById("nav-center-1").className+" nav-center-select";
		IsActive="nav-center-1";
	};
	//乐业德阳
	document.getElementById('nav-center-2').onclick=function(){
		document.getElementById(IsActive).className = document.getElementById(IsActive).className.replace(NavHeader, "");
		document.getElementById(IsActive).className = document.getElementById(IsActive).className.replace(NavCenter, "");
		document.getElementById(IsActive).className = document.getElementById(IsActive).className.replace(NavBottom, "");
		document.getElementById("nav-center-2").className = document.getElementById("nav-center-2").className+" nav-center-select";
		IsActive="nav-center-2";
	};
	//健康德阳
	document.getElementById('nav-bottom').onclick=function(){
		document.getElementById(IsActive).className = document.getElementById(IsActive).className.replace(NavHeader, "");
		document.getElementById(IsActive).className = document.getElementById(IsActive).className.replace(NavCenter, "");
		document.getElementById(IsActive).className = document.getElementById(IsActive).className.replace(NavBottom, "");
		document.getElementById("nav-bottom").className = document.getElementById("nav-bottom").className+" nav-bottom-select";
		IsActive="nav-bottom";
	};
	
	//------------------------------
	//地图搜索和公交搜索交换
	//------------------------------
	document.getElementById('search-bar-map').onclick=function(){
		this.className = "search-bar-select search-bar-selected";
		document.getElementById('search-bar-bus').className="search-bar-select";
		document.getElementById('search-map-field').style.display="block";
		document.getElementById('search-bus-field').style.display="none";
	};
	document.getElementById('search-bar-bus').onclick=function(){
		this.className = "search-bar-select search-bar-selected";
		document.getElementById('search-bar-map').className="search-bar-select";
		document.getElementById('search-map-field').style.display="none";
		document.getElementById('search-bus-field').style.display="block";
	};
	//------------------------------
	//搜索按钮
	//------------------------------
	document.getElementById('search-bus-type').onchange=function(){
		var ThisField = this.value;
		for(var FieldCount=0; FieldCount<3; FieldCount++){
			if(FieldCount==ThisField){
				document.getElementById("search-bus-field-"+FieldCount).style.display="block";	
			}else{
				document.getElementById("search-bus-field-"+FieldCount).style.display="none";
			}
		}
	};
	//------------------------------
	//搜索输入框事件
	//------------------------------
	document.getElementById('search-map-field-input').onfocus=function(){
		this.value="";	
	};
	document.getElementById('search-map-field-input').onblur=function(){
		if(this.ve==""){
			this.value="旌阳区";
		}
	};
	document.getElementById('search-bus-field-bus').onfocus=function(){
		this.value="";
	};
	
	document.getElementById('search-bus-field-bus').onblur=function(){
		if(this.value==""){
			this.value="8路";	
		}
	};
	
	document.getElementById('search-bus-field-station').onfocus=function(){
		this.value="";
	};
	document.getElementById('search-bus-field-station').onblur=function(){
		if(this.value==""){
			this.value="旌湖宾馆";
		}
	};
	
	document.getElementById('search-bus-field-input-from').onfocus=function(){
		this.value="";
	};
	document.getElementById('search-bus-field-input-from').onblur=function(){
		if(this.value==""){
			this.value="起点站";
		}
	};
	
	document.getElementById('search-bus-field-input-to').onfocus=function(){
		this.value="";
	};
	document.getElementById('search-bus-field-input-to').onblur=function(){
		if(this.value==""){
			this.value="终点站";
		}
	};
	//------------------------------
	//搜索按钮
	//------------------------------
	var searchButtonFunction = function(){
		//------------------------------------
		//获得搜索类型
		//------------------------------------
		var SearchType;
		var RadioArray = document.getElementsByName("bar-select");
		for(var i = 0; i < RadioArray.length; i++){
			if(RadioArray[i].checked)
				SearchType = RadioArray[i].value;
		}
		//-------------------------------------
		//获得地图搜索关键字和公交搜索类型
		//-------------------------------------
		var KeyWords,BusType;
		if(SearchType==0){
			KeyWords = document.getElementById('search-map-field-input').value;
			if(KeyWords==null||KeyWords==""){
				alert("ERROR:对不起，关键字不能为空！请您输入您想查找的关键字...");return;
			}
			document.getElementById('body-content-right-iframe').src="./ContentSearch.aspx?KeyWords="+KeyWords;
		}else if(SearchType=1){
			//---------------------------------
			//获得公交搜索
			//---------------------------------
			BusType	=	document.getElementById('search-bus-type').value;
			if(BusType==0){
				var BusFrom,BusTo;
				BusFrom = document.getElementById('search-bus-field-input-from').value;
				BusTo	= document.getElementById('search-bus-field-input-to').value;
				if(BusFrom==null||BusFrom==""||BusFrom=="起点站"){
					alert("ERROR:起点站不能为空...");return;
				}else if(BusTo==null||BusTo==""||BusTo=="终点站"){
					alert("ERROR:终点站不能为空...");return;	
				}else{
					document.getElementById('body-content-right-iframe').src="./Fundation/BusNoSearch.aspx?BusType="+BusType+"&BusFrom="+BusFrom+"&BusTo="+BusTo;
				}
			}else if(BusType==1){
				KeyWords = document.getElementById('search-bus-field-station').value;
				document.getElementById('body-content-right-iframe').src="./Fundation/BusNoSearch.aspx?BusType="+BusType+"&keywords="+KeyWords;
			}else if(BusType==2){
				KeyWords = document.getElementById('search-bus-field-bus').value;
				document.getElementById('body-content-right-iframe').src="./Fundation/BusNoSearch.aspx?BusType="+BusType+"&keywords="+KeyWords;
			}
		}
	};
	document.onkeydown = function(e){
		//----------------------------------------
		//获得事件的源 注：srcElement事件发起的标签
		//----------------------------------------
		var event=window.event||e;
		var target=event.srcElement||event.target;
		if(event.keyCode=="13"){
			searchButtonFunction();
		}
	};
	document.getElementById('search-botton').onclick = searchButtonFunction;
	
	//右边iframe的高度
	document.getElementById('body-content-right-iframe').style.height=(windowH-71)+'px';
	document.getElementById('tool-button-1').style.top = 71 + 'px';
	
	//----------------------------
	//梆定平面按钮事件
	//----------------------------
	document.getElementById('tool-button-6').onclick=PingMian;
	document.getElementById('tool-button-5').onclick=Sanwei;
	
	//全屏按钮事件
	document.getElementById('tool-button-7').onclick=function(e){fnFullSrc(e);};
	//--------------------------------------
	//地图导航 下拉列表
	//--------------------------------------
	document.getElementById('tool-button-1').onclick=function(){
		if(document.getElementById('tool-dropdown').style.display=="block"){
			document.getElementById('tool-dropdown').style.display="none";
		}else{
			document.getElementById('tool-dropdown').style.display="block";
			if($.browser.msie&&$.browser.version=='6.0'){
				document.getElementById('tool-dropdown').style.background="url(../image/tool-dropdown.png) no-repeat scroll";
			}
		}
	};
	/*这个事件很重要*/
	document.getElementById('tool-dropdown').onmouseout = function(e){
		var event=window.event||e;
		if(typeof(HTMLElement)!="undefined"){    //给firefox定义contains()方法，ie下不起作用
			  HTMLElement.prototype.contains=function(obj){  
				  while(obj!=null&&typeof(obj.tagName)!="undefind"){ //通过循环对比来判断是不是obj的父元素
		   　　　　	if(obj==this) return true;  
		   　　　	　obj=obj.parentNode;
		   　	　}  
				  return false;  
			  };  
		}
　      var browser=navigator.userAgent;   //取得浏览器属性
　      if (browser.indexOf("Firefox")>0){ //如果是Firefox
　　        if (this.contains(event.relatedTarget)) { //如果是子元素
　　            return;   //结束函式
			}
		}
		  if (browser.indexOf("MSIE")>0){ //如果是IE
			  if (this.contains(event.toElement)) { //如果是子元素
					return; //结束函式
			   }
		 }
	    this.style.display="none";	
	};
	document.getElementById('map-setting').onmouseout = function(e){
		var event=window.event||e;
		if(typeof(HTMLElement)!="undefined"){    //给firefox定义contains()方法，ie下不起作用
			  HTMLElement.prototype.contains=function(obj){  
				  while(obj!=null&&typeof(obj.tagName)!="undefind"){ //通过循环对比来判断是不是obj的父元素
		   　　　　	if(obj==this) return true;  
		   　　　	　obj=obj.parentNode;
		   　	　}  
				  return false;  
			  };  
		}
　      var browser=navigator.userAgent;   //取得浏览器属性
　      if (browser.indexOf("Firefox")>0){ //如果是Firefox
　　        if (this.contains(event.relatedTarget)) { //如果是子元素
　　            return;   //结束函式
			}
		}
		  if (browser.indexOf("MSIE")>0){ //如果是IE
			  if (this.contains(event.toElement)) { //如果是子元素
					return; //结束函式
			   }
		 }
	    this.style.display="none";	
	};
	//----------------------------
	//地图设置
	//----------------------------
	document.getElementById('tool-button-2').onclick=function(e){
		//----------------------------------------
		//获得事件的源 注：srcElement事件发起的标签
		//----------------------------------------
		var event=window.event||e;
		var offsetParent=event.srcElement||event.target;
		var x=0,y=0;
		while(offsetParent!=null && offsetParent.tagName.toUpperCase()!="BODY") {
			x 	+= offsetParent.offsetLeft;
			offsetParent=offsetParent.offsetParent;
		}
		//end 左边的绝对位置
		
		if(document.getElementById('map-setting').style.display=="block"){
			document.getElementById('map-setting').style.display="none";
		}else{
			document.getElementById('map-setting').style.display="block";
			document.getElementById('map-setting').style.left=x+"px";
			
			if($.browser.msie&&$.browser.version=='6.0'){
				document.getElementById('map-setting').style.background="url(../image/map-setting.png) no-repeat scroll";
			}
		}
	};
	//end 地图设置
	 //--------------------------------
	//给收缩按钮添加事件
	//--------------------------------
	var button_div_on = document.getElementById('main-frame-center-r-button-on');
	var button_div_off =	document.getElementById('main-frame-center-r-button-off');
	button_div_on.onclick=function(){
		document.getElementById('body-content-right').style.width='0px'; //地图右边部分的宽度设为0
		document.getElementById('body-content-left').style.cssText='margin-right:0px;';//地图左边的右边距设为0
		button_div_on.style.display='none';       //设置按钮的状态
		button_div_off.style.display='block';
		
		document.getElementById('map').style.width = windowW + 'px';
		deyang.displayMap();
		//--------------------------------------
		//滚动条 鹰眼和鹰眼大小的宽度
		//--------------------------------------
		document.getElementById('EzoomBar').style.right="18px";
		document.getElementById('Eye').style.right="13px";
		document.getElementById('Ein').style.right="13px";
		
		if($.browser.msie&&$.browser.version=='6.0'){
			document.getElementById('main-frame-center-r').style.right='-1px';
			document.getElementById('main-frame-footer-r').style.right='-1px';
		}
		
	};
	button_div_off.onclick=function(){
		document.getElementById('body-content-right').style.width='295px'; //地图右边部分的宽度设为295
		document.getElementById('body-content-left').style.cssText='margin-right:295px;';//地图左边的右边距设为295
		button_div_on.style.display='block';
		button_div_off.style.display='none';
		
		document.getElementById('map').style.width = (windowW - 295) + 'px';
		deyang.displayMap();
		
		//--------------------------------------
		//滚动条 鹰眼和鹰眼大小的宽度
		//--------------------------------------
		document.getElementById('EzoomBar').style.right="315px";
		document.getElementById('Eye').style.right="308px";
		document.getElementById('Ein').style.right="308px";
		
		
		if($.browser.msie&&$.browser.version=='6.0'){
			document.getElementById('main-frame-center-r').style.right='295px';
			document.getElementById('main-frame-footer-r').style.right='295px';
		}
	};
	//----------------------------
	//end 给收缩按钮添加事件
	//----------------------------
	
	
	//----------------------------
	//鹰眼地图的缩小
	//----------------------------
	$('#Ein').click(function(){
		if($('#Eye')[0].className=='close'){
			$('#Eye').show();
			$('#Eye')[0].className = 'open';
		}
		else{ 
			$('#Eye').hide();
			$('#Eye')[0].className = 'close';
		}
	});
	
	$('#eyes-button').click(function(){
		var eyesMapWidth,eyesMapHeight;
		if($('#eyes-button').attr('status')=='smalleyes'){
			eyesMapWidth = 182;
			eyesMapHeight = 168;
			$('#eyeesMap').css('width',eyesMapWidth);
			$('#eyeesMap').css('height',eyesMapHeight);
			$('#eyes-button').css('background','url(Skins/zh-chs/4.2.0925/default/image/eyes-small.png) no-repeat scroll');
			$('#eyes-button').attr('status','bigeyes');
			
		}else{
			eyesMapWidth = 350;
			eyesMapHeight = 300;
			$('#eyeesMap').css('width',eyesMapWidth);
			$('#eyeesMap').css('height',eyesMapHeight);
			$('#eyes-button').css('background','url(../image/eyes-big.png) no-repeat scroll');
			$('#eyes-button').attr('status','smalleyes');
		}
		deyang.displayEysMap(eyesMapWidth,eyesMapHeight);			
	});
}

//导航层
function showNav(typeid){
	typeid = typeid?typeid:1;
	var navBg = document.getElementById('nav-bg');
	navBg.style.display = 'block';
	navBg.style.width = (windowW - 295) + 'px';
	navBg.style.height = (windowH - 72)  + 'px';
	navBg.style.position = 'absolute';
	navBg.style.top = '71px';
	
	if(!EHOOTU_iframe.prototype.navBg)EHOOTU_iframe.prototype.navBg = document.createElement('iframe');
	
	deyang.navBg.src = './panel/Navigation.html?type='+typeid;
	deyang.navBg.allowTransparency = true;
	deyang.navBg.width = (windowW - 295) + 'px';
	deyang.navBg.style.height = (windowH - 72)  + 'px';
	deyang.navBg.style.position = 'absolute';
	deyang.navBg.style.top = '71px';
	deyang.navBg.style.display = 'block';
	deyang.navBg.scrollbars = 'none';
	deyang.navBg.style.zIndex = '1000';
	deyang.navBg.scrolling = 'no';
	deyang.navBg.frameBorder = '0';
	document.body.appendChild(deyang.navBg);
}

//关闭导航层
function closeNav(){
	if(EHOOTU_iframe.prototype.navBg)deyang.navBg.style.display = 'none';
	document.getElementById('nav-bg').style.display = 'none';	
}


//关闭实体，公司面板
function panelClose(){
	if(deyang.spotDivIframe)deyang.spotDivIframe.style.display = 'none';
}

//关闭公交面板
function busPanelClose(){
	if(deyang.BusSignDivIframe)deyang.BusSignDivIframe.style.display = 'none';
}

function fnShowEntityPop(id,CenterX,CenterY){
	closeNav();
	busPanelClose();
	deyang.spot_mouse_click({'ID':id,'CenterX':CenterX,'CenterY':CenterY});
}

function fnShowCompanyPop(id,CenterX,CenterY){
	closeNav();
	busPanelClose();
	deyang.spot_mouse_click(id,CenterX,CenterY);
}

//实体泡泡和公司泡泡
function showCompany(id,CenterX,CenterY){
	closeNav();
	busPanelClose();
	deyang.spot_mouse_click(id,CenterX,CenterY);
}

//测距
function Ranging(){
		if(deyang.ranging){return;}
		deyang.Ranging();
}
//切换成平面
function PingMian(){
		if(deyang.pingmian){return;}
		deyang.pingmian = true;
		deyang.Conversion(2);
}
//切换成三维
function Sanwei(){
		if(!deyang.pingmian){return;}
		deyang.pingmian = false;
		deyang.Conversion();
}

//--------------------------------------
//地图设置事件
//--------------------------------------
function MapSetting(obj){
  if(deyang.spot_tip_flag[obj.id]){
		$('.sign'+obj.id).css({'display': 'none'});
		obj.className="unaction";
		deyang.spot_tip_flag[obj.id] = false;
    }else{
        $('.sign'+obj.id).css({'display': 'block'});
		obj.className="action";
		deyang.spot_tip_flag[obj.id] = true;
    }
}

//获得窗口的大小
function getWindowSize(){
	if(typeof window.innerHeight=='number')windowH = window.innerHeight;
	else{
		if(document.documentElement&&document.documentElement.clientHeight)windowH = document.documentElement.clientHeight;
		else{
			if(document.body&&document.body.clientHeight)windowH = document.body.clientHeight;
		}
	}
	
	if(typeof window.innerWidth=='number')windowW = window.innerWidth;
	else{
		if(document.documentElement&&document.documentElement.clientWidth)windowW = document.documentElement.clientWidth;
		else{
			if(document.body&&document.body.clientWidth)windowW = document.body.clientWidth;
		}
	}	
}

//全屏
function fnFullSrc(e){
	//----------------------------------------
	//获得事件的源 注：srcElement事件发起的标签
	//----------------------------------------
	var event=window.event||e;
	var target=event.srcElement||event.target;
	//----------------------------------------
	//获得自定义属性的值
	//----------------------------------------
	var frame_status = target.attributes['status'].nodeValue;
	var h = windowH,w = windowW;
	//----------------------------------------
	//设置全屏
	//----------------------------------------
	
	if(frame_status=="small-screen"){
		document.getElementById('body-top').style.display='none';
		document.getElementById('body-content').style.top='0px';
		document.getElementById('map').style.top='0px'; 
		document.getElementById('body-content-right').style.width='0px'; //地图右边部分的宽度设为0
		document.getElementById('body-content-left').style.cssText='margin-right:0px;';//地图左边的右边距设为0
		document.getElementById('main-frame-center-r-button-on').style.display='none';
		document.getElementById('main-frame-center-r-button-off').style.display='block';
		//--------------------------------------
		//滚动条 鹰眼和鹰眼大小的宽度
		//--------------------------------------
		document.getElementById('EzoomBar').style.right="18px";
		document.getElementById('EzoomBar').style.top="30px";
		document.getElementById('Eye').style.right="13px";
		document.getElementById('Ein').style.right="13px";
		//-------------------------------
		//设置左边中间栏的高度
		//-------------------------------
		document.getElementById('main-frame-center-c').style.height = (h-60)+'px';
		document.getElementById('body-content-right-iframe').style.height=(h-101)+'px';
		if($.browser.msie&&$.browser.version=='6.0'){
			document.getElementById('main-frame-center-r').style.right='-1px';
		}
		
		document.getElementById('map').style.Width = w;
		document.getElementById('map').style.Height= h;
		//--------------------------------
		//左边导航定位bug
		//--------------------------------
		document.getElementById('tool-dropdown').style.top="18px";
		document.getElementById('map-setting').style.top="18px";
		//--------------------------------
		//改变里面的字
		//--------------------------------
		target.innerHTML = "退出全屏";
		target.attributes['status'].nodeValue="full-screen";
		//--------------------------------
		//地图导航
		//--------------------------------
		document.getElementById('tool-button-1').style.top = 0 + 'px';
		//重新初始化地图
		//mapInit(windowW,windowH-14);
	    document.getElementById('map').style.width = windowW + 'px';
	    document.getElementById('map').style.height = windowH - 14 + 'px';
		deyang.displayMap();
		} else {
	//-------------------------------------------
	//退出全屏
	//-------------------------------------------
		document.getElementById('body-top').style.display='block';
		document.getElementById('body-content').style.top='71px';
		document.getElementById('map').style.top='90px'; 
		
		document.getElementById('body-content-right').style.width='295px'; //地图右边部分的宽度设为295
		document.getElementById('body-content-left').style.cssText='margin-right:295px;';//地图左边的右边距设为327
		
		//vM.MapWidth(w-327);			//地图的宽度，减去右边的宽度(327)
		//-------------------------------
		//设置左边中间栏的高度
		//-------------------------------
		document.getElementById('main-frame-center-c').style.height = (windowH-130)+'px';
		
		document.getElementById('main-frame-center-r-button-on').style.display='block';
		document.getElementById('main-frame-center-r-button-off').style.display='none';
		//--------------------------------------
		//滚动条 鹰眼和鹰眼大小的宽度
		//--------------------------------------
		
		document.getElementById('EzoomBar').style.right="315px";
		document.getElementById('EzoomBar').style.top="110px";
		document.getElementById('Eye').style.right="308px";
		document.getElementById('Ein').style.right="308px";
		//--------------------------------
		//左边导航定位bug
		//--------------------------------
		document.getElementById('tool-dropdown').style.top="119px";
		document.getElementById('map-setting').style.top="119px";
		
		if($.browser.msie&&$.browser.version=='6.0'){
			document.getElementById('main-frame-center-r').style.right='327px';
			document.getElementById('main-frame-footer-r').style.right='327px';
		}
		
		//--------------------------------
		//改变里面的字
		//--------------------------------
		target.innerHTML = "全&nbsp;&nbsp;屏";
		target.attributes['status'].nodeValue="small-screen";
		//--------------------------------
		//地图导航
		//--------------------------------
		document.getElementById('tool-button-1').style.top = 71 + 'px';
		//mapInit(windowW - 295,windowH - 85);
	    document.getElementById('map').style.width = windowW - 295 + 'px';
	    document.getElementById('map').style.height = windowH - 102 + 'px';
		deyang.displayMap();
	}
}

//公交站牌移动到中心点
function showBusPanel(x,y){
	deyang.mapMoveTo(x,y);
}


function MapAdFlash(){
    //加载广告图层
    var AdDiv = document.getElementById('addiv-001');
    if(!AdDiv) {
        AdDiv = document.createElement('div'); 
        AdDiv.id = "addiv-001";
        AdDiv.style.position = 'absolute';
        deyang.mapFlashlayer.appendChild(AdDiv);
    }
    AdDiv.style.left = Math.round(-1460 * deyang.levels[deyang.level]) - deyang.center.Mx + 'px';
    AdDiv.style.top = Math.round(-395 * deyang.levels[deyang.level]) - deyang.center.My + 'px';
    AdDiv.innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + (1946 * deyang.levels[deyang.level]) + '" height="' + (1100 * deyang.levels[deyang.level]) + '"><param name="movie" value="'+host+'mapdiv/1/20091013103315390464.swf" /><embed src="'+host+'mapdiv/1/20091013103315390464.swf" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + (1946 * deyang.levels[deyang.level]) + '" height="' + (1100 * deyang.levels[deyang.level]) + '"></embed><param name="wmode" value="transparent"></param></object>';

    var AdDiv2 = document.getElementById('addiv-002');
    if (!AdDiv2){
        AdDiv2 = document.createElement('div');
        AdDiv2.id = "addiv-002";
        AdDiv2.style.position = 'absolute';
        AdDiv2.style.zIndex = 51;
        deyang.mapFlashlayer.appendChild(AdDiv2);    
     }
     AdDiv2.style.left = 165 * deyang.levels[deyang.level] - deyang.center.Mx + 'px';
     AdDiv2.style.top = 100 * deyang.levels[deyang.level]-deyang.center.My + 'px';
     AdDiv2.innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + (2433 * deyang.levels[deyang.level]) + '" height="' + (1458 * deyang.levels[deyang.level]) + '"><param name="movie" value="'+host+'mapdiv/1/20091013103315390465.swf" /><embed src="'+host+'mapdiv/1/20091013103315390465.swf" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + (2433 * deyang.levels[deyang.level]) + '" height="' + (1458 * deyang.levels[deyang.level]) + '"></embed><param name="wmode" value="transparent"></param></object>';

    var AdDiv3 = document.getElementById('addiv-003');
     if (!AdDiv3){
        AdDiv3 = document.createElement('div');
        AdDiv3.id = "addiv-003";
        AdDiv3.style.position = 'absolute';
        AdDiv3.style.zIndex = 51;
        deyang.mapFlashlayer.appendChild(AdDiv3);
     }
    AdDiv3.style.left = -3000 * deyang.levels[deyang.level] - deyang.center.Mx + 'px';
    AdDiv3.style.top = -1498 * deyang.levels[deyang.level] - deyang.center.My + 'px';
    AdDiv3.innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + (700 * deyang.levels[deyang.level]) + '" height="' + (420 * deyang.levels[deyang.level]) + '"><param name="movie" value="'+host+'mapdiv/1/20091013103315390466.swf" /><embed src="'+host+'mapdiv/1/20091013103315390466.swf" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + (700 * deyang.levels[deyang.level]) + '" height="' + (420 * deyang.levels[deyang.level]) + '"></embed><param name="wmode" value="transparent"></param></object>';

    var AdDiv4 = document.getElementById('addiv-004');
    if (!AdDiv4){
        AdDiv4 = document.createElement('div');
        AdDiv4.id = "addiv-004";
        AdDiv4.style.position = 'absolute';
        AdDiv4.style.zIndex = 51;
        deyang.mapFlashlayer.appendChild(AdDiv4);
    }
    AdDiv4.style.left = -2440 * deyang.levels[deyang.level] - deyang.center.Mx + 'px';
    AdDiv4.style.top = -820 * deyang.levels[deyang.level] - deyang.center.My + 'px';
    AdDiv4.innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + (1280 * deyang.levels[deyang.level]) + '" height="' + (800 * deyang.levels[deyang.level]) + '"><param name="movie" value="'+host+'mapdiv/1/20091013103315390467.swf" /><embed src="'+host+'mapdiv/1/20091013103315390467.swf" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + (1280 * deyang.levels[deyang.level]) + '" height="' + (800 * deyang.levels[deyang.level]) + '"></embed><param name="wmode" value="transparent"></param></object>';
    
    var AdDiv5 = document.getElementById('addiv-005');
    if(!AdDiv5){
         AdDiv5 = document.createElement('div');
         AdDiv5.id = "addiv-005";
         AdDiv5.style.position = 'absolute';
         AdDiv5.style.zIndex = 51;
         deyang.containerLayer.appendChild(AdDiv5);
     }
    AdDiv5.style.left = Math.round(-1880 * deyang.levels[deyang.level]) - deyang.center.Mx + 'px';
    AdDiv5.style.top = Math.round(1400 * deyang.levels[deyang.level]) - deyang.center.My + 'px';
    AdDiv5.innerHTML = '<object onmouseover = "dywb_mouseover(\'addiv-005\', \'dywb\')" onmouseout = "dywb_mouseout(\'addiv-005\', \'dywb\')" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + (320 * deyang.levels[deyang.level]) + '" height="' + (390 * deyang.levels[deyang.level]) + '"><param name="movie" value="'+host+'mapdiv/1/ad-1.swf" /><embed id="dywb" src="'+host+'mapdiv/1/ad-1.swf" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + (320 * deyang.levels[deyang.level]) + '" height="' + (390 * deyang.levels[deyang.level]) + '"></embed><param name="wmode" value="transparent"></param></object>';

    var AdDiv6 = document.getElementById('addiv-006');
    if(!AdDiv6){
         AdDiv6 = document.createElement('div');
         AdDiv6.id = "addiv-006";
         AdDiv6.style.position = 'absolute';
         AdDiv6.style.zIndex = 51;
         deyang.containerLayer.appendChild(AdDiv6);
     }
    AdDiv6.style.left = 4700 * deyang.levels[deyang.level] - deyang.center.Mx + 'px';
    AdDiv6.style.top = -2900 * deyang.levels[deyang.level] - deyang.center.My + 'px';
    AdDiv6.innerHTML = '<object onmouseover = "dywb_mouseover(\'addiv-006\', \'wbdy\')" onmouseout = "dywb_mouseout(\'addiv-006\', \'wbdy\')" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + (320 * deyang.levels[deyang.level]) + '" height="' + (390 * deyang.levels[deyang.level]) + '"><param name="movie" value="'+host+'mapdiv/1/ad-2.swf" /><embed id="wbdy" src="'+host+'mapdiv/1/ad-2.swf" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + (320 * deyang.levels[deyang.level]) + '" height="' + (390 * deyang.levels[deyang.level]) + '"></embed><param name="wmode" value="transparent"></param></object>';

    var AdDiv7 = document.getElementById('addiv-007');
    if(!AdDiv7){
         AdDiv7 = document.createElement('div');
         AdDiv7.id = "addiv-007";
         AdDiv7.style.position = 'absolute';
         AdDiv7.style.zIndex = 51;
         deyang.containerLayer.appendChild(AdDiv7);
     }
    AdDiv7.style.left = -3500 * deyang.levels[deyang.level] - deyang.center.Mx + 'px';
    AdDiv7.style.top = 6920 * deyang.levels[deyang.level] - deyang.center.My + 'px';
    AdDiv7.innerHTML = '<object onmouseover = "dywb_mouseover(\'addiv-007\', \'shouji\')" onmouseout = "dywb_mouseout(\'addiv-007\', \'shouji\')" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + (286 * deyang.levels[deyang.level]) + '" height="' + (206 * deyang.levels[deyang.level]) + '"><param name="movie" value="'+host+'mapdiv/1/shouji.swf" /><embed id="shouji" src="'+host+'mapdiv/1/shouji.swf" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + (286 * deyang.levels[deyang.level]) + '" height="' + (206 * deyang.levels[deyang.level]) + '"></embed><param name="wmode" value="transparent"></param></object>';

    var AdDiv8 = document.getElementById('addiv-008');
    if(!AdDiv8){
         AdDiv8 = document.createElement('div');
         AdDiv8.id = "addiv-008";
         AdDiv8.style.position = 'absolute';
         AdDiv8.style.zIndex = 51;
         deyang.containerLayer.appendChild(AdDiv8);
     }
    AdDiv8.style.left = 10626 * deyang.levels[deyang.level] - deyang.center.Mx + 'px';
    AdDiv8.style.top = 4528 * deyang.levels[deyang.level] - deyang.center.My + 'px';
    AdDiv8.innerHTML = '<object onmouseover = "dywb_mouseover(\'addiv-008\', \'shibohui\')" onmouseout = "dywb_mouseout(\'addiv-008\', \'shibohui\')" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + (286 * deyang.levels[deyang.level]) + '" height="' + (206 * deyang.levels[deyang.level]) + '"><param name="movie" value="'+host+'mapdiv/1/shibohui.swf" /><embed id="shibohui" src="'+host+'mapdiv/1/shibohui.swf" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + (286 * deyang.levels[deyang.level]) + '" height="' + (206 * deyang.levels[deyang.level]) + '"></embed><param name="wmode" value="transparent"></param></object>';
}

function dywb_mouseover(pid, tid){
    if(isIE) {
        var AdDiv = document.getElementById(pid);
        var swf_obj = AdDiv.getElementsByTagName('object')[0];
    } else {
        var swf_obj = document.getElementById(tid); 
    }

	if (tid == 'shouji' || tid == 'shibohui')
	{
		swf_obj.width = "286";
		swf_obj.height = "206"; 
	} else {
		swf_obj.width = "320";
		swf_obj.height = "390"; 
	}
}

function dywb_mouseout(pid, tid){
    if(isIE){
        var AdDiv = document.getElementById(pid);
        var swf_obj = AdDiv.getElementsByTagName('object')[0];
    } else {
        var swf_obj = document.getElementById(tid);
    }

	if (tid == 'shouji' || tid == 'shibohui')
	{
		swf_obj.width = 286*deyang.levels[deyang.level];;
		swf_obj.height = 206*deyang.levels[deyang.level];; 
	} else {
		swf_obj.width = 320*deyang.levels[deyang.level];
		swf_obj.height = 390*deyang.levels[deyang.level];
	}
}



//公交搜索显示路线
function appendBusLine(arrBusData,type){
	
	if(!deyang.busLayer){
		deyang.busLayer = document.createElement('div');
		deyang.busLayer.style.position = 'absolute';
		deyang.busLayer.style.top = '0px';
		deyang.busLayer.style.left = '0px';
		deyang.containerLayer.appendChild(deyang.busLayer);
	}else{
		deyang.busLayer.innerHTML = '';
	}
	
	
    if(arrBusData!=null){
        var coords = [];
		var PopHtml='<div style="background:url(images/left-content/bus-tip-left.gif) no-repeat scroll; font-size:12px; width:23px; height:42px; float:left; text-align:center; padding-top:5px; color:#003300;">{$No}:</div><div style="background:url(images/left-content/bus-tip-center.gif) repeat-x scroll; height:24px; min-width:20px; width:auto !important; width:20px; font-size:12px; padding:5px 5px 0 0;; float:left; color:#003300; {$width}">{$BusStationName}</div><div style="background:url(images/left-content/bus-tip-right.gif) no-repeat scroll; height:24px; width:3px; float:left;"></div>';
        if(type==1){
            var l=arrBusData.Bus_BN_UP_BS_StationName_Js.length;
            for(i=0;i<l;i++){
                var vlen = arrBusData.Bus_BN_UP_BS_StationName_Js[i].length*12.1;
                var busLineItem = document.createElement('div');
                busLineItem.style.width = (vlen + 45) + 'px';
                busLineItem.style.position = 'absolute';
                busLineItem.style.top = Math.round(arrBusData.Bus_Bs_UpY_Js[i] * deyang.levels[deyang.level]) - deyang.center.My - 25 + 'px';
      			busLineItem.style.left = Math.round(arrBusData.Bus_Bs_UpX_Js[i] * deyang.levels[deyang.level]) - deyang.center.Mx - 12 + 'px';
                busLineItem.innerHTML=PopHtml.replace('{$No}',(i+1)).replace('{$BusStationName}',arrBusData.Bus_BN_UP_BS_StationName_Js[i]).replace('{$width}','width:'+(vlen+10)+'px');
                deyang.busLayer.appendChild(busLineItem);
            }
        }else if(type==2){
            var l=arrBusData.Bus_BN_Down_BS_StationName_Js.length;           
            for(i=0;i<l;i++){
                var vlen = arrBusData.Bus_BN_UP_BS_StationName_Js[i].length*12.1;
                var busLineItem = document.createElement('div');
                busLineItem.style.width = (vlen + 45) + 'px';
                busLineItem.style.position = 'absolute';
                busLineItem.style.top = Math.round(arrBusData.Bus_Bs_DownY_Js[i] * deyang.levels[deyang.level]) - deyang.center.My - 25 + 'px';
      			busLineItem.style.left = Math.round(arrBusData.Bus_Bs_DownX_Js[i] * deyang.levels[deyang.level]) - deyang.center.Mx - 12 + 'px';
                busLineItem.innerHTML=PopHtml.replace('{$No}',(i+1)).replace('{$BusStationName}',arrBusData.Bus_BN_UP_BS_StationName_Js[i]).replace('{$width}','width:'+(vlen+10)+'px');
                deyang.busLayer.appendChild(busLineItem);
            }           
        }else if(type==3){
			var l=arrBusData.Bus_BN_S_BS_StationName_Js.length;           
            for(i=0;i<l;i++){
                var vlen = arrBusData.Bus_BN_UP_BS_StationName_Js[i].length*12.1;
                var busLineItem = document.createElement('div');
                busLineItem.style.width = (vlen + 45) + 'px';
                busLineItem.style.position = 'absolute';
                busLineItem.style.top = Math.round(arrBusData.Bus_Bs_SY_Js[i] * deyang.levels[deyang.level]) - deyang.center.My - 25 + 'px';
      			busLineItem.style.left = Math.round(arrBusData.Bus_Bs_SX_Js[i] * deyang.levels[deyang.level]) - deyang.center.Mx - 12 + 'px';
                busLineItem.innerHTML=PopHtml.replace('{$No}',(i+1)).replace('{$BusStationName}',arrBusData.Bus_BN_UP_BS_StationName_Js[i]).replace('{$width}','width:'+(vlen+10)+'px');
                deyang.busLayer.appendChild(busLineItem);
            }      	
		}
    }
}