var $facehackswitch = 0


$('#facehack').live('mouseenter', function(){
var $newdiv1 = $('<div id="face"><iframe src="http://www.facebook.com/plugins/like.php?app_id=173145829425446&amp;href=http%3A%2F%2Fpeterthomasryan.com%2F&amp;send=false&amp;layout=standard&amp;width=1&amp;show_faces=false&amp;action=recommend&amp;colorscheme=light&amp;font=arial&amp;height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:95px; height:30px;overflow:visible;" allowTransparency="true"></iframe></div>');

if ($facehackswitch == 0) {
$('div#facelink').empty().append($newdiv1);
$facehackswitch = 1;
}




});




$('#facehack').live('mouseleave', function(){
var $newdiv2 = $('<div id="facelink"><a href="">Like on Facebook</a></div>');

if ($facehackswitch == 1) {
$('div#facelink').empty().append($newdiv2);
$facehackswitch = 0;
}


});







	$.getJSON("http://twitter.com/statuses/user_timeline.json?screen_name=petexryan&count=5&callback=?",


 		function(data){


			$.each(data, function(i,item){


				ct = item.text;


				ct = ct.replace(/http:\/\/\S+/g,  '<a href="$&" target="_blank">$&</a>');


			    ct = ct.replace(/\s(@)(\w+)/g,    ' @<a href="http://twitter.com/$2" target="_blank">$2</a>');


			    ct = ct.replace(/\s(#)(\w+)/g,    ' #<a href="http://search.twitter.com/search?q=%23$2" target="_blank">$2</a>');


				$("#jstweets").append('<span style="display:inline">'+ct +"</span>   ");



 			});

$("#jstweets").cmtextconstrain({
    event: 'click', // for future extensibility to allow other events
    onExpose: function(){}, // a function to be run once the element is exposed
    onConstrain: function(){}, // a function to be run once the element is constrained
    restrict: {type: 'chars', limit: 97}, // type can be 'words' or 'chars'
    showControl: {string: '', title: '', addclass: ''}, // element shown to expose
    hideControl: {string: '', title: '', addclass: ''}, // element shown to constrain
    trailingString: '...' // string to show at end of truncated text
    });

		});

      
	 			

	$(document).ready(function(){

$("#archivebutton").rotate({ 
   bind: 
     { 'mouseenter': function(){$(this).rotate({ angle:0,animateTo:180,easing: $.easing.easeInOutExpo }); }} 
});





/*
	var $scrollingNav = $('#topnav');
 	var $scrollingNav2 = $('#topline');
	
	$('#scrollContainer').scroll(function(){	
$scrollingNav2.stop().css({left: ($('#scrollContainer').scrollLeft())}, 1);
$scrollingNav.stop().animate({left: ($('#scrollContainer').scrollLeft())}, 'slow' );
});





		*/
		
		
var test = $('#scrollContainer').scrollLeft();
$('#next').html(test)

$("div.picture").hover(function() {
$(this).find('.captioning').animate({"opacity": "1"}, 500);
},function() {
$(this).find('.captioning').animate({"opacity": "0"}, 700);

});



 
 
 
 
          
                  var s = $('.picture_holder:not(:first)');

          var curr=-1, node;

$('#next').live('click', function(){	
node = s[++curr];
                  if (node) {
                    $('#scrollContainer').scrollTo( node,300, {axis:'x',easing:'linear',offset: {left:-100}});
                  }
                  else {
                    curr = s.length-1;
                  }
});

          $(document).keydown(function(e){
        
             switch( e.keyCode ) {
               case 39:  //right
                  node = s[++curr];
                  if (node) {
                    $('#scrollContainer').scrollTo( node,300, {axis:'x',easing:'linear', offset: {left:-100}});
                  }
                  else {
                    curr = s.length-1;
                  }
                  break;
                case 37: // left
                   node = s[--curr] ;
                   if (node) {
                      $('#scrollContainer').scrollTo( node ,300, {axis:'x',easing:'linear',  offset: {left:-100}});
                      s = $('.picture_holder');
                   }
                   else {
                      curr = 0;
                    }
                   break;
                }
          });
          
          
          

});
