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={};}})());

jQuery.fn.textfill = function(options) {
	var defaults = {
		maxFontPixels: 70,
		innerTag: 'h1',
		lineHeight: 85
	};
	var Opts = jQuery.extend(defaults, options);
	return this.each(function() {
		var fontSize = Opts.maxFontPixels;
		var ourText = $(Opts.innerTag + ':visible:first', this);
		var maxHeight = $(this).height();
		var maxWidth = $(this).width();
		var textHeight;
		var textWidth;
		do {
			ourText.css('font-size', fontSize);
			textHeight = ourText.height();
			textWidth = ourText.width();
			fontSize = fontSize - 1;
		} while ((textHeight > maxHeight || textWidth > maxWidth) && fontSize > 3);
		$(Opts.innerTag, this).css({"line-height": defaults.lineHeight + "px"});
	});

};


// Character Counter
(function($){ 
 $.fn.extend({  
	 limit: function(limit,element,format) {
		
		var interval, f;
		var self = $(this);
		var substringFunction;		
		
		$(this).focus(function(){
			interval = window.setInterval(substring,100);
		});
		
		$(this).blur(function(){
			clearInterval(interval);
			substring();
		});
		
		switch (format)
		{
		case 'char':
		substringFunction = "function substring(){ var val = $(self).val();var length = val.length;if(length > limit){$(self).val($(self).val().substring(0,limit));}";
		if(typeof element != 'undefined')
			substringFunction += "if($(element).html() != limit-length){$(element).html((limit-length<=0)?'0':limit-length);}"
		break;
		case 'words':
		substringFunction = "function substring(){ var val = $(self).val(); var length = val.split(' ').length; if(length > limit) { $(self).val(val.slice(0,-1));}";
		if(typeof element != 'undefined')
			substringFunction += "if($(element).html() != limit-length){$(element).html((limit-length<=0)?'0':limit-length+1);}"
		break;
		case 'keywords':
		substringFunction = "function substring(){ var val = $(self).val();var length = val.split(',').length;if(length > limit){$(self).val(val.slice(0,-1));}";
		if(typeof element != 'undefined')
			substringFunction += "if($(element).html() != limit-length){$(element).html((limit-length<=0)?'0':limit-length+1);}"
		break;
		}
		substringFunction += "}";
		
		eval(substringFunction);
	
		substring();
	} 
}); 
})(jQuery);
