$(document).ready(function() {

	var ph = parseInt($(window).height() / 2);
	var pw = parseInt($(window).width() / 2);
	
    $('.fancybox').fancybox({
    	'autoDimensions': true,
        'showCloseButton': true,
        'enableEscapeButton': true
    });     
    
    $("a[rel^='prettyPhoto']").prettyPhoto({
	    show_title: false
    });

    $("#scroller").simplyScroll({
		autoMode: 'loop'
	});

	$(".mainbutton").css({top:ph,left:pw,margin:'-'+($('.mainbutton').height() / 2)+'px 0 0 -'+($('.mainbutton').width() / 2)+'px'});		
	$(".front_logo").css({top:ph,left:pw,margin:'-'+(($('.front_logo').height() / 2)+ 235)+'px 0 0 -'+($('.front_logo').width() / 2)+'px'});		
	$("#fpbut").css({top:ph,left:pw,margin:'-'+($('#fpbut').height() / 2)+'px 0 0 -'+(($('#fpbut').width() / 2)+ 235)+'px'});		
	$("#fpbuttons").css({top:ph,left:pw,margin:'-'+($('#fpbuttons').height() / 2)+'px 0 0 -'+($('#fpbuttons').width() / 2)+'px'});
	$("#fpbut2").css({top:ph,left:pw,margin:'-'+($('#fpbut2').height() / 2)+'px 0 0 '+(($('#fpbut2').width() / 2)+ 50)+'px'});		
	$("#flnl").css({top:ph,left:pw,margin:'160px 0px 0px -100px'});
	$("#flen").css({top:ph,left:pw,margin:'177px 0 0 -16px'});
	$("#flde").css({top:ph,left:pw,margin:'160px 0 0 68px'});
	$("#circle1").css({top:ph,left:pw,margin:'-'+($('#circle1').height() / 2)+'px 0 0 -'+($('#circle1').width() / 2)+'px'});
	$("#circle2").css({top:ph,left:pw,margin:'-'+($('#circle2').height() / 2)+'px 0 0 -'+($('#circle2').width() / 2)+'px'});
	$("#circle3").css({top:ph,left:pw,margin:'-'+($('#circle3').height() / 2)+'px 0 0 -'+($('#circle3').width() / 2)+'px'});
	
	setTimeout(function() { $('#ccl3').animate({height:'269px',width:'269px'}, 300) }, 400);
	setTimeout(function() { $('#ccl2').animate({height:'399px',width:'399px'}, 300) }, 200);
							$('#ccl1').animate({height:'535px',width:'535px'}, 300);
	setTimeout(function() {	$('#circle3').animate({'padding-top':'0px','padding-left':'0px'}, 300) }, 400); 
	setTimeout(function() { $('#circle2').animate({'padding-top':'0px','padding-left':'0px'}, 300) }, 200); 
	 						$('#circle1').animate({'padding-top':'0px','padding-left':'0px'}, 300);
	
	setTimeout(function() {
		$('#fpbuttons').animate({'padding-top':'0px','padding-left':'0px'}, 1000)
		$('#img2').animate({height:'250px',width:'250px'}, 1000)
	}, 700);
	
	setTimeout(function() {
		$('.front_logo').fadeIn()
		
		$('#img1').animate({height:'185px',width:'185px'}, 1000)
		$('#fpbut').animate({'padding-top':'0px','padding-left':'0px'}, 1000)
		
		$('#img3').animate({height:'185px',width:'185px'}, 1000)
		$('#fpbut2').animate({'padding-top':'0px','padding-left':'0px'}, 1000)
	}, 1000);
	
	var animatehome	= function() {
		
		$(".mainbutton").css({display:'none'})
		$("#circle1").fadeOut()
		$("#circle2").fadeOut()
		$("#circle3").fadeOut()
		$('.front_logo').fadeOut()
		$("#flnl").fadeOut()
		$("#flen").fadeOut()
		$("#flde").fadeOut()
		
		$("#fpbut").animate( {
			"top": "+=150px"
		}, 1000)
				
		$("#fpbuttons").animate( {
			"top": "-=0px"
		}, 200).animate( {
			"left": "-=235px"
		}, 800)
		
		$("#fpbut2").animate( {
			"top": "-=150px"
		}, 200).animate( {
			"left": "-=470px"
		}, 800)
		
		setTimeout(function() { $(".front-title").fadeIn() }, 1000)
	}
	
	$(".mainbutton").click(animatehome);
	$(window).hashchange(function(){
		if(location.hash=="#start"){
			setTimeout(animatehome,1700);
		}
	});
	$(window).hashchange();
		
});

