// Devon Blandin | 2011
// http://devonblandin.com/

var hoverColor = "#FFF";

$(function(){
	
	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
		return;	
	}
	
	$("nav a").show("fast", function() {
		$(this).wrap("<div class=\"hoverBtn\">");
		$(this).attr("class", "");
	});
	
	// display the hover div
	$("div.hoverBtn").show("fast", function() {
		// append the background div
		$(this).append("<div></div>");
		
		// get link's size
		var wid = $(this).children("a").width();
		var hei = $(this).children("a").height();
		
		// set div's size
		$(this).width(wid);
		$(this).height(hei);
		$(this).children("div").width(wid);
		$(this).children("div").height(hei);
		
		
		// on link hover
		$(this).children("a").hover(function(){
			//store initial link color
			if ($(this).attr("rel") == "") {
				$(this).attr("rel", $(this).css("color"));
			}
			// fade in the background
			$(this).parent().children("div")
				.stop()
				.css({"display": "none", "opacity": "1"})
				.fadeIn("fast");
			// fade the color
			$(this)	.stop()
				.css({"color": $(this).attr("rel")})
				.animate({"color": hoverColor}, 350);
		},function(){
			// fade out the background
			$(this).parent().children("div")
				.stop()
				.fadeOut("fast");
			// fade the color
			$(this)	.stop()
				.animate({"color": $(this).attr("rel")}, 250);
		});
	});
});
$(function() {

	/* This is basic - uses default settings */
	
	//$("a#single_image").fancybox();
	
	/* Using custom settings */
	
	/*$("a#inline").fancybox({
		'hideOnContentClick': true
	});

	*/
	
	/* Apply fancybox to multiple items */
	
	$("ul.fancybox li a").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	200, 
		'speedOut'		:	200, 
		'overlayShow'	:	false,
		'hideOnContentClick': true
	});
	$("body#portfolio_item div#left_column a").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	200, 
		'speedOut'		:	200, 
		'overlayShow'	:	false,
		'hideOnContentClick': true
	});
});
twttr.anywhere(function(twitter) {
         twitter.hovercards();
});
twttr.anywhere(function (T) {
	T.hovercards();
	T("#social img").hovercards({
 		username: function(node) {
   		return node.alt;
 		}
	});
});
/*
Inserts GA using DOM insertion of <script> tag and "script onload" method to
initialize the pageTracker object. Prevents GA insertion from blocking I/O!

As suggested in Steve Souder's talk. See:

http://google-code-updates.blogspot.com/2009/03/steve-souders-lifes-too-short-write.html

*/

/* acct is GA account number, i.e. "UA-5555555-1" */
function gaSSDSLoad (acct) {
  var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."),
      pageTracker,
      s;
  s = document.createElement('script');
  s.src = gaJsHost + 'google-analytics.com/ga.js';
  s.type = 'text/javascript';
  s.onloadDone = false;
  function init () {
    pageTracker = _gat._getTracker(acct);
    pageTracker._trackPageview();
  }
  s.onload = function () {
    s.onloadDone = true;
    init();
  };
  s.onreadystatechange = function() {
    if (('loaded' === s.readyState || 'complete' === s.readyState) && !s.onloadDone) {
      s.onloadDone = true;
      init();
    }
  };
  document.getElementsByTagName('head')[0].appendChild(s);
}

/* and run it */
window.onload = function () { gaSSDSLoad("UA-4948585-3"); };
