/****
 * Check empty fields in pricing form
 *
 * Receive the form and check each field to verify
 *
 */


function checkrequired(which) 
{
    var pass=true;
    if (document.images) 
    {
        for (i=0;i<which.length;i++) 
        {
            var tempobj=which.elements[i];
            if (tempobj.name.substring(0,8)=="required") 
            {
                if (((tempobj.type=="text"||tempobj.type=="textarea")&& 
                tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
                tempobj.selectedIndex==0)) 
                {
                    pass=false;
                    break;
                }
                
                if (tempobj.name.substring(8,30) == "email")
                {
                    strEmail = tempobj.value;
                }
            }
        }
    }
    
    if (!pass) 
    {
        shortFieldName=tempobj.name.substring(8,30).toUpperCase();
        alert("Please make sure the "+shortFieldName+" field was properly completed.");
        return false;
    }
    else
    {
        if (!validateEmail(strEmail))
        {
            return false;
        }
        return true;
    }
}




/****
 * Check for a valid email address
 *
 * For those just looking for the Regular Expression
 * to match the email address
 *
 */

function validateEmail(strEmail)
{
    var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    //str = document.getElementById('emailAddress').value;
    if(strEmail.match(emailRegEx))
    {
        return true;
    }
    else
    {
        alert('Please enter a valid email address.');
        return false;
    }
}
