﻿////////////////////////////////////////////////////////////////////
// 메인 페이지 업소 가입 페이지 폼 체크
////////////////////////////////////////////////////////////////////
var MasterPath = "ctl00_cphMain_";        // 업소가입 페이지의 ID Path.

function venderRegistrationCheckForm()
{   
        // 업소 이름 체크 루틴
        if (isEmpty(MasterPath + 'txtLodgingNameEng') == false)
        {
            alert("Please enter Property Name.");
            document.getElementById(MasterPath + 'txtLodgingNameEng').focus();
            return false;
        }
        
        // 업소 형태 체크 루틴
        if (document.getElementById(MasterPath + 'ddlLodgingCategory').value == -1)
        {
            alert("Please select a Property Type.");
            document.getElementById(MasterPath + 'ddlLodgingCategory').focus();
            return false;
        }
        
        // 국가 선택 체크 루틴
        if (document.getElementById(MasterPath + 'reg_ddlCountryList').value == 0)
        {
            alert("Please select a Country.");
            document.getElementById(MasterPath + 'reg_ddlCountryList').focus();
            return false;
        }
        
        // 도시 선택 체크 루틴
        if (document.getElementById(MasterPath + 'reg_ddlCityList').value == 0)
        {
            alert("Please select a City.");
            document.getElementById(MasterPath + 'reg_ddlCityList').focus();
            return false;
        }
        
        // 업소 주소 1 체크 루틴
        if (isEmpty(MasterPath + 'txtAddress1') == false)
        {
            alert("Please enter Address 1.");
            document.getElementById(MasterPath + 'txtAddress1').focus();
            return false;
        }  
        
        // 우편번호 체크 루틴
        if (isEmpty(MasterPath + 'txtZipCode') == false)
        {
            alert("Please enter ZipCode.");
            document.getElementById(MasterPath + 'txtZipCode').focus();
            return false;
        }  
        
        // 업소 전화번호 체크 루틴
        if (isEmpty(MasterPath + 'txtPhoneNum') == false)
        {
            alert("Please enter Phone Number.");
            document.getElementById(MasterPath + 'txtPhoneNum').focus();
            return false;
        }
        else if(chkPhoneNum(MasterPath + 'txtPhoneNum') == false)
        {
            alert("Invalid Phone Number.\nPlease enter Phone Number.");
            document.getElementById(MasterPath + 'txtPhoneNum').focus();
            return false;
        } 

        //한국내 연락번호 체크 루틴
        if(chkPhoneNum(MasterPath + 'txtPhoneNumKor') == false)
        {
            alert("Invalid Toll Free Phone Number.\nPlease enter Phone Number.");
            document.getElementById(MasterPath + 'txtPhoneNumKor').focus();
            return false;
        } 

        // 팩스 번호 체크 루틴
        if(chkPhoneNum(MasterPath + 'txtFaxNum') == false)
        {
            alert("Invalid Fax Number, Please enter Fax Number.");
            document.getElementById(MasterPath + 'txtFaxNum').focus();
            return false;
        } 


        // 신청인 이름 체크 루틴
        if (isEmpty(MasterPath + 'txtRegName') == false)
        {
            alert("Please enter your Name.");
            document.getElementById(MasterPath + 'txtRegName').focus();
            return false;
        }      
        else if(chkEnglish(MasterPath + 'txtRegName') == false)
        {
            alert("Please enter your name in English.");
            document.getElementById(MasterPath + 'txtRegName').focus();
            return false;
        }   

        // 대표자 이름 체크 루틴
        if (chkEnglish(MasterPath + 'txtCEOName') == false)
        {
           alert("Please enter contact title in English.");
           document.getElementById(MasterPath + 'txtCEOName').focus();
           return false;
        } 
          

        // 예약 통지 이메일 체크 루틴
        if (isEmpty(MasterPath + 'txtResEmail') == false)
        {
            alert("Please enter E-Mail address for Booking Notice.");
            document.getElementById(MasterPath + 'txtResEmail').focus();
            return false;
        }

        else if(checkEmail(MasterPath + 'txtResEmail') == false)
        {
            alert("Invalid E-mail address.\nPlease enter E-Mail address for Booking Notice.");
            document.getElementById(MasterPath + 'txtResEmail').focus();
            return false;
        }
        
        if(isEmpty(MasterPath + 'txtEtcEmail') != false && checkEmail(MasterPath + 'txtEtcEmail') == false)
        {
            alert("Invalid Contact E-mail address.\nPlease enter Contact E-Mail address.");
            document.getElementById(MasterPath + 'txtEtcEmail').focus();
            return false;
        }

        return true;
}

////////////////////////////////////////////////////////////////////
// 유저 예약정보 입력 체크
////////////////////////////////////////////////////////////////////
function userBookingCheckForm()
{
        // 예약자 성명 체크
        if (isEmpty(MasterPath + 'txtResLName') == false)
        {
            alert("Please Enter Customer's First Name.");
            document.getElementById(MasterPath + 'txtResLName').focus();
            return false;
        }
        
        if (isEmpty(MasterPath + 'txtResLName') != false && chkEnglish(MasterPath + 'txtResLName') == false)
        {
            alert("Please Enter Customer's First Name in English.");
            document.getElementById(MasterPath + 'txtResLName.').focus();
            return false;
        }
        
        if (isEmpty(MasterPath + 'txtResFName') == false)
        {
            alert("Please Enter Customer's Last Name.");
            document.getElementById(MasterPath + 'txtResFName').focus();
            return false;
        }
        
        if (isEmpty(MasterPath + 'txtResFName') != false && chkEnglish(MasterPath + 'txtResFName') == false)
        {
            alert("Please Enter Customer's Last Name in English.");
            document.getElementById(MasterPath + 'txtResFName').focus();
            return false;
        }
        
        // 국적 체크 
        if (document.getElementById(MasterPath + 'reg_ddlCountryList').value == 0)
        {
            alert("Please select your Nationality.");
            document.getElementById(MasterPath + 'reg_ddlCountryList').focus();
            return false;
        }
        
        // 숙박인원 체크
        if (document.getElementById(MasterPath + 'ddlAdultGuest').value == 0)
        {
            alert("Please Enter Number of Adults only (except children)");
            document.getElementById(MasterPath + 'ddlAdultGuest').focus();
            return false;
        }
        
        
        // 이메일 주소 체크
        if (isEmpty(MasterPath + 'txtResEmail') == false)
        {
            alert("Please enter E-Mail address.");
            document.getElementById(MasterPath + 'txtResEmail').focus();
            return false;
        }
        
        if (isEmpty(MasterPath + 'txtResEmail') != false && checkEmail(MasterPath + 'txtResEmail') == false)
        {
            alert("Invalid E-mail address.\nPlease enter E-Mail address.");
            document.getElementById(MasterPath + 'txtResEmail').focus();
            return false;
        }
        
        
        if (isEmpty(MasterPath + 'txtConfirmResEmail') == false)
        {
            alert("Please Re-Enter Your E-mail address correctly. ");
            document.getElementById(MasterPath + 'txtConfirmResEmail').focus();
            return false;
        }
        
        if (isEmpty(MasterPath + 'txtConfirmResEmail') != false && checkEmail(MasterPath + 'txtConfirmResEmail') == false)
        {
            alert("You entered invalid Email address,\nplease enter e-mail address.");
            document.getElementById(MasterPath + 'txtConfirmResEmail').focus();
            return false;
        }
        
       if (document.getElementById(MasterPath + 'txtResEmail').value.trim() != document.getElementById(MasterPath + 'txtConfirmResEmail').value.trim())
       {
           alert("Email Address does not match, please re-enter.");
           document.getElementById(MasterPath + 'txtConfirmResEmail').focus();
           return false;
       }
       
       // 전화번호 체크
       if (isEmpty(MasterPath + 'txtResPhoneNum') == false)
        {
            alert("Please Enter Customer's Phone Number.");
            document.getElementById(MasterPath + 'txtResPhoneNum').focus();
            return false;
        }
        
        if (isEmpty(MasterPath + 'txtResPhoneNum') != false && chkPhoneNum(MasterPath + 'txtResPhoneNum') == false)
        {
            alert("Phone number type is incorrect,\nplease enter only numbers.");
            document.getElementById(MasterPath + 'txtResPhoneNum').focus();
            return false;
        }
        
        // 카드 소유자 성명 체크
        if (isEmpty(MasterPath + 'txtApplicantName') == false)
        {
            alert("Please Enter credit card holder's name.");
            document.getElementById(MasterPath + 'txtApplicantName').focus();
            return false;
        }
        
        // 카드번호 체크
        if (isEmpty(MasterPath + 'txtCardNum1') == false)
        {
            alert("Please Enter credit card number.");
            document.getElementById(MasterPath + 'txtCardNum1').focus();
            return false;
        }
        
        if (isEmpty(MasterPath + 'txtCardNum2') == false)
        {
            alert("Please Enter credit card number.");
            document.getElementById(MasterPath + 'txtCardNum2').focus();
            return false;
        }
        
        if (isEmpty(MasterPath + 'txtCardNum3') == false)
        {
            alert("Please Enter credit card number.");
            document.getElementById(MasterPath + 'txtCardNum3').focus();
            return false;
        }
        
        if (isEmpty(MasterPath + 'txtCardNum4') == false)
        {
            alert("Please Enter credit card number.");
            document.getElementById(MasterPath + 'txtCardNum4').focus();
            return false;
        }
        
        if (isEmpty(MasterPath + 'txtCardNum1') != false && chkOnlyNumber(MasterPath + 'txtCardNum1') == false)
        {
            alert("Please enter credit card number correctly,\nonly in numbers.");
            document.getElementById(MasterPath + 'txtCardNum1').focus();
            return false;
        }
        
        if (isEmpty(MasterPath + 'txtCardNum2') != false && chkOnlyNumber(MasterPath + 'txtCardNum2') == false)
        {
            alert("Please enter credit card number correctly,\nonly in numbers.");
            document.getElementById(MasterPath + 'txtCardNum2').focus();
            return false;
        }
        
        if (isEmpty(MasterPath + 'txtCardNum3') != false && chkOnlyNumber(MasterPath + 'txtCardNum3') == false)
        {
            alert("Please enter credit card number correctly,\nonly in numbers.");
            document.getElementById(MasterPath + 'txtCardNum3').focus();
            return false;
        }
        
        if (isEmpty(MasterPath + 'txtCardNum4') != false && chkOnlyNumber(MasterPath + 'txtCardNum4') == false)
        {
            alert("Please enter credit card number correctly,\nonly in numbers.");
            document.getElementById(MasterPath + 'txtCardNum4').focus();
            return false;
        }
        
        if (isEmpty(MasterPath + 'txtCVVNumber') == false)
        {
            alert("Please enter CVV code(card security code).");
            document.getElementById(MasterPath + 'txtCVVNumber').focus();
            return false;
        }
        
        if (isEmpty(MasterPath + 'txtCVVNumber') != false && chkOnlyNumber(MasterPath + 'txtCVVNumber') == false)
        {
            alert("Please enter CVV code(card security code) in numbers.");
            document.getElementById(MasterPath + 'txtCVVNumber').focus();
            return false;
        }
        
        if (document.getElementById('chkAgree').checked == false)
        {
            alert("You must agree to the terms before proceeding,\nPlease click small on box to agree terms and conditions.");
            document.getElementById('chkAgree').focus();
            return false;
        }
        
        revealModal("modalPage");
    
    /*
        document.getElementById('reservationBody').style.display="none";
    
        var obj = document.getElementById('loadingBar');
        var objImg = document.getElementById("loadingImg"); 
        if (obj.style.display == "none")
        {
            obj.style.display = 'block';
            obj.innerHTML = "<br /><br /><br /><br /><br /><br /><br /><br /><br /><table width='695' cellspacing='0'><tr><td width='695' height='800' align='center' valign='middle'><center><img src='/main/images/ProcessingYourReservation_GIF.gif' /></center></td></tr></table>";
        }
        else
        {
            obj.style.display = 'none'
        }
    */
    return true;
}

////////////////////////////////////////////////////////////////////
// 유저 가입 정보 입력 체크
////////////////////////////////////////////////////////////////////
function RegisterMemberChkForm()
{
    // 이메일 주소 체크    
    if (isEmpty(MasterPath + 'txtUserEmail') == false)
    {
        alert("Please enter E-Mail address.");
        document.getElementById(MasterPath + 'txtUserEmail').focus();
        return false;
    }
    
    if (isEmpty(MasterPath + 'txtUserEmail') != false && checkEmail(MasterPath + 'txtUserEmail') == false)
    {
        alert("Invalid E-mail address.\nPlease enter E-Mail address.");
        document.getElementById(MasterPath + 'txtUserEmail').focus();
        return false;
    }
    
    
    // 컨펌 이메일 주소 체크    
    if (isEmpty(MasterPath + 'txtReinputUserEmail') == false)
    {
        alert("Please re-enter your E-mail address to confirm your mail address.");
        document.getElementById(MasterPath + 'txtReinputUserEmail').focus();
        return false;
    }
    
    if (document.getElementById(MasterPath + 'txtUserEmail').value.trim() != document.getElementById(MasterPath + 'txtReinputUserEmail').value.trim())
    {
        alert("E-mail address you entered does not match.");
        document.getElementById(MasterPath + 'txtReinputUserEmail').focus();
        return false;
    }
    
    // 패스워드 체크
    if (isEmpty(MasterPath + 'txtPassword') == false)
    {
        alert("Please enter your password.");
        document.getElementById(MasterPath + 'txtPassword').focus();
        return false;
    }
    
    if (isEmpty(MasterPath + 'txtPassword') != false && chkPassword(MasterPath + 'txtPassword') == false)
    {
        alert("Password must have letters and numbers.");
        document.getElementById(MasterPath + 'txtPassword').focus();
        return false;
    }
    
    if (isEmpty(MasterPath + 'txtConfirmPassword') == false)
    {
        alert("Please re-enter your password.");
        document.getElementById(MasterPath + 'txtConfirmPassword').focus();
        return false;
    }
    
    if (document.getElementById(MasterPath + 'txtPassword').value.trim() != document.getElementById(MasterPath + 'txtConfirmPassword').value.trim())
    {
        alert("Password you entered does not match.");
        document.getElementById(MasterPath + 'txtConfirmPassword').focus();
        return false;
    }    
    
    
    if (isEmpty(MasterPath + 'txtUserFName') == false)
        {
            alert("Please Enter Customer's Name.");
            document.getElementById(MasterPath + 'txtUserFName').focus();
            return false;
        }
     
     if (isEmpty(MasterPath + 'txtUserFName') != false && chkEnglish(MasterPath + 'txtUserFName') == false)
        {
            alert("Please Enter Customer's Name in English.");
            document.getElementById(MasterPath + 'txtUserFName').focus();
            return false;
        }  
        
    if (isEmpty(MasterPath + 'txtUserLName') == false)
    {
        alert("Please Enter Customer's Name.");
        document.getElementById(MasterPath + 'txtUserLName').focus();
        return false;
    }
    
    if (isEmpty(MasterPath + 'txtUserLName') != false && chkEnglish(MasterPath + 'txtUserLName') == false)
        {
            alert("Please Enter Customer's Name in English.");
            document.getElementById(MasterPath + 'txtUserLName').focus();
            return false;
        }
    
    if (document.getElementById(MasterPath + 'reg_ddlCountryList').value == 0)
    {
        alert("Please select your Nationality.");
        document.getElementById(MasterPath + 'reg_ddlCountryList').focus();
        return false;
    }
   
   return true;   
}

////////////////////////////////////////////////////////////////////
// 유저 정보 수정 체크
////////////////////////////////////////////////////////////////////
function UpdateMemberChkForm()
{
     if (isEmpty(MasterPath + 'txtCurrentPassword') == false)
    {
        alert("Please enter your new password.");
        document.getElementById(MasterPath + 'txtCurrentPassword').focus();
        return false;
    }
    
    if (isEmpty(MasterPath + 'txtChangePassword') == false)
    {
        alert("Please enter confirm password.");
        document.getElementById(MasterPath + 'txtChangePassword').focus();
        return false;
    }

    if ((isEmpty(MasterPath + 'txtChangePassword') != false) && (document.getElementById(MasterPath + 'txtCurrentPassword').value.trim() != document.getElementById(MasterPath + 'txtChangePassword').value.trim()))
    {
        alert("Password you re-entered does not match.");
        document.getElementById(MasterPath + 'txtChangePassword').focus();
        return false;
    }
    return true;
}

////////////////////////////////////////////////////////////////////
//  문의 하기 폼 체크(General Question)
////////////////////////////////////////////////////////////////////
function ReskorQnAChkForm()
{
    // 이메일 주소 체크    
    if (isEmpty(MasterPath + 'txtQuestionerEmail') == false)
    {
        alert("Please enter your E-mail Address.");
        document.getElementById(MasterPath + 'txtQuestionerEmail').focus();
        return false;
    }
    
    if (isEmpty(MasterPath + 'txtQuestionerEmail') != false && checkEmail(MasterPath + 'txtQuestionerEmail') == false)
    {
        alert("Invalid E-mail address.\nPlease enter E-Mail address.");
        document.getElementById(MasterPath + 'txtQuestionerEmail').focus();
        return false;
    }
    
    // 보내는 사람 이름 체크
    if (isEmpty(MasterPath + 'txtQuestionerName') == false)
    {
        alert("Please enter your name.");
        document.getElementById(MasterPath + 'txtQuestionerName').focus();
        return false;
    }
    
    // 제목 체크
    if (isEmpty(MasterPath + 'txtQuestionTitle') == false)
    {
        alert("Please enter Question Title");
        document.getElementById(MasterPath + 'txtQuestionTitle').focus();
        return false;
    }
    
    // 내용 체크
    if (isEmpty(MasterPath + 'txtQuestionContents') == false)
    {
        alert("Please enter Contents");
        document.getElementById(MasterPath + 'txtQuestionContents').focus();
        return false;
    }   
    return true;
}

////////////////////////////////////////////////////////////////////
//  유저 로그인 폼 체크
////////////////////////////////////////////////////////////////////
function UserLoginChkForm()
{
    // ID 체크    
    if (isEmpty(MasterPath + 'txtMemberID') == false)
    {
        alert("Please enter member ID.");
        document.getElementById(MasterPath + 'txtMemberID').focus();
        return false;
    }
    
    if (isEmpty(MasterPath + 'txtMemberID') != false && checkEmail(MasterPath + 'txtMemberID') == false)
    {
        alert("ID form is not correct.\nID should be E-mail address.");
        document.getElementById(MasterPath + 'txtMemberID').focus();
        return false;
    }
    
    // 제목 체크
    if (isEmpty(MasterPath + 'txtMemberPassword') == false)
    {
        alert("Please enter member Password.");
        document.getElementById(MasterPath + 'txtMemberPassword').focus();
        return false;
    }
    return true;
}

////////////////////////////////////////////////////////////////////
//  유저 업소에 질문하기 체크
////////////////////////////////////////////////////////////////////
function LodgingQnAChkForm()
{
    if (isEmpty('txtQuestionTitle') == false)
    {
        alert("Please enter Title.");
        document.getElementById('txtQuestionTitle').focus();
        return false;        
    }
    
    if (isEmpty('txtQuestionContents') == false)
    {
        alert("Please enter Question.");
        document.getElementById('txtQuestionContents').focus();
        return false;        
    }
    return true;    
}


////////////////////////////////////////////////////////////////////
//  유저 평가 커멘트 체크
////////////////////////////////////////////////////////////////////
function UserRatingChkForm()
{
    // 제목 체크
    if (isEmpty(MasterPath + 'txtTitle') == false && isEmpty(MasterPath + 'txtComment') != false)
    {
        alert("Please enter Title.");
        document.getElementById(MasterPath + 'txtTitle').focus();
        return false;
    }
    
    if (isEmpty(MasterPath + 'txtTitle') != false && isEmpty(MasterPath + 'txtComment') == false)
    {
        alert("Please enter Rating Review.");
        document.getElementById(MasterPath + 'txtComment').focus();
        return false;
    }
    
    // 사진 입력 체크
    if (isEmpty(MasterPath + 'txtTitle') == false && isEmpty(MasterPath + 'txtComment') == false && isEmpty(MasterPath + 'fudImage1') != false)
    {
        alert("Image can be uploaded upon completion of feedback form.");        
        document.getElementById(MasterPath + 'fudImage1').focus();        
        return false;
    }
    
    if (isEmpty(MasterPath + 'txtTitle') == false && isEmpty(MasterPath + 'txtComment') == false && isEmpty(MasterPath + 'fudImage2') != false)
    {
        alert("Image can be uploaded upon completion of feedback form");
        document.getElementById(MasterPath + 'fudImage2').focus();
        return false;
    }
    
    return true;  
}


////////////////////////////////////////////////////////////////////
//  검색 결과 후 예약할 객실 선택 체크
////////////////////////////////////////////////////////////////////
function RoomTypeChk()
{
   var PrivatePath = "ctl00_cphMain_rptPrivateRooms_";
   var DormitoryPath = "ctl00_cphMain_rptDormRooms_";
    // 객실 선택
    for ( r = 1; r < 60 ; r++)
    {
        if (r < 10)
        {
            if (document.getElementById(PrivatePath + 'ctl0' + r + '_chkPrivate') != null) 
            {            
                if (document.getElementById(PrivatePath + 'ctl0' + r + '_chkPrivate').checked == true)
                {
                    return true;
                }
             }
             if (document.getElementById(DormitoryPath + 'ctl0' + r + '_ddlDormNumBedAvailable') != null)
             {   
                if (document.getElementById(DormitoryPath + 'ctl0' + r + '_ddlDormNumBedAvailable').value > 0)
                {
                    return true;
                }                            
            }                        
        }
        else
        {
            if (document.getElementById(PrivatePath + 'ctl' + r + '_chkPrivate') != null)
            {
                if (document.getElementById(PrivatePath + 'ctl' + r + '_chkPrivate').checked == true)
                {
                    return true;
                }                
            }
            if (document.getElementById(DormitoryPath + 'ctl' + r + '_ddlDormNumBedAvailable') != null)
            {
                if (document.getElementById(DormitoryPath + 'ctl' + r + '_ddlDormNumBedAvailable').value > 0)
                {
                    return true;
                }     
            }
        }           
    }
    alert("Please Select Rooms.");
    return false;
}

////////////////////////////////////////////////////////////////////
//  친구에게 메일 보내기 체크
////////////////////////////////////////////////////////////////////
function EmailSendToFriend()
{
    // 보내는 사람 체크
    if (isEmpty('txtSenderEmail') == false)
    {
        alert("Please enter your E-Mail address.");
        document.getElementById('txtSenderEmail').focus();
        return false;
    }
    
    // 보내는 사람 이메일 주소 체크
    if (isEmpty('txtSenderEmail') != false && checkEmail('txtSenderEmail') == false)
    {
        alert("Invalid your E-mail address.\nPlease enter your E-Mail address.");
        document.getElementById('txtSenderEmail').focus();
        return false;
    }
    
    // 보내는 사람 이름 체크
    if (isEmpty('txtSenderName') == false)
    {
        alert("Please enter your name.");
        document.getElementById('txtSenderName').focus();
        return false;
    }
    
    // 받는 사람 체크
    if ((isEmpty('txtReferEmail_1') == false) && (isEmpty('txtReferEmail_2') == false) && (isEmpty('txtReferEmail_2') == false))
    {
        alert("Please enter friends E-Mail address.");
        document.getElementById('txtReferEmail_1').focus();
        return false;
    }
    
    // 보내는 사람 이메일 주소 체크
    if (isEmpty('txtReferEmail_1') != false && checkEmail('txtReferEmail_1') == false)
    {
        alert("Invalid friends E-mail address.");
        document.getElementById('txtReferEmail_1').focus();
        return false;
    }
    
    if (isEmpty('txtReferEmail_2') != false && checkEmail('txtReferEmail_2') == false)
    {
        alert("Invalid friends E-mail address.");
        document.getElementById('txtReferEmail_2').focus();
        return false;
    }
    
    if (isEmpty('txtReferEmail_3') != false && checkEmail('txtReferEmail_3') == false)
    {
        alert("Invalid friends E-mail address.");
        document.getElementById('txtReferEmail_3').focus();
        return false;
    }
    
    return true;
}