$(document).ready(function(){
													 
	// Mailto script
	// <a href="mailto:youremail(at)yourdomain.com" rel="email">your text here</a>
	$("a[rel=email]").each(function(){
		var email = $(this).attr("href");
		var email = email.substring(7,email.length);		
		var email = email.split("\(at\)");
		$(this).click(function(){       
			 document.location = "mailto:" + email[0] + "@" + email[1];	
			 return false;
    });
	});

  // menu - remove margins (css not fully supported yet)
  $("#menu .number:nth-child(6n+1)").css("margin-left","0");
  // menu - add click to li
  $(".number").each(function(){
    var url = $("a", this).attr("href");
    $(this).click(function(){
      window.location = url;
    });
  });
  // menu - add hover
  $(".number").not(".number-active").hover(
    function () {
      $(this).toggleClass("number-active");
      $("span", this).each(function(){
        var background = $(this).css("background-position");
        if (typeof(background) == "undefined") {
          var left = $(this).css("background-position-x");
        } else {
          background = background.split(" ");
          var left = background[0];
        }
        var top = "-7px";
        $(this).css("background-position",left + " " + top);
      });
    },
    function () {
      $(this).toggleClass("number-active");
      $("span", this).each(function(){
        var background = $(this).css("background-position");
        if (typeof(background) == "undefined") {
          var left = $(this).css("background-position-x");
        } else {
          background = background.split(" ");
          var left = background[0];
        }
        var top = "0";
        $(this).css("background-position",left + " " + top);
      });
    }
  );

  // portfolio - add click to table
  $(".stack-table").each(function(){
    var url = $("a", this).attr("href");
    $(this).click(function(){
      window.location = url;
    });
  });

  // portfolio - hide stack photo
  $(".stack-photo").mouseover(function(){
    $(this).hide();
  });
  $(".stack, .stack-table").mouseleave(function(){
    $(this).siblings(".stack-photo").show();
  });

  // portfolio - info action
  $("#info").click(function(){
    $(".background-close").toggle();
  });
  // portfolio - close info
  $(".close-button").click(function(){
    $(".background-close").hide();
  });

});

$(window).load(function(){
													 
	$("a").removeAttr("title");
	
});