	$(document).ready(function() { 
		$("#wrap #content").addClass("loading");
		
		$(window).resize(function() {
			checkPos();
		});			
		
		$(window).bind("load", function() {
			$("#loading").fadeOut("slow");	
		});		
		
	});
	
	$(window).load(function() { 	
		
		$("#wrap #content").removeClass("loading");
		
		$("#navigation-alpha a, #navigation-beta #selectedworks a, #navigation-beta #selectedworks-list a,#navigation-gamma a").click(function(event){
			event.preventDefault();
			linkLocation = this.href;
			$("#footer,#wrap").fadeOut(1000, redirectPage);
		});

		function redirectPage() {
			window.location = linkLocation;
		}		
			
		$("#clients-inner img").eachDelay(function(){ $(this).fadeIn("slow"); }, 150);
		
		$(".post,.project,.work").eachDelay(function(){ $(this).fadeIn("slow"); }, 400);
		
		$("#tweets").getTwitter({
			userName: "aistrope",
			numTweets: 10,
			loaderText: "Loading tweets...",
			slideIn: true,
			slideDuration: 750,
			showHeading: false,
			headingText: "Latest Tweets",
			showProfileLink: false,
			showTimestamp: true
		});			
		
		var corouselStart = 0;
		
		if(window.location.hash) {
		   var urlHash = window.location.hash.substring(1);
		   	corouselStart = urlHash - 1;
		}	
/*
		$(".jCarouselLite").jCarouselLite({
			btnNext: "#selectedworks-controls #down",
			btnPrev: "#selectedworks-controls #up",
			vertical: true,
			scroll: 2,
			visible: 8,
			speed: 1,
			//start: corouselStart,
			//beforeStart: carouselFadeOut,
			//afterEnd: carouselFadeIn
			circular: true
		});		
	*/	
		$("#footer,#about,#contact,#subscribe").fadeIn("slow");		
		
		checkPos();
		
		if($.browser.msie && $.browser.version=="6.0") {
			$("#navigation").hide();
			$("#logo").hide();
			$("h1").hide();
			$("#wrap").hide();
			$("#footer").hide();
		}

		
	});
		
	function carouselFadeOut() {
		$("#selectedworks-list ul li a").hide();
	}
	
	function carouselFadeIn() {
		$("#selectedworks-list ul li a").fadeIn("slow");
	}	
	
	function checkPos() {
		var windowWidth = $(window).width();

		if (windowWidth <= 900) {
			$('#logo').css('left',750);
			$('#logo').css('bottom',0);
		}
		
		if  (windowWidth > 900) {
			$("#logo").removeAttr("style")
		}	
		
	}

	(function(){
	  // if firefox 3.5+, hide content till load (or 3 seconds) to prevent FOUT
	  var d = document, e = d.documentElement, s = d.createElement('style');
	  if (e.style.MozTransform === ''){ // gecko 1.9.1 inference
		s.textContent = 'body{visibility:hidden}';
		e.firstChild.appendChild(s);
		function f(){ s.parentNode && s.parentNode.removeChild(s); }
		addEventListener('load',f,false);
		setTimeout(f,3000);
	  }
	})();
