YAHOO.namespace('YAHOO.nestle.page');

YAHOO.nestle.page.Recipe = function() {
	
	var loadHandler = function () {
		YAHOO.nestle.page.Recipe.init();
	}
	
	YAHOO.util.Event.onDOMReady(loadHandler);
	// YAHOO.util.Event.on(window, 'load', loadHandler);
	
	/* public methods */
	return {
		
		init : function() {
			
			this.element = YAHOO.util.Dom.getElementsByClassName('crecipe', 'div')[0];
			
			this.voteLink = YAHOO.util.Dom.getElementsByClassName('vote', 'a', this.element)[0];
			
			// create panel
			// YUI panel: http://developer.yahoo.com/yui/container/panel/
			// YUI panel API documentation: http://developer.yahoo.com/yui/docs/YAHOO.widget.Panel.html
			
			var config = {context:[this.voteLink, "tl", "tl"], width: '133px', draggable: true, visible: false, constraintoviewport: true};
			YAHOO.nestle.page.Recipe.votePanel = new YAHOO.widget.Panel("vote-panel", config);
			YAHOO.nestle.page.Recipe.votePanel.render();
			
			YAHOO.util.Event.on(this.voteLink, 'click', YAHOO.nestle.page.Recipe.votePanel.show, YAHOO.nestle.page.Recipe.votePanel, true);
			
		}
		
	};
	
}();