/* $Header: /WebSites/library/javascript/general/advancedSearch.js 2     4/11/08 9:40a Clavoie $
 *
 * The purpose of this file is to provide additional functionality for the 
 * Advanced Search page, and pages which intend to navigate to the Advanced Search
 * page.
 */

/**
 * This function redirects a form's output to the advanced search page. The form
 * should be one which normally directs to the /s/c/results.asp page.
 *
 * Example:
 *    <a href="" class="link" onclick="GoToAdvancedSearch('AdvancedSearchForm2');">
 *    Advanced Search</a>
 *
 * @param formNameId The string id of the <form> element which should be directed to the
 *                   Advanced Search page. If the id is not specified or invalid the 
 *                   function performs no action.
 */
function GoToAdvancedSearch(formNameId,searchType) {
  try {
    if(!formNameId)
      return;
    if(!searchType)
      searchType = 'a';
    var form = document.getElementById(formNameId.toString());
    if(!form || !(form.submit))
      return;
    form.action = "/s/c/search.asp?s=" + searchType;
    form.submit();
  }// end try to go to the advanced form
  catch(e) {
    if(window.console && window.console.log)
      window.console.log('Could not go to the advanced page: ' + e.toString());
  }// end catch and log errors
}// end function GoToAdvancedSearch(formNameId)

