/**
 * This file is part of the Ultimate Office Website
 * Copyright (c) 2006, SpyderHost.net, Inc.
 * All Rights Reserved
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * File     $Id: formcheck.js 1164 2006-11-13 21:20:38Z dfdugal $ <br>
 * Author   $Author: dfdugal $
 * @package ultoffice
 */
 
 
 /**
  * matchEmail
  * Function will Verify email address. Pass in the email id and the verify email id. If it failes it will
  * change the color of the input box. Once they click in the box it should call inputReset to reset the
  * colors.
  * Found example @ http://www.javascriptkit.com/script/script2/acheck.shtml
  * @param {string} email 
  * @param {string} v_email
  */
  function matchEmail(email, v_email) {
    if(email.length < 5){
       document.getElementById('email').style.backgroundColor = "red";
       document.getElementById('email_msg').innerHTML = "Please enter a Valid Address";
       return false
    }
    else {
     var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
      if (filter.test(email)) {
         // everything is okay.
      } else{
         document.getElementById('email').style.backgroundColor = "red";
         document.getElementById('email_msg').innerHTML = "Invalid E-mail Address";         
         return false;
      }
     }
     if(email != v_email){
        document.getElementById('email').style.backgroundColor = "red";
        document.getElementById('v_email').style.backgroundColor = "red";
        document.getElementById('email_msg').innerHTML = "E-mail address does not match";
         return false;
     }
     return true;
   }
   
   /**
    * resetInput
    */
    function resetInput(email) {
    	document.getElementById('email').style.backgroundColor = "transparent";
    	document.getElementById('v_email').style.backgroundColor = "transparent";
    	document.getElementById('email_msg').innerHTML = "";
    }