var nowPageNo = 0;
var pageInBlogs = [[1,2,3,4,5,6],[7,8,9,10]];
var b_slideMax = 0;
var b_target = '#blog_news_list';
var b_moveFlg = true;
var b_moveSpeed = 'fast';
var b_rooloutID;
var b_intervalID;
var b_loopTime = 5000;

$(document).ready(function(){
	var odd_even = '';
	var i = 0;
	
	$("ul#blog_news_list > li").each(function(){
		$(this).mouseover(function(){
			$(this).addClass('over');
		});
		$(this).mouseout(function(){
			$(this).removeClass('over');
		});
		
		if(i % 2 == 0){
			odd_even = 'even';
		}
		else {
			odd_even = 'odd';
		}
		
		$(this).addClass(odd_even);
		$(this).removeAttr('style');
		
		i++;
	});
	
	b_target = $(b_target);
	b_target.find('li').css('display','none');
	b_target.find('li:nth-child(1),li:nth-child(2),li:nth-child(3),li:nth-child(4),li:nth-child(5),li:nth-child(6)').css('display','block');
	
	$('#secBlog .prev').click(function(){
		if(nowPageNo != 0){
			blogListPageChg(nowPageNo-1);
		}
	});
	$('#secBlog .next').click(function(){
		if(nowPageNo != pageInBlogs.length-1){
			blogListPageChg(nowPageNo+1);
		}
	});
	
	$('#secBlog .blogpage').click(function(){
		var no = $('img',this).attr('alt');
		if(nowPageNo != no){
			blogListPageChg(no);
		}
	});
	
	b_slideMax = pageInBlogs.length;
	
	/*loopBlogPages();
	
	//rollout
	$(b_target).hover(function(){
		clearTimeout(b_intervalID);
		clearTimeout(b_rooloutID);
	},function(){
		b_rooloutID = setTimeout(function(){
			loopBlogPages();
		},3000);
	});*/
});

function blogListPageChg(tarPageNo){
	for(var i=0,len =pageInBlogs[nowPageNo].length; i<len; i++){
		b_target.find('li:nth-child('+pageInBlogs[nowPageNo][i]+')').css('display','none');
	}
	nowPageNo = tarPageNo;
	for(var i=0,len =pageInBlogs[tarPageNo].length; i<len; i++){
		b_target.find('li:nth-child('+pageInBlogs[tarPageNo][i]+')').css('display','block');
	}
}

function loopBlogPages(){
	b_intervalID = setTimeout(function(){
		var tarPageNo = nowPageNo + 1;
		if(tarPageNo >= pageInBlogs.length ){
			tarPageNo = 0;
		}
		blogListPageChg(tarPageNo);
		loopBlogPages();
	},b_loopTime);
}

