function toggle_visibility2(id) { 
 var e = document.getElementById(id); 
 if(e.style.display == 'block') 
 // e.style.visibility = 'hidden'; 
  e.style.display = 'none'; 
 else 
 // e.style.visibility = 'visible'; 
  e.style.display = 'block'; 
}
function show_alert_account_delete() {
var answer = confirm ("Are you sure you wish to delete your user account and adverts? We cannot retrieve anything once it is deleted!\nClick CANCEL if you are unsure or click OK to delete your account.")
if (answer) {
return (true);
}
else {
return (false);
}
}

function show_alert_expire() {
var answer = confirm ("Are you sure you want to expire this advert? The advert will be moved to the expired section and can resubmitted again in the future.")
if (answer) {
return (true);
}
else {
return (false);
}
}

function show_alert() {
var answer = confirm ("Are you sure you want to delete this?")
if (answer) {
return (true);
}
else {
return (false);
}
}

function show_alert_confirm() {
var answer = confirm ("Are you sure?")
if (answer) {
return (true);
}
else {
return (false);
}
}


function show_alert_remove() {
var answer = confirm ("Are you sure you want to remove your email address?")
if (answer) {
return (true);
}
else {
return (false);
}
}


function CheckPassword (passwd) {
		var lstr=passwd.length
	if (lstr<5) {
			   alert("Sorry, your password needs to be at least 5 characters long.")
		   return false
		}
		
	var valid = 1
	var GoodChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
	var i = 0
	//if (TheNumber=="") {
		// Return false if number is empty
		//valid = 0
	//}
	for (i =0; i <= passwd.length -1; i++) {
		if (GoodChars.indexOf(passwd.charAt(i)) == -1) {
 alert("\'"+passwd.charAt(i) + "\' is not a letter or number. Password must be only numbers or letters.")
			valid = 0
			return valid
		} // End if statement
	} // End for loop
	return valid
}


function echeck(str) 
{

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("E-mail not in correct format.")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("E-mail not in correct format.")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)+1==lstr){
		    alert("E-mail not in correct format.")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("E-mail not in correct format.")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("E-mail not in correct format.")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("E-mail not in correct format.")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("E-mail not in correct format.")
		    return false
		 }

 		 return true					
 }

function CheckPhoneNumber(TheNumber) {
	var valid = 1
	var GoodChars = "0123456789()-+ "
	var i = 0
	//if (TheNumber=="") {
		// Return false if number is empty
		//valid = 0
	//}
	for (i =0; i <= TheNumber.length -1; i++) {
		if (GoodChars.indexOf(TheNumber.charAt(i)) == -1) {
 alert(TheNumber.charAt(i) + " is not valid in a phone number.")
			valid = 0
			return valid
} // End if statement
	} // End for loop
	return valid
}

function CheckNumber(TheNumber) {
	var valid = 1
	var GoodChars = "0123456789."
	var i = 0
	//if (TheNumber=="") {
		// Return false if number is empty
		//valid = 0
	//}
	for (i =0; i <= TheNumber.length -1; i++) {
		if (GoodChars.indexOf(TheNumber.charAt(i)) == -1) {
 alert(TheNumber.charAt(i) + " is not a number.")
			valid = 0
			return valid
		} // End if statement
	} // End for loop
	return valid
}


function SubmitSeasonTicketForm(theForm)
{
//first off tell form that javascript is enabled so these checks have been done
theForm.jsChecks.value="Yes";

//now check the required fields exist

	if(theForm.ticket_type.value == "")
	{
		alert("Please select a type of Season Ticket.");
		theForm.ticket_type.focus();
return (false);
	
}
}

function SubmitForm(theForm)
{
//first off tell form that javascript is enabled so these checks have been done
theForm.jsChecks.value="Yes";

//now check the required fields exist

	if(theForm.email.value == "")
	{
		alert("Please enter your email address.");
		theForm.email.focus();
return (false);
	}
	else if(theForm.passwd.value == "")
	{
		alert("Please enter a password for your account.");
		theForm.passwd.focus();
return (false);
	}
	else if(theForm.contact_name.value == "")
	{
		alert("Please enter your name.");
		theForm.contact_name.focus();
return (false);
	}
	else if(theForm.address.value == "")
	{
		theForm.address.focus();
		alert("Please enter your street address.");
return (false);
	}
	else if(theForm.city.value == "")
	{
		theForm.city.focus();
		alert("Please enter your town or city.");
return (false);
	}
	else if(theForm.postcode.value == "")
	{
		theForm.postcode.focus();
		alert("Please enter your postcode.");
return (false);
	}
	else if(theForm.country.value == "")
	{
		theForm.country.focus();
		alert("Please select your country.");
return (false);
	}
	else if(theForm.tandcs.checked == false)
	{
		theForm.tandcs.focus();
		alert("To register, you must agree to our Terms and Conditions and Privacy Policy.");
return (false);
	}
	
var check=echeck(theForm.email.value);
if (check== false)
	{
		theForm.email.focus();
	return (false);
	}		
var check=CheckPhoneNumber(theForm.telephone.value);
if (check== false)
	{
		theForm.telephone.focus();
	return (false);
	}		
var check=CheckPhoneNumber(theForm.fax.value);
if (check== false)
	{
		theForm.fax.focus();
	return (false);
	}
var check=CheckPassword(theForm.passwd.value);
if (check== false)
	{
		theForm.passwd.focus();
	return (false);
	}

	
}
function SubmitMailingListForm(theForm)
{
//first off tell form that javascript is enabled so these checks have been done
theForm.jsChecks.value="Yes";

//now check the required fields exist

	if(theForm.email.value == "")
	{
		alert("Please enter your email address.");
		theForm.email.focus();
return (false);
	}
var check=echeck(theForm.email.value);
if (check== false)
	{
		theForm.email.focus();
	return (false);
	}			
}


function SubmitInstructorsForm(theForm)
{
//first off tell form that javascript is enabled so these checks have been done
theForm.jsChecks.value="Yes";

//now check the required fields exist

	if(theForm.email.value == "")
	{
		alert("Please enter your email address.");
		theForm.email.focus();
return (false);
	}
var check=echeck(theForm.email.value);
if (check== false)
	{
		theForm.email.focus();
	return (false);
	}		
	else if(theForm.name.value == "")
	{
		alert("Please enter your name.");
		theForm.name.focus();
return (false);
	}
	else if(theForm.description_short.value == "")
	{
		alert("Please enter the short description for your advert. This is used in the listings.");
		theForm.description_short.focus();
return (false);
	}
	else if(theForm.description_long.value == "")
	{
		alert("Please enter the main description for your advert.");
		theForm.description_long.focus();
return (false);
	}
	else if(theForm.qualification.value == "")
	{
		theForm.qualification.focus();
		alert("Please select your qualification.");
return (false);
	}
	else if(theForm.area.value == "")
	{
		theForm.area.focus();
		alert("Please select the area in which you operate.");
return (false);
	}
var check=CheckPhoneNumber(theForm.telephone.value);
if (check== false)
	{
		theForm.telephone.focus();
	return (false);
	}		
var check=CheckPhoneNumber(theForm.fax.value);
if (check== false)
	{
		theForm.fax.focus();
	return (false);
	}
}

function SubmitJobsForm(theForm)
{
//first off tell form that javascript is enabled so these checks have been done
theForm.jsChecks.value="Yes";

//now check the required fields exist

	if(theForm.email.value == "")
	{
		alert("Please enter your email address.");
		theForm.email.focus();
return (false);
	}
var check=echeck(theForm.email.value);
if (check== false)
	{
		theForm.email.focus();
	return (false);
	}		
	else if(theForm.job_title.value == "")
	{
		alert("Please enter the Job title.");
		theForm.job_title.focus();
return (false);
	}
	else if(theForm.description_short.value == "")
	{
		alert("Please enter the short description for your advert. This is used in the listings.");
		theForm.description_short.focus();
return (false);
	}
	else if(theForm.description_long.value == "")
	{
		alert("Please enter the main description for your advert.");
		theForm.description_long.focus();
return (false);
	}
	else if(theForm.area.value == "")
	{
		theForm.area.focus();
		alert("Please select the area in which the job operates.");
return (false);
	}
var check=CheckPhoneNumber(theForm.telephone.value);
if (check== false)
	{
		theForm.telephone.focus();
	return (false);
	}		
var check=CheckPhoneNumber(theForm.fax.value);
if (check== false)
	{
		theForm.fax.focus();
	return (false);
	}
}

function SubmitCoursesForm(theForm)
{
//first off tell form that javascript is enabled so these checks have been done
theForm.jsChecks.value="Yes";

//now check the required fields exist

	if(theForm.email.value == "")
	{
		alert("Please enter your email address.");
		theForm.email.focus();
return (false);
	}
var check=echeck(theForm.email.value);
if (check== false)
	{
		theForm.email.focus();
	return (false);
	}		
	else if(theForm.course_title.value == "")
	{
		alert("Please enter the Course title.");
		theForm.course_title.focus();
return (false);
	}
	else if(theForm.description_short.value == "")
	{
		alert("Please enter the short description for your advert. This is used in the listings.");
		theForm.description_short.focus();
return (false);
	}
	else if(theForm.description_long.value == "")
	{
		alert("Please enter the main description for your advert.");
		theForm.description_long.focus();
return (false);
	}
	else if(theForm.area.value == "")
	{
		theForm.area.focus();
		alert("Please select the area in which the course is located.");
return (false);
	}
	else if(theForm.course_type.value == "")
	{
		theForm.course_type.focus();
		alert("Please select the type of course you are advertising.");
return (false);
	}
var check=CheckPhoneNumber(theForm.telephone.value);
if (check== false)
	{
		theForm.telephone.focus();
	return (false);
	}		
var check=CheckPhoneNumber(theForm.fax.value);
if (check== false)
	{
		theForm.fax.focus();
	return (false);
	}
}

function SubmitFacilitiesForm(theForm)
{
//first off tell form that javascript is enabled so these checks have been done
theForm.jsChecks.value="Yes";

//now check the required fields exist

	if(theForm.email.value == "")
	{
		alert("Please enter your email address.");
		theForm.email.focus();
return (false);
	}
var check=echeck(theForm.email.value);
if (check== false)
	{
		theForm.email.focus();
	return (false);
	}		
	else if(theForm.facility_name.value == "")
	{
		alert("Please enter the facility name.");
		theForm.facility_name.focus();
return (false);
	}
	else if(theForm.description_short.value == "")
	{
		alert("Please enter the short description for your advert. This is used in the listings.");
		theForm.description_short.focus();
return (false);
	}
	else if(theForm.description_long.value == "")
	{
		alert("Please enter the main description for your advert.");
		theForm.description_long.focus();
return (false);
	}
	else if(theForm.facility_type.value == "")
	{
		theForm.facility_type.focus();
		alert("Please choose the type of facility.");
return (false);
	}
	else if(theForm.area.value == "")
	{
		theForm.area.focus();
		alert("Please select the area where the facility resides.");
return (false);
	}
var check=CheckPhoneNumber(theForm.telephone.value);
if (check== false)
	{
		theForm.telephone.focus();
	return (false);
	}		
var check=CheckPhoneNumber(theForm.fax.value);
if (check== false)
	{
		theForm.fax.focus();
	return (false);
	}
}

function SubmitEventsForm(theForm)
{
//first off tell form that javascript is enabled so these checks have been done
theForm.jsChecks.value="Yes";

//now check the required fields exist

	if(theForm.email.value == "")
	{
		alert("Please enter your email address.");
		theForm.email.focus();
return (false);
	}
var check=echeck(theForm.email.value);
if (check== false)
	{
		theForm.email.focus();
	return (false);
	}		
	else if(theForm.event_name.value == "")
	{
		alert("Please enter the event name.");
		theForm.event_name.focus();
return (false);
	}
	else if(theForm.description_short.value == "")
	{
		alert("Please enter the short description for your advert. This is used in the listings.");
		theForm.description_short.focus();
return (false);
	}
	else if(theForm.description_long.value == "")
	{
		alert("Please enter the main description for your advert.");
		theForm.description_long.focus();
return (false);
	}
	else if(theForm.event_type.value == "")
	{
		theForm.event_type.focus();
		alert("Please enter the type of event.");
return (false);
	}
	else if(theForm.area.value == "")
	{
		theForm.area.focus();
		alert("Please select the area where the event is.");
return (false);
	}
var check=CheckPhoneNumber(theForm.telephone.value);
if (check== false)
	{
		theForm.telephone.focus();
	return (false);
	}		
var check=CheckPhoneNumber(theForm.fax.value);
if (check== false)
	{
		theForm.fax.focus();
	return (false);
	}
}

function SubmitClubsForm(theForm)
{
//first off tell form that javascript is enabled so these checks have been done
theForm.jsChecks.value="Yes";

//now check the required fields exist

	if(theForm.email.value == "")
	{
		alert("Please enter your email address.");
		theForm.email.focus();
return (false);
	}
var check=echeck(theForm.email.value);
if (check== false)
	{
		theForm.email.focus();
	return (false);
	}		
	else if(theForm.club_name.value == "")
	{
		alert("Please enter the club name.");
		theForm.club_name.focus();
return (false);
	}
	else if(theForm.description_short.value == "")
	{
		alert("Please enter the short description for your advert. This is used in the listings.");
		theForm.description_short.focus();
return (false);
	}
	else if(theForm.description_long.value == "")
	{
		alert("Please enter the main description for your advert.");
		theForm.description_long.focus();
return (false);
	}
	else if(theForm.club_type.value == "")
	{
		theForm.club_type.focus();
		alert("Please select the type of club.");
return (false);
	}
	else if(theForm.area.value == "")
	{
		theForm.area.focus();
		alert("Please select the geopgraphic area where the club\'s main activities are.");
return (false);
	}
var check=CheckPhoneNumber(theForm.telephone.value);
if (check== false)
	{
		theForm.telephone.focus();
	return (false);
	}		
var check=CheckPhoneNumber(theForm.fax.value);
if (check== false)
	{
		theForm.fax.focus();
	return (false);
	}
}

function SubmitGearForm(theForm)
{
//first off tell form that javascript is enabled so these checks have been done
theForm.jsChecks.value="Yes";

//now check the required fields exist

	if(theForm.email.value == "")
	{
		alert("Please enter your email address.");
		theForm.email.focus();
return (false);
	}
var check=echeck(theForm.email.value);
if (check== false)
	{
		theForm.email.focus();
	return (false);
	}		
	else if(theForm.name.value == "")
	{
		theForm.name.focus();
		alert("Please enter name of them item.");
return (false);
	}
	else if(theForm.gear_type.value == "")
	{
		theForm.gear_type.focus();
		alert("What type of advert is this?");
return (false);
	}
	else if(theForm.description_short.value == "")
	{
		alert("Please enter the short description for your advert. This is used in the listings.");
		theForm.description_short.focus();
return (false);
	}
	else if(theForm.area.value == "")
	{
		theForm.area.focus();
		alert("Please enter where the item is located.");
return (false);
	}
}

function SubmitMatesForm(theForm)
{
//first off tell form that javascript is enabled so these checks have been done
theForm.jsChecks.value="Yes";

//now check the required fields exist

	if(theForm.email.value == "")
	{
		alert("Please enter your email address.");
		theForm.email.focus();
return (false);
	}
var check=echeck(theForm.email.value);
if (check== false)
	{
		theForm.email.focus();
	return (false);
	}		
	else if(theForm.name.value == "")
	{
		theForm.name.focus();
		alert("Please enter your name.");
return (false);
	}
	else if(theForm.age.value == "")
	{
		theForm.age.focus();
		alert("Please enter your age.");
return (false);
	}
	var check=CheckNumber(theForm.age.value);
if (check== false)
	{
		theForm.age.focus();
	return (false);
	}

	else if(theForm.description_short.value == "")
	{
		alert("Please enter the short description for your advert. This is used in the listings.");
		theForm.description_short.focus();
return (false);
	}
	else if(theForm.description_long.value == "")
	{
		alert("Please enter the main description for your advert.");
		theForm.description_short.focus();
return (false);
	}
	else if(theForm.interest.value == "")
	{
		theForm.interest.focus();
		alert("Please choose what you are interested in.");
return (false);
	}
	else if(theForm.area.value == "")
	{
		theForm.area.focus();
		alert("Please choose where you are located.");
return (false);
	}
}


function SubmitShopsForm(theForm)
{
//first off tell form that javascript is enabled so these checks have been done
theForm.jsChecks.value="Yes";

//now check the required fields exist

	if(theForm.email.value == "")
	{
		alert("Please enter your email address.");
		theForm.email.focus();
return (false);
	}
var check=echeck(theForm.email.value);
if (check== false)
	{
		theForm.email.focus();
	return (false);
	}		
	else if(theForm.shop_name.value == "")
	{
		alert("Please enter the shop name.");
		theForm.shop_name.focus();
return (false);
	}
	else if(theForm.description_short.value == "")
	{
		alert("Please enter the short description for your advert. This is used in the listings.");
		theForm.description_short.focus();
return (false);
	}
	else if(theForm.area.value == "")
	{
		theForm.area.focus();
		alert("Please select the area where the shop resides.");
return (false);
	}
var check=CheckPhoneNumber(theForm.telephone.value);
if (check== false)
	{
		theForm.telephone.focus();
	return (false);
	}		
var check=CheckPhoneNumber(theForm.fax.value);
if (check== false)
	{
		theForm.fax.focus();
	return (false);
	}
}


function SubmitAddress(theForm)
{
//first off tell form that javascript is enabled so these checks have been done
theForm.jsChecks.value="Yes";

//now check the required fields exist

	if(theForm.email.value == "")
	{
		alert("Please enter your email address.");
		theForm.email.focus();
return (false);
	}
	else if(theForm.name.value == "")
	{
		alert("Please enter your name.");
		theForm.name.focus();
return (false);
	}
	else if(theForm.address.value == "")
	{
		theForm.address.focus();
		alert("Please enter your street address.");
return (false);
	}
	else if(theForm.city.value == "")
	{
		theForm.city.focus();
		alert("Please enter your town or city.");
return (false);
	}
	else if(theForm.postcode.value == "")
	{
		theForm.postcode.focus();
		alert("Please enter your postcode.");
return (false);
	}
	else if(theForm.country.value == "")
	{
		theForm.country.focus();
		alert("Please select your country.");
return (false);
	}
var check=echeck(theForm.email.value);
if (check== false)
	{
		theForm.email.focus();
	return (false);
	}		
var check=CheckPhoneNumber(theForm.telephone.value);
if (check== false)
	{
		theForm.telephone.focus();
	return (false);
	}		
var check=CheckPhoneNumber(theForm.fax.value);
if (check== false)
	{
		theForm.fax.focus();
	return (false);
	}
var check=CheckPassword(theForm.password.value);
if (check== false)
	{
		theForm.passwd.focus();
	return (false);
	}
}
