// main login form validation
function validate_login2()
{
	if (document.login.email.value=="Email" || document.login.email.value=="")
	{
		alert("Please enter your email address!");
		document.login.email.value="";
		document.login.email.focus();
		return false;
	}
	if (document.login.password.value=="Password" || document.login.password.value=="")
	{
		alert("Please enter your password!");
		document.login.password.value="";
		document.login.password.focus();
		return false;
	}
	return true;
} // validate_login2()

function validate_registration_customer()
{
	if (document.register.eemail.value=="Email" || document.register.eemail.value=="")
	{
		alert("Please enter your email address!");
		document.register.eemail.value="";
		document.register.eemail.focus();
		return false;
	}
	if (document.register.name1.value=="First Name" || document.register.name1.value=="")
	{
		alert("Please enter your first name!");
		document.register.name1.value="";
		document.register.name1.focus();
		return false;
	}
	if (document.register.name2.value=="Last Name" || document.register.name2.value=="")
	{
		alert("Please enter your last name!");
		document.register.name2.value="";
		document.register.name2.focus();
		return false;
	}
	if(document.register.tac.checked!=true)
	{
		alert("You must agree to club terms and conditions to be able to use Play Golf Today!");
		document.register.tac.focus();
		return false;
	}
	return true;
} // validate_registration_customer()

function validate_password_reminder()
{
	if (document.password_reminder.yemail.value=="Your Email" || document.password_reminder.yemail.value=="")
	{
		alert("Please enter your email address!");
		document.password_reminder.yemail.value="";
		document.password_reminder.yemail.focus();
		return false;
	}
	return true;
} // validate_password_reminder()

/***********************************************************
BM/business functions
************************************************************/

// search form in customer manager business/BM CP
function validate_customer_search()
{
	if (document.customer_search.keyword.value=="search" || document.customer_search.keyword.value=="")
	{
		alert("Please enter the search keyword!");
		document.customer_search.keyword.value="";
		document.customer_search.keyword.focus();
		return false;
	}
	return true;
} // validate_customer_search()

function business_delete_customer_profile()
{
	if (confirm('Are you sure ?'))
	{
		document.customer_profile.mode.value='delete';
		document.customer_profile.submit();
	}
	else return false;
} // business_delete_customer_profile()

// BM contact detail/team members validation
function business_validate_profile()
{
	if (document.business_profile.name.value=='')
	{
		alert('Please enter club name!');
		document.business_profile.name.focus();
		return false;
	}
	if (document.business_profile.postcode.value=='')
	{
		alert('Please enter postal code!');
		document.business_profile.postcode.focus();
		return false;
	}
	return true;
} // business_validate_profile()

function business_gm_delete()
{
	if (confirm('Are you sure ?'))
	{
		document.gm_form.target='_self';
		document.gm_form.action='group_message_form.php';
		document.gm_form.mode.value='delete';
		document.gm_form.submit();
	}
	else return false;
} // business_gm_delete()

function business_gm_send()
{
	if (document.gm_form.title.value=='')
	{
		alert('Please enter the group message title!');
		document.gm_form.title.focus();
		return false;
	}
	document.gm_form.target='_self';
	document.gm_form.action='group_message_form.php';
	document.gm_form.submit();
}

function business_gm_preview()
{
	document.gm_form.target='preview';
	document.gm_form.action='group_message_preview.php';
	document.gm_form.submit();
}

function business_gm_chars_left(message_length)
{
	my_chars_left = document.getElementById('counter_chars_left');
	real_counter = message_length - document.gm_form.sms_txt.value.length;
	my_chars_left.innerHTML = real_counter;
	if (real_counter<0)
	{
		real_counter++;
		document.gm_form.sms_txt.value = document.gm_form.sms_txt.value.substring(0,message_length-1);
		my_chars_left.innerHTML = real_counter;
	}
} // business_gm_chars_left()

function club_add_partner(cid)
{
	var name = prompt('Business name:', '');
	if (name!=null && name!='')
	{
		document.partner_form.name.value = name;
		document.partner_form.id.value = cid;
		document.partner_form.submit();
	}
} // club_add_partner()

function club_delete_partner()
{
	return (confirm("This will delete partner account and partner web page!\nAre you sure?"));
} // club_delete_partner()

function club_print_partner(pin, username, pass)
{
	var my_location = "partner_print.php?pin="+pin+"&username="+username+"&pass="+pass;
	window.open(my_location, 'partner_print');
} // club_print_partner()
/***********************************************************
customer CP functions
************************************************************/

// customer profile form in customer CP
function customer_validate_profile()
{
	if (document.profile.first_name.value=='')
	{
		alert('Please enter first name!');
		document.profile.first_name.focus();
		return false;
	}
	if (document.profile.last_name.value=='')
	{
		alert('Please enter last name!');
		document.profile.last_name.focus();
		return false;
	}
	if (document.profile.email.value=='')
	{
		alert('Please enter email address!');
		document.profile.email.focus();
		return false;
	}
	if (document.profile.password.value=='')
	{
		alert('Please enter password!');
		document.profile.password.focus();
		return false;
	}
	// AAA stuff
	if (document.profile.postcode.value=='optional')
	{
		document.profile.postcode.value='';
	}
	if (document.profile.address_1.value=='optional')
	{
		document.profile.address_1.value='';
	}
	if (document.profile.address_2.value=='optional')
	{
		document.profile.address_2.value='';
	}
	if (document.profile.town.value=='optional')
	{
		document.profile.town.value='';
	}
	if (document.profile.phone_code.value=='optional')
	{
		document.profile.phone_code.value='';
	}
	if (document.profile.phone_number.value=='optional')
	{
		document.profile.phone_number.value='';
	}
	if (document.profile.sms_number.value=='optional')
	{
		document.profile.sms_number.value='';
	}
	if (document.profile.email.value=='optional')
	{
		document.profile.email.value='';
	}
	return true;
} // customer_validate_profile()

function customer_validate_invitation()
{
	if (document.invitation.friendName.value=='Hi (friends name) check this out!')
	{
		document.invitation.friendName.value='';
	}
	if (document.invitation.friendEmail.value=='email address')
	{
		document.invitation.friendEmail.value='';
	}
	if (document.invitation.friendName.value=='')
	{
		alert('Please enter friend\'s name!');
		document.invitation.friendName.focus();
		return false;
	}
	if (document.invitation.friendEmail.value=='')
	{
		alert('Please enter friend\'s email address!');
		document.invitation.friendEmail.focus();
		return false;
	}
	return true;
} // customer_validate_invitation()

function customer_delete_profile()
{
	if (confirm('Your account will be deleted and cannot be restored later!\nAre you sure ?'))
	{
		document.profile.mode.value='delete';
		document.profile.submit();
	}
	else return false;
} // customer_delete_profile()

function customer_validate_personal_alert()
{
	if (document.message.text.value=='')
	{
		alert('Please enter message!');
		document.message.text.focus();
		return false;
	}
	else return true;
} // customer_validate_personal_alert()

function customer_delete_personal_alert()
{
	if (confirm('Are you sure ?'))
	{
		document.message.mode.value='delete';
		document.message.submit();
	}
	else return false;
} // customer_delete_personal_alert()

function customer_validate_payment()
{
	if (document.tac.must.checked==false)
	{
		alert('You must agree to Terms and Conditions');
		document.tac.must.focus();
		return false;
	}
	else
	{
		return true;
	}
} // customer_validate_payment()
