var daytime_mode = 'day';

jQuery.easing.def = 'easeOutQuint';


//Activate Immediately
$(document).ready(function(){
	
	//Hides topbar initially
	$("#header-container").hide();
	
	
	// Mouse Follower
	/*
	$("#clickme-followmouse").hide();
	
	$(document).mousemove(function(e){
		$("#clickme-followmouse").show();
 		$("#clickme-followmouse").css({
 			//top: (e.pageY + 15) + "px",
 			top: -1 + "px",
 			left: (e.pageX - 50) + "px"
 		});
 	});
	*/
	
	//Reveals & Hides topbar
	$("#clickme-followmouse").toggle(
		function(){
			$("#header-container").slideDown({
				duration:500,
				easing:"easeOutQuint",
				complete: function(){}
			})
		},
		function(){ 
			$("#header-container").slideUp({
				duration:500,
				easing:"easeOutQuint",
				complete: function(){}
			})
		}
	);
	
	
	// Page "Work"
	$("#work_focus").hide();
	
	$(".work_thumb").click(function()
	{ 
		$("#work_grid").hide();
		$("#work_focus").fadeIn();
	});

	$("#close_focus").click(function()
	{ 
		$("#work_focus").hide();
		$("#work_grid").fadeIn();
	});
	
	
	
	// Animation for CSS Daytime Switcher Tooltip
	$('#css_timeline_switch').each(function (){
		
		var distance = -60;
		var timer = 400;
		var hideDelay = 500;
		var hideDelayTimer = null;
		var beingShown = false;
		var shown = false;
		var trigger = $('.trigger', this);
		var info = $('.time', this).css('opacity', 0);
		
		$([trigger.get(0), info.get(0)]).mouseover(function (){
			if (hideDelayTimer) clearTimeout(hideDelayTimer);
			if (beingShown || shown) {
				return; // don't trigger the animation again
			} 
			else {	
				//
				var date = new Date();
				var h = date.getHours();
				var m = date.getMinutes();
				// add the current time to the info box
				info.text(h+':'+m);
				//
				beingShown = true;	
				// reset position of info box
				info.css({
					top: (-40),
					left: (20),
					display: 'block'
				}).animate({
					top: '+=' + 60 + 'px',
					opacity: 1
				}, timer, 'jswing', function(){
					beingShown = false;
					shown = true;
				});
			}
			return false;
			
		}).mouseout(function(){
			if (hideDelayTimer) clearTimeout(hideDelayTimer);
			hideDelayTimer = setTimeout(function(){
				hideDelayTimer = null;
				info.animate({
					top: '-=' + 60 + 'px',
					opacity: 0
				}, 
				timer, 'jswing', function(){
					shown = false;
					info.css('display', 'none');
				});
			}, 
			hideDelay);
			return false;
		});
	});
	
	/*
	
	$('#daytime-switch a.trigger, #daytime-switch .link a').click(function() {
		var link = $(this);
		if($(link).parent().is('.day')) {
			// switch to night mode
			$('#daytime-switch').fadeOut('slow', function() {
				$('body').fadeOut('slow', function() {
					$('.switch-link').removeClass('current');
					$('.switch-link.night').addClass('current');
					daytime_mode = 'night';
					initFlash();
					$('link[title=layout]').attr('href', '/css/layout_night.css');
					$('#daytime-switch').fadeIn('fast');
					$('body').fadeIn('slow');
				});
			});
		} else {
           // switch to day mode	
			$('#daytime-switch').fadeOut('slow', function() {
				$('body').fadeOut('slow', function() {
					$('.switch-link').removeClass('current');
					$('.switch-link.day').addClass('current');
					daytime_mode = 'day';
					initFlash();
					$('link[title=layout]').attr('href', '/css/layout_day.css');
					$('#daytime-switch').fadeIn('fast');
					$('body').fadeIn('slow');
				});
			});
		}
		return false; 
	});

	*/
	
	// Simple Timeline Style Switcher
	/*

	if (thehour > 5 && thehour < 19){
		$('link[title=layout]').attr('href', 'http://www.hmwrk.fr/wp-content/themes/md/style.css');
	} else {
		$('link[title=layout]').attr('href', 'http://www.hmwrk.fr/wp-content/themes/md/style_dark.css');
	}
	
	*/

});

	
