//---------------------------------------
// start: BROWSER DETECTION
//---------------------------------------

//for NS 4+, IE 5+
var doc, doc2, doc3, sty;
var n4,ie,n6;
	if (document.layers){
		n4=true;doc = "document.";doc2="document.";doc3="";sty="";
	} else if (document.all){
		ie=true;doc = "document.all.";doc2="";doc3="";sty=".style";
	} else if(document.getElementById){
		n6=true;doc = "document.getElementById('";doc2="'');";doc3="');";sty=".style";
	} 
//---------------------------------------
// end: BROWSER DETECTION
//---------------------------------------

//---------------------------------------
// start: img descriptive text
//---------------------------------------
	imgInfoArray = new Array('Firmly placed at the center of a fundamentally traditional Yale campus, Beinecke Library is a genuine architectural surprise.  A jewel box of a building, appearing to hover over the granite plain of Beinecke Plaza, it has proportions of Platonic purity: exactly twice as deep as high, and three times as long.'   
			,'One of the largest buildings in the world devoted entirely to rare books and manuscripts, the Beinecke Rare Book and Manuscript Library has room in the central tower for 180,000 volumes and in the underground book stacks for over 600,000 volumes; it now contains about 500,000 volumes and several million manuscript pages.'
			,'The Beinecke Library contains the principal rare books and literary manuscripts of Yale University and serves as a center for research by students, faculty, and other serious readers, whether connected with Yale or not. Materials do not circulate, but may be used in the reading room on the court level.'
			,'The Beinecke Library, of Vermont marble and granite, bronze and glass, was designed by Gordon Bunshaft, of the firm of Skidmore, Owings and Merrill; the George A. Fuller Construction Company was the general contractor. The translucent marble panes of the exterior are one and one-quarter inches thick.'
			,'This architectural model for the Beinecke Library shows the ultimate shape of the building: fifteen panels long by five panels high by ten panels deep. The earliest plan was to use onyx for the panels, but when not enough could be found, wonderfully grained Vermont marble was substituted.<br><br>The sunken courtyard contains three marble sculptures by Isamu Noguchi: the earth (pyramid), the sun (circle), and chance (Cube).'
			,'Isamu Noguchi called the sculpture court he designed the "garden of the Library."  The pyramid, he said, represents the geometry of the earth, the apex of which introduces another point of infinity. The large circular disc is the sun, the coiled magnet, a ring of energy, and the cube, standing on one point, signifies chance.'
			,'Isamu Noguchi, the Japanese-American sculptor of Beinecke\'s sunken court-garden, wrote of it that "it is nowhere, yet somehow familiar. Its size is fictive, of infinite space or cloistered containment."'  
			,'The building and its endowment are the gift of Edwin J. Beinecke, Yale 1907; Frederick W. Beinecke, Yale 1909S; Walter Beinecke, Yale 1910; and their families.'
			,'The library contains five major collections: the General Collection of Rare Books and Manuscripts, the Collection of American Literature, the Collection of Western Americana, the German Literature Collection, and the Osborn Collection of English literary and historical manuscripts.  '
			,'Beinecke is a box within a box. The inner glass-walled book tower is different from, but as crisply detailed as, the surrounding stone enclosure.  Their hardness invites visitors to imagine, by contrast, the soft leather and paper of the books sealed away but in full view. '
			,'The case in the northwest corner of the Beinecke\'s mezzanine level is a quiet but powerful magnet for visitors. It contains the Gutenberg Bible, arguably the first Western book printed with movable type.'
			,'The Beinecke Library sponsors four major exhibitions each year as well as dozens of smaller exhibits in the two curved exhibition cases at the top of the stairwells on the Mezzanine level.  In addition to these events, the Library has a very active program of readings, concerts, performances, and lectures that highlight the richness of the collections. Most of these events are free and open to the public.'
			,'The Library offers short-term fellowships to support visiting scholars pursuing post-doctoral or equivalent research in its collections as well as research fellowships to graduate and professional students enrolled in Yale University who wish to consult the Beinecke Collections as a primary basis for their research.  The Library sponsors master classes taught by visiting scholars, which offer opportunities for intensive study in the Yale collections.'
			,'Beinecke\'s cool gray granite and white marble contrast with the warmer stone and red brick of the Law School, Berkeley College, and Sterling Library. The Law School is shown here with a detail of the Beinecke.'
			,'Along the walk behind Beinecke, the repetitive bays of the Law School walls are framed by limestone columns of Commons and the Library\'s white marble panels.'
		);


//---------------------------------------
// end: img descriptive text
//---------------------------------------

//--------------------------------------------------
// start: number image loading
//--------------------------------------------------
// NOTE: 	 	'numInfoArray'
//					'imgData'
//					'imgDir'
//					'currentImg' 
//
// defined on .html page before loading these functions 
//
  // numCount = numInfoArray.length;
	var numCount = 15;
	
	numImgArrayOn = new Array();	
	numImgArrayOff = new Array();	
	tourInfoArray = new Array();


	var currentImg =0								
	function loadNumberImages(imgCnt){
		for(var i=0; i < imgCnt; i++){
			numName = i+1
			if (numName <= 9){numName= '0' +numName};
			origNum = numName;

			numName = 'num' + numName;
			numImgArrayOn[numName] = new Image();
			srcOn = '../images/tour/bldg_m_' + origNum + '_on.gif'
			numImgArrayOn[numName].src = srcOn;
			numImgArrayOff[numName] = new Image();
			numImgArrayOff[numName].src = '../images/tour/bldg_m_' + origNum + '_off.gif';
			tourInfoArray[numName] = imgInfoArray[i];
		}
	}
loadNumberImages(numCount);
//--------------------------------------------------
// end: number image loading
//--------------------------------------------------

//--------------------------------------------------
// show main image
//--------------------------------------------------
var selectedImageName='num01';

function selectMainImage(chosenImgName){
	StopTheClock();
	showMainImage(chosenImgName);
}

function showMainImage(chosenImgName){
	
	selectedImageName = chosenImgName;	// set to global variable so won't appear 
																		// in 'off' position on mouse out
	
	//show correct main image
	document.tourphoto.src = '../images/tour/bldg_slide_' + chosenImgName.substring(3,5) + '.jpg';

	// set correct text
	writeInfo(chosenImgName,'')

	// turn all number graphics to the off state, except the selected one
	for(var i=0; i <numCount;i++){
			i_num = i +1;
			var imgName = '';
			if (i_num < 10){	
				imgName = 'num0' +i_num;
			}else{		
				imgName = 'num' + i_num;		
			}
		
			imgObj = eval('document.' + imgName);
	
			if (imgName == chosenImgName){
				imgObj.src = eval('numImgArrayOn.'+ imgName + '.src');		// show 'ON' image
			}else{
				imgObj.src = eval('numImgArrayOff.'+ imgName + '.src');		// show 'OFF' image
				//alert(imgObj.src);
			}
	}	
	

}

//--------------------------------------------------
// start: number image/info functions
//--------------------------------------------------
	function flipNum(imgName,onOff){
		if(timerRunning)
			return;
		if (selectedImageName ==imgName){
				return;}
		//alert(eval('tourInfoArray.'+imgName) );
		imgObj = eval('document.' + imgName)
		if (onOff==1){	
			imgObj.src = eval('numImgArrayOn.'+ imgName + '.src');
		}else {
		
			imgObj.src = eval('numImgArrayOff.'+ imgName + '.src');
		}
	}

	function playSlideShow(){
		
	}

	function writeInfo(imgName,txt){
		projInfoLayer = eval(doc+"infoLayer"+doc3);
		if (txt == ''){
			infoText = "<p  class=qinfoMainText>" + tourInfoArray[imgName] 
						+ "</p><p class=qinfoTitleText>Photograph &copy;Richard Cheek.</p>";
		}else {
			infoText = "<p  class=qinfoMainText>" + txt +"</p>";
		};
		
		if (n4){	
			document.layers[0].document.write(infoText);
			document.layers[0].document.close();
		}else{
			projInfoLayer.innerHTML = infoText;
		}
	}
	

//--------------------------------------------------
// end: number image/info functions
//--------------------------------------------------	
//--------------------------------------------------
// start: play slideshow/timer functions
//--------------------------------------------------	
var secs
var timerID = null
var timerRunning = false
var delay = 10000

function InitializeTimer()
{
    // Set the length of the timer, in seconds
    secs = 1
    StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    if (secs==16) {
        StopTheClock()
        // Alert that shows after allotted time
       // alert("You have just wasted 10 seconds of your life.")
    }  else  {
    	numName = 'num'+secs;
    	if (secs < 10){ numName = 'num0'+secs;}
    	showMainImage(numName);
        self.status = numName;
        secs = secs + 1;
        timerRunning = true;
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}

//--------------------------------------------------
// end: play slideshow/timer functions
//--------------------------------------------------	

//--------------------------------------------------
// end: main image functions
//--------------------------------------------------