﻿
function AddInShoppingCar(product) {
    $.ajax({ type: "POST", dataType: "text", url: "/Service/AddInShoppingCar.ashx", data: { "PID": product },
        error: function(http, error) { alert('Add Failed!!'); },
        success: function(data) {
            if (data == 1) {
                __doPostBack('ctl00$BaseContentPlaceHolder$lbShoppingItem', '');
                $.ajax({ type: "POST", dataType: "text", url: "/Service/StateShoppingCar.ashx", data: { 'Type': 1} });

                if ($('#OpenItemList').html() == 'OPEN') {
                    $('#OpenItemList').html('CLOSE')
                    $('#DescriptionSlidePanel').slideToggle('slow');
                } else {
                    $('#OpenItemList').html('OPEN');
                }
               
             
                alert('Added to inquiry list successfully.');
            } else if (data == 2)
                alert("Products repeat!!");
            else
                alert("Parameter error!!");
        }
    });
}

function CheckShoppingCarItem() {
    $("#ShoppingCount").empty().append($('.box_blue_photo').length);
    if ($('.box_blue_photo').length == 0) {
        $('#OpenItemList').html('OPEN');
    }
    else {
        $('#OpenItemList').html('CLOSE');
    }
}

function DelShoppingCar(product) {
    $.ajax({ type: "POST", dataType: "text", url: "/Service/DelShoppingCar.ashx", data: { "PID": product }, error: function(http, error) { alert('Inquiry failed to delete!!'); }, success: function(data) { if (data == 1) { __doPostBack('ctl00$BaseContentPlaceHolder$lbShoppingItem', ''); } else if (data == 2) alert("No such inquiry!!"); else alert("Parameter error!!"); } });
}

  
var selectMenu;
function MenuChange(currId, Status) {
    if (selectMenu != '') {
        $.ajax({ type: "POST", dataType: "text", url: "/Service/StateProductMenu.ashx", data: { 'Type': 1, "PID": currId} });
        $('#' + selectMenu).slideToggle('slow');
        $('#' + currId).slideToggle('slow');
        selectMenu = currId;
    }
}
