/*******************/
/* ProductGroup.js */
/*******************/
function ProductGroupAddToCart_Click() {
	var ddl = document.getElementById('ddlProductGroupVariants');
	var hih = document.getElementById('hihItemID');
	var hihItem = document.getElementById('ItemID');
	var hihItemCount = document.getElementById('ItemCount');
	var tiItemCount = document.getElementById('hihItemCount');
	if(ddl) {
		// multiple variants exist
		hih.value = ddl[ddl.selectedIndex].value;
	}
	if((tiItemCount.value > 1) && (tiItemCount.value < 10000)) {
		// to add multiple items to basket
		hihItemCount.value = tiItemCount.value;
	} else {
		// to add 1 item to basket
		hihItemCount.value = 0;
		tiItemCount.value = 1;
	}
	// set the non-postback form and submit
	hihItem.value = hih.value;
	document.AddToCartForm.submit();
}

var ProductGroupImg;

function ProductGroupImageOnLoad(strProductGroupImageUrl) {
	ProductGroupImg = new Image();
	ProductGroupImg.src = strProductGroupImageUrl;
}

function ProductGroupImagePopup(strProductGroupImageUrl) {
		var strUrl = 'ProductGroupImagePopup.aspx?ProductGroupImageUrl=' + strProductGroupImageUrl;
		var width = 400;
		var height = 400;
		
		if(ProductGroupImg.complete) {
			width = ProductGroupImg.width;
			height = ProductGroupImg.height;
		} else {
			strUrl += '&width=400&height=400';
		}
		winImage = window.open(strUrl, 'ProductGroupImgWin', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=' + width + ',height=' + height).focus();
}

function ProductGroupSwatchSet(strImageUrl) {
	var img = document.getElementById('ProductGroupImage');
	if(img) {
		img.src = strImageUrl;
	}
}