/*	ChillTip Version 1.0
	by Christopher Hill - http://www.chillwebdesigns.co.uk/
	Last Modification: 01/05/10
	
	For more information, visit:
	http://www.chillwebdesigns.co.uk/chilltip.html
	
	Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
	- Free for use in both personal and commercial projects
	- Attribution requires leaving author name, author link, and the license info intact
*/

$(document).ready(function(){
						   
// ChillTip Version 1.0 - add class="chillTip" and title="This is a Chilltip" tag to img,a,span attributes. 
						   
$('.chillTip').mouseover(function(){								  
	$('body').append('<div class="title"></div>');
	var title = $(this).attr("title");
	$('.title').append('<p>' + title + '</p>');
	// Change the value below to change opacity of the ChillTip from 0-100 or 0.0-1.0
	$('.title').css("filter:","alpha(opacity=85)").css("-moz-opacity","0.85").css("-khtml-opacity", "0.85").css("opacity", "0.85");  
	$('.title').fadeIn(250);  //ChillTip fade in time (recommended 500ms)
	this.tip = this.title;
	this.title = "";
	});

$('.chillTip').mousemove(function(e){
	var border_top = $(window).scrollTop(),border_right = $(window).width(),offset = 15,left_pos,top_pos;
    if(	border_right - (offset *2) >= $('.title').width() + e.pageX){left_pos = e.pageX + offset;}
	else{left_pos = border_right - $('.title').width() - offset;}
	if(border_top + (offset *2 ) >= e.pageY - $('.title').height()){top_pos = border_top + offset;}
	else{top_pos = e.pageY-$('.title').height( )- offset;}	
	$('.title').css({left:left_pos, top:top_pos});
	});

$('.chillTip').mouseout(function(){
	$('.title').remove();
	this.title = this.tip;
	});

});
