<!--
var tips = [
	'<a href=http://help.163.com/07/1123/10/3TVOK6GR00752CLF.html?b08abe1 target="_blank">2.6亿用户正在使用网易免费邮箱。</a><br><a href=http://help.163.com/07/1123/10/3TVOK6GR00752CLF.html?b08abe1 target="_blank">网易邮箱平均每分钟就有240位新注册用户。</a>',
	'<a href=http://help.163.com/07/1123/10/3TVOK6GR00752CLF.html?b08abe1 target="_blank">网易邮箱精准过滤超过98％的垃圾邮件。</a><br><a href=http://help.163.com/07/1123/10/3TVOK6GR00752CLF.html?b08abe1 target="_blank">网易邮箱拥有3G容量，280兆网盘，20兆附件。</a>',
	'<a href=http://help.163.com/07/1123/10/3TVOK6GR00752CLF.html?b08abe1 target="_blank">网易邮箱采用10亿级用户系统，<br>亿兆级存储盘阵，G级国家主干网带宽。</a>',
	/*'<a href=http://help.163.com/07/1123/10/3TVOK6GR00752CLF.html?b08abe1 target="_blank">网易邮箱病毒邮件有效拦截率高达99.8％。</a>',*/
	'<a href=http://help.163.com/07/1123/10/3TVOK6GR00752CLF.html?b08abe1 target="_blank">同等网络环境下，因为采用创新Ajax技术，<br>网易邮箱页面响应时间最高减少90％。</a>'
];
var rnd = Math.round(Math.random()*(tips.length-1));
function setCookie(name, value, isForever) {
	document.cookie = name + "=" + escape(value) + ";domain=163.com" + (isForever?";expires="+  (new Date(2099,12,31)).toGMTString():"");
}
function fSetLogType(){
	var logType = getCookie("logType");
	var selType = document.getElementById("selType");
	switch(logType){
		case "js":
			selType.selectedIndex = "1";
			break;
		case "jy":
			selType.selectedIndex = "2";
			break;
		default:
			selType.selectedIndex = "0";
	}
}
function getCookie(name) {
   var search = name + "="
   if(document.cookie.length > 0) {
      offset = document.cookie.indexOf(search)
      if(offset != -1) {
         offset += search.length
         end = document.cookie.indexOf(";", offset)
         if(end == -1) end = document.cookie.length
         return unescape(document.cookie.substring(offset, end))
      }
      else return ""
   }
}
function saveLoginType(){
		var selType = document.getElementById("selType");
		var txtStyle = document.getElementById("txtStyle");
		switch(selType.value){
			case "js":
				txtStyle.value = "21";
				break;
			case "jy":
				txtStyle.value = "16";
				break;
			default:
				txtStyle.value = selType.value;
		}
		document.cookie = "logType="+ selType.value +";expires="+  (new Date(2099,12,31)).toGMTString() +";domain=mail.163.com";
}

function fLoginFormSubmit(){
	var fm = window.document.login163;
	var user = fm.username;
	user.value = fTrim( user.value); //Trim the input value.

	if( user.value =="") {
		window.alert("\请输入您的用户名 ?");
		user.focus();
		event.returnValue = false;
		return false;
	}	

	if( fm.password.value.length =="") {
		window.alert("\请输入您的密码 ?");
		fm.password.focus();
		event.returnValue = false;
		return false;
	}

	var ati = user.value.indexOf( "@"); 
	if( ati != -1 ){
		user.value = user.value.substring(0, ati);	
	}
	var secure = fm.remUser.checked?true:false;
	var url = fm.secure.checked ? "https://reg.163.com/logins.jsp" : "http://reg.163.com/login.jsp";
	url += "?type=1&url=http://fm163.163.com/coremail/fcg/ntesdoor2?";
	url += "lightweight%3D1%26verifycookie%3D1%26";
	if(secure){
		user.autocomplete="on";
	}else{
		user.autocomplete="off";
	}
	fGetVersion(fm);
	fm.action = url + "language%3D-1%26style%3D" + fm.style.value;
	visitordata.setVals( [fm.username.value,fm.style.value,fm.secure.checked?1:0 ], fm.remUser.checked);
	visitordata.store();
	if(!fm.remUser.checked){
		setCookie('ntes_mail_noremember','true',true);
	}
	return true;
}
function fGetVersion(fm)
{
	try{
		var userAgent = window.navigator.userAgent;
		var AppName = "";
		var Version = "";
		if(userAgent.indexOf("MSIE")>-1){
			AppName   = "msie";	
			Version	= userAgent.replace(/.+MSIE/gi,"").replace(/;.+/gi,"") - 0;	
		}else if(userAgent.toUpperCase().indexOf("FIREFOX")>-1){
			AppName = "firefox";
			Version = userAgent.replace(/.+Firefox\//gi,"").replace(/\(.*\)/g,"") - 0;
		}else if(userAgent.toUpperCase().indexOf("NETSCAPE")>-1){
			AppName = "netscape";
			Version = userAgent.replace(/.+NETSCAPE\//gi,"").replace(/\(.*\)/g,"") - 0;
		}
		if((AppName == "msie" && Version < 5) || (AppName == "firefox" && Version <1) || (AppName == "netscape" && Version<7.2) || userAgent.indexOf("macintosh") != -1 || userAgent.indexOf("konqueror") != -1 || userAgent.indexOf("safari") != -1 || userAgent.indexOf("camino") != -1){
			fm.style.value = "34";
		}
	}catch(e){}
}
function Cookie( document, name, domain )
{
	this.$document = document;
	this.$name = name;
	this.$expiration = new Date(2099,12,31);
	this.$domain = domain;
	this.data = null;
}
Cookie.prototype.store = function()
{
	var cookieval = "";
	if( this.data != null)
	{
		for( var i=0; i<this.data.length;i++)
		{
			cookieval += this.data[i].join(":") + "&";
		}
	}
	if( cookieval != "" && cookieval.charAt( cookieval.length-1) == "&" )
		cookieval = cookieval.substring( 0,cookieval.length-1);
	var cookie = this.$name + "=" + cookieval + ";expires=" + this.$expiration.toGMTString() + ";domain=" + this.$domain;
	window.document.cookie = cookie;
}
Cookie.prototype.load = function()
{
	var allcookies = this.$document.cookie;
	if( allcookies == "") return false;
	var start = allcookies.indexOf( this.$name + "=" );
	if( start == -1) return false;
	start += this.$name.length +1;
	var end = allcookies.indexOf( ";", start );
	if( end == -1) end = allcookies.length;
	var cookieval= allcookies.substring( start, end );
	var a = cookieval.split("&");
	for( var i=0;i<a.length; i++)
		a[i] = a[i].split(':');
	//用户名:风格:安全
	this.data = a;
	return true;
}
Cookie.prototype.setVals = function( a, flag )
{
	if( this.data == null)
	{
		if( flag )
		{	
			this.data = [];
			this.data[0] = a;
		}
	}
	else
	{
		this.data[0][0] = a[0];
		if( flag)
			return;
		else
			this.data = null;
	}
}
function fInitUserName()
{
	var fm = window.document.login163;
	var name = "";
	if( visitordata.data != null)
	{	
		name = visitordata.data[0][0];
		fm.remUser.checked = true;
		fm.username.autocomplete="on";
		//fm.secure.checked = (visitordata.data[0][3]==1);
	}else{
		fm.username.autocomplete="off";
		fm.remUser.checked = getCookie("ntes_mail_noremember")!="true";
	}

	if( name != ""){
		fm.username.value = name;
		fm.password.focus();
	}else{
		fm.username.focus();
	}
}
function fTrim(str)
{
	return str.replace(/(^\s*)|(\s*$)/g, ""); 
}
var visitordata = new Cookie( document, "nts_mail_user", document.domain);
visitordata.load();

function $( id ){return document.getElementById( id );}


	function fEvent(sType,oInput){
		switch (sType){
			case "focus" :
				oInput.isfocus = true;
			case "mouseover" :
				oInput.style.borderColor = '#9ecc00';
				break;
			case "blur" :
				oInput.isfocus = false;
			case "mouseout" :
				if(!oInput.isfocus){
					oInput.style.borderColor='#84a1bd';
				}
				break;
		}
	}


//-->

