
// usage: log('inside coolFunc', this, arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
  log.history = log.history || [];   // store logs to an array for reference
  log.history.push(arguments);
  arguments.callee = arguments.callee.caller;  
  if(this.console) console.log( Array.prototype.slice.call(arguments) );
};
// make it safe to use console.log always
(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();)b[a]=b[a]||c})(window.console=window.console||{});


// place any jQuery/helper plugins in here, instead of separate, slower script files.


// REVIEWS, TWITTER

(function($) {

	$.fn.cycleTwitter = function(options) {
		var defaults = {
			interval: 2000,
			transition_time: 500
		}
		var opts = $.extend(defaults, options);
		var obj = this;
		
		setInterval(function() {rot(obj, opts.transition_time);}, opts.interval);	
		
	}
	
	function rot(obj, transition_time) {
		var msg_height = parseInt(obj.find("li").css("height").replace("px", ""));
		var msg_count = obj.children("li").size();
		var cur_pos = obj.css("top").replace("px", "");
		var new_pos = cur_pos - msg_height;
		obj.animate({top: new_pos}, transition_time, function() {
			if (obj.css("top").replace("px", "") <= -(msg_height * (msg_count-1))) {
				new_pos = 0;
				var el = obj.children("li").last();
				obj.prepend(el);
				obj.css("top", new_pos);
			} 
		});	
	}
	
})(jQuery);



// TRASITION

(function($) {
	
	$.fn.rotate = function(options) {
		var defaults = {
			interval: 2000,
			transition_time: 1000
		}
		var opts = $.extend(defaults, options);
		
		var obj = this;
		var num_images = this.find("img").size();
		obj.cur_image = 0;
		
		this.children("img").not(":first").hide();
		
		if (num_images > 1) {
			setInterval(function() {rot(obj, opts.transition_time, num_images);}, opts.interval);
		}
		
	}		

	// private
	
	function rot(obj, transition_time, num_images) {
		obj.find("img").eq(obj.cur_image).fadeOut(transition_time);
		
		obj.cur_image++;
		if (obj.cur_image >= num_images) obj.cur_image = 0; 
		obj.find("img").eq(obj.cur_image).fadeIn(transition_time);
	}
	
})(jQuery);





