if (ie5mac){document.location.href = "badbrowser.aspx";}

function openCentredWindow(mypage,w,h,scroll,resizable) {
	var win = null;
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable='+resizable;
	win = window.open(mypage,null,settings);
}

function enlargeImage(itemImageId) {
	openCentredWindow('Popup/Image.aspx?Type=item&Image=1&ItemImageId=' + itemImageId, 700, 700, 0, 0);
}

function moreImages(itemId, colour) {
	openCentredWindow('Popup/DetailImages.aspx?Type=item&ItemId=' + itemId + '&colour=' + colour, 725, 725, 0, 0);
}

function moreItemInfo(itemId) {
	openCentredWindow('Popup/ItemInfo.aspx?Type=item&ItemId=' + itemId, 310, 350, 1, 0);
}

function isValidEmail(email) {
   return (email.indexOf(".") > 2) && (email.indexOf("@") > 0);
}

function setPriceIncVat(txtPrice, txtVat, txtPriceIncVat) {
	var price = Number(document.getElementById(txtPrice).value);
	var vat = Number(document.getElementById(txtVat).value);
	var priceincvat = (price * (1 + (vat/100)));

	document.getElementById(txtPriceIncVat).value = priceincvat.toFixed(2);
}

function setPriceExVat(txtPrice, txtVat, txtPriceIncVat) {
  var priceIncVat = Number(document.getElementById(txtPriceIncVat).value);
  var vat = Number(document.getElementById(txtVat).value);
  var priceExVat = (priceIncVat / (1 + (vat / 100)));

  document.getElementById(txtPrice).value = priceExVat.toFixed(2);
}

function setShippingAddress() {
	document.getElementById('Content_txtShippingAddress1').value = document.getElementById('Content_txtAddress1').value;
	document.getElementById('Content_txtShippingAddress2').value = document.getElementById('Content_txtAddress2').value;
	document.getElementById('Content_txtShippingTown').value = document.getElementById('Content_txtTown').value;
	document.getElementById('Content_txtShippingCounty').value = document.getElementById('Content_txtCounty').value;
	document.getElementById('Content_txtShippingPostcode').value = document.getElementById('Content_txtPostcode').value;
	document.getElementById('Content_ddlShippingCountry').selectedIndex = document.getElementById('Content_ddlAddressCountry').selectedIndex;
}

function displaySelectASize() {
	var bShowMessage = true;

	if( document.getElementById('Content_SizeList').selectedIndex == 0 ) { bShowMessage = false; }

	if( bShowMessage == true) { alert('Sorry, that item is out of stock.'); }
	return false;
}

function checkObject(obj) {
	if (document.getElementById(obj)) { return true; } else { return false; }
}
