/*
* Generic highlighted list object for mouseovers and selections of list items in
* Serif Web Resources crossbar
* Author: DC
*/
var Xlist =
{
	currentUID: "",
    callback: null,
    outclass: "listelement",
    overclass: "listelementhot",
    selectedclass: "listelementselected",
        
	init: function(callback, first_id, first_selected) {
    	$("."+this.outclass).click(function(){
        	Xlist.selectItem(this.id);
        });
        $("."+this.outclass).mouseover(function(){
        	$(this).attr("class", Xlist.overclass); 
        }).mouseout(function(){
        	if(this.id != Xlist.currentUID)
    	    	$(this).attr("class", Xlist.outclass);
            else
            	$(this).attr("class", Xlist.selectedclass);
        });

    	this.callback=callback;
        if(first_selected)
        {
        	this.selectItem(first_id);
        }
    },
    
    selectItem: function(id) {
        if(this.currentUID != "")
    		$("#"+this.currentUID).attr("class", this.outclass);
    	this.currentUID = id;
        $("#"+id).attr("class", this.selectedclass);
        if(this.callback)
        	this.callback(id);
    }
}
