/* 
	Dan Hart
	daniel_hart@wgbh.org
	09.30.08
   ----------------------------------------------------*/
   
function CreatePoetry()
{

// ***********************************************************
//
//          Variable definitions
//
// ***********************************************************

	var name_array =  new Array ( 'doty', 'hirsch', 'hirshfield', 'kooser', 'nye', 'pastan', 'stern', 'young', 'howe', 'komunyakaa', 'hass', 'whitman', 'simic', 'clifton', 'levine', 'rich', 'olds', 'collins', 'dickinson', 'strand', 'frost', 'kunitz', 'yeats', 'barks' );
	
	var poet_array = new Array ( 'Mark Doty', 'Edward Hirsch', 'Jane Hirshfield', 'Ted Kooser', 'Naomi Shihab Nye', 'Linda Pastan', 'Gerald Stern', 'Kevin Young', 'Marie Howe', 'Yusef Komunyakaa', 'Robert Hass', 'Walt Whitman', 'Charles Simic', 'Lucille Clifton', 'Philip Levine', 'Adrienne Rich',  'Sharon Olds', 'Billy Collins', 'Emily Dickinson', 'Mark Strand', 'Robert Frost', 'Stanley Kunitz', 'WB Yeats', 'Coleman Barks' );
	
	var poem_array = new Array ( 
	'Brian, Age 7',
	'A Partial History of My Stupidity',
	'For What Binds Us',
	'Daddy Long Legs',
	'One Boy Told Me',
	'Why Are Your Poems So Dark?',
	'The Dancing',
	'Aunties',
	'The Gate', 
	'Facing It', 
	'Selected Haiku by Issa', 
	'Passage to India (Excerpt)', 
	'Stone', 
	'won\'t you celebrate...', 
	'Belle Isle, 1949', 
	'What Kind of Times...', 
	'I Go back to May, 1937', 
	'The Lanyard', 
	'I started Early...', 
	'Lines for Winter', 
	'Stopping by Woods...', 
	'Touch Me', 
	'The Wild Old Wicked Man', 
	'Translation from Rumi' );

	var array_bound = name_array.length;
	var poem_quote_array = new Array ( array_bound );
	var day_index; 
	var date_start = new Date();
	var poem_today = new Date();
	var nm = "";
	var fullnm = "";
	var poemnm = "";
	var ms_day = 86400000;
	var days = 0;
	
// ***********************************************************
//
//          Initial values
//
// ***********************************************************

	poem_quote_array[0] = "Grateful for their tour of the pharmacy..."
	poem_quote_array[1] = "Traffic was heavy coming off the bridge..."
	poem_quote_array[2] = "There are names for what binds us..."
	poem_quote_array[3] = "Here, on fine, long legs, springy as steel..."
	poem_quote_array[4] = "Music lives inside my legs..."
	poem_quote_array[5] = "Isn\'t the moon dark too..."
	poem_quote_array[6] = "In all these rotten shops, in all this broken furniture..."
	poem_quote_array[7] = "There\'s a way a woman will not relinquish her pocket book..."
	poem_quote_array[8] = "I had no idea that the gate I would step through...";
	poem_quote_array[9] = "My black face fades...";
	poem_quote_array[10] = "Don\'t worry, spiders...";
	poem_quote_array[11] = "Not you alone, proud truths of the world...";
	poem_quote_array[12] = "Go inside a stone...";
	poem_quote_array[13] = "won\'t you celebrate with me...";
	poem_quote_array[14] = "We stripped in the first warm spring night...";
	poem_quote_array[15] = "There\'s a place between two stands of trees where the grass grows uphill...";
	poem_quote_array[16] = "I see them standing at the formal gates of their colleges...";
	poem_quote_array[17] = "The other day as I was ricocheting slowly...";
	poem_quote_array[18] = "I started Early Ð Took my Dog...";
	poem_quote_array[19] = "Tell yourself...";
	poem_quote_array[20] = "Whose woods these are I think I know...";
	poem_quote_array[21] = "Summer is late, my heart...";
	poem_quote_array[22] = "Because I am mad about women...";
	poem_quote_array[23] = "Today, like every other day, we wake up empty...";
	
	//
	// ***********************************************************
	//          Change initial index here
	// ***********************************************************
	//
	date_start.setFullYear(2009,2,30); // <-- this is the "start" date
	day_index = 15 // <-- this is the first value for the index, at "start" date
	//
	// ***********************************************************
	//          end initial index 
	// ***********************************************************
	//
	days = Math.round((poem_today-date_start)/ms_day);
	day_index += days
	day_index %= array_bound; // take the modulus, to stay within bounds of our array 
	nm = name_array[day_index];
	fullnm = poet_array[day_index];
	poemnm = poem_array[day_index];
	poemq = poem_quote_array[day_index];

// ***********************************************************
//          Debugging writes
// ***********************************************************

//	document.write("date_start = " + date_start + "<br />");
//	document.write("elasped days = " + days);
//	document.write("current day index = " + day_index);
//	document.write("current day index = " + day_index);
//	document.write("name = " + nm + "<br />");
//	document.write("poet = " + fullnm + "<br />");
//	document.write("poem = " + poemnm + "<br />");

// ***********************************************************
// ***********************************************************
//
//          Start of the HTML construction 
//
// ***********************************************************
// ***********************************************************

	document.write("<div id=\"main-content\">");

// ***********************************************************
//          The left-hand image (featured poem)
// ***********************************************************

	document.write("<div id=\"main-image\">");
	document.write("<a href=\"" + nm + ".html\">");
	document.write("<img src=\"images/" + nm + "_i.jpg\" width=\"402\" height=\"266\" alt=\"" + fullnm + "\" border=\"0\" \/><\/a>");
	document.write("<div id=\"excerpt\">\"" + poemq + "\"");
	document.write("<\/div>");
	document.write("<\/div>");

// ***********************************************************
//          The grid of thumbnails 
// ***********************************************************

	document.write("<div id=\"poet-grid\">");
	
	for (i = 0; i < array_bound - 1 ; i++)
	{
		day_index++;
		if (day_index > array_bound-1) {day_index=0};
		nm = name_array[day_index];
		fullnm = poet_array[day_index];
		poemnm = poem_array[day_index];
		
		document.write("<div class=\"thumb\">");
		document.write("<div id=\"" + nm + "\">");
		document.write("<div class=\"img\"><a href=\"" + nm + ".html\"><i>" + poemnm + "<\/i><\/a>");
		document.write("<\/div>");
		document.write("<\/div>");
		document.write("<div class=\"poet\">" + fullnm + "");
		document.write("<\/div>");
		document.write("<div class=\"poem\">" + poemnm + "");
		document.write("<\/div>");
		document.write("<\/div>");
	}

// ***********************************************************
//          The student blurb at the bottom
// ***********************************************************

	document.write("<div id=\"students-blurb\">");
	document.write("<a href=\"uwm/index.html\">");
	document.write("<img src=\"images/logo_pe.gif\" width=\"112\" height=\"41\" alt=\"Poetry Everywhere\" align=\"left\" border=\"0\" \/><\/a>");
	document.write("<div class=\"text\">");
	document.write("<span class=\"title\">Animated Poetry<\/span> created by film students at the University<br\/> of Wisconsin-Milwaukee in association with the Poetry<br\/> Foundation. <span class=\"more\"><a href=\"uwm/index.html\">More<\/a> ><\/span>");
	document.write("<\/div>");
	document.write("<\/div>");
	
	document.write("<\/div>"); // poet grid
	document.write("<\/div>"); // main content

// ***********************************************************
//          End of HTML construction
// ***********************************************************

}

CreatePoetry();
