/**
 * @author KMM Timing
 */
$(function(){
  $('#sidebar_menu').accordion({
    header: 'h3',
    autoHeight: false,
    collapsible: true,
    active: '.here'
  });
  
  $(".handle").fancybox({
    'scrolling': 'no',
    'titleShow': false,
    'onClosed': function() {
      $("#contact_error").hide();
    }
  });

  $("#contact_form").bind("submit", function() {
    if ($("#contact_name").val().length < 1 || $("#contact_email").val().length < 1 || $("#contact_subject").val().length < 1 || $("#contact_comment").val().length < 1) {
      $("#contact_error").show();
      $.fancybox.resize();
      return false;
    }

    $.fancybox.showActivity();

    $.ajax({
      type: "POST",
      cache: false,
      url: "/contactformhandler.html",
      data: $(this).serializeArray(),
      success: function(data, textStatus, jqXHR) {
        $.fancybox(data);
      },
      error: function(jqXHR, textStatus, errorThrown) {
        $.fancybox(textStatus + "<br />" + errorThrown);
      } 
    });

    return false;
  });
  
  $("#header_icon").click(function() {
    $.fancybox({
      'orig': $(this),
      'href': 'assets/components/gallery/files/16/700.jpg',
      'titleShow': false,
      'transitionIn': 'elastic',
      'transitionOut': 'elastic',
      'speedIn': 600, 
      'speedOut': 200
    });
  });
});
