window.addEvent('domready', function() {

   //book online
   var myPages = $$('.bookLink'); var myBubbles = $$('.bubble'); var toggle = 'true';
   //offers
   var myOffer = $$('.offerLink'); var myPanel = $$('.offersSlide'); var open = 'true';
   //offer flyout
   var offersPullout = $$('.offerPullout'); var flyoutOffer = $$('.bubble-flyout'); var flyout = 'true';

   /*promo flyout
   var promoPullout = $$('.promoLink'); var myPromo = $$('.promoSlide'); var mouseOn = 'true';*/

   //promo flyout
   var promoPullout = $$('.promoLink'); myPromo = $$('.promoSlide'); var opnOut = 'true';

   //news flyout
   var newsPullout = $$('.newsLink'); myNews = $$('.newsSlide'); var openOut = 'true';

   //search open
   //var searchOpen = $$('.input_search'); var searchBtn = $$('.submit_search'); var slide = 'true';

   //content open
   var contentOpen = $$('.slidePanel'); var showContent = $$('.showContent'); var display = 'true';

   myPanel.setStyle('opacity', 0);
   myBubbles.setStyle('opacity', 0);
   flyoutOffer.setStyle('opacity', 0);
   //searchOpen.setStyle('opacity', 0);	searchOpen.setStyle('width', 2);
   contentOpen.setStyle('height', '0px');

   /* book online */
   myPages.each(function(el, i) {
      el.set('morph', { link: 'cancel' });
      //try { Custom.init(); }	catch(e) {}
      el.addEvents({
         'click': function() {
            if (toggle == 'true') { toggle = 'false'; myBubbles[i].morph({ 'opacity': 1, 'margin-top': '-25px' }); }
            else { toggle = 'true'; myBubbles[i].morph({ 'opacity': 0, 'margin-top': '0' }); }
         }
      });
   });

   /* Offers slide */
   myOffer.each(function(el, i) {
      el.set('morph', { link: 'cancel' });
      el.addEvents({
         'click': function() {
            if (open == 'true') {
               open = 'false';  //close promo first
               myPromo[0].morph({ 'opacity': 0, 'height': '0' });
               myNews[0].morph({ 'opacity': 0, 'height': '0' });
               mouseOn = 'true';
               var newheight = 10;
               if (myOffer.length > 0)
                  newheight = myOffer[0].getStyle('height').toInt() * myOffer.length;
               myPanel[i].morph({ 'opacity': 1, 'height': newheight + 'px' });
            }
            else { open = 'true'; myPanel[i].morph({ 'opacity': 0, 'height': '0' }); }
         }
      });
   });

   /* Promo slide 
   promoPullout.each(function(el, i) { el.set('morph', {link : 'cancel' });
		
   el.addEvents({
   'click': function() {
   if (mouseOn == 'true') { 
   mouseOn = 'false';  //close offers first
   myPanel[0].morph({ 'opacity': 0, 'height': '0' });
   myNews[0].morph({ 'opacity': 0, 'height': '0' });
   open = 'true';
   myPromo[i].morph({'opacity' : 1, 'height' : '105px'}); }
   else {mouseOn = 'true'; myPromo[i].morph({'opacity' : 0, 'height' : '0'}); }
   }
   });
   });*/

   /* promo slide */
   promoPullout.each(function(el, i) {
      el.set('morph', { link: 'cancel' });

      el.addEvents({
         'click': function() {
            if (opnOut == 'true') {
               opnOut = 'false';  //close offers first
               myPanel[0].morph({ 'opacity': 0, 'height': '0' });
               myNews[0].morph({ 'opacity': 0, 'height': '0' });
               open = 'true';
               myPromo[i].morph({ 'opacity': 1, 'height': '105px' });
            }
            else { opnOut = 'true'; myPromo[i].morph({ 'opacity': 0, 'height': '0' }); }
         }
      });
   });

   /* News slide */
   newsPullout.each(function(el, i) {
      el.set('morph', { link: 'cancel' });

      el.addEvents({
         'click': function() {
            if (openOut == 'true') {
               openOut = 'false';  //close offers first
               myPanel[0].morph({ 'opacity': 0, 'height': '0' });
               myPromo[0].morph({ 'opacity': 0, 'height': '0' });
               open = 'true';
               myNews[i].morph({ 'opacity': 1, 'height': '105px' });
            }
            else { openOut = 'true'; myNews[i].morph({ 'opacity': 0, 'height': '0' }); }
         }
      });
   });

   /* Print popout */
   var abbOpen = $$('.abb'); var showTheContent = $$('.abb_over');
   showTheContent.setStyle('opacity', 0);

   /*  */
   abbOpen.each(function(el, i) {
      el.set('morph', { link: 'cancel' });
      el.addEvents({
         'mouseenter': function() { showTheContent[i].morph({ 'opacity': 1, 'display': 'block' }); },
         'mouseleave': function() { showTheContent[i].morph({ 'opacity': 0, 'display': 'none' }); }
      });
   });

   /* Individual offer flyout */
   offersPullout.each(function(el, i) {
      el.set('morph', { link: 'cancel' });
      el.addEvents({
         'mouseenter': function() {
            flyoutOffer[i].morph({ 'opacity': 1, 'margin-left': '35px' });
         },
         'mouseleave': function() {
            flyoutOffer[i].morph({ 'opacity': 0, 'margin-left': 0 });
         }
      });
   });

   /* Searchbar slide */
   /*	searchBtn.each(function(el, i) { el.set('morph', {link : 'cancel' });
   el.addEvents({
   'mouseenter': function() {
   searchOpen[i].morph({ 'opacity' : 1, 'width' : '130px' }); 
   },
   'mouseleave' : function() {
   searchOpen[i].morph({ 'opacity' : 0, 'width' : '2px' }); }
   });
   });*/

   /* Home content slide */
   showContent.each(function(el, i) {
      el.set('morph', { link: 'cancel' });
      el.addEvents({
         'click': function() {
            if (open == 'true') { open = 'false'; contentOpen[i].morph({ 'opacity': 1, 'height': '190px' }); g('showContent').innerHTML = 'CLOSE'; showContent.setStyle('bottom', '51px'); }
            else { open = 'true'; contentOpen[i].morph({ 'opacity': 0, 'height': '0' }); showContent.setStyle('height', '14px'); showContent.setStyle('bottom', '51px'); g('showContent').innerHTML = 'MORE INFO +'; }
         }
      });
   });
});
