

// FEATURED 

function changeFeatured(value) {
  if ( typeof  changeFeatured.x == 'undefined' ) {
    changeFeatured.x = 2;
  }
  if ( typeof  changeFeatured.stopSlider == 'undefined' ) {
    changeFeatured.stopSlider = 0; // Stop/Start Slider
  }

  if(changeFeatured.stopSlider) {
    changeFeatured.stopSlider-- ;
    return; 
  }

  if (value < 0) {
    if (changeFeatured.x == 1) {
      changeFeatured.x = 2;
    } /* if */     
    else if (changeFeatured.x == 2) {
      changeFeatured.x = 3;
    } /* elseIf */     
    else {
      changeFeatured.x = 1;
    } /* else */     
  } /* if */     

  featuredProcessor(changeFeatured.x); 
  changeFeatured.x++; 
  if (changeFeatured.x > 3) {
    changeFeatured.x = 1;
  } /* if */     
}


function featuredProcessor(value) {
  $('#featuredbanner .slide').fadeOut(1000);
  $('#featuredbanner .slide' + value).fadeIn(1000);
  $('#featuredbanner .slide' + value + ' .image').css({"left":"827px"});
  $('#featuredbanner .slide' + value + ' .image').animate({"left":"0px"},500);
} 


// main
(function($) {
$(document).ready(function() {

   // initialize mega menu plug-in
   $("li.nmega").hoverIntent(
     {
     interval: 100,
     sensitivity: 4,
     over: function(){$(this).addClass("hovering");},
     timeout: 500,
     out: function (){ $(this).removeClass("hovering");}
     }
   ) ;

   // arrows
   $('#arrowleft').click(function() { 
     changeFeatured.stopSlider = 0; 
     changeFeatured(-1);
     changeFeatured.stopSlider = 1; 
    });

   $('#arrowright').click(function() { 
     changeFeatured.stopSlider = 0; 
     changeFeatured(1);
     changeFeatured.stopSlider = 1; 
    });
      
   // start the slider
   setInterval("changeFeatured(1)",9000);

   $("#rdmore1,#rdmore2,#rdmore3").tooltip({
    position: "bottom center", 
    opacity: 1.0,
    onShow: function() {
     changeFeatured.stopSlider = 1000; 
    }
    ,
    onHide: function() {
     changeFeatured.stopSlider = 0; 
    }
   });

   $(".hover1").tooltip({
    position: "bottom center", 
    opacity: 1.0,
    tipClass: 'tooltip1'
   });


  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }

  $.preLoadImages("http://andersonrose.com/wp-content/themes/arose/images/menutab2.png");


});
})(jQuery)


