/*================================================
GROUND SWF SIZE FIX
-------------------------------------------------*/
dom.layout=function(){
	this.emt=dom.$("doc-ground");
	this.emt.style.width=window.document.documentElement.scrollWidth+"px";
	this.emt.style.height=window.document.documentElement.scrollHeight+"px";
};
/*================================================
FILM LIST / SECTION INFO LAYER
-------------------------------------------------*/
dom.filmlist=function(){
	this.bt = dom.$("section-info-more");
	this.bt.call = this;
	this.emt = dom.$("section-info-body");
	this.emt.on = false;
	evt.add(this.bt, "click", function(){ this.call.view() });
	this.ground=dom.$("doc-ground");
};
dom.filmlist.prototype={
	view : function(){
		if(this.emt.on) {
			this.emt.style.display="none";
			this.emt.on=false;
			this.ground.style.width=window.document.documentElement.scrollWidth+"px";
			this.ground.style.height=window.document.documentElement.scrollHeight+"px";
		}else{
			this.emt.style.display="block";
			this.emt.on=true;
			this.ground.style.width=window.document.documentElement.scrollWidth+"px";
			this.ground.style.height=window.document.documentElement.scrollHeight+"px";
		}
	}
};
/*================================================
FILM DETAIL / SECTION LIST UTIL
-------------------------------------------------*/
dom.sectionlist=function(bt,prt){
	this.bt=bt;
	this.prt=prt;
	this.bt.on=false;
	this.bt.call=this;
	this.list=dom.$$(prt,"div","cell");
	this.total=this.list.length;
	if(this.total == 0){
		evt.add(this.bt,"click",function(){ alert("섹션 내 다른 상영작이 없습니다.") });
	}else{
		for(var i=0; i < this.total; i++){
			evt.add(this.list[i],"mouseover",function(){ this.style.backgroundColor="#D9DED2" });
			evt.add(this.list[i],"mouseout",function(){ this.style.backgroundColor="#E4E9DC" });
		}
		evt.add(this.bt,"click",function(){ this.call.showlist() });
		evt.add(this.bt,"focus",function(){ this.blur() });
	}
};
dom.sectionlist.prototype={
	showlist : function(){
		if(this.bt.on){
			this.prt.style.display="none";
			this.bt.style.backgroundPosition="122px 9px";
			this.bt.on=false;
		}else{
			this.prt.style.display="block";
			this.bt.style.backgroundPosition="122px -17px";
			this.bt.on=true;
		}
	}
};
/*================================================
FILM DETAIL / STILL MOVING
-------------------------------------------------*/
dom.still=function(emt,prev,next){
	this.emt=emt;
	this.list=dom.$$(emt,"div","cell");
	this.total=this.list.length;
	this.prev=prev;
	this.next=next;
	this.now=1;
	this.prev.call=this.next.call=this;
	this.contents="<html><head><title>원본크기로 보기 - 클릭하면 창이 닫힙니다.</title></head>"
	this.imgtemp=new Image();
	this.page=dom.$("film-still-page");
	evt.add(this.prev,"click",function(){ this.call.moveprev() });
	evt.add(this.next,"click",function(){ this.call.movenext() });
	for(var i=0,imgsrc; i<this.total; i++){
		imgsrc=this.list[i].style.backgroundImage;
		imgsrc=imgsrc.replace("url(","");
		imgsrc=imgsrc.replace(")","");
		this.imgtemp.setAttribute("src",imgsrc);
		this.list[i].no = i;
		this.list[i].call = this;
		this.list[i].src = imgsrc;
		this.list[i].ow = this.imgtemp.width;
		this.list[i].oh = this.imgtemp.height;
		evt.add(this.list[i],"click",function(){ this.call.view(this) });
	}
	this.page.innerHTML="1 / "+this.total;
};
dom.still.prototype={
	moveprev : function(){
		if(1 < this.now){
			this.now -= 1;
			this.emt.scrollLeft=554 * (this.now-1);
		}
		this.page.innerHTML=this.now+" / "+this.total;
	},
	movenext : function(){
		if(this.total > this.now){
			this.now += 1;
			this.emt.scrollLeft=554 * (this.now-1);
		}
		this.page.innerHTML=this.now+" / "+this.total;
	},
	view : function(emt){
		var contents=this.contents, win;
			contents+="<body style=\"margin: 0;\"><a href=\"#close\" onclick=\"window.close();\"><img src=\""+emt.src+"\" border=\"0\" alt=\"이미지를 클릭하면 창이 닫힙니다.\" onload=\"window.resizeTo(this.width,this.height+30);\" />";
			contents+="</a></body></html>";
		win=window.open("","bigimage","width="+emt.ow+",height="+emt.oh);
		win.document.open();
		win.document.write(contents);
		win.document.close();
	}
};
/*================================================
MY CINDI LIST
-------------------------------------------------*/
var CartReq=null;
dom.cart=function(bt,no){
	this.cart=dom.$("cindi-cart");
	this.bt=bt;
	this.bt.call=this;
	this.no=no;
	this.xls=dom.$("cindi-cart-button");
	evt.add(this.bt,"click",function(){ this.call.setcart() });
	evt.add(this.bt,"focus",function(){ this.blur() });
};
dom.cart.prototype={
	setcart : function(){
		CartReq=new ajax("/cindi2008/com/mylist.php","no="+this.no+"&mode=N",this.addcart);
	},
	addcart : function(){
		if(CartReq == null || CartReq.R == null) return;
		if(CartReq.R.readyState==4){
			if(CartReq.R.responseText=="Overlap"){
				alert("이미 목록에 있습니다.");
			}else{
				dom.$("cindi-cart").innerHTML=dom.$("cindi-cart").innerHTML+CartReq.R.responseText;
				dom.$("cindi-cart-button").style.display="block";
			}
			CartReq=null;
		}else{
		}
	}
};
dom.cartinit=function(){
	CartReq=new ajax("/cindi2008/com/mylist.php","",this.addcart);
};
dom.cartinit.prototype={
	addcart : function(){
		if(CartReq == null || CartReq.R == null) return;
		if(CartReq.R.readyState==4){
			dom.$("cindi-cart").innerHTML+=CartReq.R.responseText;
			CartReq=null;
			dom.$("cindi-cart-button").style.display="block";
		}else{
		}
	},
	delcart : function(no){
		dom.$("cindi-cart").innerHTML="";
		CartReq=new ajax("/cindi2008/com/mylist.php","no="+no+"&mode=R",this.addcart);
	}
};
/*================================================
COMMUNITY BOARD / ARTICLE COMMENT DELETE
-------------------------------------------------*/
dom.cmt = function(){
	this.delBox = dom.$$(dom.$("cmt-body-wrap"), "div", "del");
	this.delButton = dom.$$(dom.$("cmt-body-wrap"), "a", "go");
	this.delValue = dom.$$(dom.$("cmt-body-wrap"), "input");
	this.showButton = dom.$$(dom.$("cmt-body-wrap"), "a", "bt");
	for(var i = 0; i < this.delBox.length; i++){
		this.delBox[i].on = false;
		this.showButton[i].call = this.delButton[i].call = this;
		this.showButton[i].no = this.delButton[i].no = i;
		evt.add(this.showButton[i], "click", function(){ this.call.view(this) });
		evt.add(this.delButton[i], "click", function(){ this.call.valid(this) });
	}
};
dom.cmt.prototype = {
	view : function(emt){
		if(this.delBox[emt.no].on){
			this.delBox[emt.no].style.display = "none";
			this.delBox[emt.no].on = false;
		}else{
			this.delBox[emt.no].style.display = "block";
			this.delBox[emt.no].on = true;
		}
	},
	valid : function(emt) {
		if(this.delValue[emt.no].value == ""){
			alert("비밀번호를 입력하세요");
			this.delValue[emt.no].focus();
		}else{
			window["util-frame"].location.href="_cmt.php?mode=Delete&pw="+this.delValue[emt.no].value+"&c_no="+emt.c_no;
		}
	}
};

function GetEXL(){
	window["util-frame"].location.href="/cindi2008/com/mylist.php?mode=D"
};

/*================================================
COMMUNITY BOARD / ARTICLE COMMENT DELETE
-------------------------------------------------*/
dom.atdel=function(){
	this.bt=dom.$("article-delete-bt");
	this.inp=dom.$("article-delete");
	this.bt.stat=1;
	this.bt.call=this;
	evt.add(this.bt, "click", function(){ this.call.act() });
};
dom.atdel.prototype={
	act : function(){
		if(this.bt.stat==1){
			this.inp.style.display="inline";
			this.bt.stat=2;
		}else{
			if(this.inp.value==""){
				alert("비밀번호를 입력하세요");
				this.inp.focus();
			}else{
				window.document.forms["delete"].submit();
			}
		}
	}
};