﻿
var PerformanceID;
function CreateDefault(str) {

    showOverlay();
    var arrayPageSize = getPageSize()
    var silverlightarrayPageSize = GetSilverlightTicketSize();


    document.getElementById("overlay").style.width = arrayPageSize[0];
    document.getElementById("overlay").style.height = arrayPageSize[1];

    //실버라이트 티켓화면 좌표설정
  
    //document.getElementById("SilverlightTicket").style.left = silverlightarrayPageSize[0];
    CheckTicket();
    PerformanceID = str;
    SilverlightTicket.innerHTML = embedSilverlight(null, "ticketing", "row1");

}

function embedSilverlight(parentElement, pluginId, userContext) {
    var altHtml = pluginId == "ticketing" ? null : "<!--not installed-->";
    return Silverlight.createObject("/ClientBin/NewCitiZenBasic.xap",
                parentElement, pluginId,
                {
                    width: "100%", height: "100%", alt: altHtml,
                    PluginBackground: "Transparent",
                    minRuntimeVersion: "3.0.40624.0", autoUpgrade: true
                },
                { onError: onSLError, onLoad: onSLLoad },
                "PerformanceID=" + PerformanceID, userContext);
}
//외부호출용
var slCtl = null;
function onSLLoad(plugIn, userContext, sender) {
    slCtl = sender.getHost();  //HTML 버젼


    //alert(slCtl.Content.MySilverlight.MyToUpper("Test String"));  //실제로 잘 불러와지는지 테스트
    window.status += plugIn.id + " loaded into " + userContext + ". ";
}



function onSLError(sender, args) {
    // Display error message.
}


function GoTOMemberEntry() {

    location.href = 'http://citizenhall.busan.kr/04_member/member05.asp';
}

function GoToFindPwd() {
    location.href = 'http://citizenhall.busan.kr/04_member/member04.asp';

}

//다시예매하기
function TicketReload() {

    setTimeout("TicketCloseAndReloadSetTimeout()", 1000);

}
//닫기
function TicketClose() {
    if (confirm("예매를 취소하시고 종료하시겠습니까?")) {
        setTimeout("TicketCloseSetTimeout()", 1000);

    }
}
//강제종료
function CompulsionTicketClose() {
    setTimeout("TicketCloseSetTimeout()", 1000);
}

//바로닫기했을때 오류없애기 위해서 타입아웃
function TicketCloseSetTimeout() {
    SilverlightTicket.innerHTML = "";
    hiddenOverlay();
}
//다시예매하기 오류없애기 위해서 타입아웃
function TicketCloseAndReloadSetTimeout() {

    SilverlightTicket.innerHTML = "";
    CreateDefault("");

}
function hiddenOverlay() {

    document.getElementById("overlay").style.display = "none";
    document.getElementById("SilverlightTicket").style.display = "none"
}
function showOverlay() {
    document.getElementById("overlay").style.display = "block";
    document.getElementById("SilverlightTicket").style.display = "block"

}


function ResultCreateCard(transaction, respcode, respmsg, authdate, authnumber) {
    slCtl.Content.MySilverlight.EndCreateCard(transaction, respcode, respmsg, authdate, authnumber);
    //alert("ResultCreateCard" + transaction);
}

function ResultTransferSelectBank(transaction, respcode, accountNum, userName, bankcode, respDate) {
    //alert("  transaction:" + transaction + "  respcode:" + respcode + "  accountNum:" + accountNum + "  userName:" + userName + "  bankcode:" + bankcode + "  respDate:" + respDate)
    slCtl.Content.MySilverlight.EndTransferSelectBank(transaction, respcode, accountNum, userName, bankcode, respDate);

}

//신용카드 결제
//주문번호 ,금액명, 구매자명 , 상품명 , 이메일 ,전화
function SetCardAcc(cardcode, oid, amount, buyer, productinfo, buyeremail, buyerphone) {



    document.sIframe.document.location.href = "/SilverlightTicketService/NewSilverlightApplicationCardIframe.asp?cardcode=" + cardcode + "&oid=" + oid + "&amount=" + amount + "&buyer=" + buyer + "&productinfo=" + productinfo + "&buyeremail=" + buyeremail + "&buyerphone=" + buyerphone;


}

//계좌이체 결제
// 주문번호,  금액명,  주문자이름,  이메일,  전화번호,  주민번호
//주문번호 ,금액명, 구매자명 , 상품명 , 이메일 ,전화
function SetTransferSelectBank(cardcode, oid, amount, buyer, productinfo, buyeremail, buyerphone, pid) {
	
    document.sIframe.document.location.href = "/SilverlightTicketService/NewSilverlightApplicationTransferSelectBank.asp?cardcode=" + cardcode + "&oid=" + oid + "&amount=" + amount + "&buyer=" + buyer + "&productinfo=" + productinfo + "&buyeremail=" + buyeremail + "&buyerphone=" + buyerphone + "&pid=" + pid;
}


function CallOuterClass() {

    slCtl.Content.MySilverlight.EndCreateCard('');


}

//티켓내역
function SilverlightTicketServiceResult(str) {
    window.open("/SilverlightTicketService/SilverlightTicketServiceResult.aspx?PerformanceNu=" + str, "SilverlightTicketService", "width=350,height=450");
}
function GotoMovieList() {

    location.href = "/02_res/res02.asp";
}



function getPageSize() {

    var xScroll, yScroll;

    if (window.innerHeight && window.scrollMaxY) {
        xScroll = window.innerWidth + window.scrollMaxX;
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }

    var windowWidth, windowHeight;

    if (self.innerHeight) {	// all except Explorer
        if (document.documentElement.clientWidth) {
            windowWidth = document.documentElement.clientWidth;
        } else {
            windowWidth = self.innerWidth;
        }
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }

    // for small pages with total height less then height of the viewport
    if (yScroll < windowHeight) {
        pageHeight = windowHeight;
    } else {
        pageHeight = yScroll;
    }

    // for small pages with total width less then width of the viewport
    if (xScroll < windowWidth) {
        pageWidth = xScroll;
    } else {
        pageWidth = windowWidth;
    }

    return [pageWidth, pageHeight];
}
function CheckTicket() {

    if (document.getElementById("overlay") != null) {
        if (document.getElementById("overlay").style.display == "block") {
            var arrayPageSize = getPageSize()
            document.getElementById("overlay").style.width = arrayPageSize[0];
            document.getElementById("overlay").style.height = arrayPageSize[1];


            //실버라이트 티켓화면 좌표설정
            var silverlightarrayPageSize = GetSilverlightTicketSize();
            document.getElementById("SilverlightTicket").style.left = silverlightarrayPageSize[0];
        }
    }
}


function GetSilverlightTicketSize() {
    cw = screen.availWidth; // 화면 너비
    ch = screen.availHeight; // 화면 높이

//    cw = document.body.scrollWidth;
//    ch = document.body.scrollHeight;
 
    sw = 930; // 띄울 창의 너비
    sh = 596; // 띄울 창의 높이

    ml = (cw - sw) / 2; // 가운데 띄우기위한 창의 x위치
    mt = (ch - sh) / 2; // 가운데 띄우기위한 창의 y위치
    size = Array(2);
    size[0] = ml;
    size[1] = mt;
    return size;
}



/*
실명인증 추가 2009.08.14 kojaedoo
*/
function CallCheckName(name, jumin1, jumin2) {
   
    url = "http://citizenhall.busan.kr/SilverlightTicketService/WEB_person_asp/NiceCheck.asp?name=" + name + "&jumin1=" + jumin1 + "&jumin2=" + jumin2;

    document.IframeNickName.document.location.href = url;
}

function NameCheckResult(result) {

    slCtl.Content.MySilverlight.NameCheck(result);

}
function CallPerformance() {
    
    location.href = "http://citizenhall.busan.kr/02_res/res02.asp";

}


/*
도움말팝업 2009.08.20 kojaedoo
*/
//회원혜택
function MemberReceivePop() {
    window.open("http://citizenhall.busan.kr/04_member/member01_1.asp", "membpop", "width=700, height=500,scrollbars=1");

}
//티켓예매안내
function TickeInfoPop() {
    window.open("http://citizenhall.busan.kr/02_res/res01_1.asp", "membpop", "width=700, height=500,scrollbars=1");

}
//티켓예매안내
function LgDacomErrorPop(str) {
    if (str == "ActiveX") {
        //window.open("http://pgdownload.dacom.net/lgdacom/LGDacomXPayWizard.exe", "membpop", "width=700, height=500,scrollbars=1");
        location.href = "http://pgdownload.dacom.net/lgdacom/LGDacomXPayWizard.exe";
    } else {
        window.open("http://ecredit.dacom.net/renewal/html/guide_popup/menu_03.htm", "membpop", "width=700, height=500,scrollbars=1");

    }
}




window.onresize = CheckTicket