BwClasses["BwLink"] = BwLink;

function BwLink ()
{
	this.isa = BwWidget;
	this.isa();
	
    this.url = null;
    this.targ = null;
    
	this.initFromDOM = BwLink.initFromDOM;
	
    this.setUrl = BwLink.setUrl;
	this.getUrl = BwLink.getUrl;

    this.setTarget = BwLink.setTarget;
	this.getTarget = BwLink.getTarget;

    this.setValue = BwLink.setValue;
	this.getValue = BwLink.getValue;
}

BwLink.newInstance = function (linkName, linkUrl, linkTarget)
{
	var self = document.createElement ("A");
	
	self.BwClass = BwLink;
	self.BwClass();

	self.className = "BwLink";
	
	if (linkUrl==null) {
		self.setAttribute ("href", "#");
    } else {
		self.setAttribute ("href", linkUrl);
    }
	
	if (linkName) {
		self.setAttribute ("title", linkName);
	}
	
    if (linkTarget && linkUrl!='null') {
		self.setAttribute ("target", linkTarget);
	}
	
	self.initFromDOM();
	
	return self;
};

BwLink.initFromDOM = function ()
{
	BwWidget.initFromDOM.call (this);
	
	//this.style.cursor="pointer";
	var linkName = this.getAttribute ("title");
	if (linkName != null && linkName!="")
		this.setValue (linkName);
};

BwLink.setUrl = function (u)
{
    this.url = u;
    this.href=u;
};

BwLink.getUrl = function ()
{
    var u = this.url;
    if (u==null) return null;
	return u;
};

BwLink.setTarget = function (targ)
{
    this.targ = targ;
    this.target = targ;
};

BwLink.getTarget = function ()
{
    var t = this.targ;
    if (t==null) return null;
	return t;
};

BwLink.getValue = function ()
{
	return this.innerHTML;
};

BwLink.setValue = function (link)
{
	this.innerHTML = link;
};

