﻿/// <reference path="jquery-1.4.2.min-vsdoc.js" />
/*
AJAX Script
Dependency : jquery-1.4.2.min.js
*/

var AJAXObj = {
    // 에러메시지
    AlertErrorMsg: function(id) {
        var URL = '/Ajax/GetMsg.aspx';
        $.ajax({
            url: URL,
            async: false,
            type: 'POST',
            timeout: 1000,
            data: { 'id': id },
            dataType: 'text',
            success: function(msg) {
                alert(msg);
            }
        });
    },

    // SMS 인증
    SmsAuth: function(type, mobile, auth) {
        var retObj;
        var URL = '/Ajax/SMSAuth.aspx';
        $.ajax({
            url: URL,
            async: false,
            type: 'POST',
            timeout: 1000,
            data: { 'type': type, 'mobile': mobile, 'auth': auth },
            dataType: 'text',
            success: function(msg) {
                retObj = msg;
            },
            error: function() {
                retObj = "error";
            }
        });
        return retObj;
    },

    // SMS 인증 (비번재발급용)
    SmsAuthForFindPW: function(type, userid, mobile, auth) {
        var retObj;
        var URL = '/Ajax/SMSAuthForFindPW.aspx';
        $.ajax({
            url: URL,
            async: false,
            type: 'POST',
            timeout: 1000,
            data: { 'type': type, 'userid': userid, 'mobile': mobile, 'auth': auth },
            dataType: 'text',
            success: function(msg) {
                retObj = msg;
            },
            error: function() {
                retObj = "error";
            }
        });
        return retObj;
    },

    // 이전 광고 정보
    GetAdvertInfo: function(advertID) {
        var retObj;
        var URL = '/Ajax/Advert/GetAdvertInfo.aspx';
        $.ajax({
            url: URL,
            async: false,
            type: 'POST',
            timeout: 1000,
            data: { 'advertid': advertID },
            dataType: 'json',
            success: function(json) {
                retObj = json;
            },
            error: function() {
                retObj = undefined;
            }
        });
        return retObj;
    },

    // 미리보기 창 html 리턴
    GetPreviewLayerLayout: function(layoutType) {
        var retObj;
        var URL = '/Ajax/Advert/GetPreviewLayerLayout.aspx';
        $.ajax({
            url: URL,
            async: false,
            type: 'POST',
            timeout: 1000,
            data: { 'layouttype': layoutType },
            dataType: 'html',
            success: function(html) {
                retObj = html;
            },
            error: function() {
                retObj = '';
            }
        });
        return retObj;
    },
    
    // 미리보기 광고 정보 (광고주번호 암호화)
    GetAdvertInfoForLayer: function(userNumber, advertID) {
        var retObj;
        var URL = '/Ajax/Advert/GetAdvertInfoForLayer.aspx';
        $.ajax({
            url: URL,
            async: false,
            type: 'POST',
            timeout: 1000,
            data: { 'usernumber': userNumber, 'advertid': advertID },
            dataType: 'json',
            success: function(json) {
                retObj = json;
            },
            error: function() {
                retObj = undefined;
            }
        });
        return retObj;
    },
    
    // 미리보기 부가서비스 정보 (광고주번호 암호화)
    GetAddinServiceInfoForLayer: function(userNumber, advertID) {
        var retObj;
        var URL = '/Ajax/Advert/GetAddinServiceInfoForLayer.aspx';
        $.ajax({
            url: URL,
            async: false,
            type: 'POST',
            timeout: 1000,
            data: { 'usernumber': userNumber, 'advertid': advertID },
            dataType: 'text',
            success: function(text) {
                retObj = text;
            },
            error: function() {
                retObj = 'error';
            }
        });
        return retObj;
    },

    // 광고 소분류 정보
    GetAdSubGroup: function(parent) {
        var retObj;
        var URL = '/Ajax/Advert/GetAdSubGroup.aspx';
        $.ajax({
            url: URL,
            async: false,
            type: 'POST',
            timeout: 1000,
            data: { 'parent': parent },
            dataType: 'json',
            success: function(json) {
                retObj = json;
            },
            error: function() {
                retObj = undefined;
            }
        });
        return retObj;
    },

    // 광고지역선택 정보
    GetTargetLocalInfo: function(depth, parent) {
        var retObj;
        var URL = '/Ajax/Advert/GetTargetLocalInfo.aspx';
        $.ajax({
            url: URL,
            async: false,
            type: 'POST',
            timeout: 1000,
            data: { 'depth': depth, 'parent': parent },
            dataType: 'json',
            success: function(json) {
                retObj = json;
            },
            error: function() {
                retObj = undefined;
            }
        });
        return retObj;
    },


    // 해당 지역 사용 여부 - 지역 선점까지 같이 이뤄짐
    GetLocalInfo: function(groupid, localid, advertpooltype, addtype) {
        var retObj;
        var URL = '/Ajax/Advert/GetLocalInfo.aspx';
        $.ajax({
            url: URL,
            async: false,
            type: 'POST',
            timeout: 1000,
            data: { 'groupid': groupid, 'localid': localid, 'advertpooltype': advertpooltype, 'addtype': addtype },
            dataType: 'json',
            success: function(json) {
                retObj = json;
            },
            error: function(e) {
                retObj = undefined;
            }
        });
        return retObj;
    },

    // 해당 지역 취소
    DeleteLocalInfo: function(groupid, localid, deltype) {
        var retObj;
        var URL = '/Ajax/Advert/DeleteLocalInfo.aspx';
        $.ajax({
            url: URL,
            async: false,
            type: 'POST',
            timeout: 1000,
            data: { 'groupid': groupid, 'localid': localid, 'deltype': deltype },
            dataType: 'text',
            success: function(msg) {
                retObj = msg;
            },
            error: function() {
                retObj = "error";
            }
        });
        return retObj;
    },

    // 광고 정보 삭제
    DeleteBuyAllTemp: function(sessionID) {
        var retObj;
        var URL = '/Ajax/Advert/DeleteBuyAllTemp.aspx';
        $.ajax({
            url: URL,
            async: false,
            type: 'POST',
            timeout: 1000,
            data: { 'sessionid': sessionID },
            dataType: 'text',
            success: function(msg) {
                retObj = msg;
            },
            error: function() {
                retObj = "error";
            }
        });
        return retObj;
    },

    // 광고주 날짜별 통계
    GetAdvertStatPerDate: function(advertid, date) {
        var retObj;
        var URL = '/Ajax/Advert/GetAdvertStatPerDate.aspx';
        $.ajax({
            url: URL,
            async: false,
            type: 'POST',
            timeout: 1000,
            data: { 'advertid': advertid, 'date': date },
            dataType: 'json',
            success: function(json) {
                retObj = json;
            },
            error: function(e) {
                retObj = undefined;
            }
        });
        return retObj;
    },

    // 광고주 지도정보 업데이트
    UpdateMemberMapInfo: function(usernumber, latitude, longitude) {
        var retObj;
        var URL = '/Ajax/Member/UpdateMemberMapInfo.aspx';
        $.ajax({
            url: URL,
            async: false,
            type: 'POST',
            timeout: 1000,
            data: { 'usernumber': usernumber, 'latitude': latitude, 'longitude': longitude },
            dataType: 'text',
            success: function(msg) {
                retObj = msg;
            },
            error: function() {
                retObj = "error";
            }
        });
        return retObj;
    }
}