/*
From http://24ways.org/2007/capturing-caps-lock
Rewritten with jquery by Michael Crumley - 25% of original code size

EXAMPLE
<script src="jquery.js" type="text/javascript"></script>
<script src="jscapslock.js" type="text/javascript"></script>
<script type="text/javascript">
capslock.show_warning(target) {
// do something here to warn the user
}
capslock.hide_warning(target) {
// hide the warning that we created in show_warning() above
}
</script>
*/
var capslock = {
  init: function() {
	$('input[type=password]').keypress(capslock.keypress);
  },
  keypress: function(e) {
    var targ = e.target || e.srcElement;
    // get key pressed
    which = e.which;
    // get shift status
    var shift_status = false;
    if (e.shiftKey) {
      shift_status = e.shiftKey;
    } else if (e.modifiers) {
      shift_status = !!(e.modifiers & 4);
    }
    if (((which >= 65 && which <=  90) && !shift_status) ||
        ((which >= 97 && which <= 122) && shift_status)) {
      // uppercase, no shift key
      capslock.show_warning(targ);
    } else {
      capslock.hide_warning(targ);
    }
  },
  show_warning: function(targ) {
  },
  hide_warning: function(targ) {
  }
};
$(capslock.init);
