﻿/* * * * * * * * * * * * * * * *
*  Product Finder: started Jwood(10112007) completed Jwood(10182007)
*  Summary: This is a modified 
*  version of the Quiz game to 
*  accodomate Emdeon's request for   
*  a product finder. This system
*  derives a list of products based
*  on the answers given
* * * * * * * * * * * * * * * */
// BrowserCompatibility Functions
/* * * * * * * * * * * * * * *
* createNamedInput
* @type: refers to the type of input 
* @name: the name to set to the dynamically generated control
* #Summary
* Due to browser incapatibility, this function was needed to be able to 
* set an element's name dynamically
* * * * * * * * * * * * * * */
document.createNamedInput = function ( type, name )
{
	var element;
	try
	{
		element = document.createElement( '<input name="'+name+'" type="'+type+'">' );
	}
	catch ( e ) 
	{
	}
	if ( !element || !element.name ) 
	{ // Not in IE, then
		element = document.createElement( 'input' );
		element.setAttribute( 'type', type );
		element.name = name;
	}
	return element;
}
// Question Storage -------------------------------------------------------------------
quiz = new Object();
quiz.questions = new Array();
/* * * * * * * * * * * * * * *
* In the first question, the customer can choose from more than one need to be helped with
* The choices in the first question decide which products will be the most useful to the consumer
* The products are represented in 13 element array:
* Office, Assistant, POS, ClinicianRX, Claim Master, Payment Manager, ExpressBill Services, Address Correction Services
* Online Bill Presentment Online Bill Payment, eArchive/CD Archive, Electronic Lockbox Services, Patient Communications
* * * * * * * * * * * * * * */
quiz.questions[0] = new Object();
quiz.questions[0].answers = new Array();
quiz.questions[0].oneAnswer = false;
quiz.questions[0].text = "I want help with (check all that apply):";
quiz.questions[0].applicability = new Array(1,1,1,1,1,1,1,1,1,1,1,1,1);
quiz.questions[0].answers = new Array();
quiz.questions[0].answers[0] = new Object();
quiz.questions[0].answers[0].text = "Eligibility checking, processing referrals, or claim status inquiry";
quiz.questions[0].answers[0].products = new Array(1,1,1,0,0,0,0,0,0,0,0,0,0);
quiz.questions[0].answers[1] = new Object();
quiz.questions[0].answers[1].text = "Claim submission and claim tracking";
quiz.questions[0].answers[1].products = new Array(1,0,0,0,1,0,0,0,0,0,0,0,0);
quiz.questions[0].answers[2] = new Object();
quiz.questions[0].answers[2].text = "Secondary claim submission";
quiz.questions[0].answers[2].products = new Array(1,0,0,0,1,0,0,0,0,0,0,0,0);
quiz.questions[0].answers[3] = new Object();
quiz.questions[0].answers[3].text = "Managing denied claims";
quiz.questions[0].answers[3].products = new Array(1,0,0,0,1,0,0,0,0,0,0,0,0);
quiz.questions[0].answers[4] = new Object();
quiz.questions[0].answers[4].text = "Electronic Remittance Advice (ERA)";
quiz.questions[0].answers[4].products = new Array(0,0,0,0,0,1,0,0,0,0,0,0,0);
quiz.questions[0].answers[5] = new Object();
quiz.questions[0].answers[5].text = "Electronic Funds Transfer (EFT)";
quiz.questions[0].answers[5].products = new Array(0,0,0,0,0,1,0,0,0,0,0,0,0);
quiz.questions[0].answers[6] = new Object();
quiz.questions[0].answers[6].text = "Patient billing and payment";
quiz.questions[0].answers[6].products = new Array(0,0,0,0,0,0,1,1,1,1,1,1,1);
quiz.questions[0].answers[7] = new Object();
quiz.questions[0].answers[7].text= "Lab reporting and electronic prescribing";
quiz.questions[0].answers[7].products = new Array(0,0,0,1,0,0,0,0,0,0,0,0,0);
quiz.questions[1] = new Object();
quiz.questions[1].oneAnswer = true;
quiz.questions[1].applicability = new Array(1,1,1,0,1,1,1,1,1,1,1,1,1);
quiz.questions[1].text = "How many physicians are in your office?";
quiz.questions[1].answers = new Array();
quiz.questions[1].answers[0] = new Object();
quiz.questions[1].answers[0].text = "1-15";
quiz.questions[1].answers[0].filter = new Array(1,0,1,0,0,1,1,1,1,1,1,1,1);
quiz.questions[1].answers[1] = new Object();
quiz.questions[1].answers[1].text = "16+";
quiz.questions[1].answers[1].filter = new Array(0,1,0,1,1,1,1,1,1,1,1,1,1);
quiz.questions[2] = new Object();
quiz.questions[2].answers = new Array();
quiz.questions[2].oneAnswer = true;
quiz.questions[2].applicability = new Array(1,0,0,0,1,0,0,0,0,0,0,0,0);
quiz.questions[2].text = "Do you submit HCFA 1500 forms and/or UB92 forms?";
quiz.questions[2].answers[0] = new Object();
quiz.questions[2].answers[0].text = "HCFA 1500 forms only";
quiz.questions[2].answers[0].filter = new Array(1,0,0,0,1,0,0,0,0,0,0,0,0);
quiz.questions[2].answers[1] = new Object();
quiz.questions[2].answers[1].text = "UB92 forms only";
quiz.questions[2].answers[1].filter = new Array(0,0,0,0,1,0,0,0,0,0,0,0,0);
quiz.questions[2].answers[2] = new Object();
quiz.questions[2].answers[2].text = "HCFA 1500 forms and UB92 forms";
quiz.questions[2].answers[2].filter = new Array(1,0,0,0,1,0,0,0,0,0,0,0,0); //6-24: was Array(0,0,0,0,1,0,0,0,0,0,0,0,0)
quiz.questions[3] = new Object();
quiz.questions[3].answers = new Array();
quiz.questions[3].oneAnswer = true;
quiz.questions[3].applicability = new Array(1,0,1,1,1,1,1,1,1,1,1,1,1);
quiz.questions[3].text = "Do you have internet access?";
quiz.questions[3].answers[0] = new Object();
quiz.questions[3].answers[0].text = "yes";
quiz.questions[3].answers[0].filter = new Array(1,0,0,1,1,1,1,1,1,1,1,1,1);
quiz.questions[3].answers[1] = new Object();
quiz.questions[3].answers[1].text = "no";
quiz.questions[3].answers[1].filter = new Array(0,0,1,0,0,0,1,1,0,0,1,1,1);
//// Globals ----------------------------------------------------------------------------
/* * * * * * * * * * * * * * *
 * All linkage to the actual page will happen here.
	* simply enter the id of the control and you're set
 * * * * * * * * * * * * * * */
	//Page Linkage-----------------------------------------
var next = document.getElementById("htmlBtnNext");
var form = document.getElementById("form");
var questionContainer = document.getElementById("questionContainer");
var questionLabel = new Array();
var htmlSubmit = document.getElementById("htmlSubmit");
//var redirect = document.getElementById("redirect");
//var startOver = document.getElementById("startover");
//var answerContainer = document.getElementById("answerContainer");
//Dynamic Page Elements-----------------------------------------
//var response = new Array();
var question = new Array();
var answerContainer = new Array();
var responseLabel = new Array();     // responseLabel is used to display the text for the actual response control 
var responseControl = new Array();   // the control linked to the response 
var tdresponseControl = new Array();
var tdresponseLabel = new Array();
//Utility Variables-----------------------------------------
var qNumMax = quiz.questions.length;
var qNum = -1;
recommendation = new Array(0,0,0,0,0,0,0,0,0,0,0,0,0);
resolvedRecommendations = new Array();

var myRecommendations = '';

var doNotFilter = false;
//Event Hook up-----------------------------------------
next.onclick = test;
//Debugging ------------------------------
var clear = document.getElementById("htmlBtnClear");
var debug = document.getElementById("debug");
clear.onclick = clearDebug;
/* * * * * * * * * * * * * * *
* trace
* @message: description.
* #Summary
* * * * * * * * * * * * * * */
function trace ( message )
{
	/*var newText = document.createTextNode( message );
	debug.appendChild(newText);
	var breakTag = document.createElement('br');
	debug.appendChild( breakTag );*/
}
function clearDebug()
{
	debug.removeChild( firstChild );
}
/* * * * * * * * * * * * * * *
  * test()
	* #Summary
	* This function is linked to a button event so that peices of code can be tested.
	* * * * * * * * * * * * * * */
trace("__________________________________________________________");
trace("Debug");
//startOver.style.display = "none";
test();
function test()
{
	trace("__________________________________________________________");
	trace("Test Called: "+qNum);
	
	switch(qNum)
	{
		case -1: 
			trace("--Initialization stage--");
			qNum++;
			trace("qNum = "+qNum);
			nextQuestion();
			break;
		case 0:
			trace("--Data Combining stage--");
			//startOver.style.display = "";
			disableResponses();
			combineChoices();
			qNum++;
			nextQuestion();
			break;
		default:
			if  ( (qNum == 1) || (qNum == 2) )
			{
				trace("--Data Filtering stage--");
				if ( !doNotFilter )
				{
					disableResponses();
					trace("About to filter...");
					filterChoices();
					trace("Choices FILTERED!");
				}
				else
				{
					trace('Inapplicable question, skipping Question '+qNum);
					doNotFilter = false;
				}
				qNum++;
				nextQuestion();	
			}
			else
			{
				var myShowMeProductsLink = document.getElementById('showMeProductsLink');;
				myShowMeProductsLink.style.display = ""
				trace("--Results stage--");
				disableResponses();
				filterChoices();
				resolveRecommendations();
				trace("recommendation = "+recommendation);
				next.style.display = "none";
				if( hasResults() )
				{
					addProductResults();
				}
				else
				{
					showNoProduct();
				}
			}
	}
}
/* * * * * * * * * * * * * * *
* hasResults
* #Summary
* * * * * * * * * * * * * * */
function hasResults()
{
	for( var i = 0; i < recommendation.length; i++ )
	{
		if (recommendation[i])
		{
			return true;
		}
	}
	return false;
}
 /* * * * * * * * * * * * * * *
  * hide
		* @element
		* @bool
		* #Summary
  * * * * * * * * * * * * * * */
function hide(element, bool)
{
	if(bool)
	{
		document.getElementById(element).style.display = "none";
	}
	else
	{
		document.getElementById(element).style.display = "";
	}
}
/* * * * * * * * * * * * * * *
* nextQuestion()
* #Summary
* Initializes the product finder by showing the first question, 
* populating the answer container with responses and also 
* setting the flag for the first question.
* * * * * * * * * * * * * * */
function nextQuestion()
{ 
	//trace("__________________________________________________________");
	trace("NextQuestion()");
	next.disabled = true;
	if ( isNextQuestionApplicable() )
	{
		displayQuestion();
	}
	else
	{
		//qNum++;	
		doNotFilter = true;
		test();
	}
}
/* * * * * * * * * * * * * * *
* isNextQuestionApplicable()
* #Summary
* * * * * * * * * * * * * * */
function isNextQuestionApplicable()
{
	trace("isNextQuestionApplicable()");
	var isApplicable = false;
	trace(" Recommendation = "+recommendation)
	trace("Applicability = "+quiz.questions[qNum].applicability);
	if ( recommendation.length == quiz.questions[qNum].applicability.length )
	{
		if ( qNum > 0 )
		{
			for ( var i = 0; i < recommendation.length; i++ )
			{
				if ( recommendation[i] == 1 &&  quiz.questions[qNum].applicability[i] == 1 )
				{
					isApplicable = true;
					break;
				}
			}
		}
		else
		{
			isApplicable = true;
		}
	}
	else
	{
		trace("isApplicable = "+isApplicable);
		return;
	}
	trace("isApplicable = "+isApplicable);
	return isApplicable;
}
 /* * * * * * * * * * * * * * *
* displayQuestion()
* #Summary
* * * * * * * * * * * * * * */
function displayQuestion()
{
	trace("displayQuestion()");
	//	question.firstChild.nodeValue = quiz.questions[qNum].text;
	addQuestion();
	addResponses();
}
/* * * * * * * * * * * * * * *
* addQuestion()
* @parameter: desctiption.
* @parameter: description.
* #Summary
* * * * * * * * * * * * * * */
function addQuestion()
{
	trace("addQuestion()");
	question[qNum] = document.createElement('div');
	trace("new Div created in question["+qNum+"]");
	questionText = document.createTextNode(quiz.questions[qNum].text);
	trace("textNode create in question text = "+quiz.questions[qNum].text);
	question[qNum].appendChild(questionText);
	trace("questiontext appened to question["+qNum+"]");
	question[qNum].id = "questionText"+qNum;
	questionContainer.appendChild( question[qNum] );
	trace("question["+qNum+"] appended to questionContainer ");
}
/* * * * * * * * * * * * * * *
* addResponses()
* #Summary
* Fills the answerContainer with responses
* * * * * * * * * * * * * * */
function addResponses()
{
	//alert("addResponses()");
	var type;
	if ( quiz.questions[qNum].oneAnswer )
	{
		type = 'radio';
	}
	else
	{
		type = 'checkbox';
	}
	answerContainer[qNum] = document.createElement('div');
	answerContainer[qNum].id = "answerContainer";
	questionContainer.appendChild(answerContainer[qNum]);
	answerContainer[qNum].appendChild( drawGrid( quiz.questions[qNum].answers.length, 2 ) );
	responseControl = new Array();
	trace("quiz.questions[qNum].answers.length = "+quiz.questions[qNum].answers.length);
	for ( var i = 0; i < quiz.questions[qNum].answers.length; i++ )
	{
		trace('generating response:'+i);
		responseLabel[i] = document.createTextNode( quiz.questions[qNum].answers[i].text );
		responseControl[i] = document.createNamedInput( type, 'responses'+qNum );
		responseControl[i].className = "ctrl_response";
		if( type == 'radio')
		{
			responseControl[i].name = "ctrl_response_"+qNum;
		}
		else
		{
			responseControl[i].name = "ctrl_response_"+qNum+"_"+i;
		}
		responseControl[i].value = quiz.questions[qNum].answers[i].text;
		responseControl[i].id = "ctrl_response_"+qNum+"_"+i;
		responseControl[i].onclick = function ()
		{
			next.disabled = false;
		}
		tdresponseControl[i].appendChild( responseControl[i] );
		tdresponseLabel[i].appendChild( responseLabel[i] );
		tdresponseLabel[i].className = "tdresponse";
	}
}
/* * * * * * * * * * * * * * *
* drawGrid
* @rows: desctiption.
* @cols: description.
* #Summary
* * * * * * * * * * * * * * */
function drawGrid( rows, cols )
{
	trace("drawGrid("+rows+","+cols+")");
	oTbl = document.createElement( "Table" );
	oTbl.className = "responseTable";
	for( var  i = 0; i < rows; i++ )
	{
		oTR= oTbl.insertRow( i );
		for(var j = 0; j < cols; j++ )
		{
			if( j == 0 )
			{
				tdresponseControl[i] = oTR.insertCell(j);
				tdresponseControl[i].className = "tdrResponseCell";
			}
			else
			{
				tdresponseLabel[i] = oTR.insertCell(j);
				tdresponseLabel[i].className = "tdrResponseCell";
			}
		}
	}
	return oTbl;
}
/* * * * * * * * * * * * * * **************************************************************************************************^^^^^
* disableResponses()
* #Summary
* * * * * * * * * * * * * * */
function disableResponses()
{
	trace("disableResponses();");
	for( var i = 0; i < responseControl.length; i++ ) 
	{
		//responseControl[i].disabled = true;
		if(responseControl[i].checked == false)
		{
			tdresponseLabel[i].style.display = "none";
			responseControl[i].style.display = "none";
		}
	}	
}
/* * * * * * * * * * * * * * *
* contentDump()
* #Summary
* Displays all the text info contained in the quiz object.
* * * * * * * * * * * * * * */
function contentDump()
{
	for(i = 0; i < quiz.questions.length; i++)
	{
		document.write(quiz.questions[i].text+"<br />");
		for(j = 0;j < quiz.questions[i].answers.length; j++)
		{
			document.write(quiz.questions[i].answers[j].text+"<br />");
		}
	}
}
/* * * * * * * * * * * * * * *
* combineChoices()
* #Summary
* * * * * * * * * * * * * * */
function combineChoices()
{
	trace("combineChoices()");
	for ( var i = 0; i < responseControl.length; i++ )
	{
		if (	responseControl[i].checked )
		{
			recommendation = combineArrays(quiz.questions[qNum].answers[i].products, recommendation);
		}
	}
}
/* * * * * * * * * * * * * * *
* filterChoices()
* #Summary
* * * * * * * * * * * * * * */
function filterChoices()
{
	trace("filterChoices(), "+responseControl.length+" controls total");
	for ( var i = 0; i < responseControl.length; i++ )
	{
		if (responseControl[i].checked )
		{
			try
			{
			trace("responseControl["+i+".checked = "+responseControl[i].checked );
			recommendation = filterArrays(recommendation, quiz.questions[qNum].answers[i].filter, quiz.questions[qNum].applicability);
			trace("recommendation is now: "+recommendation);												
			}
			catch(e)
			{
			}
		}
		else
		{
			trace("responseControl["+i+".checked = "+responseControl[i].checked );
		}
	}
	trace("Exiting filterChoices();");
}
/* * * * * * * * * * * * * * *
* resolveRecommendations
* #Summary
* * * * * * * * * * * * * * */
function resolveRecommendations()
{
	trace("resolveRecommendations()");
	resolvedRecommendations = new Array();	
	for ( var i = 0; i < recommendation.length; i++ )
	{
		switch(i)
		{
			case 0:
				if ( recommendation[i] )
				{
					resolvedRecommendations.push("Emdeon Office");
				}
				break;
			case 1:
				if ( recommendation[i] )
				{
					resolvedRecommendations.push("Emdeon Assistant");
				}
				break;
			case 2:
				if ( recommendation[i] )
				{
					resolvedRecommendations.push("Emdeon POS");
				}
				break;
			case 3:
				if ( recommendation[i] )
				{
					resolvedRecommendations.push("Emdeon ClinicianRX");
				}
				break;
			case 4:
				if ( recommendation[i] )
				{
					resolvedRecommendations.push("Emdeon Claim Master");
				}
				break;
			case 5:
				if ( recommendation[i] )
				{
					resolvedRecommendations.push("Emdeon Payment Manager");
				}
				break;
			case 6:
				if ( recommendation[i] )
				{
					resolvedRecommendations.push("Emdeon ExpressBill Services");
				}
				break;
			case 7:
				if ( recommendation[i] )
				{
					resolvedRecommendations.push("Emdeon Return Mail Manager");
				}
				break;
			case 8:
				if ( recommendation[i] )
				{
					resolvedRecommendations.push("Emdeon Patient Pay Online" );
				}
				break;
			case 9:
				if ( recommendation[i] )
				{
					resolvedRecommendations.push("Emdeon eCashiering");
				}
				break;
			case 10:
				if ( recommendation[i] )
				{
					resolvedRecommendations.push("Emdeon Document Archive");
				}
				break;
			case 11:
				if ( recommendation[i] )
				{
					resolvedRecommendations.push("Emdeon Electronic Lockbox Services");
				}
				break;
			case 12:
				if ( recommendation[i] )
				{
					resolvedRecommendations.push("Emdeon Patient Communications");
				}
				break;
			default:
				break;
		}
	}
	//trace("Recommendations Resolved");
	return resolvedRecommendations;
}
function forceSubmit(e)
{
	alert();
}
/* * * * * * * * * * * * * * *
* funtion Name
* @parameter: desctiption.
* @parameter: description.
* #Summary
* * * * * * * * * * * * * * */
function addProductResults()
{
	trace("addProductResults()");
	//var overlay = document.getElementById('overlay');
	var recProductBox = document.getElementById('recProductBox');
	var recTable = document.getElementById('recTable');
	//recProductBox.style.height = "auto";
	//recTable.style.display = "";
	//overlay.style.display = "";
	var productDiv = new Array();
	var img = new Array();
	var headerText = new Array();
	var bodyText = new  Array();
	var productFormInput = new Array();
	trace("addProductResults() Begin");
	for( var i = 0; i < resolvedRecommendations.length; i++ )
	{
		trace("addProductResults() Iterate");
		
		/*
		headerText[i] = document.createElement('a');
		headerTextNode = document.createTextNode( resolvedRecommendations[i] );	
		headerText[i].appendChild( headerTextNode );										
		headerText[i].id = "productDisplayContainerTextHeader";
		headerText[i].setAttribute('href', getProductUrl(resolvedRecommendations[i]));
		
		headerText[i] = document.createElement('a');
		headerText[i].onclick = forceSubmit;
		headerTextNode = document.createTextNode( resolvedRecommendations[i] );	
		headerText[i].appendChild( headerTextNode );										
		headerText[i].id = "productDisplayContainerTextHeader";
		headerText[i].setAttribute('href', getProductUrl(resolvedRecommendations[i]));
		
		headerText[i] = document.createElement('a');
		headerTextNode = document.createTextNode( resolvedRecommendations[i] );	
		headerText[i].appendChild( headerTextNode );										
		headerText[i].id = "productDisplayContainerTextHeader";
		headerText[i].setAttribute('href', getProductUrl(resolvedRecommendations[i])); 
		*/
		
		headerText[i] = document.createNamedInput('submit', 'submit');
		headerText[i].setAttribute( 'value',resolvedRecommendations[i] );
		headerText[i].id = "productDisplayContainerTextHeader";
		headerText[i].name = "submit"+i;
		//alert(resolvedRecommendations[i]);
		bodyTextNode = document.createTextNode( getProductDescription( resolvedRecommendations[i] ) );
		
		bodyText[i] = document.createElement('div');
		bodyText[i].appendChild( bodyTextNode );
		bodyText[i].id = "productDisplayContainerText";
		
		productDiv[i] = document.createElement('div');
		productDiv[i].setAttribute( 'id','productDisplayContainer' );
		productDiv[i].style.backgroundColor ='TRANSPARENT';
		productDiv[i].appendChild( headerText[i] );
		productDiv[i].appendChild( bodyText[i] );
		
		productFormInput[i] = document.createNamedInput( 'hidden', "recommendation_"+i);
		productFormInput[i].className = "ctrl_response";
		productFormInput[i].name = "recommendation_"+i;
		productFormInput[i].value = resolvedRecommendations[i];
		productFormInput[i].id = "recommendation_"+i;
		
		recProductBox.appendChild(productDiv[i]);
		recProductBox.appendChild(productFormInput[i]); 
		//alert("test "+productFormInput[i].value);
		//myRecommendations = myRecommendations + productFormInput[i].value + "-";
		//document.recommendationForm.elements[1].value=myRecommendations;
		//alert("test "+myRecommendations);
		//alert("test "+document.recommendationForm.elements[1].name);
	}
	//var contactLink = document.getElementById('contactLink');
	//contactLink.style.display  = "none";
	trace("addProductResults() end");
}




function showNoProduct()
{
	var recProductBox = document.getElementById('recProductBox');
	var recTable = document.getElementById('recTable');
	//recTable.style.display = "";
	//recProductBox.style.display = "";
	//var overlay = document.getElementById('overlay');
	//overlay.style.display = "";
	var productDiv = new Array();
	var headerText = new Array();
	var bodyText = new Array();
	var productFormInput = new Array();
	var i = 0;
	headerText[i] = document.createElement('div');
	headerTextNode = document.createTextNode( "Emdeon Custom Provider Solutions" );	
	headerText[i].appendChild( headerTextNode );										
	headerText[i].id = "productDisplayContainerTextHeader";
	
	bodyTextNode=document.createTextNode("Based on the data you entered, it appears your needs require a customized solution. One of our ");
	bodyText[i] = document.createElement('div');
	bodyText[i].appendChild( bodyTextNode );
	var linkanchor = document.createElement('a');
	linkanchor.setAttribute("href", "product_finder_contact.php");
	linkanchor.appendChild(document.createTextNode("representatives "));
	bodyText[i].appendChild(linkanchor);
	bodyText[i].appendChild(document.createTextNode("would be happy to contact you to discuss the options for developing the right solution to meet your needs."));
	bodyText[i].id = "productDisplayContainerText";
	
	productDiv[i] = document.createElement('div');
	productDiv[i].setAttribute( 'id','productDisplayContainer' );
	productDiv[i].style.backgroundColor ='TRANSPARENT';
	productDiv[i].appendChild( headerText[i] );
	productDiv[i].appendChild( bodyText[i] );
	
	productFormInput[i] = document.createNamedInput( 'hidden', "recommendation_"+i);
	productFormInput[i].className = "ctrl_response";
	productFormInput[i].name = "recommendation_"+i;
	productFormInput[i].value = 'noResults';
	productFormInput[i].id = "recommendation_"+i;
	
	recProductBox.appendChild(productDiv[i]);
	recProductBox.appendChild(productFormInput[i]);
}
function getProductDescription( prodName )
{
	switch( prodName )
	{
		case "Emdeon Office":
			return "Emdeon Office utilizes the power of the internet to enable healthcare providers to conduct everyday transactions more easily, more efficiently, more accurately, and less expensively than ever before."
			break;
		case "Emdeon Assistant":
			return "Emdeon Assistant is a utility that allows a provider to automate various functions within the patient registration process."
			break;
		case "Emdeon POS":
			return "The Emdeon POS (Point-of-Service) terminals are easy to use for patient eligibility verification and are ideal for front-end locations such as registration areas, emergency rooms, admitting, and other areas where space is a consideration."
			break;
		case "Emdeon ClinicianRX":
			return "Emdeon ClinicianRx is a web-based electronic prescribing solution that saves providers time and money while emphasizing prescription accuracy and patient safety."
			break;
		case "Emdeon Claim Master":
			return "Emdeon Claim Master, a web-based billing management solution, can save time and money by providing one interface for managing claims for virtually all government and commercial payers from start to finish."
			break;
		case "Emdeon Payment Manager":
			return "Only Emdeon’s Payment Manager suite provides you single-enrollment access to the nation’s leading healthcare payment network. And with Emdeon’s comprehensive ePayment tools, you’ll unearth efficiency throughout your entire payment cycle. So break through the paper with Emdeon Payment Manager."
			break;
		case "Emdeon ExpressBill Services":
			return "Emdeon ExpressBill Services are designed to cut your processing costs by shortening the time it takes to get a statement from you to your customer."
			break;
		case "Emdeon Return Mail Manager":
			return "Emdeon uses NCOALink technology licensed by the United States Postal Service, to search all address changes filed with the USPS within the last eighteen months. This service prevents re-mailing to incorrect addresses, reduces undeliverable mail by using the most current address information available from the USPS and speeds collections."
			break;
		case "Emdeon Patient Pay Online":
			return "Emdeon Patient Pay Online is a self-service patient application that provides comprehensive and secure online billing and payment management. Emdeon Patient Pay Online will yield faster collection of patient-owed amounts, improved cash flow, and reduced billing costs, all with less effort and paperwork."
			break;
		case "Emdeon eCashiering":
			return "Emdeon eCashiering provides an integrated view of all patient payment activity and web-based access to the entire patient account enabling real-time processing of all credit card, check card, and ACH transactions."
			break;
		case "Emdeon Document Archive":
			return "Emdeon Document Archive streamlines your patient response time, reduces file maintenance and saves space. Through Emdeon Document Archive’s 24/7 desktop file retrieval and viewing capabilities, you will easily see statements and documents online that mirror those sent to your patients."
			break;
		case "Emdeon Electronic Lockbox Services":
			return "Emdeon's electronic payment processing capabilities dramatically improve billing efficiencies. With Emdeon Electronic Lockbox Services, your staff no longer wastes time sorting mail, opening and posting payments, creating deposit tickets or making bank deposits."
			break;
		case "Emdeon Patient Communications":
			return "Through Emdeon Patient Communications, Emdeon offers custom statement explanation inserts that can be used either when a client has recently started using a new statement format or when current Emdeon statement formats haved changed. This product is designed to explain statement formats and to highlight statement features, which will help educate patients and reduce statement-related support phone calls."
			break;
		default:
			break;
	}
}
/* * * * * * * * * * * * * * *
* getProductUrl
* @product: desctiption.
* #Summary
* * * * * * * * * * * * * * */
function getProductUrl(product)
{
	switch( product )
	{
		case "Emdeon Office":
			return "provider_patientaccess_office.php"
			break;
		case "Emdeon Assistant":
			return "provider_services_mediassistant.php"
			break;
		case "Emdeon POS":
			return "provider_patientaccess_pos.php"
			break;
		case "Emdeon ClinicianRX":
			return "provider_services_clinicianRX.php"
			break;
		case "Emdeon Claim Master":
			return "provider_billingmanagement_claimmaster.php"
			break;
		case "Emdeon Payment Manager":
			return "http://www.emdeon.com/epayment/"
			break;
		case "Emdeon ExpressBill Services":
			return "provider_services_statements.php"
			break;
		case "Emdeon Return Mail Manager":
			return "provider_services_address.php"
			break;
		case "Emdeon Patient Pay Online":
			return "provider_services_ebill.php"
			break;
		case "Emdeon eCashiering":
			return "provider_services_epay.php"
			break;
		case "Emdeon Document Archive":
			return "provider_services_earchive.php"
			break;
		case "Emdeon Electronic Lockbox Services":
			return "provider_services_elockbox.php"
			break;
		case "Emdeon Patient Communications":
			return "provider_cashacceleration_communication.php"
			break;
		default:
			return "provider_cashacceleration_communication.php"
			break;
	}
}
/* * * * * * * * * * * * * * *
* filterChoices()
* @array: desctiption.
* @filter: description.
* @applicability: description.
* #Summary
* * * * * * * * * * * * * * */
function filterArrays( a, f, ap)
{
	trace("filterArrays()");
	var array = a;
	var filter = f;
	var applicability = ap;
	var filtered = new Array();
	if ( array.length == filter.length )
	{
		trace("Arrays are congruent");
		for (var i = 0; i < array.length; i++)
		{
			trace("Checking element "+i+" out of "+ array.length);
			if ( applicability[i] )
			{
				if ((array[i]==0&&filter[i]==0)||(array[i]==1&&filter[i]==0)||(array[i]==0&&filter[i]==1))
				{
					trace(array[i]+"  ~ "+filter[i]+" = 0");
					filtered[i] = 0;
				}
				if ( ( array[i] == 1 &&  filter[i] == 1 ) )
				{
					trace(array[i]+"  ~ "+filter[i]+" = 1");
					filtered[i] = 1;
				}
			}
			else
			{
				filtered[i] = array[i];
				trace("Element "+i+" is inapplicable with this question, thus ignored");
			}
		}
	}
	else
	{
		trace("Arrays are not congruent");
		return;
	}
	trace("Filtration returns: "+filtered);
	return filtered;
}
/* * * * * * * * * * * * * * *
* combineArrays()
* @a1: the first array to combine
* @a2: the second array to combine with 
* #Summary 
* Takes two binary value arrays and combines them, for instance:
* 1,0,1,1,0,1,0,1,0,1,0 (Array 1)
* 0,1,0,1,0,1,0,1,1,0,1 (Array 2)
*--------------------------------
* 1,1,1,1,0,1,0,1,1,1,1 (Combined Array)
* * * * * * * * * * * * * * */
function combineArrays ( a1, a2 )
{
	trace("combineArrays()");
	var array1 = a1;
	var array2 = a2;
	var combined = new Array();
	if ( array1.length == array2.length )
	{
		for (var i = 0; i < array1.length; i++)
		{
			if ( array1[i] == 0 &&  array2[i] == 0 )
			{
				combined[i] = 0;
			}
			if ( array1[i] == 1 &&  array2[i] == 1 )
			{
				combined[i] = 1;
			}
			if ( ( array1[i] == 0 &&  array2[i] == 1 ) || ( array1[i] == 1 &&  array2[i] == 0) )
			{
				combined[i] = 1;
			}
		}
	}
	else
	{
		return;
	}
	return combined;
}