
// change row css on grid row selection
function grid_select(name, id) {
main = get(name);
last_id = main.value;
get('last_'+name).value = main.value;
main.value = id;
grid = document.getElementById(name+'_grid');
last = get(name+'_item_'+last_id);
current = get(name+'_item_'+id);
if(grid.rows) {
  if(last)
    for(k=0;k<last.cells.length;k++)
      last.cells[k].className = 'n';
  if(current)
    for(k=0;k<current.cells.length;k++)
      current.cells[k].className = 's';
}
else {
  if(last)
    last.className = 'n';
  if(current)
    current.className = 's';
}
}

// look if an item is selected
function grid_has_sel(name) {
return grid_sel(name) ? true : false;
}

// launch the modify onclick event
function grid_modify(name) {
obj = get(name+'_modify');
if(obj) obj.onclick();
}

// launch the default onclick event
function grid_detail(name) {
obj = get(name+'_detail');
if(obj) obj.onclick();
}



// download a file
// grid_download('grid_name','file.ext,file_categ,owner_id');
function grid_download(name, id) {
arr = id.split(',');
document.location = '/module/file/download.php?categ=' + arr[1] + '&file=' + arr[0];
}


// launch the search onclick event
function grid_search(name) {
obj = get(name+'_search');
if(obj) obj.onclick();
}

// return grid selection
function grid_sel(name) {
return get(name).value;
}

// return grid query
function grid_q(name) {
return get(name+'_q').value;
}

// return grid query row
function grid_r(name) {
return get(name+'_r').value;
}

// do nothin'
function nothing() {
}
