$(function() {
	imageRotator();
	tooltip();
});

function imageRotator() {
	if($('#homeBanner').length > 0) {
		var $container = $('#homeBanner').cycle({
			fx: 'fade',
			timeout: 6000,
			speed: 'fast',
			pause: 1,
			pager: '#serviceMenu',
			pagerAnchorBuilder: function(idx, slide) {
				return '#serviceMenu .slide:eq('+idx+')';
			},
			before: function(currentSlide, nextSlide) {
				$('.slide').removeClass('select');
				$('.slide[rel='+currentSlide.id+']').addClass('select');
			},
			after: function(currentSlide, nextSlide) {
				$('.slide').removeClass('select');
				$('.slide[rel='+nextSlide.id+']').addClass('select');
			}
		});
		$('.slide').click(function() {
			var i = parseInt($(this).attr('rel').substr(6));
			$container.cycle(i);
			$('.slide').removeClass('select');
			$(this).addClass('select');
			return false;
		});
	}
}
function tooltip() {
	if($('.staffBio').length > 0) {
		$('.staffBio').tooltip({
			tip: '.tooltip'
		});
	}
}
jQuery.fn.extend({
	tooltip: function(options) {
		var box = options['tip'] || this.title;
		xOffset = 25;//up & down
		yOffset = 15;// left & right
		
		$(this).css({
			'position': 'relative',
			'z-index': 1
		});
		$(box, this).css({
			'position': 'absolute',
			'z-index': 100,
			'top': 0,
			'left': $(this).width(),
			'display': 'none'
		});

    $(this).live("mouseenter", function() {
			$(this).css('z-index', 2);
      $(box, this).fadeIn("fast", function() {
				
			});
    });
    $(this).live("mouseleave", function() {
			$(this).css('z-index', 1);
      $(box, this).fadeOut("fast", function() {
				
			});
    });
	}
});
