one function for add_row all grids

On one page I have 2 grids named ‘myGrid’ and ‘myGirdDetails’. I have in a separate js script a function called add_row which I call from all single grid pages

js:
// --------------------------------------------------------------------------------------------------
// add row
// -------------------------------------------------------------------------------------------------
function add_row(aDefaultValue){
var newId = (new Date()).valueOf();
myGrid.addRow(newId,aDefaultValue);
myGrid.selectRowById(newId);
var rowIndex = myGrid.getRowIndex(newId);
window.setTimeout(function(){
myGrid.selectCell(rowIndex,0,false,true,true);
},1);
recordDel = false;
return true;
}

via a context menu in my pages I call this function:
switch(menuitemId){
case ‘context_add’ : aDefaultRowValue = [null,’’,’’,’’,’’,1,’’,’’,’’,’’];
add_row(aDefaultRowValue);
valError = true;
break;

Now I have on one page 2 grids with different gridnames. Now I want to give the grid name as parameter to the function. How do I do that. I tried :
function add_row(str gridName,aDefaultValue){
var newId = (new Date()).valueOf();
gridName.addRow(newId,aDefaultValue);
gridName.selectRowById(newId);
var rowIndex = gridName.getRowIndex(newId);
window.setTimeout(function(){
gridName.selectCell(rowIndex,0,false,true,true);
},1);
recordDel = false;
return true;
}

But this is not working.