<!--
/* *********************************************************************
* Programmer Name  : Robert McLeish
* Web Site         : http://www.foodcity.com.au
* E-Mail           : rmcleish@australianet.com.au
* Module Name      : CSScripts
* Module Filename  : csscripts.js
*
**********************************************************************
* Comments         : This file holds all standard (common) client-side
*					 javascript routines
*
**********************************************************************/

// **** global variables ****
// String that holds the last style for an element
var strOldStyleName;						

function bName() {
	// return 1 for Internet Explorer
	if (navigator.appName == "Microsoft Internet Explorer")  {
		return 1;
	}

	// return 2 for Navigator
	if (navigator.appName == "Netscape") {
		return 2;
	}
	
	// return 0 for other browsers
	return 0;
}

function netscapeHandleKeyPress() {
	//do netscape check 
	if (bName()==2) {
		document.captureEvents(Event.KEYPRESS) 
		document.onkeypress = submitEnter
	} 
}

function gotoTop()
{
	/* *********************************************************************
	* Programmer Name  : Robert McLeish
	* Web Site         : http://www.foodcity.com.au
	* E-Mail           : rmcleish@australianet.com.au
	* Module Name      : CSScripts
	* Module Filename  : csscripts.js
	* Procedure Name   : gotoTop
	* Parameters	   : None 
	*					
	**********************************************************************
	* Comments         : Jumps to top of page
	*
	**********************************************************************/
	window.location.href = '#';
}
   
function disableButton()
{
	/* *********************************************************************
	* Programmer Name  : Robert McLeish
	* Web Site         : http://www.foodcity.com.au
	* E-Mail           : rmcleish@australianet.com.au
	* Module Name      : CSScripts
	* Module Filename  : csscripts.js
	* Procedure Name   : disableButton
	* Parameters	   : None 
	*					
	**********************************************************************
	* Comments         : This routine prevents the user from using the right
	*					 mouse button
	*
	**********************************************************************/
	// check for control key being pressed - administrators back door which 
	// bypasses this routine
	if (!event.ctrlKey) {
		// check for right mouse button
		if (event.button == 2)
		{
		// show message
		alert("Sorry, this web application does not allow right clicking.")
		}
	}		
}

function forceNumericInput(e)
{
	/* *********************************************************************
	* Programmer Name  : Robert McLeish
	* Web Site         : http://www.foodcity.com.au
	* E-Mail           : rmcleish@australianet.com.au
	* Module Name      : CSScripts
	* Module Filename  : csscripts.js
	* Procedure Name   : forceNumericInput
	* Parameters	   : e = exception that called this routine
	*					
	**********************************************************************
	* Comments         : Allows the use of the enter key to submit form
	*					 Looks for the enter key, passes any other key
	*					 If enter key pressed then calls sendData routine.
	*
	**********************************************************************/
	// holds the keycode of the key that was pressed
	var keycode;
	// if a window event has just occurred then grab its keycode
	if (window.event) keycode = window.event.keyCode;
	// else, if a exception has just occurred then grab its keycode
	else if (e) keycode = e.which;
	// otherwise pass keycode along the event chain
	else return true;
	
	if (keycode==8 || keycode==46) return true;	
	else if (keycode==9) return true;
	else if (keycode==13) return true;
	else if (keycode>95 || keycode<106)	return true;
	else if (keycode<48 || keycode>57) {		
		window.event.cancelBubble = true;
		window.event.returnValue = false;		
		alert("Numbers only please!");
		return false;
	}
	else return true;
}

function submitEnter(e)
{
	/* *********************************************************************
	* Programmer Name  : Robert McLeish
	* Web Site         : http://www.foodcity.com.au
	* E-Mail           : rmcleish@australianet.com.au
	* Module Name      : CSScripts
	* Module Filename  : csscripts.js
	* Procedure Name   : submitEnter
	* Parameters	   : e = exception that called this routine
	*					
	**********************************************************************
	* Comments         : Allows the use of the enter key to submit form
	*					 Looks for the enter key, passes any other key
	*					 If enter key pressed then calls sendData routine.
	*
	**********************************************************************/
		// holds the keycode of the key that was pressed
	var keycode;
		
	//check which browser
	if (bName()==1) {
		//explorer
		// if a window event has just occurred then grab its keycode
		if (window.event) keycode = window.event.keyCode;
		// else, if a exception has just occurred then grab its keycode
		else if (e) keycode = e.which;
		// otherwise pass keycode along the event chain
		else return true;
	}
	else {
	if (bName()==2) {
		//netscape
		keycode=e.which	;
		}
	}
	
	// if keycode is 13 (enter key)
	if (keycode == 13) {
	   // then call sendData routine to process form
	   sendData();
	   return false;
	   }
	else
		// otherwise pass keycode along the event chain
		return true;
}

function fnSetStyle(objToSet) 
{
	/* *********************************************************************
	* Programmer Name  : Robert McLeish
	* Web Site         : http://www.foodcity.com.au
	* E-Mail           : rmcleish@australianet.com.au
	* Module Name      : CSScripts
	* Module Filename  : csscripts.js
	* Procedure Name   : fnSetStyle
	* Parameters	   : objToSet = element that called this routine
	*					
	**********************************************************************
	* Comments         : Sets the style of element 'objToSet' to 'EditText'
	*					 This denotes that the element can be edited.
	*
	**********************************************************************/

	if (bName()==1) {

		// store element's current style
  		strOldStyleName = document.all[objToSet].className;
  	
  		// set edit style
  		if (strOldStyleName=="RequiredText") {
  			document.all[objToSet].className='EditRequiredText';
  			}
  		else {
			document.all[objToSet].className='EditText';
		}
		return true;
	}
}

function fnRemoveStyle(objToSet)
{
	/* *********************************************************************
	* Programmer Name  : Robert McLeish
	* Web Site         : http://www.foodcity.com.au
	* E-Mail           : rmcleish@australianet.com.au
	* Module Name      : CSScripts
	* Module Filename  : csscripts.js
	* Procedure Name   : fnRemoveStyle
	* Parameters	   : objToSet = element that called this routine
	*					
	**********************************************************************
	* Comments         : Resets the style of element 'objToSet' back to
	*					 it's original style
	*
	**********************************************************************/
	if (bName()==1) {
		// if old style not available
		if (strOldStyleName=="") {
			// use default style
			strOldStyleName="SmallSelect";
		}
	
		// reset old style
		document.all[objToSet].className = strOldStyleName;
		return true;
	}
}

function openDialog(strFile, myDialog)
{	
	/* *********************************************************************
	* Programmer Name  : Robert McLeish
	* Web Site         : http://www.foodcity.com.au
	* E-Mail           : rmcleish@australianet.com.au
	* Module Name      : CSScripts
	* Module Filename  : csscripts.js
	* Procedure Name   : openDialog
	* Parameters	   : strFile		- file to display inside dialog
	*					 myDialog		- object that holds the dialog's
	*									  state variables
	*					
	**********************************************************************
	* Comments         : Displays a new dialog window using the specified 
	*					 file and returns the users values in the myDialog
	*					 object. Returns the returnValue from the dialog
	*
	**********************************************************************/
	//specify dialogs properties
	var strDialog="scrollbars=no;center=no;border=thin;help=yes;status=no;dialogLeft=0;dialogTop=0;dialogWidth=" + intWidth + "px;dialogHeight=" + intHeight + "px;";
	//call dialog and collect returnValue in result
	result = window.showModalDialog(strFile,myDialog,strDialog)
	//return result to calling routine
	return result;
}

function openWindow(strFile)
{
	/* *********************************************************************
	* Programmer Name  : Robert McLeish
	* Web Site         : http://www.foodcity.com.au
	* E-Mail           : rmcleish@australianet.com.au
	* Module Name      : CSScripts
	* Module Filename  : csscripts.js
	* Procedure Name   : openWindow
	* Parameters	   : strFile		- file to display inside dialog
	*					
	**********************************************************************
	* Comments         : Displays a new window using the specified file
	*					 Returns the new windows name
	**********************************************************************/
	//open window
	newWindow = window.open(strFile,"NewWindow","toolbar=no,location=no,directories=no,status=no,menubar=no,left=0,top=0scrollbars=no,resizable=no,copyhistory=no,width=" + intWidth + ",height=" + intHeight + ";")
	//return name of new window
	return newWindow;
}

//-->



