//variables

var quote = new Array("\"Do the white girl.\" -Amit Caspi",
"\"Farruq, Do you wear makeup?\" -Brad Grossman",
"\"Thus, in the spirit of great debate, I hereby propose the tightest resolution in CDA history... Vote LuisBacalao for Treasurer.\" - Luis Bacalao",
"\"Actually guys, vote Kucinich, he's made of magic.\" - Adam Katz",
"\"No more grandmother driving to tournaments guys. Justin makes a Taurus Wagon sexy.\" - Luis Bacalao",
"\"Of course if he actually took my allegations of retardation seriously, he'd have jumped into the gorge by now.\" -Robert Glunt",
"\"Lisa is usually right...except when she disagrees with me. Then she is wrong.\" - Andrew Grossman",
"\"Sleep on the floor. You\'ll be much more comfortable--the floor is infinite.\" - Adam Katz",
"\"But it just might B that you may want to LOC, and that's fine with ME cuz I will rock the PMC.\" -Amit Caspi",
"\"Robert didn't whisper this to me, so it probably won't be as good as many of the things I usually say.\" -Justin Berkowitz",
"\"No, I did not make-out with a girl. Stop calling me, MOM!\" -Brad Grossman");

var MiddNYC = new Array("amit.jpg","Middlebury006.jpg",
"NewYork012.jpg","debategods.jpg","Middlebury014.jpg",
"NewYork021.jpg","Fall015.jpg");

var MiddNYCcaption = new Array("Amit takes a nap in between rounds at Columbia.",
"Adam Bonnifield and his hybrid partner Pooneet Kant prepare for their semis round at Middlebury.",
"Ready for a night on the town in New York City.",
"Bradley Grossman and Justin Berkowitz are debate gods. But only to themselves.",
"Adam Bonnifield does not have table manners.",
"There are many things we do not know about Matthew Hendrickson.",
"Mark (Axel) was voted \"Most Congenial\" in his highschool yearbook. Congrats Mark.");

var mainpicture = new Array("berkcar.jpg","Middlebury006.jpg");

var mainpicturecaption = new Array("Justin Berkowitz 05 cringes after crashing into a snowbank on the trip home from the 2002 Amherst Debate Tournament. There were four survivors.",
"Adam Bonnifield 06 and Dartmouth debater Pooneet Kant prepare for their semifinal round at Middlebury.")

var Listing = new Array("Quick Facts","2003.4 Tournament Results");

var pictureIndex = 0;

var gallerylist;

//cycles quotes

function quoteGenerator() {
var quotespectrum = quote.length
var randomnumber=Math.floor(Math.random()*quotespectrum)
var repeatingquote=document.getElementById("textquote")
repeatingquote.innerHTML=quote[randomnumber]
}

//gererates the picture on the main page

function pictureGenerator() {
var numberspectrum = mainpicture.length
var randomnumber=Math.floor(Math.random()*numberspectrum)
return randomnumber;
}

//initializes the tournament listings system

function inittournament() {
	for (x = 0; x<Listing.length; x++)
			post(Listing[x]);
}

function post(tournname) {
	document.writeln("<p><a href=\"res"+tournname+".html\">"+tournname+"</a></p>");
}


//initializes the picture archival system

function init(galleryarray,galleryname,gallerycaption) {
	for (x = 0; x<galleryarray.length; x++)
		makeLink(galleryarray[x],galleryname,gallerycaption);

}
//manages picture gallery

function makeLink(filename,galleryname,gallerycaption) {
if (getCookie(filename)){
	document.writeln("<a href=\"photos/"+filename+"\" target=\"_blank\"><img src=\"photos/thumbnails/1tn"+filename+"\" border=\"0\" onMouseOver=\"swapCaption("+x+","+gallerycaption+")\" onMouseOut=\"clearCaption("+x+")\"></a>");
}
else{
	document.writeln("<a href=\"photos/"+filename+"\" target=\"_blank\"><img src=\"photos/thumbnails/tn"+filename+"\" border=\"0\" onMouseOver=\"swapCaption("+x+","+gallerycaption+")\" onMouseOut=\"clearCaption("+x+")\"></a>");
}
}

function shadePicture(num,galleryarray){
var filename = galleryarray[num];
setCookie(filename);
}

function swapCaption(num,gallerycaption){
var captionpic=document.getElementById("text")
captionpic.innerHTML=gallerycaption[num]
}

function clearCaption(num){
var captionpic=document.getElementById("text")
captionpic.innerHTML="These are pictures of<br> the team from<br> 2003-2004."
}

//cookie shiznit

var expiration = new Date();
expiration.setTime(expiration.getTime() + 172800000);

		function getCookie(name){
		  var cname = name + "=";               
		  var dc = document.cookie;             
		  if (dc.length > 0) {              
			begin = dc.indexOf(cname);       
			if (begin != -1) {           
			  begin += cname.length;       
			  end = dc.indexOf(";", begin);
			  if (end == -1) end = dc.length;
				return unescape(dc.substring(begin, end));
			} 
		  }
		  return false;
		}
		
		// An adaptation of Dorcht's function for setting a cookie.
		function setCookie(name, value, expires, path, domain, secure) {
		  document.cookie = name + "=" + escape(value) + 
		  ((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
		  ((path == null) ? "" : "; path=" + path) +
		  ((domain == null) ? "" : "; domain=" + domain) +
		  ((secure == null) ? "" : "; secure");
		}
		
		// An adaptation of Dorcht's function for deleting a cookie.
		function delCookie (name,path,domain) {
		  if (getCookie(name)) {
			document.cookie = name + "=" +
			((path == null) ? "" : "; path=" + path) +
			((domain == null) ? "" : "; domain=" + domain) +
			"; expires=Thu, 01-Jan-70 00:00:01 GMT";
		  }
		}	
