var http_request = false;		// Initialize request to false

// Create request object trying a variaty of different options
if(window.XMLHttpRequest){
	http_request = new XMLHttpRequest();
	if(http_request.overrideMimeType){
		http_request.overrideMimeType('text/plain');
	}
} else if (window.ActiveXObject) {
	try {
		http_request = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (eothermicrosoft) {
		try {
			http_request = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (failed) {
			http_request = false;
	   }//end try
	}//end try
}//end if

// Check if the server request object was created successfully
if (!http_request) {  
	alert("Error initializing XMLHttpRequest!");
	//return false;
}//end if

// This function will produce the server request
function getFullCoupon (id, seq) {
	// Create the URL to send with request
	var url = "/coupons/components/ShowCouponAjax.php?id=" + id + "&seq=" + seq;		
		
	// Set up and send new request to server
	http_request.open('GET', url, true);
	http_request.onreadystatechange = updatePage;
	http_request.send('');
}//end getFullCoupon()

// This function will be called when a successfull response is sent back from the server
function updatePage (){
	// Check if the server response is complete
	if(http_request.readyState == 4){
		// Check if server successfully loaded page
		if(http_request.status == 200) {
			document.getElementById("fullcoupon").innerHTML = http_request.responseText;
			
			document.getElementById("blockUI").style.display = "block";
			document.getElementById("fullcoupon").style.display = "block"; 

		} else if (http_request.status == 404){
			alert("Request URL does not exist");
		} else {
			alert("Error: status code is " + http_request.status);
		}//end if
	}//end if
}//end updatePage()

function hideFullCoupon (){
	document.getElementById("blockUI").style.display = "none";
	document.getElementById("fullcoupon").style.display = "none"; 
}//end hideFullCoupon()
