var item_numberArray = new Array(8);
item_numberArray[0] = "-FP1";
item_numberArray[1] = "-FP1FPT";
item_numberArray[2] = "-FP1UHG";
item_numberArray[3] = "-FP1FPTUHG";
item_numberArray[4] = "-FP12";
item_numberArray[5] = "-FP12FPT";
item_numberArray[6] = "-FP12UHG";
item_numberArray[7] = "-FP12FPTUHG";
var item_number = item_numberArray[0];
var _locationId;
var _monthlyPrice;
var _yearlyPrice;
var _trainerMonthlyPrice;
var _trialPrice;
var _FK1price;
var _siteUrl;
var _userID;
var _rootDir;
function subscribeInit(locationId, monthlyPrice, yearlyPrice, trainerMonthlyPrice, trialPrice, ultimateHomeGymPrice, siteUrl, rootDir) {
	setSiteData(locationId, siteUrl);
	_monthlyPrice = monthlyPrice;
	_yearlyPrice = yearlyPrice;
	_trainerMonthlyPrice = trainerMonthlyPrice;
	_trialPrice = trialPrice;
	_FK1price = ultimateHomeGymPrice;
	_rootDir = rootDir;
	disableStatuses();
	updateSelection();
}
function setSiteData(locationId, siteUrl) {
	_locationId = locationId;
	_siteUrl = siteUrl;
}
function initUser(userID) {
	_userID = userID;
}
function updateCustomSelection(itemNumber, itemName, itemPrice) {
	item_number = itemNumber;
	divoCsubscriptionChoice.innerHTML = "Your current selection is to get started with " + itemName + ". <b>Total price of $" + itemPrice + ".</b>";
}
function updateSelection() {
	divoCsubscriptionChoice.innerHTML = "";
	item_number = "-FP1";
		
	var PTprice = 0;
	var specialOffer = 0;
	var totalPrice = _monthlyPrice;
	if (_trialPrice != "0") {
		totalPrice = _trialPrice;
	}
	var shippingPrice = 0;

	if (eval(_trainerMonthlyPrice) > 0 && divoCFitKit2.checked) { //personal trainer
		if (_yearlyPrice != "0" && document.selectForm.selProAccount[1].checked) {
			divoCsubscriptionChoice.innerHTML = "Your current selection is to get started with a Pro Personal Trainer Account for 1 Year where you will be working with the very best Certified Fitness Counselor that will guide you towards your fitness goals.";
			if (_trialPrice != "0") {
				totalPrice = _trialPrice + eval(eval(_trainerMonthlyPrice)*12);
			} else {
				totalPrice = _yearlyPrice + eval(eval(_trainerMonthlyPrice)*12);
			}
			item_number = "-FP12FPT";
		} else {
			divoCsubscriptionChoice.innerHTML = "Your current selection is to get started with a Pro Personal Trainer Account for 1 Month where you will be working with the very best Certified Fitness Counselor that will guide you towards your fitness goals.";
			if (_trialPrice != "0") {
				totalPrice = trialPrice;
			} else {
				totalPrice = eval(_monthlyPrice + _trainerMonthlyPrice);
			}
			item_number = "-FP1FPT";
		}
	} else {
		divoCsubscriptionChoice.innerHTML = "Your current selection is to get started with a Pro Account for 1 Month.";
		if (_yearlyPrice != "0" && document.selectForm.selProAccount[1].checked) {
			divoCsubscriptionChoice.innerHTML = "Your current selection is to get started with a Pro Account for 1 Year.";
			if (_trialPrice != "0") {
				totalPrice = trialPrice;
			} else {
				totalPrice = _yearlyPrice;
			}
			item_number = "-FP12";
		}
	}
	if (eval(_FK1price) > 0 && divoCFitKit1.checked) {
		var addText = "";
		if (divoCFitKit1.checked) {
			addText = "Ultimate Home Gym";
			totalPrice = eval(totalPrice) + eval(_FK1price);
			shippingPrice = 15;
			item_number = item_number + "UHG";
		}
		totalPrice = totalPrice - specialOffer;
		divoCsubscriptionChoice.innerHTML = divoCsubscriptionChoice.innerHTML + " You will also be receiving the " + addText + ".";
	}
	if (shippingPrice == 0) {
		divoCsubscriptionChoice.innerHTML = divoCsubscriptionChoice.innerHTML + " <b>Total price of $" + (Math.round(totalPrice * 100) / 100) + ".</b>";
	} else {
		divoCsubscriptionChoice.innerHTML = divoCsubscriptionChoice.innerHTML + " <b>Total price of $" + (Math.round(totalPrice * 100) / 100) + " plus $" + (Math.round(shippingPrice * 100) / 100) + " shipping.</b>";
	}
}
var upgradeWindow = "";
function subscribe() {
	if (!IAgree.checked) {
		alert("You are required to be at least 18 years old and have read the Terms & Conditions. Please review this option above.");
		IAgree.focus();
		return;
	}
	var ballSelecter = "";
	if (eval(_FK1price) > 0) {
		if (divoCFitKit1.checked && document.getElementById("ballSelecter").value == "0") {
			alert("Please select an exercise ball size.");
			document.getElementById("ballSelecter").focus();
			return;
		}
		ballSelecter = document.getElementById("ballSelecter").value;
	}
  if (!upgradeWindow) {
  } else if (!upgradeWindow.closed) {
    upgradeWindow.window.close();
  }
	theFile = "http://"+_siteUrl+"/eft/pp/buyNow.asp?item_number="+_locationId+item_number+"&promoCode="+document.getElementById("promoCode").value+"&custom="+_userID+"|"+ballSelecter;
	upgradeWindow = window.open(theFile,"Upgrade",'scrollbars=yes,toolbar=yes,location=yes,width=900,height=750,top='+(screen.height-800)/2+',left='+(screen.width-900)/2);
	if (!upgradeWindow) {
		alert("Please enable popups to view the requested window.");
	} else {
		upgradeWindow.opener = this.window;
		upgradeWindow.focus();
	}
}
function selectChk(objChk) {
	if (objChk.checked) {
		objChk.checked = false;
	} else {
		objChk.checked = true;
	}
	updateSelection();
}
var newFKWindow = "";
function openFitKitDetails(fitkit) {
  if (!newFKWindow) {
  } else if (!newFKWindow.closed)	{
    newFKWindow.window.close();
  }
  if (fitkit == "1a") {
  	theFile = _rootDir+"include/GoFit-Ultimate-ProGym-In-A-Bag.htm";
  	height = 500;
  } else if (fitkit == "1b") {
  	theFile = _rootDir+"include/GoFit-Burst-Resistance-Exercise-Ball.htm";
  	height = 670;
  }
	newFKWindow = window.open(theFile,"FitnessKit",'scrollbars=no,toolbar=no,location=no,width=600,height='+height+',top='+(screen.height-height)/2+',left='+(screen.width-600)/2);
	newFKWindow.opener = this.window;
	if (!newFKWindow) {
		alert("Please enable popups to view the requested window.");
	} else {
		newFKWindow.focus();
	}
}
function selectFitnessKit(fitkit) {
	if (fitkit == 1) {
		if (!document.getElementById("divoCFitKit1").checked) {
			selectChk(document.getElementById("divoCFitKit1"));
		}
	} else if (fitkit == 2) {
		if (!document.getElementById("divoCFitKit2").checked) {
			selectChk(document.getElementById("divoCFitKit2"));
		}
	}
	newFKWindow.close();
}