$(document).ready(function()
{
	var loc = window.location;
	
		// Change Content 
	if( loc == "http://christopherhein.com/#/TheBook" ) { window.location = "http://christopherhein.com/TheBook"; }
	if( loc == "http://christopherhein.com/#/TheWord" ) { window.location = "http://christopherhein.com/TheWord"; }
	if( loc == "http://christopherhein.com/#/TheSkills" ) { window.location = "http://christopherhein.com/TheSkills"; }
	if( loc == "http://christopherhein.com/#/MeetMe" ) { window.location = "http://christopherhein.com/MeetMe"; }
	
		// Variables
	var current = -575;
	var cRadius = "7px";
	$('#AjaxLoad').fadeOut();
	$('#AddEntry').slideUp();
	
	$('.projectsboxes').fadeOut();
	$('h1.title').click(function()
	{
		$('.projectsboxes').fadeOut();
		$(this).next().next().fadeIn();
	});
	
	
		// Blend Settings
	$('#header .christopherhein a').blend();
	$('#header .prettythings a').blend();
	$('#header .mytalks a').blend();
	$('#header .whatido a').blend();
	$('#header .meetme a').blend();
	$('#social #linkedinicon a').blend();
	$('#social #facebookicon a').blend();
	$('#social #twittericon a').blend();
	
	
		// Subscribe Button Roll Over / Out
	$('#header .utilities .subscribe a').mouseover(function() { SubscribeSlideOut(); });
	$('#header .utilities .subscribe a').mouseout(function() { SubscribeSlideIn(); });
	$('#header .christopherhein a').click(function() { $('#content .slider').css('background-image','url(_assets/images/homepage/italltext.jpg)'); });
	$('#AddNewProject').click(function() { $('#AddEntry').slideToggle(); });
	//$('.projects a img').mouseover(function() { $(this).css('opacity', '1'); });
	//$('.projects a img').mouseout(function() { $(this).css('opacity', '.5'); });
	$('.editingcontent h1').click(function() { $(this).next('.projectsboxes').slideToggle(); });
			
		// Start Functions
	$('body#home').LoadPage();
	
	HideContent();
	$(this).delay(500, function() { loadPage(); } );
	
	
		// Functions that can be recalled
	function SubscribeSlideOut()
	{
		$('#subscribeicon').stop().animate( { backgroundPosition:"(0 40px)" }, { duration: 500 });
	}
	
	function SubscribeSlideIn()
	{
		$('#subscribeicon').stop().animate( { backgroundPosition:"(0 0)" }, { duration: 500 });
	}
	
	function HideContent()
	{
		$('#projects').css( 'display', 'none' );
		$('#twitter').css( 'display', 'none' );
		$('#augmented').css( 'display', 'none' );
		$('body#home .container #footer').fadeOut();
	}
	
	function loadPage()
	{
			// Home Page Fade In
		$('.fadingContent').fadeIn("slow");
		HideContent();
		$(this).hideLoader();
		
			// Set Content
		$(this).delay(100, function() { SlideSlider(); } );
		$(this).delay(100, function() { LoadPortfolio(); } );
	}
	
		// Homepage Slider Function
	function SlideSlider()
	{
		current += 125;
		$('#content .slider').stop().animate( { backgroundPosition:"(0 "+ current +"px)" }, { duration: 100 } );
		$(this).delay(1100, function() { SlideSlider(); } );
		
		if ( current == -450 ) { $('#content #idotext').css('background-image','url(_assets/images/homepage/webtxt.png)'); $('#content #idowords').css('background-image','url(_assets/images/homepage/idotxt.png)'); }
		if ( current == -325 ) { $('#content #idotext').css('background-image','url(_assets/images/homepage/videotxt.png)'); }
		if ( current == -200 ) { $('#content #idotext').css('background-image','url(_assets/images/homepage/phototxt.png)'); }
		if ( current == -75 ) { $('#content #idotext').css('background-image','url(_assets/images/homepage/interactivetxt.png)'); }
		if ( current == 50 ) { $('#content #idotext').css('background-image','url(_assets/images/homepage/motiontxt.png)'); }
		if ( current == 175 ) { $('#content #idotext').css('background-image','url(_assets/images/homepage/audiotxt.png)'); }
		if ( current == 300 ) { $('#content #idotext').css('background-image','url(_assets/images/homepage/printtxt.png)'); }
		if ( current == 425 ) { $('#content #idotext').css('background-image','url(_assets/images/homepage/allofittxt.png)').delay( 1200, function()
																															{
																																//$('#content #idotext').fadeOut("slow"); 
																															}).delay(1750, function()
																															{
																																$('#projects').fadeIn("slow");
																															}).delay(2250, function()
																															{
																																$('#twitter').fadeIn("slow");
																															}).delay(2750, function()
																															{
																																$('#augmented').fadeIn("slow");
																															}).delay(3225, function()
																															{
																																$('body#home .container #footer').fadeIn("slow");
																															}); }
		
			// Reset Current
		if( current > 900 )
		{
			$('#content .slider').stop();
		}
	}
	
	function StartPages()
	{
		$(this).delay(500, function() { SlideSlider(); } );
		$(this).delay(200, function() { LoadPortfolio(); } );
	}

	function LoadPortfolio()
	{
		$('.projectwrap').jomino( 
		{ 
        	interval: 100, 
        	duration: 200, 
        	easing: "easeInOutQuad", 
        	autostart: true,
        	onComplete: function() {  }
        });
        
        $('.projects').fadeIn();
        $('.projects a').fadeIn();
        $('.projects a img').fadeIn('opacity', '.5');
        //$('.projects a img').css('opacity', '.5');
        $('.projecttext').fadeIn();
        $('.projecttext span').fadeIn();
	}
	
		// Pull In the Tweeter posts
	 $(".tweet").tweet(
	 {
          join_text: "auto",
          username: "christopherhein",
          avatar_size: 0,
          count: 2,
          auto_join_text_default: "I said,", 
          auto_join_text_ed: "I",
          auto_join_text_ing: "I am",
          auto_join_text_reply: "I replied to",
          auto_join_text_url: "I was looking out",
          loading_text: "loading tweets..."
      });
    
    	// Ajax
   /* var hash = window.location.hash.substr(1);
    
	var href = $('#header div a').each(function()
	{
		var href = $(this).attr('href');
		if(hash==href.substr(0,href.length-3))
		{
			var toLoad = hash+'.html #content';
			$('#content').load(toLoad)
		}											
	});

	$('#header div a').click(function()
	{
		var toLoad = $(this).attr('href')+' #content';
		$('#content .slider').hide();
		$('#content').hide('slow', loadContent);
		$('#AjaxLoad').remove();
		$('#loading').append('<div id="AjaxLoad"></div>');
		$('#load').fadeIn('normal');
		window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-0);
		
		function loadContent()
		{
			$('#content').load( toLoad, '', showNewContent() );
			StartPages();
		}
		
		function showNewContent()
		{
			$('#content').show('normal',hideLoader());
		}
		
		function hideLoader()
		{
			$('#AjaxLoad').fadeOut('normal');
		}
		
		return false;
	});*/
      
});