//
// Library Scripts
//
var PATH="";

// when on Live server, set to TRUE
var enableTracker = true;

/* Detect Pocket PC */
function PDADetect()
{
	if (navigator.userAgent.indexOf("Windows CE") >= 0 || navigator.userAgent.indexOf("Palm OS") >= 0) {
		location = PATH+"/text.html";
	}
}

function trim(str)
{
  if (str == null || str == '') return '';
  return str.replace(/^\s*/,"").replace(/\s*$/,"");
}

function setBanner(imagename)
{
	if (imagename == null || trim(imagename) == '')
		imagename = "shelves.jpg";
	
	var html='';
	html += '<div id="lib_banner_left"><table cellspacing="0" cellpadding="0"><tr><td>';
	
	html += '<map name="Map">';
	html += '<area shape="poly" coords="0,0,340,0,315,50,260,96,200,120,0,120" href="'+PATH+'/" alt="Library Homepage">';
	html += '<area shape="poly" coords="396,2,396,30,517,30,517,10,425,10,425,2" href="'+PATH+'/help/ask/" alt="Ask a Librarian">';
	html += '<area shape="poly" coords="367,33,367,64,489,64,489,43,398,43,398,33" href="'+PATH+'/research/" alt="Research Tools">';
	html += '<area shape="poly" coords="330,63,330,91,413,91,413,73,361,73,361,63" href="'+PATH+'/services/" alt="Services">';
	html += '<area shape="poly" coords="288,116,288,87,318,87,318,97,358,97,358,116" href="'+PATH+'/" alt="Library Homepage">';
	html += '</map></td>';
	html += '<img src="http://134.74.20.33/resources/images/banner.jpg" alt="" border="0" align="right" usemap="#Map">';
	html += '</tr></table></div>';
	document.write(html);
}
function setHeading(title)
{
	var html='';
	html += '<table width="100%" cellspacing="0" cellpadding="0">';
	html += '<tr>';
	
	html += '<td class="headingText">'+title+'</td>';
	html += '</tr>';
	html += '</table>';
	document.write(html);
	document.title = title + " @ CCNY Library";
}
function setFooter()
{
	var html='';
	html += '';
	html += '<center>';
	html += '<a href="http://www.ccny.cuny.edu/library/">Library Home Page</a> | <a href="http://www.ccny.cuny.edu/library/about.html">About Us</a> | <a href="http://origin.admin.ccny.cuny.edu/library/help/askform.asp">Contact Us</a> | <a href="http://www.ccny.cuny.edu/library/form/form.html">Contact Webmaster</a> | <a href="http://www1.ccny.cuny.edu/index.cfm">The City College of New York </a><br />';
	html += 'Designed and Developed by Academic Information Technologies<br>';
	html += 'The Brooklyn College Library, All Rights Reserved &copy; 1999-2007';
	if (enableTracker)
		html += track();
	html += '</center>';

	document.write(html);
}

function track()
{
	return "<img width='1' height='1' src='http://aitdev.brooklyn.cuny.edu/lib_tracker/" + 
				"?project=library"+
				"&cookies=" + window.navigator.cookieEnabled +
				"&java=" + window.navigator.javaEnabled() +
				"&js=true" +
				"&res=" + window.screen.width + "x" + window.screen.height +
				"&ref=" + document.referrer +
				"&col_depth=" + window.screen.colorDepth + "'>";
}

function EX_track()
{
	var EXlogin='bclait' // Login 
	var EXvsrv='s10' // VServer 
	EXs=screen;EXw=EXs.width;navigator.appName!="Netscape"?EXb=EXs.colorDepth:EXb=EXs.pixelDepth; 
	navigator.javaEnabled()==1?EXjv="y":EXjv="n"; 
	EXd=document;EXw?"":EXw="na";EXb?"":EXb="na"; 
	return "<img src=http://e1.extreme-dm.com","/"+EXvsrv+".g?login="+EXlogin+"&amp;","jv="+EXjv+"&amp;j=y&amp;srw="+EXw+"&amp;srb="+EXb+"&amp;","l="+escape(EXd.referrer)+" height=1 width=1>";
	//<noscript><div id="neXTReMe"><img height="1" width="1" alt="" src="http://e1.extreme-dm.com/s10.g?login=bclait&amp;j=n&amp;jv=n" /> 
}

function openURL(url)
{
	if (url != null && url != "") {
		self.location = url;
	}
}
function window_open(page, name, properties)
{
	var win = window.open(page,name,properties);
	if (!win) {
		alert("The requested page cannot open in a new window. Please check your popup settings.");
	}
	return win;
}
function openImage(img, caption)
{
	if (!caption) caption="";

	var imgObject = new Image();
	imgObject.src = img;

	var imgWidth = imgObject.width+20;
	var imgHeight = imgObject.height+100;

	var html="";
	html += "<html><head><title>"+caption+"</title><link rel='stylesheet' href='"+PATH+"/styles/library.css'></head><body style='margin:0px'>";
	html += "<center><div style='font-weight:bold'>"+caption+"</div><a href='javascript:self.close()'><img src='"+img+"' border='0' title='"+caption.replace("<br>","\n")+" [Click to close]' /></a><br><a href='javascript:self.close()'>Close this window</a></center>";
	html += "<script>window.resizeTo("+imgWidth+","+imgHeight+")</script></body></html>";

	var w = window_open('', '', 'resizable');
	w.document.write(html);
}

function warnOfChange(url)
{
	var seconds=15;
	var html = "";
	html += '<html>';
	html += '<head>';
	html += '<title>CCNY Libraries</title>';
	html += '<script language="javascript">';
	html +=	'var cur='+seconds+';';
	html +=	'function go(){';
	html +=		'window.refs.document.location.href="http://aitdev.brooklyn.cuny.edu/referers/referers.php?pg='+url+'&redir='+location.href+'&ref='+document.referrer+'"';
	html += '}';
	html += 'function engine() {';
	html +=		'var counter=document.getElementById("counter");';
	html +=		'counter.innerHTML=eval(cur--);';
	html +=		'if (cur < 0) {location.replace("'+url+'")}';
	html += '}';
	html += 'setInterval("engine()",1000);';
	html += '</script>';
	html += '</head>';
	html += '<body>';
	html += 'This page has moved to a new location: <a href="'+url+'">'+url+'</a>.<br>';
	html += 'Please update your favorites to reflect the new page.<br>';
	html += 'Click on the link above or you will be redirected in <span id="counter"><script language="javascript">document.write(cur)</script></span> seconds.<br>';
	html += '<span onclick="document.getElementById(\'refs\').style.visibility=\'visible\'">Thank you.</span>';
	html += '<p><iframe name="refs" id="refs" src="http://library.brooklyn.cuny.edu/blank.html" width="500" height="200" frameborder="0" style="visibility:hidden"></iframe>';
	html += '<script language="javascript">go()</script>';
	html += '</body>';
	html += '</html>';
	document.write(html);
}

var isPlaying=false;
function bells()
{
	if (sound.document.location.href.indexOf("sound.html") > -1)
	{
		sound.document.location.href = "blank.html";
	}
	else
	{
		sound.document.location.href = "sound.html";
	}
}

function newImage(file)
{
	var tmp = new Image();
	tmp.src = file;
	return tmp;
}

function imgOver(obj, file)
{
	if (obj) obj.src = file;
}
function imgOut(obj, file)
{
	if (obj) obj.src = file;
}