
function InputAuthenticate(form1)
		{
	//This function is responsible for validating the form data (and either making approppriate calculations or calling out to cache routines to do so)
       //Once validation has occured the form will be "submitted"
			
			
			if (window.document.form1.LMFacilityCaseCount.value < 1)
			{
				alert("You must select an approximate case count")
				return false
							}
			else
			{
			
			}
			
				if (window.document.form1.LMHourlyWage.value < 1)
			{
				alert("You must select survey administrator's hourly wage")
				return false
							}
			else
			{
					
			}
			

			if (window.document.form1.DistributionMethod.value < 0)
			{	
				alert("you must select a distribution method")
				return false
			}
			else
				{
				
				}	

			

			//alert(form1.RadioGroup2.length);
			if 
				((form1.RadioGroup2[0].checked) || 
				 (form1.RadioGroup2[1].checked) ||
				 (form1.RadioGroup2[2].checked) || 
				 (form1.RadioGroup2[3].checked) ||
				 (form1.RadioGroup2[4].checked) ||
				 (form1.RadioGroup2[5].checked)) 
			{
			
			}
			else
			{
				alert("CTQ Online/Paper Mix needs to be selected")
				return false
			}
			
			
	// test for legitimate combinations of online/paper mix		
	//		if 	(form1.RadioGroup2[5].checked)
	//		{
	//		CustomButtonTest(); 
	//		}
			
			if ((form1.RadioGroup2[5].checked) &&
			   (form1.select.value/100) + (window.document.form1.select2.value/100) > 1)
				{	
					alert("the online + paper percentage cannot exceed 100%");
					return false
				}
		
			if ((form1.RadioGroup2[5].checked) &&
			    ((form1.select.value/100) + (window.document.form1.select2.value/100) <.39))
			{
				alert("A meaningful sample requires your combined online and paper candidates to exceed 40% ");
				return false
				}
				
				
			DataManipulation();	
				}
			
			
				
function DataManipulation()
{ 
			InternalYesNoOnComments();
		
		RadioButtons();
	
			ProjectedSurveysCompleted();
			ProjectedAnnualCost();
			CTQSurveyCalculations();
			
}


function CustomButtonTest()
{

if (window.document.form1.RadioGroup2(5).checked) 
			 {
	
			 }
			 if((window.document.form1.select.value/100) + (window.document.form1.select2.value/100) > 1)
			 	{
					alert("the online + paper percentage cannot exceed 100%");
					return false
				}
			else
				{
			
				}
				if((window.document.form1.select.value/100) + (window.document.form1.select2.value/100) <.39)
				{
				alert("your combined online + paper percentage should be at least 40% to be meaningful in this comparison");
				return false
				}
				else
				{
			
				}			
	
}

function InternalYesNoOnComments()
{
// The value is assigned a one or zero which is used to calculate additional time required
// for collecting and reporting on the comments
}

function RadioButtons()
{ 
if (window.document.form1.RadioGroup2[0].checked)
		{
			OnlinePercentage=1;
			PaperPercentage=0;
		}    
if (window.document.form1.RadioGroup2[1].checked)
		{
			OnlinePercentage=.75;
			PaperPercentage=.25;
				}
if(window.document.form1.RadioGroup2[2].checked)
		{
			
			OnlinePercentage=.50;
		  	PaperPercentage=.50;
						}	
if(window.document.form1.RadioGroup2[3].checked)
		{
			OnlinePercentage=.25;
		  	PaperPercentage=.75;
							}	
if(window.document.form1.RadioGroup2[4].checked)
		{
			OnlinePercentage=0;
		  	PaperPercentage=1;	
								}
							
if(window.document.form1.RadioGroup2[5].checked)
		{
		OnlinePercentage = (window.document.form1.select.value/100);
		PaperPercentage = (window.document.form1.select2.value/100);
		if(OnlinePercentage + PaperPercentage > 1)
			{
			alert("the online + paper percentage cannot exceed 100%");
			}
		
			
								}
}


function RoundingData(a,b)
{
var returnValue2;
returnValue2 = 0;
returnValue2 = a/b;
returnValue2=(returnValue2*100);
returnValue2=(Math.round(returnValue2));
returnValue2=(returnValue2/100);
var result = returnValue2;
return result;

}

function HelpValues()
{
alert("Thanks for using the ROI calulator.  There are four required inputs:\n\n(1) Annual Case Count - This is an estimate of your annual number of cases. \n\n(2) Mean Surveyor Wage - This is your average wage for all people included in the surveying process - from distribution to collection to tabulation.\n\n(3) Distribution - for your current survey process are you handing them out internally or are you mailing the surveys to your patients?  If you are not currently surveying, kindly select 'handing out'.\n\n(4) The CTQ Online/Paper Mix is provided to allow you to simulate various scenarious that you envision may reflect use of the CTQ service.  \nFor example, what percentage of your client population do you believe would furnish email addresses as you will receive a higher response through online surveys.  For sampling simulation help, click on 'Customize Sampling' to extend your 'what if' capabilities to Sampling")	
return false;
}

function CustomizedHelp()
{
alert("The 'Customize' button provides you the opportunity to simulate CTQ sampling.  Once you have run a standard ROI comparison you will be provided with your current projected costs, as well as surveys returned.  The corresponding CTQ results will always provide more responses at a lower cost. \n\nIn the event that you select 0% online for CTQ, you will see the same number of survey responses, yet note the cost reduction.  As you review the comparison, you may want to take advantage of the patient intelligence provided by the CTQ increase in survey responses.  However, you may determine that for your needs (and budget) that a total response level somewhere between your current response rate and higher CTQ levels are 'meaningful enough' - at least for your initial targets.\n\nYou may adjust the online and paper percentages as many times as you wish and view the result differences until the number of surveys and cost suit your needs.  CTQ will be glad to share more with you about sampling and how to make effective.  This also allows you flexibility to choose mixes other than the four provided in the button selections above.  Please be aware that your facility numbers will remain the same throughout the custom simulation.  Only the CTQ numbers will change.")	
}

function CTQBenefits()
{
window.location="http://www.ctqsolutions.com/csp/ctqprod/Features.html";
}
function CTQSurveyReport()
{  
window.location="http://www.ctqsolutions.com/csp/ctqprod/CTQTakeSurvey.csp";

}

function MoreAboutROI()
{
window.location="http://www.ctqsolutions.com/csp/ctqprod/MoreAboutROI.pdf" target=new;
}

function ProjectedSurveysCompleted()
{ 
//form1.AnnualSurveys.value = (form1.LMFacilityCaseCount.value);
window.document.form1.TxtFldInHouseSurveysCompleted.value = (window.document.form1.LMFacilityCaseCount.value * .25);
window.document.form1.TxtFldInHouseSurveysCompleted.readOnly = true;
}

function ProjectedAnnualCost()
{ 
//
//  In House Calculations - note that handed out or mailed determines the cost of total postage;  if the 
//  surveys are handed out, then there is only a cost for the stamp on the return envelope.  This also holds 
//  true for the cost of outgoing envelopes.
//  
//  
///////  Annual Cost Calculation
///////  
window.document.form1.TxtFldInHouseAnnualCost.value = 
// Postage - the first postage component is always used, unless they are having the people fill out the surveys
// and returning at time of discharge - which is easier to argue against anyway - lack of best practice
// 
((window.document.form1.LMFacilityCaseCount.value * .41)+
//
// outgoing envelopes and postage - only included if they mail out the surveys;  
// 448.50 + 20 for windows + 75 custom charge = 543;  additional envelopes are $.12/each 
//
((543.50 + (window.document.form1.LMFacilityCaseCount.value - 500) * .12) * (window.document.form1.DistributionMethod.value)) +
// Return envelopes
// 448.50 + additional envelopes are $.11/each 
// 
(448.50 + ((window.document.form1.LMFacilityCaseCount.value - 500) * .11) * (window.document.form1.DistributionMethod.value)) +
// Letterhead
(window.document.form1.LMFacilityCaseCount.value * .16) +
// Preprinted survey forms
(window.document.form1.LMFacilityCaseCount.value * .50) +
// Avery Labels
// 
(window.document.form1.LMFacilityCaseCount.value * .03) +
// Labor for Distributing
//
(window.document.form1.LMFacilityCaseCount.value * window.document.form1.LMHourlyWage.value / 60) +
//
//  add back additional incremental cost for distributing surveys inhouse
((window.document.form1.LMFacilityCaseCount.value * window.document.form1.LMHourlyWage.value / 30) * (1.1 - window.document.form1.DistributionMethod.value)) +
//
//
//  add time for mailing
((window.document.form1.LMFacilityCaseCount.value * window.document.form1.LMHourlyWage.value / 60) * (window.document.form1.DistributionMethod.value)) +
//
//
// Labor for Receiving and Summarizing
(window.document.form1.TxtFldInHouseSurveysCompleted.value * window.document.form1.LMHourlyWage.value / 15 )+
//
//  Labor to account for collecting and reporting on freeform text
(window.document.form1.LMFreeFormText.value * window.document.form1.TxtFldInHouseSurveysCompleted.value * window.document.form1.LMHourlyWage.value / 12)
)
//
var returnValue = RoundingData(window.document.form1.TxtFldInHouseAnnualCost.value,1);
window.document.form1.TxtFldInHouseAnnualCost.value = returnValue;
var returnValue5;
returnValue5=(Math.round(window.document.form1.TxtFldInHouseAnnualCost.value));
window.document.form1.TxtFldInHouseAnnualCost.value = returnValue5;
window.document.form1.TxtFldInHouseAnnualCost.readOnly = true;



//Cost Per Survey In House
//
//form1.TxtFldInHouseCostPerSurvey.value = (window.document.form1.TxtFldInHouseAnnualCost.value/window.document.form1.TxtFldInHouseSurveysCompleted.value);

var returnValue = RoundingData(window.document.form1.TxtFldInHouseAnnualCost.value,window.document.form1.TxtFldInHouseSurveysCompleted.value);

window.document.form1.TxtFldInHouseCostPerSurvey.value = returnValue;
window.document.form1.TxtFldInHouseCostPerSurvey.readOnly = true
}

//
//  CTQ Calculations
//


function CTQSurveyCalculations()
{ 
//  CTQ Survey Response Count
//  
window.document.form1.TxtFldICTQSurveys.value = ((window.document.form1.LMFacilityCaseCount.value*OnlinePercentage*.60)+(window.document.form1.LMFacilityCaseCount.value*PaperPercentage*.25));
var returnValue = RoundingData(window.document.form1.TxtFldICTQSurveys.value,1);
window.document.form1.TxtFldICTQSurveys.readOnly = returnValue;
var returnValue4;
returnValue4=(Math.round(window.document.form1.TxtFldICTQSurveys.value));
window.document.form1.TxtFldICTQSurveys.value = returnValue4;
window.document.form1.TxtFldICTQSurveys.readOnly = true;
//
// Calculation for CTQ Annual Survey Cost
//
window.document.form1.TxtFldCTQAnnualCost.value = (
(696) +
//  Annual Subscription fee + email request forms (Removed email request form fees on 10/6/2007 pgf
//
//  Preprinted surveys and envelopes
(window.document.form1.TxtFldICTQSurveys.value * .36 * PaperPercentage) +
//
//  Facility Labor for handling paper
//  
(window.document.form1.TxtFldICTQSurveys.value * PaperPercentage * window.document.form1.LMHourlyWage.value / 60) +
//
//labor for collecting email addresses
(window.document.form1.TxtFldICTQSurveys.value * window.document.form1.LMHourlyWage.value / 120 * OnlinePercentage) +
//
//  paper transaction cost - increased paper fees to 2.85 on 10/6/2007 pgf and online to 1.95
//  
(window.document.form1.LMFacilityCaseCount.value * PaperPercentage * .25 * 2.85) +
//  
//  online transaction cost
(window.document.form1.LMFacilityCaseCount.value * OnlinePercentage * .60 * 1.95)+
//
//   Outbound postage
(window.document.form1.LMFacilityCaseCount.value * PaperPercentage * .41) +
//
//   Return postage
//   
(window.document.form1.LMFacilityCaseCount.value * PaperPercentage * .25 * .41)
)
var returnValue = RoundingData(window.document.form1.TxtFldCTQAnnualCost.value,1);
window.document.form1.TxtFldCTQAnnualCost.value = returnValue;
var returnValue3;
returnValue3=(Math.round(window.document.form1.TxtFldCTQAnnualCost.value));
window.document.form1.TxtFldCTQAnnualCost.value = returnValue3;
window.document.form1.TxtFldCTQAnnualCost.readOnly = true;
//
//  Cost per CTQ Survey Calculation
//  
//form1.TxtFldCTQCostPerSurvey.value = (form1.TxtFldCTQAnnualCost.value / window.document.form1.TxtFldICTQSurveys.value);
var returnValue = RoundingData(window.document.form1.TxtFldCTQAnnualCost.value,window.document.form1.TxtFldICTQSurveys.value);
window.document.form1.TxtFldCTQCostPerSurvey.value = returnValue;
window.document.form1.TxtFldCTQCostPerSurvey.readOnly = true;
//
//form1.OnlinePercentage.value = (OnlinePercentage*100) + "%";
//form1.OnlinePercentage.readOnly = true;
//
//form1.PaperPercentage.value = (PaperPercentage*100) + "%";
//form1.PaperPercentage.readOnly = true;
//
window.document.form1.TxtFldSurveysCompletedIncrease.value = (window.document.form1.TxtFldICTQSurveys.value - window.document.form1.TxtFldInHouseSurveysCompleted.value);
window.document.form1.TxtFldSurveysCompletedIncrease.readOnly = true;
//
window.document.form1.TxtFldCostSavings.value = (window.document.form1.TxtFldInHouseAnnualCost.value - window.document.form1.TxtFldCTQAnnualCost.value);
var returnValue = RoundingData(window.document.form1.TxtFldCostSavings.value,1);
window.document.form1.TxtFldCostSavings.value = returnValue;
window.document.form1.TxtFldCostSavings.readOnly = true;
//
//form1.TxtFieldPercentageCostSavings.value = (form1.TxtFldSurveysCompletedIncrease.value / window.document.form1.TxtFldICTQSurveys.value);
var returnValue = RoundingData(window.document.form1.TxtFldCostSavings.value,window.document.form1.TxtFldInHouseAnnualCost.value);
window.document.form1.TxtFieldPercentageCostSavings.value = returnValue;
window.document.form1.TxtFieldPercentageCostSavings.value = (window.document.form1.TxtFieldPercentageCostSavings.value * 100)
var returnValue7;
returnValue7=(Math.round(window.document.form1.TxtFieldPercentageCostSavings.value));
window.document.form1.TxtFieldPercentageCostSavings.value = returnValue7;
window.document.form1.TxtFieldPercentageCostSavings.readOnly = true; 
//
//
//   
window.document.form1.TxtFldEmpTimeSaved.value = (((window.document.form1.LMFacilityCaseCount.value * 5.0) + (window.document.form1.LMFacilityCaseCount.value * 5.0 * window.document.form1.LMFreeFormText.value)   - (window.document.form1.TxtFldICTQSurveys.value * 1.5) + (window.document.form1.LMFacilityCaseCount.value * window.document.form1.DistributionMethod.value * 1.5))/60)
var returnValue = RoundingData(window.document.form1.TxtFldEmpTimeSaved.value,1);
window.document.form1.TxtFldEmpTimeSaved.value = returnValue;
var returnValue6;
returnValue6=(Math.round(window.document.form1.TxtFldEmpTimeSaved.value));
window.document.form1.TxtFldEmpTimeSaved.value = returnValue6;
window.document.form1.TxtFldEmpTimeSaved.readOnly = true;
}

function ClearOutputCells()
{
window.document.form1.TxtFieldPercentageCostSavings.value = "";	
window.document.form1.TxtFldCostSavings.value = "";
window.document.form1.TxtFldEmpTimeSaved.value = "";
window.document.form1.TxtFldSurveysCompletedIncrease.value = "";
window.document.form1.TxtFldCTQAnnualCost.value = "";	
window.document.form1.TxtFldInHouseCostPerSurvey.value = "";
window.document.form1.TxtFldInHouseSurveysCompleted.value = "";
window.document.form1.TxtFldInHouseAnnualCost.value = "";
window.document.form1.TxtFldCTQCostPerSurvey.value = ""
window.document.form1.TxtFldICTQSurveys.value = "";
}
