function transform(xmlFile, xslFile)
{
  var xml = new ActiveXObject("Msxml2.DOMDocument.3.0");
  xml.async=false;
  xml.load(xmlFile); 

  var xsl = new ActiveXObject("Msxml2.DOMDocument.3.0");
  xsl.async = false;
  xsl.load(xslFile);

  return xml.transformNode(xsl);
}

function transformGallery(xmlFile, xslFile)
{
  var xslDoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.3.0");
  xslDoc.async = false;
  xslDoc.load(xslFile);

  var xslt = new ActiveXObject("Msxml2.XSLTemplate.3.0");
  xslt.stylesheet = xslDoc;

  var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
  xmlDoc.async = false;
  xmlDoc.load(xmlFile);

  var xslProc = xslt.createProcessor();
  xslProc.input = xmlDoc;
  xslProc.addParameter("page", getQuerystring("page", 1));
  xslProc.transform();
  return xslProc.output;
}

function getQuerystring(key, default_)
{
  var query = window.location.search.substring(1); 
  var vars = query.split("&"); 
  for (var i=0;i<vars.length;i++) { 
    var pair = vars[i].split("="); 
    if (pair[0] == key) { 
      return pair[1]; 
    } 
  } 
  return default_;
}