$(function(){
	startImageGrid = function(){
		var source = $('#dynamicImageGrid');
		source.find('li').each(function(i){
			$(this).hover(
				function(){
					var dw = $(document).width(), pw = 992, tw, tPos, newPos;
					$(this).find('img').hide().eq(1).show();
					$(this).find('.tooltip').show();
					tPos = $(this).find('.tooltip').offset().left;
					tw = $(this).find('.tooltip').width() + 35;
					if ((dw - (tw + tPos)) < 0){
						newPos = 175 - (dw - (tw + tPos))*-1;
						$(this).find('.tooltip').css({
							left: newPos
						});
					}
				},
				function(){
					$(this).find('img').hide().eq(0).show();
					$(this).find('.tooltip').css({
						left: 175
					}).hide();
				}
			);
			$(this).find('img').eq(1).hide();
		});
	};
});

