function where_to_buy(what, callback)
    {
        if (callback)
            {
                if (r=document.getElementById('wtb_results'))
                    {
                        r.innerHTML = what;
                        setCookie( 'wtbw' , document.getElementById('words').value, 7);
                    }
            }
        else
            {
                if (what == 'focus')
                    {
                        if (w=document.getElementById('words'))
                            w.focus();
                    }
                else
                    {       
                        p = 'app_name=where_to_buy&words=' + what.value;
                        delayed(3,'/volume/locator/index.php', p, 'where_to_buy', 'GET');
                    }
            }
    }

var wait = false;
var timeoutID;
function delayed(h, portal, params, action, method)
{
    f = "communicate('"+portal+"','"+params+"','"+action+"','"+method+"');";

    clearInterval(timeoutID);
    timeoutID = setTimeout(f, 100*h);
}                    


function result(text,action)
    {
        switch(action)
            {
                case 'search' :
                    search(text,1);
                break;
                case 'where_to_buy' :
                    where_to_buy(text,1);
                break;
            }
    }

    
function occupyInput(caller, def)
{
    if (caller.value == '')
        caller.value = def;
}
function clearInput(caller, def)
{
    if (caller.value == def)
        caller.value = '';
}