
function UPControlPanel() {
}
UPControlPanel.prototype = new DowWidget;

UPControlPanel.prototype.postInit = function () {
	this.toggleElem = document.getElementById(this.uid+"_toggle");
	this.toggleIconElem = document.getElementById(this.uid+"_toggle_icon");
	this.toggleTextAddElem = document.getElementById(this.uid+"_toggle_text_add");
	this.toggleTextRemoveElem = document.getElementById(this.uid+"_toggle_text_remove");
	this.bindEvent(this.toggleElem,"click","toggleAction"); 
}

UPControlPanel.prototype.toggleAction = function (event) {
	this.params.rank=this.params.rank ? 0 : 1;
	this.doRanking(this.params.rank);
	this.updateToggle();
}

UPControlPanel.prototype.doRanking = function(value) {
	var action = this.createEmptyAction("ranking");
	var doc = action.ownerDocument;
	var rankingElem = doc.createElement("rank");
	rankingElem.setAttribute("value",value);
	action.appendChild(rankingElem);
	this.sendAction(action.ownerDocument);
}

UPControlPanel.prototype.updateToggle = function () {
	if (this.toggleIconElem) {
		if (this.params.rank) {
			this.unsetElementClass(this.toggleIconElem , "up_favorite_icon_off");
			this.setElementClass(this.toggleIconElem , "up_favorite_icon_on");
		} else {
			this.setElementClass(this.toggleIconElem , "up_favorite_icon_off");
			this.unsetElementClass(this.toggleIconElem , "up_favorite_icon_on");
		}
	}
	
	if (this.toggleTextAddElem && this.toggleTextRemoveElem) {
		if (this.params.rank) {
			this.toggleTextAddElem.style.display="none";
			this.toggleTextRemoveElem.style.display="inline";
		} else {
			this.toggleTextAddElem.style.display="inline";
			this.toggleTextRemoveElem.style.display="none";
		}
	}
}

