Ext.ns('Ext.ux');
Ext.ux.RightNavigation = Ext.extend(Ext.util.Observable, {
	element: null,
	currentItem: null,
	defaultIndex: 0,
	constructor: function(config) {
		config = config || {};
		Ext.apply(this, config);
		Ext.ux.RightNavigation.superclass.constructor.call(this,config);
		
		this.element = Ext.get('right-navigation');
		if (!this.element) { return; }
		this.items = this.element.select('li ul');
		if (this.items.getCount() <= 0) return;
		
		this.setup();
	},
	setup: function() {
		var self = this;
		this.items.each(function(o, el, idx) {
			var child = Ext.get(self.items.elements[idx]);
			var parent = child.parent('li');
			if (idx == self.defaultIndex) {
				self.currentItem = child;
			} else {
				child.addClass('hidden');
			}
			parent.on('mouseover', function() {
				var child = this.child('ul');
				if (!child.isVisible()) {
					self.currentItem.addClass('hidden');
					child.removeClass('hidden');
					self.currentItem = child;
				}
			}, parent, { buffer: 200 });
		});
	}
});

var QueryString = {
	get: function(name) {
		name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  var regexS = "[\\?&]"+name+"=([^&#]*)";  var regex = new RegExp( regexS );  var results = regex.exec( window.location.href );  if( results == null )    return "";  else    return results[1];
	}
};

Ext.onReady(function() {
	// setup the reset
	Ext.select('.sitemap-buttons-panel').on('click', function(e, t) {
		Ext.get(t).radioClass('tab-active');
		Ext.get('content' + t.id.slice(-1)).radioClass('tab-content-show');
	}, null, { delegate: 'div' });
	
});