	  //------------------------------//
	 // Init Functions and variables //
	//------------------------------//

	var pTrainerid;
	
	function setTrainerId(aTrainerid){
		pTrainerid = aTrainerid;
	}
		
	function NewWindow(mypage, myname, w, h, scroll) {
		var winl = (screen.width - w) / 2;
		var wint = (screen.height - h) / 4;
		winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no';
		win = window.open(mypage, myname, winprops);
		if (parseInt(navigator.appVersion) >= 4) { 
			//win.window.focus(); 
		}
	}

	// This calls a Page that will ensure that we keep logged in.
	function StayLoggedIn(){
		var url="KeepSession_AJAX.asp?sid="+Math.random()+"&type=KeepSession";
		xmlHttp=GetXmlHttpObject(dummyStayLoggedInFunction);
		xmlHttp.open("GET", url , true);
		xmlHttp.send(null);
		
		setTimeout("StayLoggedIn();", 10 * 60000);
	}

	// In this function the result of the StayLoggedIn-function is dumped.
	function dummyStayLoggedInFunction(){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
			// Get the AJAX Response
			// var pResponseText = xmlHttp.responseText;
			// Do Nothing
		}
	}
	


	  //----------------------//
	 // Navigation Functions //
	//----------------------//

	// Start of Header
	function GotoHome(){
		var pURL = "index.asp?id="+pTrainerid;
		window.location.href = pURL;
	}
	
	function GotoAboutUs(aAboutUsId){
		if (parseInt(aAboutUsId) == -10){
			var pURL = "TrainerContact_BioAndContact.asp?id="+pTrainerid;
		}
		else{
			var pURL = "TrainerContact_General.asp?id="+pTrainerid+"&EntryId="+aAboutUsId;
		}
		window.location.href = pURL;
	}
	
	function GotoMyPlan(){
		var pURL = "todaysPlan.asp?id="+pTrainerid;
		window.location.href = pURL;
	}
	
	function GotoMeals(){
		var pURL = "mealplan_schedule.asp?id="+pTrainerid;
		window.location.href = pURL;
	}
	
	function GotoResistance(){
		var pURL = "weighttraining_schedule.asp?id="+pTrainerid;
		window.location.href = pURL;
	}
	
	function GotoCardio(){
		var pURL = "cardio_schedule.asp?id="+pTrainerid;
		window.location.href = pURL;
	}
	
	function GotoZumba(){
		var pURL = "zumba_DB.asp?id="+pTrainerid;
		window.location.href = pURL;
	}
	
	function GotoCommunity(){
		var pURL = "community.asp?id="+pTrainerid;
		window.location.href = pURL;
	}
	
	function GotoCommunityAffiliates(aCategoryid){
		if (parseInt(aCategoryid) <= 0){
			var pURL = "Community_Affiliates.asp?id="+pTrainerid;
		}
		else{
			var pURL = "Community_Affiliates.asp?id="+pTrainerid+"&catid="+aCategoryid;
		}
		window.location.href = pURL;
	}
	
	function GotoCommunityLibrary(aCategoryid){
		if (parseInt(aCategoryid) <= 0){
			var pURL = "Community_Library.asp?id="+pTrainerid;
		}
		else{
			var pURL = "Community_Library.asp?id="+pTrainerid+"&catid="+aCategoryid;
		}
		window.location.href = pURL;
	}
	
	function GotoCommunityTestimonies(aCategoryid){
		if (parseInt(aCategoryid) <= 0){
			var pURL = "Community_Testimonies.asp?id="+pTrainerid;
		}
		else{
			var pURL = "Community_Testimonies.asp?id="+pTrainerid+"&catid="+aCategoryid;
		}
		window.location.href = pURL;
	}
	
	function GotoCommunityQAndA(aCategoryid){
		if (parseInt(aCategoryid) <= 0){
			var pURL = "Community_QandA.asp?id="+pTrainerid;
		}
		else{
			var pURL = "Community_QandA.asp?id="+pTrainerid+"&catid="+aCategoryid;
		}
		window.location.href = pURL;
	}
	
	function GotoCommunityPhotoGallery(){
		var pURL = "Community_PhotoGallery.asp?id="+pTrainerid;
		window.location.href = pURL;
	}
	
	function GotoCommunityFitnessTools(){
		var pURL = "Community_FitnessTools.asp?id="+pTrainerid;
		window.location.href = pURL;
	}
	
	function GotoMyCommunityPages(aCommunityPageId){
		var pURL = "Community_General.asp?id="+pTrainerid+"&entryId="+aCommunityPageId;
		window.location.href = pURL;
	}
	
	function GotoStore(aShopId){
		if (parseInt(aShopId) <= 0){
			var pURL = "shop_main.asp?id="+pTrainerid;
		}
		else{
			var pURL = "Shop_Main.asp?id="+pTrainerid+"&shop="+aShopId
		}
		window.location.href = pURL;
	}
	
	function GotMyAccount(){
			var pURL = "clientAccount.asp?id="+pTrainerid;
		window.location.href = pURL;
	}
	
	function GotoHelp(){
		var pURL = "HELP_frame.asp?id="+pTrainerid;
		NewWindow(pURL, "NWTPopup", 700, 500, 'yes');
	}
	// End of Header
	
	function LogOff(){
		var pURL = "log_off.asp?id="+pTrainerid;
		window.location.href = pURL;
	}
	
	function GotoRegistration(){
		var pURL = "register.asp?id="+pTrainerid;
		window.location.href = pURL;
	}
	
	function GotoVirtualTour(){
		var pURL = "virtualtour.asp?id="+pTrainerid;
		window.location.href = pURL;
	}
	
	function GotoFreeTrial(){
		var pURL = "Register.asp?id="+pTrainerid+"&freeconsult=1";
		window.location.href = pURL;
	}
	
	function GotoSignupHelp(){
		var pURL = "Login_Help.asp?id="+pTrainerid+"&freeconsult=1";
		window.location.href = pURL;
	}
	
	function ShowMessageContent(aMessageId){
		var pURL = "messages.asp?id="+pTrainerid+"&messageid="+aMessageId;
		window.location.href = pURL;
	}
	
	function GotoCharts(aChart){
		var pURL = "TrackResults_Chart.asp?id="+pTrainerid;
		window.location.href = pURL;
	}
	
	function GotoShoppingCart(){
		var pURL = "Shop_ShoppingCart.asp?id="+pTrainerid;
		window.location.href = pURL;
	}
	
	function GotoMonthlyOrder(){
		var pURL = "ClientAccount4.asp?id="+pTrainerid;
		window.location.href = pURL;
	}
	
	function GotoProduct(aProductId){
		var pURL = "Shop_ShowProduct.asp?id="+pTrainerid+"&productid="+aProductId;
		window.location.href = pURL;
	}

	function GotoWellnessProgram(){
		var pURL = "Shop_ShowWellnessProgram.asp?id="+pTrainerid;
		window.location.href = pURL;
	}
	
	function wellnessProgram_AddToMonthlyOrder(){
		var pURL = "clientAccount4.asp?id="+pTrainerid+"&type=wellnessprogram";
		window.location.href = pURL;
	}
	
	function wellnessProgram_AddToShoppingCart(){
		var pURL = "Shop_AddWellnessProgram.asp?id="+pTrainerid;
		window.location.href = pURL;
	}
	
	function shop_AddProductToMonthlyOrder(aProductId){
		var pURL = "clientAccount4.asp?id="+pTrainerid+"&type=addproduct&productid="+aProductId;
		window.location.href = pURL;
	}
	
	function shop_AddProductToShoppingCart(aProductId){
		pURL = "Shop_AddProduct.asp?id="+pTrainerid+"&prodid="+aProductId+"&size=-1&amount=1&ispackage=-1";
		NewWindow(pURL, 'NWTPopup', 400, 200, 'no');
	}
	
	function showTutorial(){
		pURL = "index.asp?id="+pTrainerid+"&showTutorial=1";
		window.location.href = pURL;
		return true;
	}

	function ShowMuscleGroups(){
		pURL = "Tutorial_HumanBody_MuscleGroups.asp?id="+pTrainerid;
		NewWindow(pURL, "NWTPopup", 720, 750, "no");	
	}
	
	function showTHRDiagram(){
		pURL = "hartchart.asp?id="+pTrainerid;
		NewWindow(pURL,'name','680','340','yes');
	}

	
	  //------------------//
	 // Header Functions //
	//------------------//
	
	function ShowMotivation(){
		//SlideMotivationOpen();
		var divMotivation = document.getElementById("divMotivation");
		divMotivation.style.display = "";
		divMotivation.style.visibility = "visible";
	}
	
	function HideMotivation(){
		//SlideMotivationClose();
		var divMotivation = document.getElementById("divMotivation");
		divMotivation.style.display = "NONE";
		divMotivation.style.visibility = "hidden";
	}



	  //------------------//
	 // Footer Functions //
	//------------------//
	
	function ShowTermsOfUse(){
		var pURL = "ShowUserMessage.asp?id="+pTrainerid+"&message=TermsOfUse";
		NewWindow(pURL, "NWTPopup", 650, 500, 'yes'); 
	}
	
	function ShowPrivacyPolicy(){
		var pURL = "ShowUserMessage.asp?id="+pTrainerid+"&message=PrivacyPolicy";
		NewWindow(pURL, "NWTPopup", 650, 500, 'yes');
	}
	
	function ShowUserAcknowledgement(){
		var pURL = "ShowUserMessage.asp?id="+pTrainerid+"&message=useracknowledgement";
		NewWindow(pURL, "NWTPopup", 650, 500, 'yes');
	}
	
	
	

	  //-------------------//
	 // Hompage Functions //
	//-------------------//

	function changeFrameHeight(aFrameName, aWindowHeight){
		window.document.getElementById(aFrameName).height	= aWindowHeight;
	}
		
	function PrintGroceryList(){
		var pStartDate	= getCurrentdate(0);
		var pEndDate	= getCurrentdate(6);
		
		PrintGroceryListDates(pStartDate, pEndDate);
	}
	
	function PrintGroceryListDates(aStartDate, aEndDate){
		pURL = "mealplan_grocerylist_print.asp?id="+pTrainerid+"&startdate="+aStartDate+"&enddate="+aEndDate;
		window.open(pURL,'NWTPrint','scrollbars=yes,menubar=yes,height=600,width=800,resizable=yes,toolbar=yes,location=yes,status=yes');
	}
	
	function PrintExerciseDemoList(){
		var pStartDate	= getCurrentdate(0);
		var pEndDate	= getCurrentdate(6);
		
		PrintExerciseDemoListDates(pStartDate, pEndDate)
	}
		
	function PrintExerciseDemoListDates(aStartDate, aEndDate){
		pURL = "weightTraining_ExerciseDemoList_print.asp?id="+pTrainerid+"&startdate="+aStartDate+"&enddate="+aEndDate;
		window.open(pURL,'NWTPrint','scrollbars=yes,menubar=yes,height=600,width=800,resizable=yes,toolbar=yes,location=yes,status=yes');
	}

	function LogMeasurements(){
		pURL = "personal_UpdateForm.asp?id="+pTrainerid;
		NewWindow(pURL, 'NWTPopup', '500', '500', 'yes');
	}
	
	function TrackResults(){
		pURL = "popupTrackResults.asp?id="+pTrainerid;
		NewWindow(pURL, 'NWTPopup', '500', '700', 'yes');
	}
	
	function CreateNewMealplan(){
		var pURL	= "mealplan.asp?id="+pTrainerid+"&wizardstatus=11";
		document.location.href = pURL
	}
	
	function EditExistingMealplan(){
		var pURL = "mealplan_SelectMealplan.asp?id="+pTrainerid+"&pWizardStatus=10";
		NewWindow(pURL, 'NWTPopup', 500,450,'no');
	}
	
	function ManageMyMealplan(){
		var pURL = "mealplan_Schedule.asp?id="+pTrainerid;
		document.location.href = pURL
	}
	
	function GotoFoodDatabase(){
		var pURL = "FoodDatabase.asp?id="+pTrainerid;
		document.location.href = pURL
	}
	
	function OpenExistingMealplan(aMealplanId){
		var pURL = "Mealplan.asp?id="+pTrainerid+"&mpid="+aMealplanId+"&wizardstatus=10";
		window.open(pURL,'NWTPrint','scrollbars=yes,menubar=yes,height=600,width=800,resizable=yes,toolbar=yes,location=yes,status=yes');
	}
	
	function CreateNewWTPlan(){
		var pURL = "weighttraining.asp?id="+pTrainerid+"&wizardstatus=11";
		document.location.href = pURL 
	}
	
	function EditExistingWTPlan(){
		var pURL = "weighttraining_SelectWorkout.asp?id="+pTrainerid+"&wizardstatus=10&date=";
		NewWindow(pURL, 'NWTPopup', 500,450,'no');	
	}
	
	function ManageMyWTPlan(){
		var pURL = "weighttraining_schedule.asp?id="+pTrainerid;
		document.location.href = pURL;
	}
	
	function OpenExistingWT(aWeightTrainingPlanId){
		var pURL = "weighttraining.asp?id="+pTrainerid+"&planid="+aWeightTrainingPlanId+"&actid=-1&wizardstatus=10"
		window.open(pURL,'NWTPrint','scrollbars=yes,menubar=yes,height=600,width=800,resizable=yes,toolbar=yes,location=yes,status=yes');
	}
	
	function GotoWTExerciseDatabase(){
		var pURL = "trainingDB.asp?id="+pTrainerid+"&navType=WT";
		document.location.href = pURL;
	}
	
	function CreateNewCardioPlan(){
		var pURL = "cardio_basic.asp?id="+pTrainerid+"&wizardstatus=11";
		document.location.href = pURL;
	}
	
	function EditExistingCardioPlan(){
		pURL = "agenda_cardio.asp?id="+pTrainerid+"&wizardstatus=20";
		NewWindow(pURL, 'NWTPopup', 600, 450, 'no');	
	}
	
	function ManageMyCardioPlan(){
		var pURL = "cardio_schedule.asp?id="+pTrainerid;
		document.location.href = pURL;
	}
	
	function GotoCardioExerciseDatabase(){
		var pURL = "trainingDB.asp?id="+pTrainerid+"&navType=CD";
		document.location.href = pURL;
	}
	
	function OpenExistingCardio(aCardioPlanId){
		var pURL = "cardio_basic.asp?id="+pTrainerid+"&planid="+aCardioPlanId+"&actid=-1&pos=0&wizardstatus=10"
		window.open(pURL,'NWTPrint','scrollbars=yes,menubar=yes,height=600,width=800,resizable=yes,toolbar=yes,location=yes,status=yes');
	}
	
	function GotoTodaysPlan(){
		var pURL = "todaysPlan.asp?id="+pTrainerid;
		document.location.href = pURL;
	}
	
	function GotoWeeklyGlance(){
		var pURL = "weeklyGlance.asp?id="+pTrainerid;
		document.location.href = pURL;
	}
	
	function GotoMonthlyGlance(){
		var pURL = "Calendar_General_Monthly.asp?id="+pTrainerid;
		document.location.href = pURL;
	}
	
	

	  //-------------------//
	 // General Functions //
	//-------------------//
	
	function getCurrentdate(aDaysAdded){
		var now		= new Date(new Date().getTime() + (parseInt(aDaysAdded)*24*60*60*1000));
		nowDate 	= now.getDate();
		nowMonth	= now.getMonth() + 1;
		nowYear 	= now.getYear();
		if (parseInt(nowYear) < 1900) {	nowYear += 1900; }
		
		return nowYear + "-" + nowMonth + "-" + nowDate;
	}
	
	function getSelectedOption(aRadioButton){
		var pReturn, pIndex

		pReturn = null;
		
		for(pIndex=0; pIndex < aRadioButton.length; pIndex++){
			if (aRadioButton[pIndex].checked)
				pReturn = aRadioButton[pIndex];
		}
		
		return pReturn;
	}
	