
//LIBRARY HOURS V2
//Created by Fred Schott Class of 2013
//Updated for Summer Hours by Dan Kass on 5/27 (added simple debugging tool too)
//
//Modified original library hours script to be more efficient and easier to update.
//Reduced Lines of Code from ~1000 to ~200
//Instead of hardcoding each date's hours into an array, v2 can handle weekly 
//   schedules as well as date exceptions, and will generate the day's operating 
//   hours dynamically.
//
//
// Format for adding Schedules:
//   KEY: X1: Start Month
//        X2:   End Month
//        Y1: Start Day
//        Y2:   End Day
//
//   Adding Exception Date: 	            
//       else if(  month==X && date==Y) { ...
//
//   Adding Schedule (Across One Month):
//       else if( (month==X && date>=Y1 && date<=Y2) {
//         switch(day) { ...
//
//   Adding Schedule (Across Multiple Months): 
//       if((month==X1 && date>=Y1) || (month>X1 && month<X2) || (month==X2 && date<=Y2)) {
//         switch(day) { ...
//
////////

////USE FOR TESTING
var debug = false;


//Gets Data for current Date
function getDate() {
	today=new Date(); // Initialize Date in raw form
	date=today.getDate(); // Get the numerical date
	year=today.getFullYear(); // Get the year
	day = today.getDay(); // Get the day in number form (0,1,2,3,etc.)
	month=today.getMonth()+1; // Get the month
}

//use for testing purposes
function customDate() {
	today=new Date(); // Initialize Date in raw form
	date=5; // 1-31
	year=2011; // ex 2011
	day = 5; // Get the day in number form (0,1,2,3,etc.)
	month=9; // Get the month
}


// function used to write the current date on the homepage and other pages.
function todaysDate() {
	
	//Get Date
	if(!debug) getDate(); else customDate();
	
	// Make day number value correspond to actual day name
	var dayName=new Array(7);
	dayName[0]="Sunday";
	dayName[1]="Monday";
	dayName[2]="Tuesday";
	dayName[3]="Wednesday";
	dayName[4]="Thursday";
	dayName[5]="Friday";
	dayName[6]="Saturday";
	
	// Add suffix to date (1st, 2nd, 4th, etc.)
	var dateLastDigit = date%10;
	
	//hanldes numbers in the teens...
	if (date>=10 && date <=13) suffix=("th");
	else if (dateLastDigit==1) 	suffix=("st");
	else if (dateLastDigit==2) 	suffix=("nd");
	else if (dateLastDigit==3)  suffix=("rd");
	else 						suffix=("th");
	
	// Make month number correspond to month name
		 if (month==1) 	monthName=("January");
	else if (month==2) 	monthName=("February");
	else if (month==3) 	monthName=("March");
	else if (month==4) 	monthName=("April");
	else if (month==5) 	monthName=("May");
	else if (month==6) 	monthName=("June");
	else if (month==7) 	monthName=("July");
	else if (month==8) 	monthName=("August");
	else if (month==9) 	monthName=("September");
	else if (month==10)	monthName=("October");
	else if (month==11)	monthName=("November");
	else				monthName=("December");
	
	// Write date
	document.write(dayName[day] + ", " + monthName + " " + date + suffix + ", " + year);
}


// function used to write the library hours for the current date
// UPDATE: now built to handle summer 2011 hours
function todaysHours() {

	//Get Date
	if(!debug) getDate(); else customDate();
	var tischHours, refHours, mediaHours, ddsHours, musicHours, towerHours, dateUnknown = false;
	
	////////////////
	//EXCEPTIONS - Dates with Special Library Hours
	////////////
	if(month==2 && date==20) {  		//Monday, Feb. 20
				tischHours = "10:00AM - 1:00AM";
				  refHours = "10:00AM - 10:00PM";
				mediaHours = "10:00AM - 11:30PM";
				ddsHours = "10:00AM - 11:30PM";
				musicHours = "CLOSED";
				towerHours = "5:00PM - 1:00AM";
	} else if(month==3 && date==16) { 	//Friday, Mar. 16
				tischHours = "8:00AM - 5:00PM";
				  refHours = "9:00AM - 5:00PM";
				mediaHours = "8:30AM - 5:00PM";
				ddsHours = "9:00AM - 5:00PM";
				musicHours = "9:00AM - 5:00PM";
				towerHours = "NOON - 4:00PM";
	} else if(month==3 && date==25) { 	//Sunday, March 25th
				tischHours = "10:00AM - 1:00AM";
				  refHours = "11:00AM - 1:00PM";
				mediaHours = "NOON - 11:30PM";
				ddsHours = "NOON - 11:30PM";
				musicHours = "NOON - 10:00PM";
				towerHours = "5:00PM - 1:00AM";
	} else if(month==4 && date==14) {	//Sat, Apr. 14
				tischHours = "10:00AM - 9:00PM";
				  refHours = "11:00AM - 5:00PM";
				mediaHours = "10:00AM - 6:00PM";
				ddsHours = "10:00AM - 6:00PM";
				musicHours = "12:00PM - 6:00PM";
				towerHours = "CLOSED";
	} else if(month==4 && date==15) {	//Sun, Apr. 15
				tischHours = "10:00AM - 1:00AM";
				  refHours = "11:00AM - 10:00PM";
				mediaHours = "12:00PM - 11:30PM";
				ddsHours = "12:00PM - 11:30PM";
				musicHours = "12:00PM - 10:00PM";
				towerHours = "CLOSED";
	} else if(month==4 && date==16) {	//Monday, Apr. 16
				tischHours = "10:00AM - 1:00AM";
				  refHours = "10:00AM - 10:00PM";
				mediaHours = "10:00AM - 11:30PM";
				ddsHours = "10:00AM - 11:30PM";
				musicHours = "CLOSED";
				towerHours = "5:00PM - 1:00AM";
    } else if(month==4 && date==27) {	//Friday, Apr. 27
				tischHours = "8:00AM - 9:00PM";
				  refHours = "9:00AM - 5:00PM";			
				mediaHours = "8:30AM - 9:00PM";
				ddsHours = "9:00AM - 9:00PM";
				musicHours = "9:00AM - 6:00PM";
				towerHours = "NOON - 11:00PM";
	} else if(month==4 && date==28) {	//Saturday, Apr. 28
				tischHours = "10:00AM - 9:00PM";
				  refHours = "11:00AM - 5:00PM";
				mediaHours = "10:00AM - 6:00PM";
				ddsHours = "10:00AM - 6:00PM";
				musicHours = "12:00PM - 6:00PM";
				towerHours = "CLOSED";
	} else if((month==5 && date==1) || (month==5 && date==2) || (month==5 && date==3)) {	//Tues May 1 - Thurs May 3rd
				tischHours = "8:00AM - 1:00AM";
				  refHours = "9:00AM - 10:00PM";
				mediaHours = "8:30AM - 11:30PM";
				ddsHours = "9:00AM - 11:30PM";
				musicHours = "9:00AM - 10:00PM";
				towerHours = "NOON - 3:00AM";
	} else if(month==5 && date==4)  {	//Friday, May. 4
				tischHours = "8:00AM - MIDNIGHT";
				  refHours = "9:00AM - 5:00PM";
				mediaHours = "8:30AM - 11:30PM";
				ddsHours = "9:00AM - 11:30PM";
				musicHours = "9:00AM - 6:00PM";
				towerHours = "NOON - 11:00PM";
	} else if(month==5 && date==5)  {	//Saturday, May. 5
				tischHours = "10:00AM - MIDNIGHT";
				  refHours = "11:00AM - 5:00PM";
				mediaHours = "10:00AM - 11:30";
				ddsHours = "10:00AM - 11:30";
				musicHours = "NOON - 6:00PM";
				towerHours = "NOON - 11:00PM";
	} else if(month==5 && date==6)  {	//Sunday, May. 6
				tischHours = "10:00AM - 1:00AM";
				  refHours = "11:00AM - 10:00PM";
				mediaHours = "12:00PM - 11:30PM";
				ddsHours = "12:00PM - 11:30PM";
				musicHours = "12:00PM - 10:00PM";
				towerHours = "NOON - 3:00AM";
	} else if((month==5 && date==7) ||(month==5 && date==8) || (month==5 && date==9) || (month==5 && date==10))   {	//Monday, May 7 - Thursday May 10
				tischHours = "8:00AM - 1:00AM";
				  refHours = "9:00AM - 10:00PM";
				mediaHours = "8:30AM - 11:30PM";
				ddsHours = "9:00AM - 11:30PM";
				musicHours = "9:00AM - 10:00PM";
				towerHours = "NOON - 3:00AM";			
	} else if(month==5 && date==11) {	//Friday, May. 11
				tischHours = "8:00AM - 5:00PM";
				  refHours = "9:00AM - 5:00PM";
				mediaHours = "8:30AM - 5:00PM";
				ddsHours = "9:00AM - 5:00PM";
				musicHours = "9:00AM - 5:00PM"; 
				towerHours = "NOON - 4:00PM";
	} 
	
	//Summer 2011 exceptions
	else if((month==5 && date==28) || (month==5 && date==29) ||
			 (month==5 && date==30) || (month==7 && date>=2 && date <=4) ||
			 (month==9 && date==5)) {
				tischHours = "CLOSED";
				refHours = "CLOSED";
				mediaHours = "CLOSED";
				musicHours = "CLOSED";
	}
	else if(month==8 && date==26) {
	tischHours = "9:00AM - NOON";
	refHours = "9:00AM - NOON";
	mediaHours = "9:00AM - NOON";
	musicHours = "9:00AM - NOON";
	}
	
	//Fall 2011 exceptions
	else if(month==10 && date==10) { //Monday, Oct 10
	tischHours = "10:00AM - 1:00AM";
	refHours = "10:00AM - 10:00PM";
	mediaHours = "10:00AM - 11:30PM";
	ddsHours = "10:00AM - 11:30PM";
	musicHours = "NOON - 6:00PM";
	}
	else if(month==11 && date==11) { //Friday, Nov 11
	tischHours = "10:00AM - 9:00PM";
	refHours = "10:00AM - 5:00PM";
	mediaHours = "10:00AM - 9:00PM";
	ddsHours = "10:00AM - 6:00PM";
	musicHours = "NOON - 6:00PM";
	}
	else if(month==11 && date==22) { //Tuesday, Nov 22
	tischHours = "8:00AM - 10:00PM";
	refHours = "9:00AM - 10:00PM";
	mediaHours = "8:30AM - 10:00PM";
	ddsHours = "9:00AM - 9:00PM";
	musicHours = "9:00AM - 10:00PM";
	}
	else if(month==11 && date==23) { //Wednesday, Nov 23
	tischHours = "9:00AM - 5:00PM";
	refHours = "9:00AM - 5:00PM";
	mediaHours = "8:30AM - 10:00PM";
	ddsHours = "9:00AM - 5:00PM";
	musicHours = "9:00AM - 5:00PM";
	}
	else if((month==11 && date==24)||(month==11 && date==25)|| (month==11 && date==26)) { //Thurs Nov 24th - Sat Nov 26th
	tischHours = "CLOSED";
	refHours = "CLOSED";
	mediaHours = "CLOSED";
	ddsHours = "CLOSED";
	musicHours = "CLOSED";
	}
	else if(month==12 && date==9) { //Friday, Dec 9th
	tischHours = "8:00AM - 12:00AM";
	refHours = "9:00AM - 5:00PM";
	mediaHours = "8:30AM - 11:30PM";
	ddsHours = "9:00AM - 11:30PM";
	musicHours = "9:00AM - 6:00PM";
	}
	else if(month==12 && date==10) { //Saturday, Dec 10th
	tischHours = "10:00AM - 12:00AM";
	refHours = "11:00AM - 5:00PM";
	mediaHours = "10:00AM - 11:30PM";
	ddsHours = "10:00AM - 11:30PM";
	musicHours = "12:00PM - 6:00PM";
	}
	else if(month==12 && date==16) { //Friday, Dec 16th
	tischHours = "8:00AM - 12:00AM";
	refHours = "9:00AM - 5:00PM";
	mediaHours = "9:00AM - 11:30PM";
	ddsHours = "9:00AM - 11:30PM";
	musicHours = "9:00AM - 6:00PM";
	}
	else if(month==12 && date==17) { //Saturday, Dec 17th
	tischHours = "10:00AM - 12:00AM";
	refHours = "11:00AM - 5:00PM";
	mediaHours = "10:00AM - 11:30PM";
	ddsHours = "10:00AM - 11:30PM";
	musicHours = "9:00AM - 6:00PM";
	}
	else if(month==12 && date==22) { //Thursday, Dec 22nd
	tischHours = "8:00AM - 5:00PM";
	refHours = "9:00AM - 5:00PM";
	mediaHours = "8:30AM - 5:00PM";
	ddsHours = "9:00AM - 5:00PM";
	musicHours = "9:00AM - 5:00PM";
	}
	else if((month==12 && date==23)||(month==12 && date==24)||(month==12 && date==25)||(month==12 && date==26)||(month==12 && date==30)||(month==12 && date==31)||(month==01 && date==01)|| (month==01 && date==02)|| (month==01 && date==16)) { //Friday Dec 23rd, Monday, Dec 26th, Friday December 30th, Monday Jan 2, Monday Jan 16th
	tischHours = "CLOSED";
	refHours = "CLOSED";
	mediaHours = "CLOSED";
	ddsHours = "CLOSED";
	musicHours = "CLOSED";
	}
	
	else if((month==12 && date==27)||(month==12 && date==28)||(month==12 && date==29)) { //Tues Dec 27rd, Wednesday, Dec 28th, Thursday Dec 29th
	tischHours = "9:00AM - 5:00PM";
	refHours = "9:00AM - 5:00PM";
	mediaHours = "9:00AM - 5:00PM";
	ddsHours = "9:00AM - 5:00PM";
	musicHours = "CLOSED";
	}
	
	////END EXCEPTIONS////

	////////////////
	//SESSIONS - Periods with regularly scheduled Hours
  	//           day-code = //0:Su  //1:Mo  //2:Tu  //3:We  //4:Th  //5:Fr //6:Sa
	//////////
	else if( (month==5 && date>=14 && date<=24)	 	 /*SPRING INTERSESSION*/
	      	 ||(month==3 && date>=17 && date<=24)/*SPRING BREAK*/
			 || (month==1 && date<=18)) {  /*JAN INTERSESSION*/
		switch(day) {
			//MONDAY-FRIDAY
			case 1: case 2: case 3: case 4: case 5: 
				tischHours = "9:00AM - 5:00PM";
				  refHours = "9:00AM - 5:00PM";			
				mediaHours = "9:00AM - 5:00PM";
				ddsHours = "9:00AM - 5:00PM";
				musicHours = "9:00AM - 5:00PM";
				towerHours = "CLOSED";
				
			break;
			//SATURDAY-SUNDAY
			case 0: case 6:
				tischHours = "CLOSED";
				  refHours = "CLOSED";
				mediaHours = "CLOSED";
				ddsHours = "CLOSED";
				musicHours = "CLOSED";
				towerHours = "CLOSED";
				
			break;
		}		
		
	} else if((month==1 && date>=19) || (month>1 && month<5) || (month==5 && date<=13)){ /*SPRING SESSION*/
		switch(day) {
			//MONDAY-THURSDAYS
			case 1: case 2: case 3: case 4: 
				tischHours = "8:00AM - 1:00AM";
				  refHours = "9:00AM - 10:00PM";
				mediaHours = "8:30AM - 11:30PM";
				ddsHours = "9:00AM - 11:30PM";
				musicHours = "9:00AM - 10:00PM";
				towerHours = "NOON - 1:00AM";
			break;
			//FRIDAY
			case 5:
				tischHours = "8:00AM - 9:00PM";
				  refHours = "9:00AM - 5:00PM";			
				mediaHours = "8:30AM - 9:00PM";
				ddsHours = "9:00AM - 9:00PM";
				musicHours = "9:00AM - 6:00PM";
				towerHours = "NOON - 7:00PM";
			break;
			//SATURDAY
			case 6:
				tischHours = "10:00AM - 9:00PM";
				  refHours = "11:00AM - 5:00PM";
				mediaHours = "10:00AM - 6:00PM";
				ddsHours = "10:00AM - 6:00PM";
				musicHours = "12:00PM - 6:00PM";
				towerHours = "NOON - 7:00PM";
			break;
			//SUNDAY
			case 0:
				tischHours = "10:00AM - 1:00AM";
				  refHours = "11:00AM - 10:00PM";
				mediaHours = "12:00PM - 11:30PM";
				ddsHours = "12:00PM - 11:30PM";
				musicHours = "12:00PM - 10:00PM";
				towerHours = "NOON - 1:00AM";
			break;
		}
	}  else if((month==9 && date>=6) || (month>9 && month<12) || (month==12 && date<=22)){ /*FALL SESSION*/
		switch(day) {
			//MONDAY-THURSDAYS
			case 1: case 2: case 3: case 4: 
				tischHours = "8:00AM - 1:00AM";
				  refHours = "9:00AM - 10:00PM";
				mediaHours = "8:30AM - 11:30PM";
				  ddsHours = "9:00AM – 11:30PM";
				musicHours = "9:00AM - 10:00PM";
				towerHours = "NOON - 1:00AM";
			break;
			//FRIDAY
			case 5:
				tischHours = "8:00AM - 9:00PM";
				  refHours = "9:00AM - 5:00PM";			
				mediaHours = "8:30AM - 9:00PM";
				  ddsHours = "9:00AM - 9:00PM";
				musicHours = "9:00AM - 6:00PM";
				towerHours = "NOON - 1:00AM";
			break;
			//SATURDAY
			case 6:
				tischHours = "10:00AM - 9:00PM";
				  refHours = "11:00AM - 5:00PM";
				mediaHours = "10:00AM - 6:00PM";
				  ddsHours = "12:00PM - 6:00PM";
				musicHours = "12:00PM - 6:00PM";
				towerHours = "NOON - 7:00PM";
			break;
			//SUNDAY
			case 0:
				tischHours = "10:00AM - 1:00AM";
				  refHours = "11:00AM - 10:00PM";
				mediaHours = "12:00PM - 11:30PM";
				  ddsHours = "12:00PM - 11:30PM";
				musicHours = "12:00PM - 10:00PM";
				towerHours = "NOON - 1:00AM";
			break;
		}
	}
	
	////SUMMER 2011////
	else if(((month==5 && date>=25) || (month>5 && month<7) || (month==7 && date<=1)) || //Session I - May 25 - July 1
		   ((month==7 && date>=5) || (month>7 && month<8) || (month==8 && date<=12))) { //Session II - July 5 - August 12 
		switch(day) {
			//MONDAY-THURSDAYS
			case 1: case 2: case 3: case 4: 
				tischHours = "8:45AM - 10:00PM";
				  refHours = "9:00AM - 8:00PM";			microHours = "CLOSED";
				mediaHours = "8:45AM - 10:00PM";
				musicHours = "9:00AM - 5:00PM";
			break;
			//FRIDAY
			case 5:
				tischHours = "8:45AM - 5:00PM";
				  refHours = "9:00AM - 5:00PM";			microHours = "CLOSED";
				mediaHours = "8:45AM - 5:00PM";
				musicHours = "9:00AM - 5:00PM";
			break;
			//SATURDAY
			case 6:
				tischHours = "10:00AM - 4:00PM";
				  refHours = "NOON - 4:00PM";
				mediaHours = "CLOSED";
				musicHours = "CLOSED";
			break;
			//SUNDAY
			case 0:
				tischHours = "2:00PM - 10:00PM";
				  refHours = "3:00PM - 8:00PM";
				mediaHours = "2:00PM - 10:00PM";
				musicHours = "CLOSED";
			break;
		}
	} 
	
	else if(((month==8 && date>=13) || (month>8 && month<9) || (month==9 && date<=5))) { //Intersession - August 13 - September 5
			switch(day) {
			//MONDAY-FRIDAYS
			case 1: case 2: case 3: case 4: case 5:
				tischHours = "9:00AM - 5:00PM";
				refHours = "9:00AM - 5:00PM";
				mediaHours = "9:00AM - 5:00PM";
				musicHours = "9:00AM - 5:00PM";
			break;
			//SATURDAYS-SUNDAYS
			case 6: case 0:
				tischHours = "CLOSED";
				  refHours = "CLOSED";
				mediaHours = "CLOSED";
				musicHours = "CLOSED";
			break;
		}
	}
	
	else { //Error Case: No hours found for todays date
		dateUnknown = true;
	}
	////END SESSIONS////


	//Write Hours
	var hoursWrite = "<p style=\"padding-bottom:2px;margin-bottom:2px;margin-top:0;padding-top:0\"><a href=\"/tisch/hours.htm\"><span style=\"font-size: 110%;font-weight:bold\">Hours</span></a> <span style=\"font-size: 90%;font-style:italic\">(full calendar)</span></p>";
	hoursWrite += "<p style=\"margin-top:0;padding-top:0;margin-bottom:3px;padding-bottom:3px;color:#417dc1\"><strong>Today:</strong></p><dl>";
	
	//Handles Error Case
	if(dateUnknown) {
		hoursWrite += "<dt>Unable to update library hours.</dt>";
		hoursWrite += "<dd>Please check the <a href=\"/tisch/hours.htm\">full calendar</a> for details.</dd></dl>";
	} else {
		hoursWrite += "<dt><a href=\"/tisch/index.html\">Tisch</a>:</dt><dd>" + tischHours + "</dd>";
		hoursWrite += "<dt><a href=\"/tisch/refcoll_directory.htm\">Reference Desk<a/>:</dt><dd>" + refHours + "</dd>";
		hoursWrite += "<dt><a href=\"/tisch/media_center.html\">Media Center</a>:</dt><dd>" + mediaHours + "</dd>";
		hoursWrite += "<dt><a href=\"/tisch/dds.html\">Digital Design Studio</a>:</dt><dd>" + ddsHours + "</dd>";
		hoursWrite += "<dt><a href=\"/tisch/music_library.htm\">Music Library</a>:</dt><dd>" + musicHours + "</dd>";
		hoursWrite += "<dt><a href=\"http://dining.tufts.edu/locations-hours/overview/the-tower-caf-at-tisch-library/\">Tower Cafe</a>:</dt><dd>" + towerHours + "</dd></dl>";
		//hoursWrite += "<span style=\"margin-left:4px;font-size:90%\">" + lateNightStudy + "</span><br /><br />"; 
	}
	document.write(hoursWrite);
}


// function for window popping

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}




// check for Flash plugin

function MM_CheckFlashVersion(reqVerStr,msg){
  with(navigator){
    var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    if (!isIE || !isWin){  
      var flashVer = -1;
      if (plugins && plugins.length > 0){
        var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        if (desc == "") flashVer = -1;
        else{
          var descArr = desc.split(" ");
          var tempArrMajor = descArr[2].split(".");
          var verMajor = tempArrMajor[0];
          var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          flashVer =  parseFloat(verMajor + "." + verMinor);
        }
      }
      // WebTV has Flash Player 4 or lower -- too low for video
      else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;

      var verArr = reqVerStr.split(",");
      var reqVer = parseFloat(verArr[0] + "." + verArr[2]);
  
      if (flashVer < reqVer){
        if (confirm(msg))
          window.location = "http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
      }
    }
  } 
}


// jump menus for popular databases and what's your subject widgets

function openDir(popularDatabases) { 
	var newIndex = popularDatabases.dbs.selectedIndex; 
	if ( newIndex == 0 ) { 
		alert( "Please select a database" ); 
	} else { 
		cururl = popularDatabases.dbs.options[ newIndex ].value; 
		window.location.assign( cururl ); 
	} 
} 

function openDirSubj(whatsYourSubject) { 
	var newIndex = whatsYourSubject.subjects.selectedIndex; 
	if ( newIndex == 0 ) { 
		alert( "Please select a research guide" ); 
	} else { 
		cururl = whatsYourSubject.subjects.options[ newIndex ].value; 
		window.location.assign( cururl ); 
	} 
}




function showImage(){
	
// code for choosing a random image for each page of the site

var theImages = new Array() 

theImages[0] = 'http://www.library.tufts.edu/tisch/graphics/randomPics/1.jpg'
theImages[1] = 'http://www.library.tufts.edu/tisch/graphics/randomPics/2.jpg'
theImages[2] = 'http://www.library.tufts.edu/tisch/graphics/randomPics/3.jpg'
theImages[3] = 'http://www.library.tufts.edu/tisch/graphics/randomPics/4.jpg'
theImages[4] = 'http://www.library.tufts.edu/tisch/graphics/randomPics/5.jpg'
theImages[5] = 'http://www.library.tufts.edu/tisch/graphics/randomPics/6.jpg'
theImages[6] = 'http://www.library.tufts.edu/tisch/graphics/randomPics/7.jpg'
theImages[7] = 'http://www.library.tufts.edu/tisch/graphics/randomPics/8.jpg'
theImages[8] = 'http://www.library.tufts.edu/tisch/graphics/randomPics/9.jpg'
theImages[9] = 'http://www.library.tufts.edu/tisch/graphics/randomPics/10.jpg'
theImages[10] = 'http://www.library.tufts.edu/tisch/graphics/randomPics/11.jpg'
theImages[11] = 'http://www.library.tufts.edu/tisch/graphics/randomPics/12.jpg'
theImages[12] = 'http://www.library.tufts.edu/tisch/graphics/randomPics/13.jpg'
theImages[13] = 'http://www.library.tufts.edu/tisch/graphics/randomPics/14.jpg'
theImages[14] = 'http://www.library.tufts.edu/tisch/graphics/randomPics/15.jpg'
theImages[15] = 'http://www.library.tufts.edu/tisch/graphics/randomPics/16.jpg'
theImages[16] = 'http://www.library.tufts.edu/tisch/graphics/randomPics/17.jpg'
theImages[17] = 'http://www.library.tufts.edu/tisch/graphics/randomPics/18.jpg'
theImages[18] = 'http://www.library.tufts.edu/tisch/graphics/randomPics/19.jpg'
theImages[19] = 'http://www.library.tufts.edu/tisch/graphics/randomPics/20.jpg'
theImages[20] = 'http://www.library.tufts.edu/tisch/graphics/randomPics/21.jpg'
theImages[21] = 'http://www.library.tufts.edu/tisch/graphics/randomPics/22.jpg'


var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));	
		
	
document.write('<img src="'+theImages[whichImage]+'">');
}


// code for generating Did You Know content
function contentGen() {
//

var CookieName = "randomContent";
 
var Init = true;
var Cookie = '';
var Separator = ',';
var Chunk = new Array();
var MaxContentNumber = 36;
var DispositionTimes = 0;
var Disposition = 'unique';
if(document.cookie.length > 0) {
   var spot = CookieName + '=';
   var cookiebegin = document.cookie.indexOf(spot);
   var cookieend = 0;
   if(cookiebegin > -1) {
      cookiebegin += spot.length;
      cookieend = document.cookie.indexOf(";",cookiebegin);
      if(cookieend < cookiebegin) { cookieend = document.cookie.length; }
      Cookie = document.cookie.substring(cookiebegin,cookieend);
      }
   }
if(Cookie.length > 1)
{
   Chunk = Cookie.split(Separator);
   if(Disposition == 'same') {
      var chunk = parseInt(Chunk[1]);
      chunk++;
      Chunk[1] = chunk;
      Init = false;
      if((DispositionTimes > 0) && (Chunk[1] > 0)) { Init = true; }
      }
   }
if(Init == true) {
   var nextnum = Math.ceil(Math.random() * MaxContentNumber);
   if(Chunk[0] > 0) {
      while(nextnum == Chunk[0]) { nextnum = Math.ceil(Math.random() * MaxContentNumber); }
      }
   Chunk[0] = nextnum;
   Chunk[1] = '1';
   }
if((Chunk[0] < 1) || (Chunk[0] > MaxContentNumber)) {
   Chunk[0] = Math.floor(Math.random() * (MaxContentNumber+1));
   Chunk[1] = '1';
   }
if((Chunk[0] < 1) || (Chunk[0] > MaxContentNumber)) { Chunk[0] = 1; }
var exp = '';
if(0 > 0) {
   var now = new Date();
   then = now.getTime() + (0 * 24 * 60 * 60 * 1000);
   now.setTime(then);
   exp = '; expires=' + now.toGMTString();
   }
var cookiecontent = Chunk.join(Separator);
document.cookie = CookieName + "=" + cookiecontent + '; path=/' + exp;
if(Chunk[0] == 1) {
   document.writeln('<p>That Tisch subscribes to hundreds of reliable and scholarly online alternatives to Wikipedia?  Try one of our <a href="http://www.library.tufts.edu/tisch/subject/general.htm#Dictionaries?WT.ti=Did You Know: General Subject Guide Dictionaries">our online encyclopedias and dictionaries</a>.</p>');
   }
if(Chunk[0] == 2) {
   document.writeln('<p>That Tisch Library is completely wireless?  Don\'t have your own laptop?  Then <a href="http://www.library.tufts.edu/tisch/laptopLending.html?WT.ti=Did You Know: Laptop Lending">borrow one from the circulation desk</a>.</p>');
   }
if(Chunk[0] == 3) {
   document.writeln('<p>That you can get books in just 48 hours through the Boston Library Consortium <a href="http://www.library.tufts.edu/tulips/blccat.html?WT.ti=Did You Know: Virtual Catalog">Virtual Catalog</a>?  Books are delivered to the circulation desk within 2 working days!</p>');
   }
if(Chunk[0] == 4) {
   document.writeln('<p>That Tisch Library now has Microsoft Office Suite on all the sit-down computers in the reference area?</p>');
   }
if(Chunk[0] == 5) {
   document.writeln('<p>That you can search several topical databases at once through <a href="http://multisearch.library.tufts.edu:8107/iii/mfrpro-tufts/loadSearchPage.do?searchpage=simple&searchtype=simple&accountid=tufts&accountpassword=tufts?WT.ti=Did You Know: Database MultiSearch">Database MultiSearch</a>?</p>');
   }
if(Chunk[0] == 6) {
   document.writeln('<p>That the Lilly Music Library has over 13,000 CDs that can be borrowed?  Check the catalog to see if your selection is available, have one of our staff retrieve it from our closed stacks, and you can borrow it for 7 days!</p>');
   }  
if(Chunk[0] == 7) {
   document.writeln('<p>Help build Tisch Library\'s collections by recommending items we don\'t have. While we\'re probably not going to buy your favorite beach reading, we do want to have on hand the materials you need for your class assignments and research. More information can be found <a href="http://www.library.tufts.edu/tisch/order_form.htm?WT.ti=Did You Know: Recommend a Purchase">here</a>. </p>');
   } 
if(Chunk[0] == 8) {
   document.writeln('<p>Need a scanner? Use ours, in the reference area. It will let you save your scanned images to your email or flash drive.</p>');
   } 
if(Chunk[0] == 9) {
   document.writeln('<p>Keep up with new additions to the Tufts Catalog via the <a href="http://www.library.tufts.edu/newAcq.html?WT.ti=Did You Know: New Acquisitions List">New Acquisitions List</a>. You can browse it by library location, author, and call number. You can also set up RSS feeds of new acquisitions. Stop in or call the reference desk for more information.</p>');
   }  
if(Chunk[0] == 10) {
   document.writeln('<p>You can renew books online as long as they are not overdue, recalled or have reached their renewal limit.  To renew books online, log into <a href="https://library.tufts.edu/patroninfo~S1?WT.ti=Did You Know: My Account">My account</a> and select the list of books currently checked out to you.  To renew overdue books, please call the Tisch Circulation desk @ 617-627-3347.</p>');
   } 
if(Chunk[0] == 11) {
   document.writeln('<p>Give a listen to Tisch Library\'s ongoing audio magazine series Tisch Talks . Featured topics include interviews with visiting authors, using the library catalog, finding book reviews and much more. <a href="http://www.library.tufts.edu/tisch/tischTalks.html?WT.ti=Did You Know: Tisch Talks">Check it out</a>, or better yet, set your RSS reader to subscribe to new issues automatically. </p>');
   } 
if(Chunk[0] == 12) {
   document.writeln('<p>Forgot your computer back in your dorm? We will lend you a laptop while you\'re in the library. More information can be found <a href="http://www.library.tufts.edu/tisch/laptopLending.html?WT.ti=Did You Know: Laptop Lending">here</a>.</p>');
   } 
if(Chunk[0] == 13) {
   document.writeln('<p>There\'s a new way to contact the reference desk. You can instant message us to ask any question during reference desk hours. <a href="http://www.library.tufts.edu/tisch/ra/im.htm?WT.ti=Did You Know: IM">Learn more</a>.</p>');
   } 
if(Chunk[0] == 14) {
   document.writeln('<p>You can apply for AS&E Alumni privileges at Tisch after graduation. This free service allows you to borrow materials from Tisch Library!</p>');
   } 
if(Chunk[0] == 15) {
   document.writeln('<p>You can pay Tisch Library fines with JUMBOCASH! </p>');
   }    
if(Chunk[0] == 16) {
   document.writeln('<p>You can apply for AS&E Alumni privileges at Tisch after graduation. This free service allows you to borrow materials from Tisch Library!</p>');
   }    
if(Chunk[0] == 17) {
   document.writeln('<p>You can apply for a Boston Library Consortium (BLC) card at the Tisch Circulation Desk. The BLC consists of 20 academic libraries in Boston and greater New England, including BU, BC, Brandeis, Brown and MIT. With a BLC card you can borrow materials and visit onsite!</p>');
   } 
if(Chunk[0] == 18) {
   document.writeln('<p>New Language Limits!  The Tufts Catalog now offers language limits for Latin and Ancient Greek. When you do an advanced keyword search you can limit to a language. You\'ll see the new languages listed there.</p>');
   } 
if(Chunk[0] ==19) {
	document.writeln('<p>Tisch Library has an extensive art collection. Take a walking tour of the art by using the Art Collection Guides available in the lobby and Reference Desk.</p>');
	}
	if(Chunk[0] == 20) {
   document.writeln('<p>Tisch Library offers Apple and Dell laptops for loan. All laptops are available for 4 hour periods on a first come, first served basis. You\re welcome to take the laptop outside of the library.</p>');
   } 
   if(Chunk[0] == 21) {
   document.writeln('<p>You can do your part to save the environment and save a little cash at the same time! Duplex printing is available on all Tisch Library printers. Instead of printing two pages for $.20, print one double-sided page for $.15.</p>');
   } 
   if(Chunk[0] == 22) {
   document.writeln('<p>Did you know you can now pay for printing and copying with your JumboCash account? Just swipe your Tufts ID and money is directly deducted from your account.</p>');
   } 
   if(Chunk[0] == 23) {
   document.writeln('<p>Did you know Tisch now has a color printer? One-sided printing costs $.30 per page and duplex printing costs $.45 per page.</p>');
   }    
   if(Chunk[0] == 24) {
   document.writeln('<p>Did you know Tisch offers both Mac sit down machines in the public area and Mac lending laptops available for use in the library? </p>');
   }     
   if(Chunk[0] == 25) {
   document.writeln('<p>Did you know Tisch has small and large study rooms available for individual and group study?  When you need quiet space or a place for a group to work these rooms are the place to go! </p>');
   }  
   if(Chunk[0] == 26) {
   document.writeln('<p>Did You Know that Tisch has 3 collaborative workstations where up to 6 students can work together around a PC with a large monitor and plenty of table space? </p>');
   }
   if(Chunk[0] == 27) {
   document.writeln('<p>Did you know that if you\'re looking for a place to study in the evening, Tisch Library is open until 1 a.m. from Sunday-Thursday.  And, on those nights, the Hirsh Reading Room is open for Tufts\' late, late night owls until 3 a.m.</p>');
   }
    if(Chunk[0] == 28) {
   document.writeln('<p>Did you know that since Tisch Library began surveying students and faculty in the 1990\'s, the library has consistently earned high satisfaction ratings from all of our users. Tisch Library values your opinion and regularly responds to user suggestions.</p>');
   }
    if(Chunk[0] == 29) {
   document.writeln('<p>Did you know that Tisch Library is streaming video clips for reserve viewing for 5 courses this spring with a plan to include all other reserves courses this coming summer and fall. This initiative will allow 24/7 access to students enrolled in the course through the Blackboard system.</p>');
   } 
    if(Chunk[0] == 30) {
   document.writeln('<p>Did you know that if you\'re looking for a place to study in the evening, Tisch Library is open until 1 a.m. from Sunday-Thursday.  And, on those nights, the Hirsh Reading Room is open for Tufts\' late, late night owls until 3 a.m.</p>');
   } 
    if(Chunk[0] == 31) {
   document.writeln('<p>Did you know that subject specialists are available for every discipline/class/major. You can schedule a one-on-one research appointment to get help with a research paper or project. Tisch Library offers walk-in, one-on-one, and group sessions, as well as classes, workshops, email, and IM reference services.</p>');
   } 
    if(Chunk[0] == 32) {
   document.writeln('<p>Did you know that the Lilly Music Library downhill boasts a large CD collection from which you can borrow.</p>');
   }    
    if(Chunk[0] == 33) {
   document.writeln('<p>Did you know that Tisch Library has a wonderful interlibrary loan service available to you at no additional cost. If we don\'t have the materials that you need, we can get them.</p>');
   }  
    if(Chunk[0] == 34) {
   document.writeln('<p>Did you know that Tisch Library’s computers have internet access and are equipped with Microsoft Office.  Additionally, the entire library is equipped with wireless so students can use their own laptop or borrow one from the Circulation desk for in-library use.</p>');
   }     
    if(Chunk[0] == 35) {
   document.writeln('<p>Did you know?  Working on a group project?  There are 11 group study rooms in the library and 3 collaborative workstations. Tisch Library has a study space for everyone. There are designated conversational and quiet study areas depending on whether you\'re studying in a group or by yourself.</p>');
   }
    if(Chunk[0] == 36) {
   document.writeln('<p>Did you know that Tisch Library has a Twitter account, under the name <a href=\"http://twitter.com/tischlibrary\">tischlibrary</a>.  More than 100 users found and followed us prior to any publicity.</p>');
   }       
}

// code for generating current Now at Tisch item that shows on every page

function currentNowAtTisch() {
	var CookieName = "randomNowAtTisch";
 
var Init = true;
var Cookie = '';
var Separator = ',';
var Chunk = new Array();
var MaxContentNumber = 6;
var DispositionTimes = 0;
var Disposition = 'unique';
if(document.cookie.length > 0) {
   var spot = CookieName + '=';
   var cookiebegin = document.cookie.indexOf(spot);
   var cookieend = 0;
   if(cookiebegin > -1) {
      cookiebegin += spot.length;
      cookieend = document.cookie.indexOf(";",cookiebegin);
      if(cookieend < cookiebegin) { cookieend = document.cookie.length; }
      Cookie = document.cookie.substring(cookiebegin,cookieend);
      }
   }
if(Cookie.length > 1)
{
   Chunk = Cookie.split(Separator);
   if(Disposition == 'same') {
      var chunk = parseInt(Chunk[1]);
      chunk++;
      Chunk[1] = chunk;
      Init = false;
      if((DispositionTimes > 0) && (Chunk[1] > 0)) { Init = true; }
      }
   }
if(Init == true) {
   var nextnum = Math.ceil(Math.random() * MaxContentNumber);
   if(Chunk[0] > 0) {
      while(nextnum == Chunk[0]) { nextnum = Math.ceil(Math.random() * MaxContentNumber); }
      }
   Chunk[0] = nextnum;
   Chunk[1] = '1';
   }
if((Chunk[0] < 1) || (Chunk[0] > MaxContentNumber)) {
   Chunk[0] = Math.floor(Math.random() * (MaxContentNumber+1));
   Chunk[1] = '1';
   }
if((Chunk[0] < 1) || (Chunk[0] > MaxContentNumber)) { Chunk[0] = 1; }
var exp = '';
if(0 > 0) {
   var now = new Date();
   then = now.getTime() + (0 * 24 * 60 * 60 * 1000);
   now.setTime(then);
   exp = '; expires=' + now.toGMTString();
   }
var cookiecontent = Chunk.join(Separator);
document.cookie = CookieName + "=" + cookiecontent + '; path=/' + exp;
/*if(Chunk[0] == 1) {
  document.writeln('<h3 style="padding-top: 4px">Tisch offers Spring workshops on EndNote and RefWorks</h3><hr class="grayNoPad" /><p>Between January 29 and March 25, the Reference staff is offering 90-minute workshops on these high-powered bibliographic software tools. All workshops are held in the Electronic Resources Center, Room 223. <a href="http://www.library.tufts.edu/tisch/ra/class_descriptions.htm">More information and online registration</a>.</p>');
}*/  
if(Chunk[0] == 1) {
   document.writeln('<h3 style="padding-top: 4px">Tisch Talks gets national recognition!</h3><hr class="grayNoPad" /><p><a href="http://www.library.tufts.edu/tisch/tischTalks.html?WT.ti=Now@Tisch: Tisch Talks">Tisch Talks</a>, Tisch Library\'s podcast series was recently spotted in a top 100 list, at <a href="http://www.onlinebestcolleges.com/blog/2009/100-terrific-websites-to-celebrate-national-library-week/">Online Best College.com</a>. The posting is <a href="http://www.onlinebestcolleges.com/blog/2009/100-terrific-websites-to-celebrate-national-library-week/">100 Terrific Websites to Celebrate National Library Week</a>.</p>'); 
}
if(Chunk[0] == 2) {
   document.writeln('<h3 style="padding-top: 4px">Check out the podcast series, Tisch Talks!</h3><hr class="grayNoPad" /><p>Did you know that Tisch Library has an audio magazine, Tisch Talks? Featured topics include interviews with visiting authors, using the library catalog, and finding book reviews. Check out <a href="tischTalks.html?WT.ti=Now@Tisch: Tisch Talks">this series</a>, or better yet, set your RSS reader to subscribe to new editions automatically.</p>');
   }
if(Chunk[0] == 3) {
   document.writeln('<h3 style="padding-top: 4px">Hidden Treasures at Tisch</h3><hr class="grayNoPad" /><p>Tisch library has resources to meet almost any need, including lots of things you wouldn\'t expect. Look for the Featured Resources on each of our web pages for favorites suggested by our subject experts..</p>');
   }  
if(Chunk[0] == 4) {
   document.writeln('<h3 style="padding-top: 4px">Your Tufts Library Account News Alerts</h3><hr class="grayNoPad" /><p>Now it\'s possible to get news about your library circulation activity in your RSS feed reader. To get connected, just log into your <a href="http://library.tufts.edu/patroninfo?WT.ti=Now@Tisch: Library Account News Alerts">Tufts library account</a> and select RSS Feeds. If you don\'t currently use an RSS feed reader, talk to a Tufts librarian to learn about the benefits of this great Internet tool.</p>');
   }      
if(Chunk[0] == 5) {
   document.writeln('<h3 style="padding-top: 4px">Thesis research got you down?</h3><hr class="grayNoPad" /><p>Want to get a headstart on your senior thesis research? If so, EXP 19 is for you! You will learn the major research tools and techniques specific to your subject area, develop a working bibliography of resources, and a plan for continuing your research. The specifics: Research for Success: Using the Library for Thesis and Capstone Projects (EXP 19). The class begins Tuesday February 2, 6-8:30pm and runs for 8 weeks. It is pass/fail, 1/2 credit. Register at SIS Online. More information.  </p>');
   }     
 if(Chunk[0] == 6) {
   document.writeln('<h3 style="padding-top: 4px">EndNotes and RefWorks Workshops Offered</h3><hr class="grayNoPad" /><p>EndNote and RefWorks are high-powered bibliographic citation management tools that enable users to capture references, embed them in research papers, and create instant bibliographies - all of which can make the research and writing process faster and more efficient. Between January 6 and 11, the Reference staff is offering 60-minute workshops on these tools. All workshops are held in the Electronic Resources Center, Room 223. All workshops are held in the Electronic Resources Center, Room 223. <a href="http://www.library.tufts.edu/tisch/ra/class_descriptions.htm">more information</a></p>');
   }    
}


// code for generating Featured Resource Content

function featuredResourcesGen() {
//

var CookieName = "randomFeaturedResourceContent";
 
var Init = true;
var Cookie = '';
var Separator = ',';
var Chunk = new Array();
var MaxContentNumber = 6;
var DispositionTimes = 0;
var Disposition = 'unique';
if(document.cookie.length > 0) {
   var spot = CookieName + '=';
   var cookiebegin = document.cookie.indexOf(spot);
   var cookieend = 0;
   if(cookiebegin > -1) {
      cookiebegin += spot.length;
      cookieend = document.cookie.indexOf(";",cookiebegin);
      if(cookieend < cookiebegin) { cookieend = document.cookie.length; }
      Cookie = document.cookie.substring(cookiebegin,cookieend);
      }
   }
if(Cookie.length > 1)
{
   Chunk = Cookie.split(Separator);
   if(Disposition == 'same') {
      var chunk = parseInt(Chunk[1]);
      chunk++;
      Chunk[1] = chunk;
      Init = false;
      if((DispositionTimes > 0) && (Chunk[1] > 0)) { Init = true; }
      }
   }
if(Init == true) {
   var nextnum = Math.ceil(Math.random() * MaxContentNumber);
   if(Chunk[0] > 0) {
      while(nextnum == Chunk[0]) { nextnum = Math.ceil(Math.random() * MaxContentNumber); }
      }
   Chunk[0] = nextnum;
   Chunk[1] = '1';
   }
if((Chunk[0] < 1) || (Chunk[0] > MaxContentNumber)) {
   Chunk[0] = Math.floor(Math.random() * (MaxContentNumber+1));
   Chunk[1] = '1';
   }
if((Chunk[0] < 1) || (Chunk[0] > MaxContentNumber)) { Chunk[0] = 1; }
var exp = '';
if(0 > 0) {
   var now = new Date();
   then = now.getTime() + (0 * 24 * 60 * 60 * 1000);
   now.setTime(then);
   exp = '; expires=' + now.toGMTString();
   }
var cookiecontent = Chunk.join(Separator);
document.cookie = CookieName + "=" + cookiecontent + '; path=/' + exp;
if(Chunk[0] == 1) {
   document.writeln('<p><a href="http://ezproxy.library.tufts.edu/login?url=http://www.europaworld.com" rel="nofollow">Europa World Plus</a><br/>Economic, political, and geographical information about over 250 countries and regions. Especially good for comparative statistics. </p>');
   }
if(Chunk[0] == 2) {
   document.writeln('<p><a href="http://www.library.tufts.edu/ezproxy/ezproxy.asp?LOCATION=NationMaster" rel="nofollow">NationMaster</a> Statistical data source on countries with information from sources such as the CIA World Factbook, UN, and OECD. Users can generate maps and graphs on all kinds of statistics.</p>');
   }
if(Chunk[0] == 3) {
   document.writeln('<p><a href="http://www.library.tufts.edu/ezproxy/ezproxy.asp?LOCATION=AccessScience" rel="nofollow">Access Science</a><br/>Online version of the McGraw-Hill Encyclopedia of Science &amp; Technology. Access to over 7,100 full text articles, 115,000 dictionary terms, biographies and Research Updates in science and technology. Updated daily. </p>');
   }  
if(Chunk[0] == 4) {
   document.writeln('<p><a href="http://plants.usda.gov?WT.ti=Featured Resources:Plants Database" rel="nofollow">Plants Database</a> <br/>Classifications and general information, with pictures and distribution maps of plants, lichens, mosses, etc. which grow in the United States or in its overseas territories. By the USDA, National Resources Conservation Service.</p>');
   } 
if(Chunk[0] == 5) {
   document.writeln('<p><a href="http://www.library.tufts.edu/ezproxy/ezproxy.asp?LOCATION=NationMaster" rel="nofollow">NationMaster</a> Statistical data source on countries with information from sources such as the CIA World Factbook, UN, and OECD. Users can generate maps and graphs on all kinds of statistics.</p>');
   } 
if(Chunk[0] == 6) {
   document.writeln('<p><a href="http://purl.access.gpo.gov/GPO/LPS34458?WT.ti=Featured Resources: MedlinePlus" rel="nofollow">MedlinePlus</a><br/>The US National Library of Medicine maintains this guide to health information, which lists authoritative websites by topic, directories of healthcare organizations, a medical encyclopedia and dictionaries, health information in Spanish, information on prescription and over-the-counter drugs, health news, and links to clinical trials.</p>');
   }     
}
