/*
 * GQADMOV - Greg's Quick and Dirty MOVie Gallery
 */
 
self.name = "main";

current = 1; // start with the featured movie
indexMaxA = 4; // number of movies in gallery A
indexMax = indexMaxA; // number of movies in current gallery
galleryName = "A";

function setGallery(gallery){
	galleryName = gallery;
	if( galleryName == "A" )
		indexMax = indexMaxA;
		
	displayMovie(current);
}

function gotoMovie(index){ // someone wants a specific movie
	current = index
	if (current > indexMax) // jic
		current=1;
	
	displayMovie(current);
}

function displayMovie(index){

	document.getElementById("moviegallery").innerHTML = '<center><embed src="' + galleryName + '/' + index + '-sachs.mov" width="520" height="390" autoplay="true" /></center>';
	displayThumbnails();
}

function nextMovie(){ 
	current++;
	if (current > indexMax)
		current=1;
	
	displayMovie(current);
}

function previousMovie(){
	current--;
	if (current < 1)
		current=indexMax;
	
	displayMovie(current);
}

function displayThumbnails(){
	i = 0;
	thumbHTML = "";
	while( i < indexMax){
		i++;
		if( i == current ){
			thumbHTML += '<img id="currentthumb" src="' + galleryName + 'thumbs/' + i + '-sachs.png" height="150" /></a>';
		} else {
			thumbHTML += '<a href="javascript:gotoMovie(' + i + ')"><img id="photothumb" src="' + galleryName + 'thumbs/' + i + '-sachs.png" height="150" /></a>';
		}
		
	}
	document.getElementById("thumbnails").innerHTML = '<center>' + thumbHTML + '</center>';
}
