	
	//functions.js
	
	//Create a boolean variable to check for a valid IE instance.
	var xmlhttp = false;
	
	//Check if we are using IE.
	try {
		//If the javascript version is greater than 5.
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		//If not, then use the older active x object.
		try {
			//If we are using IE.
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			//Else we must be using a non-IE browser.
			xmlhttp = false;
		}
	}
	
	//If we are using a non-IE browser, create a JavaScript instance of the object.
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	
	//A variable used to distinguish whether to open or close the calendar.
	var showCalendar = true;
	
	function AddProductsxxxxx(products_id) {
		
		//The location we are loading the page into.
		var objID = "basket";
		
		//Change the current image of the minus or plus.
			var serverPage = "basket.php";
			//Set the open close tracker variable.
			
			var obj = document.getElementById(objID);
			xmlhttp.open("GET", serverPage);
			xmlhttp.onreadystatechange = function() {
				if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
					obj.innerHTML = xmlhttp.responseText;
				}
	}
	
	}
	
	
	
	function AddProducts(products_id,qty) {

		var serverPage = "basket.php?products_id="+products_id+"&cart_quantity=" +qty;
		var obj = document.getElementById("basket");
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				obj.innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);
	}
	


	function addAllRecipe(recipes_id) {

		var serverPage = "basket.php?recipes_id="+recipes_id;
		var obj = document.getElementById("basket");
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				obj.innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);
	}
	

	function addAllPastOrders(orders_id) {

		var serverPage = "basket.php?past_orders_id="+orders_id;
		var obj = document.getElementById("basket");
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				obj.innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);
	}
	
	
	
	
	
	function AddProductsBasket(products_id,qty,action) {

		var serverPage = "basket.php?products_id="+products_id+"&cart_quantity=" +qty+"&quantity_action=" +action;
		var obj = document.getElementById("basket");
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				obj.innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);
	}	
	
	
	
	
	
	
	
	
	function DeleteProducts(customers_basket_id) {

		var serverPage = "basket.php?customers_basket_id="+customers_basket_id;
		var obj = document.getElementById("basket");
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				obj.innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);
	}

	
	
	function makerequest(serverPage, objID) {
		
		var obj = document.getElementById(objID);
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				obj.innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);
	}
	
	
	function verifyPromoCode(promotional_code, customers_id, has_discount, total, delivery_group) {

		var serverPage = "promo_code.php?promotional_code="+promotional_code +"&customers_id=" +customers_id+"&has_discount=" +has_discount+"&total=" +total+"&delivery_group=" +delivery_group;
		var obj = document.getElementById("promotional_code");
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				obj.innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);
	}	
	
	
	
	
function verifyPromoCodeTemp(promotional_code, customers_id, has_discount, total, delivery_group){
  $('#promotional_code').load("promo_code.php?promotional_code="+promotional_code +"&customers_id=" +customers_id+"&has_discount=" +has_discount+"&total=" +total+"&delivery_group=" +delivery_group);
  $('#orderTotal').load("subtotal.php");
}
	
	
	
	
		function notifyStock(pID,cname,cemail,scode) {

		var serverPage = "notify_me.php?pID="+pID+"&cname=" +cname+"&cemail=" +cemail+"&scode=" +scode;
		var obj = document.getElementById("notify");
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				obj.innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);
	}


		function callBack(cname,cnumber) {

		var serverPage = "call_me.php?cname=" +cname+"&cnumber=" +cnumber;
		var obj = document.getElementById("notify");
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				obj.innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);
	}



	function CalculateDelivery(delivery,total_paid) {
		erro=0;
		var col_array = delivery.split("!");
		var part_num=0;
		
		//total_final = eval(delivery) + eval(total_paid);
		total_final = eval(col_array[2]) + eval(total_paid);

		//total_final = col_array[1];		
		//total_final = total_paid;
			
		if(col_array[2] == 0){
		
			col_array[2] = '0.00';
		}
			
		document.getElementById("delivery_charge").innerHTML = col_array[2];
		
		totalAmount = Math.round(total_final*100)/100;
		document.getElementById("total_amount_order").innerHTML =  '&pound;' + totalAmount ;	
}



function CalculateDeliveryAjax(delivery){
   
   var col_array = delivery.split("!");
   
   col_array[2] = Math.round(col_array[2]*100)/100;

   $('#orderTotal').load("subtotal.php?delivery_price="+col_array[2]);
}


/*
	function CalculateDeliveryAjax(delivery,total_paid) {
		erro=0;
		var col_array = delivery.split("!");
		var part_num=0;
		
		//total_final = eval(delivery) + eval(total_paid);
		total_final = eval(col_array[2]) + eval(total_paid);

		//total_final = col_array[1];		
		//total_final = total_paid;
			
		if(col_array[2] == 0){
		
			col_array[2] = '0.00';
		}
		
		
		
			
		document.getElementById("delivery_charge").innerHTML = col_array[2];
		
		totalAmount = Math.round(total_final*100)/100;
		document.getElementById("total_amount_order").innerHTML =  '&pound;' + totalAmount ;	
}


*/



		function getPayment(selected, deliveryLocation) {
				
		  var i = selected.selectedIndex;  
		  payment_method(selected.options[i].value, deliveryLocation); 
		}




	function payment_method(pmethod, deliveryLocation) {
		var serverPage = "payment_select.php?pmethod="+pmethod+"&deliveryLocation="+deliveryLocation;
		var obj = document.getElementById("pmethod");
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				obj.innerHTML = xmlhttp.responseText;
			}
			

		}
		
		xmlhttp.send(null);
		
		
	}
	
	
	function payment_billing(pmethod) {
		var serverPage = "payment_billing.php?pmethod="+pmethod;
		var obj = document.getElementById("pbilling");
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				obj.innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);
	}
	
	function cvv2(pmethod) {
		var serverPage = "cvv2.php?pmethod="+pmethod;
		var obj = document.getElementById("cvv2");
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				obj.innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);
	}
	
	
	function cvv2Amex(pmethod) {
		var serverPage = "cvv2Amex.php?pmethod="+pmethod;
		var obj = document.getElementById("cvv2");
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				obj.innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);
	}
	
	

     function toggleMore(id,more,dots) {  
         var state = document.getElementById(id).style.display; 
         var stateMore = document.getElementById(more).style.display;  
          
             if (state == 'inline') {  
                 document.getElementById(id).style.display = 'none';  
                 document.getElementById(more).style.display = 'inline'; 
                 document.getElementById(dots).style.display = 'inline';  
                  
                 
             } else {  
                 document.getElementById(id).style.display = 'inline';  
                 document.getElementById(more).style.display = 'none';  
                 document.getElementById(dots).style.display = 'none';  
             }  
         }  





function updateContents(products_id, cart_quantity, inBasketID ){
  $('#basket').load("basket.php?products_id="+products_id+"&cart_quantity="+cart_quantity);
  $(inBasketID).load("basketQty.php?products_id="+products_id);
}


function updateContentsBasket(products_id, qty, action, inBasketID ){
  $('#basket').load("basket.php?products_id="+products_id+"&cart_quantity="+qty+"&quantity_action=" +action);
  $(inBasketID).load("basketQty.php?products_id="+products_id);
  
}


function updateContentsBasketPics(products_id, qty, action){
  //$('#basketPage').load("basket_pics.php?products_id="+products_id+"&cart_quantity="+qty+"&quantity_action=" +action);
  $('#basketPage').load("basket_pics.php?products_id="+products_id+"&qty=" +qty+"&action=" +action);
 // $(inBasketID).load("basketQty.php?products_id="+products_id);
  
}



jQuery(function() {
	jQuery("#suggest").suggest("getSuggestions.php",{
	onSelect: function() {
	 $("#search_mini_form").submit();
	
	}});
});









