$(document).ready(function(){

	$('.thumbs').parent().width(screen.width < 1280 ? 840 : 1050);

	if($('.top h2 a span').outerWidth() != 164){
		// google webfont didn't activated
		$('.top h2 a').css({'font-size': '47px'});
		$('.top h2 a span').css({'font-size': '33px'});
	}

	var spinner = new Image().src = '/i/spinner.gif';
			
	function showThumb(i) {

		var cnt = $('.thumbs li').length;
		var li = $($('.thumbs li')[i]);
		li.show().addClass('loading');
		
		var img = new Image();
		
		img.onload = function(){
			img.onload = null;
			li
			.removeClass('loading')
			.css({'background': 'url(/i/cat-thumbs/'+li.attr('id').substr(2)+'.jpg) no-repeat'})
			.hide()
			.fadeIn(300);
			
			if(i++ < cnt-1) setTimeout(function(){ new showThumb(i++); }, 10);
		}
		img.src = '/i/cat-thumbs/'+li.attr('id').substr(2)+'.jpg';

	}
	showThumb(0);
	
	var tooltip = $('#tooltip');
	
	$('*[title]').each(function(){
		$(this)
		.data('title', $(this).attr('title'))
		.removeAttr('title')				
		.mouseenter(function(){
			var o = $(this);
//			if(tooltip.data('over') == o.index) return;
			if(!$.browser.msie) tooltip.css({opacity: 0});
			tooltip.find('.text').html(o.data('title'))
			tooltip
			.data('over', o.index)
			.stop()
			.css({
				top: o.offset().top + o.outerHeight() + (o.outerWidth() == 200 ? -10 : 5),
				left: o.offset().left + o.outerWidth()/2 - tooltip.outerWidth()/2
			})
			.find('.t').css({left: tooltip.outerWidth()/2-11, top: '-17px'});
			if(!$.browser.msie) tooltip.animate({opacity: 1}, 200);
		})
		.mouseleave(function(){
//			if($(this).index != tooltip.data('over')){
				$.browser.msie ? tooltip.css({top: -9999}) : tooltip.stop().animate({opacity: 0}, 200);
//			}
		})
	})
	
	$('.content').css({'font-size': '1'+'1'+'p'+'x'});
	$('.content .summary').css({'font-size': '15px'});
	
});
