$(document).ready(function() {
  // Get current URL
  var path = window.location.pathname;

  // Get file name
  path = path.substring(path.lastIndexOf('/') + 1);

  // Run carousel if on homepage
  if(path == "index.php" || path == "") {
    $("#carousel").jCarouselLite({
      easing: "easeInOutQuad",
      speed: 1000,
      visible: 1,
      auto: 5000,
      pause: 1
    });
  }

  // Run fancybox
  if($(".fbox").length) {
    $(".fbox").fancybox({
      'centerOnScroll': true,
      'titlePosition': 'over',
      'transitionIn': 'fade',
      'transitionOut': 'fade',
      'speedIn': 500,
      'speedOut': 500,
      'easingIn': 'easeInOutQuad',
      'easingOut': 'easeInOutQuad'
    });
  }
});

/* Captcha Code for contact form, resets captcha code on clicks */
$(function() {
  $("#captchaReset").click(function() {
    $("#captchaCode").attr("src", "captcha.php?" + Math.random());
    $("#captcha").val("");
    $("#captcha").focus();
    return false;
  });
});

$(function() {
  $("#captchaCode").click(function() {
    $("#captchaCode").attr("src", "captcha.php?" + Math.random());
    $("#captcha").val("");
    $("#captcha").focus();
    return false;
  });
});
/* End Captcha Code */

/* XHTML Strict compatible, open REL="External" links in new window */
$(function() {
  $("a[rel*=ext]").click(function() {
    window.open(this.href);
    return false;
  });
});
/* End REL fix */
