var doc = null;
var curItem = null;
var category = "";
function init() {
	var data, iXML, nodes, ctrl, node;
	try {
		
		data = getDocument('i2.xml');
		doc = xml(data);
		doc = doc.documentElement;		category = doc.selectSingleNode("Category[@name='" + categoryId + "']");		
		var Images = category.selectNodes("Image");
		var il = $('imgList');
		il.innerHTML = "";
		var spTop=$('spTitleTop');
		var spLongDesc=$('spLongDesc');
		var spLongDesc1=$('spLongDesc1');
		var spLongDesc2=$('spLongDesc2');
	    var sp=$('spTitle');
		if (category.getAttribute('title')!=null)
		{
		spTop.innerHTML= category.getAttribute('title');
		}
		if (category.getAttribute('longDesc')!=null)
		{
		spLongDesc.innerHTML= category.getAttribute('longDesc');
		}
		if ( category.getAttribute('longDesc1')!=null)
		{
		spLongDesc1.innerHTML= category.getAttribute('longDesc1');
		}
		if (category.getAttribute('longDesc2')!=null)
		{
		spLongDesc2.innerHTML= category.getAttribute('longDesc2');
		}
		if (category.getAttribute('desc')!=null)
		{
		sp.innerHTML=category.getAttribute('desc');
		}
		var initial=null;
		for(var i=0; i<Images.length; i++) {
			var li = document.createElement('LI');
			if(!initial) initial=li;
			li.innerHTML = "<a href='#' onmouseover=\"Tip(\'<img src=&quot;Samples/images/" + Images[i].getAttribute('src') + "&quot;width=&quot;"+ Images[i].getAttribute('width') +"&quot;/> \')\" onmouseout='UnTip()'/>"+Images[i].getAttribute('desc')+"</a>" ;
			il.appendChild(li);
		
		}
		//sample(initial);
	} catch (e) {
		if (e==-1) {
			alert('Unable to load the images config file.');
			return;
		} else {
			alert(e);
			return;		}
	}
}

function sample(o) {
	var d = $('preview');
	d.innerHTML = "";
	var image = document.createElement('IMG');
	var s = $('selector');
	image.src = category.getAttribute("path") + '/' + o._src;
	image.style.width = o._width;
	image.style.height = o._height;
	d.appendChild(image);
}

function mo() {
	if(curItem) curItem.style.backgroundColor="";
	curItem = this;
	curItem.style.backgroundColor="#e1e1e1";
	sample(this);
}
function mt() { if(curItem) curItem.style.backgroundColor=""; cutItem = null; }


window.onload=init;