/*
 *
 * Copyright (c) 2006 Sam Collett (http://www.texotela.co.uk)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 * 
 */

 
/*
 * jQuery ToolTip Demo. Demo of how to add elements and get mouse coordinates
 *	There is also a ToolTip plugin found at http://interface.eyecon.ro/,
 *	  which uses a CSS class to style the tooltip, but shows it below the input/anchor, rather than where the mouse is
 *
 *
 * @name     ToolTipDemo
 * @param    bgcolour  Background colour
 * @param    fgcolour  Foreground colour (i.e. text colour)
 * @author   Sam Collett (http://www.texotela.co.uk)
 * @example  $("a,input").ToolTipDemo('#fff');
 *
 */
$.fn.Tooltip = function(bgcolour, fgcolour, css)
{
	this.mouseover(
		function(e)
		{
			var targ = $(e.target);
			
			if((!this.title && !this.alt) && !this.tooltipset) return;
			// get mouse coordinates
			// based on code from http://www.quirksmode.org/js/events_properties.html
			var mouseX = targ.offset().left;
			var mouseY = targ.offset().top + targ.height() + 2;
			mouseY += 0;
			bgcolour = bgcolour || "#eee";
			fgcolour = fgcolour || "#000";
			css = css || {
				border: '2px outset #ddd',
				padding: '2px'
			};
			
			css.position = 'absolute';
			css.backgroundColor = bgcolour;
			css.color = fgcolour;
			
			// if there is no div containing the tooltip
			if(!this.tooltipdiv)
			{
				// create a div and style it
				var div = document.createElement("div");
				this.tooltipdiv = div;
				$(div).css(css)
				// add the title/alt attribute to it
				.html((this.title || this.alt));
				this.title = "";
				this.alt = "";
				$("body").append(div);
				this.tooltipset = true;
			}
			$(this.tooltipdiv).show().css({left: mouseX + 20 + "px", top: mouseY + 3 + "px"});
		}
	).mouseout(
		function()
		{
			if(this.tooltipdiv)
			{
				$(this.tooltipdiv).hide();
			}
		}
	);
	return this;
}

function showFlashTeaser(url) {
	$.blockUI('<div id="flashPanel"></div>', { top:'200px', left:'200px', width:'450px', height:'400px' });
	
	var so = new SWFObject(url,'embeddedFlashMov','450','400','7');
	so.addParam('allowfullscreen','true');
	so.addParam('bgcolor','#FFFFFF');
	so.write('flashPanel');
	
	var flashEl = $('.blockMsg')[0];
	flashEl.innerHTML = flashEl.innerHTML + '<div><a href="#" style="position:relative;top:5px;left:0px;font-size:16px;font-weight:bold;" onclick="$.unblockUI();return false;">close</a></div>';
}