/*
 * jQuery titlebox
 *
 */


jQuery(document).ready(function() {
	titlebox_css = {
		padding: 7,
		position: "absolute",
		MozBorderRadius: 8,
		background: "#40565c",
		color: "white",
		opacity: 0.8
	};
	titlebox_code = jQuery('<div id="titlebox"></div>').css(titlebox_css).hide();
	titlebox_save = "";
	jQuery('a[rev="ttlbox"]').hover(function(handle) {
		// onmouseover
		jQuery("body").append( titlebox_code );
		titlebox_save = jQuery(this).attr("title");
		jQuery(this).attr("title", "");
		jQuery("#titlebox").text( titlebox_save ).css("top", handle.pageY + 2 + jQuery(this).height() ).css("left", handle.pageX - 5 - jQuery(this).width() ).show();
	}, function() {
		// onmouseout
		jQuery(this).attr("title", titlebox_save);
		jQuery("#titlebox").remove();
	});	
	jQuery('a[rev="ttlbox3"]').hover(function(handle) {
		// onmouseover
		jQuery("body").append( titlebox_code );
		titlebox_save = jQuery(this).attr("title");
		jQuery(this).attr("title", "");
		jQuery("#titlebox").text( titlebox_save ).css("top", handle.pageY + 2 + jQuery(this).height() ).css("left", handle.pageX ).show();
	}, function() {
		// onmouseout
		jQuery(this).attr("title", titlebox_save);
		jQuery("#titlebox").remove();
	});	
	jQuery('a[rev="ttlbox2"]').hover(function(handle) {
		console.dir( handle );
		// onmouseover
		jQuery("body").append( titlebox_code );
		jQuery("#titlebox").html( jQuery(this).html() ).css("width", 250).css("top", handle.pageY + 5 ).css("right", window.innerWidth - handle.pageX ).show();
	}, function() {
		// onmouseout
		jQuery(this).attr("title", titlebox_save);
		jQuery("#titlebox").remove();
	});
	jQuery('a[rev^="imgbox"]').hover(function(handle) {
		// onmouseover
		imgUrl = jQuery(this).attr("rev").split("|")[1];
		jQuery("body").append( titlebox_code );
		jQuery("#titlebox").html( '<img alt="" src="'+imgUrl+'" height="150" />' ).css("top", handle.pageY + 2 + jQuery(this).height() ).css("left", handle.pageX - 5 - jQuery(this).width() ).show();
	}, function() {
		// onmouseout
		jQuery("#titlebox").remove();
	});		
});