
// JScript File
// custom validation function 
function ValidateTemplate(source, arguments) {
    try {
        if (!document.getElementById("cvCheckValidations").disabled) {
            var sErrorMessage = '';

            if ((document.getElementById("txtChartURL").value).length == 0)
                sErrorMessage += '<br/><li>' + "Charts URL cannot be blank.";
            if ((document.getElementById("txtChartFTPServer").value).length == 0)
                sErrorMessage += '<br/><li>' + "Chart FTP Server Name cannot be blank.";
            if ((document.getElementById("txtChrtFTPUN").value).length == 0)
                sErrorMessage += '<br/><li>' + "Chart FTP User Name cannot be blank.";
            if ((document.getElementById("txtChrtFTPPort").value).length == 0)
                sErrorMessage += '<br/><li>' + "Chart FTP Port cannot be blank.";
            if ((document.getElementById("txtChrtFTPPwd").value).length == 0)
                sErrorMessage += '<br/><li>' + "Chart FTP Password cannot be blank.";

            /*if (document.getElementById("gvChartConfigData").rows.length == 1) {
                sErrorMessage += '<br/><li>' + "Kindly add atleast one data in ChartDataConfiguration";
            }*/

            if (sErrorMessage.length > 0) {
                showModalPopup(sErrorMessage);
                arguments.IsValid = false;
            }
            else {
                arguments.IsValid = true;
            }
        }
        else {
            arguments.IsValid = true;
        }
    }
    catch (ex)
    { }
}

function showModalPopup(sMessage) {
    document.getElementById('errorDialog').style.display = "block";
    document.getElementById('errorDialog').innerHTML = sMessage;
}

//function to enable disable CompressMOde dropdown and TickDataTradingDays - for CHART DETAILS MENU
function OnDataTypeChange() {
    if (document.getElementById('ddlDataType').options[document.getElementById('ddlDataType').selectedIndex].value == "Intraday") {
        document.getElementById("ddlComprsnMode").disabled = false;
        document.getElementById("txtTickTrdngDays").disabled = false

    }
    else {
        document.getElementById("ddlComprsnMode").disabled = true;
        document.getElementById("txtTickTrdngDays").disabled = true;
    }
}

function Text_NumKeyPress(e) {
    var iKC;
    iKC = GetKeyCode(e);
    if (iKC < 48 || iKC > 57) {
        return false;
    }
}
function GetKeyCode(e) {
    try {
        if (e.which != null) { // Look for a Mozilla-compatible browser
            return e.which;
        }
        else { // Must be an IE-compatible Browser
            return e.keyCode;
        }
    }
    catch (e) {
        LMsg('GetKeyCode : ' + e.message);
    }
}


