var WRITE ={
	addDiv : function(e,a)
{
		var addDoc = document.getElementById(a);
		wrapper = document.createElement('div');
		wrapper.setAttribute('id',e.getElementById('did').innerHTML);
		wrapper.setAttribute('style','float:left');
		protector = document.createElement('span');
		protector.style.display='block';
		protector.style.background='url(loader.php?id='+e.getElementById('item').innerHTML+')';
		protector.style.backgroundRepeat='no-repeat';
		image1 = document.createElement('img');
		image1.src = "img/protector.gif";
		image1.width=e.getElementById('width').innerHTML;
		image1.height=e.getElementById('height').innerHTML;
		protector.appendChild(image1);
		actionlink = document.createElement('a');
		actionlink.href = "#"
		actionlink.setAttribute('onclick',"Ajax('delete','"+e.getElementById('did').innerHTML+"');return false;");
		actionlink.innerHTML="D";
		actionlink2 = document.createElement('a');
		actionlink2.href = "#"
		actionlink2.setAttribute('onclick',"Ajax('enlarge','"+e.getElementById('parent').innerHTML+"');return false;");
		actionlink2.innerHTML="E";
		wrapper.appendChild(protector);
		wrapper.appendChild(actionlink);
		wrapper.appendChild(actionlink2);
		addDoc.appendChild(wrapper);
},
writeImages:function(e,a)
{
	gal = AJAX.$(a);
	gal.appendChild(WRITE.makeGallery2(e));

},
 showEnlarge: function(e)
	{
		var addDoc = document.getElementById('viewer');
		if(addDoc.childNodes.length>0) addDoc.removeChild(addDoc.childNodes[0]);
		protector = document.createElement('span');
		protector.style.display='block';
		protector.style.background='url(loader.php?id='+e.getElementsByTagName('imageLink')[0].firstChild.nodeValue+')';
		protector.style.backgroundRepeat='no-repeat';
		image = document.createElement('img');
		image.src = "img/protector.gif";
		image.width=e.getElementsByTagName('width')[0].firstChild.nodeValue;
		image.height=e.getElementsByTagName('height')[0].firstChild.nodeValue;
		protector.appendChild(image);
		addDoc.appendChild(protector);

	},
	updateDoc:function(e,a)
	{
		/*var insertEL = document.getElementById(a);
		var gal = document.createElement('div');
		if(AJAX.$("galleryLYR").childNodes.length>2) AJAX.$("galleryLYR").removeChild(AJAX.$("galleryLYR").childNodes[2]);

		var tmp=insertEL.childNodes.length;
		for(x=0;x<tmp;x++) insertEL.removeChild(insertEL.childNodes[0]);
		var eventChildren=e.getElementsByTagName('event');
		var head=document.createElement('h2');
		head.appendChild(document.createTextNode("Event Details"));

		insertEL.appendChild(head);
		if(eventChildren.length==0)
		{
alert('a');
			eventChildren=e.getElementsByTagName('noevent');
			insertEL.appendChild(document.createTextNode(eventChildren[0].getElementsByTagName("description")[0].firstChild.nodeValue));


		}
		else
		{
*/
		var fullList = document.createElement('div');
		for (i=0;i<eventChildren.length;i++)
		{
			var newEL;
			newEL = document.createElement('ul');
			newEL.appendChild(WRITE.dolistitem("Date: "+eventChildren[i].getElementsByTagName("date")[0].firstChild.nodeValue));
			newEL.appendChild(WRITE.dolistitem("Time: "+eventChildren[i].getElementsByTagName("time")[0].firstChild.nodeValue));
			newEL.appendChild(WRITE.dolistitem("Venue: "+eventChildren[i].getElementsByTagName("venue")[0].firstChild.nodeValue));
			newEL.appendChild(WRITE.dolistitem("Address: "+eventChildren[i].getElementsByTagName("address")[0].firstChild.nodeValue));
			newEL.appendChild(WRITE.dolistitem("Description: "+eventChildren[i].getElementsByTagName("description")[0].firstChild.nodeValue));
			newEL.appendChild(WRITE.dolistitem("Comment: "+eventChildren[i].getElementsByTagName("comment")[0].firstChild.nodeValue));
			newEL.appendChild(WRITE.dolistitem("Status: "+eventChildren[i].getElementsByTagName("status")[0].firstChild.nodeValue));
			fullList.appendChild(newEL);
			gal.appendChild(WRITE.makeGallery(eventChildren[i]));
			}
			insertEL.appendChild(fullList);
			AJAX.$("mainright").appendChild(gal);
		//}

	},
	dolistitem:function(t)
	{
			var li = document.createElement('li');
			textid = document.createTextNode(t);
			li.appendChild(textid);
			return li;
	},
	makeGallery:function(e)
	{
		var addDoc = document.createElement('div');
		addDoc.id="wrapper";
		for(var i=0;i<e.getElementsByTagName('dancer').length;i++)
		{
			var header = document.createElement('span');
			var headertxt = document.createTextNode(e.getElementsByTagName('dancer')[i].getAttribute("name"));
			header.appendChild(headertxt);
			wrapper = document.createElement('div');
			wrapper.appendChild(header);
			if(e.getElementsByTagName("dancer")[i].getElementsByTagName('image').length>0)
			{
			x = Math.floor(e.getElementsByTagName("dancer")[i].getElementsByTagName('image').length*Math.random())
			//for(var x=0;x<e.getElementsByTagName("dancer")[i].getElementsByTagName('image').length;x++)
			//{
				protector = document.createElement('span');
				protector.style.display='block';
				protector.style.background='url(http://www.alastairwattsentertainment.co.uk/DancerWeb/loader.php?id='+e.getElementsByTagName('imageLink')[x].firstChild.nodeValue+')';
				protector.style.backgroundRepeat='no-repeat';
				image1 = document.createElement('img');
				image1.src = "http://www.alastairwattsentertainment.co.uk/DancerWeb/img/protector.gif";
				image1.width=e.getElementsByTagName('width')[x].firstChild.nodeValue;
				image1.height=e.getElementsByTagName('height')[x].firstChild.nodeValue;
				protector.appendChild(image1);

				/*actionlink2 = document.createElement('a');
				actionlink2.href = "#"
				actionlink2.setAttribute('onclick',"Ajax('enlarge','"+e.getElementsByTagName('parent')[x].firstChild.nodeValue+"');return false;");
				actionlink2.innerHTML="E";*/

				//slider.appendChild(actionlink2);
				wrapper.appendChild(protector);
			//}

			}
			addDoc.appendChild(wrapper);

		}
		return addDoc;

	},
	makeGallery2:function(e)
	{
		var addDoc = document.createElement('div');
		addDoc.id="wrapper";
		for(var i=0;i<e.getElementsByTagName('image').length;i++)
		{
			var header = document.createElement('span');
			var headertxt = document.createTextNode(e.getElementsByTagName('stagename')[i].firstChild.nodeValue);
			header.appendChild(headertxt);
			wrapper = document.createElement('div');
			wrapper.appendChild(header);
			protector = document.createElement('span');
			protector.style.display='block';
			protector.style.background='url(http://www.alastairwattsentertainment.co.uk/DancerWeb/loader.php?id='+e.getElementsByTagName('imageLink')[i].firstChild.nodeValue+')';
			protector.style.backgroundRepeat='no-repeat';
			image1 = document.createElement('img');
			image1.src = "http://www.alastairwattsentertainment.co.uk/DancerWeb/img/protector.gif";
			image1.width=e.getElementsByTagName('width')[i].firstChild.nodeValue;
			image1.height=e.getElementsByTagName('height')[i].firstChild.nodeValue;
			protector.appendChild(image1);

				/*actionlink2 = document.createElement('a');
				actionlink2.href = "#"
				actionlink2.setAttribute('onclick',"Ajax('enlarge','"+e.getElementsByTagName('parent')[x].firstChild.nodeValue+"');return false;");
				actionlink2.innerHTML="E";*/

				//slider.appendChild(actionlink2);
			wrapper.appendChild(protector);
			//}
			addDoc.appendChild(wrapper);
		}
		return addDoc;
}
}