/**
 *  jQuery Tooltip Plugin
 *  @requires jQuery v1.2.6 or greater
 *  http://hernan.amiune.com/labs
 *
 *  Copyright (c)  Hernan Amiune (hernan.amiune.com)
 *  Licensed under MIT license:
 *  http://www.opensource.org/licenses/mit-license.php
 * 
 *  Version: 1.0
 */
 


	$(function(){
		$('#attractor1').eyesattractor({duration:3000, animationSteps:5, symbol:"Vote!", color:"#43b6df"});
    });	

(function($){ $.fn.eyesattractor = function(options){

    var defaults = {
		duration: 3000,    //duration of the animation
		animationSteps: 3, //steps of the animation
		symbol: "*",       //symbol to animate
		color: "#f00"      //color of the symbol
	};
  
    var options = $.extend(defaults, options);
	
	function endCallback(){}
	
	return this.each(function(index) {
		
		var $this = $(this);
		
		var bodyW = $("body").width() - 50;
		var bodyH = $("body").height() - 50;
		var pos = $this.position();
		var stepLength = options.duration/options.animationSteps;
		
		var $eyesattractor = $('<div>'+options.symbol+'</div>');
		$eyesattractor.css("position","absolute").css("font-size","20px").css("z-order","100");
		$eyesattractor.css("top","0px").css("left","0px").css("color",options.color);
		$('body').append($eyesattractor);
		
		for(var i=0; i<options.animationSteps-1; i++){
		    var newx = Math.floor(Math.random()*bodyW);
			var newy = Math.floor(Math.random()*bodyH);
			var newSize = Math.floor(Math.random()*100+20);
			$eyesattractor.animate({ top: newy+"px",left: newx+"px",fontSize: newSize+"px"}, stepLength);
		}
		
		$eyesattractor.animate({ top: pos.top+"px",left: pos.left+"px",fontSize: "15px"}, stepLength, 
			function(){
				$this.css("color",options.color);
				$eyesattractor.hide();
			}
		);
		

	});

}})(jQuery);
