
/******************************************************************************
 *                                                                            *
 *  client-side validation functions                                  *
 *                                                                            *
 ******************************************************************************/

function properCase(strInput, strSplitChar)
{
    // converts a string to Proper Case
    if (strSplitChar == undefined)
    {
          // use space by default
          var strSplitChar = " ";
    }

    strArray = strInput.split(strSplitChar);

    for (var i = 0; i < strArray.length; i++)
    {
        if (strArray[i].length > 1)
        {
            strArray[i] = strArray[i].charAt(0).toUpperCase() + strArray[i].substr(1).toLowerCase();
        }
        else if (strArray[i].length == 1)
        {
            strArray[i] = strArray[i].toUpperCase();
        }
    }
    return strArray.join(" ");
}

function validateEmail(tempEmail)
{

   var valid = true;
   len = tempEmail.length;

   if(len==0){
        valid = false;
   }


   spaces = tempEmail.indexOf(' ');
        // check for spaces
        if(spaces != -1)
                valid = false;

   ampers = tempEmail.indexOf('&');
        // check for ampersands
        if(ampers != -1)
                valid = false;

   at = tempEmail.indexOf('@');
        // check there is a at sign
        if(at == -1)
                valid = false;

   atmore = tempEmail.indexOf('@',(at+1));
        // check for more at signs
        if(atmore != -1)
                valid = false;

   dot = tempEmail.indexOf('.',at);
        // check for a dot after the at sign
        if(dot== -1)
                valid = false;

   if((at == 0)||(at== len))
   {
        // check where the at sign is
        valid = false;
   }

   return valid;
}



