jQuery(document).ready(function(){
	jQuery('#mainslider')
		.anythingSlider({
			hashTags:false,buildArrows:false
		})
  /* this code will make the caption appear when you hover over the panel
    remove the extra statements if you don't have captions in that location */
  .find('.panel')
    .find('div[class*=caption]').css({ position: 'absolute' }).end()
    .hover(function(){ showCaptions( jQuery(this) ) }, function(){ hideCaptions( jQuery(this) ); });

  showCaptions = function(el){
    var jQuerythis = el;
    if (jQuerythis.find('.caption-top').length) {
      jQuerythis.find('.caption-top')
        .show()
        .animate({ top: 0, opacity: 1 }, 400);
    }
    if (jQuerythis.find('.caption-right').length) {
      jQuerythis.find('.caption-right')
        .show()
        .animate({ right: 0, opacity: 1 }, 400);
    }
    if (jQuerythis.find('.caption-bottom').length) {
      jQuerythis.find('.caption-bottom')
        .show()
        .animate({ bottom: 0, opacity: 1 }, 400);
    }
    if (jQuerythis.find('.caption-left').length) {
      jQuerythis.find('.caption-left')
        .show()
        .animate({ left: 0, opacity: 1 }, 400);
    }
  };
  hideCaptions = function(el){
    var jQuerythis = el;
    if (jQuerythis.find('.caption-top').length) {
      jQuerythis.find('.caption-top')
        .stop()
        .animate({ top: -50, opacity: 0 }, 350, function(){
          jQuerythis.find('.caption-top').hide(); }); 
    }
    if (jQuerythis.find('.caption-right').length) {
      jQuerythis.find('.caption-right')
        .stop()
        .animate({ right: -150, opacity: 0 }, 350, function(){
          jQuerythis.find('.caption-right').hide(); });
    }
    if (jQuerythis.find('.caption-bottom').length) {
      jQuerythis.find('.caption-bottom')
        .stop()
        .animate({ bottom: -50, opacity: 0 }, 350, function(){
          jQuerythis.find('.caption-bottom').hide(); });
    }
    if (jQuerythis.find('.caption-left').length) {
      jQuerythis.find('.caption-left')
        .stop()
        .animate({ left: -150, opacity: 0 }, 350, function(){
          jQuerythis.find('.caption-left').hide(); });
    }
  };

  // hide all captions initially
  hideCaptions( jQuery('#mainslider .panel') );
});
