
function disableSelection(element) {
    element.onselectstart = function() {
        return false;
    };
    element.unselectable = "on";
    element.style.MozUserSelect = "none";
}

ListView_SetupItem = function(x) {
	x.onmouseover=function() { 
		this.style.backgroundImage='url(lvover.gif)'; 
	 	this.style.cursor='pointer';
	 	this.firstChild.style.backgroundImage='url(lvoverl.gif)';
	 	this.lastChild.style.backgroundImage='url(lvoverr.gif)';
	}
	x.onmouseout=function() {
		this.style.backgroundImage='';
		this.firstChild.style.backgroundImage='';
		this.lastChild.style.backgroundImage='';
	}
	x.onclick=function() {
		document.location='downloads/'+this.fnDownload;
	}
}

ListView_AddSubItem = function(row) {
	var col = row.insertCell(row.childNodes.length-1);
	col.className = 'lvitem';
	disableSelection(col);
	return col;
}

ListView_InsertItem = function(lv, icon, name, size, fn) {
	var row = lv.insertRow(-1);
	row.className = 'lvitem';
	var col = row.insertCell(-1);
	col.className = 'lviteml';
	col = row.insertCell(-1);
	col.className = 'lvitemr';

	ListView_AddSubItem(row).innerHTML="<img src='" + icon + "'/>";
	ListView_AddSubItem(row).innerHTML=name;
	var c = ListView_AddSubItem(row);
	c.innerHTML=size;
	c.style.textAlign="right";

	row.fnDownload=fn;

	ListView_SetupItem(row);
}
