/**
 * 
 * @description URL类，获取外界URL调用，触发相应的页面动作
 * @author shiqiang@staff.sina.com.cn
 * @lastmodified at 2008/1/7
 * 
 */

 var MapURL = {
 	/*
 	 * 接受浏览器中输入的URL，转码为UTF-8编码
 	 */
	mapInfo:[],
 	getUrl:function(){
		return decodeURI(window.location.href);
	},
	getParam:function(){
		try{
			var urlinfo = this.getUrl().split("?");
			if (urlinfo[1] != "" && urlinfo[1] != "undefined" && urlinfo[1] != null) {
				this.mapInfo = urlinfo[1].split("&");
				return true;
			}else{
				return false;
			}
		}catch(e){
			alert(e);
			return false;
		}
	},
	getKey:function(str){
		return str.split("=")[0];
	},
	getValue:function(str){
		return str.split("=")[1];
	},
	/*
	 * 处理URL的不同请求，做出相应的响应
	 */
	makeURLDecision:function(){
		try{
			if(this.getParam() != false){
				switch(this.getValue(this.mapInfo[0])){
					case "h":
						MapFilter.setOutCondition(this.getKey(this.mapInfo[1]),this.getValue(this.mapInfo[1]));
						break;
					/*
					 * 查询楼盘周边关键词
					 */	
					case "ha":
						MapAbc.centerxySearchDecorator(this.getValue(this.mapInfo[2]),this.getValue(this.mapInfo[1]));
						break;
					case "haro":
						MapAbc.centerxySearchDecorator(this.getValue(this.mapInfo[2]),this.getValue(this.mapInfo[1]),this.getValue(this.mapInfo[3]));
						break;
					case "har":
						MapAbc.centerkeywordSearchProxy(this.getValue(this.mapInfo[1]),this.getValue(this.mapInfo[2]));
						break;
					case "hb":
						var direction = 'end';
						if(!isNull(this.mapInfo[5])){
							direction = this.getValue(this.mapInfo[5]);
						}
													
						MapAbc.busSearchProxy(this.getValue(this.mapInfo[1]),this.getValue(this.mapInfo[2]),this.getValue(this.mapInfo[3]),this.getValue(this.mapInfo[4]),direction);

						if(!isNull(this.mapInfo[6])){
							switch(direction){
								case "start":
									$("_rightbusend").value = this.getValue(this.mapInfo[6]);
									break;
								case "end":
									$("_rightbusstart").value = this.getValue(this.mapInfo[6]);
									break;
							};
						}
						
						break;
					case "hbr":
						var direction = 'end';
						if(!isNull(this.mapInfo[5])){
							direction = this.getValue(this.mapInfo[5]);
						}
													
						MapAbc.busSearchProxy(this.getValue(this.mapInfo[1]),this.getValue(this.mapInfo[2]),this.getValue(this.mapInfo[3]),this.getValue(this.mapInfo[4]),direction);

						if(!isNull(this.mapInfo[6])){
							switch(direction){
								case "start":
									$("_rightbusend").value = this.getValue(this.mapInfo[6]);
									break;
								case "end":
									$("_rightbusstart").value = this.getValue(this.mapInfo[6]);
									break;
							};
						}
						
						MapAbc.busSearchEntrance('change',$('bus_startpoint'),$('bus_endpoint'));
						break;
					case "hd":
						var direction = 'end';
						if(!isNull(this.mapInfo[5])){
							direction = this.getValue(this.mapInfo[5]);
						}							
						
						MapAbc.driveSearchProxy(this.getValue(this.mapInfo[1]),this.getValue(this.mapInfo[2]),this.getValue(this.mapInfo[3]),this.getValue(this.mapInfo[4]),direction);

						if(!isNull(this.mapInfo[6])){
							switch(direction){
								case "start":
									$("_rightbusend").value = this.getValue(this.mapInfo[6]);
									break;
								case "end":
									$("_rightbusstart").value = this.getValue(this.mapInfo[6]);
									break;
							};
						}
						break;
					case "hdr":
						var direction = 'end';
						if(!isNull(this.mapInfo[5])){
							direction = this.getValue(this.mapInfo[5]);
						}							
						
						MapAbc.driveSearchProxy(this.getValue(this.mapInfo[1]),this.getValue(this.mapInfo[2]),this.getValue(this.mapInfo[3]),this.getValue(this.mapInfo[4]),direction);

						if(!isNull(this.mapInfo[6])){
							switch(direction){
								case "start":
									$("_rightbusend").value = this.getValue(this.mapInfo[6]);
									break;
								case "end":
									$("_rightbusstart").value = this.getValue(this.mapInfo[6]);
									break;
							};
						}
						
						MapAbc.driveSearchEntrance($('drive_startpoint'),$('drive_startcitycode'),$('drive_endpoint'),$('drive_endcitycode'));					
						break;
					default:
//						alert('OK');
						break;
				}
			}
		}catch(e){
			alert(e);
		}
	}
 }
