/* ----------------------------------------------------------------------------
Description: VBAN-specific JavaScript utility functions.
Copyright (c) 2000, by Competitive Computing, Inc.
-----------------------------------------------------------------------------*/

// set the name of the browser window.
// this is used for interaction with the Vermont Travel Planner site.
// windows that already have names will not be changed (e.g., bid detail windows).
if (this.name.length == 0)
	{
	this.name = 'VermontBusinessRegistry';
	}

function okToLeavePage()
{
	if (g_blnPageDirty)
		return confirm(g_strMsgOkToLeavePage);
	else
		return true;
}

function pageDirty()
{
	if(g_blnPageDirty)
	{ 
		return true;
	}
	else
	{
		return false;
	}	 
}

function okToDeleteRecord(strDescription)
{
	return confirm(strDescription + g_strMsgOkToDeleteRecord);
}

function okToCancel(strDescription)
{
	return confirm(strDescription + g_strMsgOkToCancel);
}

// open a new window or link to Vermont Travel Planner window if already open
function VTPWindow(strLink,strWindow) {
	vtp_window = 
		window.open(strLink,strWindow,'menubar,status,scrollbars,resizable,width=800,height=600,toolbar,location,directories');
		  
	vtp_window.name = strWindow;

	if ( OKToSetFocus() && vtp_window && ! vtp_window.closed ) 
		vtp_window.focus(); 
}

// open help window if not already open
function PopUpWindow(strLink, strWindow) {
	popup_window = 
		window.open(strLink,strWindow,'toolbar=no,width=400,height=300,status=no,scrollbars=yes,resizable=yes,menubar=no,left=20,top=20')
		  
	popup_window.name = strWindow;

	if ( OKToSetFocus() && popup_window && ! popup_window.closed ) 
		popup_window.focus(); 
}

// create a new window with your own parameters
function PopUpNewWindow(strLink, strWindow, intWidth, intHeight, intLeft, intTop) {
	popup_window =
		window.open(strLink, strWindow, 'toolbar=no,width=' + intWidth + ', height=' + intHeight + ',status=no,scrollbars=yes,resize=yes,menubar=no,left=' +intLeft + ', top='+ intTop);
		
	popup_window.name = strWindow
	if ( OKToSetFocus() && popup_window && ! popup_window.closed ) 
		popup_window.focus();

}

// open help window if not already open
function PopUpPlainWindow(strLink, strWindow) {
	popup_window = 
		window.open(strLink,strWindow)
		  
	popup_window.name = strWindow;

	if ( OKToSetFocus() && popup_window && ! popup_window.closed ) 
		popup_window.focus(); 
}


// if Netscape, or if IE 5+, then retrun true
// IE 4 is the only browser that we care about with known problems setting focus
function OKToSetFocus()
{
	blnOKToSetFocus = false; 
	if ( navigator.appName.indexOf("Microsoft") != -1 ) 
		{
		// just check for IE 4 since browsercheck.asp already screens out 3.0 and older 
		if ( navigator.appVersion.indexOf("MSIE 4.0") == -1 ) 
			blnOKToSetFocus = true; 
		} 

	if ( navigator.appName.indexOf("Netscape") != -1 ) 
		blnOKToSetFocus = true; 

	return blnOKToSetFocus;
}
