function compareDates ( a, b ){
  if (a==b) {
    return 0;
  }
  if (a <= b){
    return -1;
  }
  if (a >= b){
    return 1;
  }
}

function compareCoordinates ( a, b ){
  if(a == null && b==null) return 0;
  if(a == null){
    return -1;
  }
  if(b==null){
    return 1;
  }
  var na = Number(a.split(/\s/g).join(''));
  var nb = Number(b.split(/\s/g).join(''));
  return na < nb ? -1 : na > nb ? 1 : 0;
}

/*
 * Generic string comparison, with some paranoid checks for older browsers.
 */
function defaultCompare ( a, b ){ 
  if (a == null && b == null) return 0;
  if (a == null) return -1; //x > null for all x != null.
  if (b == null) return 1; // ..
  return a < b ? -1 : a > b ? 1 : 0; 
}

var DATE_FORMAT = 'yyyy-mm-dd';
var CURRENCY_FORMAT = " $";
var EMPTY_ROW = "no filter";
var gridDef = {
  useAmountPanel: false,
  useSearchPanel: true,
  searchControl: "Reg Exp: ",
  usePagePanel:   true,
  useResetPanel:  true,
  useEdit :       false,
  amountPerPage : 100,
  useMultiSort : false,
  datatype : 0,
  
  keyCol : "ID", 
  rowStyle : {
    markClass : "mark",
                darkClass : "dark",
    lightClass : "light",
                hoverClass : "hover"
  },
  tableStyle : {
    tableClass : "common",
    thClass    : "common",
    utilClass  : "utils",
                border : 0,
    cellpadding : 2,
    cellspacing : 1
  },
  imgSortAsc :    {
    src : "images/table/sortasc.gif", width : 10, height : 10
  },
  imgSortDesc :   {
    src : "images/table/sortdesc.gif", width : 10, height : 10
  },
  imgSortAscActive :      {
    src : "images/table/sortasca.gif", width : 10, height : 10
  },
  imgSortDescActive :     {
    src : "images/table/sortdesca.gif", width : 10, height : 10
  },
  imgMultiSortAscActive :         {
    src : "images/table/sortascma.gif", width : 10, height : 10
  },
  imgMultiSortDescActive :        {
    src : "images/table/sortdescma.gif", width : 10, height : 10
  },
  imgFirstPage : {
    src : "images/table/firstpage.gif", width : 10, height : 10
  },
  imgLastPage :   {
    src : "images/table/lastpage.gif", width : 10, height : 10
  },
  imgPrevPage :   {
    src : "images/table/prevpage.gif", width : 10, height : 10
  },
  imgNextPage :   {
    src : "images/table/nextpage.gif", width : 10, height : 10
  }
};
gridDef.colDef =  
[
 {
   title : "ID",
   titleClass : "", //default for th
   type : "Number",
   width : 75, //auto
   alignment : "center",
   compareFunction : defaultCompare,
   isVisible : false,
   useAutoIndex : false,
   useAutoFilter : false
 },
 {
   title : "Name",
   titleClass : "",
   type : "HTML",
   width : 150, //auto
   alignment : "",
   compareFunction : compareHTML,
   isVisible : true,
   useAutoIndex : false,
   useAutoFilter : false
 },
 {
   title : "RA",
   titleClass : "", //default for th
   type : "String",
   width : 120, //auto
   alignment : "center",
   compareFunction : compareCoordinates,
   isVisible : true,
   useAutoIndex : false,
   useAutoFilter : false
 },
 {
   title : "Dec",
   titleClass : "", //default for th
   type : "String",
   width : 120, //auto
   alignment : "center",
   compareFunction : compareCoordinates,
   isVisible : true,
   useAutoIndex : false,
   useAutoFilter : false
 },
 {
   title : "Type",
   titleClass : "", //default for th
   type : "String",
   width : 100, //auto
   alignment : "center",
   compareFunction : defaultCompare,
   isVisible : true,
   useAutoIndex : false,
   useAutoFilter : true
 },
 {
   title : "Discoverer",
   titleClass : "", //default for th
   type : "String",
   width : 100, //auto
   alignment : "center",
   compareFunction : defaultCompare,
   isVisible : false,
   useAutoIndex : false,
   useAutoFilter : true
 },
 {
   title : "Date",
   titleClass : "", //default for th
   type : "Date",
   width : 100, //auto
   alignment : "center",
   compareFunction : compareDates,
   isVisible : true,
   useAutoIndex : false,
   useAutoFilter : false
 },
 {
   title : "Dist",
   titleClass : "", //default for th
   type : "Distance",
   width : 100, //auto
   alignment : "center",
   compareFunction : compareDistance,
   isVisible : true,
   useAutoIndex : false,
   useAutoFilter : false
 },
 {
   title : "Catalog",
   titleClass : "", //default for th
   type : "String",
   width : 100, //auto
   alignment : "center",
   compareFunction : defaultCompare,
   isVisible : true,
   useAutoIndex : false,
   useAutoFilter : true
 } 
 ];

