$(document).ready(function() {
    // TICKER TWITTER, Thanks to Antoni Lupetti @ Woork.blogspot.com
	var first = 0;
	var speed = 2500;
	var pause = 3000;
	
		function removeFirst(){
			first = $('ul#twitter_update_list li:first').html();
			$('ul#twitter_update_list li:first')
			.animate({opacity: 0}, speed)
			.fadeOut('slow', function() {$(this).remove();});
			addLast(first);
		}
		
		function addLast(first){
			last = '<li style="display:none">'+first+'</li>';
			$('ul#twitter_update_list').append(last)
			$('ul#twitter_update_list li:last')
			.animate({opacity: 1}, speed)
			.fadeIn('slow')
		}
	
	interval = setInterval(removeFirst, pause);
	// TICKER TWITTER END  
	
	// PORTFOLIO NAV
	$('#viewall').click(function() {
		$('#portfolio ul').css("height","auto");
		$('#viewless').css("display","block");
		$('#viewall').css("display","none");
	});
	$('#viewless').click(function() {
		$('#portfolio ul').css("height","500px");
		$('#viewless').css("display","none");
		$('#viewall').css("display","block");
		$('html, body').animate({ scrollTop: 0 }, 'slow');
	});	
	// PORTFOLIO NAV END
	
	// PORTFOLIO ITEMS START
	$("#portfolio img").fadeTo("fast", 0.7); // This sets the opacity of the thumbs to fade down to 60% when the page loads

	$("#portfolio img").hover(function(){
		$(this).fadeTo("fast", 1.0); // This should set the opacity to 100% on hover
	},function(){
		$(this).fadeTo("fast", 0.7); // This should set the opacity back to 60% on mouseout
	});
	// PORTFOLIO ITEMS END
  
});

$(function() {
	var $sidebar = $("#viewless"),
	$window = $(window),
	offset = $sidebar.offset(),
	topPadding = 5;
	$window.scroll(function() {
	
	if ($window.scrollTop() > offset.top) {
		$sidebar.stop().animate({
		marginTop: $window.scrollTop() - offset.top + topPadding
	});
		} else {
			$sidebar.stop().animate({
			marginTop: 0
		});
	}
	});
});
