function createRequestObject(){
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		request_o = new XMLHttpRequest();
	}
	
	/*if (!request_o) { alert('Objet not created');} else { alert('Object created');	}	*/
	
	return request_o; //return the object
}

var http = createRequestObject(); 

/* Function called to get the product categories list */

function showDetailsPaper(str,str1){
	http.open('get','../devis/ajax_get_paper.php?product_label='+str+'&form_id=' + str1);
	http.onreadystatechange = handleProducts; 
	http.send(null);
}

/* Function called to handle the list that was returned from the internal_request.php file.. */
function handleProducts(div){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
			//document.write(response);
			document.getElementById('paper').innerHTML = response;
	}
}

function showDetailsFormat(str){
	http.open('get','../devis/ajax_get_format.php?product_id=' + str);
	http.onreadystatechange = handleProducts; 
	http.send(null);
}

/* Function called to handle the list that was returned from the internal_request.php file.. */
function handleProducts(div){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
			//document.write(response);
			document.getElementById('paper').innerHTML = response;
	}
}


