var timeZone = -new Date().getTimezoneOffset() / 60;
var bigDayBirthday = null;

$(function() {
	setSidebarLineHeight();
	startBirthdayCountdown();
});

function reloadImage(el, over) {
	// preloading implemented by CSS
	var imgNum = el.src.substr(el.src.lastIndexOf('_') + 1, 2);
	var imgIdRef = "#preload_head" + (over == 0 ? "" : "2") + "_" + imgNum;
	el.src = $(imgIdRef).attr('src');
}

function setSidebarLineHeight() {
	// this is fucking workaround... HATE IT... grrrrrr!!!!!!!!!!!!
	var contentInsideHeight = $('#content_inside').innerHeight();
	var sidebarHeight = $('#sidebar').innerHeight();
	var sidebarLine = $('#sidebar_line');
	var height = contentInsideHeight > sidebarHeight ? contentInsideHeight
			: sidebarHeight;
	sidebarLine.css('height', height + 72);
}

function startBirthdayCountdown() {
	if (bigDayBirthday == null) {
		return;
	}
	$('#countBirthday').countdown( {
		until : $.countdown.UTCDate(timeZone, bigDayBirthday),
		format : 'dHMS',
		expiryText : '<blink>Happy Birthday!</blink>',
		compact : true,
		alwaysExpire : true
	});
}
