function popWindow(index) {
  bookIndex = index;
  var webLink = 'http://catalog.flls.org/polaris/view.aspx?cn='+ bookIndex;
  var endofLink = '&amp;ctx=';
  
  if (readCookie('LibraryName') == null) {
    newWindow = window.open('../includes/chooselibrary.htm', 'ChooseLibrary', 'height=210; width=400; left=0; top =0;');
  }
  else {
    document.location = webLink + endofLink + readCookie('LibraryName');
  }
}

function jumpPage(newLoc) {
  var webLink = 'http://catalog.flls.org/polaris/view.aspx?cn='+ opener.bookIndex;
  var libraryCode = newLoc;
  var endofLink = '&amp;ctx=';

  if (opener.bookIndex != null) {
    opener.document.location = webLink + endofLink + libraryCode;
    createCookie('LibraryName',libraryCode,0);
    
//    document.write(webLink, endofLink, libraryCode);
    window.close()
  }
  else {
    alert("Your search has timed out!")
    window.close()
  }
}

function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	var ck = name+"="+value+expires+"; path=/";
//	if (days != -1) alert('Cookie\n' + ck + '\ncreated');
	document.cookie = ck;
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
        alert('Default Library has been reset');
}

function showDocument(document,winWidth,winHeight) {
  if (winWidth)
  {
    var W = winWidth
  }
  else W = '600'
  
  if (winHeight)
  {
    var H = winHeight
  }
  else H = '600'
  
  newWindow = window.open(document, 'DocumentWin','toolbar=no,location=no,scrollbars=yes,resizable=yes,width='+W+',height='+H+',left=0,top=0')
}

function showPicture(filename,winWidth,winHeight) {
  if (winWidth)
  {
    var W = winWidth
  }
  else W = '600'
  
  if (winHeight)
  {
    var H = winHeight
  }
  else H = '600'
  
  picture = filename;
  newWindow = window.open('http://www.flls.org/includes/displaypicture.html', 'PictureWin', 'toolbar=no,status=no,location=no,scrollbars=yes,resizable=yes,width='+W+',height='+H+',left=0,top=0')
}


  overdrivePix = new Array("images/overdrive/button_overdrivedownload_01.gif", "images/overdrive/button_overdrivedownload_02.gif", "images/overdrive/button_overdrivedownload_03.gif", "images/overdrive/button_overdrivedownload_04.gif", "images/overdrive/button_overdrivedownload_05.gif", "images/overdrive/button_overdrivedownload_06.gif")
  imgCt = overdrivePix.length
      
  function choosePic() {
    if (document.images) {
      randomNum = Math.floor ((Math.random() * imgCt))
      document.myPicture.src = overdrivePix[randomNum]
    }
  }

// Hide E-Mail address from spiders and other bots

  function DisplayMail(Domain, Email, Display){
	if ((Display.length == 0) || (Display.indexOf('@')+1)) {
	document.write('<a href=' + '"mai' + 'lto:' + Email + '@' + Domain + '">' + Email + '@' + Domain + '<\/a>'); }
	else  {
	document.write('<a href=' + '"mai' + 'lto:' + Email + '@' + Domain + '">' + Display + '<\/a>'); }
}

// Generate pop-under windows

  function goNewWin(NewWinAddress) {
    TheNewWin =window.open(NewWinAddress,'TheNewpop','toolbar=1, location=1,directories=1,status=1,menubar=1, scrollbars=1,resizable=1'); 
    TheNewWin.blur();
  }