// The path of where the PHP script
var phpscript = '/dmgshop/includes/ajax.asp?f=';

// Create the Divtag Handler -- Mainly an IE 6 Fix 
var divhandler = new handleDivTag(null); 
var timestamp = new Date().getTime();

// Function for making the AJAX object
function createRequestObject() {
   var request;
	// Firefox, Safari, Opera... 
	if(window.XMLHttpRequest){ 
		request = new XMLHttpRequest();
	// Internet Explorer 5+ 
   	} else if(window.ActiveXObject) {
      	request = new ActiveXObject("Msxml2.XMLHTTP");
	// There is an error or an old browser is being used.
	} else if(window.ActiveXObject) {
      	request = new ActiveXObject("Microsoft.XMLHTTP");
	// There is an error or an old browser is being used.
	}else {
		request = null;
		alert('Problem creating the XMLHttpRequest object');
   	}
   	return request;
} 

// Creating the divtag object
function handleDivTag(divtag) { 
   var divtag; 
   return divtag; 
} 

// Make the XMLHttpRequest object 
var http = createRequestObject(); 

// Main AJAX request function, called via event handlers
function sendRequest(act, value1, value2, value3, divtag) { 
	// Open PHP script for requests and send values via GET
	//alert(phpscript+act+'&value1='+value1+'&value2='+value2+'&value3='+value3+'&timestamp='+timestamp);
   http.open('get', phpscript+act+'&value1='+value1+'&value2='+value2+'&value3='+value3+'&timestamp='+timestamp); 
   // When ready, handle the response
   http.onreadystatechange = handleResponse;
   // Pass the divtag through
   divhandler.divtag = divtag;
   // Send nothing (GET has already passed values)
   http.send(null);
}

function handleResponse() { 
	// Checking if server is ready
	if(http.readyState == 4){
		if(http.status == 200){ 
		var response = http.responseText; 
			//alert(response);
			document.getElementById(divhandler.divtag).innerHTML = response;
		}else{ 
			alert("ERROR! Request status is "+ http.status); 
		}
	}
}
