﻿$(function () {
  // Make external links open in new window
  $("a[href^=http]").not(".lightbox").click(function () {
    window.open(this.href);
    return false;
  });
});

$(document).ready(function () {
  // Bouncing icons
  $(".icon img").mouseover(function () {
    $(this).animate({ top: 10 }, "fast", "easeOutCirc");
    $(this).animate({ top: 0 }, "fast", "easeOutCirc");
  })

  // Sub-nav
  $("#ctl00_HyperLink1").click(function () {
    if ($("#ctl00_BulletedList1").css("height") == "145px") {
      $("#ctl00_BulletedList1").animate({ "height": 0 }, "slow", "easeOutCirc");
    } else {
      $("#ctl00_BulletedList2").animate({ "height": 0 }, "fast", "easeOutCirc");
      $("#ctl00_BulletedList1").animate({ "height": 145 }, "fast", "easeOutCirc");
    }
  })
  $("#ctl00_HyperLink2").click(function () {
    if ($("#ctl00_BulletedList2").css("height") == "116px") {
      $("#ctl00_BulletedList2").animate({ "height": 0 }, "slow", "easeOutCirc");
    } else {
      $("#ctl00_BulletedList1").animate({ "height": 0 }, "fast", "easeOutCirc");
      $("#ctl00_BulletedList2").animate({ "height": 116 }, "fast", "easeOutCirc");
    }
  })

  // Contact form
  $("#handle").click(function () {
    if ($("#contact").css("right") == "-370px") {
      $("#contact").animate({ "right": 0 }, "slow", "easeInBack");
    } else {
      $("#contact").animate({ "right": -370 }, "fast", "easeInBack");
    }
  })
  $("#container").click(function () {
    $("#contact").animate({ "right": -370 }, "fast", "easeInBack");
  })

  // Fancy nav
  $("#nav a").mouseenter(function () {
    $(this).fadeTo("fast", .8);
    $(this).fadeTo("fast", 1);
  });

  // Lightbox
  $(".lightbox").fancybox({
    'width': '88%',
    'height': '90%',
    'transitionIn': 'fade',
    'transitionOut': 'fade',
    'type': 'iframe'
  });
  $(".popup").fancybox({
    'width': '88%',
    'height': '90%',
    'transitionIn': 'elastic',
    'transitionOut': 'elastic',
    'easingIn': 'easeOutBack',
    'easingOut': 'easeInBack'
  });

})

var animIndex = -1;
function ReturnAnimationIndexToPlay() {
  animIndex++;
  animIndex = (animIndex) % 2;
  return animIndex;
}


