// JavaScript Document
	var host=(document.location.host).indexOf("zky.cn")>=0||(document.location.host).indexOf("cq.d2d.cn")>=0?"http://cq.d2d.cn/":"http://"+document.location.host;
	//初始话对象
	MapinitVO=
	{
		//relx:相对中心坐标posinfoapi({"ID":"7886","X":"490704","Y":"423648","Name":"\u89e3\u653e\u7891","menu":"geoinfor","Img":"0","Type":"249","Telephone":""});absx:468549,absy:417066,
		relx:0,rely:0, 
		absx:490704,absy:423648,
		Layer:4,Type:3,
		width:'100%',height:'100%',
		datapath:host+"/",
		picPath:"http://mappic.d2d.cn/mappic/023",
		txtpath:"http://www.d2d.cn:80/maptxt/023",
		//类型图标路径
		typeimg:host+"/images/map/class/",
		//ajax处理页面变量
		phpbase:"/index.php"
	};
	
	if((document.location.host).indexOf("zky.cn")>=0||(document.location.host).indexOf("cq.d2d.cn")>=0)
	{
		MapinitVO.datapath="http://"+document.location.host+"/";
		//MapinitVO.picPath=host+"/mappic/023";
		//MapinitVO.txtpath=host+"/maptxt/023";	
		//MapinitVO.txtpath="http://cq.d2d.cn/maptxt/023";	
	}


	var mapdoc=null;
	//MapinitVO.datapath="http://"+document.location.host;

	/*
		右边信息栏目对象
		MasterPage:只是首页出现的ID
		Locate.dom 右边列表标志
	*/
	var Locate={width:420,dom:document.getElementById("Locate")||null,
	firstonly:(document.location.href.indexOf("index.php/map")>=0||document.location.href.indexOf("pai/")>=0)?true:false,
	Housepublish:(document.location.href.indexOf("house/publish")>=0)?true:false};
	var d2dscriptarrayget=document.getElementsByTagName("script"),d2dscriptarray=null;
	for(var i=0;i<d2dscriptarrayget.length;i++)
	{
		if(d2dscriptarrayget[i].src.indexOf("addmap.js")>=0)
		{
			if(d2dscriptarrayget[i].src.split("?").length>=2)
			 d2dscriptarray=d2dscriptarrayget[i].src.split("?")[1].split("&");	
		}
	}
	//var d2dscriptarray=document.scripts[document.scripts.length-1].src.match(/[^\?]*$/).toString().split("&");
	if(d2dscriptarray)
	{
		for(var i=0;i<d2dscriptarray.length;i++)
		{
			var d2dscriptarraytemp=d2dscriptarray[i].split("=");
			if(d2dscriptarraytemp[0]=="Layer")MapinitVO.Layer=d2dscriptarraytemp[1];
			else if(d2dscriptarraytemp[0]=="X")MapinitVO.absx=d2dscriptarraytemp[1];
			else if(d2dscriptarraytemp[0]=="Y")MapinitVO.absy=d2dscriptarraytemp[1];
			//判断地图方式
			else if(d2dscriptarraytemp[0]=="Sign"&&d2dscriptarraytemp[1]=="d2dnofull")Locate.firstonly=false;
			else if(d2dscriptarraytemp[0]=="Sign"&&d2dscriptarraytemp[1]=="d2dfull")Locate.firstonly=true;
			else if(d2dscriptarraytemp[0]=="mapeye"&&d2dscriptarraytemp[1]=="yes")Locate.mapeye=true;

			else if(d2dscriptarraytemp[0]=="d2dshowround"&&d2dscriptarraytemp[1]=="yes")Locate.d2dshowround=true;
		}
	}
	
	//上面Title对象
	var Banner={height:91};

	var _DEBUGHout=false;
	if(_DEBUGHout)
	{
		var _debugwinout=window.open("about:blank","_break");	
		_debugwinout.document.writeln("open new debug window<br>");	
	}	

	
	var d2dcalltxttime=false;
	//多JS加载 calltxtsign:控制TXT回调多次情况
	var loadJS = {
	 lock : false, ranks : [],calltxtsign:false
	 
	 , callback : function (startTime, callback) {
	 //载入完成  
	  callback && callback(new Date().valueOf() - startTime.valueOf()); //回调
	  
	  this.luck = false, this.read(); //解锁，在次载入
	 }
	 
	 , read : function () {
	 //读取
	
	  if (!this.luck && this.ranks.length) {
	   var wc = this, ranks = this.ranks.shift();	
	   var o1=ranks.o1?ranks.o1:document;
	   var head =ranks.o2?ranks.o2:o1.getElementsByTagName("head")[0]; 
	   
	   //var head =o1.getElementsByTagName("head").item(0);
	   //var head=document.body;
	  
	   if (!head) {
		ranks.length = 0, ranks = null;
		throw new Error('HEAD不存在');
	   }
	   
	   var  startTime = new Date, script = o1.createElement('script');
	   this.luck = true;
	   
	   script.onerror=function(){
		script.dele();
		 
	   };
	   
	   script.dele=function(){ 	
			script.onload = script.onreadystatechange = script.onerror = null
			 , script.parentNode.removeChild(script), script = null; //清理script标记
			 
			wc.callback(startTime, ranks.callback); 
			//回调加载TXT数据, script.src = ''
			//alert(loadJS.ranks.length);
		
			if(ranks.calltxt&&typeof ranks.calltxt=="function"&&loadJS.ranks.length==0&&!loadJS.calltxtsign&&!d2dcalltxttime)
			{
				loadJS.calltxtsign=true;
				//d2dcalltxttime=true;
				ranks.calltxt();
			}
			startTime = ranks = null;
		//alert(loadJS.ranks.length);
	   };	   
	   
	   script.onload = script.onreadystatechange = function () {
	   //对于OP9.5的BT行为实在无语不想用记时器来监视。。。目前暂无其它解决办法。。
	   //问题原因当在OP9.5下请求的文件是空文件，或者是有错误的，就会出现刷新状态并且不触发readystatechange的情况了。这很KB
		if (script && script.readyState && script.readyState != 'loaded' && script.readyState != 'complete') return;
		
		script.dele();
		
	   };
	   script.language = 'javascript';
	   script.charset = ranks.charset || 'gb2312';
	   script.src = ranks.src;
	   //alert(script.src);
	   head.appendChild(script);
	   
	  }
	 }
	 
	 , push : function (src, charset, callback,o1,o2,calltxt) {
		/*
	 	o1:o1 create element,
		o2:o2 appendChild o1 create element
		calltxt:回调函数
	 */	 
	 //加入队列
	  loadJS.calltxtsign=false;
	  this.ranks.push({ 'src' : src, 'charset' : charset, 'callback' : callback ,'o1':o1,'o2':o2,'calltxt':calltxt});
	  this.read();
	 }
	};
	
	var JSfunc = function () {
	 var ms = arguments[0] + 'ms';
	 ms += '\n' + ('undefined' != typeof CarInfo ? CarInfo.length : '0')
	 
	};
	
	
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	function CreateJS(obj)
	{
		//添加JS
		if(!obj.doma||!obj.domc||!obj.ID||!obj.Url)return;
		var CreateJSobj =obj.domc.createElement('script');
		CreateJSobj.language = 'javascript';
		CreateJSobj.id=obj.ID;
		CreateJSobj.src=obj.Url;
		obj.doma.appendChild(CreateJSobj);
		CreateJSobj=null;
		obj=null;
	}	
	function _cqh_docresz()
	{
		//onresize
		try{
			_cqh_map.docresize();
			if(typeof mapdivre=="undefined")return;
			$("#miniAD").css("left",parseInt(mapdivre.style.width)-$("#miniAD").width()-5).css("top",parseInt(mapdivre.style.height)-$("#miniAD").height()-5+Banner.height);			
		}catch(ee){}
	}
	
	var _cqh_map0 = '_cqhome_mapd0';
	var _cqh_map = _cqh_map0;
	var layerid=['mapdm0','mapd0','mapd1','boxslt','guageID'];
	

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


	var CreateMap={};
	
	CreateMap.GetBrowser=function()
	{
		//获得用户浏览器信息
		var browser=navigator.userAgent.toLowerCase();
		//浏览器版本编号
		var browsernum=null;
		if(browser.indexOf("opera")>-1)
		{
			browsernum=1;
		}else if(browser.indexOf("safari")>-1)
		{
			browsernum=2;
		}else if(browser.indexOf("firefox")>-1 ||browser.indexOf("gecko")>-1 )
		{
			browsernum=3;
		}else{
			browsernum=0;
		}
		return browsernum;
	}
	

	CreateMap.GetCode=function()
	{
		//获得当前页面编码
		var strintmp;
		//获取当前页面编码  小写
		var charset= document.getElementsByTagName('meta');
		for(var i=0;i<charset.length;i++)
		{
			strintmp= charset[i].content.toLowerCase();
			if(strintmp.indexOf('charset')>0)
			{
				strintmp =strintmp.split('=')[1];
				strintmp =strintmp.toLowerCase();
			}
		}
		
		if(strintmp)return strintmp;
		else 
		{
			strintmp=document.charset||document.characterSet;
			if(strintmp)return strintmp;
		}		
		
	}
	
	CreateMap.GetMainJS=function()
	{
		//mainJS
		loadJS.push(MapinitVO.datapath+'mapjs/023/ilmap.js', 'utf-8',JSfunc,_cqh_map.document,_cqh_map.document.body);
	}
	
	CreateMap.AddJS=function()
	{
		//添加JS'json2',
		var JSArr=['swfobject_source','json2','tools','mapeye','slidingbar','GetBoxsPos','lablemaker','peripheral','common','locationuse','datacheck','ilmapapi'];
		
		for(i=0;i<JSArr.length;i++)
		{
			if(!JSArr[i])continue;
/*			CreateJS
			(
				{
					doma:document.getElementsByTagName('head').item(0),
					domc:document,ID:i+"js",
					Url:MapinitVO.datapath+'/mapjs/023/'+JSArr[i]+'.js'
				}
			);*/
			loadJS.push(MapinitVO.datapath+'mapjs/023/'+JSArr[i]+'.js', 'utf-8',JSfunc,document,document.getElementsByTagName('head').item(0));				
		}	
		
	}
	
	CreateMap.DivSize=function()
	{
		if(!Locate.firstonly)return;
		var mapdivobj=document.getElementById("Map");
		//change DIV MAP size
		//这里还需判断是否最终页，判断Map的W、H
		if(!mapdivobj)return;
		if(parseInt(document.documentElement.clientWidth)!=0&&parseInt(document.documentElement.clientHeight)!=0&&browsernum!=1)
		{
			/*
			if (parseInt(document.documentElement.clientWidth)<998) {
				mapdivobj.style.width="578px";
			}else{
			*/
			
				if( $("#Locate").css("display") != "none" ) {
					mapdivobj.style.width=(parseInt(document.documentElement.clientWidth)-Locate.width)+"px";
				}else{
					mapdivobj.style.width=parseInt(document.documentElement.clientWidth)+"px";
				}	

			//}
			
			//var bodyclientHeight=parseInt(document.documentElement.clientHeight)>parseInt(document.body.clientHeight)?parseInt(document.documentElement.clientHeight):parseInt(document.body.clientHeight);	
			var bodyclientHeight=parseInt(document.documentElement.clientHeight);	
			//判断地图页面上边是否有信息栏 91:上边高度
			if(document.getElementById("Banner"))
			{
				mapdivobj.style.height=(bodyclientHeight-Banner.height)+"px";	
				//document.getElementById("apDiv1").style.height=(parseInt(document.documentElement.clientHeight)-Banner.height)+"px";
				//$("#apDiv1").height(bodyclientHeight-Banner.height);
			}			
			else $(mapdivobj).height(bodyclientHeight);			
			
		}else if(document.body.clientWidth){
			//opera
			/*if (parseInt(document.body.clientWidth)<998) {
				mapdivobj.style.width="578px";
			}else{
			*/	
				if( $("#Locate").css("display") != "none" ) {
					mapdivobj.style.width=(parseInt(document.body.clientWidth)-Locate.width)+"px";
				}else{
					mapdivobj.style.width=parseInt(document.body.clientWidth)+"px";
				}	

			//}
			
			var bodyclientHeight=parseInt(document.body.clientHeight);	
			//判断地图页面上边是否有信息栏 91:上边高度
			if(document.getElementById("Banner"))
			{
				mapdivobj.style.height=(bodyclientHeight-Banner.height)+"px";	
				//document.getElementById("apDiv1").style.height=(parseInt(document.documentElement.clientHeight)-Banner.height)+"px";
				//$("#apDiv1").height(bodyclientHeight-Banner.height);
			}			
			else mapdivobj.style.height=bodyclientHeight+"px";		
			
			
		}
		
		
		//alert(mapdivobj.style.height+","+mapdivobj.style.height);
	};
	
	CreateMap.Fram=function()
	{
		//position:absolute;top:0px;left:0px;z-index:2;
		var mapwidth="100%";
		var mapheight="100%";		
		var _cqh_maphtml='<iframe frameBorder=0 name='+_cqh_map+' id='+_cqh_map+' width="'+mapwidth+'" height="'+mapheight+'" scrolling="no"  style="width:'+mapwidth+';height:'+mapheight+';scrolling:no;overflow: hidden; display: block;"></iframe>';	
		var mapdivobj=document.getElementById("Map");
		mapdivobj.innerHTML=_cqh_maphtml;
		_cqh_map=eval(_cqh_map);
	};
	
	CreateMap.Div=function()
	{
		var whlt="position:relative;left:0px;top:0px;width:0px;height:0px;";
		var mapmar="margin-left: 0px;margin-top: 0px;margin-right: 0px;margin-bottom: 0px;";
	
		_cqh_map.document.open();
		//_cqh_map.document.charset=GetCode();
		_cqh_map.document.write('<html xmlns:v>');
		_cqh_map.document.write('<head">');
		_cqh_map.document.write('<meta http-equiv="content-type" content="text/html; charset=utf-8" />');
		_cqh_map.document.write('<title>Map</title>');
		_cqh_map.document.write('</head>');
		
		_cqh_map.document.write('<body style="'+mapmar+'background-color:#808080;" UNSELECTABLE="on" onresize="parent._cqh_docresz()">');
		_cqh_map.document.write('<div id="'+layerid[4]+'" style="font-size:12px;z-index:11;color:#FFFFFF;position:absolute;left:100px;top:100px;width:500px;height:20px;">地图下载等待中......</div>');		
		_cqh_map.document.write('<div id="'+layerid[0]+'" style="z-index:0;'+whlt+'">');
		_cqh_map.document.write('<div id="'+layerid[1]+'" style="z-index:0;'+whlt+'"></div>');
		_cqh_map.document.write('<div id="'+layerid[2]+'" style="z-index:2;'+whlt+'"></div></div>');
		//border:1px solid #ff0000;
		_cqh_map.document.write('<div id="'+layerid[3]+'" style="z-index:10;display:none;'+whlt+'"><img src="'+MapinitVO.datapath+'/images/map/pageclose.gif" style="position:absolute; top:30px;left:5px;cursor:pointer;z-index:10;width:14px;height:14px;" onclick="Guideuse.Con(\'none\');"/><div id="guide" style="cursor:pointer;z-index:0;'+whlt+'filter:progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=90,finishOpacity=90);opacity:0.6;background:#777;"></div></div>');
		_cqh_map.document.write('</body>');
		_cqh_map.document.write('</html>');
		_cqh_map.document.close();
	};
	
	CreateMap.Meta=function()
	{
		if(browsernum==3)
		{
			//firefox
			window.addEventListener('resize',function(){_cqh_docresz();}, false);
		}		
		
/*		var metaHead = _cqh_map.document.getElementsByTagName('HEAD').item(0); 
		var _cqh_elm0 = _cqh_map.document.createElement('meta');
		_cqh_elm0.httpEquiv='imagetoolbar';
		_cqh_elm0.content='no';
		metaHead.appendChild(_cqh_elm0);*/
	};
	

	
	CreateMap.Init=function()
	{
		//得到浏览器号
		 browsernum=CreateMap.GetBrowser();
		//添加JS
		CreateMap.AddJS();
		//解析URL.document.location.search:设置或获取 href 属性中跟在问号后面的部分
		var Href=document.location.href.split("?");
		if(Href&&Href[1]&&unescape(Href[1]).indexOf("&")>=0)
		{
			var Href1=unescape(Href[1]).split("&");
			//URL值存储对象
			var obj=
			{
				X:"",Y:"",Content:"",Datalayer:"",Title:"",Debug:""
			};
			
			for(var i=0;i<Href1.length;i++)
			{
				if(!Href1[i])continue;
				var Href2=Href1[i].split("=");
				if(!Href2[0]||!Href2[1])continue;
				if(Href2[0]=="x")obj.X=Href2[1];	
				if(Href2[0]=="y")obj.Y=Href2[1];
				if(Href2[0]=="sign"){
					obj.Sign=Href2[1];		
					if(obj.Sign=="inMapbus")CreateMap.DivSize();						
				}
				if(Href2[0]=="sign"){
					if(obj.Sign=="d2dmark")CreateMap.DivSize();						
				}				
				if(Href2[0]=="datalayer")obj.Datalayer=Href2[1];			
				if(Href2[0]=="content")obj.Content=unescape(Href2[1]);	
				if(Href2[0]=="title")obj.Title=unescape(Href2[1]);
				if(Href2[0]=="debug")obj.Debug=Href2[1];
				//cqjob
				if(Href2[0]=="name")obj.Name=unescape(Href2[1]);
				if(Href2[0]=="logo")obj.Logo=Href2[1];		
				if(Href2[0]=="telephone")obj.Telephone=Href2[1];
				if(Href2[0]=="address")obj.Address=unescape(Href2[1]);		
				
				
			}
			
			if(obj&&obj.X&&obj.Y&&obj.Sign&&obj.Sign=="cqjob")
			{
					MapinitVO.absx=obj.X
					MapinitVO.absy=obj.Y;
					var mapdivobj=document.getElementById("Map");
					//change DIV MAP size
					//这里还需判断是否最终页，判断Map的W、H
					if(parseInt(document.documentElement.clientWidth)!=0&&parseInt(document.documentElement.clientHeight)!=0&&browsernum!=1)
					{
						mapdivobj.style.width=parseInt(document.documentElement.clientWidth)+"px";	
						var bodyclientHeight=parseInt(document.documentElement.clientHeight);	
						//判断地图页面上边是否有信息栏 91:上边高度
						mapdivobj.style.height=(bodyclientHeight-Banner.height)+"px";	
					}else if(document.body.clientWidth){
						//opera
						mapdivobj.style.width=parseInt(document.body.clientWidth)+"px";
						var bodyclientHeight=parseInt(document.body.clientHeight);	
						//判断地图页面上边是否有信息栏 91:上边高度
						mapdivobj.style.height=(bodyclientHeight-Banner.height)+"px";	
					}
					Locate.dom.style.display="none";  
					$("#miniAD").hide();
			}
			
		}
		else{
			//初始化中心坐标
			if(typeof getbignews!="undefined"){
				getbignews=JSON.parse(getbignews);
				MapinitVO.absx=parseInt(getbignews[0].X);//+1600;
				MapinitVO.absy=getbignews[0].Y;						
				getbignews[0].infotype="NewsFocus";
			}
			CreateMap.DivSize();	
		}
		
		 //创建地图初始化
		this.Fram();
		this.Div();
		this.Meta();		
		
		CreateMap.GetMainJS();
		if(Locate.firstonly)$(document).ready(
			function(){
			$(window).resize(CreateMap.DivSize);	
			
		});
	};

	CreateMap.Init();	

			
		

		

	
	
	
	