$(document).ready(function(){
	var sbStatus = 0;
	//SETUP
	$("#sidebar").css({width : 1});
	$("#product_container").hide();
	$("#video_container").hide();
	$("#checkout_container").hide();
	$("#logo").hide();
	$("#footer").hide();
	$("#menu").hide();
	$('body').css('background-image', 'url(img/goodsbg.jpg)');
	$('body').css('background-repeat', 'no-repeat');
	var winHeight = $(window).height();
	$("#logo").css({'top':winHeight*0.2});
	if(jQuery.url.attr("anchor")=="store"){
		$('html, body').animate({scrollTop:0}, 'fast');	
		sbLeft();
		showStore();
		sbStatus = 1;
	}else{
		$("#sidebar").animate({opacity: 0},100);
		$("#sidebar").css({'left': '50%'});
		$("#sidebar").animate({width: 236,'left':'50%',marginLeft: "-118px", opacity: 1},600,'easeOutCirc',function() {
			$("#logo").fadeIn(600,function() {
				$("#footer").fadeIn(600);
			});
		});
	};
	
	function sbLeft(){
		$('body').css('background-image', 'url(img/bg.png)');
		$('body').css('background-repeat', 'repeat');
		$("#logo").css({'top':'20px'});
		$("#sidebar").css({width : 236,'left':'0%',marginLeft: 0});
		$("#logo").fadeIn(600);
		$("#footer").fadeIn(600);		
	}
	
	//SIDEBAR ANIMATE TO LEFT
	function sbMoveLeft(){
		$('body').css('background-image', 'url(img/bg.png)');
		$('body').css('background-repeat', 'repeat');
		$("#logo").animate({opacity: 0},200);
		$("#sidebar").animate({opacity: 0.50},200);
		$("#sidebar").animate({'left':'0%',marginLeft: 0},800,'easeOutCirc');
		$("#sidebar").animate({opacity: 1.00},200,function(){
			$("#logo").css({'top':'20px'});
			$("#logo").animate({opacity: 1},200);
			showStore();
		});
		sbStatus = 1;
	};
	
	//SIDEBAR ANIMATE TO CENTER
	function sbMoveCenter(){
		$('body').css('background-image', 'url(img/goodsbg.jpg)');
		$('body').css('background-repeat', 'no-repeat');
		$("#logo").animate({opacity: 0},200);
		$("#sidebar").animate({opacity: 0.50},200);
		$("#sidebar").animate({'left':'50%',marginLeft: "-118px"},800,'easeOutCirc');
		$("#sidebar").animate({opacity: 1.00},200,function(){
			$("#logo").css({'top':winHeight*0.2});
			$("#logo").animate({opacity: 1.00},200);	
			window.location.hash = '';
		});
		sbStatus = 0;
	};
	
	function showStore(){	
		$("#product_container").show();
		$("#menu").show();
	}
	
	function hideStore(){	
		$("#product_container").hide();
		$("#menu").hide();
	}
	
	//ENTER CLICK
	$('#logo').click(function(){
		if(sbStatus == 0){
			sbMoveLeft();
		}else{
			sbMoveCenter();
			hideStore();
		};
	});
});
