function addToCart(id){
  var opt = {
        method: 'post',
        postBody: 'id='+id+'&mode=add',
        onSuccess: function(t) {
            eval(t.responseText);

            document.getElementById("cartCount").innerHTML = cartCount+' רע.';
		        document.getElementById("cartTotal").innerHTML = '&nbsp;'+cartTotal+' דנם.';

//            var el = document.getElementById('floater');
//					  el.style.display = 'block';

        },
        on404: function(t) {
            alert('Error 404: location "' + t.statusText + '" was not found.');
        },
        onFailure: function(t) {
            alert('Error ' + t.status + ' -- ' + t.statusText);
        }
    }
  new Ajax.Request('/cart.php', opt);
}
          
function editCart(id){
	cnt = "quantity"+id;
	count  = document.getElementById(cnt).value;
  var opt = {
        method: 'post',
        postBody: 'id='+id+'&newCount='+count+'&mode=edit',
        onSuccess: function(t) {
          eval(t.responseText);

          document.getElementById("cartCount").innerHTML = cartCount+' רע.';
          document.getElementById("cartTotal").innerHTML = '&nbsp;'+cartTotal+' דנם.';
          
          document.getElementById("cartTotalCart").innerHTML = '&nbsp;'+cartTotal+' דנם.';
        },
        on404: function(t) {
            alert('Error 404: location "' + t.statusText + '" was not found.');
        },
        onFailure: function(t) {
            alert('Error ' + t.status + ' -- ' + t.statusText);
        }
    }
  new Ajax.Request('/cart.php', opt);
}  

function deleteItem(id){
  var opt = {
        method: 'post',
        postBody: 'id='+id+'&mode=delete',
        onSuccess: function(t) {
          eval(t.responseText);

          var trName='tr'+id;

          tab = document.getElementById("tableCart");
          tab.removeChild(document.getElementById(trName));
        },
        on404: function(t) {
            alert('Error 404: location "' + t.statusText + '" was not found.');
        },
        onFailure: function(t) {
            alert('Error ' + t.status + ' -- ' + t.statusText);
        }
    }
  new Ajax.Request('/cart.php', opt);
}

function set_carrency(cur){
  var opt = {
        method: 'post',
        postBody: 'cur='+cur,
        onSuccess: function(t) {
          eval(t.responseText);
          
          window.location.reload();
        },
        on404: function(t) {
            alert('Error 404: location "' + t.statusText + '" was not found.');
        },
        onFailure: function(t) {
            alert('Error ' + t.status + ' -- ' + t.statusText);
        }
    }
  new Ajax.Request('/set_currency.php', opt);
}