	
	var MinQuantity;
	var MaxQuantity;
	var MaxQuantitySDE;

	
	var TPA_VDK = new Array('$39.00'); TPA_VDK[TPA_VDK.length]=[1, '$39.00'];  TPA_VDK[TPA_VDK.length]=[6, '$37.00'];  TPA_VDK[TPA_VDK.length]=[11, '$35.00'];  TPA_VDK[TPA_VDK.length]=[26, '$33.00'];  TPA_VDK[TPA_VDK.length]=[76, '$31.00'];  TPA_VDK[TPA_VDK.length]=[100, '$29.00'];
	var TPA_WIM = new Array('$29.00'); TPA_WIM[TPA_WIM.length]=[1, '$29.00'];  TPA_WIM[TPA_WIM.length]=[6, '$27.00'];  TPA_WIM[TPA_WIM.length]=[11, '$26.00'];  TPA_WIM[TPA_WIM.length]=[26, '$24.00'];  TPA_WIM[TPA_WIM.length]=[76, '$23.00'];  TPA_WIM[TPA_WIM.length]=[100, '$22.00'];
	var TPA_SDEComplimentary = new Array('$1,995.00'); TPA_SDEComplimentary[TPA_SDEComplimentary.length] = [1, '$1,995.00']; //TPA_SDEComplimentary[TPA_SDEComplimentary.length] = [6, '$1,895.00']; TPA_SDEComplimentary[TPA_SDEComplimentary.length] = [11, '$1,795.00']; TPA_SDEComplimentary[TPA_SDEComplimentary.length] = [26, '$1,695.00']; TPA_SDEComplimentary[TPA_SDEComplimentary.length] = [76, '$1,595.00']; TPA_SDEComplimentary[TPA_SDEComplimentary.length] = [100, '$1,495.00'];
	var TPA_SDEBasic = new Array('$2,294.95'); TPA_SDEBasic[TPA_SDEBasic.length] = [1, '$2,294.95']; //TPA_SDEBasic[TPA_SDEBasic.length] = [6, '$2,194.95']; TPA_SDEBasic[TPA_SDEBasic.length] = [11, '$2,094.95']; TPA_SDEBasic[TPA_SDEBasic.length] = [26, '$1,994.95']; TPA_SDEBasic[TPA_SDEBasic.length] = [76, '$1,894.95']; TPA_SDEBasic[TPA_SDEBasic.length] = [100, '$1,794.95'];
	var TPA_SDEEssential = new Array('$2,594.95'); TPA_SDEEssential[TPA_SDEEssential.length] = [1, '$2,594.95'];// TPA_SDEEssential[TPA_SDEEssential.length] = [6, '$2,494.95']; TPA_SDEEssential[TPA_SDEEssential.length] = [11, '$2,394.95']; TPA_SDEEssential[TPA_SDEEssential.length] = [26, '$2,294.95']; TPA_SDEEssential[TPA_SDEEssential.length] = [76, '$2,194.95']; TPA_SDEEssential[TPA_SDEEssential.length] = [100, '$2,094.95'];
	var TPA_SDEPremium = new Array('$3,294.95'); TPA_SDEPremium[TPA_SDEPremium.length] = [1, '$3,294.95']; //TPA_SDEPremium[TPA_SDEPremium.length] = [6, '$3,194.95']; TPA_SDEPremium[TPA_SDEPremium.length] = [11, '$3,094.95']; TPA_SDEPremium[TPA_SDEPremium.length] = [26, '$2,994.95']; TPA_SDEPremium[TPA_SDEPremium.length] = [76, '$2,894.95']; TPA_SDEPremium[TPA_SDEPremium.length] = [100, '$2,794.95'];
	
	var orderType = "";
	/*** DEFAULT CURRENCY FORMATTING VARIABLES ***/
	var DecimalPointSymbol = '.';
	var CommaSeparatorSymbol = ',';
	var NumbersBetweenCommas = 3; // Number of digits between each comma
	var FormatDecimalPlaces = 2; // Number of decimal places to display
	var CurrencyPrefix = '';
	var CurrencySuffix = '';
	MinQuantity=1;
	MaxQuantity = 1000;
	MaxQuantitySDE = 100;
	
	/*** GLOBAL FUNCTIONS ***/
	// Returns true if the string is blank
	function isBlank(SomeString) {
		return (SomeString.toString().length == 0);
	}
	// Returns true if the value is numeric
	function isNumeric(SomeValue) {
		return ((!isNaN(SomeValue)) && (!isBlank(SomeValue)));
	}
	// Only allows numeric characters to be input (and use of navigation keys)
	function catchKeyStroke(e) {
		var KeyCode = (e.keyCode) ? e.keyCode : e.which;
		return ((KeyCode == 8) // backspace
			|| (KeyCode == 9)  // tab
			|| (KeyCode == 13) // enter
			|| (KeyCode == 37) // left arrow
			|| (KeyCode == 39) // right arrow
			|| ((KeyCode >= 46) && (KeyCode <= 57))); // 46 is delete, 47-57 is 0-9
	}
	// Returns the number formatted with commas and 2 decimal places
	function numberFormat(MoneyAmount, DecimalPlaces, DecimalCharacter, DigitsBetweenCommas, CommaSeparator) {
		if (isNumeric(MoneyAmount)) {
			// Check parameters, use defaults when necessary
			// Checking the undefined property doesn't work on Mac IE, need to check arguments.length instead!
			if (arguments.length < 2) var DecimalPlaces = FormatDecimalPlaces;
			if (arguments.length < 3) var DecimalCharacter = DecimalPointSymbol;
			if (arguments.length < 4) var DigitsBetweenCommas = NumbersBetweenCommas;
			if (arguments.length < 5) var CommaSeparator = CommaSeparatorSymbol;
			// Start logic
			if ((DecimalPlaces <= 0) || (DecimalCharacter == '')) {
				var MoneyString = Math.round(MoneyAmount).toString();
				var DecimalString = '';
			}
			else {
				var MoneyString = MoneyAmount.toString();
				var DecimalIndex = MoneyString.lastIndexOf('.');
				// Need to round off extra decimal points
				if ((MoneyString.length - DecimalIndex) > (DecimalPlaces + 1)) {
					var Rounder = Math.pow(10, DecimalPlaces);
					MoneyAmount = Math.round(MoneyAmount * Rounder) / Rounder;
					MoneyString = MoneyAmount.toString();
				}
			// Re-check the decimal point position, in case the number was rounded
			DecimalIndex = MoneyString.lastIndexOf('.');
			if ((DecimalIndex == -1) || ((MoneyString.length - DecimalIndex) <= DecimalPlaces)) {
				if (DecimalIndex == -1) MoneyString += '.';
				else DecimalPlaces = DecimalPlaces - (MoneyString.length - DecimalIndex - 1);
				for (var j=1;j<=DecimalPlaces;j++) MoneyString += '0';
			}
			var DecimalString = MoneyString.replace(/^(\d+)\.(\d+)$/, DecimalCharacter + '$2');
			MoneyString = RegExp.$1;
			}
			// Separate the thousands with a comma
			if ((DigitsBetweenCommas > 0) && (CommaSeparator != '') && (Math.abs(MoneyAmount) >= Math.pow(10, DigitsBetweenCommas))) { // Added check for amount >= 1000 to fix issue on Mac IE
				var ThousandRE = new RegExp('(\\d{' + DigitsBetweenCommas + '})', 'g');
				var MoneyArray = MoneyString.split('').reverse().join('').replace(ThousandRE, '$1' + CommaSeparator).split('');
				if (MoneyArray[MoneyArray.length-1] == CommaSeparator) MoneyArray.pop();
				MoneyString = MoneyArray.reverse().join('');
			}
			return MoneyString + DecimalString;
		}
		else return MoneyAmount;
	}
	// Strips off currency formatting, including comma separators
	function stripCurrency(FormattedPriceWithCurrency, resetGlobals) {
		if (arguments.length < 2) resetGlobals = true;
		var MainNumberExpression = ((NumbersBetweenCommas > 0) && (CommaSeparatorSymbol != '')) ? '\\d{1,' + NumbersBetweenCommas + '}(\\' + CommaSeparatorSymbol + '?\\d{' + NumbersBetweenCommas + '})*' : '\\d+';
		var DecimalExpression = (DecimalPointSymbol != '') ? '\\' + DecimalPointSymbol + '?\\d*' : '';
		var CurrencyRE = new RegExp('^(\\D*)(' + MainNumberExpression + DecimalExpression + ')(\\D*)$');
		var PriceChunk = CurrencyRE.exec(FormattedPriceWithCurrency); // Finds the matches, and puts them into an array
		if (PriceChunk == null) return 0; // If the input price doesn't match, return 0
		else {
			if (resetGlobals){
				CurrencyPrefix = PriceChunk[1];
				CurrencySuffix = PriceChunk[PriceChunk.length-1]; // Must be dynamic, because a match may be missing if no comma-separator is supplied
			}
		if (CommaSeparatorSymbol != '') {
			var CommaRE = new RegExp('\\' + CommaSeparatorSymbol, 'g');
			PriceChunk[2] = PriceChunk[2].replace(CommaRE, ''); // Strips out the commas
		}
		if ((DecimalPointSymbol != '') && (DecimalPointSymbol != '.')) {
			var DecimalRE = new RegExp('\\' + DecimalPointSymbol);
			PriceChunk[2] = PriceChunk[2].replace(DecimalRE, '.'); // Replaces the weird decimal point symbol with a real one
		}
		return parseFloat(PriceChunk[2]);
		}
	}
	/*** CALCULATOR SPECIFIC FUNCTIONS ***/
	// Resets the input value if the number is not between the min and max
	function calculatePrice_SDE() {
	    var InputQuantity = document.getElementById('license_SDE').value;
	    
	    var sdeComp = document.getElementById('radiobutton_SDEComplimentary').checked;
	    var sdeBasic = document.getElementById('radiobutton_SDEBasic').checked;
	    var sdeEssen = document.getElementById('radiobutton_SDEEssential').checked;
	    var sdePrem = document.getElementById('radiobutton_SDEPremium').checked;
	    var prodDesc;
	    var TPA_SDE;
	    if (sdeComp == true) { TPA_SDE = TPA_SDEComplimentary; prodDesc = ""; }
	    if (sdeBasic == true) { TPA_SDE = TPA_SDEBasic;prodDesc = " with Basic Support"; }
	    if (sdeEssen == true) { TPA_SDE = TPA_SDEEssential; prodDesc = " with Essential Support"; }
	    if (sdePrem == true) { TPA_SDE = TPA_SDEPremium; prodDesc = " with Premium Support"; }
	    
	    if (isBlank(InputQuantity) || !isNumeric(InputQuantity)) NewValue = 0;
	    if ((InputQuantity >= MinQuantity) && (InputQuantity <= MaxQuantitySDE)) { // Display the price and savings, based on the quantity entered
	        var BasePrice = stripCurrency(TPA_SDE[0]);
	        if (BasePrice > 0) { // Only calculate savings if there's a valid base price
	            if (InputQuantity >= MinQuantity) {
	                var TPrice = -1;
	                for (var j = TPA_SDE.length - 1; j > 0; j--) {
	                    if (InputQuantity >= TPA_SDE[j][0]) {
	                        TPrice = stripCurrency(TPA_SDE[j][1], false);
	                        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_SDE').innerHTML = CurrencyPrefix + numberFormat(CalculatedPrice) + CurrencySuffix;
	            // document.getElementById('tieredPriceSavings_SDE').innerHTML = CurrencyPrefix + numberFormat(CalculatedSavings) + CurrencySuffix;
	            // document.getElementById('youSaveText_SDE').style.visibility = (CalculatedSavings > 0) ? 'visible' : 'hidden';
	            //document.getElementById('productAmount_SDE').value = numberFormat(CalculatedSavings);
	            document.getElementById('buynow_SDE').style.visibility = 'visible';
	            document.getElementById('productAmount_SDE').value = numberFormat(CalculatedPrice);
	            document.getElementById('productDescription_SDE').value = "SmartDeploy Enterprise License" + prodDesc + " (" + InputQuantity + " User)"
	        }
	    }
	    else {
	        if (InputQuantity > MaxQuantitySDE) {
	            var ErrorHTML = 'A maximum of ' + MaxQuantitySDE + ' licenses can be ordered from this site.';
	           // document.getElementById('youSaveText_SDE').style.visibility = 'hidden';
	        }
	        else if (InputQuantity < MinQuantity) {
	            var ErrorHTML = 'Please enter an amount between ' + MinQuantity + ' and ' + MaxQuantitySDE + '.';
	        }
	        document.getElementById('tieredPriceTotal_SDE').innerHTML = '<span style="font-size:10px;font-weight:bold;width:110px;">' + ErrorHTML + '</span>';
	        document.getElementById('buynow_SDE').style.visibility = 'hidden';
	    }
	}
	
	
	// Resets the input value if the number is not between the min and max
	function calculatePrice_WIM(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_WIM[0]);
			if (BasePrice > 0) { // Only calculate savings if there's a valid base price
				if (InputQuantity >= MinQuantity) {
					var TPrice = -1;
					for (var j=TPA_WIM.length-1;j>0;j--) {
						if (InputQuantity >= TPA_WIM[j][0]) {
							TPrice = stripCurrency(TPA_WIM[j][1], false);
							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_WIM').innerHTML = CurrencyPrefix + numberFormat(CalculatedPrice) + CurrencySuffix;
				document.getElementById('tieredPriceSavings_WIM').innerHTML = CurrencyPrefix + numberFormat(CalculatedSavings) + CurrencySuffix;
				document.getElementById('youSaveText_WIM').style.visibility = (CalculatedSavings > 0) ? 'visible' : 'hidden';
				document.getElementById('productAmount_WIM').value = numberFormat(CalculatedSavings);
				document.getElementById('buynow_WIM').style.visibility = 'visible';
				document.getElementById('productAmount_WIM').value = numberFormat(CalculatedPrice);
				document.getElementById('productDescription_WIM').value = "SmartDeploy Imaging Component License (" + InputQuantity + " User)"
			}
		}
		else {
			if (InputQuantity > MaxQuantity) {
				var ErrorHTML = 'A maximum of ' + MaxQuantity + ' licenses can be ordered from this site.';
				document.getElementById('youSaveText_WIM').style.visibility = 'hidden';
			}
			else if (InputQuantity < MinQuantity) {
				var ErrorHTML = 'Please enter an amount between ' + MinQuantity + ' and ' + MaxQuantity + '.';
			}
			document.getElementById('tieredPriceTotal_WIM').innerHTML = '<span style="font-size:10px;font-weight:bold;width:110px;">' + ErrorHTML + '</span>';
			document.getElementById('buynow_WIM').style.visibility = 'hidden';
		}
	}
	// Resets the input value if the number is not between the min and max
	function calculatePrice_VDK(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_VDK[0]);
			if (BasePrice > 0) { // Only calculate savings if there's a valid base price
				if (InputQuantity >= MinQuantity) {
					var TPrice = -1;
					for (var j=TPA_VDK.length-1;j>0;j--) {
						if (InputQuantity >= TPA_VDK[j][0]) {
							TPrice = stripCurrency(TPA_VDK[j][1], false);
							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_VDK').innerHTML = CurrencyPrefix + numberFormat(CalculatedPrice) + CurrencySuffix;
				document.getElementById('tieredPriceSavings_VDK').innerHTML = CurrencyPrefix + numberFormat(CalculatedSavings) + CurrencySuffix;
				document.getElementById('youSaveText_VDK').style.visibility = (CalculatedSavings > 0) ? 'visible' : 'hidden';
				document.getElementById('productAmount_VDK').value = numberFormat(CalculatedSavings);
				document.getElementById('buynow_VDK').style.visibility = 'visible';
				document.getElementById('productAmount_VDK').value = numberFormat(CalculatedPrice);
				document.getElementById('productDescription_VDK').value = "SmartDeploy Virtual Disk Component License (" + InputQuantity + " User)"
			}
		}
		else {
			if (InputQuantity > MaxQuantity) {
				var ErrorHTML = 'A maximum of ' + MaxQuantity + ' licenses can be ordered from this site.';
				document.getElementById('youSaveText_VDK').style.visibility = 'hidden';
			}
			else if (InputQuantity < MinQuantity) {
				var ErrorHTML = 'Please enter an amount between ' + MinQuantity + ' and ' + MaxQuantity + '.';
			}
			document.getElementById('tieredPriceTotal_VDK').innerHTML = '<span style="font-size:10px;font-weight:bold;width:110px;">' + ErrorHTML + '</span>';
			document.getElementById('buynow_VDK').style.visibility = 'hidden';
		}
	}
	// Determines which key input is OK
	function checkQuantityInput(InputQuantity, e) {
	    if (catchKeyStroke(e)) {
	        var KeyCode = (e.keyCode) ? e.keyCode : e.which;
	        var character = String.fromCharCode(KeyCode);
			return !( (!isNumeric(character)) || (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
	}