$(function() {
  $('.panel a[href=#more]').click(toggleProductForm);
  $('form a[href=#submit]').click(fakeSubmit);
//  $('input[type=text],textarea').focus(function(evt) {/*$(this).select();*/$(this).val('');});
  $('input[type=text], textarea').each(function(i) {
    $(this).data('defaultVal', $(this).val());
  });
  $('input.text, textarea').focus(function(e) { if($(this).val() == $(this).data('defaultVal')) {$(this).val('');} else {$(this).select();}}).blur(function(e) { 
    if($(this).val() == '') {$(this).val($(this).data('defaultVal'));}
  });
});

function toggleProductForm(evt) {
  if($(this).parents('.product').size() != 0) {
    $panel = $(this).parents('.product');
  } else {
    $panel = $(this).parents('.panel');
  }
  $form = $panel.find('.product-form:first, .panel-form:first');
  $form.slideToggle('fast');
  $(this).toggleClass('active');
  evt.preventDefault();
}

//toggleProductForm

function fakeSubmit(evt) {
  $(this).parents('form').submit();
  evt.preventDefault();
}
