var search =  {
    //-- The url of the action
    action:         '/form/searchguide',
    //-- The form id
    formId:         '#projectSearchForm',
    //-- The id of the div that needs to be refreshed
    contentId:      '#projectListHolder',
    //-- The loader div id
    loaderId:       '#loaderDiv',
    
    //-- Add bindings
    bindings: function () {
        //-- Bind an onchange behaviour on the form elements
        $(search.formId).find('select').change(function(){
            $(search.formId).submit();
        });
    },

    //-- Init the form
    formInit: function () {
        $(search.formId).ajaxForm({
            url: search.action,
            type: 'post',
            dataType: 'html',
            beforeSend: function () {
                $(search.loaderId).show();
                 $(search.contentId).html('');
            },
            success: function (html) {
                $(search.loaderId).hide();
                $(search.contentId).html(html);
            }
        });
    },
    //-- Init the term search form
    termFormInit: function () {
        $('#searchprojectform').ajaxForm({
            url: search.action,
            type: 'post',
            dataType: 'html',
            beforeSend: function () {
                $(search.loaderId).show();
                 $(search.contentId).html('');
            },
            success: function (html) {
                $(search.loaderId).hide();
                $(search.contentId).html(html);
            }
        });
    },

    //-- Init the app
    init: function(){
        search.formInit();
        search.termFormInit();
        search.bindings();
    }
}

$(document).ready(function (){
    search.init();
});
