function addDefaultProgress(){
    $('.progress').css({
        //"display":  "block",
        "left": my_x+12,
        "top": my_y+12
    }).fadeIn(0);
}

function addDeleteMessageProgress(){
    $('.progress').css({
        //"display":  "block",
        "left": my_x-100,
        "top": my_y-100,
        "width" : "150px",
        "height" : "150px",
        "background-position": "88% 88%",
        "background-repeat": "no-repeat"
    }).fadeIn(0).mousemove(function(kmouse){
        $('.progress').css({
            left:kmouse.pageX-100,
            top:kmouse.pageY-100
        });
    });
}

function removeProgress(time){
    setTimeout(function(){
        $('.progress').css({
            //"display": "none",
            "left": my_x+12,
            "top": my_y+12,
            "width" : "25px",
            "height" : "25px",
            "background-position": "center"
        }).fadeOut(0).unbind();
    },time);
}

function request(router, flag)
{
    url = "index.php?" + router;
    if (!($.browser.msie && $.browser.version.substr(0,1)<7)) {
        if (flag) {
            addDeleteMessageProgress();
        } else addDefaultProgress();
    }
   
    loadXMLDoc(url)
}
//-------------------------------------
function loadXMLDoc(url)
{
    if (window.XMLHttpRequest)
    {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;
        req.open("GET", url, true);
        req.send(null);
       
    }
    else if (window.ActiveXObject)
    {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req)
        {
            req.onreadystatechange = processReqChange;
            req.open("GET", url, true);
            req.send();
        }
    }
}
//-------------------------------------
function processReqChange()
{
    if (req.readyState == 4)
    {
        if (req.status == 200)
        {
            x = req.responseText;
            answer(x);
        }
    }
}
//-------------------------------------
function answer(resp)
{
    //			alert (resp);
    eval (resp);
}

//=====================================

function getElObjById (objs, id)
{
    var res = false;
    for (i = 0; i < objs.length; i++)
    {
        if (objs[i].id == id) {
            res = objs[i];
            break;
        }
    }

    return res;
}
//-------------------------------------
function ExchangeBGImg (idObj, pathImg)
{
    obj = document.getElementById(idObj);
    obj.style.backgroundImage = 'URL(' + pathImg + ')';
    removeProgress(250);
}
//-------------------------------------
//function FancyboxCloseWindow (idObj, pathImg)
//{
//    removeProgress(250);
//    parent.$.fancybox.close();
//    obj = parent.document.getElementById(idObj);
//    obj.style.backgroundImage = 'URL(' + pathImg + ')';
//}
//-------------------------------------
function SetValueBasketCounter  (idObj, value)
{
    objs = document.getElementsByName('basket_counter');
    if (basketCounter = getElObjById (objs, idObj)) {
        basketCounter.value = value;
        removeProgress(100);
    }
}
//-------------------------------------
function DelRowTableById (id, totalSum)
{
    var tbl  = document.getElementById('basket_table');
    var tr = getElObjById (tbl.rows, id);

    if (tr) {
        tbl.deleteRow (tr.rowIndex);
        removeProgress(750);
    }

    SetValueBasketTotalSum  (id, totalSum);

}
//-------------------------------------
function SetValueBasketSum  (idObj, value)
{
    objs = document.getElementsByName('cost_total_one');
    if (basketSum = getElObjById (objs, idObj)) {
        basketSum.innerHTML = value;
        removeProgress(100);
    }
}
//-------------------------------------
function SetValueBasketTotalSum  (idObj, value)
{
    $(document).ready(function()
    {
        $("#cost_total_all").html(value);
    });

    removeProgress(100);
}
//-------------------------------------
function SetValueBasketCostAct  (idObj, value)
{
    $(document).ready(function()
    {
        $("#cost_act_"+idObj).html(value);
    });
}
//-------------------------------------
function SetBGColDivById  (idObj)
{
    $(document).ready(function()
    {
        $("div[class*='cost']").removeClass('cost_active');
        $("div[class='"+idObj+"']").addClass('cost_active');
        $("td[class*='cost']").removeClass('cost_active');
        $("td[class='"+idObj+"']").addClass('cost_active');
    });

}
//-------------------------------------
function SetValuesBasket  (idObj, basketCounter, costSum, costTotalSum) //������ ������� ���-�� ������� � �������� �����
{
    SetValueBasketCounter  (idObj, basketCounter);
    SetValueBasketSum  (idObj, costSum);
    SetValueBasketTotalSum  (idObj, costTotalSum);
//    SetValueBasketCostAct  (idObj, costAct);
//    SetColorTextById  (idDivCostAct);
}

