var DHTML = (document.getElementById || document.all || document.layers);

function updateView(a, productID) {
	if (!DHTML) 
		return;
		
	var bigViewImg = document.getElementById("product_big_view");
	var clickedImgId = a.getElementsByTagName("img")[0].id;
	var newSrc = imagePath + productID + "_bigview_" + clickedImgId + ".jpg";
	
	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++) {
		productViews[i] = new Image();
		productViews[i].src = imagePath + productId + "_bigview_" + i + ".jpg"; 
	}
}

function PopUp(a){

	var defaultWidth=600, defaultHeight=450;
	var maxWidth=1000, maxHeight=680;

	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 = '/dvr/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;
}

