/*
################################################################################
write by : 마약
date : 2011.03
e-mail : youngjoo0902@naver.com
################################################################################
*/

/*  디폴트 js 시작 */

//도큐먼트
var d = document;
//아이디반환
var _id = function(element){return d.getElementById(element);}
//태그반환
var _tag = function(element,passTag){if(arguments.length == 1){return d.getElementsByTagName(arguments[0]);}else{if(typeof element == "string"){return _id(element).getElementsByTagName(passTag);}else{return element.getElementsByTagName(passTag);}}}
//css정보 반환
var _css = function(element,prop){var el,read_css;el = element;if(!d.defaultView){read_css = el.currentStyle[prop];}else{read_css = d.defaultView.getComputedStyle(el,null).getPropertyValue(prop);}return read_css;}
//윈도우 온로드
var _start = function(func){var pageStart = window.onload;if(typeof window.onload != "function"){window.onload = func;}else{window.onload = function(){func();}}}
//인덱스반환
var _isIndex = function(a,b){var prnt = b;var child = prnt.childNodes;for(var i = 0; i < child.length; i++){if(a === child[i]){return i;}else{continue;}}}
//익스체크
var msie = (navigator.appName == "Microsoft Internet Explorer");
var ver = navigator.appVersion.split("; ")[1];
//xp이하
var mode_xp = (navigator.userAgent.match(/Windows NT 5.1/) == "Windows NT 5.1");
//윈7
var mode_win7 = (navigator.userAgent.match(/Windows NT 6.1/) == "Windows NT 6.1");
//ie8
var ie8 = ver == "MSIE 8.0";
//ie7
var ie7 = ver == "MSIE 7.0";
//ie6
var ie6 = ver == "MSIE 6.0";

/*  디폴트 js 끝 */


//dom로드
$(d).ready(function(){

			if(mode_xp && msie){
				if(!ie8){
					$(".input01").css("margin-top","-1px");
					//$(".input02").css("margin-top","-1px");
				}
			}

			//gnb 오버아웃
			$("#header .gnb a").hover(function(){$("#header .gnb a").each(function(){$("#header .gnb li").removeClass();});$(this).parent().addClass("on");});

			//즐감 서브메뉴 오버시 2뎁스 온,오프
			$("#kin_submenu > li > ul").each(function(index){
				$("#kin_submenu > li > ul:eq("+ index +")").addClass("kin_2depth_" + (index + 1));
			});

			//즐감 서브메뉴 2뎁스 마우스 올릴경우 이미지 온,오프
			$("#kin_submenu > li > ul > li > a").mouseover(function(){
				var ul = this.parentNode.parentNode;
				var imgs = _tag(ul,"img");
				for(var i = 0; i < imgs.length; i++){
					imgs[i].src = imgs[i].src.replace("_on.gif",".gif");
				}
				_tag(this,"img")[0].src = _tag(this,"img")[0].src.replace(".gif","_on.gif");
				this.onmouseout = function(){
					_tag(this,"img")[0].src = _tag(this,"img")[0].src.replace("_on.gif",".gif");
				}
			});

			//통합검색란 포커스인,아웃시 벨류 삽입제거
			var totalSearchDefaultValue = $("#allsearch input:eq(0)").attr("value");//통합검색 기본벨류를 전역으로 갖고 있다.
			$("#allsearch input:eq(0)").focus(function(){
					var defaultValue = $(this).attr("value");
					if(defaultValue == totalSearchDefaultValue){
						$(this).attr("value","");
					}
					$(this).blur(function(){
						if(this.value == "" || this.value == "undefined" || this.value == null){
							this.value = totalSearchDefaultValue;
						}
					});
			});

			//패밀리사이트
			$("#familySite").click(function(){
				$("#familySite").parent().next().toggleClass("on").click(
					function(){
						$("#familySite").parent().next().removeClass();
					});
				return false;
			});

			//별점선택
			$("#pointChoice").click(function(){$(this).text("별점선택");$(this).removeClass();$("#points_list").toggleClass("on");return false;});
			$("#points_list li a").click(function(){var childs = this.innerHTML;_id("pointChoice").className = "on";_id("pointChoice").innerHTML = childs;$("#points_list").removeClass();return false;});
			//$("#points_list li a").click(function(){var span = _tag(this,"span")[0].cloneNode(true);_id("pointChoice").className = "on";_id("pointChoice").innerHTML = "";_id("pointChoice").appendChild(span);$("#points_list").removeClass();return false;});//백업본

			//표정선택
			$("#figureChoice").click(function(){var defaultText = this.cloneNode(true);$(this).text(defaultText);$(this).removeClass();$("#figure_list").toggleClass("on");return false;});
			$("#figure_list li a").click(function(){var childs = this.innerHTML;_id("figureChoice").className = "on";_id("figureChoice").innerHTML = childs;$("#figure_list").removeClass();return false;});

			//즐감차트 롤링
			//zlgamChartSlide.action("zlgamChartSlide");

			//addGnbZlgam();


});


function addGnbZlgam(){
	var gnbZlgam = _tag(_id("globalNav"),"a")[0];
	gnbZlgam.style.position = "relative";
	var newDeco = d.createElement("img");//스판으로 바꿔서 css로 분리
	gnbZlgam.appendChild(newDeco);
	newDeco.src = "/images/layout/bg_gnb_deco1.gif";
	newDeco.style.position = "absolute";
	newDeco.style.top = 0 + "px";
	newDeco.style.right = 10 + "px";
}

//온로드전용시작

_start(goTop);

//온로드전용끝
$(function(){
	$(document.body).bind("click", function(e){
		$("#head_sch_list, #allsearch > h2").removeClass("on");
	});
});


function imgPreview(a,t,b){
	var myImg = _tag(a,"img")[0];
	var targetImg = _tag(_id(t),"img")[0];
	targetImg.src = b;
}

function goTop(){
	if(d.body.scrollHeight >= 2000){
		if(_id("contentsArea")){
			$("<p style=\"text-align:right; margin-top:30px;\"><a href=\"#\"><img src=\"/images/btn/gotop2.gif\" alt=\"top\"></a></p>").appendTo("#contentsArea");
		}else if(_id("searchContents")){
			$("<p style=\"text-align:right; margin-top:30px;\"><a href=\"#\"><img src=\"/images/btn/gotop2.gif\" alt=\"top\"></a></p>").appendTo("#searchContents");
		}else{
			$("<p style=\"text-align:right; margin-top:10px;\"><a href=\"#\"><img src=\"/images/btn/gotop2.gif\" alt=\"top\"></a></p>").appendTo("#wrapper div:eq(0)");
		}
	}
}

//gnb에 마우스 올릴경우
function gnbOver(elem,idx){
	var ul = _id(elem);

	if(idx > 5){
		return false;
	}
	var ul = _id(elem);
	var lists = _tag(ul,"li");
	for(var i = 0; i < lists.length; i++){
		lists[i].onmouseover = function(){
			this.className = "on";
			if(this != lists[idx] && idx != -1){
				lists[idx].className = "";
			}
		},
		lists[i].onmouseout = function(){
			this.className = "";
			if(idx != -1){
				lists[idx].className = "on";
			}
		}
	}
	if(idx != -1){
		lists[idx].className = "on";
	}
}

//즐감 최신영화 리스트에서 현재 클릭한 버튼을 기준으로 레이어 생성
//function fixLayer(layer,x,y){var obj = _id(layer); obj.style.left = x + "px"; obj.style.top = y + 25 + "px"; obj.style.display = "block";}
function fixLayer(layer,address,arg){
	var obj = _id(layer);
	var addTop;
	if(arguments.length == 3){
		addTop = arguments[2];
	}else{
		addTop = 250;
	}
	obj.style.top = d.documentElement.scrollTop + addTop + "px";
	obj.style.display = "block";
	_tag(obj,"iframe")[0].src = address;
}

//레이어 두번째
function fixLayer2(layer,x,y,address,rev){
	var obj = _id(layer);
	obj.style.display = "block";
	_tag(obj,"iframe")[0].src = address;
	obj.style.left = x + "px";
	if(arguments.length < 5){
		obj.style.top = y + "px";
	}else{
		obj.style.top = y -_tag(obj,"iframe")[0].contentWindow.d.body.scrollHeight - 20 + "px";
	}
}

function fixLayer3(layer,address,arg){
	var obj = _id(layer);
	var addTop;
	if(arguments.length == 3){
		addTop = arguments[2];
	}else{
		addTop = 250;
	}
	obj.style.top = d.documentElement.scrollTop + addTop + "px";
	obj.style.display = "block";
	_tag(obj,"iframe")[0].src = address;
	obj.style.marginLeft = -parseInt(_css(obj,"width")) / 2 + "px";
}

function fixLayer4(layer,x,y,address,rev){
	var obj = _id(layer);
	obj.style.display = "block";
	_tag(obj,"iframe")[0].src = address;
	obj.style.left = x;
	if(arguments.length < 5){
		obj.style.top = y + "px";
	}else{
		obj.style.top = y -_tag(obj,"iframe")[0].contentWindow.d.body.scrollHeight - 20 + "px";
	}
}

//토글 디스플레이
function toggle(elem){var obj = _id(elem); if(_css(obj,"display") == "none"){obj.style.display = "block";}else{obj.style.display = "none";}}

//통합검색 드롭다운 디스플레이
function search_select(e, tg,el){
	$("#head_sch_list").toggleClass("on");
	tg.parentNode.className == "on" ? tg.parentNode.className = "" : tg.parentNode.className = "on";
	tg.firstChild.nodeValue = "통합검색";
	var searchBox = _id(el);
	var anchor = _tag(searchBox,"a");
	for(var i = 0; i < anchor.length; i++){
		$(anchor[i]).click(function(){
			_id("tarGet").firstChild.nodeValue = this.firstChild.nodeValue;
			$("#head_sch_list").removeClass();
			$("#allsearch > h2").removeClass();
			return false; //  ㅠㅠㅋ
		});
		anchor[i].onmouseover = function(){
			_id("tarGet").firstChild.nodeValue = this.firstChild.nodeValue;
		}
	}

	var e = e || window.event;
	if (e.stopPropagation) e.stopPropagation();
	else window.event.cancelBubble = true;
}



function search_select_total(tg,el){$("#totalSearchList").toggleClass("on");tg.parentNode.className == "on" ? tg.parentNode.className = "" : tg.parentNode.className = "on";tg.firstChild.nodeValue = "통합검색";var searchBox = _id(el);var anchor = _tag(searchBox,"a");for(var i = 0; i < anchor.length; i++){anchor[i].onclick = function(){_id("searchTarget").firstChild.nodeValue = this.firstChild.nodeValue;$("#totalSearchList").removeClass();$("#totalSearchBox > h2").removeClass();},anchor[i].onmouseover = function(){_id("searchTarget").firstChild.nodeValue = this.firstChild.nodeValue;}}}

//즐감 서브메뉴 오버시


//naviOver("kin_submenu",0);
/*
function naviOver(wrap,num){
	var wrapper = _id(wrap);
	var lists = wrapper.childNodes;
	if(msie){
		$(lists).hover(function(){
			if(this != lists[num]){
				if(num != -1){
					$(lists[num]).removeClass();
					var beforeImg = _tag(lists[num],"img")[0];
					beforeImg.src = beforeImg.src.replace("_on.gif",".gif");
				}
				this.className = "on";
				var thisimg = _tag(this,"img")[0];
				thisimg.src = thisimg.src.replace(".gif","_on.gif");
			}
		},function(){
			if(this != lists[num]){
				if(num != -1){
					$(lists[num]).addClass("on");
					var beforeImg = _tag(lists[num],"img")[0];
					if(_tag(lists[num],"img")[0].src.match(/_on.gif/) != "_on.gif"){
						beforeImg.src = beforeImg.src.replace(".gif","_on.gif");
					}
				}
				this.className = "";
				var thisimg = _tag(this,"img")[0];
				thisimg.src = thisimg.src.replace("_on.gif",".gif");
			}
		});
		if(num != -1){
			if(_tag(lists[num],"img")[0]){
				if(_tag(lists[num],"img")[0].src.match(/_on.gif/) != "_on.gif"){
					_tag(lists[num],"img")[0].src = _tag(lists[num],"img")[0].src.replace(".gif","_on.gif");
				}
			}
			lists[num].className = "on";
		}
	}else{
		$(lists).hover(function(){
			if(this != lists[(num * 2)+1]){
				if(num != -1){
					$(lists[(num * 2)+1]).removeClass();
					var beforeImg = _tag(lists[(num * 2)+1],"img")[0];
					beforeImg.src = beforeImg.src.replace("_on.gif",".gif");
				}
				this.className = "on";
				var thisimg = _tag(this,"img")[0];
				thisimg.src = thisimg.src.replace(".gif","_on.gif");
			}
		},function(){
			if(this != lists[(num * 2)+1]){
				if(num != -1){
					$(lists[(num * 2)+1]).addClass("on");
					var beforeImg = _tag(lists[(num * 2)+1],"img")[0];
					beforeImg.src = beforeImg.src.replace(".gif","_on.gif");
				}
				this.className = "";
				var thisimg = _tag(this,"img")[0];
				thisimg.src = thisimg.src.replace("_on.gif",".gif");
			}
		});
		if(num != -1){
			if(_tag(lists[(num*2)+1],"img")[0]){
				_tag(lists[(num*2)+1],"img")[0].src = _tag(lists[(num*2)+1],"img")[0].src.replace(".gif","_on.gif");
			}
			lists[(num*2)+1].className = "on";
		}
	}
}
*/
/* 서브메뉴도 불 들어오는거*/

function naviOver(wrap,num,subNum){
	var wrapper = _id(wrap);
	var lists = wrapper.childNodes;
	if(msie){
		$(lists).hover(function(){
			if(this != lists[num]){
				if(num != -1){
					$(lists).each(function(index){
						$(lists[index]).removeClass();
					});
					$(lists[num]).addClass("beforeSelect");
					//var beforeImg = _tag(lists[num],"img")[0];
					//beforeImg.src = beforeImg.src.replace("_on.gif",".gif");
				}
				this.className = "on";
				var thisimg = _tag(this,"img")[0];
				thisimg.src = thisimg.src.replace(".gif","_on.gif");

				/*
				var firstChildLi = _tag(_tag(this,"li")[0],"img")[0];//서브메뉴 선택
				if(firstChildLi){
					if(firstChildLi.src.match(/_on.gif/) != "_on.gif"){
						firstChildLi.src = firstChildLi.src.replace(".gif","_on.gif");
					}
				}
				*/
			}
		},function(){
			if(this != lists[num]){
				if(num != -1){
					$(lists[num]).removeClass();
					$(lists[num]).addClass("on");
					var beforeImg = _tag(lists[num],"img")[0];
					if(_tag(lists[num],"img")[0].src.match(/_on.gif/) != "_on.gif"){
						beforeImg.src = beforeImg.src.replace(".gif","_on.gif");
					}
				}
				this.className = "";
				var thisimg = _tag(this,"img")[0];
				thisimg.src = thisimg.src.replace("_on.gif",".gif");


				if(!subNum && subNum != -1 && _tag(lists[num],"li").item(subNum)){//서브메뉴 선택
						var subImg = _tag(_tag(lists[num],"li")[subNum],"img")[0];
						if(subImg.src.match(/_on.gif/) != "_on.gif"){
							subImg.src = subImg.src.replace(".gif","_on.gif");
						}
				}
			}
		});

		if(num != -1){
			if(_tag(lists[num],"img")[0]){
				if(_tag(lists[num],"img")[0].src.match(/_on.gif/) != "_on.gif"){
					_tag(lists[num],"img")[0].src = _tag(lists[num],"img")[0].src.replace(".gif","_on.gif");

					if(subNum != -1 && _tag(lists[num],"li").item(0)){//3뎁스메뉴가 -1이 아니고, 3뎁스메뉴가 있을 경우만 해당 인덱스번째 불 켜주기
						if(subNum != undefined){
							var subImg = _tag(_tag(lists[num],"li")[subNum],"img")[0];
							subImg.src = subImg.src.replace(".gif","_on.gif");
						}
					}


				}
			}
			lists[num].className = "on";
		}

	}else{
		$(lists).hover(function(){
			if(this != lists[(num * 2)+1]){
				if(num != -1){
					$(lists[(num * 2)+1]).removeClass();
					var beforeImg = _tag(lists[(num * 2)+1],"img")[0];
					beforeImg.src = beforeImg.src.replace("_on.gif",".gif");
				}
				this.className = "on";
				var thisimg = _tag(this,"img")[0];
				thisimg.src = thisimg.src.replace(".gif","_on.gif");
			}
		},function(){
			if(this != lists[(num * 2)+1]){
				if(num != -1){
					$(lists[(num * 2)+1]).addClass("on");
					var beforeImg = _tag(lists[(num * 2)+1],"img")[0];
					beforeImg.src = beforeImg.src.replace(".gif","_on.gif");
				}
				this.className = "";
				var thisimg = _tag(this,"img")[0];
				thisimg.src = thisimg.src.replace("_on.gif",".gif");
			}
		});
		if(num != -1){
			if(_tag(lists[(num*2)+1],"img")[0]){
				_tag(lists[(num*2)+1],"img")[0].src = _tag(lists[(num*2)+1],"img")[0].src.replace(".gif","_on.gif");
			}
			lists[(num*2)+1].className = "on";
		}
	}
	
	if(num != -1){
		$(_tag(lists[num],"li")).mouseout(function(){//서브메뉴 선택

			if(subNum != undefined && subNum != -1){
				var firstImages = _tag(this.parentNode,"img")[subNum];
				if(firstImages.src.match(/_on.gif/) != "_on.gif"){
					firstImages.src = firstImages.src.replace(".gif","_on.gif");
				}
			}

		});
	}
}



/*
function naviOver(wrap,num){
	var idx = num;
	if(!msie){
		idx = (num * 2) + 1;
	}
	var lists = _id(wrap).childNodes;
	for(var i = 0; i < lists.length; i++){
		if(lists[i].nodeType == 3){
			continue;
		}else{
			if(i != idx){
				var anc = _tag(lists[i],"a")[0];
				anc.onmouseover = function(){
					var imgs = _tag(this,"img")[0];
					if(imgs){
						imgs.src = imgs.src.replace(".gif","_on.gif");
					}
					lists[idx].className = "";
					var loadImg = _tag(lists[idx],"img")[0];
					if(loadImg){
						loadImg.src = loadImg.src.replace("_on.gif",".gif");
					}
					this.parentNode.className = "on";
				},
				anc.onmouseout = function(){
					var imgs = _tag(this,"img")[0];
					if(imgs){
						imgs.src = imgs.src.replace("_on.gif",".gif");
					}
					lists[idx].className = "on";
					var loadImg = _tag(lists[idx],"img")[0];
					if(loadImg){
						loadImg.src = loadImg.src.replace(".gif","_on.gif");
					}
					this.parentNode.className = "";

					if(_tag(this.parentNode,"ul").item(0)){
						_tag(this.parentNode,"ul").item(0).onmouseover = function(){
							var imgs = _tag(this.parentNode,"img")[0];
							if(imgs){
								imgs.src = imgs.src.replace(".gif","_on.gif");
							}
							lists[idx].className = "";
							var loadImg = _tag(lists[idx],"img")[0];
							if(loadImg){
								loadImg.src = loadImg.src.replace("_on.gif",".gif");
							}
							this.parentNode.className = "on";
							this.onmouseout = function(){
								var imgs = _tag(this.parentNode,"img")[0];
								if(imgs){
									imgs.src = imgs.src.replace("_on.gif",".gif");
								}
								this.parentNode.className = "";
								lists[idx].className = "on";
								var loadImg = _tag(lists[idx],"img")[0];
								if(loadImg){
									loadImg.src = loadImg.src.replace(".gif","_on.gif");
								}
							}
						}
					}

					lists[idx].className = "on";
				}
			}
		}
	}
	lists[idx].className = "on";
	var loadImg = _tag(lists[idx],"img")[0];
	if(loadImg){
		loadImg.src = loadImg.src.replace(".gif","_on.gif");
	}
}
*/



//즐감 좌측 랭킹탭
function imgReplace(a){var imgs = _tag(a.parentNode,"img");for(var i = 0; i < imgs.length; i++){imgs[i].src = imgs[i].src.replace("_on.gif",".gif");}_tag(a,"img")[0].src = _tag(a,"img")[0].src.replace(".gif","_on.gif");}

//탭 메뉴 : li의 클래스를 on 으로 컨트롤, 안에 이미지가 있을 경우
function naviTab(el,idx,bool){
	var ul = _id(el);
	var lists = _tag(ul,"li");
	if(bool == true){
		var scop = lists.length;
	}else{
		var scop = lists.length - 1;
	}
	for(var i = 0; i < scop; i++){
		if(lists[i].className == "on"){
			continue;
		}else{
			lists[i].className = "";
			_tag(lists[i],"a")[0].onmouseover = function(){
				this.parentNode.className = "on";
				if(_tag(this,"img")[0]){
					if(_tag(this,"img")[0].src.match(/_on.gif/)){
							return false;
					}
					_tag(this,"img")[0].src = _tag(this,"img")[0].src.replace(".gif","_on.gif");
				}
				this.onmouseout = function(){
					this.parentNode.className = "";
					if(idx != -1){
						lists[idx].className = "on";
					}
					if(_tag(this,"img")[0]){
						_tag(this,"img")[0].src = _tag(this,"img")[0].src.replace("_on.gif",".gif");
					}
				}
			}
		}
	}
	if(idx != -1){
		lists[idx].className = "on";
		_tag(lists[idx],"img")[0].src = _tag(lists[idx],"img")[0].src.replace(".gif","_on.gif");
	}
}

//탭 메뉴 : 뉴스에서 쓰는 서브네비 컨트롤
function news_naviTab(el,num){
	var navi = _id(el);
	var idx;
	if(msie){
		idx = num;
	}else{
		idx = (num * 2) + 1;
	}
	var lists = _tag(navi,"ul")[0].childNodes;
	for(var i = 0; i < lists.length; i++){
		if(lists[i].nodeType == 3){
			continue;
		}else{
			lists[i].className = "";
			lists[i].onmouseover = function(){
				this.className = "on";
				var thisImg = _tag(this,"img")[0];
				if(thisImg && thisImg.src.match(/_on.gif/) != "_on.gif"){
					thisImg.src = thisImg.src.replace(".gif","_on.gif");
				}
				this.onmouseout = function(){
					this.className = "";
					var thisImg = _tag(this,"img")[0];
					if(thisImg){
						thisImg.src = thisImg.src.replace("_on.gif",".gif");
					}
					if(idx != -1){
						lists[idx].className = "";
						var original_img = _tag(lists[idx],"img")[0];
					}
					if(original_img && original_img.src.match(/_on.gif/) != "_on.gif"){
						original_img.src = original_img.src.replace(".gif","_on.gif");
						//_tag(lists[idx],"img")[0].src = _tag(lists[idx],"img")[0].src.replace(".gif","_on.gif");
					}
				}
			}
		}
	}
	//lists[idx].className = "on";
	if(idx != -1){
		_tag(lists[idx],"img")[0].src = _tag(lists[idx],"img")[0].src.replace(".gif","_on.gif");
	}
}

//textarea 포커스 들어가고, 나갈때 처리
function textareaChk(val,txt){
	if(val.firstChild && val.firstChild.nodeValue == txt){
		val.firstChild.nodeValue = "";
		val.onblur = function(){
			if(this.firstChild.nodeValue.length < 1){
				this.firstChild.nodeValue = txt;
			}
		}
	}
}

//탭메뉴 1번타입
function tabMenu01(val){var ul = val.parentNode.parentNode;var lists = _tag(ul,"li");for(var i = 0; i < lists.length; i++){lists[i].className = "";var imgs = _tag(lists[i],"img")[0];if(imgs){imgs.src = imgs.src.replace("_on.gif",".gif");}}val.parentNode.className = "on";var thisimg = _tag(val,"img")[0];if(thisimg){thisimg.src = thisimg.src.replace(".gif","_on.gif");}}

//갤러리 롤링타입01
var gallery_listCount = 0;
function galleryControl(el,num,show){
	gallery_listCount += num;
	var targetUL = _id(el);
	var list = _tag(targetUL,"li");
	if(gallery_listCount <= 0){
		gallery_listCount = 0;
	}else if(gallery_listCount >= list.length){
		gallery_listCount = list.length;
	}
	for(var i = 0; i < list.length; i++){
		list[i].style.display = "none";
	}
	for(var x = gallery_listCount; x < show + gallery_listCount; x++){
		if(x < list.length){
			list[x].style.display = "block";
		}else{
			for(var k = list.length - show; k < list.length; k++){
				list[k].style.display = "block";
				gallery_listCount = list.length - show;
			}
		}
	}
}

//갤러리 롤링타입01 ++addOn
var movieToggling = {
	defaultNum : 1,
	action : function(tgets,el,num){
		var ul = tgets.parentNode.parentNode;
		var lists = _tag(ul,"li");
		for(var i = 0; i < lists.length; i++){
			_id(el + (i + 1)).style.display = "none";
			lists[i].className = "";
		}
		tgets.parentNode.className = "on";
		_id(el + (num)).style.display = "block";
		movieToggling.defaultNum = num;
		gallery_listCount = 0;
		galleryControl("movieToggle" + num,gallery_listCount,5);
	}
}

//디스플레이 컨트롤
var displayControl = function(tgs,classId,num){
	var ul = tgs.parentNode.parentNode;
	var list = _tag(ul,"li");
	var max = list.length;
	for(var i = 0; i < max; i++){
		list[i].className = "";
		_id(classId + (i + 1)).style.display = "none";
	}
	list[num - 1].className = "on";
	_id(classId + num).style.display = "block";
}

var displayControl2 = function(tgs,classId,num){
	var ul = tgs.parentNode.parentNode;
	var list = _tag(ul,"li");
	var max = list.length;
	for(var i = 0; i < max; i++){
		//$(list[i]).removeClass();
		_id(classId + (i + 1)).style.display = "none";
	}
	//$(list[0]).addClass("first-child");
	//$(list[num - 1]).addClass("on");
	_id(classId + num).style.display = "block";
}

var displayControl3 = function(tgs,classId,num){
	var ul = tgs.parentNode.parentNode;
	var list = _tag(ul,"li");
	var max = list.length;
	for(var i = 0; i < max; i++){
		_id(classId + (i + 1)).style.display = "none";
		if(_tag(list[0],"img").length > 0){
			var thisImg = _tag(list[i],"img")[0];
			thisImg.src = thisImg.src.replace("_on.gif",".gif");
		}
	}
	_id(classId + num).style.display = "block";
	if(_tag(tgs,"img").length > 0){
		var thisImg = _tag(tgs,"img")[0];
		thisImg.src = thisImg.src.replace(".gif","_on.gif");
	}
}

function classOn(tgs,num){
	var ul = tgs.parentNode.parentNode;
	var list = _tag(ul,"li");
	for(var i = 0; i < list.length; i++){
		list[i].className = "";
	}
	tgs.parentNode.className = "on";
}

//이미지 슬라이드
var toggleDom = {
	action : function(elem,which,max){//li 한개 단위로 넘기기
		var thisElem = _id(elem);
		var ul = _tag(thisElem,"ul").item(0);
		var list = _tag(ul,"li");
		if(list.length < max){
			return false;
		}else{
			if(which == "left"){
				ul.insertBefore(ul.lastChild,list[0]);
			}else{
				ul.appendChild(list[0]);
			}
		}
	},
	ulToggle : function(elem,which,max){//ul덩어리 단위로 넘기기
		var thisElem = _tag(_id(elem),"div")[0];
		var ul = _tag(thisElem,"ul");
		if(ul.length < max){
			return false;
		}else{
			if(which == "left"){
				thisElem.insertBefore(thisElem.lastChild,ul[0]);
			}else{
				thisElem.appendChild(ul[0]);
			}
		}
	}
}

//즐감 차트 롤링
var zlgamChartSlide = {
	defaultSec : 1,
	slideUp : function(elem,listBox,posTop,liList){
		var para = _tag(listBox.parentNode,"p")[0];
		var prevBtn = _tag(para,"a")[0];
		var nextBtn = _tag(para,"a")[1];
		if(posTop > -16){
			posTop--;
		}
		listBox.style.top = posTop + "px";
		var motionUp = setTimeout(function(){
			zlgamChartSlide.slideUp(elem,listBox,posTop,liList);
		},10);
		if(posTop == -16){
			listBox.appendChild(liList[0]);
			clearTimeout(motionUp);
			listBox.style.top = 1 + "px";
			var repeat = setTimeout(function(){
				zlgamChartSlide.action(elem);
			},zlgamChartSlide.defaultSec * 1000);
		}
		prevBtn.onclick = function(){
			clearTimeout(motionUp);
			clearTimeout(repeat);
			var lists = _tag(listBox,"li");
			var x = 0;
			while(x < 2){
				listBox.insertBefore(listBox.lastChild,_tag(listBox,"li")[0]);
				x++;
			}
			zlgamChartSlide.action("zlgamChartSlide");
		},
		nextBtn.onclick = function(){
			clearTimeout(motionUp);
			clearTimeout(repeat);
			var lists = _tag(listBox,"li");
			listBox.appendChild(listBox.lastChild);
			zlgamChartSlide.action("zlgamChartSlide");
		}
	},
	action : function(elem){
		if(!_id(elem)) return false;
		var section = _id(elem);
		var listBox = _tag(section,"ul").item(0);
		var liList = _tag(listBox,"li");
		listBox.style.height = (liList.length * 16) + "px";
		var posTop = parseInt(_css(listBox,"top"));
		zlgamChartSlide.slideUp(elem,listBox,posTop,liList);
	}
}

//영화감상에서 예매를 누를경우
function onTicketReserve(){
	$("<div class=\"ticket_reserve png24\" id=\"layer_ticket_reserve\"><div class=\"ticket_contents\"><p class=\"ani\"><img src=\"/images/img/ticket_reserve_ani.gif\" alt=\"\" /></p><a href=\"#\" class=\"btnClose\" onclick=\"document.body.removeChild(_id('layer_ticket_reserve')); alert('예매사이트로 리다이렉트');\"><img src=\"/images/btn/btn_close01.gif\" alt=\"닫기\" /></a></div></div>").appendTo("body");
}

//동영상 퍼올경우, 파라미터로 값 날려주면 뿌려주기
function insertVod(elems,u,w,h){
	var targetElem = _id(elems);
	targetElem.innerHTML = "";
	if(arguments.length <= 1){
		width = 510;
		height = 413;
	}else{
		width = w;
		height = h;
	}
	var str = new String();
	str = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http:\/\/download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0\" width=" + width + " height=" + height + ">";
	str += "<param name=\"movie\" value=" + u + " />";
	str += "<param name=\"wmode\" value=\"transparent\" />";
	str += "<!--[if !IE]> <-->";
	str += "<object type=\"application/x-shockwave-flash\" data=" + u + " width=" + width + " height=" + height + ">";
	str += "<param name=\"movie\" value=" + u + " />";
	str += "<param name=\"wmode\" value=\"transparent\" />";
	str += "</object>";
	str += "<!--> <![endif]-->";
	str += "</object>";
	targetElem.innerHTML = str;
}

//네티즌 리뷰 댓글 활성화 기본 설정
var replyControl = {
	action : function(elem,types){
		var listsSection = _id(elem);
		if(!listsSection) return false;
		var childs = _tag(listsSection,"ul").item(0).childNodes;
		if(childs.length >= 1){
			if(types == 0){
				if(childs.item(0).className == "nodata"){
					childs.item(1).className = "";
				}else{
					childs.item(0).className = "";
				}
			}else if(types == 1){
				childs.item(0).className = "open";
			}else{
				for(var i = 0; i < childs.length; i++){
					if(_tag(childs[i],"div").item(1)){
						childs.item(i).className = "open";
					}
				}
			}
		}
	},
	subReply : function(elem,types){//대댓글 활성화 설정
		var listsSection = _id(elem);
		if(!listsSection) return false;
		var childs = _tag(listsSection,"dl");
		for(var i = 0; i < childs.length; i++){
			if(types == 0){
				_tag(childs[i],"dd")[0].className = "close";
			}else if(types == 1){
				_tag(childs[0],"dd")[0].className = "";
			}else{
				_tag(childs[i],"dd")[0].className = "";
			}
		}
	}
}

//네티즌 리뷰 대댓글 펼치고 닫기
function subReplyToggle(tg){
	var parentLi = tg.parentNode.parentNode.parentNode.parentNode;
	if(!_tag(parentLi,"div")[1]){
		//alert("댓글이 없습니다.");
		return false;
	}
	if(parentLi.className == "open"){
		$(parentLi).removeClass("open");
		$(tg).parent().removeClass("replyOn");
	}else{
		$(parentLi).addClass("open");
		$(tg).parent().addClass("replyOn");
	}
}

//네티즌 리뷰 더보기 버튼, 닫기버튼
function showHide(tg){
	var myImg = _tag(tg,"img").item(0);
	var targetDD = _tag(tg.parentNode.parentNode,"dd").item(0);
	if(myImg.src.match(/more03.gif/)){
		myImg.src = myImg.src.replace("more03.gif","close01.gif");
		targetDD.className = "";
		return false;
	}else{
		myImg.src = myImg.src.replace("close01.gif","more03.gif");
		targetDD.className = "close";
		return false;
	}
}
/*
function showHide(tg){
	var targetDD = _tag(tg.parentNode.parentNode,"dd").item(0);
	var myImg = _tag(tg,"img").item(0);
	if(myImg){
		if(myImg.src.match(/more03.gif/)){
			myImg.src = myImg.src.replace("more03.gif","close01.gif");
			targetDD.className = "";
			return false;
		}else{
			myImg.src = myImg.src.replace("close01.gif","more03.gif");
			targetDD.className = "close";
			return false;
		}
	}else{
		$(targetDD).toggleClass("close");
	}
}
*/

//특정영역의 폰트사이즈 컨트롤
function textControl(elem,add){
	var wrap = _id(elem);
	var tags = _tag(wrap,"*");
	for(var i = 0; i < tags.length; i++){
		var font_info = parseInt($(tags[i]).css("fontSize"));
		if(add == "plus"){
			if(font_info < 20){
				tags[i].style.fontSize = parseInt($(tags[i]).css("fontSize")) * 1.2 + "px";
			}
		}else{
			if(font_info > 12){
				tags[i].style.fontSize = parseInt($(tags[i]).css("fontSize")) / 1.2 + "px";
			}
		}
	}
}

//FAQ토글 테이블
function thisNextTrOn(val,elem){
	var thisTr = val.parentNode.parentNode;
	var trs = _tag(_tag(_id(elem),"tbody")[0],"tr");
	for(var i = 0; i < trs.length; i++){
		if(i % 2 == 0){
			trs[i].className = "";
		}else{
			trs[i].className = "close";
		}
	}
	if(thisTr.nextSibling.className == "close"){
		thisTr.nextSibling.className = "on";
	}else{
		thisTr.nextSibling.nextSibling.className = "on";
	}
}

//포토리스트 펼치고 닫기
function photoListToggle(tg,elem,ifm,ifmsrc){
	var wrapper = _id(elem);
	_id(ifm).style.display = "block";
	var child = _tag(wrapper,"ul")[0].childNodes;
	var para = tg.parentNode;
	for(var i = 0; i < child.length; i++){
		if(child[i].nodeName == "#text"){
			continue;
		}else{
			child[i].className = "";
		}
	}
	var cnt = _isIndex(para.parentNode,para.parentNode.parentNode);
	if(cnt == window.photoListTogglecnt){
		if(_tag(_id(elem),"iframe")[0]){
			para.parentNode.className = "";
			_id(elem).parentNode.appendChild(_id(ifm));
			_tag(_id(ifm),"iframe")[0].removeAttribute("src");
			_tag(_id(ifm),"iframe")[0].parentNode.style.height = 0 + "px";
		}else{
			para.parentNode.className = "on";
			para.parentNode.appendChild(_id(ifm));
			_tag(_id(ifm),"iframe")[0].src = ifmsrc;
		}
	}else{
		para.parentNode.className = "on";
		para.parentNode.appendChild(_id(ifm));
		_tag(_id(ifm),"iframe")[0].src = ifmsrc;
	}
	window.photoListTogglecnt = _isIndex(para.parentNode,para.parentNode.parentNode);
}

function onPrint(u,n,p,opt){
	var xpos = (screen.width / 2) - (p.split(",")[0].substring(6,p.split(",")[0].length) / 2);
	var ypos = (screen.height / 2) - (p.split(",")[1].substring(7,p.split(",")[1].length) / 2);
	if(opt == "fix"){
		var prop = p + "," + "top=" + ypos + "," + "left=" + xpos + ",toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no";
	}else{
		var prop = p + "," + "top=" + ypos + "," + "left=" + xpos + ",toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no";
	}
	window.open(u,n,prop);
}

