$(function() {

    // add some default classes
    $("div.pagination:last").addClass("bottom");
    $("div.teaser:last").addClass("last");
    $("span:last").addClass("last");
    $("div#flashMessage, div.message").animate( {backgroundColor: '#ccffcc'}, 1000).animate( {backgroundColor: '#ffffcc'}, 2000);

    // swap default values on form
    swapValues = [];
    $('.swapvalue').each(function(i){
        swapValues[i] = $(this).val();
        $(this).focus(function(){
            if ($(this).val() == swapValues[i]) {
                $(this).val("");
            }
        }).blur(function(){
            if ($.trim($(this).val()) == "") {
                $(this).val(swapValues[i]);
            }
        });
    });

    // validate the search form
    $('#sitesearch').submit(function() {
        if ($('#q').val() != 'Enter keywords') {
            return true;
        }
        return false;
    });

    // toggle the checkboxes on the Enquiry results
    $("#toggleCheckboxes").click(function() {
        $(this).parents('form').toggleCheckboxes();
        $('#summary input:checkbox').parents('td').toggleClass("selected");
    });

    $("#summary input:checkbox").click(function() {
        if ($(this).attr('checked')) {
          $(this).parents('td').addClass("selected");
        } else {
          $(this).parents('td').removeClass("selected");
        }
    });

});