// our jquery plugin
(function($) {
  $.fn.llan = function(method, options) {
    if (method == 'home_hover') {
      return this.each(function() {
        var url = 'style/home-'+$(this).attr('id')+'.jpeg';
        var element = $(this);
        $('<img>', {src : url}).bind('load', function() {
          element.mouseover(function(e) {
            if ($.fn.llan.home_hover_timer != null)
              clearTimeout($.fn.llan.home_hover_timer);
            $.fn.llan.home_hover_timer = setTimeout( function () {
              $('#home').css('background-image', 'url('+ url + ')');
              $.fn.llan.home_hover_timer = null; }, 300);
            e.stopPropagation();
          })
        });
      });
    }
  };
  $.fn.llan.home_hover_timer = null;
})(jQuery);

// setup google _gaq stack
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-28529453-1']);
_gaq.push(['_trackPageview']);

$(function() {
  // process google gaq when page is in
  $(document).ready(function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  });

  // setup background hover effects for homepage
  $('#home nav li, #home').llan('home_hover');
});


