﻿
function confirmDelete(msg) {
    return confirm(msg);
}

function Disabletheme(id, opt) {
    if (opt == 1) {
        document.getElementById(id).readOnly = "readonly";
        document.getElementById(id).style.backgroundColor = '#ffffff';
        document.getElementById(id).style.border = 'solid 1px #bfbfbf';
    }
    else {
        
        document.getElementById(id).style.backgroundColor = '#ffffff';
        document.getElementById(id).style.border = 'solid 1px #bfbfbf';
    }
}

/***********************************************************************************/
//VALIDATION-CHECKS

function CheckEmailFormat1(id) {
    var emailPat = /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
    var emailid = document.getElementById(id).value;
    var matchArray = emailid.match(emailPat);

    var objTxtGuestEmail = document.getElementById(id);

    if (matchArray == null && emailid != "") {
        document.getElementById('ctl00_PublicMainContent_lblvalidemail').style.display = "inline";
        if (objTxtGuestEmail)
            document.getElementById(id).focus();
        return false;
    }
}


function CheckEmailFormat(id) {
    var emailPat = /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
    var emailid = document.getElementById(id).value;
    var matchArray = emailid.match(emailPat);

    var objTxtGuestEmail = document.getElementById(id);

    if (matchArray == null && emailid != "") {
        alert("The email you have entered is not in a valid email format. Please try again.");
        if (objTxtGuestEmail)
            document.getElementById(id).focus();
        return false;
    }
}
//Check only numeric value is entered or not
function checkNumeric(id) {
    if (document.getElementById(id)) {
        if (isNaN(document.getElementById(id).value)) {
            alert('Enter only numeric value.');
            document.getElementById(id).focus();
            return false;
        }
    }
} //function

//Check Textbox Field is Blank or not
function checkTextBlank(id, msg) {
    var obj = document.getElementById(id);
    if (obj) {
        if (document.getElementById(id).value.trim() == '') {
            document.getElementById(id).focus();
            GoTop();
            return false;
        }
    }
} //function

//To Check Wheather Drop-Down List Item is selected or not
function checkDropDownBlank(id, msg) {
    var obj = document.getElementById(id);
    if (obj) {
        if ((obj.value == '0') || (obj.value == '') || (obj.value == 'Select from List . . .')) {
          
            obj.focus();
            return false;
        }
    }
} //function


function CheckCheckBox(id, msg) {
    if (document.getElementById(id).checked == false) {
     
        return false;
    }
}

//Check Form Validation

function validateRegistrationForm() {
    var flag = 0;
    var lblmsg = document.getElementById('ctl00_PublicMainContent_lblMessage');
    //check Organization Name is blank or not
    if (checkTextBlank('ctl00_PublicMainContent_txtName') == false) {
        flag++;
        lblmsg.innerHTML = "Please enter the Organization Name.";
        lblmsg.style.display = "inline";
        return false;
    }


    //check Address1 is blank or not
    if (checkTextBlank('ctl00_PublicMainContent_txtAddress1') == false) {
        flag++;
        lblmsg.innerHTML = "Please enter the Address.";
        lblmsg.style.display = "inline";
        return false;
    }


    //check City is blank or not
    if (checkTextBlank('ctl00_PublicMainContent_txtCity') == false) {

        flag++;
        lblmsg.innerHTML = "Please enter the City .";
        lblmsg.style.display = "inline";
        return false;
    }

           //check ZIP is blank or not
    if (checkTextBlank('ctl00_PublicMainContent_txtZip') == false) {
        flag++;
        lblmsg.innerHTML = "Please enter the ZIP .";
        lblmsg.style.display = "inline";
        return false;

    }
    if (document.getElementById('ctl00_PublicMainContent_hidType').getAttribute('value') == 'S') {
        if (document.getElementById('ctl00_PublicMainContent_rcbServiceCategory').value == 'Select from list...') {
            lblmsg.innerHTML = "Please select the Service Category.";
            lblmsg.style.display = "inline";
            flag++;
            return false;
        }

        //check Service Provider Name is blank or not
        if (checkTextBlank('ctl00_PublicMainContent_txtSPName') == false) {
            flag++;
            lblmsg.innerHTML = "Please enter the Key Contact Name.";
            lblmsg.style.display = "inline";
            return false;
        }

        //check Service Provider Email is blank or not
        if (checkTextBlank('ctl00_PublicMainContent_txtSPEmail') == false) {
            flag++;
            lblmsg.innerHTML = "Please enter the Key Contact Email Address.";
            lblmsg.style.display = "inline";
            return false;
        }

        if (checkTextBlank('ctl00_PublicMainContent_txtNewPassword1') == false) {
            flag++;
            lblmsg.innerHTML = "Please enter the Password.";
            lblmsg.style.display = "inline";
            return false;
        }
        if (checkTextBlank('ctl00_PublicMainContent_txtConfirmPassword1') == false) {
            flag++;
            lblmsg.innerHTML = "Please enter the Confirm Password.";
            lblmsg.style.display = "inline";
            return false;
        }
        if (document.getElementById('ctl00_PublicMainContent_txtNewPassword1') != null && document.getElementById('ctl00_PublicMainContent_txtConfirmPassword1') != null) {
            if (document.getElementById('ctl00_PublicMainContent_txtNewPassword1').value != document.getElementById('ctl00_PublicMainContent_txtConfirmPassword1').value) {
                document.getElementById('ctl00_PublicMainContent_txtNewPassword1').value = "";
                document.getElementById('ctl00_PublicMainContent_txtConfirmPassword1').value = "";
                GoTop();
                flag++;
                return false;
            }
        }


        if (checkTextBlank('ctl00_PublicMainContent_txtSPExtPswd') == false) {
            flag++;
            lblmsg.innerHTML = "Please enter the Password.";
            lblmsg.style.display = "inline";
            return false;
        }
        if (checkTextBlank('ctl00_PublicMainContent_txtSPExtPswdConfirm') == false) {
            flag++;
            lblmsg.innerHTML = "Please enter the Confirm Password.";
            lblmsg.style.display = "inline";
            return false;
        }
        if (document.getElementById('ctl00_PublicMainContent_txtSPExtPswd') != null && document.getElementById('ctl00_PublicMainContent_txtSPExtPswdConfirm') != null) {
            if (document.getElementById('ctl00_PublicMainContent_txtSPExtPswd').value != document.getElementById('ctl00_PublicMainContent_txtSPExtPswdConfirm').value) {
                document.getElementById('ctl00_PublicMainContent_txtSPExtPswd').value = "";
                document.getElementById('ctl00_PublicMainContent_txtSPExtPswdConfirm').value = "";
                flag++;
                GoTop();
                return false;
            }
        }

        if (document.getElementById('ctl00_PublicMainContent_rcbSQuestion') != null) {
            if (document.getElementById('ctl00_PublicMainContent_rcbSQuestion').value == 'Select from List...') {
                lblmsg.innerHTML = "Please select the Security Question.";
                lblmsg.style.display = "inline";
                flag++;
                GoTop();
                return false;
            }
        }

        if (checkTextBlank('ctl00_PublicMainContent_txtSAnswer') == false) {
            lblmsg.innerHTML = "Please enter the answer for the Security Question.";
            lblmsg.style.display = "inline";
            flag++;
            return false;
        }

        if (CheckCheckBox('ctl00_PublicMainContent_chkSPAgree') == false) {
            flag++;
            lblmsg.innerHTML = "Please check that you have read and agree to the Terms of Use and Privacy Policy.";
            lblmsg.style.display = "inline";
            return false;
        }
    }
    else {
        if (checkTextBlank('ctl00_PublicMainContent_txtCName') == false) {
            lblmsg.innerHTML = "Please enter the Key Contact Name.";
            lblmsg.style.display = "inline";
            flag++;
            return false;
        }

        //check Organization Email is blank or not
        if (checkTextBlank('ctl00_PublicMainContent_txtCEmail') == false) {
            lblmsg.innerHTML = "Please enter the Key Contact Email Address.";
            lblmsg.style.display = "inline";
            flag++;
            return false;
        }

        if (checkTextBlank('ctl00_PublicMainContent_txtNewPassword') == false) {
            lblmsg.innerHTML = "Please enter the Password.";
            lblmsg.style.display = "inline";
            flag++;
            return false;
        }
        if (checkTextBlank('ctl00_PublicMainContent_txtConfirmPassword') == false) {
            lblmsg.innerHTML = "Please enter the Confirm Password.";
            lblmsg.style.display = "inline";
            flag++;
            return false;
        }
        if (document.getElementById('ctl00_PublicMainContent_txtNewPassword') != null && document.getElementById('ctl00_PublicMainContent_txtConfirmPassword') != null) {
            if (document.getElementById('ctl00_PublicMainContent_txtNewPassword').value != document.getElementById('ctl00_PublicMainContent_txtConfirmPassword').value) {
                document.getElementById('ctl00_PublicMainContent_txtNewPassword').value = "";
                document.getElementById('ctl00_PublicMainContent_txtConfirmPassword').value = "";
                flag++;
                GoTop();
                return false;
            }
        }

        if (checkTextBlank('ctl00_PublicMainContent_txtExistingPwd') == false) {
            flag++;
            lblmsg.innerHTML = "Please enter the Password.";
            lblmsg.style.display = "inline";
            return false;
        }
        if (checkTextBlank('ctl00_PublicMainContent_txtExistingPwdConfirm') == false) {
            flag++;
            lblmsg.innerHTML = "Please enter the Confirm Password.";
            lblmsg.style.display = "inline";
            return false;
        }
        if (document.getElementById('ctl00_PublicMainContent_txtExistingPwd') != null && document.getElementById('ctl00_PublicMainContent_txtExistingPwdConfirm') != null) {
            if (document.getElementById('ctl00_PublicMainContent_txtExistingPwd').value != document.getElementById('ctl00_PublicMainContent_txtExistingPwdConfirm').value) {
                document.getElementById('ctl00_PublicMainContent_txtExistingPwd').value = "";
                document.getElementById('ctl00_PublicMainContent_txtExistingPwdConfirm').value = "";
                flag++;
                GoTop();
                return false;
            }
        }

        if (document.getElementById('ctl00_PublicMainContent_rcbCQuestion') != null) {
            if (document.getElementById('ctl00_PublicMainContent_rcbCQuestion').value == 'Select from List...') {
                lblmsg.innerHTML = "Please select the Security Question.";
                lblmsg.style.display = "inline";
                flag++;
                GoTop();
                return false;
            }
        }
        if (checkTextBlank('ctl00_PublicMainContent_txtCAnswer') == false) {
            lblmsg.innerHTML = "Please enter the answer for the Security Question.";
            lblmsg.style.display = "inline";
            flag++;
            return false;
        }

        if (CheckCheckBox('ctl00_PublicMainContent_chkCondoAgree') == false) {
            lblmsg.innerHTML = "Please check that you have read and agree to the Terms of Use and Privacy Policy.";
            lblmsg.style.display = "inline";
            flag++;
            GoTop();
            return false;
        }
    }
    if (flag == 0)
        lblmsg.style.display = "none";
        return true;
}


function validateManageUnits() {
    var flag = 0;
    var lblmsg = document.getElementById('lblMessage');

    if (document.getElementById('rcbUnit').value == 'Select from list . . .') {
      
        lblmsg.innerHTML = "Fields marked with an asterisk are required.";
        lblmsg.style.display = "inline";
        flag++;
        return false;
    }
    if (document.getElementById('hidAppliesTo').value == 'P') {
        if (document.getElementById('rcbPaymentFrequency').value == 'Select from list . . .') {
           
            lblmsg.innerHTML = "Fields marked with an asterisk are required.";
            lblmsg.style.display = "inline";
            flag++;
            return false;
        }
    }

    if (document.getElementById('hidAppliesTo').value == 'S') {
        if (document.getElementById('rcbAppliesTo').value == 'Select from list . . .') {
           
            lblmsg.innerHTML = "Fields marked with an asterisk are required.";
            lblmsg.style.display = "inline";
            flag++;
            return false;
        }
    }

    if (document.getElementById('RadDatePickerUnitPayment').value == '') {
        
        lblmsg.innerHTML = "Fields marked with an asterisk are required.";
        lblmsg.style.display = "inline";
        flag++;
        return false;
    }

    if (document.getElementById('txtAmount').value == '') {
        lblmsg.innerHTML = "Fields marked with an asterisk are required.";
        lblmsg.style.display = "inline";
        flag++;
        return false;
    }

    //check only numeric value is entered or not for Check Number
    if (checkNumeric('txtCheckNumber') == false) {
        flag++;
        return false;
    }

    if (flag == 0) {
        return true;
        lblmsg.style.display = "none";
    }
}

function validateUnitDetail() {
    //check only numeric value is entered or not for AssociationFee
    var flag = 0;
   
    if (CheckEmailFormat('ctl00_MainContent_txtEmail') == false) {
        flag++;
        return false;
    }
    if (flag == 0)
        return true;


}

function validateSendMessage() {
    //check only numeric value is entered or not for AssociationFee
    var flag = 0;
    var lblmsg = document.getElementById('ctl00_MainContent_lblMessage');
    //check Units is blank or not
    if (checkDropDownBlank('ctl00_MainContent_RCBAllUnits') == false) {
        flag++;
        lblmsg.innerHTML = "Please select the Unit.";
        lblmsg.style.display = "inline";
        return false;
    }

    //check Subject is blank or not
    if (checkTextBlank('ctl00_MainContent_txtSubject') == false) {
        flag++;
        lblmsg.innerHTML = "Please enter the Subject.";
        lblmsg.style.display = "inline";
        return false;
    }

    if (flag == 0)
        lblmsg.style.display = "none";
        return true;
}

function validatePreviousOwner() {
    //check Unit Number is blank or not
    var flag = 0;
    var lblmsg = document.getElementById('lblMessage');
    if (checkTextBlank('txtPOwnerName') == false) {
        flag++;
        lblmsg.innerHTML = "Please enter the Previous Owner Name.";
        lblmsg.style.display = "inline";
        return false;
    }
    if (flag == 0)
        return true;
        lblmsg.style.display = "none";
}


function validateProviderList() {
    var flag = 0;
    if (document.getElementById('ctl00_MainContent_txtAmount').value == '') {
        alert('Please enter the Expense Amount.');
        SetFocus("ctl00_MainContent_txtAmount");
        flag++;
        return false;
    }

    if (document.getElementById('ctl00_MainContent_rdpDate').value == '') {
        alert('Please enter the Date of Payment.');
        flag++;
        return false;
    }
    if (flag == 0)
        return true;
}

function validateExpenselist() {
    var flag = 0;
    var lblmsg = document.getElementById('lblMessage');
    if (document.getElementById('hidType').getAttribute('value') == 'C') {
        //Check if Recipient textbox blank or not
        if (checkTextBlank('txtRecipient') == false) {
            flag++;
            lblmsg.innerHTML = "Please enter the Recipient Name.";
            lblmsg.style.display = "inline";
            return false;
        }
    }

    if (document.getElementById('hidType').getAttribute('value') == 'S') {
////        if (document.getElementById('rcbRecipient').value == 'Select from List...') {
        if (document.getElementById('rcbPayList').value == 'Select from List...') {
            lblmsg.innerHTML = "Please select the Recipient Name.";
            lblmsg.style.display = "inline";
            document.getElementById('rcbRecipient').focus();
            flag++;
            return false;
        }
    }
    if (document.getElementById('txtAmount').value == '') {
        lblmsg.innerHTML = "Please enter the Expense Amount.";
        lblmsg.style.display = "inline";
        // SetFocus("txtAmount");
        flag++;
        return false;
    }

    if (document.getElementById('rdpDate').value == '') {
        lblmsg.innerHTML = "Please enter the Date of Payment.";
        lblmsg.style.display = "inline";
        flag++;
        return false;
    }
    if (flag == 0) {
        lblmsg.style.display = "none";
        return true;
    }
}

function validateServiceProvider() {
    var flag = 0;
    var lblmsg = document.getElementById('ctl00_MainContent_lblMessage');
    if (document.getElementById('ctl00_MainContent_rcbServiceCategory').value == 'Select from list...') {
        lblmsg.innerHTML = "Please select the Service Category.";
        lblmsg.style.display = "inline";
        flag++;
        return false;
        
    }

    if (flag == 0) {
        return true;
        lblmsg.style.display = "none";
    }
}


function validateFindProvider() {
    //check Name of service provider is blank or not
    var flag = 0;
    var lblmsg = document.getElementById('ctl00_MainContent_lblError');
    if (checkTextBlank('ctl00_MainContent_txtProviderName') == false) {

        lblmsg.innerHTML = "Please enter the Service Provider Name.";
        lblmsg.style.display = "inline";
        flag++;
        return false;
    }
    if (flag == 0) {
        lblmsg.style.display = "none";
        return true;
    }
      
}
function validateLogin() {
    //check Login Name is blank or not
    var flag = 0;
    if (checkTextBlank('ctl00_PublicMainContent_txtLoginID', 'Please enter the Email Address.') == false) {
        flag++;
        return false;
    }

    if (CheckEmailFormat('ctl00_PublicMainContent_txtLoginID') == false) {
        flag++;
        return false;
        
    }

    //check Password is blank or not
    if (checkTextBlank('ctl00_PublicMainContent_txtPassword', 'Please enter the Password.') == false) {
        flag++;
        return false;
    }
    if (flag == 0)
        return true;
}

function validateRetrievePassword(opt) {
   
    if (opt == 1) {
        //check Password is blank or not
        if (checkTextBlank('ctl00_MainContent_txtLoginID') == false) {
            alert('Please enter your User Name.');
            return false;
        }
    }
    if (opt == 2) {
        //check ZipCode is blank or not
        
        //check EmailAddress is blank or not
        if (checkTextBlank('ctl00_MainContent_txtEmailAddress') == false) {
            alert('Please enter the Email Address.');
            return false;
        }
    }
    if (opt == 3) {

        var lblmsg = document.getElementById('ctl00_PublicMainContent_lblAlert'); 
        //check Answer is blank or not
        if (checkTextBlank('ctl00_PublicMainContent_txtAnswer') == false) {
            lblmsg.innerHTML = "Please enter the Answer.";
            lblmsg.style.display = "inline";
            return false;
        }
    }

    if (opt == 4) {
        //check EmailAddress is blank or not for Retreive GroupID
        if (checkTextBlank('ctl00_PublicMainContent_txtEmailAddress') == false) {
            alert('Please enter your email address.');
            return false;
        }
        if (CheckEmailFormat1('ctl00_PublicMainContent_txtEmailAddress') == false)
            return false;
    }
    return true;
}

function validateChangePassword() {
    //check Old Password is blank or not
     var lblmsg = document.getElementById('ctl00_PublicMainContent_lblPassword');
     if (checkTextBlank('ctl00_PublicMainContent_txtOldPassword') == false) {
         lblmsg.innerHTML = "Please enter the Old Password.";
         lblmsg.style.display = "inline";
         return false;
    }
    //check New Password is blank or not
    if (checkTextBlank('ctl00_PublicMainContent_txtNewPassword') == false) {
        lblmsg.innerHTML = "Please enter the New Password.";
        lblmsg.style.display = "inline";
        return false;
    }
    //check Confirm Password is blank or not
    if (checkTextBlank('ctl00_PublicMainContent_txtConfirmPassword') == false) {
        lblmsg.innerHTML = "Please enter the Confirm Password.";
        lblmsg.style.display = "inline";
        return false;
    }
      if (document.getElementById('ctl00_PublicMainContent_txtNewPassword').value != document.getElementById('ctl00_PublicMainContent_txtConfirmPassword').value) {
          lblmsg.innerHTML = "New Password and Confirm Password do not match.";
          lblmsg.style.display = "inline";
          document.getElementById('ctl00_PublicMainContent_txtNewPassword').value = "";
          document.getElementById('ctl00_PublicMainContent_txtConfirmPassword').value = "";
          return false;
      }
      return true;
      lblmsg.style.display = "none";
}

function validateProviderDetail() {
    var flag = 0;
    var lblMessage = document.getElementById('ctl00_MainContent_lblMessage');
    //Check Organization Name is blank or not
    if (checkTextBlank('ctl00_MainContent_txtOrgName') == false) {
        flag++;
        lblMessage.innerHTML = "Please enter the Organization Name.";
        lblMessage.style.display = "inline";
        return false;
    }

    if (checkTextBlank('ctl00_MainContent_txtOrgAddress1') == false) {
        flag++;
        lblMessage.innerHTML = "Please enter the Address.";
        lblMessage.style.display = "inline";
        return false;
    }

    if (checkTextBlank('ctl00_MainContent_txtCity') == false) {
        flag++;
        lblMessage.innerHTML = "Please enter the City.";
        lblMessage.style.display = "inline";
        return false;
    }

    if (document.getElementById('ctl00_MainContent_rcbState').value.trim() == '') {
        lblMessage.innerHTML = "Please select the State.";
        lblMessage.style.display = "inline";
        GoTop();
        flag++;
        return false;
    }

    if (checkTextBlank('ctl00_MainContent_txtZip') == false) {
        flag++;
        lblMessage.innerHTML = "Please enter the Zip Code.";
        lblMessage.style.display = "inline";
        return false;
    }

    if (document.getElementById('ctl00_MainContent_rcbCategory').value == 'Select from list...') {
        lblMessage.innerHTML = "Please select the Service Category.";
        lblMessage.style.display = "inline";
        GoTop();
        flag++;
        return false;
    }

    //check Contact Name is blank or not
    if (checkTextBlank('ctl00_MainContent_txtContactName') == false) {
        flag++;
        lblMessage.innerHTML = "Please enter the Contact Name.";
        lblMessage.style.display = "inline";
        return false;
    }

    if (flag == 0)
        lblMessage.style.display = "none";
        return true;
}

function checkDecimal(ID, MaxLength) {
    ctrlVal = document.getElementById(ID).value;
    if (String(parseInt(ctrlVal)).length > MaxLength) {
        alert('Amount should be less than 99999');
        return false;
    }
}

function validateUnitSetUp() {
    //Check only numeric value is entered or not for Number of units
    if (checkNumeric('ctl00_MainContent_txtUnitNumber') == false)
        return false;

    //Check Number of Units is blank or not
    if (checkTextBlank('ctl00_MainContent_txtUnitNumber', 'Please enter the Number of Units.') == false)
        return false;


    if (document.getElementById('ctl00_MainContent_txtAssociationFees').value == '') {
        alert('Please enter the Association Fees.');
        SetFocus("ctl00_MainContent_txtAssociationFees");
        return false;
    }

    if (CheckStringLengthID('ctl00_MainContent_txtDate', '1', '7', 'Please enter a valid Start Date.', 'Please fill in the Date System should start tracking financials.') == false)
        return false;

    if (MonthYearValidate('ctl00_MainContent_txtDate', "Invalid Date") == false)
        return false;
}

function validateAssociation() {
    var flag = 0;
    var lblMessage = document.getElementById('ctl00_MainContent_lblMessage');
    if (checkTextBlank('ctl00_MainContent_txtAddress1') == false) {
        flag++;
        lblMessage.innerHTML = "All fields are required. Please complete all the fields.";
        lblMessage.style.display = "inline";
        return false;
    }

    if (checkTextBlank('ctl00_MainContent_txtCity') == false) {
        flag++;
        lblMessage.innerHTML = "All fields are required. Please complete all the fields.";
        lblMessage.style.display = "inline";
        return false;
    }
    if (document.getElementById('ctl00_MainContent_rcbState').value.trim() == '') {
        flag++;
        lblMessage.innerHTML = "All fields are required. Please complete all the fields.";
        lblMessage.style.display = "inline";
        return false;
    }

    if (checkTextBlank('ctl00_MainContent_txtZip') == false) {
        flag++;
        lblMessage.innerHTML = "All fields are required. Please complete all the fields.";
        lblMessage.style.display = "inline";
        return false;
    }

    if (checkTextBlank('ctl00_MainContent_txtKeyContact') == false) {
        flag++;
        lblMessage.innerHTML = "All fields are required. Please complete all the fields.";
        lblMessage.style.display = "inline";
        return false;
    }

    if (checkTextBlank('ctl00_MainContent_txtPhone') == false) {
        flag++;
        lblMessage.innerHTML = "All fields are required. Please complete all the fields.";
        lblMessage.style.display = "inline";
        return false;
    }

    if (checkTextBlank('ctl00_MainContent_txtEmail') == false) {
        flag++;
        lblMessage.innerHTML = "All fields are required. Please complete all the fields.";
        lblMessage.style.display = "inline";
        return false;
    }
    var rdpStartDate = document.getElementById('ctl00_MainContent_rdpStartDate');
    if (rdpStartDate != null) {
        if (rdpStartDate.value.trim() == '') {
            flag++;
            lblMessage.innerHTML = "All fields are required. Please complete all the fields.";
            lblMessage.style.display = "inline";
            return false;
        }

    }
    var txtBeginingBalance = document.getElementById('ctl00_MainContent_txtBeginingBalance');
    if (txtBeginingBalance != null) {
        if (rdpStartDate.value.trim() == '') {
            flag++;
            lblMessage.innerHTML = "All fields are required. Please complete all the fields.";
            lblMessage.style.display = "inline";
            return false;
        }
    } 
    
    if (flag == 0)
        return true;
      lblMessage.style.display = "none";
}

/******************************************************************************/
function textCounter(fieldID, maxlimit) {
    maxlimit = maxlimit - 1;
    field = document.getElementById(fieldID);
    if (field != null)
        if (field.value.length > maxlimit)
            field.value = field.value.substring(0, maxlimit);
}

/****************Check string is numeric value or not******************/
function checkNAN(id, msg) {
    var val = trimAll(document.getElementById(id).getAttribute("value"));
    document.getElementById(id).value = val;
    if (isNaN(val) == true) {
        document.getElementById(id).value = '0';
        alert(msg);
        return false;
    }
}

//Checking string length by ID...
function CheckStringLengthID(id, Minlength, Maxlength, MinMsg, MaxMsg) {
    var val = trimAll(document.getElementById(id).value);
    var lblmsg = document.getElementById('ctl00_MainContent_lblMessage');
    document.getElementById(id).value = val;
    var len = eval(val.length);
    if (len < Minlength) {
        lblmsg.style.display = "inline";
        lblmsg.innerHTML = MinMsg;
        document.getElementById(id).focus();
        return false;
    }
    if (len > Maxlength) {
        lblmsg.style.display = "inline";
        lblmsg.innerHTML = MaxMsg;
        document.getElementById(id).focus();
        return false; 353080020327081
    }
}

//Check string is valid date or not
function MonthYearValidate(id, msg) {
   
    var val = trimAll(document.getElementById(id).getAttribute("value"));
    var lblmsg = document.getElementById('ctl00_MainContent_lblMessage');
    if (/^([1-9]|0[1-9]|1[012])\/(19[0-9][0-9]|20[0-9][0-9])/.test(val))
        ;
    else {
        
        lblmsg.style.display = "inline";
        lblmsg.innerHTML = msg;
        document.getElementById(id).focus();
        return false;
    }
}

/********* Check Blank Fields  ***********/
function trimAll(sString) {
    while (sString.substring(0, 1) == ' ') {
        sString = sString.substring(1, sString.length);
    }
    while (sString.substring(sString.length - 1, sString.length) == ' ') {
        sString = sString.substring(0, sString.length - 1);
    }
    return sString;
}


function ValidationTempGrid() {
    var ModeType = document.getElementById('ctl00_MainContent_hidType').value;
    if (isNaN(document.getElementById(ModeType).value)) {
        alert('Enter only numeric value.');
        return false;
    }
    else
        return true;
}

function ValidateAssociationFee1() {
    if (document.getElementById('ctl00_MainContent_hidType').value == "Valid") {
        alert('Invalid Date');
        return false;
    }
    else
        return true;
}

function CheckMaxUnits() {
    var ModeType1 = document.getElementById('ctl00_MainContent_chkUnitNumber').value;
    var lblmsg = document.getElementById('ctl00_MainContent_lblMessage1');
    if (ModeType1 == "E") {
        lblmsg.innerHTML = "Oops! myCondoBooks is provided as a free service to small, self-managed Condo Associations.<br/> If your association has more than 20 units, please call us for registration and pricing.";
        lblmsg.style.display = "inline";
       // alert('Oops! myCondoBooks is provided as a free service to small, self-managed Condo Associations. If your association has more than 20 units, please call us for registration and pricing.');
        return false;
    }
    return true;
    lblmsg.style.display = "none";
}

function CheckUnitNumber() {
    var flag = 0;
    var lblReq = document.getElementById('ctl00_MainContent_lblRequiredMessage');
    var lblmsg = document.getElementById('ctl00_MainContent_lblMessage');
    if (CheckStringLengthID('ctl00_MainContent_txtDate', '1', '7', 'Please fill in the Date System should start tracking financials.', 'Invalid Date') == false) {
        flag++;
        return false;
    }
    if (MonthYearValidate('ctl00_MainContent_txtDate', "Invalid Date") == false) {
        flag++;
        return false;
    }
    var StartDate = document.getElementById('ctl00_MainContent_txtDate').value;
    if (StartDate) {
        var varCurrentDate = new Date();
        varCurrentMonth = varCurrentDate.getMonth();
        varCurrentYear = varCurrentDate.getFullYear();

        varStartMonth = StartDate.substr(0, StartDate.search("/"));
        varStartYear = StartDate.substr(StartDate.search("/") + 1);

      }

    var ModeType1 = document.getElementById('ctl00_MainContent_chkUnitNumber').value;
    if (ModeType1 == "Y") {
        flag++;
        lblmsg.innerHTML = "At least two(2) Units must be set up in order to complete registration.";
        lblmsg.style.display = "inline";
        return false;
    }
   
    var varBeginningBalance = document.getElementById('ctl00_MainContent_txtBeginningBalance').value.trim();
    if (varBeginningBalance == "") {
        flag++;
        lblmsg.innerHTML = "Beginning balance is required field.";
        lblmsg.style.display = "inline";
        lblReq.style.display = "none";
        return false;
    }
    
    if (ModeType1 == "N" || ModeType1 == "E") {
        if (confirmDelete('myCondoBooks will now setup the units entered. Continue?') == true) {
            return true;
        }
        else
            return false;
    }

    if (flag == 0)
        lblmsg.style.display = "none";
        return true;
}


function SetFocus() {
    var GetUnitNumber = document.getElementById('ctl00_MainContent_hidUnitNumber').value;
    alert(GetUnitNumber);
    document.getElementById(GetUnitNumber).focus();
    return true;
}

/****************************************************************************************************/
function validateDashboard() {
    if (document.getElementById('ctl00_MainContent_rdpStartDate').value == '') {
        alert('Please enter the Start Date.');
        return false;
    }

    if (document.getElementById('ctl00_MainContent_rdpEndDate').value == '') {
        alert('Please enter the End Date.');
        return false;
    }
    return true;
}

function GoBottom() {
    window.scrollBy(0, 1000);
}
function GoTop() {
    window.scrollBy(0, -1000);
}

//Display message to user...
function displayMessage(msg) {
    alert(msg);
    return false;
}

//To check Total Bank Accounts used on TransferFunds
function CheckBankAccounts() {
    var objBankAccounts = document.getElementById("ctl00_MainContent_hidBankAccounts");
    if (objBankAccounts) {
        if (objBankAccounts.value == "1") {
            document.getElementById("ctl00_MainContent_lblMessage").style.display = "inline";
            return false;
        }
        else
            return true;
    }
    return true;
}

function ShowHide(ctrlID, option) {
    var ctrl = document.getElementById(ctrlID);

    if (ctrl != null) {
        if (option == "Show")
            ctrl.style.display = "inline";
        else
            ctrl.style.display = "none";
    }
}


//remove space from log text box
function RemoveSpecialSymbols(id) {
    var objid = document.getElementById(id);
    if (objid)
        objid.value = html2entities(objid.value);
}

function html2entities(sometext) {
    var re = /[<>]/g
    if (sometext.length > 2500)
        sometext = sometext.substr(0, 2500);
    return sometext.replace(re, function (m) { return replacechar(m) })
}

function replacechar(match) {
    if (match == "<")
        return ""
    else if (match == ">")
        return ""
}

//function checkMaxLen(txt, maxLen) {
//    try {
//        if (txt.value.length > (maxLen - 1)) {
//            var cont = txt.value;
//            txt.value = cont.substring(0, (maxLen - 1));
//            return false;
//        };
//    }
//    catch (e)
//{ } 
//}



