// assumes jquery has been loaded prior to this
function remoteSearch() {
        if (navigator.userAgent.indexOf('Firefox') < 0) {
                // not firefox
                var searchForm = document.getElementById('saved_search_form');
                var oldAction = searchForm.action;
                searchForm.action = remoteSearchUrl; 
                searchForm.target = randomString(); 
                searchForm.submit(); 
                searchForm.action = oldAction;
        } else {
                // firefox -- use formSerialize to open the window as a GET request
                // This approach is dangerous in IE b/c IE has a much shorter length limit
                // for URLs than Firefox
                var queryString = $('#saved_search_form').formSerialize(); 
                var win = window.open(remoteSearchUrl + '?' + queryString, randomString(), 'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes'); 
                win.focus();
        }
}

function randomString() {
        var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
        var string_length = 8;
        var randomstring = '';
        for (var i=0; i<string_length; i++) {
                var rnum = Math.floor(Math.random() * chars.length);
                randomstring += chars.substring(rnum,rnum+1);
        }
        return randomstring;
}
