function buyask(ask, oid, obj) {
    if (ask != "") {
//        var res = confirm(ask);
//        if (res)
//            buy(oid, obj);
        window.open('../cart/AproveItem1.aspx?oid=' + oid, '_blank', 'width=500,height=300,status=0,toolbar=0');
    }
    else {
        buy(oid, obj);
    }
}

function buyaskGroups(ask, oid, obj, tbid) {
    tb = document.getElementById(tbid);
    count = 1;
    if (tb != null)
    {
        val = tb.value;
        if (val != null) count = val;
    }
    
    if (ask != "") {
        window.open('../cart/AproveItem2.aspx?oid=' + oid + '&count=' + count, '_blank', 'width=500,height=300,status=0,toolbar=0');
    }
    else 
    {
        buyGroups(oid, obj, count);
    }
}

function showHideCartMore() {
	stop = false;
	show = false;
	iter = 4;
	while (!stop) {
		trow1 = document.getElementById("trCart" + iter + "_1");
		trow2 = document.getElementById("trCart" + iter + "_2");
		if (trow1 == null || trow2 == null) {
			stop = true;
			break;
		}
		if (trow1.style.display == "none") show = true;
		if (show) {
			trow1.style.display = "";
			trow2.style.display = "";
		}
		else {
			trow1.style.display = "none";
			trow2.style.display = "none";
		}
		iter++;
	}

	if (show) document.getElementById("cartShowHide").firstChild.nodeValue = ". . . Скрыть . . .";
	else document.getElementById("cartShowHide").firstChild.nodeValue = ". . . Показать все . . .";
	return false;
}

function buyGroups(oid, obj, count) {
    buy2(oid, count);
}


function buy(oid, obj) {
    if(!obj.shiftKey)
    {
        buy2(oid,1);
    }
    else
    {
        var cnt = prompt('Укажите количество деталей, которые вы хотите положить в корзину', 1);
        if(cnt != null)
        {
            buy2(oid,cnt);
        }
    }
}

function buy2(oid,cnt)
{
    cartObject = document.getElementById('cart');
    if (typeof(cartObject)!="undefined") {
        ajLoadObjs('cart',
	        '../cart/buy.aspx?oid='+oid+'&cnt='+cnt+'&rnd='+Math.random(),
	        'Добавляется в корзину...');
    }
}

function fillCart() {
	cartVisible = true;
	ajLoadObjs('cart',
				'../cart/buy.aspx?rnd='+Math.random(),
				'Содержимое корзины загружается...');
}

function hideCartDetails()
{
	cartVisible = true;
	ajLoadObjs('cart',
				'../cart/buy.aspx?hide=1',
				'Содержимое корзины загружается...');
}

function showCartDetails()
{
	cartVisible = true;
	ajLoadObjs('cart',
				'../cart/buy.aspx?hide=0',
				'Содержимое корзины загружается...');
}

function showPop(url)
{
    window.open(url);
}
