// main gallery
var galleryCount = 0;
var galleryArray;
var CurrGalleryCount = 0;
var galleryAutoToggle = true;

$j('#visual').ready(function(){
	
	$j('#gnbWrap .gnb').css('height','40px');
	$j('#gnbWrap .gnb .gnbList').css('height','40px');
	$j('#gnbWrap .gnb .gnbList li a.gnbItem').css('height','40px');
	$j('#mainGalleryBtn li').css('cursor','pointer');
	
	galleryCount = $j('#visual div.mainGallery').size();
	galleryArray = $j('#visual div.mainGallery').get();
	
	$j('#visual div.mainGallery').hide();
	$j(galleryArray[0]).show();
	$j('#visual').bind({
		mouseover : function(){
			galleryAutoToggle = false;	
		},
		focusin : function(){
			galleryAutoToggle = false;
		},
		mouseout : function(){
			galleryAutoToggle = true;	
		},
		focusout : function(){
			galleryAutoToggle = true;
		}
	}),
	$j('#mainGalleryBtn li').each(function(i){
		$j(this).bind({
			click : function(){
				galleryAutoToggle = false;
				viewGallery(i);
			},
			mouseout : function(){
				galleryAutoToggle = true;	
			},
			focusout : function(){
				galleryAutoToggle = true;
			}
		})
	});
});

window.getGalleryAnother = function(add){
	var cur = CurrGalleryCount + add;
	if (galleryAutoToggle) {
		if (cur >= galleryCount) cur = 0;
		if (cur < 0) cur = galleryCount-1;
		viewGallery(cur);
	}
}

window.viewGallery = function(sel){
	if ($j('#sitemap').css('display') == 'none'){
		if (sel != CurrGalleryCount){
			$j(galleryArray[CurrGalleryCount]).show().css('opacity', '1.0').animate({opacity: 0.0}, 1000).css('z-index', '-1');
			$j(galleryArray[sel]).show().css('opacity', '0.0').animate({opacity: 1.0}, 1000).css('z-index', '100');
		
			$j('#mainGalleryBtn li').removeClass("on");
			$j('#mainGalleryBtn li:eq('+ sel +')').addClass("on");
			
			//$j(galleryArray[CurrGalleryCount]).hide('slow');
			CurrGalleryCount = sel;
		}
	}
}

setInterval('getGalleryAnother(1)',6000);

//new npdateNotice List
var UpdateListCount = 0 ;
var UpdateListArray;
var CurrUpdateListCount = 0;
var UpdateListAutoToggle = true;
$j('#mainUpdateNoticeList').ready(function(){
	
	UpdateListCount = $j('#mainUpdateNoticeList ul li').size();
	UpdateListArray = $j('#mainUpdateNoticeList ul li').get();
	
	$j('#mainUpdateNoticeList ul li').hide();
	$j(UpdateListArray[0]).show();
	
	$j('#mainUpdateNoticeList .btn img').css({'cursor':'pointer'});
	
	$j('#mainUpdateNoticeList ul li').bind({
		mouseover : function(){
			UpdateListAutoToggle = false;	
		},
		focusin : function(){
			UpdateListAutoToggle = false;	
		},
		mouseout : function(){
			UpdateListAutoToggle = true;	
		},
		focusout : function(){
			UpdateListAutoToggle = true;	
		}
	});
	$j('#mainUpdateNoticeList .btn img').bind({
		mouseover : function(){
			UpdateListAutoToggle = false;	
		},
		focusin : function(){
			UpdateListAutoToggle = false;	
		},
		mouseout : function(){
			UpdateListAutoToggle = true;	
		},
		focusout : function(){
			UpdateListAutoToggle = true;
		}
	});
});
window.getUpdateListAnother = function(add){
	if (UpdateListAutoToggle) {
		var cur = CurrUpdateListCount + add;
		
		if (cur >= UpdateListCount) cur = 0;
		if (cur < 0) cur = UpdateListCount-1;
		
		$j('#mainUpdateNoticeList ul li').hide();
		$j(UpdateListArray[cur]).show();
		CurrUpdateListCount = cur;
	}
}
$j('#UNListPre').ready(function(){
	$j('#UNListPre').bind({
		click : function(){
			UpdateListAutoToggle = true;
			getUpdateListAnother(-1);
		}	
	})
});
$j('#UNListNext').ready(function(){
	$j('#UNListNext').bind({
		click : function(){
			UpdateListAutoToggle = true;
			getUpdateListAnother(1);
		}	
	})
});
setInterval('getUpdateListAnother(1)',7000);
