function keyToUpperCase(e)
{
	if (document.all) 
	{
		var c = event.keyCode;

		// do not allow ' " or | characters - this prevents errors when trying to update the database
		if (String.fromCharCode(c) == "'" || String.fromCharCode(c) == '"' || String.fromCharCode(c) == '|')
		{
			alert("The character you have entered is not valid for this field")
			return false;
		}
		else
		{
			var C = String.fromCharCode(c).toUpperCase().charCodeAt();
			e.keyCode = C;
			return true;
		}
	}
	else 
		return true;
} // end keyToUpperCase

function keyToLowerCase(e)
{
	if (document.all) 
	{
		var c = event.keyCode;

		// do not allow ' " or | characters - this prevents errors when trying to update the database
		if (String.fromCharCode(c) == "'" || String.fromCharCode(c) == '"' || String.fromCharCode(c) == '|')
		{
			alert("The character you have entered is not valid for this field")
			return false;
		}
		else
		{
			var C = String.fromCharCode(c).toLowerCase().charCodeAt();
			e.keyCode = C;
			return true;
		}
	}
	else 
		return true;
} // end keyToLowerCase

function keyCheckNumber(e) 
{
	var keyCode = e.which ? e.which : e.keyCode;

	if ((navigator.appVersion.indexOf("MSIE 5") > 0) || (navigator.appVersion.indexOf("MSIE 6") > 0)) 
	{
		// IE 5/6 in use, needs this extra code
		if (keyCode > 95 && keyCode < 106) return(true);            
		
		// Delete key
		if (keyCode == 46) return(true);
		
		if (keyCode >= 37 && keyCode <= 40) 
		{
			if (e.type=="keypress") 
			{
				if ((keyCode == '%'.charCodeAt()) || (keyCode == '&'.charCodeAt()) || (keyCode == '('.charCodeAt())) 
				{
					return(false);
				}
			} 
			else 
			{                         
				return(true);
			}
		} 
	} 
	else 
	{
		// Right cursor key
		if (keyCode == 37) return(true);
	}

	// Allows only Numeric keys to be pressed along with (Enter, Delete, Backspace, Tab, Numlock, 4 arrow keys)
	return ((keyCode >= '0'.charCodeAt() && keyCode <= '9'.charCodeAt()) || (keyCode == 13) || (keyCode == 46) || (keyCode == 8) || (keyCode == 9) || (keyCode == 144) || ((keyCode >= 37 && keyCode <= 40) && ((keyCode != '%'.charCodeAt()) && (keyCode != '&'.charCodeAt()) && (keyCode != '('.charCodeAt()))));
	
} // end keyCheckNumber

function keyCheckNumberSubmitOnEnter(e, eventTarget, thisform) 
{
    if (keyCheckNumber(e))
        return submitOnEnter(e, eventTarget, '', thisform);
    else
        return false; 
} // end keyCheckNumberSubmitOnEnter

function keyToUpperCaseSubmitOnEnter(e, eventTarget, thisform) 
{
    if (keyToUpperCase(e))
        return submitOnEnter(e, eventTarget, '', thisform);
    else
        return false; 
} // end keyToUpperCaseSubmitOnEnter

function submitOnEnter(e, eventTarget, eventArgument, thisform) 
{
    if (e && e.keyCode == 13) {
        if ((thisform != null) && (eventTarget != null))
        {
            __doPostBack(eventTarget, eventArgument);
            return true;
        } 
    } else {    
        return true;
    }
} // end submitOnEnter

// determine browser type
function Is ()
{   // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();
    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use is.ie5up to detect IE5.
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);
    this.ie   = (agt.indexOf("msie") != -1);
    this.nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1));
    this.navonly  = (this.nav && ((agt.indexOf(";nav") != -1) ||
                     (agt.indexOf("; nav") != -1)) );
                     
    this.mozilla = (this.nav && (agt.indexOf('netscape')==-1));	
    this.opera = (agt.indexOf("opera") != -1);		
    
    this.ie3  = (this.ie && (this.major < 4));
    this.ie4  = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")==-1) );
    this.ie4up  = (this.ie  && (this.major >= 4));
    this.ie5  = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    this.ie5up  = (this.ie  && !this.ie3 && !this.ie4);
    this.nav4 = (this.nav && (this.major == 4));
    this.nav5 = (this.nav && (this.major == 5));
    this.nav5up = (this.nav && (this.major >= 5));
    this.nav6 = (this.nav && (this.major == 5) && (agt.indexOf('netscape6')!=-1));	
    this.nav7 = (this.nav && (this.major == 5) && (agt.indexOf('netscape/7')!=-1));	
    
    this.win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
    this.mac    = (agt.indexOf("mac")!=-1);    
}

var is = new Is();

