<!--

function get_base_cgi_path() {

	var base_path = "/tax/cgi-bin/taxmaster_devel/";

	return base_path;
}


function get_base_html_path() {

	return "/tax/";
}

/****************************************
the intro page is loaded directly from the frameset
defined in index.html when the system is first entered.
But, reDisplay() gets called onLoad, so we dont want the
intro to get created twice. So if the form isnt defined, then the 
right frame has never been loaded, and is being loaded, so 
dont try to get it again.

But if the user causes the intro page to be redisplayed,
the intro page must be requested in the normal tocTab manner.
So the tocTab has a regular script calling entry for the intro page.
This is the script called. In those situations, the form is defined
so the intro is NOT being loaded already, so load it normally.
****************************************/
function tocIntro() {
// pre working for Macs - this line was hosed, but MS allows
// sloppy JS
//	var ThisForm = content.frames.document.forms.MasterHeader;
//	var ThisForm = window.frames.content.MasterHeader;

	var ThisForm = getThisForm();

	if ( ThisForm ) {
		if ( ThisForm.__GLOBAL__current_page.value != "intro" ) {
			ProcessChoice(ThisForm, "Intro");
		}
	}
}


function tocProcessChoice(Choice) {
// pre working for Macs - this line was hosed, but MS allows
// sloppy JS
//	var ThisForm = content.frames.document.forms.MasterHeader;

	var ThisForm = getThisForm();

	return ProcessChoice(ThisForm, Choice);
}


// This should work with I.E. 5.5, Netscape 6.2, and I.E. 5.2 for mac OSX
function getThisForm() {

	var ThisForm;
	if  ( navigator.appName == "Netscape") {
		ThisForm = content.frames.document.forms.MasterHeader;
	}
	else {
		ThisForm = window.frames.content.MasterHeader;
	}

	return ThisForm;
}


/******************************************************
CheckPrematureChoice()
is always called as an onLoad event. The purpose is so
that if a user clicks a link while a page is loading,
The form wont be submitted until the page is completely loaded.
Otherwise, the submission could be incomplete and get a server error.
ProcessChoice() now checks if the document is fully loaded, and
if not, does appropriate setup for actually submitting the
form after the document has fully loaded.
******************************************************/
function CheckPrematureChoice(ThisForm) {

	if ( ThisForm.premature_choice.value != 1 ) {
		return false;
	}

	ProcessChoice(ThisForm, ThisForm.choice.value);
}


function unsetPrematureChoice(ThisForm) {
	ThisForm.premature_choice.value = 0;
}

function StartUpdateInformation() {

	var ThisForm = window.frames.content.MasterHeader;

	// atell process_choice what to do, and avoid a from action
	var query_string = "?choice=Display%20Update%20Information&__GLOBAL__current_page=intro";
	
	var base_path = get_base_cgi_path(ThisForm);
	window.open(base_path + "process_choice.pl" + query_string);
}



function ProcessChoice(ThisForm, Choice) {

	if ( ! ThisForm ) {
		return false;
	}

	ThisForm.choice.value = Choice;

	/****************************************
	added 6-20-2002 to stop server errors from requests
	that dont have the document fully loaded
	choice will get set either way. if the page isnt
	loaded, this returns and doesnt submit. 
	Then the body onLoad() event checks if choice
	is set. If so, immediately submit the form.

	6-26-2002
	the changed noted above caused the side effect that
	the browser back button had some odd effects.
	because choice is set when moving forward, when
	the user pressed back, the page with choice set would
	render in their browser, and CheckPrematureChoice()
	would notice choice is set, and submit the form.

	so, to alleviate this problem, i added the flag 
	premature_choice, which gets set when a premature 
	choice is made, as well as choice being set.
	then, CheckPremaureChoice() will check the flag
	before submitting. Any submission will cause 
	premature_choice to be unset. Then, when the user hits back
	premature_choice wont be set, and the form wont 
	automatically submit. I couldnt do this with choice,
	because choice needs to be set for the cgi handlers.
	****************************************/

	if ( ! IsPageFullyLoaded(ThisForm) ) {
		ThisForm.premature_choice.value = 1;
		return false;
	}

	if ( ValidateCounties(ThisForm) ) {
		unsetPrematureChoice(ThisForm);
		if ( (navigator.appName == "Netscape") &&
				(ThisForm.__GLOBAL__current_page.value == "Full Search Search") ) {
            var right_frame;

            if ( self.name == "content" ) {
                right_frame = self;
            }
            else if ( self.content ) {
                right_frame = content;
            }
            else {
                // this case happens when the browse screen comes up from the fbs lookup
                // since there is no frameset
                right_frame = self;
            }

			right_frame.OpenAllSearchSpans();
		}
		return ThisForm.submit();
	}
	else {
		return false;
	}
}

// 3-6-2003 - this is from ProcessChoice() - its the part to check if
// the page is fully loaded. returns false if its not fully loaded,
// true otherwise
function IsPageFullyLoaded(ThisForm) {

	var right_frame;

	if ( self.name == "content" ) {
		right_frame = self; 
	}
	else if ( self.content ) {
		right_frame = content;
	}
	else {
		// this case happens when the browse screen comes up from the fbs lookup
		// since there is no frameset
		right_frame = self;
	}

	if  ( (navigator.appName != "Netscape") &&
				(right_frame.document.readyState != "complete") ) {
		return false;
	}
	return true;
}


function ValidateCounties(ThisForm) {

	var	choice = ThisForm.choice.value;

	if ( ThisForm.__GLOBAL__current_page ) {
		current_page = ThisForm.__GLOBAL__current_page.value;

		if ( (current_page == "select_counties") || (current_page == "User_Setup") ) {
			if ( choice == "Restore Defaults" ) {
				return true;
			}

			chosen_counties = AnyCheckBoxesTagged(ThisForm.counties);
			if ( (chosen_counties > 0) && (chosen_counties <= 4) ) {
				return true;
			}
			else if ( (chosen_counties == 0) && (choice = "Save Setup") ) {
				// dont know that i like this one
				return true;
			}
			else {
				alert("You must select between 1 and 4 counties!");
				return false;
			}
		}
	}

	return true;
}
	

/**********************************************************************
function	:	StartHelp()
author		:	sean peters
start date	:	4-26-2002
desc		:	this function causes the help system to be launched in 
				a new window. there will be a hidden variable called
				help_context, so that if the user enters help from 
				a "page", as opposed to from the navigation menu
				the help will come up contextually.

				Since the help is mainly a non-cgi system, bringing
				up the help contextually will be a bit of a hack,
				in that the cgi to do it will probably just read and
				write the appropriate static page, as if it were
				called regularly. (maybe not though)
**********************************************************************/
function OLD_StartHelp() {
// pre working for Macs - this line was hosed, but MS allows
// sloppy JS
//	var ThisForm = content.frames.document.forms.MasterHeader;
	var ThisForm = window.frames.content.MasterHeader;

	var help_context = "";
	var query_string = "?choice=Start%20Help";

	if ( ThisForm.help_context ) {
		help_context = ThisForm.help_context.value;
		query_string += "&help_context=" + help_context;
	}

	var base_path = get_base_cgi_path(ThisForm);
	window.open(base_path + "help/help_choice.pl" + query_string);
}


function StartHelp() {

//	alert("Help is coming soon");

	var ThisForm = window.frames.content.MasterHeader;
	var base_path = get_base_html_path(ThisForm);
	window.open(base_path + "help/PL_help.pdf");
}


function ProcessChoiceInTarget(ThisForm, choice, id_widget, new_target) {

// 3-6-2003 added this, because the premature choice mechanisms dont
// funciton properly for things that open in new windows.
	if  ( ! IsPageFullyLoaded(ThisForm) ) {
		return false;
	}

	if ( ! new_target ) {
		new_target = "_new_window";
	}

	// this is to ensure that a unique id is assigned each time
	// so that a new window is displayed each time
	ThisForm.elements[id_widget].id++;
	new_target += "_" + ThisForm.elements[id_widget].id;

	// GET THE CRITERIA IN A NEW WINDOW
	var save_old_target = ThisForm.target;
	ThisForm.target = new_target;

	ProcessChoice(ThisForm, choice);

	// OTHERWISE, EVERYTHING FROM NOW ON WILL OPEN IN A NEW WINDOW
	ThisForm.target = save_old_target;
}


function CheckBrowseMatchesValue(ThisForm) {

	var browse_matches = ThisForm.elements['Browse Matches'].value;

	if ( ! isAnInteger(browse_matches) || (browse_matches == 0) ) {
		alert(browse_matches + " is not a valid value for Matches Per Browse Screen\n" +
			"You must choose a number between 1 and 99");
		ThisForm.elements['Browse Matches'].value =
			ThisForm.elements['__SESSION__Browse Matches'].value;
	}
}


<!-- end of scripts -->

