window.log=function(){log.history=log.history||[];log.history.push(arguments);if(this.console){arguments.callee=arguments.callee.caller;var a=[].slice.call(arguments);(typeof console.log==="object"?log.apply.call(console.log,console,a):console.log.apply(console,a))}};
(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,timeStamp,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();){b[a]=b[a]||c}})((function(){try
{console.log();return window.console;}catch(err){return window.console={};}})());

(function($){
	
	$.fn.Spanify = function(settings) {
		
		var config = {};
		if (settings) $.extend(config, settings);
  	
		this.each(function() {           
      
			var $self = $(this);

			init_Spanify();
				
			function init_Spanify() {
				init_draw();
			}
			
			function init_draw() {
				
				var h2 = $self.find('h2');
				
				$(h2).each(function () {
					
					/*
					 * Find all words, spaces and html tags and use in an array
					*/
					var pattern = /(?:(?:<\/?\w+[^>]*>)|(([0-9A-Za-z\;\'\,\-\—\–\.\&\"\!]+)))?/g;
					
					var html = $(this).html();
					var matches =  html.match(pattern);
					var str = '';
					
					$(matches).each(function (i) {
						var m = matches[i];
						if (m[0] != '<' && m[1] != '<') {
							if (m == '') {
								str+= '<span class="spanify-space">&nbsp;</span>';
							} else {
								str+= '<span>' + m + '</span>';
							}
						} else {
							str+= m;
						}
						
					});
					
					$(this).replaceWith(str);
				});
			}
			  
		}); 
      
		return this;
	} // Spanify End ------------------------------------------------------------------------------------------------------

})(jQuery);



