// GUTS.JS

$(window).load(function() {
			
			// Display correct anchor if there is a hash in the URL
			
    			anchor = unescape(self.document.location.hash.substring(3))
				
				if (anchor) {
        			$.scrollTo('#' + anchor);
					
					if (anchor && 
						anchor == 'sugino-blog' ||
						anchor == 'stlto' || 
						anchor == 'garston-motors' || 
						anchor == 'autobahr' || 
						anchor == '140-keystrokes' ||
						anchor == 'genuine-sound-team' ||
						anchor == 'tru-performance-nutrition' ||
						anchor == 'steven-brenner' ||
						anchor == 'html5') {
						$('#pd').show();
						$('#' + anchor).show();
						$('#pb-' + anchor).show();
						$.scrollTo('#' + anchor, {offset:-40});
					}
				}
			
			

            $('.wipe').click(function(e) {
                    var url = $(this).attr('href');
                    url = url.replace(/^#/, '#!/');
                    document.location.hash = url;
                    return false;
                });
				
			// For project hashes. Sets the URL hash to the REL of the respective link.	
			 $('.turnOnDetails').click(function(e) {
                    var url = $(this).attr('rel');
                    url = url.replace(/^#/, '');
                    document.location.hash = '#!/' + url;
                    return false;
                });
				
			// For project hashes. Sets the URL hash to the REL of the respective link.	
			 $('.returnToPortfolio').click(function(e) {
                    var url = $(this).attr('href');
                    url = url.replace(/^#/, '#!/');
                    document.location.hash = url;
                    return false;
                });
				
	
				
				// Change the document title to the correct one
				
				/* 
			if(document.location.hash != "") {
				var title = document.location.hash;
				title = title.replace(/^.*#/, '');
				var str = title;
				
				str = str.toLowerCase().replace(/\b[a-z]/g, convert);
					function convert() {
						  return arguments[0].toUpperCase();
					}
				
				document.title = str + ' | Spencer Crone, Web Designer and Developer';
			} else {
				document.title = 'Welcome | Spencer Crone, Web Designer and Developer';
			} */
			
			document.onkeyup = KeyCheck;       
 
	function KeyCheck(e)
		{
		   var KeyID = (window.event) ? event.keyCode : e.keyCode;
 
		   switch(KeyID)
		   {
 
		      case 37: // left arrow
		      window.location = "#!/portfolio";
			  $.scrollTo('#portfolio', 1000);
			  $('#pb-sugino-blog').fadeOut(1200);
			  $('#pb-stlto').fadeOut(1200);
			  $('#pb-garston-motors').fadeOut(1200);
			  $('#pb-140-keystrokes').fadeOut(1200);
				$('#pb-genuine-sound-team').fadeOut(1200);
				$('#pb-autobahr').fadeOut(1200);
				$('#pb-tru-performance-nutrition').fadeOut(1200);
				$('#pb-steven-brenner').fadeOut(1200);
				$('#pb-html5').fadeOut(1200);
				$('#pd').fadeOut(1000);
				$('#sugino-blog').fadeOut(1000);
				$('#stlto').fadeOut(1000);
				$('#garston-motors').fadeOut(1000);
				$('#140-keystrokes').fadeOut(1000);
				$('#genuine-sound-team').fadeOut(1000);
				$('#autobahr').fadeOut(1000);
				$('#tru-performance-nutrition').fadeOut(1000);
				$('#steven-brenner').fadeOut(1000);
				$('#html5').fadeOut(1000);
		      break;
 
		      case 38: // up arrow
		      window.location = "#!/portfolio";
			  $.scrollTo('#portfolio', 1000);
			  $('#pb-sugino-blog').fadeOut(1200);
			  $('#pb-stlto').fadeOut(1200);
			  $('#pb-garston-motors').fadeOut(1200);
			  $('#pb-140-keystrokes').fadeOut(1200);
        $('#pb-genuine-sound-team').fadeOut(1200);
        $('#pb-autobahr').fadeOut(1200);
        $('#pb-tru-performance-nutrition').fadeOut(1200);
        $('#pb-steven-brenner').fadeOut(1200);
        $('#pb-html5').fadeOut(1200);
        $('#pd').fadeOut(1000);
        $('#sugino-blog').fadeOut(1000);
		$('#stlto').fadeOut(1000);
		$('#garston-motors').fadeOut(1000);
        $('#140-keystrokes').fadeOut(1000);
        $('#genuine-sound-team').fadeOut(1000);
        $('#autobahr').fadeOut(1000);
        $('#tru-performance-nutrition').fadeOut(1000);
        $('#steven-brenner').fadeOut(1000);
        $('#html5').fadeOut(1000);
		      break;
 
		      case 39: // right arrow
		      window.location = "#!/connect";
			  $.scrollTo('#connect', 1000);
		      break;
 
		      case 40: // down arrow
		      window.location = "#!/welcome";
			  $.scrollTo('#welcome', 1000);
		      break;
		   }
		}
				
        });
		 

