//#require "base.js"


function XmlDoc_Native() {
}

XmlDoc_Native.create = function() {
	return document.implementation.createDocument("", "xml", null);
}

function XmlDoc_MS() {
}

XmlDoc_MS.create = function() {
	var axml = new ActiveXObject("Microsoft.XMLDOM");
	axml.appendChild(axml.createElement("xml"));
	return axml;
}

function getXmlDocClass() {
	if (document.implementation && document.implementation.createDocument) {
		return XmlDoc_Native;
	}
	else {
		return XmlDoc_MS;
	}
}

var XmlDocument = getXmlDocClass();



/*
* Xslt Processor (Browser unabhängig)
* Funktioniert nicht im Konqueror
* Transformiert ein XML String mit Hilfe eines XSL Files
*/

/*
 * Gemeinsamkeiten aller Implementierungen
 */
function XsltBase() {
}

XsltBase.prototype.mkXslUrl = function(xslFile) {
	return xslFile + "?lang=" + lang + "&xsltOutput="+xsltOutput+"&PHPSESSID=" + getCookie("PHPSESSID");
}


/* ---------------------------------------------------------------------------
 * Browser mit nativem XSLTProcessor
 */
function Xslt_Native() {
	this.processor = null;
}
Xslt_Native.prototype = new XsltBase();


// Lädt das XSL file und iniziert den XSLTProcessor
Xslt_Native.prototype.init = function(xslFile) {
	xslFile = this.mkXslUrl(xslFile);
	this.processor = new XSLTProcessor();
	var xslt;
	try {
		// Mozilla
		xslt = document.implementation.createDocument(
				"http://www.w3.org/1999/XSL/Transform", "xsl", null);
		
		xslt.async = false;
		xslt.load(xslFile);
		this.processor.importStylesheet(xslt);
	}
	catch(e) {
		// Safari
		xslt = new Ajax();
		xslt.asyncron = false;
		xslt.url = xslFile;
		xslt.startPostRequest("");
		this.processor.importStylesheet(xslt.xmlHttpReq.responseXML);
	}
}

// Setzt einen Parameter für den XSLTProcessor
Xslt_Native.prototype.setParameter = function(name, value) {
	this.processor.setParameter(null, name, value);
}

Xslt_Native.prototype.transformToDocument = function(node) {
	return this.processor.transformToDocument(node);
}



/* ---------------------------------------------------------------------------
 * Browser die die Google XSLT-Lib verwendnen
 */
function Xslt_Google() {
	this.processor = null;
}
Xslt_Google.prototype = new XsltBase();


Xslt_Google.prototype.init = function(xslFile) {
	xslFile = this.mkXslUrl(xslFile);
	try {
		var xslt = document.implementation.createDocument(
				"http://www.w3.org/1999/XSL/Transform", "xsl", null);
		xslt.async = false;
		//xslt.load(server + trainerPath +xslFile);
		xslt.load(xslFile);
		this.processor = xslt;
	}
	catch(e) {
		// Safari
		var xslt = new Ajax();
		xslt.asynchron = false;
		//xslt.url = server + trainerPath +xslFile;
		xslt.url = xslFile;
		xslt.startPostRequest("");
		this.processor = xslt.xmlHttpReq.responseXML; //???
	}
	this.cache = {};
}

Xslt_Google.prototype.setParameter = function(name, value) {
	if (this.cache[name])
	{
		this.cache[name].setAttribute("select", "'" + value +"'");
	}
	else
	{
		var xPathExpr = "//xsl:param[@name='"+name+"']";
		var xPath = new XPath();
		xPath.evaluate(xPathExpr, this.processor);
		var param;
		if (param = xPath.iterateNext())
		{
			this.cache[name] = param;
			param.setAttribute("select", "'" + value +"'");
		}
	}
}

Xslt_Google.prototype.transformToDocument = function(node) {
	if (node.ownerDocument)
	{
		return xsltProcess(node, this.processor.documentElement);
	}
	else if (node.documentElement)
	{
		return xsltProcess(node.documentElement, this.processor.documentElement);
	}
}


/* ---------------------------------------------------------------------------
 * IE mit geeigneten ActiveXObjecten
 */
function Xslt_MS() {
	this.processor = null;
}
Xslt_MS.prototype = new XsltBase();

//xsltAjax = new Ajax();
//xsltAjax.asynchron = false;
Xslt_MS.prototype.init = function(xslFile) {
	//logDebug("loading xslt: " + xslFile);
	xslFile = this.mkXslUrl(xslFile);
	var xslDom;
	try {
		xslDom = new ActiveXObject(ActiveX_XSLStylesheet);
	}
	catch (e) {
		//logDebug("Creating ActiveX_XSLTemplate failed (passed on)");
		//logExpt(e, "Creating "+ActiveX_XSLStylesheet+" failed (passed on)");
		throw e;
	}
	xslDom.async = false;
	
	xslDom.load(xslFile);
	if (xslDom.parseError.errorCode != 0) {
		var strErrMsg = "Problem Parsing Style Sheet:\n" +
			" Error #: " + xslDom.parseError.errorCode + "\n" +
			" Description: " + xslDom.parseError.reason + "\n" +
			" In file: " + xslDom.parseError.url + "\n" +
			" Line #: " + xslDom.parseError.line + "\n" +
			" Character # in line: " + xslDom.parseError.linepos + "\n" +
			" Character # in file: " + xslDom.parseError.filepos + "\n" +
			" Source line: " + xslDom.parseError.srcText;
		//logError("Loading Xslt failed:" + xslFile);
		//alert(strErrMsg);
		//throw new Error("loading Xslt failed");
		return false;
	}
	//logDebug("file loaded");
	//var req = xsltAjax.startGetRequest(xslFile, "");
	//xslDom.loadXML(req.xmlHttp.responseText);

	var xslTemplate;
	try {
		xslTemplate = new ActiveXObject(ActiveX_XSLTemplate);
	}
	catch (e) {
		//logDebug("Creating ActiveX_XSLTemplate failed (passed on)");
		//logExpt(e, "Creating "+ActiveX_XSLTemplate+" failed (passed on)");
		throw e;
	}
	xslTemplate.stylesheet = xslDom;
	this.processor = xslTemplate.createProcessor();
}

Xslt_MS.prototype.setParameter = function(name, value) {
	this.processor.addParameter(name, value);
}

Xslt_MS.prototype.transformToDocument = function(node) {
	// Der IE scheint kein XMLDocument zurückgegeben zu können,
	// wenn man die XSLTransformation mit Parameter aufrufen will ...
	this.processor.input = node;
	this.processor.transform();
	var xml = this.processor.output;
	try
	{
		var xmlDoc;
		try {
			xmlDoc = new ActiveXObject(ActiveX_XMLDOM);
		}
		catch (e) {
			logExpt(e, "Creating "+ActiveX_XMLDOM+" failed (passed on)");
			throw e;
		}
		xmlDoc.asyncron = false;
		xmlDoc.loadXML(xml);
		if (xmlDoc.parseError.errorCode != 0)
		{
			//alert("Warning: String created instead of XmlNode or XmlDocument.");
			return xml;
		}
		return xmlDoc;
	}
	catch(e)
	{
		//alert("Warning: String created instead of XmlNode or XmlDocument.");
		return xml;
	}
}


/* ---------------------------------------------------------------------------
 * Keine Unterstützung für Xslt
 */
function Xslt_None() {
	this.processor = null;
	//this.init();
}
Xslt_None.prototype = new XsltBase();


Xslt_None.prototype.init = function(xslFile) {
}

Xslt_None.prototype.setParameter = function(name, value) {
}

Xslt_None.prototype.transformToDocument = function(node) {
	//logError("The browser does not Support Xslt");
	return null;
}


// ---------------------------------------------------------------------------

// Auswahl der passenden Xslt-Klasse
function getXsltClass() {
	if (typeof XSLTProcessor != 'undefined') {
		//logDebug("Xslt: Using native Xslt");
		return Xslt_Native;
	}
	if (typeof XsltProcess != 'undefined') {
		//logDebug("Xslt: using Google XsltLib");
		return Xslt_Google;
	}
	if (typeof ActiveXObject != 'undefined') {
		//logDebug("Xslt: using MSXML2 Xslt");
		return Xslt_MS;
	}

	//logError("No Xslt found.");
	//alert("The browser does not support XSLT");
	return Xslt_None;
}

var Xslt = getXsltClass();

Xslt.prototype.setLangParameter = function(direction) {
	var a = "_from";
	var b = "_to";
	if (direction && direction == 0) {
		a = "_to";
		b = "_from";
	}
	switch (lp) {
		case "ende":
			this.setParameter(a, "en");
			this.setParameter(b, "de");
		break;
		case "frde":
			this.setParameter(a, "fr");
			this.setParameter(b, "de");
		break;
		case "esde":
			this.setParameter(a, "es");
			this.setParameter(b, "de");
		break;
		case "itde":
			this.setParameter(a, "it");
			this.setParameter(b, "de");
		break;
		case "chde":
			this.setParameter(a, "ch");
			this.setParameter(b, "de");
		break;
		case "rude":
			this.setParameter(a, "ru");
			this.setParameter(b, "de");
		break;
	}
}

/* ===========================================================================
* XPath (Browser unabhängig)
* Funktioniert nicht im Konqueror
*/


function XPathBase() {
}


/* ---------------------------------------------------------------------------
 * Browser mit nativem XPath
 */
function XPath_Native() {
	this.XPathResult = null;
}
XPath_Native.prototype = new XPathBase();

// Parameter |xmlNode| optional
XPath_Native.prototype.evaluate = function(xPathExpr, xmlDoc, xmlNode) {
	this.xpexpr = xPathExpr; // debug
	if (!xmlNode)
		xmlNode = xmlDoc;
	this.xPathResult = xmlDoc.evaluate(xPathExpr, xmlNode, null,
			XPathResult.ANY_TYPE, null);
}

XPath_Native.prototype.iterateNext = function() {
	return this.xPathResult.iterateNext();
}



function XPath_Manual() {
	this.foundNodes = null;
	this.foundIdx = 0;
}

XPath_Manual.prototype.fallback = function(xPathExpr, xmlDoc, xmlNode) {
	if (!this.FallbackClass) {
		throw new Exception("Can't handle XPath and no fallback: " + xPathExpr);
	}
	var other = new this.FallbackClass();
	other.evaluate(xPathExpr, xmlDoc, xmlNode);
	this.foundIdx = 0;
	this.foundNodes = [];
	var node;
	while (node = other.iterateNext()) {
		this.foundNodes.push(node);
	}
}

/**
 * Optimierte Behandlung spezieller XPath-Anfragen
 * Erkannte Syntax:
 * Anfang des Ausdrucks:
 *   //*[@id='foo']
 *   //bar[@id='foo']             Tagname "bar" wird in diesem Fall ignoriert
 *   .
 *   id('foo')
 * Weitere durch / getrennte Elemeente
 *   bar[@xyz='foo']
 *   *[@xyz='foo']
 *   bar
 *   *
 * Auch // im Pfad wird akzeptiert, führt aber zum kompletten Durchsuchen
 * des DOM-Unterbaumes.
 */
XPath_Manual.prototype.evaluate = function(xPathExpr, xmlDoc, xmlNode) {
	var re_id = /^(\*|\w*)\[@id='(.*?)'\]$/;
	var re_idf = /^id\('(.*)'\)$/;
	var re_tag = /^(\*|\w+)(?:\[@(\w+)='(.*?)'\])?$/;

	var xmlBase = null;
	var elems = xPathExpr.split('/');
	var m;
	
	// TODO: Hier kann es zu Problemen kommen, es wird nur ein Node ausgewählt
	if (m = elems[0].match(/^ancestor::(\*|\w+)(?:\[@(\w+)='(.*?)'\])?/)) {
		xmlNode = xmlNode.parentNode;
		while (xmlNode) {
			if (xmlNode.nodeName.toLowerCase() == m[1] && xmlNode.className.toLowerCase() == m[3]) {
				elems[0] = ".";
				break;
			}
			xmlNode = xmlNode.parentNode;
		}
		xmlBase = xmlNode.parentNode;
	}
	
	if (elems[0] == '.') {
			// "./foo"
		xmlBase = xmlNode;
		elems.shift();
	}
	else if (elems[0] == '..') {
			// "../foo"
		xmlBase = xmlNode.parentNode;
		elems.shift();
	}
	else if (m = elems[0].match(re_idf)) {
		xmlBase = xmlDoc.getElementById(m[1]);
		elems.shift();
	}
	else if (elems[0] === '' && elems[1] === '' && (m = elems[2].match(re_id))) {
			// "//xy[@id='...']
		xmlBase = xmlDoc.getElementById(m[2]);
		elems.shift();
		elems.shift();
		elems.shift();
	}
	else {
		//logDebug("Not optimizable xpath expression: "+xPathExpr);
		return this.fallback(xPathExpr, xmlDoc, xmlNode);
	}

	var hits = [xmlBase];
	for (var i=0; i < elems.length; i++) {
		// alle level der expression
		var subhits = [];
		var wildcard = (elems[i] === '');
		if (wildcard) {
			i++;
			if (i >= elems.length) {
				//logDebug("Xpath expressioin not understood: "+xPathExpr);
				return this.fallback(xPathExpr, xmlDoc, xmlNode);
			}
			//logDebug("xpath expression containing // will cause full subtree search (might be inefficient): " + xPathExpr);
		}
		var em = elems[i].match(re_tag);
		if (!em) {
			// expression-Teil benutzt einen unbekannten Ausdruck
			//logDebug("Not optimizable xpath expression: "+xPathExpr);
			return this.fallback(xPathExpr, xmlDoc, xmlNode);
		}
		if (em[2] == "class" && !is_ie8up) {
			em[2] = "className";
		}
		// alle potentiellen parent-Elemente:
		for (var j=0; j < hits.length; j++) {
			// Passende Kinder suchen:
			for (var ch = hits[j].firstChild; ch; ch = ch.nextSibling) {
				if (wildcard) {
					// Gleich zur aktuellen Suche hinzufügen, da wir ein "//" Pattern
					// behandlen.
					hits.push(ch);
				}
				if (em[1] != '*') {
					if (ch.nodeName.toLowerCase() != em[1].toLowerCase()) {
						continue;
					}
				}
				if (em.length > 1 && em[2] != '' && em[3] != '') {
					if (ch.getAttribute(em[2]) !== em[3]) {
						continue;
					}
				}
				// keine weiteren Bedingungen
				subhits.push(ch);
			}
		}
		hits = subhits;
	}
	self.foundNodes = hits;
	self.foundIdx = 0;
}

XPath_Manual.prototype.iterateNext = function() {
	return self.foundNodes[self.foundIdx++];
}

// TODO: Testweise XPath_Native einfach ersetzt, rückgängig machen
XPath_Manual.prototype.FallbackClass = XPath_Native;
//XPath_Native = XPath_Manual;


/* ---------------------------------------------------------------------------
 * Browser die die Google XSLT-Lib verwendnen
 */
function XPath_Google() {
	this.xPathResult = null;
}
XPath_Google.prototype = new XPathBase();

XPath_Google.prototype.evaluate = function(xPathExpr, xmlDoc, xmlNode) {
	var context = null;
	if (xmlNode) {
		context = new ExprContext(xmlNode);
	}
	else {
		context = new ExprContext(xmlDoc);
	}

	this.iterator = 0;
	this.xPathResult = xpathEval(xPathExpr, context).nodeSetValue();
	return;

	// manuelles aufsplitten in einzelne Teile
	// durch das return unreachable
	/*var parts = xPathExpr.match(/^(.*?(?:@|id\().*?)(\/.*@.*)/);
	if (parts) {
		var preselect = xpathEval(parts[1], context).nodeSetValue().shift();
		if (preselect) {
			this.xPathResult = xpathEval("."+parts[2], new ExprContext(preselect)).nodeSetValue();
		}
		else {
			this.xPathResult = new Array();
		}
	}
	else {
		this.xPathResult = xpathEval(xPathExpr, context).nodeSetValue();
	}
	return;
	// durch das return unreachable
	var tmp = xpathEval(xPathExpr, new ExprContext(xmlDoc));
	if (xmlNode) {
		this.xPathResult = xpathEval(xPathExpr, new ExprContext(xmlNode)).nodeSetValue();
	}
	else {
		this.xPathResult = xpathEval(xPathExpr, new ExprContext(xmlDoc)).nodeSetValue();
	}*/
}

XPath_Google.prototype.iterateNext = function() {
	if (this.xPathResult.constructor == Array && this.xPathResult.length > 0)
	{
		return this.xPathResult.shift();
	}
	if (typeof this.xPathResult == "object" && this.xPathResult.length > this.iterator)
	{
		this.iterator++;
		return this.xPathResult[this.iterator-1];
	}
}


/* ---------------------------------------------------------------------------
 * IE mit geeigneten ActiveXObjecten
 */
function XPath_MS() {
	this.XPathResult = null;
}
XPath_MS.prototype = new XPathBase();

XPath_MS.prototype.evaluate = function(xPathExpr, xmlDoc, xmlNode) {
	xmlDoc.setProperty("SelectionLanguage", "XPath");
	this.iterator = 0;
	if (xmlNode) {
		this.xPathResult = xmlNode.selectNodes(xPathExpr);
	}
	else {
		this.xPathResult = xmlDoc.selectNodes(xPathExpr);
	}
}

XPath_MS.prototype.iterateNext = function() {
	if (this.xPathResult.constructor == Array && this.xPathResult.length > 0)
	{
		return this.xPathResult.pop();
	}
	if (typeof this.xPathResult == "object" &&
			this.xPathResult.length > this.iterator)
	{
		this.iterator++;
		return this.xPathResult[this.iterator-1];
	}
}

//var XPath_MS_HTML = XPath_Google;
var XPath_MS_HTML = XPath_Manual;
//XPath_Manual.prototype.FallbackClass = XPath_Native;

function XPath_MS_Dispatch() {
}

XPath_MS_Dispatch.prototype.log = noaction;

XPath_MS_Dispatch.prototype.evaluate = function(xPathExpr, xmlDoc, xmlNode) {
	this.worker = null;
	if (xmlDoc == document) {
		this.log("XPath-Dispatch: evaluating with XPath_MS_HTML");
		this.worker = new XPath_MS_HTML();
	}
	else {
		this.log("XPath-Dispatch: evaluating with XPath_MS");
		this.worker = new XPath_MS();
	}
	return this.worker.evaluate(xPathExpr, xmlDoc, xmlNode);
}

XPath_MS_Dispatch.prototype.iterateNext = function() {
	return this.worker.iterateNext();
}

/* ---------------------------------------------------------------------------
 * No XPath support
 */
function XPath_None() {
}
XPath_None.prototype = new XPathBase();

XPath_None.prototype.evaluate = function(xPathExpr, xmlDoc, xmlNode) {
	//logError("The browser does not support XPath");
}

XPath_None.prototype.iterateNext = function() {
	return null;
}


// ---------------------------------------------------------------------------


// Auswahl der passenden XPath-Klasse
function getXPathClass() {
	if (typeof document.evaluate != 'undefined'
			// IE Xpath-js: (TODO remove)
			&& typeof document.evaluate.emulated == 'undefined') {
		//logDebug("XPath: Using native XPath");
		return XPath_Native;
	}
	if (typeof XsltProcess != 'undefined') {
		//logDebug("XPath: using Google XSLTlib");
		return XPath_Google;
	}
	if (typeof ActiveXObject != 'undefined') {
		//logDebug("XPath: using MS_XPath_Dispatch");
		// benötigt die Google Xslt-Libs für manche Transformationen -> nachladen
		//addScript("/library/js/google-xslt/util.js");
		//addScript("/library/js/google-xslt/xmltoken.js");
		//addScript("/library/js/google-xslt/dom.js");
		//addScript("/library/js/google-xslt/xpath.js");
		//addScript("/library/js/google-xslt/xslt.js");
		//addScript("/library/js/html-xpath/html-xpath.js");
		document.write("<script src=\"/js/html-xpath/html-xpath.js\">\n</script>");
		return XPath_MS_Dispatch;
	}

	//logError("No XPath found.");
	//alert("The browser does not support XPath");
	return XPath_None;
}

var XPath = getXPathClass();
// XPath.prototype.log = taggedLogging('XPath', logDebug);


// statische Funktion für üblichen Sonderfall
XPath.getSingleNode = function(xpExpr, xmlDoc, curNode) {
	var xp = new XPath();
	xp.evaluate(xpExpr, xmlDoc, curNode);
	var rv = xp.iterateNext();
	if (xp.iterateNext() != null) {
		throw new Error("XPath single node search returned more than one result");
	}
	return rv;
}

// ==========================================================================

/**
* Ein dummer Browser kann keine internen Objekte Prototypen ...
*/
var appendXSLTResult = function(obj, result) {
	if (typeof result == 'object') {
		try {
			if (result.documentElement.nodeName.toLowerCase() == "html") {
				// Webkit gibt immer ein Komplettes HTML-Fragment zurück mit html und body
				var xPath = new XPath();
				xPath.evaluate("/html/body/*", result);
				var node;
				while (node = xPath.iterateNext()) {
					//node = result.documentElement;
					appendXSLTObject(obj, node);
				}
			}
			else {
				appendXSLTObject(obj, result.documentElement);
			}
		}
		catch(e) {
			// Hack für den IE ...
			obj.innerHTML += result.xml;
		}
	}
	else if (typeof result == 'string') {
		obj.innerHTML += result;
	}
	else {
		//logError("Unknown result type");
	}
}

function appendXSLTObject(obj, node) {
	// Knoten wird ins Zieldokument importiert
	var resultnode = null;
	if (obj.ownerDocument) {
		if (!obj.ownerDocument.importNode) {
			// IE6 und IE7 kennen importNode nicht.
			//obj.ownerDocument._importNode = _importNode;
			//resultnode = obj.ownerDocument._importNode(node, true);
			obj.innerHTML = node.xml;
			return;
			
		}
		else {
			resultnode = obj.ownerDocument.importNode(node, true);
		}
	}
	else {
		resultnode = node;
	}
	while (resultnode.attributes.length > 0) {
		resultnode.removeAttributeNode(resultnode.attributes[0]);
	}
	if (resultnode.nodeName == "transformiix:result") {
		// Der Result Node selber wird nicht eingefügt
		var node = resultnode.firstChild;
		while(node) {
			obj.appendChild(node.cloneNode(true));
			node = node.nextSibling;
		}
	}
	else {
		obj.appendChild(resultnode);
	}
}

/**
* Importiert einen Node (und seine childNodes) in das übergebene Document
*/
function importNode(node, xmlDoc, childNodes)
{
	try
	{
		return xmlDoc.importNode(node, childNodes);
	}
	catch(e)
	{
		return node;
	}
}

/**
* Setzen eines Cookies
*
* @var string name Name des Cookies
* @var string value Wert des Cookies
* @var int expires Ablaufsdatum in Tagen von jetzt an gerechnet
* @var string path Pfad für das das Cookie gültig ist
* @var string domain Domain für die das Cookie gilt
* @var boolean secure Zeigt an ob das Cookie nur über https gesendet werden soll
*/
function setCookie( name, value, expires, path, domain, secure )
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );

	// expires in days
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expiresDate = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expiresDate.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

/**
* Liest ein Cookie aus.
*
* @var string name Name des zu lesenden Cookies
* @return string Wert des Cookies
*/
function getCookie(name)
{
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) 
	{
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ';', len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

// IE HACK: Define _importNode for IE since it doesnt support importNode
function _importNode(oNode, bImportChildren) {
	var oNew;

	if(oNode.nodeType == 1) {
		oNew = document.createElement(oNode.nodeName);

		for(var i = 0; i < oNode.attributes.length; i++) {
			if(oNode.attributes[i].nodeValue != null && oNode.attributes[i].nodeValue != '') {
				var attrName = oNode.attributes[i].name;

				if(attrName == "class") {
					oNew.setAttribute("className", oNode.attributes[i].value);
				}
				else {
					oNew.setAttribute(attrName, oNode.attributes[i].value);
				}
			}
		}

		if(oNode.style != null && oNode.style.cssText != null) {
			oNew.style.cssText = oNode.style.cssText;
		}
	}
	else if(oNode.nodeType == 3) {
		oNew = document.createTextNode(oNode.nodeValue);
	}

	if(bImportChildren && oNode.hasChildNodes()) {
		for(var oChild = oNode.firstChild; oChild; oChild = oChild.nextSibling) {
			oNew.appendChild(document._importNode(oChild, true));
		}
	}

	return oNew;
}
// IE HACK (end)

/*function appendXSLTResult(result)
{
	if (typeof result == 'object')
	{
		try
		{
			this.appendChild(result.documentElement);
		}
		catch(e)
		{
			// Hack für den IE ...
			this.innerHTML = result.xml;
		}
	}
	else if (typeof result == 'string')
	{
		this.innerHTML = result;
	}
	else
	{
		alert("Unknown result type");
	}
}

if (Node && Node.prototype)
{
	Node.prototype.appendXSLTResult = appendXSLTResult;
}
else if (Objecte && Objecte.prototype)
{
	Objecte.prototype.appendXSLTResult = appendXSLTResult;
}
else
{
	// Dummer IE
}*/

