/////////////////////////////////////////////
//
//	一般处理函数
//
////////////////////////////////////////////

var _sliderBar;
var _maxPrice = 99999;
var _minPrice = 0;
var _bounPre = 0.7;
var _bounCost = 30000; 
var _maxTimeOut;
var _minTimeOut;
var _parTimeOut;
var _eventObject;
var _sortIndex=0;
var _starArea=false;
var _starTimeout;
var _selStarCont;
var _selStarNum;
var _selNowMenu;


//查询区域工具选择
function sSearchTool(n)
{
	var a = document.getElementById("sata");
	var b = document.getElementById("satb");
	var c = document.getElementById("satc");
	var d = document.getElementById("satd");
	var e = document.getElementById("sate");
	var at = document.getElementById("satat");
	var bt = document.getElementById("satbt");
	var ct = document.getElementById("satct");
	var dt = document.getElementById("satdt");
	var et = document.getElementById("satet");

	//先把全部的样式设回去
	at.className = "tb";
	bt.className = "td";
	ct.className = "td";
	dt.className = "td";
	et.className = "td";
	a.style.display = "none";
	b.style.display = "none";
	c.style.display = "none";
	d.style.display = "none";
	e.style.display = "none";
	
	if ( n == "a" )
	{
		at.className = "ta";
		a.style.display = "";
	}else{
		document.getElementById("sat"+n+"t").className = "tc";
		document.getElementById("sat"+n).style.display = "";
	}
}

//调整页面DIV的位置和尺寸
function sPageDiv()
{
	var objTitle = el("dTitle");
	var objNavbar = el("navbar");
	var objBotcon = el("dBotcon");
	//var objInstruc = el("instruc");
	var objBotdiv = el("botdiv");
	var objConleft = el("conleftarea");
	var objMapA = el("conmaparea");
	var objMapdiv = el("maparea");
	var objInfoarea = el("infoarea");

	//var s1 = document.body.clientHeight - objTitle.offsetHeight - objNavbar.offsetHeight - objInstruc.offsetHeight - objBotdiv.offsetHeight;
	var s1 = document.documentElement.clientHeight - objTitle.offsetHeight - objNavbar.offsetHeight - objBotdiv.offsetHeight;
	var s2 = objBotcon.offsetWidth - objConleft.offsetWidth;
	var s3 = objBotcon.offsetLeft + objBotcon.offsetWidth - objInfoarea.offsetWidth - 15;
	var s4 = objBotcon.offsetTop;
	var s5 = document.documentElement.clientWidth - 4;
	var s6 = (s2-8)<0?0:s2-8;
	objBotcon.style.height = (s1-4) + "px";
	//objBotcon.style.width = s5 + "px";
	objMapA.style.width = (s6) + "px";
	objMapdiv.style.width = (s6) + "px";
	objMapdiv.style.height = (s1-6) + "px";

	//调整浮动信息区的位置
	objInfoarea.style.top = (s4+1) + "px";
	objInfoarea.style.left = s3 + "px";
	el("infotparea_a").style.top = "0px";
	el("infotparea_b").style.top = el("infocontbg").offsetHeight + "px";
	//var a2 = el("infotparea_b");

	//调整返回区高度
	sResultDiv();
}

//计算返回区的高度
function sResultDiv()
{
	var objBotcon = document.getElementById("dBotcon");
	var objSel = document.getElementById("satSel");
	var objInds = document.getElementById("inds");
	var objl = document.getElementById("dLife");
	var objt = document.getElementById("dTraffic");
	var objh = document.getElementById("dHealth");
	var obje = document.getElementById("dEducation");
	var objp = document.getElementById("dPollution");

//alert(objBotcon.offsetHeight);
	//调整全部返回区的尺寸(23是指数区域高度)
	var s1 = objBotcon.offsetHeight - objSel.offsetHeight - 15;
	objl.style.height = (s1-10) + "px";
	objt.style.height = (s1-10) + "px";
	objh.style.height = (s1-10) + "px";
	obje.style.height = (s1-10) + "px";
	objp.style.height = (s1-10) + "px";
	//alert(objSel.offsetHeight+","+s1)
}

//根据提交的X,Y和等级定位地图
function orMap(id,x,y,l)
{
	if ( !l || l < 0 )
	{
		l=16;
	}
	_m.coordRecenterTo(x,y,l);
	stf.hidemap();
	stf.reloadmap();
	stf.showInfoWin(x,y,id);
}

// 除去左边空白
String.prototype.Ltrim = function()
{
	var regEx = /^\s+/g;
	return this.replace(regEx,'');              
   } 
   
//除去右边空白
String.prototype.Rtrim = function()
{
       var regEx = /\s+$/g;
       return this.replace(regEx,'');              
}
    
// 除去两边空白
String.prototype.Trim = function()
{
       var regEx = /(^\s+)|(\s+$)/g;
       return this.replace(regEx,'');              
}

var _wls=window.location.search;
_wls=_wls.replace(/[?]/g,'');

//获取指定参数
function getParam(Param)
{
	var aryTemp1, aryTemp2

	aryTemp1 = _wls.split("&")
	for ( var i=0; i<aryTemp1.length; i++ )
	{
		aryTemp2 = aryTemp1[i].split("=")
		if ( aryTemp2[0] == Param )
		{
			return aryTemp2[1];
		}
	}
	return "";
}

function el(a){return document.getElementById(a)};
function en(a){return document.getElementsByName(a)};
function si(a,b){document.getElementById(a).innerHTML=b;};
function co(a){return document.createElement(a)};
function cc(a){var b=ce("div");b.className=a;return b}




/////////////////////////////////////////////
//
//	显示区相关处理
//
////////////////////////////////////////////


	
	var aryInfoLife = [];
	var aryInfoTraffic = [];
	var aryInfoHealth = [];
	var aryInfoEducation = [];
	var aryInfoPollution = [];
	var aryHdivLife = [];
	var aryHdivTraffic = [];
	var aryHdivHealth = [];
	var aryHdivEducation = [];
	var aryHdivPollution = [];
	var arySprPtLife = [];
	var arySprPtTraffic = [];
	var arySprPtHealth = [];
	var arySprPtEducation = [];
	var arySprPtPollution = [];
	var viewLength = 2;
	var aryInfoId;

	function loadPoiList(a,b)
	{
		var features=a.fs;
		var cGrid="";
		var oldCategory="";
		var conR = el("lv"+b);
		var conE = el("ex"+b);
		var conT = el("tx"+b);
		var intStarLength = 80;
		var aryinfo = eval("aryInfo"+b);
		var aryHdiv = eval("aryHdiv"+b);
		var temp1;

		//判断是否需要执行
		if ( conR.innerHTML != "" )
		{
			return;
		}

		//设置星级
		//conE.style.width = ( parseFloat(a.index) * intStarLength/2 ) + "px";
		//conT.innerHTML = (parseFloat(a.index)/2) + "星";
		//conE.style.width = ( parseInt(a.index) /100 * intStarLength ) + "px";
		//temp1 = parseInt(a.index);
		//temp1 = temp1 + "";
		//if ( temp1.length == 1 )
		//{
		//	temp1 = "0"+temp1;
		//}
		//conT.innerHTML = temp1;

		var t0,t1,t2,t3;
		var t21,t22,t23,t24,t25;
		var idex = 0;
		var hideDiv;
		//没有内容就退出
		if (!features)
		{
			return;
		}
		//内容
		for(var i=0;i<features.length;i++)
		{
			var feature=features[i];
			aryinfo[i] = [];

			//保存相关信息
			aryinfo[i][0] = feature.category;
			aryinfo[i][1] = feature.name;
			aryinfo[i][2] = feature.img;
			aryinfo[i][3] = feature.desc;
			aryinfo[i][4] = feature.distance;
			aryinfo[i][5] = feature.point;
			aryinfo[i][6] = feature.negative;

			//大类分割
			t0 = co("DIV");
			if (oldCategory != aryinfo[i][0] )
			{
				t0.className = "list6";
				t0.innerHTML = aryinfo[i][0];
				oldCategory= aryinfo[i][0];
				if ( aryinfo[i][6] == "1" )
				{
					t0.style.color = "#414141";
				}
				idex = 0;
			}
			else
			{
				t0.className = "list7";
				idex = idex + 1;
			}

			//判断是否需要添加到隐藏容器中
			if ( idex > viewLength )
			{
				if ( b != "Traffic" && b != "Health"&& b != "Pollution" )
				{
					if ( idex == viewLength+1 )
					{
						aryHdiv[aryHdiv.length] = []
						hideDiv = co("DIV");
						hideDiv.className = "listhide"
						hideDiv.appendChild(t0);
						aryHdiv[aryHdiv.length-1][0] = hideDiv;
						//展开文字
						t1 = co("DIV");
						t1.className = "listOpen1";
						t1.innerHTML = "<span class='listOpen11' onclick='aiResultOpen(\""+i+"\",\""+b+"\","+(aryHdiv.length-1)+")'>更多 >></span>";
						hideDiv.appendChild(t1);
						aryHdiv[aryHdiv.length-1][1] = t1;
						//容器区
						t2 = co("DIV");
						t2.className = "listOpen2";
						t2.style.display = "none";
						hideDiv.appendChild(t2);
						aryHdiv[aryHdiv.length-1][2] = t2;
						//添加到主容器
						conR.appendChild(hideDiv);
					}
					continue;
				}
			}

			//添加到容器
			conR.appendChild(t0);
			getSResultOne(i,b,aryinfo[i],conR);
		}
	}

	//返回拼好的结果对象
	function getSResultOne(a,b,c,d)
	{
		var t0,t1,t2,t3;
		var t21,t22,t23,t24,t25;

		//主容器和覆盖容器
		t1 = co("DIV");
		t1.className = "list0";
		t1.id = "slist"+a+b;
		t2 = co("DIV");
		t3 = co("DIV");
		t3.className = "listmask";
		t3.setAttribute("in",a);
		t3.setAttribute("type",b);
		t3.onclick = aiClick;
		t3.onmouseover = aiMouseover;
		t3.onmouseout = aiMouseout;
		t1.appendChild(t3);
		t1.appendChild(t2);			

		//图标
		t21 = co("DIV");
		t21.className = "list1";
		t21.innerHTML = "<div style='height:15px' class='legend"+c[2]+"'></div>"
		t2.appendChild(t21);
			
		//文字
		t22 = co("DIV");
		t22.className = "list2";
		t23 = co("DIV");
		t23.className = "list21";
		t23.innerHTML = c[1];
		t24 = co("DIV");
		t24.className = "list22";
		t24.innerHTML = c[4]+"米";
		t22.appendChild(t23);
		t22.appendChild(t24);

		//详细信息
		if(c[3] !='')
		{
			t25 = co("DIV");
			t25.className = "list23";
			t25.innerHTML = c[3];
			t22.appendChild(t25);
		}

		//调整影响
		if ( c[6] == "1" )
		{
			try
			{
				t23.style.color = "#414141";
				t24.style.color = "#414141";
				t25.style.color = "#414141";
			}catch(ErrorX){}
		}

		//添加
		t2.appendChild(t22);
		d.appendChild(t1)

		//设置覆盖区的高度
		t3.style.height = t1.offsetHeight + "px";
	
		//添加的绘制点数组
		eval("arySprPt"+b)[eval("arySprPt"+b).length] = c;
	}

	var _eFeatures;
	var _toldId;
	var _tFeature;

	//点击展开
	function aiResultOpen(a,b,c)
	{
		var aHobj = eval("aryHdiv"+b)[c];
		var aInfo = eval("aryInfo"+b);
		var Category;
		var t0;
		var pstyle,x,y,f;
		//打开显示
		aHobj[1].style.display = "none";
		aHobj[2].style.display = "";
		//如果添加过结果就直接展开
		if ( aHobj[2].innerHTML != "" )
		{
			return;
		}
		//当前类型
		Category = aInfo[a][0];
		//没有就添加结果
		for(var i=a;i<aInfo.length;i++)
		{
			//判断是否是当前类
			if ( aInfo[i][0] != Category )
			{
				break;
			}
			//添加分割线
			if ( i != a )
			{
				t0 = co("DIV");
				t0.className = "list7";
				aHobj[2].appendChild(t0);
			}
			//内容
			getSResultOne(i,b,aInfo[i],aHobj[2]);
			//新增点单独绘制
			pstyle = parseInt(aInfo[i][2]);
			pstyle = "S" + (1711+pstyle);
			x = (aInfo[i][5]).split(",")[0];
			y = (aInfo[i][5]).split(",")[1];
			f = _m.map.addPoint(x,y,aInfo[i][1],null,pstyle,{"on":"false","style":"Label01"},null,false);
		}
	}

	//点击事件
	function aiClick()
	{
		var a,b,c;
		a = this.getAttribute("in");
		b = this.getAttribute("type");
		c = eval("aryInfo"+b)[parseInt(a)];
		sCentMap(c[1],c[5].split(",")[0],c[5].split(",")[1],"",c[2]);
	};

	//移入事件
	function aiMouseover()
	{
		var a,b,c,d,e;
		a = this.getAttribute("in");
		b = this.getAttribute("type");
		c = el("slist"+a+b);
		d = eval("aryInfo"+b)[parseInt(a)];
		if ( _toldId )
		{
			if ( _toldId.id != c.id )
			{
				_toldId.className = "list0";
				c.className = "list01";
				e = true;
			}
		}else{
				c.className = "list01";
				e = true;
		}
		_toldId = c;
		//绘制点
		if ( e ){ sDrawTempPoint(d[1],d[5].split(",")[0],d[5].split(",")[1],"",d[2]); }
	};

	//移出事件
	function aiMouseout()
	{
		var a,b,c;
		a = this.getAttribute("in");
		b = this.getAttribute("type");
		c = el("slist"+a+b);
		c.className = "list0";
		_toldId = "";
		sDrawTempPoint();
	};

	//临时点
	function sDrawTempPoint(name,x,y,l,t)
	{//debugger;
		var s;
		if ( !l || l < 0 )
		{
			l=16;
		}
		//清除点
		if (_tFeature)
		{
			_m.map.removeFeature(_tFeature);
		}
		//画点
		if ( name )
		{
			//s = "S" + (1711+parseInt(t));
			if ( parseInt(t) < 39 )
			{
				s = "S" + (1711+parseInt(t));
			}else{
				switch (parseInt(t)) {
   					case 39:
       					  s = "S1795";
					  break;
				}
			}
			_tFeature = _m.map.addPoint(x,y,name,null,s,{"on":"true","style":"Label01"},null,false);
			_tFeature.element.label.style.zIndex = 10;
		}
	}

	//定位中心点
	function sCentMap(name,x,y,l,t)
	{
		var s;
		if ( !l || l < 0 )
		{
			l=16;
		}
		//清除点
		if (_eFeatures)
		{
			_m.map.removeFeature(_eFeatures);
		}
		//画点
		//s = "S" + (1711+parseInt(t));
		if ( parseInt(t) < 39 )
		{
			s = "S" + (1711+parseInt(t));
		}else{
			switch (parseInt(t)) {
   				case 39:
       				  s = "S1795";
				  break;
			}
		}
		_eFeatures = _m.map.addPoint(x,y,name,null,s,{"on":"true","style":"Label01"},null,false);
		_eFeatures.element.label.style.zIndex = 10;		
		//定位
		_m.coordRecenterTo(x,y,l);
	}

	//撒点
	function sSprPoint(a)
	{
		//var p = eval("g_Jason_"+a);
		//var features=p.fs;
		var features = eval("arySprPt"+a);
		var feature;	
		var x,y
		var pstyle;
		var lstyle;
		var f;

		//清除全部旧点
		_m.clearAll();

		//循环加其它点
		for(var i=0;i<features.length;i++)
		{
			feature = features[i];
			pstyle = parseInt(feature[2]);
			if ( pstyle < 39 )
			{
				pstyle = "S" + (1711+pstyle);
			}else{
				switch (pstyle) {
   					case 39:
       					  pstyle = "S1795";
					  break;
				}
			}
			x = (feature[5]).split(",")[0];
			y = (feature[5]).split(",")[1];
			f = _m.map.addPoint(x,y,feature[1],null,pstyle,{"on":"false","style":"Label01"},null,false);
		}

		//绘制中心点
		var st = g_Jason_House.status;
		var t1,t2,t3;
		x = (g_Jason_House.point).split(",")[0];
		y = (g_Jason_House.point).split(",")[1];
		//绘制中心点
		t1 = jSalingType(st);
		if ( t1 == "g" )
		{
			pstyle = "S1750";
			lstyle = {"on":"true","style":"F26"};
		}
		if ( t1 == "r" ) {
			pstyle = "S1751";
			lstyle = {"on":"true","style":"F25"};
		}
		if ( t1 == "o" )
		{
			pstyle = "S1752";
			lstyle = {"on":"true","style":"F27"};
		}
		if ( t1 == "b" )
		{
			pstyle = "S1880";
			lstyle = {"on":"true","style":"F28"};
		}
		if ( t1 == "p" )
		{
			pstyle = "S1881";
			lstyle = {"on":"true","style":"F29"};
		}

		//价格未知的情况
		var strRprice = g_Jason_House.price;
		if ( strRprice == 0||strRprice == "0元/平方米"||strRprice == "0.0元/平方米" ) {
			strRprice = '价格未知'
		}else{
			strRprice = strRprice + "元/平方米";
		}
		strRprice=strRprice.replace("元/平方米元/平方米","元/平方米");
		t2 = g_Jason_House.caption+" "+strRprice
		f = _m.map.addPoint(x,y,t2,null,pstyle,lstyle,null,false);
		f.element.label.style.zIndex = 10;
		//_m.coordRecenterTo(x,y,14);
	}

	//打开指定文字区并执行撒点
	function sSasp(a)
	{
		var nSelect
		if ( a == "a" )
		{
			sSearchTool('a');
			loadPoiList(g_Jason_Life,"Life");
			sSprPoint('Life');
			Log.send("page=poi&click=Life");
		}
		if ( a == "b" )
		{
			sSearchTool('b');
			loadPoiList(g_Jason_Traffic,"Traffic");
			sSprPoint('Traffic');
			Log.send("page=poi&click=Traffic");
		}
		if ( a == "c" )
		{
			sSearchTool('c');
			loadPoiList(g_Jason_Health,"Health");
			sSprPoint('Health');
			Log.send("page=poi&click=Health");
		}
		if ( a == "d" )
		{
			sSearchTool('d');
			loadPoiList(g_Jason_Education,"Education");
			sSprPoint('Education');
			Log.send("page=poi&click=Education");
		}
		if ( a == "e" )
		{
			sSearchTool('e');
			loadPoiList(g_Jason_Pollution,"Pollution");
			sSprPoint('Pollution');
			Log.send("page=poi&click=Pollution");
		}
		//保存当前选择的菜单项
		_selNowMenu = a;
	}

	//判断销售状态，返回三种色值
	function jSalingType(a)
	{
		var c;
		if ( a == "在售" )
		{
			c = "r"
		}else if ( a == "尾房" )
		{
			c = "r"
		}else if ( a == "待售" )
		{
			c = "r"
		}else{
			c = "p";
		}
		return c;
	}

	function loadInfo()
	{
		var p;
		var t;
		//对象ID
		aryInfoId = g_Jason_House.id;
		//相关参数提交
		el("tenName").innerHTML =  g_Jason_House.caption;
		//document.title = document.title.replace("楼盘名称",g_Jason_House.caption)
		el("nfdp").href = g_Jason_House.url;
		//打开默认显示
		t = "a";
		p = getParam("p");
		if (p=="3"){t="b"};
		if (p=="4"){t="c"};
		if (p=="5"){t="d"};
		if (p=="6"){t="e"};
		sSasp(t);

		//楼盘信息内容
		loadpro(aryInfoId);
	}



/////////////////////////////////////////////
//
//	加载滑动条和相关处理
//
////////////////////////////////////////////

function PanBone(a,b)
{
	if(!a) return;

	var bc=a,_this=this,mh,sliding,bcc=bc.map.container,bot=bc.map.container.offsetTop,bol=bc.map.container.offsetLeft,add=Event.addBuiltInListener,ofw=(bcc.offsetHeight-bcc.clientHeight)/2,ofw=ofw?ofw:0,bpot=bc.map.container.offsetParent.offsetTop,level=18,num=8,sw;minlevel=18;maxlevel=7;
	ofw = 1;

	if(typeof b=="object"){
		mh=b.ms?true:false;
		sliding=b.sliding?true:false;
	};

	lg=function(a){
		var a=a?a:"";
		Event.trigger(_this,"panbone",a);
	} ;

	this.ce=function(o,p){
		var el=document.createElement(o.tag||'div');
		var useSet=el.setAttribute?true:false;
		for(var attr in o){
			if(attr=="tag"||attr=="children"||attr=="cn"||attr=="html"||attr=="style"||typeof o[attr]=="function") continue;
			if(attr=="cls"){
				els(el,o["cls"].split(",")[0],o["cls"].split(",")[1])
				//el.className = o["cls"];
			}else{
				if(useSet) el.setAttribute(attr,o[attr]);
				else el[attr] = o[attr];
			}
		}

		if(o.html){
			el.innerHTML=o.html;
		}
		if(p){
			p.appendChild(el);
		}
		return el;
	}

	this.swMH=function(a,b){
		if(sw&&sw==a) return;
		var cls1,cls2,hy;
		if(a.id=="$boneMap"){
			cls1="BoneMap1";
			cls2="BoneHbd2";
			hy=false;
		} else if(a.id=="$boneHybird"){
			cls1="BoneHbd1";
			cls2="BoneMap2";
			hy=true;
		} 
		a.className=cls1;
		b.className=cls2;
		bc.setHyBird(hy);
		sw=a;
		cls1=cls2=hy=null;
	} 

	this.setEvent=function(a){
		if(a.setCapture)a.setCapture();
		if(window.captureEvents)window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
	} 

	this.releaseEvent=function(a){
		if(a.releaseCapture)a.releaseCapture();
		if(window.releaseEvents)window.releaseEvents(Event.MOUSEMOVE|Event.MOUSEUP);
	} 

	this.isIE=document.all?true:false;

	this.getMC=function(e){
		return _this.isIE?e.clientY+Math.max(document.body.scrollTop,document.documentElement.scrollTop):e.pageY;
	}

	this.edcls=function(a,b,c)
	{
		if ( document.all )
		{
			a.className = b;
		}else{
			if (c)
			{
				a.className = c;
			}else{
				a.className = b;
			}
		}	
	}

	var cre=this.ce;
	var els=this.edcls;
	var sc=cre({cls:"Bone"} ,bcc);
	sc.onselectstart=function()
	{
		return false;
	};

	//缩放的背景
	var o=cre({cls:"BoneOut,BoneOutF"} ,sc);
	if(sliding) var st=cre({cls:"BoneSt,BoneStF"} ,sc);
	var i=cre({cls:"BoneIn,BoneInF"} ,sc);
	if(sliding) {var sl=cre({cls:"BoneSl,BoneSlF"} ,sc);var p=cre({cls:"BonePop2"} ,sc);} 

	cre=null;

	add(o,"click",function(i){var l=bc.getSds().getMplevels();var _top=(bc.getLevelIndex()+1);if(_top<l.length){bc.animateZoomTo(_top);};_stopEvent(i);lg("BoneZOOMOUT");});
	add(i,"click",function(i){var _top=(bc.getLevelIndex()-1);if(_top>=0){bc.animateZoomTo(_top);};_stopEvent(i);lg("BoneZOOMIN");});

	if(sliding){
		var x,y,ox,oyt,oyb;
		var isDrag=false;
		var zb=parseInt(sl.offsetHeight/2+1);
		var ovf=_this.isIE?59:57 

		sl.onmousedown=function(a){
			sl.style.position="absolute";
			bot=bc.map.container.offsetTop;
			bol=bc.map.container.offsetLeft;
			bpot=bc.map.container.offsetParent.offsetTop;
			isDrag=true;
			var d=document;
			if(!a)a=window.event;
			y=a.layerY?a.layerY:a.offsetY;
			oyt=st.offsetTop+ofw;
			oyb=oyt+st.offsetHeight-sl.offsetHeight;
			_this.setEvent(sl);
			var zl;
			d.onmousemove=function(a){
				if(!isDrag) return;
				if(!a)a=window.event;
				var mus=_this.getMC(a);
				if(!a.pageY)a.pageY=mus;
				var ty=a.pageY-y-bot-ofw-bpot-ovf;
				if(ty>oyt&&ty<oyb){
					sl.style.top=ty+"px";
					zl=(sl.offsetTop-st.offsetTop);
				}
			} 
			d.onmouseup=function(a){
				isDrag=false;
				_this.releaseEvent(sl);
				sl.onmousemove=null;
				sl.onmouseup=null;
				d.onselectstart=null;
				if(zl){
					zl=zl 
					zl=Math.abs(parseInt(zl/num)-level);
					try{stf.hidemap();}catch(ErrorX){};
					_this.adjustZOOM(zl);
				} 
				x=y=oyt=oyb=zl=za=null;
			} 
			d.onselectstart=function(){
				return false;
			} 
		} 

		st.onclick=function(a){
			if(!a)a=window.event;
			var py=a.layerY?a.layerY:a.offsetY;
			if(!_this.isIE) py=py-st.offsetTop 
			py=Math.abs(parseInt(py/num)-level);
			try{stf.hidemap();}catch(ErrorX){};
			_this.adjustZOOM(py);
			py=null;
		} 

		st.onmousemove=function(a){
			p.style.position="absolute";
			if(!a)a=window.event;
			var mus=_this.getMC(a);
			bpot=bc.map.container.offsetParent.offsetTop;
			if(!a.pageY)a.pageY=mus;
			var py=a.layerY?a.layerY:a.offsetY;
			if(!_this.isIE) py=py-st.offsetTop 
			py=Math.abs(parseInt(py/num)-level);
			//_this.adjustPOP(py);
			py=null;
		} 

		st.onmouseout=function(a){
			p.style.display="none";
		} 
	} 

	this.adjustPOP=function(a,b){

		var szHtm="";
		var zpop=false;
		var tmp=Math.abs(a-level);
		var za=(tmp+1)*num;

		switch (a){
			case 17:{
				szHtm="街";
				zpop=true;
				break;
			}
			case 14:{
				szHtm="区";
				zpop=true;
				break;
			}
			case 11:{
				szHtm="市";
				zpop=true;
				break;
			} 
			case 8:{
				szHtm="省";
				zpop=true;
				break;
			}
			default:{
				szHtm="";
				zpop=false;
				break;
			} 
		} 

		if(zpop){
			p.innerHTML=szHtm;
			p.style.display="block";
			p.style.top=(za-zb+st.offsetTop-(p.offsetHeight/2)-2)+"px";
		}else{
			p.style.display="none";
		} 
	} 

	this.adjustSL=function(a){

		try{
			//首先判断级别，超出范围就回来
			if ( a>minlevel ){a=minlevel};
			if ( a<maxlevel ){a=maxlevel};
			//调整滑轨
			var tmp=Math.abs(a-level);
			var za=(tmp+1)*num;
			sl.style.top=(za-zb+st.offsetTop)+"px";
			return a;
		} catch(e){} 
	} 

	this.adjustZOOM=function(a){
		bc.map.zoomTo(parseInt(a));
	} 

	this.setHybird=function(a){
		_this.swMH(hb,mp);
	} 

	if(sliding){
		this.adjustSL(bc.getLevelIndex());
		Event.addListener(bc,"sdschange",function(a){_this.adjustSL(bc.getLevelIndex());});
		Event.addListener(bc.map,"zoom",function(a,b){_this.adjustSL(bc.getLevelIndex());});
	}
}



/////////////////////////////////////////////
//
//	加载详细信息
//
////////////////////////////////////////////
//*************************************************************************************************************
//var serverPath = "http://10.11.26.136:8080/RTCutServer/iengine";
var serverPath = "http://lspengine.go2map.com/StoreEstateServer/iengine";
var strBusSearch = "http://map.sogou.com/?#s=m==bus!!fromtype==name!!totype==coord!!start==#p1!!end==#p2!!from==#p1!!to==#p3!!appid==#p4";
var strNavSearch = "http://map.sogou.com/?#s=m==nav!!fromtype==name!!totype==coord!!start==#p1!!end==#p2!!from==#p1!!to==#p3!!appid==#p4";

//获取楼盘属性
function loadpro(a)
{
	if(g_Jason_House.status=="在售"||g_Jason_House.status=="尾房"||g_Jason_House.status== "待售"){
		source=1;
	}else{
		source=2;
	}
	var url;
	if ( a )
	{
		url = "id="+a;
		url += "&source="+source+"&list=0";
		//城市
		url += "&m=" + _cityInfo.abbr;
		//回调
		url += "&cb=SearchCallBack"
		//完整串
		url = serverPath + "?" + url;
		//url = serverPath + "?" + url;
		//提交
		var sa = document.createElement('SCRIPT');
		sa.setAttribute( 'src', url );
		document.body.appendChild(sa);
	}
}

//回调函数
function SearchCallBack(a)
{
	var strCaption;
	var strLink;
	var strAddress;
	var strPhone;
	var strSalinglink;
	var strRprice;
	var strRdate;
	var strProperty;
	var strArchitecture;
	var strClosedate;
	var strBuilder;
	var strRealpic;
	var strRoompic;
	var strSchools;
	var intStarLength = 16;
	//uid
	id = a.id
	//拼写地址
	//strAddress = a.city + a.district + " " + a.address;
	strAddress = a.district + " " + a.address;
	si("spAddress",strAddress);
	//拼写电话
	strPhone = a.tel;
	si("spPhone",strPhone);
	//销售动态
	//strSalinglink = a.saling_link;
	//el("spSalinglink").href=strSalinglink;
	//el("spSalinglink").target="_blank";
	//更新事件
	strRdate = a.date;
	si("spRdate",strRdate);
	//物业
	strProperty = a.property;
	si("spProperty",strProperty);
	//建筑类型
	//strArchitecture = a.architecture;
	//si("spArchitecture",strArchitecture);
	//入住时间
	strClosedate = a.closedate;
	si("spClosedate",strClosedate);
	//销售类型
	//strSale = a.status;
	//si("spSale",strSale);
	//tSale(el("spSale"),strSale);
	tSale(a);
	//地产商
	strBuilder = a.developer;
	si("spBuilder",strBuilder);
	//外景图
	strRealpic = a.viewlink;
	el("spRealpic").href=strRealpic;
	el("spRealpic").target="_blank";
	//户型图
	strRoompic = a.layoutlink;
	el("spRoompic").href=strRoompic;
	el("spRoompic").target="_blank";
	//学校
	strSchools = a.schools;
	si("spSchools",strSchools);
	//公交自驾
	caption = a.caption;
	sBNtype("a");
	//准备点击定位
	cx = parseFloat(a.x);
	cy = parseFloat(a.y);
	//拼写标题和详细信息连接
	strCaption = a.caption;
	si("spCaption",strCaption);
	//详情链接
	strLink = a.link;
	if ( strLink ) {
		el("spLink").href=strLink;
		el("spLink").target="_blank";
		
	}else{
		el("spLink").innerHTML = "";
	}

	//使用当前数据更新价格和指数信心
	upDateInfo(a);

	//strTitle = "<span class='tc1'>" + a.caption + "</span><span class='tc2'>  [<a class='tc3' onclick=window.open('" + a.link + "')>详情</a>]</span>"
	setTimeout(setSize,300);
}

function setSize()
{
	//输入框的监听
	aListenerInput();
	//设置标题内容和调整弹出框尺寸
	try{
		//打开显示
		el("infoarea").style.visibility = "visible";
		//调用默认
		sConInfoDiv("o");
		//调整省略
		adjustEllipsis();
	}catch(ErrorX){}
}

//销售状态的颜色
function tSale(a)
{
	var strSale = a.status;
	var strSalinglink = a.saling_link;
	var strRentlink = a.resale_link;
	var tlink = a.link;
	var stRprice;

	if ( strSale == "在售" || strSale == "尾房" || strSale == "待售" )
	{
		//销售状态
		si("spSale","新房");
		el("spSale").style.color= "#29B612";
		//销售信息
		el("spSalinglink").innerHTML = "销售动态";
		el("spSalinglink").href=strSalinglink;
		el("spSalinglink").target="_blank";
		//价格
		strRprice = a.price;
	}else{
		si("spSale","二手房");
		el("spSale").style.color= "#F20105";
		//销售信息
		if ( strRentlink ) { tlink = strRentlink; }
		el("spSalinglink").innerHTML = "租售信息";
		el("spSalinglink").href=tlink;
		el("spSalinglink").target="_blank";
		//价格
		strRprice = a.price;
	}
	
	a.price = strRprice;
	strRprice = parseInt(strRprice);
	if ( strRprice ==0) {
		strRprice = '<font size="3" color="#ff0000"><b>价格未知</b></font>'
	}else{
		strRprice = '<font size="3" color="#ff0000"><b>' + (strRprice+"").replace("元/平方米","") + '</b></font>元/平方米'
	}
	si("spRprice",strRprice);
}

//判断文字区域宽度高度，调整是否使用省略样式
function adjustEllipsis()
{
	var w = el("mcont").offsetWidth;
	var f,t;

	//名称
	f = el("spCaption");
	t = el("sppname").offsetWidth - el("spCaption").offsetWidth;
	sie(f,w-40,t);
	//地址
	f = el("spAddress");
	t = 0;
	sie(f,w,t);
	//物业类型
	f = el("spProperty");
	t = 0;
	sie(f,w,t);
	//入住时间
	f = el("spClosedate");
	t = el("spprec").offsetWidth - el("spClosedate").offsetWidth;
	sie(f,w,t);
	//学校
	f = el("spSchools");
	t = el("sppres").offsetWidth - el("spSchools").offsetWidth;
	sie(f,w,t);
	//开发商
	f = el("spBuilder");
	t = el("sppreb").offsetWidth - el("spBuilder").offsetWidth;
	sie(f,w,t);
}
//判断宽度，应用省略
function sie(a,b,c)
{
	var fw = a.offsetWidth;
	var ow = b - c;
	var pf;
	if ( fw > ow )
	{
		//添加浮动元素，显示省略符号
		tmp = cc("c");
		//父元素
		pf = a.parentNode.parentNode;
		//设置宽度
		tmp.style.position = "absolute";
		tmp.style.left = (pf.offsetLeft+b-15) + "px";
		tmp.style.top = pf.offsetTop + "px";
		tmp.className = "esisfx";
		tmp.innerHTML = "..."
		el("mcont").appendChild(tmp);
		//收回一点
		pf.style.width = ( b - 15 ) + "px";
		pf.style.overflow = "hidden";
		//添加注释
		a.title = a.innerHTML;
	}
}

function sBtype(){sBNtype("b")}
function sNtype(){sBNtype("n")}

function sBNtype(type)
{
	var s = el("spWay");
	var b = el("aBus");
	var n = el("aNav");
	var t = el("txtBN");

	bnType = type;
	if ( type == "n" || type == "a" )
	{
		b.onclick = sBtype;
		b.className = "spc";
		if ( type == "n" )
		{
			n.onclick = null;
			n.className = "spt";
		}
	}
	if ( type == "b" || type == "a" )
	{
		n.onclick = sNtype;
		n.className = "spc";
		if ( type == "b" )
		{
			b.onclick = null;
			b.className = "spt";
		}
	}
	//显示输入框
	s.style.visibility = "visible";

	//关闭显示，全部收起状态
	if ( type == "a" )
	{
		s.style.visibility = "hidden";
	}
}

//输入框的监听
function aListenerInput()
{
	var eventObject;
	//名称查询输入框
	el("txtBN").onkeypress = sSearchNameEnter;
	//为默认文字时清除输入框
	el("txtBN").onclick = function()
	{
		if ( el("txtBN").value == "请指定出发地点" )
		{
			el("txtBN").value = "";
		}
	};
}

//名称条件查询
function sSearchNameEnter()
{
	var eventObject;
	var keyCode;
	if ( window.event )
	{
		eventObject = event;
	}else{
		eventObject = arguments[0];
		//keyCode = eventObject.charCode;
	}
	keyCode = eventObject.keyCode;
	//是回车就提交
	if ( keyCode == 13 )
	{
		sSearchName();
	}
}

//公交换乘和行车路线查询
function sSearchName()
{
	var txtName = el("txtBN").value;
	var url;
	var appid = "1361";
	txtName = txtName.Trim();
	if ( txtName )
	{
		if ( bnType == "b" )
		{
			url = strBusSearch;
		}
		if ( bnType == "n" )
		{
			url = strNavSearch;
		}
		url = url.replace(/#p1/g,txtName);
		url = url.replace(/#p2/g,caption);
		url = url.replace(/#p3/g,cx+","+cy);
		if ( _cityInfo.appid ) { appid = _cityInfo.appid }
		url = url.replace(/#p4/g,appid);
		window.open(url);	
		//设回焦点
		el("txtBN").focus();
	}else{
		alert("请输入查询名称！");
	}
}

//打开关闭浮动详细信息页
function sConInfoDiv(a)
{
	var a1 = el("infotparea_a");
	var a2 = el("infotparea_b");
	var a3 = el("infocontbg");

	//默认关闭
	a1.style.visibility = "hidden";
	a2.style.visibility = "hidden";

	//打开
	if ( a == "o" )
	{
		a2.style.visibility = "visible";
		a3.style.display = "";
		//a2.style.top = a3.offsetHeight + "px";
		Log.send("page=poi&click=detailOpen");
	}
	//关闭
	if ( a == "c" )
	{
		a1.style.visibility = "visible";
		a3.style.display = "none";
		//a1.style.top = "0px";
		Log.send("page=poi&click=detailClose");
	}
}

//使用当前数据更新价格和指数信心
function upDateInfo(a)
{//debugger;
	setScoreInfo(a.SCORE_LIFE,"Life");
	setScoreInfo(a.SCORE_TRAFFIC,"Traffic");
	setScoreInfo(a.SCORE_HEALTH,"Health");
	setScoreInfo(a.SCORE_EDUCATION,"Education");
	setScoreInfo(a.SCORE_POLLUTION,"Pollution");
	g_Jason_House.price = a.price;
	if ( _selNowMenu ){ sSasp(_selNowMenu); }
}

//
function setScoreInfo(a,b)
{
	var conR = el("lv"+b);
	var conE = el("ex"+b);
	var conT = el("tx"+b);
	var temp1;
	var intStarLength = 80;

	//设置星级
	conE.style.width = ( parseInt(a) /100 * intStarLength ) + "px";
	temp1 = parseInt(a);
	temp1 = temp1 + "";
	if ( temp1.length == 1 )
	{
		temp1 = "0"+temp1;
	}
	conT.innerHTML = temp1;
}



//城市信息
var _defCityInfo = { name:"北京",abbr:"bj",appid:"1421" }
var _cityInfo;
function getCityInfo()
{
	try{
		if ( !_nCityInfo.name || !_nCityInfo.abbr ) { return _defCityInfo }
		return _nCityInfo;
  	}catch(e){   
		return _defCityInfo; 
  	}
}

