


$(document).ready(function() {
						   
  $(".home_one").hoverIntent({
	sensitivity: 3, 
	interval: 200, 
	over: makeTall1, 
	timeout: 500, 
	out: makeShort1
  });

  $(".home_two").hoverIntent({
	sensitivity: 3, 
	interval: 200, 
	over: makeTall2, 
	timeout: 500, 
	out: makeShort2
  });
  
  $(".home_three").hoverIntent({
	sensitivity: 3, 
	interval: 200, 
	over: makeTall3, 
	timeout: 500, 
	out: makeShort3
  });
  
  $(".home_four").hoverIntent({
	sensitivity: 3, 
	interval: 200, 
	over: makeTall4, 
	timeout: 500, 
	out: makeShort4
  });
  
  $("#home_feature").hoverIntent({
	sensitivity: 3, 
	interval: 200, 
	over: makeTall5, 
	timeout: 500, 
	out: makeShort5
  });
  
  /* HOME ANIMATION */
  function fadeAndMove(feature) {
	if (doAnimate) {  
	  feature.fadeOut("fast", function (feature) {
	    return function () {
		  $(".feature_right div").hide();
			
		  /* HIGHLIGHT RELEVANT CONTROL */
		  if ($(this).attr("id") == "feature_one") {
		    $(".feature_nav .on").removeClass("on");
			$(".home_one").removeClass("first_off");
		    $(".home_one").addClass("on");
			$(".home_four").addClass("last_off");
		  }
		  else if ($(this).attr("id") == "feature_two") {
		    $(".feature_nav .on").removeClass("on");
		    $(".home_two").addClass("on");
			$(".home_one").addClass("first_off");
			$(".home_four").addClass("last_off");
		  }
		  else if ($(this).attr("id") == "feature_three") {
		    $(".feature_nav .on").removeClass("on");
		    $(".home_three").addClass("on");
			$(".home_one").addClass("first_off");
			$(".home_four").addClass("last_off");
		  }
		  else if ($(this).attr("id") == "feature_four") {
		    $(".feature_nav .on").removeClass("on");
			$(".home_four").removeClass("last_off");
		    $(".home_four").addClass("on");
			$(".home_one").addClass("first_off");
		  }
		
		  /* FADE IN NEXT ITEM OR GO BACK TO FIRST */
		  feature.fadeIn("fast", function () {
		    if ($(this).attr("id") == "feature_four") {
			  setTimeout(function () {
			    fadeAndMove($(".feature_right div:first"));
			  }, 5000);
		    }
		    else {
		      setTimeout(function () {
			    fadeAndMove($(feature.next()));
			  }, 5000);
		    }
		  });
	    };
	  }(feature));
	}
  }


  /* HOME FEATURES */

  var doAnimate = true;

  fadeAndMove($(".feature_right div:first"));

  function makeTall1() {
	$("#feature_one").fadeIn();
	$("#feature_two").hide();
	$("#feature_three").hide();
	$("#feature_four").hide();
	$(".home_two").removeClass("on");
	$(".home_three").removeClass("on");
	$(".home_four").removeClass("on").addClass("last_off");
	$(this).removeClass("first_off");
	$(this).addClass("on");
	doAnimate = false;
  }
  function makeTall2() {
	$("#feature_one").hide();
	$("#feature_two").fadeIn();
	$("#feature_three").hide();
	$("#feature_four").hide();
	$(".home_one").removeClass("on").addClass("first_off");
	$(".home_three").removeClass("on");
	$(".home_four").removeClass("on").addClass("last_off");
	$(this).addClass("on");
	doAnimate = false;
  }
  function makeTall3() {
	$("#feature_one").hide();
	$("#feature_two").hide();
	$("#feature_three").fadeIn();
	$("#feature_four").hide();
	$(".home_one").removeClass("on").addClass("first_off");
	$(".home_two").removeClass("on");
	$(".home_four").removeClass("on").addClass("last_off");
	$(this).addClass("on");
	doAnimate = false;
  }
  function makeTall4() {
	$("#feature_one").hide();
	$("#feature_two").hide();
	$("#feature_three").hide();
	$("#feature_four").fadeIn();
	$(".home_one").removeClass("on").addClass("first_off");
	$(".home_two").removeClass("on");
	$(".home_three").removeClass("on");
	$(this).removeClass("last_off");
	$(this).addClass("on");
	doAnimate = false;
  }
  function makeTall5() {
	  doAnimate = false;
  }
  
  function makeShort1() {
    return false;
  }
  function makeShort2() {
    return false;
  }
  function makeShort3() {
    return false;
  }
  function makeShort4() {
    return false;
  }
  function makeShort5() {
    return false;
  }
  

  
});