//====================================================================================================
//	File Name		:	user.js
//----------------------------------------------------------------------------------------------------
//	Purpose			:	Client side validation in JavaScript.
//	Creation Date	:	17-Nov-2003
//====================================================================================================

//====================================================================================================
//	Function Name	:	Form_Submit()
//	Purpose			:	This function will check inputted field by user are valid or not.
//	Return			:	none
//----------------------------------------------------------------------------------------------------
function Form_Submit(frm)
{ 
	with(frm)
    {
		if(login_name.value =='Login*')
		{
			alert('Please enter a valid login name. Space will not be accepted as a character.');
			login_name.focus();
			return false;
		}
		if(login_name.value.length < 3 || login_name.value.length > 12)
		{
			alert("Login Name should be minimum 3 and maximum 12 characters");
			login_name.focus();
			return false;
		}
		if(!IsValidString(login_name, 'Please enter a valid login name. Space will not be accepted as a character'))
		{
			return false;
		}
		if(password.value =='Password*')
		{
			alert('Please enter password');
			password.focus();
			return false;
		}
		if(password.value.length < 6 || password.value.length > 12)
		{
			alert("Password should be minimum 6 and maximum 12 characters");
			password.focus();
			return false;
		}
		if(conpassword.value =='Password*')
		{
			alert('Please enter confirm password');
			conpassword.focus();
			return false;
		}
				
		if(password.value != conpassword.value)
		{
			alert('Password and confirm password should be same');	
			conpassword.focus();
			return false;
		}
		
		if(security_answer.value =='Security Answer*')
		{
			alert('Please ensure you have selected a desired security question and enter an answer for it');
			security_answer.focus();
			return false;
		}
		
		if(comp_name.value =='Club Name*')
		{
			alert('Please enter club name');
			comp_name.focus();
			return false;
		}
		
		if(first_name.value =='First Name*')
		{
			alert('Please enter first name');
			first_name.focus();
			return false;
		}
		
		if(last_name.value =='Last Name*')
		{
			alert('Please enter last name');
			last_name.focus();
			return false;
		}
		
		if(phone.value =='Phone*')
		{
			alert('Please enter phone number');
			phone.focus();
			return false;
		}
		
		if(email_name.value =='Email*')
		{
			alert('Please enter email address');
			email_name.focus();
			return false;
		}
		if(!IsEmail(email_name, 'Please enter a valid email address'))
		{
			return false;
		}
		if(address.value =='Address*')
		{
			alert('Please enter address');
			address.focus();
			return false;
		}
		
		if(city.value =='Suburb*')
		{
			alert('Please enter suburb');
			city.focus();
			return false;
		}
		
		/*if(country.value =='Country*')
		{
			alert('Please enter country');
			country.focus();
			return false;
		}*/
		
		if(zip.value =='Post Code*')
		{
			alert('Please enter post code');
			zip.focus();
			return false;
		}
		if(!IsZip(zip, 'Post code should be 4 digits only.'))
		{
			return false;
		}
		if(security_code.value =='')
		{
			alert('Please enter security code');
			security_code.focus();
			return false;
		}
		
		Submit1.value='Submit';
		submit();
    }
}

function Form_Submit1(frm)
{ 
	with(frm)
    {
		
		if(!IsEmpty(email_name, 'Please Enter Email.'))
		{
			return false;    
		}
		if(!IsEmail(email_name, 'Please Enter Valid Email.'))
		{
			return false;
		}
		
		
	Submit1.value='Save';
	submit();
		
    }
	
	
}


//====================================================================================================
//	Function Name	:	Show_Click()
//	Purpose			:	This function will set the Office id and action and then submit the form.
//	Parameters		:	OfficeId  - Office Id whose detail will to be edit
//	Return			:	none
//----------------------------------------------------------------------------------------------------
function Show_Click(User_Auth_Id)
{
	with(document.frmUser)
	{
		user_auth_id.value = User_Auth_Id;
		Action.value = "Show";
		submit();
	}
}
//====================================================================================================
//	Function Name	:	Add_Click()
//	Purpose			:	This function will executed when user submits a form. It checks validity of 
//						every field in the form.
//	Parameters		:	frm  - form name
//	Return			:	true or false
//----------------------------------------------------------------------------------------------------
function Add_Click()
{
	with(document.frmUser)
	{
		Action.value = "Add";
		submit();
	}
}
//====================================================================================================
//	Function Name	:	Edit_Click()
//	Purpose			:	This function will executed when user submits a form. It checks validity of 
//						every field in the form.
//	Parameters		:	frm  - form name
//	Return			:	true or false
//	Author			:	Nitin Rana
//----------------------------------------------------------------------------------------------------
function Edit_Click(User_Auth_Id)
{
	with(document.frmUser)
	{
		Action.value = "Update";
		user_auth_id.value = User_Auth_Id;		
		submit();
	}
}
//====================================================================================================
//	Function Name	:	Delete_Click()
//	Purpose			:	This function will set the Office id and action and then submit the form.
//	Parameters		:	OfficeId  - Office Id whose detail will to be edit
//	Return			:	none
//	Author			:	Dinesh Sailor
//	Creation Date	:	17-Nov-2003
//----------------------------------------------------------------------------------------------------
function Delete_Click(User_Auth_Id)
{
	with(document.frmUser)
	{
		if(confirm('Are you sure you want to delete this user?'))
		{	
			user_auth_id.value = User_Auth_Id;
			Action.value = "Delete";
			submit();
		}
	}
}
//====================================================================================================
//	Function Name	:	Print_Click()
//	Purpose			:	This function will set the Office id and action and then submit the form.
//	Parameters		:	OfficeId  - Office Id whose detail will to be edit
//	Return			:	none
//	Author			:	Dinesh Sailor
//	Creation Date	:	17-Nov-2003
//----------------------------------------------------------------------------------------------------

function Print_Click(User_Auth_Id)
{
	with(document.frmUser)
	{
		popupWindowURL("user.php?Action=Print&user_auth_id="+User_Auth_Id, 'PageContent', 650, 500, false, false, true);
	}
}

//====================================================================================================
//	Function Name	:	Update_Click()
//	Purpose			:	This function will set the Office id and action and then submit the form.
//	Return			:	none
//	Creation Date	:	21-April-2006
//----------------------------------------------------------------------------------------------------

function Update_Click(User_Login_Id,ApprovalStatus)
{
	with(document.frmUser)
	{
		auth_login_id.value = User_Login_Id;
		approval_status.value = ApprovalStatus;
		Action.value = "Modify";
		submit();
	}
}