function showSwatch(swatchImg, colorName) {
document.getElementById('swatch').src = swatchImg;
document.getElementById('swatch').style.visibility = 'visible';
document.getElementById('swatchTitle').innerHTML= colorName;
}
function showProductImage(productImg, productImageName) {
document.getElementById('productImage').src = productImg;
document.getElementById('productImageTitle').innerHTML= productImageName;
}
function changeProductImage(newImage) {
document.productImage.src=newImage;
}

var selectedSwatchImg = null;
var selectedColor = null;

function getSwatchImg(color) {
if(selectedSwatchImg != null) {
   selectedSwatchImg.style.border="1px black solid";
   selectedSwatchImg.width=30;
   selectedSwatchImg.height=30;
}
selectedSwatchImg = document.getElementsByName(color)[0];
selectColor(document.getElementsByName(color)[0]);
changeProductImage(document.getElementsByName(color)[0].id);
selectedColor = color;
//alert(selectedColor);
}

function selectColor(swatchImg) {
if(selectedSwatchImg != null) {
   selectedSwatchImg.style.border="1px black solid";
   selectedSwatchImg.width=30;
   selectedSwatchImg.height=30;
}
selectedSwatchImg=swatchImg;
swatchImg.style.border="3px black solid";
swatchImg.width=26;
swatchImg.height=26;
//alert(swatchImg.parentNode.style);
var colorName = swatchImg.name;
//alert(colorName);
var colorPrintSelect=document.getElementsByName("Color");
if(colorPrintSelect.length==0) colorPrintSelect=document.getElementsByName("Print");
var options = colorPrintSelect[0].options;
for(i=0;i<options.length;i++) {
	var optionName = options[i].value;
	//optionName = optionName.substring(0, optionName.indexOf('(')-1);
	if(optionName == colorName) {
		colorPrintSelect[0].options[i].selected=true;
	}
}
//alert(document.getElementsByName("currentColorDisplay")[0].innerHTML);
//document.getElementsByName("currentColorDisplay")[0].innerHTML = colorName;
updateCurrentColorDisplay(colorName);
}

function updateCurrentColorDisplay(colorName) {
//alert(document.getElementsByName("currentColorDisplay").length);
document.getElementsByName("currentColorDisplay")[0].innerHTML = colorName;
}

function doSwatchMouseOver(swatchImg) {
changeProductImage(swatchImg.id);
updateCurrentColorDisplay(swatchImg.name);
}

function doSwatchMouseOut(swatchImg) {
changeProductImage(selectedSwatchImg.id);
updateCurrentColorDisplay(selectedSwatchImg.name);
}