var main = 
{
	prev : $(window).height(),
	showWhyContent : function()
	{				
		var bottom = $(window).height() - 290;
	
		$("#why-rollr-show").animate({"bottom":bottom+"px"},500,function(){
			$("#why-rollr-show").hide();
			$("#why-rollr-hide").show();
		});
		
		$("#fade-bg").slideUp(500,function(){
			$("#just-signup-div").fadeIn(500);
			$("#why-content-inner").fadeIn(500);
		});
		
		$("#why-rollr-content").show();
		$("#why-spacer").show();
						
	},
	hideWhyContent : function()
	{
		$("#why-rollr-hide").hide();
		$("#why-content-inner").hide();
		
		var top = $(window).height() - 132;
			
		$("#why-rollr-show").show().css({"top":"157px"})/*.removeAttr("style")*/.animate({"top":top+"px","bottom":"0px"},500,function(){
			$("#why-rollr-show").removeAttr("style");
			$("#why-rollr-content").hide();
		});
		
		$("#just-signup-div").hide();
		
		$("#fade-bg").slideDown(500,function(){
		});
	},
	resizeLogo : function()
	{
		var h = $(window).height();
		//var w = $(window).width();
		
		var moved = false;
		
		if (main.prev > h) {
			// Shrinking
			var ch = $("#logo img").height();
			if (ch > 50 && h < 600) {
				var nh = ch - (main.prev-h);
				nh = (nh < 50) ? 50 : nh;
				$("#logo img").height(nh);
				main.prev = h;
				moved = true;
			}
		} else if (main.prev < h) {
			// Grow
			var ch = $("#logo img").height();
			if (ch < 155) {
				var nh = ch + (h-main.prev);
				nh = (nh > 155) ? 155 : nh;
				$("#logo img").height(nh);
				main.prev = h;
				moved = true;
			}
		}
		
		if (moved == false) main.prev = h;
	}
}

$(document).ready(function(){

	$(document).click(function(e){
		var $this = $(e.target);
		
		switch($this.attr('id')) 
		{
			// To show the content
			case 'why-rollr-title-show':
			case 'why-title-h3-show':
			case 'up-arrow-circle':
				main.showWhyContent();
				break;
			// To hide the content
			case 'why-rollr-title-hide':
			case 'why-title-h3-hide':
			case 'down-arrow-circle':
				main.hideWhyContent();
				break;
			case 'show-scroll-top':
				alert($(document).scrollTop());
				break;
			default:
				break;
		}
	});
	
	// On load resize
	/*if ($(window).height() < 600) {
		var h = $(window).height() - 448;
		h = (h < 50) ? 50 : (h > 155) ? 155 : h;
		$("#logo img").height(h);
	}*/
	
	$(window).resize(function(){
		
		//main.resizeLogo();
		
	});
});
