	/**
	*	Javascript function to add a produt
	*
	*/
	
	function addToBasket(productid,baseurl,language,messageTitle,animate) {
		
		// Fetch quantity value
		var quantity = document.getElementById('product'+productid+'quantityfield').value;
		
		// Isolate the basket form for the product to add
		var basketForm = document.getElementById('product'+productid+'basketform');
		
		// Loop through elements on the current products' form backwards to find the last variation select
		var selectedvariant = '';
		for(i=basketForm.elements.length-1; i>=0; i--) {
			var currentElement = basketForm.elements[i];
			if(currentElement.name.substring(0,9) == "variation") {
				selectedvariant = currentElement.value;
				break;
			}
		}
		
		var ajaxRequest;
		
		try {
			// Opera 8.0+, Firefox, Safari
			ajaxRequest = new XMLHttpRequest();
		} catch (e) {
			// Internet Explorer Browsers
			try {
				ajaxRequest = new ActiveXObject('Msxml2.XMLHTTP');
			} catch (e) {
				try {
					ajaxRequest = new ActiveXObject('Microsoft.XMLHTTP');
				} catch (e) {
					// Something went wrong!
					alert('Failed to generate AJAX object.');
					return false;
				}
			}
		}
	
		// Function that will receive data sent from the server
		ajaxRequest.onreadystatechange = function() {
			// Check ready state
			if(ajaxRequest.readyState == 4) {
				displaySystemMessage(ajaxRequest.responseText, messageTitle, 'infoMessage', animate);
				
				// Check if a shopping basket summary is on the page (and will require updating)
				if(document.getElementById('shopping_basket_summary')) {
					try {
						// Opera 8.0+, Firefox, Safari
						ajaxRequest = new XMLHttpRequest();
					} catch (e) {
						// Internet Explorer Browsers
						try {
							ajaxRequest = new ActiveXObject('Msxml2.XMLHTTP');
						} catch (e) {
							try {
								ajaxRequest = new ActiveXObject('Microsoft.XMLHTTP');
							} catch (e) {
								// Something went wrong!
								alert('Failed to generate AJAX object.');
								return false;
							}
						}
					}
					
					ajaxRequest.onreadystatechange = function() {
						// Check ready state
						if(ajaxRequest.readyState == 4) {
							document.getElementById('shopping_basket_summary').innerHTML = ajaxRequest.responseText;
						}
					};
					
					ajaxRequest.open('GET', baseurl+'/includes/ajaxfunctions/shopping_basket_summary.php?language='+language, true);
					ajaxRequest.send(null);
				}
			}
		};
		
		ajaxRequest.open('GET', baseurl+'/includes/ajaxfunctions/add_to_basket.php?productid='+productid+'&quantity='+quantity+'&selectedvariant='+selectedvariant+'&language='+language, true);
		ajaxRequest.send(null);
		
	}