$(document).ready(function() {
	$(document).bind("mousemove",function(e){
		
		var yPercentage = Math.floor(((e.pageX/$(document).width())-0.5)*45);
		var xPercentage = -(Math.floor(((e.pageY/$(document).height())-0.5)*30));
		var rPercentage = (e.pageY/$(document).height());
		var bPercentage = (e.pageX/$(document).width());
	
		$("#logo").css({webkitTransformOrigin:(100*rPercentage)+"% "+(100*bPercentage)+"%", webkitTransform:"rotateX("+xPercentage+"deg) rotateY("+yPercentage+"deg)",textShadow:"0px 3px 10px rgba("+Math.floor(255*rPercentage)+",0,"+Math.floor(255*bPercentage)+",1)"});
		
	});

	$(".hBar")
	.bind("click",function(){
		
		$(this).toggleClass("active");
		if($(this).hasClass("active")){
			var percentageShowing = ($(this).children(".content").width()/$(this).children(".content").children(".innerContent").width());
			var scrollBarWidth = (percentageShowing * $(this).children(".content").width());
			$(this).children(".scrollBar").stop().animate({opacity:1, width:scrollBarWidth+"px"},400,"easeInOutQuad");
			$(this).stop().animate({marginTop:'0px'},400,"easeInOutQuad");
		} else {
			$(this).stop().animate({marginTop:'-210px'},400,"easeInOutQuad");
			$(this).children(".scrollBar").stop().animate({opacity:0},400,"easeInOutQuad");
		};
		
		
		
		//this.style.webkitTransform = "translate3d(0px,0px,0px)"; 
		//$(this).stop(true,false).animate({padding:"30px", margin:"-30px"},300);
		//;
	})
	.children(".content")
	.bind("mouseenter",function(){

		//alert($(this).width());
	//	$(this).removeClass("active");
		//this.style.webkitTransform = "translate3d(0px,0px,-100px)"; 
		//$(this).stop(true,false).animate({padding:"0px", margin:"0px"},300);
	})
	;
	
	return false;
	$("#backgroundTexture").bind("load",function(){
		$("#backgroundTexture").animate({opacity:1,top:'0px'},4000,"easeOutElastic");
	})
	$("#backgroundTexture").bind("load",function(){
		
		$("#topMenu").animate({top:'19px'},4000,"easeOutElastic",function() {
			//topMenu.style.webkitTransform = "rotateX(0deg)";
			$(this).animate({boxShadow: "0 0 16px rgba(0,0,0,0.4)"},1000);
		});
		
		$("#backgroundContent").animate({top:'0px'},4000,"easeOutElastic",function() {
			$("#backgroundBars").delay(1000).animate({width:"100%"},3000,"easeInSine",function(){
			});
			$(this).animate({boxShadow: "0 0 16px rgba(0,0,0,0.4)"},1000);
			
		});
	})

	//.bind("mouseleave",function(){
	//	$(this).removeClass("active");
		//this.style.webkitTransform = "translate3d(0px,0px,-100px)"; 
		//$(this).stop(true,false).animate({padding:"0px", margin:"0px"},300);
	//})
});
