/* when using dijit titlePane, anchor links to them don't work. this finds all such links and adds
 * some script so they toggle and stuff. also, if there's a tabContainer it selects the right contentPane
 */
dojo.addOnLoad(function ()
{
	var as = document.getElementsByTagName('a');
	for (var i = 0; i < as.length; i += 1) {
		if (as[i].getAttribute('href', 2 /* for IE */).charAt(0) == '#') {
			var el = dijit.byId(as[i].getAttribute('href', 2 /* for IE */).substr(1));
			if (el && el.baseClass == 'dijitTitlePane') {
				as[i].onclick = function (el)
				{
					return function ()
					{
						var cont = dijit.byId('mainTabContainer');
						if (cont) {
							cont.selectChild(dijit.byId(el.domNode.parentNode.id));
						}
						if (!el.open) {
							el.toggle();
						}
					};
				}(el);
			}
		}
	}
	var el = dijit.byId(window.location.hash.substr(1));
	if (el && el.baseClass == 'dijitTitlePane') {
		var cont = dijit.byId('mainTabContainer');
		if (cont) {
			cont.selectChild(dijit.byId(el.domNode.parentNode.id));
		}
		document.foo = el;
		el.toggle();
	}
});
