var $utils=(function($){
	if(!$){return;}
	return{
		'attributes':function(o,eh){
			if(typeof(o)=='object'){
//alert('NamedNodeMap: '+this.is(o,'NamedNodeMap')+'\nObject Class: '+this.getClass(o));
				if(this.is(o,'NamedNodeMap')){// NOT IE Compatible
					var map={},ehre=/^on/i;
					for(var i=0;i<o.length;i++){
						if(eh || !eh && !ehre.test(o[i].nodeName)){
							map[o[i].nodeName]=this.typecast(o[i].nodeValue);
						}
					}
					return map;
				}
//alert('Is Object Not NamedNodeMap\n'+o);
//alert(o+'\nnodeType:'+o.nodeType+'\no.toString: '+o.toString()+'\nObject toString: '+Object.prototype.toString.call(o));
//alert('test\n'+(o==Object.prototype.toString.call(o))+'\no.match'+String(o).match(/^\[object\s(.*)\]$/));

				// convert to a DOM Node object and rerun as the attributes
				return this.attributes((o.nodeType===1?o:o[0]).attributes,eh);
			}
			return this.attributes($(o)[0].attributes,eh);
		},
		'getClass':function(o){
			var s=Object.prototype.toString.call(o).match(/^\[object\s(.*)\]$/);
//			if(s[1]=='Object' && o.nodeType===1){
//				return String(o).match(/^\[object\s(.*)\]$/)[1];
//			}
			return s[1];
		},
		'init':function(object,data,fn){
			var instance=$.extend(true,{},object);
			if(!fn){fn='init'}
			if(data && instance[fn]){
				instance[fn].apply(instance,data);
			}
			return instance;
		},
		'is':function(o,c){
			if(this.getClass(c)=='Array'){
				return $.inArray(this.getClass(o),c)>=0;
			}
			return this.getClass(o)==c;
		},
		'typecast':function(o){
			if((/(\d*)\.{0,1}(\d+)/).test(o)){
				return isNaN(o)?o:Number(o);
			}else if((/true|false/i).test(o)){
				return o=='true';
			}else if(o=='null' || o=='undefined'){
				return o=='null'?null:undefined;
			}
			return o;
		}
	}
})(typeof(jQuery)!=='undefined'?jQuery:null);

