/* ****************************************************
* File: users.js
* Project: JProjecta1WK
* Author:         Wayne K.
* Date created:   10/10/05
* Purpose:        will be used to to identify valid users and user logon functions 
* Functions listed:
*				                   
* Additional Info: none
***************************************************** */

//function to validation if any value entered into textfields
		 
		function valNewMember()
		//Determine checkbox value
           
		{
			// check to see if the user name field is blank
			if (document.getElementById('userName').value == "")
			{
			alert("You must enter a user name.");
			document.getElementById('userName').focus();
			return (false);
			}
			
			// check to see if the password field is blank
			if (document.getElementById('passName').value == "")
			{
			alert("You must enter a password.");
			document.getElementById('passName').focus();
			return (false);
			}
			
			// check to see if the password field is blank
			if (document.getElementById('verifyPassword').value == "")
			{
			alert("Please verify password.");
			document.getElementById('verifyPassword').focus();
			return (false);
			}
			else
			{
			sendApp();
			}
			
		}

//function to validation if "any" value entered into textfields
		 
		function validate()
		//Determine checkbox value
           
		{
			// check to see if the user name field is blank
			if (document.getElementById('userName').value == "")
			{
			alert("You must enter a user name.");
			document.getElementById('userName').focus();
			return (false);
			}
			
			// check to see if the password field is blank
			if (document.getElementById('passName').value == "")
			{
			alert("You must enter a password.");
			document.getElementById('passName').focus();
			return (false);
			}
			else
			{
			memberLogin();
			
			
			}
			
           
			
		}

//function to identify members CORRECT user name and password
         function memberLogin(userName,passName)
	{
		var userName = document.getElementById('userName').value;
		var passName = document.getElementById('passName').value;
		var loggedin = false;
 
		// check for USER NAME AND PASSWORD

		if (userName=="Kim" && passName=="Rush") 
		{ 
		loggedin=true;
		
		window.location="members/kas.html";
		}
			if (userName=="kim" && passName=="rush") 
			{
			loggedin=true;
			
			window.location="members/kas.html";
			}
			
			if (userName=="temp" && passName=="pass") 
			{
			loggedin=true;
			
			window.location="members/kas.html";
			}
			
			if (userName=="sakya" && passName=="pass") 
			{
			loggedin=true;
			
			window.location="members/guest.html";
			}
			// write cookie for username with lifespan
			writeCookie("welcome",userName,1);
			// write cookie for logon with no persistance
			writeCookie("welcome",passname,0);
		
		/// Alert for incorrect
		if (loggedin==false) {
		alert("Login failed! Please Try Again");
		}
	}
		
//function to submit new member application		
		function sendApp()
         {
		var name = document.getElementById('userName').value;
		var password = document.getElementById('passName').value;
		var subj = 'Greetings from your web page!';
		var bodyText = 'User name:' + name + '%0A' + 'Password:'+ password;
		location.href='mailto:kasstudio@yahoo.com?Subject=' + subj + '&body=' + bodyText;
	}
	
	
	
	
	
	
	


		 









