// I ♥ jQuery

jQuery(document).ready(function () {
	
  jQuery('#mycarousel').jcarousel();
  
  // Navigation Hover		
  $("#social li a, .item-wrap ul li img").hover(function () {
    $(this).stop().animate({
      marginTop: "-5px"
    }, 100);
  }, function () {
    $(this).stop().animate({
      marginTop: "0px"
    }, 300);
	
    // Project info hover 
    $('.item-wrap ul li img').each(function () {
      var title = $(this).attr("alt");
      $(this).hover(function () {
        $('div#output').html('<p>' + title + '</p>').stop(true, true).fadeIn(300);
      }, function () {
        $('div#output').html('<p>' + title + '</p>').stop(true, true).fadeOut(600);
      });
    });
	
	//Tweet
	
	jQuery(function($){
        $("div.tweet-box").tweet({
          avatar_size: 32,
          count: 1,
          username: "allyreid",
          template: "{text} » {retweet_action}"
        });
      }).bind("loaded", function(){
        $(this).find("a.tweet_action").click(function(ev) {
          window.open(this.href, "Retweet",
                      'menubar=0,resizable=0,width=550,height=420,top=200,left=400');
          ev.preventDefault();
        });
      });
	
    // Contact form 
    $("#contactform").validate({
      rules: {
        name: "required",
        email: "required"
      },
      messages: {
        name: "Please enter your name",
        email: "Please enter a valid email address"
      },
      submitHandler: function (form) {
        $(form).ajaxSubmit({
          success: function () {
            $('#myModal a.close-reveal-modal').trigger('click'); // Closes my modal window
            alert('Your message has been sent!');
          }
        });
      }
    });
  });
}); //end

