
var aTxtSearchIds     = new Array("txt_search", "txt_school", "txt_town");
var aTxtSearchPrompts = new Array();

$(document).ready(function () {

    // the prompt message is assigned to the title property of <input >
    for(var i=0; i < 3; i++)
    {
        var ctl = document.getElementById(aTxtSearchIds[i]);
        aTxtSearchPrompts[i] = ctl.title;
        ctl.title = "";

        var s   = $.trim(ctl.value);
        if(s.length == 0 || s == aTxtSearchPrompts[i])
        {
           ctl.value = aTxtSearchPrompts[i];
           ctl.style.color     = "#aaa";
           ctl.style.fontStyle = "italic";
        }
        else
        {
            ctl.style.color     = "black";
            ctl.style.fontStyle = "normal";
        }
    }
});

function id2ndx(p_ctl)
{
    for(var i=0; i < 3; i++)
    {
        if(p_ctl.id == aTxtSearchIds[i])
            return i;
    }
}

function txt_search_onfocus(p_ctl)
{
    var p_prompt = aTxtSearchPrompts[id2ndx(p_ctl)];
    if(p_ctl.value == p_prompt)
        p_ctl.value = "";

    p_ctl.style.color     = "black";
    p_ctl.style.fontStyle = "normal";
    p_ctl.select();
}

function txt_search_onblur(p_ctl)
{
    p_ctl.value = $.trim(p_ctl.value);
    if(p_ctl.value.length == 0)
    {
       var p_prompt = aTxtSearchPrompts[id2ndx(p_ctl)];

       p_ctl.value           = p_prompt;
       p_ctl.style.color     = "#aaa";
       p_ctl.style.fontStyle = "italic";
    }
}



