var currentSmallPhoneNav = 0;
var twitter = false;
var footerPosition = 0;

$(function(){
  $('.homePhoneOverlay').show().css('opacity','0');
	$('.homePhone').mouseenter(function(){
	  $(this).find('.homePhoneOverlay').stop().animate({opacity:1},250);
	}).mouseleave(function(){
	  $(this).find('.homePhoneOverlay').stop().animate({opacity:0},250);
	});
  $('.smallPhoneFull').show().css('opacity','0');
  $('#smallPhoneNav' + currentSmallPhoneNav + ' .smallPhoneFull').css('opacity','1');
	$('#smallPhoneNav a').mouseenter(function(){
	  $('.smallPhoneFull').stop().animate({opacity:0},300);
	  $(this).find('.smallPhoneFull').stop().animate({opacity:1},300);
	});
	$('#smallPhoneNav').mouseleave(function(){
	  $('.smallPhoneFull').stop().animate({opacity:0},300);
	  $('#smallPhoneNav' + currentSmallPhoneNav + ' .smallPhoneFull').stop().animate({opacity:1},300);
	});
	
	if(twitter) {
	  goTwitterJSON();
    $('.twitter').click( function() {
		  window.location = 'http://twitter.com/tabbedout';
	  });
	}
	
	$('#footerMore').click(function(){
	  if($('#footerLogos img').length > (footerPosition + 1) * 8){
	    footerPosition++;
	    $('#footerLogos').animate({left:footerPosition * -946},500);
	  }
	});
	
	$('#footerPrev').click(function(){
	  if(footerPosition > 0){
	    footerPosition--;
	    $('#footerLogos').animate({left:footerPosition * -946},500);
	  }
	});
});

function goTwitterJSON(){
	var twitterURL = 'http://twitter.com/statuses/user_timeline/tabbedout.json?count=3&callback=?';
	$.getJSON(twitterURL,
		function(data){
			for( var i=0; i < data.length; i++) {
				$('.twitter ul').append('<li>' + data[i].text + '</li>');
			}	
			$('.twitter').fadeIn();
		}
	);
}
