InfoMenu = function(lc, dc)
{
 this.data = [];

 this.init = function( linkClass, divClass )
 {
  this.getElemsWithClass( linkClass );
 }
 
 this.getElemsWithClass = function( cName )
 {
  var allElems = document.getElementsByTagName('*'), 
      menuObj,
      foundCount = 0,
      rx = new RegExp('\\b'+cName+'\\b');
      
  for( var i = 0, len = allElems.length; i < len; i++ )
   if( rx.test( allElems[ i ].className ) )
   {
    foundCount++;
      
    var s = allElems[ i ];
    
    while( (s=s.nextSibling) && s.nodeName != 'DIV' )
    ;
    
    if( s )
    {
     this.data.push( menuObj = {lnk : allElems[ i ], div : s, closed:true, closing:false, timer:null, clipLevel:0, realHeight:0} );
     
     this.addToHandler( menuObj.lnk, 'onclick', this.enclose( this.toggle, this, menuObj ) );      
     
     this.addToHandler( menuObj.lnk, 'onmouseout', function(){ this.blur(); } );      
     
     menuObj.realHeight = menuObj.div.offsetHeight;
    
     menuObj.div.style.overflow = 'hidden';     
    } 
    else
     alert('A content <div> was not found for the link at position ' + foundCount + 
           '\n\n\"' + allElems[i].text +'\"\n\n' + allElems[i].id);
      
    menuObj.div.style.height = '0px';
   }
 }
 
 this.toggle = function( inst, infoObj )
 {  
  if( infoObj.clipLevel && infoObj.clipLevel < 10 )  
   infoObj.closing ^= true;
  
  clearInterval( infoObj.timer );
  
  infoObj.timer = setInterval( inst.enclose( inst.clipElem, infoObj ), 51 );    //moz interval bug ?
  
  return false;
 } 
 
 this.clipElem = function( elem )
 {        
  if( (elem.closing && (--elem.clipLevel) == 0) || ( !elem.closing && (++elem.clipLevel) == 10 ) )
  {
   clearTimeout( elem.timer );
   elem.closing ^= true;
  }
     
  elem.div.style.height = Math.ceil( elem.realHeight * elem.clipLevel * 0.1) + 'px';  
 }
  
 this.openOne = function( linkId )
 {    
  for(var i = 0, len = this.data.length; i < len && this.data[ i ].lnk.id !== linkId; i++ )
  ;
    
  if( i != len )
  {
   this.data[ i ].closing = false;  
   this.toggle( this, this.data[ i ] );
  }
 }
 
 this.enclose = function( funcRef, paramArray )
 {
  var args = [];
 
  for(var i=0; i < arguments.length - 1; i++)
   args[ i ] = arguments[i + 1]; 
   
  return function(){ return funcRef.apply( this, args ) };  
 }
 
 this.gebi = function( id )
 {
  var eRef = document.getElementById( id );
    
  return ( eRef && eRef.id === id ) ? eRef : null ;
 }
 
 this.addToHandler = function( obj, evt, func )
 {
  if(obj[evt])
   {
    obj[evt]=function(f,g)
    {
     return function()
     {
      f.apply(this,arguments);
      return g.apply(this,arguments);
     };
    }(func, obj[evt]);
   }
   else
    obj[evt]=func;
 }


 this.init(lc, dc);
  
}