jQuery.extend({
	scrollTo : function(selector, speed, easing) {
	  if (this.test(selector)) {
	      var targetOffset = $(selector).offset().top;
	      $('html,body').animate({scrollTop: targetOffset}, speed, easing);
	  }
    },

	/*
	  Function: attempt
	  Helper to execute a function and suppress errors.
	
		Parameters:
			- fn: function to bind
			- bind: context to bind the function to
			
		Returns:
			null
	*/
	attempt: function(fn, bind, args) {
		try {
			fn.apply(bind || null, jQuery.splat(args));
		}
		catch (e) {}
		return null;
	},
	
/*
	  Function: bind
	  Binds a function to a context.
		Does not execute the function.
	
		Parameters:
			- fn: function to bind
			- bind: context to bind the function to
			
		Returns:
			function
	*/
	bind: function(fn, bind) {
	  return jQuery.pass(fn, Array, bind);
	},

	/*
	  Function: camelize
	  Converts lowercase and underscored text to camelCase.
	*/
	camelize: function(str) {
		return str.replace(/_(\w)/g, function(all, letter){
			return letter.toUpperCase();
		});
	},
	
	/*
	  Function: ucfirst
	  Converts lowercase and underscored text to First Letter Capital.
	*/
	ucfirst: function(str) {
		if (str == undefined)
			return false;
		
		if (str.length==0)
			return false;
		
		return reg = str.replace(/(^\w)|(_\w)/g, function(i, all){
			return i.toUpperCase().replace('_', '');
		});
	},

/*
  Function: count
  Gets length of objects or arrays.
	*/
	count: function(obj) {
	  if (jQuery.type(obj) == 'object') {
	    var len = 0;
	    for (var i in obj)
	      len++;
	  }
	  else
	    len = (obj) ? obj.length : null;
	    
	  return len;
	},

/*
  Function: low
  Shortcut for toLowerCase.
	*/
	low: function(str) {
		return (jQuery.type(str) == 'string') ? str.toLowerCase() : str;
	},

/*
	  Function: now
	  Helper to get timestamp.
	
		Returns:
			date
	*/
	now: Date.now || function() {
		return +new Date;
	},
	
/*
	  Function: pass
	  Passes arguments to a function and creates a closure.
		Does not execute the function.
	
		Parameters:
			- fn: function
			- args: one or more arguments (as an array)
			- bind: optional context to bind
			
		Returns:
			function
	*/
	pass: function(fn, args, bind) {
		return function() {
			var returns = function() {
				return fn.apply(bind || null, jQuery.splat(args));
			};
			return returns();
		};
	},
	
/*
	  Function: random
	  Returns a random int between the min and max given.
	  If no min and max then returns boolean 1:2
	*/
	random: function(min, max) {
	  if (!min && !max)
	    return Math.round(Math.random());
	  
    return Math.floor(Math.random() * (max - min + 1) + min);
	},
	
/*
	  Function: slugize
	  Makes a string URL friendly.
	
		Parameters:
			- str: str to convert
			- replace: optional replacement string, default underscore
			
		Returns:
			str
	*/
	slugize: function(str, replacement) {
	  if (!replacement)
	    replacement = '_';
	    
	  var map = {
      'à|á|å|â': 'a',
      'è|é|ê|ẽ|ë': 'e',
      'ì|í|î': 'i',
      'ò|ó|ô|ø': 'o',
      'ù|ú|ů|û': 'u',
      'ç': 'c',
      'ñ': 'n',
      'ä|æ': 'ae',
      'ö': 'oe',
      'ü': 'ue',
      'Ä': 'Ae',
      'Ü': 'Ue',
      'Ö': 'Oe',
      'ß': 'ss',
      '[^\\w\\s]': ' ',
      '\\s+': replacement
	  }
	  
	  for (key in map) {
	    var re = new RegExp(key, 'g');
	    str = str.replace(re, map[key]);
	  }
      
  	return str;
	},

/*
	  Function: splat
	  Converts any object to an array if it is not already.
	
		Parameters:
			- obj
			
		Returns:
			array
	*/
	splat: function(obj) {
		if (!obj)
			return [];
		return (jQuery.isArray(obj)) ? obj : [obj];
	},
	
/*
	  Function: test
	  Tests to see if a given expression exists in the DOM, if not returns false
	
		Parameters:
			- selector
			- context
			
		Returns:
			an array of elements or false
	*/
	test: function(selector, context) {
		var results = jQuery(selector, context);
		return (results.length) ? results : false;
	},
	
/*
	  Function: toFloat
	  Shortcut for parseFloat.
	*/
	toFloat: function(num) {
		var n = parseFloat(num);
		return isNaN(n) ? 0 : n;
	},

/*
	  Function: toInt
	  Shortcut for parseInt.
	*/
	toInt: function(num, base) {
		var n = parseInt(num, base || 10);
		return isNaN(n) ? 0 : n;
	},
	
/*
	  Function: type
	  Returns type.
	*/
	type: function(obj) {
	  var type = typeof obj;
	  if (type == 'object') {
	    if (jQuery.isArray(obj)) type = 'array';
	    if (jQuery.isFunction(obj)) type = 'function';
	  }
	  if (type == 'number' && isNaN(obj) == true)
	    type = 'NaN';
	  
	  return type;
	},
	
/*
  Function: up
  Shortcut for toUpperCase.
	*/
	up: function(str) {
		return (jQuery.type(str) == 'string') ? str.toUpperCase() : str;
	}
});