// code expander

$(document).ready(function(){$("pre").css({overflow:"hidden"});});

$(function(){
	$("pre").hover(function() {
		var codeInnerWidth = $("code", this).width() + 10;
		if (codeInnerWidth > 760) {
			$(this).stop(true, false).css({zIndex:"99",position:"relative",overflow:"hidden"}).animate({width:codeInnerWidth+"px"});
		}
	}, function() {
		$(this).stop(true, false).animate({width:760});
	});
});

$(document).ready(function() {
	$('.project-image').hover(function () {
	 $("img", this).stop().animate({top:"-25px"},{queue:false,duration:350});
		 }, function() {
     $("img", this).stop().animate({top:"0px"},{queue:false,duration:350});
	 
	});
});

// latest tweet

getTwitters('tweet', { 
  id: 'nathanstaines', 
  count: 1, 
  enableLinks: true, 
  ignoreReplies: true, 
  clearContents: true,
  template: '<span class="twitterStatus">"%text%"</span> <span class="twitterTime"><a href="http://twitter.com/%user_screen_name%/statuses/%id%/">%time%</a></span>'
});

// Image Fade Rollovers

$(document).ready(function() {
	$('.fadeThis').append('<span class="hover"></span>').each(function () {
	  var $span = $('> span.hover', this).css('opacity', 0);
	  $(this).hover(function () {
	    $span.stop().fadeTo(500, 1);
	  }, function () {
	    $span.stop().fadeTo(500, 0);
	  });
	});
});

// Inline Labels

$().ready(function(){

// Select all textboxes and assign them to an array
var textboxes = $('form.awesome input.input-text');

// Iterate through all textboxes in the form
textboxes.each(function(index, input){

var label = $(input).prev();

label.wrapInner("<span></span>")
label.children("span").animate({opacity: 0.9},0);

// check for autocomplete by browser
if( index == 0 ){
  setInterval(function(){
     textboxes.each(function(index,inputX){
      if ( inputX.value!="" ) {
        $(inputX).prev().children("span").animate({opacity: 0},0);
      }
    });
 }, 100);
}

// Fade the label back when a field gains focus     
input.onfocus = function(){
  if (input.value==""){
    label.children("span").animate({opacity: 0.4},200)     
  }
}

// Check if a field is empty when the user switches out
input.onblur = function(){
  if (input.value==""){
    label.children("span").animate({opacity: 0.9},200)        
  }
}

// Fade the label back if a field has text      
if (input.value!="") {
  label.addClass('hastext');
}

// Fade the label back when the user starts to type     
input.onkeypress = function(){
  label.children("span").animate({opacity: 0},200) 
};

});

});