var schigh=0;if (screen.height <= 800) schigh=1;
function page() {
	this.buildPage();
// 	this.buildDebug();
}
page.prototype.buildPage = function() {
	this.myScrollArea = new scrollArea();
	document.body.appendChild(this.myScrollArea.draw());
	this.myNav = new nav();
	this.myNav.myParent = this;
	document.body.appendChild(this.myNav.draw());
	if (schigh == 1) {
		this.myNav2 = new nav2();
		this.myNav2.myParent = this;
		document.body.appendChild(this.myNav2.draw());
	}
	this.sound = new soundPlayer();
	document.body.appendChild(this.sound.draw());
}
page.prototype.showDetails = function(detailName,imageIndex) {
	if (detailsOpen) {
//		this.hideDetails();
//		detailsPage = new details();
		detailsPage.clear();
		detailsPage.setVars(detailName,imageIndex);
//		detailsPage.myParent = this;
		document.body.appendChild(detailsPage.draw(false));
	}
	else {
		this.hideDetails();
		detailsPage = new details();
		detailsPage.setVars(detailName,imageIndex);
		detailsPage.myParent = this;
		document.body.appendChild(detailsPage.draw(true));
	}
}
page.prototype.hideDetails = function() {
	detailsOpen = false;
	clearInterval(growInt);
	closeVideo();
	try {
		document.body.removeChild(detailsPage.myDiv);
	}
	catch (excep) {
		// ebug(excep);
	}
}
page.prototype.showNext = function(currentIndex) {
	var newIndex = currentIndex + 1;
	closeVideo();
	if (newIndex > this.myScrollArea.imageArray.length - 1) {
		newIndex = 0;
	}
	var imageName = this.myScrollArea.imageArray[newIndex].myRecord.getPropertyValue("imageID");
	this.showDetails(imageName,newIndex);
}
page.prototype.showNew = function(newIndex) {
//	var imageName = this.myScrollArea.imageArray[newIndex].myRecord.getPropertyValue("imageID");
//	this.showDetails(imageName,newIndex);
}
page.prototype.showPrev = function(currentIndex) {
	var newIndex = currentIndex - 1;
	closeVideo();
	if (newIndex < 0) {
		newIndex = this.myScrollArea.imageArray.length - 1;
	}
	var imageName = this.myScrollArea.imageArray[newIndex].myRecord.getPropertyValue("imageID");
	this.showDetails(imageName,newIndex);
}
page.prototype.buildDebug = function() {
// <div id="debugDiv" style="overflow: scroll; position: absolute; width: 200px; height:200px; left: 1200px; top:100px; background: #eeeeee;"></div>
	var dbd = document.createElement("div");
	dbd.setAttribute("style","overflow: scroll; position: absolute; width: 200px; height:200px; left: 1100px; top:100px; background: #eeeeee;");
	dbd.setAttribute("id","debugDiv");
	document.body.appendChild(dbd);
}
function debug(textIn) {
	var debugDiv = document.getElementById("debugDiv");
	if (debugDiv) {
		debugDiv.innerHTML = textIn+"<br/>"+debugDiv.innerHTML;
	}
}

