// plugin definition
jQuery.fn.vertical = function(options) {
	// Extend our default options with those provided.
	// Note that the first arg to extend is an empty object -
	// this is to keep from overriding our "defaults" object.
	var opts = jQuery.extend({}, jQuery.fn.vertical.defaults, options);
	jQuery(this).each(function() {
		var classname = $(this).attr("class").split(' ').slice(-1);
		$(this).addClass("active");
		if(classname != 'active') {
			var string = jQuery(this).text().split("");
			var target = this;
			jQuery(this).text("");
			jQuery.each(string, function() {
				$(target).append("<span style='position: relative;' class='letter'>"+this+"</span>");
			});
			var offSet = opts.top;
			jQuery(target).children("span[class=letter]").each(function() {
				var pos = jQuery(this).position();
				if(pos.left > opts.left) {
					var newLeft = parseInt("-"+Math.abs(pos.left -opts.left));
				} else if (pos.left < opts.left) {
					var newLeft = parseInt(Math.abs(pos.left -opts.left));
				} else {
					var newLeft = pos.left;
				}
				jQuery(this).animate({left : newLeft+"px", top : offSet+"px"}, opts.duration);
				offSet += opts.spacing;
			});
		}
	});
	return this;
};
// plugin defaults - added as a property on our plugin function
jQuery.fn.vertical.defaults = {
	left: 0,
	top: 0,
	spacing: 13,
	duration: 5000
};
