function isBadWord(content)
{
    x = content.split(" ");

    for(i=0;i<x.length;i++)
    {
        for(j=0;j<badwords.length-1;j++)
        {
            if(badwords[j].toLowerCase()==x[i].toLowerCase())
            return true;
        }
    }
    return false;
}

function spotCheck()
{
  if(IsBlank('spot','user_name'))
  {
   alert("Please Enter the Name.");
   return false;
  }
  if(IsEmail('spot','email'))
  {
   alert("Please Enter the Valid Email.");
   return false;
  }
  if(IsBlank('spot','country'))
  {
   alert("Please Enter the Country.");
   return false;
  }
 
  if(IsBlank('spot','spot_name'))
  {
   alert("Please Enter the Spot Name.");
   return false;
  }
  var sStr1 = document.spot.spot_name.value;
  sStr1 = sStr1.toString();
  sStr1 = sStr1.toLowerCase(); 
  sStr1 = sStr1.replace(/(^\s*)|(\s*$)/g,"");          
  sStr1 = sStr1.replace(/\s{1,}/g,"_") ;                        
  sStr1 = sStr1.replace(/(\-)/g,  "_") ;          
  sStr1 = sStr1.replace(/(\|)/g,  "_") ; 
  sStr1 = sStr1.replace(/(\[)/g,  "_") ; 
  sStr1 = sStr1.replace(/(\])/g, "_") ;           
  sStr1 = sStr1.replace(/(\{)/g, "_") ; 
  sStr1 = sStr1.replace(/(\})/g, "_") ;           
  sStr1 = sStr1.replace(/(\,)/g, "_") ;           
  sStr1 = sStr1.replace(/(\/)/g, "_") ; 
  sStr1 = sStr1.replace(/(\])/g, "_") ; 
  sStr1 = sStr1.replace(/(\))/g, "_") ;            
  sStr1 = sStr1.replace(/(\()/g, "_") ;            
  sStr1 = sStr1.replace(/(\~)/g, "") ;
  sStr1 = sStr1.replace(/(\`)/g, "") ; 
  sStr1 = sStr1.replace(/(\!)/g, "") ;
  sStr1 = sStr1.replace(/(\@)/g, "") ;
  sStr1 = sStr1.replace(/(\#)/g, "") ; 
  sStr1 = sStr1.replace(/(\$)/g, "") ;  
  sStr1 = sStr1.replace(/(\%)/g, "") ;
  sStr1 = sStr1.replace(/(\^)/g, "") ;
  sStr1 = sStr1.replace(/(\&)/g, "") ;
  sStr1 = sStr1.replace(/(\*)/g, "") ; 
  sStr1 = sStr1.replace(/(\+)/g, "") ; 
  sStr1 = sStr1.replace(/(\=)/g, "") ;  
  sStr1 = sStr1.replace(/(\\)/g, "") ;
  sStr1 = sStr1.replace(/(\:)/g, "") ; 
  sStr1 = sStr1.replace(/(\")/g, "") ; 
  sStr1 = sStr1.replace(/(\')/g, "") ; 
  sStr1 = sStr1.replace(/(\;)/g, "") ;                              
  sStr1 = sStr1.replace(/(\<)/g, "") ; 
  sStr1 = sStr1.replace(/(\>)/g, "") ; 
  sStr1 = sStr1.replace(/(\.)/g, "") ; 
  sStr1 = sStr1.replace(/(\?)/g, "") ;   
               
  document.spot.ref_spot_name.value  = sStr1;
    
  if(IsBlank('spot','spot_country'))
     {
       alert("Please Select the Spot Country.");
       return false;
     }
  
  if(IsBlank('spot','new_region'))
  {
      if(IsBlank('spot','spot_region'))
      {
           alert("Please Select the Spot Region.");
           return false;
      }
  }
  
  if(isBadWord(document.getElementById('access_spot_text').value))
  {
        alert("Bad word provided in How do you get to this spot.");
        return false;
  }

  if(isBadWord(document.getElementById('additional_info').value))
  {
        alert("Bad word provided in Describe the spot.");
        return false;
  }

  if(isBadWord(document.getElementById('about_atmosphere').value))
  {
        alert("Bad word provided in Things to do when it's flat...");
        return false;
  }

  if(isBadWord(document.getElementById('about_site').value))
  {
        alert("Bad word provided in What are your recommendations for Surf shops...");
        return false;
  }

  return true;
  document.spot.submit;
}

function editspotCheck()
{
      if(IsBlank('spot','user_name'))
      {
       alert("Please Enter the Name.");
       return false;
      }
      if(IsEmail('spot','email'))
      {
       alert("Please Enter the Valid Email.");
       return false;
      }
      if(IsBlank('spot','country'))
      {
       alert("Please Enter the Country.");
       return false;
      } 
     return true;
     document.spot.submit; 
}

function resubmit()
    {
         //document.spot.action="addspot.php";
         document.spot.submit();
         return true;
    }

 
