	function ajaxObject(){
    try {
      return new XMLHttpRequest();  // Opera 8.0+, Firefox, Safari
    } catch (e){
      try {
          return new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          return new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e){
          return false;
        }
      }
    }			
	};
	
	function addToBasket(pid){
    var qtyField;
		var pidField;
		
		qtyField = document.getElementById("qty_"+pid);
		pidField = document.getElementById("pid_"+pid);
		
		if (qtyField.value > 0 && pidField.value != ""){
			var codeReq;	
		  if (codeReq = ajaxObject()){
		    codeReq.onreadystatechange = function(){
		      if(codeReq.readyState == 4){
		        alert("Added Successfully");
	  	    }
		    }
	
		    codeReq.open("GET", "dyn/addtobasket.php?qty=" + qtyField.value + "&pid=" + pidField.value, true);
		    codeReq.send(null);
				
			} else {
				alert("Im afraid there is a problem with your browser, you may need to update it to the latest version.");
			}
		}
		
		return false;
	};
	
	function updateBasket(){
    var smallBasket;
		
		smallBasket = document.getElementById("basketLocation");
		pidField = document.getElementById("pid_"+pid);
		
		if (qtyField.value > 0 && pidField.value != ""){
			var codeReq;	
		  if (codeReq = ajaxObject()){
		    codeReq.onreadystatechange = function(){
		      if(codeReq.readyState == 4){
		        alert("Added Successfully");
	  	    }
		    }
	
		    codeReq.open("GET", "dyn/addtobasket.php?qty=" + qtyField.value + "&pid=" + pidField.value, true);
		    codeReq.send(null);
				
			} else {
				alert("Im afraid there is a problem with your browser, you may need to update it to the latest version.");
			}
		}
		
		return false;
	};
		

