function autosizeImages() {
	imagesArray = document.getElementsByTagName("img");
	for (var i=0; i<imagesArray.length; i++) {
		// As long as width exceeds 600px, shrink height by 25% 
		// (Width is automatically scaled as long it's not defined in HTML)
		while (imagesArray[i].width > 700) {
			newHeight = imagesArray[i].height / 1.25;
			imagesArray[i].height = newHeight;
		}
	}
}

function setSectionLinks() {
	// Alternative for setting named anchor for Bio (using id attribute)
 	// firstParagraph = document.getElementsByTagName("p");
	// firstParagraph[0].id = "bio";

	// Set id for H1 tag. Write link for Bio 
	h1Tag = document.getElementsByTagName("h1");
	h1Tag[0].id = "bio";
	sectionLinksBox = document.getElementById("InfoType");
	sectionLinks = "<a href=\"#bio\">Biography</a>";

	// Set arrays for link text and named anchors (using id attribute)
	sectionLinkNamesArray = new Array("Artist's Note","Director's Note","Press Review","Synopsis","Photos");
	sectionAnchorsArray = new Array("artistnote","directorsnote","pressreview","synopsis","photos");

	// Check contents of H2 tags. Set ids and write links
	h2TagsArray = document.getElementsByTagName("h2");
	for (var i=0; i<h2TagsArray.length; i++) {
		for (var k=0; k<sectionLinkNamesArray.length; k++) {
			if (h2TagsArray[i].innerHTML == sectionLinkNamesArray[k]) {
				h2TagsArray[i].id = sectionAnchorsArray[k];
				sectionLinks += "<a href=\"#" + sectionAnchorsArray[k] + "\">" + sectionLinkNamesArray[k] + "</a>";
			} // End if
		} // End nested For loop 
	} // End For loop 
	sectionLinksBox.innerHTML = sectionLinks;
}

// Sets div.Page overflow to hidden (needed for IE7 when images are resized using JS)
function setDivPage() {
	divPageArray = document.getElementsByTagName("div");
	for (var m=0; m<divPageArray.length; m++) {
		if (divPageArray[m].className == "Page") {
			divPageArray[m].className = "PageJS";
		}
	}
}

function setPage() {
	autosizeImages();
	setSectionLinks();
	setDivPage();
}
