
jQuery(
	function($) {		//added at start up

		$('.a2p a').click(function(ev) {		//process each link under class a2p	[however news-link is not in yet?]
			window.location.hash = this.href.replace(/.+\/([^\/]+)\/index\.html/,'$1') + '|default';
			loadPage(this.href);
			ev.preventDefault();
		});

		
		if(window.location.hash);else{window.location.hash += 'home|default';}		//if no suffix, add default

		if (window.location.hash) {	//if contains hash, load page (this is for the given URL, not navigation)
			if (window.location.hash.indexOf('|') === -1) {window.location.hash += '|default';}
			var path = window.location.href.replace(/(index\.html)?#/,'');		// must be index.html
			path = path.replace('\|','/') + '.html';
			loadPage(path);			//href
		}

		function loadPage(path) {
			var section = path.replace(/\/[^\/]+\.html/,'');
			var header = section.replace(/.+\/([^\/]+)/,'$1').replace(/_/, ' ');
			//alert(header);	//head=home
			$('div.normal').empty().append('<div id="demo-frame"></div>')		//append center & right menu
				.find('#demo-frame').load(header+'.html',
					function(){
						$("#tabs").tabs(); 
						$('.a2pnr a').click(function(ev) {		//process each link under class a2p	[however news-link is not in yet?]
							window.location.hash = this.href.replace(/.+\/([^\/]+)\/index\.html/,'$1') + '|default';
							//location.reload();
							loadPage(this.href);
							ev.preventDefault();
						});
						$("#report tr:odd").addClass("odd");
						$("#report tr:not(.odd)").hide();
						$("#report tr:first-child").show();
						$("#report tr.odd").click(function(){
							$(this).next("tr").toggle();
							$(this).find(".arrow").toggleClass("up");
						});	
					}
				)
		}
	}
);


