// This js file was created by Preble Law.

// This code is covered under a comprehensive C.A.S.E. license: 
// Copy And Steal Everything.  I mean, I pretty much copied most 
// of this from elsewhere, why should I really claim it as my own?

// Michael A. Cohen modified this file for the RollingTurtle site
// I got it from www.zirkel.com, where it was used to display random images
// rather than quotes.  Now you know.

	function DisplayRandomQuote() {
	// JavaScript to interpolate random quotes into a page.
	var quoteindex = 6;					// number of quotes currently used
		
	var quote = new Array(quoteindex);	// Array to hold quotes
	var attrib = new Array(quoteindex);	// Array for attributions
     var alink = new Array(quoteindex);	// Array for attribution links
		
	// Set up the images.
    	quote[0] = "If a man follows the mind given him and makes it his teacher, then who can be without a teacher?"; 
	attrib[0] = "Chuang Tzu";
     alink[0] = "www.clas.ufl.edu/users/gthursby/taoism/cz-text2.htm"; 																

    	quote[1] = "Come downstairs and say hello."; 
	attrib[1] = "Guster";
     alink[1] = "www.guster.com";
     
     quote[2] = "How many nights I've prayed for this -- to let my work begin."; 
	attrib[2] = "Leonard Cohen, First We Take Manhattan";
     alink[2] = "www.leonardcohenfiles.com";
     
     quote[3] = "All fear is bondage."; 
	attrib[3] = "Anon.";
     alink[3] = "www.wmin.ac.uk/csd/Staff/Keane/jkf&d.htm";
     
     quote[4] = "Thou shalt not kill."; 
	attrib[4] = "God";
     alink[4] = "www.theonion.com/onion3734/god_clarifies_dont_kill.html"; 			

     quote[5] = "War is a force that gives us meaning."; 
	attrib[5] = "Chris Hedges";
     alink[5] = "www.amnestyusa.org/amnestynow/war_meaning.html";
     
	// pickRandom - Return a random number in a given range. If we're running
    // on an older browser that doesn't support 'Math.random()', we can fake
    // it by using the current time. This isn't ideal for mission-critical
    // security applications, but it's fine here. Note that we divide the
    // current time by 1000 to get rid of the milliseconds which Navigator
    // doesn't seem to take into account.
    
		// Write out the html, using a randomly-chosen image name.
    
    var choice = pickRandom(quoteindex);
   	document.writeln('<p class="quote">' + quote[choice] + '</p><p class="attrib">- <a href="http://' + alink[choice] + '">' + attrib[choice] + '</a></p>');
	};
		
	function pickRandom(range) {
  	if (Math.random) return Math.round(Math.random() * (range-1));
    else {
			var now = new Date();
			return (now.getTime() / 1000) % range;	
		};
	};