function NavSlider(){
	var NavHeight = $('#NavPanel ul').height();	
	var StartPoint = $('#MainNav').position().top;
	$('#SliderArrow').click(
		function(){
			if($('#SliderArrow').hasClass('Closed')){
				$('#MainNav').animate(
					{
						'height'	:	(NavHeight+120)+'px',
						'top'		:	'50px'
					}
					,750
				);
				$('#SliderArrow').animate(
					{						
						'top'		:	'0px'
					}
					,750
					,function(){
						$(this).removeClass('Closed');
					}
				);
			}
			else{
				$('#MainNav').animate(
					{
						'height'	:	'80px',
						'top'		:	StartPoint+'px'
					}
					,750
				);
				$('#SliderArrow').animate(
					{						
						'top'		:	'56px'
					}
					,750
					,function(){
						$(this).addClass('Closed');
					}
				);
			}
		}
	)
	$('#NavPanel li a').click(
		function(){
			if(Panning){
				Panning=false;
				clearTimeout(FadeTimeOut);
				/*
				$('#Backing1').stop().fadeOut(500,function(){
					$(this).css('left','0px').css('top','0px');
				});				
				$('#Backing2').stop().fadeOut(500,function(){
					$(this).css('left','0px').css('top','0px');
					$('#Backing2').html('<img src="/images/HomepageBackgrounds/blank.png"/>');
					$('#Backing1').html('');
					setTimeout(
						function(){
							LoadContent();
						}
						,100
					);
				});
				*/
				
				setTimeout(
					function(){
						LoadContent();
					}
					,10
				);
				
			}
			else{
				setTimeout(
					function(){
						LoadContent();
					}
					,100
				);
			}
		}
	)
}

function LoadContent(){
	var pathname = window.location.hash;
	pathname = pathname.replace('#','');
	$.ajax({
		method:	'GET',
		url: '/DATA/'+pathname,
		dataType: 'json',
		success: function(data) {							
			var Content = data.content;
			var Image = data.image;
			$('#ImageBuffer').html(Image);
			$('#PageContentPanel').fadeOut(
				500
				,function(){
					$(this).html(Content);
					$(this).fadeIn(500);
					DoFonts();
				}
			);
			$('#ImageBuffer').waitForImages(function() {
				SwitchBG(Image)
			});
		},
		error: function(){
			alert('Please wait...');
		}
	});
}

function SwitchBG(Image){
	$('#Backing1').html($('#Backing2').html());
	$('#Backing1').css('z-index',-1).css('width','100%').css('height','100%');
	$('#Backing2').css('z-index',-2).css('opacity',1).css('display','block');
	$('#Backing1').css('opacity',1).css('display','block');
	$('#Backing2').html(Image);
	if(FirstLoad){
		$('#Backing2 img').css('display','none');
	}
	setTimeout(function(){
		var Sizes=GetImgSize($('#Backing2 img').attr('src'));
		ImgWidth=Sizes.ImgWidth;
		ImgHeight=Sizes.ImgHeight;
		RatioX=ImgWidth/ImgHeight;
		RatioY=ImgHeight/ImgWidth;
		while (ImgWidth<ScreenWidth || ImgHeight<ScreenHeight){
			ImgWidth+=RatioX;
			ImgHeight+=RatioY;
		}
		ImgWidth=parseInt(ImgWidth);
		ImgHeight=parseInt(ImgHeight);				
		$('#Backing2 img').css('width',ImgWidth+'px');	
		$('#Backing2 img').css('height',ImgHeight+'px');
		if(FirstLoad){
			$('#Backing2 img').fadeIn(300);
			FirstLoad=false;
		}
		$('#Backing1').fadeOut(1500);
	}
	,100
	);
}

