function toggleLayer(whichLayer, hideshow) {

	if (document.getElementById) {

		// this is the way the standards work

		var style2 = document.getElementById(whichLayer).style;

		if (hideshow == "HIDE") style2.display = "none";
		if (hideshow == "SHOW") style2.display = "block";

	} else if (document.all) {

		// this is the way old msie versions work

		var style2 = document.all[whichLayer].style;

		if (hideshow == "HIDE") style2.display = "none";
		if (hideshow == "SHOW") style2.display = "block";

	} else if (document.layers) {

		// this is the way nn4 works

		var style2 = document.layers[whichLayer].style;

		if (hideshow == "HIDE") style2.display = "none";
		if (hideshow == "SHOW") style2.display = "block";

	}

}

function doChangeImage (imageNo,PortraitLandscape, largeImagePrefix, smallImagePrefix, imageDir, selectedExt, notSelectedExt, numberThumbs) { 
	
	var thumbObjectPrefix = "";
	var featureObjectPrefix = "";

	if (PortraitLandscape == "P") {
		thumbObjectPrefix = "PortraitThumbImage";
		featureObjectPrefix = "FeatureImagePortrait";
	} else {
		thumbObjectPrefix = "LandscapeThumbImage";
		featureObjectPrefix = "FeatureImageLandscape";
	}

	var imageName = thumbObjectPrefix + imageNo;

	// Step 1: Change the main image
	document[featureObjectPrefix].src = imageDir + largeImagePrefix + imageNo + ".jpg";

	// Step 2: Change all the thumbs
	document[thumbObjectPrefix + imageNo].src = imageDir + smallImagePrefix + imageNo + selectedExt;


	for (var x = 1; x <= numberThumbs; x++) {
   		if (x.toString() != imageNo) {
   			document[thumbObjectPrefix + x].src = imageDir + smallImagePrefix + x + "_notselected" + notSelectedExt;

   		}
   	}


   	if (PortraitLandscape == "P") {

   		toggleLayer("PORTRAIT", "SHOW");
   		toggleLayer("LANDSCAPE", "HIDE");
   	} else if (PortraitLandscape == "L") {
   		toggleLayer("PORTRAIT", "HIDE");
   		toggleLayer("LANDSCAPE", "SHOW");
   	}

}