/*
 prolog, jenom aby byly fce definované
*/

window.ShowMenu = function ( id ) { } ;
window.HideMenu = function () { } ;
window.GetUrl = function ( id ) { } ;

/*
 /prolog

 flash menu bind INIT
*/

/*

window.ShowMenu =
 function ( id ) {
//  window.fmb.show( id );
  window.fmb.showHref( id );
 }
;

window.HideMenu =
 function () {
//  window.fmb.hide( );
  window.fmb.hideHref( );
 }
;

window.GetUrl =
 function ( id ) {
  window.fmb.navigate( id );
 }
;

//
//  /flash menu bind INIT
// 
//  flash menu bind START
//

window.fmb =
// "Flash Menu Bind"
 {
  hoverClass:
   'menuLIhover'
  ,
  actualClass:
   'actual'
  ,
  show:
   function ( id ) {
    this.log('show START',id);
    this.hide( this.lis );
    if ( this.lis[id] ) {
     if ( this.lis[id].className.indexOf(this.hoverClass) < 0 ) {
      this.lis[id].className += ' ' + this.hoverClass;
     }
    }
    this.log('show END',id);
   }
  ,
  hide:
   function ( objs ) {
    this.log('hide()');
    this.unHoverize( );
   }
  ,
  navigate:
   function ( id ) {
    if ( this.lisHrefs[id] ) {
     window.location.href = this.lisHrefs[id];
    }
   }
  ,
  showHref:
   function ( id ) {
    if ( this.lisHrefs[id] ) {
     window.status = this.lisHrefs[id];
    }
   }
  ,
  hideHref:
   function ( ) {
    window.status = '';
   }
  ,
  lis:
   { klasik: undefined
   , casablanca: undefined
   , noline: undefined
   , economic: undefined
   }
  ,
  lisHrefs:
   { klasik: undefined
   , casablanca: undefined
   , noline: undefined
   , economic: undefined
   }
  ,
  unHoverize:
   function ( objs ) {
    if ( !objs ) objs = this.lis;
    var RX = new RegExp( this.hoverClass , 'ig' );
    for ( var li in objs ) {
     objs[li].className = objs[li].className.replace( RX , ' ' );
     this.log('unHoverize:', objs[li].tagName );
    }
   }
  ,
  bindLIs:
   function ( ) {
    if ( window.menuLIhoverClass ) {
     this.hoverClass = window.menuLIhoverClass;
    }
    this.log('bindLIs start');
    var menu = document.getElementById('menu');
    if ( !menu ) {
     return false
    }
    if ( menu.normalize ) {
     menu.normalize()
    };
    this.lis['klasik'] = menu.getElementsByTagName('li')[0];
    this.lis['casablanca'] = this.getSiblingNode(this.lis['klasik']);
    this.lis['noline'] = this.getSiblingNode(this.lis['casablanca']);
    this.lis['economic'] = this.getSiblingNode(this.lis['noline']);
    for ( var li in this.lis ) {
     if ( this.lis[li].className == this.actualClass ) {
      var bs = this.lis[li].getElementsByTagName('b');
      if (bs.length == 2) {
       this.lisHrefs[li] = false;
      } else {
       this.lisHrefs[li] = this.lis[li].getElementsByTagName('a')[0].href;
      }
     } else {
      this.lisHrefs[li] = this.lis[li].getElementsByTagName('a')[0].href;
     }
    }
    this.log(this.lis['klasik'],this.lis['casablanca'],this.lis['noline'],this.lis['economic']);
   }
  ,
  getSiblingNode:
   function ( thisNode, tagName ) {
    if ( !thisNode ) {
     this.log('chybí thisNode');
     return false
    };
    if ( !tagName ) {
     if ( thisNode.tagName ) {
      tagName = thisNode.tagName;
     } else {
      this.log('chybí tagName');
      return false
     }
    };
    var sibling = thisNode.nextSibling;
    if ( !sibling ) {
     this.log('došli sousedi');
     return false
    };
    if ( sibling.tagName && ( sibling.tagName == tagName.toUpperCase() ) ) {
     this.log('mám to:', sibling);
     return sibling
    } else {
     this.log('rekurze…');
     return this.getSiblingNode( sibling, tagName );
    };
    this.log('WTF?');
   }
  ,
  log:
  // pokud není firebug, bude přepsáno prázdnou fcí
   function ( ) {
    window.console.log( arguments.callee, arguments );
   }
  //,
 }
;

if ( !window.console || !window.console.log ) {
 window.fmb.log = function ( ) { } ;
}

if ( window.addEvent ) {
 window.addEvent( window, 'load', function(){ window.fmb.bindLIs() } );
}

// 
//  flash menu bind END
// 

/* */