function addMenuArrow () {
  if($('#nav_top li.active').position() != null){
	  var timeout;

	  elMenuMarker = document.createElement('img');
	  $(elMenuMarker).attr('src', '/sites/all/themes/theme_name/img/bgNavtopActive.png')
					 .attr('id', 'menumarker')
					 .attr('alt', '');

	  $('.layout_navtop').css('position','relative').append(elMenuMarker);

	  $('#menumarker').css('position','absolute').css('top',0).css('left', $('#nav_top li.active').position()['left'] + ($('#nav_top li.active').width() / 2) + $('#nav_top').position()['left']);

	  $('#nav_top li').mouseover(function () {
		clearTimeout(timeout);
		$('#menumarker').stop().animate({'left': $(this).position()['left'] + ($(this).width() / 2) + $('#nav_top').position()['left'] - 3}, 400);
	  });

	  $('#nav_top li').mouseout(function () {
		timeout = setTimeout(function () {
		  $('#menumarker').stop().animate({'left': $('#nav_top li.active').position()['left'] + ($('#nav_top li.active').width() / 2) + $('#nav_top').position()['left'] - 3}, 400);
		}, 500);
	  });
  }
}//function

function formatTitle(title, currentArray, currentIndex, currentOpts){
	return "<div class=\"title\">" + title + "</div><div class=\"count\">Image " + (currentIndex + 1) + " of " + currentArray.length + "</div><div class=\"close\"><a onclick=\"$.fancybox.close();\">Close</a></div>";
}

$(document).ready(function() {
	$('a[rel=carehomegallery]').fancybox({
		cyclic: true,
		titlePosition: 'inside',
		titleFormat: formatTitle,
		showCloseButton: false
	});
	
	addMenuArrow();
	
	$('.layout_content_home .imageArea .rotator').cycle({
		fx:'fade',
		timeout:5000,
		speed:2000
	});
	
	$('.clear').before('<div class="clear"><!-- --></div>');
});


