$(document).ready(function(){

  if (!imagePath && !flashPath) {
    $(".expand, .collapse").hide();
  }
  var isNotLoaded = true;
  var headHeight = $(".head .animation").height();
  var headShiftSpeed = 1000;
  $(".head .switch a").bind("click", function(){
    if ($(".head").hasClass("expanded")) {
      $(".head .wrapper").animate({height: "145"}, headShiftSpeed, function(){
        $(".head").addClass("collapsed").removeClass("expanded");
      });
    } else {
      if (isNotLoaded && isCollapsed) {
        if (imagePath) {
          $(".animation").css("background", "url(" + imagePath + ")");
        }
        if (flashPath) {
          $(".animation").append('<embed src="' + 
            flashPath +
            '" wmode="opaque" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" />'
          );
        }
        if ($.browser.msie && $.browser.version <= 6) {
          $(".png").removeClass("png").addClass("png");
        }
        isNotLoaded = false;
      }
      $(".head .animation").show();
      $(".head").addClass("expanded");
      $(".head .wrapper").animate({height: headHeight}, headShiftSpeed);
      $(".head").removeClass("collapsed");
    }
    return false;
  });

  $("a[rel=lightbox]").lightBox();

  $("a[rel^=photo]").each(function(i) {
	  $("a[rel=" + this.rel + "]").lightBox();
  });

  $("a[rel^=gallery]").click(function() {
	  $("a[rel=photo" + this.rel.substring(7) + "]:first").click();
	  return false;
  });


/*
  if (!($.browser.msie && $.browser.version <= 6)) {
    $(".auto").removeClass("auto");
    var fadeSpeed = 10;
    $(".banner").hover(function(){
      $(this).find(".wrap, .next, .photos").fadeIn(fadeSpeed);
    },function(){
      $(this).find(".wrap, .next, .photos").fadeOut(fadeSpeed);
    });
  }

  $("a").not("a[rel=lightbox]").not("a[rel^=photo]").not("a[rel^=gallery]").not(".expand").not(".collapse").bind("click", function(){
    reg = /#\w*$/;
    address = $(this).attr("href");
    var href = window.location.href, isAnchor = false;
    if (reg.test(address)) {
      var t = address;
      t = t.replace(reg, '');
      href = href.replace(reg, '');
      new_reg = new RegExp(t + "$");
      if (new_reg.test(href)) {
        isAnchor = true;			
      }
    }
    if (!isAnchor && address.indexOf("mailto:") != 0) {
      $("#sky, #ground").show().animate({height: "51%"}, 1000, function() {
        window.location.href = address;
      });
      return false
    }
    return true;
  });*/

});