/* Needed for layout fix? */
function equalHeight(group) {
	tallest = 0;
	group.each(function() {
		thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}

$(document).ready(function() {

  equalHeight($(".holder"));

  if ($('#main .options .watch, .seetrailer').length) {
    $('#main .options .watch a, .seetrailer').bind('click', function(event) {
      event.preventDefault();

      var currentTrailer = $(this);
      var trailerTitle   = currentTrailer.attr('data-trailer-title');
      var trailerWidth   = currentTrailer.attr('data-trailer-width');
      var trailerHeight  = currentTrailer.attr('data-trailer-height');
      var trailerHref    = currentTrailer.attr('href');
      
      var input = '<iframe src="' + trailerHref + '" style="border:0px transparent none;" name="' + trailerTitle + ' - Flicks.co.nz" scrolling="no" frameborder="0" marginheight="0" marginwidth="0" width="' + trailerWidth + '" height="' + (parseInt(trailerHeight) + parseInt(37)) + '"><p>Your browser does not support iFrames.</p></iframe>';
      
      $.facebox(input);
      
      // Catch the close action of Facebox
      $(document).bind('close.facebox', function() {
        $('#facebox div.content').empty();
      });
      
      return false;
    });
  }
  
  $('input[type="text"], textarea').bind({
    focus: function () {
      var field = $(this);
      if (field.val() === field.attr('title')) {
        field.val('');
      }
    },
    blur: function () {
      var field = $(this);
      if (field.val() === '') {
        field.val(field.attr('title'));
      }
    }
  }).each(function () {
    var field = $(this);
    if (field.val() === '') {
      field.val(field.attr('title'));
    }
  });

  $('#review, .comment-form').submit(function() {
    $.each($(this).find('input[type="text"], textarea'), function() {
      var field = $(this);
      if (field.val() === field.attr('title')) {
        field.val('');
      }
    });
  });

//  $('#photos').galleryView({
//    panel_width: 691,
//    panel_height: 267,
//    frame_width: 100,
//    frame_height: 38,
//    transition_speed: 1200,
//    background_color: 'transparent',
//    border: 'none',
//    easing: 'easeInOutBack',
//    pause_on_hover: true,
//    nav_theme: 'custom',
//    overlay_height: 52,
//    filmstrip_position: 'bottom',
//    overlay_position: 'none'
//  });

});

