﻿
/* -------------------------------------------------
 *
 *  한줄 리뷰 추천 (중복체크)
 *  1. P_GOODS_ID : 리뷰상품아이디
 *  2. P_CUST_ID  : 리뷰상품등록한 사용자아이디
 *  3. P_CUST_ID2 : 리뷰상품등록한 추천사용자 아이디
 *  4. P_MALL_ID  : 몰 아이디
 *
 *  결과 : 100 (성공) , 그이외값 실패
 *
 * ---------------------------------------------------- */
 
function SetRecomendOneReview(Mall_id,Goods_id,Cust_id1,Cust_id2,PageNumber,Flag) {

 $.ajax
        (
	        {
	            type: 'Get',
	            url: '/Product/Detail_2010/AjaxResultPage/AjaxResult.aspx',
	            data: 'Type=UPDATE&Url=ONEREVIEW&Goods_id=' + Goods_id +'&Mall_id=' + Mall_id + '&Cust_id1=' + Cust_id1 + '&Cust_id2=' + Cust_id2,
	            success: function(msg) {
	                switch (msg) {
	                    case "100":
	                        if (Flag=="S"){
	                            PagingLoad("one_review","/Product/Detail_2010/ContentControl/Goods_OneReview.aspx?Goods_Id="+Goods_id+ "&Mall_id="+Mall_id +"&PageNumber=" + PageNumber); 	                         
	                        }else{
	                        PagingLoad("DetailView", "/Product/Detail_2010/ContentControl/Goods_Detail_OneReview.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_id + "&PageNumber=" + PageNumber); 	                         
	                        }
	                        alert("추천되었습니다..");
	                        break;
	                    case "-100":	                        
	                        alert("이미 추천하신 글입니다.");
	                        break;
	                    case "-999":
	                        alert("추천을 실패하셨습니다.");
	                        break;
	                   default :
	                        alert("실패하셨습니다.");
	                    break;	                       
	                }
	            }
	        }
        );
}

/* -------------------------------------------------
 *
 *  한줄 리뷰 (중복체크 및 저장)
 *  1. P_GOODS_ID : 리뷰상품아이디
 *  2. P_MALL_ID  : 몰아이디
 *  3. P_CUST_ID  : 리뷰상품등록한 사용자아이디
 *  4. P_CONTENTS : 한줄리뷰글
 *  3. P_GRADE    : 할줄리뷰 등급
 *
 *  결과 : 100 (성공) , 그이외값 실패
 *
 * ---------------------------------------------------- */


function SetOneReviewInsert(Goods_id,Mall_id,Cust_id,txtcontent,StarCount,Flag) {

    $.ajax
        (
	        {
	            type: 'Get',
	            url: '/Product/Detail_2010/AjaxResultPage/AjaxResult.aspx',
	            data: 'Type=INSERT&Url=ONEREVIEW&Goods_id=' + Goods_id + '&Mall_id=' + Mall_id + '&Cust_id=' + Cust_id + '&Contents=' + txtcontent + '&Grade=' + StarCount,
	            success: function(msg) {
	                switch (msg) {
	                    case "100":
	                        
	                        if (Flag == "S") {
	                            PagingLoad("one_review", "/Product/Detail_2010/ContentControl/Goods_OneReview.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_id);
	                        } else {
	                        PagingLoad("DetailView", "/Product/Detail_2010/ContentControl/Goods_Detail_OneReview.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_id);
	                        }
	                        alert("저장되었습니다..");
	                        $("#txtcontent").val = "";
	                        break;
	                    case "-100":
	                        alert("한 상품의 중복입력은 금지 되었습니다..");
	                        break;
	                    case "-999":
	                        alert("실패하셨습니다.");
	                        break;
	                    default:
	                        alert("실패하셨습니다.");
	                        break;
	                }
	            }
	        }
        );
}


function SetOneReviewUpdate(Goods_id,Mall_id,Cust_id,txtcontent,StarCount,Flag) {

 $.ajax
        (
	        {
	            type: 'Get',
	            url: '/Product/Detail_2010/AjaxResultPage/AjaxResult.aspx',
	            data: 'Type=MOD&Url=ONEREVIEW&Goods_id=' + Goods_id +'&Mall_id=' + Mall_id + '&Cust_id=' + Cust_id + '&Contents=' + txtcontent+ '&Grade=' + StarCount,
	            success: function(msg) {
	                switch (msg) {
	                    case "100":
	                       if (Flag=="S")
	                        {
	                         PagingLoad("one_review","/Product/Detail_2010/ContentControl/Goods_OneReview.aspx?Goods_Id="+Goods_id+ "&Mall_id="+Mall_id); 	                         
	                         }else{
	                         PagingLoad("DetailView", "/Product/Detail_2010/ContentControl/Goods_Detail_OneReview.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_id); 	                         
	                         }
	                        alert("저장되었습니다..");
	                         $("#txtcontent").val="";
	                          $("#Review_btn_txt").html("저장하기");
	                        break;
	                    case "-100":
	                        alert("실패하셨습니다");
	                        break;
	                    case "-999":
	                        alert("실패하셨습니다.");
	                        break;
	                    default :
	                        alert("실패하셨습니다.");
	                    break;	                       
	                }
	            }
	        }
        );
}

function SetOneReviewDelete(Goods_id,Mall_id,Cust_id,txtcontent,StarCount,Flag) {

    $.ajax
        (
	        {
	            type: 'Get',
	            url: '/Product/Detail_2010/AjaxResultPage/AjaxResult.aspx',
	            data: 'Type=DEL&Url=ONEREVIEW&Goods_id=' + Goods_id + '&Mall_id=' + Mall_id + '&Cust_id=' + Cust_id + '&Contents=' + txtcontent + '&Grade=' + StarCount,
	            success: function(msg) {
	                switch (msg) {
	                    case "100":
	                        
	                        if (Flag == "S") {
	                            PagingLoad("one_review", "/Product/Detail_2010/ContentControl/Goods_OneReview.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_id);
	                        } else {
	                        PagingLoad("DetailView", "/Product/Detail_2010/ContentControl/Goods_Detail_OneReview.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_id);
	                        }
	                        alert("삭제되었습니다..");
	                        break;
	                    case "-100":
	                        alert("실패하셨습니다");
	                        break;
	                    case "-999":
	                        alert("실패하셨습니다.");
	                        break;
	                    default:
	                        alert("실패하셨습니다.");
	                        break;
	                }
	            }
	        }
        );
}

/* -------------------------------------------------
 *
 *  책 속 한 문장 (중복체크 및 저장 / 수정 / 삭제)
 *  1. P_GOODS_ID : 리뷰상품아이디
 *  2. P_MALL_ID  : 몰아이디
 *  3. P_CUST_ID  : 등록한 사용자아이디
 *  4. P_WRITER   : 등록한 사용자이름
 *  5. P_CONTENTS : 책 속 한 문장
 *  6. P_PAGE_NO  : 페이지
 *  7. P_FLAG     : 1. ADD (등록)
 *                  2. MOD (수정)
 *                  3. DEL (삭제)
 *
 *  결과 : 100 (성공) , 그이외값 실패
 *
 * ---------------------------------------------------- */

function SetInsertOneContens(Content,PageNum,Mod,Gubun) {

var Goods_id = $("#hd_Goods_id").val();
var Mall_id= $("#hd_Mall_id").val();
var Cust_id= $("#Cust_id").val();

$.ajax
        (
	        {
	            type: 'Get',
	            url: '/Product/Detail_2010/AjaxResultPage/AjaxResult.aspx',
	            data: 'Type=ADD&Url=ONECONTENTS&Goods_id=' + Goods_id + '&Mall_id=' + Mall_id + '&Cust_id=' + Cust_id + '&Contents=' + escape(Content) + '&Page_No=' + PageNum,
	            success: function(msg) {
	                switch (msg) {
	                    case "100":	                        
	                        if (Gubun == "S") {
	                            PagingLoad("book_word", "/Product/Detail_2010/ContentControl/Goods_OneContents.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_id);
	                        } else {
	                            PagingLoad("DetailView", "/Product/Detail_2010/ContentControl/Goods_Detail_OneContents.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_id);
	                        }
	                        alert("저장되었습니다..");
	                        $("#popup_small").remove();
	                        break;
	                    case "-100":
	                        alert("실패하셨습니다");
	                        break;
	                    case "-999":
	                        alert("실패하셨습니다.");
	                        break;
	                    default:
	                        alert("실패하셨습니다.");
	                        break;
	                }
	            }
	        }
        );
}

function SetUpdateOneContens(Content,PageNum,Mod,Gubun) {

var Goods_id = $("#hd_Goods_id").val();
var Mall_id= $("#hd_Mall_id").val();
var Cust_id= $("#Cust_id").val();    
    
 $.ajax
        (
	        {
	            type: 'Get',
	            url: '/Product/Detail_2010/AjaxResultPage/AjaxResult.aspx',
	            data: 'Type=MOD&Url=ONECONTENTS&Goods_id=' + Goods_id +'&Mall_id=' + Mall_id + '&Cust_id=' + Cust_id + '&Contents=' + escape(Content)+ '&Page_No=' + PageNum,
	            success: function(msg) {
	                switch (msg) {
	                    case "100":
	                        if (Gubun=="S"){
	                            PagingLoad("book_word","/Product/Detail_2010/ContentControl/Goods_OneContents.aspx?Goods_Id="+Goods_id+ "&Mall_id="+Mall_id); 	                         
	                        }else{
	                            PagingLoad("DetailView", "/Product/Detail_2010/ContentControl/Goods_Detail_OneContents.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_id); 	                         
	                        }
	                        alert("저장되었습니다..");
	                         $("#popup_small").remove();
	                        break;
	                    case "-100":
	                        alert("실패하셨습니다");
	                        break;
	                    case "-999":
	                        alert("실패하셨습니다.");
	                        break;
	                    default :
	                        alert("실패하셨습니다.");
	                    break;	                       
	                }
	            }
	        }
        );
}
function SetDeleteOneContens(Content,PageNum,Mod,Gubun) {

var Goods_id = $("#hd_Goods_id").val();
var Mall_id= $("#hd_Mall_id").val();
var Cust_id= $("#Cust_id").val();    
    
 $.ajax
        (
	        {
	            type: 'Get',
	            url: '/Product/Detail_2010/AjaxResultPage/AjaxResult.aspx',
	            data: 'Type=DEL&Url=ONECONTENTS&Goods_id=' + Goods_id +'&Mall_id=' + Mall_id + '&Cust_id=' + Cust_id + '&Contents=&Page_No=',
	            success: function(msg) {
	                switch (msg) {
	                    case "100":
	                        if (Gubun=="S"){
	                            PagingLoad("book_word","/Product/Detail_2010/ContentControl/Goods_OneContents.aspx?Goods_Id="+Goods_id+ "&Mall_id="+Mall_id); 	                         
	                        }else{
	                        PagingLoad("DetailView", "/Product/Detail_2010/ContentControl/Goods_Detail_OneContents.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_id); 	                         
	                        }
	                        alert("삭제되었습니다.");
	                         $("#popup_small").remove();
	                        break;
	                    case "-100":
	                        alert("실패하셨습니다");
	                        break;
	                    case "-999":
	                        alert("실패하셨습니다.");
	                        break;
	                    default :
	                        alert("실패하셨습니다.");
	                    break;	                       
	                }
	            }
	        }
        );
}
/* -------------------------------------------------
 *
 *  우편번호 지역변경
 *  1. ZIPCODE : 우편번호
 *
 *
 * ---------------------------------------------------- */


function SetZipCodeValue(ZIPCODE)
{
    var Goods_id = $("#hd_Goods_id").val();
    var Mall_Id= $("#hd_Mall_id").val();
    Close_Layer('info_area');   
     PagingLoad("info_delivery","/Product/Detail_2010/AddControl/Delevery_Info.aspx?GOODS_ID=" + Goods_id +"&Mall_ID=" + Mall_Id +"&Type=RENEW&ZIPCODE="+ZIPCODE); 
}

/* -----------------------------------------------------------------------------------
 *
 *  상품상세 태그관련  공감 추천 (중복체크)
 *  1. P_TAG_NO   : 태그관련 번호 (시퀀스)
 *  2. P_GOODS_ID : 태그관련 상품코드
 *  3. P_MALL_ID  : 몰 아이디
 *  4. P_CUST_ID  : 리뷰상품등록한 사용자아이디
 *
 *  결과 : 100 (성공) , -100 (이미등록), -200 (태그존재하지 않음),  그이외값 실패
 *
 * ------------------------------------------------------------------------------------ */


function TagRecommendAjax(tag_no,Goods_id,Mall_id,Login_Cust_id,tag_text) {

 $.ajax
        (
	        {
	            type: 'Get',
	            url: '/Product/Detail_2010/AjaxResultPage/AjaxResult.aspx',
	            data: 'Type=INSERT&Url=RELATIONTAG&Goods_id=' + Goods_id +'&Mall_id=' + Mall_id + '&Cust_id=' + Login_Cust_id + '&Tag_no=' + tag_no+ '&Tag_text=' + tag_text,
	            success: function(msg) {
	                switch (msg) {
	                    case "100":
	                        PagingLoad("RelationTag","/Product/Detail_2010/RightControl/Goods_RelationTag.aspx?Goods_Id="+Goods_id+ "&Mall_Id="+Mall_id); 	                         
	                        alert("추천되었습니다...");	                         
	                        break;
	                    case "-100":
	                        alert("실패하셨습니다.");
	                        break;
	                    case "-200":
	                        alert("이미 추천하셨습니다.");	                        
	                        break;
	                    default :
	                        alert("실패하셨습니다.");
	                    break;	                       
	                }
	            }
	        }
        );
}



/* -----------------------------------------------------------------------------------
*
*  상품상세 태그관련  입력
*  1. Login_Cust_id   :  사용자아이디
*  2. Goods_id : 태그관련 상품코드
*  3. Mall_id  : 몰 아이디
*  4. tag_text  :  사용자아이디
*
*  결과 : 
*
* ------------------------------------------------------------------------------------ */


function SetrelationTag(Login_Cust_id, Goods_id, Mall_id, tag_text) {

    $.ajax
        (
	        {
	            type: 'POST',
	            url: '/Product/Detail_2010/AjaxResultPage/AjaxResult.aspx',
	            data: 'Type=CONTENTINSERT&Url=RELATIONTAG&Goods_id=' + Goods_id + '&Mall_id=' + Mall_id + '&Cust_id=' + Login_Cust_id + '&Tag_text=' + tag_text,
	            success: function(msg) {	                
	                switch (msg) {
	                    case "100":
	                        PagingLoad("RelationTag", "/Product/Detail_2010/RightControl/Goods_RelationTag.aspx?Goods_Id=" + Goods_id + "&Mall_Id=" + Mall_id);
	                        alert("저장되었습니다...");
	                        break;
	                    case "-999":
	                        alert("실패하셨습니다.");
	                        break;
	                    default:
	                        alert("실패하셨습니다.");
	                        break;
	                }
	            }
	        }
        );
}



function SetRecomendTemaList(Goods_id,Mall_Id,Thm_id,PageNumber,cust_id) {

 $.ajax
        (
	        {
	            type: 'Get',
	            url: '/Product/Detail_2010/AjaxResultPage/AjaxResult.aspx',
	            data: 'Type=INSERT&Url=TEMARECOM&Thm_id=' + Thm_id +"&cust_id=" + cust_id,
	            success: function(msg) {
	                switch (msg) {	                    
	                    case "0":	                        
	                        PagingLoad("theme_list","/Product/Detail_2010/ContentControl/Goods_TemaList.aspx?Goods_Id=" + Goods_id +"&Mall_id=" +Mall_Id + "&PageNumber="+PageNumber);
	                        alert("자신이만든테마리스트는추천할수없습니다.");
	                        break;	
                        case "1":	                        
	                        PagingLoad("theme_list","/Product/Detail_2010/ContentControl/Goods_TemaList.aspx?Goods_Id=" + Goods_id +"&Mall_id=" +Mall_Id + "&PageNumber="+PageNumber);
	                        alert("이미추천하셨습니다.");
	                        break;
                        case "2":	                        
	                        PagingLoad("theme_list","/Product/Detail_2010/ContentControl/Goods_TemaList.aspx?Goods_Id=" + Goods_id +"&Mall_id=" +Mall_Id + "&PageNumber="+PageNumber);
	                        alert("추천되었습니다.");
	                        break;
	                        	                        	                                           
	                   default :
	                        alert("실패하셨습니다.");
	                    break;	                       
	                }
	            }
	        }
        );
}

  /* -----------------------------------------------------------------------------------
       *
       *  상품상세 우수리뷰 자세히 보기
       *  1. RID   : (시퀀스)
       * ------------------------------------------------------------------------------------ */

function ShowDetailReview(rid)
{
    var shortdiv = '#ReviewShort_' + rid;
    var Alldiv = '#ReviewAll' + rid;

    $.get("/Product/Detail_2010/AjaxResultPage/AjaxResult.aspx?Type=SELECT&Url=EXCELENT&RID=" + rid, function(data) {
        $(Alldiv).html(data);
        $(Alldiv).append("<img src=\"http://image.libro.co.kr/NewProdut/btn_s_close.gif\" style=\"cursor:pointer\" onclick=\"javascript:ShowSimpleReview('" + rid + "')\"/>");
        $(Alldiv).show();
        $(shortdiv).hide();
        
    });

 }

 function ShowSimpleReview(rid) {
     var shortdiv = '#ReviewShort_' + rid;
     var Alldiv = '#ReviewAll' + rid;
     $(shortdiv).show();
     $(Alldiv).hide();
 }
 

 function ShowDetailReviewExcelent(rid) {
     var shortdiv = '#ReviewShortExcelent_' + rid;
     var Alldiv = '#ReviewAllExcelent' + rid;

     $.get("/Product/Detail_2010/AjaxResultPage/AjaxResult.aspx?Type=SELECT&Url=EXCELENT&RID=" + rid, function(data) {
         $(Alldiv).html(data);
         $(Alldiv).append("<img src=\"http://image.libro.co.kr/NewProdut/btn_s_close.gif\" style=\"cursor:pointer\" onclick=\"javascript:ShowSimpleReviewExcelent('" + rid + "')\"/>");
         $(Alldiv).show();
         $(shortdiv).hide();

     });

 }

 function ShowSimpleReviewExcelent(rid) {
     var shortdiv = '#ReviewShortExcelent_' + rid;
     var Alldiv = '#ReviewAllExcelent' + rid;
     $(shortdiv).show();
     $(Alldiv).hide();
 }



 /* -----------------------------------------------------------------------------------
 *
 *  리뷰추천
 *  1. RID   : (시퀀스)
 * ------------------------------------------------------------------------------------ */

 function ReviewRecommendUpdate(rid, from_source,gubun,page,Goods_id) {    
//         var Goods_id = $("#hd_Goods_id").val();
         var Mall_id = $("#hd_Mall_id").val();
         var Cust_id = $("#Cust_id").val();

         $.ajax
        (
	        {
	            type: 'POST',
	            url: '/Product/Detail_2010/AjaxResultPage/AjaxResult.aspx',
	            data: 'Type=INSERT&Url=REVIEWRECOM&Rid=' + rid + "&Goods_id=" + Goods_id + '&Mall_id=' + Mall_id + '&Cust_id=' + Cust_id + "&from_source=" + from_source,
	            success: function(msg) {
	                switch (msg) {
	                    case "100":
	                        PagingLoad("reader_review", "/Product/Detail_2010/ContentControl/Goods_Review.aspx?Goods_id=" + Goods_id + "&Mall_id=" + Mall_id + "&PageNumber=" + page);	                        
	                        alert("추천되었습니다..");
	                        break;
	                    case "-100":
	                        PagingLoad("reader_review", "/Product/Detail_2010/ContentControl/Goods_Review.aspx?Goods_id=" + Goods_id + "&Mall_id=" + Mall_id + "&PageNumber=" + page);
	                        alert("이미추천하셨습니다.");
	                        break;
	                        	                  
	                    default:
	                        alert("실패하셨습니다.");
	                        break;
	                }
	            }
	        }
        );
   
 }


//리뷰디테일 추천하기
 function ReviewRecommendUpdateDetail(rid, from_source, gubun, page, Goods_id) {     
     var Mall_id = $("#hd_Mall_id").val();
     var Cust_id = $("#Cust_id").val();
     
     $.ajax
        (
	        {
	            type: 'POST',
	            url: '/Product/Detail_2010/AjaxResultPage/AjaxResult.aspx',
	            data: 'Type=INSERT&Url=REVIEWRECOM&Rid=' + rid + "&Goods_id=" + Goods_id + '&Mall_id=' + Mall_id + '&Cust_id=' + Cust_id + "&from_source=" + from_source,
	            success: function(msg) {
	                switch (msg) {
	                    case "100":	                        
	                        if (gubun == "Detail") {
	                            $('#DetailView').load("/Product/Detail_2010/ContentControl/Goods_Detail_Review.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_id + "&PageNumber=" + page);
	                        } else {
	                        $('#DetailView').load("/Product/Detail_2010/ContentControl/Goods_Detail_Excellent.aspx?Goods_Id=" + Goods_id + "&Mall_id=" + Mall_id + "&PageNumber=" + page);
	                        }
	                        alert("추천되었습니다..");
	                        break;
	                    case "-100":
	                        alert("이미추천하셨습니다.");
	                        break;

	                    default:
	                        alert("실패하셨습니다.");
	                        break;
	                }
	            }
	        }
        );

 }
