function createHttpRequest(){
  if(window.ActiveXObject){
    try {
      return new ActiveXObject("Msxml2.XMLHTTP")
    } catch (e) {
      try {
        return new ActiveXObject("Microsoft.XMLHTTP")
      } catch (e2) {
        return null
      }
    }
  } else if(window.XMLHttpRequest){
    return new XMLHttpRequest()
  } else {
    return null
  }
}

var timerID;
var httpoj;

function requestFile( data , method , fileName , async, callback ) {
  httpoj = createHttpRequest();
  
  httpoj.open( method , fileName , async );
  
  timerID = setTimeout("HttpAbort('Sorry, Connection Timeout...')",9000);
  
  data = encodeURI(data);
  
  httpoj.onreadystatechange = function() { 
    if (httpoj.readyState==4 && httpoj.status==200) {
      clearInterval(timerID);
      callback(httpoj);
    }
  }
  if(method == 'POST') {
    if(!window.opera) {
      httpoj.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    }
  }

  httpoj.send( data );

}
function HttpAbort(msg){
  if (httpoj.readyState == 0 || httpoj.readyState == 4) return;
  httpoj.abort();
  window.alert(msg);
  clearTimeout(timerID);
}


