<!--

// This script reveals Ask a Librarian live when 
// it is Sun-Thurs, 3-5;7-10 pm EST. It can cope with time zone  only 
// as well as the OS clock understands it. 
//  Daylight savings time must be currentlly manually adjusted
// Developed Feb 31, 2003 - Sam McDonald (rulweb@rci.rutgers.edu)- Rutgers University Libraries
// comments for your education - send mail if you like it or use it
// revised March 2008

  now = new Date();                     // 'now' is time when page is loaded..does not seem to get cached
  day_of_week = now.getDay();           // get day of week 
  hour = now.getHours();                // get hour in 24 hour time (0-23)
  timez = now.getTimezoneOffset();      // EST is 5hrs (300 min) earlier  than Standard Greenwich Mean Time
  var show_AAL_L   = false;  		// the flag for whether the time parameters are met ..used in nav script
  var show_AAL_L_A = false;  		// the flag for whether the time parameters are met
  var show_AAL_L_B = false;  		// the flag for whether the time parameters are met

  //help from http://tech.irt.org/articles/js076/index.htm
   if ((navigator.appVersion.indexOf('MSIE 3') != -1)) timez = timez * (-1);  //MSIE 3 has a error, makes timezone the wrong sign
   now.setTime(now.getTime() + timez*60*1000);				    //recalculate local time to GMT
   now.setTime(now.getTime() + -4*60*60*1000);  			    
              //recalculate GMT to EST -  the 5 is NYC time EST (GMT - 300(min) = 5 hours)
              //adjust from 5 to 4 for daylight savings

//alert("Day is:" + day_of_week);
//alert("Hour is:" + hour);

//sun
if (day_of_week == 0) {
if (hour == 19 || hour == 20 || hour == 21) {
show_AAL_L_A  = true;
show_AAL_L  = true;
}}

//monday-th   2-3:59p, 7-9:59p  
if (day_of_week == 1 || day_of_week == 2 || day_of_week == 3 || day_of_week == 4) {         
if (hour == 14 || hour == 15 || hour == 19 || hour == 20 || hour == 21) {
show_AAL_L_A  = true;
show_AAL_L  = true;
}}

//monday-th  4-5:59
if (day_of_week == 1 || day_of_week == 2 || day_of_week == 3 || day_of_week == 4) {         
if (hour == 16 || hour == 17) {
show_AAL_L_B  = true;
show_AAL_L  = true;
}}


  //disable tag follows, comment out if wanted active
  //show_AAL_L    = false;
  //show_AAL_L_A  = false; 
  //show_AAL_L_B  = false; 

var meeboOffset; //used late to shift main pic down from 14 to 260 if aal service active
meeboOffset = 14;
//alert("meeboOffset=" + meeboOffset);
if (show_AAL_L_A  == true){
 meeboOffset = 260;
}


if (show_AAL_L_B  == true){
 meeboOffset = 260;
}

/*************************************************************************
  This code is from Dynamic Web Coding 
  at http://www.dyn-web.com/
  Copyright 2001-3 by Sharon Paine 
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  Permission granted to use this code 
  as long as this entire notice is included.
*************************************************************************/
  var ns4 = (document.layers)? true:false;

// resize fix for ns4
var origWidth, origHeight;


if (document.layers) {
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

// link style change
var cur_link;
function doLinkClass(lnk) {
  if (lnk && lnk.blur) lnk.blur();	// remove marquee
  if (!lnk || cur_link == lnk) return;
  if (cur_link) cur_link.className = "done";
  lnk.className = "on";
  cur_link = lnk;
}

var cur_lyr;	// holds id of currently visible layer
function swapLayers(lnk,id) {
  doLinkClass(lnk);
  if (cur_lyr) hideLayer(cur_lyr);
  showLayer(id);
  cur_lyr = id;
}

var last_hilite = "";

// change the image and bullets on MouseOver
function swapLayers2(lnk,id,item,bullet) {
  if (!ns4){
     document.getElementById('lyr1').style.visibility="hidden";
     doLinkClass(lnk);
     if (cur_lyr) hideLayer(cur_lyr);
     showLayer(id);
     cur_lyr = id;
     last_hilite.src = "/rul/images/arrow_inactive.gif";
     bullet.src = "/rul/images/arrow_active.gif";
     last_hilite = bullet;
  }
}

function closeLayer(lnk,id) {
  document.getElementById(id).style.visibility="hidden";
  document.getElementById('lyr1').style.visibility="visible";
    //hide left menu arrow and link
  last_hilite.src = "/rul/images/arrow_inactive.gif";
  doLinkClass(lnk);
}

function showLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.visibility = "visible";
}

function hideLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) { lyr.css.visibility = "hidden";}
}

function getElemRefs(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? getLyrRef(id,document): null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}

// get reference to nested layer for ns4
// from old dhtmllib.js by Mike Hall of www.brainjar.com
function getLyrRef(lyr,doc) {
	if (document.layers) {
		var theLyr;
		for (var i=0; i < doc.layers.length; i++) {
	  	theLyr = doc.layers[i];
			if (theLyr.name == lyr) return theLyr;
			else if (theLyr.document.layers.length > 0) 
	    	if ((theLyr = getLyrRef(lyr,theLyr.document)) != null)
					return theLyr;
	  }
		return null;
  }
}


function init(id,lyr) {
 if (!ns4){
  var lnk = getElemRefs(id);
  swapLayers(lnk,lyr);
  myImgDim = getDim(document.images.MyImage);
  var left_1 = myImgDim.x + 20;
  var top_1 = myImgDim.y + meeboOffset;
  //var advbrowser=document.getElementById;

  
  //http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow_dev.htm

       document.getElementById('lyr1').style.left= left_1.toString() + "px";
       document.getElementById('lyr1').style.top=top_1.toString() + "px";

       document.getElementById('lyr2').style.left= left_1.toString() + "px";
       document.getElementById('lyr2').style.top=top_1.toString() + "px";

       document.getElementById('lyr3').style.left= left_1.toString() + "px";
       document.getElementById('lyr3').style.top=top_1.toString() + "px";

       document.getElementById('lyr4').style.left= left_1.toString() + "px";
       document.getElementById('lyr4').style.top=top_1.toString() + "px";

       document.getElementById('lyr5').style.left= left_1.toString() + "px";
       document.getElementById('lyr5').style.top=top_1.toString() + "px";

       document.getElementById('lyr6').style.left= left_1.toString() + "px";
       document.getElementById('lyr6').style.top=top_1.toString() + "px";

       document.getElementById('lyr7').style.left= left_1.toString() + "px";
       document.getElementById('lyr7').style.top=top_1.toString() + "px";

       document.getElementById('lyr8').style.left= left_1.toString() + "px";
       document.getElementById('lyr8').style.top=top_1.toString() + "px";

       document.getElementById('lyr9').style.left= left_1.toString() + "px";
       document.getElementById('lyr9').style.top=top_1.toString() + "px";

       document.getElementById('lyr10').style.left= left_1.toString() + "px";
       document.getElementById('lyr10').style.top=top_1.toString() + "px";

       document.getElementById('lyr11').style.left= left_1.toString() + "px";
       document.getElementById('lyr11').style.top=top_1.toString() + "px";

       document.getElementById('lyr12').style.left= left_1.toString() + "px";
       document.getElementById('lyr12').style.top=top_1.toString() + "px";

       document.getElementById('lyr13').style.left= left_1.toString() + "px";
       document.getElementById('lyr13').style.top=top_1.toString() + "px";

       document.getElementById('lyr14').style.left= left_1.toString() + "px";
       document.getElementById('lyr14').style.top=top_1.toString() + "px";

       document.getElementById('lyr15').style.left= left_1.toString() + "px";
       document.getElementById('lyr15').style.top=top_1.toString() + "px";

       document.getElementById('lyr16').style.left= left_1.toString() + "px";
       document.getElementById('lyr16').style.top=top_1.toString() + "px";

       document.getElementById('lyr17').style.left= left_1.toString() + "px";
       document.getElementById('lyr17').style.top=top_1.toString() + "px";

       document.getElementById('lyr18').style.left= left_1.toString() + "px";
       document.getElementById('lyr18').style.top=top_1.toString() + "px";

       document.getElementById('lyr19').style.left= left_1.toString() + "px";
       document.getElementById('lyr19').style.top=top_1.toString() + "px";

       document.getElementById('lyr20').style.left= left_1.toString() + "px";
       document.getElementById('lyr20').style.top=top_1.toString() + "px";
  }


}

function getDim(el){
	for (var lx=0,ly=0;el!=null;
	  lx+=el.offsetLeft,ly+=el.offsetTop,el=el.offsetParent);
	return {x:lx,y:ly}
}

/* mouse over arrow in layers. eg. Search cat, research res, about the libs */
var last_hilite2 = "";

function arrowSwap(id,arrow) {
 last_hilite2.src = "/rul/images/arrow_active_lg_b.gif";
 arrow.src = "/rul/images/arrow_active_lg.gif";
 last_hilite2 = arrow;
}


//inactivity timer
//after 1 minute, front page image return if no action 1,000 milliseconds = 1 second. 1 min = 60,000 milliseconds
//http://www.faqts.com/knowledge_base/view.phtml/aid/2100/fid/145
//alert("started");

var tid, time, action;

//setInactivityTimer (1000, 'alert(message1 + (time / 1000) + message2);', true);
setInactivityTimer (120000, "init('lnk1','lyr1');", true);

function setInactivityTimer (time, action, repeat) {
//alert("in timer");
  window.time = time;
  window.action = action;
  window.repeat = repeat;
  if (tid) 
    clearTimeout(tid);
  if (document.layers)
    document.captureEvents(Event.MOUSEMOVE | Event.KEYUP);
  document.onmousemove = document.onkeyup =
    function (evt) {
      setInactivityTimer(window.time, window.action, window.repeat);
      return true;
    };
  if (repeat)
    action += '; setInactivityTimer(' + time + ', "' + action + '", ' + repeat + ');';
  else 
    action += '; clearEvents();';
  //tid = setTimeout(action, time);
    //commented out march 7, 2007..broken?
}

function clearEvents() {
  if (document.layers)
    document.releaseEvents(Event.MOUSEMOVE | Event.KEYUP);
    document.onmousemove = document.onkeyup = null;
}

// front page image rotation
//calculate which image to show based on day
today                   = new Date();
todayDate               = today.getDate();                                   // gives a num 1-31
todayDateString         = todayDate.toString();                              // convert number to string to grab last digit
//todayDateStringLength   = todayDateString.length;                            // get num of char is string..counts from zero so -1
//todayDateStringLastChar = todayDateString.charAt(todayDateStringLength -1);  // gives you the last character..counts from zero so -1
//todayDateStringAsNum    = parseInt(todayDateStringLastChar);                 // convert this character to a number..for easy use?
todayDateStringAsNum = (parseInt(todayDateString) - 1);      // convert this character to a number..for easy use?

function rotateImage() {
  document.write('<a href="/rul/captions.shtml" style="border-bottom: none;"><img src="/rul/images/' + todayDateStringAsNum + '.jpg"' + 'alt="RU Libraries images - Click to see more...with captions" title="RU Libraries images - Click to see more...with captions" width="400" height"350" border="0" /></a>');
}


// =================================
//test zone







//-->
