Function Xajax ()
{
If (xajaxDebug) this. DebugMessage = function (text) {alert ("Xajax Debug: n" + text )};
This. workId = ''xajaxwork'' + new Date (). getTime ();
This. depth = 0;
// Get the XMLHttpRequest Object
This. getRequestObject = function ()
{
If (xajaxDebug) this. DebugMessage ("Initializing Request Object ..");
Var req;
Try
{
Req = new ActiveXObject ("Msxml2.XMLHTTP ");
}
Catch (e)
{
Try
{
Req = new ActiveXObject ("Microsoft. XMLHTTP ");
}
Catch (e2)
{
Req = null;
}
}
If (! Req & typeof XMLHttpRequest! = "Undefined ")
Req = new XMLHttpRequest ();
If (xajaxDebug ){
If (! Req) this. DebugMessage ("Request Object Instantiation failed .");
}
Return req;
}
// Xajax. $ () is shorthand for document. getElementById ()
This. $ = function (sId) // $ what is it?
{
Return document. getElementById (sId );
}
// Xajax. include (sFileName) dynamically encoded des an external javascript file
This. include = function (sFileName)
{
Var objHead = document. getElementsByTagName (''head '');
Var objScript = document. createElement (''script '');
ObjScript. type = ''text/javascript '';
ObjScript. src = sFileName;
ObjHead [0]. appendChild (objScript );
}
// Xajax. addHandler adds an event handler to an element
This. addHandler = function (sElementId, sEvent, sFunctionName)
{
If (window. addEventListener)
{
// What does eval mean?
Eval ("this. $ (''" + sElementId + "''). addEventListener (''" + sEvent + "'', "+ sFunctionName +", false );");
}
Else
{
Eval ("this. $ (''" + sElementId + "''). attachEvent (''on "+ sEvent +" ''," + sFunctionName + ", fal **);");
}
}
// * Ajax. removeHandler removes an event handler from an element
This. removeHandler = function (sElementId, sEvent, sFunctionName)
{
If (window. addEventListener)
{
Eval ("this. $ (''" + sElementId + "''). removeEventListener (''" + sEvent + "'', "+ sFunctionName +", false );");
}