﻿// JScript File
var _timerTransactionTime = 0;
function xmlhttpPost(strURL, post, onResponse) {
    var xmlHttpReq = false;
    var self = this;

	function onTimeout()
	{
		self.xmlHttpReq.abort();
		//onResponse('Timeout'+self.i);
	}
    // IE
    if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }else
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.setRequestHeader('Connection', 'close');
    self.xmlHttpReq.setRequestHeader('Cache-Control', 'no-cache');
    
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4 && onResponse) {
            onResponse(self.xmlHttpReq.responseText);
            var now = new Date();
            _timerTransactionTime = (now - _timerStartTime)/1000;
        }
    }
	window.setTimeout(onTimeout, 3000);
	_timerStartTime = new Date();
    self.xmlHttpReq.send(post);
	return self.xmlHttpReq;
}
