//Filename:HandleKeys.js

/////////////////////////////////////////////////////////////////////////	
///// This Section is activated off of the the the field where the	///// 
///// cycle count is enterd.  The function evaluates every key  	/////
///// stroke enterd in the field and ensures that only numerics are	/////
///// allowed to be enterd.  If the return key of tab Key is hit	/////
///// the function advances the user to the next availiable field	/////
///// ----- Copyright LSK Data Management Solutions:April-2000----- /////
/////////////////////////////////////////////////////////////////////////
function handleKey(AllowPeriod, AllowAlphaChar, AllowDashes){
	
	var isNav4Int, isIE4Int
	var keyStrokeAcct 
	
	if (parseInt(navigator.appVersion)>=4){
		isNav4Int= (navigator.appName=="Netscape")
		isIE4Int= (navigator.appName.indexOf("Microsoft") != -1)
	}

	if (isIE4Int){
		var pressedKey = window.event.keyCode
		keyStrokeAcct  = evalKeyStroke(pressedKey, AllowPeriod, AllowAlphaChar, AllowDashes)

	} else {
		if (isNav4Int){
			var pressedKey = window.event.which
			keyStrokeAcct  = evalKeyStroke(pressedKey, AllowPeriod, AllowAlphaChar, AllowDashes)
	
		} else {
			keyStrokeAcct = true
		}
	}

	return keyStrokeAcct 
}


function evalKeyStroke(pressedKey,AllowPeriod, AllowAlphaChar, AllowDashes){
		if (pressedKey>31 && (pressedKey<48 || pressedKey>57)) {
			if (pressedKey==46) {
				if (AllowPeriod) {
					return true
				} else {
					return false
				}

			} else if (pressedKey==34 || pressedKey==39) {
				return false

			} else if (pressedKey==45) {
				if(AllowDashes){
					return true
				}else{
					return false
				}
				
			} else if (AllowAlphaChar){
				return true

			} else {
				return false

			}
		}else {
			if (pressedKey == 13){
				//handle return or enter Key				
				return 13	
			
			}else{
				return true
			}
		}
	
}
//***********************************************************************//
