function RTrim(theString)
{    
	var start = 0;    
	var end = theString.length - 1;    
	var trimming = true;    

	while ( trimming && end >= start )    
	{      
		if ( theString.charAt(end) == " " )      
		{        
			end--;      
		} else {        
			trimming = false;      
		}    
	}    
	if ( end < 0 )    
	{      
		end = 0;    
	}    
	return theString.substring(start,end + 1);  
}  

function CheckFields()  {    
	var theForm = document.freebies;    
	var FormError = false;    
	var ErrorMsg = "We need more information in order to contact you:\n";	


	if ((theForm.Firstname.value == null) || (RTrim(theForm.Firstname.value) == ""))
	{      
		FormError = true;      
		ErrorMsg += "\n    Please fill in your first name.";    
	} 
	if ((theForm.Lastname.value == null) || (RTrim(theForm.Lastname.value) == ""))
	{      
		FormError = true;      
		ErrorMsg += "\n    Please fill in your last name.";    
	} 
	if ((theForm.Address1.value == null) || (RTrim(theForm.Address1.value) == ""))
	{      
		FormError = true;      
		ErrorMsg += "\n    Please fill in your address in the Address1 line.";    
	} 
	if ((theForm.City.value == null) || (RTrim(theForm.City.value) == ""))
	{      
		FormError = true;      
		ErrorMsg += "\n    Please fill in your City.";    
	} 
	if ((theForm.State.value == null) || (RTrim(theForm.State.value) == ""))
	{      
		FormError = true;      
		ErrorMsg += "\n    Please fill in your State.";    
	} 
	if ((theForm.Zip.value == null) || (RTrim(theForm.Zip.value) == ""))
	{      
		FormError = true;      
		ErrorMsg += "\n    Please fill in your Zip or Postal code.";    
	} 
	if ((theForm.email.value == null) || (RTrim(theForm.email.value) == ""))
	{      
		FormError = true;      
		ErrorMsg += "\n    Please fill in your e-mail.";    
	} 
	if ((theForm.Dayphone.value == null) || (RTrim(theForm.Dayphone.value) == ""))
	{      
		FormError = true;      
		ErrorMsg += "\n    Please fill in your Daytime Phone number.";    
	} 



	if ( FormError )    
	{      
		alert(ErrorMsg);      
		return false;    
	} else {      
		return true;    
	}  
}