﻿
function AddFavorites(id,type) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: "/WebService/ShoppingCar.asmx/Favorites",
        data: "{id:'" + id + "',type:'" + type + "'}",
        dataType: 'json',
        success: function(result) {
            if (result.d == "请您先登录,再加入收藏!") {
                alert('请您先登录，再加入收藏！'); window.location.href = '/Member/Login.aspx?url=' + document.URL;
            }
            else {
                alert(result.d);
            }
        }
    });
}

function AddEnFavorites(id, type) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: "/WebService/ShoppingCar.asmx/EnFavorites",
        data: "{id:'" + id + "',type:'" + type + "'}",
        dataType: 'json',
        success: function(result) {
            if (result.d == "Please sign in first, and then operate.") {
                alert('Please sign in first, and then operate.'); window.location.href = '/Member/EnLogin.aspx?url=' + document.URL;
            }
            else {
                alert(result.d);
            }
        }
    });
}

function AddCar(entIdShop, proid) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: "/WebService/ShoppingCar.asmx/AddCars",
        data: "{entIdShop:'" + entIdShop + "',proid:'" + proid + "'}",
        dataType: 'json',
        success: function(result) {
                alert(result.d);
        }
    });
}


function NewAddCar(entIdShop, proid) {
    var count = document.getElementById("txtCount").value;
    var maxCount = document.getElementById("HidAmount").value;
    
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: "/WebService/ShoppingCar.asmx/NewAddCars",
        data: "{entIdShop:'" + entIdShop + "',proid:'" + proid + "',count:'" + count + "',maxCount:'" + maxCount + "'}",
        dataType: 'json',
        success: function(result) {
           
            if (result.d == "商品添加失败!") {
                alert(result.d);
            }
            else
                showLayer();
        }
    });
}


function AddEnCar(entIdShop, proid) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: "/WebService/ShoppingCar.asmx/EnAddCars",
        data: "{entIdShop:'" + entIdShop + "',proid:'" + proid + "'}",
        dataType: 'json',
        success: function(result) {
            alert(result.d);
        }
    });
}
function selectall(c) {
    var chk = document.getElementsByTagName("input");
    for (var i = 0; i < chk.length; i++) {

        if (chk[i].type == "checkbox") {
            chk[i].checked = c.checked;
        }
    }
}

//function showBargainOrAddCar(isPrice, myCategoryId, entId) {
//    if (isPrice == "true") {
//        document.getElementById(" showBargainOrAddCar").innerHTML = "";
//        <img src="http://img.etradenow.cn/images/ShoppingCar/shop_Car.GIF" runat="server" id="imgAddCar" visible="false" />
//         <a  href="javascript:AddCar('<%#Eval("EntId") %>','<%#Eval("MyCategoryId") %>')">加入购物车</a>
//    } else {
//    document.getElementById(" showBargainOrAddCar").innerHTML = "";
//        <img height="13" src="http://img.etradenow.cn/images/gyxx/liuyan.gif" width="16">
//                                                                    <a href='/CN/Product/Supply/Bargain.aspx?pid=<%#Eval("MyCategoryId") %>' target="_blank">
//                                                                        &nbsp;我要询价</a>
//    }
//}

