// 		*** jsHomeLib.js ***
//		created by: Bo Kinloch bkinloch@prodigy.net January, 2002 for the Transcriptions site.
//	A modest library of JavaScript functions used by the Transcriptions index or home page to create dynamically timed 
//	and moving content. 	*/

//*	*** detector( ) ***
var browser_name, browser_version;
//This function performs basic browser detection and alerts non-IE 4 users to the errors of their ways. */
function detector(){
	browser_name = navigator.appName;
	browser_version = parseFloat(navigator.appVersion);
	
	if( browser_name != "Microsoft Internet Explorer" || browser_version < 4 ){
		alert("You are viewing a dynamically enhanced website using DHTML.  Because browsers other than Internet Explorer do not fully support dynamically enhanced and scriptable features as robustly as IE, you may wish to switch browsers on your computer or download an IE 5.5 or later version from Microsoft. A Flash plug-in is not required at this time. You are currently using: " + browser_name + " " + browser_version );
	}
}

//	*** theSwap( ) *** 
//This is a function that encapsulates the link rollover behavior for the home page.  It takes the name to be used for 
//both the page and the image to be simultaneously swapped (i.e. name *.gif && *Text.html) the "stage" image and the left col specifically.
//When creating new content one MUST FOLLOW THIS NAMING CONVENTION: the stage image is called 
//'the_name.gif' where 'the_name' is the name of the (new or replaced) category. *Note: even if the image is a jpg, it can and MUST be renamed as ".gif."* Another page must also be created to 
//be displayed as the text in the left column. It MUST be named "'the_name'Text.html' 
//where 'the_name' is the same as 'the_name' used in "the_nameStage.html." EXAMPLE : main.gif & mainText.html */
var the_name = null;
function theSwap( the_name ){
	window.document.theStage.src = "images/" + the_name + ".gif";
	window.document.theLeftCol.location = the_name + "Text.html";
}

//	*** slideShow( ) ***
var the_interval = null; 
var i = 0;
var frameNms = new Array("about", "curriculum", "lci", "magazine", "research", "bookshelf", "hypertext", "newMedia", "topics", "resources", "events", "main");
function slideShow(the_interval){
	if(i){
		theSwap( frameNms[i]);
		i++;
	}
	the_interval = setInterval("theSwap(frameNms[i% frameNms.length]); i++;", 13000);
	return the_interval;
}
function stopShow(the_interval){
	if(the_interval){
		clearInterval(the_interval);
		the_interval = null;
	}
	return the_interval;
}
function nextSlide(the_interval){
	if(the_interval){
		i--;
		the_interval = stopShow(the_interval);
	}
	theSwap(frameNms[(++i) % frameNms.length]);
	return the_interval;
}
function prevSlide(the_interval){
	var index = i % frameNms.length;
	the_interval = stopShow(the_interval);
	if((index-1) < 0){
		i = frameNms.length;
		theSwap(frameNms[(--i) % frameNms.length]);
	} else {
	--i;
	theSwap(frameNms[i % frameNms.length]);
	}
}
/************************************************************
*	imgLinker() 
*		This function's a real bear. I would like to replace it 
*		with almost anything more elegant, but in the meantime
*		I guess it'll have to do. It retrieves the current array
*		member to figure out which page to link to (hence the long
*		list of 'else if' When will JScript get a switch statement?
*
*************************************************************/
function imgLinker(){
	var link_name;
	if(the_interval){
		i--;
	}
	link_name = frameNms[i % frameNms.length];
	if(link_name == "main"){
		i = 0;
		return;
	}
	else if(link_name == "about"){
		window.document.location = "about/index.asp";
	}
	else if(link_name == "curriculum"){
		window.document.location = "curriculum/index.asp";
	}	
	else if(link_name == "lci"){
		window.document.location = "curriculum/lci/index.asp";
	}
	else if(link_name == "magazine"){
		window.document.location = "curriculum/lci/magazine";
	}	
	else if(link_name == "research"){
		window.document.location = "research/index.asp";
	}
	else if(link_name == "bookshelf"){
		window.document.location = "research/bookshelf/index.asp";
	}
	else if(link_name == "hypertext"){
		window.document.location = "research/hypertext/index.asp";
	}
	else if(link_name == "newMedia"){
		window.document.location = "research/new_media_writing/index.asp";
	}
	else if(link_name == "topics"){
		window.document.location = "research/topics/index.asp";
	}	
	else if(link_name == "resources"){
		window.document.location = "resources/index.asp";
	}
	else if(link_name == "events"){
		window.document.location = "events/index.asp";
	}	
}