(function() {
	var $P = getPackageForName("nic.dhar.widgets");
	$P.Flip = function(element, initParams) {
		if(element) {
			this.flipEl = element;
		}
		//Close Button.
		var closeButton = this.flipEl.one("div.overlay-hd a.close");
		closeButton.on("click", this.hide, this);
	};
	
	$P.Flip.prototype.setEl = function(el){alert(1);}
	/*
	 * Show the flip.
	 */
	$P.Flip.prototype.show = function() {
		this.flipEl.setStyle("display", "block");
	};

	/*
	 * Hide the flip.
	 */
	$P.Flip.prototype.hide = function() {
		this.flipEl.setStyle("display", "none");
	};

	/*
	 * Update the flip Content.
	 */
	$P.Flip.prototype.update = function(event) {
		var imgObj = event.currentTarget;
		var title = event.currentTarget.getAttribute("title");
		var flipTitle = this.flipEl.one("div.overlay-hd strong");
		flipTitle._node.innerHTML = title;

		var thumb = event.currentTarget.getAttribute("src");
		var src = thumb.replace(/thumbnail/g, "overlay");
		var flipContent = this.flipEl.one("div.overlay-bd");
		flipContent._node.innerHTML = '<img src="' + src + '" title="' + title + '" alt="' + title + '"/>';
		this.show();
	};
})();
