var backgrounds = new Array("head1", "head2", "head3", "head4");

function change_bg()
{
    document.getElementById("head").style.backgroundImage = "url('/files/images/" + backgrounds[Math.round(Math.random() * (backgrounds.length - 1))] + ".jpg')";
}

function change_width(oElem)
{
	var width = document.documentElement.clientWidth || document.body.clientWidth;

	return (width > 800 ? "80%" : "100%");
}

function basket_put(product_id)
{
    basket_process(product_id);
    request.send("/basket.php", "product_id=" + product_id + "&rand=" + Math.random().toString(), basket_info);
}

function basket_info(text)
{
    eval(text);
    basket_process(product_id);
    document.getElementById("basket_info").innerHTML = info;
}

function basket_process(product_id, display)
{
    var oProduct = document.getElementById("p" + product_id);

    for(var i = 0, len = oProduct.childNodes.length; i < len; i++)
    {
        elem = oProduct.childNodes[i];

        if(elem.nodeName == "A")
        {
            oProduct.removeChild(elem);

            img = document.createElement("IMG");
            img.setAttribute("src", "/files/images/loading.gif");
            img.setAttribute("width", 16);
            img.setAttribute("height", 16);

            oProduct.appendChild(img);

            break;
        }
        else if(elem.nodeName == "IMG")
        {
            oProduct.removeChild(elem);

            a = document.createElement("A");
            a.setAttribute("href", "/order/");
            a.className = "selected";
            a.innerHTML = "заказано";

            oProduct.appendChild(a);
        }
    }
}

