/*
 *    AUTHOR:      Xingwu Chai
 *
 *    DESCRIPTION: This JS file has the responsibility of fetching 
 *                 the staff search web service criteria entered, and
 *                 redirecting the browser to the search screen.
 *
 *    ASSUMPTIONS: It is assumed that this js file will be used on
 *                 a web page with a primary form named "StaffSearchForm".
 *                 It is further assumed that the search handler url 
 *                 is "EntryPoint"...
 */

/*
    This is the entry staff search function. Calling it will verify we have
    a form to process. Upon successful verification, reference to form
    will be passed to the staff_search_form function.
*/

function staffsearch(){
    var form = null;
    
    //get a handle to the page's form
    if(document.StaffSearchForm){
        staff_search_form(document.StaffSearchForm);
    }else{
        alert("There was an error processing your request. Please try again later.");
    }
}

/*
    This function performs the bulk of client side processing for staff searches.
    Upon successful validation of search field, it posts data to the staff
    search handler.
*/
function staff_search_form(form){
    staff_search_submit(form);
}

/*
    This function posts the data to the search handler.
    We add "&ch=" to switch to the Home channel when displaying the search results
*/
function staff_search_submit(form){
    var goURL;
    goURL = "EntryPoint?viewtype=staffsearch&action=get_staffsearch&firstName=" + escape(form.firstName.value) + "&lastName=" + escape(form.lastName.value) + "&ch=";
    window.location = goURL;
}
