/* 다음캐쉬 */
function openDaumCash(itemId,popName) {
	var returnURL = "http://movie.daum.net/vod/detail.do?itemId=" + itemId;
	if(popName) { var param = "&isPopup=1&popName=" + popName; }
	else { var param = "&isPopup=0"; }
	var url = "https://bill.daum.net/Elf/cash/Credit.daum?popURL=" + encodeURIComponent(returnURL) + param;
	var winFeat = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=580,height=543";
	UI.popUp(url, "bill", winFeat);
}
var vod = {};
vod.payController = function(price,cash,itemId){
	this.price = price;
	this.cash = cash;
	this.itemId = itemId;
}
vod.payController.prototype = {
	_paymentType : "MOBILE",

	setPayType : function(type) {
		if(this._paymentType != type) {
			this._paymentType = type;
		}
	},
	pay : function(){
		if(this._paymentType == "DAUMCASH"){
			if(this.price > this.cash){
				alert("Daum캐쉬가 부족합니다.\n Daum캐쉬 추가 충전후 이용해주세요.");
				return false;
			}else{
				document.location = "/vod/pay/daumcash.do?itemId="+this.itemId;
			}
		}else{
			new UI.Ajax({url:"/vod/pay/request.do",param:"itemId=" + this.itemId + "&paymentType=" + this._paymentType,method:"POST",onComplete:this.callBI.bind(this)});
		}
	},
	callBI : function(req) {
		eval(req.responseText);
		if(RequestPayment.error == "error" ){
			alert("결제가 실패하였습니다.");
			return;
		}
		this.openBI(RequestPayment.Rcvseq, RequestPayment.Pgcate);
	},
	openBI : function(rcvseq, pgcate) {
		var url = "https://bill.daum.net/Elf/instant/"+pgcate+".daum?rsvseq="+ rcvseq;
		var winOpt = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=549,height=674";
		UI.popUp(url, "bill", winOpt);
	}
}