/* 
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
var ids;
var types;
var dropDownObj;
var formNum = 0;
var nextFunctionCall = "";
var browserName = navigator.appName;
var displayStyle = "block";
var objFileName = null;
var objClaimID = null;
var objFormNumber = "1";
var searchType = "";
var currentTab = "-1";
var tabs = "0";
var naObj = null;
var ifscName;

if (browserName == "Netscape") {
    displayStyle = "table-row";
}

function hideShowJointHolder() {
    try {
        if (document.forms[0].appHoldingMode.value == 1) {
            document.getElementById("app2Title").parentNode.innerHTML = "<span id='span_single' class='display'>N.A.</span>" + document.getElementById("app2Title").parentNode.innerHTML;
            document.getElementById("app2Title").style.display = "none";
            //document.forms[0].app2FirstName.parentNode.innerHTML="<span class='display'>N.A.</span>"+document.forms[0].app2FirstName.parentNode.innerHTML;
            //document.forms[0].app2FirstName.style.display="none";

        } else {
            if (document.getElementById("span_single")) {
                document.getElementById("app2Title").parentNode.removeChild(document.getElementById("app2Title").parentNode.firstChild);
            }
            document.getElementById("app2Title").style.display = "block";
            //document.forms[0].app2FirstName.parentNode.removeChild(document.forms[0].app2FirstName.parentNode.firstChild);
            //document.forms[0].app2FirstName.style.display="block";

        }
    } catch (err) {
        alert(err.toString());
    }
}

function cutoffdate() {
    var benDOB = document.forms[0].appBenDOB.value;
    var cutOffDate = document.forms[0].minorCutOffDate.value;
    var toDay = document.forms[0].toDay.value;
    var yyyymmddBenDOB = "";
    var yyyymmddToDay = "";
    if (document.forms[0].appSchemeCode.value == "011" || document.forms[0].appSchemeCode.value == "012") {
        if (benDOB != "") {
            yyyymmddBenDOB = yyyymmddBenDOB.concat(benDOB.substr(6, 4), benDOB.substr(3, 2), benDOB.substr(0, 2));
            yyyymmddToDay = yyyymmddToDay.concat(cutOffDate.substr(6, 4), cutOffDate.substr(3, 2), cutOffDate.substr(0, 2));
            if (parseInt(yyyymmddBenDOB, 10) < yyyymmddToDay) {
                alert("Only for Minor Beneficiary");
                document.forms[0].appBenDOB.focus();
                return false;
            } else {
                return true;
            }
        }
        return false;
    } else {
        return true;
    }
}


function saveContinue(actionType, currentTab) {
    var action = document.forms[0].action;
    document.forms[0].action = "saveContinue.do?actionType=" + actionType;
    if (currentTab != -1) {
        document.forms[0].target = "dummyframe";
    } else {
        //document.forms[0].target="";
    }
    document.forms[0].submit();
    document.forms[0].action = action;
    if (currentTab != -1) {
        document.forms[0].target = "";
        document.getElementById("mytabber").tabber.tabShow(currentTab);
    }
}

function validateMFApplication(currentTab) {
    var alertMessage = "";
    alertMessage = alertMessage + checkForZero(document.forms[0].appSchemeCode, "Please Select Scheme");
    alertMessage = alertMessage + checkForZero(document.forms[0].appSchemeOption, "Please Select Scheme Option");
    alertMessage = alertMessage + checkForBlank(document.forms[0].appID, "Please Enter Applicant ID");
    alertMessage = alertMessage + checkForBlank(document.forms[0].appPAN, "Please Enter Applicant PAN No.");
    if (currentTab == '-1') {
        alertMessage = alertMessage + checkForBlank(document.forms[0].appFirstName, "Please Enter Applicant First Name");
        alertMessage = alertMessage + checkForBlank(document.forms[0].appResAdd1, "Please Enter Applicant Address Line 1");
        alertMessage = alertMessage + checkForNo(document.forms[0].appPANCopy, "Please Enclosed Copy of PAN Card");
        alertMessage = alertMessage + checkForNo(document.forms[0].appKYCCopy, "Please Enclosed Copy of KYC");
        if (document.forms[0].appSchemeCode.value == "011" || document.forms[0].appSchemeCode.value == "012") {
            alertMessage = alertMessage + checkForBlank(document.forms[0].appBenFirst, "Please Enter Beneficiary First Name");
            alertMessage = alertMessage + checkForBlank(document.forms[0].appBenDOB, "Please Enter Beneficiary Date of Birth");
            alertMessage = alertMessage + checkForBlank(document.forms[0].appParantFirst, "Please Enter Beneficiary Parent First Name");
        }
        if (document.forms[0].appSchemeCode.value != "015") {
            alertMessage = alertMessage + checkForZero(document.forms[0].invfrequency, "Please Select Payment Interval");
            alertMessage = alertMessage + checkForZero(document.forms[0].invnoofInstallments, "Please Select No. of Installments");
        }
        alertMessage = alertMessage + checkForZero(document.forms[0].invSOF, "Please Select Source of Fund");
        alertMessage = alertMessage + checkForZero(document.forms[0].appAnualIncome, "Please Select Annual Income Slab");
        alertMessage = alertMessage + checkForZero(document.forms[0].instrBankName, "Please Select Bank");
        alertMessage = alertMessage + checkForZero(document.forms[0].invInstrType, "Please Select Instrument Type");
        alertMessage = alertMessage + checkForZero(document.forms[0].invInstrAmount, "Please Enter Instrument Amount");
        alertMessage = alertMessage + checkForZero(document.forms[0].invInstrNo, "Please Enter Instrument Number");
        alertMessage = alertMessage + checkForZero(document.forms[0].invInstrDate, "Please Enter Instrument Date");
        alertMessage = alertMessage + checkForZero(document.forms[0].appAmt, "Please Enter Application Amount");
    }
    if (alertMessage != "") {
        displayErrorMessage("<ol>" + alertMessage + "</ol>")
        return false;
    } else {
        if (currentTab != '-1') {
            saveContinue('ContinueSave', currentTab);
        } else {
            //saveContinue('SaveMFApplication',currentTab);
        }
        return true;
    }
}

function displayErrorMessage(alertMessage) {
    var divElem = document.getElementById("messagebody");
    divElem.innerHTML = "<h3 class=lefttablehead>Cannot Submit Due To Following Errors</h3>" + alertMessage +
    "<p align=center><input align='center' type=button class='modalbutton' value='Close' onclick='javascript:popupClose();'></p>"
    document.getElementById("opaquepopup").style.display = '';
    document.getElementById("coverpopup").style.display = '';
    document.getElementById("opaquepopup").style.display = 'block';
    document.getElementById("opaquepopup").setAttribute("align", "center");
    document.getElementById("coverpopup").style.display = 'block';
    document.getElementById("coverpopup").style.top = (window.screen.height / 4) + "px";
    document.getElementById("coverpopup").style.left = (window.screen.width / 3) + "px";
}

function changeInputColor(inputObj, onError) {
    if (onError) {
        inputObj.style.backgroundColor = "#FFFACD";
    } else {
        inputObj.style.backgroundColor = "#FFFFFF";
    }
}

function checkForBlank(inputObj, errorMsg) {
    var retValue = "";
    if (inputObj.value.replace(/^\s+|\s+$/g, '') == "" || inputObj.value == "-1") {
        retValue = "<li class=modalline>" + errorMsg + ".</li>";
        changeInputColor(inputObj, true);
    } else {
        changeInputColor(inputObj, false);
    }
    return retValue;
}

function checkForNo(inputObj, errorMsg) {
    var retValue = "";
    if (inputObj.checked) {
        changeInputColor(inputObj, false);
    } else {
        retValue = "<li class=modalline>" + errorMsg + ".</li>";
        changeInputColor(inputObj, true);
    }
    return retValue;
}

function checkForZero(inputObj, errorMsg) {
    var retValue = "";
    if (inputObj.value.replace(/^\s+|\s+$/g, '') == "" || inputObj.value == "0") {
        retValue = "<li class=modalline>" + errorMsg + ".</li>";
        changeInputColor(inputObj, true);
    } else {
        changeInputColor(inputObj, false);
    }
    return retValue;
}

function checkForPositive(inputObj, errorMsg) {
    var retValue = "";
    if (inputObj.value.replace(/^\s+|\s+$/g, '') == "" || inputObj.value == "0" || inputObj.value > 0) {
        retValue = "<li class=modalline>" + errorMsg + ".</li>";
        changeInputColor(inputObj, true);
    } else {
        changeInputColor(inputObj, false);
    }
    return retValue;
}

function checkForNegative(inputObj, errorMsg) {
    var retValue = "";
    if (inputObj.value == "") {
        inputObj.value = "0";
    }
    if (inputObj.value < 0) {
        retValue = "<li class=modalline>" + errorMsg + ".</li>";
        changeInputColor(inputObj, true);
    } else {
        changeInputColor(inputObj, false);
    }
    return retValue;
}

function filterSchemeOption(ids, objVar) {
    dropDownObj = objVar;
    var od = document.getElementsByName(ids);
    if (document.getElementById(ids) == null) {
        od[0].id = od[0].name;
    }
    var selectedValue = document.getElementById(ids).value;
    var url = "dropdownajax.do?actionType=getXMLScheme&filteron=" + selectedValue;
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = setSchemeOptionDrowDown;
        req.open("GET", url, true);
        req.send(null);
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLObject");
        if (req) {
            req.onreadystatechange = setSchemeOptionDrowDown;
            req.open("GET", url, true);
            req.send();
        }
    }
}

function setSchemeOptionDrowDown() {
    var optValue;
    var optName;
    var headingPresent = false;
    if (req.readyState <= 3) {
    } else if (req.readyState == 4) {
        if (req.status == 200) {
            document.getElementById(dropDownObj).options.length = 1;
            if (document.getElementById(dropDownObj).value == "0") {
                headingPresent = true;
            }
            var response = req.responseXML.documentElement;
            if (response != null) {
                if (response.childNodes.length > 0) {
                    for (var i = 0; i < response.childNodes.length / 2; i++) {
                        if (headingPresent) {
                            document.getElementById(dropDownObj)[i + 1] = null;
                        } else {
                            document.getElementById(dropDownObj)[i] = null;
                        }
                        optValue = response.getElementsByTagName("id")[i].firstChild.data;
                        optName = xmldecode(response.getElementsByTagName("name")[i].firstChild.data);
                        optName = xmldecode(optName);
                        if (headingPresent) {
                            document.getElementById(dropDownObj).options[i + 1] = new Option(optName, optValue);
                        }
                        else {
                            document.getElementById(dropDownObj).options[i] = new Option(optName, optValue);
                        }
                    }
                } else {
                    document.getElementById(dropDownObj).options.length = 1;
                }
            }
        }
    }
}

function schemeFieldDisplay(schemeCD, schemeOptionCD) {
    if (document.forms[0].appSchemeCode.value != "0" && document.forms[0].appSchemeOption.value != "0") {
        var url = "dropdownajax.do?actionType=getXMLSchemeFieldControl&schemeCode=" + document.forms[0].appSchemeCode.value + "&schemeOption=" + document.forms[0].appSchemeOption.value;
        if (window.XMLHttpRequest) {
            req = new XMLHttpRequest();
            req.onreadystatechange = setSchemeFieldDispaly;
            req.open("GET", url, true);
            req.send(null);
        } else if (window.ActiveXObject) {
            req = new ActiveXObject("Microsoft.XMLObject");
            if (req) {
                req.onreadystatechange = setSchemeFieldDispaly;
                req.open("GET", url, true);
                req.send();
            }
        }
    }
}
function nextObj() {
    document.getElementById("appID").focus();
}

function setSchemeFieldDispaly() {
    var optValue;
    var optName;
    var acnt = 0;
    var optType;
    var headingPresent = false;
    if (req.readyState <= 3) {
    } else if (req.readyState == 4) {
        //to display all tabs
        document.getElementById("personaldet").className = "tabbertab";
        document.getElementById("contactdet").className = "tabbertab";
        document.getElementById("benefdet").className = "tabbertab";
        document.getElementById("jointAltdet").className = "tabbertab";
        document.getElementById("nomdet").className = "tabbertab";
        document.getElementById("bankdet").className = "tabbertab";
        document.getElementById("paydet").className = "tabbertab";
        document.getElementById("ulipdet").className = "tabbertab";
        //alert(show.value);
        document.getElementById("mytabber").removeChild(document.getElementById("mytabber").childNodes[0]);
        document.getElementById("mytabber").tabber.init(document.getElementById("mytabber"));
        backTab(0);
        //end
        if (req.status == 200) {
            var response = req.responseXML.documentElement;
            if (naObj != null) {
                for (var z = 0; z < naObj.length; z++) {
                    optValue = naObj[z];
                    //document.getElementById(optValue).
                    document.getElementById(optValue).parentNode.removeChild(document.getElementById(optValue).parentNode.firstChild);
                    document.getElementById(optValue).style.display = "block";
                }
                naObj = new Array();
            }
            if (response != null) {
                if (response.childNodes.length > 0) {
                    if (naObj == null) {
                        naObj = new Array();
                    }
                    try {
                        for (var i = 0; i < response.childNodes.length; i++) {
                            optValue = response.getElementsByTagName("SV_VALIDATE_ID")[i].firstChild.data;
                            optType = response.getElementsByTagName("SV_VALIDATE_TYPE")[i].lastChild.data;
                            //alert("optValue "+optValue+" optType "+optType);

                            if (optType == "F") {
                                if (document.getElementById(optValue)) {
                                    optName = document.getElementById(optValue).parentNode.innerHTML;
                                    naObj[acnt] = optValue;
                                    acnt = acnt + 1;
                                    document.getElementById(optValue).parentNode.innerHTML =
                                    "<span id='span_na' class='display'>N.A.</span>" + optName;
                                    document.getElementById(optValue).style.display = "none";
                                }
                            } else if (optType == "T") {
                                var addNode = document.getElementById(optValue);
                                var mainNode = document.getElementById("mytabber");
                                //alert(show.value);
                                addNode.className = "tabbertabhide";
                                //alert(show.value);
                                mainNode.removeChild(mainNode.childNodes[0]);
                                mainNode.tabber.init(mainNode);
                                backTab(0);
                            }

                            /*if(headingPresent){
                            document.getElementById(dropDownObj)[i+1] = null;
                            }else{
                            document.getElementById(dropDownObj)[i] = null;
                            }
                            optValue = response.getElementsByTagName("id")[i].firstChild.data;
                            optName = xmldecode(response.getElementsByTagName("name")[i].firstChild.data);
                            optName = xmldecode(optName);
                            if(headingPresent){
                            document.getElementById(dropDownObj).options[i+1] = new Option(optName,optValue);
                            }
                            else{
                            document.getElementById(dropDownObj).options[i] = new Option(optName,optValue);
                            }
                            */
                        }
                    } catch (err) {
                        //alert(err.toString());
                    }
                } else {
                    //document.getElementById(dropDownObj).options.length = 1;
                }
            }
        }
    }
}

function xmldecode(message) {
    var returnValue = message;
    while (returnValue.indexOf("/?/") != -1) {
        returnValue = returnValue.replace("/?/", "&");
    }
    return returnValue;
}

function searchApplicantData(id, searchType) {
    var searchFor = id.value;
    this.searchType = searchType;
    if (searchFor == null || searchFor.length != 10) {
        if (searchType == "P")
            alert("Please enter 10 digit PAN No.");
        else
            alert("Please enter 10 digit Applicant ID.");
    } else {
        var url = 'dropdownajax.do?actionType=searchIDorPAN&'
        if (searchType != "") {
            url = url + "searchFor=" + searchType + "#" + searchFor;
            if (window.XMLHttpRequest) {
                req = new XMLHttpRequest();
                req.onreadystatechange = fillApplicantData;
                req.open("GET", url, true);
                req.send(null);
            } else if (window.ActiveXObject) {
                req = new ActiveXObject("Microsoft.XMLHTTP");
                if (req) {
                    req.onreadystatechange = fillApplicantData;
                    req.open("GET", url, true);
                    req.send();
                }
            }
        }
    }
}

function fillApplicantData() {
    if (req.readyState <= 3) {
        //document.getElementById('load').innerHTML = "Loading...<img src=<%=request.getContextPath()%>/img/indicator.gif />";
    } else if (req.readyState == 4) {
        //document.getElementById('load').innerHTML = "";
        var apppan = "";
        var appid = "";
        if (req.status == 200) {
            var response = req.responseXML.documentElement;
            var eleName = "";
            var eleType = "";
            if (response.childNodes.length > 0) {
                for (var x = 0; x < document.forms[0].elements.length; x++) {
                    eleName = document.forms[0].elements[x].name;
                    eleType = document.forms[0].elements[x].type;
                    if (eleType != "reset" && eleType != "submit" && eleType != "button") {
                        try {
                            document.forms[0].elements[x].value = response.getElementsByTagName(eleName)[0].firstChild.data;
                        } catch (err) {
                            //document.forms[0].elements[x].value = "";
                        }
                    }
                }
                apppan = (document.getElementById("appID").value);
                appid = (document.getElementById("appPAN").value);
                if (searchType == "P" & apppan == "") {
                    alert("PAN Not Registered with VLE Please Register...!");
                    document.getElementById("appPAN").value = "";
                    document.getElementById("appPAN").focus();
                } else if (searchType == "I" & appid == "") {
                    alert("Applicant ID not Found...!");
                    document.getElementById("appID").value = "";
                    document.getElementById("appID").focus();
                }
                //document.getElementById('load').innerHTML = "Code not Found";
            } else {
                if (searchType == "P" & apppan == "") {
                    alert("PAN Not Registered with VLE Please Register...!");
                    document.getElementById("appPAN").value = "";
                    document.getElementById("appPAN").focus();
                } else if (searchType == "I" & appid == "") {
                    alert("Applicant ID not Found...!");
                    document.getElementById("appID").value = "";
                    document.getElementById("appID").focus();
                }
                //document.getElementById('load').innerHTML = "Code not Found";
            }
        }
    }
}

function checkField(obj, maxLength, message, type) {
    if (obj.value.toString().length != maxLength & obj.value.toString().length > 0) {
        alert(message);
        obj.focus();
        return false;
    } else if (obj.value.toString().length > 0 & obj.value.toString().length == 10) {
        searchApplicantData(obj, type);
    }
    return true;
}

function saveApplicationData() {
    if (req.readyState <= 3) {
        //document.getElementById('load').innerHTML = "Loading...<img src=<%=request.getContextPath()%>/img/indicator.gif />";
    } else if (req.readyState == 4) {
        //document.getElementById('load').innerHTML = "";
        if (req.status == 200) {
            var response = req.responseXML.documentElement;
            alert("return response.... " + response);
        }
    }
}

function backTab(currentTab) {
    document.getElementById("mytabber").tabber.tabShow(currentTab - 1);
}

//Filter Bank Branch Drop Down

function filterBankBranch(ids, objVar) {
    dropDownObj = objVar;
    var od = document.getElementsByName(ids);
    if (document.getElementById(ids) == null) {
        od[0].id = od[0].name;
    }
    var selectedValue = document.getElementById(ids).value;

    var url = "dropdownajax.do?actionType=getBranchDetails&bankName=" + selectedValue;
    if (window.XMLHttpRequest) {

        req = new XMLHttpRequest();
        req.onreadystatechange = setBankBranchDrowDown;
        req.open("GET", url, true);
        req.send(null);
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLObject");
        if (req) {
            req.onreadystatechange = setBankBranchDrowDown;
            req.open("GET", url, true);
            req.send();
        }
    }
}

function setBankBranchDrowDown() {
    var optValue;
    var optName;
    var headingPresent = false;
    if (req.readyState <= 3) {
    } else if (req.readyState == 4) {
        if (req.status == 200) {
            document.getElementById(dropDownObj).options.length = 1;
            if (document.getElementById(dropDownObj).value == "0") {
                headingPresent = true;
            }
            var response = req.responseXML.documentElement;
            if (response != null) {
                if (response.childNodes.length > 0) {
                    for (var i = 0; i < response.childNodes.length / 2; i++) {
                        if (headingPresent) {
                            document.getElementById(dropDownObj)[i + 1] = null;
                        } else {
                            document.getElementById(dropDownObj)[i] = null;
                        }
                        //  optValue = xmldecode(response.getElementsByTagName("id")[i].firstChild.data);
                        optName = xmldecode(response.getElementsByTagName("name")[i].firstChild.data);
                        optName = xmldecode(optName);
                        if (headingPresent) {
                            document.getElementById(dropDownObj).options[i + 1] = new Option(optName, optName);
                        } else {
                            document.getElementById(dropDownObj).options[i] = new Option(optName, optName);
                        }
                    }
                } else {
                    document.getElementById(dropDownObj).options.length = 1;
                }
            }
        }
    }
}


//Set IFSC Drop Down

function FillIFSCData(branch, bank, ifsc) {
    var branchName = document.getElementById(branch).value;
    var bankName = document.getElementById(bank).value;
    ifscName = ifsc;
    var url = "dropdownajax.do?actionType=getIFSCDetail";
    if (document.getElementById(branch) != null) {
        url = url + "&branchName=" + branchName + "&bankName=" + bankName;
        //alert(branchName+"Bank "+bankName+"URL:"+url);
        if (window.XMLHttpRequest) {
            req = new XMLHttpRequest();
            req.onreadystatechange = fillIData;
            req.open("GET", url, true);
            req.send(null);
        } else if (window.ActiveXObject) {
            req = new ActiveXObject("Microsoft.XMLHTTP");
            if (req) {
                req.onreadystatechange = fillIData;
                req.open("GET", url, true);
                req.send();
            }
        }
    }
}

function fillIData() {
    if (req.readyState <= 3) {
        // document.getElementById('load').innerHTML = "Loading...<img src=images/indicator.gif />";
    } else if (req.readyState == 4) {
        //document.getElementById('load').innerHTML = "";
        if (req.status == 200) {
            var response = req.responseXML.documentElement;
            var display = "";
            var value = "";
            if (response != null && response.childNodes.length > 0) {
                try {
                    value = response.getElementsByTagName("ifsc")[0].childNodes[0].nodeValue;
                    document.getElementById(ifscName).disabled = true;
                    document.getElementById(ifscName).value = value;
                } catch (err) {
                }
            } else {
                document.getElementById(ifscName).disabled = false;
                document.getElementById(ifscName).value = "";
            }
        }
    }
}

//Form Validations

function checkForm() {
    var appFname = document.getElementById("appFirstName").value;
    alert("Enter Valid Name" + appFname);
    if (appFname == null || appFname == "") {
    }
}


function showOtherText() {
    var str = document.getElementById("applicantStatus").options[document.getElementById("applicantStatus").selectedIndex].text;
    if (str == "OTHERS") {
        document.getElementById("applicantOtherStatus").disabled = false;
    } else {
        document.getElementById("applicantOtherStatus").disabled = true;
    }
}

//function showchequedetails(ele)
//{
//    var str=document.getElementById("applicantStatus").options[document.getElementById("applicantStatus").selectedIndex].text;
//    if(str=="AUTO DEBIT (RBI's ECS (DEBIT CLEARING)/DIRECT DEBIT)")
//    {
//        document.getElementById("applicantOtherStatus").disabled=false;
//    }
//    else
//    {
//        document.getElementById("applicantOtherStatus").disabled=true;
//    }
//
//}

function isNumberKey(evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode;
    //alert(charCode);
    if ((parseInt(charCode) >= 48 && parseInt(charCode) <= 57) || parseInt(charCode) == 8 || parseInt(charCode) == 9) {
        return true;
    }
    else if (parseInt(charCode) >= 96 && parseInt(charCode) <= 105) {
        return true;
    }
    return false;
}
/*
function  isPAN(elem){
alert(elem.value)
var alphaExp = /^([a-zA-Z]{5})([0-9]{4})([A-Za-z]{1})$/;
// alert(elem.value.match(alphaExp));
if(elem.value.match(alphaExp)) return true;
else {
alert("Please Enter valid PAN");
elem.value="";
elem.focus();        
return false;
}
}*/
function alpha(elem, e) {
    var k;
    document.all ? k = e.keyCode : k = e.which;
    if ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57)) {
        //if((k > 96 && k < 123))
        {
            elem.value = elem.value.toUpperCase();
        }
        return true;
    }
    else
        return false;
}
function isAmount(evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode;
    //alert(charCode);
    if ((parseInt(charCode) >= 48 && parseInt(charCode) <= 57) || parseInt(charCode) == 8 || parseInt(charCode) == 9 || parseInt(charCode) == 190 || parseInt(charCode) == 110) {
        return true;
    }
    else if (parseInt(charCode) >= 96 && parseInt(charCode) <= 105) {
        return true;
    }
    return false;
}

function isDOB(ele) {
    var dat = ele.value;
    var day, mon, year;
    day = dat.substr(0, 2);
    mon = dat.substr(3, 2);
    year = dat.substr(6, 4);
    var dat2 = new Date(mon + "/" + day + "/" + year);
    var dat1 = new Date;
    if (dat2 >= dat1) {
        alert("Enter Valid DOB");
        return false;
    } else {
        return true;
    }
}

//Scheme Validations

function checkDobBen() {
    var sch_code = document.getElementById("appSchemeCode");
    var dob = document.getElementById("appBenDOB").value;
    var day = dob.substr(0, 2);
    var mon = dob.substr(3, 2);
    var year = dob.substr(6, 4);
    var dat2 = new Date(mon + "/" + day + "/" + year);
    var dat1 = new Date();
    if (sch_code.options[sch_code.selectedIndex].text == "CCP ADVANTAGE FUND" || sch_code.options[sch_code.selectedIndex].text == "CCP CAREER BALANCED PLAN") {
        if (dat1.getFullYear() - dat2.getFullYear() > 15) {
            alert("Invalid");
        }
    }
}


function emailValidator(elem) {
    var emailExp = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    if (emailExp.test(elem.value) == true)
        return true;
    else {
        alert("Please Enter valid email Id");
        return false;
    }
}

function addRows(tablename) {
    var size = 0;
    var prevsize = 0;
    var tableID = document.getElementById(tablename);
    var rows = tableID.getElementsByTagName("tr");
    var rowSize = rows.length;
    var col = rows[rowSize - 1].getElementsByTagName("td");
    var lastRowValues = rows[rowSize - 1].getElementsByTagName("input");
    //                for(var y = 0;y<lastRowValues.length;y++){
    //                    if(lastRowValues[y].value==""){
    //                        alert("Fill all information.");
    //                        lastRowValues[y].focus();
    //                        //break;
    //                        return false;
    //                    }
    //                }
    var lastrow = col[0].parentNode;
    var newrow = lastrow.cloneNode(true);
    lastrow.parentNode.appendChild(newrow);
    newrow.style.display = "table-row";
    rows = tableID.getElementsByTagName("tr");
    rowSize = rows.length;

    var inputs = rows[rowSize - 1].getElementsByTagName("input");
    var img = rows[rowSize - 1].getElementsByTagName("img");

    var select = rows[rowSize - 1].getElementsByTagName("select");
    size = rowSize - 2;
    for (var x = 0; x < inputs.length; x++) {
        //alert(inputs[x].value);
        if (x == 0 && tablename == "instrdetails") {
            //inputs[x].value = "";
            inputs[x].name = "instrBank";

            inputs[x].value = document.getElementById("appBankName").value;
        }
        if (x == 1 && tablename == "instrdetails") {
            inputs[x].name = "instrBranch";
            //alert(document.getElementById("appBranchName").value);
            inputs[x].value = document.getElementById("appBranchName").value;

        }
        if (x == 2 && tablename == "instrdetails") {
            inputs[x].name = "instrPin";

            inputs[x].value = document.getElementById("appBankPin").value;

        }
        if (x == 3 && tablename == "instrdetails") {
            inputs[x].name = "instrAccNo";
            // alert(document.getElementById("appAccountNumber").value);
            inputs[x].value = document.getElementById("appAccountNumber").value;

        }
        if (x == 4 && tablename == "instrdetails") {

            inputs[x].name = "instrNo";
        }

        if (x == 5 && tablename == "instrdetails") {

            inputs[x].id = "instrdetails" + size;
            inputs[x].name = "instrDate";
            img[0].onclick = function () {
                JACS.show(document.getElementById(inputs[5].id), this);
            };
            //inputs[5].onblur=function(){return isDateSIP(document.getElementById(inputs[5].id));};
        }

        if (x == 0) {
            //alert("in input ");
            //inputs[x].focus();
        }
    }
    for (x = 0; x < select.length; x++) {
        if (x == 0 && tablename == "instrdetails") {
            //alert("in select");
            select[x].focus();
            break;
        }
    }
    return false;
}


function filterInstallments(ids, objVar) {
    dropDownObj = objVar;
    var od = document.getElementsByName(ids);
    if (document.getElementById(ids) == null) {
        od[0].id = od[0].name;
    }
    var selectedValue = document.getElementById(ids).options[document.getElementById(ids).selectedIndex].text;
    //alert(selectedValue);
    var url = "dropdownajax.do?actionType=getInstallment&interval=" + selectedValue;
    if (window.XMLHttpRequest) {

        req = new XMLHttpRequest();
        req.onreadystatechange = setInstallmentDrowDown;
        req.open("GET", url, true);
        req.send(null);
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLObject");
        if (req) {
            req.onreadystatechange = setInstallmentDrowDown;
            req.open("GET", url, true);
            req.send();
        }
    }
}


function setInstallmentDrowDown() {
    var optValue;
    var optName;
    var headingPresent = false;

    if (req.readyState <= 3) {
    } else if (req.readyState == 4) {
        if (req.status == 200) {
            document.getElementById(dropDownObj).options.length = 1;
            if (document.getElementById(dropDownObj).value == "0") {
                headingPresent = true;
            }
            var response = req.responseXML.documentElement;
            if (response != null) {
                if (response.childNodes.length > 0) {

                    for (var i = 0; i < response.childNodes.length / 2; i++) {

                        if (headingPresent) {
                            document.getElementById(dropDownObj)[i + 1] = null;

                        } else {
                            document.getElementById(dropDownObj)[i] = null;
                        }

                        optValue = xmldecode(response.getElementsByTagName("id")[i].firstChild.data);

                        optName = xmldecode(response.getElementsByTagName("name")[i].firstChild.data);

                        optName = xmldecode(optName);
                        if (headingPresent) {
                            document.getElementById(dropDownObj).options[i + 1] = new Option(optName, optValue);
                        } else {
                            document.getElementById(dropDownObj).options[i] = new Option(optName, optValue);
                        }
                    }
                } else {
                    document.getElementById(dropDownObj).options.length = 1;
                }
            }
        }
    }
}

function yesNo(objCheckBox) {
    if (objCheckBox.checked) {
        objCheckBox.value = "Y"
    } else {
        objCheckBox.value = "N"
    }
}

function activeTab(show) {
    var addNode = document.getElementById("sipdet");
    var adNode = document.getElementById("tdrdet");
    var mainNode = document.getElementById("mytabber");
    //alert(show.value);
    if (show.checked) {
        addNode.className = "tabbertab";
        adNode.className = "tabbertab";
        show.value = 'Y';
    } else {
        addNode.className = "tabbertabhide";
        adNode.className = "tabbertabhide";
        show.value = 'N';
    }
    //alert(show.value);
    mainNode.removeChild(mainNode.childNodes[0]);
    mainNode.tabber.init(mainNode);
    backTab(0);
}

function showSIPOptions() {
    var cheque = document.getElementById("chequedetails");
    var ecs = document.getElementById("ecsdetails");
    var sipopt = document.getElementById("sipOpt");
    var instr = document.getElementById("instrdetails");
    if (sipopt.value == 1) {
        ecs.style.display = "table";
        cheque.style.display = "none";
        instr.rows[1].style.display = "none";
        instr.style.display = "none";
    } else if (sipopt.value == 2) {
        cheque.style.display = "table";
        ecs.style.display = "none";
        instr.rows[1].style.display = "none";
        instr.style.display = "table";
    } else if (sipopt.value == 0) {
        // alert(sipopt.value);
        ecs.style.display = "none";
        cheque.style.display = "none";
        instr.rows[1].style.display = "none";
        instr.style.display = "none";
    }
}

function showGrid() {
    var limit = document.getElementById("sipNumberofCheques");
    var table = document.getElementById("instrdetails");
    var rows = table.rows;
    //alert(rows.length);
    var length = rows.length;

    if (length > 2) {
        for (i = 2; i < length; i++) {
            //alert("dele "+i);
            table.deleteRow(-1);
        }
    }
    //alert(limit.value);
    for (j = 0; j < (limit.value); j++) {
        //alert("add "+j);
        addRows("instrdetails");

    }
    table.rows[1].style.display = "none";
    table.style.display = "table";
    //alert(table.rows.length);
}

//slide image javascript
var aWFMNBspm = "#F7C01E";
var awFMNBspm = 2;
var AWFmNBspm = 10;
var AWFMNBspm = 6;
var awfmnBSpm = "ridge";
var AwfmnBSpm = "#F7C01E";
var aWfmnBSpm = "arial,helvetica,verdana";
var awFmnBSpm = 12;
var awfMnBSpm = "#000000";
var AWfmnBSpm = "bold";
var aWFmnBSpm = "normal";
awFMnBSpm = document.getElementById;
AWFmnBSpm = document.getElementById && document.all;
aWFMnBSpm = document.getElementById && !document.all;
AWFMnBSpm = document.layers;
var awfmnbSPm;
var AwfmnbSPm;
var aWfmnbSPm;
var awFmnbSPm;
var awfMnbSPm;
var AWfmnbSPm;
var aWFmnbSPm = 2;
var awFMnbSPm;
var AWFmnbSPm = "";
//var AWFmnbSPm="This script was made by USINGIT.COM (C)2002 All rights reserved. Visit www.usingit.com for more free scripts!";

function showTip(aWFMnbSPm, AWFMnbSPm, awfmnbsPM) {
    aWfmnbSPm = aWFMnbSPm;
    if (awFMnBSpm) {
        awfmnbSPm = "aWFmNBspm2";
        AwfmnbSPm = document.getElementById ? document.getElementById(awfmnbSPm) : '';
        AWfmnbSPm = (AWFmnBSpm) ? document.body.clientHeight : (aWFMnBSpm) ? window.innerHeight : 0;
        awFmnbSPm = AWFMnbSPm + 2 * AWFMNBspm;
        awfMnbSPm = awfmnbsPM + 2 * AWFMNBspm;
        AwfmnbSPm.style.width = awFmnbSPm;
        AwfmnbSPm.style.height = awfMnbSPm;
        AwfmnbSPm.style.top = (AWFmnBSpm) ? document.body.scrollTop + AWfmnbSPm : window.pageYOffset + AWfmnbSPm;
        AwfmnbSPm.innerHTML = "";
        var tipDIVCodes = "<div>" + aWfmnbSPm + "</div>";
        if (AWFmnBSpm) {
            AwfmnbSPm.insertAdjacentHTML("BeforeEnd", tipDIVCodes);
        } else if (aWFMnBSpm) {
            AwfmnbSPm.innerHTML = tipDIVCodes;
        }
    }
    if (AWFMnBSpm) {
        awfmnbSPm = "AWfmNBspm";
        AwfmnbSPm = document.layers[awfmnbSPm];
        AWfmnbSPm = window.innerHeight;
        awFmnbSPm = AWFMnbSPm + 2 * AWFMNBspm;
        awfMnbSPm = awfmnbsPM + 2 * AWFMNBspm + 2;
        AwfmnbSPm.moveTo(0, eval(window.pageYOffset + AWfmnbSPm));
        AwfmnbSPm.width = awFmnbSPm;
        AwfmnbSPm.clip.width = awFmnbSPm;
        AwfmnbSPm.document.write("<div width=" + awFmnbSPm + " height=" + awfMnbSPm + " style='font-family:" + aWfmnBSpm + ";font-size:" + awFmnBSpm + "px;color:" + awfMnBSpm + ";background-color:" + aWFMNBspm + ";font-weight:" + AWfmnBSpm + ";font-style:" + aWFmnBSpm + ";border:" + AWFMNBspm + "px " + awfmnBSpm + " " + AwfmnBSpm + ";'>" + aWfmnbSPm + "</div>");
        AwfmnbSPm.document.close();
    }
    AwfmnbsPM();
};
function AwfmnbsPM() {
    if (window.opera) return;
    if (aWFmnbSPm <= awfMnbSPm) {
        if (awFMnBSpm) {
            AwfmnbSPm.style.visibility = "visible";
            AwfmnbSPm.style.top = (AWFmnBSpm) ? (document.body.scrollTop + AWfmnbSPm) - aWFmnbSPm : (window.pageYOffset + AWfmnbSPm) - aWFmnbSPm;
            AwfmnbSPm.style.height = aWFmnbSPm;
            aWFmnbSPm += awFMNBspm;
            awFMnbSPm = setTimeout("AwfmnbsPM()", AWFmNBspm);
        }
        if (AWFMnBSpm) {
            AwfmnbSPm.visibility = "visible";
            AwfmnbSPm.moveTo(0, (eval(window.pageYOffset + AWfmnbSPm) - aWFmnbSPm));
            AwfmnbSPm.height = aWFmnbSPm;
            AwfmnbSPm.clip.height = (aWFmnbSPm);
            aWFmnbSPm += awFMNBspm;
            awFMnbSPm = setTimeout("AwfmnbsPM()", AWFmNBspm);
        }
    } else {
        clearTimeout(awFMnbSPm);
    }
};
function hideTip() {
    clearTimeout(awFMnbSPm);
    if (awFMnBSpm) {
        AwfmnbSPm.innerHTML = "";
        AwfmnbSPm.style.visibility = "hidden";
        aWFmnbSPm = 2;
    }
    if (AWFMnBSpm) {
        AwfmnbSPm.document.write("");
        AwfmnbSPm.document.close();
        AwfmnbSPm.visibility = "hidden";
        AwfmnbSPm.width = 0;
        AwfmnbSPm.height = 0;
        AwfmnbSPm.clip.width = 0;
        AwfmnbSPm.clip.height = 0;
        aWFmnbSPm = 2;
    }
};
function aWfmnbsPM() {
    if (window.opera)
        return;
    if (window.status != AWFmnbSPm)
        window.status = AWFmnbSPm;
};
setInterval("aWfmnbsPM()", 500);
if (awFMnBSpm) {
    document.write("<div id='aWFmNBspm2' class='awfm3nBspm'></div>");
}
if (AWFMnBSpm) {
    AwfmnbSPm = eval("document.AWfmNBspm");
    AwfmnbSPm.visibility = "hidden";
}
//