function popUpBox(box)
{
   bOpen.animate({top: $(window).height()});

   box.animate({top: Math.max(30, $(window).height()-box.outerHeight())});
   bOpen = box;

   $('.info1, .info2, .learnMore, .clouds, .banner, .logo').fadeOut();
   return false;
}

$(document).ready(function(){
   if ($(window).height() > 500 && $(window).width() > 900)
      $('body').css({overflow: 'hidden'});
   $('#mainContent').css({position: 'static', paddingTop: '100%'});

   cloudMovement = '40px';
   cloudDuration = 1000;

   clouds = $('.clouds a');

   /*
   For some reason, because there is an element with the ID of info/buy/etc.
   Internet F'ing Explorer thinks there's a Javascript object with that name.
   Therefore: a prefix. *sigh*
   */
   bInfo = $('#info');
   bBuy = $('#buy');
   bTerms = $('#terms');
   bOpen = bTerms;

   boxes = bInfo.add(bBuy).add(bTerms);

   boxes.prepend('<div class="boxtop"></div><div class="boxcurve"></div><a href="#" class="close">Close</a>');

   boxes.css({position:'absolute', width: 800, top: $(window).height(), left: '50%', marginLeft: -400, zIndex: 2});

   if ($(window).height()-200 > bBuy.outerHeight())
      boxes.height($(window).height()-350)
   else
      boxes.height(bBuy.height());


   $('.close').click(function(){
      $('.info1, .info2, .learnMore, .clouds, .banner, .logo').fadeIn();
      $(this).parent().animate({top: $(window).height()});
      return false;
   });

   clouds.hover(function(){
      $(this).animate({marginTop: '-'+cloudMovement, paddingBottom: cloudMovement}, {duration: cloudDuration, easing: 'easeOutElastic'})
   },
   function(){
      $(this).queue("fx", []);
      $(this).animate({marginTop: 0, paddingBottom: 15}, {duration: cloudDuration, easing: 'easeOutElastic'})
   });

   clouds.click(function(){return popUpBox(bBuy)});

   $('.learnMore').click(function(){return popUpBox(bInfo)});

   $('.terms').click(function(){return popUpBox(bTerms)});

   $('select', bBuy).change(function(){
      window.open("http://www.ryman.co.uk/Storefinder.asp?Branch="+$('select option:selected', bBuy).attr('value'));
   });
})
