$(function () {

	$('.smooth')
		.bind('mouseenter', function (e) {
			$(this).stop().animate({opacity: 1});
		})
		.bind('mouseleave', function (e) {
			$(this).stop().animate({opacity: 0});
		});
		
	$('#hameed .contact')
		.bind('mouseenter', function (e) {
			$('#feel').stop().animate({opacity: 1});
		})
		.bind('mouseleave', function (e) {
			$('#feel').stop().animate({opacity: 0});
		});
		
	function howmanyrows() {
		var h = $('#section').height();
		var r = h / 154;
		
		return r;
	}
		
	$('#controls')
		.bind('checkupdn', function (e) {
			var t = $('#section').scrollTop();
			var b = $('#section .video:not(.dnone):last').position().top;
			var r = (howmanyrows() - 1) * 154;
			
			$('#controls .up').removeClass('disabled');
			$('#controls .dn').removeClass('disabled');
			
			if (t == 0) {
				$('#controls .up').addClass('disabled');
			}
			
			if (r == b) {
				$('#controls .dn').addClass('disabled');
			}
		});
		
	$('#controls').trigger('checkupdn');
	
	$('#section')
		.bind('scrollup', function () {
			$(this).scrollTo('-=154px', {
				duration: 150,
				axis: 'y',
				onAfter: function () {
					$('#controls').trigger('checkupdn');
				}
			});
		})
		.bind('scrolldn', function () {
			$(this).scrollTo('+=154px', {
				duration: 150,
				axis: 'y',
				queue: false,
				onAfter: function () {
					$('#controls').trigger('checkupdn');
				}
			});
		});

	$('#controls .dn')
		.mousehold(200, function () {
			$('#section').trigger('scrolldn');
		});
		
	$('#controls .up')
		.mousehold(200, function () {
			$('#section').trigger('scrollup');
		});
		
		$(window)
			.bind('cresize', function () {
				var
					OH = $(window).height(),
					MH = 60,
					FH = 259,
					SH = $('#section').height(),
					EH = OH - FH - SH - MH;
					
				console.log(EH);
					
				
				var _H = (Math.floor((SH + EH) / 154) * 154);
				$('#section').height(_H);
				
				$('#controls').trigger('checkupdn');
			})
			.bind('resize', $.debounce(50, function (e) {
				$(this).trigger('cresize');
			}));

		$(window).trigger('cresize');
	
});
