

loadWhy = function() {
		new Elaborator('partners', 870, 300, 'partners.xml');


		showContent = function(thetype) {
			location.href = "#business";
			$$('.content-boxes').each(function(gh) {gh.hide();});
			
			$(thetype).show();
		}
}

var hash = location.hash;

function initPage(){



	setInterval(function()
	{
	    if (location.hash != hash)
	    {
	        hash = location.hash;
	        //loadHash();
	    }
	}, 100);

	initTabs();
	initMainnav();
	initAJAXTabs();
	loadHash();
}
function initMainnav(){
	var _btn = $$('#topnav > li > a');
	var _pageHold = $$('div.pages-holder')[0];
	for (var i = 0; i < _btn.length; i++){
		_btn[i]._ind = i;
		_btn[i].stopObserving();
		_btn[i].observe('click', function(event) {
			var _href = this.href;
			var _url = this.href;
			_href = _href.split('/');
			_href = _href[_href.length-1];
			_href = _href.split('.html')[0];
			_href = _href.split('.php')[0];
			_url ='inc'+_url.split('/inc')[1];
			
			if($(_href)){
			
				if (_href == "home"){
					var _btn = $$('#nav > li > a');
					for (var k = 0; k < _btn.length; k++){
						$(_btn[k].parentNode).removeClassName('active');
					}
					
					var _newBlock2 = $("home2");
					$$('div.inners').invoke('hide');
					initFade(_newBlock2);
				}
				var _newBlock = $(_href);
				$$('div.page').invoke('hide');
				initFade(_newBlock);
				location.href = location.href.substr(0, location.href.indexOf("#")) + "#path_" +_href;

			}
			else{
				new Ajax.Request(_url, {
					onSuccess: function(response) {
						$$('div.page').invoke('hide');
						_pageHold.insert(response.responseText);
						var _newEl = $(_href);
						initFade(_newEl);
						location.href = location.href.substr(0, location.href.indexOf("#")) + "#path_" +_href;

					}
				});
			}
			if(event) event.preventDefault();
		});
	}
	
	/*var reqs = $$('#requestinfo a');
	req = reqs[0];
	req.stopObserving();
	req.observe('click', function(event) {
			var _href = this.href;
			var _url = this.href;
			_href = _href.split('/');
			_href = _href[_href.length-1];
			_href = _href.split('.html')[0];
			_url ='inc'+_url.split('/inc')[1];
			if($(_href)){
				var _newBlock = $(_href);
				$$('div.page').invoke('hide');
				initFade(_newBlock);
			}
			else{
				new Ajax.Request(_url, {
					onSuccess: function(response) {
						$$('div.page').invoke('hide');
						_pageHold.insert(response.responseText);
						var _newEl = $(_href);
						initFade(_newEl);
					}
				});
			}
			if(event) event.preventDefault();
		});

*/
	var logoas = $$('#logo a');
	logoa = logoas[0]
	logoa.stopObserving();
	logoa.observe('click', function(event) {
			var _href = this.href;
			var _url = this.href;
			_href = _href.split('/');
			_href = _href[_href.length-1];
			_href = _href.split('.html')[0];
			_url ='inc'+_url.split('/inc')[1];
			if($(_href)){
				var _newBlock = $(_href);
				$$('div.page').invoke('hide');
				initFade(_newBlock);
			}
			else{
				new Ajax.Request(_url, {
					onSuccess: function(response) {
						$$('div.page').invoke('hide');
						_pageHold.insert(response.responseText);
						var _newEl = $(_href);
						initFade(_newEl);
					}
				});
			}
			if(event) event.preventDefault();
		});
		
	
}

loadHash = function () {
	var anchor = window.location.href.split('#')[1];
	var _pageHold = $$('div.pages-holder')[0];

	

	if (anchor != null && anchor.substr(0, 5) == 'path_') {
		var path = anchor.substr(5);
		
		var _href = path;
		var _url = path;
		
		_href = _href.split('/');

		var _newhref = '';
		for(i=0; i<_href.length; i++) {
			_newhref = _newhref + '-' + _href[i];
		}
		_href = _newhref;
		
		if (_url.include('news/')) {
			_url = _url.sub('news/', 'news.php/');		
				
		} else {
			_url = _url + '.html';
		}


		_url = '/inc/' + _url;
		

		if($(_href)){
			
			/*if (_href == "home"){
				var _btn = $$('#nav > li > a');
				for (var k = 0; k < _btn.length; k++){
					$(_btn[k].parentNode).removeClassName('active');
				}
				
				var _newBlock2 = $("home2");
				$$('div.inners').invoke('hide');
				initFade(_newBlock2);
			}*/
							
			var _newBlock = $('news'+_href);
			$$('div.page').invoke('hide');
			initFade(_newBlock);
		}
		else{
			new Ajax.Request(_url, {
				onSuccess: function(response) {
					
					$$('div.page').invoke('hide');
					_pageHold.insert(response.responseText);
					
					var _newEl = $('news-'+_href);
					initFade(_newEl);
				}
			});
		}
		
	}

}

function initFade(_el){
	_el.show();
	_el.style.opacity = 0;
	new Effect.Opacity(_el, { from: 0, to: 1, duration: 0.6});
}
function initAJAXTabs(){
	var _btn = $$('#nav > li > a');
	var _pageHold = $$('div.inner-pages')[0];
	for (var i = 0; i < _btn.length; i++){
		_btn[i]._ind = i;
		_btn[i].stopObserving();
		_btn[i].observe('click', function(event) {
			var _href = this.href;
			var _url = this.href;

			for (var k = 0; k < _btn.length; k++){
				$(_btn[k].parentNode).removeClassName('active');
			}
			$(this.parentNode).addClassName('active');
			_href = _href.split('/');
			_href = _href[_href.length-1];
			_href = _href.split('.html')[0];
			_url ='inc'+_url.split('/inc')[1];

			

			$("ngenlogobutton").className = $("ngenlogobutton").className.replace("active", "");

			if ((_href == "theatre") || (_href == "boardroom")) {
				$("ngenlogobutton").className += ' active';
			}


			if($(_href)){
			
				var _newBlock = $(_href);
				$$('div.inners').invoke('hide');
				initFade(_newBlock);
				

			}
			else{
				new Ajax.Request(_url, {
					onSuccess: function(response) {
						$$('div.inners').invoke('hide');
						_pageHold.insert(response.responseText);
						var _newEl = $(_href);
						initFade(_newEl);
						initTabs();
						location.href = location.href.substr(0, location.href.indexOf("#")) + "#path_" +_href;
					}
				});
			}
			if(event) event.preventDefault();
		});
	}
}
function initTabs()
{
	var sets = document.getElementsByTagName("ul");
	
	for (var i = 0; i < sets.length; i++)
	{
		if (sets[i].className.indexOf("tabset") != -1)
		{
			var tabs = [];
			var links = $$('ul a.tab');
			
			for (var j = 0; j < links.length; j++)
			{
				if (links[j].className.indexOf("tab") != -1)
				{
					tabs.push(links[j]);
					links[j].tabs = tabs;
					var c = document.getElementById(links[j].href.substr(links[j].href.indexOf("#") + 1));

					if (c) if (links[j].parentNode.className.indexOf("active") != -1) c.style.display = "block";
					else c.style.display = "none";
					links[j].onclick = function (){
						return false;
					}
					
					
					links[j].onmouseover = function ()
					{
						var a = $$('ul.logos li > a');
						
						if ($("datacentredescription")) {
							$("datacentredescription").hide();
						}

						var c = document.getElementById(this.href.substr(this.href.indexOf("#") + 1));
						if (c)
						{
							for (var i = 0; i < this.tabs.length; i++)
							{
								var tab = document.getElementById(this.tabs[i].href.substr(this.tabs[i].href.indexOf("#") + 1));
								if (tab)
								{
									tab.style.display = "none";
								}
								this.tabs[i].parentNode.className = this.tabs[i].parentNode.className.replace("active", "");
							}
							this.parentNode.className += " active";
							$(c).show();
						}
						var rel = this.rel;
						for (var i=0; i < a.length; i++) {
							if (rel.indexOf(a[i].rel) != -1) {
								a[i].parentNode.className += ' active';
							}
						}

					}
					links[j].onmouseout = function(){
						
						var a = $$('ul.logos li > a');
						
						
						if ($("datacentredescription")) {
							$("datacentredescription").show();
						}
						
						for (var i=0; i<a.length; i++) {
							a[i].parentNode.className = a[i].parentNode.className.replace('active','');
							
							for (var y = 0; y < this.tabs.length; y++)
							{
								var tab = document.getElementById(this.tabs[y].href.substr(this.tabs[y].href.indexOf("#") + 1));
								if (tab)
								{
									tab.style.display = "none";
								}
								this.tabs[y].parentNode.className = this.tabs[y].parentNode.className.replace("active", "");
							}
						}

					}
				}
			}
		}
	}
}

ajaxifyLinks = function (theArea) {

	var _btn = $$('#' + theArea + ' a');
	var _pageHold = $$('div.pages-holder')[0];

	for (var i = 0; i < _btn.length; i++){
		_btn[i]._ind = i;
		
		if (_btn[i].hasClassName("noajax")) {
			_btn[i].target = "blank";
		
		}
		
		if (!_btn[i].hasClassName("lightwindow") && !_btn[i].hasClassName("noajax")) {
			_btn[i].stopObserving();
			_btn[i].observe('click', function(event) {
				var _href = this.href;
				var _url = this.href;
				
				_href = _href.split('/');
	
				var _newhref = '';
				for(i=5; i<_href.length-1; i++) {
					_newhref = _newhref + '-' + _href[i];
				}
				_href = _newhref;
	
				if($('news'+_href)){
					
					/*if (_href == "home"){
						var _btn = $$('#nav > li > a');
						for (var k = 0; k < _btn.length; k++){
							$(_btn[k].parentNode).removeClassName('active');
						}
						
						var _newBlock2 = $("home2");
						$$('div.inners').invoke('hide');
						initFade(_newBlock2);
					}*/
					
					var _newBlock = $('news'+_href);
					$$('div.page').invoke('hide');
					initFade(_newBlock);
				}
				else{
					new Ajax.Request(_url, {
						onSuccess: function(response) {
							
							$$('div.page').invoke('hide');
							_pageHold.insert(response.responseText);
							
							var _newEl = $('news-'+_href);
							initFade(_newEl);
						}
					});
				}
				if(event) event.preventDefault();
			});
		}
	}

}


ajaxifyRequestLinks = function (theArea) {

	var _btn = $$('#' + theArea + ' .request a');
	var _pageHold = $$('div.pages-holder')[0];


	for (var i = 0; i < _btn.length; i++){

		_btn[i]._ind = i;
		_btn[i].stopObserving();
		_btn[i].observe('click', function(event) {
			var _href = this.href;
			var _url = this.href;

			$('home').hide();

			for (var k = 0; k < _btn.length; k++){
				$(_btn[k].parentNode).removeClassName('active');
			}
			$(this.parentNode).addClassName('active');
			_href = _href.split('/');
			_href = _href[_href.length-1];
			_href = _href.split('.html')[0];
			_url ='inc'+_url.split('/inc')[1];	

			$("ngenlogobutton").className = $("ngenlogobutton").className.replace("active", "");

			if ((_href == "theatre") || (_href == "boardroom")) {
				$("ngenlogobutton").className += ' active';
			}


			if($(_href)){
			
				var _newBlock = $(_href);
				$$('div.inners').invoke('hide');
				initFade(_newBlock);
				

			}
			else{
				new Ajax.Request(_url, {
					onSuccess: function(response) {
						$$('div.inners').invoke('hide');
						_pageHold.insert(response.responseText);
						var _newEl = $(_href);
						initFade(_newEl);
						initTabs();
						location.href = location.href.substr(0, location.href.indexOf("#")) + "#path_" +_href;
					}
				});
			}
			if(event) event.preventDefault();
		});
	}

}


if (window.addEventListener)
	window.addEventListener("load", initPage, false);
else if (window.attachEvent && !window.opera)
	window.attachEvent("onload", initPage);
	

