﻿function BuyBoard(boardId, anchor){
    var boardIdIndex = basketList.indexOf(boardId);
    if(boardIdIndex == -1)
        basketList.push(boardId);
    else
        basketList.splice(boardIdIndex, 1);
    $("BasketCount").innerHTML = basketList.length;
    Basket.BuyBoard(boardId, OnComplete, OnError, anchor);
}
function OnComplete(result, anchor, methodName){
    switch(methodName){
        case 'BuyBoard':
            anchor.className = result ? 'buy' : 'buy2';
            anchor.setAttribute("alt", result ? "убрать из корзины" : "добавить в корзину");
            anchor.setAttribute("title", result ? "убрать из кор    зины" : "добавить в корзину");
            $('notepad').style.display = basketList.length > 0 ? 'block' : 'none';
            //SetFilterPosition();
            SetBasketPosition();
            break;
    }
}
function OnError(){}
if (!Array.prototype.indexOf){
    Array.prototype.indexOf = function(obj) {
        var len = this.length;
        for (var i = 0; i < len; i++) {
            if (this[i] === obj) {
                return i;
            }
        }
        return -1;
    };
}
function ClearBoard(anchor) {
    Basket.ClearBoard(OnComplete, OnError, anchor);
    basketList = [];
    $("BasketCount").innerHTML = '0';
    $('notepad').style.display = 'none';
    var images = document.getElementsByTagName("a");
    for (var i = 0; i < images.length; i++) {
        if (images[i].className == 'buy')
            images[i].className = 'buy2';
    }
}