

var search = {

    focus: function(el, focus) {
        if (focus) {
            if (el.value == 'Search') el.value = '';
            klass.remove(el, 'empty');
        } else {
            if (el.value == '') el.value = 'Search';
            if (el.value == 'Search') {
                klass.append(el, 'empty');
            } else {
                klass.remove(el, 'empty');
            }
        }
    },
    submit: function(e, hide) {
        if (!e) var e = window.event;
        if (e.keyCode != 13) return false;
        var v = app.get('search_text').value;
        if (v) {
            if (hide) {
                app.get('loading').style.display = 'block';
                app.get('search_results').style.display = 'none';
            }
            /*
            v = v.replace(' ', '+');
            v = v.replace('/', '-');
            v = v.replace('"', '');
            v = v.replace('\'', '');
            v = v.toLowerCase();
            */
            v = '/' + escape(v);
        }
        window.location = '/search' + v;
    }
}

