XIXI.$(document).ready(function () {
    myclick();
});
function myclick() {
    XIXI.$("#btn_submit").click(checkconfig);
}
function btn_submit_on() {
    //document.getElementById("btn_submit").disabled="";
    //document.getElementById("btn_submit").type="image";
}
function checkconfig() {
    document.getElementById("checkout_confirmation").style.display = "none";
    XIXI.$("#orderTotals").after("<div align='right' style='color:#FF0000;font-weight:bold;padding-right:20px;'>Hold On<br><img src='/App_Themes/Default/images/loading.gif'/> </div>");

    XIXI.$.ajax({
        type: "POST",
        contentType: "application/octet-stream,multipart/form-data,application/x-www-form-urlencoded,*.*,*/*",
        url: "cartclear.php",
        data: null,
        success: function (result) {
            End();
            //XIXI.$("#orderTotals").html(result).show();

        }
    });

}

function openwin() {
    window.open("Specials.html", "newwindow", "height=600,width=600,top=300,left=400,toolbar=no,menubar=no,scrollbars=yes,resizable=no, location=no,status=no");
}
function openwin1() {
    window.open("Specials.html", "newwindow", "height=600,width=600,top=300,left=400,toolbar=no,menubar=no,scrollbars=yes,resizable=no, location=no,status=no");
}


function layer_show(layer_name, action) {
    if (action == "show") {
        document.getElementById(layer_name).style.visibility = "visible";
    }
    else if (action == "hide") {
        document.getElementById(layer_name).style.visibility = "hidden";
    }

}


function checkorders() {
    //document.getElementById("btn_submit").disabled="disabled";
    //alert("testdddddddd");
}

function checkpd() {

    /*做判断，需要对一些条件进行限制*/
    //左右眼的Near addition是否可用
    var rnadd = XIXI.$("#attrib_9").attr("disabled");
    var lnadd = XIXI.$("#attrib_5").attr("disabled");
    var rpd = XIXI.$("select[@name='id[13]'] option[@selected]").text();
    var lpd = XIXI.$("select[@name='id[14]'] option[@selected]").text();
    var pd = XIXI.$("select[@name='id[10]'] option[@selected]").text();
    var nd = XIXI.$("select[@name='id[12]'] option[@selected]").text();
    var lsph = XIXI.$("select[@name='id[2]'] option[@selected]").text();
    var lcyl = XIXI.$("select[@name='id[3]'] option[@selected]").text();
    var rsph = XIXI.$("select[@name='id[6]'] option[@selected]").text();
    var rcyl = XIXI.$("select[@name='id[7]'] option[@selected]").text();
    var spd = null;
    spd = parseFloat(lpd) + parseFloat(rpd);
    //alert("dddd");
    //alert(rpd);
    //alert(lpd);
    var AttentionValue = null;
    var alertflag = null;
    if (rnadd) {
        var rnaddtxt = XIXI.$("#attrib_9").val();
        if (rnaddtxt == '+0.00') {
            AttentionValue = 20;
            alertflag = 1;
        }
    }
    if (lnadd) {
        var lnaddtxt = XIXI.$("#attrib_9").val();
        if (lnaddtxt == '+0.00') {
            AttentionValue = 20;
            alertflag = 1;
        }
    }
    //upload doglasses need change 658 to 661
    if (document.getElementById("attrib_18-661").checked) {
        if (rpd != "" && lpd != "") {
        }
        else {
            AttentionValue = 7;
            alertflag = 1;
        }
    }
    //left + right pd check 
    //1)sph and cyl have number
    //2)lpd or rpd have number
    //3)progressive lensess
    if (lsph != 0 || lcyl != 0 || rsph != 0 || rcyl != 0) {
        if (pd > 0) {
            if (lpd > 0 || rpd > 0) {
                if (pd == spd) {
                    //alert("this pd=spd");
                }
                else {
                    //alert("this pd!=spd");
                    AttentionValue = 8;
                    alertflag = 1;
                }
            }
        }
        if (nd > 0) {
            if (lpd > 0 || rpd > 0) {
                if (nd == spd) {
                    //alert("this nd=spd");
                }
                else {
                    //alert("this nd!=spd");
                    AttentionValue = 8;
                    alertflag = 1;
                }
            }
        }
    }
    //check progressive lensess ,upload doglasses need change 658 to 661
    if (document.getElementById("attrib_18-661").checked) {
        if (pd > 0) {
            if (pd == spd) {
                alert("document this pd=spd");
            }
            else {
                alert("document this pd!=spd");
                AttentionValue = 8;
                alertflag = 1;
            }
        }
        if (nd > 0) {
            if (nd == spd) {
                alert("document this nd=spd");
            }
            else {
                alert("document this nd=spd");
                AttentionValue = 8;
                alertflag = 1;
            }
        }

    }
    if (document.getElementById("attrib_4-0").value == "" && document.getElementById("attrib_3").value != 273 && document.getElementById("attrib_3").value != 102)
        AttentionValue = 1;
    if (document.getElementById("attrib_8-0").value == "" && document.getElementById("attrib_7").value != 275 && document.getElementById("attrib_7").value != 217)
        AttentionValue = 1;
    if ((document.getElementById("attrib_2").value != "" && document.getElementById("attrib_2").value != 35) || (document.getElementById("attrib_3").value != "" && document.getElementById("attrib_3").value != 102) || (document.getElementById("attrib_6").value != "" && document.getElementById("attrib_6").value != 166 && document.getElementById("attrib_6").value != 35) || (document.getElementById("attrib_7").value != "" && document.getElementById("attrib_7").value != 217)) {
        if ((document.getElementById("attrib_10").value == "" || document.getElementById("attrib_10").value == 276) && (document.getElementById("attrib_12").value == "" || document.getElementById("attrib_12").value == 330)) {
            if (AttentionValue == null)
                AttentionValue = 3;
            else
                AttentionValue = AttentionValue + "" + 3;
        }
    }
    if (AttentionValue == 1 || AttentionValue == 3 || AttentionValue == 13)
        alertflag = 1;
    AttentionValue = getAttentionValue(AttentionValue);
    if ((document.getElementById("attrib_5").disabled == "" && document.getElementById("attrib_5").value == 271) || (document.getElementById("attrib_9").disabled == "" && document.getElementById("attrib_9").value == 270)) alertflag = 1;
    languages_code = document.getElementById("attrib_languagecode").value;
    if (isNaN(XIXI.$("#attrib_4-0").val()) || isNaN(XIXI.$("#attrib_8-0").val())) {
        //alert(AttentionValue);
        AttentionValue = 9;
        show_attrib_attention(AttentionValue, languages_code);
        return false;
    }
    else if (AttentionValue != null) {
        //alert(AttentionValue);
        show_attrib_attention(AttentionValue, languages_code);
        if (alertflag == 1)
            return false;
        else
            document.cart_quantity.submit();
    }
    else {
        document.cart_quantity.submit();
    }
}
