﻿function RefreshIframe() {
//    var iframe = document.getElementById("iframe");
    //    iframe.src = iframe.src;
    //alert("Hi");
    document.getElementById("iframe").contentWindow.location.reload(true);
//    $("#LabelRetryCaptcha").attr("style", "display:'none'");
//    $("#LabelCapthcaText").attr("style", "display:''");
}
function SubmitCaptcha() {
    var CaptchaText = $("#TextBoxCaptcha").val();
    //alert(CaptchaText);
    $.ajax({
        type: "POST",
        url: "/services.aspx/IsValid",
        data: "{'strCaptchaText':'" + CaptchaText + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        async: false,
        success: function(msg) {
            $.each(msg.d, function(index, item) {
                if (item.Display == "yes") {
                    //alert("yes");
                    //chooseEngine();
                    GetEncParameters();
                    document.FlexPricer.submit();
                }
                else {
                    RefreshIframe();
                    $("#LabelRetryCaptcha").attr("style", "display:''");
                    $("#LabelCapthcaText").attr("style", "display:none");
                }
            });
        }
    });
}
function ShowCaptcha() {
//    var HowCaptcha = "";
//    $.ajax({
//        type: "POST",
//        url: "/services.aspx/CheckIp",
//        data: "{}",
//        contentType: "application/json; charset=utf-8",
//        dataType: "json",
//        async: false,
//        success: function(msg) {
//            $.each(msg.d, function(index, item) {
//                if (item.Display == "yes") {
//                    $("#divCaptcha").dialog("open");
//                }
//                else {
//                    alert(item.Display)
//                }
//            });
//        }
//    });
    //alert("Show:" + HowCaptcha);
    //    return HowCaptcha;

    $("#divCaptcha").dialog("open");
}
