	
	function getXMLHTTPRequest () {
		try {
			req = new XMLHttpRequest ();
		} catch (err1) {
			try {
				req = new ActiveXObject ("Msxml2.XMLHTTP");
			} catch (err2) {
				try {
					req = new ActiveXObject ("Microsoft.XMLHTTP");
				} catch (err3) {
					req = false;
				} 
			} 
		}
		return req;
	}
	
	var http = getXMLHTTPRequest ();
	
	function updateBasket (action, prodid) {
		var actionurl = 'baskethandler.php?' + action + '=' + prodid;
		randno = parseInt (Math.random () * 999999999999999);
		var modurl = actionurl + "&rand=" + randno;  
		http.open ("GET", modurl, true);
		http.onreadystatechange = useHttpResponse;
		http.send (null);
	}
	function useHttpResponse () {
		if (http.readyState == 4) {
			if (http.status == 200) {
				document.getElementById ('basket').innerHTML = http.responseText;
			} else {
				document.getElementById ('basket').innerHTML = 'Fatal error processing basket!';
			}
		}
	}
	
	function positionbasketwrapper () {
		if ((thispos != Math.max ((document.body.scrollTop - offset + upperLimit), initialPos)) && (!moving) ) {
			var launch = new Date ();
			start = launch.valueOf ();
			target = Math.min (Math.max((document.body.scrollTop - offset + upperLimit), initialPos), lowerLimit);
			C = thispos - target;
			moving = 1;
			movebasketwrapper ();
			positionbasketwrapper ();
		}
		setTimeout ("positionbasketwrapper ()", 1000);
	}
	function movebasketwrapper () {
		var going = new Date ();
		now = going.valueOf ();
		t = (now - start) / 1000;
		with (Math) { thispos = target + C*exp(-10*t)*sin(3*t+(PI/2)); }
		document.getElementById ("basketwrapper").style.top = thispos + 'px';
		if (t > 0.7) {
			if (Math.abs (thispos - Math.max ((document.body.scrollTop + upperLimit), initialPos)) < 3) document.getElementById ("basketwrapper").style.top = Math.max ((document.body.scrollTop + upperLimit), initialPos);
			thispos = parseInt (document.getElementById ("basketwrapper").style.top);
			moving = 0;
			return 1;
		} else {
			setTimeout ("movebasketwrapper ()", 5);
		}
	}
