/*** GLOBAL VARIABLES ***/
var MinQuantity = 10;
var MaxQuantity = 1000;
var orderType = "";
// change min quantity order type see code on 10023pn1
if ((location.href.toUpperCase().indexOf("SP=10023") != -1) && (location.href.toUpperCase().indexOf("PN=1") != -1)) {
if (orderType == "SEA Server License") {
var MinQuantity = 1;
}
}
/*** FUNCTIONS ***/
// Resets the input value if the number is not between the min and max
function calculatePrice(InputQuantity) {
if (isBlank(InputQuantity)) NewValue = 0;
if ((InputQuantity >= MinQuantity) && (InputQuantity <= MaxQuantity)) { // Display the price and savings, based on the quantity entered
var BasePrice = stripCurrency(TPA[0]);
if (BasePrice > 0) { // Only calculate savings if there's a valid base price
if (InputQuantity >= MinQuantity) {
var TPrice = -1;
for (var j=TPA.length-1;j>0;j--) {
if (InputQuantity >= TPA[j][0]) {
TPrice = stripCurrency(TPA[j][1]);
break;
}
}
if (TPrice < 0) TPrice = BasePrice;
var CalculatedPrice = InputQuantity * TPrice;
var CalculatedSavings = (InputQuantity * BasePrice) - CalculatedPrice;
}
else {
var CalculatedPrice = 0;
var CalculatedSavings = 0;
}
document.getElementById('tieredPriceTotal').innerHTML = CurrencyPrefix + numberFormat(CalculatedPrice) + CurrencySuffix;
document.getElementById('tieredPriceSavings').innerHTML = CurrencyPrefix + numberFormat(CalculatedSavings) + CurrencySuffix;
document.getElementById('youSaveText').style.visibility = (CalculatedSavings > 0) ? 'visible' : 'hidden';
}
}
else {
if (InputQuantity > MaxQuantity) var ErrorHTML = 'A maximum of ' + MaxQuantity + ' licenses can be ordered from this site.
Need more than ' + MaxQuantity + '?';
else if (InputQuantity < MinQuantity) var ErrorHTML = 'If you wish to purchase Volume Licensing, please enter an amount between ' + MinQuantity + ' and ' + MaxQuantity + '.';
document.getElementById('tieredPriceTotal').innerHTML = '' + ErrorHTML + '';
document.getElementById('youSaveText').style.visibility = 'hidden';
}
}
// Determines which key input is OK
function checkQuantityInput(InputQuantity, e) {
if (catchKeyStroke(e)) {
var KeyCode = (e.keyCode) ? e.keyCode : e.which;
return !((KeyCode == 13) || ((isBlank(InputQuantity)) && (KeyCode == 48))); // Enter key is not allowed (form-submit), and the first digit entered can't be 0
}
else return false; // All other key strokes are disabled
}