﻿//var httpsUrl = "https://Login.mcircle.co.kr/hidocTFT/";
//var httpsUrl = "https://www.dev.hidoc.co.kr/Member/SSL/";
var httpsUrl = "https://Login.hidoc.co.kr/Hidoc";

function NewSSL() {
    this.ID;
    this.Name;
    this.Password;
    this.EmailID;
    this.EmailHost;
    this.Regno1;
    this.Regno2;
    this.BirthDay;
    this.Year;
    this.Tel;
    this.Tel1;
    this.Tel2;
    this.Tel3;
    this.AreaSiDo;
    this.AreaSiGu;
    this.AreaDong;
    this.Gender;
    this.MedicalPartString;
    this.IsMailReceive
    this.InterestInfoString

    //의사회원추가 정보
    this.HospitalName;
    this.HospitalTel1;
    this.HospitalTel2;
    this.HospitalTel3;
    this.HospitalZipCode;
    this.HospitalAddress1;
    this.HospitalAddress2;

    this.DI; // iPIN 주민번호 고유코드
    this.ReqCONUM;  // IPIN 인증번호

    this.Type;

    this.TargetPath;
    this.ReturnUrl;
    this.RedirectUrl;

    this.Send = function() {

        if (this.TargetPath != null) {
            // 보낼폼을 생성
            var $newForm = $("<form id='formSSL' method='post' action='" + httpsUrl + this.TargetPath + "'></form>");

            // ID
            if (this.ID != null)
                $("<input type='hidden' value='" + this.ID + "' id='ID' name='ID' />").appendTo($newForm);

            // 성명
            if (this.Name != null)
                $("<input type='hidden' value='" + this.Name + "' id='Name' name='Name' />").appendTo($newForm);

            // 비밀번호
            if (this.Password != null)
                $("<input type='hidden' value='" + this.Password + "' id='Password' name='Password' />").appendTo($newForm);

            // 이메일
            if (this.EmailID != null)
                $("<input type='hidden' value='" + this.EmailID + "' id='EmailID' name='EmailID' />").appendTo($newForm);

            if (this.EmailHost != null)
                $("<input type='hidden' value='" + this.EmailHost + "' id='EmailHost' name='EmailHost' />").appendTo($newForm);

            // 메일수신여부
            if (this.IsMailReceive != null)
                $("<input type='hidden' value='" + this.IsMailReceive + "' id='IsMailReceive' name='IsMailReceive' />").appendTo($newForm);

            // 전화번호
            if (this.Tel != null)
                $("<input type='hidden' value='" + this.Tel + "' id='Tel' name='Tel' />").appendTo($newForm);

            // 전화번호1
            if (this.Tel1 != null)
                $("<input type='hidden' value='" + this.Tel1 + "' id='Tel1' name='Tel1' />").appendTo($newForm);
            // 전화번호2
            if (this.Tel2 != null)
                $("<input type='hidden' value='" + this.Tel2 + "' id='Tel2' name='Tel2' />").appendTo($newForm);
            // 전화번호3
            if (this.Tel3 != null)
                $("<input type='hidden' value='" + this.Tel3 + "' id='Tel3' name='Tel3' />").appendTo($newForm);

            // 지역
            if (this.AreaSiDo != null)
                $("<input type='hidden' value='" + this.AreaSiDo + "' id='AreaSiDo' name='AreaSiDo' />").appendTo($newForm);
            if (this.AreaSiGu != null)
                $("<input type='hidden' value='" + this.AreaSiGu + "' id='AreaSiGu' name='AreaSiGu' />").appendTo($newForm);
            if (this.AreaDong != null)
                $("<input type='hidden' value='" + this.AreaDong + "' id='AreaDong' name='AreaDong' />").appendTo($newForm);

            // 관심정보
            if (this.InterestInfoString != null)
                $("<input type='hidden' value='" + this.InterestInfoString + "' id='InterestInfo' name='InterestInfoString' />").appendTo($newForm);

            // 주민번호1
            if (this.Regno1 != null)
                $("<input type='hidden' value='" + this.Regno1 + "' id='Regno1' name='Regno1' />").appendTo($newForm);

            // 주민번호2
            if (this.Regno2 != null)
                $("<input type='hidden' value='" + this.Regno2 + "' id='Regno2' name='Regno2' />").appendTo($newForm);

            // 생년월일
            if (this.BirthDay != null)
                $("<input type='hidden' value='" + this.BirthDay + "' id='BirthDay' name='BirthDay' />").appendTo($newForm);

            // 생년
            if (this.Year != null)
                $("<input type='hidden' value='" + this.Year + "' id='Year' name='Year' />").appendTo($newForm);

            // 성별
            if (this.Gender != null)
                $("<input type='hidden' value='" + this.Gender + "' id='Gender' name='Gender' />").appendTo($newForm);

            // 회원타입
            if (this.Type != null)
                $("<input type='hidden' value='" + this.Type + "' id='Type' name='Type' />").appendTo($newForm);

            // 진료과
            if (this.MedicalPartString != null)
                $("<input type='hidden' value='" + this.MedicalPartString + "' id='MedicalPartString' name='MedicalPartString' />").appendTo($newForm);

            // iPIN 주민번호 고유코드
            if (this.DI != null)
                $("<input type='hidden' value='" + this.DI + "' id='DI' name='DI' />").appendTo($newForm);

            // IPIN 인증번호
            if (this.ReqCONUM != null)
                $("<input type='hidden' value='" + this.ReqCONUM + "' id='ReqCONUM' name='ReqCONUM' />").appendTo($newForm);

            // 리턴 URL설정
            if (this.ReturnUrl == null)
                $("<input type='hidden' value='" + this.ReturnUrl + "' id='ReturnUrl' name='ReturnUrl' />").appendTo($newForm);
            else
                $("<input type='hidden' value='http://" + location.host + this.ReturnUrl + "' id='ReturnUrl' name='ReturnUrl' />").appendTo($newForm);

            //의사 추가정보
            // 병원명
            if (this.HospitalName != null)
                $("<input type='hidden' value='" + this.HospitalName + "' id='HospitalName' name='HospitalName' />").appendTo($newForm);
            if (this.HospitalTel1 != null)
                $("<input type='hidden' value='" + this.HospitalTel1 + "' id='HospitalTel1' name='HospitalTel1' />").appendTo($newForm);
            if (this.HospitalTel2 != null)
                $("<input type='hidden' value='" + this.HospitalTel2 + "' id='HospitalTel2' name='HospitalTel2' />").appendTo($newForm);
            if (this.HospitalTel3 != null)
                $("<input type='hidden' value='" + this.HospitalTel3 + "' id='HospitalTel3' name='HospitalTel3' />").appendTo($newForm);
            if (this.HospitalZipCode != null)
                $("<input type='hidden' value='" + this.HospitalZipCode + "' id='HospitalZipCode' name='HospitalZipCode' />").appendTo($newForm);
            if (this.HospitalAddress1 != null)
                $("<input type='hidden' value='" + this.HospitalAddress1 + "' id='HospitalAddress1' name='HospitalAddress1' />").appendTo($newForm);
            if (this.HospitalAddress2 != null)
                $("<input type='hidden' value='" + this.HospitalAddress2 + "' id='HospitalAddress2' name='HospitalAddress2' />").appendTo($newForm);                                                                                                

            // RedirectUrl
            if (this.RedirectUrl != null)
                $("<input type='hidden' value='" + this.RedirectUrl + "' id='RedirectUrl' name='RedirectUrl' />").appendTo($newForm);

            // 폼을 body에 붙임
            $newForm.appendTo("body");

            $newForm.submit();
        }
        else {
            alert("SSL객체에 TargetPath 값이 지정되지 않았습니다.");
            location.reload();
            return false;
        }
    }
}
