﻿//取得url参数
function request(paras) {
    var url = location.href;
    var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&");
    var paraObj = {}
    for (i = 0; j = paraString[i]; i++) {
        paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf
("=") + 1, j.length);
    }
    var returnValue = paraObj[paras.toLowerCase()];
    if (returnValue == null)
        return "";
    if (returnValue.indexOf("#") > 0) {
        returnValue = returnValue.split("#")[0];
    }
    if (typeof (returnValue) == "undefined") {
        return "";
    } else {
        return returnValue;
    }
}

//取得int值

function getInt(str1) {
    var strlen = str1.toString().split(".");
    if (strlen.length > 0)
        return strlen[0];

}

function addCookieShopCart(pid, pnum) {
    if (confirm("真的要将此产品放入购物车？")) {
        $.get("/services/CookieShopCart.ashx", { a: "" + Math.random() + "", action: "add", pid: pid, pnum: pnum },
            function (data) {
                alert(data);
                if (data == "添加购物车成功")
                    location.href = "/cart/ShopingCart.aspx";
            });
    }
}

function ShopingCart() {
    $.get("/services/CookieShopCart.ashx", { a: "" + Math.random() + "", action: "get" },
            function (data) {
                $("#ShopingCartBox").html(data);
            });
}

function RemoveShopingCart(pid) {
    $.get("/services/CookieShopCart.ashx", { a: "" + Math.random() + "", action: "remove", pid: pid },
            function (data) {
                alert(data);
                ShopingCart();
            });
}

function SetShopingCartPNum(pid) {
    var id = "#ShopingCartNum" + pid;
    var pnum = $(id).val();
    if (pnum == "") {
        alert('请填写产品的数量');
        return;
    }
    $.get("/services/CookieShopCart.ashx", { a: "" + Math.random() + "", action: "set", pid: pid, pnum: pnum },
            function (data) {
                alert(data);
                ShopingCart();
            });
}

function ProductCollection(pid) {
    if (confirm("真的要收藏此产品？")) {
        $.get("/services/Collection.ashx", { a: "" + Math.random() + "", action: "add", pid: pid },
            function (data) {
                $("#PCollection").html(data);
            });
    }
}

function getVideo(id) {

    $.get("/services/Video.ashx", { vid: "" + escape(id) + "" }, function (data) {
        if (data.length > 0) {
            $('.vi').html(data);

        }
    });

}

function changeClass(con) {
    $(".o2").attr("class", "o1");
    con.className = "o2";
}
