function emptyfield(dataField) 
{
	if (Trim(dataField.value) == "")
		return true;
	else
		return false;
}

function removereturns(dataField)
{
	var v1, v2 = "";

	v1 = dataField.value;
	for (i = 0; i < v1.length; i++){
		var x = v1.charAt(i);
		if (escape(x) == "%0D"){
			v2 += "<br>";
			i = i +1;
		}
		else
			v2 += x;
	}
	dataField.value = v2;
}

function filenameOK(filename)
{
	if(filename.toUpperCase() != "NONE") {
		filetyp = filename.substring(filename.lastIndexOf("."), filename.length);
		if(filetyp.length!=0){
			if ((filetyp != ".gif") && (filetyp != ".jpg") && (filetyp != ".GIF") && (filetyp != ".JPG")) {
				alert("Only GIF or JPG images may be used!");		
				return false;
			}
		}
	}
	return true;
}

function filenameZipOK(filename)
{
	if(filename.toUpperCase() != "NONE") {
		filetyp = filename.substring(filename.lastIndexOf("."), filename.length);
		if(filetyp.length!=0){
			if ((filetyp != ".zip") && (filetyp != ".ZIP")) {
				alert("Only ZIP files may be uploaded!");		
				return false;
			}
		}
	}
	return true;
}

function emailOK(email)
{
	parts=email.split("@");
	if (parts.length>1)
	{
		if (parts[0].length>1)
		{
			domain=parts[1].split(".");
			if (domain.length>1)
			{
				if(domain[0].length>1  && domain[domain.length-1].length>1) {
					return true;
				}
			}
		}
	}
	return false;
}

/*
==================================================================
LTrim(string) : Returns a copy of a string without leading spaces.
==================================================================
*/
function LTrim(str)
/*
   PURPOSE: Remove leading blanks from our string.
   IN: str - the string we want to LTrim
*/
{
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(0)) != -1) {
      // We have a string with leading blank(s)...

      var j=0, i = s.length;

      // Iterate from the far left of string until we
      // don't have any more whitespace...
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;

      // Get the substring from the first non-whitespace
      // character to the end of the string...
      s = s.substring(j, i);
   }
   return s;
}

/*
==================================================================
RTrim(string) : Returns a copy of a string without trailing spaces.
==================================================================
*/
function RTrim(str)
/*
   PURPOSE: Remove trailing blanks from our string.
   IN: str - the string we want to RTrim

*/
{
   // We don't want to trip JUST spaces, but also tabs,
   // line feeds, etc.  Add anything else you want to
   // "trim" here in Whitespace
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      // We have a string with trailing blank(s)...

      var i = s.length - 1;       // Get length of string

      // Iterate from the far right of string until we
      // don't have any more whitespace...
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;


      // Get the substring from the front of the string to
      // where the last non-whitespace character is...
      s = s.substring(0, i+1);
   }

   return s;
}

/*
=============================================================
Trim(string) : Returns a copy of a string without leading or trailing spaces
=============================================================
*/
function Trim(str)
/*
   PURPOSE: Remove trailing and leading blanks from our string.
   IN: str - the string we want to Trim

   RETVAL: A Trimmed string!
*/
{
   return RTrim(LTrim(str));
}

