function categoryTab(elemId,num,max) {
	$(elemId).className = 'tab_img'+num;
	for (var i=1;i<max+1;i++) {
		if (i==num) {
//			$(elemId+'_'+num).className = 'on';
			$(elemId+'_L'+i).className = 'block';
		}
		else {
//			$(elemId+'_'+num).className = 'off';
			$(elemId+'_L'+i).className = 'none';
		}
	}
}

// 2008-03-20 수정 //
function recentTab(elemId,num,max) {
	$(elemId + '_menu').className = 'tab_img'+num;
	for (var i=1;i<max+1;i++) {
		if (i==num) {
			document.getElementById(elemId+'_menu_'+num).className = 'on';
			document.getElementById(elemId+'_item_'+i).className = 'block';
		}
		else {
			document.getElementById(elemId+'_menu_'+num).className = 'off';
			document.getElementById(elemId+'_item_'+i).className = 'none';
		}
	}
}

var Main = {
	loadedSites: [],
	movedBanner1: false,
	setCagegoryPaging: function(country_cd,no,max) {
		if ( no > 0 && max > 0 ) {
			for (var i = 1; i <= max; i++) {
				if (no == i) {
					$('Categories_' + country_cd + '_' + i).style.display='block';
					$('Paging_' + country_cd + '_' + i).className='on';
				} else {
					$('Categories_' + country_cd + '_' + i).style.display='none';
					$('Paging_' + country_cd + '_' + i).className='';
				}
			}
		}
	},

	setMainBanner: function(no,max) {
		var thumb = $('event_thumb');
		for (var i=1; i <= max; i++) {
			var thumbnails = thumb.getElementsByTagName('A')[i-1].getElementsByTagName('IMG')[0];
			if ( i == no ) thumbnails.className = "main_thumbon";
			else thumbnails.className = "main_thumb";
		}
		$('event_mainbanner').className = 'event_mainbanner' + no;
		$('event_mainbanner').onclick = function() {
			/*
			if (no == 4) 	{
				Webtranslation('210011',thumb.getElementsByTagName('A')[no-1].href,false);
				return false;
			}
			else {
				location = thumb.getElementsByTagName('A')[no-1].href;
			}
			*/
			location = thumb.getElementsByTagName('A')[no-1].href;
		}
	},

	moveMainBanner: function(no) {
		if (no < 1 || no > 4) no = 1;
		if (!this.movedBanner1) {
			this.setMainBanner(no,4);
			no++;
		}
		setTimeout("Main.moveMainBanner(" + no + ")", 3000);
	},

	setFlag: function(elemID,country_cd) {
		$(elemID + '_flag').className = 'flag_' + country_cd;
		if (country_cd == 'jp') {
			$(elemID + '_list_jp').className = 'on';
			$(elemID + '_list_us').className = 'none';
			if (elemID == 'helper') {
				$('helper_link_jp').className = 'on';
				$('helper_link_us').className = 'none';
			}
		} else {
			$(elemID + '_list_jp').className = 'none';
			$(elemID + '_list_us').className = 'on';
			if (elemID == 'helper') {
				$('helper_link_jp').className = 'none';
				$('helper_link_us').className = 'on';
			}
		}
	},

	setRecentTab: function(no,max) {
		$('recent_btn').className = 'tab_img' + no;
		for (var i=1; i <= max; i++) {
			if (i == no) {
				$('recent_btn_' + no).className = 'on';
				$('recent_list_'+i).className = 'block';
			}
			else {
				$('recent_btn_' + no).className = 'off';
				$('recent_list_'+i).className = 'none';
			}
		}
	},

	setBestBrand: function(no,max,imgSrc,siteLink) {
		var large = $('bestbrand_large_img');
		for (var i = 1; i <= max; i++) {
			var thumb = $('bestbrand_thumb_' + i);
			var thumbSrc = thumb.src;
			if ( i == no ) {
				if (  thumbSrc.indexOf(no + '.gif') != -1  ) {
					thumb.src = thumbSrc.substring(0, thumbSrc.indexOf(no + '.gif', 0)) + (no + 'on.gif');
					large.href = siteLink;
					large.getElementsByTagName('IMG')[0].src = imgSvr + imgSrc;
				}
			}
			else {
				if (  thumbSrc.indexOf('on.gif') != -1  )
					thumb.src = thumbSrc.substring(0, thumbSrc.indexOf('on.gif', 0)) + '.gif';
			}
		}
	},

	setBestBrandSearch: function(no) {
		new Ajax.Updater({ success:'bestbrand_search_list' },'/common/ajax.main_brandlist.asp?c_id=' + no);
	},

	setCommunity: function(no,max,siteLink) {
		var large = $('community_img');
		for (var i = 1; i <= max; i++) {
			var thumb = $('community_num_' + i).getElementsByTagName('IMG')[0];
			var thumbSrc = thumb.src;
			if ( i == no ) {
				if (  thumbSrc.indexOf(no + '.gif') != -1  ) {
					thumb.src = thumbSrc.substring(0, thumbSrc.indexOf(no + '.gif', 0)) + (no + '_on.gif');
					large.onclick = function() {
						location = siteLink;
					};
					large.className = 'c_img' + no;
				}
			}
			else {
				if (  thumbSrc.indexOf('on.gif') != -1  )
					thumb.src = thumbSrc.substring(0, thumbSrc.indexOf('_on.gif', 0)) + '.gif';
			}
		}
	},

	setViewCategoryALL: function(site_cd) {
		if (this.loadedSites[site_cd]) {
			$('category_all_view_' + site_cd).show();
			return;
		}
		new Ajax.Updater({ success:'category_all_view_' + site_cd },'/common/ajax.main_categoryall.asp?site_cd=' + site_cd, {onComplete:function() {
			var posOffset = $('category_list').positionedOffset();
			$('category_all_view_' + site_cd).setStyle({left:posOffset[0] + 'px',top:posOffset[1] - 5 + 'px'});
			$('category_all_view_' + site_cd).show();
			Main.loadedSites[site_cd] = true;
		}});
	}
}
