function thumbnails (ident, thumbsarray, mode) {
    
    this.ident = ident;
    this.thumbs = thumbsarray;
    this.mode = mode;
    this.player;
    
    this.target = document.getElementById(ident);
    this.target.jObject = this;
    
    this.maxthumbs = 6;
    
    this.thumbswidth = 0;
    this.pics = Array();
    
    this.converted = false;
    
    this.setPlayer = function (player) {
    	this.player = player;
    	this.init();
    	
    	
    }
    this.convert = function() {
        
        
        
        var theBar = document.getElementById(this.ident + "bar");
        
        var cat = document.getElementById(this.ident + "st").innerHTML;
        
        
        /*this.clearElement(this.ident + "bar");
        
        var ul  = document.createElement("ul");
        ul.id = this.ident;
        ul.className = "thumbnails";
       
        theBar.appendChild(ul);
        
        
        
      
        
        
        this.init();
        
        var span = document.createElement("span");
        span.className = "subtitle";
        span.innerHTML = cat;
        
        theBar.appendChild(span);*/
        this.mode = "normal";
        this.target = document.getElementById(this.ident);
        
        theBar.id = "";
        theBar.style.height = "auto";
        theBar.style.width = "auto";
        theBar.style.overflow = "hidden";
        theBar.className = "";

        
        this.target.style.height = "auto";
        this.target.style.width = "790px";
        this.target.style.left = "0";
        
        this.target.onmouseover = function () {};
        this.target.onmousemove = function () {};
        
        
        
        
    }
    
    this.clearElement = function (element) {
		
		var content = document.getElementById(element);

        if ( content.hasChildNodes() )
        {
  	    while ( content.childNodes.length >= 1 )
            {
    			content.removeChild( content.firstChild );       
    	    } 
		}
	
        
    }
    
    this.init = function() {
        
        for (var x = 0; x < this.thumbs.length; x++) {
            
            
            var pic = new Image();
            pic.src = this.thumbs[x].image;
            
            if (this.mode == "thumbs") {
            	pic.jObject = this;
            	pic.picId = x;
				pic.onload = function () { this.jObject.loaded(this.picId); }

                
                this.pics[this.pics.length] = {'pic': pic, 'loaded':false};
            }
            
            var li = document.createElement("li");
        
            var a = document.createElement("a");
            a.href = this.thumbs[x].link;
            
            if (this.thumbs[x].text != '')
            {
            	
            	a.jObject = this;
            	a.picId = x;
            	
				a.onmouseout = function (event) { this.jObject.hideToolTip(this.picId, event); }
				a.onmouseover = function (event) { this.jObject.showToolTip(this.picId, event); }
				a.onmousemove = function (event) { this.jObject.showToolTip(this.picId, event); }

                
                var div = document.createElement("div");
                div.id = this.ident + "TT" + x;
                
  				
  				div.className = "tooltip";
  				
                div.appendChild(document.createTextNode(this.thumbs[x].text));
                
                document.body.appendChild(div);
                //alert("hello");
                this.hideToolTip(x);
            
            }
            if (this.thumbs[x].onclick != '') {
            	a.player = this.player;
            	a.playId = parseInt(this.thumbs[x].onclick);
            	
				a.onclick = function () { this.player.display(this.playId); return false; }
            	
            	
            }
            
            
            var img = document.createElement("img");
            img.src = this.thumbs[x].image;
            
            
            a.appendChild(img);
            li.appendChild(a);
            this.target.appendChild(li);            
            
        }
        
        if (this.mode == "thumbs" && this.thumbs.length > 6) {
            
            this.target.style.width = (this.thumbs.length * 124) + "px";
            
            
            this.target.style.height = "100px";
            this.target.style.overflow = "hidden";
            
            var span = document.createElement("a");
            span.href = "#";
            span.className = "thumbscount";
            
            
            span.jObject = this;
			span.onclick = function () { this.jObject.convert(); return false; }

        
        
            span.innerHTML = "" + (this.thumbs.length - this.maxthumbs) + " MORE... ";
        
            document.getElementById(this.ident + "bar").appendChild(span);
        }
        
        //document.body.ttObject = this;
        //document.body.onunload = function () { document.body.ttObject.hideAllToolTips(); }
        
        if (this.mode == "full" && this.converted == false) {
            	this.converted = true;
            	this.convert();
            	
            }

    }
    
    this.hideAllToolTips = function () {
            
        for (x = 0; x < this.thumbs.length; x++) {
                
         this.hideToolTip(x);           
        }
    }
    
    this.showToolTip = function(id, e) {
        
        var e = (window.event) ? window.event : e;
        
        var tooltip = document.getElementById(this.ident + "TT" + id);
        
        var mouseX;
        var mouseY;
        
        
        
        if('undefined'!=typeof e.pageX) {
            
            mouseX = e.pageX;
            mouseY = e.pageY;
            
        }
        else
        {
        	//alert ("clientY: " + e.clientY + " scrollTop:" + document.body.scrollTop);
            mouseX = e.clientX + document.documentElement.scrollLeft;
            mouseY = e.clientY + document.documentElement.scrollTop;
            
        }
        
        tooltip.style.left = "" + (mouseX - 10) + "px";
        tooltip.style.top = "" + (mouseY - 30) + "px";
        
        tooltip.style.display = "block";
        tooltip.style.visibility = "visible";
        
        
        
    }
    
    this.hideToolTip = function(id) {
        
        var tooltip = document.getElementById(this.ident + "TT" + id);
        
        tooltip.style.display = "none";
        tooltip.style.visibility = "hidden";
        
    }
    
    
    this.loaded = function (id) {
        this.pics[id].loaded = true;
        
        if (this.mode == "thumbs") {
            if (this.allLoaded()) this.setWidth();
        }
    }
    this.allLoaded = function() {
        
        for (var x = 0; x < this.pics.length; x++) {
            
            if (this.pics[x].loaded == false) return false;
            
        }
        
        return true;
        
    }
    
    this.setWidth = function () {
        
        var counter = 0;
        var totalheight = 0;
        var barwidth = 0;
        
        for (x = 0; x < this.pics.length; x++) {
            
            counter += this.pics[x].pic.width;
            counter += 8;   //margin
            counter += 8;   //width + border
            counter += 9;   // extra to account for temporary stretch !!!!!!!!!!
            
            if (x < this.maxthumbs) barwidth += this.pics[x].pic.width + 22;
            
            if (this.pics[x].pic.height > totalheight) totalheight = this.pics[x].pic.height;
        }
        totalheight += 60;
        
        
        this.target.style.width = "" + counter + "px";
        document.getElementById(this.ident + "bar").style.height = "" + totalheight + "px";
        document.getElementById(this.ident + "bar").style.width = "" + barwidth + "px";
        
    }
}
