/*-- Validation Functions --*/

function validate_for_numeric_only(num)
{
     var re = /(^-?\d\d*$)/;

     return re.test(num);
}

function validate_email(mail_add)
{
     /*-- Check for invalid characters --*/
     var re = /\w+|[@_.]+/;
     for(var i=0; i<mail_add.length; i++)
          if(!re.test(mail_add.charAt(i)))
               return false;

	/*-- Make sure there is an "@" symbol --*/
     var at_pos = mail_add.indexOf("@",1)
	if (at_pos == -1)
		return false;

     /*-- Make sure there is a domain --*/
	if(mail_add.charAt(at_pos+1) == ".")
         return false;

     /*-- Make sure there is only one "@" symbol --*/
	if (mail_add.indexOf("@", at_pos+1) > -1)
		return false;

     /*-- Make sure there is a dot --*/
	var period_pos = mail_add.indexOf(".", at_pos)
	if (period_pos == -1)
		return false;

     /*-- Mare sure there are only three letters after the period. --*/
	if (period_pos+3 > mail_add.length)
		return false;

	return true;
}

function validate_zip_code(num)
{
    /*-- Declare Regular Expression --*/
     var re = /\d+/;

     /*-- Loop through account number and make --*/
     /*-- sure all characters are numbers.     --*/
     for(var i=0; i<num.length; i++)
     {
          if(!re.test(num.charAt(i)))
          {
               /*-- There is a non-numeric character --*/
               return false;
          }
     }
     return true;
}

function validate_phone_number(num)
{
     /*-- Check for invalid characters --*/
     var re = /\d+|[.() -]+/;
     for(var i=0; i<num.length; i++)
          if(!re.test(num.charAt(i)))
               return false;
     return true;
}