// -- Product Tab Hide/Show --
function changeClass(currClass) {
	var obj = document.getElementById('product-nav-buttons').getElementsByTagName('a');

	for (var x=0; x < obj.length; x++) {
		if (obj[x].className.search(/-on/) > -1) {
			obj[x].className = obj[x].className.replace(/-on/, "-off");
		} else if (obj[x].className == currClass) {
			obj[x].className = obj[x].className.replace(/-off/, "-on");
		}
	}
}

// -- Hide Product Divs --
function hideDivs() {
//	var divs = document.getElementsByTagName('div');
	var divs = document.getElementById('content-wrapper').getElementsByTagName('div');

	for (var i=0; i < divs.length; i++) {
		if (divs[i].id.search(/nav-/) > -1) {
			if (document.getElementById) {
				divs[i].style.display = "none";
			}
			else if (document.all) {
				document.all[divs[i]].style.display = "none";
			}
			else if (document.layers) {
				document.layers[divs[i]].display = "none";
			}
		}
	}
}



// -- Show Product Div --
function showDiv(whichLayer) {
	if (document.getElementById) {
		// this is the way the standards work
		document.getElementById(whichLayer).style.display = "block";
	}
	else if (document.all) {
		// this is the way old msie versions work
		document.all[whichlayer].style.display = "block";
	}
	else if (document.layers) {
		// this is the way nn4 works
		document.layers[whichLayer].display = "block";
	}
}


// -- Product Image View Rollovers --
function doHover(obj, highlight) {
	if (highlight) {
		addClass(obj, 'product-selected');
	} else {
		removeClass(obj, 'product-selected');
	}
}

function doClick(obj, group) {
	g = document.forms["hiddenform"][group];

	r = getChecked(g);
	b = getBoxByRadio(r);

	if (b != obj) {
		removeClass(b, 'product-selected');
		r.checked = false;
	}

	getRadioByBox(g, obj).checked = true;
	addClass(obj, 'product-selected');
}

function addClass(obj, className) {
	obj.className = className;
}

function removeClass(obj, className) {
	obj.className = '';
}

function removeElement(arr, ele) {
	for (var i = 0; i < arr.length; i++) {
		if (arr[i] == ele) {
			arr[i] = arr[arr.length-1];
			arr.length--;
		}
	}
	return arr;
}

function getChecked(group) {
	for (var i = 0; i < group.length; i++) {
		if (group[i].checked) return group[i];
	}
	return null;
}

function getBoxByRadio(radio) {
	return document.getElementById(radio.value);
}

function getRadioByBox(group, box) {
	for (var i = 0; i < group.length; i++) {
		if (group[i].value == box.id) return group[i];
	}
	return null;
}

function viewProduct(name,src) {
	if (document.images)
       		document.images[name].src = src;
}


function enlargeImage() {
	var enlargeWin = null;

	if (!enlargeWin || enlargeWin.closed) {
		if (document.images.productimage.src.indexOf("/") > -1) {
			var imageLoc = document.images.productimage.src.split("/");
			var imageName = imageLoc[imageLoc.length - 1];
		} else {
			imageName = document.images.productimage.src;
		}

		enlargeWin = window.open("about:blank", "enlargeWin", "scrollbars=no,toolbar=no,location=no,status=no,menubar=no,width=503,height=467"); 
		enlargeWin.location.href = "/popups/enlarge-image.asp?ImageURL="+ document.images.productimage.src.replace(".gif", "-large.gif"); 
//		enlargeWin.location.href = "/popups/enlargeImage.asp?image="+ imageName; 
		enlargeWin.focus(); 
	}
}