        var prefix = "ctl00_";
        var prefix2 = "ctl00_ContentPlaceHolder1_";
        var xFlagColour="#FF4040";
        var flagged=false;
        var msg="";
        function ge(x) {
            var prefix = "ctl00_";
            var prefix2 = "ctl00_ContentPlaceHolder1_";
            if (document.getElementById(x))
                return document.getElementById(x);
            if (document.getElementById(prefix + x))
                return (document.getElementById(prefix + x));
            return (document.getElementById(prefix2 + x));
        }

        function init() {
            if (ge('txtUserEmail')) {
                ge('txtUserEmail').onfocus = userfocus;
                ge('txtUserEmail').onblur = userblur;
                ge('txtUserEmail').onkeypress = logpress;
            }
            // MS: removed this to solve bugs 4941 + 4921 in TFS. Using clickButton() method below instead.
//            if (ge('txtPassword')) {
//                ge('txtPassword').onblur = passblur;
//                ge('txtPassword').onkeypress = logpress;
//            }
            
            try { pageinit(); }
            catch (x) { }
        }

        function logpress() {
            if (event.keyCode == 13) {
                event.returnValue = false;
                event.cancel = true;
                ge('hidLoggingIn').value = 'Y';
                alert(__doPostBack.toString());
                //__doPostBack(ge('btnLogin').name, ''); MS: threw errors
            }
        }

        // MS: added this to capture the enter key in the 'password' text box. Similar to above but couldn't risk modifying it due to use elsewhere.
        //     Using the newer DefaultButton wasn't an option either as unfamiliar with the site/use.
        function clickButton(e, buttonid) {
            var evt = e ? e : window.event;
            var bt = document.getElementById(buttonid);

            if (bt) {
                if (evt.keyCode == 13) {
                    bt.click();
                    return false;
                }
            }
        }
        
        function userfocus() {
            if (ge('txtUserEmail').value == 'Email address')
                ge('txtUserEmail').value = '';
        }

        function userblur() {
            if (ge('txtUserEmail').value == '')
                ge('txtUserEmail').value = 'Email address';
        }

        function passfocus() {
            ge('txtPassworddummy').style.display = 'none';
            ge('txtPassword').style.display='inline';
            ge('txtPassword').focus();
        }

        function passblur() {
            if (ge('txtPassword').value.length == 0) {
                ge('txtPassword').style.display = 'none';
            }
        }
        
        window.onload = init;

        var allvalid = true;
        function flag(what, why) {
            allvalid = false;
            //if (what.indexOf(prefix2) < 0)
            //    if (what.indexOf(prefix)<0)
            //        what = prefix + what;
            ge(what).style.backgroundColor = xFlagColour;
            if (what.indexOf('div') > -1)
                ge(what).style.border = '2px solid ' + xFlagColour;
            if (flagged == false) {
                flagged = true;
                if (what.indexOf('div') > -1)
                    what = what.replace("div", "chk");
                ge(what).focus();  
            }
            if (why.length > 0)
                msg += why + '\n';
        }

