﻿// http://www.howtocreate.co.uk/jslibs/htmlhigh/capsDetect.html
//"JavaScript offers no way to check the state of the Caps Lock, so the only way to detect it is to check the
// letters pressed and compares them with the SHIFT key state"

function capLock(e){
	if( !e ) e = window.event;
	var kc = e.keyCode ? e.keyCode : e.which;
	var sk = e.shiftKey ? e.shiftKey : ( (kc == 16) ? true:false );
	// get the src element
	var src = e.srcElement ? e.srcElement : e.target;
	// get the last character
	var c = src.value.substr( src.value.length-1,1 );
	// check upper/Lower case
	var caps_on = (!sk && c != c.toLowerCase()) || (sk && c != c.toUpperCase());//(((kc >= 65 && kc <= 90) && !sk)||((kc >= 97 && kc <= 122) && sk))//
   	FloatingHelpBubble.ForceShowHide(caps_on);
	// Caps lock is on
	if(caps_on && !FloatingHelpBubble.Visible){ // if the line above failed to show the help
		FloatingHelpBubble.ToggleHelp(PwdFieldClientID,"<span style='color:red;'>Caps Lock is On</span>"); // PwdFieldClientID is defined as a global var defined on the Default.aspx
	}
}
