﻿/**
 * @author Remy Sharp
 * @date 2008-03-27
 * @url http://jqueryfordesigners.com/coda-popup-bubbles/
 * @license Creative Commons License - ShareAlike http://creativecommons.org/licenses/by-sa/3.0/
 *
 * See URL for markup examples and screencast
 */

(function ($) {
	$.fn.bubble = function (options) {
		var defaults = {
			'trigger' : '.trigger',
			'popup' : '.popup',
			'distance' : 10,
			'hideDelay' : 500,
			'effectTime' : 250
		};
		
		var settings = $.extend({}, defaults, options);
		
		var startingTop = $(settings.popup).css("left");
		
		return this.each(function () {
			var hideDelayTimer = null;

			var trigger = $(settings.trigger);
			var popup = $(settings.popup);

			$([trigger.get(0), popup.get(0)]).mouseover(function () {
				if (hideDelayTimer) clearTimeout(hideDelayTimer);

				if (popup.is(':animated, :visible')) {
					return;
				} else {
					popup.css({
						display: 'block',
						left: startingTop
					}).animate({
						opacity: 1,
						left: '-=' + settings.distance + 'px'
					}, settings.effectTime);				
				}
			}).mouseout(function () {
				if (hideDelayTimer) clearTimeout(hideDelayTimer);

				hideDelayTimer = setTimeout(function () {
					hideDelayTimer = null;
					popup.animate({
						left: '-=' + settings.distance + 'px',
						opacity: 0
					}, settings.effectTime, 'swing', function () {
						popup.css('display', 'none');
					});		
				}, settings.hideDelay);
			});
		});
	}
})(jQuery);


  function makeRoundedBox( idOfContent, imageNamePrefix )
	{
		if( imageNamePrefix == undefined )
		    imageNamePrefix = idOfContent;
		var element = $("#" + idOfContent);
		var innerHtml = element.innerHTML;
		
		element.wrapInner( "<div id='" + idOfContent + "_content'></div>" );
		element.prepend( "<div id='" + idOfContent + "_rtop'><div></div></div>" );
		element.append(  "<div id='" + idOfContent + "_bottom' ><div id='" + idOfContent + "_rbottom'></div></div>" );

		element.css( { background: "url(" + imageNamePrefix + "_tl.png) no-repeat top left" } );
		$("#" +idOfContent + "_rtop").css(
		{
			background: "url(" + imageNamePrefix + "_tr.png) no-repeat top right"
		});
		
		$("#" +idOfContent + "_content").css(
		{
			background: "url(" + imageNamePrefix + "_r.png) top right repeat-y",
			marginTop: "-19px",
			padding: "0 15px" 
		});
		
		$("#" +idOfContent + "_bottom").css(
		{
			background: "url(" + imageNamePrefix + "_bl.png) no-repeat bottom left",
			marginTop: "-19px"
		});		

		$("#" +idOfContent + "_rbottom").css(
		{
			background: "url(" + imageNamePrefix + "_br.png) no-repeat bottom right"
		});
		
		$("#" + idOfContent + "_rbottom, #" + idOfContent + "_bottom, #" + idOfContent + "_rtop").css(
		{
			width: "100%",
			height: "15px",
			fontSize: "1px"
		});
	}