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.aspx", "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(svalue,tvalue){if(svalue!=null){if(tvalue=="10")location.href = "/" + svalue + "/food";else if(tvalue=="20")location.href = "/" + svalue + "/shopping";else if(tvalue=="30")location.href = "/" + svalue + "/life";else if(tvalue=="40")location.href = "/" + svalue + "/service";else location.href = "/" + svalue + "/food";}}
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 = "#FFFFFF";}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("DialogLoading");if (!objDialog) objDialog = document.createElement("div");t_DiglogW = ow;t_DiglogH = oh;DialogLoc();objDialog.id = "DialogLoading";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 0px";objDialog.innerHTML = showdata;document.body.appendChild(objDialog);}
function DialogFullShow(showdata,ow,oh,w,h){var objDialog = document.getElementById("DialogLoading");if (!objDialog) objDialog = document.createElement("div");t_DiglogW = ow;t_DiglogH = oh;DialogLoc();objDialog.id = "DialogLoading";var oS = objDialog.style;oS.display = "block";oS.top ="0 px";oS.left ="0 px";oS.margin = "0px";oS.padding = "0px";oS.width ="100%";oS.height ="100%";oS.position = "absolute";oS.zIndex = "5";oS.background = "#FFF";oS.border = "solid #000 0px";objDialog.innerHTML = showdata;document.body.appendChild(objDialog);}
function DialogHide(){ScreenClean();var objDialog = document.getElementById("DialogLoading");if (objDialog) objDialog.style.display = "none";}

//告诉朋友
function TellFriendOpen(){	window.open('/tellfriend.aspx?localurl='+window.location.pathname,'Share','width=580,height=480,resizable=yes,scrollbars=yes,status=0');}

function TellFriend(type,typeID)
{
	ScreenConvert();
	if (type && typeID)
	{
		DialogShow("<div id=\"DialogLoading\">正在读取,请稍候...</div>",110,24,124,24);
		var PostData = "do=tfget&type=" + type + "&typeID=" + typeID + "&localurl=" + StrCode(window.location.pathname);
		PostRequest(window.location.protocol + "//" + window.location.host + "/AJAX_Comm.aspx", PostData);
	}
	else
	{
		DialogShow("<div id=\"DialogLoading\">读取失败,请<a href=\"javascript:DialogHide();\" class=\"BL\">稍候再试</a>...</div>",130,10,134,20);
	}
	
}

function TellFriendOK()
{
	var objUserName = gid("UserName");
	var objUserMail = gid("UserMail")
	var objFriendMail = gid("FriendMail")
	var objMailTitle = gid("MailTitle")
	var objMailBody = gid("MailBody")
	//var objDialogValidator = gid("DialogValidator");
	
	if(objUserName && objUserMail && objFriendMail && objMailTitle && objMailBody)
	{
		var PostData = "do=tfsend&UserName=" + StrCode(objUserName.value) + "&UserMail=" + StrCode(objUserMail.value) + "&FriendMail=" + StrCode(objFriendMail.value) + "&MailTitle=" + StrCode(objMailTitle.value) + "&MailBody=" + StrCode(objMailBody.value);
		DialogShow("<div id=\"DialogLoading\">正在发送,请稍候...</div>",110,10,124,20);
		PostRequest(window.location.protocol + "//" + window.location.host + "/AJAX_Comm.aspx", PostData);
	}
	else
	{
		DialogShow("<div id=\"DialogLoading\">读取失败,请<a href=\"javascript:DialogHide();\" class=\"BL\">稍候再试</a>...</div>",130,24,134,24);
		return false;
	}
}

/* innerhtml.js
 * Copyright Ma Bingyao <andot@ujn.edu.cn>
 * Version: 1.9
 * LastModified: 2006-06-04
 * This library is free.  You can redistribute it and/or modify it.
 * http://www.coolcode.cn/?p=117
 */

var global_html_pool = [];
var global_script_pool = [];
var global_script_src_pool = [];
var global_lock_pool = [];
var innerhtml_lock = null;
var document_buffer = "";

function set_innerHTML(obj_id, html, time) {
    if (innerhtml_lock == null) {
        innerhtml_lock = obj_id;
    }
    else if (typeof(time) == "undefined") {
        global_lock_pool[obj_id + "_html"] = html;
        window.setTimeout("set_innerHTML('" + obj_id + "', global_lock_pool['" + obj_id + "_html']);", 10);
        return;
    }
    else if (innerhtml_lock != obj_id) {
        global_lock_pool[obj_id + "_html"] = html;
        window.setTimeout("set_innerHTML('" + obj_id + "', global_lock_pool['" + obj_id + "_html'], " + time + ");", 10);
        return;
    }

    function get_script_id() {
        return "script_" + (new Date()).getTime().toString(36)
          + Math.floor(Math.random() * 100000000).toString(36);
    }

    document_buffer = "";

    document.write = function (str) {
        document_buffer += str;
    }
    document.writeln = function (str) {
        document_buffer += str + "\n";
    }

    global_html_pool = [];

    var scripts = [];
    html = html.split(/<\/script>/i);
    for (var i = 0; i < html.length; i++) {
        global_html_pool[i] = html[i].replace(/<script[\s\S]*$/ig, "");
        scripts[i] = {text: '', src: '' };
        scripts[i].text = html[i].substr(global_html_pool[i].length);
        scripts[i].src = scripts[i].text.substr(0, scripts[i].text.indexOf('>') + 1);
        scripts[i].src = scripts[i].src.match(/src\s*=\s*(\"([^\"]*)\"|\'([^\']*)\'|([^\s]*)[\s>])/i);
        if (scripts[i].src) {
            if (scripts[i].src[2]) {
                scripts[i].src = scripts[i].src[2];
            }
            else if (scripts[i].src[3]) {
                scripts[i].src = scripts[i].src[3];
            }
            else if (scripts[i].src[4]) {
                scripts[i].src = scripts[i].src[4];
            }
            else {
                scripts[i].src = "";
            }
            scripts[i].text = "";
        }
        else {
            scripts[i].src = "";
            scripts[i].text = scripts[i].text.substr(scripts[i].text.indexOf('>') + 1);
            scripts[i].text = scripts[i].text.replace(/^\s*<\!--\s*/g, "");
        }
    }

    var s;
    if (typeof(time) == "undefined") {
        s = 0;
    }
    else {
        s = time;
    }

    var script, add_script, remove_script;

    for (var i = 0; i < scripts.length; i++) {
        var add_html = "document_buffer += global_html_pool[" + i + "];\n";
        add_html += "document.getElementById('" + obj_id + "').innerHTML = document_buffer;\n";
        script = document.createElement("script");
        if (scripts[i].src) {
            script.src = scripts[i].src;
            if (typeof(global_script_src_pool[script.src]) == "undefined") {
                global_script_src_pool[script.src] = true;
                s += 2000;
            }
            else {
                s += 10;
            }
        }
        else {
            script.text = scripts[i].text;
            s += 10;
        }
        script.defer = true;
        script.type =  "text/javascript";
        script.id = get_script_id();
        global_script_pool[script.id] = script;
        add_script = add_html;
        add_script += "document.getElementsByTagName('head').item(0)";
        add_script += ".appendChild(global_script_pool['" + script.id + "']);\n";
        window.setTimeout(add_script, s);
        remove_script = "document.getElementsByTagName('head').item(0)";
        remove_script += ".removeChild(document.getElementById('" + script.id + "'));\n";
        remove_script += "delete global_script_pool['" + script.id + "'];\n";
        window.setTimeout(remove_script, s + 10000);
    }

    var end_script = "if (document_buffer.match(/<\\/script>/i)) {\n";
    end_script += "set_innerHTML('" + obj_id + "', document_buffer, " + s + ");\n";
    end_script += "}\n";
    end_script += "else {\n";
    end_script += "document.getElementById('" + obj_id + "').innerHTML = document_buffer;\n";
    end_script += "innerhtml_lock = null;\n";
    end_script += "}";
    window.setTimeout(end_script, s);
}

function InitAjax()
{
　var ajax=false; 
　try { 
　　ajax = new ActiveXObject("Msxml2.XMLHTTP"); 
　} catch (e) { 
　　try { 
　　　ajax = new ActiveXObject("Microsoft.XMLHTTP"); 
　　} catch (E) { 
　　　ajax = false; 
　　} 
　}
　if (!ajax && typeof XMLHttpRequest!='undefined') { 
　　ajax = new XMLHttpRequest(); 
　} 
　return ajax;
}

function PostRequest(Url,Mod)
{	
　//如果没有把参数newsID传进来
　if (typeof(Url) == 'undefined')
　{
　　return false;
　}
  //实例化Ajax对象
　var AjaxRequestObj = InitAjax();

  

　//使用Get方式进行请求
　

  if (typeof(Mod) != 'undefined')
　{
	
　　//需要进行Ajax的URL地址
　	var url = Url+Mod;
    //获取新闻显示层的位置

    AjaxRequestObj.open("GET", url, true); 

　	var show = document.getElementById(Mod+"_Content"); 
	//获取执行状态

	AjaxRequestObj.onreadystatechange = function() { 
		　　//如果执行是状态正常，那么就把返回的内容赋值给上面指定的层
		if (AjaxRequestObj.readyState == 4 && AjaxRequestObj.status == 200) { 
			//show.innerHTML = AjaxRequestObj.responseText; 
			set_innerHTML(Mod+"_Content", AjaxRequestObj.responseText);
		} 
	}
	
　}else{

	AjaxRequestObj.open("GET", Url, true); 

	var show = document.getElementById("Msg");
	
	AjaxRequestObj.onreadystatechange = function() { 
		　　//如果执行是状态正常，那么就把返回的内容赋值给上面指定的层
		if (AjaxRequestObj.readyState == 4 && AjaxRequestObj.status == 200) { 
			//show.innerHTML = AjaxRequestObj.responseText;
			set_innerHTML(Mod+"_Content", AjaxRequestObj.responseText);
		} 
	}
  }
　//发送空
　AjaxRequestObj.send(null); 
}



function BlockFullCover(Url){
	
	if (typeof(Url) == 'undefined')
	{
	　　return false;
	}
	ScreenConvert();
	DialogFullShow("<div id=\"DialogLoading_Content\" name=\"DialogLoading_Content\" style=\"font-size:9pt;height:24\" >正在读取,请稍候...[<a href=\"#\" onClick=\"DialogHide();\">取消加载</a>]</div>",210,224,224,224);
	PostRequest(Url,"DialogLoading");
}

function BlockCover(Url){
	
	if (typeof(Url) == 'undefined')
	{
	　　return false;
	}
	ScreenConvert();
	DialogShow("<div id=\"DialogLoading_Content\" name=\"DialogLoading_Content\" style=\"font-size:9pt;height:24\" align=\"center\" valign=\"middle\"><br><img src=\"/html/images/info/loading.gif\">&nbsp;&nbsp;正在读取,请稍候...[<a href=\"#\" onClick=\"DialogHide();\">取消加载</a>]</div>",400,324,400,42);
	PostRequest(Url,"DialogLoading");
}

function WishListAction(ActionType, ReferID, WishType, update)
{
	ScreenConvert();
	DialogShow("<div id=\"DialogLoading_Content\">正在读取,请稍候...</div>",110,24,124,24);
	/*if (update == null) update = true;
	update = (update)?1:0;
	if (ActionType != null && ReferID != null && WishType != null)
	{
		var PostData = "do=" + ((ActionType == 0)?"delmsgwishlist":"addwishlist") + "&referid=" + ReferID + "&wishtype=" + WishType + "&update=" + update;
		//PostRequest(window.location.protocol + "//" + window.location.host + "/AJAX_Comm.aspx", PostData);
		PostRequest("center.php?mods=pageajax&block=Mod_Block_myblog","DialogLoading");
	}*/
	PostRequest("center.php?mods=pageajax&block=Mod_Block_myblog","DialogLoading");
}

function BlockShow(msg){
	DialogShow("<div id=\"DialogLoading\"><table width=\"400\" border=\"0\" height=\"240\" cellspacing=\"1\" cellpadding=\"10\" align=\"center\" bgcolor=\"#CCCCCC\"><tr><td bgcolor=\"#FFFFFF\"  align=\"center\">"+msg+"</td></tr></table></div>",400,324,400,42);
}