// JavaScript Document
function expandCollapse(action, w, h, text) {
  action == 'open' ? $('#over, #open, #textarea').show() : $('#over, #open, #textarea').hide();
  $('#box').css({'height': h+"px", "width": w+"px"});
  $('.sh').css({'height': h+"px", "width": w+"px"});
  $('#textarea').css({"width": w+"px"});
  $('#textarea').html(text);
  $('#over').css('height', "100%");
  $('#textarea').css('margin-left', -5);   
}

$(function() {
  next_counter = 2;
  previous_counter = 0;
  $('.photo_nav').show();
  $('#set2, #set3, #set4, #set5, #set6').hide();
  $('#image-gallery img').bind('click', function() {
    expandCollapse('open', 600, 400, $(this).next().html());
    $("#box").html("<img src='"+$(this).attr('class')+"' />");
    return false;
  });
  
  $('#previous').click(function() {
	  if(previous_counter == 0) {
		return false;  
	  }
	  $('#set1, #set2, #set3, #set4, #set5, #set6').hide();
	  $('#set'+previous_counter).show();
	  previous_counter--;
	  next_counter--;
	  return false;
  });
  
  $('#next').click(function() {
	  if(next_counter == 7) {
		return false;  
	  }
	  $('#set1, #set2, #set3, #set4, #set5, #set6').hide();
	  $('#set'+next_counter).show();
	  next_counter++;
	  previous_counter++;
	  return false;
  });

  $('#close').bind('click', function() {
    expandCollapse('close');
    return false;
  });
  return false;
});
