﻿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(sel1, sel2){var sel1Obj = gid(sel1);var sel2Obj = gid(sel2);if (sel1Obj && sel2Obj ){var sel1Value = sel1Obj.value;var sel2Value = sel2Obj.value;var SearchURL = "/searchshop/c"+ sel1Value + "l" + StrCode(sel2Value)+"p0";location.href = SearchURL;}}
function SearchEventClass(sel1, sel2){var sel1Obj = gid(sel1);var sel2Obj = gid(sel2);if (sel1Obj && sel2Obj ){var sel1Value = sel1Obj.value;var sel2Value = sel2Obj.value;var SearchURL = "/searchevent/c"+ sel1Value + "l" + StrCode(sel2Value)+"t0";location.href = SearchURL;}}
function SearchKeyword(sel2, sel3,areacode){
var sel2Obj = gid(sel2);var sel3Obj = gid(sel3);
if (sel2Obj && sel3Obj)
{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="";
if (sel2Value=="address" ||sel2Value=="name" )
{
 SearchURL = "/roughsearchshop/" + sel2Value + "/" + StrCode(sel3Value);
}
else if(sel2Value=="tag")
{
SearchURL = "/tag/" + areacode + "/" + StrCode(sel3Value);
}
else if(sel2Value=="course")
{
SearchURL = "/course/" + areacode + "/" + StrCode(sel3Value);
}


location.href = SearchURL;}}


function SearcheventKeyword(sel2, sel3,areacode){
var sel2Obj = gid(sel2);var sel3Obj = gid(sel3);
if (sel2Obj && sel3Obj)
{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="";
if (sel2Value=="title" )
{
 SearchURL = "/eventtitle/" + areacode + "/" + StrCode(sel3Value);
}
else if(sel2Value=="tag")
{
SearchURL = "/eventtag/" + areacode + "/" + StrCode(sel3Value);
}
else if(sel2Value=="star")
{
SearchURL = "/eventstar/" + areacode + "/" + 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 TellFriendOpen(){	window.open('/tellfriend.aspx?track=1036&localurl='+window.location.pathname,'Share','width=580,height=480,resizable=yes,scrollbars=yes,status=0');}

function TellFriend(type,referid)
{
	ScreenConvert();
	if (type && referid)
	{
		DialogShow("<div id=\"DialogLoading\">正在读取,请稍候...</div>",110,24,124,24);
		var PostData = "do=showtelfriend&type="+type+"&referid="+referid+"" + "&localurl=" + StrCode(window.location.pathname);
		PostRequest(window.location.protocol + "//" + window.location.host + "/ajax/docommon", PostData);
		
		
	}
	else
	{
		DialogShow("<div id=\"DialogLoading\">读取失败,请<a href=\"javascript:DialogHide();\" class=\"BL\">稍候再试</a>...</div>",130,10,134,20);
	}
	
}



function TellFriendOK(type)
{
	var objUserName = gid("UserName");
	var objUserMail = gid("UserMail")
	var objFriendMail = gid("FriendMail")
	var objMailTitle = gid("TelMailTitle")

	var objMailBody = gid("TelMailBody")
	var objDialogValidator = gid("errorshow");
	var objTrackID = gid("teltrackid");
	var objtrackIDText ="0";
	if  (objTrackID.value !="0")
	{
	    objtrackIDText = objTrackID.value;
	} 
	if ( objMailTitle.value == 0)
	{
	   
	     objDialogValidator.innerHTML = "请输入标题";
	    objMailTitle.focus();
	    return false;
	}
	
	if (Trim(objUserName.value).length == 0)
	{
	    objDialogValidator.innerHTML = "请输入姓名";
	    objUserName.focus();
	    return false;
	}
	if (Trim(objUserMail.value).length == 0)
	{
	    objDialogValidator.innerHTML = "请输入邮件地址";
	    objUserMail.focus();
	    return false;
	}
	if (!CheckEmail(objUserMail.value))
	{
	    objDialogValidator.innerHTML = "邮件格式不正确。";	    
	    objUserMail.focus();
	    return false;
	}
	if (Trim(objFriendMail.value).length == 0)
	{
	    objDialogValidator.innerHTML = "请输入好友EMAIL";
	    objFriendMail.focus();
	    return false;
	}
	
	if (!CheckEmail(objFriendMail.value))
	{
	    objDialogValidator.innerHTML = "邮件格式不正确";
	    objFriendMail.focus();
	    return false;
	}
	
	
	
	
	
	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)+"&type="+type+"&trackid="+objtrackIDText;
		DialogShow("<div id=\"DialogLoading\">正在发送,请稍候...</div>",110,10,124,20);
		PostRequest(window.location.protocol + "//" + window.location.host + "/ajax/docommon", PostData);
	}
	else
	{
		DialogShow("<div id=\"DialogLoading\">读取失败,请<a href=\"javascript:DialogHide();\" class=\"BL\">稍候再试</a>...</div>",130,24,134,24);
		return false;
	}
}

function CheckEmail(mail)
{
	
	if (mail.match(/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/))
	{
		return true;
	}
	else
	{
		return false;
	}
}

function Auth(name, url)
{
	ScreenConvert();
	name = UnStrCode(name);
	var AJAX_LoginBody="<div id=\"DialogTitle\"><div id=\"DialogTitleText\">" + name + "</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\">" + name + "，请先登录或快速注册！</div><div id=\"DialogValidator\"></div><div id=\"DialogButtons\"><button id=\"AjaxMainLogin\" onclick=\"location.replace('/login/" + name + "，请先登录?repath=" + url + "');\">立即登录</button>&nbsp;&nbsp;&nbsp;&nbsp;<button id=\"AjaxMainReg\" onclick=\"location.replace('/reg/" + name + "，请先注册?repath=" + url + "');\">快速注册</button>&nbsp;&nbsp;&nbsp;&nbsp;<button id=\"AjaxMainCancle\" onclick=\"return DialogHide();\">取消</button></div>";
	DialogShow(AJAX_LoginBody,250,120,300,150);	
}
				

function Track(id)
{
    var widthpx = window.screen.width;
    var heightpx = window.screen.height;
    
	var PostData = "do=trace&id="+id+"&widthpx="+widthpx+"&heightpx="+heightpx;
	PostRequest(window.location.protocol + "//" + window.location.host + "/ajax/dotrace", PostData);
}

function addFavor(url, title)
{ 
	if(document.all) 
		window.external.AddFavorite(url, title); 
	else if(window.sidebar) 
		window.sidebar.addPanel(title, url, "") 
}
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 + "，请先登录或免费注册！</div><div id=\"DialogValidator\"></div><div id=\"DialogButtons\"><button id=\"AjaxMainReg\" onclick=\"location.replace('/reg/" + Title + "，请先注册?repath=" + StrCode(window.location.pathname) + "');\">免费注册</button>&nbsp;&nbsp;&nbsp;&nbsp;<button id=\"AjaxMainCancle\" onclick=\"return DialogHide();\">取消</button>&nbsp;&nbsp;&nbsp;&nbsp;<button id=\"AjaxMainLogin\" onclick=\"location.replace('/login/" + Title + "，请先登录?repath=" + StrCode(window.location.pathname) + "');\">立即登录</button></div>";DialogShow(AJAX_LoginBody,250,120,300,150); }
function Affirm(title){if(!confirm(title)) return false;}
function baidusearch(keyword){
var strkeyword = StrCode(keyword);
if (gid("txtName"))
    strkeyword=StrCode(gid("txtName").value+" ")+strkeyword;
window.open("http://www.baidu.com/s?ie=utf-8&wd="+strkeyword+"",'123','scrollbars=yes,resizable=yes,toolbar=yes,status=yes,menubar=yes,location=yes,height=500,width=500');

}

function gsearchStar()
{
    var objStar = gid("txtgStar");
 
    var errinfo = gid("ghinfo");
    if (objStar)
    {
        var objStarvalue = objStar.value;
       
        if (objStarvalue.length ==0)
        {
            errinfo.innerHTML = "<span class=\"Error\" >请输入明星的名字</span>";
            objStar.focus();
            return false;
        }
        location.href="/celebrity_s/Name/"+StrCode(objStarvalue);
    }
}

function gsearchBirthday()
{
    var objmonth = gid("_ctl0:SearchBar1:lstgMonth");
    var objday   = gid("_ctl0:SearchBar1:lstgDay");
    var errinfo = gid("ghinfo");
    if (objmonth && objday)
    {
        var monthvalue = objmonth.value;
        var dayvalue = objday.value;
        if (monthvalue ==0)
        {
        errinfo.innerHTML = "<span class=\"Error\" >请输入月份</span>";
        return false;
        }
             
        
        if (dayvalue ==0)
        {
        errinfo.innerHTML = "<span class=\"Error\" >请输入日期</span>";
        return false;
        }
        
        location.href="/celebrity_s/Birthday/"+monthvalue+"-"+dayvalue;
    }
}

function onsubmiting()
{
    ScreenConvert();
    DialogShow("<div id=\"DialogLoading\">信息提交中,请稍候...</div>",110,10,124,20);
}
