/*
 * register.js
 * This file is part of Entrans
 *
 * Copyright (C) 2005 Khader Abbeb N
 * Copyright (C) 2005 R.Vigneswaran 
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, 
 * Boston, MA 02111-1307, USA. 
 *
 */

	function fn_login()
	{
	  	var user_name,passwd;
  		user_name 	= document.login_form.uname.value;
		passwd    	= document.login_form.passwd.value;
		if(user_name==""||passwd=="") {
		    window.alert("Enter Username and Password");
		    return false;
		}
		return true;
	}
	function fn_validate()
	{
		document.reg_form.user_name.value = document.login_form.uname.value;
		document.reg_form.passwd.value    = document.login_form.passwd.value;

	  	var mail_id,user_name,passwd,pass_confirm;
  		user_name 	= document.reg_form.user_name.value;
		mail_id   	= document.reg_form.mail_id.value;
		passwd    	= document.reg_form.passwd.value;
		passwd_confirm= document.reg_form.passwd_confirm.value;

		if(user_name==""||passwd==""||passwd_confirm=="")
		    window.alert("Missing value for mandatory field(s)");
		else if(passwd_confirm!=passwd)
		{
		    window.alert("Passwords are not same");
		    document.reg_form.passwd.value="";
		    document.login_form.passwd.value="";
		    document.reg_form.passwd_confirm.value="";
		}
		else if(passwd.length<6)
		{
		    window.alert("Password is too short");
		    document.login_form.passwd.value="";
		    document.reg_form.passwd.value="";
		    document.reg_form.passwd_confirm.value="";
		}
		else if(document.reg_form.recv_mail[0].checked&&mail_id=="")
		      window.alert("Mail id is mandatory if you want mails to be sent.");
		else if(mail_id!=""&&mail_id.indexOf('@')==-1)
		      window.alert("Mail id is not valid.");      
		else
		{
		    document.reg_form.sub_register.value="yes";
		    return true;
		}
		return false;
	}
