var Rc = {
	version: 0.1,
	
	init: function() {
		
		
	},
	
	is: {
		Opera: !!(window.opera && opera.buildNumber),
		WebKit: /WebKit/.test(navigator.userAgent)
	}
	
};

(function(){
	var ua = navigator.userAgent, av = navigator.appVersion, v, i;
	
	Rc.is.IE = !Rc.is.WebKit && !Rc.is.Opera && (/MSIE/gi).test(ua) && (/Explorer/gi).test(navigator.appName);
	Rc.is.IE6 = Rc.is.IE && /MSIE [56]/.test(ua);
	
	Rc.is.Gecko = !Rc.is.WebKit && /Gecko/.test(ua);
	Rc.is.Mac = ua.indexOf('Mac') != -1;
	
})();

//prototype

Number.prototype.format = function() {
	str = parseInt(this).toString();
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(str)) {
		str = str.replace(rgx, '$1' + ' ' + '$2');
	}
	return str;
}


Rc.Switcher = Class.create({
	
	options: {}, elements: [],
	
	initialize: function(e) {
		this.options = Object.extend({
			'class': 'selected',
			onSelect: null
		},arguments[1] || {});
		
		this.elements = e;
		
		this.elements.each(function(el){
			el.observe('click',this._switch.bind(this,el));
		}.bind(this));
	},
	
	switchTo:function(el) {
		if (!el.hasClassName(this.options['class'])) {
			
			this.elements.invoke('removeClassName',this.options['class']);
			el.addClassName(this.options['class']);
			
			if (this.options.onSelect) {
				this.options.onSelect.call(this,el);
			}
		}
	},
	
	_switch: function(el){ //just wrapper to stop event
		Event.stop(arguments[1]);
		this.switchTo(el);
	}
});




