/**
 * @author Dale Larsen
 * Copyright 2011 Advanced Brain Technologies
 */
$(function(){
   DD_roundies.addRule('.menuHoverE3', 8, true);
   DD_roundies.addRule('#pipeRoundiesHack, .menuHoverFF, .menuHoverMember', '8px 8px 0px 0px', true);
   
   var hearSeeIdeaRowHtml = '<div class="divImg" style="width: 30px; height: 28px; background-image: url(\'/images/hear.png\');"></div>';
   hearSeeIdeaRowHtml += '<div class="divImg" style="width: 30px; height: 28px; background-image: url(\'/images/see.png\');"></div>';
   hearSeeIdeaRowHtml += '<div class="divImg" style="width: 30px; height: 28px; background-image: url(\'/images/idea.png\');"></div>';
   
   var menuLinkItems = [{
      'name': 'home',
      'href': '/'
   }, {
      'name': 'order',
      'href': '/order.jsp'
   }, {
      'name': 'authors',
      'href': '/book_authors.jsp'
   }, {
      'name': 'about the book',
      'href': '/about.jsp'
   }, {
      'name': 'book preview',
      'href': '/book_preview.jsp'
   }, {
      'name': 'endorsements',
      'href': '/endorsements.jsp'
   }, {
      'name': 'press',
      'href': '/media_inquiries.jsp'
   }, {
      'name': 'speaking &amp; events',
      'href': '/events.jsp'
   }, {
      'name': 'book links <span class="hearSeeIdeaRow"><span class="hearSeeIdeaRow"><img src="/images/hear.png"/><img src="/images/see.png" style="height: 24px; margin-top: -2px;"/><img src="/images/idea.png" /></span></span>',
      'href': '/link0'
   }];
   var menuLinkItems2 = [{
      name: 'Home',
      href: '/'
   }, {
      name: 'Authors',
      href: '/book_authors.jsp'
   }, {
      name: 'About the Book',
      href: '/about.jsp'
   }, {
      name: 'Endorsements',
      href: '/endorsements.jsp'
   }, {
      name: 'Book Preview',
      href: '/book_preview.jsp'
   }, {
      name: 'Press',
      href: '/media_inquiries.jsp'
   }];
   $('#mainMenu2').abtHomeMenu2({
      items: menuLinkItems2,
      menuLeftOffset: -17,
      featItem: {
         href: '/about.jsp',
         src: '/images/home2/authors_menu.jpg'
      }
   });
   
   $('#eventsMenuLink').abtHomeMenu2({
      items: [{
         name: 'Local',
         href: '/events.jsp'
      }, {
         name: 'Teleseminars',
         href: '/teleseminar.jsp'
      }, {
         name: 'Interviews / Press',
         href: '/media_inquiries.jsp'
      }],
      menuLeftOffset: -139,
      menuId: 'eventsDropMenu',
      featItem: {
         href: '/events.jsp',
         src: '/images/event_drop.jpg'
      }
   });
   $('#innerMainMenu2').abtHomeMenu2({
      items: menuLinkItems2,
      menuLeftOffset: -309
   });
   
   $('#bookMainMenuLink').bookLinkMenu();
   
   $('#mainHomeMenu').abtHomeMenu({
      menuTitle: 'the book',
      itemHoverColor: '#e5e5e5',
      class_prefix: 'inner',
      items: menuLinkItems
   });
   
   $('#mainInnerMenu').abtHomeMenu({
      menuTitle: 'the book',
      itemHoverColor: '#e5e5e5',
      class_prefix: 'inner',
      items: menuLinkItems
   });
   
   var useNewLogin = false;
   $('#createAcntBtn' + (!useNewLogin ? ', #loginBtn' : '')).click(function(e){
      var comingSoonHtml = 'Membership coming soon';
      comingSoonHtml += '<br /><br />';
      comingSoonHtml += '<button type="button" id="okayClose">Close</button>';
      abtPopup.open(comingSoonHtml, 200, 75, function($box){
         $box.css({
            top: '50px',
            right: '200px',
            'z-index': 30000
         });
      }, e, 'puff', 500, function(){
         $('#okayClose').click(function(){
            abtPopup.close('puff', 700);
         });
      });
   });
   
   $('#logoutBtn').unbind('click').click(function(e){
      doLogout();
   });
   $('#myAcntBtn').unbind('click').click(function(e){
      location.href = '/member_area/my_account.do';
   });
   /* uncomment to work on new login*/
   if (useNewLogin) {
      $('#loginBtn').unbind('click').click(function(e){
         $.get('/includes/login.jsp', function(data){
         
            abtPopup.open(data, 300, 140, function($box){
               $box.css({
                  top: '50px',
                  right: '200px',
                  'z-index': 30000
               });
            }, e, 'puff', 500, function(){
            
            });
         });
      });
   }
   
   $('.menuHoverE3').hover(function(){
      this.style.backgroundColor = '#e5e5e5';
   }, function(){
      this.style.backgroundColor = '#fff';
   });
   $('.menuHoverFF').not('.noHilight').hover(function(){
      this.style.backgroundColor = '#fff';
   }, function(){
      this.style.backgroundColor = '';
   });
   $('.menuHoverMember').not('.noHilight').hover(function(){
      this.style.backgroundColor = '#e8eff5';
   }, function(){
      this.style.backgroundColor = '';
   });
});

