//====================================================================================================
//	File Name		:	testimonials.js
//----------------------------------------------------------------------------------------------------
//	Purpose			:	Client side validation in JavaScript.
//	Author			:	Manoj Rana
//	Creation Date	:	07-June-2003
//	Copyright		:	Copyrights © 2003 Dot Infosys
//	Email			:	info@dotinfosys.com
//	History			:
//						Date				Author					Remark
//						07-June-2003		Manoj Rana			Initial Release
//
//====================================================================================================

//====================================================================================================
//	Function Name	:	Form_Submit()
//	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			:	Manoj Rana
//	Creation Date	:	07-June-2003
//----------------------------------------------------------------------------------------------------
function Form_Submit_Step1(frm)
{
	with(frm)
    {
		if(!IsEmpty(user_login_id, L_Js_enter_the_Username))
        {
			return false;
        }
		else if(!IsValidString1(user_login_id,L_Js_Please_Enter_Valid_Character))
		{
			return false;	
		}		

		if(!IsEmpty(user_password, L_Js_Enter_Password))
        {
			return false;
        }
    	if(!IsEmpty(user_passwordretype, L_Js_Retype_Password))
        {
			return false;
        }
		if(user_password.value!=user_passwordretype.value)
        {
			alert(L_Js_retype_password);
			user_passwordretype.focus();
			return false;
        }
    	
		
		if(!IsEmail(user_email, L_Js_Valid_Email_Address))
        {
			return false;
        }
    	if(!IsEmail(user_emailretype, L_Js_Retype_Email_Address))
        {
			return false;
        }
		if(user_email.value!=user_emailretype.value)
        {
			alert(L_Js_Address_is_not_matching);
			user_emailretype.focus();
			return false;
        }

		if(user_referance.value != '')
        {
			if(!IsValidString(user_referance,L_Js_Please_Enter_Valid_Character1))
			{
				return false;	
			}
		}

       	if(gender_id.value == '')
        {
			alert(L_Js_Enter_Gender);
			gender_id.focus();
			return false;
        }

		if(!membership_option.checked)
        {

			alert('Please agree to our membership agreement');
			membership_option.focus();
			return false;
        }

/*
		if(!notify_me.checked)
        {
			alert(L_Js_Check_Terms_of_Use);
			notify_me.focus();
			return false;
        }*/

		return true;
    }

}

function Form_Submit_Step2(frm)
{

	with(frm)
    {	
		if(!IsEmpty(member_name, 'enter valid user name'))
		{
			return false;
		}

		if(!IsLen(member_name,1,15, 'enter valid user name wthine range'))
		{
			return false;
		}

		if(frm.member_name2)
		{
			if(!IsEmpty(member_name2, 'enter valid user name'))
			{
				return false;
        	}

			if(!IsLen(member_name2,1,15, 'enter valid user name wthine range'))
			{
				return false;
			}
		}
		if(frm.birth_date2)
		{
			if((frm.birth_date2.value) < 18)
			{
				alert(L_Js_Due_to_under_18);
				frm.birth_date2.focus();
				return false;
			}
		}
		if((frm.birth_date.value) < 18)
		{
			alert(L_Js_Due_to_under_18);
			frm.birth_date.focus();
			return false;
		}

		if(!IsComboSelected(country_id,'please select conuntry'))
		{
			return false;
		}
		if(state_id.style.display=='block')
		{
			if(!IsComboSelected(state_id,'please select state'))
			{
				return false;
			}
		}
		else
		{
			if(!IsEmpty(text_state_id, 'enter valid state'))
	        {
			return false;
    	    }
		}

		if(!IsEmpty(text_city_id,'enter valid city'))
		{
			return false;
		}

		if(!IsZip(zip_code,'Enter Valid Zipcode'))
        {
			return false;
        }

	/*	if(!IsLen(zip_code,1,5, 'Enter Proper Zipcode'))
		{
			return false;
		}*/

	return true;
	}
}
//====================================================================================================
//	Function Name	:	Show_Click()
//	Purpose			:	This function will set the Person id and action and then submit the form.
//	Parameters		:	PersonId  - Person Id whose detail will to be shown
//	Return			:	none
//	Author			:	Manoj Rana
//	Creation Date	:	07-June-2003
//----------------------------------------------------------------------------------------------------
function Show_Click(AdviceId)
{
	with(document.frmAdvice)
	{
		advice_id.value = AdviceId;
		Action.value = "Show";

		submit();
	}
}

//====================================================================================================
//	Function Name	:	Add_Click()
//	Purpose			:	This function will set action and then submit the form.
//	Parameters		:	none
//	Return			:	none
//	Author			:	Manoj Rana
//	Creation Date	:	07-June-2003
//----------------------------------------------------------------------------------------------------
function Add_Click()
{
	with(document.frmAdvice)
	{
		//alert('here');
		Action.value = "Add";
		submit();
	}
}

//====================================================================================================
//	Function Name	:	Edit_Click()
//	Purpose			:	This function will set the Person id and action and then submit the form.
//	Parameters		:	PersonId  - Person Id whose detail will to be edit
//	Return			:	none
//	Author			:	Manoj Rana
//	Creation Date	:	07-June-2003
//----------------------------------------------------------------------------------------------------
function Edit_Click(AdviceId)
{
	with(document.frmAdvice)
	{
		advice_id.value = AdviceId;
		Action.value = "Modify";
		submit();
	}
}

//====================================================================================================
//	Function Name	:	Delete_Click()
//	Purpose			:	This function will set the Person Id and action and then submit the form.
//	Parameters		:	PersonId  - Person Id whose detail will to be delete
//	Return			:	none
//	Author			:	Jinasa Naik
//	Creation Date	:	07-June-2003
//----------------------------------------------------------------------------------------------------
function Delete_Click(AdviceId)
{
	with(document.frmAdvice)
	{
		advice_id.value = AdviceId;
		Action.value = "Delete";
		submit();
	}
}

//====================================================================================================
//	Function Name	:	Form_Submit_Login()
//	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			:	Manoj Rana
//	Creation Date	:	07-June-2003
//----------------------------------------------------------------------------------------------------
function Form_Submit_Login(frm)
{
	with(frm)
    {
    	if(!IsEmpty(username, 'Please, Enter Username.'))
        {
			return false;
        }
		
    	if(!IsEmpty(password, 'Please, Enter Password.'))
        {
			return false;
        }
		Action.value = "Login";
        return true;
    }

}
