YAHOO.namespace("tellafriend");
var DOM = YAHOO.util.Dom;
var EVT = YAHOO.util.Event;

YAHOO.tellafriend.button = function(hook, pageType) {
	this.init(hook, pageType);
};

YAHOO.tellafriend.button.prototype = {
	pageType : null,
	location : '',
	
	init: function(hook, pageType) {
		this.pageType = pageType;
		this.location = location.href;
		EVT.on(hook, 'click', function(e) { EVT.preventDefault(e); this.showDialog(); }, this, true);
	},
	
	showDialog: function() {
		var winWidth	= 370;
		var winHeight	= 480;
		
		var winLeft		= (DOM.getDocumentWidth() - winWidth) / 2;
		var winTop		= (DOM.getDocumentHeight() / 2) - winHeight;
		
		var tellwinparam = 'scrollbars=0,toolbar=0,menubar=0,resizable=0,status=0,width='+winWidth+',height='+winHeight+',top='+winTop+',left='+winLeft;
		var tellwindow = window.open('/tell-friend.html?type='+this.pageType+'&loc='+this.location, 'tellwindow', tellwinparam);
		if(window.focus) { tellwindow.focus(); }
	}
}