function validateFields()
{
  alert ('validating fields');
  var lsRegExp = /'/g;  /* Replace apostrophes to fix SQL issue */

  var spotLat = document.getElementById("spotLat");

  if (spotLat.value == "")
  {
	alert("Please click on the map to place this spot");

  	var address = document.getElementById("address");
	address.focus();

    return false;
  }


  var spotName = document.getElementById("spotName");
  spotName = String(spotName).replace(lsRegExp, "''")	

  if (spotName.value == "")
  {
    spotName.className = "error";
	alert("Please give this spot a name");
	spotName.focus();

    return false;
  }

  var spotRating = document.getElementById("spotRating");
  spotRating = String(spotRating).replace(lsRegExp, "''")	

  if (spotRating.value == "")
  {
    spotRating.className = "error";
	alert("Please rate this spot");
	spotRating.focus();

    return false;
  }

  var spotSecurity = document.getElementById("spotSecurity");
  spotSecurity = String(spotSecurity).replace(lsRegExp, "''")	

  if (spotSecurity.value == "")
  {
    spotSecurity.className = "error";
	alert("Please tell us how long you can skate here");
	spotSecurity.focus();

    return false;
  }

  var spotClass = document.getElementById("spotClass");
  spotClass = String(spotClass).replace(lsRegExp, "''")	

  if (spotClass.value == "")
  {
    spotClass.className = "error";
	alert("Please select how we can classify this spot");
	spotClass.focus();

    return false;
  }

  var spotDesc = document.getElementById("spotDesc");
  spotDesc = String(spotDesc).replace(lsRegExp, "''")	

  if (spotDesc.value == "")
  {
    spotDesc.className = "error";
	alert("Please describe this spot");
	spotDesc.focus();

    return false;
  }

	alert ('done validating fields');

	alert ('fixing <br>');

	spotDesc.value=escape(spotDesc.value)

	for(i=0; i<spotDesc.value.length; i++){
 		if(spotDesc.value.indexOf("%0D%0A") > -1){
			spotDesc.value=spotDesc.value.replace("%0D%0A","<br />")
		}
		else if(spotDesc.value.indexOf("%0A") > -1){
			spotDesc.value=spotDesc.value.replace("%0A","<br />")
		}
		else if(spotDesc.value.indexOf("%0D") > -1){
			spotDesc.value=spotDesc.value.replace("%0D","<br />")
		}
	}

	spotDesc.value=unescape(spotDesc.value);

	alert ('done fixing <br>');
	
	return true;

}
