function ajaxObject(url, callbackFunction) {
	var that=this;      
	this.updating = false;
	this.abort = function() {
		if (that.updating) {
			that.updating=false;
			that.AJAX.abort();
			that.AJAX=null;
		}
	}
	this.update = function(passData,postMethod) { 
		if (that.updating) { 
			return false; 
		}
		that.AJAX = null;                          
		if (window.XMLHttpRequest) {              
			that.AJAX=new XMLHttpRequest();              
		} 
		else {                                  
			that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");
		}                                             
		if (that.AJAX==null) {                             
			return false;                               
		} 
		else {
			that.AJAX.onreadystatechange = function() {  
				if (that.AJAX.readyState==4) {             
					that.updating=false;                
					that.callback(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML);        
					that.AJAX=null;                                         
				}                                                      
			}                                                        
			that.updating = new Date();                              
			if (/post/i.test(postMethod)) {
				var uri=urlCall+'?'+that.updating.getTime();
				that.AJAX.open("POST", uri, true);
				that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				that.AJAX.setRequestHeader("Content-Length", passData.length);
				that.AJAX.send(passData);
			} 
			else {
				var uri=urlCall+'?'+passData+'&amp;timestamp='+(that.updating.getTime()); 
				that.AJAX.open("GET", uri, true);                             
				that.AJAX.send(null);                                         
			}              
			return true;                                             
		}                                                                           
	}	
	var urlCall = url;        
	this.callback = callbackFunction || function () { };
}

function processData(responseText, responseStatus) {
	if (responseStatus!=200) {
		alert(responseStatus + ' -- Error Processing Request');
	}
}

function pleaseClearMe(Me){
	Me.value="";
}

function priceify(num){
	num = num.toString();
	if (num.indexOf('.') == 0){
		num += '.00';
	}
	else if (num.indexOf('.') == num.length -2){
		num += '0';
	}
	return(num);
}


function changeQuantity(quantity, prod){
	//alert(quantity.value);
	if((quantity.value == 0) || (isInteger(quantity.value) == false)){	//if they change it back to "Please Select..."
		document.getElementById("myShipping").setAttribute("disabled", "disabled");
		document.getElementById('buyOnline').style.display = "none";
		document.getElementById("priceCalc").innerHTML = "";
	}
	else{						//on change to valid entry
		//change bottle text
		var priceCalc = document.getElementById("priceCalc");
		var price = quantity.value * 7.95;
		priceCalc.innerHTML = ("Price: £" + priceify(price));
		if(price > 50){
			priceCalc.innerHTML += " + Free Postage!";
		}
		else{
			priceCalc.innerHTML += " + &pound;1.95 <span id='pnp'>p&amp;p</span>";
		}
	}
}

function buyOnline(){
	document.getElementById('buyOnline').style.display = "inline";
}

isInteger = function( s ) {
	return !isNaN(parseInt(s));
}

function viewCart(){
	document.viewCart.submit() ;
}

function viewCartTop(){
	document.viewCartTop.submit() ;
}


function addToCart(){
	document.addToCart.submit() ;
}

