function loadXMLDoc(url) {
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;
        req.open("GET", url, true);
        req.send(null);
    	}
	// branch for IE/Windows ActiveX version
	else if (window.ActiveXObject) {
        isIE = true;
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChange;
            req.open("GET", url, true);
            req.send();
        	}
    	}
	}
	
function getConnected(str) {
	// branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
		req.overrideMimeType("text/xml");
		sendstr = str;
    	}
	// branch for IE/Windows ActiveX version
	else if (window.ActiveXObject) {
        isIE = true;
        req = new ActiveXObject("Microsoft.XMLHTTP");
		sendstr = '';
        }
	return sendstr;
	}

function connect(towhat,how,str,action) {
	try {
		var sendstr = getConnected(str);
		/*
		var req = new XMLHttpRequest();
		req.overrideMimeType("text/xml");
		*/
		}
	catch (e){
		alert('Error creating the connection!');
		return;
		}
		
	try {
		req.open(how,towhat,true);
		if (how == "POST") req.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
		req.onreadystatechange = processReqChange;
		req.send(sendstr);
		}
	catch (e){
		alert('An error has occured making the request: '+e);
		return;
		}
	
	}
	
processReqChange = function() {
	// req.onload = function() {
	switch(req.readyState) {
		case 1,2,3:
		break;
		case 4:
			loaded = true;
			if(req.status !=200) {
				alert('The server responded with a bad status code: '+req.status);
				}
			else {
				// var responseXML = new DOMParser().parseFromString(req.responseText, 'text/xml');
				// theTimeLine.parseResponse2(req.responseXML);
				theTimeLine.parseResponse(req.responseText);
				/*switch(action) {
					case "timeline":
						alert(responseXML);
						theTimeLine.parseResponse(responseXML);
					break;
					}*/
				}
		break;
		};
	}
	
TimeLine = function() {
	/* don't remove me, i am the object creator */
	// set IE variable
	b.IE() ? this.ie = true : this.ie = false;
	}
	
TimeLine.prototype.parseResponse2 = function(xml) {
	this.xmlDoc = xml;
	removeRows();
	this.buildInfoOld();
	}
	
TimeLine.prototype.parseResponse = function(xml) {
	this.xmlDoc = xml;
	removeRows();
	this.buildInfo();
	}
	
TimeLine.prototype.getXmlValue = function(objroot,root,row,tag,i) {
	return objroot.getElementsByTagName(root)[row].getElementsByTagName(tag).item(i).firstChild.nodeValue;
	}
	
TimeLine.prototype.getNrRecord = function(tag) {
	var el = this.xmlDoc.getElementsByTagName(tag);
	if (el.length) {
		return el.length;
		}
	else{
		return 0;
		}
	}
	
TimeLine.prototype.buildAnimation = function(file) {
	
	var w = 354;
	var h = 290;
	var d = document.createElement('div');
	d.setAttribute("id","animation");
	d.setAttribute("style","width:"+w+"px;");
	// create the object tag & set attributes
	// no we have to try to make the whole thing as a string
	/*var o = document.createElement('object');
	o.setAttribute("classid","clsid:D27CDB6E-AE6D-11cf-96B8-444553540000");
	o.setAttribute("codebase","http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0");
	o.setAttribute("width",w);
	o.setAttribute("height",h);*/
	// create the params and append to object
	var params = new Array();
	
	params[0] = ["movie","swf/"+file+".swf"];
	params[1] = ["loop","true"];
	params[2] = ["menu","true"];
	params[3] = ["quality","high"];
	params[4] = ["bgcolor","#ffffff"];
	params[5] = ["wmode","opaque"];
	
	// create the embed tag to add attributes which are also params
	// but of course IE doesn't recognise <embed> in the DOM
	// so we have to make a string instead...
	var o = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+w+'" height="'+h+'"><param name="movie" value="'+params[0][1]+'" /><param name="loop" value="'+params[1][1]+'" /><param name="menu" value="'+params[2][1]+'" /><param name="quality" value="'+params[3][1]+'" /><param name="bgcolor" value="'+params[4][1]+'" /><param name="wmode" value="opaque" />';
	var em = '<embed src="'+params[0][1]+'" loop="'+params[1][1]+'" menu="'+params[2][1]+'" quality="'+params[3][1]+'" bgcolor="'+params[4][1]+'" width="'+w+'" height="'+h+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="opaque"></embed>';
	var flashstr = o + em + '</object>';
	var flash_text = document.createTextNode(flashstr);
	// var em = document.createElement('embed');
	/*	
	for (var i=0;i<params.length;i++) {
		var p = document.createElement('param');
		var n = params[i][0];
		var v = params[i][1];
		p.setAttribute("name",n);
		p.setAttribute("value",v);
		o.appendChild(p);
		n == "movie" ? en = "src" : en = n;
		// alert(en);
		// em.setAttribute(en,v);
		}*/
	/*
	// set other embed attributes
	em.setAttribute("movie","swf/"+file+".swf");
	em.setAttribute("width",w);
	em.setAttribute("height",h);
	em.setAttribute("type","application/x-shockwave-flash");
	em.setAttribute("pluginspage","http://www.macromedia.com/go/getflashplayer");*/
	try {
		// o.appendChild(em_text);
		// d.appendChild(flash_text);
		d.innerHTML = flashstr;
		}
	catch(e) {
		alert(e);
		}
	
	
	return d;
	}
	
TimeLine.prototype.buildInfoOld = function() {
	
	// create a wrap div to put padding etc in
	var wrapdiv = document.createElement('div');
	wrapdiv.setAttribute("id","wrapdiv");
	
	// create the title
	var title = this.getXmlValue(this.xmlDoc,'articleinfo',0,'title',0);
	
	var id = this.xmlDoc.getElementsByTagName("article")[0].getAttribute("id");
	
	var showanim = this.xmlDoc.getElementsByTagName("swf")[0].getAttribute("value");
	
	var h2 = document.createElement('h2');
	var h2_text = document.createTextNode(title);
	h2.setAttribute("id","infopane-title");
	h2.appendChild(h2_text);
		
	// let's stick in the flash animation
	if (showanim == "true") {
		var anim = this.buildAnimation(id);
		infoPane.appendChild(anim);
		wrapdiv.className = "hasflash";
		// wrapdiv.appendChild(anim);
		}
	
	wrapdiv.appendChild(h2);
	
	// go through the sections
	var sections = this.xmlDoc.getElementsByTagName("section");
	
	for (var i=0; i<sections.length; i++) {
		if (sections[i].getAttribute("id") == "bio") {
			var biosect = sections[i];
			var biosectrow = i;
			}
		else if (sections[i].getAttribute("id") == "maths") {
			var mathssect = sections[i];
			var mathssectrow = i;
			}
		}
	
	var bioparas = biosect.getElementsByTagName("para");
	
	// create the paras
	for (var i=0; i<bioparas.length; i++) {
		
		var para_text = this.getXmlValue(this.xmlDoc,'section',biosectrow,'para',i);
		// para_text = superTextile(para_text);
		var p = document.createElement('p');
		var p_text = document.createTextNode(para_text);
		p.appendChild(p_text);
		wrapdiv.appendChild(p);
		
		}
				
	infoPane.appendChild(wrapdiv);
	
	assignIntLinkHandlers();
	initInfoPaneScroller();
	
	}
	
// different option for build function
	
TimeLine.prototype.buildInfo = function() {
	
	// alert(this.xmlDoc);
	
	infoPane.innerHTML = this.xmlDoc;
	
	assignIntLinkHandlers();	
	jsMath.Process();
	// initInfoPaneScroller();
	
	}