www.rblbank.com Open in urlscan Pro
2a02:26f0:1700:13::b856:fb1b  Public Scan

URL: https://www.rblbank.com/creditcardlandingpage/support/js/creditCard.js?v=8.1
Submission: On August 11 via manual from IN — Scanned from DE

Form analysis 0 forms found in the DOM

Text Content

var flagpopup = 0;
var otp_popup = null;
var unver_mobile = null;
var dropOffPopupStatus = 0; // FOR DROPOFF POP UP
var targetUrl = "/credit-card";
var ajaxRequest = true;
var counter = 60;
var parameterShouldNotPresent = "(cardId=\\d*&)";
var SalesforceURL = null;

function read_XML_Card(cardType) {
    var valueAppend = null;
    var queryString = getQueryString();
    var browserurl = window.location.href.slice(0, window.location.href.indexOf('?'));

    $.ajax({
        type: "GET",
        url: browserurl+"/support/config/config.xml",
        dataType: "xml",
        success: function (xml) {
            SalesforceURL = $($(xml).find("SalesforceURL")[0]).attr("value");
            $.ajax({
                type: "GET",
                url: browserurl+"/support/xml/Card.xml",
                dataType: "xml",
                success: function (xml) {
                    var tags = $(xml).find("a");
                    $(tags).each(function (index, value) {
                        if ($(value).attr("CardName") == cardType) {
                            valueAppend = 'cardId=' + $(value).attr("CardValue").toString();
                            return false;
                        }
                    });
                    queryString += valueAppend;
                    //alert(SalesforceURL + "?" + queryString);
                    var final_string = SalesforceURL + "?" + queryString;
                    window.location.assign(final_string);
                    //window.open(final_string);
                    return false;
                },
                error: function (error) {
                    alert("Error inner:" + error)
                }
            });
        },
        error: function (error) {
            alert("Error outer:" + error)
        }
    });
}

function getQueryString() {
    URLstring = window.location.href.slice(window.location.href.indexOf('?') + 1) + "&";
    if ((window.location.href + "&") != URLstring) {
        var regEx = new RegExp(parameterShouldNotPresent);
        URLstring = URLstring.replace(regEx, '');
        return URLstring;
    }
    else {
        return "";
    }
}

jQuery(document).ready(function () {
    //--$(".noramlSelectBox").select2({});
	/*if($('#mycarousel > li').length > 3) {
		jQuery('#mycarousel').jcarousel();
	}*/
    //$('.form-control-dropdown').material_select();

    creditCardObj = new creditCard();
    creditCardObj.activateValidation('creditcardinfoform', true);
    getPreFilledForms();
    if (gFormData != undefined && gFormData != "") {
        gFormData = eval('(' + gFormData + ')');
        creditCardObj.setDefaultFieldsValue();
        changeEmployeeType($("#employmentType").val());
    }
    var emp_type = $("#employmentType").val();
    emp_type = (emp_type != undefined && parseInt(emp_type)) ? emp_type : 1;
    changeEmployeeType(emp_type);

    var modal = document.getElementById('myModal');
    var span = document.getElementById('myModalClose');
    var details = document.getElementById("details");

    //~ var span = document.getElementsByClassName("close")[0];

    if (details != undefined) {
        details.onclick = function () {
            modal.style.display = "block";
        };
    }
    // When the user clicks on <span> (x), close the modal
    if (span != undefined) {
        span.onclick = function () {
            modal.style.display = "none";
        };
    }
    // When the user clicks anywhere outside of the modal, close it
    if (modal != undefined) {
        window.onclick = function (event) {
            if (event.target == modal) {
                modal.style.display = "none";
            }
        };
    }
    //~ window.addEventListener('onbeforeunload', function(e) {
    //~ e.returnValue = 'NITIN';
    //~ });
    //~ 
	/*
		window.onbeforeunload = function(e){
			var s = 'Are you sure you want to leave?';
			e.returnValue = s;
			e.currentTarget = "http://ggog.com";
			console.log(e);
			return s;
		};
	*/
    //~ $(window).bind("beforeunload",function(event) {
    //~ return "You have some unsaved changes";
    //~ alert(1);
    //~ console.log(event);
    //~ return false;
    //~ });
});

function creditCard() {
    this.confirmAadhaar = function () {
        var ajax_hit = true;
        var aadhaar_otp = M.byId("txt_aadhaar_otp").value;
        M.byId('txt_aadhaar_otp').style.borderColor = C[8];
        $("#verify-code-error").hide();
        if (ajax_hit && aadhaar_otp != "" && aadhaar_otp.length == 6 && M.IsNumeric(aadhaar_otp)) {
            ajax_hit = false;
            $("#call_loader").show();

            q = "page=confirmaadhaar&aadhaar_otp=" + aadhaar_otp;
            M.AJAX.request({
                target: targetUrl,
                query: q,
                method: 'POST',
                onSuccess: function (res) {
                    if (res.match(/^error|Error\:/i) != null) {
                        msg = res.replace(/^error|Error\:/i, '');
                        $("#verify-code-error").html(msg);
                        $("#verify-code-error").show();
                        ajax_hit = true;
                        $("#call_loader").hide();
                    } else if (res != "") {
                        res = M.trim(res);
                        gFormData = eval('(' + res + ')');
                        M.byId('itemOverlay').innerHTML = "";
                        M.byId('itemWrapper').style.display = 'none';
                        M.byId('pageOverlay').style.display = 'none';

                        creditCardObj.setDefaultFieldsValue();
                    }
                },
                onFailed: function (msg) {
                    showError(msg, true);
                    ajax_hit = true;
                    $("#call_loader").hide();
                }
            });
        } else {
            M.byId('txt_aadhaar_otp').style.borderColor = C[5];
            $("#verify-code-error").html("Please enter your valid aadhaar no...");
            $("#verify-code-error").show();
        }
    },

        this.setDefaultFieldsValue = function () {
            if (gFormData != undefined && gFormData != "") {
                var formData = gFormData;
                if (M.byId("fname") != undefined && (formData.name != undefined && formData.name.first_name != undefined && formData.name.first_name != "")) {
                    M.byId("fname").value = formData.name.first_name;
                }
                if (M.byId("mname") != undefined && (formData.name != undefined && formData.name.middle_name != undefined && formData.name.middle_name != "")) {
                    M.byId("mname").value = formData.name.middle_name;
                }
                if (M.byId("lname") != undefined && (formData.name != undefined && formData.name.last_name != undefined && formData.name.last_name != "")) {
                    M.byId("lname").value = formData.name.last_name;
                }
                //added by Shubham on 08-03-2017
                if (M.byId("dateOfBirth") != undefined && (formData.dob != undefined && formData.dob != "")) {
                    M.byId("dateOfBirth").value = formData.dob;
                }
                if (M.byId("txt_father_name") != undefined && (formData.careOf != undefined && formData.careOf != "")) {
                    M.byId("txt_father_name").value = formData.careOf;
                }
                //			if(M.byId("dobday") != undefined && (formData.dob != undefined && formData.dob.day != undefined && formData.dob.day !="")) {
                //				var dobday = $('#dobday').select2('val');
                //				if(parseInt(dobday) == 0 || dobday == "") {
                //					$('#dobday').select2('val', formData.dob.day);
                //				}
                //			}
                //			if(M.byId("dobmonth") != undefined && (formData.dob != undefined && formData.dob.month != undefined && formData.dob.month !="")) {
                //				var tmp_month = (parseInt(formData.dob.month) > 9) ? formData.dob.month.toString() : "0"+formData.dob.month.toString();
                //				var dobmonth = $('#dobmonth').select2('val');
                //				if(parseInt(dobmonth) == 0 || dobmonth == "") {
                //					$('#dobmonth').select2('val', tmp_month);
                //				}
                //			}
                //			if(M.byId("dobyear") != undefined && (formData.dob != undefined && formData.dob.year != undefined && formData.dob.year !="")) {
                //				var dobyear = $('#dobyear').select2('val');
                //				if(parseInt(dobyear) == 0 || dobyear == "") {
                //					$('#dobyear').select2('val', formData.dob.year);
                //				}
                //			}
                if (M.byId("cities") != undefined && (formData.address != undefined && formData.address.city != undefined && parseInt(formData.address.city) > 0)) {
                    //--var city = $('#cities').select2('val');
                    //                                alert(city+"===="+formData.address.city);
                    if (city <= 0) {
                        //--$('#cities').select2('val', formData.address.city);
                    }
                }
                if (M.byId("pincode") != undefined && (formData.address != undefined && formData.address.pincode != undefined && parseInt(formData.address.pincode) > 0)) {
                    //--var pincode = $('#pincode').select2('val');
                    if (pincode <= 0) {
                        //--$('#pincode').select2('val', formData.address.pincode);
                    }
                }
                if (M.byId("mobile") != undefined && (formData.mobile != undefined && M.isMobile(formData.mobile))) {
                    if (M.byId("mobile").value == "") {
                        M.byId("mobile").value = formData.mobile;
                        creditCardObj.confirmMobileNumber(M.byId("mobile"));
                    }
                }
                if (M.byId("gndr") != undefined && (formData.gender != undefined && parseInt(formData.gender) > 0)) {
                    if (parseInt(M.byId("gndr").value) == 0 || M.byId("gndr").value == "") {
                        M.byId("gndr").value = formData.gender;
                        $('#gender_' + formData.gender).addClass('active');
                    }
                }
                if (M.byId("emailid") != undefined && (formData.email != undefined && M.isEmail(formData.email))) {
                    if (M.byId("emailid").value == "") {
                        M.byId("emailid").value = formData.email;
                    }
                }
                if (M.byId("addressL1") != undefined && (formData.address != undefined && formData.address.address_1 != undefined)) {
                    if (M.byId("addressL1").value == "") {
                        M.byId("addressL1").value = formData.address.address_1;
                    }
                }
                var addressL3 = "";
                if ((formData.address != undefined && formData.address.address_3 != undefined)) {
                    addressL3 = ", " + formData.address.address_3;
                }
                if (M.byId("addressL2") != undefined && (formData.address != undefined && formData.address.address_2 != undefined)) {
                    if (M.byId("addressL2").value == "") {
                        M.byId("addressL2").value = (formData.address.address_2 + addressL3);
                    }
                }
            }
        },

        this.getAadhaar = function () {
            var ajax_hit = true;
            var aadhaar_no = M.byId("txt_aadhaar").value;
            M.byId('txt_aadhaar').style.borderColor = C[8];
            $("#verify-code-error").hide();
            if (ajax_hit && aadhaar_no != "" && aadhaar_no.length == 12 && M.IsNumeric(aadhaar_no)) {
                ajax_hit = false;
                $("#call_loader").show();
                q = "page=getaadhaar&aadhaar_no=" + aadhaar_no;
                M.AJAX.request({
                    target: targetUrl,
                    query: q,
                    method: 'POST',
                    onSuccess: function (res) {
                        if (res.match(/^error|Error\:/i) != null) {
                            msg = res.replace(/^error|Error\:/i, '');
                            $("#verify-code-error").html(msg);
                            $("#verify-code-error").show();
                            ajax_hit = true;
                            $("#call_loader").hide();
                        } else if (res.match(/^display\:/i) != null) {
                            msg = res.replace(/^display\:/i, '');
                            $("#aadhaar_section").html(msg);
                            $("#call_loader").hide();
                        }
                    },
                    onFailed: function (msg) {
                        showError(msg, true);
                        ajax_hit = true;
                        $("#call_loader").hide();
                    }
                });
            } else {
                M.byId('txt_aadhaar').style.borderColor = C[5];
                $("#verify-code-error").html("Please enter your valid aadhaar no...");
                $("#verify-code-error").show();
            }
        },

        this.sco = function (flg) {
            if (parseInt(flg) > 0) {
                q = "page=getsocial&sco=" + flg;
                M.AJAX.request({
                    target: targetUrl,
                    query: q,
                    method: 'POST',
                    onSuccess: function (res) {
                        if (res.match(/^error|Error\:/i) != null) {
                            msg = res.replace(/^error|Error\:/i, '');
                            $("#verify-code-error").html(msg);
                        } else if (res.match(/^display\:/i) != null) {
                            msg = res.replace(/^display\:/i, '');
                            if (M.trim(msg) == "done") {
                                if (flg == 99) {
                                    M.byId('itemOverlay').innerHTML = ""
                                    M.byId('itemWrapper').style.display = 'none'
                                    M.byId('pageOverlay').style.display = 'none'
                                } else if (flg == 2) {
                                    var url = targetUrl + "?page=socialmedia&sType=facebook";
                                    var newwindow = window.open(url, 'mywindow', 'height=400,width=350,screenX=400,screenY=200,resizable=true');
                                    if (window.focus) {
                                        newwindow.focus();
                                    }
                                    return false;
                                    //alert("FB");
                                } else if (flg == 3) {
                                    var url = targetUrl + "?page=socialmedia&sType=linkedin";
                                    var newwindow = window.open(url, 'mywindow', 'height=400,width=350,screenX=400,screenY=200,resizable=true');
                                    if (window.focus) {
                                        newwindow.focus();
                                    }
                                    return false;
                                }
                            }
                        }
                    },
                    onFailed: function (msg) {
                        showError(msg, true);
                    }
                });
            }
        },

        this.openPopUp = function (src, card_id) {
            if (card_id == undefined) return false;
            $('#pageOverlay').fadeIn('slow', function () {
                if (browserver == 'MSIE' || browserver == 'MSIE6') { $('#itemWrapper').bgiframe(); }
                if (M.byId('cc_content_' + card_id) != undefined) {
                    M.byId('itemWrapper').style.display = 'block';
                    M.byId('itemOverlay').style.display = 'block';
                    M.byId('cc_content_' + card_id).style.display = 'block';
                }
            });
        },
        this.killJustPopup = function () {
            //M.byId('itemOverlay').innerHTML=""
            M.byId('itemWrapper').style.display = 'none'
            M.byId('pageOverlay').style.display = 'none'
            $(".cc_content_pop").hide();
            //M.getForm('capturedValue')['selectedCardId'].value='';    
        },
        this.setSelectedTabVal = function (src, select_value, value_elem_id) {
            var elem = $(src);
            elem.closest('div').find('a').removeClass('active');
            elem.addClass('active');

            if (value_elem_id == 'cities') {
                //--$('#' + value_elem_id).select2('val', select_value);
                $('#cities').valid();
            } else if (value_elem_id == 'employmentType') {
                changeEmployeeType(select_value);
                //changeEmployee(select_value);
                $('#' + value_elem_id).val(select_value);
                $('#' + value_elem_id).valid();
            } else {
                $('#' + value_elem_id).val(select_value);
                $('#' + value_elem_id).valid();
            }
            return false;
        },

        this.submitThirdPage = function () {
            var val = {};
            if ($('#creditcardthirdform').valid()) {
                $('#page-loader').find('h4').html('Hold on... checking your eligibility'); //page-loader
                $('#page-loader').fadeIn(); //page-loader
                $('#page-level-errors').hide();

                holdProgress("third_page_submit");

                $("#third_page_submit").html('Wait! Checking your eligiblity...');
                $("#third_page_submit").unbind('click');
                holdProgress("third_page_submit");
                var elements = document.forms["creditcardthirdform"].elements;
                var elem = ['employmentType', 'employer', 'grossincome', 'panCard', 'addressL1', 'addressL2', 'city_id', 'pincode', 'existing_other_loan_cc'];
                var q = 'page=creditcardapp';
                for (i = 0; i < elements.length; i++) {
                    if ($.inArray(elements[i].name, elem) == -1) {
                        continue;
                    }
                    if (elements[i].name == "employer") {
                        elements[i].value = escape(elements[i].value);
                        elements[i].value = decodeURI(elements[i].value);
                    }

                    q += "&" + elements[i].name + "=" + elements[i].value;
                    val[elements[i].name] = elements[i].value;
                }
                /*
                if (M.byId('existing_other_loan_cc_yes') != undefined && $('#existing_other_loan_cc_yes').is(':checked') == true) {
                    q += "&existing_other_loan_cc=Y";
                    val["existing_other_loan_cc"] = "Y";
                } else if (M.byId('existing_other_loan_cc_no') != undefined && $('#existing_other_loan_cc_no').is(':checked') == true) {
                    q += "&existing_other_loan_cc=N";
                    val["existing_other_loan_cc"] = "N";
                }
                */
                var data_str = '';
                for (var se in val) data_str += val[se] + "|";
                var checksum = rstr2hex(rstr_md5(data_str));
                q += "&client_checksum=" + checksum;

                if (ajaxRequest == true) {
                    ajaxRequest = false;
                    M.AJAX.request({
                        target: targetUrl,
                        query: q,
                        method: 'POST',
                        postmsg: M.byId('postmsg'),
                        onSuccess: creditCardObj.finishAppCreditCardSubmit, //submitSearchCreditCard
                        onFailed: function (msg) {
                            //showError(msg, true);
                            $("#third_page_submit").html('Next <div class="ripple-container"></div>');
                            $("#third_page_submit").bind('click');
                            holdProgress("third_page_submit");
                        }
                    });
                } else {
                    $("#third_page_submit").html('Next <div class="ripple-container"></div>');
                    holdProgress("third_page_submit");
                }
            } else {
                $("#third_page_submit").html('Next <div class="ripple-container"></div>');
                $("#third_page_submit").bind('click');
            }
            return false;
        },

        this.finishAppCreditCardSubmit = function (res) {
            ajaxRequest = true;
            holdProgress("third_page_submit");
            res = M.trim(res);
            //var res_arr = res.split("__*__");
            //var display_html = (res_arr[0] != undefined) ? res_arr[0] : res;
            //var pop_html = (res_arr[1] != undefined) ? res_arr[1] : "";

            var res_arr = res.split("__*__");
            var display_html = (res_arr[0] != undefined) ? res_arr[0] : res;
            var refCode = (res_arr[1] != undefined) ? res_arr[1] : "";
            var aipCode = (res_arr[2] != undefined) ? parseInt(res_arr[2]) : 0;
            var pop_html = "";
            var otp_popup = 0;
            var msg = "";
            //showError(msg, false);

            if (pop_html.match(/^otp_html\:/i) != null || display_html.match(/^otp_html\:/i) != null) {
                M.byId('pageOverlay').style.display = 'none';
                M.byId('itemWrapper').style.display = 'none';
                M.byId('itemOverlay').style.display = '';
                if (M.byId('pageOverlay') != undefined) {
                    M.byId('pageOverlay').style.display = 'block';
                    M.byId('itemWrapper').style.display = 'block';

                    if (pop_html.match(/^otp_html\:/i) != null) {
                        M.byId('itemOverlay').innerHTML = pop_html.replace(/^otp_html\:/i, '');
                    } else if (display_html.match(/^otp_html\:/i) != null) {
                        M.byId('itemOverlay').innerHTML = display_html.replace(/^otp_html\:/i, '');
                    }
                }
                otp_popup = 1;
            }

            if (display_html.match(/^error|Error\:/i) != null) {
                msg = display_html.replace(/^error|Error\:/i, '');
                showHeaderError(msg, true);
                $("#third_page_submit").html('Next <div class="ripple-container"></div>');
                $("#third_page_submit").bind('click');
            } else {	//if(display_html.match(/^display\:|ap8970\:|ap8971\:/i)!=null)
                M.byId('main_container_row').innerHTML = display_html.replace(/^display\:|ap8970\:|ap8971\:/i, '');
                M.byId('main_container_row').style.height = 'auto';
                var aip = 0;
                var apass = 0;
                if (res.match(/^ap8970\:/i) != null) {
                    apass = 1;
                    aip = 1;
                }
                var rpass = 0;
                if (res.match(/^ap8975\:/i) != null) {
                    rpass = 1;
                    aip = 2;
                }
                $.material.init();
                $("#progress_bar").css("width", "100%");
                /* FOR PIXEL CODE 
                if (isus==0 && (typeof callpixelimg != 'undefined') && callpixelimg!=undefined && callpixelimg!=null && callpixelimg!="" && M.byId('pixeltracking')!=undefined && apass===1) {
                	
                    if ((typeof optional_information != 'undefined') && optional_information!=undefined && optional_information!=null && optional_information!="") {
                        callpixelimg = callpixelimg.replace("optional_information", optional_information);
                    } else {
                        var tmpDateTime = (new Date()).getTime();
                        var randomConcat = 100*(Math.random());
                        randomConcat = "x" + Math.floor(randomConcat);
                        tmpDateTime = randomConcat.concat(tmpDateTime);
                        callpixelimg = callpixelimg.replace("optional_information", tmpDateTime);
                    }
                    if (callpixeltype == 1) {
                        M.byId('pixeltracking').src = callpixelimg;                        
                    } 
                }*/
                /* END  */
                /*
                if((callpixelcard != undefined && parseInt(callpixelcard) === 1) && (callpixelapi !=undefined && (callpixelapi.indexOf(aip) != -1 || callpixelapi.indexOf(-1) != -1)) && (callpixeliframe != undefined && callpixeliframe != "") && (callpixelimg != undefined && callpixelimg != "")) {
                    callpixelimg = callpixelimg.replace("SUB_ID_VAL", ''+callpixeliframe+'_'+refCode+'_'+aipCode+'');
                	
                    M.byId("iframe_pixel").innerHTML = '<img src="'+callpixelimg+'" width="1" height="1" />';
                }
                */

                /*
                if((callpixelsetype !=undefined && callpixelsetype == 3) && apass == 1 && M.byId("iframe_pixel") !=undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard) == 1) && (aipCode != undefined && aipCode)) {
                    console.log("s3");
                    M.byId("iframe_pixel").innerHTML = '<img src="https://icubes.go2cloud.org/SL4vf?adv_sub='+callpixeliframe+'_'+refCode+'_'+aipCode+'" width="1" height="1" />';
                } else if((callpixelsetype !=undefined && callpixelsetype == 3) && apass == 1 && M.byId("iframe_pixel") !=undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard) == 2) && (aipCode != undefined && aipCode)) {
                    console.log("s2");
                    M.byId("iframe_pixel").innerHTML = '<img src="https://icubes.go2cloud.org/SL4vh?adv_sub='+callpixeliframe+'_'+refCode+'_'+aipCode+'" width="1" height="1" />';
                } 
                */

                /*
                $("#third_form_container_div").animate({opacity: '0','height':'0px'}, 2000);
                M.byId('third_form_container_div').style.display = 'none';
                M.byId('first_form_container_div').style.display = 'block';
            	
                M.byId('third_form_container_div').innerHTML = '';
                M.byId('second_form_container_div').innerHTML = '';
                $("#first_form_container_div").attr("style", "");
                */
                /*
                $('#step-line-4').attr("class","line-divider-last active");
                $('#step-4').attr("class","active");
                $("#progressbar").hide();
                */
                //goToByScroll('first_form_container_div');
            } /*else {
			$("#third_page_submit").html('Check eligiblity<i class="arrow"></i>');
			$("#third_page_submit").bind('click');
		}*/
            /*
            if(M.byId('page-level-errors').style.display == 'block') {
                goToByScroll('page-level-errors');
            }
            */
        },


        this.submitSecondPage = function () {
            var val = {};
            if ($('#creditcardsecondform').valid()) {
                $('#page-loader').find('h4').html('Hold on... checking your eligibility'); //page-loader
                $('#page-loader').fadeIn(); //page-loader
                $('#page-level-errors').hide();

                $("#second_page_submit").html('Saving...');
                $("#second_page_submit").unbind('click');

                var elements = document.forms["creditcardsecondform"].elements;
                var elem = ['mname', 'lname', 'txt_father_name', 'addressL1', 'addressL2', 'txt_landmark', 'city_id', 'pincode', 'area', 'store_code', 'referee_code', 'se_code', 'txt_embosser_name'];
                var q = 'page=datacreditcard';
                for (i = 0; i < elements.length; i++) {
                    if ($.inArray(elements[i].name, elem) == -1) {
                        continue;
                    }
                    q += "&" + elements[i].name + "=" + elements[i].value;
                    val[elements[i].name] = elements[i].value;
                }

                var data_str = '';
                for (var se in val) data_str += val[se] + "|";
                var checksum = rstr2hex(rstr_md5(data_str));
                q += "&client_checksum=" + checksum;

                if (ajaxRequest == true) {
                    ajaxRequest = false;
                    M.AJAX.request({
                        target: targetUrl,
                        query: q,
                        method: 'POST',
                        postmsg: M.byId('postmsg'),
                        onSuccess: creditCardObj.finishDataCreditCardSubmit, //submitSearchCreditCard
                        onFailed: function (msg) {
                            showError(msg, true);
                            $("#second_page_submit").html('Save');
                            $("#second_page_submit").bind('click');
                        }
                    });
                } else {
                    $("#second_page_submit").html('Wait!!! Saving...');
                }
            } else {
                $("#second_page_submit").html('Save');
                $("#second_page_submit").bind('click');
            }
            return false;
        },


        this.finishDataCreditCardSubmit = function (res) {
            ajaxRequest = true;
            res = M.trim(res);
            var res_arr = res.split("__*__");
            var display_html = (res_arr[0] != undefined) ? res_arr[0] : res;
            var pop_html = (res_arr[1] != undefined) ? res_arr[1] : "";
            var otp_popup = 0;
            var msg = "";
            showError(msg, false);

            if (pop_html.match(/^otp_html\:/i) != null || display_html.match(/^otp_html\:/i) != null) {
                M.byId('pageOverlay').style.display = 'none';
                M.byId('itemWrapper').style.display = 'none';
                M.byId('itemOverlay').style.display = '';
                if (M.byId('pageOverlay') != undefined) {
                    M.byId('pageOverlay').style.display = 'block';
                    M.byId('itemWrapper').style.display = 'block';

                    if (pop_html.match(/^otp_html\:/i) != null) {
                        M.byId('itemOverlay').innerHTML = pop_html.replace(/^otp_html\:/i, '');
                    } else if (display_html.match(/^otp_html\:/i) != null) {
                        M.byId('itemOverlay').innerHTML = display_html.replace(/^otp_html\:/i, '');
                    }
                }
                otp_popup = 1;
            }

            if (display_html.match(/^error|Error\:/i) != null) {
                msg = display_html.replace(/^error|Error\:/i, '');
                showError(msg, true);
                $("#second_page_submit").html('Save');
                $("#second_page_submit").bind('click');
            } else if (display_html.match(/^display\:/i) != null) {
                M.byId('third_form_container_div').innerHTML = display_html.replace(/^display\:/i, '');
                $("#second_form_container_div").animate({ opacity: '0', 'height': '0px' }, 2000);
                M.byId('second_form_container_div').style.display = 'none';
                M.byId('third_form_container_div').style.height = 'auto';
                //--$(".noramlSelectBox").select2({});
                creditCardObj.activateValidation('creditcardthirdform', true);
                creditCardObj.callAutocompleteEmployer('employer');

                $('#step-line-3').attr("class", "line-divider-second active");
                $('#step-3').attr("class", "active");

                creditCardObj.setDefaultFieldsValue();

                //goToByScroll('progressbar');
            } else {
                $("#second_page_submit").html('Save');
                $("#second_page_submit").bind('click');
            }

            if (M.byId('page-level-errors').style.display == 'block') {
                goToByScroll('page-level-errors');
            }
        },

        this.submitFirstPage = function () {
            var val = {};
            //alert(0);
            //$('#page-level-errors').hide();
            if ($('#creditcardinfoform').valid()) {
                $("#first_page_submit").attr('class', 'sbmt-btn active');
                //alert(1);
                //$('#page-loader').find('h4').html('Hold on... checking your eligibility'); //page-loader
                //$('#page-loader').fadeIn(); //page-loader

                //$('#page-level-errors').hide();

                //~ $("#first_page_submit").html('Next<span class="btn-arrow"></span>');
                $("#first_page_submit").unbind('click');

                holdProgress("first_page_submit");
                var elements = document.forms["creditcardinfoform"].elements;
                var elem = ['panCard', 'employmentType', 'employer', 'grossincome', 'cities', 'pincode', 'addressL1', 'addressL2', 'dateOfBirth', 'txt_title', 'gndr', 'emailid', 'mobile', 'info_provided', 'fname', 'mname', 'lname', 'area'];
                var q = 'page=searchcreditcard';//singlecreditcard
                for (i = 0; i < elements.length; i++) {
                    if ($.inArray(elements[i].name, elem) == -1) {
                        continue;
                    }
                    if (elements[i].name == "employer") {
                        elements[i].value = escape(elements[i].value);
                        elements[i].value = decodeURI(elements[i].value);
                    } else if (elements[i].name == 'gndr') {
                        elements[i].value = $('input[name=' + elements[i].name + ']:checked').val();
                    } else if (elements[i].name == 'grossincome') {
                        elements[i].value = M.unformatMoney(M.byId('grossincome').value);
                    }
                    q += "&" + elements[i].name + "=" + elements[i].value;
                    val[elements[i].name] = elements[i].value;
                }
                /*if (M.byId('existing_other_loan_cc_yes') != undefined && $('#existing_other_loan_cc_yes').is(':checked') == true) {
                    q += "&existing_other_loan_cc=Y";
                    val["existing_other_loan_cc"] = "Y";
                } else if (M.byId('existing_other_loan_cc_no') != undefined && $('#existing_other_loan_cc_no').is(':checked') == true) {
                    q += "&existing_other_loan_cc=N";
                    val["existing_other_loan_cc"] = "N";
                }
                if (M.byId('exit_cust_yes') != undefined && $('#exit_cust_yes').is(':checked') == true) {
                    q += "&exit_cust=Y";
                    val["exit_cust"] = "Y";
                } else if (M.byId('exit_cust_no') != undefined && $('#exit_cust_no').is(':checked') == true) {
                    q += "&exit_cust=N";
                    val["exit_cust"] = "N";
                }
                if (M.byId('scb_credit_card_yes') != undefined && $('#scb_credit_card_yes').is(':checked') == true) {
                    q += "&scb_credit_card=Y";
                    val["scb_credit_card"] = "Y";
                } else if (M.byId('scb_credit_card_no') != undefined && $('#scb_credit_card_no').is(':checked') == true) {
                    q += "&scb_credit_card=N";
                    val["scb_credit_card"] = "N";
                }*/
                //~ var dobday = $('#dobday').val();
                //~ var dobmonth = $('#dobmonth').val();
                //~ var dobyear = $('#dobyear').val();

                //~ if(dobday!="" && dobmonth!="" && dobyear!="") {
                //~ q += "&dateOfBirth=" + dobday + '-' + dobmonth + '-' + dobyear;
                //~ val['dateOfBirth'] = dobday + '-' + dobmonth + '-' + dobyear;
                //~ }

                var data_str = '';
                for (var se in val) data_str += val[se] + "|";
                var checksum = rstr2hex(rstr_md5(data_str));
                q += "&client_checksum=" + checksum;

                if (ajaxRequest == true) {
                    ajaxRequest = false;
                    M.AJAX.request({
                        target: targetUrl,
                        query: q,
                        method: 'POST',
                        postmsg: M.byId('postmsg'),
                        onSuccess: creditCardObj.finishSearchCreditCardSubmit, //submitSearchCreditCard
                        onFailed: function (msg) {
                            showError(msg, true);
                            //~ $("#first_page_submit").html('Next<span class="btn-arrow"></span>');
                            $("#first_page_submit").bind('click');
                            holdProgress("first_page_submit");
                        }
                    });
                } else {
                    //~ $("#first_page_submit").html('Next<span class="btn-arrow"></span>');
                }
            } else {
                //~ $("#first_page_submit").html('Next<span class="btn-arrow"></span>');
                $("#first_page_submit").bind('click');
            }
            return false;
        },


        this.finishSearchCreditCardSubmit = function (res) {
            ajaxRequest = true;
            holdProgress("first_page_submit");
            res = M.trim(res);
            var res_arr = res.split("__*__");
            var display_html = (res_arr[0] != undefined) ? res_arr[0] : res;
            var pop_html = (res_arr[1] != undefined) ? res_arr[1] : "";
            var otp_popup = 0;
            var msg = "";
            //showError(msg, false);

            if (pop_html.match(/^otp_html\:/i) != null || display_html.match(/^otp_html\:/i) != null) {
                M.byId('pageOverlay').style.display = 'none';
                M.byId('itemWrapper').style.display = 'none';
                M.byId('itemOverlay').style.display = '';
                if (M.byId('pageOverlay') != undefined) {
                    M.byId('pageOverlay').style.display = 'block';
                    M.byId('itemWrapper').style.display = 'block';

                    if (pop_html.match(/^otp_html\:/i) != null) {
                        M.byId('itemOverlay').innerHTML = pop_html.replace(/^otp_html\:/i, '');
                    } else if (display_html.match(/^otp_html\:/i) != null) {
                        M.byId('itemOverlay').innerHTML = display_html.replace(/^otp_html\:/i, '');
                    }
                }
                counterStart();
                otp_popup = 1;
                $('#mobile_verification_code').keyup(function (event) {
                    var key = event.which;
                    if (this.value != undefined && (this.value).length == 6 && key == 13) {
                        //console.log("===> " + key + " | " + this.value); 
                        $("#show-step-2").click();
                    }
                });

                //~ if(pop_html != "") {
                //~ M.byId('otp_container_div').innerHTML = pop_html.replace(/^otp_html\:/i, '');
                //~ } else {
                //~ M.byId('otp_container_div').innerHTML = display_html.replace(/^otp_html\:/i, '');
                //~ }
                //~ $("#first_form_container_div").animate({opacity: '0','height':'0px'}, 2000);
                //~ M.byId('first_form_container_div').style.display = 'none';
                //~ M.byId('otp_container_div').style.height = 'auto';
                //~ counterStart();
                //~ $("#progress_bar").css("width", "30%");
            } else if (display_html.match(/^error|Error\:/i) != null) {
                msg = display_html.replace(/^error|Error\:/i, '');
                showHeaderError(msg, true);
                goToByScroll('page-level-err');
                //$("#first_page_submit").html('Next<span class="btn-arrow"></span>');
                $("#first_page_submit").bind('click');
            } else if (display_html.match(/^display\:/i) != null) {
                M.byId('second_form_container_div').innerHTML = display_html.replace(/^display\:/i, '');
                $("#first_form_container_div").animate({ opacity: '0', 'height': '0px' }, 2000);
                M.byId('first_form_container_div').style.display = 'none';
                M.byId('second_form_container_div').style.height = 'auto';
                //--$(".noramlSelectBox").select2({});
                creditCardObj.activateValidation('creditcardthirdform', true);
                creditCardObj.setDefaultFieldsValue();
                scinit();
                $.material.init();
                $("#progress_bar").css("width", "60%");
                //$("select").dropdown();
                //getPreFilledForms();
                //$('#step-line-2').attr("class","line-divider active");
                //$('#step-2').attr("class","active");
                //goToByScroll('progressbar');
            }
            /*if(M.byId('page-level-errors').style.display == 'block') {
                goToByScroll('page-level-errors');
            }*/
        },



        /*
         * MOBILE OTP
         */
        this.confirmMobileNumber = function (obj, mobileFlag) {
            $('#mobile').valid();
            var elemId = obj.id;
            var elem = $('#' + elemId);
            if (elem.val() == '' || !M.isMobile(elem.val().toString())) {
                return false;
            }

            if (mobileFlag == "TOPMOBILE") {
                var notify_elem = $("#msg_box_top");
            } else {
                var notify_elem = elem.closest('div').find("#mobile-error");
            }

            //notify_elem.html("<span class=\"correct-img-emp\"><img height=\"15\" src='/support/img_rp/loader_green_small_new.gif'></span>");
            //notify_elem.show();
            if (ajaxRequest == true) {
                ajaxRequest = false;
                var q = 'page=confirmmobile&confirm_mobile_onblur=1&verify_mobile_number=' + elem.val();
                M.AJAX.request({
                    target: targetUrl,
                    query: q,
                    method: 'POST',
                    onSuccess: function (msg) {
                        ajaxRequest = true;
                        if (msg.match(/^success\:/i) != null) {
                            notify_elem.html("<span class=\"sucessfield has-arrowMark\">" + msg.replace('success:', '') + "</span>");

                        } else if (msg.match(/^Error\:/i) != null) {
                            notify_elem.html("<span class=\"sucessfield has-arrowMark\">" + msg.replace('Error:', '') + "</span>");

                        } else if (msg.match(/^error_onblur\:/i) != null) {
                            notify_elem.html("<span class=\"sucessfield has-arrowMark\">" + msg.replace('error_onblur:', '') + "</span>");

                        } else if (msg.match(/^error_sms\:/i) != null) {
                            notify_elem.html("<span class=\"sucessfield has-arrowMark\">" + msg.replace('error_sms:', '') + "</span>");

                            if (notify_elem.find("#mobile_div").length) {
                                elem.val(notify_elem.find("#mobile_div").html());
                                elem.attr('readonly', 'readonly');
                            }
                        }
                    }
                });
            }
        },

        this.verifyMobileCode = function (elem, redirectFlag) {
            var elem = $(elem);
            var code = elem.closest("#enter-otp").find("#mobile_verification_code");
            var mobileNo = elem.closest("#enter-otp").find("#mobileNo");
            var errorfield = elem.closest("#enter-otp").find("#verify-code-error");
            var sucessfield = elem.closest("#enter-otp").find("#verify-code-success");

            if (mobileNo.val() == '') {
                code.addClass("error");
                errorfield.html("Kindly enter a mobile no");
                errorfield.show();
                sucessfield.hide();
                return;
            }

            if (!M.isMobile(mobileNo.val().toString())) {
                code.addClass("error");
                errorfield.html("Kindly enter a valid mobile no");
                errorfield.show();
                sucessfield.hide();
                return;
            }

            if (code.val() == '') {
                code.addClass("error");
                errorfield.html("Please enter verification code");
                errorfield.show();
                sucessfield.hide();
                return;
            }

            if (ajaxRequest == true) {
                ajaxRequest = false;
                q = "page=verifymobilecode";
                q += "&verify_mobile_number=" + mobileNo.val();
                q += "&mobile_verification_code=" + code.val();

                $('#otp-code-loader').show();
                errorfield.hide();
                sucessfield.removeClass('has-arrowMark').html("Verifying your sms code. Please wait..");
                sucessfield.show();

                M.AJAX.request({
                    target: targetUrl,
                    query: q,
                    method: 'POST',
                    onSuccess: function (res) {
                        ajaxRequest = true;
                        res = M.trim(res);
                        if (res.match(/^display|ap8970|ap8971|ap8975\:/i) != null) {
                            if (M.byId('pageOverlay').style.display == "block") {
                                M.byId('pageOverlay').style.display = 'none';
                                M.byId('itemWrapper').style.display = 'none';
                                M.byId('itemOverlay').style.display = '';
                                M.byId('itemOverlay').innerHTML = "";
                            }
                            res = M.trim(res);

                            var res_arr = res.split("__*__");
                            var display_html = (res_arr[0] != undefined) ? res_arr[0] : res;
                            var refCode = (res_arr[1] != undefined) ? res_arr[1] : "";
                            var aipCode = (res_arr[2] != undefined) ? parseInt(res_arr[2]) : 0;
                            var secretkey = (res_arr[3] != undefined) ? res_arr[3] : 0;

                            M.byId('first_form_container_div').style.display = 'none';
                            M.byId('third_form_container_div').innerHTML = display_html.replace(/^display\:|ap8970\:|ap8971\:|ap8975\:/i, '');;
                            M.byId('third_form_container_div').style.height = 'auto';
                            var aip = 0;
                            var apass = 0;
                            if (res.match(/^ap8970\:/i) != null) {
                                apass = 1;
                                aip = 1;
                            }
                            var rpass = 0;
                            if (res.match(/^ap8975\:/i) != null) {
                                rpass = 1;
                                aip = 2;
                            }

                            // Facebook Conversion Code
                            if (M.byId("facebook_pixel") != undefined && apass == 1 && lmsflg == 0) { // || rpass==1
                                fbq('init', '835958713188608'); // Insert your pixel ID here.
                                fbq('track', 'PageView');
                                fbq('track', 'Lead');
                                M.byId("facebook_pixel").innerHTML = '<noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=835958713188608&ev=PageView&noscript=1"/></noscript>';
                            }

                            // Google Conversion Code
                            if (apass == 1 && lmsflg == 0) {	// || rpass==1
                                var google_conversion_id = 859932097;
                                var google_conversion_language = "en";
                                var google_conversion_format = "3";
                                var google_conversion_color = "ffffff";
                                var google_conversion_label = "8eUHCN-XzG4QwYuGmgM";
                                var google_remarketing_only = false;
                                $.getScript('//www.googleadservices.com/pagead/conversion.js');

                                var image = new Image(1, 1);
                                image.src = "//www.googleadservices.com/pagead/conversion/859932097/?label=8eUHCN-XzG4QwYuGmgM&guid=ON&script=0";
                            }

                            if ((apass == 1 || rpass == 1) && secretkey != "") {
                                var image1 = new Image(1, 1);
                                image1.src = 'https://rblbank.rupeepower.com/services/api/credit-card/gcampg?rc=' + refCode + '&st=' + aipCode + '&sc=' + callpixeliframe + '&ky=' + secretkey + '';
                            }

                            if (isus == 0 && (typeof callpixelimg != 'undefined') && callpixelimg != undefined && callpixelimg != null && callpixelimg != "" && M.byId('pixeltracking') != undefined && apass === 1) {

                                if ((typeof optional_information != 'undefined') && optional_information != undefined && optional_information != null && optional_information != "") {
                                    callpixelimg = callpixelimg.replace("optional_information", optional_information);
                                } else {
                                    var tmpDateTime = (new Date()).getTime();
                                    var randomConcat = 100 * (Math.random());
                                    randomConcat = "x" + Math.floor(randomConcat);
                                    tmpDateTime = randomConcat.concat(tmpDateTime);
                                    callpixelimg = callpixelimg.replace("optional_information", tmpDateTime);
                                }
                                if (callpixeltype == 1) {
                                    M.byId('pixeltracking').src = callpixelimg;
                                }
                            }

                            if ((callpixelsetype != undefined && callpixelsetype == 53) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                if (selcallpixelcard == 22) {
                                    M.byId("iframe_pixel").innerHTML = '<img src="https://rblbankpromotions.com/p.ashx?o=4&e=3&f=js&t=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" width="1" height="1" border="0" />';
                                } else if (selcallpixelcard == 6) {
                                    M.byId("iframe_pixel").innerHTML = '<img src="https://rblbankpromotions.com/p.ashx?o=6&e=3&f=js&t=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" width="1" height="1" border="0" />';
                                } else if (selcallpixelcard == 24) {
                                    M.byId("iframe_pixel").innerHTML = '<img src="https://rblbankpromotions.com/p.ashx?o=7&e=3&f=js&t=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" width="1" height="1" border="0" />';
                                } else if (selcallpixelcard == 5) {
                                    M.byId("iframe_pixel").innerHTML = '<img src="https://rblbankpromotions.com/p.ashx?o=8&e=3&f=js&t=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" width="1" height="1" border="0" />';
                                }
                            } else if ((callpixelsetype != undefined && callpixelsetype == 52) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<img src="https://apoxymedia.net/p.ashx?o=91&e=45&f=img&t=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" width="1" height="1" border="0" />';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 51) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<iframe src="https://jansetu.in/p.ashx?o=1512&e=5&t=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" height="1" width="1" frameborder="0"></iframe>';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 50) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<iframe src="https://www.s2d6.com/js/globalpixel.js?x=sp&a=1924&h=69702&o=' + callpixeliframe + '_' + refCode + '_' + aipCode + '&g=&s=0.00&q=1" scrolling="no" frameborder="0" width="1" height="1"></iframe>';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 49) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<iframe src="https://adworld.go2cloud.org/aff_l?offer_id=326&adv_sub=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" scrolling="no" frameborder="0" width="1" height="1"></iframe>';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 48) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<iframe src="https://millennialdigital.in/p.ashx?o=1493&e=73&t=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" height="1" width="1" frameborder="0"></iframe>';
                                M.byId("iframe_pixel").innerHTML = '<img src="https://opicle.go2cloud.org/aff_l?offer_id=4872&adv_sub=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" width="1" height="1" />';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 47) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<iframe src="https://adclickzone.go2cloud.org/aff_l?offer_id=340&adv_sub=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" scrolling="no" frameborder="0" width="1" height="1"></iframe>';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 46) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<img src="https://luvianetwork.go2cloud.org/aff_l?offer_id=1057&adv_sub=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" width="1" height="1" />';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 45) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<img src="https://affnads.go2cloud.org/aff_l?offer_id=68&adv_sub=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" width="1" height="1" />';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 44) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<img src="https://tracking.catalystrendz.in/aff_l?offer_id=6448&adv_sub=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" width="1" height="1" />';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 43) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<img src="http://sense.offserve.org/conv?offer_id=442&adv_sub1=' + callpixeliframe + '_' + refCode + '_' + aipCode + '&amount=AMOUNT" height="1" width="1"/>';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 42) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<img src="http://thefridaycode.in/CAdmin/callback.php?platform=cookie_pixel&click_id=1&orderid=track_id&ordervalue=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" width="1px" height="1px" />';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 41) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<img src="https://tunicalabs.diginow.in/tx/px.php?m=img&c=1659136&leadid=' + callpixeliframe + '_' + refCode + '_' + aipCode + '"/>';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 40) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<iframe src="https://tracking.adzjunction.com/track?offer_id=3&track_id=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" height="1" width="1" frameborder="0" scrolling="no"></iframe>';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 39) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<img src="https://frwd.info/p.ashx?o=505&e=365&f=img&t=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" width="1" height="1" border="0" />';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 38) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<img src="https://vrtztrk.com/p.ashx?o=458&e=172&f=img&t=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" width="1" height="1" border="0" />';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 37) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<img src="http://pointificsecure.com/p.ashx?o=580&e=291&f=img&t=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" width="1" height="1" />';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 36) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<img src="https://ctn.go2cloud.org/aff_l?offer_id=869&adv_sub=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" width="1" height="1" />';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 35) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                //M.byId("iframe_pixel").innerHTML = '<img src="https://livingnetmediapvtltd.go2cloud.org/aff_l?offer_id=318" width="1" height="1" />';
                                M.byId("iframe_pixel").innerHTML = '<img src="https://livingnetmediapvtltd.go2cloud.org/aff_l?offer_id=318&adv_sub=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" width="1" height="1" />';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 34) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<iframe src="http://kenscio.go2cloud.org/aff_l?offer_id=244&adv_sub=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" scrolling="no" frameborder="0" width="1" height="1"></iframe>';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 33) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<iframe src="https://adclickzone.go2cloud.org/aff_l?offer_id=340&adv_sub=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" scrolling="no" frameborder="0" width="1" height="1"></iframe>';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 32) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<iframe src="https://forksurgetrk.com/p.ashx?o=1718&e=498&t=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" height="1" width="1" frameborder="0"></iframe>';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 31) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                //M.byId("iframe_pixel").innerHTML = '<img src="http://sense.offserve.org/conv?offer_id=442&adv_sub1='+callpixeliframe+'_'+refCode+'_'+aipCode+'&amount=AMOUNT" height="1" width="1"/>';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 30) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                //M.byId("iframe_pixel").innerHTML = '<script src="https://www.s2d6.com/js/globalpixel.js?x=sp&a=1924&h=69702&o='+callpixeliframe+'_'+refCode+'_'+aipCode+'&g=&s=0.00&q=1"></script>';
                                M.byId("iframe_pixel").innerHTML = '<iframe src="https://www.s2d6.com/js/globalpixel.js?x=sp&a=1924&h=69702&o=' + callpixeliframe + '_' + refCode + '_' + aipCode + '&g=&s=0.00&q=1" scrolling="no" frameborder="0" width="1" height="1"></iframe>';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 29) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<img src="https://adosiz.adsizzler.com/tracking/conversion/597?partner_trans_id=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" width="1" height="1" border="0">';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 28) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<img src="http://bigtrunk.go2cloud.org/aff_l?offer_id=187&adv_sub=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" width="1" height="1" />';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 27) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                //M.byId("iframe_pixel").innerHTML = '<img src="https://grs69.voluumtrk.com/conversion.gif?cid='+callpixeliframe+'_'+refCode+'_'+aipCode+'" width="1" height="1"/>';
                                M.byId("iframe_pixel").innerHTML = '<img src="https://grs69.voluumtrk.com/conversion.gif?cid=' + callpixeliframe + '_' + refCode + '_' + aipCode + '&payout=cpl&txid=na" width="1" height="1"/>';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 26) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<iframe src="https://cdn.freecharge.in/rbl-cc-integration/cibil-success?SUB_ID=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" scrolling="no" frameborder="0" width="1" height="1"></iframe>';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 25) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<iframe src="https://geoadmedia.go2cloud.org/aff_l?offer_id=402&adv_sub=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" scrolling="no" frameborder="0" width="1" height="1"></iframe>';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 24) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<img src="https://primedigital.go2cloud.org/aff_l?offer_id=1812&adv_sub=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" width="1" height="1" />';
                                M.byId("iframe_pixel").innerHTML = '<img src="http://track.go2digital.in/aff_l?offer_id=1808&adv_sub=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" width="1" height="1" />';
                                //M.byId("iframe_pixel").innerHTML = '<img src="http://track.go2digital.in/aff_l?offer_id=1446&adv_sub='+callpixeliframe+'_'+refCode+'_'+aipCode+'" width="1" height="1" />';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 23) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<img src="https://cardekhoaffiliate.go2cloud.org/aff_l?offer_id=1168&adv_sub=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" width="1" height="1" />';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 22) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<iframe src="https://httpool-secure.net/p.ashx?o=69&e=44&t=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" height="1" width="1" frameborder="0"></iframe>';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 21) && (apass == 1 || rpass == 1) && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard) == 2) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<img src="https://icubes.go2cloud.org/SL4vh?adv_sub=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" width="1" height="1" />';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 21) && (apass == 1 || rpass == 1) && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard) == 1) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<img src="https://icubes.go2cloud.org/SL4vf?adv_sub=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" width="1" height="1" />';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 20) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<iframe src="https://ebayindia.go2cloud.org/aff_l?offer_id=48" scrolling="no" frameborder="0" width="1" height="1"></iframe>';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 19) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                //M.byId("iframe_pixel").innerHTML = '<iframe src="https://payoom.go2cloud.org/aff_l?offer_id=1372&adv_sub='+callpixeliframe+'_'+refCode+'_'+aipCode+'&amount=AMOUNT" scrolling="no" frameborder="0" width="1" height="1"></iframe>';
                                M.byId("iframe_pixel").innerHTML = '<iframe src="https://eploop.go2pixel.org/tracking/conversion/?offer_id=525&orderAmount=ORDER_AMOUNT&orderID=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" height="0" width="0"></iframe>';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 18) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<iframe src="https://aqugen.go2cloud.org/aff_l?offer_id=603&adv_sub=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" scrolling="no" frameborder="0" width="1" height="1"></iframe>';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 17) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<img src="https://ctn.go2cloud.org/aff_l?offer_id=869&adv_sub=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" width="1" height="1" />';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 16) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<iframe src="https://tracking.vcommission.com/SL8Tw?adv_sub=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" scrolling="no" frameborder="0" width="1" height="1"></iframe>';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 15) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                //M.byId("iframe_pixel").innerHTML = '<iframe src="https://icubes.go2cloud.org/SL4pV?adv_sub='+callpixeliframe+'_'+refCode+'_'+aipCode+'&adv_sub2=SUB_ID2" scrolling="no" frameborder="0" width="1" height="1"></iframe>';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 14) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<img src="https://clickonik.go2cloud.org/aff_l?offer_id=244&adv_sub=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" width="1" height="1" />';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 13) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<img src="http://www.hatsoffdigi.com/rbl-1.php?hop=7K097X3RT9/r/YWJkdWxrYWRpckBoYXRzb2ZmZGlnaXRhbC5jb20" id="1834606000000576001_imgsrc_url_1" border="0">';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 12) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<img src="https://opicle.go2cloud.org/aff_l?offer_id=3526&adv_sub=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" width="1" height="1" />';
                                //M.byId("iframe_pixel").innerHTML = '<img src="https://opicle.go2cloud.org/aff_l?offer_id=3526&adv_sub='+callpixeliframe+'_'+refCode+'_'+aipCode+'" width="1" height="1" />';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 11) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<iframe src="https://camclik.com/p.ashx?o=72&e=35&t=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" height="1" width="1" frameborder="0"></iframe>';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 10) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<iframe src="https://tracking.proformics.com/aff_l?offer_id=1132&adv_sub=' + callpixeliframe + '_' + refCode + '_' + aipCode + '&adv_sub2=SUB_ID" scrolling="no" frameborder="0" width="1" height="1"></iframe>';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 9) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<iframe src="https://tracking.salesleaf.com/aff_l?offer_id=597&adv_sub=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" scrolling="no" frameborder="0" width="1" height="1"></iframe>';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 8) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<iframe src="https://affiliatevia.go2jump.org/SL3UZ?adv_sub=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" scrolling="no" frameborder="0" width="1" height="1"></iframe>';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 7) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<img src="https://poly.go2cloud.org/aff_l?offer_id=670&adv_sub=' + callpixeliframe + '_' + refCode + '_' + aipCode + '<https://www.google.com/url?q=https%3A%2F%2Fpoly.go2cloud.org%2Faff_l%3Foffer_id%3D670%26adv_sub%3DSUB_ID&sa=D&sntz=1&usg=AFQjCNHweh3zBUIMTvBQ9iqgg1h7JA5crw>" width="1" height="1" />';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 6) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<img src="http://www.intellectads.co.in/track/conversion.asp?cid=845&conversionType=1&key=' + callpixeliframe + '_' + refCode + '_' + aipCode + '&opt1=&opt2=&opt3=" height="1" width="1" />';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 5) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<iframe src="https://mediadecks.com/p.ashx?o=71&e=2&t=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" height="1" width="1" frameborder="0"></iframe>';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 4) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<img src="https://track.in.omgpm.com/apptag.asp?APPID=' + callpixeliframe + '_' + refCode + '_' + aipCode + '&MID=863522&PID=16379&status=" border="0" height="1" width="1">';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 3) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<img src="https://adcanopus.go2cloud.org/aff_l?offer_id=189&adv_sub=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" width="1" height="1" />';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 2) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<iframe src="https://tracking.affiliatehub.co.in/SL1N7?adv_sub=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" height="1" width="1" scrolling="no" frameborder="0"></iframe>';
                            } else if ((callpixelsetype != undefined && callpixelsetype == 1) && apass == 1 && M.byId("iframe_pixel") != undefined && (callpixeliframe != undefined && callpixeliframe != "") && (refCode != undefined && refCode != "") && (callpixelcard != undefined && parseInt(callpixelcard)) && (aipCode != undefined && aipCode)) {
                                M.byId("iframe_pixel").innerHTML = '<iframe src="https://rbl.adsplay.in/trackingcode_lead_condi.php?pgmid=' + callpixelcard + '&orderId=' + callpixeliframe + '_' + refCode + '_' + aipCode + '" height="1" width="1" scrolling="no" frameborder="0"></iframe>';
                            }

                            ga('send', 'event', 'Creditcard-submit', 'AIPapproved', 'Submit-click', 1);

                            if (apass == 1 || rpass == 2) {
                                //~ $.getScript('//platform.twitter.com/oct.js');
                                twttr.conversion.trackPid('nz32d', { tw_sale_amount: 0, tw_order_quantity: 0 });
                                var image = new Image(1, 1);
                                image.src = "https://analytics.twitter.com/i/adsct?txn_id=nz32d&p_id=Twitter&tw_sale_amount=0&tw_order_quantity=0";
                                image.src = "//t.co/i/adsct?txn_id=nz32d&p_id=Twitter&tw_sale_amount=0&tw_order_quantity=0";
                            }

                            if (aipCode == 1) {
                                window.location.href = window.location.href + "&d=1";
                            } else if (aipCode == 2) {
                                window.location.href = window.location.href + "&d=2";
                            } else if (aipCode == 3) {
                                window.location.href = window.location.href + "&d=3";
                            }
                        } else if (res.match(/^error|Error|error_session|error_sms\:/i) != null) {
                            res = res.replace(/^error_session\:|error_sms\:|error\:|Error\:/i, '');
                            res = M.trim(res);
                            code.addClass("error");
                            errorfield.html(res);
                            errorfield.show();
                            sucessfield.hide();
                            $('#otp-code-loader').hide();
                        } else if (res.match(/^display\:/i) != null) {
                            if (M.byId('pageOverlay').style.display == "block") {
                                M.byId('pageOverlay').style.display = 'none';
                                M.byId('itemWrapper').style.display = 'none';
                                M.byId('itemOverlay').style.display = '';
                                M.byId('itemOverlay').innerHTML = "";
                                if (M.byId('second_form_container_div').style.display == "block" && M.byId('itemOverlay').innerHTML == "") {
                                    M.byId('second_form_container_div').innerHTML = res;
                                }
                            }
                        }
                    },
                    onFailed: function (msg) {
                        showError(msg, true);
                    }
                });
            }
        },

        this.resendMobileVerificationCode = function (elem) {
            var code = $("#mobile_verification_code");
            var notification = $("#resend-code-notification");
            var mobile_resend = $("#mobile_resend");
            var change_number_error = $("#change-number-error");
            var verify_number_success = $('#verify-code-success');
            var verify_code_error = $('#verify-code-error');

            if ($(elem).attr('id') == 'change-number-resend') {
                if (mobile_resend.val() == '') {
                    mobile_resend.addClass("error");
                    change_number_error.html("Kindly enter your mobile number");
                    change_number_error.show();
                    return false;
                }

                if (!M.isMobile(mobile_resend.val().toString())) {
                    mobile_resend.addClass("error");
                    change_number_error.html("Kindly enter a valid mobile number");
                    change_number_error.show();
                    return false;
                }

                unver_mobile = $("#mobileNo").val();
                $("#mobileNo").val(mobile_resend.val());
                code.val('');
                code.attr('placeholder', 'Enter OTP sent by SMS on ' + mobile_resend.val())
                $('#mobile_no').val(mobile_resend.val());
                $('#change-mnumber').hide();
                $('#enter-otp').show();
                $("#enter_opt_heading").html("Enter the OTP sent to <strong>" + mobile_resend.val() + "</strong>");
            }

            q = "page=resendmobilecode";
            q += "&mobile=" + $('#mobileNo').val();

            code.removeClass('error');
            $("#verify-code-error").hide();
            if ($(elem).attr('id') != 'change-number-resend') {
                //notification.removeClass().addClass('txtorng').html("Please wait! Sending verification code...");
                //notification.show();
                //verify_number_success.removeClass('has-arrowMark').html('Please wait! Sending verification code...');
                //verify_number_success.show();
                //change_number_error.show();
            } else {
                //$('#otp-code-loader').show();
                //$('#verify-code-success').removeClass('has-arrowMark').html('Please wait! Sending verification code...');
                //$('#verify-code-success').show();
            }

            if (ajaxRequest == true) {
                ajaxRequest = false;
                M.AJAX.request({
                    target: targetUrl,
                    query: q,
                    method: 'POST',
                    onSuccess: function (msg) {
                        ajaxRequest = true;
                        //$('#otp-code-loader').hide();
                        msg = M.trim(msg);
                        console.log(msg);

                        if (msg.match(/^success\:/i) != null) {
                            msg = msg.replace(/^success\:/i, '');

                            //~ $("#mobile_verification_code").attr("placeholder","Enter OTP sent by SMS on "+mobile_resend.val());
                            if ($(elem).attr('id') != 'change-number-resend') {
                                verify_number_success.html(msg);
                                verify_number_success.show();
                                change_number_error.show();
                                counterStart();
                            } else {
                                change_number_error.html(msg);
                                change_number_error.show();
                            }
                        } else if (msg.match(/^error_sms\:|Error\:/i) != null) {
                            msg = msg.replace(/^error_sms\:|Error\:/i, '');

                            if ($(elem).attr('id') != 'change-number-resend') {
                                verify_code_error.html(msg);
                                verify_code_error.show();
                                verify_number_success.hide();
                            } else {
                                change_number_error.html(msg);
                                change_number_error.show();
                            }
                        }
                    },
                    onFailed: function (msg) {
                        ajaxRequest = true;
                        var l = M.byId('error_msg');
                    }
                });
            }
            return false;
        },

        /*
         * 
         */
        this.activateValidation = function (form_id, validation_flg) {
            var minimum = 3;
            var dateFields = ["dobday", "dobmonth", "dobyear"];
            var nameFields = ["txt_title", "fname"];
            var validation_triggered = false;
            if (validation_flg == undefined) {
                validation_flg = true;
            }

            var frm = $("#" + form_id);
            frm.validate({
                ignore: ':hidden:not(#gndr,#employmentType,#existing_other_loan_cc,#scb_credit_card,#exit_cust)',	//
                errorElement: "div",
                errorClass: "invalidFiled",
                ignoreTitle: true,
                rules: {
                    cities: {
                        required: true,
                        number: true
                    },
                    gndr: {
                        required: true,
                        number: true
                    },
                    employmentType: "required",
                    city_id: {
                        required: true,
                        number: true
                    },
                    txt_title: {
                        required: true,
                        number: true
                    },
                    pincode: {
                        required: true,
                        number: true
                    },
                    area: {
                        required: true,
                        number: true
                    },
                    dobday: {
                        required: true,
                        validDate: dateFields
                    },
                    dobmonth: {
                        required: true,
                        validDate: dateFields
                    },
                    dobyear: {
                        required: true,
                        validDate: dateFields
                    },
                    employer: "required",
                    existing_other_loan_cc: {
                        required: true,
                        alpha: true
                    },
                    scb_credit_card: {
                        required: true,
                        alpha: true
                    },
                    exit_cust: {
                        required: true,
                        alpha: true
                    },
                    status_view_app_code: "required",
                    acceptTC: "required",
                    fname: {
                        required: true,
                        alpha: true,
                        notEqualTo: ["#lname", "#mname"]
                    },
                    lname: {
                        required: true,
                        alpha: true,
                        notEqualTo: ["#fname", "#mname"]
                    },
                    mname: {
                        required: false,
                        alpha: true,
                        notEqualTo: ["#fname", "#lname"]
                    },
                    txt_father_name: {
                        required: true,
                        alphaSpace: true
                    },
                    txt_embosser_name: {
                        required: true,
                        number: true,
                        rangelength: [10, 10]
                    },
                    addressL1: {
                        required: true,
                        validAddress: true,
                        rangelength: [minimum, 40]
                    },
                    addressL2: {
                        required: false,
                        validAddress: true,
                        rangelength: [minimum, 40]
                    },
                    txt_landmark: {
                        required: false,
                        validAddress: true,
                        rangelength: [minimum, 40]
                    },
                    dateOfBirth: {
                        required: true,
                        validDateFormat: true
                    },
                    office_email: {
                        required: false,
                        validEmail: true
                    },
                    emailid: {
                        required: true,
                        validEmail: true
                    },
                    mobile: {
                        required: true,
                        validMobile: true
                    },
                    city: {
                        required: true,
                        alphaSpace: true
                    },
                    grossincome: {
                        required: true,
                        amountLength: true
                    },
                    panCard: {
                        required: true,
                        validPancard: true
                    },
                    store_code: {
                        required: true,
                        number: true,
                    },
                    referee_code: {
                        required: false,
                        alphaNumber: true,
                        rangelength: [8, 8]
                    },
                    se_code: {
                        required: true,
                        alphaNumber: true,
                    },
                },
                messages: {
                    fname: 'Please enter a valid first name',
                    lname: 'Please enter a valid last name',
                    gndr: 'Please select your gender',
                    mobile: 'Please enter a valid mobile number',
                    emailid: 'Please enter a valid email',
                    panCard: 'Please enter a valid PAN',
                    employmentType: 'Please select your employment type',
                    addressL1: 'Please enter a valid address line 1, accepts only these special characters  , - \' ',
                    addressL2: 'Please enter a valid address line 2, accepts only these special characters  , - \' ',
                    grossincome: 'Please enter your net monthly income',
                    cities: 'Please select city of your current residence',
                    pincode: 'Please select pincode of your current residence',
                    referee_code: 'Referee Code is invalid',
                    store_code: 'Store Code is invalid',
                    dateOfBirth: 'Please enter a valid date of birth',
                    dobday: 'Please select a correct Date of Birth',
                    dobmonth: 'Please select a correct Date of Birth',
                    dobyear: 'Please select a correct Date of Birth',
                    scb_credit_card: 'Please confirm, Do you have an existing RBL Credit Card?',
                    exit_cust: 'Please confirm, Have you applied for an RBL Credit Card in the past 90 days?',
                },
                groups: {
                    //~ dateOfBirth: dateFields.join(" "),
                },
                highlight: function (element) {
                    //console.log("highlight -" + $(element).attr('id'));
                    /*
                    if ($(element).hasClass('css-checkbox')) {
                        $(element).closest('.rp-terms').addClass("err-chk");
                    } else {
                        $(element).closest('li').addClass('error');
                    }
    
                    //hide info message for mobile number if error
                    if ($(element).attr('id') === 'mobile') {
                        $(element).closest('li').find('#msg_box').hide();
                    }
                    */
                },
                unhighlight: function (element) {
                    //console.log("unhighlight -" + $(element).attr('id'));
                    /*
                    if ($(element).hasClass('css-checkbox')) {
                        $(element).siblings('label').removeClass('css-labelerror-checkbox').addClass('css-label');
                        $(element).closest('.rp-terms').removeClass('err-chk');
                    } else {
                        $(element).closest('li').removeClass('error');
                    }
                	
                    //show info message for mobile number if error
                    if ($(element).attr('id') === 'mobile') {
                        $(element).closest('li').find('#msg_box').show();
                    }
                    */
                },
                invalidHandler: function (form, validator) {
                    var errors = validator.numberOfInvalids();
                    if (errors) {
                        /*var first_error = validator.errorList[0].element;
                        $('#page-level-errors').find('strong').html('Uh Oh! ');
                        var lbl = '';
    
                        if ($(first_error).closest('#application-step-3').length) {
                            lbl = ' stopped us from taking a decision on your card.';
                        } else {
                            lbl = ' stopped us from checking your eligibility.';
                        }
    
                        if (errors == 1) {
                            lbl = ' ' + errors + ' error' + lbl;
                        } else {
                            lbl = ' ' + errors + ' error(s)' + lbl;
                        }
    
                        $('#page-level-errors').find('#error-content').html(lbl);
                        $('#page-level-errors').show();
    
                    	
                        $('html, body').animate({
                            scrollTop: $(validator.errorList[0].element).offset().top - 120
                        }, 500, function () {
                            validator.errorList[0].element.focus();
                        });*/
                    }

                },
                errorPlacement: function (error, element) {
                    /*
                    if (!validation_triggered) {
                        validation_triggered = true;
                    }
                    if ($(element).attr('id') == 'acceptTC' || $(element).attr('id') == 'info_provided') {
                        return;
                    }
                    */
                    //console.log("errorPlacement -" + $(element).attr('id'));
                    if ($(element).attr('id') == 'dobday' || $(element).attr('id') == 'dobmonth' || $(element).attr('id') == 'dobyear') {
                        error.insertAfter("#dobfield");
                        error.appendTo($("#dobfield").closest('div'));
                        console.log($(element).attr('id'));
                    } else if ($(element).attr('id') == 'existing_other_loan_cc') {
                        error.insertAfter("#existing_other_loan_cc_u");
                        error.appendTo($("#existing_other_loan_cc_u").closest('div'));
                    } else {
                        error.insertAfter($(element).parent());
                        error.appendTo($(element).closest('div'));
                    }

                },
                success: function (label) {

                    /*
                    var fieldErrorId = $(label).attr("id");
                    var fieldErrorIdArr = fieldErrorId.split('-');
                    var fieldId = (fieldErrorIdArr[0] != undefined) ? fieldErrorIdArr[0] : "";
                    */
                    //creditCardObj.fieldsHints(fieldId,fieldErrorId);
                }
            });

            $('.form-control', frm).change(function () {
                if (validation_triggered) {
                    frm.validate().element($(this));
                }
            });
        },

        this.fieldsHints = function (fieldId, fieldErrorId, label) {
            var city_id = 0;
            var fname = "";
            var dobday = 0;
            var dobmonth = 0;
            var dobyear = 0;
            var employment_type = 0;
            var _class = "";
            if (fieldId == "cities") {
                city_id = $("#" + fieldId).val();
                city_name = $("#" + fieldId + " option[value='" + city_id + "']").text();

                if (city_id == 157) {
                    $("#" + fieldErrorId).html("Ah! You are a Delhiite");
                } else if (city_id == 12) {
                    $("#" + fieldErrorId).html("Ah! You are a Bangalorean");
                } else if (city_id == 15) {
                    $("#" + fieldErrorId).html("Ah! You are a Mumbaikar");
                } else if (city_id == 13) {
                    $("#" + fieldErrorId).html("Ah! You are a Chennaite");
                } else {
                    $("#" + fieldErrorId).html("Ah! You are from " + city_name);
                }
                $("#" + fieldErrorId).attr("class", "invalidFiled valid");
            } else if (fieldId == "gndr") {
                $("#" + fieldErrorId).attr("class", "invalidFiled valid");
            } else if (fieldId == "txt_title") {
                $("#" + fieldErrorId).attr("class", "invalidFiled valid");
            } else if (fieldId == "dateOfBirth") {
                /*
                dobday = $("#dobday").val();
                dobday = parseInt(dobday);
                dobmonth = $("#dobmonth").val();
                dobmonth = parseInt(dobmonth);
                dobyear = $("#dobyear").val();
                dobyear = parseInt(dobyear);
                */
                var dateofbirth_arr = $("#dateOfBirth").val().split("-");
                dobday = (dateofbirth_arr[0] != undefined) ? parseInt(dateofbirth_arr[0]) : 0;
                dobmonth = (dateofbirth_arr[1] != undefined) ? parseInt(dateofbirth_arr[1]) : 0;
                dobyear = (dateofbirth_arr[2] != undefined) ? parseInt(dateofbirth_arr[2]) : 0;
                if (dobyear > 0 && dobday > 0 && dobmonth > 0 && dateofbirth_arr.length != null) {
                    if ((dobday >= 21 && dobmonth == 3) || (dobday <= 19 && dobmonth == 4)) {
                        $("#" + fieldErrorId).html("Aries are active, determined and ambitious.");
                        _class = "aries-msg";
                    } else if ((dobday >= 21 && dobmonth == 4) || (dobday <= 20 && dobmonth == 5)) {
                        $("#" + fieldErrorId).html("Taurus are secure, subtle strength and patient.");
                        _class = "taurus-msg";
                    } else if ((dobday >= 21 && dobmonth == 5) || (dobday <= 22 && dobmonth == 6)) {
                        $("#" + fieldErrorId).html("Geminis are inquisitive, intelligent and changeable.");
                        _class = "gemini-msg";
                    } else if ((dobday >= 23 && dobmonth == 6) || (dobday <= 22 && dobmonth == 7)) {
                        $("#" + fieldErrorId).html("Cancers are said to be people of sensation and feeling.");
                        _class = "cancer-msg";
                    } else if ((dobday >= 23 && dobmonth == 7) || (dobday <= 22 && dobmonth == 8)) {
                        $("#" + fieldErrorId).html("A Leo always makes their presence known.");
                        _class = "leo-msg";
                    } else if ((dobday >= 23 && dobmonth == 8) || (dobday <= 22 && dobmonth == 9)) {
                        $("#" + fieldErrorId).html("Virgos are helpful, critical, shy, and meticulous.");
                        _class = "virgo-msg";
                    } else if ((dobday >= 23 && dobmonth == 9) || (dobday <= 21 && dobmonth == 10)) {
                        $("#" + fieldErrorId).html("Libras are known to be mild mannered, easy going and sociable.");
                        _class = "libra-msg";
                    } else if ((dobday >= 22 && dobmonth == 10) || (dobday <= 21 && dobmonth == 11)) {
                        $("#" + fieldErrorId).html("Scorpio zodiac sign natives are known to be the intense, powerful and self-controlled people.");
                        _class = "scorpio-msg";
                    } else if ((dobday >= 22 && dobmonth == 11) || (dobday <= 21 && dobmonth == 12)) {
                        $("#" + fieldErrorId).html("Sagittarius are often highly intelligent, adventurous and curious.");
                        _class = "sagittarius-msg";
                    } else if ((dobday >= 22 && dobmonth == 12) || (dobday <= 19 && dobmonth == 1)) {
                        $("#" + fieldErrorId).html("Capricorns have high achieving characteristics.");
                        _class = "capricon-msg";
                    } else if ((dobday >= 20 && dobmonth == 1) || (dobday <= 18 && dobmonth == 2)) {
                        $("#" + fieldErrorId).html("Aquarius are progressive, original and independent.");
                        _class = "aquarian-msg";
                    } else if ((dobday >= 19 && dobmonth == 2) || (dobday <= 20 && dobmonth == 3)) {
                        $("#" + fieldErrorId).html("Pisces are compassionate, artistic, intuitive and gentle.");
                        _class = "pisces-msg";
                    }


                    $("#" + fieldErrorId).attr("class", "invalidFiled valid " + _class);
                } else {
                    //console.log("DATE "+M.byId(fieldErrorId));
                    //M.byId(fieldErrorId).style.display = "none";
                    //console.log("DATE "+M.byId(fieldErrorId).style.display);
                    $("#" + fieldErrorId).attr("class", "invalidFiled valid");
                    //$("#"+fieldErrorId).html("Enter a valid data of birth.");
                }
            } else if (fieldId == "fname") {
                fname = $("#" + fieldId).val();
                $("#" + fieldErrorId).html("Nice to meet you " + capitalize(fname));
                $("#" + fieldErrorId).attr("class", "invalidFiled valid name-msg");
            } else if (fieldId == "mobile") {
                $("#" + fieldErrorId).html("Your Privacy is our primary concern!");
                $("#" + fieldErrorId).attr("class", "invalidFiled valid privacy-msg");
            } else if (fieldId == "emailid") {
                $("#" + fieldErrorId).html("Let's keep in touch.");
                $("#" + fieldErrorId).attr("class", "invalidFiled valid touch-msg");
            } else if (fieldId == "employmentType") {
                employment_type = $("#" + fieldId).val();
                if (employment_type == 1) {
                    $("#" + fieldErrorId).html("There's no denying the comfort of a salary!");
                } else if (employment_type == 2) {
                    $("#" + fieldErrorId).html("So you are your own boss!!!");
                }
                $("#" + fieldErrorId).attr("class", "invalidFiled valid touch-msg");
            } else if (fieldId == "grossincome") {
                $("#" + fieldErrorId).html("Earn nicely, spend wisely and you will live happily.");
                $("#" + fieldErrorId).attr("class", "invalidFiled valid touch-msg");
            } else if (fieldId == "panCard") {
                $("#" + fieldErrorId).html("PAN card is sure, dependable, nationally recognized proof of an individual.");
                $("#" + fieldErrorId).attr("class", "invalidFiled valid touch-msg");
            } else if (fieldId == "txt_embosser_name" || fieldId == "se_code" || fieldId == "office_email" || fieldId == "referee_code" || fieldId == "store_code" || fieldId == "txt_title" || fieldId == "existing_other_loan_cc" || fieldId == "panCard" || fieldId == "grossincome" || fieldId == "employer" || fieldId == "employmentType" || fieldId == "city" || fieldId == "mname" || fieldId == "lname" || fieldId == "txt_father_name" || fieldId == "addressL1" || fieldId == "addressL2" || fieldId == "txt_landmark" || fieldId == "pincode" || fieldId == "city_id" || fieldId == "area") {
                $("#" + fieldErrorId).attr("class", "invalidFiled valid");
            }
        },

        // AUTOCOMPLETE FUNCTION
        this.callAutocompleteEmployer = function (id) {
            $(function () {
                if (M.byId(id) != undefined) { // in case of SE/SEP
                    $("#" + id).autocomplete({
                        source: function (request, response) {
                            var $this = $(this);
                            var $element = $(this.element);
                            var jqXHR = $element.data('jqXHR');
                            if (jqXHR) {
                                jqXHR.abort();
                            }
                            $element.data('jqXHR', $.ajax({
                                url: targetUrl,
                                dataType: "json",
                                async: "false",
                                mode: "abort",
                                contentType: 'application/json; charset=utf-8',
                                asyn: false,
                                data: {
                                    employer_name: request.term,
                                    page: "getemployerlist"
                                },
                                beforeSend: function () {
                                    if (M.byId('matchbox') != undefined) {
                                        M.byId('matchbox').innerHTML = "<img height=\"20\" src=\"/support/img_rp/loader_green_small_new.gif\">";
                                    }
                                },
                                success: function (returnObj) {
                                    //console.log(returnObj);
                                    if (returnObj.msg == 'Success') {
                                        response($.map(returnObj.data, function (item) {
                                            return { label: item.employee_company_name, value: item.employee_company_name }
                                        })
                                        );
                                    }

                                    if (M.byId('matchbox') != undefined) {
                                        M.byId('matchbox').innerHTML = "";
                                    }
                                }
                            })
                            );
                        },
                        minLength: 3,
                        selectFirst: true,
                        selectOnly: true,
                        select: function (event, ui) {
                            $("#" + id).val(ui.item.label);
                            return true;
                        }
                    }).keydown(function (e, data, ui) {
                        if (e.which == 9 && false) {
                            var countUi = $(".ui-autocomplete").length;
                            var actualCountUi = countUi - 1;
                            if ($(".ui-autocomplete:eq(" + actualCountUi + ")").css('display') != 'none') {
                                var res = $(".ui-autocomplete:eq(" + actualCountUi + ") li:first a").html();
                                $("#" + id).val(res);
                                return true;
                            }
                        }
                    });
                }
            });
        },

        this.populatePincode = function (city_id, divId, src, loader) {
            var target = src;
            if (city_id > 0) {
                //--$("#"+target).select2('val',"");
                M.byId(loader).style.display = "inline";
                M.AJAX.request({
                    target: targetUrl,
                    query: "page=pincode&city_id=" + city_id,
                    method: 'POST',
                    onSuccess: function (res) {
                        res = M.trim(res);
                        M.byId(loader).style.display = "none";
                        if (res != '') {
                            if (M.byId(target) != undefined) {
                                M.byId(target).disabled = false;
                            }
                            $('#' + target).empty();
                            $('#' + target).html(res);
                        } else {
                            M.byId(src).innerHTML = '';
                            M.byId(src).innerHTML = '<select name="' + target + '" id="' + target + '"  disabled="disabled"/><option value=\'\'>Select</option></select><span style="display: none; padding-left:10px; margin-left:-55px;" id="' + loader + '"><img height="22px" src="/support/img_rp/loader_green.gif"></span>';
                        }
                    },
                    onFailed: function (msg) {
                    }
                });
            } else {
                M.byId(src).innerHTML = '<select name="' + target + '" id="' + target + '"  disabled="disabled"/><option value=\'\'>Select</option></select><span style="display: none; padding-left:10px; margin-left:-55px;" id="' + loader + '"><img height="22px" src="/support/img_rp/loader_green.gif"></span>';
            }
        },

        this.populateArea = function (pincode, divId, target, loader) {
            var html = "";
            M.byId(divId).style.display = "none";
            M.byId(target).disabled = true;
            if (pincode > 0) {
                M.byId(loader).style.display = "inline";

                M.AJAX.request({
                    target: targetUrl,
                    query: "page=area&pincode=" + pincode,
                    method: 'POST',
                    onSuccess: function (res_json) {
                        res_json = M.trim(res_json);
                        var res = eval('(' + res_json + ')');
                        if (res.length != undefined && res.length > 0) {
                            html += "<option value=''>Select Area</option>";
                            $.each(res, function (key, val) {
                                html += "<option value='" + val.id + "'>" + val.value + "</option>";
                            });

                            M.byId(divId).style.display = "block";
                            M.byId(target).disabled = false;
                            $('#' + target).empty();
                            $("#" + target).html(html);
                        } else {
                            M.byId(divId).style.display = "none";
                            M.byId(target).disabled = true;
                        }
                        M.byId(loader).style.display = "none";
                    },
                    onFailed: function (msg) {

                    }
                });
            }
            $('#creditcardinfoform').valid();
        },

        this.SelectCityId = function (obj) {
            $('#cities').valid();
            var cityId = obj.value;
            $("a[id^='city_']").removeClass('active');
            if (cityId == 157 || cityId == 15 || cityId == 12 || cityId == 13 || cityId == 8 || cityId == 3) {
                $('#city_' + cityId).addClass('active');
            }
        },

        this.getAppStatus = function (frm) {
            var r = false;
            var error = "";
            var req = false;
            var app_code = "";
            var mobile = "";

            if ($('#appTrackForm').valid()) {
                r = (frm['status_view_app_code'] != undefined && frm['status_view_app_code'].value != "" && frm['status_view_app_code'].value.match(/^[#|\!|I|T|H]+(CL|HL|PL|CI|HI|IP|RI|MI|EL|CC)+[A-Z0-9]{5,20}/) != null);
                frm['status_view_app_code'].style.borderColor = "#aaaaaa";
                if (!r) {
                    frm['status_view_app_code'].style.borderColor = C[5];
                    error = "Please enter a valid Reference No";
                }
                if (M.trim(frm['mobile'].value) == '') {
                    frm['mobile'].style.borderColor = C[5];
                    if (r) error = "Please enter your Mobile No";
                    r = false;
                } else if (M.isMobile(frm['mobile'].value.toString()) == null) {
                    frm['mobile'].style.borderColor = C[5];
                    if (r) error = "Please enter a valid Mobile No";
                    r = false;
                } else {
                    frm['mobile'].style.borderColor = '#aaaaaa';
                }

                if (!r || error != "") {
                    if (M.byId("track-error") != undefined) {
                        M.byId("track-error").style.display = "block";
                        M.byId("track-error").innerHTML = error;
                    }
                } else if (!req && r) {
                    M.byId("track-error").style.display = "none";
                    app_code = frm['status_view_app_code'].value.toString();
                    app_code = escape(app_code);
                    app_code = decodeURI(app_code);
                    mobile = frm['mobile'].value.toString();

                    M.AJAX.request({
                        target: targetUrl,
                        query: "page=appstatus&app_code=" + app_code + "&mobile=" + mobile,
                        method: 'POST',
                        onSuccess: function (res) {
                            res = M.trim(res);
                            if (res != null) {
                                if (res.match(/^error_sms\:|Error\:/i) != null) {
                                    req = true;
                                    res = res.replace(/^Error\:/i, '');
                                    M.byId("track-error").innerHTML = res;
                                    M.byId("track-error").style.display = "block";
                                } else {
                                    M.byId("app_track_show").innerHTML = res;
                                }
                            }
                        },
                        onFailed: function (msg) {
                            req = false;
                        }
                    });
                }
            }
            return false;
        }

}

function goToByScroll(id) {
    if (id != undefined) {
        $('html,body').animate({
            scrollTop: $("#" + id).offset().top
        }, 'slow');
    }
}

function capitalize(s) {
    s = s.toLowerCase();
    return s[0].toUpperCase() + s.slice(1);
}

function showError(msg, flg) {
    if (M.byId("page-level-errors") != undefined && M.byId("error-content") != undefined) {
        if (flg) {
            $('#error-content').html(msg);
            $('#page-level-errors').show();

            goToByScroll('page-level-errors');
        } else {
            $('#error-content').html("");
            $('#page-level-errors').hide();
        }
    } else {
        alert(msg);
    }
}

function tuDe(vl, id) {
    if (parseInt(vl) > 0 && M.byId(id) != undefined) {
        if (M.byId("tu_step_" + vl) != undefined) {
            M.byId("tu_step_" + vl).style.display = 'block';
            M.byId(id).innerHTML = "";
        }
    }
}

function getStatusExitingCard() {
    var exiting_credit_card_ck = $("input:radio[name='scb_credit_card']:checked");
    if (exiting_credit_card_ck.val() == "Y") {
        M.byId('tr_exiting_cc').style.display = '';
        M.byId('exiting_cc').disabled = false;

        //M.byId('tr_grossincome').style.display = 'none';
        //M.byId('grossincome').disabled = true;                
    } else {
        M.byId('tr_exiting_cc').style.display = 'none';
        M.byId('exiting_cc').disabled = true;

        //M.byId('tr_grossincome').style.display = '';        
        //M.byId('grossincome').disabled = false;        
        getExitingCard(false);
    }
    return false;
}

function setGolfCardFields() {
    var flg = $("input:radio[name='txt_club_member_typ']:checked").val();
    if (flg == 1) {
        M.byId("tr_golf_card_0").style.display = '';
        M.byId("tr_golf_card_1").style.display = '';
        M.byId("tr_addon_0").style.display = '';
        M.byId("txt_addon_card_flg").checked = false;
        M.byId("txt_addon_card_flg").disabled = false;
        setGolfCardAddonFields();
    } else if (flg == 2) {
        M.byId("tr_golf_card_0").style.display = 'none';
        M.byId("tr_golf_card_1").style.display = 'none';
        M.byId("tr_addon_0").style.display = '';
        M.byId("txt_addon_card_flg").checked = true;
        M.byId("txt_addon_card_flg").disabled = true;
        M.byId("txt_primary_club_member").checked = true; //@ADD on 29-07-15
        M.byId("txt_primary_club_member").disabled = true; //@ADD on 31-07-15
        setGolfCardAddonFields();
    } else if (flg == 3) {
        M.byId("tr_golf_card_0").style.display = '';
        M.byId("tr_golf_card_1").style.display = 'none';
        M.byId("tr_addon_0").style.display = '';
        M.byId("txt_addon_card_flg").checked = false;
        M.byId("txt_addon_card_flg").disabled = false;
        setGolfCardAddonFields();
    }
}
//TAG: GOLF CARD
function setPrimaryGolfCardFields() {
    if (M.byId("txt_primary_club_member") == undefined) return false;
    if (M.byId("txt_primary_club_member").checked == true) {
        //M.byId("tr_golf_card_2_1").style.display = '';
        M.byId("tr_golf_card_2_2").style.display = '';
    } else {
        //M.byId("tr_golf_card_2_1").style.display = 'none';
        M.byId("tr_golf_card_2_2").style.display = 'none';
    }
}

//TAG: GOLF CARD
function setGolfCardAddonFields() {
    if (M.byId("txt_addon_card_flg") == undefined) return false;
    var flg = $("input:radio[name='txt_club_member_typ']:checked").val();
    if (M.byId("txt_addon_card_flg").checked == true && flg > 0) {
        var group_arr = [];
        if (flg == 1) {
            group_arr = ["tr_addon_1", "tr_addon_2", "tr_addon_3", "tr_addon_5"];
        } else if (flg == 2) {
            group_arr = ["tr_addon_1", "tr_addon_2", "tr_addon_3", "tr_addon_5", "tr_addon_4", "tr_golf_card_2_2"]; //ADD LAST @29-07-2015
        } else if (flg == 3) {
            group_arr = ["tr_addon_1", "tr_addon_2", "tr_addon_3", "tr_addon_5"];
        }
        if (group_arr != undefined && group_arr.length > 0) {
            for (var i = 0; i < group_arr.length; i++) {
                M.byId(group_arr[i]).style.display = '';
            }
        }
    } else {
        M.byId("tr_addon_1").style.display = 'none';
        M.byId("tr_addon_2").style.display = 'none';
        M.byId("tr_addon_3").style.display = 'none';
        M.byId("tr_addon_4").style.display = 'none';
        M.byId("tr_addon_5").style.display = 'none';
        M.byId("txt_primary_club_member").checked = false;
        setPrimaryGolfCardFields();
    }
}

function getStatusExitingCust() {
    var exiting_bank_ck = $("input:radio[name='scb_exit_cust']:checked");
    if (exiting_bank_ck.val() == "Y") {
        M.byId('tr_bank_account_no').style.display = '';
        M.byId('bank_card_account_no').disabled = false;
    } else {
        M.byId('tr_bank_account_no').style.display = 'none';
        M.byId('bank_card_account_no').disabled = true;
        M.byId('bank_card_account_no').value = "";
    }
    return false;
}
//23 MARCH 2016 : ADDED by DEEPESH
function changeEmployeeType(obj_val) {
    getCompany(parseInt(obj_val));
}

function changeEmployee(obj_val) {
    getCompanyList(parseInt(obj_val));
}

function getCompany(sal_type) {
    console.log("s0--- " + sal_type);
    if (sal_type == undefined || sal_type == 0) { sal_type = 1; }
    if (sal_type == 2) {
        $("#employer").unbind();
        $("#employer").val('');
        $("#employer").attr('placeholder', 'Enter your company name');
        console.log("s2---");
    } else if (sal_type == 1) {
        $("#employer").attr('placeholder', 'Type slowly to autofill');
        autoSuggestCompany();
        console.log("s1---");
    }
}

function autoSuggestCompany() {
    console.log("Call--- autoSuggestCompany");
    $(document).ready(function () {
        $("#employer").autocomplete({
            source: function (request, response) {
                var $this = $(this);
                var $element = $(this.element);
                var jqXHR = $element.data('jqXHR');
                if (jqXHR) {
                    jqXHR.abort();
                }
                $element.data('jqXHR', $.ajax({
                    url: targetUrl, dataType: "json", async: "false", mode: "abort", contentType: 'application/json; charset=utf-8', asyn: false, data: { employer_name: request.term, page: "getemployerlist" }, beforeSend: function () {
                        if (M.byId('matchbox1') != undefined) {
                            M.byId('matchbox1').innerHTML = "  <img height=\"18\" style=\"vertical-align:middle\" src=\"/support/img_rp/loader_green_small_new.gif\">";
                        }
                    }, success: function (returnObj) {
                        response($.map(returnObj.data, function (item) {
                            return { label: item.employee_company_name, value: item.employee_company_name }
                        }));
                        if (M.byId('matchbox1') != undefined) {
                            M.byId('matchbox1').innerHTML = "";
                        }
                    }
                }));
            }, minLength: 3, selectFirst: true, selectOnly: true, select: function (event, ui) {
                $("#employer").val(ui.item.label);
                return true;
            }
        }).keydown(function (e, data, ui) {
            if (e.which == 13) {
                setTimeout(function () {
                    $(".ui-autocomplete").css('display', 'none');
                    M.byId('grossincome').focus();
                }, 500)
            }
            if (e.which == 9 || e.which == 13) {
                if ($(".ui-autocomplete").css('display') != 'none') {
                    var res = $(".ui-autocomplete li:first a").html();
                    $("#employer").val(res);
                    return true;
                }
            }
        });
    });
}

function getCompanyList(sal_type) {
    if (sal_type == undefined || sal_type == 0) { sal_type = 1; }
    if (sal_type == 1) {
        $("#employer").focus(function () {
            if (this.value == 'Type slowly to autofill') { this.value = '' }
        });
        $("#employer").blur(function () {
            if (this.value == '') { this.value = 'Type slowly to autofill' }
        });
        $("#employer").val('Type slowly to autofill');

        $(document).ready(function () {
            $("#employer").autocomplete({
                source: function (request, response) {
                    var $this = $(this);
                    var $element = $(this.element);
                    var jqXHR = $element.data('jqXHR');
                    if (jqXHR) {
                        jqXHR.abort();
                    }
                    $element.data('jqXHR', $.ajax({
                        url: "/credit-card-new", dataType: "json", async: "false", mode: "abort", contentType: 'application/json; charset=utf-8', asyn: false, data: { employer_name: request.term, page: "getemployerlist" }, beforeSend: function () {
                            if (M.byId('matchbox1') != undefined) {
                                M.byId('matchbox1').innerHTML = "  <img height=\"18\" style=\"vertical-align:middle\" src=\"/support/img_rp/loader_green_small_new.gif\">";
                            }
                        }, success: function (returnObj) {
                            response($.map(returnObj.data, function (item) {
                                return { label: item.employee_company_name, value: item.employee_company_name }
                            }));
                            if (M.byId('matchbox1') != undefined) {
                                M.byId('matchbox1').innerHTML = "";
                            }
                        }
                    }));
                }, minLength: 3, selectFirst: true, selectOnly: true, select: function (event, ui) {
                    $("#employer").val(ui.item.label);
                    return true;
                }
            }).keydown(function (e, data, ui) {
                if (e.which == 13) {
                    setTimeout(function () {
                        $(".ui-autocomplete").css('display', 'none');
                        M.byId('grossincome').focus();
                    }, 500)
                }
                if (e.which == 9 || e.which == 13) {
                    if ($(".ui-autocomplete").css('display') != 'none') {
                        var res = $(".ui-autocomplete li:first a").html();
                        $("#employer").val(res);
                        return true;
                    }
                }
            });
        });
    } else if (sal_type == 2) {
        var aci = $("#employer").autocomplete("destroy");
        $('.autocomplete-w1').parent().remove();
        if (browserver == 'MSIE6') { $('.autocomplete-w1').bgiframe(); }

        $("#employer").val('');
        $("#employer").unbind();
    }
}

function getExitingCard(flg) {
    if (flg == false) {
        $('#exiting_cc option:first-child').attr("selected", "selected");
    }
    var card_id = M.byId('exiting_cc').value;
    var selElem = M.byId('employmentType');
    if (card_id != "" && card_id != "9999") {
        M.byId('tr_limit_cc').style.display = '';
        M.byId('tr_vintage_cc').style.display = '';
        M.byId('limit_cc').disabled = false;
        M.byId('vintage_mm').disabled = false;
        M.byId('vintage_yy').disabled = false;
        //$("#employmentType").html(getEmployerList(2));
    } else {
        M.byId('tr_limit_cc').style.display = 'none';
        M.byId('tr_vintage_cc').style.display = 'none';
        M.byId('limit_cc').disabled = true;
        M.byId('vintage_mm').disabled = true;
        M.byId('vintage_yy').disabled = true;
        //$("#employmentType").html(getEmployerList(1));
    }
    return false;
}

function getEmployerList(option_case) {
    var employer_list_arr = { 1: 'Salaried: RBL Salary A/C', 2: 'Self Employed Business', 3: 'Self Employed Professional', 4: 'Salaried: Other Bank Salary A/C', 5: 'Salaried: By Cash or Check' };
    var htmlOption = "<option value=''>Select</option>";
    $.each(employer_list_arr, function (employer_id, employer_name) {
        if (option_case == 1) {
            if (employer_id == 1 || employer_id == 4 || employer_id == 5)
                htmlOption += "<option value=" + employer_id + ">" + employer_name + "</option>";
        } else if (option_case == 2) {
            htmlOption += "<option value=" + employer_id + ">" + employer_name + "</option>";
        }
    });
    return htmlOption;
}
function submitCreditCardApplication() {
    var frm = M.getForm('creditcardappform');
    if (frm == null) return;
    M.byId("submitButton").style.visibility = "hidden";
    var form_element = ['gndr', 'addressL1', 'pincode', 'employmentType', 'grossincome'];

    var val = {};
    //for(var i=0;i<elem.length;i++) val[elem[i]]=null;
    var willPost = 1;
    var normalage = 1;
    var flag = 1;
    var error_msg = '';
    for (var nxt = 0; nxt < form_element.length; nxt++) {
        if (frm[form_element[nxt]] != undefined && !frm[form_element[nxt]].disabled) {
            var elemVal = M.getElementValue(frm[form_element[nxt]]);
            frm[form_element[nxt]].style.borderColor = C[8];
            val[form_element[nxt]] = elemVal;
            if (elemVal <= 0 || !elemVal) {
                willPost = 0
                frm[form_element[nxt]].style.borderColor = C[5];
            }
        }
    }
    if (M.byId('gndr') != undefined) {
        M.byId('gndr').style.borderColor = C[8];
        if (M.byId('gndr').value == '') {
            M.byId('gndr').style.borderColor = C[5];
            willPost = 0
            if (flag == 1) {
                error_msg = 'Please select gender';
                flag = 0;
            } else {
                error_msg = '';
            }
        }
    }
    // code added on 22 01 2013 
    if (M.byId('fname') != undefined) {
        M.byId('fname').style.borderColor = C[8];
        if (M.byId('fname').value != "") {
            // code added on 22 01 2013
            if (M.byId('fname').value != '' && (!M.isAlpha(M.trim(M.byId('fname').value.toString())) || (M.byId('fname').value.toString()).match(/\<|\>|\"|\`|\.|\\|\[|\]/g))) {
                //if(M.isSpecialCharsWithN(M.byId('mname').value.toString()) || (M.byId('mname').value.toString()).match(/\<|\>|\"|\`|\.|\\| |\[|\]/g) || !checkNumericValue(M.byId('mname').value.toString())) {
                M.byId('fname').style.borderColor = C[5];
                willPost = 0
                if (flag == 1) {
                    error_msg = 'Please check - first name should not contain any special character';
                    flag = 0;
                } else {
                    error_msg = '';
                }
            } else if (M.trim(M.byId('fname').value.toString()).length < 1 || M.trim(M.byId('fname').value.toString()).length > 39) {
                M.byId('fname').style.borderColor = C[5];
                willPost = 0
                if (flag == 1) {
                    error_msg = "First name requires min 2 characters and max 39 characters";
                    flag = 0;
                } else {
                    error_msg = '';
                    M.byId('fname').style.borderColor = C[5];
                }
            } else { // end of code added on 22 01 2013
                val['fname'] = M.byId('fname').value;
            }
        } else {
            M.byId('fname').style.borderColor = C[5];
            willPost = 0
            if (flag == 1) {
                error_msg = "First name requires min 2 characters and max 39 characters";
                flag = 0;
            } else {
                error_msg = '';
                M.byId('fname').style.borderColor = C[5];
            }
        }
    }

    M.byId('mname').style.borderColor = C[8];
    if (M.byId('mname').value != "") {
        // code added on 22 01 2013
        if (M.byId('mname').value != '' && (!M.isAlpha(M.trim(M.byId('mname').value.toString())) || (M.byId('mname').value.toString()).match(/\<|\>|\"|\`|\.|\\|\[|\]/g))) {
            //if(M.isSpecialCharsWithN(M.byId('mname').value.toString()) || (M.byId('mname').value.toString()).match(/\<|\>|\"|\`|\.|\\| |\[|\]/g) || !checkNumericValue(M.byId('mname').value.toString())) {
            M.byId('mname').style.borderColor = C[5];
            willPost = 0
            if (flag == 1) {
                error_msg = 'Please check - middle name should not contain any special character';
                flag = 0;
            } else {
                error_msg = '';
            }
        } else if (M.trim(M.byId('mname').value.toString()).length < 1 || M.trim(M.byId('mname').value.toString()).length > 39) {
            M.byId('mname').style.borderColor = C[5];
            willPost = 0
            if (flag == 1) {
                error_msg = "Middle name requires min 2 characters and max 39 characters";
                flag = 0;
            } else {
                error_msg = '';
                M.byId('mname').style.borderColor = C[5];
            }
        } else { // end of code added on 22 01 2013
            val['mname'] = M.byId('mname').value;
        }
    }

    if (M.byId('lname') != undefined && M.byId('txt_father_name') != undefined) {
        M.byId('lname').style.borderColor = C[8];
        M.byId('txt_father_name').style.borderColor = C[8];
        if (M.trim(M.byId('lname').value) == null && M.trim(M.byId('txt_father_name').value) == null) {
            M.byId('lname').style.borderColor = C[5];
            M.byId('txt_father_name').style.borderColor = C[5];
            willPost = 0
            if (flag == 1) {
                error_msg = 'Please enter last name OR father\'s name';
                flag = 0;
            } else {
                error_msg = '';
            }
        } else if (M.byId('lname').value != '' && (!M.isAlpha(M.trim(M.byId('lname').value.toString())) || (M.byId('lname').value.toString()).match(/\<|\>|\"|\`|\.|\\|\[|\]/g))) {
            //} else if(M.trim(M.byId('lname').value)!=null && (M.isSpecialCharsWithN(M.byId('lname').value.toString()) || (M.byId('lname').value.toString()).match(/\<|\>|\"|\`|\.|\\| |\[|\]/g) || !checkNumericValue(M.byId('lname').value.toString()))){
            M.byId('lname').style.borderColor = C[5];
            willPost = 0
            if (flag == 1) {
                error_msg = 'Please check - last name should not contain any special character';
                flag = 0;
            } else {
                error_msg = '';
            }
        } else if (M.trim(M.byId('lname').value) != null && (M.trim(M.byId('lname').value.toString()).length < 1 || M.trim(M.byId('lname').value.toString()).length > 39)) {
            M.byId('lname').style.borderColor = C[5];
            willPost = 0
            if (flag == 1) {
                error_msg = "Last name requires min 1 characters and max 39 characters";
                flag = 0;
            } else {
                error_msg = '';
            }
        }

        if (M.byId('txt_father_name').value != '' && (M.byId('txt_father_name').value.toString()).match(/\<|\>|\"|\`|\.|\\|\[|\]/g)) {
            //} else if(M.trim(M.byId('txt_father_name').value)!=null && (M.isSpecialCharsWithN(M.byId('txt_father_name').value.toString()) || (M.byId('txt_father_name').value.toString()).match(/\<|\>|\"|\`|\.|\\|\[|\]/g) || !checkNumericValuewithSpace(M.byId('txt_father_name').value.toString()))){
            M.byId('txt_father_name').style.borderColor = C[5];
            willPost = 0
            if (flag == 1) {
                error_msg = 'Please check - Father name should not contain any special character';
                flag = 0;
            } else {
                error_msg = '';
            }
        } else if (M.trim(M.byId('txt_father_name').value) != null && (M.trim(M.byId('txt_father_name').value.toString()).length < 1 || M.trim(M.byId('txt_father_name').value.toString()).length > 39)) {
            M.byId('txt_father_name').style.borderColor = C[5];
            willPost = 0
            if (flag == 1) {
                error_msg = "Father name requires min 1 characters and max 39 characters";
                flag = 0;
            } else {
                error_msg = '';
            }
        } else {
            val['lname'] = M.byId('lname').value;
            val['txt_father_name'] = M.byId('txt_father_name').value;
        }
    }

    if (M.trim(M.byId('fname').value) == M.trim(M.byId('lname').value)) {
        M.byId('fname').style.borderColor = C[5];
        M.byId('lname').style.borderColor = C[5];
        willPost = 0
        if (flag == 1) {
            error_msg = "First name and last name cannot be same";
            flag = 0;
        } else {
            error_msg = '';
        }
    } else if (M.trim(M.byId('mname').value) != null && (M.trim(M.byId('lname').value) == M.trim(M.byId('mname').value)) && M.trim(M.byId('lname').value) != "") {
        M.byId('fname').style.style.borderColor = C[5];
        M.byId('mname').style.borderColor = C[5];
        willPost = 0
        if (flag == 1) {
            error_msg = "Middle name and Last name cannot be same";
            flag = 0;
        } else {
            error_msg = '';
        }
    }

    if (M.byId('addressL1') != undefined) {
        M.byId('addressL1').style.borderColor = C[8];
        if (M.byId('addressL1').value == '' || M.byId('addressL1').value == null) {
            M.byId('addressL1').style.borderColor = C[5];
            willPost = 0
            if (flag == 1) {
                error_msg = "Please enter address1";
                flag = 0;
            } else {
                error_msg = '';
            }
        } else if (M.byId('addressL1').value != "" && (M.trim(M.byId('addressL1').value.toString()).length < 4 || M.trim(M.byId('addressL1').value.toString()).length > 40)) {
            M.byId('addressL1').style.borderColor = C[5];
            willPost = 0
            if (flag == 1) {
                error_msg = "Address line 1 requires min 4 characters and max 39 characters";
                flag = 0;
            } else {
                error_msg = '';
            }
        } else if (M.byId('addressL1').value != "" && (M.byId('addressL1').value.toString()).match(/\<|\>|\"|\'|\~|\(|\)|\@|\$|\^|\*|\_|\.|\+|\=|\:|\?|\"|\!|\%|\;|\&|\+|\[|\]/g)) {
            M.byId('addressL1').style.borderColor = C[5];
            willPost = 0
            if (flag == 1) {
                error_msg = "Address line 1 accepts only these special characters # , - ' / ";
                flag = 0;
            } else {
                error_msg = '';
            }
        }
    }

    M.byId('addressL2').style.borderColor = C[8];
    if (M.byId('addressL2').value != '') {
        if (M.trim(M.byId('addressL2').value).length < 4 || M.trim(M.byId('addressL2').value).length > 40) {
            M.byId('addressL2').style.borderColor = C[5];
            willPost = 0
            if (flag == 1) {
                error_msg = "If entered, address line 2 requires min 4 characters and max 39 characters";
                flag = 0;
            } else {
                error_msg = '';
                M.byId('addressL2').style.borderColor = C[5];
            }
        } else if ((M.byId('addressL2').value.toString()).match(/\<|\>|\"|\'|\~|\(|\)|\@|\$|\^|\*|\_|\.|\+|\=|\:|\?|\"|\!|\%|\;|\&|\+|\[|\]/g)) {
            M.byId('addressL2').style.borderColor = C[5];
            willPost = 0
            if (flag == 1) {
                error_msg = "Address line 2 accepts only these special characters # , - ' / ";
                flag = 0;
            } else {
                error_msg = '';
            }
        }
    }

    M.byId('txt_landmark').style.borderColor = C[8];
    if (M.byId('txt_landmark').value != '') {
        if (M.trim(M.byId('txt_landmark').value).length < 4 || M.trim(M.byId('txt_landmark').value).length > 40) {
            M.byId('txt_landmark').style.borderColor = C[5];
            willPost = 0
            if (flag == 1) {
                error_msg = "If entered, landmark line 2 requires min 4 characters and max 39 characters";
                flag = 0;
            } else {
                error_msg = '';
                M.byId('txt_landmark').style.borderColor = C[5];
            }
        } else if ((M.byId('txt_landmark').value.toString()).match(/\<|\>|\"|\'|\~|\(|\)|\@|\$|\^|\*|\_|\.|\+|\=|\:|\?|\"|\!|\%|\;|\&|\+|\[|\]/g)) {
            M.byId('txt_landmark').style.borderColor = C[5];
            willPost = 0
            if (flag == 1) {
                error_msg = "landmark accepts only these special characters # , - ' / ";
                flag = 0;
            } else {
                error_msg = '';
            }
        }
    }
    if (M.byId('city_id') != undefined) {
        M.byId('city_id').style.borderColor = C[8];
        if (M.byId('city_id').value == '' || M.byId('city_id').value == 0) {
            M.byId('city_id').style.borderColor = C[5];
            willPost = 0
            if (flag == 1) {
                error_msg = 'Please select city';
                flag = 0;
            } else {
                error_msg = '';
            }
        } else {
            val["city_id"] = M.byId('city_id').value;
        }
    }

    if (M.byId('pincode') != undefined) {
        M.byId('pincode').style.borderColor = C[8];
        if (M.byId('pincode').value == '' || M.byId('pincode').value == 0) {
            M.byId('pincode').style.borderColor = C[5];
            willPost = 0
            if (flag == 1) {
                error_msg = 'Please select pincode';
                flag = 0;
            } else {
                error_msg = '';
            }
        }
    }
    if (M.byId('employer') != undefined) {

        M.byId('employer').style.borderColor = C[8];
        /*
        if(M.byId('employer').value == '' || M.byId('employer').value == 'Type slowly to autofill') {
            M.byId('employer').style.borderColor=C[5];
            willPost=0
            if(flag == 1) {
                error_msg = 'Please select employer';
                flag = 0;
            } else {
                error_msg = '';
            }
        }
        */
        if (M.trim(M.byId('employer').value) == null || M.byId('employer').value == 'Type slowly to autofill' || (M.byId('employer').value.toString()).match(/\<|\>|\"|\'|\~|\@|\$|\^|\*|\_|\+|\=|\:|\?|\"|\!|\%|\;|\+|\[|\]/g)) {
            willPost = 0
            M.byId('employer').style.borderColor = C[5];
            if (flag == 1) {
                error_msg = 'Your employer name have some invalid special chars.';
                flag = 0;
            } else {
                error_msg = '';
            }
        }
    }

    form_element = ['pa\156\103ard', 'pa\156\103ardLater'];
    frm[form_element[0]].style.borderColor = C[8];
    //if(!frm[form_element[1]].checked || frm[form_element[0]].value != "") { //Case PAN later case
    if (frm[form_element[0]] != undefined) {
        if (frm[form_element[0]].disabled == true) {
            frm[form_element[0]].disabled = false;
            frm[form_element[0]].style.background = '#FFFFFF';
        }
        if (M.trim(frm[form_element[0]].value) == null || M.trim(frm[form_element[0]].value) == "" || !M.isPAN(frm[form_element[0]].value.toString())) {
            frm[form_element[0]].style.borderColor = C[5];
            willPost = 0

            if (flag == 1 && (M.trim(frm[form_element[0]].value) == null || M.trim(frm[form_element[0]].value) == "" || !M.isPAN(frm[form_element[0]].value.toString()))) {
                error_msg = 'Please enter PAN card in correct format';
                flag = 0;
            } else {
                error_msg = '';
            }
        } else if (frm[form_element[0]].value.toUpperCase().indexOf('P', 3) == -1) {
            willPost = 0
            frm[form_element[0]].style.borderColor = C[5];
            if (flag == 1) {
                error_msg = 'Please enter correct PAN';
                flag = 0;
            } else {
                error_msg = '';
            }
        }
    }

    if (M.byId('employmentType') != undefined) {
        M.byId('employmentType').style.borderColor = C[8];
        if (M.byId('employmentType').value == '' || M.byId('employmentType').value == 0) {
            M.byId('employmentType').style.borderColor = C[5];
            willPost = 0
            if (flag == 1) {
                error_msg = 'Please select Type of Employment';
                flag = 0;
            } else {
                error_msg = '';
            }
        }
    }
    if (M.byId('grossincome') != undefined) {
        M.byId('grossincome').style.borderColor = C[8];
        if (M.byId('grossincome').value == '') {
            M.byId('grossincome').style.borderColor = C[5];
            willPost = 0
            if (flag == 1) {
                error_msg = 'Please enter Net monthly Salary / Income';
                flag = 0;
            } else {
                error_msg = '';
            }
        }
    }
    if (M.byId('salarybank') != undefined) {
        M.byId('salarybank').style.borderColor = C[8];
        if (M.byId('salarybank').disabled == false && (M.byId('salarybank').value == '' || M.byId('salarybank').value == 0)) {
            M.byId('salarybank').style.borderColor = C[5];
            willPost = 0
            if (flag == 1) {
                error_msg = 'Please select  Salaried bank account with';
                flag = 0;
            } else {
                error_msg = '';
            }
        } else {
            val['salarybank'] = M.byId('salarybank').value;
        }
    }


    if (M.byId('existing_other_loan_cc_yes') != undefined && M.byId('existing_other_loan_cc_no') != undefined) {
        if (M.byId('existing_other_loan_cc_yes').checked == true) {
            val['existing_other_loan_cc'] = "Y";
        } else {
            val['existing_other_loan_cc'] = "N";
        }
    }

    if (M.byId("txt_club_member_1") != undefined && M.byId("txt_club_member_2") != undefined && M.byId("txt_club_member_3") != undefined) {
        var flg = $("input:radio[name='txt_club_member_typ']:checked").val();
        var tmp_arr = ['s_glf1', 's_glf2', 's_glf3'];
        for (var i = 0; i <= tmp_arr.length; i++) {
            if (M.byId(tmp_arr[i]) != undefined) {
                //M.byId(tmp_arr[i]).style.borderColor=C[8];
                $("#" + tmp_arr[i]).css({ "border": "", "margin-right": "" });
                if (flg == undefined) {
                    //M.byId(tmp_arr[i]).style.borderColor=C[5];
                    $("#" + tmp_arr[i]).css({ "border": "1px solid red", "margin-right": "10px" });
                    willPost = 0
                    if (flag == 1) {
                        error_msg = 'Please select your Club Member Type';
                        flag = 0;
                    } else {
                        error_msg = '';
                    }
                }
            }
        }
        //alert(flg);
        if (flg == 1 || flg == 3) {
            M.byId("tr_golf_card_0").style.display = '';
            if (M.byId("txt_ghin_id") != undefined) {
                M.byId('txt_ghin_id').style.borderColor = C[8];
                if (M.byId('txt_ghin_id').value != '') {
                    var elemVal = M.byId('txt_ghin_id').value;
                    if (M.isSpecialChars(elemVal) != null && !M.isEmpty(elemVal)) {
                        M.byId('txt_ghin_id').style.borderColor = C[5];
                        willPost = 0
                        if (flag == 1) {
                            error_msg = 'Please select your Club GHIN No';
                            flag = 0;
                        } else {
                            error_msg = '';
                        }
                    } else {
                        val["txt_ghin_id"] = M.byId('txt_ghin_id').value;
                    }
                }
            }
        }

        if (flg == 1) {
            M.byId("tr_golf_card_1").style.display = '';
            if (M.byId("txt_golf_club_city") != undefined) {
                M.byId('txt_golf_club_city').style.borderColor = C[8];

                if (M.byId("txt_golf_club_city").value == '') { // ADD CHECK MANDATORY FIELD ON 31-07-15
                    M.byId('txt_golf_club_city').style.borderColor = C[5];
                    willPost = 0
                    if (flag == 1) {
                        error_msg = 'Please select your Club Home';
                        flag = 0;
                    } else {
                        error_msg = '';
                    }
                } else if (M.byId("txt_golf_club_city").value != '' && M.isSpecialChars(M.byId('txt_golf_club_city').value) != null && !M.isEmpty(M.byId('txt_golf_club_city').value)) {
                    M.byId('txt_golf_club_city').style.borderColor = C[5];
                    willPost = 0
                    if (flag == 1) {
                        error_msg = 'Please select your Club Home';
                        flag = 0;
                    } else {
                        error_msg = '';
                    }
                } else {
                    val["txt_golf_club_city"] = M.byId('txt_golf_club_city').value;
                }
            }
            if (M.byId("txt_club_membership_no") != undefined) {
                M.byId('txt_club_membership_no').style.borderColor = C[8];
                if (M.byId("txt_club_membership_no").value == '') { // ADD CHECK MANDATORY FIELD ON 31-07-15
                    M.byId('txt_club_membership_no').style.borderColor = C[5];
                    willPost = 0
                    if (flag == 1) {
                        error_msg = 'Please enter Club MemberShip No';
                        flag = 0;
                    } else {
                        error_msg = '';
                    }
                } else if (M.byId("txt_club_membership_no").value != '' && M.isSpecialChars(M.byId("txt_club_membership_no").value) != null && !M.isEmpty(M.byId("txt_club_membership_no").value)) {
                    M.byId('txt_club_membership_no').style.borderColor = C[5];
                    willPost = 0
                    if (flag == 1) {
                        error_msg = 'Please check your Club Home MemberShip No';
                        flag = 0;
                    } else {
                        error_msg = '';
                    }
                } else {
                    val["txt_club_membership_no"] = M.byId('txt_club_membership_no').value;
                }
            }
        }
        if (flg != undefined) {
            val["txt_club_member_typ"] = flg;
        }

        if (M.byId("txt_addon_card_flg") != undefined) {
            if (M.byId("txt_addon_card_flg").checked == true) {
                val["txt_addon_card_flg"] = "Y";
                var field_arr = ['txt_addon_relation', 'txt_addon_fname', 'txt_addon_lname'];
                for (var i = 0; i <= field_arr.length; i++) {
                    if (M.byId(field_arr[i]) != undefined) {
                        M.byId(field_arr[i]).style.borderColor = C[8];
                        var elemVal = M.byId(field_arr[i]).value;
                        if (M.isSpecialChars(elemVal) != null || M.isEmpty(elemVal)) {
                            M.byId(field_arr[i]).style.borderColor = C[5];
                            willPost = 0
                            if (flag == 1) {
                                error_msg = 'Sorry! But you are missing some required fields below';
                                flag = 0;
                            } else {
                                error_msg = '';
                            }
                        } else {
                            val[field_arr[i]] = M.byId(field_arr[i]).value;
                        }
                    }
                }

                if (M.byId('txt_addon_dob') != undefined) {
                    frm['txt_addon_dob'].style.borderColor = C[8]
                    if (M.trim(frm['txt_addon_dob'].value) == null || !M.isDate(frm['txt_addon_dob'].value.toString())) {
                        frm['txt_addon_dob'].style.borderColor = C[5];
                        normalage = 0;
                        if (flag == 1) {
                            error_msg = 'Please enter Date of Birth in correct format <small>(DD-MM-YYYY)</small>';
                            flag = 0;
                        } else {
                            error_msg = '';
                        }
                    } else if (M.dateDiffDays(frm['txt_addon_dob'].value) > 0 && M.isDate(frm['txt_addon_dob'].value.toString())) {
                        frm['txt_addon_dob'].style.borderColor = C[5]
                        normalage = 0;
                        if (flag == 1) {
                            error_msg = 'Date of Birth can not be greater than current date';
                            flag = 0;
                        } else {
                            error_msg = '';
                        }
                    } else {
                        val["txt_addon_dob"] = M.trim(frm['txt_addon_dob'].value);
                        //var addon_age = parseInt(M.isDate(val["txt_addon_dob"], true));
                        var addon_age = calculateAgeInYear(frm['txt_addon_dob'].value);
                        //console.log(addon_age);
                        if ((addon_age < 18 || addon_age >= 23) && flg == 2) { // FOR guardian
                            frm['txt_addon_dob'].style.borderColor = C[5]
                            normalage = 0;
                            if (flag == 1) {
                                error_msg = 'Addon age does not meet our internal policy guidelines.';
                                flag = 0;
                            } else {
                                error_msg = '';
                            }
                        } else if ((addon_age < 18 || addon_age > 75) && (flg == 1 || flg == 3)) {
                            frm['txt_addon_dob'].style.borderColor = C[5]
                            normalage = 0;
                            if (flag == 1) {
                                error_msg = 'Addon age does not meet our internal policy guidelines.';
                                flag = 0;
                            } else {
                                error_msg = '';
                            }
                        }
                    }
                }
                //'txt_addon_mnmae'
                if (M.byId('txt_addon_mname') != undefined) {
                    frm['txt_addon_mname'].style.borderColor = C[8]
                    if (frm['txt_addon_mname'].value != "") {
                        val["txt_addon_mname"] = M.trim(frm['txt_addon_mname'].value);
                    }
                }

                if (M.byId('txt_addon_mobile') != undefined) {
                    frm['txt_addon_mobile'].style.borderColor = C[8]
                    if (M.trim(frm['txt_addon_mobile'].value) == null || !M.isMobile(frm['txt_addon_mobile'].value.toString())) {
                        frm['txt_addon_mobile'].style.borderColor = C[5];
                        normalage = 0;
                        if (flag == 1) {
                            error_msg = 'Please enter addon member mobile no';
                            flag = 0;
                        } else {
                            error_msg = '';
                        }
                    } else {
                        val["txt_addon_mobile"] = M.trim(frm['txt_addon_mobile'].value);
                    }
                }

                if (M.byId("txt_primary_ghin_id") != undefined) {
                    M.byId('txt_primary_ghin_id').style.borderColor = C[8];
                    if (M.byId('txt_primary_ghin_id').value != '') {
                        var elemVal = M.byId('txt_primary_ghin_id').value;
                        if (M.isSpecialChars(elemVal) != null && !M.isEmpty(elemVal)) {
                            M.byId('txt_primary_ghin_id').style.borderColor = C[5];
                            willPost = 0
                            if (flag == 1) {
                                error_msg = 'Please select your Club GHIN No';
                                flag = 0;
                            } else {
                                error_msg = '';
                            }
                        } else {
                            val["txt_primary_ghin_id"] = M.byId('txt_primary_ghin_id').value;
                        }
                    }
                }

                if (M.byId("txt_primary_club_member") != undefined && flg == 2) {
                    if (M.byId("txt_primary_club_member").checked == true) {
                        val["txt_primary_club_member"] = "Y";
                        //M.byId("tr_golf_card_2_1").style.display = '';
                        M.byId("tr_golf_card_2_2").style.display = '';

                        if (M.byId("txt_primary_golf_club_city") != undefined) {
                            M.byId('txt_primary_golf_club_city').style.borderColor = C[8];
                            if (M.byId("txt_primary_golf_club_city").value == '') { // ADD CHECK MANDATORY FIELD ON 31-07-15
                                M.byId('txt_primary_golf_club_city').style.borderColor = C[5];
                                willPost = 0
                                if (flag == 1) {
                                    error_msg = 'Please select your Club Home';
                                    flag = 0;
                                } else {
                                    error_msg = '';
                                }
                            } else if (M.byId("txt_primary_golf_club_city").value != '' && M.isSpecialChars(M.byId("txt_primary_golf_club_city").value) != null && !M.isEmpty(M.byId("txt_primary_golf_club_city").value)) {
                                M.byId('txt_primary_golf_club_city').style.borderColor = C[5];
                                willPost = 0
                                if (flag == 1) {
                                    error_msg = 'Please select your Club Home';
                                    flag = 0;
                                } else {
                                    error_msg = '';
                                }
                            } else {
                                val["txt_primary_golf_club_city"] = M.byId('txt_primary_golf_club_city').value;
                            }
                        }
                        if (M.byId("txt_primary_club_membership_no") != undefined) {
                            M.byId('txt_primary_club_membership_no').style.borderColor = C[8];
                            if (M.byId("txt_primary_club_membership_no").value == '') { // ADD CHECK MANDATORY FIELD ON 31-07-15
                                M.byId('txt_primary_club_membership_no').style.borderColor = C[5];
                                willPost = 0
                                if (flag == 1) {
                                    error_msg = 'Please enter Club MemberShip No';
                                    flag = 0;
                                } else {
                                    error_msg = '';
                                }
                            } else if (M.byId("txt_primary_club_membership_no").value != '' && M.isSpecialChars(M.byId("txt_primary_club_membership_no").value) != null && !M.isEmpty(M.byId("txt_primary_club_membership_no").value)) {
                                M.byId('txt_primary_club_membership_no').style.borderColor = C[5];
                                willPost = 0
                                if (flag == 1) {
                                    error_msg = 'Please select your Club Home MemberShip No';
                                    flag = 0;
                                } else {
                                    error_msg = '';
                                }
                            } else {
                                val["txt_primary_club_membership_no"] = M.byId('txt_primary_club_membership_no').value;
                            }
                        }
                    } else {
                        val["txt_primary_club_member"] = "N";
                    }
                }
            } else {
                val["txt_addon_card_flg"] = "N";
            }
        }
    }

    if (M.byId('officeAddressL1') != undefined) {
        M.byId('officeAddressL1').style.borderColor = C[8];
        if (M.byId('officeAddressL1').value != "") {
            var officeAddressL1 = M.trim(M.byId('officeAddressL1').value.toString());
            if (officeAddressL1.length < 4 || officeAddressL1.length > 39) {
                M.byId('officeAddressL1').style.borderColor = C[5];
                willPost = 0
                if (flag == 1) {
                    error_msg = "Address line 1 requires min 4 characters and max 39 characters";
                    flag = 0;
                } else {
                    error_msg = '';
                    M.byId('officeAddressL1').style.borderColor = C[5];
                }
            } else if ((officeAddressL1.toString()).match(/\<|\>|\"|\'|\~|\(|\)|\@|\$|\^|\*|\_|\.|\+|\=|\:|\?|\"|\!|\%|\;|\&|\+|\[|\]/g)) {
                M.byId('officeAddressL1').style.borderColor = C[5];
                willPost = 0
                if (flag == 1) {
                    error_msg = "Address line 1 accepts only these special characters # , - ' / ";
                    flag = 0;
                } else {
                    error_msg = '';
                    M.byId('officeAddressL1').style.borderColor = C[5];
                }
            } else {
                val["officeAddressL1"] = M.byId('officeAddressL1').value;
            }
        } else if (M.byId('officeAddressL1').value == "") {
            M.byId('officeAddressL1').style.borderColor = C[5];
            willPost = 0
            if (flag == 1) {
                error_msg = "Address line 1 requires min 4 characters and max 39 characters";
                flag = 0;
            }
        }
    }
    if (M.byId('officeAddressL2') != undefined) {
        M.byId('officeAddressL2').style.borderColor = C[8];
        if (M.byId('officeAddressL2').value != '') {
            var officeAddressL2 = M.trim(M.byId('officeAddressL2').value.toString());
            if (officeAddressL2 == null) {
                officeAddressL2 = "";
            }
            if (officeAddressL2.length < 4 || officeAddressL2.length > 39) {
                M.byId('officeAddressL2').style.borderColor = C[5];
                willPost = 0
                if (flag == 1) {
                    error_msg = "If entered, address line 2 requires min 4 characters and max 39 characters";
                    flag = 0;
                } else {
                    error_msg = '';
                    M.byId('officeAddressL2').style.borderColor = C[5];
                }
            } else if ((M.byId('officeAddressL2').value.toString()).match(/\<|\>|\"|\'|\~|\(|\)|\@|\$|\^|\*|\_|\.|\+|\=|\:|\?|\"|\!|\%|\;|\&|\+|\[|\]/g)) {
                M.byId('officeAddressL2').style.borderColor = C[5];
                willPost = 0
                if (flag == 1) {
                    error_msg = "Address line 2 accepts only these special characters # , - ' / ";
                    flag = 0;
                } else {
                    error_msg = '';
                }
            } else {
                val["officeAddressL2"] = M.byId('officeAddressL2').value;
            }
        }
    }

    if (M.byId('officeState') != undefined) {
        M.byId('officeState').style.borderColor = C[8];
        if (M.byId('officeState').value == '' || M.byId('officeState').value == 0) {
            M.byId('officeState').style.borderColor = C[5];
            willPost = 0
            if (flag == 1) {
                error_msg = 'Please select office city state.';
                flag = 0;
            } else {
                error_msg = '';
            }
        } else {
            val["officeState"] = M.byId('officeState').value;
        }
    }

    if (M.byId('officeCity') != undefined && !M.byId('officeCity').disabled) {
        M.byId('officeCity').style.borderColor = C[8];
        if (M.byId('officeCity').value == '' || M.byId('officeCity').value == 0) {
            M.byId('officeCity').style.borderColor = C[5];
            willPost = 0
            if (flag == 1) {
                error_msg = 'Please select office city.';
                flag = 0;
            } else {
                error_msg = '';
            }
        } else {
            val["officeCity"] = M.byId('officeCity').value;
        }
    }

    if (M.byId('officePincode') != undefined && !M.byId('officePincode').disabled) {
        M.byId('officePincode').style.borderColor = C[8];
        if (M.byId('officePincode').value == '' || M.byId('officePincode').value == 0) {
            M.byId('officePincode').style.borderColor = C[5];
            willPost = 0
            if (flag == 1) {
                error_msg = 'Please select office city.';
                flag = 0;
            } else {
                error_msg = '';
            }
        } else {
            val["officePincode"] = M.byId('officePincode').value;
        }
    }


    var radios = ['acceptTC'];

    /*M.byId(radios[0]+'\106or').style.background="#fff";
    frm[radios[0]].style.borderColor=C[0]
    val[radios[0]]=true;
    if(!frm[radios[0]].checked) {
        willPost=0
        M.byId(radios[0]+'\106or').style.background=C[1];
        frm[radios[0]].style.borderColor=C[1]
    }*/
    var r4 = M.byId(radios[0] + "For")
    if (frm[radios[0]].checked) {
        val[radios[0]] = true;
        frm[radios[0]].style.outline = '2px solid #0B5D94';
        r4.style.background = 'none';
        //r4.style.color = '#FFF';
    } else {
        frm[radios[0]].style.outline = '2px solid #FF0000';
        //r4.style.background='lightYellow';
        //r4.style.color = '#FFF';
        willPost = 0
    }
    val["gndr"] = M.byId('gndr').value;
    if (M.byId('addressL2').value != '') {
        val["addressL2"] = M.byId('addressL2').value;
    }
    if (M.byId('panCard').value != '') {
        val["panCard"] = M.byId('panCard').value;
    }
    if (M.byId('employer').value != '') {
        var employer = escape(M.byId('employer').value);
        employer = decodeURI(employer);
        val["employer"] = employer;
    }
    if (M.byId('txt_landmark').value != '') {
        val["txt_landmark"] = M.byId('txt_landmark').value;
    }
    if (M.byId('txt_coupon_code') != undefined) {
        M.byId('txt_coupon_code').style.borderColor = C[8];
        if (M.byId('txt_coupon_code').value != '') {
            var elemVal = M.byId('txt_coupon_code').value;
            if (elemVal.match(/^[a-zA-z0-9\-]+$/) == null) {
                M.byId('txt_coupon_code').style.borderColor = C[5];
                willPost = 0
                if (flag == 1) {
                    error_msg = 'Coupan Code is Invalid.';
                    flag = 0;
                } else {
                    error_msg = '';
                }
            } else {
                val["coupon_code"] = M.byId('txt_coupon_code').value;
            }
        }
    }
    //WORKING FOR RelationShip 
    /*if(M.byId('existing_customer_yes').checked == true) {
        val['existing_customer'] = "Y";
        M.byId('rbl_customer_id').style.borderColor=C[8];
        M.byId('rbl_customer_account_no').style.borderColor=C[8];
        if(M.byId('rbl_customer_id') != undefined && M.trim(frm['rbl_customer_id'].value) == null && M.trim(frm['rbl_customer_account_no'].value) == null) {
        	willPost=0;
        	M.byId('rbl_customer_id').style.borderColor=C[5];
            if(flag == 1) {
                error_msg = 'Provide your RBL Permanent Customer ID for faster identity verification and card processing';
                flag = 0;
            } else {
                error_msg = '';
            }        	
        }
        if(M.byId('rbl_customer_account_no') != undefined && M.trim(frm['rbl_customer_account_no'].value) == null && M.trim(frm['rbl_customer_id'].value) == null) {
        	willPost=0;
        	M.byId('rbl_customer_account_no').style.borderColor=C[5];
            if(flag == 1) {
                error_msg = 'Provide your RBL Permanent Account Number for faster identity verification and card processing';
                flag = 0;
            } else {
                error_msg = '';
            }        	
        } else {
        	if(M.byId('rbl_customer_id') != undefined  && M.trim(frm['rbl_customer_id'].value) != "") {
        		val['rbl_customer_id'] = M.trim(frm['rbl_customer_id'].value);
        	}
        	if(M.byId('rbl_customer_account_no') != undefined  && M.trim(frm['rbl_customer_account_no'].value) != "") {
        		val['rbl_customer_account_no'] = M.trim(frm['rbl_customer_account_no'].value);
        	}
        }
    } else {
        val['existing_customer'] = "N";
    }*/
    //val['existing_customer'] = "N";
    var mp = M.byId('msg-panel-2'), l = M.byId("postmsg");
    mp.style.display = "block";

    if (willPost && normalage) {
        var returnValue = '';
        window.scrollTo(0, 175);
        for (i = 0; i < form_element.length - 2; i++) val[form_element[i]] = M.getElementValue(frm[form_element[i]]);
        mp.className = "msg-corr corner-all";
        M.byTag("b", mp)[0].innerHTML = "Getting approval for your card  application";
        M.byTag("em", mp)[0].innerHTML = " Please wait while your application is being submitted...";
        //l.innerHTML="Submitting...";
        //l.className="posting";
        if (returnValue == 1) {
            M.byId('msg-panel-2').style.display = 'none';
            M.byId("submitButton").style.visibility = "visible";
            M.scrollTop();
            return;
        } else {
            if (M.byId('pageOverlay')) {
                M.byId('pageOverlay').style.display = 'block'
                M.byId('itemWrapper').style.display = 'block'
                M.byId('itemOverlay').innerHTML = "<p style='font-size:2em;'>Getting approval for your credit card application...</p><p style='font-size:1.5em;'>Please do not refresh the page or click on the back button</p>\
                    <br /><p style='font-size:1.2em;'>Please wait...</p><br/><br/><img height='18px' src='/support/img_rp/sumatra/progress-bar.gif' alt=''/><br/><br/><br/>";
            }
            if (M.byId('alert_popup') != undefined) {
                var returnValue = 1;
            }

            if (returnValue == 1 && flagpopup == 0 && M.byId('panCardLater').checked == false) {
                $('#pageOverlay').fadeIn('slow', function () {
                    if (browserver == 'MSIE' || browserver == 'MSIE6') { $('#itemWrapper').bgiframe() }
                    M.byId('itemWrapper').style.display = 'block';
                    M.byId('itemOverlay').style.display = 'block';
                    M.byId('itemOverlay').innerHTML = "<div onclick=\"collectdocumentPopup(3);\" class=\"close-btn\"></div><div class=\"h125\"><div class=\"faq-contents\"><table width=\"100%\"> <colgroup><col width=\"44%\"/><col width=\"56%\"/></colgroup><tbody><tr><td colspan=\"2\" class=\"fs14\"><strong>Have you collected documents from customer?</strong></td></tr><tr><td colspan=\"2\">&nbsp;</td></tr><tr><td colspan=\"2\" class=\"fs14\"><span onclick=\"collectdocumentPopup(1);\"><img style=\"cursor:pointer;\" src=\"/support/img_rp/sumatra/yes_done.png\" /></span>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"cursor:pointer;\" onclick=\"collectdocumentPopup(2);\"><img style=\"cursor:pointer;\" src=\"/support/img_rp/sumatra/no_done.png\" /></span>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"cursor:pointer;\" onclick=\"collectdocumentPopup(3);\"><img style=\"cursor:pointer;\" src=\"/support/img_rp/sumatra/cancel_done.png\" /></span></td></tr><tr><td colspan=\"2\">&nbsp;</td></tr><tr><td colspan=\"2\"><ul class=\"popupalert\" style=\"text-align: left; padding-left: 95px;\"><li> Yes means document have been collected.</li><li>No means document have not been collected.</li></ul></td></tr></tbody></table></div></div>";

                });
            } else if (flagpopup == 1) {
                val["doc_collection_flag"] = M.byId('alert_popup').value;
                submitCreditCardApp(frm, val);
            } else {
                submitCreditCardApp(frm, val);
            }


        }
    }
    else {
        window.scrollTo(0, 175);
        mp.className = "msg-war corner-all";
        M.byTag("b", mp)[0].innerHTML = "Missing: ";
        if (error_msg != '') {
            M.byTag("em", mp)[0].innerHTML = " " + error_msg;
        } else {
            M.byTag("em", mp)[0].innerHTML = "Sorry! But you are missing some required fields below";
        }
        //l.innerHTML="";
        //l.className=""
        M.byId("submitButton").style.visibility = "visible";
        M.scrollTop();
    }
}

function collectdocumentPopup(src) {

    if (parseInt(src) == 1) {
        flagpopup = 1;
        M.byId('alert_popup').value = "Y";
        submitCreditCardApplication();
    } else if (parseInt(src) == 2) {
        M.byId('alert_popup').value = "N";
        flagpopup = 1;
        submitCreditCardApplication();
    } else if (parseInt(src) == 3) {
        M.byId('alert_popup').value = "";
        M.byId('msg-panel-2').style.display = 'none';
        M.byId("submitButton").style.visibility = "visible";
        autoSave();
        killJustPopup();
    }
    return false;
}

function submitCreditCardApp(frm, val) {
    var data_str = '';
    for (var se in val) data_str += val[se] + "|";
    var checksum = rstr2hex(rstr_md5(data_str));

    var s = 'page=creditcardapp&client_checksum=' + checksum; for (var se in val) s += "&" + se + "=" + val[se];
    //alert(s);
    //return false;
    M.AJAX.request({
        target: '/credit-card-new',
        query: s,
        method: 'POST',
        postmsg: M.byId('postmsg'),
        onSuccess: finishCreditCardAppSubmit,
        onFailed: function (msg) {
            var l = M.byId('postmsg');
            l.className = "req";
            l.innerHTML = msg;
        }
    });
}

function reviewCreditCardApplication(frm) {
    var frm = M.getForm('reviewcardappform');
    if (frm == null) return;
    M.byId('appform').value = 1;
    frm.submit();
}

function finishCreditCardAppSubmit(res) {
    res = M.trim(res);
    if (res.match(/^otp_not_done\:/i) != null) {
        M.byId('pageOverlay').style.display = 'none';
        M.byId('itemWrapper').style.display = 'none';
        M.byId('itemOverlay').style.display = '';
        if (M.byId('pageOverlay')) {
            M.byId('pageOverlay').style.display = 'block'
            M.byId('itemWrapper').style.display = 'block'
            M.byId('itemOverlay').innerHTML = res.replace(/^otp_not_done\:/i, '');
        }
        otp_popup = 1;
    } else if (res.match(/^error\:/i) == null) {
        if (res.match(/^down_sell_card\:/i) != null) {
            M.byId('pageOverlay').style.display = 'none';
            M.byId('itemWrapper').style.display = 'none';
            M.byId('form_panel').innerHTML = res.replace(/^down_sell_card\:/i, '');
        } else {
            var apass = 0;
            if (res.match(/^ap8970\:/i) != null) {
                res = res.replace(/^ap8970\:/i, '');
                apass = 1;
            }
            var POSTACT = M.byId("prePostFormBlock");
            POSTACT.className = "";
            POSTACT.innerHTML = res;
            M.byId('pageOverlay').style.display = 'none';
            M.byId('itemWrapper').style.display = 'none';
            //M.byId('app_track').style.display='';
            M.byId('notes_selected_product_name_new').innerHTML = '';
            if (M.byId('navigation_new') != undefined) {
                M.byId('navigation_new').innerHTML = '<ul id="step_box" class="step_box" style="float:right;"><li class="w80"><a href="/credit-card-new"><span>1</span><p>CHOOSE<br />CARD</p></a></li><li class="w80"><a href="javascript:;"><span>2</span><p>APPLY<br/>ONLINE</p></a></li><li class="w90"><span class="active">3</span><p>INSTANT<br/>APPROVAL</p></li></ul>';
            }
            M.byId('card_applicant_name').innerHTML = M.byId('card_user_name').value;
            if (M.byId('heading1') != undefined) {
                M.byId('heading1').className = 'dontshow';
            }
            if (M.byId('pickupDate') != undefined) {
                var currentTime = new Date();
                var month = currentTime.getMonth() + 1;
                var day = currentTime.getDate();
                var year = currentTime.getFullYear();
                var hour = currentTime.getHours();
                var minutes = currentTime.getMinutes();
                if (hour >= 11) {
                    if (minutes > 30 || hour > 11) {
                        day = day + 1;
                    }
                }
                $(function () { $("#pickupDate").datepick({ changeMonth: true, changeYear: true, yearRange: year + ':' + year, minDate: new Date(year, month - 1, day), maxDate: new Date(year, month - 1, day + 15), shortYearCutoff: '+1' }); });

            }
            /* FOR PIXEL CODE */
            if (isus == 0 && (typeof callpixelimg != 'undefined') && callpixelimg != undefined && callpixelimg != null && callpixelimg != "" && M.byId('pixeltracking') != undefined && apass === 1) {

                if ((typeof optional_information != 'undefined') && optional_information != undefined && optional_information != null && optional_information != "") {
                    callpixelimg = callpixelimg.replace("optional_information", optional_information);
                } else {
                    var tmpDateTime = (new Date()).getTime();
                    var randomConcat = 100 * (Math.random());
                    randomConcat = "x" + Math.floor(randomConcat);
                    tmpDateTime = randomConcat.concat(tmpDateTime);
                    callpixelimg = callpixelimg.replace("optional_information", tmpDateTime);
                }

                if (callpixeltype == 1) {
                    M.byId('pixeltracking').src = callpixelimg;
                }
            }
            /* END  */
        }
        //tab.parentNode.removeChild(tab);
        // Added by Sandeep | on | 1_06_2015
        //ga('send','event','Creditcard-submit','AIPapproved','Submit-click',1); 

    } else {
        var mp = M.byId('msg-panel-2');
        mp.className = "msg-err corner-all";
        M.byTag("b", mp)[0].innerHTML = "Error: ";
        M.byTag("em", mp)[0].innerHTML = res.replace(/^error\:/i, '');
        var l = M.byId('postmsg');
        //l.innerHTML="Application Submission failed!";
        //l.className="req";
        M.byId("submitButton").style.visibility = "visible";
        M.byId('pageOverlay').style.display = 'none';
        M.byId('itemWrapper').style.display = 'none';
    }
    //M.scrollTop();
}

function empTypeSelect(src, align, ask4Emp) {
    var tmp_ret_val = showPerspectiveRows4EmpType(src, align, ask4Emp);
    if (src.options[src.selectedIndex].value == 1) {
        if (browserver == 'MSIE6') {

            var aci = $("#employer").autocomplete({ width: 300, zIndex: 9999, delimiter: /(,|;)\s*/, lookup: E, minChars: 2 });
            $('.autocomplete-w1').bgiframe();
        }
    }
    return tmp_ret_val;
}

function monthDiff(d1, d2) {
    var months;
    months = (d2.getFullYear() - d1.getFullYear()) * 12;
    months -= d1.getMonth() + 1;
    months += d2.getMonth();
    return months <= 0 ? 0 : months;
}
function searchCreditCard(frm) {
    if (frm == null) return false
    var subtn = M.byId("subtn")
    if (M.byId('extra_msg') != undefined) {
        M.byId('extra_msg').innerHTML = '';
    }
    var subtnPrevClass = subtn.style.className
    subtn.style.className = "btn btn-gray lh0"
    var elem = ['txt_title', 'fname', 'dateOfBirth', 'cities', 'mobile', 'emailid', 'state']
    var val = {};
    var willPost = 1
    var flag = 1;
    var error_msg = '';

    for (var nxt = 0; nxt < elem.length; nxt++) {
        if (browserver == 'MSIE6' || browserver == 'MSIE') {
            M.byId('txt_title').className = "w175";
            M.byId('cities').className = "w175";
            if (M.byId('state') != undefined) {
                M.byId('state').className = "w175";
            }
        }
        if (frm[elem[nxt]] != undefined && !frm[elem[nxt]].disabled) {
            var elemVal = M.getElementValue(frm[elem[nxt]])
            frm[elem[nxt]].style.borderColor = C[8]
            val[elem[nxt]] = elemVal;
            if (!elemVal || elemVal <= 0) {
                willPost = 0;
                frm[elem[nxt]].style.borderColor = C[5];
                if (browserver == 'MSIE6') {
                    if (M.byId('txt_title').value == 0) {
                        M.byId('txt_title').className = "required w175";
                    }
                    if (M.byId('cities').value == '') {
                        M.byId('cities').className = "required w175";
                    }
                    if (M.byId('state') != undefined && M.byId('state').value == '') {
                        M.byId('state').className = "required w175";
                    }
                }
            }
        }
    }
    // TITLE
    if (M.byId('txt_title') != undefined) {
        M.byId('txt_title').style.borderColor = C[8];
        if (M.byId('txt_title').value == '') {
            M.byId('txt_title').style.borderColor = C[5];
            willPost = 0;
            if (flag == 1) {
                error_msg = 'Please select title';
                flag = 0;
            } else {
                error_msg = '';
            }
        }
    }

    //First Name 
    if (M.byId('fname') != undefined) {
        M.byId('fname').style.borderColor = C[8];
        if (M.byId('fname').value == '') {
            M.byId('fname').style.borderColor = C[5];
            willPost = 0;
            if (flag == 1) {
                error_msg = 'Please enter first name';
                flag = 0;
            } else {
                error_msg = '';
            }
        } else if (M.byId('fname').value != '' && (!M.isAlpha(M.byId('fname').value.toString()) || (M.byId('fname').value.toString()).match(/\<|\>|\"|\.|\[|\]/g))) {
            M.byId('fname').style.borderColor = C[5];
            willPost = 0;
            if (flag == 1) {
                error_msg = 'Please check - first name should not contain any special character';
                flag = 0;
            } else {
                error_msg = '';
            }
        }
    }
    // DATE OF BIRTH 
    if (M.byId('dateOfBirth') != undefined) {
        M.byId('dateOfBirth').style.borderColor = C[8];
        if (M.trim(M.byId('dateOfBirth').value) == null || !M.isDate(M.byId('dateOfBirth').value.toString())) {
            M.byId('dateOfBirth').style.borderColor = C[5];
            willPost = 0;
            if (flag == 1) {
                error_msg = 'Please enter Date of Birth in correct format <small>(DD-MM-YYYY)</small>';
                flag = 0;
            } else {
                error_msg = '';
            }
        }
        if (M.dateDiffDays(M.byId('dateOfBirth').value) > 0 && M.isDate(M.byId('dateOfBirth').value.toString())) {
            M.byId('dateOfBirth').style.borderColor = C[5];
            willPost = 0;
            if (flag == 1) {
                error_msg = 'Date of Birth can not be greater than current date';
                flag = 0;
            } else {
                error_msg = '';
            }
        }
    }
    // CITY 
    if (M.byId('cities') != undefined) {
        M.byId('cities').style.borderColor = C[8];
        if (M.byId('cities').value == '' || M.byId('cities').value == 0) {
            M.byId('cities').style.borderColor = C[5];
            willPost = 0;
            if (flag == 1) {
                error_msg = 'Please select city';
                flag = 0;
            } else {
                error_msg = '';
            }
        }
    }
    // STATE 
    if (M.byId('state') != undefined) {
        M.byId('state').style.borderColor = C[8];
        if (M.byId('state').value == '' || M.byId('state').value == 0) {
            M.byId('state').style.borderColor = C[5];
            willPost = 0;
            if (flag == 1) {
                error_msg = 'Please select state';
                flag = 0;
            } else {
                error_msg = '';
            }
        }
    }
    // MOBILE
    if (M.byId('mobile') != undefined) {
        M.byId('mobile').style.borderColor = C[8];
        if (M.trim(M.byId('mobile').value) == '') {
            M.byId('mobile').style.borderColor = C[5];
            willPost = 0;
            if (flag == 1) {
                error_msg = 'Please enter your mobile number';
                flag = 0;
            } else {
                error_msg = '';
            }
        }
        if (M.isMobile(M.byId('mobile').value.toString()) == null) {
            M.byId('mobile').style.borderColor = C[5];
            willPost = 0;
            if (flag == 1) {
                error_msg = 'Please enter a valid 10 digit mobile number (do not enter 0 or +91)';
                flag = 0;
            } else {
                error_msg = '';
            }
        }
    }
    //EMAIL 
    if (M.byId('emailid') != undefined) {
        M.byId('emailid').style.borderColor = C[8];
        if (M.trim(M.byId('emailid').value) == '') {
            M.byId('emailid').style.borderColor = C[5];
            willPost = 0;
            if (flag == 1) {
                error_msg = 'Please enter your email ID';
                flag = 0;
            } else {
                error_msg = '';
            }
        }
        if (!M.isEmail(M.byId('emailid').value.toString())) {
            M.byId('emailid').style.borderColor = C[5];
            willPost = 0;
            if (flag == 1) {
                error_msg = 'Please enter a valid email address';
                flag = 0;
            } else {
                error_msg = '';
            }
        }
    }
    if (M.byId('recaptcha_response_field') != undefined) {
        M.byId('recaptcha_response_field').style.borderColor = "#3c3c3c";
        if (M.byId('recaptcha_response_field').value == "") {
            willPost = 0
            M.byId('recaptcha_response_field').style.borderColor = C[5];
        } else {
            val['recaptcha_response_field'] = M.byId('recaptcha_response_field').value;
        }
    }
    M.byId('loader_scb').style.display = '';
    var mp = M.byId('msg-panel');
    if (willPost) {
        mp.className = "MessageContainer";
        M.byTag("b", mp)[0].innerHTML = "";
        M.byTag("em", mp)[0].innerHTML = "";
        M.byTag("b", mp)[0].innerHTML = "";
        M.byTag("em", mp)[0].innerHTML = "Please wait while your inputs are being submitted...";
        submitSearchCreditCard(frm, val);
    } else {
        window.scrollTo(0, 175);
        mp.className = "msg-war";
        if (!willPost) {
            M.byTag("b", mp)[0].innerHTML = "Missing: ";
            if (error_msg != '') {
                M.byTag("em", mp)[0].innerHTML = " " + error_msg;
            } else {
                M.byTag("em", mp)[0].innerHTML = "Fill required fields below";
            }

        } else {
            M.byTag("b", mp)[0].innerHTML = "Error: ";
            M.byTag("em", mp)[0].innerHTML = " " + error_msg;
        }
        subtn.disabled = false
        subtn.style.className = subtnPrevClass
        M.byId('loader_scb').style.display = 'none';
    }
    mp.style.display = "block"
    return false;
}

function searchCreditCard_OLD(frm) {
    if (frm == null) return false
    var subtn = M.byId("subtn")
    if (M.byId('extra_msg') != undefined) {
        M.byId('extra_msg').innerHTML = '';
    }
    var subtnPrevClass = subtn.style.className
    subtn.style.className = "btn btn-gray lh0"
    var elem = ['cities', 'dateOfBirth', 'grossincome', 'salarybank1', 'employmentType', 'emailid', 'mobile']
    var val = {};

    var radios = ['infoprovide'];
    var willPost = 1
    var normalage = 1
    var normalagemsg = '';
    var flag = 1;
    var error_msg = '';
    for (var nxt = 0; nxt < elem.length; nxt++) {
        if (browserver == 'MSIE6' || browserver == 'MSIE') {
            M.byId('cities').className = "w175";
            M.byId('employmentType').className = "w175";
        }
        if (frm[elem[nxt]] != undefined && !frm[elem[nxt]].disabled) {
            var elemVal = M.getElementValue(frm[elem[nxt]])
            frm[elem[nxt]].style.borderColor = C[8]
            val[elem[nxt]] = elemVal;
            if (!elemVal || elemVal <= 0) {
                willPost = 0;
                flag = 0;
                frm[elem[nxt]].style.borderColor = C[5];
                if (browserver == 'MSIE6') {
                    if (M.byId('cities').value == 0) {
                        M.byId('cities').className = "required w175";
                    }
                    if (M.byId('employmentType').value == '') {
                        M.byId('employmentType').className = "required w175";
                    }
                }
            }
        }
    }

    //TAG : GOLF CARD
    if (M.byId("scb_credit_card_yes") != undefined && M.byId("scb_credit_card_no") != undefined) {
        M.byId('existing_card_holder').style.border = "";
        if ((M.byId('scb_credit_card_yes') == undefined || M.byId('scb_credit_card_yes').checked == false) && (M.byId('scb_credit_card_no') == undefined || M.byId('scb_credit_card_no').checked == false)) {
            willPost = 0;
            flag = 0;
            M.byId('existing_card_holder').style.border = C[5] + " 2px solid";
        }
        if (M.byId('scb_credit_card_yes') != undefined && M.byId('scb_credit_card_yes').checked == true) {
            frm['exiting_cc'].style.borderColor = C[8];
            if (M.byId('exiting_cc') != undefined && !frm['exiting_cc'].disabled && M.trim(frm['exiting_cc'].value) == null) {
                frm['exiting_cc'].style.borderColor = C[5];
                normalage = 0;
                if (flag == 1) {
                    error_msg = 'Please select your Credit Card';
                    flag = 0;
                } else {
                    error_msg = '';
                }
            } else {
                val['exiting_cc'] = M.trim(frm['exiting_cc'].value);
                if (M.byId('exiting_cc') != undefined && M.trim(frm['exiting_cc'].value) != '9999') {
                    frm['limit_cc'].style.borderColor = C[8];
                    if (M.byId('limit_cc') != undefined && !frm['limit_cc'].disabled && M.trim(frm['limit_cc'].value) == null) {
                        frm['limit_cc'].style.borderColor = C[5];
                        normalage = 0;
                        if (flag == 1) {
                            error_msg = 'Please enter your Credit Limit on existing Credit Card';
                            flag = 0;
                        } else {
                            error_msg = '';
                        }
                    } else {
                        val['limit_cc'] = M.unformatMoney(frm['limit_cc'].value);
                    }
                    var date_tmp = 1;
                    if (M.byId("vintage_mm") !== undefined && M.byId("vintage_yy") !== undefined) {
                        var int_month = parseInt(M.trim(frm["vintage_mm"].value));
                        var int_year = parseInt(M.trim(frm["vintage_yy"].value));

                        var current_date = new Date();
                        var current_year = current_date.getFullYear();
                        var current_month = current_date.getMonth();
                        //console.log(current_month);
                        frm['vintage_mm'].style.borderColor = C[8];
                        if (M.trim(frm["vintage_mm"].value) == null || int_month < 1 || int_month > 12 || (int_month > current_month && current_year == int_year)) {
                            frm['vintage_mm'].style.borderColor = C[5];
                            date_tmp = 0;
                            normalage = 0;
                            if (flag == 1) {
                                error_msg = 'Please check vintage of your existing credit card month';
                                flag = 0;
                            } else {
                                error_msg = '';
                            }
                        }
                        frm['vintage_yy'].style.borderColor = C[8];

                        if (isNaN(int_year) || int_year < 1932 || int_year > current_year) {
                            frm['vintage_yy'].style.borderColor = C[5];
                            date_tmp = 0;
                            normalage = 0;
                            if (flag == 1) {
                                error_msg = 'Please check vintage of your existing credit card year';
                                flag = 0;
                            } else {
                                error_msg = '';
                            }
                        }
                    }

                    if (date_tmp) {
                        var get_date = new Date(int_year, int_month, 1);
                        var today = new Date();
                        var getmonth = monthDiff(today, get_date);
                        frm['vintage_mm'].style.borderColor = C[8];
                        frm['vintage_yy'].style.borderColor = C[8];
                        if (getmonth >= 12) {
                            //frm['vintage_mm'].style.borderColor=C[5];
                            //frm['vintage_yy'].style.borderColor=C[5];
                            date_tmp = 0;
                            normalage = 0;
                            if (flag == 1) {
                                error_msg = 'Thank you for your interest in RBL Bank Credit Cards.<br/>We regret to inform you that we are unable to proceed with your application process at this point in time as it does not meet our internal policy guidelines.<br/>Please check and re-submit in case you have entered any details incorrectly.';
                                flag = 0;
                            } else {
                                error_msg = '';
                            }
                        } else {
                            val['vintage_date'] = "1" + "-" + int_month + "-" + int_year;
                        }
                    }
                }
            }
        }
    }
    //TAG: GOLF CARD
    if (M.byId('scb_exit_cust_yes') != undefined && M.byId('scb_exit_cust_no') != undefined) {
        M.byId('existing_cust').style.border = "";
        if (M.byId('scb_exit_cust_yes').checked == false && M.byId('scb_exit_cust_no').checked == false) {
            willPost = 0;
            flag = 0;
            M.byId('existing_cust').style.border = C[5] + " 2px solid";
        } else if (M.byId("bank_card_account_no") != undefined) {
            frm['bank_card_account_no'].style.borderColor = C[8];
            if (M.trim(frm['bank_card_account_no'].value) == null && !frm['bank_card_account_no'].disabled) {
                frm['bank_card_account_no'].style.borderColor = C[5];
                willPost = 0;
                if (flag == 1) {
                    error_msg = 'Please enter you account no.';
                    flag = 0;
                } else {
                    error_msg = '';
                }
            }
        }
    }

    frm[elem[1]].style.borderColor = C[8]
    if (M.trim(frm[elem[1]].value) == null || !M.isDate(frm[elem[1]].value.toString())) {
        frm[elem[1]].style.borderColor = C[5]
        normalage = 0;
        if (flag == 1) {
            error_msg = 'Please enter Date of Birth in correct format <small>(DD-MM-YYYY)</small>';
            flag = 0;
        } else {
            error_msg = '';
        }
    }
    if (M.dateDiffDays(frm[elem[1]].value) > 0 && M.isDate(frm[elem[1]].value.toString())) {
        frm[elem[1]].style.borderColor = C[5]
        normalage = 0;
        if (flag == 1) {
            error_msg = 'Date of Birth can not be greater than current date';
            flag = 0;
        } else {
            error_msg = '';
        }
    }
    frm[elem[5]].style.borderColor = C[8];
    if (M.trim(frm[elem[5]].value) == '') {
        frm[elem[5]].style.borderColor = C[5];
        willPost = 0
        if (flag == 1) {
            error_msg = 'Please enter your email ID';
            flag = 0;
        } else {
            error_msg = '';
        }
    }
    if (!M.isEmail(frm[elem[5]].value.toString())) {
        frm[elem[5]].style.borderColor = C[5];
        willPost = 0
        if (flag == 1) {
            error_msg = 'Please enter a valid email address';
            flag = 0;
        } else {
            error_msg = '';
        }
    }
    frm[elem[6]].style.borderColor = C[8];
    if (M.trim(frm[elem[6]].value) == '') {
        frm[elem[6]].style.borderColor = C[5];
        willPost = 0
        if (flag == 1) {
            error_msg = 'Please enter your mobile number';
            flag = 0;
        } else {
            error_msg = '';
        }
    }
    if (M.isMobile(frm[elem[6]].value.toString()) == null) {
        frm[elem[6]].style.borderColor = C[5];
        willPost = 0
        if (flag == 1) {
            error_msg = 'Please enter a valid 10 digit mobile number (do not enter 0 or +91)';
            flag = 0;
        } else {
            error_msg = '';
        }
    }
    //DO FOR PAN
    /*frm[elem[7]].style.borderColor=C[8];
    if(M.trim(frm[elem[7]].value)=='') {
        frm[elem[7]].style.borderColor=C[5];
        willPost=0
        if(flag == 1) {
            error_msg = 'Please enter your PAN';
            flag = 0;
        } else {
            error_msg = '';
        }
    } else if(!M.isPAN(M.trim(frm[elem[7]].value))) {
        frm[elem[7]].style.borderColor=C[5];
        willPost=0
        if(flag == 1) {
            error_msg = 'Please enter a valid PAN';
            flag = 0;
        } else {
            error_msg = '';
        }
    }*/

    if (M.byId('employmentType').value == 4) {
        if (M.byId('salarybank') != undefined) {
            if (M.byId('salarybank').value == '' || M.byId('salarybank').value == 0) {
                M.byId('salary_div').style.borderColor = C[5];
                M.byId('salarybank').style.borderColor = C[5];
                willPost = 0
                if (flag == 1) {
                    error_msg = 'Please select salaried bank account ';
                    flag = 0;
                } else {
                    error_msg = '';
                }
            } else {
                M.byId('salary_div').style.borderColor = C[8];
                M.byId('salarybank').style.borderColor = C[8];
                val['salarybank'] = M.byId('salarybank').value;
            }
        }
    }
    if (frm[radios[0]] != undefined) {
        var r4 = M.byId(radios[0] + "For")
        if (frm[radios[0]].checked) {
            frm[radios[0]].style.outline = '2px solid #0B5D94';
            r4.style.background = 'none';
            r4.style.color = '#FFF';
            val['infoprovide'] = "on";
        } else {
            frm[radios[0]].style.outline = '2px solid #FF0000';
            //r4.style.background='lightYellow';
            r4.style.color = '#FFF';
            willPost = 0
        }
    }
    if (M.byId("scb_credit_card_yes") != undefined && M.byId("scb_credit_card_no") != undefined) {
        if (M.byId('scb_credit_card_yes').checked == true) {
            val['scb_credit_card'] = "Y";
        }
        if (M.byId('scb_credit_card_no').checked == true) {
            val['scb_credit_card'] = "N";
        }
    }


    if (M.byId('scb_exit_cust_yes') != undefined && M.byId('scb_exit_cust_no') != undefined) {
        if (M.byId('scb_exit_cust_yes').checked == true) {
            val['exit_cust'] = "Y";
            if (M.byId("bank_card_account_no") != undefined) {
                val['exit_cust_acc_no'] = M.byId("bank_card_account_no").value;
            }
        } else {
            val['exit_cust'] = "N";
        }
    }





    M.byId('loader_scb').style.display = '';
    var mp = M.byId('msg-panel');
    if (willPost && normalage) {
        mp.className = "MessageContainer";
        M.byTag("b", mp)[0].innerHTML = "";
        M.byTag("em", mp)[0].innerHTML = "";
        M.byTag("b", mp)[0].innerHTML = "";
        M.byTag("em", mp)[0].innerHTML = "Please wait while your inputs are being submitted...";
        submitSearchCreditCard(frm, val);
    } else {
        window.scrollTo(0, 175);
        mp.className = "msg-war";
        if (!willPost) {
            M.byTag("b", mp)[0].innerHTML = "Missing: ";
            if (error_msg != '') {
                M.byTag("em", mp)[0].innerHTML = " " + error_msg;
            } else {
                M.byTag("em", mp)[0].innerHTML = "Fill required fields below";
            }

        } else {
            M.byTag("b", mp)[0].innerHTML = "Error: ";
            M.byTag("em", mp)[0].innerHTML = " " + error_msg;
        }
        subtn.disabled = false
        subtn.style.className = subtnPrevClass
        M.byId('loader_scb').style.display = 'none';
    }
    mp.style.display = "block"
    //retVal = willPost*normalage;

    //return retVal?true:false
    return false;
}

function saveEmail(f1) {
    var f2 = M.getForm('capturedValue');
    var success = 0;
    if (f2['emailid'] != undefined && f1['justEmail'] != undefined) {
        if (M.isEmail(f1['justEmail'].value.toString()) == null) {
            M.byId("invalid_message").innerHTML = "Invalid format of email id".fontcolor("red");
        } else {
            f2['emailid'].value = f1['justEmail'].value;
            success = 1;
        }
    }

    if (success == 1 && f2['mobile'] != undefined && f1['justMobile'] != undefined) {
        if (M.isMobile(f1['justMobile'].value.toString()) == null) {
            M.byId("invalid_message").innerHTML = "Invalid format of mobile".fontcolor("red");
        } else {
            f2['mobile'].value = f1['justMobile'].value;
            if (success == 1) {
                f2.submit();
            }
        }
    }
    return false;
}

function applyCreditCard(c, askEmail) {
    var frm = M.getForm('capturedValue');
    if (frm == null) {
        frm = M.getForm('capturedValue-2');
    }
    if (frm != null) {
        if (c != undefined && frm['selectedCardId'] != undefined) frm['selectedCardId'].value = c;
    }

    if (askEmail) {
        if (M.byId('pageOverlay')) {
            M.byId('pageOverlay').style.display = 'block';
            M.byId('itemWrapper').style.display = 'block';
            M.byId('itemOverlay').innerHTML = "<form name='x' id='x' action='/credit-card-new' class='p10' onsubmit=\"return saveEmail(this);\"><table width='100%'><tr><td colspan='2' align='right'><a href=\"\" onClick=\"killJustPopup();return false;\">X</a></td></tr><tr><td  width='30%' align='right'><label>Your email address:<b class='req'>*</b>&nbsp;</label></td><td align='left'><input type='text' name='justEmail' maxlength='101' class='h2 w250 p5' value='" + M.byId("emailid").value + "'/></td></tr><tr><td></td><td align='left'><label>Application confirmation will be mailed to this address.</label></td></tr><tr><td colspan='2'>&nbsp;</td></tr><tr><td align='right'><label>Your mobile number:<b class='req'>*</b></label>&nbsp;</td><td align='left'><input type='text' name='justMobile' maxlength='10' onKeyDown='return M.digit(event);' class='h2 w250 p5' value='" + M.byId("mobile").value + "'/></td></tr><tr><td></td><td align='left'><label>Any alerts will be sent to this mobile.</label></td></tr><tr><td colspan='2'>&nbsp;</td></tr><tr><td></td><td align='left'><button class='rp-button rp-button-medium' type='submit'>Continue to proceed</button></td></tr></table></form><p id='invalid_message'></p>";
            return;
        }
    } else {
        frm.submit();
    }
}

function applyCreditNewCardOLD(id) {
    s = "page=applynewcard&card_id=" + id;
    M.AJAX.request({
        target: '/credit-card-new',
        query: s,
        method: 'POST',
        onSuccess: function (msg) {
            if (msg == '1') {
                M.byId('shade').style.display = 'none';
                M.byId('ints').style.display = 'none';
                M.byId('middle').style.display = 'block';
            } else if (msg == '0') {
                M.byId("invalid_message").innerHTML = "some error occured please try again".fontcolor("red");
                M.byId('recaptcha_ndnc_field').style.color = 'red';
                return false;
            } else if (msg == '2') {
                M.byId("invalid_message").innerHTML = "Your session has expired. for apply new card <a href='/credit-card-new'>click</a>".fontcolor("red");
                return false;
            }

        },
        onFailed: function (msg) {
            var l = M.byId('invalid_message');
            l.className = "submitError";
            l.innerHTML = msg;
        }
    });
}

function applyCreditNewCard(id) {
    s = "page=applynewcard&selectedCardNewId=" + id;
    M.AJAX.request({
        target: '/credit-card-new',
        query: s,
        method: 'POST',
        onSuccess: finishSearchCreditCardNewApply,
        onFailed: function (msg) {
            var l = M.byId('invalid_message');
            l.className = "submitError";
            l.innerHTML = msg;
        }
    });
}

function applyDownsellCreditCard(id) {
    s = "downSellSelectedCardId=" + id;
    M.AJAX.request({
        target: '/credit-card-new',
        query: s,
        method: 'POST',
        onSuccess: function (res) {
            if (res.match(/^error\:/i) == null) {
                var POSTACT = M.byId("prePostFormBlock");
                POSTACT.className = "";
                POSTACT.innerHTML = res;
                //M.byId("sub_form_1").innerHTML = res;
                M.byId('pageOverlay').style.display = 'none';
                M.byId('itemWrapper').style.display = 'none';
                //M.byId('app_track').style.display='';
                //M.byId('notes_selected_product_name_new').innerHTML='';
                if (M.byId('navigation_new') != undefined) {
                    M.byId('navigation_new').innerHTML = '<ul id="step_box" class="step_box" style="float:right;"><li class="w80"><a href="/credit-card-new"><span>1</span><p>CHOOSE<br />CARD</p></a></li><li class="w80"><a href="javascript:;"><span>2</span><p>APPLY<br/>ONLINE</p></a></li><li class="w90"><span class="active">3</span><p>INSTANT<br/>APPROVAL</p></li></ul>';
                }
                if (M.byId('card_applicant_name') != undefined) {
                    M.byId('card_applicant_name').innerHTML = M.byId('card_user_name').value;
                }
                if (M.byId('heading1') != undefined) {
                    M.byId('heading1').className = 'dontshow';
                }
                if (M.byId('pickupDate') != undefined) {
                    var currentTime = new Date();
                    var month = currentTime.getMonth() + 1;
                    var day = currentTime.getDate();
                    var year = currentTime.getFullYear();
                    var hour = currentTime.getHours();
                    var minutes = currentTime.getMinutes();
                    if (hour >= 11) {
                        if (minutes > 30 || hour > 11) {
                            day = day + 1;
                        }
                    }
                    $(function () { $("#pickupDate").datepick({ changeMonth: true, changeYear: true, yearRange: year + ':' + year, minDate: new Date(year, month - 1, day), maxDate: new Date(year, month - 1, day + 15), shortYearCutoff: '+1' }); });
                }
            } else {

            }
        },
        onFailed: function (msg) {
            var l = M.byId('invalid_message');
            l.className = "submitError";
            l.innerHTML = msg;
        }
    });
}

function killJustPopup() {
    M.byId('itemOverlay').innerHTML = ""
    M.byId('itemWrapper').style.display = 'none'
    M.byId('pageOverlay').style.display = 'none'
    M.getForm('capturedValue')['selectedCardId'].value = '';
}

function acceptCaptchaCondition(frm) {
    if (M.byId('recaptcha_ndnc_field').value == '') {
        M.byId("invalid_message").innerHTML = "Please enter security code".fontcolor("red");
        M.byId('recaptcha_ndnc_field').style.borderColor = 'red';
        return false;
    } else {
        s = "page=checkcaptchandnc&recaptcha_ndnc_field=" + frm['recaptcha_ndnc_field'].value;
        M.AJAX.request({
            target: '/credit-card-new',
            query: s,
            method: 'POST',
            onSuccess: function (msg) {
                if (msg == '1') {
                    M.byId('shade').style.display = 'none';
                    M.byId('ints').style.display = 'none';
                    M.byId('middle').style.display = 'block';
                } else if (msg == '0') {
                    M.byId("invalid_message").innerHTML = "wrong security code entered".fontcolor("red");
                    M.byId('recaptcha_ndnc_field').style.color = 'red';
                    return false;
                } else if (msg == '2') {
                    M.byId("invalid_message").innerHTML = "Your session has expired".fontcolor("red");
                    return false;
                }

            },
            onFailed: function (msg) {
                var l = M.byId('invalid_message');
                l.className = "submitError";
                l.innerHTML = msg;
            }
        });


    }
    return false;
}

function hideshowDiv(id, totdiv) {
    objdiv1 = eval("document.getElementById('Id" + id + "')")
    objimg1 = eval("document.getElementById('img" + id + "')")

    for (i = 1; i <= totdiv; i++) {
        objdiv = eval("document.getElementById('Id" + i + "')")
        objimg = eval("document.getElementById('img" + i + "')")
        objdiv.style.display = 'none'
        objimg.className = ''
    }
    objdiv1.style.display = ''
    objimg1.className = 'selected'
}

function showRelationShip() {

    if (M.byId('existing_customer_no').checked == true) {
        M.byId('relation_lable').style.display = 'none';
        M.byId('relation_div').style.display = 'none';
    }
    if (M.byId('existing_customer_yes').checked == true) {
        M.byId('relation_lable').style.display = '';
        M.byId('relation_div').style.display = '';

    }
}
function finCounterCard(src) {
    if (!src) return;
    var trgTop = M.byId('finCountTop');
    var current = parseInt((trgTop.value == '' ? 0 : trgTop.value));

    if (current == 3 && src.checked) {
        src.checked = false;
        alert("You can compare a maximum of 3 cards");
        return;
    }

    if (src.checked)
        trgTop.value = current + 1;
    else
        trgTop.value = current - 1;

    current = parseInt((trgTop.value == 'No' ? 0 : trgTop.value));
    var d = current < 2;
}

function showCompareCards(a, src) {
    //var E = (M.getForm('CompareCards'));
    var frm = M.getForm('CompareCards');
    if (frm == null) return;
    var finCount = M.byId('finCountTop');
    if (finCount.value == '0' || finCount.value == '') {
        alert('No card is selected.');
        return;
    }
    else if (finCount.value == '1') {
        alert('Please select at least 2 cards to compare');
        return;
    }
    var allIs = M.byTag("input", (src != undefined ? M.byId(src) : null)), selected = new Array();
    var ids = '';
    for (var i = 0; i < allIs.length; i++) {
        if (allIs[i].type == "checkbox" && allIs[i].checked) {
            selected[selected.length] = allIs[i].value;
            ids += allIs[i].value + ',';
        }
    }
    M.byId('compare_ids').value = ids;
    frm.submit();
}

var saveEmailCount = 0;

function saveEmailWithCardQuote() {
    if (M.byId('email_save').value == 'YOUR EMAIL ID HERE') {
        M.byId('email_save').style.borderColor = "red";
        return false;
    }

    if (!M.isEmail(M.byId('email_save').value.toString())) {
        M.byId('email_save').style.borderColor = C[5];
        return false;
    }
    s = "page=savequotecreditcardemail";
    s += "&email_save=" + M.byId('email_save').value;
    M.byId("msg-email").style.display = 'block';
    M.byId("msg-email").innerHTML = '<div style="width:150px;"><img src="/support/img_rp/rp-loader.gif"></div>';
    M.AJAX.request({
        target: '/credit-card-new',
        query: s,
        method: 'POST',
        onSuccess: finishSaveEmailWithData,
        onFailed: function (msg) {
            var l = M.byId('msg-email');
            l.className = "submitError";
            l.innerHTML = msg;
        }
    });
}

function finishSaveEmailWithData(res) {
    saveEmailCount = saveEmailCount + 1;
    res = M.trim(res);
    if (res.match(/^Error\:/i) == null) {
        var POSTACT = M.byId("msg-email");
        POSTACT.style.display = 'block';
        POSTACT.className = "";
        POSTACT.innerHTML = res;
        if (saveEmailCount > 2) {
            M.byId('save_email_div').style.display = 'none';
            M.byId('email_save_btn').disabled = true;
            M.byId('email_save').disabled = true;

        } else {
            M.byId('email_save_btn').disabled = false;
            M.byId('email_save').disabled = false;
        }
    } else {
        var mp = M.byId('msg-email');
        mp.style.display = 'block';
        mp.className = "msg-err corner-all";
        mp.innerHTML = res;
    }
}

function showDocumentLable() {
    if (M.byId('income_proof').value > 0) {
        if (x_value != undefined) {
            var document_array = x_value.split(",");
            for (var i = 0; i < (document_array.length - 1); i++) {
                var document_new = document_array[i].split("-");
                if (M.byId('income_proof').value == document_new[0]) {
                    M.byId('document').innerHTML = document_new[1];
                }
            }
        }
    } else {
        M.byId('document').innerHTML = 'Income proof value';
    }
}

function emailVerification() {
    if (M.byId('email').value == '') {
        M.byId('email').style.borderColor = C[5];
        return;
    }
    if (!M.isEmail(M.byId('email').value.toString())) {
        M.byId('email').style.borderColor = C[5];
        return;
    }
    if (M.byId('email_verification_code').value == '') {
        M.byId('email_verification_code').style.borderColor = C[5];
        return;
    }
    s = "page=verifyemailcode";
    s += "&verify_email=" + M.byId('email').value;
    s += "&verify_code=" + M.byId('email_verification_code').value;
    M.byId("msg-error-email").innerHTML = '';
    M.byId("msg-error-email").innerHTML = '&nbsp;<img src="/support/img_rp/rp-loader.gif">';
    M.AJAX.request({
        target: '/credit-card-new',
        query: s,
        method: 'POST',
        onSuccess: finishVerifyEmailWithData,
        onFailed: function (msg) {
            var l = M.byId('msg-error-email');

        }
    });
}

function finishVerifyEmailWithData(res) {
    res = M.trim(res);
    if (res.match(/^Error\:/i) == null) {
        var POSTACT = M.byId("email_verified_input");
        M.byId("msg-error-email").innerHTML = '';
        M.byId('email').readOnly = true;
        M.byId('email_verified_label').innerHTML = '&nbsp;';
        POSTACT.innerHTML = '<img src="/support/img_rp/correct_new_medium.png">&nbsp;' + res;

    } else {
        var new_msg = res.split("Error:");

        var mp = M.byId('msg-error-email');
        mp.style.color = 'red';
        mp.innerHTML = new_msg[1];
    }
}

function mobileVerification() {
    if (M.byId('mobileNo').value == '') {
        M.byId('mobileNo').style.borderColor = C[5];
        return;
    }
    if (!M.isMobile(M.byId('mobileNo').value.toString())) {
        M.byId('mobileNo').style.borderColor = C[5];
        return;
    }
    if (M.byId('mobile_verification_code').value == '') {
        M.byId('mobile_verification_code').style.borderColor = C[5];
        return;
    }
    s = "page=verifymobilecode";
    s += "&verify_mobile=" + M.byId('mobileNo').value;
    s += "&verify_code=" + M.byId('mobile_verification_code').value;
    M.byId("msg-error-mobile").innerHTML = '';
    M.byId("msg-error-mobile").innerHTML = '&nbsp;<img src="/support/img_rp/rp-loader.gif">';
    M.AJAX.request({
        target: '/credit-card-new',
        query: s,
        method: 'POST',
        onSuccess: finishVerifyMobileWithData,
        onFailed: function (msg) {
            var l = M.byId('msg-error-mobile');

        }
    });
}

function finishVerifyMobileWithData(res) {
    res = M.trim(res);
    if (res.match(/^Error\:/i) == null) {
        var POSTACT = M.byId("mobile_verified_input");
        M.byId("msg-error-mobile").innerHTML = '';
        M.byId('mobileNo').readOnly = true;
        M.byId('mobile_verified_label').innerHTML = '&nbsp;';
        POSTACT.innerHTML = '<img src="/support/img_rp/correct_new_medium.png">&nbsp;' + res;

    } else {
        var new_msg = res.split("Error:");

        var mp = M.byId('msg-error-mobile');
        mp.style.color = 'red';
        mp.innerHTML = new_msg[1];
    }
}

function resendEmailVerificationCode() {
    if (M.byId('email').value == '') {
        M.byId('email').style.borderColor = "red";
        return;
    }

    if (!M.isEmail(M.byId('email').value.toString())) {
        M.byId('email').style.borderColor = C[5];
        return;
    }
    s = "page=sendemailcode";
    s += "&email_save=" + M.byId('email').value;
    M.byId("msg-error-email").innerHTML = '';
    M.byId("msg-error-email").innerHTML = '&nbsp;<img src="/support/img_rp/rp-loader.gif">';
    M.AJAX.request({
        target: '/credit-card-new',
        query: s,
        method: 'POST',
        onSuccess: finishResendCodeEmailWithData,
        onFailed: function (msg) {
            var l = M.byId('msg-error-email');
        }
    });
}

var sendCodeEmailCount = 0;
function finishResendCodeEmailWithData(res) {
    res = M.trim(res);
    if (res.match(/^Error\:/i) == null) {
        sendCodeEmailCount = sendCodeEmailCount + 1;

        if (sendCodeEmailCount > 2) {
            M.byId('resend_btn').style.display = 'none';
            M.byId("msg-error-email").innerHTML = '';
            M.byId("msg-error-email").innerHTML = '&nbsp;' + res;
        } else {
            M.byId("msg-error-email").innerHTML = '';
            M.byId("msg-error-email").innerHTML = '<img src="/support/img_rp/correct_new_medium.png">&nbsp;' + res;
        }
    } else {
        var new_msg = res.split("Error:");
        var mp = M.byId('msg-error-email');
        mp.style.color = 'red';
        mp.innerHTML = new_msg[1];

    }
}

var sendCodeMobileCount = 0;
function finishResendCodeMobileWithData(res) {
    res = M.trim(res);
    if (res.match(/^Error\:/i) == null) {
        sendCodeMobileCount = sendCodeMobileCount + 1;

        if (sendCodeMobileCount > 2) {
            M.byId('mobile_resend_btn').style.display = 'none';
            M.byId("msg-error-mobile").innerHTML = '';
            M.byId("msg-error-mobile").innerHTML = '&nbsp;' + res;
        } else {
            M.byId("msg-error-mobile").innerHTML = '';
            M.byId("msg-error-mobile").innerHTML = '<img src="/support/img_rp/correct_new_medium.png">&nbsp;' + res;
        }
    } else {
        var new_msg = res.split("Error:");
        var mp = M.byId('msg-error-mobile');
        mp.style.color = 'red';
        mp.innerHTML = new_msg[1];

    }
}

function showAddress() {
    if (M.byId('address_type_residence').checked == true) {
        M.byId('residence_address').style.display = '';
        M.byId('other_address').style.display = 'none';
    }
    if (M.byId('address_type_other').checked == true) {
        M.byId('residence_address').style.display = 'none';
        M.byId('other_address').style.display = '';
    }
}

function submitDocumentCollection() {

    var s = '';
    var val = {};
    var mp = M.byId('msg-panel-4');
    mp.className = 'msg-err corner-all';
    M.byId('matchbox').innerHTML = '';
    var dateDiffVal = M.dateDiffDays(M.byId('pickupDate').value);
    var dateInput = M.byId('pickupDate').value;
    var dateInputArray = dateInput.split('-');
    var checkdate = new Date(dateInputArray[1] + '/' + dateInputArray[0] + '/' + dateInputArray[2]);
    var day = checkdate.getDay();
    if (M.byId('address_type_other').checked == true) {
        M.byId('app_other_address_1').style.borderColor = C[8];
        if (M.byId('app_other_address_1').value == "") {
            M.byId('app_other_address_1').style.borderColor = C[5];
            mp.className = 'msg-war corner-all';
            return false;
        } else {
            val['app_other_address_1'] = M.byId('app_other_address_1').value;
        }
        M.byId('other_city').style.borderColor = C[8];
        if (M.byId('other_city').value == "") {
            M.byId('other_city').style.borderColor = C[5];
            mp.className = 'msg-war corner-all';
            return false;
        } else {
            val['other_city'] = M.byId('other_city').value;
        }
        M.byId('other_pincode').style.borderColor = C[8];
        if (M.byId('other_pincode').value == "") {
            M.byId('other_pincode').style.borderColor = C[5];
            mp.className = 'msg-war corner-all';
            return false;
        } else {
            val['other_pincode'] = M.byId('other_pincode').value;
        }
        if (M.byId('app_other_address_2').value != "") {
            val['app_other_address_2'] = M.byId('app_other_address_2').value;
        }
        val['address_type'] = "Y";
    }
    M.byId('pickupDate').style.borderColor = C[8]
    if ((!M.isDate((M.byId('pickupDate').value).toString())) || M.byId('pickupDate').value == '') {
        M.byId('pickupDate').style.borderColor = C[5]
        mp.className = 'msg-war corner-all';
        return false;
    } else if (dateDiffVal < 0) {
        M.byId('pickupDate').style.borderColor = C[5]
        mp.className = 'msg-war corner-all';
        M.byTag("b", mp)[0].innerHTML = "Missing: ";
        M.byTag("em", mp)[0].innerHTML = "Sorry! Pickup date can't be in the past";
        M.byId('matchbox').innerHTML = "";
        return false;

    } else if (day == 0) {
        M.byId('pickupDate').style.borderColor = C[5]
        mp.className = 'msg-war corner-all';
        M.byTag("b", mp)[0].innerHTML = "Missing: ";
        M.byTag("em", mp)[0].innerHTML = "Sorry! Pickup date can't be sunday";
        M.byId('matchbox').innerHTML = "";
        return false;
    } else if (M.dateDiffDays(M.byId('pickupDate').value) > 14) {
        M.byId('pickupDate').style.borderColor = C[5]
        M.byTag("b", mp)[0].innerHTML = "Missing: ";
        M.byTag("em", mp)[0].innerHTML = "Sorry! Document collection data has to be within next 2 week";
        //M.byId('matchbox').innerHTML = "<font style='color:red'>&nbsp;Date can't be more than two week</font>";
        M.byId('matchbox').innerHTML = "";
        return false;
    } else {
        M.byId('chqPKTime').style.borderColor = C[8]
        if (M.byId('chqPKTime').value == '0') {
            M.byId('chqPKTime').style.borderColor = C[5]
            return false;
        } else if (M.byId('chqPKTime').value == 1) {
            val['chqPKTimeFromH'] = '09';
        } else if (M.byId('chqPKTime').value == 2) {
            val['chqPKTimeFromH'] = '11';
        } else if (M.byId('chqPKTime').value == 3) {
            val['chqPKTimeFromH'] = '13';
        } else if (M.byId('chqPKTime').value == 4) {
            val['chqPKTimeFromH'] = '15';
        }
    }
    if (M.byId('iframe_osnpsin') != undefined) {
        M.byId('iframe_osnpsin').innerHTML = '<img src="/support/img_rp/rp-loader.gif">';
    }
    s = "page=collectdocument";
    for (var se in val) s += "&" + se + "=" + val[se];
    s += "&collection_date=" + M.byId('pickupDate').value;
    M.byId('matchbox').innerHTML = '&nbsp;<img src="/support/img_rp/rp-loader.gif">';
    /*alert(s);
    return false;*/
    M.AJAX.request({
        target: '/credit-card-new',
        query: s,
        method: 'POST',
        onSuccess: function (msg) {
            if (msg.match(/^Error\:/i) == null) {
                //M.byId('matchbox').innerHTML = '';
                M.byId('collection_div').style.borderColor = '#fff';
                M.byId('collection_div').innerHTML = msg;
                if (M.byId('iframe_osnpsin') != undefined) {
                    M.byId('iframe_osnpsin').innerHTML = '<iframe width=\"350px;\" height=\"195px;\" style=\"border:none;\" src=\"https://www.surveygizmo.com/s3/1125197/osnpsin\"></iframe>';
                }
            } else {
                mp.className = "msg-war corner-all";
                M.byTag("b", mp)[0].innerHTML = "Error: ";
                M.byTag("em", mp)[0].innerHTML = msg.replace(/^error\:/i, '');
                M.byId('matchbox').innerHTML = '';
                if (M.byId('iframe_osnpsin') != undefined) {
                    M.byId('iframe_osnpsin').innerHTML = '';
                }
            }
        },
        onFailed: function (msg) {

        }
    });
    return false;
}

function populatePincode(city_id, flg) {
    if (flg == undefined) { flg = 1; }

    if (M.byId('pincode') != undefined && flg == 1) {
        var target = M.byId('pincode');
    } else if (M.byId('other_pincode') != undefined && flg == 2) {
        var target = M.byId('other_pincode');
    } else if (M.byId('officePincode') != undefined && flg == 3) {
        var target = M.byId('officePincode');
    }

    //M.byId('loader_scb-1').style.display = "";
    M.AJAX.request({
        target: '/credit-card-new',
        query: "page=pincode&city_id=" + city_id,
        method: 'POST',
        postmsg: M.byId('postmsg'),
        onSuccess: function (msg) {
            if (browserver == 'MSIE' || browserver == 'MSIE6') {
                if (M.byId('other_pincode_div') != undefined && (flg == 1 || flg == 2)) {
                    M.byId('other_pincode_div').innerHTML = '';
                    M.byId('other_pincode_div').innerHTML = '<select name="' + target.id + '" id="' + target.id + '" class="w100" />' + msg + '</select><span style="display: none; padding-left:10px; margin-left:-55px;" id="loader_scb-1"><img height="22px" src="/support/img_rp/loader_green.gif"></span>';
                } else if (M.byId('office_pincode_div') != undefined && flg == 3) {
                    M.byId('office_pincode_div').innerHTML = '';
                    M.byId('office_pincode_div').innerHTML = '<select name="' + target.id + '" id="' + target.id + '" class="w100" />' + msg + '</select><span style="display: none; padding-left:10px; margin-left:-55px;" id="loader_scb-1"><img height="22px" src="/support/img_rp/loader_green.gif"></span>';
                }
            } else {
                target.disabled = false;
                //M.byId('loader_scb-1').style.display = "none";
                target.innerHTML = msg;
            }
            //M.byId('other_pincode_div').innerHTML = '';
            //M.byId('other_pincode_div').innerHTML = msg;
        },
        onFailed: function (msg) {

        }
    });
}

function populateCity(state_id, flg) {
    if (flg == undefined) {
        flg = 1;
    }
    if (M.byId('city') != undefined && flg == 1) {
        var target = M.byId('city');
        var target_pincode = M.byId('pincode');
        target.disabled = true;
    } else if (M.byId('other_city') != undefined && flg == 2) {
        var target = M.byId('other_city');
        var target_pincode = M.byId('other_pincode');
    } else if (M.byId('txt_permanent_city') != undefined && flg == 3) {
        var target = M.byId('txt_permanent_city');
        var target_pincode = M.byId('txt_permanent_pincode');
    } else if (M.byId('officeCity') != undefined && flg == 4) {
        var target = M.byId('officeCity');
        var target_pincode = M.byId('officePincode');
        target.disabled = true;
    } else if (M.byId('cities') != undefined && flg == 5) {
        var target = M.byId('cities');
        var target_pincode = undefined;
        target.disabled = true;
    }

    if (M.byId('city_loader') != undefined && (flg == 1 || flg == 2 || flg == 5)) {
        var loader_div = M.byId('city_loader');
        loader_div.style.display = "";
    } else if (M.byId('permanent_city_loader') != undefined && flg == 3) {
        var loader_div = M.byId('permanent_city_loader');
        loader_div.style.display = "";
    } else if (M.byId('officeCityLoader') != undefined && flg == 4) {
        var loader_div = M.byId('officeCityLoader');
        loader_div.style.display = "";
    }

    if (state_id <= 0 || state_id == "") {
        target.selectedIndex = 0;
        target.disabled = true;
        loader_div.style.display = "none";
        if (target_pincode != undefined) {
            target_pincode.selectedIndex = 0;
            target_pincode.disabled = true;
        }
        return false;
    } else {
        if (target_pincode != undefined) {
            target_pincode.selectedIndex = 0;
            target_pincode.disabled = true;
        }
    }

    M.AJAX.request({
        target: '/credit-card-new',
        query: "page=city&state_id=" + state_id,
        method: 'POST',
        postmsg: M.byId('postmsg'),
        onSuccess: function (msg) {
            if (browserver == 'MSIE' || browserver == 'MSIE6') {
                if (M.byId('residence_city_div') != undefined && flg == 1) {
                    M.byId('residence_city_div').innerHTML = '';
                    M.byId('residence_city_div').innerHTML = '<select name="' + target.id + '" id="' + target.id + '" class="w175" onchange="populatePincode(this.value, 1);" />' + msg + '</select><span style="display: none; padding-left:10px; margin-left:-55px;" id="city_loader"><img height="22px" src="/support/img_rp/loader_green.gif"></span>';
                    M.byId('other_pincode_div').innerHTML = '<select name="pincode" id="pincode" class="w108" /><option value="">Select</option></select><span id="loader_scb-1" style="display: none; padding-left:10px; margin-left:-55px;"><img height="22px" src="/support/img_rp/loader_green.gif"></span>';
                } else if (M.byId('permanent_city_div') != undefined && flg == 3) {
                    M.byId('permanent_city_div').innerHTML = '';
                    M.byId('permanent_city_div').innerHTML = '<select name="' + target.id + '" id="' + target.id + '" class="w175" onchange="populatePincode(this.value, 3);" />' + msg + '</select><span style="display: none; padding-left:10px; margin-left:-55px;" id="permanent_city_loader"><img height="22px" src="/support/img_rp/loader_green.gif"></span>';
                } else if (M.byId('office_city_div') != undefined && flg == 4) {
                    M.byId('office_city_div').innerHTML = '';
                    M.byId('office_city_div').innerHTML = '<select name="' + target.id + '" id="' + target.id + '" class="w175" onchange="populatePincode(this.value, 3);">' + msg + '</select><span style="display: none; padding-left:10px; margin-left:-55px;" id="office_city_loader"><img height="22px" src="/support/img_rp/loader_green.gif"></span>';
                } else if (M.byId('city_div') != undefined && flg == 5) {
                    M.byId('city_div').innerHTML = '';
                    M.byId('city_div').innerHTML = '<select name="' + target.id + '" id="' + target.id + '" class="w175">' + msg + '</select><span style="display: none; padding-left:10px; margin-left:-55px;" id="city_loader"><img height="22px" src="/support/img_rp/loader_green.gif"></span>';
                }
            } else {
                target.disabled = false;
                if (loader_div != undefined) {
                    loader_div.style.display = "none";
                }
                target.innerHTML = msg;
            }
            //M.byId('other_pincode_div').innerHTML = '';
            //M.byId('other_pincode_div').innerHTML = msg;
        },
        onFailed: function (msg) {

        }
    });
}

function showTravelType() {

}

function confirmMobileNumberOnBlur() {
    if (!M.isMobile(M.byId('mobile').value.toString())) {
        M.byId('mobile').style.borderColor = C[5];
        return;
    }
    s = "page=confirmmobile&confirm_mobile_onblur=1";
    s += "&verify_mobile_number=" + M.byId('mobile').value;
    M.byId("msg_box").innerHTML = "<span class=\"\"><img height=\"15\" src='/support/img_rp/loader_green_small.gif'></span>"
    M.AJAX.request({
        target: '/credit-card-new',
        query: s,
        method: 'POST',
        onSuccess: function (msg) {

            if (msg.match(/^success\:/i) != null) {
                M.byId("msg_box").innerHTML = "<span class=\"correct-bg\"></span><span class=\"\">" + msg.replace('success:', '') + "</span>";
            } else if (msg.match(/^error_sms\:/i) != null) {
                M.byId("msg_box").innerHTML = "<span class=\"wrong-bg\"></span><span class=\"\">" + msg.replace('error_sms:', '') + "</span>";
                if (M.byId("mobile_div") != undefined) {
                    M.byId("mobile").value = M.byId("mobile_div").innerHTML;
                    M.byId("mobile").readOnly = true;
                }
            } else if (msg.match(/^error_onblur\:/i) != null) {
                M.byId("msg_box").innerHTML = "<span class=\"wrong-bg\"></span><span class=\"\">Your privacy is protected.</span>";
                var mp = M.byId('msg-panel');
                mp.style.display = "";
                mp.className = "msg-war";
                M.byTag("b", mp)[0].innerHTML = "Error: ";
                M.byTag("em", mp)[0].innerHTML = msg.replace('error_onblur:', '');
                //M.byId("mobile").value = ;

            } else {
                M.byId("msg_box").innerHTML = "<span class=\"wrong-bg\"></span><span class=\"\">" + msg.replace('Error:', '') + "</span>";
            }
            if (M.byId('loader-verify') != undefined) {
                M.byId('loader-verify').style.display = "none";
            }
        },
        onFailed: function (msg) {
            var l = M.byId('error_msg');

        }
    });
}

function confirmMobileNumber() {
    M.byId("error_msg").innerHTML = '';
    M.byId("code_TR").style.display = 'none';
    M.byId("error_msg").className = '';
    if (M.byId('mobileNo').value == '') {
        M.byId('mobileNo').style.borderColor = C[5];
        M.byId("error_msg").className = 'msg-war';
        M.byId("error_msg").innerHTML = 'Please enter mobile number';
        return;
    }
    if (!M.isMobile(M.byId('mobileNo').value.toString())) {
        M.byId('mobileNo').style.borderColor = C[5];
        M.byId("error_msg").className = 'msg-war';
        M.byId("error_msg").innerHTML = 'Please enter valid mobile number';
        return;
    }
    if (M.byId('mobile') != undefined) {
        M.byId('mobile').disabled = false;
        if (M.byId('mobileNo') != undefined) {
            M.byId('mobile').value = M.byId('mobileNo').value;
            M.byId('mobile').disabled = true;
        }
    }
    s = "page=confirmmobile";
    s += "&verify_mobile_number=" + M.byId('mobileNo').value;
    M.byId("error_msg").className = 'MessageContainer';
    M.byId("error_msg").innerHTML = '';
    M.byId("error_msg").innerHTML = 'Sending SMS verification code...&nbsp;<img src="/support/img_rp/loader_green_small_new.gif">';
    M.AJAX.request({
        target: '/credit-card-new',
        query: s,
        method: 'POST',
        onSuccess: finishConfirmMobileNumber,
        onFailed: function (msg) {
            var l = M.byId('error_msg');

        }
    });
}

function verifyMobileCode() {
    M.byId("msg-panel").style.display = "none";
    M.byId("error_msg").innerHTML = "";
    M.byId("error_msg").className = '';
    if (M.byId('mobileNo').value == '') {
        M.byId('mobileNo').style.borderColor = C[5];
        M.byId("error_msg").className = 'msg-war';
        M.byId("error_msg").innerHTML = "Please enter mobile number";
        return;
    }
    if (!M.isMobile(M.byId('mobileNo').value.toString())) {
        M.byId('mobileNo').style.borderColor = C[5];
        M.byId("error_msg").className = 'msg-war';
        M.byId("error_msg").innerHTML = "Please enter valid mobile number";
        return;
    }
    if (M.byId('mobile_verification_code').value == '' && sendCodeMobileCount < 3) {
        M.byId('mobile_verification_code').style.borderColor = C[5];
        M.byId("error_msg").className = 'msg-war';
        M.byId("error_msg").innerHTML = "Please enter verification code";
        return;
    }
    s = "page=verifymobilecode";
    s += "&verify_mobile_number=" + M.byId('mobileNo').value;
    s += "&mobile_verification_code=" + M.byId('mobile_verification_code').value;
    // 12-03-2014
    if (otp_popup == 1) {
        s += "&otp_true_again_verify=" + otp_popup;
    }
    // 12-03-2014
    M.byId("error_msg").innerHTML = '';
    M.byId("error_msg").className = 'MessageContainer';
    M.byId("error_msg").innerHTML = 'Verifying your sms code. Please wait..&nbsp;&nbsp;<img src="/support/img_rp/loader_green_small_new.gif">';

    M.AJAX.request({
        target: '/credit-card-new',
        query: s,
        method: 'POST',
        onSuccess: function (res) {
            if (res.match(/^error_sms\:/i) != null) {
                res = res.replace('error_sms:', '');
                M.byId("msg-panel").style.display = "none";
                //M.byId("subtn").style.visibility="hidden";        
                //M.byId("btn_tr").style.display="none";        
                M.byId("error_msg").innerHTML = "<b>Error</b>: " + res;
                M.byId("error_msg").className = "msg-war";

            } else if (res.match(/^otp_true_again_verify\:/i) != null) {
                if (otp_popup == 1) {
                    $('#pageOverlay').fadeOut('slow', function () {
                        $('#itemWrapper').fadeOut('slow', function () {
                            M.byId('itemOverlay').innerHTML = "";
                        })
                    })
                    otp_popup = null;
                    submitCreditCardApplication();
                }
                // 12-03-2014
            } else {
                $('#pageOverlay').fadeOut('slow', function () {
                    $('#itemWrapper').fadeOut('slow', function () {
                        M.byId('itemOverlay').innerHTML = "";
                    })
                })
            }
        },
        onFailed: function (msg) {
            var l = M.byId('error_msg');

        }
    });
}

function finishConfirmMobileNumber(res) {
    res = M.trim(res);
    if (res.match(/^Error\:/i) == null) {
        if (sendCodeMobileCount > 3) {
            finishSearchCreditCardSubmitTest(res);
        } else {
            var POSTACT = M.byId("mobile_verified_input");
            M.byId("error_msg").innerHTML = '';
            M.byId("error_msg").className = '';
            M.byId('mobileNo').readOnly = true;
            M.byId('code_box').style.display = '';
            M.byId('code_TR').style.display = '';
            M.byId('code_box').innerHTML = '&nbsp;&nbsp;<input type="text" onkeydown="return M.digit(event);" name="mobile_verification_code" id="mobile_verification_code" maxlength="6" onkeydown="return M.digit(event);" class="w50" />';
            M.byId('verify_btn').innerHTML = '&nbsp;&nbsp;<a class="btn_new btn-cyan" href="javascript:verifyMobileCode();">GO</a>&nbsp;&nbsp;<a id="mobile_resend_btn" class="btn_new btn-cyan"  href="javascript:resendMobileVerificationCode();">RESEND</a>';
            //POSTACT.innerHTML='<img src="/support/img_rp/correct_new_medium.png">&nbsp;'+res;
        }
    } else {
        var new_msg = res.split("Error:");
        var mp = M.byId('error_msg');
        mp.style.color = 'red';
        mp.innerHTML = new_msg[1];
        M.byId("error_msg").className = 'msg-war';
    }
}

function resendMobileVerificationCode() {
    M.byId("msg-panel").style.display = "none";
    M.byId('mobileNo').style.borderColor = C[8];
    if (M.byId('mobileNo').value == '') {
        M.byId('mobileNo').style.borderColor = "red";
        return;
    }

    if (!M.isMobile(M.byId('mobileNo').value.toString())) {
        M.byId('mobileNo').style.borderColor = C[5];
        return;
    }
    M.byId('mobile_verification_code').style.borderColor = C[8];
    M.byId('mobile_verification_code').value = '';

    s = "page=resendmobilecode";
    s += "&mobile=" + M.byId('mobileNo').value;
    M.byId("error_msg").innerHTML = '';
    M.byId("error_msg").className = 'MessageContainer';
    M.byId("error_msg").innerHTML = 'Sending verification code&nbsp;<img src="/support/img_rp/loader_green_small_new.gif">';
    M.AJAX.request({
        target: '/credit-card-new',
        query: s,
        method: 'POST',
        onSuccess: finishResendMobileCodeWithData,
        onFailed: function (msg) {
            var l = M.byId('error_msg');
        }
    });
}

function finishResendMobileCodeWithData(res) {
    res = M.trim(res);
    if (res.match(/^Error\:/i) == null) {
        sendCodeMobileCount = sendCodeMobileCount + 1;
        if (sendCodeMobileCount > 3) {
            M.byId('mobile_resend_btn').style.display = 'none';
            M.byId("error_msg").innerHTML = '';
            M.byId("error_msg").innerHTML = '&nbsp;' + res;
        } else {
            M.byId("error_msg").innerHTML = '';
            M.byId("error_msg").className = 'MessageContainer';
            M.byId("error_msg").innerHTML = '<img src="/support/img_rp/correct_new_medium.png">&nbsp;' + res;
        }
    } else {
        var new_msg = res.split("Error:");
        var mp = M.byId('error_msg');
        mp.style.color = 'red';
        mp.innerHTML = new_msg[1];

    }
}

function submitSearchCreditCard(frm, val) {
    var data_str = '';
    for (var se in val) data_str += val[se] + "|";
    var checksum = rstr2hex(rstr_md5(data_str));

    var s = 'page=searchcreditcard&client_checksum=' + checksum; for (var se in val) s += "&" + se + "=" + val[se];
    M.AJAX.request({
        target: '/credit-card-new',
        query: s,
        method: 'POST',
        postmsg: M.byId('postmsg'),
        onSuccess: finishSearchCreditCardSubmitTest,
        onFailed: function (msg) {
            var l = M.byId('postmsg');
            l.className = "req";
            l.innerHTML = msg;
        }
    });
}

function finishSearchCreditCardSubmitTest(res) {
    res = M.trim(res);
    //alert(res);
    //return false;
    var basic_info_tab_show_flg = true;
    if (M.byId("loader_scb") != undefined) {
        M.byId('loader_scb').style.display = 'none';
    }
    // 12-03-2014
    if (res.match(/^otp_true_again_verify\:/i) != null) {
        if (otp_popup == 1) {
            $('#pageOverlay').fadeOut('slow', function () {
                $('#itemWrapper').fadeOut('slow', function () {
                    M.byId('itemOverlay').innerHTML = "";
                })
            })
            otp_popup = null;
            submitCreditCardApplication();
        }
        // 12-03-2014
    } else if (res.match(/^success\:/i) != null) {
        res = res.replace('success:', '');
        //M.byId('mobile_verify').innerHTML = res;
        M.byId('cities').disabled = true;
        M.byId('dateOfBirth').disabled = true;
        M.byId('employmentType').disabled = true;
        M.byId('grossincome').disabled = true;
        M.byId('emailid').disabled = true;
        M.byId('mobile').disabled = true;
        if (M.byId('recaptcha_response_field') != undefined) {
            M.byId('recaptcha_response_field').disabled = true;
        }
        if (M.byId('salarybank') != undefined) {
            M.byId('salarybank').disabled = true;
        }
        if (M.byId('scb_credit_card_yes') != undefined) {
            M.byId('scb_credit_card_yes').disabled = true;
        }
        if (M.byId('scb_credit_card_no') != undefined) {
            M.byId('scb_credit_card_no').disabled = true;
        }
        //M.byId("subtn").style.visibility="hidden";        
        //M.byId("btn_tr").style.display="none";        
        M.byId("msg-panel").style.display = "none";
        if (M.byId("error_msg") != undefined) {
            M.byId("error_msg").innerHTML = "";
        }

    } else if (res.match(/^error_sms\:/i) != null) {
        res = res.replace('error_sms:', '');
        M.byId("msg-panel").style.display = "none";
        //M.byId("subtn").style.visibility="hidden";        
        //M.byId("btn_tr").style.display="none";        
        M.byId("error_msg").innerHTML = "<b>Error</b>: " + res;
        M.byId("error_msg").className = "msg-war";
    } else if (res.match(/^error\:/i) == null) {
        if (res.match(/^sales_done\:/i) != null) {
            basic_info_tab_show_flg = false;
            res = res.replace('sales_done:', '');
        }
        ContentHeight = M.byId('Accordion0Content').offsetHeight;
        if (browserver == 'MSIE6' || browserver == 'MSIE') {
            $('#Accordion0Content').fadeOut('slow', function () {
                // Animation complete
                M.byId('msg-panel').style.display = 'none';
                if (M.byId('captcha_tr') != undefined) {
                    M.byId('captcha_tr').deleteCell(1);
                    M.byId('captcha_tr').style.display = 'none';
                }
                if (M.byId('cities') != undefined) {
                    M.byId('cities').disabled = false;
                    M.byId('cities').style.borderColor = C[0];
                }
                if (M.byId('dateOfBirth') != undefined) {
                    M.byId('dateOfBirth').disabled = false;
                    M.byId('dateOfBirth').style.borderColor = C[0];
                }
                if (M.byId('employmentType') != undefined) {
                    M.byId('employmentType').disabled = false;
                    M.byId('employmentType').style.borderColor = C[8];
                }
                if (M.byId('grossincome') != undefined) {
                    M.byId('grossincome').disabled = false;
                    M.byId('grossincome').style.borderColor = C[8];
                }
                if (M.byId('emailid') != undefined) {
                    M.byId('emailid').disabled = false;
                    M.byId('emailid').style.borderColor = C[0];
                }
                if (M.byId('mobile') != undefined) {
                    M.byId('mobile').disabled = false;
                    M.byId('mobile').style.borderColor = C[0];
                }
                if (M.byId('salarybank') != undefined) {
                    M.byId('salarybank').style.borderColor = C[8];
                }
                if (M.byId('scb_credit_card_yes') != undefined) {
                    M.byId('scb_credit_card_yes').disabled = false;
                }
                if (M.byId('scb_credit_card_no') != undefined) {
                    M.byId('scb_credit_card_no').disabled = false;
                }
                M.byId("subtn").style.visibility = "";
                M.byId("btn_tr").style.display = "";
                M.byId("loader_scb").style.display = "none";
                if (M.byId('mobile_verify') != undefined) {
                    M.byId('mobile_verify').innerHTML = '';
                }
            });
            //$("#Accordion0Content").animate({filter: alpha(opacity = 0),'height':'0px'},1000);
        } else {
            $("#Accordion0Content").animate({ opacity: '0', 'height': '0px' }, 1000);
        }
        //var res_new = res.split("fb_msg:");
        var res_new = res.split("_*_");
        if (res_new[1] != undefined) {
            var otp_html = res_new[1];
            M.byId('itemOverlay').innerHTML = otp_html;
            $('#pageOverlay').fadeIn('slow', function () {
                $('#itemWrapper').fadeIn('slow', function () {
                })
            })
        }
        res = res_new[0];
		/*if(res_new[1]!=undefined) {
			res = res_new[1];
			$("#form_1").html("");
		} else {
			$("#heading1").removeClass('dontshow');
			$("#heading1").addClass('showpanel');
		}*/
        $("#form_panel").html(res);
        //var offset = parseInt(M.byId('Accordion1Table').offsetHeight) + 10;
        var offset = $("#sub_form_1").offsetHeight;
        //alert(offset);
        if (basic_info_tab_show_flg) {
            $("#heading1").removeClass('dontshow');
            $("#heading1").addClass('showpanel');
        }
        if (browserver == 'MSIE6' || browserver == 'MSIE') {
            $('#Accordion1Content').fadeIn('slow', function () {
                M.byId('heading1').onclick = function () { animateCard(); };
                //M.byId('heading1').setAttribute('onclick','animateCard()');
            });
            //$("#Accordion0Content").animate({filter: alpha(opacity = 0),'height':'0px'},1000);
        } else {
            $("#Accordion1Content").animate({ 'height': offset + 'px' }, 1001, function () {

                if (M.byId('Accordion0Content').style.display == 'block') {
                    M.byId('Accordion0Content').style.display = 'none';
                    M.byId('heading1').setAttribute('onclick', 'animateCard()');
                    M.byId('msg-panel').style.display = 'none';
                    if (M.byId('captcha_tr') != undefined) {
                        M.byId('captcha_tr').innerHTML = '<td colspan="2"></td>';
                    }
                    if (M.byId('cities') != undefined) {
                        M.byId('cities').disabled = false;
                        M.byId('cities').style.borderColor = C[0];
                    }
                    if (M.byId('dateOfBirth') != undefined) {
                        M.byId('dateOfBirth').disabled = false;
                        M.byId('dateOfBirth').style.borderColor = C[0];
                    }
                    if (M.byId('employmentType') != undefined) {
                        M.byId('employmentType').disabled = false;
                        M.byId('employmentType').style.borderColor = C[8];
                    }
                    if (M.byId('grossincome') != undefined) {
                        M.byId('grossincome').disabled = false;
                        M.byId('grossincome').style.borderColor = C[8];
                    }
                    if (M.byId('emailid') != undefined) {
                        M.byId('emailid').disabled = false;
                        M.byId('emailid').style.borderColor = C[0];
                    }
                    if (M.byId('mobile') != undefined) {
                        M.byId('mobile').disabled = false;
                        M.byId('mobile').style.borderColor = C[0];
                    }
                    if (M.byId('salarybank') != undefined) {
                        M.byId('salarybank').style.borderColor = C[8];
                    }
                    if (M.byId('scb_credit_card_yes') != undefined) {
                        M.byId('scb_credit_card_yes').disabled = false;
                    }
                    if (M.byId('scb_credit_card_no') != undefined) {
                        M.byId('scb_credit_card_no').disabled = false;
                    }
                    M.byId("subtn").style.visibility = "";
                    M.byId("btn_tr").style.display = "";
                    M.byId('loader_scb').style.display = 'none';
                    if (M.byId('mobile_verify') != undefined) {
                        M.byId('mobile_verify').innerHTML = '';
                    }
                } else {

                }
                $("#Accordion1Content").css("overflow", "hidden")
            });
        }
        if (M.byId('employer') != undefined) {
            getCompanyList(1);
            //var aci=$("#employer").autocomplete({width:300, zIndex: 9999, delimiter:/(,|;)\s*/, lookup:E, minChars:2});
            //if(browserver == 'MSIE6') { $('.autocomplete-w1').bgiframe(); }
        }

        if (M.byId('txt_addon_dob') != undefined) {
            $(function () { $("#txt_addon_dob").datepick({ changeMonth: true, changeYear: true, yearRange: '1997:1930', minDate: new Date(1930, 1 - 1, 1), maxDate: new Date(1997, 4, 14) }); });
        }
        //all autosave function
        //setInterval(function(){autoSave()}, 45000);
    } else {
        var new_res = res.split("_*_");
        var error_type = null;
        var error_msg = '';
        if (new_res[1] != undefined) {
            error_type = new_res[1];
            error_msg = new_res[0];
        } else {
            error_msg = res;
        }

        if (parseInt(error_type) == 1) {
            //ineligible because of low income or age
        } else if (parseInt(error_type) == 2) {
            //ineligible because of duplicate mobile
        } else if (parseInt(error_type) == 3) {
            //ineligible because age is not in correct format
        } else if (parseInt(error_type) == 4) {
            //ineligible because city not listed
        } else if (parseInt(error_type) == 5) {
            //ineligible because captcha not match
        } else if (parseInt(error_type) == 6) {
            //ineligible because session expire 
        }
        if (M.byId("subtn") != undefined) {
            M.byId("subtn").style.visibility = "";
        }
        if (M.byId("btn_tr") != undefined) {
            M.byId("btn_tr").style.display = "";
        }
        M.byId("msg-panel").style.display = "";
        var mp = M.byId('msg-panel');
        mp.className = "msg-war";
        M.byTag("b", mp)[0].innerHTML = "Error: ";
        //M.byTag("em", mp)[0].innerHTML=res.replace(/^error\:/i, '');
        M.byTag("em", mp)[0].innerHTML = error_msg.replace(/^error\:/i, '');
        if (M.byId("error_msg") != undefined) {
            M.byId("error_msg").innerHTML = "";
        }
    }
}

function animateCard() {


    if (browserver == 'MSIE6' || browserver == 'MSIE') {
        $('#Accordion1Content').fadeOut('slow', function () {
            $("#heading1").removeClass('showpanel');
            $("#heading1").addClass('dontshow');
        });
        $('#Accordion0Content').fadeIn('slow', function () {
            M.byId('Accordion1Content').style.display = 'none';
            M.byId('heading1').removeAttribute('onclick', 0);
            var offset = M.byId("sub_form_1").offsetHeight;

        });

    } else {
        $("#Accordion1Content").animate({ opacity: '0', 'height': '0px' }, 1000);
        $("#heading1").removeClass('showpanel');
        $("#heading1").addClass('dontshow');

        $("#Accordion0Content").animate({ opacity: '1', 'height': ContentHeight + 'px' }, 1001, function () {
            if (M.byId('Accordion1Content').style.display == 'block') {
                M.byId('Accordion1Content').style.display = 'none';
                M.byId('heading1').removeAttribute('onclick', 0);
                var offset = M.byId("sub_form_1").offsetHeight;
                //M.byId('Accordion0Content').style.height = offset+'px';
                //alert(M.byId("sub_form_1").offsetHeight);
            }
            M.byId('Accordion0Content').style.height = 'auto';
        });
    }
}

function showDocumentLabel_NEW(sal_typ) {
    if (sal_typ == undefined) sal_typ = 1;
    if (M.byId('income_proof').value > 0) {
        s = "page=documentlabel";
        M.AJAX.request({
            target: '/credit-card-new',
            query: s,
            method: 'POST',
            onSuccess: function (msg) {
                //alert(msg);
                var document_array = msg.split(",");
                for (var i = 0; i < (document_array.length - 1); i++) {
                    var document_new = document_array[i].split("-");
                    if (M.byId('income_proof').value == document_new[0]) {
                        M.byId('document').innerHTML = document_new[1];
                    }
                }
            },
            onFailed: function (msg) {
                //var l=M.byId('msg-error-email');

            }
        });
    } else {
        if (sal_typ == 1 || sal_typ == 4 || sal_typ == 5)
            M.byId('document').innerHTML = 'Net monthly income as per payslip';
        if (sal_typ == 2 || sal_typ == 3)
            M.byId('document').innerHTML = 'Credit card limit';
    }
}

function finishSearchCreditCardNewApply(res) {
    //alert(res);
    if (res.match(/^error\:/i) == null) {
        var offset = '';
        if (browserver == 'MSIE6' || browserver == 'MSIE') {
            $('#Accordion1Content').fadeOut('slow', function () {
                $("#form_panel").html(res);
                offset = $("#sub_form_1").offset();
            });
            $('#Accordion1Content').fadeIn('slow', function () {
                M.byId('Accordion1Content').style.display = 'block';
                if (M.byId('employer') != undefined) {
                    var aci = $("#employer").autocomplete({ width: 300, zIndex: 9999, delimiter: /(,|;)\s*/, lookup: E, minChars: 2 });
                    if (browserver == 'MSIE6') { $('.autocomplete-w1').bgiframe(); }
                }
            });
        } else {
            $("#Accordion1Content").animate({ opacity: '0', 'height': '0px' }, 500, function () {
                $("#form_panel").html(res);
                offset = $("#sub_form_1").offset();
                $("#Accordion1Content").animate({ 'height': offset + 'px' }, 2000, function () {
                    //M.byId('Accordion1Content').style.display = 'block';
                    if (M.byId('employer') != undefined) {
                        var aci = $("#employer").autocomplete({ width: 300, zIndex: 9999, delimiter: /(,|;)\s*/, lookup: E, minChars: 2 });
                        if (browserver == 'MSIE6') { $('.autocomplete-w1').bgiframe(); }
                    }
                });
            });

        }

    } else {
        M.byId("msg-panel-3").style.display = "";
        var mp = M.byId('msg-panel-3');
        mp.className = "msg-war";
        M.byTag("b", mp)[0].innerHTML = "Error: ";
        M.byTag("em", mp)[0].innerHTML = res.replace(/^error\:/i, '');
        if (M.byId("error_msg") != undefined) {
            M.byId("error_msg").innerHTML = "";
        }
    }
}

function getSalaryBank() {
    if (M.byId('employmentType').value == 4) {
        M.byId('salarybank').disabled = false;
    } else {
        M.byId('salarybank').disabled = true;
    }
}

function getPickupTime(pickupdate) {
    M.byId('chqPKTime').disabled = false;
    M.byId('chqPKTime').innerHTML = '';
    var elem = M.byId('chqPKTime');
    var optionHtml = '';
    var time = 0;
    if (M.byId('chqPKTime').selectedIndex > 0) {
        var time = M.byId('chqPKTime').selectedIndex;
    }
    var CurrentDate = (M.dateDiffDays(pickupdate));
    var dateNew = new Date();
    var hour = dateNew.getHours();
    if (CurrentDate == 0) {
        if (hour >= 9 && hour < 11) {
            elem.options[elem.options.length] = new Option('Select', 0, true, false);
            elem.options[elem.options.length] = new Option('9am to 11am', 1, false, false);
            elem.options[elem.options.length] = new Option('11am to 1pm', 2, false, false);
            elem.options[elem.options.length] = new Option('1pm to 3pm', 3, false, false);
            elem.options[elem.options.length] = new Option('3pm to 6pm', 4, false, false);
        } else if (hour >= 11 && hour < 13) {
            elem.options[elem.options.length] = new Option('Select', 0, true, false);
            elem.options[elem.options.length] = new Option('11am to 1pm', 2, false, false);
            elem.options[elem.options.length] = new Option('1pm to 3pm', 3, false, false);
            elem.options[elem.options.length] = new Option('3pm to 6pm', 4, false, false);
        } else if (hour >= 13 && hour < 15) {
            elem.options[elem.options.length] = new Option('Select', 0, true, false);
            elem.options[elem.options.length] = new Option('1pm to 3pm', 3, false, false);
            elem.options[elem.options.length] = new Option('3pm to 6pm', 4, false, false);
        } else if (hour >= 15 && hour <= 17) {
            elem.options[elem.options.length] = new Option('Select', 0, true, false);
            elem.options[elem.options.length] = new Option('3pm to 6pm', 4, false, false);
        } else {
            elem.options[elem.options.length] = new Option('Select', 0, true, false);
            elem.options[elem.options.length] = new Option('9am to 11am', 1, false, false);
            elem.options[elem.options.length] = new Option('11am to 1pm', 2, false, false);
            elem.options[elem.options.length] = new Option('1pm to 3pm', 3, false, false);
            elem.options[elem.options.length] = new Option('3pm to 6pm', 4, false, false);
        }
    } else {
        elem.options[elem.options.length] = new Option('Select', 0, true, false);
        elem.options[elem.options.length] = new Option('9am to 11am', 1, false, false);
        elem.options[elem.options.length] = new Option('11am to 1pm', 2, false, false);
        elem.options[elem.options.length] = new Option('1pm to 3pm', 3, false, false);
        elem.options[elem.options.length] = new Option('3pm to 6pm', 4, false, false);
    }
    M.byId('chqPKTime').selectedIndex = time;
}

function openPopup(src) {
    $('#pageOverlay').fadeIn('slow', function () {
        if (browserver == 'MSIE' || browserver == 'MSIE6') { $('#itemWrapper').bgiframe(); }

        M.byId('itemWrapper').style.display = 'block';
        M.byId('itemOverlay').style.display = 'block';
        if (src.id == 'eligibility') {
            M.byId('itemOverlay').innerHTML = M.byId('eligibility_content').innerHTML;
        } else if (src.id == 'payment') {
            M.byId('itemOverlay').innerHTML = M.byId('payment_content').innerHTML;
        } else if (src.id == 'ezone') {
            M.byId('itemOverlay').innerHTML = M.byId('term-ezone').innerHTML;
        } else if (src.id == 'flipkart') {
            M.byId('itemOverlay').innerHTML = M.byId('term-flipkart').innerHTML;
        } else if (src == 'savingaccount') { //Add new condition | 21-11-2013 | Sachendra | Show light box in last page| REVIEWED BY Ramesh//
            M.byId('itemOverlay').innerHTML = M.byId('saving_account').innerHTML;
        } else if (src.id == 'specialoffer-tnc') { //Add new condition | 18-02-2014 | Ramesh Maurya | Show light box in last page term credit card
            M.byId('itemOverlay').innerHTML = M.byId('term-specialoffer').innerHTML;
        } else if (src.id == 'myntra') {
            M.byId('itemOverlay').innerHTML = M.byId('term-myntra').innerHTML;
        } else if (src.id == 'jabong') {
            M.byId('itemOverlay').innerHTML = M.byId('term-jabong').innerHTML;
        } else if (src.id == 'goibibo') {
            M.byId('itemOverlay').innerHTML = M.byId('term-goibibo').innerHTML;
        } else {
            M.byId('itemOverlay').innerHTML = M.byId('faq_content').innerHTML;
        }
    });

}

function getNewCaptcha() {
    if (M.byId('recaptcha_response_field') != undefined) {
        M.byId('captch_div').innerHTML = '<img src="/support/img_rp/loader_green.gif">';
        s = "page=newcaptcha";
        M.AJAX.request({
            target: '/credit-card-new',
            query: s,
            method: 'POST',
            onSuccess: function (msg) {
                M.byId('captch_div').innerHTML = msg;
            },
            onFailed: function (msg) {
                //var l=M.byId('msg-error-email');

            }
        });
    }
}

function submitAppPreCheck_new(frm) {
    var r = (frm['status_view_app_code'] != undefined && frm['status_view_app_code'].value != "" && frm['status_view_app_code'].value.match(/^[#|\!|I|T|H]+(CL|HL|PL|CI|HI|IP|RI|MI|EL|CC)+[A-Z0-9]{5,20}/) != null);
    frm['status_view_app_code'].style.borderColor = "#aaaaaa";
    if (!r) {
        frm['status_view_app_code'].style.borderColor = C[5]
    }
    if (M.trim(frm['dob'].value) == null || !M.isDate(frm['dob'].value.toString())) {
        frm['dob'].style.borderColor = C[5];
        r = false;
    } else if (M.dateDiffDays(frm['dob'].value) > 0 && M.isDate(frm['dob'].value.toString())) {
        frm['dob'].style.borderColor = C[5];
        r = false;
    } else {
        frm['dob'].style.borderColor = '#aaaaaa';
    }
    if (M.trim(frm['mobile'].value) == '') {
        frm['mobile'].style.borderColor = C[5];
        r = false;
    } else if (M.isMobile(frm['mobile'].value.toString()) == null) {
        frm['mobile'].style.borderColor = C[5];
        r = false;
    } else {
        frm['mobile'].style.borderColor = '#aaaaaa';
    }
    return r;
}

function submitAppPreCheck_noappcode(frm) {
    var r = true;
    if (M.trim(frm['dob'].value) == null || !M.isDate(frm['dob'].value.toString())) {
        frm['dob'].style.borderColor = C[5];
        r = false;
    } else if (M.dateDiffDays(frm['dob'].value) > 0 && M.isDate(frm['dob'].value.toString())) {
        frm['dob'].style.borderColor = C[5];
        r = false;
    } else {
        frm['dob'].style.borderColor = '#aaaaaa';
    }
    if (M.trim(frm['mobile'].value) == '') {
        frm['mobile'].style.borderColor = C[5];
        r = false;
    } else if (M.isMobile(frm['mobile'].value.toString()) == null) {
        frm['mobile'].style.borderColor = C[5];
        r = false;
    } else {
        frm['mobile'].style.borderColor = '#aaaaaa';
    }
    return r;
}

function autoSave() {
    var frm = M.getForm('creditcardappform');
    if (frm == null) {
        return false;
    } else {
        var val = {};

        if (!M.isSpecialChars(frm['fname'].value.toString())) {
            val['fname'] = frm['fname'].value;
        }
        if (!M.isSpecialChars(frm['mname'].value.toString())) {
            val['mname'] = frm['mname'].value;
        }
        if (!M.isSpecialChars(frm['lname'].value.toString())) {
            val['lname'] = frm['lname'].value;
        }
        if (!M.isSpecialCharsWithN(frm['txt_father_name'].value.toString())) {
            val['txt_father_name'] = frm['txt_father_name'].value;
        }
        if (M.byId('bobi') != undefined && M.byId('bobi').value != '') {
            val['bobi'] = M.byId('dobi').value;
        }
        if (M.byId('gndr') != undefined && M.byId('gndr').value > 0) {
            val['gndr'] = M.byId('gndr').value;
        }
        if (M.byId('qualification') != undefined) {
            val['qualification'] = M.byId('qualification').value;
        }
        if (M.byId('addressL1') != undefined && M.byId('addressL1').value != '') {
            val['addressL1'] = M.byId('addressL1').value;
        }
        if (M.byId('addressL2') != undefined && M.byId('addressL2').value != '') {
            val['addressL2'] = M.byId('addressL2').value;
        }
        if (M.byId('city_id') != undefined) {
            val['city_id'] = M.byId('city_id').value;
        }
        if (M.byId('pincode') != undefined && M.byId('pincode').value > 0) {
            val['pincode'] = M.byId('pincode').value;
        }
        //if(M.byId('employer')!=undefined){ 
        if (M.byId('employer') != undefined && M.byId('employmentType') != undefined && M.byId('employmentType') == 1) {
            if (M.byId('employer').value != '' && M.byId('employer').value != 'Type Slowly for autofill') {
                val['employer'] = M.byId('employer').value;
            }
        }
        if (M.byId('designation') != undefined) {
            if (M.byId('designation').value > -1) {
                val['designation'] = M.byId('designation').value;
            }
        }
        if (M.byId('company_type') != undefined) {
            if (M.byId('company_type').value > 0) {
                val['company_type'] = M.byId('company_type').value;
            }
        }
        if (M.byId('txt_landmark') != undefined && M.byId('txt_landmark').value != '') {
            val['txt_landmark'] = M.byId('txt_landmark').value;
        }

        if (M.byId('employmentType') != undefined) {
            if (M.byId('employmentType').value > 0) {
                val['employmentType'] = M.byId('employmentType').value;
            }
        }
        if (M.byId('salarybank') != undefined) {
            if (M.byId('salarybank').disabled == false && M.byId('salarybank').value > 0) {
                val['salarybank'] = M.byId('salarybank').value;
            }
        }
        if (M.byId('grossincome') != undefined) {
            if (M.unformatMoney(M.byId('grossincome').value) > 0) {
                val['grossincome'] = M.unformatMoney(M.byId('grossincome').value);
            }
        }
        if (M.byId('kyc_doc_flg_yes') != undefined && M.byId('kyc_doc_flg_no') != undefined) {
            if (M.byId('kyc_doc_flg_yes').checked == true) {
                val['kyc_doc_flg'] = "Y";
            } else {
                val['kyc_doc_flg'] = "N";
            }
        }
        if (M.byId('income_proof') != undefined && M.byId('income_proof').value > 0) {
            val['income_proof'] = M.byId('income_proof').value;
        }
		/*
		if(M.byId('panCardLater').checked == false) {
			var panNumber = M.byId('panCard').value;
			if(panNumber != "") {
				if(M.isPAN(panNumber)) {
					val['panCard'] = M.byId('panCard').value;
				} else {
					val['panCard'] = "";
				}
			} else {
				val['panCard'] = "";
			}
        } else {
            val['panCard'] = "";
        }
		*/
        if (M.byId('panCard') != undefined) {
            if (M.byId('panCard').value != '' && M.isPAN(M.byId('panCard').value)) {
                val['panCard'] = M.byId('panCard').value;
            }
        }
        if (M.byId('document_value') != undefined) {
            if (M.unformatMoney(M.byId('document_value').value) > 0) {
                val['document_value'] = M.unformatMoney(M.byId('document_value').value);
            }
        }
        if (M.byId('existing_customer_yes') != undefined && M.byId('existing_customer_yes').checked == true) {
            val['existing_customer'] = "Y";
            val['relationship_type'] = "";
            var checkboxLength = document.getElementsByName('relationship_type').length;
            var option_values = [];
            var check_least_one = 0;
            for (var i = 0; i < checkboxLength; i++) {
                if (M.byId('relationship_type_' + i).checked == true) {
                    option_values.push(M.byId('relationship_type_' + i).value);
                }
            }
            val['relationship_type'] = option_values;

        } else {
            val['existing_customer'] = "N";
            val['relationship_type'] = "";
        }

        var s = 'page=autosavepage';
        for (var se in val) s += "&" + se + "=" + val[se];
        M.AJAX.request({
            target: '/credit-card-new',
            query: s,
            method: 'POST',
            onSuccess: function (msg) {
                if (msg.match(/^Error\:/i) == null) {

                } else {

                }
            },
            onFailed: function (msg) {

            }
        });
        return false;
    }
}

document.createElement("header");
document.createElement("section");
document.createElement("aside");
document.createElement("footer");

$(function () {
    selectCode();
    accordionCode();
    $('.lyteBoxOverlay').css('opacity', '0.7');
    var hrf = (window.location.href).split('#');
    if (hrf.length == 2) {
        var jumpToCard1 = hrf[1];
        var jumpToCard2 = ['yatraPlatinum', 'manhattanPlatinum', 'superValueTitanium', 'platinumRewards', 'innerCirclePlatinum'];
        var jumpToCard3;

        for (var i = 0; i < jumpToCard2.length; i++) {
            if (jumpToCard1 == jumpToCard2[i]) {
                jumpToCard3 = i + 1;
                $('.contentWrapper').find('.card' + jumpToCard3).find('.applyNow').click();
                break;
            }
        }
    }
});

function selectCode() {
    $("select").each(function () {
        $(this).children("option").each(function () {
            if ($(this).attr("selected")) {
                $(this).parent().prev().html($(this).html());
            }
        });
    });
    $("select").change(function () {
        $(this).prev().html($(this).find("option:selected").text());
    });
}

function accordionCode() {
    var rotateCounter = 0;
    $('.contentWrapper .accordionHeader .applyNow').click(function () {
        if (!$('.contentWrapper *').is(':animated')) {
            $("html,body").animate({ scrollTop: 150 }, 800);
            $('.close').hide().delay(3000).fadeIn('slow');

            $('#accContWrap').css('overflow', 'visible');
            $(this).parents('.accordionHeader').find('.accShadow').fadeOut();
            $(this).parents('.accordionHeader').find('aside').animate({ 'margin-right': '0', 'opacity': '0' }, 300, function () {
                $(this).removeAttr('style').hide();
            });
            $('.applyNow').animate({ 'right': '10px', 'opacity': '0' }, 300, function () {
                $(this).removeAttr('style').hide();
            });

            $('header img').eq(2).fadeOut(1200);
            ind = $(this).parents('.accordionHeader').index('.accordionHeader');
            aniTop = (230 * ind) * (-1);
            $('.contentWrapperScroller').animate({ 'margin-top': aniTop + 'px' }, 500);

            $(this).parents('.accordionHeader').next().addClass('active').delay(600).slideDown(function () {

                $('.contentWrapper').animate({ 'height': '763px' }, 500);

                var leftContId = ($(this).parents('.contentWrapperScroller').find('.active').prev().attr('class')).split('accordionHeader card')[1];
                $('#accContWrap .leftCont').css({ 'margin-top': '-30px', 'opacity': 0 }).find('#card' + leftContId + 'Detail').show().siblings().removeAttr('style');
                $('#accContWrap .rightCont').css({ 'margin-top': '-50px', 'opacity': 0 });
                $('#accContWrap').fadeIn(function () {
                    $('#accContWrap .leftCont').delay(100).animate({ 'margin-top': '0px', 'opacity': 1 }, 300);
                    $('#accContWrap .rightCont').delay(300).animate({ 'margin-top': '0px', 'opacity': 1 }, 600);
                    $('.dummyBox').css('left', '0px').animate({ 'left': '400px' }, 400);
                    //$('.moreCards').removeClass('activeCards').removeAttr('style');

                    innerImg = $('.active').prev().find('.detailActivePage');
                    for (var i = 0; i < innerImg.find('img').length; i++) {
                        //innerImg.find('img').eq(i).show().css('opacity','0').delay(i*300).animate({'opacity':'1', 'bottom':'-3px'},1200);
                        innerImg.find('img').eq(i).delay(i * 300).fadeIn(1200);
                    }

                    aniThs = $('.active').prev().find('.card');

                    if ('v' == '\v') {
                        aniThsIE = '.' + (($('.active').prev().attr('class')).split('accordionHeader ')[1]) + ' .card';
                        aniThsIE1 = (($('.active').prev().attr('class')).split('accordionHeader ')[1]).split('card')[1];
                        aniThsIE2 = 'images/card' + aniThsIE1 + '' + aniThsIE1 + '.png';
                        $(aniThsIE).fadeOut(function () {
                            //alert(aniThsIE2)
                            $(aniThsIE).attr('src', aniThsIE2).css({ 'margin-left': '20px', 'margin-top': '10px' });
                            $(aniThsIE).fadeIn();
                        });
                    }
                    else {
                        rotateInterval = setInterval(function () {
                            if (rotateCounter < 50) {
                                val = rotateCounter / 2;
                                marT = -(val * 2);
                                if ('v' == '\v') {
                                    //$(aniThsIE).rotate({angle:val});
                                    //marT = marT+36;
                                    //$(aniThsIE).css({'margin-top':marT+'px', 'margin-left':'80px'});
                                }
                                else {
                                    aniThs.css({ 'margin-top': marT + 'px', 'transform': 'rotate(' + val + 'deg)', '-webkit-transform': 'rotate(' + val + 'deg)', '-moz-transform': 'rotate(' + val + 'deg)', '-o-transform': 'rotate(' + val + 'deg)', '-ms-transform': 'rotate(' + val + 'deg)' });
                                }
                                rotateCounter++;
                            }
                            else if (rotateCounter == 50) {
                                aniThs.animate({ 'margin-top': '-39px' }, 100);
                                clearInterval(rotateInterval);
                            }
                        }, 10);
                    }
                });
            });
        }
    });

    $('.accordionFooter .more').click(function () {
        if ($('.moreCards').hasClass('activeCards')) {
            //$('.moreCards').css('overflow','hidden').removeClass('activeCards').slideUp();
            //$('.contentWrapper').delay(200).animate({'height':'850px'})
            $(this).removeClass('activeMoreBtn');
            $('.moreCards').removeClass('activeCards').hide();
            $('.contentWrapper').delay(200).css({ 'height': '850px' })
        }
        else {
            //$('.moreCards').addClass('activeCards').slideDown().css('overflow','visible');
            //$('.contentWrapper').animate({'height':'1300px'});
            $(this).addClass('activeMoreBtn');
            $("html,body").animate({ scrollTop: 890 }, 800);
            $('.moreCards').addClass('activeCards').show();
            $('.contentWrapper').css({ 'height': '1300px' });
        }
    });

    $('.contentWrapper .close').click(function () {
        if (!$('.contentWrapper *').is(':animated')) {
            $(this).fadeOut('fast');
            $("html,body").animate({ scrollTop: 0 }, 800);
            $('.active').prev().find('.detailActivePage').find('img').fadeOut(1000);
            $('#accContWrap').slideUp();
            $('.active').slideUp(function () {
                $('header img').eq(2).fadeIn(1200);
                $('.active').prev().find('.accShadow').fadeIn(1600);
                $('.contentWrapperScroller').delay(300).animate({ 'margin-top': '0px' }, 500, function () {


                    if ($('.contentWrapperScroller .moreCards').hasClass('activeCards')) {
                        $('.contentWrapper').animate({ 'height': '1300px' }, 500);
                    }
                    else {
                        $('.contentWrapper').animate({ 'height': '850px' }, 500);
                    }

                    /*
                    innerImg = $('.active').prev().find('.detailActivePage');
                    for(var i=0;i<innerImg.find('img').length; i++){
                        //innerImg.find('img').eq(i).show().css('opacity','1').delay(i*50).animate({'opacity':'0', 'bottom':'-3px'},300);
                        innerImg.find('img').eq(i).delay(i*30).fadeOut(250);
                    }*/
                    $('.active').prev().find('aside').delay(200).fadeIn();
                    $('.applyNow').delay(400).fadeIn();
                    $('.dummyBox').css('left', '0px').animate({ 'left': '400px' }, 400);

                    aniThs = $('.active').prev().find('.card');
                    if ('v' == '\v') {
                        aniThsIE = '.' + (($('.active').prev().attr('class')).split('accordionHeader ')[1]) + ' .card';
                        /*$(aniThsIE).animate({'margin-top':'30px'},1500, function(){
                            $(aniThsIE).css({'margin-top':'-30px'});
                            $(aniThsIE).removeAttr('style');
                        });*/

                        aniThsIE1 = (($('.active').prev().attr('class')).split('accordionHeader ')[1]).split('card')[1];
                        aniThsIE2 = 'images/card' + aniThsIE1 + '.png';
                        $(aniThsIE).fadeOut(function () {
                            //alert(aniThsIE2)
                            $(aniThsIE).attr('src', aniThsIE2).css({ 'margin-left': '20px', 'margin-top': '10px' });
                            $(aniThsIE).fadeIn();
                        });
                    }
                    else {
                        rotateCounter = 50;
                        rotateInterval = setInterval(function () {
                            if (rotateCounter > 0) {
                                val = rotateCounter / 2;
                                marT = -(val * 2);
                                if (marT < -40) { marT = -39 }
                                if ('v' == '\v') {
                                    //$(aniThsIE).rotate({angle:val});
                                    //$(aniThsIE).css({'margin-left':'80px'});
                                }
                                else {
                                    aniThs.css({ 'margin-top': marT + 'px', 'transform': 'rotate(' + val + 'deg)', '-webkit-transform': 'rotate(' + val + 'deg)', '-moz-transform': 'rotate(' + val + 'deg)', '-o-transform': 'rotate(' + val + 'deg)', '-ms-transform': 'rotate(' + val + 'deg)' });
                                }
                                rotateCounter--;
                            }
                            else if (rotateCounter <= 0) {
                                innerImg.find('img').removeAttr('style');
                                aniThs.removeAttr('style');
                                $('.contentWrapper .active').removeClass('active');
                                if ('v' == '\v') {
                                    $(aniThsIE).css({ 'margin-left': '40px' });
                                }
                                clearInterval(rotateInterval);

                            }
                        }, 10);
                    }
                });
            });
        }
    });

    $('.contentWrapper .proceedBt').click(function () {
        var leftContId = ($(this).parents('.contentWrapperScroller').find('.active').prev().attr('class')).split('accordionHeader card')[1];
        $('.thankyouContentWrapper').find('#thankyou_card' + leftContId).show().siblings().hide();
        var txt = $('.thankyouContentWrapper').find('#thankyou_card' + leftContId).attr('alt');
        $('.thankyouContentWrapper').find('.text3').text(txt + ' Credit Card');

        $('#wrapper').css({ 'height': '970px', 'overflow': 'hidden' }).animate({ 'height': '750px' }, 800);
        $('.thankyouContentWrapper').show().css('top', '970px').animate({ 'top': '165px' }, 800, function () {
            $('.contentWrapper .close').click();
        });
        setTimeout(function () {
            $("html,body").animate({ scrollTop: 500 }, 800);
        }, 800)
    });

    $('.thankyouContentWrapper .chooseAnotherCard').click(function () {
        $('#wrapper').css({ 'height': '750px' }).animate({ 'height': '970px' }, 800, function () {
            $('#wrapper').removeAttr('style');
        });
        $('.thankyouContentWrapper').show().css('top', '165px').animate({ 'top': '0', 'opacity': '0' }, 500, function () {
            $('.thankyouContentWrapper').removeAttr('style');
        });

    });

    $('.closeWrapper a, .lyteBoxOverlay').click(function () {
        $('.lyteBoxWrapper').fadeOut(function () {
            $('.lyteBoxOverlay').fadeOut();
        });
    });

    $('.btnShare').click(function () {
        $('.lyteBoxOverlay').fadeIn(function () {
            $('.lyteBoxWrapper').fadeIn();
            $('#shareCont').fadeIn().siblings().hide();
        });
    });

    $('.btnLike').click(function () {
        $('.lyteBoxOverlay').fadeIn(function () {
            $('.lyteBoxWrapper').fadeIn();
            $('#likeCont').fadeIn().siblings().hide();
        });
    });

    $('.btnInvite').click(function () {
        $('.lyteBoxOverlay').fadeIn(function () {
            $('.lyteBoxWrapper').fadeIn();
            $('#inviteCont').fadeIn().siblings().hide();
        });
    });

    $('.btnEligibility').click(function () {
        $('.lyteBoxOverlay').fadeIn(function () {
            $('.lyteBoxWrapper').fadeIn();
            $('#eligibility').fadeIn().siblings().hide();
        });
    });

}

function checkNumericValue(str) {
    var allValid = true;
    for (i = 0; i < str.length; i++) {
        ch = str.charAt(i);
        if (ch.match(/^[0-9 .]+$/) != null) {
            allValid = false;
        }
    }
    return allValid;
}
function checkNumericValuewithSpace(str) {
    var allValid = true;
    for (i = 0; i < str.length; i++) {
        ch = str.charAt(i);
        if (ch.match(/^[0-9.]+$/) != null) {
            allValid = false;
        }
    }
    return allValid;
}
function openPoupAlert() {
    $('#pageOverlay').fadeIn('slow', function () {
        if (browserver == 'MSIE' || browserver == 'MSIE6') { $('#itemWrapper').bgiframe(); }

        M.byId('itemWrapper').style.display = 'block';
        M.byId('itemOverlay').style.display = 'block';
        M.byId('itemOverlay').innerHTML = M.byId('alert_popup').innerHTML;

    });
}
function displayAnnualSalary(labelname, val) {
    if (val > 0) {
        var annual_salary = 0;
        var annual_sal = "Annual (" + INR + ")";
        annual_salary = 12 * val;
        annual_salary = M.formatAsMoneyStr(annual_salary.toString());
        annual_salary = annual_salary;
        annual_sal = annual_sal + " " + annual_salary;
        $("#" + labelname).html(annual_sal);
    } else {
        $("#" + labelname).html("");
    }
}
/* START | 29-Oct-2013 | Ramesh | Add new css for credit card to saving account banner */
function showHide() {
    if ($("#item_3d").attr('class') == "menutarget") {
        document.getElementById('big_small').innerHTML = '<img src="/support/img_rp/sumatra/small-banner.jpg" />';
        document.getElementById('3d').innerHTML = '<img src="/support/img_rp/sumatra/expand.png" />';
        $("#item_3d").removeClass("menutarget");
        $("#item_3d").addClass("closed");
    } else {
        //document.getElementById('item_3d').style.display = 'block';
        document.getElementById('big_small').innerHTML = '<img src="/support/img_rp/sumatra/big-banner.jpg" />';
        document.getElementById('3d').innerHTML = '<img src="/support/img_rp/sumatra/close.png" />';
        $("#item_3d").removeClass("closed");
        $("#item_3d").addClass("menutarget");
    }

}
/* END | 29-Oct-2013 | Ramesh | Add new css for credit card to saving account banner */
function openResendBox() {
    oldHtmlresndbox = M.byId("resend_box").innerHTML;
    M.byId("resend_box").innerHTML = "<font class=\"mobile_display\">Mobile No <b class=\"req\">*</b></font><input onkeydown=\"return M.digit(event)\" type=\"tel\" name=\"mobile_resend\" id=\"mobile_resend\" maxlength=\"10\" class=\"resend\">&nbsp;&nbsp;<a id=\"mobile_resend_btn\" class=\"btn-green\" style=\"padding-left:0px; padding-right:0px;\" href=\"javascript:resendMobileVerificationCodeNew();\"><img style=\"cursor: pointer; vertical-align:top;\" src=\"/support/img_rp/sumatra/confirm_resend.png\"></a>&nbsp;&nbsp;<a class=\"btn-green\" style=\"padding-left:0px; padding-right:0px;\" href=\"javascript:closeResendBox();\">Cancel</a>";
    unver_mobile = M.byId("mobileNo").value;
    M.byId("mobileNo").value = "";
}
function closeResendBox() {
    M.byId("resend_box").innerHTML = oldHtmlresndbox;
    oldHtmlresndbox = null;
    if (unver_mobile == null) {
        M.byId("mobileNo").value = M.byId("mobile_no").value;
    } else {
        M.byId("mobileNo").value = unver_mobile;
    }

}

function resendMobileVerificationCodeNew() {
    //M.byId("msg-panel").style.display="none";
    if (M.byId('mobile_resend') != undefined) {
        M.byId('mobile_resend').style.borderColor = C[8];
        if (M.byId('mobile_resend').value == '') {
            M.byId('mobile_resend').style.borderColor = C[5];
            return false;
        }
        if (!M.isMobile(M.byId('mobile_resend').value.toString())) {
            M.byId('mobile_resend').style.borderColor = C[5];
            return false;
        }
        unver_mobile = M.byId("mobileNo").value;
        M.byId("mobileNo").value = M.byId("mobile_resend").value;

        //M.byId('mobile_verification_code').style.borderColor = C[8];
        M.byId('mobile_verification_code').value = '';
    }

    q = "page=resendmobilecode";
    q += "&mobile=" + M.byId('mobileNo').value;
    M.byId("error_msg").innerHTML = '';
    M.byId("error_msg").className = 'MessageContainer';
    M.byId("error_msg").innerHTML = 'Sending verification code&nbsp;<img src="/support/img_rp/loader_green_small_new.gif">';
    M.AJAX.request({
        target: '/credit-card-new',
        query: q,
        method: 'POST',
        onSuccess: function (msg) {
            msg = M.trim(msg);
            if (msg.match(/^success\:/i) != null) {
                M.byId("error_msg").innerHTML = '';
                M.byId("error_msg").style.color = '';
                M.byId("error_msg").innerHTML = '<img src="/support/img_rp/correct_new_medium.png">&nbsp;' + msg;
                if (M.byId('new_mobile') != undefined) {
                    if (M.byId('mobile_resend') != undefined) {
                        M.byId('new_mobile').innerHTML = M.byId('mobile_resend').value;
                        M.byId('mobileNo').value = M.byId('mobile_resend').value;
                        unver_mobile = M.byId("mobileNo").value;
                        M.byId('resend_box').innerHTML = 'SMS Sent to ' + M.byId('mobileNo').value + ' ';
                        if (M.byId('mobile') != undefined) {
                            M.byId('mobile').value = M.byId('mobileNo').value;
                        }
                    }

                }


            } else if (msg.match(/^error_sms\:/i) != null) {
                var new_msg = msg.split("error_sms:");
                var mp = M.byId('error_msg');
                mp.style.color = C[5];
                mp.innerHTML = new_msg[1];
                if (M.byId("mobile_resend") != undefined) {
                    M.byId("mobile_resend").disabled = true;
                }
                if (M.byId("mobileNo") != undefined) {
                    M.byId("mobileNo").value = M.byId("mobile").value;

                }
            } else if (msg.match(/^error\:/i) != null) {
                var new_msg = msg.split("Error:");
                var mp = M.byId('error_msg');
                mp.style.color = C[5];
                mp.innerHTML = new_msg[1];
                if (M.byId("mobile_resend") != undefined) {
                    M.byId("mobile_resend").disabled = true;
                }
                if (M.byId("mobileNo") != undefined) {
                    M.byId("mobileNo").value = M.byId("mobile").value;

                }
            }
        },
        onFailed: function (msg) {
            var l = M.byId('error_msg');
        }
    });
}

//________ADD NEW FUNCTION__________@SACHENDRA____//
function calculateAgeInYear(dob) {
    var dateofbirth = dob.split("-");
    var year = Number(dateofbirth[2]);
    var month = Number(dateofbirth[1]) - 1;
    var day = Number(dateofbirth[0]);
    var today = new Date();
    var age = today.getFullYear() - year;
    if (today.getMonth() < month || (today.getMonth() == month && today.getDate() < day)) {
        age--;
    }
    return age;
}

function dropOff() {
	/*
    if (dropOffPopupStatus == undefined) {
        // variable is undefined
        return true;        
    } else if(dropOffPopupStatus == 0) {
        query="loan_type_id=4";
        M.popup("/drop-off-popup?"+encodeURI(query),"",410,540);
        
        //var uri = "?loan_type_id=2&source_id="+M.byId('source_id').value;
        //M.popup("drop-off-popup"+uri,"",380,500);
    }
    */
}

var win = window; // eslint-disable-line no-undef
var jq = win.jQuery;
var appendContent = true;

function generateContent() {
    jq('.scrollpanel').each(function (idx, el) {
        for (var i = 0; i < 1; i += 1) {
            jq(el).prepend('<div class="foo">' + i + '</div>');
        }
    });
}

function updateContent() {
    var $panel = jq('.no5');
    var $panelContent = jq('.no5 > .sp-viewport > .sp-container');
    var length = $panelContent.children().length;

    if (length <= 0) {
        appendContent = true;
    } else if (length >= 1) {
        appendContent = false;
    }

    if (appendContent) {
        $panelContent.prepend('<div class="foo">' + length + '</div>');
    } else {
        $panelContent.children().eq(0).remove();
    }

    $panel.scrollpanel('update');
}

function scinit() {
    generateContent();
    jq('.scrollpanel').scrollpanel();

    win.setInterval(updateContent, 1000);
}

function getPreFilledForms() {
    $(".form-control").each(function () {
        function emptyListener($this) {
            requestAnimationFrame(function () {
                emptyListener($this);
            });
            if ($this.data("oldval") != $this.val()) {
                $this.data("oldval", $this.val);
                $this.trigger("change");
            }
        }
        emptyListener($(this));
    });
}

function passKey(c) {
    var n = c + 1;
    var p = c - 1;
    var v = "";
    var b = false;
    if ($("#otp_code_" + c).val().length >= 1) {
        $("#otp_code_" + n).focus();
    } else if ($("#otp_code_" + c).val().length == 0) {
        $("#otp_code_" + p).focus();
    }
    for (var i = 1; i <= 6; i++) {
        v += $("#otp_code_" + i).val();
    }

    if (v.length == 6) {
        b = true;
    }
    if (b) {
        if ($("#verify_mobile_btn").hasClass("disabled")) {
            $("#verify_mobile_btn").removeClass("disabled");
        }
    } else if (!$("#verify_mobile_btn").hasClass("disabled")) {
        $("#verify_mobile_btn").addClass("disabled");
    }
}

function counterStart() {
    if (counter > 0) {
        counter = counter - 1;
        //console.log(counter);
        if (M.byId("otp_counter") != undefined) {
            $("#otp_counter").html("00:" + ((counter > 9) ? counter : "0" + counter));
        }
        setTimeout("counterStart()", 1500);
        //counterStart();
        if (!$("#resend_mobile_btn").hasClass("disabled")) {
            $("#resend_mobile_btn").addClass("disabled");
        }
    } else if (counter == 0) {
        if ($("#resend_mobile_btn").hasClass("disabled")) {
            counter = 60;
            $("#resend_mobile_btn").removeClass("disabled");
        }
    }
}

function holdProgress(id) {
    if (!$("#" + id).hasClass("disabled")) {
        $("#" + id).addClass("disabled");
    } else {
        $("#" + id).removeClass("disabled");
    }
}

function showHeaderError(msg, show) {
    if (show) {
        $("#err-content").html(msg);
        $("#page-level-err").show();
    } else {
        $("#page-level-err").hide();
    }
}

function showfinal(flg) {
    if (flg != undefined && flg == "1") {
        //~ $("#end_cc_btn").show();
    } else if (flg != undefined && flg == "2") {
        $("#end_cc_btn").hide();
        $("#msg_cc_show").show();
    }
}