function GridMenu( number ) {
  
  var O = new Object;
  O.number_of_page_elements = number;
  
  if( window.navigator.appVersion.indexOf("IE")!= -1 ) {
    // IE dont seem to like css rolovers, so 
    // we can control them with the javascript.
    // if there are any other IE specific options here
    // would be a good place to put them. :)
    O.jsRollovers = true;
  } else 
    O.jsRollovers = false;
    
  O.cause_event = 'mouseover';
  O.revert_event = 'mouseout';
  O.menu_item_prefix = 'menu';
  O.thumb_item_prefix = 'thumb';
  O.delimiter = '_';
  O.menu_item_active_class = 'menu_active';
  O.thumb_item_active_class = 'thumbnail_active';
  O.menu_item_event_class = 'menu_active_event';
  O.thumb_item_event_class = 'thumbnail_active_event';

  O.link_in = function ( e ) {
    e = ExtendEvent( e );
    // e.cancelPropagation();
    var id = e.getEventTarget().id.split( O.delimiter )[1];
    switch (e.getEventTarget().id.split( O.delimiter )[0] ) {
      case O.menu_item_prefix:
        O.do_menu( id, e.type );
        break;
      case O.thumb_item_prefix:
        O.do_thumbs( id, e.type );
        break;
    }
    return true;
  }

  O.do_menu = function( id, type, child ) {
    if ( O.jsRollovers == true && !child ) O.do_thumbs( id, type, true );
    var obj = getObj( O.thumb_item_prefix + O.delimiter + id );
    switch ( type ) {
      case O.cause_event:
        obj.setAttribute( "class", O.thumb_item_event_class );
        obj.setAttribute( "className", O.thumb_item_event_class );       
        break;
      case O.revert_event:
        obj.setAttribute( "class", O.thumb_item_active_class );
        obj.setAttribute( "className", O.thumb_item_active_class );
        break;
    }
    return true;
  }
  
  O.do_thumbs = function( id, type, child ) {
    if ( O.jsRollovers == true && !child ) O.do_menu( id, type, true );
    var obj = getObj( O.menu_item_prefix + O.delimiter + id );
    switch ( type ) {
      case O.cause_event:
        obj.setAttribute( "class", O.menu_item_event_class );
        obj.setAttribute( "className", O.menu_item_event_class );       
        break;
      case O.revert_event:
        obj.setAttribute( "class", O.menu_item_active_class );
        obj.setAttribute( "className", O.menu_item_active_class );
        break;
    }
    return true;
  }

  O.apply_events = function() {
    for ( i = 1; i <= O.number_of_page_elements; i++ ) {
      // Set Menu Item Events
      obj = getObj( document.getElementById( O.menu_item_prefix + O.delimiter + i ) );
      
      if ( obj ) {
        if ( obj.className == O.menu_item_active_class ) {
          obj.addEventHandler( O.cause_event, O.link_in );
          obj.addEventHandler( O.revert_event, O.link_in );
        }
      }
      
      // Set Thumbnail Item Events
      obj = getObj( document.getElementById( O.thumb_item_prefix + O.delimiter + i ) );
      if ( obj ) {
        if ( obj.className == O.thumb_item_active_class ) {
          obj.addEventHandler( O.cause_event, O.link_in );
          obj.addEventHandler( O.revert_event, O.link_in );
        }
      }
    }
    return true;
  }
  
  return O;
}
function initGridMenu() {
  // Do things
  //if ( document.title.indexOf( "projects" ) != -1 ) {
    var Y = new GridMenu( 30 );
    Y.apply_events();
  //}
}

