var skin = "NYU"

/** Function: string getBasicBobcatSearchScreen
  *  Navigates to the Basic Search Screen in BobCat
  * 
  * Parameters:
  *  boolean pop_new_window:
  *    Flags whether launch in a new window
  *    true - launch new screen in new window
  *    false - load new screen in current window
  */
function getBasicBobcatSearchScreen (pop_new_window) {
  getBobcatSearchScreen (pop_new_window, "basic", "")
}

/** Function: string getExpertBobcatSearchScreen
  *  Navigates to the Expert Search Screen in BobCat
  * 
  * Parameters:
  *  boolean pop_new_window:
  *    Flags whether launch in a new window
  *    true - launch new screen in new window
  *    false - load new screen in current window
  */
function getExpertBobcatSearchScreen (pop_new_window) {
  getBobcatSearchScreen (pop_new_window, "expert", "")
}

/** Function: string getReserveBobcatSearchScreen
  *  Navigates to the Reserve Search Screen in BobCat
  * 
  * Parameters:
  *  boolean pop_new_window:
  *    Flags whether launch in a new window
  *    true - launch new screen in new window
  *    false - load new screen in current window
  */
function getReserveBobcatSearchScreen (pop_new_window) {
  getBobcatSearchScreen (pop_new_window, "reserve", "")
}

/** Function: string getPatronBobcatSearchScreen
  *  Navigates to the Patron Login Screen in BobCat
  * 
  * Parameters:
  *  boolean pop_new_window:
  *    Flags whether launch in a new window
  *    true - launch new screen in new window
  *    false - load new screen in current window
  */
function getPatronBobcatLoginScreen (pop_new_window) {
  getBobcatSearchScreen (pop_new_window, "patron", "")
}

/** Function: string getPatronBobcatSearchScreen
  *  Navigates to the specified search screen in BobCat
  * 
  * Parameters:
  *  boolean pop_new_window:
  *    Flags whether launch in a new window
  *    true - launch new screen in new window
  *    false - load new screen in current window
  *
  *  string search_type (optional):
  *    basic - Basic Search Screen
  *    expert - Expert Search Screen
  *    reserve - Reserve Search Screen
  *    patron - Patron Login Screen
  */
function getBobcatSearchScreen (pop_new_window, search_type, pop_options) {
  var bobcat_url;
  switch (search_type) {
    case "basic":
      bobcat_url = EZBobcatBasicSearchScreenURLGenerator(skin);
      break;
    case "expert":
      bobcat_url = EZBobcatExpertSearchScreenURLGenerator(skin);
      break;
    case "reserve":
      bobcat_url = EZBobcatReserveSearchScreenURLGenerator(skin);
      break;
    case "patron":
      bobcat_url = EZBobcatPatronLoginScreenURLGenerator(skin);
//      bobcat_url = EZBobcatBasicSearchScreenURLGenerator(skin);
      break;
    default:
      break;
  }
  if (bobcat_url) {
    launchBobcat(bobcat_url, pop_new_window, pop_options);
  }
}

/** Function: string searchBobcatByAllKeywordForScores
  *  Executes a single term Keyword Search in All Keywords limited by Scores in BobCat
  * 
  * Parameters:
  *  string term:
  *    search term
  *  string attribute:
  *    search attribute
  *  boolean pop_new_window:
  *    Flags whether launch in a new window
  *    true - launch new screen in new window
  *    false - load new screen in current window
  */
function searchBobcatByAllKeywordForScores (term, pop_new_window) {
  searchBobcatByKeyword (term, pop_new_window, "score");
}

/** Function: string searchBobcatByAllKeywordForSounds
  *  Executes a single term Keyword Search in All Keywords limited by Sounds in BobCat
  * 
  * Parameters:
  *  string term:
  *    search term
  *  string attribute:
  *    search attribute
  *  boolean pop_new_window:
  *    Flags whether launch in a new window
  *    true - launch new screen in new window
  *    false - load new screen in current window
  */
function searchBobcatByAllKeywordForSounds (term, pop_new_window) {
  searchBobcatByKeyword (term, pop_new_window, "sound");
}

/** Function: string searchBobcatByAllKeywordForVideos
  *  Executes a single term Keyword Search in All Keywords limited by Videos in BobCat
  * 
  * Parameters:
  *  string term:
  *    search term
  *  string attribute:
  *    search attribute
  *  boolean pop_new_window:
  *    Flags whether launch in a new window
  *    true - launch new screen in new window
  *    false - load new screen in current window
  */
function searchBobcatByAllKeywordForVideos (term, pop_new_window) {
  searchBobcatByKeyword (term, pop_new_window, "video");
}

/** Function: string searchBobcatByAllKeywordForMedia
  *  Executes a single term Keyword Search in All Keywords limited by Media in BobCat
  * 
  * Parameters:
  *  string term:
  *    search term
  *  string attribute:
  *    search attribute
  *  boolean pop_new_window:
  *    Flags whether launch in a new window
  *    true - launch new screen in new window
  *    false - load new screen in current window
  */
function searchBobcatByAllKeywordForMedia (term, pop_new_window) {
  searchBobcatByKeyword (term, pop_new_window, "media");
}

/** Function: string searchBobcatByAllKeywordForBooks
  *  Executes a single term Keyword Search in All Keywords limited by Books in BobCat
  * 
  * Parameters:
  *  string term:
  *    search term
  *  string attribute:
  *    search attribute
  *  boolean pop_new_window:
  *    Flags whether launch in a new window
  *    true - launch new screen in new window
  *    false - load new screen in current window
  */
function searchBobcatByAllKeywordForBooks (term, pop_new_window) {
  searchBobcatByKeyword (term, pop_new_window, "book");
}

/** Function: string searchBobcatByAllKeyword
  *  Executes a single term Keyword Search in All Keywords in BobCat
  * 
  * Parameters:
  *  string term:
  *    search term
  *  string attribute:
  *    search attribute
  *  boolean pop_new_window:
  *    Flags whether launch in a new window
  *    true - launch new screen in new window
  *    false - load new screen in current window
  */
function searchBobcatByAllKeyword (term, pop_new_window) {
  searchBobcatByKeyword (term, pop_new_window, "all");
}

/** Function: string searchBobcatByKeyword
  *  Executes a single term Keyword Search in BobCat
  * 
  * Parameters:
  *  string term:
  *    search term
  *  string attribute:
  *    search attribute
  *  boolean pop_new_window:
  *    Flags whether launch in a new window
  *    true - launch new screen in new window
  *    false - load new screen in current window
  *  string search_type (optional):
  *    all - Keyword Search in All Keywords
  *    book - Keyword Search in All Keywords for Books
  *    score - Keyword Search in All Keywords for Scores
  *    sound - Keyword Search in All Keywords for Sound Recordings
  *    video - Keyword Search in All Keywords for Videos
  *    empty - Keyword Search based on term1 and attr1
  */
function searchBobcatByKeyword (term, pop_new_window, resource_type, attribute) {
  var bobcat_url;
  if (term) {
    switch (resource_type) {
      case "media": 
        bobcat_url = EZBobcatAllKeywordSearchForMediaURLGenerator(skin, term);
        break;
      case "video": 
        bobcat_url = EZBobcatAllKeywordSearchForVideosURLGenerator(skin, term);
        break;
      case "sound":
      bobcat_url = EZBobcatAllKeywordSearchForSoundsURLGenerator(skin, term);
        break;
      case "score":
        bobcat_url = EZBobcatAllKeywordSearchForScoresURLGenerator(skin, term);
        break;
      case "book":
        bobcat_url = EZBobcatAllKeywordSearchForBooksURLGenerator(skin, term);
        break;
      case "all":
        bobcat_url = EZBobcatAllKeywordSearchURLGenerator(skin, term);
        break;
      case "reserves":
        bobcat_url = EZBobcatReserveAllKeywordSearchURLGenerator(skin, term);
        break;
      default:
        if (attribute) {
          bobcat_url = EZBobcatKeywordSearchURLGenerator (skin, term, attribute);
        }
        break;
    }
    if (bobcat_url) {
      launchBobcat(bobcat_url, pop_new_window);
    }
  }
}

function launchBobcat (bobcat_url, pop_new_window, pop_options) {
  if (bobcat_url) {
    if (pop_new_window && pop_new_window == true) {
      pop_url(bobcat_url, pop_options);
    } else {
      window.location = bobcat_url;
    }
  }
}
