$(function(){

	// ***
	// Scrolling background
	// ***

	// height of background image in pixels
	var backgroundheight = 4000;

	// get the current minute/hour of the day
	var now = new Date();
	var hour = now.getHours();
	var minute = now.getMinutes();

	// work out how far through the day we are as a percentage - e.g. 6pm = 75%
	var hourpercent = hour / 24 * 100;
	var minutepercent = minute / 30 / 24 * 100;
	var percentofday = Math.round(hourpercent + minutepercent);

	// calculate which pixel row to start graphic from based on how far through the day we are
	var offset = backgroundheight / 100 * percentofday;

	// graphic starts at approx 6am, so adjust offset by 1/4
	var offset = offset - (backgroundheight / 1);

	function scrollbackground() {
		// decrease the offset by 1, or if its less than 1 increase it by the background height minus 1
		offset = (offset < 1) ? offset + (backgroundheight - 1) : offset - 1;
		// apply the background position
		$('html').css("background-position", "50% " + offset + "px");
		// call self to continue animation
		setTimeout(function() {
			scrollbackground();
			}, 70
		);
	}

	// Start the animation
	scrollbackground();
});

	// ***
	// transition effect
	// ***

$(document).ready(function () {
	// transition effect
	style = 'easeOutQuart';
	// if the mouse hover the image
	$('.capture').hover(
		function() {
			//display heading and caption
			$(this).children('div:first').stop(false,true).animate({top:0},{duration:200, easing: style});
			$(this).children('div:last').stop(false,true).animate({bottom:0},{duration:200, easing: style});
		},
		function() {
			//hide heading and caption
			$(this).children('div:first').stop(false,true).animate({top:-70},{duration:200, easing: style});
			$(this).children('div:last').stop(false,true).animate({bottom:-70},{duration:200, easing: style});
		}
	);
});

/**
Vertigo Tip by www.vertigo-project.com
Requires jQuery
*/

this.vtip = function() {
	this.xOffset = -70; // x distance from mouse
	this.yOffset = 20; // y distance from mouse       

	$(".vtip").unbind().hover(    
		function(e) {
			this.t = this.title;
			this.title = ''; 
			this.top = (e.pageY + yOffset); this.left = (e.pageX + xOffset);
			$('body').append( '<p id="vtip">' + this.t + '</p>' );
			$('p#vtip').css("top", this.top+"px").css("left", this.left+"px").fadeIn("slow");
		},
		function() {
			this.title = this.t;
			$("p#vtip").fadeOut("slow").remove();
		}
	).mousemove(
		function(e) {
			this.top = (e.pageY + yOffset);
			this.left = (e.pageX + xOffset);
			$("p#vtip").css("top", this.top+"px").css("left", this.left+"px");
		}
	);
};
jQuery(document).ready(function($){vtip();})
