// All functions have the prefix T_ for Tools

function T_createRequest()
{
 var obj = null;   
   
 if(window.XMLHttpRequest)     obj = new XMLHttpRequest();			// Firefox      
 else if(window.ActiveXObject) obj = new ActiveXObject("Microsoft.XMLHTTP");	// Internet Explorer   
 else return null;

 return obj; 
}

function T_asynchRequest(url, parameters, mainFunc, loadFunc)
{
 var test = 0;

 userData = T_createRequest();
 if(userData == null) return;

 userData.open("POST", url, true);
 userData.onreadystatechange = function()
 {
  if(userData.readyState == 4)	if(mainFunc) mainFunc(userData.responseText);
  else							if(loadFunc) loadFunc(userData.readyState);
 }
 userData.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
 userData.send(parameters);
 
 return test;
}

function T_showWindow(windowHnd, mode)
{
 document.getElementById('screen').style.display = mode;
 document.getElementById(windowHnd).style.display = mode;
}

function T_centerWindow(windowHnd)
{
 windowHnd = document.getElementById(windowHnd);
 
 var W = document.body.offsetWidth;
 var w = parseInt(windowHnd.style.width.substr(0, windowHnd.style.width.length-2));
 var H = document.body.offsetHeight;
 var h = parseInt(windowHnd.style.height.substr(0, windowHnd.style.height.length-2));
 
 windowHnd.style.left = ((W-w)*0.5)+"px";
 windowHnd.style.top = ((H-h)*0.5)+"px";
}