
	var sizeOfTopKeyword = 1;
	var currentTopKeyword = 1;//getRandomNum(1,4);

	function topKeywordPrev() {
		objHide('TOP_KEYWORD_'+currentTopKeyword);
		if(currentTopKeyword==1) currentTopKeyword = sizeOfTopKeyword;
		else currentTopKeyword = currentTopKeyword-1;
		objShow('TOP_KEYWORD_'+currentTopKeyword);		
	}
	
	function topKeywordNext() {
		objHide('TOP_KEYWORD_'+currentTopKeyword);
		if(currentTopKeyword==sizeOfTopKeyword) currentTopKeyword = 1;
		else currentTopKeyword = currentTopKeyword+1;
		objShow('TOP_KEYWORD_'+currentTopKeyword);		
	}	

	var sizeOfBestNews = 3;
	var currentBestNews = 1;
	var currentNewsNum = new Array();
	currentNewsNum.push(1);
	currentNewsNum.push(5);
	currentNewsNum.push(9);
	
	function bestNews(page) {
		objHide("LIST_BEST_NEWS_0");
		objHide("LIST_BEST_NEWS_1");
		objHide("LIST_BEST_NEWS_2");
		objShow("LIST_BEST_NEWS_"+(page-1));
	}
	
	
	function bestNewsPrev() {
		if(currentBestNews == 1) currentBestNews = sizeOfBestNews;
		else currentBestNews = currentBestNews-1;
		bestNews(currentBestNews)
	}
	
	function bestNewsNext() {
		if(currentBestNews == sizeOfBestNews) currentBestNews = 1;
		else currentBestNews = currentBestNews+1;
		bestNews(currentBestNews)
	}
	
	function newsTextOver(i,id,imageId) {
		var _currentNewsNum = currentNewsNum[0];
		
		if(i>8) _currentNewsNum = currentNewsNum[2];
		else if(i>4) _currentNewsNum = currentNewsNum[1];
		
	
		if(_currentNewsNum!=i) {
			clearNewsTimer();
			//objHide('NEWS_IMAGE_'+currentNewsNum);
			getObj('NEWS_TEXT_'+_currentNewsNum).className = '';
			getObj('NEWS_TEXT_TAB_'+_currentNewsNum).src = getObj('NEWS_TEXT_TAB_'+_currentNewsNum).src.replace("on.gif", "off.gif");
			
			
			var imageNum = 0;
			if(i>8) imageNum = 2;
			else if(i>4) imageNum = 1;
			
			var url = "/v3/content/ShowThumbImage.do?id="+imageId+"&contentId="+id+"&width=120&height=100";
			getObj('NEWS_IMAGE_'+imageNum).style.background = "url('"+url+"') no-repeat center";
			getObj('NEWS_IMAGE_'+imageNum).innerHTML = '<a href="/v3/View.do?dispatch=view&id='+id+'&returnURL=%2Fv3%2FNews.do"></a>'
			
			
		//	if(true) return;
		
			if(i>8) currentNewsNum[2] = i;
			else if(i>4) currentNewsNum[1] = i;
			else currentNewsNum[0] = i;
			
			//objShow('NEWS_IMAGE_'+currentNewsNum);
			getObj('NEWS_TEXT_'+i).className = 'current';
			getObj('NEWS_TEXT_TAB_'+i).src = getObj('NEWS_TEXT_TAB_'+i).src.replace("off.gif", "on.gif");
		}
	}
	
	function setNewsTimer() {
		timerOfNews = setInterval(bestNewsNext,20*1000);
	}
	
	function clearNewsTimer() {
		clearInterval(timerOfNews);
	}
	
	var sizeOfItemToday = 2;
	var currentItemToday = 1;
	
	function itemTodayPrev() {
		if(currentItemToday == 1) currentItemToday = sizeOfItemToday;
		else currentItemToday = currentItemToday-1;
		if(currentItemToday==1) {
			objHide('ITEM_OF_TODAY_3');
			objHide('ITEM_OF_TODAY_4');
			objShow('ITEM_OF_TODAY_1');
			objShow('ITEM_OF_TODAY_2');
		} else {
			objHide('ITEM_OF_TODAY_1');
			objHide('ITEM_OF_TODAY_2');
			objShow('ITEM_OF_TODAY_3');
			objShow('ITEM_OF_TODAY_4');
		}
	}
	
	function itemTodayNext() {
		if(currentItemToday == sizeOfItemToday) currentItemToday = 1;
		else currentItemToday = currentItemToday+1;
		if(currentItemToday==1) {
			objHide('ITEM_OF_TODAY_3');
			objHide('ITEM_OF_TODAY_4');
			objShow('ITEM_OF_TODAY_1');
			objShow('ITEM_OF_TODAY_2');
		} else {
			objHide('ITEM_OF_TODAY_1');
			objHide('ITEM_OF_TODAY_2');
			objShow('ITEM_OF_TODAY_3');
			objShow('ITEM_OF_TODAY_4');
		}
	}
	
	
	
	var itemTodayList;
	var sizeOfHotSpot = 2;
	var currentHotSpot = 1;
	
	function hotSpotPrev() {
		objHide("HOT_SPOT_"+currentHotSpot);
		if(currentHotSpot == 1) currentHotSpot = sizeOfHotSpot;
		else currentHotSpot = currentHotSpot-1;
		objShow("HOT_SPOT_"+currentHotSpot);
	}
	
	function hotSpotNext() {
		objHide("HOT_SPOT_"+currentHotSpot);
		if(currentHotSpot == sizeOfHotSpot) currentHotSpot = 1;
		else currentHotSpot = currentHotSpot+1;
		objShow("HOT_SPOT_"+currentHotSpot);
	}
	

	var currentEventBanner = 1;
	
	function eventBannerPrev() {
		objHide('EVENT_BANNER_'+currentEventBanner);
		if(currentEventBanner==1) currentEventBanner = sizeOfEventBanner;
		else currentEventBanner = currentEventBanner-1;
		objShow('EVENT_BANNER_'+currentEventBanner);
	}
	
	function eventBannerNext() {
		objHide('EVENT_BANNER_'+currentEventBanner);
		if(currentEventBanner==sizeOfEventBanner) currentEventBanner = 1;
		else currentEventBanner = currentEventBanner+1;
		objShow('EVENT_BANNER_'+currentEventBanner);
	}
	
	var currentQuickLink = 0;
	function quick_link(id) {
		if(currentQuickLink == id) {
			currentQuickLink = 0;
			objHide('selector'+id);
		} else {
			objHide('selector1');
			objHide('selector2');
			objHide('selector3');
			objShow('selector'+id);
			currentQuickLink = id;
		}
	}
	
	
	var channelns;
	var current_channeln = 0;
	
	function channelN() {
		var url = "/v3/xml/main_channeln_xml.jsp";
		var message = "Ã¤³ÎNÀ» °¡Á®¿Ã ¼ö ¾ø½À´Ï´Ù.";
		
		var myAjax = new Ajax.Request(url,
			{
				method:'get',
				onComplete: function(transport){
					var response = transport.responseText  || "no response text";
					var obj = JINDO.xml2obj(response);
					var content = obj.content;
					
					if(typeof content.length == "number") {
						channelns = content;
						var num = getRandomNum(1,channelns.length);
						current_channeln = num-1;
						current_channeln = 0;
						//objShow("CHANNELN_BUTTON");
					} else {
						channelns = new Array();
						channelns.push(content);
					}
					setChannelN(current_channeln);
				},
				onFailure: function(){ 
					alert(message);
					return false;
				},
				encoding: 'euc-kr',
				contentType: 'application/x-www-form-urlencoded'
			}
		);
	}
	
	function setChannelN(n) {
		var movieWidth = 217;
		var movieHeight = 167;
		var textLen = 50;
	
		var content = channelns[n];
		var movie = content.movie;
		var title = content.titleKor;
					
		if(title.length>textLen) title = title.substring(0,textLen)+".."
		getObj('CHANNELN_TEXT').innerHTML = '<a href="/v3/ChannelN.do?dispatch=view&id='+content.id+'">'+title+'</a>';
		
		moviePlayer('CHANNELN_MOVIE','CHANNELN_MOVIE_TEXT',movie.url,movieWidth,movieHeight,movie.thumb_id);
		/*
		if(useFlash) {
			moviePlayer('CHANNELN_MOVIE','CHANNELN_MOVIE_TEXT',movie.url,movieWidth,movieHeight,movie.thumb_id,'none',false,50);
		}else {
			var html = ""
			html = "<div style=\"position:relative;\">"
			html += "<a href=\""+movie.url+"\">";
			html += "<img src=\"http://www.noblesse.com/v3/ShowEmbedThumb.do?id="+movie.thumb_id+"&width=217\">";
			html += "<div style=\"position: absolute;left:180px;top:125px;width:70px;height:70px;\"><img  class=\"png24\" src=\"http://www.noblesse.com/v3/img/btn/btn_play1234.png\"></div>";
			html += "</a>";
			html += "</div>";
			getObj('CHANNELN_MOVIE').innerHTML = html;
		}
		*/
	}
	
	function nextChannelN() {
		if( (current_channeln+1) == channelns.length) current_channeln = 0;
		else current_channeln++;
		
		setChannelN(current_channeln);
	}
	
	function prevChannelN() {
		if( current_channeln==0) current_channeln = channelns.length-1;
		else current_channeln--;
		
		setChannelN(current_channeln);
	}
	
	
	

	var timerOfNews;
	function init() {
		//openNoticeLayer('main_ad_middle_layer');
		objShow('TOP_KEYWORD_'+currentTopKeyword);
		setNewsTimer();
		channelN();
		
		editorspickNext();
		if(sizeOfTopKeyword==1) {
			objHide('BTTN_TOP_KEYWORD');
		}
		
		if(getRandomNum(0,1)==0) hotSpotNext();
		if(getRandomNum(0,1)==0) itemTodayNext();	
		
		init2();
	}
	
	function addbookmark(){
		var bookmarkurl="http://www.noblesse.com"; 
		var bookmarktitle="Noblesse";
	 
		if (document.all) window.external.AddFavorite(bookmarkurl,bookmarktitle); 
	} 	
	
	
	
	var timerOfBanners;
	var currentBanner = 0;
	var main_banners;
	
	function mainBanner() {
		if(useFlash) flash('MAIN_BANNER','/v3/tiles/main/banner.swf',679,185,'transparent',null);
		else banner();
	}


	function banner() {
		var html = '<a href="" id="M_BANNER_LINK"><img id="M_BANNER_IMAGE" src="" border=0/></a>'+
				'<div style="position: absolute; left:0px; top:0px;width: 27px; height: 185px; z-index: 10000" id="M_BANNER_LEFT_BTTN"><a href="javascript:bannerPrev(0);"><img border="0" src="http://www.noblesse.com/v3/img/btn/btn_arrow_left16.png" width="27" height="185"></a></div>'+
				'<div style="position: absolute; left:652px;top:0px; width: 27px; height: 185px; z-index: 10000" id="M_BANNER_RIGHT_BTTN"><a href="javascript:bannerNext(0);"><img border="0" src="http://www.noblesse.com/v3/img/btn/btn_arrow_right16.png" width="27" height="185"></a></div>';
		
		document.write(html);
		
		var url = "/v3/xml/banner_xml.jsp";
		var message = "¹è³Ê ¸ñ·ÏÀ» °¡Á®¿Ã ¼ö ¾ø½À´Ï´Ù.";

		var myAjax = new Ajax.Request(url,
			{
				method:'get',
				onComplete: function(transport){
					var response = transport.responseText  || "no response text";
					var obj = JINDO.xml2obj(response);
					
					var content = obj.banner;
					
					if(typeof content.length == "number") {
						main_banners = content;
					} else {
						main_banners = new Array();
						main_banners.push(obj.banner);
						objHide("M_BANNER_LEFT_BTTN");
						objHide("M_BANNER_RIGHT_BTTN");
					}
					bannerSet(0);
					setBannersTimer();
				},
				onFailure: function(){ 
					alert(message);
					return false;
				},
				encoding: 'euc-kr',
				contentType: 'application/x-www-form-urlencoded'
			}
		);
	}
	
	function bannerRoll() {
		bannerNext(1);
	}
	
	function bannerPrev(i) {
		if(currentBanner==0) currentBanner = main_banners.length-1;
		else currentBanner--;
		bannerSet(currentBanner);
		if(i==0) clearBannersTimer();
	}
	
	function bannerNext(i) {
		if(currentBanner==(main_banners.length-1)) currentBanner = 0;
		else currentBanner++;
		bannerSet(currentBanner);
		if(i==0) clearBannersTimer();
	}
	
	function bannerSet(n) {
		getObj('M_BANNER_IMAGE').src = main_banners[n].image;
		getObj('M_BANNER_LINK').href = main_banners[n].url;
	}
	
	function setBannersTimer() {
		timerOfBanners = setInterval(bannerRoll,5*1000);
	}
	
	function clearBannersTimer() {
		clearInterval(timerOfBanners);
	}		

	function autoBlur(){
	  if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG")
	  document.body.focus();
	}
	document.onfocusin=autoBlur;
	 
	function editorspickPrev() {
		objHide('EDITORS_PICK_'+currentEditorsPick);

		if(currentEditorsPick==0) currentEditorsPick=sizeOfEditorsPick-1;
		else currentEditorsPick = currentEditorsPick-1;
		
		objShow('EDITORS_PICK_'+currentEditorsPick);
		
	}
	
	function editorspickNext() {
		objHide('EDITORS_PICK_'+currentEditorsPick);

		if(currentEditorsPick==(sizeOfEditorsPick-1)) currentEditorsPick=0;
		else currentEditorsPick = currentEditorsPick+1;
		
		objShow('EDITORS_PICK_'+currentEditorsPick);
	}
	
	function styleListPrev() {
		objHide('STYLE_LIST_'+currentStyleList);

		if(currentStyleList==0) currentStyleList=sizeOfStyleList-1;
		else currentStyleList = currentStyleList-1;
		
		objShow('STYLE_LIST_'+currentStyleList);
		
	}
	
	function styleListNext() {
		objHide('STYLE_LIST_'+currentStyleList);

		if(currentStyleList==(sizeOfStyleList-1)) currentStyleList=0;
		else currentStyleList = currentStyleList+1;
		
		objShow('STYLE_LIST_'+currentStyleList);
	}	 
