function setPng24(obj) {
	obj.width=obj.height=1;
	obj.className=obj.className.replace(/\bpng24\b/i,'');
	obj.style.filter =
	"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
	obj.src='about:blank;';
	return '';
}

function swf(w,h,Src,FlashVars,Title){
	var d = Math.round(Math.random()*100);
	html = '';
	html += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" id="swf_'+d+'" width="'+w+'" height="'+h+'" title="'+Title+'">';
	html += '<param name="allowScriptAccess" value="sameDomain" />';
	html += '<param name="allowFullScreen" value="false" />';
	html += '<param name="movie" value="'+Src+'" />';
	html += '<param name="quality" value="high" />';
	html += '<param name="FlashVars" value="xml_url='+FlashVars+'" />';
	html += '<embed src="'+Src+'" flashvars="xml_url='+FlashVars+'" quality="high" width="'+w+'" height="'+h+'" id="swf_'+d+'" name="swf_'+d+'" title="'+Title+'" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	html += '</object>';
	document.write(html);
}


function popWin(url,name,width,height,scrollbars) {
	popWindow=window.open(url,name,'scrollbars='+scrollbars+',width='+width+',height='+height);
	popWindow.focus();
}

// 상단 채널 Toggle
ChannelList = {}
ChannelList.toggleList = function() {
	if (this.listTitle.className == 'hide') {
		this.listTitle.className = "show"
		this.list.style.display = "block"
	} else {
		this.listTitle.className = "hide"
		this.list.style.display = "none"
	}
}
ChannelList.init = function() {
	this.list = document.getElementById('channelList')
	this.listTitle = this.list.parentNode.getElementsByTagName("a")[0]
	var self = this
	this.listTitle.onclick = function(e) {
		var evt = window.event || e
		evt.cancelBubble = true
		if (evt.stopPropagation) evt.stopPropagation();
		self.toggleList()
	}

	document.body.onclick = function() {
		self.listTitle.className = "hide"
		self.list.style.display = "none"
	}
}

// 좌측 프로그램 Toggle
ProgramList = {}
ProgramList.toggleSubList = function(index) {
	for(var i = 0, len = this.subListTitles.length; i < len ; i++){
		var subListTitle = this.subListTitles[i]
		var subList = this.subLists[i]
		if (i == index && subListTitle.className == 'hide')	{
			subListTitle.className = "show"
			subList.style.display = "block"
		} else {
			subListTitle.className = "hide"
			subList.style.display = "none"
		}
	}
}

ProgramList.init = function () {
	this.programList = document.getElementById('programList')
	this.subLists = this.programList.getElementsByTagName('ul')
	this.subListTitles = []

	for (var i = 0, len = this.subLists.length; i < len; i++) {
		var subList = this.subLists[i]
		var subListTitle = subList.parentNode.getElementsByTagName("a")[0]
		this.subListTitles.push(subListTitle)
		subListTitle.index = i
		var self = this
		subListTitle.onclick = function() {
			self.toggleSubList(this.index)
		}
	}
}

// 브랜드 채널 Mouse Effect
BrandList = {}
BrandList.effectOver = function(index) {
	for(var i = 0, len = this.brandTitles.length; i < len ; i++){
		var brandTitle = this.brandTitles[i]
		if(i == index){
			brandTitle.className = 'on'
		}
	}
}
BrandList.effectOut = function(index) {
	for(var i = 0, len = this.brandTitles.length; i < len ; i++){
		var brandTitle = this.brandTitles[i]
		if(i == index){
			brandTitle.className = ''
		}
	}
}
BrandList.init = function() {
	this.brandList = document.getElementById('brandList')
	this.brandListItem = this.brandList.getElementsByTagName('li')
	this.brandTitles = []
	for (var i = 0, len = this.brandListItem.length; i < len; i++) {
		var brandTitle = this.brandListItem[i]
		this.brandTitles.push(brandTitle)
		brandTitle.index = i
		var self = this
		brandTitle.onmouseover = function() {
			self.effectOver(this.index)
		}
		brandTitle.onmouseout = function() {
			self.effectOut(this.index)
		}
	}
}

// 공지사항 Mouse Effect
NoticeList = {}
NoticeList.effectOver = function(index) {
	for(var i = 1, len = this.noticeListRows.length; i < len ; i++){
		var noticeRow = this.noticeListRows[i]
		if(i == index){
			noticeRow.className = noticeRow.className == 'lastline'?'lastline on':'on'
		}
	}
}
NoticeList.effectOut = function(index) {
	for(var i = 1, len = this.noticeListRows.length; i < len ; i++){
		var noticeRow = this.noticeListRows[i]
		if(i == index){
			noticeRow.className = noticeRow.className == 'lastline on'?'lastline':''
		}
	}
}
NoticeList.init = function() {
	this.noticeList = document.getElementById('noticeList')
	this.noticeListItem = this.noticeList.getElementsByTagName('tr')
	this.noticeListRows = []
	for (var i = 0, len = this.noticeListItem.length; i < len; i++) {
		var noticeRow = this.noticeListItem[i]
		this.noticeListRows.push(noticeRow)
		noticeRow.index = i
		var self = this
		noticeRow.onmouseover = function() {
			self.effectOver(this.index)
		}
		noticeRow.onmouseout = function() {
			self.effectOut(this.index)
		}
	}
}


function toggleLayer(id) {
 try {
 var obj = document.getElementById(id);
 obj.style.display = (obj.style.display == "none") ? "block" : "none";
 } catch (e) {

 }
 return true;
}

//동영상카테고리
toggleCategory = function(aLink){
	var listsMore = document.getElementById('listonoff')

	if(listsMore.style.display != "none"){
		listsMore.style.display = "none";
		if(aLink) aLink.className = "ico_cate open";
	}else{
		listsMore.style.display = "";
		if(aLink) aLink.className = "ico_cate close";
	}
}

//인기채널
toggleChannel = function(aLink){
	var listsMore = document.getElementById('listonoff02')

	if(listsMore.style.display != "none"){
		listsMore.style.display = "none";
		if(aLink) aLink.className = "ico_cate open";
	}else{
		listsMore.style.display = "";
		if(aLink) aLink.className = "ico_cate close";
	}
}

// 썸네일
function onPreviewOver() {
	this.className = this.className.replace('thumbNormal', 'thumbSelect');
}
function onPreviewOut() {
	this.className = this.className.replace('thumbSelect', 'thumbNormal');
}
function onPreviewOver2() {
	this.className = this.className.concat(' slideOver');
}
function onPreviewOut2() {
	this.className = this.className.replace('slideOver', '');
}
function initPreview(thumbListArray) {
	for(var j = 0; j < thumbListArray.length; j++)
	{
		var wrap = document.getElementById(thumbListArray[j]);
		var thumbs = (function() {
			var collect = getElementsByClassName('thumbNormal', wrap);
			return collect.length > 0 ? collect : getElementsByClassName('slideItem', wrap)
		})();
		for (var i = 0; i < thumbs.length; i++)
		{
			thumbs[i].onmouseover = onPreviewOver;
			thumbs[i].onmouseout = onPreviewOut;
		}
	}
}
function walkTheDom(node, func) {
	func(node);
	node = node.firstChild;
	while(node) {
		walkTheDom(node, func);
		node = node.nextSibling;
	}
}
function getElementsByClassName(className, context) {
	var collection = [],
		reg = new RegExp(className, 'g');
	walkTheDom(context || document.body, function(node) {
		if(node.nodeType === 1) {
			if(node.className.match(reg)) {
				collection.push(node);
			}
		}
	});
	return collection;
}

/* IE6 SP1 이후 background 깜빡거림관련 */
try {
    document.execCommand("BackgroundImageCache", false, true);
} catch(ignored) {}

function showTab(obj){
	var objWrap = obj.parentNode.parentNode;
	var arrH4 = objWrap.getElementsByTagName('H4')
	var arrBQ = objWrap.getElementsByTagName('OL')

	for (var i = 0, len = arrH4.length; i < len; i++) {
		if (arrH4[i] == obj.parentNode) {
			arrH4[i].className = 'select'
			arrBQ[i].style.display = 'block'
		} else {
			arrH4[i].className = 'normal'
			arrBQ[i].style.display = 'none'
		}
	}
}

/* Slide */
function getDisplayList() {
	var objDiscovery = document.getElementById('vodlist')
	var arrDiv = objDiscovery.getElementsByTagName('li')
	var arrResult = []

	for (var i = 0, len = arrDiv.length; i < len; i++) {
		var objDiv = arrDiv[i]
		if (objDiv.className == 'fold' || objDiv.className == 'unfold') {
			arrResult.push(objDiv)
		}
	}

	return arrResult
}

function getTextLinkList() {
	var objDiscovery = document.getElementById('vodlist')
	var arrDiv = objDiscovery.getElementsByTagName('li')
	var arrResult = []

	for (var i = 0, len = arrDiv.length; i < len; i++) {
		var objDiv = arrDiv[i]
		if (objDiv.className == 'fold' || objDiv.className == 'unfold') {
			var objH4 = objDiv.getElementsByTagName('h4')[0]
			var objA = objH4.getElementsByTagName('a')[0]
			arrResult.push(objA)
		}
	}

	return arrResult
}
function openClose() {
	var arrDiv = this.list

	// 클릭한 display no 구하기
	var clickedDisplayDiv = this.parentNode.parentNode

	for (var i = 0, len = arrDiv.length; i < len; i++) {
		if (arrDiv[i] == clickedDisplayDiv)	{
			var clickedDisplayNo = i
			break
		}
	}

	var openDisplayNo = 0 //열릴 display no

	if (clickedDisplayDiv.className += 'fold ') {
		openDisplayNo = clickedDisplayNo
	} else {
		if (clickedDisplayNo == arrDiv.length - 1) {
			openDisplayNo = 0
		} else {
			openDisplayNo = clickedDisplayNo + 1
		}
	}

	//열고 닫는 처리
	for (var i = 0, len = arrDiv.length; i < len; i++) {
		var displayDiv = arrDiv[i]

		if (i == openDisplayNo) {
			displayDiv.className += ' unfold'
		} else {
			displayDiv.className += ' fold'
		}
	}
}
function initSlide() {
	var arrDisplayDiv = getDisplayList()

	// 타이틀 텍스트에 핸들러 추가
	var arrTextLink = getTextLinkList()
	for (var i = 0, len = arrTextLink.length; i < len; i++) {
		arrTextLink[i].list = arrDisplayDiv
		arrTextLink[i].onclick = openClose
	}
}

//베스트&10만 동영상
function toggleClassName(elm, clsName) {
	if(elm.className.match(clsName)) {
		elm.className = elm.className.replace(clsName, '');
	} else {
		elm.className = elm.className.concat(' ' + clsName);
	}
}

//메인 테마 슬라이드탭
/*function changeThemeTab() {
	var tab = document.getElementById('newThemeTab');
	var tabList = document.getElementById('newThemeList');
	var childs = getElementNodes(tab);
	var selected = {current:childs[1], prev:childs[0]};
	for(var i=0; i<childs.length; i++) {
		childs[i].onclick = (function(index) {
			return function() {
				if(childs[index] && childs[index] !== selected.current) {
					selected.current.className = selected.current.className.replace('selected', '');
					if(selected.prev)
						selected.prev.className = selected.prev.className.replace('selectPrev', '');

					childs[index].className = childs[index].className.concat(' selected');
					if(childs[index - 1])
						childs[index - 1].className = childs[index - 1].className.concat(' selectPrev');

					tabList.className = tabList.className.replace(/tab[0-9]+/, 'tab' + index);
					selected = {current:childs[index], prev:childs[index - 1]};
				}
			};
		})(i);
	}

	var tabArrow = ({
		tabHeight: 47,
		lastTabIndex: 4,
		timer: null,
		isRunning: false,
		init: function(style) {
			this.tabArrow = [document.getElementById('arrowTop'), document.getElementById('arrowBottom')];
			this.initTabPosition = parseInt(this.getCssProperty(tab, 'top'));
			this.topMoveSize = (style.tabCount - this.lastTabIndex) * this.tabHeight;
			this.bottomMoveSize = 0;
			for(var i=0; i<this.tabArrow.length; i++) {
				var _this = this;
				this.tabArrow[i].onclick = function() {
					if(!_this.isRunning) {
						_this.moveSlide(this);
					}
				}
			}
		},
		getCssProperty: function(obj, prop) {
			if(document.defaultView) {
				return this.removePx(document.defaultView.getComputedStyle(obj, null).getPropertyValue(prop));
			} else {
				return this.removePx(obj.currentStyle[prop]);
			}
		},
		removePx: function(obj) {
			var value = obj.replace(/(\d+)px/, function(c, r) {
				return r;
			});
			return value;
		},
		moveSlide: function(e) {
			var _this = this;
			var isTopArrow = e.className.match(/top/) ? true : false;
			var moveTabPosition = parseInt(_this.getCssProperty(tab, 'top'));
			if(isTopArrow) {
				if(_this.topMoveSize == Math.abs(_this.initTabPosition)) return;
				var top = moveTabPosition - 4;
				if(Math.abs(top) > _this.initTabPosition + _this.tabHeight) {
					tab.style.top = top + Math.abs(top) - (_this.initTabPosition + _this.tabHeight) + 'px'
					childs[_this.lastTabIndex].className = childs[_this.lastTabIndex].className.replace('last', '');
					childs[++_this.lastTabIndex].className = childs[_this.lastTabIndex].className.concat(' last');
					_this.initTabPosition += _this.tabHeight;
					_this.isRunning = false;
					window.clearTimeout(_this.timer);
				} else {
					tab.style.top = top + 'px';
					_this.isRunning = true;
					_this.timer = window.setTimeout(function(){_this.moveSlide(e);}, 1);
				}
			} else {
				if(_this.bottomMoveSize == Math.abs(_this.initTabPosition)) return;
				var top = moveTabPosition + 4;
				if(top > 0 || Math.abs(top) < Math.abs(_this.initTabPosition - _this.tabHeight)) {
					tab.style.top = top + (Math.abs(_this.initTabPosition - _this.tabHeight) - Math.abs(top));
					childs[_this.lastTabIndex].className = childs[_this.lastTabIndex].className.replace('last', '');
					childs[--_this.lastTabIndex].className = childs[_this.lastTabIndex].className.concat(' last');
					_this.initTabPosition -= _this.tabHeight;
					_this.isRunning = false;
					window.clearTimeout(_this.timer);
				} else {
					tab.style.top = top + 'px';
					_this.isRunning = true;
					_this.timer = window.setTimeout(function(){_this.moveSlide(e);}, 1);
				}
			}
		}
	}).init({tabCount:8});
}
function getElementNodes(elm) {
	var temp = elm.firstChild;
	var elms = [];
	while(temp) {
		if(temp.nodeType === 1) {
			elms.push(temp);
		}
		temp = temp.nextSibling;
	}
	return elms;
}*/