var isIE;

if(navigator.appName == "Microsoft Internet Explorer" )
{
	isIE = true;
}

/* method for setting focus on control */
var focusControl = '';

function SetFocus()
{
	if( focusControl == '')
	{
		alert("no focus");
		return;
	}
	else
	{
		alert("focus");
		document.getElementById(focusControl).focus();
	}
}

function SetFocusControl( ctrl )
{
	alert("setcontrol" + ctrl);
	focusControl = ctrl;
}

/* methods for catpturing textbox keypresses to tie text boxes to buttons */
var buttonID;


function getButton( btnID )
{
	//set which button we need to target
	buttonID = btnID;
	
	//capture non IE events
	if(!isIE)
	{
		document.captureEvents(Event.KEYDOWN);
	}
		
	//specifiy event to fire on key down
	document.onkeydown = submitText;
}

function submitText(evt)
{
	
	var pressedButton;

	if(isIE)
	{
		pressedButton = window.event.keyCode;
	}
	else
	{
		pressedButton = evt.which;
	}
	
	if(pressedButton == 13)
	{
		if(isIE)
		{
			with(event)
			{
				cancelBubble = true;
				returnValue = false;
			}
		}
		//fire the click event of the selected button
		document.getElementById(buttonID).click();
	}
}

function convertKey(input)
{
	// KEY CONSTANTS
	var BACKSPACE_KEY = 8;
	var TAB_KEY = 9;
	var RETURN_KEY = 13;
	var DELETE_KEY = 46;
	var LOWER_CASE_A = 97;
	var LOWER_CASE_Z = 122;
	var UPPER_CASE_DELTA = 32;
	
	//	convert lower-case alpha char to upper-case alpha char
	if (event.keyCode >= LOWER_CASE_A && event.keyCode <= LOWER_CASE_Z) {
		event.keyCode -= UPPER_CASE_DELTA;
	}

	// check for valid key too based on valid barcode symbology allowable characters
	if ((!IsCharInCharSet(event.keyCode)) && (event.keyCode != RETURN_KEY))
	{
		alert("The '" + String.fromCharCode(event.keyCode) + "' character is not valid for this part.");
		event.keyCode = 0;
		return false;
	}
	return true;
}

function autoTab(clientId, target)
{
	var DELETE_KEY = 46;
	var NUM_KEY_0 = 96;
	var NUM_KEY_9 = 105;
	
	if (
        (event.keyCode != DELETE_KEY) &&
        (
         (IsCharInCharSet(event.keyCode) == true) ||
         ((event.keyCode >= NUM_KEY_0) && (event.keyCode <= NUM_KEY_9))
        )
	   )
	{
		var elem = document.getElementById(clientId + "_" + target);
		elem.focus();
	}
}

function highlightContent(clientId, target) {
	var elem = document.getElementById(clientId + "_" + target);
	elem.select();
}


