﻿function search() {
    var q = $('#query').attr("value");
    $('#search-window').show();
    $('#results').html('<img id="contentLoading" src="/media/images/ajax/loading.gif"/>');
    var u = "http://" + location.host + "/SearchJson.aspx?searchfor=" + q;
    $.getJSON(u, function (data) {
        if (data != "") {
            $('#results').html('');
            $.each(data, function (i, result) {
                $("<div/>").html('<a href="' + result.url + '">' + result.name + '</a>'
                                    + '<br />' + result.description
                                    + '<br /><span class="little">' + result.url + ' - '
                                    + result.size + ' bytes - '
                                    + result.date + '</span>').appendTo("#results");
            });
        }
        else {
            $('#results').html("No Result");
        }
    });
}
$(document).ready(function () {
    $("#search-window .buttons").click(function () { $("#search-window").hide(); });
    $('#query').click(function () {
        $(this).css("color", "black");
        $(this).val("");
    });
});
