$(function(){

	$(".button").hover(function(){
			$(this).addClass("btnHover");
		},function(){
			$(this).removeClass("btnHover");
	});

	$(".button_r").hover(function(){
			$(this).addClass("btnRHover");
		},function(){
			$(this).removeClass("btnRHover");
	});

	$('.folioInfo a').css({'opacity' : '0.4'});

	$('.folioInfo a').hover(function(){
		$(this).css({'opacity' : '1'});
	},function(){
		$(this).css({'opacity' : '0.4'});
	});

	$('.folioInfo a').mouseover(function(){

		var a = $(this).find('img').attr('alt');
		var t = a.split(' || ')[0];
		var d = a.split(' || ')[1];
		
		$('#info strong').text(t);
		$('#info span').text(d);
		$('#info').show();

		$('.folioInfo a').mousemove(function(e){
			var px = Math.round((e.pageX)) + 15;
			var py = Math.round((e.pageY)) - 10;
		
			$('#info').show().css({ 'top': py + 'px', 'left': px + 'px' });
		});
	});

	$('.folioInfo a').mouseout(function(){
		$('#info').hide();
	});
	
	$('.artof, .empty').click(function(){
		var w = $('body').width();
		var h = $('#common').height();

		$('#about').width(w).height(h).fadeIn(700, function(){
			var d = ( h - $('#about .text').outerHeight() ) / 2;
			$('#about .text').animate({ 'margin-top' : d },100)
		});
	});

	$('#about').click(function(){
		$(this).fadeOut();
	});
	
	$('#about .text').click(function(){
		return false;
	});
	
	$('.close').click(function(){
		$(this).parent().parent().fadeOut();
	});
	
	$('a.blank').click(function(){
		this.target = '_blank';
	});

	$('.zoomIn').click(function(){
		var w1 = $('body').width();
		var h1 = $('#common').height();
		var img = $(this).attr('href');
		
		$('body').prepend('<div id="zoomIn"><img src="' + img + '" alt="" title="Нажмите здесь, чтобы закрыть предпросмотр" /></div>');
		$('#zoomIn').width(w1).height(h1).fadeIn(400);
		$('#zoomIn img').load(function(){
			var h2 = $(this).height();
			
			if ( h1 > h2 ) {
				$('#zoomIn').height(h1);
			} else {
				$('#zoomIn').height(h2);
			}
				$(this).fadeIn(200);
		});

		return false;
	});
	
	$('#zoomIn img').live('click', function(){
		$('#zoomIn').fadeOut(200, function(){
			$('#zoomIn').remove();
		});
	});
});
