var AjaxerXHRMapper=new Array();

function Ajaxer(url)
{
   try {  this.xmlRequest = new ActiveXObject('Msxml2.XMLHTTP');}
    catch (e) 
    {
        try {   this.xmlRequest = new ActiveXObject('Microsoft.XMLHTTP');}
        catch (e2) 
        {
          try {  this.xmlRequest = new XMLHttpRequest();}
          catch (e3) {  this.xmlRequest = false;}
        }
     }

    this.url = url;
    this.response='XML';
    this.callback=function () {}; // do nothing
    this.extra='';

	this.registerCallback=function(callbackFunction,extra)
	{
    	this.callback=(callbackFunction);
    	this.extra=extra;
  	};

//  	this.xmlRequest.ajaxer=this;

	var self=this;
    this.xmlRequest.onreadystatechange = function()
    {
        if (self.xmlRequest.readyState == 4)
        {
        	if(self.response=='XML')
        	{
				self.callback(self.xmlRequest.responseXML,self.extra);
			}
			else
				self.callback(self.xmlRequest.responseText,self.extra);
        }
    };

    this.execute=function()
    {
		this.xmlRequest.open("GET", this.url , true);
		this.xmlRequest.send(null);
    };

    this.call=function(param)
    {
		this.callback(param);
    };
}

function getElementByXMLid(node,id) {
	//get all the tags in the doc
	tagsNode = node.getElementsByTagName('*');
	for (i=0;i<tagsNode.length;i++) {
	//is there an id attribute?
		if(tagsNode[i].hasAttribute)
		{
			if (tagsNode[i].hasAttribute('id'))
			{
			//if there is, test its value
			
				if (tagsNode[i].getAttribute('id') == id)
				{
					//and return it if it matches
					return tagsNode[i];
				}
			}
		}
		else
		{
			if (tagsNode[i].getAttribute('id') == id)
			{
				//and return it if it matches
				return tagsNode[i];
			}	
		}
	}
	return null;
}

function getElementByTag(node,tag,elementPosition) {
	//get all the tags in the doc
	elementPosition = elementPosition||0;
	tagsNode = node.getElementsByTagName(tag);
	if(tagsNode[elementPosition]!=undefined)
	{
		return tagsNode[elementPosition];
	}
	return null;
}