	
$(window).load(function() {

	//DYNAMIC BACKGROUND
	resizeBackground();
	$(window).resize(resizeBackground);
	
    function resizeBackground() {
    	//set image variables
		imagewidth = $("img#background").width();
		imageheight = $("img#background").height();
   
		//set browser variables
		browserwidth = $(window).width();
		browserheight = $(window).height();
   		
   		//set background box to browser varaibles
		$("div#background-container").css({ width: browserwidth, height: browserheight});
   		
 		//Resize window
 		//Image height adopts browser width and muliply difference to height
		var new_imagewidth = browserwidth;
		var new_imageheight = browserheight;
		
		//for some reason it doesn't take variables at the moment
		var new_imageheight = (($(window).width()/ $("img#background").width()) * $("img#background").height());
   		$("img#background").css({ width: new_imagewidth, height: new_imageheight });
   		
   		//Resize image if image width is less than image height (height is taller)
  		
		if (new_imageheight < browserheight) {
			var new_imageheight = browserheight;
			var new_imagewidth = ((new_imageheight / imageheight) * imagewidth);

			$("img#background").css({ width: new_imagewidth, height: new_imageheight });
		}
		
		//BROWSER TEST
		var browserName = $.browser.name;
	
		if (browserName == "msie") {
			if(parseInt(jQuery.browser.version) == 6) {
				$(window).scroll(function() {
					var distance = $(document).scrollTop();
					$("div#background-container").css({ top: distance});
				});
			}
		}
				
    }										

	//DYNAMIC BACKGROUND
	setTimeout(function() {									
		$('#background').fadeIn(500);							
	}, 500);

		
	var navTag = $("body").attr('id');

	if( navTag == 'home'){
		$('#nav #index').addClass('active');		
	}
	if( navTag == 'work'){
		$('#nav #work').addClass('active');	
	}
	if( navTag == 'company'){
		$('#nav #company').addClass('active');	
	}
	if( navTag == 'careers'){
		$('#nav #careers').addClass('active');	
	}
	if( navTag == 'community'){
		$('#nav #community').addClass('active');	
	}
	if( navTag == 'fcv_iphone_app'){
		$('#nav #iphone').addClass('active');	
	}
	if( navTag == 'contact'){
		$('#nav #contact').addClass('active');	
	}
	
	//FCV TAB
	$("div#fcv_tab").bind("mouseover mouseout", function() {
		$(this).children("h3").toggleClass("over");
	});
	$("div#fcv_tab").bind("mousedown", function() {
		$(this).children("h3").remove();
	});
	
	$("div#fcv_tab").easydrag();
	
	//GRAB FIRST TWEET AND MOVE IT
	//$("ul#twitter_update_list li:first span").appendTo("div#twitter_single");
	//$("body#home ul#twitter_update_list li:first").remove();
	
	//measure number of characters
	var tweet_length = $("div#twitter_single span").text().length;
	if (tweet_length <= 66) {
		$("div#twitter_single span").css("fontSize","20px");
		$("div#twitter_single span").css("marginTop","3px");
	}
	if (tweet_length >= 73) {
		$("div#twitter_single span").css("fontSize","18px");
		$("div#twitter_single span").css("marginTop","5px");
	}
	if (tweet_length >= 81) {
		$("div#twitter_single span").css("fontSize","16px");
		$("div#twitter_single span").css("marginTop","5px");
	}
	if (tweet_length >= 91) {
		$("div#twitter_single span").css("fontSize","14px");
		$("div#twitter_single span").css("marginTop","7px");
	}
	if (tweet_length >= 104) {
		$("div#twitter_single span").css("fontSize","12px");
		$("div#twitter_single span").css("marginTop","8px");
	}
	if (tweet_length >= 120) {
		$("div#twitter_single span").css("fontSize","11px");
		$("div#twitter_single span").css("marginTop","9px");
	}
	if (tweet_length >= 131) {
		$("div#twitter_single span").css("fontSize","10px");
		$("div#twitter_single span").css("marginTop","11px");
	}
	if (tweet_length >= 147) {
		$("div#twitter_single span").css("fontSize","9px");
		$("div#twitter_single span").css("marginTop","11px");
	}
	
	//Limit tweets
	$("div.twitter div.tweet").each(function(e) {
		if (e<=3) {
			$(this).css("display","block");
		} else {
			$(this).css("display","none");
		}
	});
	
	//Make every link in feed open a blank window
	//$("div#feeds a").add("div.tweet a").attr("target","_blank");
	
	$("div#feeds div#tweet a").attr("target","_blank");

	//WORK
	$("div#company_list ul.clients li").each(function() {
		$(this).hover(
		function() {
			$(this).find("img").animate({opacity:"0.4"},500);
		},
		function() {
			$(this).find("img").animate({opacity:"1.0"},500);
		});
	});
	
});
