
function addToBasket(id)
{

if(id>0)
{
$('#addToBasketBox'+id).text('proszę czekać...');

 var id_cechy1_js, id_cechy2_js, id_cechy3_js;


 if(document.getElementById("id_cechy1")){ id_cechy1_js=$("#id_cechy1").val(); }
 if(document.getElementById("id_cechy2")){ id_cechy2_js=$("#id_cechy2").val(); }
 if(document.getElementById("id_cechy3")){ id_cechy3_js=$("#id_cechy3").val(); }

 $.post("inc/ajax_koszyk.php", { id_cechy1:id_cechy1_js, id_cechy2:id_cechy2_js, id_cechy3:id_cechy3_js, id: id, action: 'add' },
    function(data)
    {
    $('#KoszykTopSmall').hide();
    $('#KoszykTopBig').fadeIn(500);
    $('#addToBasketBox'+id).html(data.info);
    $('#KoszykIlosc').html(data.ilosc);
    $('#KoszykWartosc').html(data.wartosc);

    statusWysylka(data.wartosc)
    },
    "json"
  );
}

}




//bezplatnma wysylk
function statusWysylka(wartosc)
{
var tofreesend;

    tofreesend=parseInt(100-wartosc);
    if(tofreesend>0) { $('#freesend').html('<b>'+tofreesend+'</b> zł do bezpłatnej wysyłki'); }else{$('#freesend').html('bezpłatna wysyłka!');}

}
























//--usuwanie------------------------------
function delFromBasket(id)
{
if(id>0)
{
$('#BasketContent').text('proszę czekać...');

 $.post("inc/ajax_koszyk.php", { id:id, action: 'del' },
    function(data)
    {
    $('#KoszykIlosc').html(data.ilosc);
    $('#KoszykWartosc').html(data.wartosc);
    statusWysylka(data.wartosc)
    refreshBasket();
    },
    "json"
  );
}
}

//-----------------------------------------------




















//--zmien ilosc------------------------------
function changeBasket(id,znak)
{
if(id>0)
{
$('#BasketContent').text('proszę czekać...');

 $.post("inc/ajax_koszyk.php", { id:id, znak:znak, action: 'change' },
    function(data)
    {
    $('#KoszykIlosc').html(data.ilosc);
    $('#KoszykWartosc').html(data.wartosc);
    statusWysylka(data.wartosc)
    refreshBasket();
     if(data.status!='' && data.status!=null)
     {
     $('#KomunikatKoszyk').fadeIn(500).html(data.status).delay(2800).fadeOut(400);
     }
    },
    "json"
  );
}
}
//-----------------------------------------------









//--odswiez koszyk------------------------------
function refreshBasket()
{

$('#BasketContent').text('proszę czekać...');


 $.post("inc/ajax_koszyk.php", { action: 'refresh' },
    function(data)
    {
    $('#BasketContent').html(data);
    freesendBasket();
    }
  );

}
//--------------------------------------------------





//--dane o brakujacej kwocie do bezplatnej wysylki------------------------------
function freesendBasket()
{

$('#freesendkoszyk').text('...');


 $.post("inc/ajax_koszyk.php", { action: 'freesend' },
    function(data)
    {
    $('#freesendkoszyk').html(data);
    }
  );

}
//--------------------------------------------------







function StopClose()
{
document.getElementById("CloseBtn").innerHTML='Proszę czekać...';
setTimeout("closeAndRefresh()",300)
}















