﻿function getInput(tp) {
    if (tp != 'ok') return ymPrompt.close();
    var v = document.getElementById('myInput').value;
    if (v == '')
        alert('请输入您要查询的订单号！')
    else {
        window.top.location = '/Home/OrderInquire/'+v;
        ymPrompt.close();
    }
}



function getposition(xelement, offset) {
    var c = 0;
    while (xelement) {
        c += xelement[offset];
        xelement = xelement.offsetParent;
    }
    return c;
}


// 显示菜单
function ShowMenu(menuid) {

    var menuobject = $('#sonmenu' + menuid);
    var xleft = getposition(document.getElementById('menu' + menuid), 'offsetLeft');
    var xtop = getposition(document.getElementById('menu' + menuid), 'offsetTop') + document.getElementById('menu' + menuid).clientHeight - 8;

    xleft += 'px';
    xtop += 'px';
    menuobject.css({ "left": xleft });
    menuobject.css({ "top": xtop });
    menuobject.show();
}

// 关闭菜单
function HideMenu(menuid) {
    $('#sonmenu' + menuid).hide();
}

function IndexDemo(str1, str2) {

    return str1.indexOf(str2);

}

function CheckLoginAjax1() {
    var flag = false;
    $.ajax({
        timeout: 1000000,
        //  async :false, 是否异步， 同步则同步请求将锁住浏览器
        type: "post",
        url: "/Home/CheckLoginAjax1/",
        beforeSend: function(XMLHttpRequest) {
            //ShowLoading();
        },

        success: function(data, textStatus) {

            if (data == "1") {
                flag = true;
            }
            return flag;

        },
        complete: function(XMLHttpRequest, textStatus) {
            //HideLoading();
        },


        error: function(XMLHttpRequest, textStatus, errorThrown) {
            alert("error");
            //请求出错处理
        }
    });
}

$(document).ready(function() {

    //    if (CheckLoginAjax1()) {
    //        $.cookie("UserName", "", { expires: -1, path: '/', domian: '', secure: false });
    //        $.cookie("UserID", "", { expires: -1, path: '/', domian: '', secure: false });
    //    }

    $("#flRight img").lazyload({ threshold: 200 });
    $("img").lazyload({ threshold: 200 });

    // alert(window.location);
    var href = " " + window.location;
    var index = IndexDemo(href, 'ProductClass/');
    var index2 = IndexDemo(href, "Promotions/");
    var index3 = IndexDemo(href, "GridShop");
   
    if (index3 > 0) {

        $('#menugrid').attr('class', 'dang');
    } else if (index == -1) {
       
        $('#menu0').attr('class', 'dang');
    }
    else {
        var num = href.substr(index + 13, 2);
        num = num.replace(/(.)(?=[^$])/g, "$1,").split(",");

        var reg = /[0-9]/;
        var cln = '';
        for (var i = 0; i < num.length; i++) {
            if (reg.test(num[i])) {
                cln += num[i];
            }

        }
        if (cln < 9) {
            $('#menu1').attr('class', 'dang');

        } else if (cln >= 9 && cln < 17) {
            $('#menu9').attr('class', 'dang');

        } else if (cln >= 17 && cln < 28) {
            $('#menu17').attr('class', 'dang');
        } else if (cln >= 28 && cln <= 33) {
            $('#menu28').attr('class', 'dang');
        } else {
            $('#menu0').attr('class', 'dang');
        }

    }


});

function searchprice() {



    var price = $('#price').val();

    window.top.location = '/Home/PriceInquire/'+price+'/1';

}


