// noisybear.js
//(c) 2008 - noisybear.com
//

var Noisybear = {
	
	$: function(object) { return document.getElementById(object); },
	
	$A: function(object) {
		if (!object) return [];
		if ( !Browser.Init.isWebKit ) {
			 if (object.toArray) return object.toArray();
			  var length = object.length || 0, results = new Array(length);
			  while (length--) results[length] = object[length];
			  return results;
		} else {
			if (!(Noisybear.isFunction(object) && object == '[object NodeList]') &&
			object.toArray) return object.toArray();
			var length = object.length || 0, results = new Array(length);
			while (length--) results[length] = object[length];
			return results;
		}
	},
	
	element: function(object) { return document.createElement(object) },
	
	style: function(name, attributes) {
		for (i =0; i<attributes.length; i++) {
			begin = attributes[i].indexOf(':', attributes[i]);
			end = attributes[i].indexOf(';', attributes[i]);
			s = unescape(attributes[i].substring(0,begin));
			a = unescape(attributes[i].substring(begin+1,end));
			name.style[s] = a;
		}
	},
	
	msg: function(element, message) { this.element = Noisybear.$(element); this.element.innerHTML = message; },
	
	extend: function(destination, source) {
	  for (var property in source)
		destination[property] = source[property];
	  return destination;
	},
	
	keys: function(object) {
		var keys = [];
		for (var property in object) keys.push(property);
		return keys;
	},
	
	getElementsBySelector: function() {
		var args = $A(arguments), element = $(args.shift());
		return this.findChildElements(element, args);
	},
	
	findChildElements: function(element, expressions) {
		expressions = split(expressions.join(','));
		
	},
	
	isFunction: function(object) { return typeof object == "function";},
	
	emptyFunction: function() { }
	
}

function $(object) { return Noisybear.$(object); }

function $A(object) { return Noisybear.$(object); }

function element(object) { return Noisybear.element(object); }

function style(name, attributes) { return Noisybear.style(name, attributes); }

function msg(element, message) {return Noisybear.msg(element, message); }

function extend(destination, source) { return Noisybear.extend(destination, source); }

function keys(object) { return Noisybear.keys(object); }