
function validateContactDetails(aForm) {


	if( ! aForm.name.value ){
		alert("Please fill in your name");
		return false;
	}
	
	if( ! aForm.town.value ){
		alert("Please let us know where you live");
		return false;
	}
	
	if(! isValidEmail(aForm.email.value)){
		alert("Please insert a valid email address");
	
		return false;
	}



	if(aForm.telephone && ! aForm.telephone.value){
		alert("Telephone number is required!");
		return false;
	}

	aForm.submit();

}


function validateCompetitionForm(){

	if( ! contribution.name.value ){
		alert("Please fill in your name");
		return false;
	}
		
	if(! isValidEmail(contribution.email.value)){
		alert("Please insert a valid email address");
	
		return false;
	}

	if(! contribution.answer.value){
		alert("An answer is needed!");
		return false;
	}

	if(contribution.prize && ! contribution.prize.value){
		alert("Please specify a prize!");
		return false;
	}

	if(contribution.telephone && ! contribution.telephone.value){
		alert("Telephone number is required!");
		return false;
	}

	contribution.submit();
}





function validateCompetitionForm(){

	if( ! contribution.name.value ){
		alert("Please fill in your name");
		return false;
	}
		
	if(! isValidEmail(contribution.email.value)){
		alert("Please insert a valid email address");
	
		return false;
	}

	if(! contribution.answer.value){
		alert("An answer is needed!");
		return false;
	}

	if(contribution.prize && ! contribution.prize.value){
		alert("Please specify a prize!");
		return false;
	}

	if(contribution.telephone && ! contribution.telephone.value){
		alert("Telephone number is required!");
		return false;
	}

	contribution.submit();
}


function validateYoursayForm(){

	if( ! contribution.subject.value ){
		alert("Please say what you're contacting us about");
		return false;
	}

	if( ! contribution.yoursay.value ){
		alert("You must be contacting us about something!");
		return false;
	}
		
		
	if( ! contribution.town.value ){
		alert("Please say where you're from");
		return false;
	}
		

	if( ! contribution.name.value ){
		alert("Please fill in your name");
		return false;
	}
		
	if(! isValidEmail(contribution.email.value)){
		alert("Please insert a valid email address");
	
		return false;
	}

	var i;
	var str = contribution.yoursay.value;

	var someLowerCase=false;
	for(i=0; i< str.length; i++){
		
		if(str.charCodeAt(i) >= 97 && str.charCodeAt(i) <= 122){
			someLowerCase=true;
		}
	}
	
	
	if(! someLowerCase){
		contribution.yoursay.value = contribution.yoursay.value.toLowerCase();
	}

	contribution.submit();
}

function validateEventsForm(){
/* event dates times cost details eaddress epostcode phonepublic emailpublic website */

	if( ! contribution.event.value ){
		alert("Please fill in the name of the event");
		return false;
	}
	
	if( ! contribution.dates.value ){
		alert("Please fill in the date of the event");
		return false;
	}
	if( ! contribution.times.value ){
		alert("Please fill in the times of the event");
		return false;
	}	
	if( ! contribution.cost.value ){
		alert("Please fill in the cost of admission. If admission is free of charge, please say so");
		return false;
	}	
	if( ! contribution.details.value ){
		alert("Please tell us the details of the event");
		return false;
	}
	if( ! contribution.eaddress.value ){
		alert("Please fill in the address of the event");
		return false;
	}	
	
	if( ! contribution.epostcode.value ){
		alert("Please fill in the postcode of the event. This will allow us to include a map with the listing");
		return false;
	}	
	
	
	if( ! contribution.phonepublic.value && ! contribution.phonevenue.value){
		alert("Please fill in a phone number either for the event, or the venue, or both");
		return false;
	}
	
	
	if( ! contribution.emailpublic.value || ! isValidEmail(contribution.emailpublic.value)){
		alert("Please fill in a valid email address for the event");
		return false;
	}	
	
	if(! isValidEmail(contribution.email.value)){
		alert("Please insert a valid email address for yourself");
	
		return false;
	}
	contribution.submit();
}

function validateUnsignedbandsForm(){
/* band from members when_did_you_start where_play favourite_local_venue best_moment style_and_influences songs_covered recordings_available future_plans any_other_local_bands_you_rate bad_gigging_moments whats_in_the name fantasy_venue like_to_see new_law anythingelse website connection

only validate key fields

*/

	if( ! contribution.band.value ){
		alert("Please fill in the name of the band or artist");
		return false;
	}
	
	if( ! contribution.members.value ){
		alert("Please fill in the members of your band, or the name of the artist");
		return false;
	}
	if( ! contribution.connection.value ){
		alert("Please state your connection to the band or artist");
		return false;
	}	
	
	if( ! contribution.name.value ){
		alert("Please fill in your name");
		return false;
	}		
	if(! isValidEmail(contribution.email.value)){
		alert("Please insert a valid email address for yourself");
	
		return false;
	}	

	contribution.submit();
}

function validateArtistProfileForm(){
/*
only validate key fields

*/
    
	if( ! contribution.where.value ){
		alert("Please let us know where you are");
		return false;
	}
	
	if( ! contribution.how_did_you_get_started.value ){
		alert("Please let us know how you began");
		return false;
	}
	if( ! contribution.media.value ){
		alert("Please let us know what medium/media you work in");
		return false;
	}	
	if( ! contribution.influences_inspirations.value ){
		alert("Please let us know what your influences and inspirations are");
		return false;
	}	
	
	if( ! contribution.where_exhibiting.value ){
		alert("Please let us know where you are exhibiting");
		return false;
	}		
		
	if( ! contribution.name.value ){
		alert("Please fill in your name");
		return false;
	}	
	
	if(! isValidEmail(contribution.email.value)){
		alert("Please insert a valid email address for yourself");
	
		return false;
	}	

	contribution.submit();
}




function validateNewsletterForm(){


	if(! isValidEmail(contribution.email.value)){
		alert("Please insert a valid email address");
	
		return false;
	}	

	contribution.submit();
}


function isValidEmail(email) {
	var niceEmail = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/g;
	if (! email.match(niceEmail) ) {
  	 return false;
   } else {
   return true;
   }
 
 }




