/**
 * @author Filip Michalowski / Fi Stockholm
 */
Namespace.create("ng.modules.eventsModule");

ng.modules.eventsModule.EventsModule = function () {

	//private variables:
	var moduleContainer;
	var moduleData;
	var DEFAULT_HEIGHT = 210;

	//private methods:
	var draw = function() {		
		
		
	};
	
	var updateStyles = function() {
		// set colors of table rows
		moduleContainer.find("table.contentTable tbody tr:odd td").css("background-color", "#ffffff");
		
		// set first row top border		
		moduleContainer.find("table.contentTable tbody tr:first td").css("border-style", "solid");
		
		// set scrollbar if more than 5 items
		if (moduleContainer.find("table.contentTable tbody tr").length > 5) {
			
			var heightFive = 0;
			var initialRowWidth = moduleContainer.find("table.contentTable tbody tr:lt(1)").width();
			
			// first set the initial height to show the scrollbar and calcute correct height values
			moduleContainer.find("div.contentTableWrapper").css("max-height", DEFAULT_HEIGHT+"px");		
			
			// calculate the height of first 5 rows
			moduleContainer.find("table.contentTable tbody tr:lt(5)").each(function() {
				heightFive += $(this).height();
			})
			
			moduleContainer.find("div.contentTableWrapper").css("max-height", heightFive+"px");
			
			// set the width header table last cell
			var finalRowWidth = moduleContainer.find("table.contentTable tbody tr:lt(1)").width();						
			moduleContainer.find("table.headerTable td.eventTicketsCell").width( moduleContainer.find("table.headerTable td.eventTicketsCell").width() + ( initialRowWidth - finalRowWidth ) );
		
		}
		
	};

	//the returned object here will become ng.modules.eventsModule.EventsModule:
	return  {
		
		// public
		eventsArray: [],

		init: function (container, data) {
			moduleContainer = container;
			moduleData = data;
			
			updateStyles();
			
		}

	};
}(); // the parens here cause the anonymous function to execute and return


/**
 * Markup templates for the eventsModule
 */
ng.modules.eventsModule.EventsModuleTemplates = 
{
	
};