/******* Collection of reusable functions *******/

function trim(value) 
{
   var temp = value;
   var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
   if (obj.test(temp)) { temp = temp.replace(obj, '$2'); }
   var obj = / +/g;
   temp = temp.replace(obj, " ");
   if (temp == " ") { temp = ""; }
   return temp;
}

// validate email - from CodeToad.com
function isValidEmail(str)
{

   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}