// texteffect
// easytooltip

(function($) {               
    $.fn.typewriter = function(options,event) {
        if( typeof(options) != "object" ){
            event = options;
            options = {};
            step = 0;
        }
        var settings = {
            'duration'  : 1000   ,
            callback: null
        };
                
        this.each(function() {
            $.extend(settings,options);
            var $ele = $(this); 
            //console.log($ele);
            var str = $ele.text(); 
            var progress = 0;            
            var len = str.length;
            var step = (options.step)?options.step:Math.ceil(options.duration/len);
            $ele.text('');
            switch(event){        
                case 'finish':
                    $ele.text(str);
                    progress = len;
                break;
                default:
                    var timer = setInterval(function() {
                        progress = $ele.text().length +1 ;
                        $ele.text(str.substring(0, progress) + (progress & 1 ? '' : ''));
                        //console.log(" -"+progress+" "+len);
                        if (progress > len) {                            
                            clearInterval(timer);
                            //$ele.text($ele.text().replace(/\_/g,''));
                            if(options.callback){
                                options.callback.call();
                            }
                        }
                    }, step);
                break;
            }
        });                    
        return this;                
    };           
})(jQuery);
/*
 * 	Easy Tooltip 1.0 - jQuery plugin
 *	written by Alen Grakalic	
 *	http://cssglobe.com/post/4380/easy-tooltip--jquery-plugin
 *
 *	Copyright (c) 2009 Alen Grakalic (http://cssglobe.com)
 *	Dual licensed under the MIT (MIT-LICENSE.txt)
 *	and GPL (GPL-LICENSE.txt) licenses.
 *
 *	Built for jQuery library
 *	http://jquery.com
 *
 */
 
(function($) {

	$.fn.easyTooltip = function(options){
	  
		// default configuration properties
		var defaults = {	
			xOffset: 10,		
			yOffset: 25,
			tooltipId: "easyTooltip",
			clickRemove: false,
			content: "",
			useElement: ""
		}; 
			
		var options = $.extend(defaults, options);  
		var content;
				
		this.each(function() {  				
			var title = $(this).attr("title");				
			$(this).hover(function(e){											 							   
				content = (options.content != "") ? options.content : title;
				content = (options.useElement != "") ? $("#" + options.useElement).html() : content;
				$(this).attr("title","");									  				
				if (content != "" && content != undefined){			
					$("body").append("<div id='"+ options.tooltipId +"'>"+ content +"</div>");		
					$("#" + options.tooltipId)
						.css("position","absolute")
						.css("top",(e.pageY - options.yOffset) + "px")
						.css("left",(e.pageX + options.xOffset) + "px")						
						.css("display","none")
						.fadeIn("fast")
				}
			},
			function(){	
				$("#" + options.tooltipId).remove();
				$(this).attr("title",title);
			});	
			$(this).mousemove(function(e){
				$("#" + options.tooltipId)
					.css("top",(e.pageY - options.yOffset) + "px")
					.css("left",(e.pageX + options.xOffset) + "px")					
			});	
			if(options.clickRemove){
				$(this).mousedown(function(e){
					$("#" + options.tooltipId).remove();
					$(this).attr("title",title);
				});				
			}
		});
	  
	};

})(jQuery);
