//////////////////////// effect func below ////////////////////////
function UrlConv(url)
{
	//if(url.href.indexOf("backdoor.jsp")>0)
		//url="http://www.chinaren.com";
	url = url + "";
	var m_url = url;
	var outstring = "";
	var x1 = 0;
	for(x1 = 0 ; x1 < (m_url.length) ; x1++)
	{
		chr = m_url.substr(x1,1);
		if(chr=='&')
		{
			outstring += "%26";
			continue;
		}
		if(chr=='?')
		{
			outstring += "%3F";
			continue;
		}
		if(chr==':')
		{
			outstring += "%3A";
			continue;
		}
		outstring += chr;
	}
	return outstring;
}

function showerror(erricon,errmsg) {
        top.document.location = "http://alumni.chinaren.com/error.jsp?erricon=" + erricon + "&errmsg=" + errmsg + "&url=" + UrlConv(top.window.location);
}

function ChkLogin() {
	if(document.FM.username.value.length<3 || document.FM.username.value.length>32) {
		alert('请输入用户名');
		return false;
	}
	if(document.FM.password.value.length<2 || document.FM.password.value.length>32) {
		alert('请输入密码');
		return false;
	}
	if(document.FM.us[1].checked) {
		document.ts.cn.value=document.FM.username.value;
		document.ts.pw.value=document.FM.password.value;
		document.ts.submit();
		return false;
	}
	if (document.FM.us[2]) {
		if (document.FM.us[2].checked) {
			if(document.FM.username.value.length != 11 || document.FM.username.value<13000000000 || document.FM.username.value>13999999999) {
				alert("请输入正确的11位手机号码!");
				document.FM.username.focus();
				return false;           
			}       
			document.ts.cn.value=document.FM.username.value;
			document.ts.pw.value=document.FM.password.value;
			document.ts.action = "http://sms.sohu.com/sms_login_chinaren.php";
			document.ts.submit();
			return false;
		}
	}
	return true;
}

function ChkLoginUrs() {
	if(document.FM.uid.value.length<3 || document.FM.uid.value.length>32) {
		alert('请输入用户名');
		return false;
	}
	if(document.FM.pwd.value.length<2 || document.FM.pwd.value.length>32) {
		alert('请输入密码');
		return false;
	}
	return true;
}

function trim(str) {
	regExp1 = /^ */;
	regExp2 = / *$/;
	return str.replace(regExp1,'').replace(regExp2,'');
}


//////////////////////// emotion func below ////////////////////////

var emotion_shortcut = ":) #_# 8*) :D :-> :P B_) B_I ^_* :$ :| :( :.( :_( >:( :V *_* :^ :? :! =:| :% :O :X |-) :Z :9 :T :-* *_/ :#| :69 //shuang //qiang //ku //zan //heart //break //F //W //mail //strong //weak //share //phone //mobile //kiss //V //sun //moon //star (!) //TV //clock //gift //cash //coffee //rice //watermelon //tomato //pill //pig //football //shit";
var e_arr = emotion_shortcut.split(" ");

var Emotion_Num = e_arr.length;

var EmotionArray = new Array(Emotion_Num);

for (i=0; i<Emotion_Num; i++) {
	var idx = e_arr[i];
	EmotionArray[idx] = i;
}

var abs_path    =       "<img src=http://images.chinaren.com/product/alumni/htmledit/emotion3/";
var suffix      =       ".gif border=0>";

function getEmotion(idx) {
        document.write(abs_path + EmotionArray[idx] + suffix);
}

function doStr(src) {
	//src = src.replace(/script/i, "noscript");
	src = src.replace(/frame/ig, "noframe");
	src = src.replace(/(flash.tom.com)/ig, " $1");
	var quote = /(:\)|\#_\#|8\*\)|:->|:D|:P|B_\)|B_I|\^_\*|:\$|:\||:\(|:\.\(|:_\(|>:\(|:V|\*_\*|:\^|:\?|:\!|\=:\||:%|:O|:X|\|-\)|:Z|:9|:T|:-\*|\*_\/|:#\||:69|\/\/shuang|\/\/qiang|\/\/ku|\/\/zan|\/\/heart|\/\/break|\/\/F|\/\/W|\/\/mail|\/\/strong|\/\/weak|\/\/share|\/\/phone|\/\/mobile|\/\/kiss|\/\/V|\/\/sun|\/\/moon|\/\/star|\(\!\)|\/\/TV|\/\/clock|\/\/gift|\/\/cash|\/\/coffee|\/\/rice|\/\/watermelon|\/\/tomato|\/\/pill|\/\/pig|\/\/football|\/\/shit)/g;
	var src = src.replace(quote, "<script" + ">getEmotion('$1')</" + "script>");
	document.write(src);
}

function doFlatTxt(src, classuuid) {
	src = src.replace(/script/ig, "noscript");
	src = src.replace(/(flash.tom.com)/ig, " $1");
	if (src.indexOf("求学网")!=-1 || src.toLowerCase().indexOf("qiuxue")!=-1) {
		document.write("校友录提示: 该条留言是广告, 已被系统过滤!");
	} else {
		if (src.indexOf("手机留言:")==0) {
                        src = src.replace("手机留言:", "<a href=javascript:sms_sub_1(1,1,\"" + classuuid + "\") class=cla2>手机留言:</a>");
                }
		var quote = /(:\)|\#_\#|8\*\)|:->|:D|:P|B_\)|B_I|\^_\*|:\$|:\||:\(|:\.\(|:_\(|>:\(|:V|\*_\*|:\^|:\?|:\!|\=:\||:%|:O|:X|\|-\)|:Z|:9|:T|:-\*|\*_\/|:#\||:69|\/\/shuang|\/\/qiang|\/\/ku|\/\/zan|\/\/heart|\/\/break|\/\/F|\/\/W|\/\/mail|\/\/strong|\/\/weak|\/\/share|\/\/phone|\/\/mobile|\/\/kiss|\/\/V|\/\/sun|\/\/moon|\/\/star|\(\!\)|\/\/TV|\/\/clock|\/\/gift|\/\/cash|\/\/coffee|\/\/rice|\/\/watermelon|\/\/tomato|\/\/pill|\/\/pig|\/\/football|\/\/shit)/g;
		var src = src.replace(quote, "<script" + ">getEmotion('$1')</" + "script>");
		document.write(src);
	}
}
//////////////////////// Image to Symbol ////////////////////////

var imgToSymbol = new Array(Emotion_Num);

for (var i in EmotionArray) {
	var idx = "<IMG src=\"http://images.chinaren.com/product/alumni/htmledit/emotion3/" + EmotionArray[i] + ".gif\" border=0>";
	imgToSymbol[idx] = i;
}

function imgToSym(src) {
        var quote = /<IMG src=\"http:\/\/images\.sohu\.com\/product\/alumni\/htmledit\/emotion3\/([0-9][0-9]?)\.gif\" border=0>/g;
        var src = src.replace(quote, function ($1) {return imgToSymbol[$1];});
        return src;
}

//////////////////////// show func below ////////////////////////
String.prototype.equals = function(strTerm) {
	var strToSearch = this;
	strTerm = strTerm;
	if(strToSearch==strTerm)
		return true;
	else
		return false;
}

function showProvincesList() {
	document.write("<select name=prov class=input2 style='width: 80px'>");
	//document.write("<option VALUE=0 >未知地区</option>");
	document.write("<option VALUE=1 selected>北京市</option>");
	document.write("<option VALUE=2>天津市</option>");
	document.write("<option VALUE=3>河北省</option>");
	document.write("<option VALUE=4>山西省</option>");
	document.write("<option VALUE=5>辽宁省</option>");
	document.write("<option VALUE=6>吉林省</option>");
	document.write("<option VALUE=7>上海市</option>");
	document.write("<option VALUE=8>江苏省</option>");
	document.write("<option VALUE=9>浙江省</option>");
	document.write("<option VALUE=10>安徽省</option>");
	document.write("<option VALUE=11>福建省</option>");
	document.write("<option VALUE=12>江西省</option>");
	document.write("<option VALUE=13>山东省</option>");
	document.write("<option VALUE=14>河南省</option>");
	document.write("<option VALUE=15>内蒙古自治区</option>");
	document.write("<option VALUE=16>黑龙江省</option>");
	document.write("<option VALUE=17>湖北省</option>");
	document.write("<option VALUE=18>湖南省</option>");
	document.write("<option VALUE=19>广东省</option>");
	document.write("<option VALUE=20>广西壮族自治区</option>");
	document.write("<option VALUE=21>海南省</option>");
	document.write("<option VALUE=22>四川省</option>");
	document.write("<option VALUE=23>重庆市</option>");
	document.write("<option VALUE=24>台湾省</option>");
	document.write("<option VALUE=25>贵州省</option>");
	document.write("<option VALUE=26>云南省</option>");
	document.write("<option VALUE=27>西藏自治区</option>");
	document.write("<option VALUE=28>陕西省</option>");
	document.write("<option VALUE=29>甘肃省</option>");
	document.write("<option VALUE=30>青海省</option>");
	document.write("<option VALUE=31>宁夏回族自治区</option>");
	document.write("<option VALUE=32>新疆维吾尔族自治区</option>");
	document.write("<option VALUE=33>香港特别行政区</option>");
	document.write("<option VALUE=34>澳门特别行政区</option>");

	document.write("<option VALUE=100>东南亚</option>");
	document.write("<option VALUE=101>欧　洲</option>");
	document.write("<option VALUE=102>南美洲</option>");
	document.write("<option VALUE=103>大洋洲</option>");
	document.write("<option VALUE=104>非　洲</option>");
	document.write("<option VALUE=105>亚　洲</option>");
	document.write("<option VALUE=106>美　国</option>");
	document.write("<option VALUE=107>加拿大</option>");
	document.write("<option VALUE=108>新加坡</option>");
	document.write("<option VALUE=109>韩　国</option>");
	document.write("<option VALUE=110>日　本</option>");

	document.write("</select>");
}

function showHello() {
	var welcomestring;
	var d = new Date();	
	h = d.getHours();
	if(h<6)
		welcomestring="凌晨好";
	else if (h<9)
		welcomestring="早上好";
	else if (h<12)
		welcomestring="上午好";
	else if (h<14)
		welcomestring="中午好";
	else if (h<17)
		welcomestring="下午好";
	else if (h<19)
		welcomestring="傍晚好";
	else if (h<22)
		welcomestring="晚上好";
	else
		welcomestring="夜里好";
	document.write(welcomestring);
}

function login() {
	var theHost = top.window.location.host;
	var theUrl = top.window.location.href;
	if (theHost.indexOf("alumni.sohu.com")>-1)
		theUrl = theUrl.replace(/alumni.sohu.com/gi, "alumni.chinaren.com");
	top.window.location = "http://profile.chinaren.com/zhs/loginTip.jsp?group=alumni&url=" + UrlConv(theUrl);
	//top.document.location = "http://profile.chinaren.com/zhs/login.jsp?group=alumni&url=" + UrlConv(top.window.location);
}

function logout() {
	//top.document.location = "http://profile.chinaren.com/zhs/backdoor.jsp?group=alumni&url=" + UrlConv(top.window.location);
	top.document.location = "http://profile.chinaren.com/zhs/backdoor.jsp?group=alumni&url=http://www.chinaren.com";
}

function logintourl(url) {
	top.document.location = "http://profile.chinaren.com/zhs/login.jsp?group=alumni&url=" + url;
}

function alert_inv()
{
	alert("您不是本班成员，或者您没有登录！");
}

function isEmail(email)
{
        invalidChars = " /;,:{}[]|*%$#!()`<>?";
        if (email == "")
        {
                return false;
        }
        for (i=0; i< invalidChars.length; i++)
        {
                badChar = invalidChars.charAt(i)
                if (email.indexOf(badChar,0) > -1)  {
                        return false;
                }
        }
        atPos = email.indexOf("@",1)
        if (atPos == -1)  {   return false;  }
        if (email.indexOf("@", atPos+1) != -1) {   return false;  }
        periodPos = email.indexOf(".",atPos)
        if(periodPos == -1) {
                return false;  // and at least one "." after the "@"
        }
        if ( atPos +2 > periodPos)  {
                return false;  // and at least one character between "@" and "."
        }
        if ( periodPos +3 > email.length)  {   return false;  }
        return true;
}

function getsmspwd(obj) {
	obj.value = trim(obj.value);
	if(obj.value.length != 11)
	{
		alert("请输入手机号码，或手机号码位数不对！");
		obj.focus();
		return;
	}

	window.open("http://register.mail.sohu.com/reg/SendPass.jsp?mobile=" + obj.value,"","width=200,height=200");
}

function GetCookie(sName) {
	var aCookie = document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++) {
		var aCrumb = aCookie[i].split("=");
		if (sName == aCrumb[0]) 
			return unescape(aCrumb[1]);
	}
	return "";
}

function loginTip(tip) {
	var theHost = top.window.location.host;
	var theUrl = top.window.location.href;
	if (theHost.indexOf("alumni.sohu.com")>-1)
		theUrl = theUrl.replace(/alumni.sohu.com/gi, "alumni.chinaren.com");
	top.document.location = "http://my.chinaren.com/zhs/loginTip.jsp?group=alumni&url=" + UrlConv(theUrl) + "&tip=" + encodeURI(tip);
}

