/*
	Script: collections.js
	
	Copyright: Fishnet NewMedia (c) 2005
	
	Create: 12.06.05
	
	Version: 1.0
	
	Compatibility: JavaScript 1.2
	
	Changes: none
*/

var photos = null;

// create an object literal to be used as an 
// associative array for storing image objects
var image_cache = {};
image_cache["spacer"] = imageLoad("/images/spacer.gif");
for (var i = 1; i <= 8; i++) {
	var num = i < 10 ? "0" + i.toString() : i;
	image_cache["style_name_" + num] = imageLoad("/images/collections/style_name_" + num + ".gif");
}

function imageLoad(filename) {
    // create a new image object and returns object to caller
    var img = new Image();
    img.src = filename;
    return img;
}

function initPhoto() {
	// create a reference to all photos
	photos = document.getElementsByName("photo");
	// set the mouseover event handler for all photos
	for (var i = 0; photos[i]; i++) {
		photos[i].onmouseover = mouseOverPhoto;
		photos[i].onmouseout = mouseOutPhoto;
	}
}

function mouseOverPhoto() {
	// change the photo border
	this.className = "box_hover";
	// swap the style name image
	var regx = /\d+/;
	var match = null;
	match = regx.exec(this.src);
	document.style_name.src = image_cache["style_name_0" + match[0]].src;
}

function mouseOutPhoto() {
	// change the photo border
	this.className = "box";
}