var currentSelection = -1;

function highlightItem(obj, state) {
	
	i = obj.getAttribute('id');
	
	if (i != currentSelection) {
		if (state == 1) {
			obj.setAttribute('src', imagebarData[i][1]);
		} else {
			obj.setAttribute('src', imagebarData[i][0]);
		}                   
	}
}

function selectItem(obj) {
	
	i = obj.getAttribute('id');
 
	// reset all toolbar buttons to normal
	ibar = document.getElementById('imagebar');
	items = ibar.getElementsByTagName('img');
	for (x = 0; x < items.length; x++) {
			items[x].setAttribute('src', imagebarData[(x+1)][0]);
	}
 
	// set selected button to click state
	obj.setAttribute('src', imagebarData[i][2]);
 
	// publish ID of clicked button
	currentSelection = i;
	
}

for (i=0; i < aryImages.length; i++) {
	var preload = new Image();
	preload.src = aryImages[(i+1)];
}

function swap(imgIndex) {
	document['imgMain'].src = aryImages[imgIndex];
}
