
var main = (function main() {
	
	'use strict';
	
	return {
		
		hover: {
		
			init: function init() {
				
				var $menuLi, $worksMenuA, $worksContentLi;
				
				$menuLi = $('#header ul.menu li:not(.active)');
				$worksMenuA = $('#works-menu a');
				$worksContentLi = $('#works-content li');
			
				$('img.menu-off', $menuLi).show();
				$('img.menu-on', $menuLi).hide();
				$('#works-menu a').css('color', '#666666');
				$('div.over', $worksContentLi).hide();
						
				$menuLi.bind('mouseover', function () { $('img.menu-off', $(this)).hide(); $('img.menu-on', $(this)).show(); });
				$menuLi.bind('mouseout', function () { $('img.menu-off', $(this)).show(); $('img.menu-on', $(this)).hide(); });
			
				$worksMenuA.bind('mouseover', function () { $(this).css('color', '#000000'); });
				$worksMenuA.bind('mouseout', function () { if (!$(this).hasClass('selected')) { $(this).css('color', '#666666'); } });
			
				$worksContentLi.bind('mouseover', function () { $('div.over', $(this)).show(); });
				$worksContentLi.bind('mouseout', function () { $('div.over', $(this)).hide(); });
			}
		},
	
		slider: {
		
			videos: [],
			currentVideo: '',
		
			init: function init(id) {
			
				var that = this;
						
				$('#slider-' + id + ' div.scrollable').scrollable({
					touch: false,
					onSeek: function () {
						that.currentVideo = '';
						that.stopVideos();
					}
				});
			},
		
			stopVideos: function stopVideos() {
			
				while (this.videos.length > 0) {					
					var id = this.videos.pop();				
					if (id !== this.currentVideo) {
						jwplayer(id).pause(true);
					}
				}
			}
		},
	
		works: {
		
			init: function init() {			
				
				var that, $worksMenuA;
				
				that = this;
				$worksMenuA = $('#works-menu a');
				$worksMenuA.bind('click', function () {
					var $this = $(this);
					$worksMenuA.removeClass('selected').css('color', '#666666');
					$this.addClass('selected').css('color', '#000000');
					that.changeCat($this.attr('id'));
				});
			
				//$('#works-menu a:first').trigger('click');
			},
		
			changeCat: function changeCat(id) {
								
				$.each($('#works-content li'), function (index, elem) {
					var $elem = $(elem);
					if ($elem.hasClass(id)) {
						$elem.show();
					} else {
						$elem.hide();
					}
				});
			}	
		}
	};

}());
