initBoardChooser = function(){
	var boards = $('#boardsBlocks>.board');
	var buttons = $('#boardsList>.button-1-active,#boardsList>.button-1');
	$(buttons).each(function(){
		$(this).click(function(){
			var rel = $(this).find('a').attr('rel');
			$('#'+rel).css({'zIndex': 10}).animate({'top':0}, 300, function(){
				$(boards).css({'zIndex': 1});
				$(boards).not('#'+rel).css({'top': '280px'});
			});
			$(buttons).not(this).attr({'className': 'button-1'});
			$(this).attr({'className': 'button-1-active'});
			return false;
		});
	});
}
initNewsList = function(){
	var naviL = $('#newsNavi>.l,#newsNavi>.l-unactive');
	var naviR = $('#newsNavi>.r,#newsNavi>.r-unactive');
	var news = $('#newsList>.news');
	var nCount = 0;
	$(naviL).click(function(){
		if( nCount > 0 ){
			$(news[nCount]).animate({'left':'203px'}, 300);
			nCount--;
		}
		if( nCount <= 0 ){
			$(naviL).attr({'className':'l-unactive'});
		}else{
			$(naviL).attr({'className':'l'});
		}
		if( nCount >= news.length-1 ){
			$(naviR).attr({'className':'r-unactive'});
		}else{
			$(naviR).attr({'className':'r'});
		}
	});
	$(naviR).click(function(){
		if( nCount < news.length-1 ){
			nCount++;
			$(news[nCount]).animate({'left':0}, 300);
		}
		if( nCount <= 0 ){
			$(naviL).attr({'className':'l-unactive'});
		}else{
			$(naviL).attr({'className':'l'});
		}
		if( nCount >= news.length-1 ){
			$(naviR).attr({'className':'r-unactive'});
		}else{
			$(naviR).attr({'className':'r'});
		}
	});
}
$(document).ready(function(){
	initBoardChooser();
	initNewsList();
	if( $.browser.msie && $.browser.version == 6 ){
		$('#pageContent .mainMenu ul li').hover(function(){
			$(this).addClass('hover');
		}, function(){
			$(this).removeClass('hover');
		});
		$('.button-1 .btn, .button-1-active .btn, .button-2 .btn, .button-2-active .btn').hover(function(){
			$(this).addClass('hover');
		}, function(){
			$(this).removeClass('hover');
		});
	}
})
