
function setupButtonRollover(elt) {
	if (elt.getAttribute("overimage") && elt.getAttribute("offimage")) {			
		eval("elt.onmouseover = function() {elt.src ='"+elt.getAttribute('overimage')+"'}");
		eval("elt.onmouseout = function() {elt.src ='"+elt.getAttribute('offimage')+"'}");
	}
}

var cachedImages = new Array();

function roll(imgName, which) {
	if (eval(imgName + "_" + which + ".src")) {
		document.images[imgName +"_image"].src = eval(imgName + "_" + which + ".src");
	}
}

function cacheImages() {
	for (i=0; i<document.images.length; i++) {
		var workingImage = document.images[i];
		if (workingImage.getAttribute("overImage") && workingImage.getAttribute("offImage")) {
			
			eval("workingImage.onmouseover = function() {this.src =cachedImages['"+workingImage.getAttribute('overimage')+"'].src;}");
			eval("workingImage.onmouseout = function() {this.src =cachedImages['"+workingImage.getAttribute('offimage')+"'].src;}");
			var index = cachedImages.length;
			cachedImages[""+workingImage.getAttribute('overimage')] = new Image(); 
			cachedImages[""+workingImage.getAttribute('overimage')].src = workingImage.getAttribute('overimage')
			cachedImages[""+workingImage.getAttribute('offimage')] = new Image(); 
			cachedImages[""+workingImage.getAttribute('offimage')].src = workingImage.getAttribute('offimage')
		}
	}
}
function init() {
	cacheImages();
	var searchField = document.getElementById("q");
	if (searchField) searchField.focus();

}
function goToPage(baseUrl,selectElement,viewBy, searchTerm) {
	document.location = baseUrl + "viewBy="+viewBy+"&q="+searchTerm+"&page="+selectElement.options[selectElement.selectedIndex].value;
}
function goToGenre(baseUrl, selectElement ) {
  document.location = baseUrl + "viewBy=genre&page=1&genre="+selectElement.options[selectElement.selectedIndex].value;
}

window.onload = init;