//Passed-in values:
var heading_graphic_loc = "images/heading.gif";
var pics_location = "images";
var last_page_num = 11;
var even_number_pictures = "false";
var alt_heading_text = "School of Business & Economics Dedication & Alumni Reunion Reception";
var alt_photos_text = "School of Business & Economics Dedication & Alumni Reunion Reception";

function get_page_name () {
// This function returns the name of the current page.
// Get URL of current page.  Convert it from object to string so we can work with it.
var loc = String (this.location); 
// Replace slashes in URL with commas.  Also create an array that has each of the sections
// of the URL in one slot in the array.
loc=loc.split("/"); 
// loc is now http:,,www.ncat.edu,events,homecoming,2002,new_ad,index.html 
// Also:
// loc[0] = http:
// loc[1] = 
// loc[2] = www.ncat.edu
// loc[3] = events
// loc[4] = homecoming
// loc[5] = 2002
// loc[6] = new_ad
// loc[7] = index.html

// Set loc to the last item in the array.
loc = loc[loc.length-1];
// loc is now index.html

// Create an array that splits index. and html apart from each other.
loc = loc.split(".");
// loc is now index, html
// loc[0] = index
// loc[1] = html

loc=loc[loc.length-2]; 
return (loc);
}


function get_page_num (page_name) {
	// This function returns the page number.  If the page name is pic1., this function
	// returns 1.  If the page name is pic256., this function returns 256.
	var len, curr_page_number;
	len = page_name.length;
	curr_page_number = page_name.substring(3, len);
	return (curr_page_number);
}
 
function write_page_content() {
var heading = "<table width='95%' align='center' border='0'> <tr> <td valign='top'><div align='center'><img src='" + heading_graphic_loc + "' alt='" + alt_heading_text + "'> </div></td></tr></table><br><br>";

// Beginning of table for photographs
var photos_heading = "<table width='95%' align='center' border='0'><tr>"

// Pictures #1 and #2
var photos1 = "<td height='59' valign='top'><div align='center'><img border='5' + width ='315' + height ='236' + src=' " + pic1_name + " ' alt='" + alt_photos_text + "'></td>";
var photos2 = "<td height='59' valign='top'><div align='center'><img border='5' + width ='315' + height ='235' +  src=' " + pic2_name + " ' alt='" + alt_photos_text + "'></td>";

// End of table for photographs
var photos_footer = "</tr></table>";

var photos = photos_heading + photos1 + photos2 + photos_footer;

// Navigational Menu
var menu_heading = "<table border='0' width='100%' align='center'><tr>";
var menu_prev = "<td width='20%'><div align='center'><font size='2' face='Arial' color='#FFFFFF'><< <a href='javascript:location.href=prev_page_name'>Previous Page</a> >></font></div></td>";
var menu_home = "<td width='60%'><div align='center'><font face='Arial' size='2' color='#FFFFFF'><< <a href='index.html'>Reception Photo Gallery Home</a>>></font></td>";
var menu_next = "<td width='20%'><div align='center'><font face='Arial' size='2' color='#FFFFFF'><< <a href='javascript:location.href=next_page_name'>Next Page</a> >></font></div></td>" ;
var menu_footer = "</tr> </table>";
var menu_placeholder;

// Display the "Next" link only if we are not displaying the last page.
if (last_page_num != curr_page_num)
	document.write ("<body topmargin='0' bgcolor='#00287a' link='#FFFFFF' vlink='#FFFFFF'>" + heading + photos + "<br><br>" + menu_heading + menu_prev + menu_home + menu_next + menu_footer + "</body>");
else {
	// We execute the else block only if we are on the last page.  If we are on the last page, we need to
	// determine whether we have an even number of pictures.  If we do, by the time we're on the last page,
	// we only have one picture left and we need to adjust the page display accordingly.
	if (even_number_pictures == "true");
		photos = photos_heading + photos1 + photos_footer;
	menu_prev = "<td width='49%'><div align='center'><font size='2' face='Arial' color='#FFFFFF'><< <a href='javascript:location.href=prev_page_name'>Previous Page</a> >></font></div></td>";
	menu_placeholder = "<td width='2%'><div align='center'></td>";
	menu_home = "<td width='49%'><div align='center'><font face='Arial' size='2' color='#FFFFFF'><< <a href='index.html'>Reception Photo Gallery Home</a>>></font></td>";
	document.write ("<body topmargin='0' bgcolor='#00287a' link='#FFFFFF' vlink='#FFFFFF'>" + heading + photos + "<br><br>" + menu_heading + menu_prev + menu_placeholder + menu_home + menu_footer + "</body>");	

	}

}



var this_page_name = get_page_name();
//	document.write ("Page name:  " + this_page_name);
var this_page_num = get_page_num(this_page_name);
//	document.write ("  Page number:  " + this_page_num);



// Convert strings to integers, and compute prev and next pages.
var prev_page_num = parseInt(this_page_num) - 1;
var curr_page_num = parseInt(this_page_num);
var next_page_num = parseInt(this_page_num) + 1;
var pic1_num = (curr_page_num * 2) - 1;
var pic2_num = curr_page_num * 2;
// document.write ("Previous page:  " + prev_page_num + "     Next page:  " + next_page_num);
var prev_page_name;
if (curr_page_num == 1)
	prev_page_name = "index.html"
else
	prev_page_name = "pic" + prev_page_num + ".html";
var next_page_name = "pic" + next_page_num + ".html";
var pic1_name = pics_location + "/pic" + pic1_num + ".jpg";
var pic2_name = pics_location + "/pic" + pic2_num + ".jpg";
//	document.write ("Previous page name:  " + prev_page_name + "  Next page name:  " + next_page_name);
//	document.write ("Left picture name:   " + pic1_name + "       Right pic name:  " + pic2_name);


write_page_content();
