window.addEvent('domready', function(){
	
	if($('switch_priv') && $('switch_corp')) {
		
		var Switcher = new Class({
			initialize: function() {
				
				this.priv = $('switch_priv');
				this.priv_cell = this.priv.getParent();
				this.priv_content = $('priv_content');
				this.pointer_priv = $('pointer_priv');
				this.corp = $('switch_corp');
				this.corp_cell = this.corp.getParent();
				this.corp_content = $('corp_content');
				this.pointer_corp = $('pointer_corp');
				
				this.setActionHandlers();
			}
		});
		
		Switcher.implement({
			
			switchToPriv: function() {
				
				this.priv_cell.addClass('sc-curr');
				this.pointer_priv.removeClass('hidden');
				this.priv_content.removeClass('hidden');
				this.corp_cell.removeClass('sc-curr');
				this.pointer_corp.addClass('hidden');
				this.corp_content.addClass('hidden');
			},	
			
			switchToCorp: function() {
				
				this.corp_cell.addClass('sc-curr');
				this.pointer_corp.removeClass('hidden');
				this.corp_content.removeClass('hidden');
				this.priv_cell.removeClass('sc-curr');
				this.pointer_priv.addClass('hidden');
				this.priv_content.addClass('hidden');
			},
			
			setActionHandlers: function() {
				
				var obj = this;
				
				obj.priv.addEvent('click', function(e){
					
					new Event(e).stop();
					obj.switchToPriv();
				});
				
				obj.priv.getParent().addEvent('click', function() {
					
					obj.switchToPriv();
				});
				
				obj.corp.addEvent('click', function(e){
					
					new Event(e).stop();
					obj.switchToCorp();
				});
				
				obj.corp.getParent().addEvent('click', function(){
					
					obj.switchToCorp();
				});
			}
		});
		
		new Switcher;
	}
});
