function openWin(URL) {
    LibrariesWindow=window.open(URL,"librarieswindow","toolbar=no,width=200,height=400,status=no,scrollbars=yes,resizable=yes,menubar=no,alwaysRaised=yes");
}
function openSmallWin(URL) {
    LibrariesWindow=window.open(URL,"librarieswindow","toolbar=no,width=200,height=400,status=no,scrollbars=yes,resizable=yes,menubar=no,alwaysRaised=yes");
}
function openMediumWin(URL) {
    LibrariesWindow=window.open(URL,"librarieswindow","toolbar=no,width=300,height=600,status=no,scrollbars=yes,resizable=yes,menubar=no,alwaysRaised=yes");
}
function openLargeWin(URL) {
    LibrariesWindow=window.open(URL,"librarieswindow","toolbar=no,width=400,height=800,status=no,scrollbars=yes,resizable=yes,menubar=no,alwaysRaised=yes"

);
}
function openLargeWin2(URL) {
    LibrariesWindow=window.open(URL,"librarieswindow","toolbar=no,width=500,height=700,status=no,scrollbars=yes,resizable=yes,menubar=no,alwaysRaised=yes");
}
function openXLargeWin(URL) {
    var LibrariesWindow=window.open(URL,"librarieswindow","toolbar=no,width=800,height=800,status=no,scrollbars=yes,resizable=yes,menubar=no,alwaysRaised=yes");
}
function openSFXWin(URL) {
    LibrariesWindow=window.open(URL,"librarieswindow","toolbar=no,width=500,height=450,status=no,scrollbars=yes,resizable=yes,menubar=no,alwaysRaised=yes,accessKey=1");
}

function openWinLibraries(URL) {
    LibrariesWindow=window.open(URL,"librarieswindow","toolbar=no,width=205,height=540,status=no,scrollbars=yes,resizable=yes,menubar=no,alwaysRaised=yes");
}

function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_o'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

window.onload = initRollovers;

var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
}


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function VoyagerTagIt()
{
    var txt;
    var bibid;
    var app;
    if (navigator.appName == 'Microsoft Internet Explorer') { 
        app = 'http://tags.library.upenn.edu/cgi-bin/postnote?aid=a;title='+document.title+';url='+encodeURIComponent(location.href)+';';
        app += 'lid='+document.frm.BIB.value;
        app += ';sid=voyager';
        void(window.open(app,'btw','resizable=1'));
    } else {
        app = 'http://tags.library.upenn.edu/cgi-bin/postnote?aid=a;title='+window._content.document.title+';url='+encodeURIComponent(window._content.location.href)+';';
        app += 'lid='+window._content.document.frm.BIB.value+';sid=voyager';
        void(btw=window.open(app,'btw','resizable=1'));
        btw.focus();
    }
}

var xmlHttp;

function franklinTest()
{
    if (!document.frm || !document.frm.BIB) return false;

    var url="/cgi-bin/voy_ajax_tag?bibid="+document.frm.BIB.value;
    xmlHttp=GetXmlHttpObject(stateChanged); 
    xmlHttp.open("GET", url , true);
    xmlHttp.send(null);
}

function stateChanged() 
{ 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
        document.getElementById("annotation").innerHTML=xmlHttp.responseText;
    } 
} 

function GetXmlHttpObject(handler)
{ 
    var objXmlHttp=null;

    if (navigator.userAgent.indexOf("Opera")>=0) { return; }
    if (navigator.userAgent.indexOf("MSIE")>=0) {
        var strName="Msxml2.XMLHTTP";
        if (navigator.appVersion.indexOf("MSIE 5.5")>=0) { strName="Microsoft.XMLHTTP"; }
        try
        {
            objXmlHttp=new ActiveXObject(strName);
            objXmlHttp.onreadystatechange=handler;
            return objXmlHttp;
        }
        catch(e) { return; }
    }
    if (navigator.userAgent.indexOf("Mozilla")>=0) {
        objXmlHttp=new XMLHttpRequest();
        objXmlHttp.onload=handler;
        objXmlHttp.onerror=handler;
        return objXmlHttp;
    }
} 

var ajaxObject;
var targetDiv;

function ajaxWidget(url,div)
{
    if (!url || !div) { return false; }

    targetDiv = div;
    ajaxObject=GetXmlHttpObject(ajaxState);
    ajaxObject.open("GET", url, true);
    ajaxObject.send(null);
}

function ajaxState()
{
    if (ajaxObject.readyState==4 || ajaxObject.readyState=="complete") {
        document.getElementById(targetDiv).innerHTML=ajaxObject.responseText;
    }
}

function VoyagerRecordCapture(app)
{
    // Test if an app was passed
    if (!app) { return false; }

    // Test if a record can be captured
    if (!document.frm || !document.frm.BIB) {
        alert('You must be on the Record Page for the item you are requesting before you click on "FDD".');
        return false;
    }

    // Capture standard set of variables
    var title = document.title;
    var url   = encodeURIComponent(location.href);
    var bibid = document.frm.BIB.value;

    // Append the variables to the app
    app += '?title='+title+';url='+url+';bibid='+bibid;

    // Call the app
    if (navigator.appName == 'Microsoft Internet Explorer') {
        void(window.open(app,'btw','width=650,height=410,left=50,top=50,resizable=1,scrollbars=yes'));
    } else {
        void(btw=window.open(app,'btw','width=650,height=410,left=50,top=50,resizable=1,scrollbars=yes'));
        btw.focus();
    }
}

function errorMsg()
{
  alert("Netscape 6 or Mozilla is needed to install a sherlock plugin");
}
function addEngine(name,ext,cat)
{
  if ((typeof window.sidebar == "object") && (typeof
  window.sidebar.addSearchEngine == "function"))
  {
    //cat="Web";
    //cat=prompt('In what category should this engine be installed?','Web')
    window.sidebar.addSearchEngine(
      "http://labs.library.upenn.edu/searchplugins/"+name+".src",
      "http://labs.library.upenn.edu/searchplugins/"+name+"."+ext,
      name,
      cat );
  }
  else
  {
    errorMsg();
  }
}

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;
}
//var $homepage = readCookie('hp');

if (readCookie('hp')){
var $homepage = readCookie('hp');
}
else{
var $homepage = "";
}

var winnew = null;
function chatWindow(){
winnew = window.open('http://service.velaro.com/visitor/requestchat.aspx?siteid=4326&showwhen=inqueue','VelaroChat','height=404,width=350,toolbar=0,location=0,menubar=0,status=0,scrollbars=0,resizable=1,replace=0')
}

var orgbodyclass;
function swapbodyclass() { 
	var bodyelement= document.getElementsByTagName('body')[0]; 	
	if (bodyelement.className == "printer"){
		bodyelement.className = orgbodyclass;
	} else {
		orgbodyclass = bodyelement.className;
		bodyelement.className = "printer";
		
	}
}


