jQuery(document).ready(function () {

	jQuery('#_login_button').hover(function () {
		jQuery(this).attr('src', '/_template/images/layout/login_button_over.png');
	}, function () {
		jQuery(this).attr('src', '/_template/images/layout/login_button.png');
	});
	
	countdown();
});

function countdown() {
	//target date, todays date...
	
	jQuery.ajax({
		success: loadCountdown
		, url: '/_ajax/getCountDownDate.php'
		, dataType: 'text'
	});
	
	function loadCountdown(data) {
		var _target_date = new Date(data);
		var _date        = new Date();
		
		if (_date < _target_date) {
			
			//work out diff in seconds
			var difference = Math.round( ((_target_date - _date) / 1000) );
			
			//number of days...
			var days = Math.floor(difference / 86400);
			
			//remaining seconds, number of hours
			difference = (difference % 86400);
			var hours = Math.floor(difference / 3600);
			
			//remaining seconds, number of minutes...
			difference = (difference % 3600);
			var minutes	= Math.floor(difference / 60);
			
			//pad the numbers with 0
			if (    days.toString().length < 2 )    days = '0' +    days.toString();
			if (   hours.toString().length < 2 )   hours = '0' +   hours.toString();
			if ( minutes.toString().length < 2 ) minutes = '0' + minutes.toString();
			
			//display...
			jQuery('#countdown ._dd span').text(days);
			jQuery('#countdown ._mm span').text(hours);
			jQuery('#countdown ._yy span').text(minutes);
			
			//loop every thirty seconds, more accurate than 60 seconds..
			setTimeout(countdown, 30000);
			
		} else {
			jQuery('#countdown ._dd span').text('00');
			jQuery('#countdown ._mm span').text('00');
			jQuery('#countdown ._yy span').text('00');
		}
	}
}

function showMessage(type, title, message) {

	jQuery('#message').removeClass().addClass('message_' + type);
	jQuery('#message').children('h1').text(title);
	jQuery('#message').children('p').html(message);
	
	jQuery('#message').css('display', 'none');
	jQuery('#message').css('bottom', '0');
	
	jQuery('#message').slideDown(100);
}


