var load_count = load_counts[grid_selection-1];

//Check whether we've run out of images to load:
if(load_count < manifest_size){
    .
    .
    .
}