s1JS.Jobs.Recruiters = {};

s1JS.Jobs.Recruiters.Profile = 
{
    detail_height: null,  // cache for
    $loader: null,        // multiple requests
    init:function()
    {        
        this.detail_height = $('#right-col').height();
        this.$loader = $('#left-col-loading');
        
        // Initiate functionality exclusive to JS
        // i.e show the search results, hide the contact box and resize the loader    
        $('#search-results').show();        
        this.setLoaderHeight();  
        
        $('#store-job').click(this.storeJob);
        $('#show-contact').click(function(e) { $contact_box.slideToggle("fast"); return false; });
       
        // set up the AJAX search results
        var page_data = this.makePageData();     
        var results = new s1JS.Jobs.AjaxResults({page_data:page_data});
        results.doRequest();    
        results.updateSearchCookie();
    },   
    /*
     *  Sets the height of the loader div so that it covers the contents of the left column
     */ 
    setLoaderHeight:function()
    {
        var column_height = $('#left-col').height();              
        (column_height > this.detail_height) ? this.$loader.height(column_height) : this.$loader.height(this.detail_height);
        this.$loader.show();
    },
    /*
     *  Extends the global page_data object with AJAX search results properties,
     *  this can't be done in the template (which would be easier) because to 
     *  locally cache the file, every value on the page has to be static.
     */     
    makePageData:function()
    {
        var page_data = {};
        page_data.type = 'current';
    
        // Build our page_data based on cookie
        // or if no cookie fall back on vacancy criteria
        var query = s1JS.Jobs.Cookies.readCookie('search');   
        
        page_data.script = '/search/results.cgi';      
        page_data.page = 1;
        page_data.current_page = 1;    
        page_data.number_per_page = 10;       
        
        page_data.query_string = '?s1jobs2005=1&corestrict=' + co_search;
        page_data.original_query_string = page_data.query_string;       
        return page_data;
    }    
    
};


s1JS.Jobs.addLoader(function() { s1JS.Jobs.Recruiters.Profile.init(); });
