ApplicationPages = {
	application : function() {
		$(".slider").huffslider({
		  duration:10000
		});
		$(".prev-arrow").bind('click', function() {
		  $(".slider").huffslider('prev');
		});
		$(".next-arrow").bind('click', function() {
		  $(".slider").huffslider('next');
		});
		if ($(".scroller > div").height() < $(".scroller").height()) 
			$(".more-link").add(".less-link").remove();
		
		if ($(".red-black").size() >= 1) {
			$(".red-black").live('mouseenter', function() {
				$(this).animate({
					backgroundColor:"#B70412"
				}, 500);
			});
			$(".red-black").live('mouseleave', function() {
				$(this).animate({
					backgroundColor:"#000000"
				}, 500);
			});
			var interval_count = 0;
			setTimeout(function() {
				var interval = setInterval(function() {
					if (++interval_count > 2) {
						clearInterval(interval)
						return;
					}
					$(".red-black").animate({
						backgroundColor:"#B70412"
					}, 250, function() {
						$(".red-black").animate({
							backgroundColor:"#000000"
						}, 250);
					});
				}, 500);
			}, 1500)
		}
		if ($(".post-comments").size() > 0) {
			FB.init("51132609e1abe2ca368de2bad6bd3959", "http://citylifefilmproject.com/xd_receiver.htm");
		}
		
		$(".videos-list li").hover(function() {
			$(".title", this).animate({top:112}, 200);
		}, function() {
			$(".title", this).animate({top:142}, 200);
		});
	}
};

(function($, undefined) {
	$(document).ready(function() {
		if ($("#content.videos-page").size()>0) {
			(function() {
				var r = 0.33;
				var c = $("#content"), vl = $(".videos-list");
				var ch = c.height(), vh = vl.height();
				var su = r * ch, sd = (1-r) * ch;
				var speed = 100, dir = 0, delta = 10, max = 10;
				function startScroll() {
					if (dir != 0) {
						var t = parseInt(vl.css('top'));
						if (dir == -1 && t >= 0) {
							return
						} else if (dir == 1 && Math.abs(t) >= vh - ch) {
							return;
						}
						vl.animate({top:(dir==1?'-=':'+=')+delta+"px"}, speed, startScroll);
					}
				}
				
				/*$("#content").bind('mousemove', function(e) {
					var y = e.pageY-c.get(0).offsetTop;
					if (y < su) {
						if (dir != -1) {
							dir = -1;
							startScroll();
						}
					} else if (y > sd) {
						if (dir != 1) {
							dir = 1;
							startScroll();
						}
					} else {
						dir = 0;
					}
				});
				$("#content").bind('mouseout', function() {
					dir = 0;
				});*/
			})();
		}
		
		$(".dropdown li").live('mouseenter', function() {
			$(this).animate({
				backgroundColor : "#727272"
			}, 500);
		})
		$(".dropdown li").live('mouseleave', function() {
			$(this).animate({
				backgroundColor : "#B3B3B3"
			}, 500);
		});

		$('.more-link').live('click', function(e) {
			e.preventDefault();
			var link = $(this);
			var cont = link.parent().siblings(".scroller").find("div").eq(0);
			var DELTA = 350;
			
			link.siblings(".less-link").fadeIn(1500, 'easeInExpo');
			var check = parseInt(cont.css('top'))*-1 + DELTA;
			if (check >= cont.height()) return;
			//if ((Math.abs(parseInt(cont.css('top'))) + (DELTA*2)) >= cont.height()) link.fadeOut(1500, 'easeOutExpo');
			cont.animate({
				top : "-="+DELTA+"px"
			}, 1500, 'easeInOutExpo');
		});
		$(".less-link").live('click', function(e) {
			e.preventDefault();
			var link = $(this);
			var cont = link.parent().siblings(".scroller").find("div").eq(0);
			var DELTA = 350;
			
			link.siblings(".more-link").fadeIn(1500, 'easeInExpo');
			if (parseInt(cont.css('top')) >= 0) return;
			//if (parseInt(cont.css('top'))+DELTA >= 0) link.fadeOut(1500, 'easeOutExpo');
			cont.animate({
				top : "+="+DELTA+"px"
			}, 1500, 'easeInOutExpo');
		});
	});
})(jQuery);

