var xmlhttp;
function alertme() {
	var $alert = $('#alert');
		var alerttimer = window.setTimeout(function () { $alert.trigger('click'); }, 3000);
		$alert.animate({height: $alert.css('line-height') || '50px'}, 200)
		.click(function () {
			window.clearTimeout(alerttimer);
			$alert.animate({height: '0'}, 200);
		});
}

function updatebag(id) {
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }

if (id!=null) {
		var quant = document.getElementById('addquant').value;
		document.getElementById('miniBag').innerHTML="<img src='images/whiteajax-loader.gif' alt='loading' style='margin-left:15px;' />";
		var url="ajaxincludes/updatebag.php?add="+id+"&q="+quant;
		url=url+"&sid="+Math.random();
		xmlhttp.onreadystatechange=getbag;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
}		
if (id==null) {
		document.getElementById('miniBag').innerHTML="<img src='images/whiteajax-loader.gif' alt='loading' style='margin-left:15px;' />";
		var url="ajaxincludes/updatebag.php?";
		url=url+"&sid="+Math.random();
		xmlhttp.onreadystatechange=getbag;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
}
}
function getbag() {
	if (xmlhttp.readyState==4) {
		data=xmlhttp.responseText.split("[BRK]");
		document.getElementById('miniBag').innerHTML=data[0];
		if (data[1]=='&pound;0.00') {
			if (document.getElementById("wholebag") != null) {document.getElementById('wholebag').innerHTML="<div class='warning'>Your bag is empty!</div>";}
			}
		if (data[1]!='&pound;0.00') {
		if (document.getElementById("subprice") != null) {document.getElementById('subprice').innerHTML=data[1];}
		if (document.getElementById("grandprice") != null) {document.getElementById('grandprice').innerHTML=data[2];}
		if (document.getElementById("checkout") != null) {document.getElementById('checkout').innerHTML=data[3];}
		}
	}
}
function GetXmlHttpObject() {
if (window.XMLHttpRequest) { return new XMLHttpRequest(); }
if (window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP"); }
return null;
}