$(function() {
	var tw = (Math.floor(($("#header").width()-20)/186)) * 186;
	$("#contentsContainer").width(tw);
	$(window).resize(function(){
		var w = (Math.floor(($("#header").width()-20)/186)) * 186;
		if(tw != w) {
			tw = w;
			$('#contentsBlock').width(tw);
			$("#contentsContainer").stop().animate({width: tw}, 600, 'swing')
		}
	})

	$('#contentsBlock').masonry({
		itemSelector: '.box,.box_w',
		 animate: true
	});

	/*$('#contentsBlock dt').not('#navi img').hover(
		
		function () {
			$(this).css('opacity', 0.7);
		},
		function () {
			$(this).css('opacity', 1);
		}
	);*/

	$('.box, .box_w').not('#navi,#news, #blog').each( function(){
		if($('a', this).size() > 0) {
			$(this).hover(
				function () {
					$(this).addClass('hover');
					$('img, object', this).css('opacity', 0.7);
				},
				function () {
					$(this).removeClass('hover');
					$('img, object', this).css('opacity', 1);
				}
			).click(function(){
				location.href = $('a', this).attr("href");
			}).css("cursor", "pointer");
			$('a', this).click( function(e){
				e.preventDefault();
			});
		}
	});
});

