/*
 * jQuery Timer Plugin
 * http://www.evanbot.com/article/jquery-timer-plugin/23
 *
 * @version      1.0
 * @copyright    2009 Evan Byrne (http://www.evanbot.com)
 
 EXAMPLE:
 
 $(document).ready(function(){

  // This will hold our timer
  var myTimer = {};

  // Wait for #start to be clicked...
  $("#start").click(function(){

    // Set the timer for 2 seconds
    myTimer = $.timer(2000,function(){

      // Display hello message when timer goes off
      alert('A Delayed Hello!');


    // Optional function to call when timer is canceled
    },function(){
	
      // Display new message when canceled
      alert('Hello Message Canceled!');
	
    });

  });


  // If #cancel is clicked cancel the timer
  $('#cancel').click(function(){

    $.clearTimer(myTimer);

  });

 */ 

jQuery.timer = function(time,func,callback){
	var a = {timer:setTimeout(func,time),callback:null}
	if(typeof(callback) == 'function'){a.callback = callback;}
	return a;
};

jQuery.clearTimer = function(a){
	clearTimeout(a.timer);
	if(typeof(a.callback) == 'function'){a.callback();};
	return this;
};