
function StrCode(str) {
	if (encodeURIComponent) {
		return encodeURIComponent(str);
	}
	if (escape) {
		return escape(str);
	}
}
function UnStrCode(str) {
	if (decodeURIComponent) {
		return decodeURIComponent(str);
	}
	if (unescape) {
		return unescape(str);
	}
}
function Trim(s) {	
	var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
	return (m == null) ? "" : m[1];

}
function HtmlEncode(text) {
	var re = {"<":"&lt;", ">":"&gt;", "&":"&amp;", "\"":"&quot;"};
	for (i in re) {
		text = text.replace(new RegExp(i, "g"), re[i]);
	}
	return text;
}
function HtmlDecode(text) {
	var re = {"&lt;":"<", "&gt;":">", "&amp;":"&", "&quot;":"\""};
	for (i in re) {
		text = text.replace(new RegExp(i, "g"), re[i]);
	}
	return text;
}
function gid(id) {
	return document.getElementById ? document.getElementById(id) : null;
}
function gname(name) {
	return document.getElementsByTagName ? document.getElementsByTagName(name) : new Array();
}
var get_e_src = function (e) {
	if (e) {
		return e.target;
	}
	if (window.event) {
		return window.event.srcElement;
	}
	return null;
};
function addEvent(obj, evType, fn, useCapture) {
	if (obj.addEventListener) {
		obj.addEventListener(evType, fn, useCapture);
		return true;
	}
	if (obj.attachEvent) {
		return obj.attachEvent("on" + evType, fn);
	}
	alert("Unable to add event listener for " + evType + " to " + obj.tagName);
}
function Browser() {
	var ua, s, i;
	this.isIE = false;
	this.isNS = false;
	this.isOP = false;
	this.isSF = false;
	ua = navigator.userAgent.toLowerCase();
	s = "opera";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isOP = true;
		return;
	}
	s = "msie";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isIE = true;
		return;
	}
	s = "netscape6/";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isNS = true;
		return;
	}
	s = "gecko";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isNS = true;
		return;
	}
	s = "safari";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isSF = true;
		return;
	}
}
function ClickButton(event, buttonid) {
	var btnObj = gid(buttonid);
	if (btnObj) {
		var e = (event || window.event);
		if (e.keyCode == 13) {
			btnObj.click();
			return false;
		}
	}
	return true;
}
function WarpClass(eID, tID, fID, ev) {
	var eObj = document.getElementById(eID);
	var tObj = document.getElementById(tID);
	var fObj = document.getElementById(fID);
	if (eObj && tObj) {
		if (!tObj.style.display || tObj.style.display == "block") {
			tObj.style.display = "none";
			eObj.className = "Warp";
			if (fObj) {
				fObj.style.display = "none";
			}
		} else {
			tObj.style.display = "block";
			eObj.className = "UnWarp";
			if (ev) {
				eval(ev);
			}
			if (fObj) {
				fObj.style.display = "block";
			}
		}
	}
}
function OpenNewWindow(u, i, w, h, r, s, t) {
	var t = 20;
	var l = 120;
	if (window.screen.height) {
		t = (window.screen.height - h) / 2;
	}
	if (window.screen.width) {
		l = (window.screen.width - w) / 2;
	}
	var win = window.open(u, i, "width=" + w + ",height=" + h + ",resizable=" + (r ? "yes" : "no") + ",scrollbars=" + (s ? "yes" : "no") + ",status=" + (t ? "1" : "0") + ", top=" + t + ", left=" + l);
	if (win) {
		win.focus();
	}
}
function mcl(show, div, btn, over, padd) {
	var objdiv = gid(div);
	var objbtn = gid(btn);
	if (objdiv && objbtn) {
		var browser = new Browser();
		if (show) {
			objdiv.style.display = "block";
			if (browser.isIE && over) {
				var allselect = gname("select");
				for (var i = 0; i < allselect.length; i++) {
					allselect[i].style.visibility = "hidden";
				}
			}
			objdiv.style.top = (objbtn.offsetTop + objbtn.offsetHeight - 2) + "px";
			objdiv.style.left = (objbtn.offsetLeft - (padd ? 0 : 50)) + "px";
		} else {
			objdiv.style.display = "none";
			if (browser.isIE && over) {
				var allselect = gname("select");
				for (var i = 0; i < allselect.length; i++) {
					allselect[i].style.visibility = "visible";
				}
			}
		}
	}
}
function SelectTagGet(svalue, tvalue) {
	if (svalue != null) {
		if (tvalue == "1") {
			location.href =  "/food.jsp?type="+tvalue;
		} else {
			if (tvalue == "2") {
				location.href = "/shopping.jsp?type="+tvalue;
			} else {
				if (tvalue == "3") {
					location.href =  "/life.jsp?type="+tvalue;
				} else {
					if (tvalue == "4") {
						location.href = "/service.jsp?type="+tvalue;
					} else {
						location.href =  "/food.jsp?type=1";
					}
				}
			}
		}
	}
}

function SearchClass(city, sel1, sel2, sel3) {
	var sel1Obj = gid(sel1);
	var sel2Obj = gid(sel2);
	var sel3Obj = gid(sel3);
	if (sel1Obj && sel2Obj && sel3Obj) {
		var sel1Value = sel1Obj.value;
		var sel2Value = sel2Obj.value;
		var sel3Value = sel3Obj.value;
		var aValue="";
		if (sel2Value == "0") {
			sel2Value = "";
		}
		if (sel3Value == "0") {
			sel3Value = "";
		}else if(sel3Value.indexOf("C")!=-1){
			aValue="&aid="+sel3Value.substring(1);
		}else if(sel3Value.indexOf("B")!=-1){
			aValue="&aaid="+sel3Value.substring(1);
		}
		var SearchURL = "/search_m.jsp?type="+sel1Value+"&cid=" + city + 
					"&mid=" + sel1Value + "&mcid=" + sel2Value + aValue;
		location.href = SearchURL;
	}
}
function SearchKeyword(city, sel1, sel2) {
	var sel1Obj = gid(sel1);
	var sel2Obj = gid(sel2);
	if (sel1Obj && sel2Obj) {
		var sel1Value = sel1Obj.value;
		var sel2Value = sel2Obj.value;
		if ((!sel2Value) || sel2Value.indexOf("\u8bf7\u8f93\u5165") >= 0) {
			alert("\u8bf7\u8f93\u5165\u641c\u7d22\u5173\u952e\u5b57!");
			sel2Obj.focus();
			return;
		}
		sel2Value = Trim(sel2Value);
		sel2Value = sel2Value.replace("%", "");
		sel2Value = sel2Value.replace("\"", "");
		var SearchURL = "/search_k/" + city + "/" + sel1Value + "_" + StrCode(sel2Value);
		location.href = SearchURL;
	}
}
function ClickSearchBox(sel) {
	var selObj = gid(sel);
	if (selObj != null && selObj.value.indexOf("\u8bf7\u8f93\u5165") >= 0) {
		selObj.className = "input_01";
		selObj.select();
	}
}
function BlurSearchBox(sel) {
	var selObj = gid(sel);
	if (selObj != null) {
		if (selObj.value.indexOf("\u8bf7\u8f93\u5165") >= 0) {
			selObj.className = "SimpleInputGray";
		}
	}
}
function InitRequest() {
	var C_req = null;
	try {
		C_req = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e) {
		try {
			C_req = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (oc) {
			C_req = null;
		}
	}
	if (!C_req && typeof XMLHttpRequest != "undefined") {
		try {
			C_req = new XMLHttpRequest();
		}
		catch (fa) {
			alert("\u5bf9\u4e0d\u8d77!\u60a8\u7684\u6d4f\u89c8\u5668\u4e0d\u652f\u6301\u8be5\u529f\u80fd,\u8bf7\u4f7f\u7528Internet Explorer 6.0\u6216FireFox\u6d4f\u89c8\u5668!");
			C_req = null;
		}
	}
	return C_req;
}
function PostRequest(url, data) {
	var AjaxRequestObj = InitRequest();
	if (AjaxRequestObj != null) {
		AjaxRequestObj.onreadystatechange = function () {
			if (AjaxRequestObj.readyState == 4 && AjaxRequestObj.responseText) {
				ProcessAjaxData(AjaxRequestObj.responseText);
			}
		};		
		AjaxRequestObj.open("POST", url, true);
		AjaxRequestObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		AjaxRequestObj.send(data);
	}
}
function ProcessAjaxData(data) {
	eval(data);
}
var t_DiglogX, t_DiglogY, t_DiglogW, t_DiglogH;
function DialogLoc() {
	var dde = document.documentElement;
	if (window.innerWidth) {
		var ww = window.innerWidth;
		var wh = window.innerHeight;
		var bgX = window.pageXOffset;
		var bgY = window.pageYOffset;
	} else {
		var ww = dde.offsetWidth;
		var wh = dde.offsetHeight;
		var bgX = dde.scrollLeft;
		var bgY = dde.scrollTop;
	}
	t_DiglogX = (bgX + ((ww - t_DiglogW) / 2));
	t_DiglogY = (bgY + ((wh - t_DiglogH) / 2));
}
function DialogShow(showdata, ow, oh, w, h) {
	var objDialog = document.getElementById("DialogMove");
	if (!objDialog) {
		objDialog = document.createElement("div");
	}
	t_DiglogW = ow;
	t_DiglogH = oh;
	DialogLoc();
	objDialog.id = "DialogMove";
	var oS = objDialog.style;
	oS.display = "block";
	oS.top = t_DiglogY + "px";
	oS.left = t_DiglogX + "px";
	oS.margin = "0px";
	oS.padding = "0px";
	oS.width = w + "px";
	oS.height = h + "px";
	oS.position = "absolute";
	oS.zIndex = "5";
	oS.background = "#FFF";
	oS.border = "solid #000 3px";
	objDialog.innerHTML = showdata;
	document.body.appendChild(objDialog);
}
function DialogHide() {
	ScreenClean();
	var objDialog = document.getElementById("DialogMove");
	if (objDialog) {
		objDialog.style.display = "none";
	}
}
function Track(id) {
	var PostData = "do=track&id=" + id;
	PostRequest(window.location.protocol + "//" + window.location.host + "/AJAX_Comm.aspx", PostData);
}
function HeadSearch(cityid, shoptype) {
	var objKeyword = gid("HeadKeyword");
	if (objKeyword != null) {
		if (objKeyword.value.length == 0 || objKeyword.value.indexOf("\u8bf7\u8f93\u5165") >= 0) {
			ClickSearchBox("HeadKeyword");
			alert("\u8bf7\u8f93\u5165\u5546\u6237\u540d\u3001\u5730\u5740\u7b49\u5173\u952e\u5b57\uff01");
		} else {
			if(shoptype=="4" || shoptype=="5"){
					self.location = "/search_nk.jsp?type="+shoptype+"&cid=" + cityid + "&mid=" + shoptype + "&key=" + Trim(objKeyword.value);
			}else{
				self.location = "/search_k.jsp?type="+shoptype+"&cid=" + cityid + "&mid=" + shoptype + "&key=" + Trim(objKeyword.value);
			}
		}
	}
}
function HeadSearchPromo(cityid) {
	var objKeyword = gid("HeadKeyword");
	if (objKeyword != null) {
		if (objKeyword.value.length == 0 || objKeyword.value.indexOf("\u8bf7\u8f93\u5165") >= 0) {
			ClickSearchBox("HeadKeyword");
			alert("\u8bf7\u8f93\u5165\u5546\u6237\u540d\u3001\u6807\u9898\u7b49\u5173\u952e\u5b57\uff01");
		} else {
			self.location = "/promo/" + cityid + "/search/" + StrCode(Trim(objKeyword.value));
		}
	}
}
function GroupSearch() {
	var objKeyword = gid("HeadKeyword");
	if (objKeyword != null) {
		if (objKeyword.value.length == 0) {
			objKeyword.focus();
			alert("\u8bf7\u8f93\u5165\u5173\u952e\u5b57\uff01");
		} else {
			self.location = "/group/allgroups/" + StrCode(Trim(objKeyword.value));
		}
	}
}
function NeedLogin(Title) {
	ScreenConvert();
	var AJAX_LoginBody = "<div id=\"DialogTitle\"><div id=\"DialogTitleText\">" + Title + "</div><div id=\"DialogTitleBtn\" onclick=\"return DialogHide();\" onmouseover=\"var objShut = document.getElementById('DialogTitleBtn');objShut.style.border='solid 1px #000000';\" onmouseout=\"var objShut = document.getElementById('DialogTitleBtn');objShut.style.border='solid 1px #EEE';\"></div></div><div id=\"DialogContent\">" + Title + "\uff0c\u8bf7\u5148\u767b\u5f55\u6216\u514d\u8d39\u6ce8\u518c\uff01</div><div id=\"DialogValidator\"></div><div id=\"DialogButtons\"><button id=\"AjaxMainReg\" onclick=\"location.replace('/reg/" + Title + "\uff0c\u8bf7\u5148\u6ce8\u518c?redir=" + StrCode(window.location.pathname) + "');\">\u514d\u8d39\u6ce8\u518c</button>&nbsp;&nbsp;&nbsp;&nbsp;<button id=\"AjaxMainLogin\" onclick=\"location.replace('/login/" + Title + "\uff0c\u8bf7\u5148\u767b\u5f55?redir=" + StrCode(window.location.pathname) + "');\">\u7acb\u5373\u767b\u5f55</button>&nbsp;&nbsp;&nbsp;&nbsp;<button id=\"AjaxMainCancle\" onclick=\"return DialogHide();\">\u53d6\u6d88</button></div>";
	DialogShow(AJAX_LoginBody, 250, 120, 300, 150);
}
function ScreenConvert() {
	var browser = new Browser();
	var objScreen = gid("ScreenOver");
	if (!objScreen) {
		var objScreen = document.createElement("div");
	}
	var oS = objScreen.style;
	objScreen.id = "ScreenOver";
	oS.display = "block";
	oS.top = oS.left = oS.margin = oS.padding = "0px";
	if (document.body.clientHeight) {
		var wh = document.body.clientHeight + "px";
	} else {
		if (window.innerHeight) {
			var wh = window.innerHeight + "px";
		} else {
			var wh = "100%";
		}
	}
	oS.width = "100%";
	oS.height = wh;
	oS.position = "absolute";
	oS.zIndex = "3";
	if ((!browser.isSF) && (!browser.isOP)) {
		oS.background = "#cccccc";
	} else {
		oS.background = "#cccccc";
	}
	oS.filter = "alpha(opacity=40)";
	oS.opacity = 40 / 100;
	oS.MozOpacity = 40 / 100;
	document.body.appendChild(objScreen);
	var allselect = gname("select");
	for (var i = 0; i < allselect.length; i++) {
		allselect[i].style.visibility = "hidden";
	}
}
function ScreenClean() {
	var objScreen = document.getElementById("ScreenOver");
	if (objScreen) {
		objScreen.style.display = "none";
	}
	var allselect = gname("select");
	for (var i = 0; i < allselect.length; i++) {
		allselect[i].style.visibility = "visible";
	}
}
function OpenNewWindow(u, i, w, h, r, s, t) {
	window.open(u, i, "width=" + w + ",height=" + h + ",resizable=" + (r ? "yes" : "no") + ",scrollbars=" + (s ? "yes" : "no") + ",status=" + (t ? "1" : "0"));
}
function TellFriendOpen() {
	OpenNewWindow("/tellfriend.aspx?track=1036&localurl=" + window.location.pathname, "Share", 580, 480, 1, 1, 0);
}
function __showEventListener(e) {
	if (!_sc) {
		_sc = true;
		if (document.links) {
			var _dl = document.links;
			var _dlo = null;
			var _dloh = null;
			var _dlot = null;
			for (var i = 0; i < _dl.length; i++) {
				_dlo = _dl[i];
				_dloh = _dlot = null;
				if (_dlo) {
					if (_dlo.href) {
						_dloh = _dlo.href;
					}
					if (_dlo.innerHTML) {
						_dlot = _dlo.innerHTML;
					} else {
						if (_dlo.innerText) {
							_dlot = _dlo.innerText;
						} else {
							if (_dlo.text) {
								_dlot = _dlo.text;
							}
						}
					}
					if (_dloh != null && _dlot != null) {
						__showCount(_dlo, _dloh, _dlot);
					}
				}
			}
		}
	}
}
function __showCount(o, h, t) {
	if (DP_URLMatch.length < 0) {
		return;
	}
	for (var i = 0; i < DP_URLMatch.length; i++) {
		if (location.href.indexOf("http://" + _host + DP_URLMatch[i][0]) > -1 && t == DP_URLMatch[i][1]) {
			o.href = "/redirect/" + DP_URLMatch[i][3] + "?url=" + StrCode(h);
		}
	}
}
function showdiv(Layer1) {
	Layer1.style.filter = "Alpha(opacity=80)";
	Layer1.style.backgroundColor = "#ffcc00";
	Layer1.style.cursor = "hand";
}
function noshowdiv(Layer1) {
	Layer1.style.filter = "Alpha(opacity=30)";
	Layer1.style.backgroundColor = "";
}
function winopen(url) {
	talk = window.open(url, "DisplayWindow", "width=400,height=300,,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,menubar=no,resizable=yes,fullscreen=no");
}

