// JavaScript Document
function checkcommunityform(id){
	if(id==1){		
		if($('loginEmailAddress').value==''){alert('Please enter your email address you used to signup with.');return false;}
		if($('loginpassword').value==''){alert('Please enter your password.');return false;}
	}
	if(id==2){	
		if($('contactname').value==''){alert('Please enter a contact name.');return false;}
		if($('signupEmailAddress').value==''){alert('Please enter an email address.');return false;}
		if($('signupPassword').value==''){alert('Please enter a password.');return false;}		
	}
	return true;
}


function clearDates(date){
	$($('StartDate').value).style.background='';
	if($('EndDate').value!=''){
		$($('EndDate').value).style.background='';
	}
	$('StartDate').value=date;					
	$('EndDate').value='';		
}

function selectDate(cell,date,sw){	
	if(sw==2){		
		if($('StartDate').value==date){
			$($('StartDate').value).style.background='';
			$('StartDate').value='';
			if($('EndDate').value!=''){
				$('StartDate').value=$('EndDate').value;
				$('EndDate').value='';
			}
			return false
		}		
		if($('EndDate').value==date){
			$($('EndDate').value).style.background='';
			$('EndDate').value='';			
			return false
		}		
		
		if($('StartDate').value==''){		
			$('StartDate').value=date;
			$('EndDate').value=date;
		}else{	
			if($(cell).next('td')){
				//Friday				
				if($('StartDate').value==$(cell).next('td').id){
					$('EndDate').value=$('StartDate').value
					$('StartDate').value=date;						
				}else{					
					clearDates(date)		
				}				
			}else{
				//Saturday
				if($('StartDate').value==$(cell).previous('td').id){
					$('EndDate').value=date;	
				}else{
					clearDates(date)				
				}
			}
		}	
	}else{			
		if($('StartDate').value==date){
			$($('StartDate').value).style.background='';
			$('StartDate').value='';
			$('EndDate').value='';
			return false
		}	
		if($('StartDate').value!=''){
			$($('StartDate').value).style.background='';
		}	
		$('StartDate').value=date;
		$('EndDate').value=date;		
	}	
	$(cell).style.background='#3b8d3b';
}

function placeBooking(){
	if($('StartDate').value==''){
		alert('Please select a booking date for your selected booking')
	}else{
		window.location='?Booking=1&StartDate='+$('StartDate').value+'&EndDate='+$('EndDate').value	
	}
}

function bookingCheckForm(){
	if($('Contactname').value==''){alert('Please enter a contact name');$('Contactname').focus();return false;}
	if($('CharityName').value==''){alert('Please enter a group name');$('CharityName').focus();return false;}
	if($('Town').value==''){alert('Please enter your location');$('Town').focus();return false;}
	if($('Postcode').value==''){alert('Please enter your postcode');$('Postcode').focus();return false;}
	if($('Telephone').value==''){alert('Please enter a contact telephone number');$('Telephone').focus();return false;}
	if($('Email').value==''){alert('Please enter your email address');$('Email').focus();return false;}
	if($('RegCharityNo')){
		if($('RegCharityNo').value==''){alert('Please enter your charity number');$('RegCharityNo').focus();return false;}
	}
	return true;
}