// official hashtag
var hashTag = '#nextwebdev ';

$(document).ready(function() {
	
   $('textarea').focus().attr('value', hashTag).keyup(function() {
	  
	  var len = this.value.length;
	  
	  // process maximym limit
      if (len >= 140) {
		  this.value = this.value.substring(0, 140);
	  }
	  
	  // process minimum limit
	  if (len < hashTag.length) {
		  this.value = hashTag;
		  len = hashTag.length;
	  }

	  // update characters counter
	  leftChars = 140 - len;
	  if (leftChars < 0) {
		leftChars = 0;
	  }
	  $('#description span').text(leftChars);

   });
  
  $('#submit-it').click(function() {
	  
	  $('#share-vision').hide();
	  $('#go-social').show();
	  
	  var textElem = $('textarea');
	  window.open('http://twitter.com/?status=' + encodeURIComponent( textElem.attr('value') ));
	  	  
	  return false;
  });
  
});

