﻿
$().ready(function() {
    //search box watermark
    //when the user is in the textbox if the value is Search TheraCare.com
    //clear it. If any other text is entered it will be ignored
    $(".searchinput").focus(function() {
        if ($(this).val() == "Search TheraCare.com") {
            $(this).val("");
            $(this).removeClass("searchwatermark");
        }
    });


    //when the user exits the search box check to see if the value
    //is blank. If it is then put the word Search back in there.
    $(".searchinput").blur(function() {
        if ($(this).val() == "") {
            $(this).val("Search TheraCare.com");
            $(this).addClass("searchwatermark");
        }
    });



    $('.searchinput').keydown(function(event) {
        if (event.keyCode == '13') {
            $('.searchbtn').click();
        }
    });


    // get user settings - username
    $.ajax({
        url: ROOT_URL + 'UserCookieSettings.ashx',
        cache: false,
        success: function(data) {
            if (data == "") {
                // do nothing as do not remember;
            } else {
                var item = document.getElementById("username");
                if (item) {
                    item.value = data;
                }
            }
        }
    });

});


function SetLoginFocus() {
    var uname = document.getElementById("username").value;
    if (uname == "") {
        $('#username').focus();
    } else {
        $('#password').focus();
    }

}

function AutoTab(ID, nextID)
{
    var item = document.getElementById(ID);
   
    if (item.value.length == item.maxLength)
    {
        document.getElementById(nextID).focus();
    }
}


function NumbersOnly(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        return false
    }
    return true
}


//function GetHoverTip(name, id) {
//    var pagename = '';

//    switch (name) {
//        case 'format':
//            pagename = 'formatting.htm';
//            break;
//    }


//    $.ajax({
//        url: ROOT_URL + 'intranet/admin/cms/hovertips/' + pagename,
//        cache: false,
//        success: function(data) {
//            document.getElementById(id).innerHTML = data;
//        }
//    });


//}






