if ((top.TitleFeeUIServiceInit == "undefined") || (top.TitleFeeUIServiceInit != true))
{

	/*************************************************************************
	 *
	 * Title Fee UI Service CLASS definition.
	 *
	 */
	function TitleFeeUIService(){

		this.document = null;
		this.state = null;
		this.questionTree = null;
		this.endorsementList = null;
		this.questionStream = null;
		this.uiServiceStatus = "";
		this.titleFeeService;
		this.rateList = null;
		this.conditionList = new Array();
		this.userLocked = false;
		this.selectedCounty = "";

		this.showLenderRateOnly = false;
		
		this.tfcStateMap = null;

		// when true, shows NRFC params as part of quote
		this.debugMode = false;
		
		// Register the component managers

		ButtonActionManager.register(this);
		TFCStateMapActionManager.register(this);
		TableSetActionManager.register(this);
		DynamicFormActionManager.register(this);
		
	}

	TitleFeeUIService.TEXT = "1";
	TitleFeeUIService.RADIO = "2";


	/*************************************************************************
	 *
	 * Global initializer
	 *
	 */
	function initializeComponents(state){	 
		TitleFeeUIService.initializeClient(state, document);
	}
	
	TitleFeeUIService.initializeClient = function(_state, _document){
		top.titleFeeUIService = new TitleFeeUIService();
		top.titleFeeUIService.setDocument(_document);
		top.titleFeeUIService.setTitleFeeService(new TitleFeeService());
		top.titleFeeUIService.createBreadCrumb(_document);

		top.eventService.publish('View', 'setVisibility', 'ContentView', true);		

		if ( _state == '' ) {
			top.titleFeeUIService.tfcStateMap = new TFCStateMap('ContentView', _document);
			top.titleFeeUIService.tfcStateMap.setMapContent();
			top.titleFeeUIService.displayStateMapForm();
		} else {
			top.titleFeeUIService.displayBlankForm();
			TFCStateMapActionManager.doStateMapAction(_state);
		}

	}

	/*************************************************************************
	 *
	 * Setter/Getter Methods
	 *
	 */
	TitleFeeUIService.prototype.setDocument = function (_document){
		this.document = _document;
	}

	TitleFeeUIService.prototype.setTitleFeeService = function(_service){
		this.titleFeeService = _service;
		this.titleFeeService.setUIService(this);
	}
	
	TitleFeeUIService.prototype.setState = function(_state){
		this.state = _state;
	}
	
	TitleFeeUIService.prototype.setQuestionTree = function(_question){
		this.questionStream = new QuestionStream(_question);
		this.questionTree = _question;
	}
	
	TitleFeeUIService.prototype.displayFirstQuestion = function(){
		nextQuestion = this.questionStream.getFirstQuestion();
		if ( nextQuestion != null)
			this.displayQuestionForm(nextQuestion);
		else {
			this.lockUserGestures();
			this.titleFeeService.getPolicyRate(this.state.getStateCode(), this.state.getSelectedCountyId(), this.getQuestionStreamParameters(), "");
		}
		this.unlockUserGestures();
	}
	
	TitleFeeUIService.prototype.setEndorsementList = function(_list){
		this.endorsementList = _list;
	}
	
	TitleFeeUIService.prototype.setRateList = function(_rateList){
		this.rateList = _rateList;
	}

	TitleFeeUIService.prototype.setUIServiceStatus = function(_uiServiceStatus){
		this.uiServiceStatus = _uiServiceStatus;
	}

	TitleFeeUIService.prototype.getUIServiceStatus = function(){
		return this.uiServiceStatus;
	}

	TitleFeeUIService.prototype.hasSelectedEndorsements = function(){
		var hasEndorsements = false;
		if ( this.endorsementList != null ) {
			for ( var i = 0; i < this.endorsementList.length; i++ ) {
				if ( this.endorsementList[i].isSelected() ) {
					hasEndorsements = true;
					break;
				}
			}
		}
		return hasEndorsements;
	}
	
	TitleFeeUIService.prototype.reload = function(data){
		if ( data != null && data.length > 0 ) {
			//alert("data length = " + data.length);
			this.setState(data[0]);
			this.displayCountyGroupForm();
			this.resetEndorsementsList();
			this.resetRateList();

			this.addCrumb('State', 'State is ' + this.state.getStateName(), 'StateContainer');

			top.eventService.publish('View', 'setVisibility', 'buttonview', true);		
		}
	}
	
	TitleFeeUIService.prototype.getEndorsementDesc = function(endorsementId){
		if (this.endorsementList != null) {
			for ( var i = 0; i < this.endorsementList.length; i++ ) {
				if ( this.endorsementList[i].getNRFCEndorsementId() == endorsementId) {
					return this.endorsementList[i].getEndorsementDesc();
				}
			}
		} else {
			return '';
		}
	}


	/*************************************************************************
	 *
	 * Locking/Unlocking
	 *
	 */
	TitleFeeUIService.prototype.lockUserGestures = function(){
		this.userLocked = true;
		document.body.style.cursor = 'wait';
	}
	TitleFeeUIService.prototype.unlockUserGestures = function(){
		this.userLocked = false;
		document.body.style.cursor = 'default';
	}

	/*************************************************************************
	 *
	 * DO Actions
	 *
	 */
	TitleFeeUIService.prototype.doStateMapAction = function(stateCode){
		if ( (this.state == null) || (stateCode != this.state.getStateCode()) ) {
			this.lockUserGestures();
			if (stateCode == "IA") {
				this.unlockUserGestures();
				window.alert("Please contact local " + stateCode + " underwriting office.");
				window.location = "http://titlefees.firstam.com/";
			} else if (stateCode == "WA") {
				this.unlockUserGestures();
				window.alert("Washington is currently unavailable for premium quoting purposes.  We are updating our system and apologize for any inconvenience.");
				window.location = "http://titlefees.firstam.com/";
			} else {
				this.titleFeeService.getState(stateCode);
			}
		}
		else {
			// if the same state was selected
			// do not go to the server for the Question Tree and State

			this.resetQuestionStream();
			this.resetEndorsementsList();
			this.resetRateList();

			this.addCrumb('State', 'State is ' + this.state.getStateName(), 'StateContainer');

			top.eventService.publish('View', 'setVisibility', 'buttonview', true);
			this.displayCountyGroupForm();
		}
		
	}
	
	TitleFeeUIService.prototype.doFormAction = function(attribute, action, value){
		if ( attribute == 'CountyList' ) {
			if ( this.state.getSelectedGroupId() > 0 && 
			     this.state.getSelectedGroupId() != value ) {
				this.resetQuestionStream();
				this.resetEndorsementsList();
			}
			this.state.setSelectedIds(value);
		}
		else if ( attribute.substr(0, 6) == 'Answer' ) {
			var currentQuestion = this.questionStream.getCurrentQuestion();
			if (currentQuestion.getAnswerType() == TitleFeeUIService.RADIO) {
				if ( currentQuestion.getSelectedAnswerId() > 0 && 
				     currentQuestion.getSelectedAnswerId() != value ) {
					this.resetAnswersAfter(value);
					this.resetEndorsementsList();
					this.resetRateList();
				}
				currentQuestion.setSelectedAnswerId(value);
			}
			else if (currentQuestion.getAnswerType() == TitleFeeUIService.TEXT) {
				var answer = currentQuestion.getAnswer(0);
				if ( value != null && value != 'undefined') {
					answer.setValue(value);
				}
				else
				{
					alert("Please enter a value");
				}
				currentQuestion.setSelectedAnswerId(answer.getAnswerId());
				this.resetRateList();
			}
		}
		else if ( attribute == 'Endorsement' ) {
			var resetRateList = false;
			//this.removeLastCrumb();
			for (var i = 0; i < this.endorsementList.length; i++) {
				if ( this.endorsementList[i].getNRFCEndorsementId() == value ) {
					if ( this.endorsementList[i].isSelected() ) {
						resetRateList = true;
						this.endorsementList[i].setSelected(false);
						break;
					}
					else {
						resetRateList = true;
						this.endorsementList[i].setSelected(true);
						break;
					}
				}
			}
			if ( resetRateList ) {
				this.resetRateList();
			}
		}
	}
	
	/**
	 * Get previous question only if the given question has one radio answer.
	 * Traverse previous until we find one that has more than one radio answer
	 * or whose answer type is not radio (or reached the beginning).
	 */
	TitleFeeUIService.prototype.doPreviousQuestionHandling = function(previousQuestion)
	{
		while ((previousQuestion != null) &&
		  (previousQuestion.getAnswerList() != null) && 
		  (previousQuestion.getAnswerList().length == 1) && 
		  (previousQuestion.getAnswerType() == TitleFeeUIService.RADIO)) {
		  	var answer = previousQuestion.getAnswerList()[0];
			this.removeLastCrumb();
			previousQuestion = this.questionStream.getPreviousQuestion();							
		}
		return previousQuestion;
	}

	/**
	 * Get next question only if the question has one radio answer.
	 * Traverse next until we find one that has more than one radio ansewr
	 * or whose answer type is not radio (or reached the end).
	 */	
	TitleFeeUIService.prototype.doNextQuestionHandling = function(nextQuestion)
	{
		while ((nextQuestion != null) &&
		  (nextQuestion.getAnswerList() != null) && 
		  (nextQuestion.getAnswerList().length == 1) && 
		  (nextQuestion.getAnswerType() == TitleFeeUIService.RADIO)) {
		  	var answer = nextQuestion.getAnswerList()[0];
			nextQuestion.setSelectedAnswerId(answer.getAnswerId());
			this.addCrumb('Answer' + answer.getAnswerId(), answer.getAnswerNote(), 'PolicyContainer');
			nextQuestion = this.questionStream.getNextQuestion();							
		}
		return nextQuestion;
	}
	
	TitleFeeUIService.prototype.doButtonAction = function(buttonId){
		var uiServiceStatus = this.getUIServiceStatus();

		if ( this.validateAnswer(uiServiceStatus) ) {
			if ( buttonId == 'Previous' ) {
				if ( uiServiceStatus == 'TFC_UISERVICESTATUS_COUNTYGROUP' ) {
					this.removeLastCrumb();
					this.displayStateMapForm();
				}
				else if ( uiServiceStatus == 'TFC_UISERVICESTATUS_QUESTION' ) {
					this.removeLastCrumb();

					// 20060906dj - added "skip question with one answer" behavior
					var previousQuestion = this.questionStream.getPreviousQuestion();			
					previousQuestion = this.doPreviousQuestionHandling(previousQuestion);
										
					if ( previousQuestion != null ) {
						if (document.getElementById('Next').innerHTML == 'Print Quote')
						{
							top.eventService.publish('Button','changelabel','Next', 'Next >>');
						}
						this.displayQuestionForm(previousQuestion);
					}
					else {
						if ( this.state.getCountyGroupList().length > 1 ) {
							if (document.getElementById('Next').innerHTML == 'Print Quote')
							{
								top.eventService.publish('Button','changelabel','Next', 'Next >>');
							}
							this.displayCountyGroupForm();
						}
						else {
							if (document.getElementById('Next').innerHTML == 'Print Quote')
							{
								top.eventService.publish('Button','changelabel','Next', 'Next >>');
							}
							this.displayStateMapForm();
						}
					}
				}
				else if ( uiServiceStatus == 'TFC_UISERVICESTATUS_QUOTE' ) {
					this.removeLastCrumb(); // remove the quote
					if (this.rateList.length == 2) {
						this.removeLastCrumb(); // remove the quote
					} 
					this.removeLastCrumb(); // remove last question
					
					// 20060906dj - added "skip question with one answer" behavior					
					var previousQuestion = this.questionStream.getLastQuestion();
					previousQuestion = this.doPreviousQuestionHandling(previousQuestion);
										
					if (document.getElementById('Next').innerHTML == 'Print Quote')
					{
						top.eventService.publish('Button','changelabel','Next', 'Next >>');
					}
					this.displayQuestionForm(previousQuestion);
				}
				else if ( uiServiceStatus == 'TFC_UISERVICESTATUS_ENDORSEMENTS' ) {
					this.displayQuoteForm();
				}
				else if ( uiServiceStatus == 'TFC_UISERVICESTATUS_FINALQUOTE' ) {
					this.removeLastCrumb();
					this.displayEndorsementsForm();
				}
			}
			else if ( buttonId == 'Next' ) {
				if (document.getElementById(buttonId).innerHTML == 'Print Quote')
				{
					window.print();
				}
				else
				{
					var nextQuestion = null;
					var selectedCountyGroupId = null;
					if ( uiServiceStatus == 'TFC_UISERVICESTATUS_COUNTYGROUP' ) {
//						selectedCountyGroupId = this.state.getSelectedGroupId();
						if (this.state.getSelectedCountyId() != 0)
						{
							this.addCrumb('CountyGroup', 'County is ' + this.state.getSelectedCountyName(), 'StateContainer');
							this.selectedCounty = this.state.getSelectedCountyName();
							this.lockUserGestures();
							var questionTree = this.titleFeeService.getQuestionTree(this.state.getStateCode(), this.state.getSelectedGroupId());
	//						nextQuestion = this.questionStream.getFirstQuestion();
						}
						else
						{
							alert("Please select a county");
						}
					}
					else if ( uiServiceStatus == 'TFC_UISERVICESTATUS_QUESTION' ) {
						//alert("got here uiServiceStatus = " + uiServiceStatus);
						var answer = this.questionStream.getCurrentQuestionSelectedAnswer();
						var currentQuestion = this.questionStream.getCurrentQuestion();
						if (answer != null)
						{
							if ( currentQuestion.getAnswerType() == TitleFeeUIService.TEXT ) {
								if (isNaN(answer.getValue()))
								{
									alert("Please enter a numeric value.");
									return;
								}
								else if (answer.getValue() == '')
								{
									alert("Please enter a value.");
									return;
								}
								else if (answer.getValue() < 20000 || answer.getValue() > 3000000)
								{
									alert("The Title Fee Calculator does not quote transactions which are under $20,000 or over $3,000,000.\nPlease contact your local First American Title office to obtain a quote.");
									return;
								}
								else
								{
									this.addCrumb('Answer' + answer.getAnswerId(), answer.getAnswerNote() + ' ' + top.Formatter.currencyFormat(answer.getValue()), 'PolicyContainer');
								}
							}
							else if ( currentQuestion.getAnswerType() == TitleFeeUIService.RADIO ) {
								this.addCrumb('Answer' + answer.getAnswerId(), answer.getAnswerNote(), 'PolicyContainer');
							}
						}
						else
							alert("Please enter a value.");
						
						// 20060906dj - added "skip question with one answer" behavior
						var nextQuestion = this.questionStream.getNextQuestion();
						nextQuestion = this.doNextQuestionHandling(nextQuestion);
						  
					}
					else if ( uiServiceStatus == 'TFC_UISERVICESTATUS_QUOTE' ) {
						this.enableButtons('enable','enable','enable','disable');
					}					
					
					if ( uiServiceStatus != 'TFC_UISERVICESTATUS_COUNTYGROUP' ) {
					
						if ( nextQuestion != null || selectedCountyGroupId != 0) {
							//alert("got here nextQuestion = " + nextQuestion + " and selectedCountyGroupId = " + selectedCountyGroupId);
							if (selectedCountyGroupId != 0)
							{
								//alert("got here 2");
								if ( nextQuestion != null)									 	
									this.displayQuestionForm(nextQuestion);
								else
								{
									//alert("got here and nextQuestion = " + nextQuestion);
									top.eventService.publish('Button', 'disable','Previous','');
									top.eventService.publish('Button', 'disable','Next','');
									this.lockUserGestures();
									this.savedQuestionStreamParameters = this.getQuestionStreamParameters();
									this.titleFeeService.getPolicyRate(this.state.getStateCode(), this.state.getSelectedCountyId(), this.savedQuestionStreamParameters, "");
								}
							}
							else
								this.displayCountyGroupForm();
						}
						else {
							this.lockUserGestures();
							this.titleFeeService.getPolicyRate(this.state.getStateCode(), this.state.getSelectedCountyId(), this.getQuestionStreamParameters(), "");
						}
					
					}
				}
			}
			else if ( buttonId == 'AddEndorsements' ) {
				top.eventService.publish('Button', 'disable','Previous','');
				top.eventService.publish('Button', 'disable','Next','');
				top.eventService.publish('Button', 'disable','AddEndorsements','');
				var policyParameter = this.questionStream.getPolicyParameter();
				this.lockUserGestures();
				this.titleFeeService.getEndorsementList(this.state.getStateCode(), this.questionStream.getParameterValue(this.questionStream.getPolicyParameter()));
			}
			else if ( buttonId == 'Finish' ) {
				var endorsementNames = '';
				for (var i = 0; i<this.endorsementList.length; i++) {
					if ( this.endorsementList[i].isSelected() )  {
						if ( endorsementNames != '' ) {
//							endorsementNames += ', ' + this.endorsementList[i].getNRFCEndorsementId();
							endorsementNames += ', ' + this.endorsementList[i].getEndorsementDesc();
						}
						else {
//							endorsementNames += this.endorsementList[i].getNRFCEndorsementId();
							endorsementNames += this.endorsementList[i].getEndorsementDesc();
						}
					}
				}
				if ( endorsementNames != '' ) {
					this.addCrumb('Endorsements', endorsementNames, 'EndorsementsContainer');
				}
				top.eventService.publish('Button', 'disable','Previous','');
				top.eventService.publish('Button', 'disable','Finish','');
				this.lockUserGestures();
				this.titleFeeService.getPolicyRate(this.state.getStateCode(), this.state.getSelectedCountyId(), 
                                                                 this.getQuestionStreamParameters(), this.getEndorsements());
			}
		}		
	}
	
	TitleFeeUIService.prototype.doRowSelected = function(table, rowId){
		// BreadCrumb Selection
		var uiServiceStatus = this.getUIServiceStatus();
		
		top.eventService.publish('View', 'setVisibility', 'ErrorView', false);	
		top.eventService.publish('View', 'setVisibility', 'ContentView', true);		
		top.eventService.publish('View', 'setVisibility', 'buttonview', true);	

		if ( (rowId != 'StateContainer' && this.tfcStateMap == null) || this.tfcStateMap != null ) {
			this.removeCrumbsAfter(rowId);
		}
		
		// if CONTAINERS were selected
		if (rowId == 'StateContainer') {
			if ( this.tfcStateMap != null ) {
				if (document.getElementById('Next').innerHTML == 'Print Quote')
				{
					top.eventService.publish('Button','changelabel','Next', 'Next >>');
				}
				this.displayStateMapForm();
			}
		}
		else if (rowId == 'PolicyContainer') {
			if ( uiServiceStatus == 'TFC_UISERVICESTATUS_QUESTION' ||
				 uiServiceStatus == 'TFC_UISERVICESTATUS_QUOTE' ||
			     uiServiceStatus == 'TFC_UISERVICESTATUS_ENDORSEMENTS' ||
			     uiServiceStatus == 'TFC_UISERVICESTATUS_FINALQUOTE' ) {
				var question = this.questionStream.getFirstQuestion();
				if (document.getElementById('Next').innerHTML == 'Print Quote')
				{
					top.eventService.publish('Button','changelabel','Next', 'Next >>');
				}
				this.displayQuestionForm(question);
			}
		}
		else if (rowId == 'QuoteContainer') {
			if ( uiServiceStatus == 'TFC_UISERVICESTATUS_ENDORSEMENTS' ||
			     uiServiceStatus == 'TFC_UISERVICESTATUS_FINALQUOTE' ) {
				this.displayQuoteForm();
			}
		}
		else if (rowId == 'EndorsementsContainer') {
			if ( uiServiceStatus == 'TFC_UISERVICESTATUS_FINALQUOTE' ) {
				this.displayEndorsementsForm();
			}
		}
		else if (rowId == 'FinalQuoteContainer') {
			if ( uiServiceStatus == 'TFC_UISERVICESTATUS_FINALQUOTE' ) {
				this.displayFinalQuoteForm();
			}
		}
		
		// if CRUMBS were selected
		if (rowId == 'State') {
			if (document.getElementById('Next').innerHTML == 'Print Quote')
			{
				top.eventService.publish('Button','changelabel','Next', 'Next >>');
			}
			this.displayCountyGroupForm();
		}
		else if (rowId == 'CountyGroup') {
			this.removeLastCrumb();
			var question = this.questionStream.getFirstQuestion();
			if (document.getElementById('Next').innerHTML == 'Print Quote')
			{
				top.eventService.publish('Button','changelabel','Next', 'Next >>');
			}
			this.displayCountyGroupForm();
		}
		else if (rowId.substr(0, 6) == 'Answer') {
			var answerId = rowId.substr(6);
			
			this.questionStream.setCurrentQuestion(answerId);

			var question = this.questionStream.getAnswerNextQuestion(answerId);
			if ( question != null ) {
				if (document.getElementById('Next').innerHTML == 'Print Quote')
				{
					top.eventService.publish('Button','changelabel','Next', 'Next >>');
				}
				this.displayQuestionForm(question);
			}
			else {
				this.displayQuoteForm(question);
			}

		}
		else if (rowId == 'Endorsements') {
			this.removeLastCrumb();
			this.displayEndorsementsForm();
		}
	}
	

	/*************************************************************************
	 *
	 * Create Content
	 *
	 */
	TitleFeeUIService.prototype.createBreadCrumb = function(_document){
		top.tableSetActionManager = new TableSetActionManager();
		top.tableSetActionManager.createBreadCrumb('BreadCrumbTableSet', _document);

		// create the breadcrumb containers

		// State Container
		var container = new Container();
		container.setId('StateContainer');
		container.setLabel('1. Select State');
		container.setAttributes(new HashMap('className', 'mainlink'));
		top.eventService.publish('BreadCrumb', 'addContainer', 'BreadCrumbTableSet', container);

		// Policy Container
		var container = new Container();
		container.setId('PolicyContainer');
		container.setLabel('2. Select Policy');
		container.setAttributes(new HashMap('className', 'mainlink'));
		top.eventService.publish('BreadCrumb', 'addContainer', 'BreadCrumbTableSet', container);

		// Quote Container
		var container = new Container();
		container.setId('QuoteContainer');
		container.setLabel('3. Complete Quote');
		container.setAttributes(new HashMap('className', 'mainlink'));
		top.eventService.publish('BreadCrumb', 'addContainer', 'BreadCrumbTableSet', container);
/*
		// Endorsements Container
		var container = new Container();
		container.setId('EndorsementsContainer');
		container.setLabel('4. Add Endorsements');
		container.setAttributes(new HashMap('className', 'mainlink'));
		top.eventService.publish('BreadCrumb', 'addContainer', 'BreadCrumbTableSet', container);

		// Final Quote Container
		var container = new Container();
		container.setId('FinalQuoteContainer');
		container.setLabel('5. Complete Quote + Endorsement(s)');
		container.setAttributes(new HashMap('className', 'mainlinkdbl'));
		top.eventService.publish('BreadCrumb', 'addContainer', 'BreadCrumbTableSet', container);
*/
	}
/*
	TitleFeeUIService.prototype.createCountyGroupFormFields = function(state){
		var field;
		var group = new Group();
		group.setLabel("CountyGroup");
		
		field = new Field(0);
		field.setLabel("Please select a county.");
		field.setInputType("text");
		field.setGroup(group);

		var countyGroupList = state.getCountyGroupList();
		for(var i=0; i<countyGroupList.length; i++){
			field = new Field(countyGroupList[i].getGroupId());
			field.setLabel(countyGroupList[i].getName());
			field.setAttribute("CountyGroup");
			field.setInputType("radio");
			if (countyGroupList[i].getGroupId() == state.getSelectedGroupId()) {
				field.setChecked(true);
			}
			field.setGroup(group);
		}
		return group;
	}
*/
	TitleFeeUIService.prototype.createBlankContent = function(state){
		var field;
		var group = new Group();
		group.setLabel("Blank");
		
		for(var i=0; i<20; i++){
			field = new Field(i);
			field.setLabel("&nbsp;");
			field.setInputType("text");
			field.setGroup(group);
		}
		return group;
	}

	TitleFeeUIService.prototype.createCountyListFormFields = function(state){
		var field;
		var group = new Group();
		group.setLabel("CountyList");
		
		field = new Field(0);
		field.setLabel("Please select a county:&nbsp;&nbsp;");
		field.setInputType("list");
		field.setGroup(group);
		field.setAttribute("CountyList");
		
		// 20061025dj - retain county selection
		if (this.state != null && this.state.getSelectedCountyId() != null) {
			field.setValue(this.selectedCounty);
		}

		
		var countyGroupList = state.getCountyGroupList();
		
		field.addListValue("");
		for(var i=0; i<countyGroupList.length; i++){
			var countyList = countyGroupList[i].getCountyList();
			for (var j=0; j<countyList.length; j++) {
				field.addListValue(countyList[j].getCountyName());
			}
		}
		field.sortListValues();

		return group;
	}

	TitleFeeUIService.prototype.createQuestionFormFields = function(question){
		var field;
		var group = new Group();
		group.setLabel("Question");

		field = new Field(0);
		field.setLabel(question.getQuestionDesc() /*+ ' (' + question.getQuestionId() + ')'*/);
		field.setInputType("text");
		field.setGroup(group);

		if ( question.getAnswerType() == TitleFeeUIService.RADIO ) {
			var answerList = question.getAnswerList();
			for(var i=0; i<answerList.length; i++){
				field = new Field(answerList[i].getAnswerId());
				field.setLabel(answerList[i].getAnswerDesc());
				field.setAttribute("Answer");
				field.setInputType("radio");
				if (question.getSelectedAnswerId() == 0 && i == 0) {
					question.setSelectedAnswerId(answerList[i].getAnswerId());
				}
				if (answerList[i].getAnswerId() == question.getSelectedAnswerId() ) {
					field.setChecked(true);
				}
				field.setGroup(group);
			}
		}
		else if ( question.getAnswerType() == TitleFeeUIService.TEXT ) {
			var answer = question.getAnswer(0);
			field = new Field(answer.getAnswerId());
			field.setLabel('');
			field.setAttribute("Answer");
			field.setInputType("textarea");
			if ( answer.getValue() > 0 ) {
				field.setValue(answer.getValue());
			}
			field.setGroup(group);
		}
		return group;
	}

	TitleFeeUIService.prototype.createQuoteFormFields = function(){
		var total = 0;
		var field;
		var group = new Group();
		group.setLabel("Quote");

		for(var i=0; i<this.rateList.length; i++){
			field = new Field(i);
			if ( i == 0 ) { // Policy Rate
				if ( !this.showLenderRateOnly ) { // This is a special case used for few streams (see TFC_SHOW_LENDER_RATE_ONLY default parameter)
					if (this.rateList.length == 2)
						field.setLabel("<b>Owner's Rate: " + top.Formatter.currencyFormat(this.rateList[i].getValue()) + "</b>");
					else
						field.setLabel("<b>Quote: " + top.Formatter.currencyFormat(this.rateList[i].getValue()) + "</b>");
					
					total += parseFloat(this.rateList[i].getValue());
					total = Math.round(total * 100) / 100;
				}
			}
			else { 
//				field.setLabel("<b>" + this.getEndorsementDesc(this.rateList[i].getId()) + ": " + top.Formatter.currencyFormat(this.rateList[i].getValue()) + "</b>");
				if (this.rateList.length == 2)
					field.setLabel("<b>Lender's Rate: " + top.Formatter.currencyFormat(this.rateList[i].getValue()) + "</b>");
				else
					field.setLabel("<b>" + this.rateList[i].getName() + ": " + top.Formatter.currencyFormat(this.rateList[i].getValue()) + "</b>");
				total += parseFloat(this.rateList[i].getValue());
				total = Math.round(total * 100) / 100;
			}
			field.setInputType("text");
			field.setGroup(group);
		}

		field = new Field("Total");
		field.setLabel("<br><b>Total: " + top.Formatter.currencyFormat(total) + "</b>");
		field.setInputType("text");
		field.setGroup(group);

		field = new Field("Conditions Statement");
		field.setLabel("<br><br><b>The Premium above is based on the following conditions:</b><br><br>");
		field.setInputType("text");
		field.setGroup(group);
		
		for(var i=0; i<this.conditionList.length; i++){
			field = new Field(i);
			//if (this.conditionList[i].
			//alert(this.conditionList[i]);
			field.setLabel(this.conditionList[i].crumb.getLabel());
			field.setInputType("text");
			field.setGroup(group);
		}
		
		field = new Field("Notes Header");
		field.setLabel("<br><br><b><i>Notes:</i></b><br><br>");
		field.setInputType("text");
		field.setGroup(group);

//		field = new Field("Notes");
		var stateNote = this.state.getNote();
		var notes = new Array();
		notes = stateNote.split('|');
		for(var i=0; i<notes.length; i++){
			field = new Field(i);
			field.setLabel(notes[i]);
			field.setInputType("text");
			field.setGroup(group);
		}
		
		//20070427dj show NRFC Parameters
		if (this.debugMode) {
			var fmtStr = this.savedQuestionStreamParameters.replace(/\|/g,"<br/>");

			field = new Field("NRFC Parameters");
			field.setLabel("<br/><b>NRFC Parameters:</b><br/><small>" +fmtStr+"</small>");
			field.setInputType("text");
			field.setGroup(group);			
		}
		
		return group;
	}
	
	TitleFeeUIService.prototype.createFinalQuoteFormFields = function(){
		var total = 0;
		var field;
		var group = new Group();
		group.setLabel("Quote");

		for(var i=0; i<this.rateList.length; i++){
			field = new Field(i);
			if ( i == 0 ) { // Policy Rate
				field.setLabel("<b>Premium: " + top.Formatter.currencyFormat(this.rateList[i].getValue()) + "</b>");
			}
			else { // Endorsement Rate
				field.setLabel("<b>" + this.getEndorsementDesc(this.rateList[i].getId()) + ": " + top.Formatter.currencyFormat(this.rateList[i].getValue()) + "</b>");
//				field.setLabel("<b>" + this.rateList[i].getName() + ": " + top.Formatter.currencyFormat(this.rateList[i].getValue()) + "</b>");
			}
			field.setInputType("text");
			field.setGroup(group);
			total += parseFloat(this.rateList[i].getValue());
			total = Math.round(total * 100) / 100;
		}
/*
		field = new Field("Total");
		field.setLabel("<b>TOTAL QUOTE: " + top.Formatter.currencyFormat(total) + "</b>");
		field.setInputType("text");
		field.setGroup(group);
*/		
		field = new Field("Conditions Statement");
		field.setLabel("<br><br><b>The Premium above is based on the following conditions:</b><br><br>");
		field.setInputType("text");
		field.setGroup(group);
		
		for(var i=0; i<this.conditionList.length; i++){
			field = new Field(i);
			field.setLabel(this.conditionList[i].crumb.getLabel());
			field.setInputType("text");
			field.setGroup(group);
		}
		
		field = new Field("Notes Header");
		field.setLabel("<br><br><b><i>Notes:</i></b><br><br>");
		field.setInputType("text");
		field.setGroup(group);

		var stateNote = this.state.getNote();
		var notes = new Array();
		notes = stateNote.split('|');
		for(var i=0; i<notes.length; i++){
			field = new Field(i);
			field.setLabel(notes[i]);
			field.setInputType("text");
			field.setGroup(group);
		}
		
		return group;
	}

	TitleFeeUIService.prototype.createEndorsementsFormFields = function(list){
		var field;
		var group = new Group();
		group.setLabel("Endorsements");

		field = new Field(0);
		field.setLabel("Please select the applicable endorsements.");
		field.setInputType("text");
		field.setGroup(group);

		for(var i=0; i<this.endorsementList.length; i++){
			field = new Field(this.endorsementList[i].getNRFCEndorsementId());
			field.setLabel(this.endorsementList[i].getEndorsementDesc());
			field.setAttribute("Endorsement");
			field.setInputType("checkbox");
			if (this.endorsementList[i].isSelected() ) {
				field.setChecked(true);
			}
			field.setGroup(group);
		}
		return group;
	}

	/*************************************************************************
	 *
	 * Display Content
	 *
	 */
	TitleFeeUIService.prototype.displayBlankForm = function(){
		var group = this.createBlankContent();
		
		var dynamicForm = new DynamicForm();
		var html = dynamicForm.buildForm(group);
		top.eventService.publish('View', 'setVisibility', 'ContentView', true);		
		top.eventService.publish('View','setContent','ContentView', html);
	}
	
	TitleFeeUIService.prototype.displayStateMapForm = function(){
		top.eventService.publish('View', 'setContent', 'ContentView', this.tfcStateMap.getMapContent());		
		top.eventService.publish('View', 'setVisibility', 'buttonview', false);		
	
		this.setUIServiceStatus('TFC_UISERVICESTATUS_STATE');
		this.highlightContainer('StateContainer');
		this.selectedCounty = "";
		if (this.state != null && this.state.getSelectedCountyId() != null) {
			this.state.setSelectedIds("");			
		}		
		
		this.unlockUserGestures();
	}

	TitleFeeUIService.prototype.displayCountyGroupForm = function(){
//		var group = this.createCountyGroupFormFields(this.state);
		var group = this.createCountyListFormFields(this.state);
		
		var dynamicForm = new DynamicForm();
		var html = dynamicForm.buildForm(group);
		top.eventService.publish('View','setContent','ContentView', html);

		if ( this.tfcStateMap != null )	
			this.enableButtons('enable','enable','disable','disable');
		else
			this.enableButtons('disable','enable','disable','disable');
			
		this.setUIServiceStatus('TFC_UISERVICESTATUS_COUNTYGROUP');
		this.highlightContainer('StateContainer');
		top.eventService.publish('View', 'setVisibility', 'ContentView', true);		

		this.unlockUserGestures();
	}

	TitleFeeUIService.prototype.displayQuestionForm = function(_question){
		var group = this.createQuestionFormFields(_question);
		
		var dynamicForm = new DynamicForm();
		var html = dynamicForm.buildForm(group);
		top.eventService.publish('View','setContent','ContentView', html);

		this.enableButtons('enable','enable','disable','disable');
		this.setUIServiceStatus('TFC_UISERVICESTATUS_QUESTION');
		this.highlightContainer('PolicyContainer');
		this.unlockUserGestures();
	}

	TitleFeeUIService.prototype.displayQuoteForm = function(){
		if ( this.rateList != null ) {
			var group = this.createQuoteFormFields();

			if ( !this.showLenderRateOnly ) {
				if (this.rateList.length == 2) {
					this.addCrumb('Rate', "Owner's Rate " + top.Formatter.currencyFormat(this.rateList[0].getValue()), 'QuoteContainer');
					this.addCrumb('Rate', "Lender's Rate " + top.Formatter.currencyFormat(this.rateList[1].getValue()), 'QuoteContainer');
				} else {
					this.addCrumb('Rate', 'Quote ' + top.Formatter.currencyFormat(this.rateList[0].getValue()), 'QuoteContainer');
				}
			}
			else {
				this.addCrumb('Rate', "Lender's Rate " + top.Formatter.currencyFormat(this.rateList[1].getValue()), 'QuoteContainer');
			}

			var dynamicForm = new DynamicForm();
			var html = dynamicForm.buildForm(group);
			top.eventService.publish('View','setContent','ContentView', html);

			top.eventService.publish('Button','changelabel','Next', 'Print Quote');
			this.enableButtons('enable','enable','enable','disable');
			this.setUIServiceStatus('TFC_UISERVICESTATUS_QUOTE');
			this.highlightContainer('QuoteContainer');
			this.unlockUserGestures();
		}
	}

	TitleFeeUIService.prototype.displayEndorsementsForm = function(){
		var group = this.createEndorsementsFormFields();
		
		var dynamicForm = new DynamicForm();
		var html = dynamicForm.buildForm(group);
		top.eventService.publish('View','setContent','ContentView', html);
		
		this.enableButtons('enable','disable','disable','enable');
		this.setUIServiceStatus('TFC_UISERVICESTATUS_ENDORSEMENTS');
		this.highlightContainer('EndorsementsContainer');
		this.unlockUserGestures();
	}
	
	TitleFeeUIService.prototype.displayFinalQuoteForm = function(){
		var group = this.createFinalQuoteFormFields();
		
		var dynamicForm = new DynamicForm();
		var html = dynamicForm.buildForm(group);
		top.eventService.publish('View','setContent','ContentView', html);

		top.eventService.publish('Button','changelabel','Next', 'Print Quote');
		this.enableButtons('enable','enable','disable','disable');
		this.setUIServiceStatus('TFC_UISERVICESTATUS_FINALQUOTE');
		this.highlightContainer('FinalQuoteContainer');
		this.unlockUserGestures();
	}

	/*************************************************************************
	 *
	 * Navigation Methods
	 *
	 */
	TitleFeeUIService.prototype.enableButtons = function(previousFlag, nextFlag, endorsementsFlag, finishFlag){
		top.eventService.publish('Button', previousFlag,'Previous','');
		top.eventService.publish('Button', nextFlag,'Next','');
		top.eventService.publish('Button', endorsementsFlag,'AddEndorsements','');
		top.eventService.publish('Button', finishFlag,'Finish', '');
	}
	
	
	/*************************************************************************
	 *
	 * Reset Methods
	 *
	 */
	TitleFeeUIService.prototype.resetAnswersAfter = function(answerId){
		this.questionStream.removeQuestionsAfter(answerId);
	}
	
	TitleFeeUIService.prototype.resetEndorsementsList = function(){
		if ( this.endorsementList != null ) {
			for ( var i = 0; i < this.endorsementList.length; i++ ) {
				this.endorsementList[i].setSelected(false);
			}
		}
	}
	
	TitleFeeUIService.prototype.resetRateList = function(){
//		this.rateList = new Array();
	}
	
	TitleFeeUIService.prototype.resetQuestionStream = function(){
		if ( this.questionStream != null ) {
			this.questionStream.removeAll();
		}
	}
	


	/*************************************************************************
	 *
	 * Build Parameters Methods
	 *
	 */
	TitleFeeUIService.prototype.getQuestionStreamParameters = function(){
		return this.questionStream.getParameters();
	}
	
//	TitleFeeUIService.prototype.getDefaultQuestionStreamParameters = function(){
//		return this.questionStream.getDefaultParameters();
//	}

	TitleFeeUIService.prototype.getEndorsements = function(){
		// build a string of the form:
		// paramId=paramCode|paramId=paramCode|paramId=paramCode|paramId=paramCode
		var endorsements = '';
		var paramList;
		for (var i = 0; i < this.endorsementList.length; i++) {
			if ( this.endorsementList[i].isSelected() ) {
				var id = this.endorsementList[i].getEndorsementId();
				paramList = this.endorsementList[i].getParamNameList();
				for (var j = 0; j < paramList.length; j++) {
					if (paramList[j] == 'ENDORSEMENT' || paramList[j] == 'ENDORSEMENTS') // Is this right?
					{
						endorsements += paramList[j] + "=" + this.endorsementList[i].getNRFCEndorsementId()+ "|";
//						alert('endorsements: ' + endorsements);
					}
					else
						endorsements += paramList[j] + "=" + this.questionStream.getParameterValue(paramList[j]) + "|";
//						alert('endorsements: ' + endorsements);
				}
			}
		}
//		alert('endorsements: ' + endorsements);
		return endorsements;
	}
	

	/*************************************************************************
	 *
	 * BreadCrumb Navigation
	 *
	 */
	
	TitleFeeUIService.prototype.addCrumb = function(crumbId, crumbLabel, containerId){
		var crumb = new Crumb();
		crumb.setId(crumbId);
		if (crumbLabel.length == 1)
			crumbLabel = "";
			if (crumbId == "CountyGroup")
			{
				if (crumbLabel.length > 101)
					crumb.setLabel(crumbLabel.substr(0,101) + "...");
				else
					crumb.setLabel(crumbLabel);
			}
			else
				crumb.setLabel(crumbLabel);

		crumb.setAttributes(new HashMap('className', 'sublinks'));
		var breadCrumbPayload = new BreadCrumbPayload(crumb, containerId);
		top.eventService.publish('BreadCrumb', 'addCrumb', 'BreadCrumbTableSet', breadCrumbPayload);
		this.conditionList.push(breadCrumbPayload);
	}

	TitleFeeUIService.prototype.removeLastCrumb = function(){
		top.eventService.publish('BreadCrumb', 'removeLastCrumb', 'BreadCrumbTableSet', '');
		
		this.conditionList.pop();
	}
	
	TitleFeeUIService.prototype.removeCrumbsAfter = function(rowId){
		top.eventService.publish('BreadCrumb', 'removeCrumbsAfter', 'BreadCrumbTableSet', rowId);
		
		// clear the conditionList starting from the end of the list to the clicked Crumb/Container
		var isContainer = false;
		
		for(var i=0; i<this.conditionList.length; i++){
			if ( this.conditionList[i].containerId == rowId ) {
				isContainer = true;
				while ( this.conditionList.length > i ) {
					this.conditionList.pop();
				}
			}
		}

		while ( !isContainer && 
			this.conditionList[this.conditionList.length - 1] != null &&
			this.conditionList[this.conditionList.length - 1].crumb != null && 
			this.conditionList[this.conditionList.length - 1].crumb.getId() != rowId ) 
		{
			this.conditionList.pop();
		}
	}
	
	TitleFeeUIService.prototype.highlightContainer = function(containerId){
		top.eventService.publish('BreadCrumb', 'highlightContainer', 'BreadCrumbTableSet', containerId);
	}

	/*************************************************************************
	 *
	 * QuestionStream CLASS Definition
	 *
	 */
	function QuestionStream (_firstQuestion) {
		this.currentQuestionIndex = 0;
		this.questionList = new Array();
		this.questionList[0] = _firstQuestion;
	}
	
	QuestionStream.prototype.getCurrentQuestion = function(){
		return this.questionList[this.currentQuestionIndex];
	}

	QuestionStream.prototype.setCurrentQuestion = function(answerId){
		for ( var q = 0; q < this.questionList.length - 1; q++ ) {
		    if ( this.questionList[q].getSelectedAnswerId() == answerId ) {
				this.currentQuestionIndex = ++q;
				break;
		    }
		}
	}

	QuestionStream.prototype.getFirstQuestion = function(){
		this.currentQuestionIndex = 0;
		return this.questionList[this.currentQuestionIndex];
	}
	
	QuestionStream.prototype.getLastQuestion = function(){
		this.currentQuestionIndex = this.questionList.length - 1;
		return this.questionList[this.currentQuestionIndex];
	}

	QuestionStream.prototype.getPreviousQuestion = function(){
		if ( this.currentQuestionIndex > 0 ) {
			return this.questionList[--this.currentQuestionIndex];
		}
		else {
			return null;
		}
	}

	QuestionStream.prototype.getNextQuestion = function(){
		var nextQuestion = null;
		if ( this.currentQuestionIndex < this.questionList.length - 1 ) {
			nextQuestion = this.questionList[++this.currentQuestionIndex];
		}
		else {
			var currentAnswer = this.getCurrentQuestionSelectedAnswer();
			if ( currentAnswer != null ) {
				nextQuestion = currentAnswer.getNextQuestion();
				if ( nextQuestion != null ) {
					this.addQuestion(nextQuestion);
				}
			}
			else {
				nextQuestion = this.questionList[this.currentQuestionIndex];
			}
		}
		return nextQuestion;
	}
	
	QuestionStream.prototype.hasMoreQuestions = function(){
		var moreQuestionsFlag = true;
		if ( this.questionList != null && this.questionList.length - 1 == this.currentQuestionIndex ) 
		{
			var currentAnswer = this.getCurrentQuestionSelectedAnswer();
			if ( currentAnswer != null ) {
				if ( currentAnswer.getNextQuestion() == null ) {
					moreQuestionsFlag = false;
				}
			}
		}
		return moreQuestionsFlag;
	}

	QuestionStream.prototype.addQuestion = function(question){
		this.questionList.push(question);
		this.currentQuestionIndex++;
	}

	QuestionStream.prototype.removeQuestionsAfter = function(answerId){
		var question = this.getQuestionForAnswer(answerId);

		var questionId = 0;
		do {
			questionId = this.questionList[this.questionList.length - 1].getQuestionId();
			if ( questionId != question.getQuestionId() ) {
				this.questionList.pop();
			}
			else {
				this.currentQuestionIndex = this.questionList.length - 1;
				break;
			}
		} while (this.questionList.length > 0);
	}
	
	QuestionStream.prototype.removeAll = function(){
		this.currentQuestionIndex = 0;
		for(var i = this.questionList.length - 1; i >= 0; i--) {
			this.questionList[i].setSelectedAnswerId(0);
			if ( i > 0 ) {
				this.questionList.pop();
			}
		}
	}
	
	QuestionStream.prototype.getCurrentQuestionSelectedAnswer = function(){
		var answer = null;
		var currentQuestion = this.questionList[this.currentQuestionIndex];
		var selectedAnswerId = currentQuestion.getSelectedAnswerId();
		var answerList = currentQuestion.getAnswerList();
		for ( var i = 0; i < answerList.length; i++ ) {
			if ( answerList[i].getAnswerId() == selectedAnswerId ) {
				answer = answerList[i];
				break;
			}
		}
		return answer;
	}

	QuestionStream.prototype.getQuestionForAnswer = function(answerId){
		var question = null;
		for ( var q = this.questionList.length - 1; q >= 0; q-- ) {
			var answerList = this.questionList[q].getAnswerList();
			for ( var i = 0; i < answerList.length; i++ ) {
				if ( answerList[i].getAnswerId() == answerId ) {
					question = this.questionList[q];
					break;
				}
			}
			if ( question != null ) {
				break;
			}
		}
		return question;
	}

	QuestionStream.prototype.getAnswerNextQuestion = function(answerId){
		var question = null;
		for ( var q = 0; q < this.questionList.length; q++ ) {
			var answerList = this.questionList[q].getAnswerList();
			for ( var i = 0; i < answerList.length; i++ ) {
				if ( answerList[i].getAnswerId() == answerId ) {
					question = answerList[i].getNextQuestion();
					break;
				}
			}
			if ( question != null ) {
				break;
			}
		}
		return question;
	}

	QuestionStream.prototype.getParameters = function(){
	
		var parameters = "";
		var defaultParameterString = "";
          var answerMap = new Object();
          var loanAmount = 0;
		
		// Special handling (hack) for certain streams
		// require us to report lender rate only even when
		// NRFC returns two amounts.
		top.titleFeeUIService.showLenderRateOnly = false;
		
		// Navigate the stream actually taken...
		for ( var qidx = 0; qidx < this.questionList.length; qidx++ ) {
			var question = this.questionList[qidx];
			var answerList = question.getAnswerList();
						
			// For this question's answers...
			for ( var aidx = 0; aidx < answerList.length; aidx++ ) {
				var answer = answerList[aidx];
				if ( answer.getAnswerId() == question.getSelectedAnswerId() ) {
					// 20061102dj - hack the hack - new strategy doesn't have
					// parameters with questions
					//if ( question.getParamName() == 'LENDER_AMOUNT' ){
					//	loanAmount = answer.getValue();
					//}
					if (question.getQuestionDesc().indexOf('transaction amount?') > 0) {
						loanAmount = answer.getValue();
					}
										
					if (question.getAnswerType() == TitleFeeUIService.TEXT) {
						answerMap["$A"+answer.getAnswerId()+"$"] = answer.getValue();
					}
					
					if (answer.getDefaultParameterString().length > 0) {
						defaultParameterString = answer.getDefaultParameterString();						
					}
				}
			}
		}
		
		// The meta-params and default params have been captured.  Finalize by
		// replacing meta-parameter tags with actual answers within the default parameter string.
		if (defaultParameterString != null && defaultParameterString != "undefined") {
			tempDefaultParams = defaultParameterString;
			for (var key in answerMap) {
				while (tempDefaultParams.indexOf(key) != -1) {
					tempDefaultParams = tempDefaultParams.replace(key, answerMap[key]);
				}
			}
			defaultParameterString = tempDefaultParams;			
		}
		
		parameters = defaultParameterString;
		
		// Code for exception streams and custom parameters - hack
		var excludeParameter = 'TFC_SHOW_LENDER_RATE_ONLY=1';
		var index = parameters.indexOf(excludeParameter);
		var actualParameters = "";
		if ( index >= 0 ) {
			top.titleFeeUIService.showLenderRateOnly = true;
			// remove parameter from list (it's just a flag for our custom handling and not an NRFC parameter)
			actualParameters += parameters.substring(0, index);
			if ( parameters.length > index + excludeParameter.length ) {
				actualParameters += parameters.substring(index + excludeParameter.length + 1, parameters.length);
			}
			
			// add OWNER_AMOUNT parameter - hack
			if (actualParameters.substring(actualParameters.length-1,actualParameters.length) != '|') {
				actualParameters += '|';
			}
			
			if (actualParameters.indexOf(excludeParameter) == -1) {
				actualParameters += 'OWNER_AMOUNT=' + loanAmount;				
			}
		}
		else {
			actualParameters = parameters;
		}
		
		//alert("actualParameters =>" + actualParameters + "<");

		return actualParameters;
	}

	QuestionStream.prototype.getPolicyParameter = function(){
		var policyParamSubstring = "LENDERS_COVERAGE_CLASS";
		var policyParamSubstringIndex = -1;
		var paramName = '';
		for ( var q = 0; q < this.questionList.length; q++ ) {
			if ( this.questionList[q].getParamName().length > 0 ) {
				policyParamSubstringIndex = this.questionList[q].getParamName().indexOf(policyParamSubstring);
				if ( policyParamSubstringIndex > -1 ){
					paramName = this.questionList[q].getParamName();
					break;
				}
			}
			
		}
		//if ( paramName.length == 0 ) {
		//	alert("QuestionStream.prototype.getPolicyParameter(): There is no POLICY_TYPE parameter for this stream!\nIs this correct?");
		//}
		//alert("paramName = " + paramName);
		return paramName;
	}
	 
	/*************************************************************************
	 *
	 * Display Exception Content
	 *
	 */
	TitleFeeUIService.prototype.createMessageForm = function(_content){
		var field;
		var group = new Group();

		field = new Field('error');
		field.setLabel(_content);
		field.setInputType("text");
		field.setGroup(group);
		
		//20070427dj show NRFC Parameters
		if (this.debugMode) {
			var fmtStr = this.savedQuestionStreamParameters.replace(/\|/g,"<br/>");

			field = new Field("NRFC Parameters");
			field.setLabel("<br/><b>NRFC Parameters:</b><br/><small>" +fmtStr+"</small>");
			field.setInputType("text");
			field.setGroup(group);			
		}
		
		
		var dynamicForm = new DynamicForm();
		var html = dynamicForm.buildForm(group);
		
		return html;
	}

	TitleFeeUIService.prototype.displayBusinessException = function(_content){
		top.eventService.publish('View', 'setVisibility', 'ErrorView', true);	
		
		var html = this.createMessageForm(_content);
		
		this.resetViewChange();
		this.unlockUserGestures();
	}

	TitleFeeUIService.prototype.displaySystemException = function(_content){
		top.eventService.publish('View', 'setVisibility', 'ErrorView', true);	
		top.eventService.publish('View', 'setVisibility', 'ContentView', false);		
		top.eventService.publish('View', 'setVisibility', 'buttonview', false);	
		
		var html = this.createMessageForm(_content);
		
		top.eventService.publish('View','setContent','ErrorView', html);
		
		this.rateList = null;

		this.unlockUserGestures();
	}

	/*************************************************************************
	 *
	 * Validation and Error handling
	 *
	 */
	TitleFeeUIService.prototype.validateAnswer = function(uiServiceStatus){
		return true;
	}

	//////////////////////////////////////
	
	top.TitleFeeUIServiceInit = true;

}




