if (typeof(DList) == "undefined") {

    function DList(listName, autoClass) {
	    var that = this;
	    this.listName = listName;
	    this.prefix = 'tab_';			//Navigation item class prefix (+'<this.listName>')
	    this.titlePrefix = 'title_';
	    this.navElementType = 'div';	//Navigation element type
	    this.interaction = 'onmouseover';
	    this.initialised = false;
	    this.tabFormat = '';
    	
	    this.walkTheDOM = function(node, func) {
		    func(node);
		    node = node.firstChild;
		    while (node) {
			    this.walkTheDOM(node, func);
			    node = node.nextSibling;
		    }
	    };
    	
	    this.getElementsByClassName = function(className) {
		    var results = [];
		    this.walkTheDOM(document.body, function(node) {
			    var a, c = node.className, i;
    			
			    if (c) {
				    a = c.split(' ');
    				
				    for (i = 0; i < a.length; i += 1) {
					    if (a[i] === className) {
						    results.push([node.id]);
						    break;
					    }
				    }
    				
			    }
    			
		    });
		    return results;
	    };
    	
	    this.buildNav = function() {
    		
		    var navParent = document.getElementById('holder_'+that.listName);
		    navParent.innerHTML = '';
    		
		    for (var i=0;i<that.itemArray.length;i++) {
			    var divClass = that.prefix+that.listName;
			    var divIdName = that.prefix+that.itemArray[i][0];
			    var newElement = document.createElement(that.navElementType);
			    newElement.setAttribute('id',divIdName);
			    newElement.setAttribute('class',that.prefix+that.listName);
    			
			    var title = that.itemArray[i][0].replace(/_/g, "&nbsp;").replace(/dAND/g, "&amp;").replace(/dAT/g, "?").replace(/dCO/g, "&copy;").replace(/dDOL/g, "$").replace(/dEXC/g, "!").replace(/dFST/g, ".").replace(/dGT/g, "&gt;").replace(/dLT/g, "&lt;").replace(/dNUM/g, i+1).replace(/dPER/g, "%").replace(/dPLUS/g, "+").replace(/dQUE/g, "?").replace(/dQUO/g, "'").replace(/dREG/g, "&reg;").replace(/dTM/g, "&trade;").replace(/dUND/g, "_");
			    if (that.navElementType === 'img') {
				    newElement.setAttribute('alt',title);
			    } else {
				    newElement.innerHTML = title;
			    }
			    navParent.appendChild(newElement);			
		    }
	    }
    	
	    this.itemArray = [];
    	
	    if (typeof(autoClass) === 'undefined') {
		    autoClass = false;
	    } else {
		    this.itemArray = this.getElementsByClassName(autoClass);
	    }
    	
	    this.oneOnly = true;			//Show one item at a time
	    this.allowClose = false;		//Allow items to be closed
	    this.sticky = false;			//Mouse off results in sticky item being selected
	    this.imageDir = 'images/';		//Images directory
	    this.navImages = [];			//Images array
	    this.defaultItem = 0;			//Array index of default item to display
	    this.holder = 'holder_'+that.listName;
    	
	    this.changeContent = function(itemName) {
		    var itemElement = document.getElementById(itemName);
		    if (itemElement == null) {
			    return;
		    }
		    var itemTab = document.getElementById(that.prefix + itemName);

		    if (itemElement.style.display == 'none') {
    			
			    if (that.oneOnly === true)	{
				    that.hideContent();
			    }
    		
			    itemElement.style.display = 'block';	//Show item
    			
			    if (that.navImages.length === 0) {
				    //Do class based navigation
				    itemTab.className = that.prefix + that.listName + '_on';
			    } else {
				    //Do image based navigation
				    var itemIndex = that.getItemIndex(itemName);
				    if (itemIndex !== -1) {
					    itemTab.src = that.navImages[itemIndex][1].src;
    					
				    } else {
					    itemTab.className = that.prefix + that.listName + '_on';
				    }
			    }
    			
		    } else {
    			
			    if (that.allowClose) {
    				
				    itemElement.style.display = 'none';
				    var itemIndex = that.getItemIndex(itemName);
				    if (itemIndex !== -1) {
					    itemTab.src = that.navImages[itemIndex][1].src;
				    } else {
					    itemTab.className = that.prefix + that.listName + '_on';
				    }
			    }
		    }

	    };	/* end this.changeContent() */
    	
	    this.hideContent = function() {
		    var itemCount = that.itemArray.length;
    		
		    for (var i=0;i<itemCount;i++) {
			    //alert(this.itemArray[i][0]);
			    itemElement = document.getElementById(that.itemArray[i][0]);
			    itemElement.style.display = 'none';
    			
			    navElement = document.getElementById(that.prefix + that.itemArray[i][0]);
    			
			    if (typeof(that.navImages[i]) !== 'undefined') {
				    navElement.src = that.navImages[i][0].src;
			    } else {
				    navElement.className = that.prefix + that.listName;
			    }
		    }
	    };	/* end this.hideContent() */
    	
	    this.hideTitles = function() {
		    var itemCount = that.itemArray.length;
    		
		    for (var i=0;i<itemCount;i++) {
			    titleElement = document.getElementById(that.titlePrefix + that.itemArray[i][0]);

			    if (titleElement !== null) {
			        titleElement.style.display = 'none';
			    }
		    }
	    };	/* end this.hideTitles() */

	    this.init = function()	{
		    that.buildNav();
		    that.hideTitles();
		    that.hideContent();
    				
		    that.changeContent(that.itemArray[that.defaultItem][0]);
    		
		    document.getElementById(that.holder)[that.interaction] = function(e) {
			    // get either event (W3C) or window event object (MSIE)
			    e = e || window.event; 
			    // get either target (W3C) or event source (MSIE)
			    var t = e.target || e.srcElement; 
			    if (that.initialised) {
				    if (t.id !== that.holder) {
					    that.changeContent(t.id.substring(that.prefix.length));
				    }
			    }
    			
			    return false;
		    }
    		
		    setTimeout(
			    function() {
				    that.initialised = true;
			    },
			    1000
		    );
	    };
    	
	    this.preload = function(images) {
		    for (var i=0;i<images.length;i++) {
			    that.navImages[i] = [new Image(),new Image()];
			    that.navImages[i][0].src = that.imageDir+images[i][0];
			    that.navImages[i][1].src = that.imageDir+images[i][1];
		    }
		    this.navElementType = 'img';
	    }
    	
	    this.getItemIndex = function(itemName) {
    		
		    for (var i=0;i<that.itemArray.length;i++) {
			    if (that.itemArray[i][0] === itemName) {
				    return i;
			    }
		    }
		    return -1;
	    }
    	
	    //Shows all items in this.itemArray
	    this.showAll = function() {
    	
		    for (var i=0;i<this.itemArray.length;i++) {
			    //alert("class: " + this.listName);
			    document.getElementById(that.itemArray[i][0]).className = that.listName;
			    document.getElementById(that.prefix + that.itemArray[i][0]).className = that.prefix + this.listName + "_on";
		    }
    		
	    };
    	
	    this.change_class = function(targetID, newClass) {
		    if (targetID !== null) {
			    document.getElementById(targetID).className = newClass;
		    }
	    };
    	
    }
}