var currentWidth = 0;
var checkTimer;

addEventListener("load", function(event)
{                   
    setTimeout(checkOrientAndLocation, 0);
    checkTimer = setInterval(checkOrientAndLocation, 300);
}, false); 

function checkOrientAndLocation()
{
    if (window.innerWidth != currentWidth)
    {
        currentWidth = window.innerWidth;
        var orient = currentWidth == 320 ? "profile" : "landscape";
        document.body.setAttribute("orient", orient);
        setTimeout(scrollTo, 100, 0, 1);
    }
}

function showSearchForm()
{
    var form = $('searchForm');

    form.style.display = 'block';

    form.onclick = function(event)
    {
        if(event.target == form && form.hasClassName('dialog'))
        {
            form.style.display = 'none';
            return false;
        }
    };
}

function submitSearchForm()
{
    document.location.href = '/relevance/search/'+$('searchForm').search.value.replace(' ', '+')+'/1';
    return false;
}
