$(document).ready(function() {
	 
	$('.gallery a').fancybox();
	

	$('.nice-table td').css('width','250px');


	$("#myBook").imBookFlip({
		page_class: 'imBookPage'
	});
	
	

function minHeight(divName) { // min height function to set all heights equal to heighest value
  var minHeight = 0;
  var element = $(divName);
  element.each(function () {
    if ($(this).height() > minHeight) {
      minHeight = $(this).height();
    }
  });
  $(divName).height(minHeight); // set largest height
}
minHeight(".bucketRow");
	

// tip hover tool
	$('.tip-message').on({
		click: function(e) {
			e.preventDefault();
		},
		mouseenter: function() {
			
	  	text = $(this).attr('alt');
	  	$('body').prepend('<div class="tip-message-box">'+text+'</div>');
	  	
			$(this).mousemove(function(e){
				var cssObj = {
					'left'			: e.pageX+10,
					'top'				: e.pageY+10
				}
				$('.tip-message-box').css(cssObj);
			});
		},
		mouseleave: function() {
			$('.tip-message-box').remove();
		}
	});


	$("#menu").hide();
   $("#dropDown").hover(function() {
   	if($("#menu").is(":hidden")) {
  		$("#menu").slideDown(800,"easeOutBounce");
		}
	},
   function() {
  		$("#menu").slideUp();
 	});
   

   $("#navigation li").mouseover(function() {
		$(this).children('ul').addClass('subMenu');
	}).mouseout(function(){
		$('#navigation ul li ul').removeClass('subMenu');
 	});




// Fancybox Gallery

$("a.heathcare-gallery").fancybox({
	'titleShow'		: false,
	'transitionIn'	: 'elastic',
	'transitionOut'	: 'elastic'
});


	


	// Slides
	var thisTarget = "#slide1";
	$("#fadeLinks img:first").attr('src', 'images/dot_on.gif');
	$("#slide1").show();

	$("#fadeLinks a").click(function () {
		clearInterval(cycleIntervalID);
		$("#fadeLinks img").attr('src', 'images/dot_off.gif');
     	$(this).children().attr('src', 'images/dot_on.gif'); // child element is an img. 
		
		var hrefVal = $(this).attr('href'); // value of href
		// Assign value of the link target, check if target is current target
		thisTarget == hrefVal ? doFade = false : doFade = true;
		thisTarget = hrefVal;

		fadeImage(doFade);
		this.blur();
		return false;
    });

	function fadeImage(doFade) {
		if(doFade) {
			$('#splash div').fadeOut("slow");
			$(thisTarget).fadeIn("slow");
		}
	}

	function imageCycle() {
		$("#fadeLinks img").attr('src', 'images/dot_off.gif');
		if(thisTarget == "#slide1") {
			thisTarget = "#slide2";
			$('#fadeLinks a[href*="slide2"]').children().attr('src', 'images/dot_on.gif');
		} else if(thisTarget == "#slide2") {
			thisTarget = "#slide3";
			$('#fadeLinks a[href*="slide3"]').children().attr('src', 'images/dot_on.gif');
		} else if(thisTarget == "#slide3") {
			thisTarget = "#slide4";
			$('#fadeLinks a[href*="slide4"]').children().attr('src', 'images/dot_on.gif');		
		} else {
			thisTarget = "#slide1";
			$('#fadeLinks a[href*="slide1"]').children().attr('src', 'images/dot_on.gif');
		}
		fadeImage(true);
	}
	var cycleIntervalID = setInterval(imageCycle, 9000);
	
});


// Twitter Feed scroll bars
function twitterScroll() {
	$('.scroll-pane').jScrollPane({showArrows: true});
}


