function isEmail(string) {
if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
return true;
else
return false;
}

function checksubscribed()
{
   // the variables below are assigned to each
   // form input
   var fname, femail;

   with(window.document.subscribe)
   {
      fname = fullname;
      femail = email;
   }

   // alert the visitor if email is empty or
   // if the format is not correct
   if( trim(fname.value) == '' )
   {
      alert('Please enter a name for your subscription account');
      fname.focus();
      return false;
   }
   // alert the visitor if message is empty
   else if( trim(femail.value) == '' || !isEmail(trim(femail.value)) )
   {
      alert('Please enter a valid email address.');
      femail.focus();
      return false;
   }
   else
   {
      // when all input are correct
      // return true so the form will submit
      return true;
   }
}


function trim(str)
{
   return str.replace(/^\s+|\s+$/g,'');
}


function checkform()
{
   // the variables below are assigned to each
   // form input
   var oldcat, cat, url, name, desc;

   with(window.document.linksubmit)
   {
      oldcat= catName;
      cat	= newCat;
      url	= linkURL;
      name	= linkName;
	  desc	= linkDesc;
   }

   if ( (trim(oldcat.value) == '' && trim(cat.value) == '' )
   || ( trim(oldcat.value) != ''  && trim(cat.value) != '' ) )
   {
      alert('Either select a category, or suggest a new category');
      oldcat.focus();
      return false;
   }
   // alert the visitor if email is empty or
   // if the format is not correct
   else if( trim(url.value) == '' )
   {
      alert('Please enter a valid URL for submission');
      url.focus();
      return false;
   }
   // alert the visitor if message is empty
   else if( trim(name.value) == '' )
   {
      alert('Please enter a name for the link');
      name.focus();
      return false;
   }
   else if( trim(desc.value) == '' )
   {
      alert('Please enter a description for the link');
      desc.focus();
      return false;
   }
   else
   {
      // when all input are correct
      // return true so the form will submit
      return true;
   }
}
