// basic jQuery extensions
$.extend($,
{
	// for debugging purposes - caution - writes to global space
	log : function()
	{
		window.log = function(){
			try{
				console.log.apply(console,arguments);
			} catch(error)
			{
				// .. IE
			}
		};
		return window.log;
	}(),
	
	// get a timer, pass old timer for time since then
	time : function(t)
	{
		var d = (new Date()).getTime();
		return ( t? d-t  : d );
	},
	
	numPrefix : function(){
		Number.prototype.prefix = function(l){
			var s = this.toString();
			while (s.length<l) s = '0'+s;
			return s;
		}
		return true;
	}(),
	
	// Original Author: Rafael Lima (http://rafael.adm.br)
	cssBrowserSelect : (function()
	{
		var ua=navigator.userAgent.toLowerCase(),
			is=function(t){ return ua.indexOf(t) != -1; },
			h=document.getElementsByTagName('html')[0],
			b=( !(/opera|webtv/i.test(ua)) && /msie (\d)/.test(ua) )? ('ie ie'+RegExp.$1):
				is('gecko/')? 'gecko':
					is('opera/9')? 'opera opera9':
						/opera (\d)/.test(ua)? 'opera opera'+RegExp.$1:
							is('konqueror')? 'konqueror':
								is('applewebkit/')? 'webkit safari':
									is('mozilla/')? 'gecko':'',
			os=( is('x11')||is('linux') )? ' linux':
				is('mac')? ' mac':
					is('win')? ' win':
						'',
			c=b+os+' js';
		
		h.className += h.className?' '+c:c;
		
		return true;
	})()
});
