// JavaScript Document
// Added by MP Haagsma, 31 March 2005.
// useful javascript navigation functions

 function f_cancel(ls_url) {
	// alert(ls_url); // debug 
	// on a button, call like this: 
	// onClick="return f_cancel('/aglc_secure/Raffle_U10k/raffle/licence_new.jsp')"
	
	window.location =  ls_url  ;

}

//////////////////////////////////////////////////////////////////////////////
//
//	Method:  		f_setFocusToField(adw,  aColumnName, row)
//	
//	Arguments:		adw - the datawindow control (object)
//					aColumnName - the column (object)
//					row - the row
//
//	Returns:  		none
//						
//	Description:  	Set the focus to a specific field  
//					in a specific datawindow.  
//					Note: findControl() is in dwcomn.js     
//
//////////////////////////////////////////////////////////////////////////////		
function f_setFocusToField(adw,  aColumnName, row)  {
 	var oSelect = adw.findControl (aColumnName, row, true)
		if (oSelect != null){
			oSelect.focus();
		} 
}

//////////////////////////////////////////////////////////////////////////////
//
//	Method:  		f_resetDDLB( aDWControl, aColName, aJSRow )
//	
//	Arguments:		 DWName, ColName and RowNo 
//
//	Returns:  		none
//						
//	Description:  	Empties a DDLB dynamically. 
//
/* * * * * * * *
First line in the function maps the ColName and RowNo 
into a control referring to that specific item on the page.
courtesy of: MicK, Michael Kramer Rilau, Cynergy Systems, Europe
*****************************/	
// Note: findControl() is in dwcomn.js     
//
//////////////////////////////////////////////////////////////////////////////		

function f_resetDDLB( aDWControl, aColName, aJSRow ) {
  var oSelect = aDWControl.findControl (aColName, aJSRow, true)
    for(var i=0; i<oSelect.options.length; i++ ) {
      if (i == oSelect.selectedIndex) { /* SKIP to avoid losing current value */ } else {
        oSelect.options.remove(i);
        i--;
      }
    }
  };

//////////////////////////////////////////////////////////////////////////////
//
//	Method:  		f_getHelpContextId(as_HelpPageName, as_CallingPageName)
//	
//	Arguments:		as_HelpPageName 	- the help apps start page. 
//					as_CallingPageName 	- the webpage name
//
//	Returns:  		The Help Context id: if the page is found, the number, else, 0. 
//						
//	Description:  	Function is used to return the context id used by RoboHelp to present
//					a specific help page.  
//  Modifications:
// 2006.03.22	- Herb, replace with functions from copied aglc_secure.
//////////////////////////////////////////////////////////////////////////////		
function f_getHelpContextId(as_HelpPageName, as_CallingPageName){

	var _s_HelpPageName_liqliclist = "/aglc_public/aglc_site/liquor/help/LiquorLicenseeList.htm";

	switch(as_CallingPageName)
		{
		case "lsearch.jsp":
			as_HelpPageName.setValue( _s_HelpPageName_liqliclist);
			return 10;
			break
			
		case "liquorlicenseelist_html.jsp":
			as_HelpPageName.setValue( _s_HelpPageName_liqliclist);
			return 12;
			break
	
		default:
			as_HelpPageName.setValue( _s_HelpPageName_liqliclist);
			return 0;
		}
}

//////////////////////////////////////////////////////////////////////////////
//
//	Method:  		f_help(as_url)
//	
//	Arguments:		as_url - the url of the calling page
//
//	Returns:  		none 
//						
//	Description:  	Open the supplied help file. 
//					Check for a context id for the calling page and if found
//					open the context page in a single paine window.
//  Modifications:
// 2006.03.22	- Herb, replace with functions from copied aglc_secure.
//
//////////////////////////////////////////////////////////////////////////////
 function f_help(as_url){
	 
	var lv_helppage = "";
	
	// Remove the directory path from start of the URL
	var sPageAndParms = as_url.substring(as_url.lastIndexOf('/') + 1);
		
	// Remove any trailing page parameters
	var li_pos = sPageAndParms.indexOf(';')
	if (li_pos > 0){
		var sPage = sPageAndParms.substring(0, li_pos );
	}else{
		sPage = sPageAndParms;
	}
	
	var ls_helpLocation = new param;
	// Get the Help Context id.
	var li_index = f_getHelpContextId(ls_helpLocation,sPage);

	
	// Call single paine help window for a context page or dual-paine for a general call.
	if ( li_index > 0){
		lv_helppage = "javascript:RH_ShowHelp(0,'" + ls_helpLocation.getValue() + ">AGLC_default_single', HH_HELP_CONTEXT," + li_index + "\);" ;
	}else{
		lv_helppage = "javascript:RH_ShowHelp(0,'" + ls_helpLocation.getValue() + ">AGLC_default', HH_HELP_CONTEXT," + 0 + "\);" ;
	}
	window.location = lv_helppage;

 }
 

//////////////////////////////////////////////////////////////////////////////
//
//	Method:  		param
//	
//	Arguments:		none
//
//	Returns:  		none
//						
//	Description:  	Sets param array value, used by f_help() and 
//                  f_getHelpContextId(), to pass the reference value for 
//                  different help file name.
//
//          Note:   Ihis func is kind of acting as a hash tab.
//
//////////////////////////////////////////////////////////////////////////////
function param()
{
    this.array = new Array(1);
 
    this.setValue = function(v) { this.array[0] = v; }
    this.getValue = function()  { return this.array[0]; }
}

 