function openWindowCentered(url,windowName,w,h,otherOptions){
	w += 32; //add space for items like scroll bars etc.
	h += 96;
	wleft = (screen.width - w) / 2;
	wtop = (screen.height - h) / 2;
	var win = window.open(url,
    name,
    'width=' + w + ', height=' + h + ', ' +
    'left=' + wleft + ', top=' + wtop + ', ' +
    otherOptions);
	// Just in case width and height are ignored
	win.resizeTo(w, h);
	// Just in case left and top are ignored
	win.moveTo(wleft, wtop);
	win.focus();
}

// Compare Products
function compareProducts(){
	var chkBoxes = document.getElementsByName("productChkBox");
	var productCodes = "";
	var minItemsToSelect = 2;
	var maxItemsToSelect = 4;
	if(chkBoxes!=null){
		//alert("len=" + chkBoxes.length);
		if(chkBoxes.length>0){
			var combiner = "";
			var selectedCount = 0;
			for(var i=0;i<chkBoxes.length;i++){
				if(chkBoxes[i].checked){
					productCodes += combiner+chkBoxes[i].value;
					combiner=",";
					selectedCount++;
				}
			}
		}
	}
	//alert(productCodes);
	if(selectedCount<minItemsToSelect){
		alert(YOU_SHOULD_SELECT_AT_LEAST_TWO_PRODUCTS);
		return false;
	}
	if(selectedCount>maxItemsToSelect){
		alert(YOU_SHOULD_SELECT_AT_MOST_FOUR_PRODUCTS);
		return false;
	}else{
		//window.open("ProductCompare?Products="+productCodes,"productCompare","height=600,width=775,left=25,top=20,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");		
		openWindowCentered(PRODUCTS_FOLDER + "ProductCompare?Products="+productCodes,"productCompare",780,600,"status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");
		return false;
	}
}

//Product Details
function showProductDetail(productCode){
	//window.open("ProductAllDetails?Products="+productCode,"productAllDetails","height=600,width=775,left=250,top=20,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");
	openWindowCentered(PRODUCTS_FOLDER + "ProductAllDetails?Products="+productCode,"productAllDetails",780,600,"status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");
	return false;
}

//open large image page
function showProductLargeImage(imageUrl){
	openWindowCentered("/ui/ShowProductImage.aspx?imageUrl=" + imageUrl,"showProductLargeImage", 375, 330, "status=no,toolbar=no,menubar=no,location=no");
	return false;
}

function showProductTechnicalImage(imageUrl, languageCode){
	openWindowCentered("/ui/ShowProductTechnicalImage.aspx?sLanguage=" + languageCode + "&imageUrl=" + imageUrl,"showProductLargeImage", 480, 430, "status=no,toolbar=no,menubar=no,location=no");
	return false;
}

function showTechnicalIconDescription(country,lang,attrName,attrValue){
	//window.open("ProductAllDetails?Products="+productCode,"productAllDetails","height=600,width=775,left=250,top=20,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");
	openWindowCentered("/ui/TechnicalIconPopup.aspx?sCountry=" + country + "&sLanguage=" + lang + "&attr=" + attrName + "&attrVal=" + attrValue,"technicalIconDesc",240,200,"status=no,toolbar=no,menubar=no,location=no,scrollbars=no");
	return false;
}

function sendToFriend(pageUrl){
	window.open(pageUrl,"SendFriend", "height=500,width=300,left=100,top=100,status=no,toolbar=no,menubar=no,location=no");
	return false;
}

function openBlankPage(pageUrl){
	window.open(pageUrl,"CampaignProductPrices");
	return false;
}

function showProductPage(combo){
	if(combo==null){
		return false;
	}
	if(combo.selectedIndex==-1){
		return false
	}
	var url = combo.options[combo.selectedIndex].value;
	if(url!=null && url.length>0){
		window.location.href=url;
	}
}

//print page
function printPage(){
	window.print();
}