// Turn off the alert pop up
wf.showAlertOnError = false;

// Replace the standard validation routine and do our Ajax stuff
wf.functionName_formValidation = "myCustomValidation";
function myCustomValidation (evt) {
    // Determine which form we're dealing with
    var srcForm = wf.utilities.getSrcElement(evt);
    while (srcForm && srcForm.tagName.toUpperCase() != 'FORM') {
       srcForm = srcForm.parentNode;
    }
    var opt;
    var successDiv;
    var formAction;
    if (srcForm.name == 'ccc_contactcustcare') {
       successDiv = 'ccc_emailSuccess';
       formAction = '../php/ccc_sendmail.php';
       opt = {
          onLoading: function(request) {
             sendmail_onLoading('ccc_loadBar');
          },
          onComplete: function(request) {
             sendmail_onComplete('ccc_loadBar', successDiv);
          },
          parameters: Form.serialize(srcForm),
          insertion: Insertion.Bottom,
          asynchronous: true
       }
    } else {
       if (srcForm.name == 'nsn_quoterequest') {
          successDiv = 'nsn_emailSuccess';
          formAction = '../php/nsn_sendmail.php';
          opt = {
             onLoading: function(request) {
                sendmail_onLoading('nsn_loadBar');
             },
             onComplete: function(request) {
                sendmail_onComplete('nsn_loadBar', successDiv);
             },
             parameters: Form.serialize(srcForm),
             insertion: Insertion.Bottom,
             asynchronous: true
          }
       }
    }
    if(wf.formValidation(evt)) {
       if (!(successDiv == undefined || formAction == undefined)) {
          new Ajax.Updater(successDiv, formAction, opt);
          return wf.utilities.XBrowserPreventEventDefault(evt);
       }
    }
}
function sendmail_onLoading(theLoadingDiv) {
    // Make the Progress Bar Appear
    new Effect.Appear(theLoadingDiv, {queue: 'front'});
}
function sendmail_onComplete(theLoadingDiv, theSuccessDiv) {
    // Fade the Progress Bar
    new Effect.Fade(theLoadingDiv);
    // Show the result!
    new Effect.Appear(theSuccessDiv, {queue: 'end'});
}