

// Class for replacing HTML using XSL transformation

function BxContent ()
{
}

BxContent.prototype.replace = function (elem, sXML, sXSL)
{
    if (!sXML.length) sXML = aBxConfig['urlRoot'] + "Util/empty_xml/";
    if (!sXSL) return false;

	showScreen();

	var $this = this;
  
    var e = 'string' == (typeof elem) ? $(elem) : elem;
    if (!e) return false;

	var h = function (r)
	{
		e.innerHTML = r;
		
		hideScreen();

        $this.onLoadComplete (e);
	}
	
	new BxXslTransform (sXML, sXSL, h);

	return false;
}

BxContent.prototype.fillCombo = function (elem, sXML)
{
    if (!sXML) return false;

    showScreen();

    var $this = this;

    var e = 'string' == (typeof elem) ? $(elem) : elem;
    if (!e) return false;

   	var h = function (r)
    {
        var items = r.responseXML.getElementsByTagName('item');
        e.options.length = 0;
	    for (var i = 0; i < items.length; i++)
    	{
        	var id = items[i].firstChild.firstChild.nodeValue;            
			var name = items[i].firstChild.nextSibling.firstChild.nodeValue;
	    	
            e.options[e.options.length] = new Option(name, id);
        }

        hideScreen();

        e.disabled = false;
        if (e.options[0]) e.options[0].selected = true;
        
        $this.onLoadComplete (e);
    }

    new BxXmlRequest(sXML, h, 1);

    return false;
}

BxContent.prototype.onLoadComplete = function (e)
{
    return true;
}
