Chinna,
In this code:
var col = sel.columns; _left = sel.parent.parentPage.marginPreferences.left; _right = sel.parent.parentPage.marginPreferences.right, allcolwidth = 0;
_left and _right are defined as global variables. To make them local (as you no doubt intended), in lines 1 and 2 replace ; with ,
Also, instead of var col = sel.columns use var col = sel.columns.everyItem().getElements() so that the script processes an array rather than a collection, which speeds up things enormously.
Peter