
  jQuery(function() {
    var body, html, s, text_inputs;
    body = $('body');
    html = $('html');
    text_inputs = $('input:not([type="submit"]), textarea');
    $('#feature.carousel').flexslider({
      slideshow: true,
      animation: 'slide',
      controlNav: false,
      pauseOnHover: true,
      slideshowSpeed: 5000
    });
    $('#tattoo .carousel').flexslider({
      slideshow: true,
      animation: 'slide',
      controlNav: true,
      manualControls: '.thumbnails a',
      pauseOnHover: true,
      slideshowSpeed: 8000
    });
    $('#artists.carousel').elastislide({
      imageW: 66
    });
    $('.thumbnail-carousel').elastislide({
      imageW: 68,
      margin: 10,
      minItems: 4
    });
    $('.related-carousel').elastislide({
      imageW: 100,
      margin: 20,
      minItems: 3
    });
    s = $('#artists.carousel').find('li.selected').detach();
    s.prependTo('#artists.carousel ol.slides');
    s = null;
    $('body').fitVids();
    if ($('#main_content.blog').length) $('article .post_content').fitVids();
    $('input[type="submit"]').addClass('submit');
    $('a:has(img)').addClass('img');
    $("nav .disclosure > a").after($("<em>+</em>").click(function(event) {
      var em, li;
      em = $(this);
      li = em.parent();
      if (li.hasClass("open")) {
        em.text("-");
        return $(li.find('ul')).slideUp().closest('li').removeClass('open');
      } else {
        em.text("+");
        return $(li.find('ul')).slideDown().closest('li').addClass('open');
      }
    })).click(function(event) {
      if ($(this).next('em:visible').click().length > 0) {
        return event.preventDefault();
      }
    });
    $("nav .disclosure.open > em").text("-");
    $('#sorting').change(function() {
      var option;
      option = $(this).val();
      return location.href = option ? '/collections/' + option : '/';
    });
    $('#woooosh').click(function(e) {
      var button, form;
      e.preventDefault();
      button = $(this);
      form = $('form.contact');
      form.ajaxStart(function() {
        return button.addClass('sending').attr('value', 'Sending...');
      });
      form.ajaxStop(function() {
        return button.removeClass('sending');
      });
      return $.ajax({
        url: 'http://www.oak.is.php5-23.dfw1-2.websitetestlink.com/temp/tattly/form',
        data: {
          'to': 'aGVsbG9AdGF0dC5seQ',
          'key': '87defc23bbfae9f7bc0a2a10539d9b80',
          'subject': 'Tattly contact form',
          'name': "" + ($('#first_name').val()) + " " + ($('#last_name').val()),
          'email': $('#email_address').val(),
          'message': $('#message').val()
        },
        dataType: 'jsonp',
        success: function(data) {
          if (data.result && data.result === true) {
            return $('form.contact').fadeOut(0).html('<p>Thank you!</p>').fadeIn();
          } else {
            return alert('An error has occurred, please try again');
          }
        }
      });
    });
    if (body.hasClass('404')) body.addClass('_404');
    if (html.hasClass('ie')) {
      $('img:last-child, li:last-child, p:last-child').addClass('last-child');
      $('input:not([type="submit"])').addClass('not_submit');
      $('#designers > ul > li:nth-child(odd), #team li:odd').addClass('odd');
      $('#designer h2 + p').addClass('images');
      $('#social li:last-child').prepend('/');
      $('.submit').hover(function() {
        return $(this).addClass('hover');
      }, function() {
        return $(this).removeClass('hover');
      });
    }
  });

