$(document).ready(function(){
	$('body').append('<div id="ToolTipDiv"></div>');
	$('[tooltip]').each(function(){
		$(this).hover(function(e){
			$(this).mousemove(function(e){
				var tipY = e.pageY + 16;
				var tipX = e.pageX + 16;
				$("#ToolTipDiv").css({'top': tipY, 'left': tipX});
			});
			
			//get the path and the filename
				var src = $(this).attr('src');
				var split2 = src.split('groups/');
				var split3 = split2[1];
				var path2 = split3.split('/');
				var path = path2[0];

				var splitSrc = src.split('_');
				var src2 = splitSrc[0];
				var splitSrc2 = src2.split(path+'/');
				var link = splitSrc2[1];
				var extGet = splitSrc[1];
				var extSplit = extGet.split('.');
				var ext = extSplit[1];
				
				
				var tool = 'images/portfolio/groups/'+path+'/'+link+'_tip.'+ext;
				$('<img src="'+tool+'" />').load(function(){
					picW = this.width;
					picH = this.height;
				//check image width constraints
					maxW = 500;
					if(picW > maxW){
						firstT = picH * maxW;
						twoT = Math.round(firstT/picW);
						
						picW = maxW;
						picH = twoT;
					}
				//check image width constraints
					path = '<img src="'+tool+'" alt="'+link+'" width="'+picW+'" height="'+picH+'" />';
					$("#ToolTipDiv").html(path).stop(true,true).fadeIn("fast");
				});				
			//get the path and the filename
		}, function(){
			$("#ToolTipDiv").stop(true,true).fadeOut("fast");
		});
	});
});
