var _url="http://rlcode.com";
var _loginurl="http://rlcode.com";
var disptype=1;//显示方式 0正常 1长条

var newwindow = 0;//是否打开新窗口 0 不打开 1 打开

function Channel(c_name,c_url,c_loginurl){
	this.c_name = c_name;
	this.c_url = c_url;
	this.c_loginurl = c_loginurl;
	return this;
}

function ChannelList(){
	this.length= 3;
	this[0]=new Channel("WebDisk","http://rlcode.com/webdisk/passport_login.jsp","http://rlcode.com/webdisk/");
	this[1]=new Channel("论坛","http://rlcode.com/forum/passport_login.jsp","http://rlcode.com/forum/");
	this[2]=new Channel("相册","http://rlcode.com/photo/passport_login.jsp","http://rlcode.com/photo/");
//	this[3]=new Channel("购物","http://rlcode.com/mall/cn/passport_login.jsp","http://rlcode.com/mall/");
	return this;	
}

channels = new ChannelList();

function initChannels(channelSelect,defaultVal){
	for(i=0;i<channels.length;i++)
	{
		channelSelect.add(new Option(channels[i].c_name,i));
	}
	if(defaultVal!="")
		channelSelect.value = defaultVal;
}

function hello(obj,msg){
  alert(msg);
  obj.focus();
}

//是否为空
function isempty(obj,msg){
   var r = (obj.value=="");
   if(r)hello(obj,msg);
   return r;
}

function validCheck(reg,obj,msg){
   if(!msg){
     return obj.match(reg);
   }
   var r = validCheck(reg,obj.value);
   if(!r)hello(obj,msg);
   return r;
}

//检查 只能包含中文、字母、数字
function strvalidCheck(obj,msg){
   var reg = /^([^\x00-\x7f]|[a-zA-Z0-9]|[.()~!@#$%^&*_])+$/;
   return validCheck(reg,obj,msg);
}

//email
function emailCheck(obj,msg){
   var reg = /^[_a-z0-9]+@([_a-z0-9]+\.)+[a-z0-9]{2,3}$/;
   return validCheck(reg,obj,msg);
}

function Isemail(obj){
   var reg = /^[_a-z0-9]+@([_a-z0-9]+\.)+[a-z0-9]{2,3}$/;
   return validCheck(reg,obj);
}

	function userlogin(){
		var f = login;
		f.action="http://rlcode.com/passport/user/login.action";
		f.target  = "";
       if(newwindow==1)f.target="_blank";		
		_url = channels[f.channelSelect.value].c_url;
		_loginurl = channels[f.channelSelect.value].c_loginurl;		
		f.url.value=_url;
		f.loginurl.value=_loginurl;
		if (isempty(f.account,"请输入帐号！"))
				  return false;

		if(!strvalidCheck(f.account,"只能包含中文、字母、数字"))
		  return false;

		if (isempty(f.pwd,"请输入密码！"))
				  return false;
		return true;
	}
	function forgetpasswd(){
		var f = login;
		
		f.action="http://rlcode.com/passport/user/forgetpasswd.jsp";
		f.target="_blank";
		if (isempty(f.account,"请输入帐号！")){
		return;
		}
		
		if(!strvalidCheck(f.account,"只能包含中文、字母、数字"))
		  return;
		
		f.submit();
	}

	function reg(){
		var f = login;
		f.action="http://rlcode.com/passport/user/register.jsp";
		f.target="_blank";					
		f.submit();
	}

if(disptype==0){
document.writeln("<table width=173 border=0 cellpadding=0 cellspacing=0 bgcolor=#FFDAC2>");
document.writeln("<form action=front/login.jsp?act=login method=post");
if(newwindow==1)document.writeln(" target=_blank");
document.writeln(" name=login id=login onSubmit=return userlogin()>	  ");
document.writeln("<input type=hidden name=url>");
document.writeln("<input type=hidden name=loginurl>");
document.writeln("        <tr> ");
document.writeln("      <td width=45 align=right>帐号</td>");
document.writeln("          <td width=130><input name=account type=text id=account size=17>");
document.writeln("              </td>");
document.writeln("        </tr>");
document.writeln("        <tr> ");
          
document.writeln("      <td align=right>密码</td>");
document.writeln("          <td><input name=pwd type=password id=pwd size=17></td>");
document.writeln("        </tr>");
document.writeln("        <tr> ");
document.writeln("      <td align=right>=></td>");
document.writeln("          <td><select name=channelSelect id=channelSelect></select>");
document.writeln("        </td>");
document.writeln("        </tr>");

document.writeln("        <tr> ");
document.writeln("          <td colspan=2><div align=center><a href=javascript:if(userlogin())login.submit();><img src=http://rlcode.com/passport/user/images/btn_login.gif width=54 height=21 hspace=1 vspace=2 border=0></a><a href=javascript:reg();><img src=http://rlcode.com/passport/user/images/btn_register.gif width=54 height=21 hspace=1 vspace=2 border=0></a> ");
document.writeln("        </div></td>");
document.writeln("        </tr>");
document.writeln("        <tr  align=center> ");
document.writeln("          <td colspan=2><a href=javascript:forgetpasswd();><img src=http://rlcode.com/passport/user/images/btn_getpassword.gif width=95 height=21  border=0></a></td>");
document.writeln("        </tr>");
document.writeln("</form>");
document.writeln("      </table>");

}else if(disptype==1){
document.writeln("<table width=100% border=0 cellpadding=0 cellspacing=0 bgcolor=#FFDAC2>");
document.writeln("<form action=front/login.jsp?act=login method=post");
if(newwindow==1)document.writeln(" target=_blank");
document.writeln(" name=login id=login onSubmit=return userlogin()>	  ");
document.writeln("<input type=hidden name=url>");
document.writeln("<input type=hidden name=loginurl>");
document.writeln("        <tr> ");
document.writeln("          <td align=right>账号：</td>");
document.writeln("          <td><input name=account type=text id=account size=15>");
document.writeln("              </td>");
document.writeln("          <td align=right>密码：</td>");
document.writeln("          <td><input name=pwd type=password id=pwd size=15></td>");
document.writeln("          <td><select name=channelSelect id=channelSelect></select></td>");
document.writeln("          <td align=center><a href=javascript:if(userlogin())login.submit();><img src=http://rlcode.com/passport/user/images/btn_login.gif width=54 height=21 hspace=1 vspace=2 border=0></a></td><td align=center><a href=javascript:reg();><img src=http://rlcode.com/passport/user/images/btn_register.gif width=54 height=21 hspace=1 vspace=2 border=0></a></td>");
document.writeln("<td align=center><a href=javascript:forgetpasswd();><img src=http://rlcode.com/passport/user/images/btn_getpassword.gif width=95 height=21  border=0></a></td>");
document.writeln("</form>");
document.writeln("      </table>");
}


initChannels(login.channelSelect,"");