//declare global variables
var thumbNumRight
var thumbNumLeft
var archiveNum = 1;
var picture = "images/furniture/celebration/small_celebration/small_Celebration";
var thumb = "images/furniture/celebration/thumbnails/thumb_Celebration"

var pictureLarge = "images/furniture/celebration/Celebration";

function archiveBack() {
  if (archiveNum <= 1) {
	    archiveNum = 5
			thumbNumRight = archiveNum-4
			thumbNumLeft = 2
	  } else if (archiveNum == 2) {
		  archiveNum = 1
			thumbNumRight = 2
			thumbNumLeft = 5
		} else {
	  archiveNum--
		thumbNumRight = archiveNum+1
		thumbNumLeft = archiveNum-1
		}
		document.getElementById('archiveCount').childNodes[0].nodeValue=archiveNum + "/5";
		document.image.src = picture + archiveNum + ".jpg";
		document.next.src = thumb + thumbNumRight + ".jpg";
		document.back.src = thumb + thumbNumLeft + ".jpg";
		
		getImageWidth = document.image.width;
		marginSize = (440-getImageWidth)/2;
		
		imageText();
	}
									
	function archiveNext() {
	  if (archiveNum >= 5) {
			archiveNum = 1
			thumbNumRight = archiveNum+1
			thumbNumLeft = 5
			} else {
			archiveNum++
			thumbNumRight = archiveNum+1
			thumbNumLeft = archiveNum-1
			}
			document.getElementById('archiveCount').childNodes[0].nodeValue=archiveNum + "/5";
			document.image.src = picture + archiveNum + ".jpg";			
			document.next.src = thumb + thumbNumRight + ".jpg";
			document.back.src = thumb + thumbNumLeft + ".jpg";
    
		  getImageWidth = document.image.width;
			marginSize = (440-getImageWidth)/2;
			
			imageText();
		
}
	
function imageWindow() { // Function to create a new popup window.
			var imageLarge = pictureLarge + archiveNum + ".jpg";
			// Create and open new window
			var newWindow = window.open("", "Large_Image", 'width=900,height=700,left=0,top=0,scrollbars=1') 
			// Set openWindow variable and write HTML elements.
			var openWindow = newWindow.document;
			openWindow.write('<html><head><title>Large Archive Image</title>');
			openWindow.write('<style type="text/css">body{background:black;} a{color:white;text-decoration:none;font-size:1.3em;}</style>');

			openWindow.write('</head><body><p align="center">');
			openWindow.write('<img src="' + imageLarge + '" alt="Large Archive Image" title="Large Archive Image" \/></p>');
			openWindow.write('<p align="center"><a href="javascript:self.close()">Close Window</a></p>');
			openWindow.write('</body></html>');
			openWindow.close();  
			
} // End of imageWindow function.

// Picture description.

// JON READ BELOW 
// Each case number coincides with the image number in the gallery
// Just chnage the text for the variable descrip.
 
function imageText()
				 {
				 var descrip = archiveNum;
				 switch(descrip)
				 {
				 	case 1:
  				descrip = "Celebration - Sharing a meal together around the table";
  				break;
					
					case 2:
  				descrip = "click photo to enlarge";
  				break;
					
					case 3:
  				descrip = "click photo to enlarge";
  				break;
					
					case 4:
  				descrip = "Easily extendable through industrial quality running gear";
  				break;
					
					case 5:
  				descrip = "click photo to enlarge";
  				break;
					
					case 6:
  				descrip = "Image 6";
  				break;
					
					case 7:
  				descrip = "Image 7";
  				break;
					
					case 8:
  				descrip = "Image 8";
  				break;
					
					case 9:
  				descrip = "Image 9";
  				break;
					
					case 10:
  				descrip = "Image 10";
  				break;
					
					case 11:
  				descrip = "Image 11";
  				break;
					
					case 12:
  				descrip = "Image 12";
  				break;
					
					case 13:
  				descrip = "Image 13";
  				break;
					
					case 14:
  				descrip = "Image 14";
  				break;
					
					case 15:
  				descrip = "Image 15";
  				break;
					
					case 16:
  				descrip = "Image 16";
  				break;
					
					case 17:
  				descrip = "Image 17";
  				break;
					
					case 18:
  				descrip = "Image 18";
  				break;
					
					case 19:
  				descrip = "Image 19";
  				break;
					
					case 20:
  				descrip = "Image 20";
  				break;
					
					case 21:
  				descrip = "Image 21";
  				break;
					
					case 22:
  				descrip = "Image 22";
  				break;
					
					default:
  				descrip = "Default"
				}

				document.getElementById('description').childNodes[0].nodeValue=descrip

}
