﻿document.write('<script type="text/javascript" src="../../Etc/js/jsNor.js"></script>')
var timeout_value = 500000;

function flash_view(flash_file, x, y) {
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + x + '" height="' + y + '">');
    document.write('<param name="movie" value="' + flash_file + '">');
    document.write('<param name="quality" value="high">');
    document.write('<param name="wmode" value="transparent">');
    document.write('<embed src="' + flash_file + '" width="' + x + '" height="' + y + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>');
    document.write('</object>');
}


function setSelectBox(selName) {
    sel = eval("document.all." + selName);

    borderColor = sel.bordercolor;
    selWidth = parseInt(sel.width);
    bgColor = sel.bgcolor;
    rectLeft = selWidth - 2;
    spanWidth = selWidth;
    header = "<span style='position:relative;margin-right:0px;";
    header += "width:" + spanWidth + ";height:18px;border:1px solid " + borderColor + ";background-color:" + bgColor + ";'>\n";
    header += "<span style='position: absolute;left:0px;top:-1px;";
    header += "width:" + selWidth + ";height:17px;clip:rect(2," + rectLeft + ",16,2);'>\n";
    footer = "</span></span>";

    sel.style.backgroundColor = bgColor;
    sel.style.width = selWidth;

    sel.outerHTML = header + sel.outerHTML + footer;
}

function key_book_search() {
    if (event.keyCode == 13) {
        book_search();
    }
}

function book_search() {
    var values = $("#txt_BookSearch").val();

    if (values == "") {
        alert("검색어를 입력하세요.");
        return;
    }

    var f = document.form1;

    if (location.href.indexOf("SEARCH_LIST.aspx") > -1) {
        f.action = "SEARCH_PROC.aspx";
    }
    else {
        f.action = "../../SrcWeb/BOOK/SEARCH_LIST.aspx";
    }
    
    f.method = "post";
    f.submit();

}

function go_url(no, url) {
    var select = $("select");
    var page, sstring;

    if (select.length > 0) {
        page = select[0].value;
    }
    else {
        page = "";
    }
    sstring = $("#txt_Search").val();

    document.location = url + "?no=" + no + "&page=" + page + "&sstring=" + sstring;
}

function go_url_comm(no, url) {
    var select = $("select");
    var page, stype, sstring;    

    if (select.length == 2) {
        page = select[1].value;
        stype = select[0].value;
        sstring = $("#txt_Search").val();
    }
    else {
        stype = select[0].value;
        page = "";        
        sstring = $("#txt_Search").val();
    }

    document.location = url + "?no=" + no + "&page=" + page + "&stype=" + stype + "&sstring=" + sstring;
}

function View_Book(code) {
    $("#check").val('true');

    WindowOpen("../../files/eBook/" + code + "_eBook.html", screen.width, screen.height, "preview");
}

function getCartList() {
    $.ajax({
        url: '../../ajax/ajax.aspx?',
        type: 'POST',
        data: "fn=getCartList"
        ,
        timeout: timeout_value,
        error: function(rtn) {
            alert(rtn);
        },
        success: function(rtn) {
            $("#cart_list").html(rtn);
        }
    });
}

function getCartList1() {
    $.ajax({
        url: '../../ajax/ajax.aspx?',
        type: 'POST',
        data: "fn=getCartList1"
        ,
        timeout: timeout_value,
        error: function(rtn) {
            alert(rtn);
        },
        success: function(rtn) {
            $("#cart_list").html(rtn);
        }
    });
}

function tot_check() {
    var tot = $name("top_tot");
    var item = $name("chk_item");

    for (i = 0; i < item.length; i++) {
        if (tot[0].checked) {
            item[i].checked = true;
        }
        else {
            item[i].checked = false;
        }
    }
}

function go_order(type) {
    var f = document.form1;

    var book_scode = document.form1.BookCode;
    var Qty = document.form1.Qty;
    var RUrl = document.form1.RUrl;

    RUrl.value = location.href;

    var check = $name("chk_item");

    for (i = 0; i < check.length; i++) {
        if (type == "tot") {
            book_scode.value = book_scode.value + check[i].value.split(',')[0] + ",";
            Qty.value = Qty.value + check[i].value.split(',')[1] + ",";
        }
        else {
            if (check[i].checked) {
                book_scode.value = book_scode.value + check[i].value.split(',')[0] + ",";
                Qty.value = Qty.value + check[i].value.split(',')[1] + ",";
            }
        }
    }

    if (book_scode.value == "") {
        alert("항목을 선택하세요.");
        return;
    }

    if ($("#isLogin").val() == "True") {
        f.action = "../../SrcWeb/ORDER/ORDER.aspx";
    }
    else {
        f.action = "../../SrcWeb/MEMBER/LOGIN_ORDER.aspx";
    }
    f.method = "post";
    f.submit();
}

function returnSite(value) {

    var options = "toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes";
    WindowOpen(value, 1024, 768, "", options);
}

//board(password check)
function create_pop_password(type) {

    var callback_function = function() { }

    var html = "<div id='zipcode_box'>";
    html += "<div class='check_box_s'>";
    html += "<div class='float_zipcode'>";
    html += "<div class='floatL_code'>";
    html += "비밀번호 확인";
    html += "</div>";
    html += "<div class='floatR_code'>";
    html += "<a href='javascript:$id(\"jqi_state0_button닫기\").click();'>";
    html += "<img src='../../images/member/pop_closebtn.gif' alt='' /></a>";
    html += "</div></div>";
    html += "<div class='check_box_gray'>";
    html += "<input type='password' name='user_password' id='user_password' style='width: 150px; ime-mode: disabled' onkeypress='if(event.keyCode==13){other_password(" + '"' + type + '"' + ")}'/>";
    html += "<a href='javascript:other_password(" + '"' + type + '"' + ")'><img src='../../images/member/btn_pop_ok.gif' alt='' align='absmiddle' style='padding: 0 0 0 5px' /></a>";
    html += "</div></div></div>";
        
    var popup = $.prompt(html, {
        submit: callback_function,
        buttons: { "닫기": true }
    }).find("#jqi").css("width", "250px");

    chagne_popup_location(popup);

    $("#user_password").focus();

}

function other_password(type) {
    var user_password = $("#user_password").val();
    var no = $("#Hidden_NO").val();
    var url= $("#Hidden_URL").val();

    $.ajax({
        url: '../../ajax/ajax.aspx',
        type: 'POST',
        data: "fn=Check_password" + "&user_password=" + user_password + "&no=" + no,
        timeout: timeout_value,
        error: function(e) {
            unblock()
            alert(e);
        },
        success: function(rtn) {
            if (rtn == "SUCCESS") {
                if (type == "modify") {
                    $id("jqi_state0_button닫기").click();
                    $("#hbtn_modify").click();
                }
                else if (type == "delete") {
                    $id("jqi_state0_button닫기").click();
                    $("#hbtn_delete").click();
                }
                else if (type == "view") {
                    $id("jqi_state0_button닫기").click();
                    go_url(no, url);
                }

            }
            else {
                alert("패스워드가 일치하지 않습니다.");
                SetFocusControl("user_password");
            }
        }
    });
}

function open_popup(width, height, title) {
    var url = "popup.aspx";
    var wdProsecutor;
    var Found = false
    var start, end
    var i = 0
    var noticeCookie = "";
    var name;
    name = "NewtonPopup";

    while (i <= document.cookie.length) {
        start = i
        end = start + name.length

        if (document.cookie.substring(start, end) == name) {
            Found = true
            break
        }
        i++
    }

    if (Found == true) {
        start = end + 1
        end = document.cookie.indexOf(";", start)
        if (end < start)
            end = document.cookie.length
        noticeCookie = document.cookie.substring(start, end)
    }
    if (noticeCookie != "no")
        WindowOpen(url, width, height, "MainPOPUP");
}

function closeWin() {
    if (document.form1.notice.checked)  // 폼네임 cnjform 은 동일해야 합니다.
        setCookie("NewtonPopup", "no", 1);   // 위에서 지정한 쿠키네임과 일치 해야 합니다.
    top.close();
}
