/* Author:

*/
$(function(){
  $("p:last-child").addClass("last-child");
  $("p:first").addClass("first-of-type");
  $("section img:first").addClass("first-of-type");

  var url = document.location.pathname;
  $("header nav a").each(function(){
  	regex = new RegExp(url+"$")
  	if (url != "/" && (regex.test(this.href) || regex.test(this.href+"/") || regex.test(this.href+"/index.html"))) {
  		$(this).parent("li").addClass("active");
  		$(this).parent("li").parents("li").addClass("active");
  	}

  });

  Cufon.replace('nav a', {hover: true});
  Cufon.replace('h2, p');
  Cufon.now(); 

  function set_internal_link(href) {
    var a = $("a[href="+href+"]")
    if (a && a.attr("href").charAt(0) == "#") {
      $("#right nav .active").removeClass("active")
      a.parent("li").addClass("active")

      Cufon.replace('nav a', {hover: true});
      $("#content div").hide();
      $("#content "+a.attr("href")).show();
    }
  }

  if (window.location.hash) {
    set_internal_link(window.location.hash);
  }

  $("#right nav a, #right area").click(function(){
    set_internal_link($(this).attr("href"));
  })
  $("#right nav a, #right area").bind("mouseenter",function(){
    set_internal_link($(this).attr("href"));
  })
})


$(window).load(function(){
  $("#slideshow").append("<a href='#next' id='next' class='control'>&gt;</a>")
  $("#slideshow").append("<a href='#prev' id='prev' class='control'>&lt;</a>")
  $("#slideshow").cycle({slideExpr: "img", timeout:2800, prev: "#prev", next: "#next"});
  $("#space #slideshow").cycle({slideExpr: "img", timeout:5000, prev: "#prev", next: "#next"});
})






