		(function($) {
		  var cache = [];
		  // Arguments are image paths relative to the current page.
		  $.preLoadImages = function() {
			var args_len = arguments.length;
			for (var i = args_len; i--;) {
			  var cacheImage = document.createElement('img');
			  cacheImage.src = arguments[i];
			  cache.push(cacheImage);
			}
		  }
		})(jQuery)

		function spinner(holderid, R1, R2, count, stroke_width, colour) {
			var sectorsCount = count || 12,
				color = colour || "#fff",
				width = stroke_width || 15,
				r1 = Math.min(R1, R2) || 35,
				r2 = Math.max(R1, R2) || 60,
				cx = r2 + width,
				cy = r2 + width,
				r = Raphael(holderid, r2 * 2 + width * 2, r2 * 2 + width * 2),
				
				sectors = [],
				opacity = [],
				beta = 2 * Math.PI / sectorsCount,

				pathParams = {stroke: color, "stroke-width": width, "stroke-linecap": "round"};
				Raphael.getColor.reset();
			for (var i = 0; i < sectorsCount; i++) {
				var alpha = beta * i - Math.PI / 2,
					cos = Math.cos(alpha),
					sin = Math.sin(alpha);
				opacity[i] = 1 / sectorsCount * i;
				sectors[i] = r.path([["M", cx + r1 * cos, cy + r1 * sin], ["L", cx + r2 * cos, cy + r2 * sin]]).attr(pathParams);
				if (color == "rainbow") {
					sectors[i].attr("stroke", Raphael.getColor());
				}
			}
			var tick;
			(function ticker() {
				opacity.unshift(opacity.pop());
				for (var i = 0; i < sectorsCount; i++) {
					sectors[i].attr("opacity", opacity[i]);
				}
				r.safari();
				tick = setTimeout(ticker, 1000 / sectorsCount);
			})();
			return function () {
				clearTimeout(tick);
				r.remove();
			};
		}

		function sizeBackground() {
			if($(window).height() < 1020) {
				$('#background').height(1020);
			}
			if($(window).width() < 1180) {
				$('#background').width(1180);
			}
		}

		function rotateCoffee() {
			angle -= 540;
			img2.animate({rotation: angle}, 15000, ">", function () {});
		}

		// create custom animation algorithm for jQuery called "bouncy" 
		$.easing.bouncy = function (x, t, b, c, d) { 
			var s = 1.70158; 
			if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; 
			return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; 
		} 
		 
		// create custom tooltip effect for jQuery Tooltip 
		$.tools.tooltip.addEffect("bouncy", 
		 
			// opening animation 
			function(done) { 
				this.getTip().animate({top: '+=15'}, 500, 'bouncy', done).show(); 
			}, 
		 
			// closing animation 
			function(done) { 
				this.getTip().animate({top: '-=15'}, 500, 'bouncy', function()  { 
					$(this).hide(); 
					done.call(); 
				}); 
			} 
		);

		$(document).ready(function(){
		
			jQuery.preLoadImages('/artwork/background.jpg');
			sizeBackground();

			var pageLoader = spinner("pageLoader", 40, 70, 10, 15, "#fff");
			$('#all').hide();

			$(".toolTip[title]").tooltip({
				tip: '#flowTip', 
				offset: [-10, 2],
				effect: 'bouncy'
			}).dynamic( {
				bottom: {
					direction: 'down',
					bounce: true
				}
			});
	
			var src1 = '/artwork/badge.png';
			var src2 = '/artwork/cafea-inside.png';
			angle = 0;

			$('#badge').html();
			var R1 = Raphael("badge", 337, 355);
			img1 = R1.image(src1, 50, 50, 237, 255);

			$('#badge').mouseout(function(){
				img1.animate({rotation: 0}, 250, "<")
			}).mouseover(function(){
				img1.animate({rotation: 15}, 150, ">")
			});

			$('#badge').animate({
					top: '-110px'
				}, 500, 'swing');

			$('#cafea-inside').html();
			var R2 = Raphael("cafea-inside", 145, 145);
			img2 = R2.image(src2, 0, 0, 145, 145);

			$('#cafea').mouseout(function(){}).mouseover(function () {
				rotateCoffee();
			});
			rotateCoffee();
			
			setTimeout(function () {R1.safari(); R2.safari();});
		});

		$(window).load(function () {
			$('#all').show();
			$('#pageLoader').remove();
		});

		$(window).resize(function() {
			sizeBackground();
		});