// JavaScript Document
var timeOutId;
var ome = false;
var currentMenu = "";
var imgArray = new Array();
var imageToShow = 0;
var currentArray = 0;

function showNav(theNavLayer) {
	clearTimeout(timeOutId);
	hideNav('program_pop_nav');
	hideNav('projects_pop_nav');
	hideNav('media_pop_nav');	
	if(theNavLayer == 'program_pop_nav') {
		document.getElementById(theNavLayer).style.visibility = 'visible';
		document.getElementById('program_arrow').style.visibility = 'visible';
	}

	if(theNavLayer == 'projects_pop_nav') {
		document.getElementById(theNavLayer).style.visibility = 'visible';
		document.getElementById('projects_arrow').style.visibility = 'visible';
	}

	if(theNavLayer == 'media_pop_nav') {
		document.getElementById(theNavLayer).style.visibility = 'visible';
		document.getElementById('media_arrow').style.visibility = 'visible';
	}

	currentMenu = theNavLayer;
}



function setActivePage() {
	if (navigator.appVersion.indexOf("Win")!=-1) {
		document.getElementById('program_pop_nav').style.width='130px';
		document.getElementById('program_pop_nav').style.height='80px';
		document.getElementById('program_pop_nav').style.left='530px';
		document.getElementById('program_pop_nav').style.top='40px';
		
		document.getElementById('projects_pop_nav').style.width='130px';
		document.getElementById('projects_pop_nav').style.height='80px';
		document.getElementById('projects_pop_nav').style.left='530px';

		document.getElementById('projects_pop_nav').style.top='100px';

		document.getElementById('media_pop_nav').style.width='130px';
		document.getElementById('media_pop_nav').style.height='80px';
		document.getElementById('media_pop_nav').style.left='530px';
		document.getElementById('media_pop_nav').style.top='162px';

		if(document.getElementById('content_long')) {
			document.getElementById('content_long').style.width = '355';
		}
		if(document.getElementById('content_short')) {
			document.getElementById('content_short').style.width = '355';
		}
		if(document.getElementById('content_wide')) {
			document.getElementById('content_wide').style.width = '511';
		}

	}
	document.getElementById(activePage).style.color= '#990000';
	
	imgArray[0] = new Array('v1_1.jpg','v1_2.jpg');
	imgArray[1] = new Array('v2.jpg');
	imgArray[2] = new Array('v4_1.jpg');
	imgArray[3] = new Array('v5_1.jpg','v5_2.jpg', 'v5_3.jpg');
	imgArray[4] = new Array('v6.jpg','v6_1.jpg','v6_2.jpg');
	imgArray[5] = new Array('v7_1.jpg','v7_2.jpg');
	imgArray[6] = new Array('v8_1.jpg','v8_2.jpg', 'v8_3.jpg', 'v8_4.jpg');
	imgArray[7] = new Array('v20_1.jpg','v20_2.jpg','v20_3.jpg', 'v20_4.jpg', 'v20_5.jpg', 'v20_6.jpg', 'v20_7.jpg','v20_8.jpg', 'v20_9.jpg');
	imgArray[8] = new Array('v21_1.jpg','v21_2.jpg', 'v21_3.jpg');
	imgArray[9] = new Array('v23.jpg','v23_1.jpg','v23_2.jpg','v23_3.jpg', 'v23_4.jpg', 'v23_5.jpg', 'v23_6.jpg', 'v23_7.jpg');
	imgArray[10] = new Array('v25_1.jpg','v25_2.jpg','v25_3.jpg', 'v25_4.jpg', 'v25_5.jpg');
	imgArray[11] = new Array('v27_1.jpg','v27_2.jpg');
	imgArray[12] = new Array('v29_5.jpg','v29_8.jpg','v29_10.jpg', 'v29_11.jpg');
	imgArray[13] = new Array('v32_1.jpg','v32_2.jpg','v32_3.jpg');
	imgArray[14] = new Array('v9_1.jpg','v9_2.jpg','v9_3.jpg', 'v9_4.jpg', 'v9_5.jpg', 'v9_6.jpg', 'v9_7.jpg','v9_8.jpg');
	if(activeCoverage != '') {
		document.getElementById(activeCoverage).style.color= '#000000';
		document.getElementById(activeCoverage).style.fontSize= '12px';
	}
}

function showImages(imgArrayPos, imageNum) {
	currentArray = imgArrayPos;
	theImage = imgArray[imgArrayPos][imageNum];
	document.getElementById('showImage').src = "images/" + theImage;
	document.getElementById('imgViewer').style.visibility = 'visible';	
}

function closeImageViewer() {
	document.getElementById('imgViewer').style.visibility = 'hidden';
	document.getElementById('showImage').src = "images/spacer.gif";
	document.getElementById('showImage').width = 400;
	document.getElementById('showImage').height = 300;
}

function nextImage() {
	if (imageToShow == (imgArray[currentArray].length - 1)) {
		imageToShow = 0;
	} else {
		imageToShow = imageToShow + 1;
	}
	showImages(currentArray,imageToShow);
}	

function prevImage() {
	if (imageToShow == 0) {
		imageToShow = imgArray[currentArray].length;
	} else {
		imageToShow = imageToShow - 1;
	}
	showImages(currentArray,imageToShow);
}	

function setNavTimeout(theNavLayer) {
	timeOutId = setTimeout("hideNav('" + theNavLayer + "')", 1000);	
}

function hideNav(theNavLayer) {
	if(theNavLayer == 'program_pop_nav') {
		document.getElementById(theNavLayer).style.visibility = 'hidden';
		document.getElementById('program_arrow').style.visibility = 'hidden';
	}

	if(theNavLayer == 'projects_pop_nav') {
		document.getElementById(theNavLayer).style.visibility = 'hidden';
		document.getElementById('projects_arrow').style.visibility = 'hidden';
	}

	if(theNavLayer == 'media_pop_nav') {
		document.getElementById(theNavLayer).style.visibility = 'hidden';
		document.getElementById('media_arrow').style.visibility = 'hidden';
	}

	currentMenu = "";
}

function clearTimeOut(theNavLayer) {
	clearTimeout(timeOutId);	
}

var myQuote = new Array(
	'"I came to VRI to see and work on cars that push the boundaries of current technology and ideas."<br /><br />-BEN ROMAJIN-STANT, STUDENT',
	'"VRI is all about unique insights and technology applied to real world engineering problems. Best of all, we get to build and drive the results."<br /> <br />-JOHN BROWN, STUDENT',
	'"The VRI is the best place around to learn hybrid technology and get to use the wide variety of tools and equipment that we do."<br /> <br />-Ryan Sluss, Student',
	'"Gain experience on all facets of cars, something an engineering degree can\'t do."<br /> <br />-Austin Hinderer, Student',
	'"Nowhere else presents the same kind of experience and learning focused on vehicles that the VRI provides."<br /> <br />-Kirk Koontz, Student',
	'"To learn what goes into designing and testing parts. Finding problems and solving them."<br /> <br />-Marc Njos, Student',
	'"This is an excellent springboard into a multitude of engineering related fields. This program shows future employers that you\'re up to date with the cutting edge of vehicle/composite/mechanical technologies."<br /> <br />-Drew Wohlenhaus, Student',
	'"You\'re surrounded by students and teachers that share the same interests."<br /> <br />-Nate McPherson, Student',
	'"The VRI can help me gain a foothold in the industry."<br /> <br />-Matt Haugness, Student',
	'"This department combines access to the finest equipment and materials with world class educators."<br /> <br />-Ben Vos, Student',
	'"I attended a pretty good engineering school in New York . . . after a year, I had used a lathe for, maybe, five or six hours . . .the formula team had a senior-only driving rule and doubts about having a female member, (so) I came to the VRI."<br /> <br />-Emily Harding, Student',
	'"You get a lot of hands-on knowledge about vehicles, engines and everything in between."<br /> <br />-Nick Ross, Student',
	'"The VRI provides opportunities and hands-on experience that no other program can match."<br /> <br />-Chris J. Higbee, Student',
	'"To contribute to breakthroughs and developments in automotive design."<br /> <br />-Russell Pendergraff, Student',
	'"The VRI offers the freedom to pursue unproven theories, designs, etc."<br /> <br />-Adam Baxter, Student',
	'"To learn how to build amazing cars and to do something that has never been done in the auto industry."<br /> <br />-Joshua Smith, Student',
	'"To see and work on cars that push the boundries of current technology."<br /> <br />-Ben Romeijn-Stout, Student',
	'"It\'s like engineering but better."<br /> <br />-Eric Olausen, Student'
)



var bottomQuote = new Array(
	'FROM COWS TO MPG.<br /> VRI ON ABC GOOD MORNING AMERICA~sm_inset_eric_leonhardt.jpg~http://abcnews.go.com/Video/playerIndex?id=2016274~_blank',
	'FEDERAL WAY DRIVES TOWARD ENVIRONMENTALLY-FRIENDLY GOAL.~sm_inset_viking32a.jpg~coverage_9_21_07.htm~_self',
	'INVENTING A LEAN GREEN MACHINE.~sm_inset_light.jpg~coverage_9_27_04.htm~_self'
)

var myArrayLength = myQuote.length;	
var currentTopQuote = 0;
var currentBottomQuote = 0;
var bottomArrayLength = bottomQuote.length;

function setPageParams() {
	setTopQuote('-1');
	//setBottomQuote('-1');
	setActivePage();
}

function setTopQuote(myNumber) {
	if(myNumber < 0) {
		theQuote = getRandomNum(myArrayLength);
	} else {
		if(myNumber == (myArrayLength - 1)) {
			theQuote = 0;
		} else {
			theQuote = myNumber + 1;
		}
	}
	currentTopQuote = theQuote
	document.getElementById("top_quote").innerHTML= myQuote[theQuote];
}



function setBottomQuote(myNumber) {
	if(myNumber < 0) {
		theQuote = getRandomNum(bottomArrayLength);
	} else {
		if(myNumber == (bottomArrayLength - 1)) {
			theQuote = 0;
		} else {
			theQuote = myNumber + 1;
		}
	}
	currentBottomQuote = theQuote
	
	block_array = bottomQuote[theQuote];
	block_array = block_array.split("~");
	quote_str = block_array[0];
	img_src = "images/" + block_array[1];
	link_src = block_array[2];
	link_target = block_array[3];

	document.getElementById("bottom_quote").innerHTML= quote_str;
	document.getElementById("bottom_image").src = img_src;
	document.getElementById("bottom_link").href = link_src;
	document.getElementById("bottom_link").target = link_target;
}

function getRandomNum(myLength) {
	 return Math.floor(Math.random() * myLength);
}	

function nextQuote() {
	setTopQuote(currentTopQuote);
}

function nextBottomQuote() {
	setBottomQuote(currentBottomQuote);
}	