/* jQuery Carousel (http://www.clecompte.com/building-simple-jquery-rotating-carousel/)
===================================================== */
$(document).ready(function() {  
  /* HOME ANIMATION */
  function contentRotate(feature) {
	if (doAnimate) {  
	  feature.fadeOut("fast", function (feature) {
	    return function () {
		  $(".feature_content div").hide();			
		  /* HIGHLIGHT RELEVANT CONTROL */
		  if ($(this).attr("id") == "feature_one") {
		    $(".feature_nav .on").removeClass("on");
		    $(".home_one").addClass("on");
		  }
		  else if ($(this).attr("id") == "feature_two") {
		    $(".feature_nav .on").removeClass("on");
		    $(".home_two").addClass("on");
		  }
		  else if ($(this).attr("id") == "feature_three") {
		    $(".feature_nav .on").removeClass("on");
		    $(".home_three").addClass("on");
		  }		
		  /* FADE IN NEXT ITEM OR GO BACK TO FIRST */
		  feature.fadeIn("fast", function () {
		    if ($(this).attr("id") == "feature_three") {
			  setTimeout(function () {
			    contentRotate($(".feature_content div:first"));
			  }, 4000);
		    }
		    else {
		      setTimeout(function () {
			    contentRotate($(feature.next()));
			  }, 4000);
		    }
		  });
	    };
	  }(feature));
	}
  }
  /* HOME FEATURES */
  $(".feature_nav a").hover(function() {
    var current = $(this).attr("title");
	$(".feature_nav .on").removeClass("on");
	$(this).addClass("on");
  }); 
  $(".feature_nav a").click(function() {
    return false;
  });
  var doAnimate = true;
  contentRotate($(".feature_content div:first"));
  $(".home_one").hover(function() {
	$("#feature_one").fadeIn();
	$("#feature_two").hide();
	$("#feature_three").hide();
	doAnimate = false;
  });
  $(".home_two").hover(function() {
	$("#feature_one").hide();
	$("#feature_two").fadeIn();
	$("#feature_three").hide();
	doAnimate = false;
  });
  $(".home_three").hover(function() {
	$("#feature_one").hide();
	$("#feature_two").hide();
	$("#feature_three").fadeIn();
	doAnimate = false;
  });
});


/* ---------------------------------------------
http://adipalaz.com/experiments/jquery/generated_tabs.html
Requires: jQuery v1.3+
When using this script, please keep this notice intact.
===================================================== */
(function($) {
$.fn.gTabs = function(options) {
    var defaults = {
        section : 'div', // the container element of the individual sections
        head : 'h3', // the section heading
        prefix : 'section', // the prefix of the hash
        def : 1, // the section to be shown by default
        hideHead : 'true' // whether to show or to hide the section headings
    };
    var o = $.extend({}, defaults, options);   
    return this.each(function() {
        var container = $(this),
            prefixLength = o.prefix.length,
            num = location.hash.slice(prefixLength + 1) || o.def;        
        // insert 'ul' before the the element that contains the sections:
        container.before('<ul id="tabs"></ul>');
        // the 'link text' in each tab is generated using the heading of the corresponding section:
        container.find('>' + o.section).each(function(i){
          $('#tabs').append('<li><a class="tab" href="#' + o.prefix + (i+1) + '">' + $(this).prev(o.head).text() + '</a></li>');
          if(o.hideHead) $(this).prev(o.head).hide();
        });       
        // hide all sections except the current (or default) one, and add class='active' to the current (or default) tab:
        container.find('>' + o.section + ':not(:eq(' + (num -1) + '))').hide().end()
        .prev('#tabs').find('a:eq(' + (num -1) + ')').addClass('active');
        $('#tabs a').click(function(thisTab) {
              var thisTab = $(this).closest('#tabs').find('a').index(this);
              $(this).addClass('active').parent().siblings('li').find('a.active').removeClass('active');
              $(this).closest('#tabs').next(container).find('>' + o.section + ':eq(' + thisTab + ')').fadeIn(400).siblings(o.section + ':visible').hide();
        });
    });
};
})(jQuery);
		<!--//--><![CDATA[//><!--
		$("html").addClass("js");
		$(function() {
		  $("#tab-area").gTabs();
		  $("html").removeClass("js");
		});
		//--><!]]>


/** jQuery Background Image Animations (See http://snook.ca/archives/javascript/jquery-bg-image-animations/)
 * @author Alexander Farkas
 * v. 1.02
===================================================== */
(function($) {
	$.extend($.fx.step,{
	    backgroundPosition: function(fx) {
            if (fx.state === 0 && typeof fx.end == 'string') {
                var start = $.curCSS(fx.elem,'backgroundPosition');
                start = toArray(start);
                fx.start = [start[0],start[2]];
                var end = toArray(fx.end);
                fx.end = [end[0],end[2]];
                fx.unit = [end[1],end[3]];
			}
            var nowPosX = [];
            nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
            nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];
            fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];
           function toArray(strg){
               strg = strg.replace(/left|top/g,'0px');
               strg = strg.replace(/right|bottom/g,'100%');
               strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
               var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
               return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
           }
        }
	});
})(jQuery);
		$(function(){
			$('#nav a')
				.css( {backgroundPosition: "0 0"} )
				.mouseover(function(){
					$(this).stop().animate({backgroundPosition:"(-310px 0)"}, {duration:25})
				})
				.mouseout(function(){
					$(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:500, complete:function(){
						$(this).css({backgroundPosition: "0 0"})
					}})
				})
		});


/* New Window for External Links - Kevin Yank - http://blogs.sitepoint.com/standards-compliant-world/
===================================================== */
function externalLinks() {  
 if (!document.getElementsByTagName) return;  
 var anchors = document.getElementsByTagName("a");  
 for (var i=0; i<anchors.length; i++) {  
   var anchor = anchors[i];  
   if (anchor.getAttribute("href") &&  
       anchor.getAttribute("rel") == "external")  
     anchor.target = "_blank";  
 }  
}  
window.onload = externalLinks;
