<!--
/////////////////////////////////////////////////////////////////////////////////////////////
//  
// Procedure:   frmContact_onSubmit(objForm)
// Purpose:     Validates the Contact form.
// Programmer:  the king
// Date:        may/2004
// inputs:      objForm. A form object.
// outputs:     True or false value depending whether there is no validation errors.
//
/////////////////////////////////////////////////////////////////////////////////////////////
function frmSubscribe_onSubmit(objForm) {

    var strMissingInfo = "";
            
    strMissingInfo += checkTextForEmailAddr(objForm.txtEmail, '\n     -  Your email', 'subscribe', 'subscribetexterror');

    if (strMissingInfo != "") 
    {
        strMissingInfo = "To send your message, you must enter:\n" +
                           "_____________________________________\n" +
        strMissingInfo + "\n_____________________________________" +
        "\n\nPlease re-enter and submit again!";
        alert(strMissingInfo);
        return false;
    }
    else {
        try
        {
            objForm.cmdSubmit.disabled = true;
        }
        catch(ex)
        {
        }
        return true;
    }
}   

/////////////////////////////////////////////////////////////////////////////////////////////
//  
// Procedure:   frmTrade_onSubmit(objForm)
// Purpose:     Validates the Contact form.
// Programmer:  the king
// Date:        may/2004
// inputs:      objForm. A form object.
// outputs:     True or false value depending whether there is no validation errors.
//
/////////////////////////////////////////////////////////////////////////////////////////////
function frmTrade_onSubmit(objForm) {

    var strMissingInfo = "";
    strMissingInfo += checkTextForNullValue(objForm.txtName, '\n     -  Your name', 'text', 'texterror');
    strMissingInfo += checkTextForEmailAddr(objForm.txtEmail, '\n     -  Your email', 'text', 'texterror');
    strMissingInfo += checkTextForNullValue(objForm.txtMessage, '\n     -  Your message', 'textarea', 'textareaerror');

    if (strMissingInfo != "") 
    {
        strMissingInfo = "To send your message, you must enter:\n" +
                           "_____________________________________\n" +
        strMissingInfo + "\n_____________________________________" +
        "\n\nPlease re-enter and submit again!";
        alert(strMissingInfo);
        return false;
    }
    else {
        objForm.cmdSubmit.disabled = true;
        return true;
    }
}   

function checkTextForNullValue(objFormElement, strErrorMsg, strClass, strClassError) {
    var rc;
        
    if (objFormElement.value == '') {
        objFormElement.className = strClassError;
        rc = strErrorMsg;
    } else {
        objFormElement.className = strClass;
        rc = '';
    }
    return rc;
}

function checkSelectForNullValue(objFormElement, strErrorMsg, strClass, strClassError) {
    var rc;
    
    if (objFormElement.options[objFormElement.selectedIndex].value == '') {
        objFormElement.className = strClassError;
        rc = strErrorMsg;
    } else {
        objFormElement.className = strClass;
        rc = '';
    }
    return rc;
}
function checkTextForEmailAddr(objFormElement, strErrorMsg, strClass, strClassError) {
    var rc;
        
    if (!IsEmail(objFormElement.value)) {
        objFormElement.className = strClassError;
        rc = strErrorMsg;
    } else {
        objFormElement.className = strClass;
        rc = '';
    }
    return rc;
}
function IsEmail(Expression)
    {
        if (Expression == null)
            return (false);

        var supported = 0;
        if (window.RegExp)
        {
            var tempStr = "a";
            var tempReg = new RegExp(tempStr);
            if (tempReg.test(tempStr)) supported = 1;
        }
        if (!supported) 
            return (Expression.indexOf(".") > 2) && (Expression.indexOf("@") > 0);
        var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
        var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
        return (!r1.test(Expression) && r2.test(Expression));
    }
    //-->
