window.onload = initAll;
var jasonWin = this.window;
var count=0;
var picSwitch=0;

function closeJasonWindow() {
	
	jasonWin.close();
	return false;
	
}


function initAll() {
	
	if (document.getElementById) {
	document.getElementById("closeWin").onclick = closeJasonWindow;
	document.getElementById("reload").onclick = newQuote;
	document.getElementById("pic1").onclick = dontReturn;
	document.getElementById("quote").innerHTML = "&#34;Umm, hi... I didn't prepare an audition. Time for improv... click the &#39;speak&#39; button and I'll make up a new line.&#34;";
	countQuotes();
	setupRollover(document.images[0]);
	}
	else	{
		alert("Sorry, your browser doesn't support this script");
	}
}

function dontReturn () {
	count=0;
	countQuotes();
	document.getElementById("quote").innerHTML = "&#34;Okay... I'll start over...&#34;";
	return false;
}


function setupRollover(thisImage) {

	thisImage.outImage = new Image();
	thisImage.outImage.src = thisImage.src;
	thisImage.onmouseout = rollOut;

	thisImage.overImage = new Image();
	thisImage.overImage.src = "images/jason.jpg";
	thisImage.onmouseover = rollOver;
		
}


function rollOut() {
	this.src = this.outImage.src;
}

function rollOver() {
	this.src = this.overImage.src;
}
	

function newQuote() {
	document.getElementById("quote").innerHTML = makeQuote();
	countQuotes();
	return false;
}

function countQuotes() {
		if (count<100) {
		document.getElementById("counter").innerHTML = count;
		count++; }
		else {
		document.getElementById("counter").innerHTML = "About a million...";
		}
}

function makeQuote() {
	var subject = newSubject();
	var verb = newVerb();
	var ending = newEnd();
	var sentence = "&#34;" + subject + " " + verb + " " + ending + ".&#34;";
	return sentence;
	}
	
function newSubject() {
	var subjectList = new Array("McGuirk","Stephanie","Brendon","Melissa","Missus Small",
	"Walter","Perry","Dwayne","Josie","Junior Adelberg","Shannon","Fenton");
	var i = Math.floor(Math.random () * 12);
	return subjectList[i];
}

function newVerb() {
	var j = Math.floor(Math.random() * 4);
	switch(j) {
		case 0:
		var firstPart = "played";
		var playedList = new Array("guitar","piano","the rainstick","dice");
		var x = Math.floor(Math.random() * 4);
		var secondPart = playedList[x];
		var wholeVerb = firstPart + " " + secondPart;
		return wholeVerb;
		break;
		
		case 1:
		var firstPart = "found";
		var foundList = new Array("Alexand","dentures","Smatchimo","Tonto","a shoehorn");
		var x = Math.floor(Math.random() * 5);
		var secondPart = foundList[x];
		var wholeVerb = firstPart + " " + secondPart;
		return wholeVerb;
		break;

		case 2:
		var firstPart = "drank";
		var drankList = new Array("pee","chocolate milk","Sex on the Beach");
		var x = Math.floor(Math.random() * 3);
		var secondPart = drankList[x];
		var wholeVerb = firstPart + " " + secondPart;
		return wholeVerb;		
		break;	
	
		case 3:
		var firstPart = "felt";
		var feltList = new Array("confused","giddy","kinda wierd","a little dizzy","powerful");
		var x = Math.floor(Math.random() * 5);
		var secondPart = feltList[x];
		var wholeVerb = firstPart + " " + secondPart;
		return wholeVerb;
		break;
	
		default:
	}
	
}

function newEnd() {
	var endList = new Array("in the sandbox","after the tolerance seminar",
	"because of the sugar rush","when my parents were in Toronto","because it was my birthday",
	"outside Camp Campingston","for the school play","in the bleachers",
	"but now I have to pee");
	var k = Math.floor(Math.random() * 9);
	return endList[k];
}

	

