function changeSet(dir) {
    if(dir==-1 && currentSet==1) {
		//nothing
    } else if (dir==1 && currentSet==numOfSets) {
            //nothing
    } else {
        currentSet = currentSet+dir; //increment or decrement the current set

		nxtController = document.getElementById("thumbNextController");
		prevController= document.getElementById("thumbPrevController");
		//if the number of sets is over 1, and we are over 1, prev button should be highlighted
		if(numOfSets > 1 && currentSet>1) {
			prevController.className = "yellowtext";//"text_grey";
		}
		if(numOfSets > 1 && currentSet!=numOfSets) {
			nxtController.className = "yellowtext";
		}
		//if we are on the first set, prev should be blanked out
		if(currentSet==1) {
			prevController.className = "text_grey";
		}
		//if we are on the last set, next should be blanked out
		if(currentSet == numOfSets) {
			nxtController.className="text_grey";
		}

		prevController.style.fontSize = "10px";
		nxtController.style.fontSize = "10px";
		prevController.style.fontWeight = "normal";
		nxtController.style.fontWeight = "normal";
		

        thbPicIndex = (currentSet-1)*set;
		
		thumbIndexStartNum = thbPicIndex+1;
		thumbIndexEndNum   = thbPicIndex+1;
		
		document.images["expThmb1"].src = expanThbPic[thbPicIndex];
		
        if(expanThbPic[thbPicIndex+1]!=undefined) {
			document.getElementById("photo2Thumb").style.visibility="visible";
			document.images["expThmb2"].src = expanThbPic[thbPicIndex+1];
			thumbIndexEndNum   = thbPicIndex+2;
        } else {
			document.getElementById("photo2Thumb").style.visibility="hidden";
		}
        
		if(expanThbPic[thbPicIndex+2]!=undefined) {
			document.getElementById("photo3Thumb").style.visibility="visible";
			document.images["expThmb3"].src = expanThbPic[thbPicIndex+2];
			thumbIndexEndNum   = thbPicIndex+3;
		} else {
			document.getElementById("photo3Thumb").style.visibility="hidden";
		}
        
		if(expanThbPic[thbPicIndex+3]!=undefined) {
			document.getElementById("photo4Thumb").style.visibility="visible";
			document.images["expThmb4"].src = expanThbPic[thbPicIndex+3];
			thumbIndexEndNum   = thbPicIndex+4;
		} else {
			document.getElementById("photo4Thumb").style.visibility="hidden";
		}
		
		if(expanThbPic[thbPicIndex+4]!=undefined) {
			document.getElementById("photo5Thumb").style.visibility="visible";
			document.images["expThmb5"].src = expanThbPic[thbPicIndex+4];
			thumbIndexEndNum   = thbPicIndex+5;
		} else {
			document.getElementById("photo5Thumb").style.visibility="hidden";
		}
		
		//document.getElementById("setNum").innerHTML = "set "+ currentSet+" of "+numOfSets;
		
		document.getElementById("thumbIndexStart").innerHTML = thumbIndexStartNum;
		document.getElementById("thumbIndexEnd").innerHTML = thumbIndexEndNum;
		
    }
    
}

function changeLrgImg (numOfThmb,fromThumb) {
    if(fromThumb=="fromThumb") {
		thbPicIndex = (currentSet-1)*set;
    	indexOfLrgImg = (numOfThmb-1) + thbPicIndex;
	} else {
		thbPicIndex = numOfThmb-1;
    	indexOfLrgImg = numOfThmb-1;
	}
    
		nxtController = document.getElementById("mainNextController");
		prevController= document.getElementById("mainPrevController");
		curCount = indexOfLrgImg;
		topCount = expanThbPic.length-1;
		
		//if the number of sets is over 1, and we are over 1, prev button should be highlighted
		if(topCount > 1 && curCount>0) {
			prevController.className = "yellowtext";//"text_grey";
		}
		if(topCount > 1 && curCount!=topCount) {
			nxtController.className = "yellowtext";
		}
		//if we are on the first set, prev should be blanked out
		if(curCount==0) {
			prevController.className = "text_grey";
		}
		//if we are on the last set, next should be blanked out
		if(curCount == topCount) {
			nxtController.className="text_grey";
		}
		prevController.style.fontSize = "10px";
		nxtController.style.fontSize = "10px";
		prevController.style.fontWeight = "normal";
		nxtController.style.fontWeight = "normal";
	
			

	
    document.images["expLrgPic"].src = expanLrgPic[indexOfLrgImg];
    document.getElementById("picIndex").innerHTML = (indexOfLrgImg+1);
	if(indexOfLrgImg!=0) {
		//document.getElementById("titleTxt").innerHTML = '<a href="javascript:changeLrgImg(1)">'+captions[0]+'</a>';
		if(captions[indexOfLrgImg]!="") {
		//	document.getElementById("captionTxt").innerHTML = captions[indexOfLrgImg]+'<img src="images/csq.gif" width="1" height="23" alt="" border="0" align="absmiddle">';	
		} else {
		//	document.getElementById("captionTxt").innerHTML = '<img src="images/csq.gif" width="1" height="13" alt="" border="0">';
		}
	} else {
		//document.getElementById("titleTxt").innerHTML = captions[0];
		//document.getElementById("captionTxt").innerHTML = '<img src="images/csq.gif" width="1" height="13" alt="" border="0">';
	}
}

function incrLrgImg(dir) {
    if(dir==-1 && indexOfLrgImg==0) {
        //nothing
    } else if(dir==1 && indexOfLrgImg==(expanThbPic.length-1)) {
        //nothing
    } else {
        indexOfLrgImg = indexOfLrgImg+dir;
		
		
		nxtController = document.getElementById("mainNextController");
		prevController= document.getElementById("mainPrevController");
		curCount = indexOfLrgImg;
		topCount = expanThbPic.length-1;
		//if the number of sets is over 1, and we are over 1, prev button should be highlighted
		if(topCount > 1 && curCount>0) {
			prevController.className = "yellowtext";//"text_grey";
		}
		if(topCount > 1 && curCount!=topCount) {
			nxtController.className = "yellowtext";
		}
		//if we are on the first set, prev should be blanked out
		if(curCount==0) {
			prevController.className = "text_grey";
		}
		//if we are on the last set, next should be blanked out
		if(curCount == topCount) {
			nxtController.className="text_grey";
		}
		prevController.style.fontSize = "10px";
		nxtController.style.fontSize = "10px";
		prevController.style.fontWeight = "normal";
		nxtController.style.fontWeight = "normal";
	
		
        document.images["expLrgPic"].src = expanLrgPic[indexOfLrgImg];
//        document.getElementById("imgNum").innerHTML = "image "+ (indexOfLrgImg+1) +" of "+ (expanLrgPic.length);
	    document.getElementById("picIndex").innerHTML = (indexOfLrgImg+1);
		if(indexOfLrgImg!=0) {
			//document.getElementById("titleTxt").innerHTML = '<a href="javascript:changeLrgImg(1)">'+captions[0]+'</a>';
			if(captions[indexOfLrgImg]!="") {
			//	document.getElementById("captionTxt").innerHTML = captions[indexOfLrgImg]+'<img src="images/csq.gif" width="1" height="23" alt="" border="0" align="absmiddle">';	
			} else {
				//document.getElementById("captionTxt").innerHTML = '<img src="images/csq.gif" width="1" height="13" alt="" border="0">';
			}
		} else {
			//document.getElementById("titleTxt").innerHTML = captions[0];
			//document.getElementById("captionTxt").innerHTML = '<img src="images/csq.gif" width="1" height="13" alt="" border="0">';
		}

    }
}
/*
function ImagePreloader(images, callback)
{
	// store the call-back
	this.callback = callback;
	// initialize internal state.
	this.nLoaded = 0;
	this.nProcessed = 0;
	this.aImages = new Array;
	// record the number of images.
	this.nImages = images.length;
	// for each image, call preload()
	for ( var i = 0; i < images.length; i++ )
		this.preload(images[i]);
}

ImagePreloader.prototype.preload = function(image)
{
	// create new Image object and add to array
	var oImage = new Image;
	this.aImages.push(oImage);
  
	// set up event handlers for the Image object
	oImage.onload = ImagePreloader.prototype.onload;
	oImage.onerror = ImagePreloader.prototype.onerror;
	oImage.onabort = ImagePreloader.prototype.onabort;
 

	// assign pointer back to this.
	oImage.oImagePreloader = this;
	oImage.bLoaded = false;

	// assign the .src property of the Image object
	oImage.src = image;
}

ImagePreloader.prototype.onComplete = function()
{
	this.nProcessed++;
	if ( this.nProcessed == this.nImages ) {
		this.callback(this.aImages, this.nLoaded);
	}
}

ImagePreloader.prototype.onload = function()
{
	this.bLoaded = true;
	this.oImagePreloader.nLoaded++;
	this.oImagePreloader.onComplete();
}

ImagePreloader.prototype.onerror = function()
{
	this.bError = true;
	this.oImagePreloader.onComplete();
}

ImagePreloader.prototype.onabort = function()
{
	this.bAbort = true;
	this.oImagePreloader.onComplete();
}

largestHeight = 1;

var ip=null;
function preloadPhotos() {
	ip = new ImagePreloader(expanLrgPic, checkHeights);
}
*/

