function openHelpWindow(helpURL)
{
  var fullURL = "/help/" + helpURL + ".html";
  window.open(fullURL, "", "scrollbars,toolbar,resizable,height=400,width=450");
}

function openSmallWindow(myURL)
{
  var fullURL = "http://" + myURL;
  window.open(fullURL, "", "scrollbars,toolbar,resizable,height=400,width=650");
}

function setIP (ipaddr)
{
  deleteCookie("pclsPatronIP", "/", "pascolibraries.org");
  var expdate = new Date();
  fixCookieDate (expdate);
  expdate.setTime (expdate.getTime() + (365*24*60*60*1000));
  setCookie("pclsPatronIP", ipaddr.substring(0,7), expdate, "/", "pascolibraries.org");
}

function testIP ()
{
  deleteCookie("pclsInLib", "/", "pascolibraries.org");
  var expdate = new Date();
  fixCookieDate (expdate);
  expdate.setTime (expdate.getTime() + (365*24*60*60*1000));

  if (getCookie("pclsPatronIP") == "10.195.")
  {
    setCookie("pclsInLib", 1, expdate, "/", "pascolibraries.org");
  }
  else
  {
    setCookie("pclsInLib", 0, expdate, "/", "pascolibraries.org");
  }

}

function displayDownloadBookMain()
{
  var inLib = parseInt(getCookie("pclsInLib"));

  if (!inLib)
  {
    var tempHTML = "<a href='http://digitalbooks.tblc.org'><img src='/images/bm_downloadbook.jpg' border='0' width='848' height='31' alt='Download a Book'></a><br>";
    document.write(tempHTML);
  }

}

function doSearch(sform)
{

  var stype, scat, cw_url, ab_url, ga_url, gs_url, pc_url, stext, snum;
  var preferences="&keywords=&keywords=&after=&specific=&before=&lowdate=&hidate=&useCodes=false";
  // carlweb url
  cw_url = "http://pac.pascolibraries.org/carlweb/jsp/DoSearch?databaseID=2600&initialsearch=true&count=10&finish=search_page.jsp&mode=manual&terms=";
  // cw_url = "http://pac.pascolibraries.org/carlweb/jsp/search_page.jsp?homeBranch=SEEREC";
  // ab url
  ab_url = "http://ls2.pascolibraries.org/#section=search&term=";
  //google url
  ga_url = "http://www.google.com/search?hl=en&q=";
  //google site search url
  gs_url = "http://www.google.com/cse?cx=004280827538064312838%3A5ddwrqzv1bo&ie=UTF-8&q=&sa=Search?hl=en&q=";
  pc_url = "http://portal.pascocountyfl.net/portal/server.pt?in_hi_opt_comm_community=202&in_hi_space=SearchResult&in_hi_control=searchstart&in_tx_query="
  //pasco county search url
  stext = sform.terms.value;
  stext = stext.replace(/ +/g,"%20");
  snum = sform.searchtype.value;

  for (i=0; i<sform.searchcat.length; i++)
  {
    if (sform.searchcat[i].checked)
    {
      scat = sform.searchcat[i].value;
    }
  }

  var absearches=new Array("","title:","author:","subject:","call:","isbn:")
  var cwsearches=new Array("&Search=Search&index=w","&Search=Search&index=tw%2F","&Search=Search&index=n","&Search=Search&index=sd%2F","&Search=Search&index=c","&Search=Search&index=i")

  if (scat == "cw")
  {
    stype = cwsearches[snum];
    //alert (cw_url+stype+stext);
    //window.location=cw_url + stype + "&terms=" + stext;
    window.location=cw_url + "&terms=" + stext + stype + preferences;
  }
  else if (scat == "ab")
  {
    stype = absearches[snum];
    //alert (ab_url+stype+stext);
    window.location=ab_url + stype + stext;
  }
  else if (scat == "ga")
  {
    stype = absearches[snum];
    //alert (ga_url+stext);
    window.location=ga_url + stext;
  }
  else if (scat == "gs")
  {
    stype = absearches[snum];
    //alert (gs_url+stext);
    window.location=gs_url + stext + "&sa=Search";
  }
  else if (scat == "pc")
  {
    stype = absearches[snum];
    //alert (pc_url+stext);
    window.location=pc_url + stext;
  }

  //alert(stype);

  return false;
}

