function $(TagID) { return document.getElementById(TagID); }
function $innerHTML(TagID, data) { var el = document.getElementById(TagID); if (el != null) el.innerHTML = data; }

function GetHttpObject()
{ 
var req = false;
if(window.XMLHttpRequest) {
try {
	req = new XMLHttpRequest();
} catch(e) {
	req = false;
}
// branch for IE/Windows ActiveX version
} else if(window.ActiveXObject) {
try {
    req = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
    try {
        req = new ActiveXObject("Microsoft.XMLHTTP");
    } catch(e) {
        req = false;
    }
}
}
  return req;
}
function WriteLoadingToInnerHTML(DivName) {
/*
	var div = $(DivName);
	var filename = 'working.gif';
	var text = '<p align=center><img src="../Images/'+filename+'" border=0></p>';
	if(div != null) {
	    if(div.innerHTML.indexOf(filename) == -1) { div.innerHTML = text; }
	}
*/	
}
function WriteError(DivName, Text) { $innerHTML(DivName, '<br><FONT color=Red>'+Text+'</FONT><br>');  }

var  XmlHttp;

////
function sendCommand(url)
{
XmlHttp = GetHttpObject();
if( XmlHttp ) {
XmlHttp.open("Get", url, true);
XmlHttp.send("");
} }
////
function getDataToInnerHTML(DivName, url)
{
XmlHttp = GetHttpObject();
if( XmlHttp ) {
XmlHttp.onreadystatechange = function () {
  if( XmlHttp && XmlHttp.readyState == 4 )
  {
    if( XmlHttp.status == 200 && XmlHttp.statusText == "OK" ) {
		$innerHTML(DivName, XmlHttp.responseText);
    } else {
		WriteError(DivName, XmlHttp.statusText);
    }
	XmlHttp = null;
  } else {
	WriteLoadingToInnerHTML(DivName);
  }
}
XmlHttp.open("Get", url, true);
XmlHttp.send("");
} }
////
function getDataToInnerHTMLAndRunScript(DivName, url, func_name)
{
XmlHttp = GetHttpObject();
if( XmlHttp ) {
XmlHttp.onreadystatechange = function () {
  if( XmlHttp.readyState == 4 )
  {
    if( XmlHttp.status == 200 && XmlHttp.statusText == "OK" ) {
		$innerHTML(DivName, XmlHttp.responseText);
		eval(func_name+'();');
    } else {
		WriteError(DivName, XmlHttp.statusText);
    }
	XmlHttp = null;
  } else {
	WriteLoadingToInnerHTML(DivName);
  }
}
XmlHttp.open("Get", url, true);
XmlHttp.send("");
} }
///
function getInfoToInnerHTML(DivName, url) {
XmlHttp = GetHttpObject();
if( XmlHttp ) {
XmlHttp.onreadystatechange = function (){
  if( XmlHttp.readyState == 4 )
  {
    if( XmlHttp.status == 200 && XmlHttp.statusText == "OK" ) {
		$innerHTML(DivName, XmlHttp.responseText);
    } else {
		WriteError(DivName, XmlHttp.statusText);
    }
	XmlHttp = null;
  }
}
XmlHttp.open("Get", url, true);
XmlHttp.send("");
}}
///
function RunAspxPageCommand(DivName, url) {
XmlHttp = GetHttpObject();
if( XmlHttp ) {
XmlHttp.onreadystatechange = function () {
  if( XmlHttp.readyState == 4 )
  {
    if( XmlHttp.status == 200 && XmlHttp.statusText == "OK" ) {
		this.window.close();
    } else {
		WriteError(DivName, XmlHttp.statusText);
    }
	XmlHttp = null;
  } else {
	WriteLoadingToInnerHTML(DivName);
  }
}
XmlHttp.open("Get", url, true);
XmlHttp.send("");
}}
///
function getInfoToInnerHTMLPOST(DivName, url) {
XmlHttp = GetHttpObject();
if( XmlHttp ) {
XmlHttp.onreadystatechange = function (){
  if( XmlHttp.readyState == 4 )
  {
    if( XmlHttp.status == 200 && XmlHttp.statusText == "OK" ) {
		$innerHTML(DivName, XmlHttp.responseText);
    } else {
		WriteError(DivName, XmlHttp.statusText);
    }
	XmlHttp = null;
  }
}
XmlHttp.open("POST", url, true);
XmlHttp.send($(DivName).value);
}}
///
function sendDataToInnerHTMLPOST(DivName, url, data) {
XmlHttp = GetHttpObject();
if( XmlHttp ) {
XmlHttp.onreadystatechange = function (){
  if( XmlHttp.readyState == 4 )
  {
    if( XmlHttp.status == 200 && XmlHttp.statusText == "OK" ) {
		$innerHTML(DivName, XmlHttp.responseText);
    } else {
		WriteError(DivName, XmlHttp.statusText);
    }
	XmlHttp = null;
  } else {
	WriteLoadingToInnerHTML(DivName);
  }
}
XmlHttp.open("POST", url, true);
XmlHttp.send(data);
}}
///
///
function sendDataToInnerHTMLPOSTAndRunScript(DivName, url, data, func_name) {
XmlHttp = GetHttpObject();
if( XmlHttp ) {
XmlHttp.onreadystatechange = function (){
  if( XmlHttp.readyState == 4 )
  {
    if( XmlHttp.status == 200 && XmlHttp.statusText == "OK" ) {
		$innerHTML(DivName, XmlHttp.responseText);
		eval(func_name+'();');
    } else {
		WriteError(DivName, XmlHttp.statusText);
    }
	XmlHttp = null;
  } else {
	WriteLoadingToInnerHTML(DivName);
  }
}
XmlHttp.open("POST", url, true);
XmlHttp.send(data);
}}
///
function sendDataToInnerHTMLPOSTAndReload(url, data) {
XmlHttp = GetHttpObject();
if( XmlHttp ) {
XmlHttp.onreadystatechange = function (){
  if( XmlHttp.readyState == 4 )
  {
    if( XmlHttp.status == 200 && XmlHttp.statusText == "OK" ) {
        var newUrl = XmlHttp.responseText;
        if(newUrl == null || newUrl == '') newUrl = document.location;
		document.location = newUrl;
    } else {
		//WriteError(DivName, XmlHttp.statusText);
    }
	XmlHttp = null;
  }
}
XmlHttp.open("POST", url, true);
XmlHttp.send(data);
}}
///

