﻿
var keypressed;
                  
function setCursorToTextEnd(textControlID)
{
    var text = document.getElementById(textControlID);
    
    if (text != null && text.value.length > 0)
    {
        if (text.createTextRange)
        {
            var FieldRange = text.createTextRange();
            FieldRange.moveStart('character', text.value.length);
            FieldRange.collapse();
            FieldRange.select();
        }
    }
}
            
function validSearchInput(key)
{
    if((key > 47 && key<58) || (key > 64 && key<91) || (key > 96 && key<123) || key == 192 || key == 221 || key == 222 || key == 32 || key == 8)
    {
        return true;
    }
    else	
    {
        return false;
    }
}
            
document.onkeydown = alertkey;         
            
function alertkey(e) 
{
    if( !e ) {
        //if the browser did not pass the event information to the
        //function, we will have to obtain it from the event register
        if( window.event ) 
        {
            //Internet Explorer
            e = window.event;
        } else {
            //total failure, we have no way of referencing the event
            return;
        }
    }
    
    if( typeof( e.keyCode ) == 'number'  ) 
    {
        //DOM
        e = e.keyCode;
        } else if( typeof( e.which ) == 'number' ) {
        //NS 4 compatible
        e = e.which;
        } else if( typeof( e.charCode ) == 'number'  ) {
        //also NS 6+, Mozilla 0.9+
        e = e.charCode;
        } else {
        //total failure, we have no way of obtaining the key code
        return;
    }

    keypressed = e;
}
