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 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 Logout(){PostRequest(window.location.protocol + "//" + window.location.host + "/AJAX_Comm.html", "do=logout");}
function CopyURL(){if (window.clipboardData){var copy = window.location.href;var ok = window.clipboardData.setData("Text", copy);if (ok){alert("已经把当前网址复制到剪贴板，\n\n"+"您可以使用(Ctrl+V或鼠标右键)粘贴功能，\n\n"+"发送到MSN、QQ、Blog或者论坛。\n");}}}
function SelectTagGet(tid, svalue, ktid){var TObj = gid(tid);if (TObj && svalue){var PostData = "do=selecttagget&target=" + StrCode(tid) + "&svalue=" + StrCode(svalue) + "&kt=" + StrCode(ktid);PostRequest(window.location.protocol + "//" + window.location.host + "/AJAX_Comm.html", PostData);}}
function SelectTagInit(tid, sbody){var TObj = gid(tid);if (TObj && sbody){TObj.length = 0;for (var i=0;i<sbody.length;i++){TObj.options[TObj.length] = new Option(HtmlDecode(sbody[i][0]), HtmlDecode(sbody[i][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;if (sel2Value == "0") sel2Value = "";if (sel3Value == "0"){sel3Value = "";}else{sel3Value = "&d=" + sel3Value;}var SearchURL = "/search/m/" + city + "/" + sel1Value + "/" + StrCode(sel2Value + sel3Value);location.href = SearchURL;}}
function SearchKeyword(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;if (!sel3Value){alert("请输入搜索关键字!");sel3Obj.focus();return;}sel3Value = Trim(sel3Value);sel3Value = sel3Value.replace("%","");sel3Value = sel3Value.replace("\"","");var SearchURL = "/search/k/" + city + "/" + sel1Value + "/" + sel2Value + "/" + StrCode(sel3Value);location.href = SearchURL;}}

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("对不起!您的浏览器不支持该功能,请使用Internet Explorer 6.0或FireFox浏览器!");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);}
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 = "#181818";}else{oS.background = "#F0F0F0";}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";}
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 ShowMyDialog( msg )
{
	ScreenConvert();
	msg = UnStrCode(msg);
	var strHtmlCode="<div id=\"DialogTitle\"><div id=\"DialogTitleText\">" + "温馨提示"+ "</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\">" + msg + "</div><div id=\"DialogValidator\"></div><div id=\"DialogButtons\"><button id=\"AjaxMainCancle\" onclick=\"return DialogHide();\">取  消</button></div>";
	DialogShow(strHtmlCode,250,120,260,50);	
}

function emailCheck ( emailStr) 
{		
	var emailPat=/^[-_a-z0-9]+@([_a-z0-9]+\.)+[a-z0-9]{2,3}$/;
	var matchArray=emailStr.match(emailPat);
	if (matchArray==null) 
	{		
		return false;
	}
	return true;
}
function CheckByteLength(_str,_minlen,_maxlen) {
	if (_str == null) return false;
	var l = _str.length;
	var _blen = 0;
	for(i=0; i<l; i++) {
		if ((_str.charCodeAt(i) & 0xff00) != 0) {
			_blen ++;
		}
		_blen ++;
	}
	if (_blen > _maxlen || _blen < _minlen) {
		return false;
	}
	return true;
}

function DialogShowAjax(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 #73A2D6 1px";objDialog.innerHTML = showdata;document.body.appendChild(objDialog);}
function DialogHideAjax(){var objDialog = document.getElementById("DialogMove");if (objDialog) objDialog.style.display = "none";}
function ShowMyDialogAjax( msg )
{		
	var strHtmlCode="<div id=\"DialogTitle\"><div id=\"DialogTitleText\">" + "温馨提示"+ "</div><div id=\"DialogTitleBtn\" onclick=\"return DialogHideAjax();\" 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\">" + msg + "</div>";
	DialogShowAjax(strHtmlCode,250,80,300,80);	
}


// Cookies 操作
function SetCookie(name,value)
{
/*
 *--------------- setCookie(name,value) -----------------
 * setCookie(name,value) 
 * 功能:设置得变量name的值

 * 参数:name,字符串;value,字符串.
 * 实例:setCookie('username','baobao')
 *--------------- setCookie(name,value) -----------------
 */   
    var exp  = new Date();
    exp.setTime(exp.getTime() + 1*60*60*1000);	
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();    
}

function GetCookie(name)
{
/*
 *--------------- getCookie(name) -----------------
 * getCookie(name)
 * 功能:取得变量name的值

 * 参数:name,字符串.
 * 实例:alert(getCookie("baobao"));
 *--------------- getCookie(name) -----------------
 */
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
    if(arr !=null) return unescape(arr[2]); return '';
}

// 验证是否是数字

function isNumber(str){	
	var oneDecimal=false;	
	var oneChar=0;	
	str=str.toString ();	
	for(var i=0;i<str.length;i++){
		
		oneChar=str.charAt(i).charCodeAt(0);		
		// -
		if(oneChar==45){			
			return false;			
		}
		// 小数点

		if(oneChar==46){			
			if(!oneDecimal){				
				oneDecimal=true;				
				continue;	
			}else {				
				return false;	
			}			
		}
		// 数字只能在0和9之间
		if(oneChar<48||oneChar>57){						
			return false;	
		}		
	}
	return true;	
}




