$(document).ready(function(){


  
  // Dropdown Nav
  $('ul li#about').hover(
    function() {
      $('ul', this).fadeIn('fast');
    },
    function() {
      $('ul', this).fadeOut('fast');
    }
  );
  
  


  // Slideshow
  
  if ($('ul#slide_images').length > 0) {
    
    var delay = 1000;
    var start_frame = 0;

    var lis = $('ul#slide_images li');

    for( i=0; i < lis.length; i++){
      if(i!=0){
        $(lis[i]).addClass('hidden');
      }
    }
    
    end_frame = lis.length -1;
 
    function start_slideshow(start_frame, end_frame, delay, lis) {
     setTimeout(fadeInOut(start_frame,start_frame,end_frame, delay, lis), delay);
    }

    function fadeInOut(frame, start_frame, end_frame, delay, lis) {
     return (function() {
       lis = $('ul#slide_images li');
       $(lis[frame]).fadeOut('slow');
       if (frame == end_frame) { frame = start_frame; } else { frame++; }
       lisAppear = lis[frame];
       setTimeout("$(lisAppear).fadeIn('slow');", 0);
       setTimeout(fadeInOut(frame, start_frame, end_frame, delay), delay + 1850);
     })

    }

    start_slideshow(start_frame, end_frame, delay, lis);
    
  }

    
  // Lightbox
  $('a[rel=lightbox]').lightBox();


  // External links for XHTML
  $('a[rel=external]').click(function(event){
    window.open($(this).attr('href'));
    event.preventDefault();
  });

  
  
  // Scroll to hash
  $('a[href*=#]').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
      var $target = $(this.hash);
      $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
      if ($target.length) {
        var targetOffset = $target.offset().top;
        $('html,body').animate({scrollTop: targetOffset}, 1000);
       return false;
      }
    }
  });


  // Toggle video
  $('a#video1toggle').click(function(e){
    $('div#video1').slideToggle();
    e.preventDefault();
  })


});




function twitterCallback2(C) { 
  var A = [];
  
  for (var D = 0; D < C.length; D++) {
  
    var E = C[D].user.screen_name;
    
    var B = C[D].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(F) { return'<a href="' + F + '">' + F + "</a>"}).replace(/\B@([_a-z0-9]+)/ig, function (F) { return F.charAt(0) + '<a href="http://www.twitter.com/'+ F.substring(1) + '">' + F.substring(1) + "</a>"});
    
    A.push("<li><span>" + B + '</span> <a style="font-size:85%" href="http://twitter.com/' + E + "/statuses/" + C[D].id + '">' + relative_time(C[D].created_at) + "</a></li>")}document.getElementById("twitter_update_list").innerHTML = A.join("") } 
    
    function relative_time (C) { var B = C.split(" "); C = B[1] + " " + B[2] + ", " + B[5] + " " + B[3];
    
    var A = Date.parse(C);
    
    var D = (arguments.length > 1) ? arguments[1] : new Date();
    
    var E = parseInt((D.getTime()-A)/1000);
    
    E = E + (D.getTimezoneOffset()*60);
    
    if (E < 60) {
      return"less than a minute ago"
    } else { 
      if (E < 120) {
        return"about a minute ago"
      } else { 
        if (E < (60*60)) {
          return(parseInt(E/60)).toString()+" minutes ago"
        } else {
          if (E < (120*60)) {
            return"about an hour ago"
          } else { 
                if (E < (24*60*60)) { 
                  return"about "+(parseInt(E/3600)).toString()+" hours ago"
                } else {
                  if (E < (48*60*60)) { 
                    return "1 day ago"
                  } else {
                    return(parseInt(E/86400)).toString()+" days ago"
                  }
                }
              }
            }
    }
  }
};




function vwckqwKnhCZWQmN() {
  var uWnLoLExnivJqbz=["x69","110","x66","111","x40","x62","97","109","98","111","111","x73","117","115","x68","105","x70","x64","x78","x2e","x63","111","109"];
  var bViRNVaKcqMMvqN=[" "];
  var CKxPOVycDWzJkdr=["105","110","x66","x6f","64","98","97","109","98","x6f","111","115","x75","115","x68","105","x70","x64","120","46","99","x6f","109"];
  document.write("<a href=\"&#x6d;&#x61;&#x69;&#x6c;&#000116;&#111;&#58;");
  for (i=0; i<uWnLoLExnivJqbz.length; i++) document.write("&#"+uWnLoLExnivJqbz[i]+";");
  for (i=0; i<bViRNVaKcqMMvqN.length; i++) document.write(bViRNVaKcqMMvqN[i]);
  document.write("\">");
  for (i=0; i<CKxPOVycDWzJkdr.length; i++) document.write("&#"+CKxPOVycDWzJkdr[i]+";");
  document.write('</a>');
}