function ajaxFunction(scriptName, id, elementToReplace) {

	// The variable that makes Ajax possible
	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("Your browser does not support AJAX");
				return false;
			}
		}
	}
	
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function() {
		if (ajaxRequest.readyState == 4) {
			document.getElementById(elementToReplace).innerHTML = ajaxRequest.responseText;
			//alert(ajaxRequest.responseText);
		}
	}
	
	var get_vars = "?id=" + id + "&rand=" + new Date().getTime()
	
	ajaxRequest.open("GET", scriptName + get_vars, true);
	ajaxRequest.send(null); 
	
}


function activateSeries(manufacturer_id) {
	document.getElementById('series').style.backgroundPosition='0 -184px';
	ajaxFunction('/scripts/activateSeries.php', manufacturer_id, 'series-select');
	document.getElementById('printer-select').innerHTML='<select name="printer" size="1" disabled="disabled"><option value="">-- Select --</option></select>';
}

function activatePrinter(series_id) {
	document.getElementById('printer').style.backgroundPosition='0 -184px';	
	ajaxFunction('/scripts/activatePrinter.php', series_id, 'printer-select');
}

/*function activateCartridge(printer_id) {
	window.location='/list-cartridges.php?printer='+printer_id;
}*/

function activateCartridge(url) {
	window.location=url;
}
