function isConnected() {
	return false;
}


/*function getPage() {
	//debug:alert("holamundo");
	var myurl=document.location;
	myurl=myurl.split("/");
	//debug:alert(myurl);
	var fileName = myurl[myurl.length -1];
	alert (fileName);	
	//return "index";
}

function getPageName()
{
	url = document.location.href;

	if (url.split("\\").lenght > 1) { //windows style
		//very old browsers... and I'm tired.
	}
	else { //linux and web sytle (IE6 parses to /)
		fullFileName = url.split("/");
		fileName = fullFileName[fullFileName.length -1];
		alert (fileName.split(".")[0]);
		return (fileName.split(".")[0]);
	}
}
*/

//MBR: Returns an xmlObject from an external xmlFile.
function getXMLobject(xmlFile) {
	var oDomDoc = Sarissa.getDomDocument();
	if (isConnected()) {
		oDomDoc.async = false; // this is the important part
	}
	else {
		oDomDoc.async = false; // this is the important part
	}
	
	oDomDoc.load(xmlFile);
	//debug:alert(Sarissa.serialize(oDomDoc));// show the file contents
	
	if(oDomDoc.parseError != 0) {
	   //debug:alert("not well formed or other error!");
	   //debug://debug:alert("<pre>"+Sarissa.getParseErrorText(oDomDoc)+"</pre>");
		 //document.location.href="error.html";
	   document.write ("<h1><center>¿ "+xmlFile +" ?<center></h1><strong>Jiuston llamando a Hugo:</strong> L´XML que demanes ("+xmlFile+") no existeix. <br/><br/><strong>Solució:</strong> Crea el document dins de la carpeta \"es_ES\" (fer cut&paste de l´inici.xml i adaptar-lo pot ser una bona idea) i refresca o torna a fer click en el link que t´ha fet arribar aquí.<br/>")
	   return "";
	}
	else {
	   //debug:alert("loaded ok");
	   return oDomDoc;
	}
}

// Takes xmlFile and transform it using xslFile.
function XSLTransform(xmlFile,xslFile,node) {

	//debug: alert ("entra: " + xmlFile +"|" + xslFile + "|" + node);
	
	var xmlDoc = getXMLobject(xmlFile);
	var xslDoc = getXMLobject(xslFile);
	
	// create an instance of XSLTProcessor
	var processor = new XSLTProcessor();
	
	xslDoc = (new DOMParser()).parseFromString(Sarissa.serialize(xslDoc), "text/xml");
	
	// make the stylesheet reusable by importing it in the XSLTProcessor
	processor.importStylesheet(xslDoc);
	// set a stylesheet parameter (pass from javascript to xslt)
	// processor.setParameter(null, "title", paramValue);

  // create source document
  // var xmlDoc = Sarissa.getDomDocument("books.xml","marc", null);
  // transform the document 
  var newDocument = processor.transformToDocument(xmlDoc);
  // show transformation results
  //debug:alert(Sarissa.serialize(newDocument));
	document.getElementById(node).innerHTML = Sarissa.unescape(Sarissa.serialize(newDocument));
	//document.getElementById("contenido").appendChild(document.importNode(newDocument, true));
}
