﻿// JavaScript
// jfp 09-05-13

var MenuRollProperty = function(){}; //菜单滚动配置类
MenuRollProperty.prototype = {
	menu : null,
	leftBut : null,
	scroll : null,
	rightBut : null,
	menuBody : null,
	leftButCss : [],
	rightButCss : [],
	menuWidth : 0,
	butsWidth : 0,
	closedHand : "url(/skins/images/closedhand.cur), url(skins/images/closedhand.cur), auto"
}

var MenuRoll =function(){return this.initialize.apply(this, arguments)}; //菜单滚动控制类
MenuRoll.prototype = {
	initialize : function(menuPro) {
		menuPro.butsWidth = parseInt(menuPro.leftBut.offsetWidth) + parseInt(menuPro.rightBut.offsetWidth);
		this.menuPro = menuPro;
		this.refBodyWidth();
		with(menuPro) {
			menu.onselectstart = function(){return false};
			menu.ondragstart = function(){return false};
			leftBut.onmousedown = function(){this.direction = 2; this.roll()}.bind(this);
			leftBut.onmouseup = function(){this.direction = 0}.bind(this);
			rightBut.onmousedown = function(){this.direction = 1; this.roll()}.bind(this);
			rightBut.onmouseup = function(){this.direction = 0}.bind(this);
			scroll.onmousedown = this.down.bindWithEvent(this);
			scroll.scrollLeft = 0;
		}
	},
	refBodyWidth : function() {
		with(this.menuPro) {
			menuBody.style.width = "10000px";
			menuBody.style.width = (menuBody.children[0].offsetWidth + 1) + "px";
		}
	},
	setMenuWidth : function(width) {
		with(this.menuPro) {
			if(width < butsWidth + 20) width = butsWidth + 20;
			menuWidth = width;
			menu.style.width = width + "px";
			scroll.style.width = (width - butsWidth) + "px";
		}
		this.refButState();
	},
	roll : function() {
		with(this.menuPro) {
			if(this.direction == 1) {
				if(scroll.scrollLeft + 3 < scroll.scrollWidth - scroll.offsetWidth){
					scroll.scrollLeft += 3;
					setTimeout(this.roll.bind(this), 5);
				}else {
					scroll.scrollLeft = scroll.scrollWidth - scroll.offsetWidth;
					this.direction == 0;
				}
			}else if(this.direction == 2) {
				if(scroll.scrollLeft - 3 > 0){
					scroll.scrollLeft -= 3;
					setTimeout(this.roll.bind(this), 5);
				}else {
					scroll.scrollLeft = 0;
					this.direction == 0;
				}
			}
		}
		this.refButState();
	},
	refButState : function() {
		with(this.menuPro) {
			var lCss = leftButCss[(scroll.scrollLeft > 0) ? 1 : 0];
			if(leftBut.className != lCss) leftBut.className = lCss;
			var rCss = rightButCss[(scroll.scrollLeft < scroll.scrollWidth - scroll.offsetWidth) ? 1 : 0];
			if(rightBut.className != rCss) rightBut.className = rCss;
		}
	},
	down : function(event) {
		event = event || window.event;
		if(!event) return;
		
		this.onDown = true;
		this.downX = event.clientX;
		var scroll = this.menuPro.scroll;
		this.downScrollLeft = scroll.scrollLeft;
		
		if(scroll.setCapture) {
			scroll.setCapture();
			if(!scroll.onmousemove){
				scroll.onmousemove = this.move.bindWithEvent(this);
				scroll.onmouseup = this.up.bindWithEvent(this);
			}
		}else {
			this.moveEvent = this.move.bindWithEvent(this);
			this.upEvent = this.up.bindWithEvent(this);
			$attachEvent(document, $EventName.mousemove, this.moveEvent);
			$attachEvent(document, $EventName.mouseup, this.upEvent);
		}
	},
	move : function(event) {
		if(!this.onDown) return;
		event = event || window.event;
		if(!event) return;
		
		var scroll = this.menuPro.scroll;
		if(!this.onMoving) {
			scroll.style.cursor = this.menuPro.closedHand;
			
			if(!this.coverDiv) {
				this.coverDiv = $To($C("div"), scroll);
				this.coverDiv.className = "coverLay";
				this.coverDiv.style.left = scroll.offsetLeft + "px";
				this.coverDiv.style.top = scroll.offsetTop + "px";
				this.coverDiv.style.width = scroll.offsetWidth + "px";
				this.coverDiv.style.height = scroll.offsetHeight + "px";
				this.coverDiv.style.cursor = this.menuPro.closedHand;
			}
			this.coverDiv.style.display = "block";
			
			this.onMoving = true;
		}
		
		var cx = this.downX - event.clientX;
		if(cx > 0) {
			if(this.downScrollLeft + cx < scroll.scrollWidth - scroll.offsetWidth)
				scroll.scrollLeft = this.downScrollLeft + cx;
			else
				scroll.scrollLeft = scroll.scrollWidth - scroll.offsetWidth;
		}else {
			if(this.downScrollLeft + cx > 0)
				scroll.scrollLeft = this.downScrollLeft + cx;
			else
				scroll.scrollLeft = 0;
		}
		this.refButState();
	},
	up : function(event) {
		if(!this.onDown) return;
		event = event || window.event;
		if(!event) return;
		
		if(this.coverDiv) this.coverDiv.style.display = "none";
		
		var scroll = this.menuPro.scroll;
		if(scroll.releaseCapture){
			scroll.releaseCapture();
		}else {
			$detachEvent(document, $EventName.mousemove, this.moveEvent);
			$detachEvent(document, $EventName.mouseup, this.upEvent);
		}
		
		scroll.style.cursor = "default";
		this.onMoving = false;
		this.onDown = false;
	}
}

var NavButton = function(){return this.initialize.apply(this, arguments)}; //导航按钮类
NavButton.prototype = {
	curIndex : 0,
	butCss : ["def", "hov" , "cur"],
	initialize : function(butTemp, curIndex, butCss) {
		this.butTemp = butTemp;
		this.buttons = [];
		if(typeof butCss != "undefined") this.butCss = butCss;
		for(var i=0, j=0; i<butTemp.children.length; i++){
			if(butTemp.children[i].tagName == "LI" || butTemp.children[i].tagName == "INPUT" || butTemp.children[i].tagName == "DIV") {
				this.buttons[this.buttons.length] = butTemp.children[i];
				this.buttons[j].className = this.butCss[0];
				this.buttons[j].onmouseover = this.over;
				this.buttons[j].onmouseout = this.out;
				this.buttons[j].index = j;
				this.buttons[j]._this = this;
				//this.buttons[j].id = "aa";
				this.buttons[j].select = this.select;
				j++;
			}
		}
		this.setCurIndex(curIndex);
	},
	select : function() {
	    this._this.setCurIndex(this.index)
	},
	over : function() {
        if(this.className != this._this.butCss[2]) this.className = this._this.butCss[1];
	},
	out : function() {
        if(this.className == this._this.butCss[1]) this.className = this._this.butCss[0];
	},
	setCurIndex : function(curIndex) {
		if(this.curIndex != curIndex)
			this.buttons[this.curIndex].className = this.butCss[0];
		this.buttons[curIndex].className = this.butCss[2];
		this.curIndex = curIndex;
	}
}

var HDCtrlProperty = function(){}; //左右分隔栏配置类
HDCtrlProperty.prototype = {
	HDLine : null,
	HDLineBut : null,
	panes : [],
	exPaneWidth : 0,
	indexCanEx : 0,
	leftCss : [],
	rightCss : [],
	expand : true
}

var HDCtrl = function(){return this.initialize.apply(this, arguments)}; //左右分隔栏控制
HDCtrl.prototype = {
	initialize : function(HDCtrlPro) {
		this.HDCtrlPro = HDCtrlPro;
		with(HDCtrlPro) {
			HDLineBut.onmouseover = this.over.bind(this);
			HDLineBut.onmouseout = this.out.bind(this);
			HDLineBut.onclick = this.chgExpand.bind(this);
			HDLineBut.onmousedown = function(event) {event=event||window.event;if(event)cancelBubble(event)};
			HDLine.onmousedown = this.down.bindWithEvent(this);
			this.HDLineWidth = HDLine.offsetWidth;
		}
		this.out();
	},
	over : function() {
		with(this.HDCtrlPro) {
			var css = ((indexCanEx == 0 && expand)
									|| (indexCanEx == 1 && !expand)) ? leftCss[1] : rightCss[1];
			if(HDLineBut.className != css) HDLineBut.className = css;
		}
	},
	out : function() {
		with(this.HDCtrlPro) {
			var css = ((indexCanEx == 0 && expand)
									|| (indexCanEx == 1 && !expand)) ? leftCss[0] : rightCss[0];
			if(HDLineBut.className != css) HDLineBut.className = css;
		}
	},
	chgExpand : function() {
		var w;
		with(this.HDCtrlPro) {
			if(expand) {
				panes[indexCanEx].style.display = "none";
				w = panes[indexCanEx ^ 1].offsetWidth + exPaneWidth;
				panes[indexCanEx ^ 1].style.width = (w < 100 ? 100 : w) + "px";
				expand = false;
				if(typeof this.onUnExpand == "function") this.onUnExpand(); // 激发 onUnExpaned 事件
			}else {
				w = panes[indexCanEx ^ 1].offsetWidth - exPaneWidth;
				panes[indexCanEx ^ 1].style.width = (w < 100 ? 100 : w) + "px";
				panes[indexCanEx].style.display = "block";
				expand = true;
				if(typeof this.onExpand == "function") this.onExpand(); // 激发 onExpaned 事件
			}
		}
		if(typeof this.onResized == "function") this.onResized(w); // 激发 onResized 事件, 参数为主 pane 宽度
		this.out();
	},
	down : function(event) {
		event = event || window.event;
		if(!event) return;
		
		this.onDown = true;
		this.downX = event.clientX;
		var HDCtrlPro = this.HDCtrlPro
		var HDLine = HDCtrlPro.HDLine;
		if(!this.moveLine) {
			this.moveLine = $To($C("div"), document.body);
			this.moveLine.className = "moveLine";
			this.moveLine.style.backgroundImage = "url(/skins/images/moveLineBg.gif)";
			this.moveLine.style.cursor = "col-resize"
		}
		with(this.moveLine.style) {
			borderTop = "none";
			left = absoluteX(HDLine) + "px";
			top = absoluteY(HDLine) + "px";
			width = HDLine.offsetWidth - 2 + "px";
			height = HDLine.offsetHeight + "px";;
			display = "block";
		}
		if(this.moveLine.setCapture) {
			if(!this.moveLine.onmousemove){
				this.moveLine.onmousemove = this.move.bindWithEvent(this);
				this.moveLine.onmouseup = this.up.bindWithEvent(this);
			}
			this.moveLine.setCapture();
		}else {
			this.moveEvent = this.move.bindWithEvent(this);
			this.upEvent = this.up.bindWithEvent(this);
			$attachEvent(document, $EventName.mousemove, this.moveEvent);
			$attachEvent(document, $EventName.mouseup, this.upEvent);
		}
		this.tCursor = document.body.style.cursor;
		if(!this.tCursor) this.tCursor = "";
		document.body.style.cursor = "col-resize";
		
		this.position = [];
		this.chg_position = false; this.chg_expand = HDCtrlPro.expand;
		var w = HDCtrlPro.panes[HDCtrlPro.indexCanEx ^ 1].offsetWidth - (HDCtrlPro.expand ? 0 : HDCtrlPro.exPaneWidth);
		if(w > HDCtrlPro.exPaneWidth) {
			this.position[0] = HDCtrlPro.exPaneWidth / 2;
			this.position[1] = HDCtrlPro.exPaneWidth + (w - HDCtrlPro.exPaneWidth) / 2;
			this.position[2] = w + HDCtrlPro.exPaneWidth / 2;
		}else {
			if(HDCtrlPro.indexCanEx == 1)	{
				this.position[0] = w / 2;
				this.position[1] = -1;
				this.position[2] = w + HDCtrlPro.exPaneWidth / 2;
			}else {
				this.position[0] = HDCtrlPro.exPaneWidth / 2;
				this.position[1] = -1;
				this.position[2] = HDCtrlPro.exPaneWidth + w / 2;
			}
		}
	},
	move : function(event) {
		event = event || window.event;
		if(!event) return;
		
		if(!this.onDown) return;
		var cx = event.clientX;
		var HDCtrlPro = this.HDCtrlPro;
		
		var w = HDCtrlPro.panes[HDCtrlPro.indexCanEx ^ 1].offsetWidth - (HDCtrlPro.expand ? 0 : HDCtrlPro.exPaneWidth);
		if(HDCtrlPro.indexCanEx == 1) {
			if(cx <= this.position[0]) {
				this.moveLine.style.left = 0;
				this.chg_position = true; this.chg_expand = false;
			}else if(cx > this.position[2]) {
				this.moveLine.style.left = w + HDCtrlPro.exPaneWidth + "px";
				this.chg_position = false; this.chg_expand = false;
			}else if((this.position[1] == -1 || cx > this.position[1]) && cx <= this.position[2]) {
				this.moveLine.style.left = w + "px";
				this.chg_position = false; this.chg_expand = true;
			}else if(cx <= this.position[1]) {
				this.moveLine.style.left = HDCtrlPro.exPaneWidth + "px";
				this.chg_position = true; this.chg_expand = true;
			}
		}else {
			if(cx <= this.position[0]) {
				this.moveLine.style.left = 0;
				this.chg_position = false; this.chg_expand = false;
			}else if(cx > this.position[2]) {
				this.moveLine.style.left = w + HDCtrlPro.exPaneWidth + "px";
				this.chg_position = true; this.chg_expand = false;
			}else if((this.position[1] == -1 && cx <= this.position[2]) || cx <= this.position[1]) {
				this.moveLine.style.left = HDCtrlPro.exPaneWidth + "px";
				this.chg_position = false; this.chg_expand = true;
			}else if(cx > this.position[1] && cx <= this.position[2]) {
				this.moveLine.style.left = w + "px";
				this.chg_position = true; this.chg_expand = true;
			}
		}
		
	},
	up : function(event) {
		event = event || window.event;
		if(!event) return;
		
		if(!this.onDown) return;
		if(this.moveLine.releaseCapture){
			this.moveLine.releaseCapture();
		}else {
			$detachEvent(document, $EventName.mousemove, this.moveEvent);
			$detachEvent(document, $EventName.mouseup, this.upEvent);
		}
		
		this.moveLine.style.display = "none";
		document.body.style.cursor = this.tCursor;
		
		var HDCtrlPro = this.HDCtrlPro;
		if(this.chg_position) {
			HDCtrlPro.panes[0].swapNode(HDCtrlPro.panes[1]);
			var tempObj = HDCtrlPro.panes[0];
			HDCtrlPro.panes[0] = HDCtrlPro.panes[1];
			HDCtrlPro.panes[1] = tempObj;
			HDCtrlPro.indexCanEx ^= 1;
			if(typeof this.onPositionChanged == "function") this.onPositionChanged();
		}
		if(this.chg_expand != HDCtrlPro.expand) {
			this.chgExpand();
		}
		
		this.onDown = false;
		this.out();
	}
}

var SearchCtrl = function(){return this.initialize.apply(this, arguments)}; // 主搜索控件
SearchCtrl.prototype = {
    initialize : function() {
        this.create();
    },
    create : function() {
        this.showList = [$("trafficSType"), $("trafficSG0"), $("trafficSG2"), $("searchKey"), $("searchBut1")];
        this.searchKey = this.showList[3];
        this.searchBut = $("searchBut");
        this.searchBut1 = this.showList[4];
        this.trafficSBegin = $("trafficSBegin");
        this.trafficSEnd = $("trafficSEnd");
        this.keyWList = {
            "map" : "260px",
            "house" : "260px",
            "news" : "260px",
            "traffic1" : "174px",
            "traffic2" : "109px"
        };
        this.keyWTList = {
            "map" : "sKeywords_map",
            "house" : "sKeywords_xlp",
            "news" : "sLinks_zx",
            "traffic0" : "sKeywords_jt",
            "traffic1" : "sKeywords_jt",
            "traffic2" : "sKeywords_jt"
        };
        this.sTipList = {
            "map" : "建筑 / 企业 / 道路 / 河流",
            "house" : "新楼盘 / 出租房/ 二手房",
            "news" : "新闻 / 行情 / 资讯",
            "traffic1" : "站名,例如:崇安寺",
            "traffic2" : "线路号,例如:105"
        };
        this.searchUrl = {
            "house" : "/rightPage/newHouse/newHouseMore.aspx?keywords={2}"
        };
        this.advSearchUrl = {
            "map" : "",
            "house" : "",
            "news" : "",
            "traffic0" : "/rightPage/bus/bus_default.aspx",
            "traffic1" : "/rightPage/bus/bus_default.aspx",
            "traffic2" : "/rightPage/bus/bus_default.aspx"
        };
        this.showGroup = [];
        this.showGroup["map"] = [3];
        this.showGroup["house"] = [3, 4];
        this.showGroup["news"] = [3];
        this.showGroup["traffic0"] = [0, 1, 4];
        this.showGroup["traffic1"] = [0, 3, 4];
        this.showGroup["traffic2"] = [0, 2, 3, 4];
        
        this.searchBut.onmouseover = function(){this.className = "skin searchBut_Hov"};
        this.searchBut.onmouseout = function(){this.className = "skin searchBut_Def"};
        this.searchBut1.onmouseover = function(){this.className = "skin searchBut1_Hov"};
        this.searchBut1.onmouseout = function(){this.className = "skin searchBut1_Def"};
        this.searchKey.searchCtrl = this;
        this.searchKey.onfocus = function(){
            var searchCtrl = this.searchCtrl;
            if(this.value == searchCtrl.sTipList[searchCtrl.searchType]) {
                this.value = "";
                this.style.color = "#0066CC";
            }
        };
        this.searchKey.onblur = function(){
            var searchCtrl = this.searchCtrl;
            if(this.value == "") {
                this.style.color = "#BBBBBB";
                this.value = searchCtrl.sTipList[searchCtrl.searchType];
            }
        };
        this.trafficSBegin.onfocus = function(){
            if(this.value == "起始地") {
                this.value = "";
                this.style.color = "#0066CC";
            }
        };
        this.trafficSBegin.onblur = function(){
            if(this.value == "") {
                this.style.color = "#BBBBBB";
                this.value = "起始地";
            }
        };
        this.trafficSEnd.onfocus = function(){
            if(this.value == "目的地") {
                this.value = "";
                this.style.color = "#0066CC";
            }
        };
        this.trafficSEnd.onblur = function(){
            if(this.value == "") {
                this.style.color = "#BBBBBB";
                this.value = "目的地";
            }
        };
        this.searchBut.onclick = this.sButClick.bind(this);
        this.searchBut1.onclick = function() {
            if(typeof this.onAdvSearchButClick == "function")
                this.onAdvSearchButClick(this.advSearchUrl[this.searchType]);
        }.bind(this);
        
        this.hotKeywords = $("hotKeywords");
        this.loadKeywords("sKeywords_xlp");
    },
    chgGroup : function(key) {
        this.searchType = key;
        if(key == "traffic0" && $("trafficSType").value != 0)
            $("trafficSType").value = 0;
        var arr = this.showGroup[key];
        for(var i=0; i<this.showList.length; i++) {
            if(this.showList[i]) {
                if(arr.indexOf(i) > -1)
                    this.showList[i].style.display = "";
                else
                    this.showList[i].style.display = "none";
            }
        }
        if(this.searchKey.style.display != "none") {
            this.searchKey.style.width = this.keyWList[key];
            this.searchKey.style.color = "#BBBBBB";
            this.searchKey.value = this.sTipList[key];
        }
        if(this.hotKType != this.keyWTList[key])
            this.loadKeywords(this.keyWTList[key]);
    },
    loadKeywords : function(type) {
        AjaxSend("_type:" + type + "_;", "_page.loadKeywords", function(value, context) {
            this.hotKType = getValue(value, "type");
            this.hotKeywords.innerHTML = (this.hotKType == "sLinks_zx" ? "<span class='t1'>热门链接:</span>" : "<span class='t1'>热门关键字:</span>") + getValue(value, "keywords");
        }.bind(this));
    },
    isEmpty : function(obj) {
        if(obj.value == "") return false;
        if(obj == this.trafficSBegin)
            return obj.value == "起始地";
        else if(obj == this.trafficSEnd)
            return obj.value == "目的地";
        else
            return obj.value == this.sTipList[this.searchType];
    },
    sButClick : function() {
	    if(this.searchType == "traffic0") {
//	        if(this.isEmpty(this.trafficSBegin) || this.isEmpty(this.trafficSEnd)) {
//	            alert("请输入起始地和目的地！");
//	            return false;
//	        }
//            if(this.trafficSBegin.value == this.trafficSEnd.value) {
//                alert("起始地和目的地不能相同！");
//                return false;
//	        }

            if(this.isEmpty(this.trafficSBegin) || this.isEmpty(this.trafficSEnd))
                setRPage("/rightPage/bus/bus_default.aspx?from=" + this.trafficSBegin.value + "&to=" + this.trafficSEnd.value);
            else
    	        setRPage("/rightPage/bus/bus_result.aspx?from=" + this.trafficSBegin.value + "&to=" + this.trafficSEnd.value);
    	    this.trafficSEnd.value = this.trafficSBegin.value = "";
	    }else if(this.searchType == "house") {
	        var keywords;
	        if(this.isEmpty(this.searchKey))
	            keywords = "";
	        else
	            keywords = this.searchKey.value
//	        if(this.isEmpty(this.searchKey)) {
//	            alert("请输入关键字！");
//	            return false;
//	        }
	        
	        setRPage(this.searchUrl[this.searchType].format(keywords), "fangchan", 0);
	        this.searchKey.vlaue = "";
	    }else if(this.searchType == "news") {
//	        if(this.isEmpty(this.searchKey)) {
//	            alert("请输入关键字！");
//	            return false;
//	        }
	        
	        
	    }
	    
//        if(typeof this.onAdvSearchButClick == "function")
//            this.onAdvSearchButClick(this.advSearchUrl[this.searchType]);
    }
}

var TabCtrl = function(){return this.initialize.apply(this, arguments)};
TabCtrl.prototype = {
    initialize : function(parent, mapTemp, title) {
        this.isIE = (navigator.userAgent.indexOf("MSIE") != -1);
        this.parent = parent;
        this.mapTemp = mapTemp;
        
        this.div = $To($C("div", {className : "tabCtrl"}), parent);
        this.div.style.display = "none";
        this.div.onselectstart = function(){return false};
        this.curIndex = 0;
                
        this.tabs = [];
        if(typeof(title) != "string") title = "地图";
        this.createTab(title, mapTemp, true);
        this.createTab("正在加载..", null);
        this.createTab("正在加载..", null);
        
        this.createCloseBut();
    },
    createTab : function(value, element, isCur) {
        var tab = $To($C("div", {className : (isCur ? "tabCtrlBut_cur" : "tabCtrlBut_def")}), this.div);
        $To($C("div", {className : "tabCtrlBut_L", innerHTML : (!this.isIE ? "<img class='tabCtrlBut_imgL' src='skins/blue/" + (isCur ? "tab_cur_L" : "tab_def_L") + ".png' width='8px' height='21px' />" : "")}), tab);
        tab.valueTemp = $To($C("div", {className : "tabCtrlBut_C", innerHTML : value}), tab);
        $To($C("div", {className : "tabCtrlBut_R", innerHTML : (!this.isIE ? "<img class='tabCtrlBut_imgL' src='skins/blue/" + (isCur ? "tab_cur_R" : "tab_def_R") + ".png' width='16px' height='21px' />" : "")}), tab);

        tab._this = this;
        if(!element) {
            element = $To($C("iframe", {frameBorder : 0, width : "100%", height : "100%", src : ""}), this.parent);
            element.style.display = "none";
            element._this = this;
            element._tab = tab;
            if(isIE)
                element.onreadystatechange = this.onReady;
            else
                element.onload = this.onReady;
        }
        tab.element = element;
        tab.onmouseover = this.over;
        tab.onmouseout = this.out;
        tab.onclick = this.click;
        tab.index = this.tabs.length;
        if(isCur) this.curIndex = tab.index;
        this.tabs[this.tabs.length] = tab;
        if(tab.index > 0) {
            tab.style.display = "none";
            tab.ondblclick = this.close;
        }
    },
    onReady : function() {
        if(isIE && this.readyState != "complete") return;
        var win = this.contentWindow, title;
        if(win && typeof win.document != "unknown" && typeof win.document != "undefined")
            title = win.document.title;
        if(!title)
            title = "正在加载...";
        this._this.setTitle(this._tab, title);
    },
    createCloseBut : function() {
        var div = $To($C("div", {className : "tabCtrlCloseBut_def"}), this.div);
        div._this = this;
        if(!this.isIE)
            div.innerHTML = "<img src='skins/blue/tab_close_def.png' width='42px' height='20px' />";
        div.onmouseover = this.over;
        div.onmouseout = this.out;
        div.onclick = this.close;
        
        this.closeBut = div;
    },
    setTitle : function(tab, value) {
        if(typeof tab == "number")
            tab = this.tabs[tab];
        tab.title = value + "(双击关闭)";
        if(value.length > 20)
            value = value.substring(0, 20) + "...";
        tab.valueTemp.innerHTML = value;
    },
    setState : function(obj, state) {
        obj.className = obj.className.replace(/_(def|hov|cur)/, "_" + state);
        if(!isIE) {
            var imgs = obj.getElementsByTagName("img");
            for(var i=0; i<imgs.length; i++) {
                imgs[i].src = imgs[i].src.replace(/_(def|hov|cur)/, "_" + state);
            }
        }
    },
    over : function() {
        if(this._this.curIndex == this.index) return;
        this._this.setState(this, "hov");
    },
    out : function() {
        if(this._this.curIndex == this.index) return;
        this._this.setState(this, "def");
    },
    click : function() {
        if(this._this.curIndex == 0 && this.index != 0) {
            if(typeof this._this.onBeforeMapHidden == "function")
                this._this.onBeforeMapHidden();
        }else if(this._this.curIndex != 0 && this.index == 0){
            if(typeof this._this.onBeforeMapShow == "function")
                this._this.onBeforeMapShow();
        }
    
        var tabs = this._this.tabs, tab;
        var cur = tabs[this._this.curIndex];
        this._this.setState(cur, "def");
        cur.element.style.display = "none";
        
        this._this.setState(this, "cur");
        this.element.style.display = "block";
        this._this.curIndex = this.index;
        this._this.closeBut.style.display = (this.index > 0) ? "block" : "none";
        
        if(typeof this._this.onTabClick == "function")
            this._this.onTabClick(this.index);
    },
    close : function() {
        var tabs = this._this.tabs, tab;
        
        var oldCur = tabs[this._this.curIndex];
        
        for(var i=0, next=0; i<tabs.length; i++)
            if(tabs[i].style.display != "none" && tabs[i] != oldCur)
                next = i;
        tabs[next].onclick();
        
        oldCur.src = "about:blank";
        oldCur.element.style.display = "none";
        oldCur.style.display = "none";
        
        if(next == 0)
            this._this.div.style.display = "none";
    },
    isTabShowed : function(tabIndex) {
	    if(this.div.style.display == "none") return false;
	    if(typeof tabIndex == "number")
	        return (this.tabs[tabIndex].style.display != "none");
	    else
	        return (this.tabs[1].style.display != "none") || (this.tabs[2].style.display != "none");
	},
    showTab : function(index, url) {
        if(!(index >= 0 && index <= 2)) return;

        if(this.div.style.display == "none")
            this.div.style.display = "block";
        if(this.tabs[index].style.display == "none") {
            this.tabs[index].style.display = "block";
            this.tabs[index].element.style.display = "block";
        }
        if(typeof url == "string") {
            this.setTitle(index, "正在加载...");
            try {
	            with(this.tabs[index].element.contentWindow.document) {
	                open();
	                innerHTML = "";
	                close();
	            }
	        }catch(e){}
            if(!url || url == "")
                url = this.tabs[tabId][tabIndex].url;
            if(url.match(/\?/))
                url += "&t=" + new Date().valueOf();
            else
                url += "?t=" + new Date().valueOf();
            this.tabs[index].element.src = url;   
        }
        this.tabs[index].onclick();
    },
    select : function(index) {
        if(typeof index != "number") index = 2;
        else if(index < 0 || index > 2) return;
        if(this.tabs[index].click)
            this.tabs[index].click();
    }
}

var RIfmTab = function(){return this.initialize.apply(this, arguments)}; // 右侧框架内Tab控件
RIfmTab.prototype = {
	initialize : function(ctrlPro) {
		this.rIfmBg = ctrlPro.rIfmBg;
		this.tabTemp = ctrlPro.tabTemp;
		this.rIfm = ctrlPro.rIfm;
		this.tabsDiv = [];
		this.tabs = [];
	},
	isIE : (navigator.userAgent.indexOf("MSIE") != -1),
	stateCss : ["rIfmBorderBg rIfm_noTab", "rIfmBorderBg rIfm_tab"],
	tabCss : ["skin rIfmTab_def", "skin rIfmTab_hov", "skin rIfmTab_cur"],
	curId : "",
	curStateIndex : 0,
	curTabIndex : 0,
	chgState : function(stateIndex) {
	    if(this.curStateIndex == stateIndex) return;
	    this.rIfmBg.className = this.stateCss[stateIndex];
	    this.curStateIndex = stateIndex;
	},
	showTab : function(tabsPro, tabId, tabIndex, url) {
	    try {
	        with(this.rIfm.contentWindow.document) {
	            open();
	            innerHTML = "";
	            close();
	        }
	    }catch(e){}
	
	    this.rIfmBg.className = this.stateCss[1];
	    this.curStateIndex = 1;
	
	    if(this.curId != "") {
	        this.tabsDiv[this.curId].style.display = "none";
	        this.curId = "";
	    }
	    if(typeof tabIndex == "undefined") tabIndex = 0;
	    
	    if(this.tabsDiv[tabId]) {
	        this.tabsDiv[tabId].style.display = "block";
        }else {
	        var tabDiv = this.tabsDiv[tabId] = $To($C("div"), this.tabTemp);
	        var tabs = this.tabs[tabId] = [];
	        var len = tabsPro.length;
	        for(var i=0,tab,div,icon; i<len; i++) {
	            tab = tabs[tabs.length] = $To($C("div", {className : this.tabCss[0]}), tabDiv);
	            if(typeof tabsPro[i].id == "string")
	                tab.id = tabsPro[i].id;
	            tab.index = i;
	            tab.url = tabsPro[i].url;
	            if(!tab.url) tab.url = "";
	            div = $To($C("div", {className : "icon"}), tab);
	            icon = tabsPro[i].icon;
	            if(icon.toLowerCase().endsWith("png")) {
	                if(this.isIE)
	                    div.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + icon + "', sizingMethod='scale')";
	                else {
	                    var img = $To($C("img", {src : icon, width : 20, height : 20}), div);
	                    img.style.textAlign = "center";
	                }
	            }else
	                div.style.background = icon;
	            var label = $To($C("div", {className : "label", innerHTML : tabsPro[i].label}), tab);
	            tab.title = tabsPro[i].title ? tabsPro[i].title : label.innerText;
	            tab.action = tabsPro[i].action;
	            tab.onmouseover = this.over.bindWithEvent(this);
	            tab.onmouseout = this.out.bindWithEvent(this);
	            tab.onclick = this.click.bindWithEvent(this);
	        }
        }
        
	    this.curId = tabId;
	    tab = this.tabs[tabId][tabIndex];
        
        if(!url || url == "")
            url = tab.url;
        if(url.match(/\?/))
            url += "&t=" + new Date().valueOf();
        else
            url += "?t=" + new Date().valueOf();
	    this.rIfm.src = url;
	    this.tabs[tabId][this.curTabIndex].className = this.tabCss[0];
	    tab.className = this.tabCss[2];
        this.curTabIndex = tabIndex;
        
	    if(typeof tab.action == "function")
	        tab.action(tab.id);
	},
	hideTab : function() {
	    this.rIfmBg.className = this.stateCss[0];
	    this.curStateIndex = 0;
	},
	getTab : function(event) {
		var tab = $ele(event);
		
	    while(tab && typeof tab.index == "undefined") {
	        tab = tab.parentNode;
	    }
	    if(!tab) return null;

		return tab;
	},
	over : function(event) {
	    event = event || window.event;
	    var tab = this.getTab(event);
	    if(!tab || this.curTabIndex == tab.index || tab.className == this.tabCss[1]) return;
	    tab.className = this.tabCss[1];
	},
	out : function(event) {
	    event = event || window.event;
	    var tab = this.getTab(event);
	    if(!tab || this.curTabIndex == tab.index || tab.className == this.tabCss[0]) return;
	    tab.className = this.tabCss[0];
	},
	click : function(event) {
	    event = event || window.event;
	    var tab = this.getTab(event);
	    if(!tab) return;
	    var url = tab.url;
        if(url.match(/\?/))
            url += "&t=" + new Date().valueOf();
        else
            url += "?t=" + new Date().valueOf();
	    this.rIfm.src = url;
	    if(typeof tab.action == "function")
	        tab.action(tab.id);
	    if(this.curTabIndex != tab.index) {
	        this.tabs[this.curId][this.curTabIndex].className = this.tabCss[0];
	        tab.className = this.tabCss[2];
	        this.curTabIndex = tab.index;
	    }
	}
}

/*
var InfoDialog = function(){return this.initialize.apply(this, arguments)}; // 大信息窗口
InfoDialog.typeList = ["newHouse", "community"];
InfoDialog.tabConfig = {
    "newHouse" : [
        {label: "简介", url: "info.aspx", selected: true},
        {label: "详情", url: "detail.aspx"},
        {label: "鉴赏", title: "效果图/实景图/户型图", url: "imgs.aspx"},
        {label: "视频", url: "videos.aspx"},
        {label: "物业", title: "物业公司介绍", url: "property.aspx"},
        {label: "开发商", title: "开发商介绍", url: "developer.aspx"},
         //{label: "<a href=# onclick=javascript:alert(id) style='color:ffffff;'>s咨询<a>", url: "developer.aspx"},
         {label: "找周边", url:"about_other.aspx", target: "rightIfm", closeCur: "yes"}
        // {label: "找周边2", url: "about_other.aspx"},
       //{label: "规划", url: "layout.aspx"}, setRPage("/rightPage/house/tenement/more.aspx?"+subValue);
        // {label: "找周边3", url: "about_other.aspx"},//{label: "楼书", url: "about_other.aspx"}
        // {label: "<a target=_blank href=tencent://message/?uin=1370981968&Site=楼盘咨询&Menu=Yes style='color:ffffff;'>咨询<a>", isTitleEvent:true}
    ],
    "community" : [
        {label: "概览", url: "info.aspx", selected: true},
       // {label: "详情", url: "details.aspx"}, 
	{label: "出售", url: "sale.aspx"},
        {label: "出租", url: "tenement.aspx"}
//        {label: "鉴赏", title: "效果图/实景图/户型图", url: "imgs.aspx"},
//        {label: "全景", title: "全景展示", url: "virs.aspx"}
        //{label: "视频", url: "videos.aspx"},
      
        //{label: "价格", url: "price.aspx"}
        //,        {label: "点评", url: "comments.aspx"}
    ]
}
InfoDialog.prototype = {
	initialize : function(type, id) {
        this.create(type);
        this.type = type;
        this.createTabs(type, id);
	},
	isIE : (navigator.userAgent.indexOf("MSIE") != -1),
	create : function(type) {
	    var index = InfoDialog.typeList.indexOf(type);
	    this.div = $To($C("div", {className: "infoDlg"}), document.body);
	    this.topBg = $To($C("div", {className: "infoDlg_skin" + index}), this.div);
	    this.topBg.onmousedown = this.down.bindWithEvent(this);
	    if(!this.isIE)
	        this.topBgImg = $To($C("img", {src: "/images/infoDlg_t_skin" + index + ".png", width: 580, height: 80}), this.topBg);
	    $To($C("div", {className: "bg_c"}), this.div);
	    $To($C("div", {className: "bg_b", innerHTML: (this.isIE ? "" : "<img src='/images/infoDlg_b.png' width='580px' height='43px' />")}), this.div);
	    this.title = $To($C("div", {className: "title"}), this.div);
	    this.closeBut = $To($C("div", {className: "closeBut_def"}), this.topBg);
	    if(!this.isIE)
	        this.closeButImg = $To($C("img", {src: "/images/infoDlg_close_skin" + index + "_def.png", width: 18, height: 18}), this.closeBut);
	    this.closeBut._this = this;
	    with(this.closeBut) {
	        onmouseover = this.over;
	        onmouseout = this.out;
	        onmousedown = function(event) {cancelBubble(event);}
	        onclick = this.hide.bind(this);
	    }
	    this.tab = $To($C("div", {className: "tab"}), this.topBg);
	    this.tabLabelTemp = $To($C("div", {className: "labelTemp"}), this.topBg);
	    
	    this.ifm = $To($C("iframe", {className: "infoDlgIfm", frameBorder: 0}), this.div);
	    
	    $attachEvent(window, $EventName.resize, this.setPosition.bind(this));
	},
	createTabs : function(type, id) {
	    this.removeTabs();
        this.tabs = [];
	    var div, div1, tabsPro = InfoDialog.tabConfig[type], index = InfoDialog.typeList.indexOf(type);
	    for(var i=0,len=tabsPro.length; i<len; i++) {
	        div = $To($C("div", {className: (tabsPro[i].selected ? "but_cur" : "but_def"), innerHTML : (this.isIE ? "" : "<img src='/images/infoDlg_but_skin" + index + "_" + (tabsPro[i].selected ? "cur" : "def") + ".png' />")}), this.tab);
	        div._this = this;
	        div.index = i;
	        div.url = tabsPro[i].url;
	        div.target = tabsPro[i].target;
	        div.closeCur = tabsPro[i].closeCur;
	        
	        div1 = $To($C("div", {className: "infoDlg_label", innerHTML: tabsPro[i].label}), this.tabLabelTemp);
	        if(tabsPro[i].title) div1.title = tabsPro[i].title;
	        div1.onmouseover = div.onmouseover = this.over.bind(div);
	        div1.onmouseout = div.onmouseout = this.out.bind(div);
	        div1.onmousedown = div.onmousedown = function(event) {cancelBubble(event);}
	        div1.onclick = div.onclick = this.click.bind(div);
	        
	        if(tabsPro[i].selected) {
	            this.ifm.src = this.fmtUrl(tabsPro[i].url, type, id);
	            this.defIndex = this.curIndex = i;
	        }
	        this.tabs[i] = div;
	    }
	},
	removeTabs: function() {
	    this.tab.innerHTML = "";
	    this.tabLabelTemp.innerHTML = "";
	},
	fmtUrl : function(url, type, id) {
	    url = "/mapPage/" + type + "/" + url;
        url += (url.match(/\?/) ? "&" : "?") + "id=" + id + "&t=" + new Date().valueOf();
	    return url;
	},
    setState : function(obj, state) {
        obj.className = obj.className.replace(/_(def|hov|cur)/, "_" + state);
        if(!isIE) {
            var imgs = obj.getElementsByTagName("img");
            for(var i=0; i<imgs.length; i++) {
                imgs[i].src = imgs[i].src.replace(/_(def|hov|cur)/, "_" + state);
            }
        }
    },
	over : function() {
	    if(this._this && this.index != this._this.curIndex)
	        this._this.setState(this, "hov");
	},
	out : function() {
	    if(this._this && this.index != this._this.curIndex)
	        this._this.setState(this, "def");
	},
	click : function() {
	    if(this._this.isTitleEvent) return;
	    if(!this.url) return;	    
	    var _this = this._this;
	    var src = _this.fmtUrl(this.url, this._this.type, this._this.id);
	    if(this.target) 
	   
	        $(this.target).src = src; 
	    else
	        _this.ifm.src = src;
	    _this.setState(_this.tabs[_this.curIndex], "def");
	    _this.setState(this, "cur");
	    _this.curIndex = this.index;
	    if(this.closeCur == "yes")
	    {
	        _this.div.style.display = "none";
	        _this.showed = false;
	        addHere(_this.latlng);
	    }
	},
	show : function(type, id, name) {
	    if(!this.type || this.type != type) {
	        var index = InfoDialog.typeList.indexOf(type);
	        this.topBg.className = "infoDlg_skin" + index;
	        if(!this.isIE) {
	            this.topBgImg.src = this.topBgImg.src.replace(/skin\d+/, "skin" + index);
	            this.closeButImg.src = this.closeButImg.src.replace(/skin\d+/, "skin" + index);
	        }
	        this.createTabs(type, id);
	        this.type = type;
	    }
	    
	    this.id = id;
	    this.title.innerHTML = name;
	    this.setPosition();
	    this.tabs[this.defIndex].onclick();
	    this.div.style.display = "block";
	    this.showed = true;
	},
	setPosition : function() {
	    var bodySize = fnGetWindowSize();
	    var l = (bodySize.width - 580) / 2;
	    var t = (bodySize.height - 490) / 2;
	    this.div.style.left = (l < 0 ? 0 : l) + "px";
	    this.div.style.top = (t < 0 ? 0 : t) + "px";
	},
	hide : function() {
	    this.div.style.display = "none";
	    this.showed = false;
	},
    down : function(event) { //当调整对话框大小，位置时鼠标按下时调用方法
		this.onDown = true;
		var moveLine,div = this.div;
		if(!this.moveLine){
			moveLine = this.moveLine = $To($C("div"),div.parentNode); moveLine.className = "moveLine";
			moveLine.style.zIndex = this.zIndex + 1000;
		}else moveLine = this.moveLine;
		
		this.downX = event.clientX;
		this.downY = event.clientY;
		this.downL = div.offsetLeft;
		this.downT = div.offsetTop;
		moveLine.style.left = this.downL + "px";
		moveLine.style.top = this.downT + "px";
		moveLine.style.width = (div.offsetWidth - 2) + "px";
		moveLine.style.height = (div.offsetHeight - 2) + "px";
		moveLine.style.display = "block";
		if(moveLine.setCapture) {
			moveLine.setCapture();
			if(!moveLine.onmousemove){
				moveLine.onmousemove = this.move.bindWithEvent(this);
				moveLine.onmouseup = this.up.bindWithEvent(this);
			}
		}else{
		    if(!this.dialogEventDiv){
		        this.dialogEventDiv = $To($C("div"), document.body);
		        this.dialogEventDiv.className = "dialogEventDiv";
		        this.dialogEventDiv.style.zIndex = this.zIndex + 1001;
		        this.dialogEventDiv.style.cursor = (event.srcElement || event.target).style.cursor;
			    $attachEvent(this.dialogEventDiv, $EventName.mousemove, this.moveMethod = this.move.bindWithEvent(this));
			    $attachEvent(this.dialogEventDiv, $EventName.mouseup, this.upMethod = this.up.bindWithEvent(this));
			}
		}
	},
	move : function(event) { //当调整对话框大小，位置时鼠标移动时调用方法
		if(this.onDown){
			var L,T,moveLine = this.moveLine;
			var cX = event.clientX - this.downX,cY = event.clientY - this.downY;
			L = this.downL + cX;
			T = this.downT + cY;

			if(L < 0) L = 0;
			if(T < 0) T = 0;
			moveLine.style.left = L + "px";
			moveLine.style.top = T + "px";
		}
	},
	up : function(event) { //当调整对话框大小，位置时鼠标松开时调用方法
		if(this.onDown){
			var L,T,moveLine = this.moveLine;
			var cX = event.clientX - this.downX,cY = event.clientY - this.downY;
			L = this.downL + cX;
			T = this.downT + cY;

			if(L < 0) L = 0;
			if(T < 0) T = 0;
			moveLine.style.left = L + "px";
			moveLine.style.top = T + "px";
			this.div.style.display = "none";
			this.div.style.left = L + "px";
			this.div.style.top = T + "px";
			this.div.style.display = "block";
			if(moveLine.releaseCapture){
				moveLine.releaseCapture();
			}else{
			    if(this.dialogEventDiv){
				    $detachEvent(this.dialogEventDiv, $EventName.mousemove, this.moveMethod);
				    $detachEvent(this.dialogEventDiv, $EventName.mouseup, this.upMethod);
				    this.dialogEventDiv.style.display = "none";
				    this.dialogEventDiv.parentNode.removeChild(this.dialogEventDiv);
				    this.dialogEventDiv = null;
				}
			}
			moveLine.style.display = "none";
			this.onDown = false;
		}
	}
}

var ListDialog = function(){return this.initialize.apply(this, arguments)}; // 列表窗口
ListDialog.typeList = ["tenement", "rTenement", "sale", "buy"];
ListDialog.prototype = {
	initialize : function(type) {
        this.create(type);
        this.type = type;
        this.orderArr = ["desc", "asc", "", "desc"];
        
        this.refPrice = this.priceResponse.bind(this);
        this.refList = this.listResponse.bind(this);
	},
	isIE : (navigator.userAgent.indexOf("MSIE") != -1),
	create : function(type) {
	    var index = ListDialog.typeList.indexOf(type);
	    this.div = $To($C("div", {className: "listDlg_skin" + index}), document.body);
	    this.topBg = $To($C("div", {className: "listDlg_t"}), this.div);
	    this.topBg.onmousedown = this.down.bindWithEvent(this);
	    if(!this.isIE)
	        this.topBgImg = $To($C("img", {src: "/images/listDlg_t_skin" + index + ".png", width: 339, height: 40}), this.topBg);
	    $To($C("div", {className: "listDlg_c"}), this.div);
	    $To($C("div", {className: "listDlg_b", innerHTML: (this.isIE ? "" : "<img src='/images/listDlg_b.png' width='339px' height='70px' />")}), this.div);
	    this.closeBut = $To($C("div", {className: "closeBut_def"}), this.topBg);
	    if(!this.isIE)
	        this.closeButImg = $To($C("img", {src: "/images/listDlg_close_skin" + index + "_def.png", width: 18, height: 18}), this.closeBut);
	    this.closeBut._this = this;
	    with(this.closeBut) {
	        onmouseover = this.over;
	        onmouseout = this.out;
	        onmousedown = function(event) {cancelBubble(event);}
	        onclick = this.hide.bind(this);
	    }
	    
	    this.img = $To($C("img", {className: "listDlg_img", src: "/images/blank.gif"}), this.div);
	    this.img.onerror = function(){this.src = "/images/blank.gif"};
	    
	    this.title = $To($C("div", {className: "listDlg_title"}), this.div);
	    this.priceInfo = $To($C("div", {className: "listDlg_priceInfo", innerHTML: "正在加载价格信息..."}), this.div);
	    
	    var bar = $To($C("div", {className: "listDlg_bar"}), this.div);
	    this.count = $To($C("div", {className: "listDlg_count", innerHTML: "正在加载房源信息..."}), bar);
	    
	    this.orderBut = [];
	    this.orderBut[0] = $To($C("div", {id: "updateTime", className: "listDlg_orderBut", innerHTML: "时间<img src='/images/order_def.gif' width='11px' height='10px' />", onclick: this.chgOrderBy}), bar);
	    this.orderBut[1] = $To($C("div", {id: "price", className: "listDlg_orderBut", innerHTML: "价格<img src='/images/order_def.gif' width='11px' height='10px' />", onclick: this.chgOrderBy}), bar);
	    this.orderBut[2] = $To($C("div", {id: "roomArea", className: "listDlg_orderBut", innerHTML: "面积<img src='/images/order_def.gif' width='11px' height='10px' />", onclick: this.chgOrderBy}), bar);
	    this.orderBut[0]._this = this; this.orderBut[1]._this = this; this.orderBut[2]._this = this;

        this.listTemp = $To($C("div", {className: "listDlg_listTemp"}), this.div);
           
	    $attachEvent(window, $EventName.resize, this.setPosition.bind(this));
	},
    setState : function(obj, state) {
        obj.className = obj.className.replace(/_(def|hov|cur)/, "_" + state);
        if(!isIE) {
            var imgs = obj.getElementsByTagName("img");
            for(var i=0; i<imgs.length; i++) {
                imgs[i].src = imgs[i].src.replace(/_(def|hov|cur)/, "_" + state);
            }
        }
    },
	over : function() {
	    if(this._this)
	        this._this.setState(this, "hov");
	},
	out : function() {
	    if(this._this)
	        this._this.setState(this, "def");
	},
	show : function(type, id, name) {
	    if(typeof(type) == "string" && (!this.type || this.type != type)) {
	        var index = ListDialog.typeList.indexOf(type);
	        this.div.className = "listDlg_skin" + index;
	        if(!this.isIE) {
	            this.topBgImg.src = this.topBgImg.src.replace(/skin\d+/, "skin" + index);
	            this.closeButImg.src = this.closeButImg.src.replace(/skin\d+/, "skin" + index);
	        }
	        this.type = type;
	    }
	    
	    if(typeof(name) == "string")
	        this.title.innerHTML = name;
	    if(typeof(id) != "undefined" && this.id != id) {
	        this.loadInfo(type, id, this.orderBy);
	        this.id = id;
	    }
	    this.setPosition();
	    this.div.style.display = "block";
	    this.showed = true;
	},
	setPosition : function() {
	    var bodySize = fnGetWindowSize();
	    var l = (bodySize.width - 339) / 2;
	    var t = (bodySize.height - 350) / 2;
	    this.div.style.left = (l < 0 ? 0 : l) + "px";
	    this.div.style.top = (t < 0 ? 0 : t) + "px";
	},
	hide : function() {
	    this.div.style.display = "none";
	    this.showed = false;
	},
    chgOrderBy : function() {
        var _this = this._this;
        var orderBy = _this.orderArr[_this.orderArr.indexOf(this.order) + 1];

        _this.loadList(_this.type, _this.id, (orderBy != "" ? (this.id + " " + orderBy) : ""));
    },
    chgPage : function(page) {
        this.loadList(this.type, this.id, this.orderBy, page);
    },
	loadInfo : function(_type, _id, _orderBy) {
	    this.loadPrice(_type, _id);
        this.loadList(_type, _id, _orderBy);
	},
	loadPrice : function(_type, _id) { //加载价格信息
	    this.priceInfo.innerHTML = "正在加载价格信息...";
	    AjaxSend({type: _type, id: _id}, "Data.DataLoader.houseInfo_getAvgPrice", this.refPrice);
	},
	loadList : function(_type, _id, _orderBy, _page) { //加载价格信息
	    this.count.innerHTML = "正在加载房源信息...";
	    this.listTemp.innerHTML = "";
	    if(typeof _orderBy != "string") _orderBy = "";
	    if(typeof _page != "number") _page = 1;
	    AjaxSend({type: _type, id: _id, orderBy: _orderBy, page: _page}, "Data.DataLoader.houseInfo_getListByCommunityId", this.refList);
	},
	priceResponse : function(value, context) {
	    this.priceInfo.innerHTML = value;
	},
	listResponse : function(value, context) {
	    if(value == "")
	        this.count.innerHTML = "该小区共有<span style='color:#377BE0'>0</span>套房源";
	    else {
	        this.count.innerHTML = "该小区共有<span style='color:#377BE0'>" + getValue(value, "count") + "</span>套房源";
	        this.listTemp.innerHTML = getValue(value, "list");
	        var orderBy = getValue(value, "orderBy");
	        for(var i=0; i< 3; i++) {
	            var img = this.orderBut[i].getElementsByTagName("img")[0];
	            if(orderBy != "" && orderBy.indexOf(this.orderBut[i].id) > -1) {
	                this.orderBut[i].order = orderBy.replace(/^\w+ /,"");
	                img.src = "/images/order_" + this.orderBut[i].order + ".gif";
	            }else {
	                this.orderBut[i].order = "";
	                img.src =  "/images/order_def.gif";
	            }
	        }
	        this.orderBy = orderBy;
	    }
	},
    down : function(event) { //当调整对话框大小，位置时鼠标按下时调用方法
		this.onDown = true;
		var moveLine,div = this.div;
		if(!this.moveLine){
			moveLine = this.moveLine = $To($C("div"),div.parentNode); moveLine.className = "moveLine";
			moveLine.style.zIndex = this.zIndex + 1000;
		}else moveLine = this.moveLine;
		
		this.downX = event.clientX;
		this.downY = event.clientY;
		this.downL = div.offsetLeft;
		this.downT = div.offsetTop;
		moveLine.style.left = this.downL + "px";
		moveLine.style.top = this.downT + "px";
		moveLine.style.width = (div.offsetWidth - 2) + "px";
		moveLine.style.height = (div.offsetHeight - 2) + "px";
		moveLine.style.display = "block";
		if(moveLine.setCapture) {
			moveLine.setCapture();
			if(!moveLine.onmousemove){
				moveLine.onmousemove = this.move.bindWithEvent(this);
				moveLine.onmouseup = this.up.bindWithEvent(this);
			}
		}else{
		    if(!this.dialogEventDiv){
		        this.dialogEventDiv = $To($C("div"), document.body);
		        this.dialogEventDiv.className = "dialogEventDiv";
		        this.dialogEventDiv.style.zIndex = this.zIndex + 1001;
		        this.dialogEventDiv.style.cursor = (event.srcElement || event.target).style.cursor;
			    $attachEvent(this.dialogEventDiv, $EventName.mousemove, this.moveMethod = this.move.bindWithEvent(this));
			    $attachEvent(this.dialogEventDiv, $EventName.mouseup, this.upMethod = this.up.bindWithEvent(this));
			}
		}
	},
	move : function(event) { //当调整对话框大小，位置时鼠标移动时调用方法
		if(this.onDown){
			var L,T,moveLine = this.moveLine;
			var cX = event.clientX - this.downX,cY = event.clientY - this.downY;
			L = this.downL + cX;
			T = this.downT + cY;

			if(L < 0) L = 0;
			if(T < 0) T = 0;
			moveLine.style.left = L + "px";
			moveLine.style.top = T + "px";
		}
	},
	up : function(event) { //当调整对话框大小，位置时鼠标松开时调用方法
		if(this.onDown){
			var L,T,moveLine = this.moveLine;
			var cX = event.clientX - this.downX,cY = event.clientY - this.downY;
			L = this.downL + cX;
			T = this.downT + cY;

			if(L < 0) L = 0;
			if(T < 0) T = 0;
			moveLine.style.left = L + "px";
			moveLine.style.top = T + "px";
			this.div.style.display = "none";
			this.div.style.left = L + "px";
			this.div.style.top = T + "px";
			this.div.style.display = "block";
			if(moveLine.releaseCapture){
				moveLine.releaseCapture();
			}else{
			    if(this.dialogEventDiv){
				    $detachEvent(this.dialogEventDiv, $EventName.mousemove, this.moveMethod);
				    $detachEvent(this.dialogEventDiv, $EventName.mouseup, this.upMethod);
				    this.dialogEventDiv.style.display = "none";
				    this.dialogEventDiv.parentNode.removeChild(this.dialogEventDiv);
				    this.dialogEventDiv = null;
				}
			}
			moveLine.style.display = "none";
			this.onDown = false;
		}
	}
}
*/

var ListDialog, InfoDialog;
ListDialog = InfoDialog = function(){return this.initialize.apply(this, arguments)};
InfoDialog.prototype = {
	initialize : function() {
	    this.url = "/mapPage/{0}/pop.aspx?id={1}&t={2}";
	    this.div = $To($C("div", {className: "lsitDlgTemp"}), document.body);
	    this.ifm = $To($C("iframe", {className: "lsitDlgIfm", frameBorder: 0, allowTransparency: true, scrolling: "no"}), this.div);
	},
	show : function(type, id) {
	    this.ifm.src = this.url.format(type, id, new Date().valueOf());
	    this.setPosition();
	    this.div.style.display = "block";
	    this.showed = true;
	},
	setPosition : function() {
	    var bodySize = fnGetWindowSize();
	    var l = (bodySize.width - 650) / 2;
	    var t = (bodySize.height - 450) / 2;
	    this.div.style.left = (l < 0 ? 0 : l) + "px";
	    this.div.style.top = (t < 0 ? 0 : t) + "px";
	},
	hide : function() {
	    this.ifm.src = "about:blank";
	    this.div.style.display = "none";
	    this.showed = false;
	},
	down : function(event) { //当调整对话框大小，位置时鼠标按下时调用方法
		this.onDown = true;
		var moveLine,div = this.div;
		if(!this.moveLine){
			moveLine = this.moveLine = $To($C("div"),div.parentNode); moveLine.className = "moveLine";
			moveLine.style.zIndex = this.zIndex + 1000;
		}else moveLine = this.moveLine;
		
		this.downX = event.clientX;
		this.downY = event.clientY;
		this.downL = div.offsetLeft;
		this.downT = div.offsetTop;
		moveLine.style.left = this.downL + "px";
		moveLine.style.top = this.downT + "px";
		moveLine.style.width = (div.offsetWidth - 2) + "px";
		moveLine.style.height = (div.offsetHeight - 2) + "px";
		moveLine.style.display = "block";
		if(moveLine.setCapture) {
			moveLine.setCapture();
			if(!moveLine.onmousemove){
				moveLine.onmousemove = this.move.bindWithEvent(this);
				moveLine.onmouseup = this.up.bindWithEvent(this);
			}
		}else{
		    if(!this.dialogEventDiv){
		        this.dialogEventDiv = $To($C("div"), document.body);
		        this.dialogEventDiv.className = "dialogEventDiv";
		        this.dialogEventDiv.style.zIndex = this.zIndex + 1001;
		        this.dialogEventDiv.style.cursor = (event.srcElement || event.target).style.cursor;
			    $attachEvent(this.dialogEventDiv, $EventName.mousemove, this.moveMethod = this.move.bindWithEvent(this));
			    $attachEvent(this.dialogEventDiv, $EventName.mouseup, this.upMethod = this.up.bindWithEvent(this));
			}
		}
	},
	move : function(event) { //当调整对话框大小，位置时鼠标移动时调用方法
		if(this.onDown){
			var L,T,moveLine = this.moveLine;
			var cX = event.clientX - this.downX,cY = event.clientY - this.downY;
			L = this.downL + cX;
			T = this.downT + cY;

			if(L < 0) L = 0;
			if(T < 0) T = 0;
			moveLine.style.left = L + "px";
			moveLine.style.top = T + "px";
		}
	},
	up : function(event) { //当调整对话框大小，位置时鼠标松开时调用方法
		if(this.onDown){
			var L,T,moveLine = this.moveLine;
			var cX = event.clientX - this.downX,cY = event.clientY - this.downY;
			L = this.downL + cX;
			T = this.downT + cY;

			if(L < 0) L = 0;
			if(T < 0) T = 0;
			moveLine.style.left = L + "px";
			moveLine.style.top = T + "px";
			this.div.style.display = "none";
			this.div.style.left = L + "px";
			this.div.style.top = T + "px";
			this.div.style.display = "block";
			if(moveLine.releaseCapture){
				moveLine.releaseCapture();
			}else{
			    if(this.dialogEventDiv){
				    $detachEvent(this.dialogEventDiv, $EventName.mousemove, this.moveMethod);
				    $detachEvent(this.dialogEventDiv, $EventName.mouseup, this.upMethod);
				    this.dialogEventDiv.style.display = "none";
				    this.dialogEventDiv.parentNode.removeChild(this.dialogEventDiv);
				    this.dialogEventDiv = null;
				}
			}
			moveLine.style.display = "none";
			this.onDown = false;
		}
	}
}
