/* Welcome uses jQuery to Run. */

// Set the code that runs when the page is ready
$(document).ready(function () {
                      // Add events
                      if (SM == 'y') {
                          sendWelcomeEmail();
                      }
                  });

// This function validates the form data
function sendWelcomeEmail() {
    // Make sure we have the data we want
    if (UID.length < 1) {
        showFaderMsg({msg: 'The Welcome email was not sent. [GT_E0232]',
                      msgContainer: '#errMsg', msgIsErr: true, pauseDur:15000});
        $('#myparentname').focus();
        return;
    }

    // Send the confirmation email
    jQuery.getJSON(BASEURL+'users/welcomeEmail',
                   {userid: UID, baseurl: SITEURL, syn: SYN, ack: ACK,
                   synlist:genS(['userid','baseurl']),
                   acklist:genH(UID + SITEURL), rand: Math.random()},
                   function(data, textStatus) {
                       // Decode the JSON
                       results = data;

                       // Check to make sure there was no error
                       if (!results.success) {
                           // Show a message
                           showFaderMsg({msg: 'The Welcome email was not sent.&nbsp;[' + results.errorNumber + ']&nbsp;' + results.extendedText,
                                        msgContainer: '#errMsg', msgIsErr: true, pauseDur:15000});
                           return;
                       }

                       // The email was sent.
                       showFaderMsg({msg: 'The Welcome has been sent.',
                                    msgContainer: '#errMsg', msgIsErr: false});
                       return;
                   });
}

