var theserver = 'www.brewium.com/';

function callAddCart(mnum,mid,qty,sid)
{
  qty1 = parseInt(parseFloat(qty));
  if (qty1 == qty){
  	if (qty1 > 0){
  var url;
  url = "http://" + theserver + "BrewiumCart.php?t=add&m=" + mnum + "&p=" + mid + "&q=" + qty1 + "&sid=" + sid;
  _hf = document.createElement('script');
  if ( ! _hf ) return;
  _hf.setAttribute("name","hf");
  _hf.setAttribute("id","hf");
  document.getElementsByTagName('head')[0].appendChild(_hf);
  _hf.setAttribute('src', url);
  	}
  	else
  	{
  	alert('Your quantity is invalid.');
  	}
  }
  else
  {
    alert('Your quantity is invalid.');
  }      
}

function callClearCart(cartnum,sid)
{
  var quest = confirm('Are you sure you want to clear and remove this cart?');
  if (quest){
  var url;
  url = "http://" + theserver + "BrewiumCart.php?t=clear&c=" + cartnum + "&sid=" + sid;
  _hf = document.createElement('script');
  if ( ! _hf ) return;
  _hf.setAttribute("name","hf");
  _hf.setAttribute("id","hf");
  document.getElementsByTagName('head')[0].appendChild(_hf);
  _hf.setAttribute('src', url);
  }
}

function callCheckout(cartnum,sid)
{
  var url;
  url = "http://" + theserver + "BrewiumCart.php?t=checkout&c=" + cartnum + "&sid=" + sid;
  _hf = document.createElement('script');
  if ( ! _hf ) return;
  _hf.setAttribute("name","hf");
  _hf.setAttribute("id","hf");
  document.getElementsByTagName('head')[0].appendChild(_hf);
  _hf.setAttribute('src', url);      
}

function callUpdateCart(sid)
{
  var url;
  url = "http://" + theserver + "BrewiumCart.php?t=update&sid=" + sid;
  _hf = document.createElement('script');
  if ( ! _hf ) return;
  _hf.setAttribute("name","hf");
  _hf.setAttribute("id","hf");
  document.getElementsByTagName('head')[0].appendChild(_hf);
  _hf.setAttribute('src', url);      
}

function callNewCart(sid)
{
  var url;
  url = "http://" + theserver + "BrewiumCart.php?t=new&sid=" + sid;
  _hf = document.createElement('script');
  if ( ! _hf ) return;
  _hf.setAttribute("name","hf");
  _hf.setAttribute("id","hf");
  document.getElementsByTagName('head')[0].appendChild(_hf);
  _hf.setAttribute('src', url);      
}

function callSetActive(c, sid, after)
{
  var url;
  url = "http://" + theserver + "BrewiumCart.php?t=setactive&c=" + c + "&after=" + after + "&sid=" + sid;
  _hf = document.createElement('script');
  if ( ! _hf ) return;
  _hf.setAttribute("name","hf");
  _hf.setAttribute("id","hf");
  document.getElementsByTagName('head')[0].appendChild(_hf);
  _hf.setAttribute('src', url);      
}
