$(document).ready(function() {
  
	$('.verticalAlign').vAlign();

	$('.tastyUl .right').hover(function() {
		$(".navNext").animate({ paddingLeft: '45px' }, 100, "linear", "callback"); 
	}, function() {
		$(".navNext").animate({ paddingLeft: '40px' }, 100, "linear", "callback");
  });
  
	$('.tastyUl .left').hover(function() {
		$(".navPrevious").animate({ paddingLeft: '35px' }, 100, "linear", "callback");
	}, function() {
		$(".navPrevious").animate({ paddingLeft: '40px' }, 100, "linear", "callback");
	});
  
	$(".tastyUl .right a").click(function(){
		var margin = $('#innerHold').css('margin-left').replace(/px/g,'');
		margin = parseInt(margin) - 1500;
		if(margin < -7500) margin = 0;
		$("#innerHold").animate({ marginLeft: margin }, 1000, "easeInOutCubic");
		return false;
	});  

	$(".tastyUl .left a").click(function(){
		var margin = $('#innerHold').css('margin-left').replace(/px/g,'');;
		margin = parseInt(margin) + 1500;
		$("#innerHold").animate({ marginLeft: margin }, 1000, "easeInOutCubic");
		return false;
	});  
	
	//Deep Links - Home Position
	
		$(".tastyUl .contentHead a").click(function(){
		var margin = $('#innerHold').css('margin-left').replace(/px/g,'');
		margin = 0;
		$("#innerHold").animate({ marginLeft: margin }, 1000, "easeInOutCubic");
		return false;
	});  
	
	
	//Deep Links - One
	
		$(".tastyUl .contentFoot .footNutshell a").click(function(){
		var margin = $('#innerHold').css('margin-left').replace(/px/g,'');;
		margin = -1500;
		$("#innerHold").animate({ marginLeft: margin }, 1000, "easeInOutCubic");
		return false;
	});  
	
			$(".tastyUl .contentFoot .footAwards a").click(function(){
		var margin = $('#innerHold').css('margin-left').replace(/px/g,'');;
		margin = -3000;
		$("#innerHold").animate({ marginLeft: margin }, 1000, "easeInOutCubic");
		return false;
	});  
	
			$(".tastyUl .contentFoot .footClients a").click(function(){
		var margin = $('#innerHold').css('margin-left').replace(/px/g,'');;
		margin = -4500;
		$("#innerHold").animate({ marginLeft: margin }, 1000, "easeInOutCubic");
		return false;
	});  
	
			$(".tastyUl .contentFoot .footOnline a").click(function(){
		var margin = $('#innerHold').css('margin-left').replace(/px/g,'');;
		margin = -6000;
		$("#innerHold").animate({ marginLeft: margin }, 1000, "easeInOutCubic");
		return false;
	});  
	
			$(".tastyUl .contentFoot .footContact a").click(function(){
		var margin = $('#innerHold').css('margin-left').replace(/px/g,'');;
		margin = -7500;
		$("#innerHold").animate({ marginLeft: margin }, 1000, "easeInOutCubic");
		return false;
	});    
	
  
	//$(".thumbnailbg").fadeTo("fast", 0.0);
  
	$('.streamForward').hover(function() {
		$(".streamForward img").animate({ paddingTop: '5px' }, 100, "linear", "callback");
	}, function() {
		$(".streamForward img").animate({ paddingTop: '0px' }, 100, "linear", "callback");
  });

	$('.streamBack').hover(function() {
		$(".streamBack img").animate({top: '-5px' }, 100, "linear", "callback");
	}, function() {
		$(".streamBack img").animate({top: '0px' }, 100, "linear", "callback");
	});

	// links
	$('.linkNav a').click(function() {
		$('.linkNav a').removeClass('active');
		$(this).addClass('active');
		$('.links').hide();
		$('#'+$(this).text()).show();
	});
	
	var loading = false;
	$('#streamNewer, #streamOlder').click(function() {
		var el = $('#streamOfLife');

		if(el.queue('fx').length > 0 || loading)
			return false;
		
		var itemCount = 6;
		var mT  = parseInt(el.css('marginTop'));
		var liC = $('#streamOfLife li').length;
		var liH = liC * $('#streamOfLife li:last').outerHeight(true);
		var ulH = 438;
		
		if(this.id == 'streamOlder') {
			mT = mT - ulH;
			if(liH + mT == ulH) { // if it'll be the last ones, get some more
				loading = true;
				$.post('/ajax/', { action: 'stream', offset: liC, count: itemCount }, function(html) {
					$('#streamOfLife').append(html);
					$('a.thickbox').unbind('click');
					tb_init('a.thickbox');
					loading = false;
				});
			}
		} else {
			mT = mT + ulH;
		}
		
		if(mT <= 0 && mT + liH > 0)
			el.animate({ marginTop: mT + 'px' }, 1000, 'easeInOutCubic');
			
		return false;
	});

});

    var flickrURL = "flickr.com";
    function outLinks() {
    var outLink;
    if (document.getElementsByTagName('a')) {
    for (var i = 0; (outLink = document.getElementsByTagName('a')[i]); i++) {
    if (outLink.href.indexOf(flickrURL) > 0) {
    outLink.setAttribute('target', '_blank');}}}};

(function ($) {
// VERTICALLY ALIGN FUNCTION
$.fn.vAlign = function() {
	return this.each(function(i){
		var ah = $(this).height();
		var ph = 642;
		var mh = (ph - ah) / 2;
		$(this).css('margin-top', mh);
	});
};
})(jQuery);



