var item = new Array()
item[0]="<a href='#'><iframe src='1.htm' marginwidth = '0' name='iframe1' id='iframe1' width='366px' height='234px' scrolling='no' frameborder='0'></iframe>"
item[1]="<a href='#'><iframe src='2.htm' marginwidth = '0' name='iframe1' id='iframe1' width='366px' height='234px' scrolling='no' frameborder='0'></iframe>"
item[2]="<a href='#'><iframe src='3.htm' marginwidth = '0' name='iframe1' id='iframe1' width='366px' height='234px' scrolling='no' frameborder='0'></iframe>"
item[3]="<a href='#'><iframe src='4.htm' marginwidth = '0' name='iframe1' id='iframe1' width='366px' height='234px' scrolling='no' frameborder='0'></iframe>"
item[4]="<a href='#'><iframe src='5.htm' marginwidth = '0' name='iframe1' id='iframe1' width='366px' height='234px' scrolling='no' frameborder='0'></iframe>"
var textitem = new Array()
textitem[0]="<a href='#'><iframe src='1text.htm' marginwidth = '0' name='iframe2'  width='100%' height='40px' scrolling='no' frameborder='0' ></iframe>"
textitem[1]="<a href='#'><iframe src='2text.htm' marginwidth = '0' name='iframe2'  width='100%' height='40px' scrolling='no' frameborder='0' ></iframe>"
textitem[2]="<a href='#'><iframe src='3text.htm' marginwidth = '0' name='iframe2' width='100%' height='40px' scrolling='no' frameborder='0' ></iframe>"
textitem[3]="<a href='#'><iframe src='4text.htm' marginwidth = '0' name='iframe2' width='100%' height='40px' scrolling='no' frameborder='0' ></iframe>"
textitem[4]="<a href='#'><iframe src='5text.htm' marginwidth = '0' name='iframe2'  width='100%' height='40px' scrolling='no' frameborder='0' ></iframe>"
//var more_text ="<a href='#'><iframe src='more_text.htm' marginwidth = '0' name='iframe7' id='iframe7' width='100%' height='25px' scrolling='no' frameborder='0' ></iframe>"
//item[5]="<a href='#'><iframe src='http://www.ed.psu.edu/external/rotating/6.htm' name='iframe1' id='iframe1' width='363' height='270' scrolling='no' frameborder='0'></iframe>"
//item[6]="<a href='#'><iframe src='http://www.ed.psu.edu/external/rotating/7.htm' name='iframe1' id='iframe1' width='363' height='270' scrolling='no' frameborder='0'></iframe>"
var lastPicture=0
var topNumber=4
var numberOfPictures=5
var bottomNumber=0
var loopIndex = 0
currentPicture = Math.round(Math.random() * topNumber) + bottomNumber;
var pictureArray = ""
pictureArray=pictureArray + currentPicture
var stopRotation = true;

var ns6=document.getElementById&&!document.all

	/*	JavaScript does not offer Left and Right functions. Use the following functions to extract the left or the right part of a string.  */

 
function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}
function changeImage(imageName){
	
window.clearTimeout(this.timeoutID);

//delete this.timeoutID;  IE6 sees this as a javascript error  JEB6

//alert("imagename = " + imageName + " and " + "currentPicture = " + displayedPicture);
if(imageName=="img0" && displayedPicture !=0){
/*document.getElementById("div1").style.border = "bold";
document.getElementById("div1").style.borderColor = 'red';*/
document.getElementById("divMain").innerHTML=item[0];
document.getElementById("divMore").innerHTML=more_text;
displayedPicture=0;
}
else if(imageName=="img1" && displayedPicture !=1){
/*document.getElementById("div2").style.border = "inset";*/
document.getElementById("divMain").innerHTML=item[1];
document.getElementById("divMore").innerHTML=more_text;
displayedPicture=1;
}
else if(imageName=="img2" && displayedPicture !=2){
/*document.getElementById("div3").style.border = "inset";*/
document.getElementById("divMain").innerHTML=item[2];
document.getElementById("divMore").innerHTML=more_text;
displayedPicture=2;
}
else if(imageName=="img3" && displayedPicture !=3){
/*document.getElementById("div4").style.border = "inset";*/
document.getElementById("divMain").innerHTML=item[3];
document.getElementById("divMore").innerHTML=more_text;
displayedPicture=3;
}
else if(imageName=="img4" && displayedPicture !=4){
/*document.getElementById("div5").style.border = "inset";*/
document.getElementById("divMain").innerHTML=item[4];
document.getElementById("divMore").innerHTML=more_text;
displayedPicture=4;
}





//alert(item[currentPicture]);
//alert(x);
//alert(item[currentPicture].indexOf("iframe3"));

//setTimeout("changeItem()",10000);

}

function selectImage(imageName)
{
	window.clearTimeout(this.timeoutID);
	resetButtons();
	
	if(imageName=="img0" && displayedPicture !=0)
	{
		document.getElementById(imageName).style.border = 'inset';
		document.getElementById("divMain").innerHTML=item[0];
		document.getElementById("divText").innerHTML=textitem[0];
		document.getElementById("divMore").innerHTML=more_text;
		displayedPicture=0;
	}
	else if(imageName=="img1" && displayedPicture !=1)
	{
		document.getElementById(imageName).style.border = 'inset';
		document.getElementById("divMain").innerHTML=item[1];
		document.getElementById("divText").innerHTML=textitem[1];
		document.getElementById("divMore").innerHTML=more_text;
		displayedPicture=1;
	}
	else if(imageName=="img2" && displayedPicture !=2)
	{
		document.getElementById(imageName).style.border = 'inset';
		document.getElementById("divMain").innerHTML=item[2];
		document.getElementById("divText").innerHTML=textitem[2];
		document.getElementById("divMore").innerHTML=more_text;
		displayedPicture=2;
	}
	else if(imageName=="img3" && displayedPicture !=3)
	{
		document.getElementById(imageName).style.border = 'inset';
		document.getElementById("divMain").innerHTML=item[3];
		document.getElementById("divText").innerHTML=textitem[3];
		document.getElementById("divMore").innerHTML=more_text;
		displayedPicture=3;
	}
	else if(imageName=="img4" && displayedPicture !=4)
	{
		document.getElementById(imageName).style.border = 'inset';
		document.getElementById("divMain").innerHTML=item[4];
		document.getElementById("divText").innerHTML=textitem[4];
		document.getElementById("divMore").innerHTML=more_text;
		displayedPicture=4;
	}
	
}

function resetImage(imageName){
/*if(imageName=="img0"){
document.getElementById("div1").style.border = "solid";
}
if(imageName=="img1"){
document.getElementById("div2").style.border = "solid";
}
if(imageName=="img2"){
document.getElementById("div3").style.border = "solid";
}
if(imageName=="img3"){
document.getElementById("div4").style.border = "solid";
}
if(imageName=="img4"){
document.getElementById("div5").style.border = "solid";
}*/
}
function resetButtons()
{
	//divNumber= displayedPicture+1;

	for (var i = 0; i <= 4; i++) 
	{
		document.getElementById("img"+i).style.border = 'outset';
		//jeb6 document.getElementById("div"+i).style.borderColor = 'black';
	}

		//document.getElementById("div" + divNumber).style.border = "inset";
		//nextDiv=divNumber +1;
		//document.getElementById("div" +divNumber).style.border-color = 'red';
		//document.getElementById("div" +nextDiv).style.borderColor = 'red';
}

function changeItem()
{
	if(document.layers)
	{
		document.layerMain.document.write(item[currentPicture])
		document.layerMain.document.close()
		
	}
	
	//this prevents an error if the code for the div with id = divMain has not been installed in the form.  jeb6 12/11/06
	if (document.getElementById("divMain"))
	{
		if(ns6)document.getElementById("divMain").innerHTML=item[currentPicture]
		 
		{
			if(document.all)
			{
				divMain.innerHTML=item[currentPicture];
			}
		}
	}
	
	if (document.getElementById("divText"))
	{
		if(ns6)document.getElementById("divText").innerHTML=textitem[currentPicture]
		 
		{
			if(document.all)
			{
				divText.innerHTML=textitem[currentPicture];
			}
		}
	}
	
	//document.getElementById("divMore").innerHTML=more_text;
	displayedPicture=currentPicture;
	//resetButtons(currentPicture);
	currentPicture = Math.round(Math.random() * topNumber) + bottomNumber;
	
	//if all the pictures have  been shown in this sequence, start the sequence over by clearing the first 3 pictures
	//this enables the pictures to be randomly ordered, but prevents a picture from repeating until at least 5 others
	// have shown first 
		if (pictureArray.length >= 5) {
		//lastPicture = Right(pictureArray, 1);
		pictureArray=Right(pictureArray,4);}
		loopIndex=0;
		//if  the last picture is the same as the current picture, get another picture
		
		// generate a new picture.  If it is already in the list, generate a new picture.  Keep doing this until you have
		// a picture that has not been show in this sequence.  Stop trying and quit the loop after 1000 tries.
		while (pictureArray.indexOf(currentPicture) != -1)
			{
			loopIndex++;
			currentPicture = Math.round(Math.random() * topNumber) + bottomNumber;
			/*while (lastPicture == currentPicture)
				{
					currentPicture = Math.round(Math.random() * topNumber) + bottomNumber;
				}
		    if (loopIndex>=1000) {break}*/
			}
		pictureArray = pictureArray + currentPicture;
	
this.timeoutID=setTimeout("changeItem()",7500)
}
window.onload=changeItem