var notes_qty = 3;

function build_div_notes () {
	var notes_cnt = 0;
	for (idx = notes_max; idx >= notes_idx; --idx) {
		wr_note ( notes[idx].yr, notes[idx].mo, notes[idx].dy, notes[idx].wkdy
				  , notes[idx].head, notes[idx].title, notes[idx].note, notes[idx].img
				  , notes[idx].photoby, notes[idx].url );
		notes_cnt = notes_cnt + 1;
		if (notes_cnt == notes_qty) { break; }
	}
	document.write("<tr></tr>\n");
	document.write("<tr>\n");
	document.write("	<td valign=\"top\" align=\"left\" style=\"padding:0px; width:100%;\">\n");
	document.write("		<div class=\"leadinghead\">Archives</div>\n");
	document.write("		<div id=\"leading_title\">Read Previous Stories</div>\n");
	document.write("		<span class=\"createdate\">Older than: " + notes[idx].wkdy + ", " + notes[idx].dy + " " + notes[idx].mo + " " + notes[idx].yr + "</span>\n");
	document.write("		<div id=\"leading_intro\">\n");
	document.write("			Have you missed a story featued on the site, or would you like view past stories?\n");
	document.write("			If you answered yes to either question, you can view past stories by using the link provided.\n");
	document.write("			<span id=\"leading_more\" onclick=\"javascript: void(window.open(\'archives.htm\',\'Story Archives\',\'toolbar=no,location=no,status=no,directories=no,menubar=no,scrolling=auto,scrollbars=yes,width=416,height=600,resizable=no\'))\"><a href=\"javascript: void(0)\">Click Here</a></span>\n");
	document.write("		</div>\n");
	document.write("		<div class=\"leading_divider\"></div>\n");
	document.write("	</td>\n");
	document.write("</tr>\n");
}

function wr_note (yr, mo, dy, wkdy, head, title, note, img, photoby, url) {
	document.write("<tr>\n");
	document.write("	<td valign=\"top\" align=\"left\" style=\"padding:0px; width:100%;\">\n");
	if (img != '') {
		document.write("		<div id=\"leading_img\">\n");
		document.write("			<img src=\"images/stories/" + img + "\" align=\"top\" width=\"134\" height=\"50\" alt=\"\" /><br />\n");
		document.write("			<span class=\"photoby\">" + photoby + "</span>\n");
		document.write("		</div>\n");
	}
	document.write("		<div class=\"leadinghead\">" + head + "</div>\n");
	document.write("		<div id=\"leading_title\">" + title + "</div>\n");
	document.write("		<span class=\"createdate\">" + wkdy + ", " + dy + " " + mo + " " + yr + "</span>\n");
	document.write("		<div id=\"leading_intro\">\n");
	document.write("			" + note + "\n");
	if (url != '') {
		document.write("			<span id=\"leading_more\"><a href=\"" + url + "\" target=\"_notes\">Full Story</a></span>\n");
	}
	document.write("		</div>\n");
	document.write("		<div class=\"leading_divider\"></div>\n");
	document.write("	</td>\n");
	document.write("</tr>\n");
}

function build_div_archives () {
	for (idx = notes_max - notes_qty; idx >= 0; --idx) {
		wr_note ( notes[idx].yr, notes[idx].mo, notes[idx].dy, notes[idx].wkdy
				  , notes[idx].head, notes[idx].title, notes[idx].note, notes[idx].img
				  , notes[idx].photoby, notes[idx].url );
	}
}
