var xmlSocket = null;



function requestInit(text) {
  if(window.ActiveXObject) {
    xmlSocket = new ActiveXObject("Microsoft.XMLHTTP");
  } else {
    if(window.XMLHttpRequest) {
      xmlSocket = new XMLHttpRequest();
	  //xmlSocket.setRequestHeader("", "close");
	  xmlSocket.setRequestHeader("Connection", "close");
    } else {
      xmlSocket = null;
    }
  }

  //xmlSocket = window.ActiveXObject ? new ActiveXObject ("Microsoft.XMLHTTP") : (window.XMLHttpRequest ? new XMLHttpRequest() : null);

  if(!xmlSocket)
    return;

  var xmlRequest = text;

  requestSend('./request_pop_windows.php', xmlRequest);
}

function requestSend(url, text) {
  if(!xmlSocket)
    return;

  try {
    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
  } catch (e) {}

  xmlSocket.onreadystatechange = sendCallback;
  xmlSocket.open("GET", url, true);
  xmlSocket.send(text);
}

function sendCallback() {
  if(xmlSocket && xmlSocket.readyState == 4 && xmlSocket.status == 200) {
    drawSocketAnswer();
	if (xmlSocket != null){
		xmlSocket.abort();
		xmlSocket = null;
	}
	
  }
 /* if (xmlSocket != null){
  	xmlSocket.abort();
	xmlSocket=null;
  }*/
}

function drawSocketAnswer() {
  //document.getElementById('Text').innerHTML += xmlSocket.responseText;
  //window.scroll(0,getElementTop(document.getElementById('Footer')));
  inStr = xmlSocket.responseText;
  outArray = Array();
  tmp = inStr.split('&');
  for(i in tmp)
  {
    res = tmp[i].split('=');
    eval(res[0] + '("' + res[1] + '");');
	/*outArray[i] = Array();
    outArray[i]['func'] = res[0];
    outArray[i]['param'] = res[1];*/
  }
  
  //xmlSocket=null;
  
  //return(outArray);
}

function getElementTop(obj) {
  var ret_val = 0;
  ret_val = obj.offsetTop;
  objHTMLelement = obj.offsetParent;
  while (objHTMLelement != null) {
    ret_val += objHTMLelement.offsetTop;
    objHTMLelement = objHTMLelement.offsetParent;
  }
  return ret_val;
}



function make_array(inStr)
{
  outArray = Array();
  tmp = inStr.split('&');
  for(i in tmp)
  {
    res = tmp[i].split('=');
    eval(res[0] + '("' + res[1] + '");');
    
	
	
	/*outArray[i] = Array();
    outArray[i]['func'] = res[0];
    outArray[i]['param'] = res[1];*/
  }
  return(outArray);
}
 
//arr = make_array('document.writeln=120&alert=140&alert=12367');


