// Global variables/constants.
var intWindowHeight, intWindowWidth;
var isNS, isAllowableNS, isIE, isFF;
var intAvailHeight = window.screen.availHeight;
var	intAvailWidth = window.screen.availWidth;
var chatFormCols = 1;
var chatFormButtonLeft = 1;
var STATUS_SUCCESSFUL_REFRESH_CYCLE = "STATUS_SUCCESSFUL_REFRESH_CYCLE";
// Global variables/constants.
var WINDOW_HEIGHT_CONFIG_CHECK	= 550;
var WINDOW_WIDTH_CONFIG_CHECK	= 425;
var WINDOW_HEIGHT_XFER_NOTIFY	= 200;
var WINDOW_WIDTH_XFER_NOTIFY	= 325;
var WINDOW_WIDTH_800_600_CHAT_RESIZE	= 600;
var WINDOW_WIDTH_1280_1024_CHAT_RESIZE	= 640;
var intChatResizeWidth = ( (window.screen.width == 800) ? WINDOW_WIDTH_800_600_CHAT_RESIZE : WINDOW_WIDTH_1280_1024_CHAT_RESIZE );
isNS = ( navigator.appName == "Netscape" );
isAllowableNS = ( isNS && ( parseFloat(navigator.appVersion) < 5 ) );
isIE = ( navigator.appName == "Microsoft Internet Explorer" );
isFF = ( navigator.userAgent.indexOf("Firefox") != -1 );
isMac = ( navigator.platform == "MacPPC" );
var LOGOUT_REASON_LEAVE_HOME	= "leave_home";
var LOGOUT_REASON_LEAVE_EMAIL	= "leave_email";
var strPatronLogoutPage; //URL of patron logout page. Set in vrl_frames_patron.asp
function loadQueueDropDown(val) {
	top.window.oVRLFrames.refreshFrame("VRLTabs","vrl_tabs.asp?tabsel=queues&q_id=" + val);
}function loadActiveUsersDropDown(val,ostype) {
	top.window.oVRLFrames.refreshFrame("VRLChatSend", "vrl_message_host.asp?patronid=" + val + "&process=selpatron&ostype=" + ostype);
}function newPatronNotification(qid,qname,session_tab,patron_id) {
	var strPopUpURL, strPopUpTitle, strPopUpContentFile, strPopUpContentParms;
	var strPopUpWinParms;
	//	Set up window parms & open window.
	strPopUpWinParms		= "height=350,width=470,resizable=yes,scrollbars=yes";
	strPopUpContentFile		= "contentfile=vrl_info_patron.asp";
	strPopUpTitle			= "New Patron Alert!";
	strPopUpContentParms	= strPopUpContentFile + "&contentfileparms=patron_id=" + escape(patron_id) + ",patron_login_name=" + escape(patron_id) + ",context=queue,context_id=" + qid + ",new_patron=true,title=" + escape(strPopUpTitle);
	strPopUpURL				= "vrl_info_patron.asp?" + strPopUpContentParms;
	eval("oWin" + patron_id + " = top.window.openPopUpWinWithReturn(strPopUpURL,'PatronInfoPopUp" + patron_id + "',strPopUpWinParms);");
}function xferPatronNotification(from_host_name,patron_name) {
	var strPopUpURL, strPopUpTitle, strPopUpContentFile, strPopUpContentParms;
	var strPopUpWinParms;
	strPopUpContentFile		= "contentfile=vrl_alert_newpatron.asp";
	strPopUpContentParms	= "contentfileparms=XFER," + from_host_name + "," + patron_name;
	strPopUpTitle			= "Transferred Patron Alert!";
	strPopUpURL				= "/" + top.window.oVRLState.siteName + "/popUpFrames.asp?title=" + escape(strPopUpTitle) + "&" + strPopUpContentFile + "&" + strPopUpContentParms;
	strPopUpWinParms		= "height=" + WINDOW_HEIGHT_XFER_NOTIFY + ",width=" + WINDOW_WIDTH_XFER_NOTIFY + ",resize=yes";
	top.window.oXferPatronNotification = openPopUpWinWithReturn(strPopUpURL,"VRLPatronTransfer",strPopUpWinParms);
}function waitPatronNotification(title) {
	var strPopUpURL, strPopUpTitle, strPopUpContentFile, strPopUpContentParms;
	var strPopUpWinParms;
	strPopUpContentFile		= "contentfile=vrl_alert_newpatron.asp";
	strPopUpContentParms	= "contentfileparms=WAIT";
	strPopUpTitle			= title;
	strPopUpURL				= "/" + top.window.oVRLState.siteName + "/popUpFrames.asp?title=" + encodeURIComponent(strPopUpTitle) + "&" + strPopUpContentFile + "&" + strPopUpContentParms;
	strPopUpWinParms		= "height=250,width=250,resize=yes";
	top.window.oWaitPatronNotificationWin = openPopUpWinWithReturn(strPopUpURL,"VRLPatronWait",strPopUpWinParms);
}function refreshOpToOpWindow(url,name,parms) {
	var strWinParms;
	var strWinType;
	var bWinClosed;
	var oWin;
	var oWinLoc;
	strWinParms = "height=275,width=352,resizable=yes,scrollbars=yes";
	strWinType = eval("typeof(top.window." + name + ")");
	if ( strWinType != "undefined" ) {
		// There is a window.
		bWinClosed = eval("top.window." + name + ".closed");
		if ( bWinClosed ) {
			// The window has been closed; open it.
			oWin = openPopUpWinWithReturn(url,name,strWinParms);
			oWin.focus();
			eval("top.window." + name + " = oWin;");
		} else {
			// The window is open; just refresh the message window.
			eval("oWinLoc=top.window." + name + ".VRLOpToOpMsgs.document.location");
			eval("oWinLoc.href = rebuildLocationWithoutHash(oWinLoc);");
		}
	}else { // There is no window; open one.
		oWin = openPopUpWinWithReturn(url,name,strWinParms);
		oWin.focus();
		eval("top.window." + name + " = oWin;");
	}
}function rebuildLocationWithoutHash(obj_location) {
	return obj_location.protocol + "//" + obj_location.host + obj_location.pathname + obj_location.search;
}function openPopUpWin(url,name,parms) {
	var oPopUpWin;
	oPopUpWin = window.open(url,name,parms);
}function openPopUpWinWithReturn(url,name,parms) {
	var oPopUpWin;
	oPopUpWin = window.open(url,name,parms);
	return oPopUpWin;
}function loadChatItem(replytype,content,cobrowse_mode) {
	var strType;
	var strContent, strContent1;
	var oTarget, strLocation;
	strType = replytype.toUpperCase();
	switch(strType) {
		case "CLSEBENTRY":
			strContent = content.replace(/&#39;/g,"'");
			strContent1 = strContent.replace(/&#144;/g,"\n");
			oTarget = top.window.getFrame('VRLChatSend').document.frmVRLHostMessageSend.txtMessageBody;
			oTarget.value = strContent1;
			top.window.getFrame('VRLChatSend').document.frmVRLHostMessageSend.btnSend.disabled = false;
			break;
		case "CLSVRLBOOKMARK":
			var strLocalPath = "/" + top.window.oVRLState.VRLFQDN + "/";
			var bLocalLocation = ( content.indexOf(strLocalPath) != -1 )
			top.window.sendevent("loadChatItem: " + cobrowse_mode + ", PRO string = " + COBROWSE_MODE_PRO);
			top.window.oVRLState.currentCobrowseURL = content;
			// For a local location (on the VRL server) we'll load it directly - not through vrl_page_rewrite.asp
			if ( !bLocalLocation ) {
				strContent1 = content.replace(/http:/g,"http_");
			} else {
				strContent1 = content;
			}
			if ( cobrowse_mode != COBROWSE_MODE_PRO ) {
				if ( cobrowse_mode == top.window.COBROWSE_MODE_TEXTONLY ) {
					top.window.getFrame('VRLChatSend').document.frmVRLHostMessageSend.txtMessageBody.value = top.window.getFrame('VRLChatSend').document.frmVRLHostMessageSend.txtMessageBody.value + " " + content;
					top.window.getFrame('VRLChatSend').document.frmVRLHostMessageSend.btnSend.disabled = false;
					window.open(content);
				} else {
					if ( !top.window.oPagePushWindow.push ) {
						if ( !bLocalLocation ) {
							strLocation = "https://" + top.window.oVRLState.VRLFQDN + "/" + top.window.oVRLState.siteName + "/pagepush/" + strContent1;
						} else {
							strLocation = strContent1;
						}
					} else {
						if ( !bLocalLocation ) {
							strLocation = "https://" + top.window.oVRLState.VRLFQDN + "/" + top.window.oVRLState.siteName + "/pagepush/push/" + strContent1;
							top.window.oPagePushWindow.push = false;
						} else {
							strLocation = strContent1;
						}
					}
					top.window.oPagePushWindow.setLocation(strLocation);
					top.window.oPagePushWindow.focus();
				}
			} else {
				top.window.doConavigate(content, "");
				top.window.sendevent("doConavigate called in loadChatItem");
			}
			top.window.oVRLState.currentCobrowseURL = strContent1;
			break;
		case "CLSSHAREDFILE":
			var intFileID, strPath, strParms, oSFWin;
			var strRefreshFile;
			
			if ( document.location.href.indexOf("_patron.asp") > 0 ) {
				strRefreshFile = "vrl_process_patron.asp";
			} else {
				strRefreshFile = "vrl_process_host.asp";
			}
			strParms = "height=500,width=500,scrollbars=yes,status=yes,location=no,menubar=yes,resizable=yes";
			intFileID = content;
			// the cobrowse_mode parameter is used for shared files as a "load" parameter - a way to tell the function 
			// whether this is a file that is just being viewed, not pushed. The querystring parameter "load" below 
			// will be used in vrl_sharedfile_load.asp to determine whether or not to raise the "shared file sent"
			// and "new message" events - a "load" doesn't raise them.
			if ( cobrowse_mode == "load" ) {
				strPath = "vrl_sharedfile_load.asp?shared_file_id=" + intFileID + "&load=true";
			} else {
				strPath = "vrl_sharedfile_load.asp?shared_file_id=" + intFileID;
			}
			oSFWin = openPopUpWinWithReturn(strPath,"VRLSharedFileWindow" + intFileID,strParms);
			oSFWin.focus();
	}	// END switch
}function deleteReply(id) {
	var strLoc;
	var oTabWin = top.window.getFrame('VRLTabs');
	if ( confirm("Are you sure you want to delete this scripted reply?\n\nPress 'OK' to continue.") ) {
		strLoc = oTabWin.document.location.href;
		if ( oTabWin.document.location.search.length == 0 ) {
			oTabWin.document.location.href = strLoc + "?tabsel=scripts&replydelid=" + id;
		}else {
			// Remove the replydelid in the querystring there's already one there. If there is, that means the user has deleted one one the previous page load.
			strLoc = strLoc.replace(/&replydelid=\d+(\D|$)/i,"");		
			oTabWin.document.location.href = strLoc + "&replydelid=" + id;
		}
	}
}function deleteBookmark(id) {
	var strLoc;
	var oTabWin = top.window.getFrame('VRLTabs');
	if ( confirm("Are you sure you want to delete this bookmark?\n\nPress 'OK' to contiunue.") ) {
		strLoc = oTabWin.document.location.href;
		if ( oTabWin.document.location.search.length == 0 ) { // The querystring might be empty if the session vars were used to remember state.
			oTabWin.document.location.href = strLoc + "?tabsel=bookmarks&replydelid=" + id;
		}else { // Remove the delid in the querystring there's already one there. If there is, that means the user has deleted one one the previous page load.
			strLoc = strLoc.replace(/&delid=\d+(\D|$)/i,"");		
			oTabWin.document.location.href = strLoc + "&delid=" + id;
		}
	}
} function deleteSharedFile(id) {
	var strLoc;
	var oTabWin = top.window.getFrame('VRLTabs');
	if ( confirm("Are you sure you want to delete this shared file?\n\nPress 'OK' to contiunue.") ) {
		strLoc = oTabWin.document.location.href;
		if ( oTabWin.document.location.search.length == 0 ) { // The querystring might be empty if the session vars were used to remember state.
			oTabWin.document.location.href = strLoc + "?tabsel=files&replydelid=" + id;
		}else { // Remove the replydelid in the querystring there's already one there. If there is, that means the user has deleted one one the previous page load.
			strLoc = strLoc.replace(/&shared_file_delid=\d+(\D|$)/i,"");		
			oTabWin.document.location.href = strLoc + "&shared_file_delid=" + id;
		}
	}
} function timedWinClose(seconds) {
	var intMilliSeconds;
	intMilliSeconds = seconds*1000;
	setTimeout("top.window.opener.top.window.focus();top.window.close();",intMilliSeconds);
} function processSaveXScriptSelection(save_val,parms) {
	if ( !save_val ) {
		if ( confirm("Are you sure?\n\nYou will not get another opportunity to save the transcript for this session.") ) {
			document.frmSaveXScript.action = "vrl_xscript_patronlogout.asp?process=nosave&contentfileparms=" + parms;
			return true;
		}else
			return false;
	}
} function popupTimeout(timedout,usertype) {
	if ( timedout ) {
		if ( usertype.toUpperCase() == "CLSVRLHOST" ) {
			alert("Your session has timed out!\n\nTo access the system administrative functions please login again.");
			top.window.opener.document.location.href = "vrleb_intro.asp?process=timedout";
		}else {
			alert("Your session has timed out!\n\nYou will be returned to the home screen.");
			top.window.opener.document.location.href = "vrleb_intro.asp";
		}
		top.window.close();
	}
} function confirmEndPatronSession(tabsel, patronid) {
	if ( confirm("Are you sure you want to end this patron's session?\n\nPress 'OK' to continue.") )
		document.location.href = "vrl_tabs.asp?tabsel=" + tabsel + "&bootid=" + patronid + "&process=dis_es_link";
} function chkDate(mo,day,year) {
	var intNumDays;
	var bGoodMonth, bGoodDay, bGoodYear;
	bGoodMonth = ( mo.search(/^[\d]{1,4}$/) != -1 );
	bGoodDay = ( day.search(/^[\d]{1,4}$/) != -1 );
	bGoodYear = ( year.search(/^[\d]{1,4}$/) != -1 );
	if ( bGoodMonth && bGoodDay && bGoodYear ) {
		if ( ( mo > 12 ) || ( mo < 1 ) )
			bGoodMonth = false
		else
			bGoodMonth = true

		if ( (mo == 1) || (mo == 3) || (mo == 5) || (mo == 7) || (mo ==  8) || (mo == 10) || (mo == 12) ) {
			intNumDays = 31;
		} else if ( (mo == 2) ) {
			if ( isLeapYear(year) ) {
				intNumDays = 29;
			} else {
				intNumDays = 28;
			}
		} else {
			intNumDays = 30;
		}
		if ( (day > intNumDays) || !bGoodMonth ) {
			alert(mo + "-" + day + "-" + year + " is an invalid date!\n\nPlease change the date and submit your request again.");
			return false;
		} else {
			return true;
		}
	} else {
		alert(mo + "-" + day + "-" + year + " is an invalid date!\n\nPlease change the date and submit your request again.");
		return false;
	}
}function isLeapYear(year) {
	return ( (year % 4) == 0 ) && ( ( !(year % 100) == 0 ) || ( (year % 400) == 0 ) );
}function hasHTMLTags(txt) {
	if ( txt.indexOf("<") != -1 || txt.indexOf(">") != -1 ) {
		alert("The characters '<' and '>' are not allowed in the message text field!");
		return false;
	}else {
		return true;
	}
}function goBack(oWin) {
	oWin.history.back();
}function rptTypeOnChangeRefresh(option_selected) {
	document.location.href = "http://" + document.location.host + document.location.pathname + "?rpt_sel=" + option_selected;
}function openPatronChatWindow(entry_mode) {
	var strParms;
	var strPage;
	var intAvailHeight, intAvailWidth;
	var intCobrowseHeight;
	var intWinHeight, intWinWidth;
	intAvailHeight = window.screen.availHeight;
	intAvailWidth = window.screen.availWidth;
	intCobrowseHeight = intAvailHeight - 485;
	strPage = "vrl_frames_patron.asp";
	if ( entry_mode == top.window.COBROWSE_MODE_CLASSIC ) {
		intWinHeight	= (intAvailHeight * .9);
		intWinWidth		= 250;
		strParms		= "location=no,status=no,height=" + intWinHeight + ",width=" + intWinWidth + ",toolbar=no,resizable=yes,scrollbars=yes,menubar=no,screenX=0,screenY=0,top=0,left=0";

		top.window.VRLChatWin = window.open(strPage,"VRLplusBrowserConfig",strParms);
	}else {
		intWinHeight	= (intAvailHeight - 200);
		intWinWidth		= window.screen.availWidth - 100;
		strParms		= "location=no,status=no,height=" + intWinHeight + ",width=" + intWinWidth + ",toolbar=no,resizable=yes,scrollbars=yes,menubar=no,screenX=0,screenY=0,top=0,left=0";
		top.window.VRLChatWin = window.open(strPage,"VRLplusBrowserConfig",strParms);
		top.window.VRLChatWin.resizeTo(intWinWidth, intWinHeight + 29);
	}
}function openPatronVRLWindow(fqdn, cobrowse_domain, site_name, cobrowse_mode) {
	var strParms;
	var strPage;
	var intAvailHeight, intAvailWidth;
	var intCobrowseHeight;
	var intWinHeight, intWinWidth;
	intAvailHeight = window.screen.availHeight;
	intAvailWidth = window.screen.availWidth;
	intCobrowseHeight = intAvailHeight - 485;
	strPage = "https://" + fqdn + "/" + site_name + "/vrl_frames_patron.asp?cobrowse_mode=" + cobrowse_mode + "&cobrowse_domain=" + cobrowse_domain + "&is_net_xfer=" + is_net_xfer + "&switch_over=" + switch_over;
	if ( cobrowse_mode.toUpperCase() == top.window.COBROWSE_MODE_PRO ) {
		if ( isNS && !isMac ) {
			intWinHeight	= (intAvailHeight * .9);
			intWinWidth		= (window.screen.availWidth * .9);
			strParms		= "location=no,status=no,height=" + intWinHeight + ",width=" + intWinWidth + ",toolbar=no,resizable=no,scrollbars=yes,menubar=no,screenX=0,screenY=0,top=0,left=0";

			window.open(strPage,"VRLplusBrowserConfig",strParms);
		}else {
			intWinHeight	= (intAvailHeight - 200);
			intWinWidth		= window.screen.availWidth - 100;
			
			top.window.resizeTo(intWinWidth, intWinHeight + 29);
			top.window.location.href = strPage;
		}
	}else {
		intWinHeight	= (intAvailHeight - 125);
		intWinWidth		= 275;
		strParms		= "location=no,status=no,height=" + intWinHeight + ",width=" + (intAvailWidth - intWinWidth) + ",toolbar=no,resizable=yes,scrollbars=yes,menubar=no,screenX=275,screenY=0,top=0,left=275";
		top.window.resizeTo(intWinWidth, intWinHeight + 29);
		top.window.location.href = strPage;
	}
}function openHostVRLWindow_sb1(fqdn, site_name, browse_capability, vdesk_array, vmversion) {
	var oVRLWin;
	var strPage;
	var bSingleCheckBox = ( typeof(vdesk_array.checked) != "undefined" );
	strVDeskList = "";
	// If typeof(vdesk_array.length) is a number, we have an array, i.e. more than one VDesk in the cb list.
	if ( !bSingleCheckBox ) {
		if ( typeof(vdesk_array.length) == "number" ) {
			for ( i = 0; i < vdesk_array.length; i++ ) {
				if ( vdesk_array[i].checked ) {
					strVDeskList = strVDeskList + vdesk_array[i].value + ",";
				}
			}
			strVDeskList = strVDeskList.replace(/,$/,"");
		}else {
			strVDeskList = vdesk_array.value;
		}
	}else {
		if ( vdesk_array.checked ) {
			strVDeskList = vdesk_array.value;
		}
	}
	if ( strVDeskList.length == 0 ) {
		alert('You must select at least one Virtual Desk to enter Live Chat!');
		return false;
	}else {
		strPage	= "https://" + fqdn + "/" + site_name + "/vrl_frames_host.asp?browse_cap=" + browse_capability + "&vmversion=" + vmversion + "&vdesk_list=" + strVDeskList;
		
		oVRLWin = openPopUpWinWithReturn(strPage,"VRLplusHost", setChatWinParms(browse_capability));
		top.window.close();
	}
}function setChatWinParms(browse_capability) {
	var strParms = "";
	if ( browse_capability == top.window.COBROWSE_MODE_TEXTONLY ) {
		strParms = "width=380,height=" + ( window.screen.availWidth * .9 ) + ",status=no,resizable=yes,scrollbars=yes,location=no,menubar=no,screenX=0,screenY=0,top=0,left=0";
	} else {
		strParms = "height=" + ( window.screen.availHeight * .9 ) + ",width=" + ( window.screen.availWidth * .9 ) + ",status=no,resizable=yes,scrollbars=yes,location=no,menubar=no,screenX=0,screenY=0,top=0,left=0";
	}
	return strParms;
}function openHostVRLWindow(fqdn, site_name, cobrowse_domain, cobrowse_mode) {
	var oVRLWin;
	var strParms;
	var strPage;
	if ( cobrowse_mode == top.window.COBROWSE_MODE_PRO ) {
		if ( isAllowableNS ) {
			strParms = "height=" + ( window.screen.availHeight * .9 ) + ",width=" + ( window.screen.availWidth * .9 ) + ",status=no,resizable=no,scrollbars=yes,location=no,menubar=no,screenX=0,screenY=0,top=0,left=0";
		}
		else {
			strParms = "height=" + ( window.screen.availHeight * .9 ) + ",width=" + ( window.screen.availWidth * .9 ) + ",status=no,resizable=yes,scrollbars=yes,location=no,menubar=no,screenX=0,screenY=0,top=0,left=0";
		}
	}else {
		strParms	= "height=" + ( window.screen.availHeight * .9 ) + ",width=" + ( window.screen.availWidth * .4 ) + ",status=no,resizable=yes,scrollbars=yes,location=no,menubar=no,screenX=0,screenY=0,top=0,left=0";
	}
	strPage	= "https://" + fqdn + "/" + site_name + "/vrl_frames_host.asp?cobrowse_mode=" + cobrowse_mode + "&cobrowse_domain=" + cobrowse_domain; //"/site_name/vrl_app_host.asp";
	oVRLWin = openPopUpWinWithReturn(strPage,"VRLplusHost",strParms);
}function reopenHostVRLWindow(fqdn, site_name, cobrowse_domain, current_cobrowse_mode) {
	var oVRLWin;
	var strParms;
	var strPage;
	if ( current_cobrowse_mode == top.window.COBROWSE_MODE_PRO ) {
		strParms	= "height=" + ( window.screen.availHeight - 75 ) + ",width=" + ( window.screen.availWidth - 50 ) + ",status=no,resizable=yes,scrollbars=yes,location=no,menubar=no,screenX=0,screenY=0,top=0,left=0";
	}else {
		strParms	= "height=" + ( window.screen.availHeight - 75 ) + ",width=" + ( window.screen.availWidth/2 ) + ",status=no,resizable=yes,scrollbars=yes,location=no,menubar=no,screenX=0,screenY=0,top=0,left=0";
	}
	strPage	= "https://" + fqdn + "/" + site_name + "/vrl_frames_host.asp?cobrowse_domain=" + cobrowse_domain + "&process=cb_reconfig"; //"/site_name/vrl_app_host.asp";
	oVRLWin = openPopUpWinWithReturn(strPage,"VRLplusHost",strParms);
}function isUndefined(obj) {
	var bUndefined;
	bUndefined = ( typeof(obj) == "undefined" );
	return bUndefined;
}function openConfigCheckWindow_sb(user_type) {
	var oCheckWin;
	var strParms;
	var strPage;
	if ( user_type == top.window.USER_TYPE_PATRON ) {
		strPage	= "vrl_config_check_sb.asp?user_type=" + user_type.toUpperCase() + "&browse_mode=" + top.window.oVRLState.VRLCobrowseMode;
	}
	else {
		strPage	= "vrl_config_check_sb.asp?user_type=" + user_type.toUpperCase();
	}
	strParms = "height=" + WINDOW_HEIGHT_CONFIG_CHECK + ",width=" + WINDOW_WIDTH_CONFIG_CHECK + ",resizable=yes,scrollbars=yes,location=no,menubar=no,screenX=0,screenY=0,top=0,left=0";
	top.window.sharedbrowser.document.location.href = strPage;
}function openConfigCheckWindow(user_type) {	
	var oCheckWin;
	var strParms;
	var strPage;
	strPage		= "vrl_config_check.asp?user_type=" + user_type.toUpperCase();
	strParms	= "height=" + WINDOW_HEIGHT_CONFIG_CHECK + ",width=" + WINDOW_WIDTH_CONFIG_CHECK + ",resizable=yes,scrollbars=yes,location=no,menubar=no,screenX=0,screenY=0,top=0,left=0";
	top.window.oConfigWin = openPopUpWinWithReturn(strPage,"VRLplusBrowserConfig",strParms);
	if ( !checkForWin(top.window.oConfigWin) ) {
		openPopUpWin(strPage,"VRLplusBrowserConfig",strParms);
	}
}function patronOfflineProcessing(method, patronid) {
	var strMethod = method.toLowerCase();
	var intNumArgs = arguments.length;
	var intDBPatronID;
	var strLogoutParms = "?process=" + strMethod + "&patronid=" + patronid + "&virtual_desk_id=" + top.window.oVRLState.VRLVirtualDeskID;
	strLogoutParms = strLogoutParms + "&dbpatronid=" + top.window.oVRLState.VRLDBPatronID;
	top.window.oVRLState.offlineMethod = strMethod;
	if ( strMethod == 'close' || strMethod == 'logout' || strMethod == 'remove' || strMethod == 'open_quit' || strMethod == 'host_offline' || strMethod == top.window.LOGOUT_REASON_LEAVE_EMAIL || strMethod == top.window.LOGOUT_REASON_LEAVE_HOME ) {
		top.window.location.replace(strPatronLogoutPage + strLogoutParms);
	}else {
		top.window.oVRLState.refreshPage = 'blank.htm';
		top.window.getFrame('VRLChatSend').document.location.href = 'vrl_message_patron.asp?disable_chat=true';
	}
}function onWinClose() {
	chatWinCloseOut_alt();
}function chatWinCloseOut_alt() {
	var strBase = "https://" + top.window.oVRLState.VRLFQDN;
	var bDoLogoutProcessing, bNSWindowResize, bNetXfer, bReconfigureCobrowse, bClassicSwitchOver;
	var bIsOperator = ( top.window.oVRLState.myUserType == top.window.USER_TYPE_OPERATOR );
	var bIsPatron = ( top.window.oVRLState.myUserType == top.window.USER_TYPE_PATRON );
	var bOpHasActivePatrons = ( top.window.oVRLState.VRLactiveUserID != "0" );
	var bLogoutConfirm, strConfMsg;
	var oAdminWin;
	
	bNSWindowResize			= ( top.window.isAllowableNS && top.window.oVRLState.offlineMethod.toUpperCase() == "WINDOW_CLOSED" );
	bClassicSwitchOver		= top.window.oVRLState.offlineMethod.toUpperCase() == "CLASSIC_SWITCHOVER";
	bReconfigureCobrowse	= top.window.oVRLState.reconfigureCobrowse;
	bDoLogoutProcessing		= !bNSWindowResize && !bReconfigureCobrowse && !bClassicSwitchOver;
	
	top.window.sendevent('bReconfigureCobrowse=' + bReconfigureCobrowse);
	
	checkForWinAndClose(top.window.oWaitPatronNotificationWin);
	checkForWinAndClose(top.window.oNewPatronNotificationWin);
	checkForWinAndClose(top.window.oXferPatronNotification);
	
	if ( bDoLogoutProcessing ) {
		if ( !top.window.oVRLState.loggedOut ) {
			if ( top.window.oVRLState.VRLCobrowseMode.toUpperCase() == top.window.COBROWSE_MODE_PRO ) {
				top.window.hbapi.HBExitSession();
				top.window.hbapi.HBLogout();
			}
			if ( bIsOperator ) {
				if ( bOpHasActivePatrons && top.window.oVRLState.offlineMethod.toUpperCase() == "LOGOUT" ) {
					strConfMsg = "There are still patrons in your active session, are you sure you want to go offline?\n\nOK = Yes\nCancel = No";
					bLogoutConfirm = confirm(strConfMsg);
				}else {
					bLogoutConfirm = true;
				}
				if ( bLogoutConfirm ) {
					if ( top.window.oVRLState.reconfigureCobrowse ) {
						top.window.oVRLState.reconfigureCobrowse = false;
					}
					top.window.oVRLState.loggedOut = true;
					window.open(strBase + "/" + top.window.oVRLState.siteName + "/vrl_go_offline.asp","VRLOfflineProcessingWin","height=10,width=10,location=no");
					top.window.close();
				}
			}else if ( bIsPatron ) {
				if ( top.window.oVRLState.offlineMethod.toUpperCase() != "OPEN" ) {
					// We only need to refresh the main window to log the patron out if they haven't already been logged out as a result of having their session ended by the operator.
					
					//top.window.refreshPatronMainWin(strBase + '/' + top.window.oVRLState.siteName + '/vrl_logout_patron.asp?process=' + top.window.oVRLState.offlineMethod + '&patronid=' + top.window.oVRLState.VRLSessionID);
					var strMethod = top.window.oVRLState.offlineMethod;
					
					top.window.oVRLState.offlineMethod = "logout";
					top.window.location.href = strBase + '/' + top.window.oVRLState.siteName + '/vrl_logout_patron.asp?process=' + strMethod + '&patronid=' + top.window.oVRLState.VRLSessionID;
				}
				if ( top.window.oVRLState.reconfigureCobrowse ) {
					top.window.oVRLState.reconfigureCobrowse = false;
				}
				top.window.oVRLState.loggedOut = true;
			}
		}
	}
	top.window.sendevent('...chatWinCloseOut() done.');
}function refreshAdminWin() {
	var oAdminWin;
	oAdminWin = window.open('','VRLplusAdminWin');
	if ( oAdminWin.document.location.href == "about:blank" ) {
		oAdminWin.document.location.href = '/' + top.window.oVRLState.siteName + '/vrleb_admin.asp';
	}
	oAdminWin.focus();
}function checkForWinAndClose(obj_win) {
	if ( checkForWin(obj_win) ) {
		obj_win.close();
	}
}function checkForWin(obj_win) {
	try {
		if ( typeof(obj_win) != "undefined" ) {
			if ( obj_win == null ) {
				return false;
			}else if ( !obj_win.closed ) {
				return true;
			}else {
				return false;
			}
		}else {
			return false;
		}
	} catch (e) {
		top.window.sendevent('An error has ocurred attempting to close a window: ' + e);
		return false;
	}
}function enterPressed(e) {
    var myChar;
	var KEY_ENTER = 13;
    if (document.all) {
        e = window.event;
		myChar = e.keyCode;
    }else {
        if (document.layers) {
 			var myChar = e.which;
 		}
	}
    if ( myChar == KEY_ENTER ) {
		
        if (document.layers) {
            return true;
        }else if (document.all) {
            e.returnValue = true;
            return true;
        }
    }
}function submitOnEnter(e) {
	if ( enterPressed(e) ) {
		submitForm();
		return false;
	}
}function refreshPatronMainWin(url) {
	//var oMainWin;
	var intResizeHeight = intAvailHeight * (.75);
	var intResizeWidth	= intAvailWidth * (.75);
	top.window.oMainWin = window.open(url,'VRLplusPatronOnline');
}function realignClassicBrowseWin() {	
	if ( isAllowableNS || isIE ) {
		var intChatWinLeft = top.window.screenLeft;
		var intChatWinTop = top.window.screenTop;
		var intLeftOffset = 377;
		var intTopOffset = 72;
		top.window.oPagePushWindow.moveTo(intChatWinLeft + intLeftOffset, intChatWinTop + intTopOffset);
	}
}/* ===================================================================
/  Page push window object & methods
/  =================================================================== */
function pagePushWindow_refresh() {
	// See if the window exists and our object's location is set to something "valid."
	top.window.sendevent('Refreshing page push window.');
	if ( !isUndefined(this.winRef) ) {
		if ( !this.winRef.closed ) {
			this.winRef = top.window.openPopUpWinWithReturn(this.location, this.name, this.parms);
		}else {
			this.winRef = top.window.openPopUpWinWithReturn(this.location, this.name, this.parms);
		}
	}
	top.window.sendevent('Done refreshing page push window.');
}function pagePushWindow_setLocation(location) {
	// See if the window exists and our object's location is set to something "valid."
	this.location = location;
	if ( this.frameindex != null ) {
		try {
			if ( this.name != top.window.frames[this.frameindex].name ) {
				this.name = top.window.frames[this.frameindex].name;
				//top.window.frames[this.frameindex].name = this.name;
			}
		}catch (e) {
			//alert("Cannot load location. Error: " + e);
			//alert("Location: " + top.window.frames[this.frameindex].document.location.href);
			//alert("The browse frame appears to have a problem with the current page.");
		}
	}
	try {
		this.winRef = window.open(this.location, this.name, this.parms);
		top.window.sendevent('Setting page push location: ' + location);
	}catch (e) {
		alert("Error: " + e);
		alert("Location: " + top.window.frames[this.frameindex].document.location.href);
	}
	top.window.sendevent('Done setting page push location: ' + location);
}function pagePushWindow_closed() {
	if ( !isUndefined(this.winRef) ) {
		return this.winRef.closed;
	}
}function pagePushWindow_close() {
	if ( !isUndefined(this.winRef) ) {
		if ( !this.closed() ) {
			this.winRef.close();
		}
	}
}function pagePushWindow_focus() {
	if ( !isUndefined(this.winRef) ) {
		if ( !this.closed() ) {
			this.winRef.focus();
		}
	}
}function pagePushWindow_open() {
	this.winRef = top.window.openPopUpWinWithReturn(this.location, this.name, this.parms);
}function pagePushWindow_moveTo(x, y) {
	if ( !isUndefined(this.winRef) ) {
		if ( !this.winRef.closed ) {
			this.winRef.moveTo(x, y);
		}
	}
}function pagePushWindow(location, name, frame_index, parms) {
	// Properties
	this.winRef;
	this.location		= location;
	this.name			= name;
	this.frameindex		= frame_index;
	this.parms			= parms;
	this.closed			= pagePushWindow_closed;
	this.push			= false;
	// Methods
	this.setLocation	= pagePushWindow_setLocation;
	this.refresh		= pagePushWindow_refresh;
	this.open			= pagePushWindow_open;
	this.close			= pagePushWindow_close;
	this.focus			= pagePushWindow_focus;
	this.moveTo			= pagePushWindow_moveTo;
}function vrlFrames_readyToInit() {
	var bConavDefined = !isUndefined(this.conavframesetLoaded);
	var bHBApiDefined = !isUndefined(this.hbapiLoaded);
	var bapiFramesDefined = !isUndefined(this.apiFramesLoaded);
	if ( bapiFramesDefined ) {
		return true;
	}else {
		return false;
	}
}function vrlFrames_refreshFrame(frame_name, frame_document_path) {
	var strTmpFrame;
	var bFrameLoaded;
	var oTmpWin = window.open('', frame_name);
	bFrameLoaded = eval("this." + frame_name + "Loaded");
	if ( bFrameLoaded ) {
		oTmpWin.document.location.replace(frame_document_path);
	}
}function vrlFrames() {
	this.refreshFrame	= vrlFrames_refreshFrame;
	this.readyToInit	= vrlFrames_readyToInit;
}function getFrame(frame_name) {
	var oWin = window.open('',frame_name);
	return oWin;
}function listObjectProperties(obj) {
	var strNames;
	for ( i in obj ) {
		strVal = eval("obj." + i)
		strNames += i + "=" + strVal + "<BR>";
	}
	return strNames;
} function refreshTabs(tab_name) {
	//alert("refreshTabs: selected=" + top.window.oVRLState.tabSelected + ", tab_name=" + tab_name);
	if ( top.window.oVRLState.tabSelected == tab_name ) {
		top.window.oVRLFrames.refreshFrame('VRLTabs','vrl_tabs.asp');
	}
}
function ChatFormResizer(obj_doc, obj_send_name, obj_message_name) {
	this.textOnlyEnabled = false;
	this.doc			= obj_doc;
	this.docBody		= obj_doc.body;
	this.sendButton		= obj_doc.getElementById(obj_send_name);
	this.messageBox		= obj_doc.getElementById(obj_message_name);
	this.resize			= ChatFormResizer_resize;
	this.setAltVal		= ChatFormResizer_setAltVal;
	this.setColsDenom	= ChatFormResizer_setColsDenom;
	this.getButtonOffset= ChatFormResizer_getButtonOffset;
	this.getAltDenom	= ChatFormResizer_getAltDenom;
	
	this.setColsDenom();
}function ChatFormResizer_resize() {
	var intCols = top.window.chatFormCols;
	var intLeft = top.window.chatFormButtonLeft;
	
	// Set button position.
	this.sendButton.style.left = intLeft;
	// Set text box width.
	this.messageBox.cols = intCols;
	
	intCols = this.docBody.clientWidth/this.colsDenom + this.setAltVal();
	intLeft = this.docBody.clientWidth - this.getButtonOffset() + 'px';
	
	top.window.chatFormCols = intCols;
	top.window.chatFormButtonLeft = intLeft
	
	// Set button position.
	this.sendButton.style.left = intLeft;
	// Set text box width.
	this.messageBox.cols = intCols;
}function ChatFormResizer_setColsDenom() {
	if ( isIE ) {
		this.colsDenom = 7;
	}else if ( isFF ) {
		this.colsDenom = 7.1;
	}else {
		this.colsDenom = 7;
	}
}function ChatFormResizer_setAltVal() {
	var intAlt, intNorm;
	
	intNorm = this.colsDenom * 100;

	if ( isIE ) {
		intAlt = (this.docBody.clientWidth-intNorm)/this.getAltDenom();
	}else if ( isFF ) {
		intAlt = (this.docBody.clientWidth-intNorm)/this.getAltDenom();
	}else {
		intAlt = (this.docBody.clientWidth-intNorm)/this.getAltDenom();
	}
	return intAlt;
}function ChatFormResizer_getButtonOffset() {
	if ( this.textOnlyEnabled ) {
		return 71;
	} else {
		return 66;
	}
}function ChatFormResizer_getAltDenom() {
	if ( this.textOnlyEnabled ) {
		return 40;
	} else {
		return 45;
	}
}function toggleAdminMenu(isSB) {
	var padding;
	if (isSB == 'True') { padding = "150px"; } else { padding = "97px"; }
	if (document.getElementById("adminMenuDD").style.left == "-999em") { document.getElementById("adminMenuDD").style.left = padding; document.getElementById("adminMenuDD").style.top = "48px";  }
	else { document.getElementById("adminMenuDD").style.left = "-999em" }
}