﻿function MaximizeTray(maximizedTrayId) {
  // Hide all the normal size trays.
  toggleAllTrays(false);
  
  // Show the tray to be maximized.
  $('#' + maximizedTrayId).fadeIn(450);
}

function toggleAllTrays(show) {
  if (show) {
    $('#traysNormal').fadeIn(450);
  }
  else {
    $('#traysNormal').hide();
  }
}

function initializeTrayEvents() {
  $('#comfortNormal').click(
    function() {
      MaximizeTray('comfortExpanded');
    });
    
  $('#comfortNormal').mouseover(
    function() {
      SwapImageShowHide(document.getElementById('homeimg1On'), document.getElementById('homeimg1Off'));
    } );
    
  $('#comfortNormal').mouseout(
    function() {
      SwapImageShowHide(document.getElementById('homeimg1Off'), document.getElementById('homeimg1On'));
    } 
    );

  $('#relaxationNormal').click(
    function() {
      MaximizeTray('relaxationExpanded');
    });
    
  $('#relaxationNormal').mouseover(
    function() {
      SwapImageShowHide(document.getElementById('homeimg2On'), document.getElementById('homeimg2Off'));
    } );
    
  $('#relaxationNormal').mouseout(
    function() {
      SwapImageShowHide(document.getElementById('homeimg2Off'), document.getElementById('homeimg2On'));
    } 
    );

  $('#assuranceNormal').click(
    function() {
      MaximizeTray('assuranceExpanded');
    });
    
   $('#assuranceNormal').mouseover(
    function() {
      SwapImageShowHide(document.getElementById('homeimg3On'), document.getElementById('homeimg3Off'));
    } );
    
  $('#assuranceNormal').mouseout(
    function() {
      SwapImageShowHide(document.getElementById('homeimg3Off'), document.getElementById('homeimg3On'));
    } 
    );

  $('#atYourVillaNormal').click(
    function() {
      MaximizeTray('atYourVillaExpanded');
    });
    
   $('#atYourVillaNormal').mouseover(
    function() {
      SwapImageShowHide(document.getElementById('homeimg4On'), document.getElementById('homeimg4Off'));
    } );
    
  $('#atYourVillaNormal').mouseout(
    function() {
      SwapImageShowHide(document.getElementById('homeimg4Off'), document.getElementById('homeimg4On'));
    } 
    );

  $('.trayCloseContainer').click(
    function() {
      $('.trayMaximized').hide();
      toggleAllTrays(true);
  });


  $('#priceTextAnchor').mouseover(
    function() {
      SwapImageShowHide(document.getElementById('imgPriceOn'), document.getElementById('imgPriceOff'));
    } );
        
    $('#priceTextAnchor').mouseout(
    function() {
      SwapImageShowHide(document.getElementById('imgPriceOff'), document.getElementById('imgPriceOn'));
    } );
}