var  ordine;
function callRequest(orderId, step_id){
	custTextValue = document.getElementById("custom_text"+orderId).value;
	makeRequest('http://www.thatsarte.com/doCustomization.php?step_id='+step_id+'&orderId='+orderId+'&customText='+custTextValue,orderId);
	ordine = orderId;
} 
var http_request = false;
function makeRequest(url,orderId) {
http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/html');
			// See note below about this line
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	http_request.onreadystatechange = customize;
	http_request.open('GET', url, true);
	http_request.send(null);
}

function customize() {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			orderId = ordine;
			targetDiv = document.getElementById("divCustomText"+orderId);
			var loadImgContainer = document.createElement('div');
			var loadImg =  document.createElement('img');
			loadImg.src = "http://www.ajaxload.info/cache/ff/ff/ff/ff/00/00/1-1.gif";
			loadImgContainer.appendChild(loadImg);
			targetDiv.appendChild(loadImgContainer);
			//
			targetDiv.innerHTML = http_request.responseText;
			new Effect.Highlight(targetDiv, {startcolor:'#ffffff', endcolor:'#ffff00'},{duration: 0.5});
			//alert(http_request.responseText+' '+orderId);
		} else {
			alert('There was a problem with the request.');
		}
	}
}
