$(document).ready(function() {
  // make divs clickable
  $(".clickable").click(function(){
    window.location=$(this).find("a").attr("href");
    return false;
  });

  // clears default focused fields
  $(".clearMeFocus").focus(function () {
    if ($(this).val() === $(this).attr("title")) {
      $(this).val("");
    }
  }).blur(function () {
    if ($(this).val() === "") {
      $(this).val($(this).attr("title"));
    }
  });

  // initiates draggable elements
  $(function() {
    $(".drag-me").draggable({ stack: ".drag-me" });
  });

  // initiates image rotator on front page
  $('#rotator').cycle();

  // initiates gallery lightbox
  $("a[rel=rge-gallery]").fancybox({
    'titleShow'		: false,
    'transitionIn'		: 'elastic',
    'transitionOut'		: 'elastic'
  });
  
  $("a[rel=nye-gallery]").fancybox({
    type : 'iframe',
    width : 1050,
    height : 1294,
    titleShow : false,
    centerOnScroll : true,
    transitionIn : 'elastic'
  });

  var v = jQuery("#c_form").validate({
    submitHandler: function(form) {
      jQuery(form).ajaxSubmit({
        success: function() {
          $('#contact_form').fadeOut(500);
          $('#contact_form_success').delay(500).fadeIn('slow');
        }
      });
    }
  });
  
  // menu switch
  $('.menu-nav-item a').click(function(){
    var loc = $(this).attr('id');
    $('.menu-nav-item').removeClass('active');
    $('.menu-type-content').addClass('inactive');
    $('#menu-' + loc).removeClass('inactive');
    $(this).parent().addClass('active');
    return false;
  });
});
