var DHTML = (document.getElementById || document.all || document.layers);
//	UPDATES THE FLASH PIECE - IF THERE IS ONE

function updateView(a, productID) {
	if (!DHTML) 
		return;
		
	var bigViewImg = document.getElementById("product_big_view");
	var clickedImgId = a.getElementsByTagName("img")[0].id;
		if (clickedImgId != "0") {
			var newSrc = imagePath + productID + "_bigview_" + clickedImgId + ".jpg";
			bigViewImg.src = newSrc;
		}
		else {
			//alert("help");
			//var newSrc = imagePath + productID + ".jpg";
			var newSrc = "/consumers/product_flash.asp?sPage=" + productID;
			//parent.("product_big_name").location = "product_flash.asp";
			bigViewImg.src = newSrc;
		}
}

function highlightThumb(a) {
	if (!DHTML) 
		return;

	var imgToHighlight = a.getElementsByTagName("img")[0];
	imgToHighlight.style.border = "1px #dedede solid";
}

function unHighlightThumb(a) {
	if (!DHTML) 
		return;

	var imgToHighlight = a.getElementsByTagName("img")[0];
	imgToHighlight.style.border = "1px white solid";
}

function preloadViews(productId) {
	productViews = new Array();

	for (var i=1; i<=3; i++) {
		productImages[i] = new Image();
		productImages[i].src = imagePath + productId + "_bigview_" + i + ".jpg"; 
	}
}

function PopUp(a){

	var defaultWidth=600, defaultHeight=450;
	var maxWidth=1000, maxHeight=700;

	var width = (a.width?a.width:a.getAttribute('width')?a.getAttribute('width'):defaultWidth)*1;
	var height = (a.height?a.height:a.getAttribute('height')?a.getAttribute('height'):defaultHeight)*1;

	var scrollBars = width<=maxWidth && height<=maxHeight ? 0 : 1;

	width+=45+(scrollBars?20:0);
	height+=75+(scrollBars?20:0);
	var w = a.getAttribute?a.getAttribute('width')*1:'';
	var h = a.getAttribute?a.getAttribute('height')*1:'';
	href = '/consumers/includes/zoom_image.asp?img='+escape(a.href)+'&w='+w+'&h='+h;

	width=Math.min(width,maxWidth);
	height=Math.min(height,maxHeight);

	var win=window.open(href,a.target,'width='+width+',height='+height+',scrollbars='+scrollBars+',resizable=1,top=20,left=20');
	win.resizeTo(width,height);
	win.focus();

	return false;
}

//new scripty for Home Monitoring Flash/image switches

function hmSwitch(selectedImage, totalImages) {
	//first, hide all
	for (var i=1; i<=totalImages; i++) {
		document.getElementById("bigview" + i).style.display = "none";
	}
	//then, show the one that was clicked
	document.getElementById("bigview" + selectedImage).style.display = "block";
}
