var lastDirBrowserKey = "";

/**
 * Makes the call that gets the HTML for the listing of a directory catagories
 * Sets a preloader
 * Sets the key for the last call made 
 * @param {string} $header_id The ID of the Header Type
 * @param {string} $type If its listed as a alpha or not 
 */
function request_directory_browser($header_id,$type)
{
    if(lastDirBrowserKey != $header_id){
        var directory_browser_element = $("#directory_browser_element")[0];
        enterPreLoader(directory_browser_element);
        
        var params = new Array();
        params[0] = $header_id;
        params[1] = $type;
        var json = new JSON;
        json.request('directory_browser',params,callback_directory_browser,'','/libs/JSON/misc_actions.php') ;
        lastDirBrowserKey = $header_id;
    }
}

/**
 * The callback from request_directory_browser
 * First checks for err_codes
 * Second populates the innerHTML of the directory_browser_element
 * @param {array} $data [html]
 */
function callback_directory_browser($data)
{
    if($data.err_code) {
        error_handler_by_id($data.err_code);
    } else {
        var directory_browser_element = $('#directory_browser_element');
        directory_browser_element.html($data.html);
    }
}
