jQuery(function($){
	
		$.fn.randomtext = function(opts){
			var elms = this;
			var defaults = 
			{
				
				speed: 5000,
				json:"testimonials.js"
				
			}
			
			var opts = $.extend(defaults, opts);
			var testim_json = opts.json;
			var testims;
			
			$.getJSON(testim_json, function(data){
					var testimObj = eval(data.testims);
					var idx = 0;
				
			window.setInterval(changeTestims, opts.speed);
			
			elms.html('<p>'+testimObj[idx].testim + '<span>'+ testimObj[idx].byline +'</span></p>');
			
			function changeTestims(){
				elms.fadeOut(function(){
					elms.html('<p>'+testimObj[idx].testim + '<span>'+ testimObj[idx].byline +'</span></p>').fadeIn();
				});
				
				if (idx == testimObj.length - 1) {
					idx = 0;
				}else{
					idx++;
				}
			}
		});
			return elms;
	}
		
});
