﻿function PagingLoad(element_id, url) {
       
        $.get(url, function(data, textStatus) {
        $('#' + element_id).replaceWith(data);
//         $('#ajaxBox').hide();
        });
       
}

function get_formInstance() {
    var form = document.createElement("form");
    form.method = "POST";
    document.body.appendChild(form);
    return form;
}


function GoAllcart(id) {

    var value = "";
    var isItem = false;
    var form = document.form1;
    var cnt = 0;
    var adult_flag = true;
    var flag = false;
    
    $('#' + id).find(":checkbox").each(function() {
        if (this.checked == true) {           
            cnt = cnt + 1; 
        }
    });
    
    $('#' + id).find(":checkbox").each(function() {
        if (this.checked == true) {
            cnt = cnt - 1; 
            if (cnt == 0)
            value += eval("('" + this.value + "')");
            else
            value += eval("('" + this.value + "')") + ",";            
            isItem = true;           
        }
    });

    $('#' + id).find(":checkbox").each(function() {
        if (this.checked == true) {

            if (($(this).attr("dgree") == "19" || $(this).attr("dgree") == "18") && !check_login()) //로긴안하고
            {
                if (confirm("연19세이상회원만구입가능한상품입니다.\n로그인을하시겠습니까?")) {

                    var backUrl = escape(parent.document.URL);
                    location.href = "/Customer/Adult_Login.aspx?ReturnUrl=" + backUrl;
                    flag = false;
                    adult_flag = false;
                  

                } else {
                    flag = false;
                    adult_flag = false;

                }
            } else if (($(this).attr("dgree") == "19" || $(this).attr("dgree") == "18") && check_login()) {
                if (parseInt(getCookie("age_flag")) >= 18) {
                    flag = true;
                } else {
                    alert("연19세이상회원만구입가능한상품입니다.");
                    flag = false;
                    adult_flag = false;
                  
                }
            } else {
                adult_flag = true;
            }

        }
    });

    if (adult_flag) {
        if (isItem) {
            form.__VIEWSTATE.disabled = true;
            form.action = "/Order/AddToShoppingCart.aspx?goods_id=" + value;
            form.submit();
        }
        else {
            alert("장바구니에 담을 상품을 선택하세요.");
        }
    }

}


function GoAllCustody(id) {

    var value = "";
    var isItem = false;
    var form = document.form1; 
    var cnt =0;
    $('#' + id).find(":checkbox").each(function() {
        if (this.checked == true) {           
            cnt = cnt + 1; 
        }
    });
    
    $('#' + id).find(":checkbox").each(function() {
        if (this.checked == true) {
            cnt = cnt - 1; 
            if (cnt == 0)
            value += eval("('" + this.value + "')");
            else
            value += eval("('" + this.value + "')") + ",";            
            isItem = true;           
        }
    });        
       
    if (isItem) {       
     var arr;
     pop = window.open('','cc','width=500,height=390,menubar=no,resizable=no,statusbar=no,scrollbars=no');
     form.__VIEWSTATE.disabled = true;
     form.action = "/Customer/MyLibro/POP_CustodyAdd.aspx?goods_id="+value;
     form.target = "cc";
     form.submit();          
    }
    else {
        alert("보관함에 담을 상품을 선택하세요");
        return; 
    }

}



function cnt_up() {
    var old_qty = parseInt($('#ORD_CNT').val());
    var BonusTxt = $('#hd_BonusCnt').val();
    var Mall_id = $('#hd_Mall_id').val();
    var Libro_Code = $('#hd_Goods_Libro_Code').val();

    if (Mall_id == "5" && (BonusTxt != null && BonusTxt != "") && old_qty > 1) {
        alert("부록있는 잡지는 2권초과 주문할수 없습니다.");
        $('#ORD_CNT').focus();        
        $('#ORD_CNT').select();
    } else if (Libro_Code.substring(0, 3) == "131" && old_qty > 1) {
        alert("대학교제는 2권초과 주문할수 없습니다.");
        $('#ORD_CNT').focus();
        
        $('#ORD_CNT').select();        
    }
     else {
        old_qty = old_qty + 1;
        $('#ORD_CNT').val(old_qty);
    }
    return;
}


function cnt_down() {
    var old_qty = parseInt($('#ORD_CNT').val());

    if (old_qty>1)
    {
    old_qty = old_qty-1;
    $('#ORD_CNT').val(old_qty);
    }else{
     alert("1개 이하로는 주문할 수 없습니다.");
    }
        return;
    
}


function checkBoxAll(id, checkObj) {
    $('#' + id).find(":checkbox").each(function() {
        if (!this.disabled)
        this.checked = checkObj.checked;

    });

}




function get_obj_x(obj) {
    return $(obj).offset().left + $(obj).width() / 2;
}

function get_obj_y(obj) {
    return $(obj).offset().top + $(obj).height();
}

function set_layer_xy(obj, x, y) {
    $(obj).css("top", y);
    $(obj).css("left", x - $(obj).width() / 2);
}


function OpenlayerInfo(layerId, obj) {

    if ($('#' + layerId).length == 0) {
        var layer = document.createElement("div");
        document.body.appendChild(layer);
        $(layer).css("position", "absolute");
        $(layer).hide();

        var x, y;

        x = get_obj_x(obj);
        y = get_obj_y(obj);

        $(layer).load('/Product/Detail_2010/PopUp/Layer_Info.htm #' + layerId, function() {
        set_layer_xy(this, x + 15, y - 20);
            $(this).show();
        });
        
    }

}



function ReaderslayerInfo(layerId, obj, username, grade,gisu) {
    var str_gisu = gisu;
    if (str_gisu == null || str_gisu == "") {
        str_gisu = "0";
    }
     if ($('#' + layerId).length == 0) {
     var layer = document.createElement("div");
     document.body.appendChild(layer);
     $(layer).css("position", "absolute");
     $(layer).hide();

    var x, y;

     x = get_obj_x(obj);
     y = get_obj_y(obj);

    $(layer).load('/Product/Detail_2010/PopUp/Layer_Info.htm #' + layerId, function() {
    set_layer_xy(this, x + 10, y - 20);
         $("#username", this).html(username);
         $("#gisu", this).html(str_gisu);         
         var gradetxt ="";         
         if (grade=="0")
         {
            gradetxt ="일반회원";
         }else if(grade=="1")
         {
            gradetxt ="실버회원";
         }else if(grade=="2")
         {
            gradetxt ="골드회원";
         }else if(grade=="3")
         {
            gradetxt ="VIP회원";
         }else if(grade=="5")
         {
            gradetxt ="플래티늄 회원";
         }else
         {
            gradetxt ="일반회원";
         }
         
         $("#grade", this).html(gradetxt);    
         
         if (grade!="0")
         {
            var gradetxt1= "";
            if(grade=="1")
            {
               gradetxt1 = "<li><span class='silver'>실버 회원</span>혜택(구매시) <br>추가 적립금 <strong>1%</strong>을 <br>드립니다.</li>";
            }else if(grade=="2")
            {
               gradetxt1 ="<li><span class='gold'>골드 회원</span>혜택(구매시) <br>추가 적립금 <strong>2%</strong>와 <strong>1000원 할인쿠폰</strong>을 <br>드립니다.</li>";
            }else if(grade=="3")
            {
               gradetxt1 ="<li><span class='vip'>VIP 회원</span>혜택(구매시) <br>추가 적립금 <strong>3%</strong>와 <strong>2000원 할인쿠폰</strong>을 <br>드립니다.</li>";
            }else if(grade=="5")
            {
               gradetxt1 ="<li><span class='platinum'>플래티늄 회원</span>혜택(구매시) <br>추가 적립금 <strong>5%</strong>와 <strong>3000원 할인쿠폰</strong>을 <br>드립니다.</li>";
            }else
            {
               gradetxt1 = "<li><span class='silver'>실버 회원</span>혜택(구매시) <br>추가 적립금 <strong>1%</strong>을 <br>드립니다.</li>";
            }
            $("#Readerstxt", this).html(gradetxt1);
        }
        var d = new Date();

        $("#Month", this).html(d.getMonth()+1); 
         
         $(this).show();
    });

    }
}


function BarcodeLayer(layerId, obj, isbn, barcode) {

     if ($('#' + layerId).length == 0) {
     var layer = document.createElement("div");
     document.body.appendChild(layer);
     $(layer).css("position", "absolute");
     $(layer).hide();

    var x, y;

     x = get_obj_x(obj);
     y = get_obj_y(obj);

    $(layer).load('/Product/Detail_2010/PopUp/Layer_Info.htm #' + layerId, function() {
         set_layer_xy(this, x+15, y-20);
         $("#isbn", this).html(isbn);
         $("#barcode", this).html(barcode);
         
         if (isbn != null && barcode != null)
         {
             //$("#barcodetxt", this).html("이 상품은 ISBN이 2개가 존재하는 상품입니다. (2007년 이후 출간물의 ISBN이 10자리에서 13자리로 변경됨)");
             $("#barcodetxt", this).html("2007년 이후 출간물의 ISBN이 10자리에서 13자리로 변경되었습니다.");        
         }
         $(this).show();
    });

    }
}

function CatLayer(layerId, obj, isbn, barcode) {

    if ($('#' + layerId).length == 0) {
        var layer = document.createElement("div");
        document.body.appendChild(layer);
        $(layer).css("position", "absolute");
        $(layer).hide();

        var x, y;

        x = get_obj_x(obj);
        y = get_obj_y(obj);        
        $(layer).load('/Product/Detail_2010/PopUp/Layer_Info.htm #' + layerId, function() {
        set_layer_xy(this, x + 15, y - 20);
            $("#cat", this).html(isbn);
            $("#barcode", this).html(barcode);

            $(this).show();
        });

    }
}


function DeleveryLayer(layerId, obj,strtxt) {

     if ($('#' + layerId).length == 0) {
     var layer = document.createElement("div");
     document.body.appendChild(layer);
     $(layer).css("position", "absolute");
     $(layer).hide();

    var x, y;

     x = get_obj_x(obj);
     y = get_obj_y(obj);
    
    var txt = strtxt.split("|");
    
    $(layer).load('/Product/Detail_2010/PopUp/Layer_Info.htm #' + layerId, function() {
    set_layer_xy(this, x + 15, y - 20);
         $("#Ready", this).html(txt[2]);
         $("#ProductOut", this).html(txt[3]);
         $("#DeleveryComplete", this).html(txt[4]);         
         $(this).show();
    });

    }
}

function Get_X_Size(x, PanType) {
    var Return_X = Math.round(x / 2);
    if (Return_X > 148)
        Return_X = 168;
     
    return Return_X;
}

function Get_Y_Size(y, PanType) {
    var Return_Y = Math.round(y / 2);
    if (Return_Y > 210)
        Return_Y = 230;
    return Return_Y;
}

function Get_PanX_Size(PanType) {
    var Return_X = 0;
    
   
    if (PanType.indexOf("B5") > -1) {
        Return_X = 182;
    }
    if (PanType.indexOf("A5") > -1) {
        Return_X = 148;
    }
    if (PanType.indexOf("B6") > -1) {
        Return_X = 128;
    }
    if (PanType.indexOf("A3") > -1) {
        Return_X = 297;
    }
    if (PanType.indexOf("A6") > -1) {
        Return_X = 105;
    }
    if (PanType.indexOf("B4") > -1) {
        Return_X = 257;
    }
    if (PanType.indexOf("B7") > -1) {
        Return_X = 91;
    }
    if (PanType.indexOf("A4") > -1) {
        Return_X = 210;
    }
    if (PanType.indexOf("A5신") > -1) {
        Return_X = 152;
    }
    return Return_X;
}

function Get_PanY_Size(PanType) {
    var Return_Y = 0;
    
    if (PanType.indexOf("B5") > -1) {
        Return_Y = 257;
    }
    if (PanType.indexOf("A5") > -1) {
        Return_Y = 210;
    }
    if (PanType.indexOf("B6") > -1) {
        Return_Y = 182;
    }
    if (PanType.indexOf("A3") > -1) {
        Return_Y = 420;
    }
    if (PanType.indexOf("A6") > -1) {
        Return_Y = 148;
    }
    if (PanType.indexOf("B4") > -1) {
        Return_Y = 364;
    }
    if (PanType.indexOf("B7") > -1) {
        Return_Y = 128;
    }
    if (PanType.indexOf("A4") > -1) {
        Return_Y = 297;
    }
    if (PanType.indexOf("A5신") > -1) {
        Return_Y = 225;
    }
    return Return_Y;
}



function OpenShapInfo(layerId, obj,shapWidth,shapheight,PanType) {

     if ($('#' + layerId).length == 0) {
     var layer = document.createElement("div");
     document.body.appendChild(layer);
     $(layer).css("position", "absolute");
     $(layer).hide();

    var x, y;

     x = get_obj_x(obj);
     y = get_obj_y(obj);
    
    var sizeX, sizeY;

    if (shapWidth != null && shapWidth != "") {
        sizeXi = Math.round(shapWidth);
        sizeYi = Math.round(shapheight);

        sizeX = Get_X_Size(sizeXi, PanType);
        sizeY = Get_Y_Size(sizeYi, PanType);

    } else {
        sizeXi = Get_PanX_Size(PanType);
        sizeYi = Get_PanY_Size(PanType);        
        sizeX = Math.round(Get_PanX_Size(PanType)/2);
        sizeY = Math.round(Get_PanY_Size(PanType)/2);
        
    }




    $(layer).load('/Product/Detail_2010/PopUp/Layer_Info.htm #' + layerId, function() {
        set_layer_xy(this, x + 40, y - 25);
        if (sizeX == 168 && sizeY == 230) {
            $("#area_book_size", this).html("<div class='area_book' id='area_book_size' style='width:" + sizeX + "px; height:" + sizeY + "px;'></div>");
            $("#textsize", this).html("<p class='size' id='textsize'><strong class='green'>" + sizeXi + "x" + sizeYi + "mm</strong><br/><strong>! A3</strong>보다 크거나 작을 수 있습니다. </p>");
        } else {
            $("#area_book_size", this).html("<div class='area_book' id='area_book_size' style='width:" + sizeX + "px; height:" + sizeY + "px;'></div>");
            if (shapWidth != null && shapWidth != "") {
                $("#textsize", this).html("<p class='size' id='textsize'><strong class='green'>" + sizeXi + "x" + sizeYi + "mm</strong></p>");
            } else {
                if (PanType.indexOf("변형") > -1) {
                    $("#textsize", this).html("<p class='size' id='textsize'><strong class='green'>" + PanType + "</strong></br><strong>! " + PanType.replace("변형", "") + "</strong>보다 크거나 작을 수 있습니다.</p>");
                } else {
                    $("#textsize", this).html("<p class='size' id='textsize'><strong class='green'>" + sizeXi + "x" + sizeYi + "mm</strong></p>");
                }
            }
        }

        $(this).show();
    });

    }
}



function PeaCntLayer(layerId, obj,s_date, e_date) {

     if ($('#' + layerId).length == 0) {
     var layer = document.createElement("div");
     document.body.appendChild(layer);
     $(layer).css("position", "absolute");
     $(layer).hide();

    var x, y;

     x = get_obj_x(obj);
     y = get_obj_y(obj);

    $(layer).load('/Product/Detail_2010/PopUp/Layer_Info.htm #' + layerId, function() {
    set_layer_xy(this, x + 15, y - 20);                       
         $("#txt_date", this).html(s_date + "~" +e_date);                 
         $(this).show();
    });

    }
}






function AddressChangeLayer(layerId, obj) {
  
  if ($('#' + layerId).length == 0) {
     
     var layer = document.createElement("div");
     document.body.appendChild(layer);
     $(layer).css("position", "absolute");
     $(layer).hide();
    
    var x, y;

     x = get_obj_x(obj);
     y = get_obj_y(obj);    
    $(layer).load('/Product/Detail_2010/PopUp/AddressSearch.aspx' , function(data) {
    set_layer_xy(this, x + 15, y - 20);
//         $("#BookInfo").html( $("#BingImgDiv").html());
         $(this).show();
    });

    }
} 



function CardInfoLayer(layerId, obj,InfoName,infoUrl) {
  
  if ($('#' + layerId).length == 0) {
     
     var layer = document.createElement("div");
     document.body.appendChild(layer);
     $(layer).css("position", "absolute");
     $(layer).hide();
    
    var x, y;
     
     x = get_obj_x(obj);
     y = get_obj_y(obj);    
     $(layer).load('/Product/Detail_2010/PopUp/Layer_Info.htm #' + layerId, function() {
     set_layer_xy(this, x + 28, y - 25);
     var SplitName = InfoName.split("|");
     var SplitUrl = infoUrl.split("|");
     var strtxt ="";   
     for(var i=0;i<SplitName.length;i++)
     {
        if (SplitName[i].indexOf("롯데") > -1)
        {
            strtxt = "<a href='" + SplitUrl[i] +"'><img src='http://image.libro.co.kr/NewProdut/card_01.jpg' alt='카드' border='0'></a>";
        }
        if (SplitName[i].indexOf("올앳") > -1)
        {
            strtxt += "<a href='" + SplitUrl[i] +"'><img src='http://image.libro.co.kr/NewProdut/card_02.jpg' alt='카드' border='0'></a>";
        }
        if (SplitName[i].indexOf("삼성") > -1)
        {
            strtxt += "<a href='" + SplitUrl[i] +"'><img src='http://image.libro.co.kr/NewProdut/card_03.jpg' alt='카드' border='0'></a>";
        }
        if (SplitName[i].indexOf("KB") > -1)
        {
            strtxt += "<a href='" + SplitUrl[i] +"'><img src='http://image.libro.co.kr/NewProdut/card_04.jpg' alt='카드' border='0'></a>";
        }
        if (SplitName[i].indexOf("우리") > -1)
        {
            strtxt += "<a href='" + SplitUrl[i] +"'><img src='http://image.libro.co.kr/NewProdut/card_05.jpg' alt='카드' border='0'></a>";
        }
        if (SplitName[i].indexOf("에듀") > -1)
        {
            strtxt += "<a href='" + SplitUrl[i] +"'><img src='http://image.libro.co.kr/NewProdut/card_06.jpg' alt='카드' border='0'></a>";
        }

     }
        $("#CardImg").html(strtxt);
         $(this).show();
    });

    }
}



function Close_Layer(id) {    
    $('#' + id).parent().remove();
    
}


//클립보드 복사
function clip() {
    var url = parent.document.URL;    
    window.clipboardData.setData("Text", url);
    alert("URL이 클립보드에 복사되었습니다. CTRL+V하시면 URL이 입력됩니다");
}

//로그인 체크
function check_login() {
    
    var logYn = false;
    try {
        logYn = ($("#LoginYnH").val() == "No") ? false : true;        
    }
    catch (Exception) {
    }
    return logYn;
}

//로그인 체크
function check_login_Msg() {
    
   
    var logYn = false;
    try {
        logYn = ($("#LoginYnH").val() == "No") ? false : true;     
        
        if (!logYn)
        {            
            alert("로그인을 해주세요.")
            var rtn = escape(parent.document.URL);
			location.href = "/Customer/Regist_Login.aspx?rtn=" + rtn;
            
        }    
    }
    catch (Exception) {
    }
    return logYn;
}

function GoCart(f)
{
 var form = document.form1;
 var flag = false;
 var post_case = "";
 var old_qty = parseInt($('#ORD_CNT').val());
 var adult_flag = true;
  var flag = false;
 var degree = $('#hd_Goods_Degree').val();
 var BonusTxt = $('#hd_BonusCnt').val();
 var Mall_id = $('#hd_Mall_id').val();
 var Libro_Code = $('#hd_Goods_Libro_Code').val();


 if ((degree == "19" || degree == "18") && !check_login()) //로긴안하고
 {
     if (confirm("연19세이상회원만구입가능한상품입니다.\n로그인을하시겠습니까?")) {

         var backUrl = escape(parent.document.URL);
         location.href = "/Customer/Adult_Login.aspx?ReturnUrl=" + backUrl;
         flag = false;
         adult_flag = false;
         
     }else {
         flag = false;
         adult_flag = false;
         
     }
 } else if ((degree == "19" || degree == "18") && check_login()) {

    if (parseInt(getCookie("age_flag")) >= 18) {
         flag = true;
     } else {
         alert("연19세이상회원만구입가능한상품입니다.");
         flag = false;
         adult_flag = false;

     }
}else {
    adult_flag = true;
}

if (Mall_id == "5" && (BonusTxt != null && BonusTxt != "") && old_qty > 1) {
    alert("부록있는 잡지는 2권초과 주문할수 없습니다.");
    $('#ORD_CNT').focus();    
    $('#ORD_CNT').select();    
    flag = false;
    adult_flag = false;
}

 if (Libro_Code.substring(0, 3) == "131" && old_qty > 1) {
    alert("대학교제는 2권초과 주문할수 없습니다.");
    $('#ORD_CNT').focus();   
    $('#ORD_CNT').select();    
    flag = false;
    adult_flag = false;
} 

if (adult_flag) {
    if (old_qty < 1) {
        old_qty = 1;
    }
    f = f + '|0|0|' + old_qty;
    var url = "/Order/AddToShoppingCart.aspx?goods_id=" + f;

    if (document.forms[0].posterCase != null) {
        if (document.forms[0].posterCase[1].checked)
            url = url + "&post_case=1";
    }
    document.location.replace(url);
}
}

function GoCustody(f)
{
 var form = document.form1;
 var flag = false;
 
 window.open('/Customer/MyLibro/POP_CustodyAdd.aspx?goods_id=' + f,'cc','width=500,height=390,menubar=no,resizable=no,statusbar=no,scrollbars=no');
} 


function openRecom(goods_id, mallId) {
 window.open('/Product/Common/RecommendMail.aspx?goods_id=' + goods_id + "&mall=" + mallId,'winLarge','width=625, height=740 status=no');
}
function questionGoods(goods_id) {
 location.href = "/Information/CustomerService.aspx?goods_id="+goods_id;
}
function PTA(goods_id, mall_id) {
 window.open('/Product/Common/ProductTakeAway.aspx?goods_id=' + goods_id+'&mall_id='+mall_id,'cc','width=530,height=300,menubar=no,resizable=no,status=no,scrollbars=no');
} 

function PopNewPub(code,type){
        window.open('/Customer/POP_NewPub.aspx?type='+type+"&code="+code,'POPNEWPUB','width=450,height=600,menubar=no,resizable=no,statusbar=no,scrollbars=no');        	    
}


function setMCookie(name, value, expires) { 
		if(expires == 0) {
			document.cookie = name + "=" + escape(value) + "; PATH=/"; 
		} else { 
			var dt = new Date(); 
			dt.setDate(dt.getDate() + expires); 
			document.cookie = name + "=" + escape(value) + "; PATH=/; EXPIRES=" + dt.toGMTString() + ";"; 
		}
	} 	

function getMCookie(name) { 		
	var ne    = name + "=";
	var x     = 0; 
	var cklen = document.cookie.length;		
	while (x <= cklen) { 
		var y = (x+ne.length); 
		if (document.cookie.substring(x, y) == ne) {  
			var end = document.cookie.indexOf(";",y);
			if(end == -1)end = document.cookie.length;
			return unescape(document.cookie.substring(y,end));
		} 
		x = document.cookie.indexOf(" ", x) + 1; 
		if (x == 0) break; 
	} 
	return "" ;
}

function close_div(id) {
    $('#' + id).remove();
}

function couponDown(goods_id) {
	window.open('/Product/Common/CouponProcess.aspx?goods_id=' + goods_id, 'winLarge','top=100 left=100 width=656 height=600');
}



function LengthCheck(txt, limitLength, countId)
{
 var str = $(txt).val();
 var strLength = 0;
 var result = "";
 for (i = 0; i < str.length; i++)
 {
 var code = str.charCodeAt(i)
 var ch = str.substr(i,1).toUpperCase()

 code = parseInt(code)

 if ((ch < "0" || ch > "9") && (ch < "A" || ch > "Z") && ((code > 255) || (code < 0)))
    strLength = strLength + 2;
 else
    strLength = strLength + 1;

 if(strLength > limitLength){
    alert(limitLength + ' 를 초과하였습니다.');
    $(txt).val(result);
 return;
 }
 else result += str.charAt(i);
 }
    $(countId).text(strLength);
}


function fn_div_Toggle(divId) {
    
    var id = "#" + divId;    
    $(id).toggle();
} 



function fn_contents(obj, contents_list_id) {

 $('.more_contents', $('#' + contents_list_id)).toggle(); 
 $('.origin_book_open').toggle();

} 

function fn_relationToggle(obj, contents_list_id,mall) {
 $('.rel_contents', $('#' + contents_list_id)).toggle();
 $('.rel_'+ mall +'_open').toggle();
} 

function fn_SubjectToggle(obj, contents_list_id,mall) {
 $('.Subject_contents', $('#' + contents_list_id)).toggle();
 $('.sub_'+ mall +'_open').toggle();
} 


function AfertCloseDivLoin(obj)
{
    if (!check_login())
    {
        Close_Layer(obj);
        var rtn = escape(parent.document.URL);
        location.href = "/Customer/Regist_Login.aspx?rtn=" + rtn;
    }    
}


function GoLinktab(Tab)
{
   
 
   var Goods_id = $('#hd_Goods_id').val();
   var Mall_Id = $('#hd_Mall_id').val();
   var Cat_code = $('#hd_Goods_Libro_Code').val();
   var Goods_Name = $('#hd_Goods_Name').val();
   var Goods_publisher = $('#hd_Goods_Publisher').val();
   
   
     if (Tab=="Tab1")//  기본정보
      {     
      
             $("#tab_board").hide();
             $(".content_board").hide();
             $(".rightitem").show();  
            
             $(".content_simple").show();
             
                
             if (Mall_Id=="7")
             {
                 $(".TotMusic").show();                 
                 PagingLoad("music_grouping","/Product/Detail_2010/ContentControl/Music_Grouping.aspx?Goods_Id=" +Goods_id + "&Mall_id=" +Mall_Id +"&Goods_Name=" + escape(Goods_Name) +"&Goods_Publisher=" + Goods_publisher);                                                
                 PagingLoad("music_info","/Product/Detail_2010/ContentControl/Music_Info.aspx?Goods_Id=" + Goods_id + "&Mall_id=" +Mall_Id + "&LIBRO_CODE=" +Cat_code);           
                 PagingLoad("music_list","/Product/Detail_2010/ContentControl/Music_List.aspx?Goods_Id="+ Goods_id + "&Mall_id=" +Mall_Id);   
                 
             }else if (Mall_Id=="8")
             {
                 $(".TotDVD").show();            
                 PagingLoad("dvd_grouping","/Product/Detail_2010/ContentControl/DVD_Grouping.aspx.asp?Goods_Id=" +Goods_id + "&Mall_id=" +Mall_Id +"&Goods_Name=" + escape(Goods_Name) +"&Goods_Publisher=" + Goods_publisher);                                                
                 PagingLoad("dvd_info","/Product/Detail_2010/ContentControl/Dvd_Info.aspx?Goods_Id=" + Goods_id + "&Mall_id=" +Mall_Id + "&LIBRO_CODE=" +Cat_code);
                 PagingLoad("dvd_story", "/Product/Detail_2010/ContentControl/Dvd_story.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_Id);
                 PagingLoad("dvd_notice", "/Product/Detail_2010/ContentControl/Goods_NoticeInfo.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_Id);                                                                         
                
             } else {
                 $(".TotBook").show();         
                 PagingLoad("series_book","/Product/Detail_2010/ContentControl/Goods_Series.aspx?Goods_Id=" +Goods_id + "&Mall_id=" +Mall_Id +"&Goods_Name=" + escape(Goods_Name) +"&Goods_Publisher=" + Goods_publisher);
                 PagingLoad("book_grouping", "/Product/Detail_2010/ContentControl/Books_Grouping.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_Id + "&LIBRO_CODE=" + Cat_code);
                 PagingLoad("thistime_story", "/Product/Detail_2010/ContentControl/Goods_ComicStory.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_Id);           
                 PagingLoad("book_info","/Product/Detail_2010/ContentControl/Goods_Intro.aspx?Goods_Id="+ Goods_id + "&Mall_id=" +Mall_Id);
                 PagingLoad("book_story", "/Product/Detail_2010/ContentControl/Goods_book_story.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_Id);
                 PagingLoad("story_image", "/Product/Detail_2010/ContentControl/Goods_ComicImg.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_Id);
                 PagingLoad("writer_info", "/Product/Detail_2010/ContentControl/Goods_AuthorList.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_Id);                 
                 PagingLoad("writer_say", "/Product/Detail_2010/ContentControl/Goods_AuthorWord.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_Id);
                 PagingLoad("recommend_text", "/Product/Detail_2010/ContentControl/Goods_Recommend_Txt.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_Id);
                 PagingLoad("book_word", "/Product/Detail_2010/ContentControl/Goods_OneContents.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_Id);
                 PagingLoad("together_book", "/Product/Detail_2010/ContentControl/Goods_Together_Read.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_Id);
                 PagingLoad("theme_list", "/Product/Detail_2010/ContentControl/Goods_TemaList.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_Id);
                 PagingLoad("publish_review", "/Product/Detail_2010/ContentControl/Goods_Publish_review.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_Id);
                 PagingLoad("this_other", "/Product/Detail_2010/ContentControl/Goods_Together_Sale.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_Id);
                 PagingLoad("bonus_book", "/Product/Detail_2010/ContentControl/Goods_Bonus.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_Id);                
             }                 
             PagingLoad("bookers","/Product/Detail_2010/ContentControl/Goods_WebZine.aspx?Goods_Id="+ Goods_id );  
             PagingLoad("one_review","/Product/Detail_2010/ContentControl/Goods_OneReview.aspx?Goods_Id="+ Goods_id + "&Mall_id=" +Mall_Id);                                                     
             PagingLoad("reader_review","/Product/Detail_2010/ContentControl/Goods_Review.aspx?Goods_Id="+ Goods_id + "&Mall_id=" +Mall_Id);
         }         
      if (Tab=="Tab2")//  우수리뷰
      {
      
          $(".rightitem").hide();
          $(".content_simple").hide();
          $(".content_board").show();
          $("#tab_board").show();
          $("#DetailView").show();
          PagingLoad("tab_board", "/Product/Detail_2010/AddControl/Goods_Tab_Link.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_Id + "&Tab=Tab2");        
          $('#DetailView').load("/Product/Detail_2010/ContentControl/Goods_Detail_Excellent.aspx?Goods_Id="+ Goods_id + "&Mall_id=" +Mall_Id, function() {
          $('#DetailView').show("slow", function() {
             MoveLocation('tab_board');
          });
        });     
        
      }
      if (Tab=="Tab3")//  독자리뷰
      {
          $(".rightitem").hide();
          $(".content_simple").hide();
          $(".content_board").show();
          $("#tab_board").show();
          $("#DetailView").show();   
           PagingLoad("tab_board","/Product/Detail_2010/AddControl/Goods_Tab_Link.aspx?Goods_Id="+ Goods_id + "&Mall_id=" +Mall_Id+ "&Tab=Tab3");        
          $('#DetailView').load("/Product/Detail_2010/ContentControl/Goods_Detail_Review.aspx?Goods_Id="+ Goods_id + "&Mall_id=" +Mall_Id, function() {
          $('#DetailView').show("slow", function() {
             MoveLocation('tab_board');
          });
        });       
      }
      if (Tab=="Tab4")//  한줄리뷰
      {        
        $(".rightitem").hide();
        $(".content_simple").hide();       
        $(".content_board").show();         
        $("#tab_board").show(); 
        $("#DetailView").show();             
        PagingLoad("tab_board","/Product/Detail_2010/AddControl/Goods_Tab_Link.aspx?Goods_Id="+ Goods_id + "&Mall_id=" +Mall_Id+ "&Tab=Tab4");        
        $('#DetailView').load("/Product/Detail_2010/ContentControl/Goods_Detail_OneReview.aspx?Goods_Id="+ Goods_id + "&Mall_id=" +Mall_Id, function() {
        $('#DetailView').show("slow", function() {
            MoveLocation('tab_board');
         });
       });
       
      }
      if (Tab=="Tab5")//  책속 한문장
      {
        $(".rightitem").hide();
        $(".content_simple").hide();
        $(".content_board").show();             
        $("#tab_board").show();   
        $("#DetailView").show();           
        PagingLoad("tab_board","/Product/Detail_2010/AddControl/Goods_Tab_Link.aspx?Goods_Id="+ Goods_id + "&Mall_id=" +Mall_Id+"&Tab=Tab5"); 
        
        $('#DetailView').load("/Product/Detail_2010/ContentControl/Goods_Detail_OneContents.aspx?Goods_Id="+ Goods_id + "&Mall_id=" +Mall_Id, function() {
        $('#DetailView').show("slow", function() {
            MoveLocation('tab_board');
         });
       });


   }
   
      if (Tab=="Tab6") //  테마리스트
      {
        $(".rightitem").hide();
        $(".content_simple").hide();
        $(".content_board").show();               
        $("#tab_board").show();  
        $("#DetailView").show();  
                   
        PagingLoad("tab_board","/Product/Detail_2010/AddControl/Goods_Tab_Link.aspx?Goods_Id="+ Goods_id + "&Mall_id=" +Mall_Id+"&Tab=Tab6");

        $('#DetailView').load("/Product/Detail_2010/ContentControl/Goods_Detail_Temalist.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_Id, function() {
        $('#DetailView').show("slow", function() {
            MoveLocation('tab_board');
         });
       });
    
       
      }
}

function MoveLocation(Div) {
    Div ="#"+Div;
    s = HrefMake(location.href);
    window.location.href = s + Div;
}
function HrefMake(host) {
    var s = host.indexOf("#");
    var retunvalue;
    if (s != -1) {
        retunvalue = host.substring(0, s);
    } else {
        retunvalue = host;
    }
    return retunvalue;    
}

$(document).click(function(e) {
    if ($('#layer_user_info').length > 0) {
        $('#layer_user_info').remove();
    }
}); 



function MemInfo_Layer(TargetName, obj) {
    if ($('#layer_user_info').length == 0) {
               
        $(obj).click(function(e) {

        xpoint = e.pageX +"px";  //상단 좌표

        ypoint = e.pageY+"px"; //좌측 좌표
         
        });

        $.get('/Product/Detail_2010/PopUp/MemberInfo.aspx?Cust_id=' + TargetName, function(data) {
            element = $('<div id="layer_user_info" style="position:absolute; width:125px; height:60px; left:' + xpoint + '; top:' + ypoint + ';"></div>');
            $('body').append(element);
            element.html(data);            
        });

    }
}



var HTTP_URL = "http://www.libro.co.kr/";
var BLOG_URL = "http://blog.libro.co.kr/";


function GoBlog(cust_id){
window.open(BLOG_URL + cust_id);
}


function GoReview(cust_id){    
    window.open(HTTP_URL + "/Product/BookReviewCustList.libro?user_id=" + cust_id);
}


function win_popOutofStock(ActionName) {
    var Goods_id = $('#hd_Goods_id').val();
    var Mall_id = $('#hd_Mall_id').val();
    
    window.open('/Customer/POP_OutOfStock.aspx?goods_id=' + Goods_id + '&actionName=' + ActionName, 'deli3', 'width=480,height=475,scrollbars=no,resizable=0,status=0');
}

function ReviewWrite_pop(gubun) {
    if (check_login_Msg()) {
        var Goods_id = $('#hd_Goods_id').val();
        var Cust_id = $('#Cust_id').val();
        var Mall_id = $('#hd_Mall_id').val();
        window.open('/Product/Detail_2010/PopUp/Write_Review.aspx?Goods_id=' + Goods_id + '&Cust_id=' + Cust_id + '&Mall_id=' + Mall_id + '&Gubun=' + gubun, 'Review', 'width=830,height=720,scrollbars=no,resizable=0,status=0');
    }
} 


function WriteOneCentents(obj,Flag,Gubun)
{

   if (check_login())
    {        
          
       if ($('#popup_small').length == 0) {
             var layer = document.createElement("div");
             document.body.appendChild(layer);
             $(layer).css("position", "absolute");
             $(layer).hide();

             var x, y;

             x = get_obj_x(obj);
             y = get_obj_y(obj);
             
             var Goods_id = $('#hd_Goods_id').val();
             var Mall_Id = $('#hd_Mall_id').val();   
             var Cust_id = $('#Cust_id').val();   
             var Url = "/Product/Detail_2010/PopUp/WriteOneContents.aspx?Type=" + Flag +"&Goods_id=" + Goods_id +"&Mall_Id=" + Mall_Id +"&Cust_id=" + Cust_id +"&Gubun=" + Gubun;

             $(layer).load(Url, function() {
                 $("#Pop_Goods_Name").html( $('#hd_Goods_Name').val());
                 set_layer_xy(this, x -100, y);
                 $(this).show();
             });
         
       }
        
    }else{
         check_login_Msg();
    }  
}


function ShowTabReview(Goods_id, Mall_id, Type, ReviewAvg)
{
    PagingLoad("reader_review", "/Product/Detail_2010/ContentControl/Goods_Review.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_id + "&Type=" + Type + "&ReviewAvg=" + ReviewAvg);
}


function ShowTabReviewDetail(Goods_id, Mall_id, Type, ReviewAvg) {    
    $('#DetailView').load("/Product/Detail_2010/ContentControl/Goods_Detail_Review.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_id + "&Type=" + Type + "&ReviewAvg=" + ReviewAvg);                  
}


//주제어 검색

function search_Subject(id) {
     var value = "";
     var isCheck = false;
     $('#' + id).find(":checkbox").each(function() {
     if (this.checked == true) {
     value += this.value + " ";
     isCheck = true;
     }
     });

     if (isCheck) {
        window.open("/SearchCenter/searchResult.aspx?qkeyword=" + value);
     }
     else {
        alert("주제어를 선택하여 주시기 바랍니다.");
     }
 }


 function ReviewRecommendMine(rid, from_source, Write_Cust_id,gubun,page,goods_id) {

     var Cust_id = $("#Cust_id").val();
     if (check_login_Msg()) {
         if (Cust_id == Write_Cust_id) {
             alert("자신의 글을 추천하실 수 없습니다.");
         } else {
             ReviewRecommendUpdate(rid, from_source, gubun, page, goods_id);
         }
     }

 }

//리뷰디테일 추천
 function ReviewRecommendDetail(rid, from_source, Write_Cust_id, gubun, page, goods_id) {

     var Cust_id = $("#Cust_id").val();
     if (check_login_Msg()) {
         if (Cust_id == Write_Cust_id) {
             alert("자신의 글을 추천하실 수 없습니다.");
         } else {
            ReviewRecommendUpdateDetail(rid, from_source, gubun, page, goods_id);
         }
     }

 }

 function reloadreview(gubun) {
     var Goods_id = $('#hd_Goods_id').val();
     var Mall_Id = $('#hd_Mall_id').val();
     if (gubun == "S") {
         PagingLoad("reader_review", "/Product/Detail_2010/ContentControl/Goods_Review.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_Id);
     } else {
         $('#DetailView').load("/Product/Detail_2010/ContentControl/Goods_Detail_Review.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_Id);
     }
 }

 /* pngimg */
 function setPng24(obj) {
     obj.width = obj.height = 1;
     obj.className = obj.className.replace(/\bpng24\b/i, '');
     obj.style.filter =
    "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + obj.src + "',sizingMethod='image');"
     obj.src = '';
     return '';
 }

 function etcLayer(layerId, obj, url) {
     var imglink = "<img src='" + url + "' alt='' />";
    
     if ($('#' + layerId).length == 0) {
         var layer = document.createElement("div");
         document.body.appendChild(layer);
         $(layer).css("position", "absolute");
         $(layer).hide();

         var x, y;
         x = $(obj).offset().left;
         y = $(obj).offset().top;

      
         $(layer).load('/Product/Detail_2010/PopUp/Layer_Info.htm #' + layerId, function() {
             set_layer_xy(this, x, y);
             $("#imgurl", this).html(imglink);
             $(this).show();
         });

     }
 }


 function SaleJisuLayer() {
   
    if ($('#sale_quotient').length == 0) {
         var layer = document.createElement("div");
         document.body.appendChild(layer);
         $(layer).css("position", "absolute");
         $(layer).hide();

         var x, y;
         obj = $('#flash_info');
         x = get_obj_x(obj);
         y = get_obj_y(obj);

         $(layer).load('/Product/Detail_2010/PopUp/Layer_Info.htm #sale_quotient', function() {
             set_layer_xy(this, x - 180, y - 170);        
             $(this).show();
         });

     }
 }

 

 function MakeTemaList() {
//     location.href = "/Cafe/Theme/ThemeMk.aspx";
//     location.href.target = "_blank";
     window.open("/Cafe/Theme/ThemeMk.aspx", 'cc') 
 }

 function GoFlash(gubun, TotCount) {
     var Goods_id = $('#hd_Goods_id').val();
     var Mall_id = $('#hd_Mall_id').val();

     $.get('/Product/Detail_2010/AddControl/Flash_Best.aspx?Goods_id=' + Goods_id + "&Mall_id=" + Mall_id + "&gubun=" + gubun + "&TotCount=" + TotCount, function(data) {
         if (gubun == "B") {
             element = $('<div id="flash_detail_info" style="position:absolute; width:560px; height:220px; left:' + 500 + '; top:' + 360 + ';"></div>');
         } else {
             element = $('<div id="flash_detail_info" style="position:absolute; width:560px; height:200px; left:' + 500 + '; top:' + 420 + ';"></div>');
         }
         $('body').append(element);
         element.html(data);
     });
     
 }

 function PreImgView(goods_id, Goods_Name, Mall_id, CAT_CODE) {

     //window.open('/Product/Detail_2010/PopUp/PreImgViewer.aspx?goods_id=' + goods_id + '&Goods_Name=' + Goods_Name + '&Mall_id=' + Mall_id + '&CAT_CODE=' + CAT_CODE, '미리보기', 'width=1045,height=800,menubar=0,resizable=0,statusbar=0,scrollbars=0,resizable=0');
     window.open('/Product/Detail_2010/PopUp/PreImgViewer.aspx?goods_id=' + goods_id + '&Goods_Name=' + Goods_Name + '&Mall_id=' + Mall_id + '&CAT_CODE=' + CAT_CODE, '미리보기', 'width=1024,height=722,menubar=0,resizable=0,statusbar=0,scrollbars=0,resizable=0');
 }

 function id_show(d) {
     $('#'+d).show();
 }


 function id_hidden(d) {
     $('#' + d).hide();
 }


 function showBigImageV2(Goods_id, obj) {

     if ($('#ShowBigImgPop').length == 0) {
         var layer = document.createElement("div");
         document.body.appendChild(layer);
         $(layer).css("position", "absolute");
         $(layer).hide();

         var x;
         var y;

        
         x = $('.ImgArea').offset().left;
         y = $('.ImgArea').offset().top;
        
         $(layer).load('/Product/Detail_2010/PopUp/ShowBigImg.aspx?Goods_id=' + Goods_id, function() {
             set_layer_xy(this, x, y);           
             $(this).show();
         });

     }

   
 }


function getCookie(uName) {

 var flag = document.cookie.indexOf(uName + '=');
 if (flag != -1) {
 flag += uName.length + 1
 end = document.cookie.indexOf(';', flag)

 if (end == -1) end = document.cookie.length
 return unescape(document.cookie.substring(flag, end))
 }
}
 