function _JL_HTTPRequest() {
 var xmlhttp,alerted
 /*@cc_on @*/
 /*@if (@_jscript_version >= 5)
 // JScript gives us Conditional compilation, we can cope with old IE versions.
  try {
   xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
  } catch (e) {
   alert("You must have Microsofts XML parsers available")
  }
 @else
  alert("You must have JScript version 5 or above.")
  xmlhttp=false
  alerted=true
 @end @*/
 if (!xmlhttp && !alerted) {
  // Non ECMAScript Ed. 3 will error here (IE<5 ok), nothing I can 
  // realistically do about it, blame the w3c or ECMA for not
  // having a versioning capability in  <SCRIPT> or ECMAScript.
  try {
   xmlhttp = new XMLHttpRequest();
  } catch (e) {
   alert("You need a browser which supports an XMLHttpRequest Object.\nMozilla build 0.9.5 has this Object and IE5 and above, others may do, I don't know, any info jim@jibbering.com")
  }
 }
 return xmlhttp
}

xmlhttp=_JL_HTTPRequest()



RDF_NS="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
rdfNS=""
GlobalID=0
inTriples=new Array()
Namespaces=null
xml=null


alert('a')
function GetTriples(url) {
alert('b')
 inTriples=new Array()
alert('c')
 xmlhttp.open("GET", url,false);
alert('d')
 xmlhttp.send(null)
alert('e')
 xml=xmlhttp.responseXML
 Namespaces=getNamespaces(xml.documentElement)
 createPredicates(xml.documentElement.childNodes)
 return inTriples
}

function outputNTriples() {
 str=''
 for (i=0;i<inTriples.length;i++) {
  if (inTriples[i].subject.indexOf('genid')==0) str+='_:n'+inTriples[i].subject.substr(6)+' '
   else str+='&lt;'+inTriples[i].subject+'&gt;'
  str+='&lt;'+inTriples[i].predicate+'&gt; '
  if (inTriples[i].type=='literal') str+='"'+inTriples[i].object+'"'
  else  if (inTriples[i].object && inTriples[i].object.indexOf('genid')==0) str+='_:n'+inTriples[i].object.substr(6)+''
   else str+='&lt;'+inTriples[i].object+'&gt;'
  str+='.<BR>'
 }
 return str
}

function createPredicates(els) {
 var el,i,j,attr,nn,nv,attr,ns
 for (i=0;i<els.length;i++) {
  subject=GenID()
  el=els[i]
  while (el && el.nodeType!=1) el=els[++i]
		if (el) {
   attrs=el.attributes
 		for (j=0;j<attrs.length;j++) {
    attr=attrs.item(j)
    nn=String(':'+attr.nodeName+'::').split(':')
    ns=nn[1]
    nn=nn[2]
    nv=attr.nodeValue
    if (ns==rdfNS && nn=='about') {
     subject=nv
     inTriples.push(new Triple(subject,Namespaces['_'+rdfNS]+"type",Namespaces['_'+ns]+el.nodeName))
 			}
			}
  }
  if (el) AnalyseChildren(subject,el.childNodes)
 }
}
function AnalyseChildren(subject,els) {
 var el,i,n,attr,nn,nv,attr,ns
	if (els) {
  for (i=0;i<els.length;i++) {
  el=els[i]
  while (el && el.nodeType!=1) el=els[++i]
		if (el) {
   nn=el.nodeName
   if (nn.indexOf(':')==-1) ns=''
    else {
     ns=nn.split(':')[0]
     nn=nn.split(':')[1]
    }
   nvobj=getNodeValue(el)
   nv=nvobj.val;typ=nvobj.type
   inTriples.push(new Triple(subject,Namespaces['_'+ns]+nn,nv,typ))
		}
  } 
	}
}

function getNodeValue(el) {
 var i,attr,els,subj
 attrs=el.attributes
 predicate=""
	for (j=0;j<attrs.length;j++) {
  attr=attrs.item(j)
  nn=String(':'+attr.nodeName+'::').split(':')
  ns=nn[1]
  nn=nn[2]
  nv=attr.nodeValue
  if (ns==rdfNS && nn=='resource') return {val:nv,type:'resource'}
 }
 els=el.childNodes
 if (els.length==0) return ""
 if (els.length==1 && els[0].nodeType==3) return {val:els[0].nodeValue,type:'literal'}
 subj=GenID()
 AnalyseChildren(subj,els)
 return {val:subj,type:'resource'}
}

function GenID() {
 return "genid:"+(++GlobalID)
}

function getNamespaces(el) {
 var nn,ns
 var attr=el.attributes
 var arr=new Array()
	for (var i=0;i<attr.length;i++) {
  nn=':'+xml.documentElement.attributes.item(i).nodeName+"::"
  nn=nn.split(':')[2]
  ns=xml.documentElement.attributes.item(i).nodeValue
  arr[i]=ns
  arr['_'+nn]=arr[i]
  if (ns==RDF_NS) rdfNS=nn
 }
 return arr
}



function Triple(subject,predicate,object,type) {
 this.subject=subject
 this.predicate=predicate
 this.object=object
 this.type=type
 return this
}



