$(document).ready(function(){						   
	
		
	$("#testimonial").click(function(){	
		$("#testPopup").animate({"top": "0"}, "slow");							 
	
	});
	
	$("#testClose").click(function(){
		$("#testPopup").animate({"top": "477"}, "slow");							
			
	});
	
	$("#privacy").click(function(){	
		$("#privPopup").animate({"top": "0"}, "slow", function(){
			 $("#researchText").hide();
		});						 
	
	});
	
	$("#privClose").click(function(){
		$("#researchText").show();						   
		$("#privPopup").animate({"top": "477"}, "slow");							
			
	});	
	
	$("#casestudy").click(function(){	
		$("#casePopup").animate({"top": "0"}, "slow");							 
	
	});
	
	$("#caseClose").click(function(){
		$("#casePopup").animate({"top": "477"}, "slow");							
			
	});	
	
	var moving = false;
	
	$("#scrollDOWN").click(function(){
		var top = $("#text").css("top");	
		var height = $('#text').innerHeight();	
		var containerHeight = $("#scrollContainer").css("height");

		top = top.replace("px","")
		containerHeight = containerHeight.replace("px","")
			
		top = parseInt(top)
		containerHeight = parseInt(containerHeight)
		
		var maxTop = height - containerHeight;
			
		maxTop = maxTop - (maxTop*2);
			
		var nextTop = top - 90;
	
		if (nextTop < maxTop) {			
			nextTop = maxTop;	
		}
		
		if (moving == false) {	
			moving = true;
			$("#text").animate({"top": nextTop}, "slow",function(){
				 moving = false;
			});
		}			
	});
	
	$("#scrollUP").click(function(){
	
		var top = $("#text").css("top");	
		top = top.replace("px","")	
		top = parseInt(top)
			
		maxTop = 0;
		
		var nextTop = top + 90;
		
		if (nextTop > maxTop) {		
			nextTop = maxTop;	
		}
		
		
		if ((top < 0) && (moving == false)) {
			moving = true;
			$("#text").animate({"top": nextTop}, "slow",function(){
				 moving = false;
			});
		}			
	});
	
	var moving_priv = false;
	
	$("#priv_scrollDOWN").click(function(){
		var top = $("#privText").css("top");	
		var height = $('#privText').innerHeight();	
		var containerHeight = $("#privScrollContainer").css("height");

		top = top.replace("px","")
		containerHeight = containerHeight.replace("px","")
			
		top = parseInt(top)
		containerHeight = parseInt(containerHeight)
		
		var maxTop = height - containerHeight;
			
		maxTop = maxTop - (maxTop*2);
			
		var nextTop = top - 120;
	
		if (nextTop < maxTop) {			
			nextTop = maxTop;	
		}
		
		if (moving == false) {	
			moving = true;
			$("#privText").animate({"top": nextTop}, "slow",function(){
				 moving = false;
			});
		}			
	});
	
	$("#priv_scrollUP").click(function(){
	
		var top = $("#privText").css("top");	
		top = top.replace("px","")	
		top = parseInt(top)
			
		maxTop = 0;
		
		var nextTop = top + 120;
		
		if (nextTop > maxTop) {		
			nextTop = maxTop;	
		}
		
		
		if ((top < 0) && (moving == false)) {
			moving = true;style="z-index:0;"
			$("#privText").animate({"top": nextTop}, "slow",function(){
				 moving = false;
			});
		}			
	
	
	});
});	
