﻿function getArea() {

    var country = document.getElementById("drp_Country");
    if (country.options[country.selectedIndex].text == "中国")
        document.getElementById("sp_area").style.display = "";
    else
        document.getElementById("sp_area").style.display = "none";
}

function resetSearch() {
    $("#txt_Keys").val("");
    $("#drp_Country").val("");
    $("#drp_Area").val("");
    $("#sp_area").hide();
    $("#txt_StartPrice").val("");
    $("#txt_EndPrice").val("");
    $("span[id*='FreshRating_Star_']").attr("class", "ratingStar emptyRatingStar");
    //$("span[id*='FeedbackRating_Star_']").attr("class", "ratingStar filledRatingStar");
    $("#FreshRating_RatingExtender_ClientState").val("0");
}

$(document).ready(function() {

    readVisited(0);

    //Tab CSS Transform
    if ($G('cid').length != 0) {
        switch ($G('cid')) {
            case "125":
                document.getElementById("li2").className = "";
                document.getElementById("li4").className = "selected";
                break;
            case "158":
                document.getElementById("li2").className = "";
                document.getElementById("li5").className = "selected";
                break;
            default:
                document.getElementById("li2").className = "selected2";
                break;
        }
    }
});


function addCart(product, _price, _pubtype) {

    var _count = 1;

    $.ajax({
        url: 'cart.ashx', //请求地址
        type: 'GET',
        dataType: "json",
        data: { Param: "savecart", pro: product, count: _count, price: _price, type: _pubtype },
        cache: false,
        success: function(json) {
            showCartCount(json, product);
        }
    });
}

function showCartCount(json, product) {
    var total = 0.00;
    var sumCount = 0;
    //遍历JOSN   
    $.each(json,
             function(i, item) {
                 sumCount++;
             }
         )

    alert("成功添加到购物车");
    $("#sp_headerCartCount").html(sumCount);
    //$("#cartDone" + product).show();
    //$("#cartAdd" + product).hide();
}

function showBigPhoto(obj) {
    var pos = findPos(obj);

    $("#preview").css({
        top: (pos.y - 19) + "px",
        left: (pos.x + 101) + "px"
    }).show();
    $("#img_show").attr("src", $(obj).attr("src"));

}

function hideBigPhoto() {

    $("#preview").hide();
}
