// By Mark Wilton-Jones 14/10/2002

//this will make the script alert a message if Caps Lock is engaged
var capsError = 'WARNING:\n\nCaps Lock is enabled\n\nThis field is case sensitive';

//this will make the script run a function and pass it a parameter saying if Caps Lock is engaged
//function format NOT compatible with v1 - it will now be run even if Caps Lock is not enabled

function capsError( capsEngaged ) {
        if( capsEngaged ) {
                //do something to warn the user that caps lock is engaged
        } else {
                //remove any warnings that caps lock is engaged
        }
}


function capsDetect( e ) {
        if( !e ) { e = window.event; } if( !e ) { MWJ_say_Caps( false ); return; }
        //what (case sensitive in good browsers) key was pressed
        var theKey = e.which ? e.which : ( e.keyCode ? e.keyCode : ( e.charCode ? e.charCode : 0 ) );
        //was the shift key was pressed
        var theShift = e.shiftKey || ( e.modifiers && ( e.modifiers & 4 ) ); //bitWise AND
        //if upper case, check if shift is not pressed. if lower case, check if shift is pressed
        MWJ_say_Caps( ( theKey > 64 && theKey < 91 && !theShift ) || ( theKey > 96 && theKey < 123 && theShift ) );
}

function MWJ_say_Caps( oC ) {
        if( typeof( capsError ) == 'string' ) { if( oC ) { alert( capsError ); } } else { capsError( oC ); }
}
