$(document).ready(function(){
  $('#home .hpBlock .rest').hide();

  var blockState = new Array();
  blockState['block1'] = $('#block1 .rest').height();
  blockState['block2'] = $('#block2 .rest').height();
  blockState['block3'] = $('#block3 .rest').height();
  blockState['block4'] = $('#block4 .rest').height();

  //Slide up and down on click
	$(".hpBlock").mouseenter(function(){
      id = $(this).attr('id');
      $(this).height(blockState[$(this).parent().attr('id')]);
      $(this).children(".rest").stop(true, true).slideDown("fast", callEnter);
	});

	$(".hpBlock").mouseleave(function(){
      $(this).children(".rest").stop(true, true).slideUp("fast", callLeave);
	});

  function callEnter() {
    $(this).clearQueue();
    $(this).height(blockState[$(this).parent().attr('id')]);
    $(this).show();
  }

  function callLeave() {
    $(this).clearQueue();
    $(this).height(blockState[$(this).parent().attr('id')]);
    $(this).hide();
  }

  var flashvars = {};
  var params = {wmode: 'transparent'};
  var attributes = {};
  swfobject.embedSWF("front/swf/home.swf", "flashAnimation", "350", "250", "9.0.0", "expressInstall.swf", flashvars, params, attributes);

});
