function updateFooter() {
	height = $(window).height();
	if(height>825) $('#footer').css("height", (height-715)+'px');
}

function checkThumbnailHover() {
	var hover = $('.thumbnail.hover');
	var image = hover.find('img:visible').hide();
	var nextImage = image.next();
	if(nextImage.length == 0) nextImage = hover.find('img:eq(0)');
	nextImage.show();
}

$(document).ready(function() {
	// adjust menu width
	$('#menu>ul>li>ul:eq(0)').css({width: '130px'});
	$('#menu>ul>li>ul:eq(1)').css({width: '230px'});

	// add hover effect for IE6
	$('#menu>ul>li').hover(function() {$(this).addClass('hover');}, function() {$(this).removeClass('hover');});

	// adjust footer to page height
	updateFooter();
	setInterval('updateFooter()', 100);

	// youtube video thumbnail animation and fancybox initialization
	if($('div.video').length) {
		$('div.thumbnail').hover(function() {
			$(this).addClass('hover');
		},
		function() {
			$(this).removeClass('hover');
		});
		$('div.thumbnail img:not(:first-child)').hide();
		$('div.video a').fancybox({width: 600, height: 480, padding: 10, 'type': 'swf', 'swf': {'allowfullscreen': 'true'}, overlayColor: '#000', outerStyles: {background: 'none repeat scroll 0 0 #fee6c2', '-moz-box-shadow': '#000 1px 1px 5px 1px', '-webkit-box-shadow': '#000 1px 1px 5px 1px'}, hideOnOverlayClick: false});
		setInterval('checkThumbnailHover()', 1000);
	}

	if($('a.click-enlarge').length) {
		$('a.click-enlarge').fancybox({padding: 10, overlayColor: '#000', titleShow: false, outerStyles: {'-moz-box-shadow': '#000 1px 1px 5px 1px', '-webkit-box-shadow': '#000 1px 1px 5px 1px'}});
	}
});
