function Ie6Menu() {
	if (window.ie6) {
		navRoot = document.getElementById("mainNav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.className=="mainNavLi") {
				node.onmouseover=function() { this.className+=" over";}
				node.onmouseout=function()  { this.className=this.className.replace(" over", ""); }
			} 
		}
	}
}

function CenterCont() {
	var windowHeight = window.getSize().y;
	if (windowHeight > 0) {
		var contentElement = document.getElementById('FullCont');
		var contentHeight = contentElement.offsetHeight;
		if (windowHeight - contentHeight > 0) {
			contentElement.style.marginTop = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
		} else {
		  windowHeight = window.innerHeight
		  if (windowHeight) {
			contentElement.style.marginTop = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
		  }
		}
	}
}

var HideMenu = true;
var CurPage = 'home';
var CurLang = 'en';

if (location.search != "")	{
  MyUrl = location.search.substr(1).split("&")
  for (var i=0; i<MyUrl.length; i++)  {
	var MyData = MyUrl[i].split("=");
	if (MyData[0] == 'page') 
		CurPage = MyData[1];
	else if (MyData[0] == 'language') 
		CurLang = MyData[1];
  }
}

window.addEvent('domready', function() {

	Ie6Menu();
	CenterCont();
	$('mainCont').style.height='410px';
	$('mainNav').style.overflow='hidden';
	
	if (window.ie) $('mainNav').style.background='none';
	var myMainNav = new Fx.Morph('mainNav', {wait: false, duration:1000,  transition: Fx.Transitions.Bounce.easeOut});

	var mainNav = $('mainNav')
	mainNav.addEvent('mouseleave', function(e) { new Event(e).stop(); myMainNav.start('.mainNavDown'); });
	mainNav.addEvent('mouseenter', function(e) { new Event(e).stop(); myMainNav.start('.mainNavUp'); HideMenu = false; });

	(function(){if (HideMenu) myMainNav.start('.mainNavDown');}).delay(1000);

	var MyTips = new Tips($$('img'), {
	  enlarge: true,
	  initialize:function(){ this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);},
	  onShow: function(toolTip) { this.fx.start(1);},
	  onHide: function(toolTip) { this.fx.start(0);}
	});
	
	if (CurPage == 'team') {
		var accordion = new Accordion('.toggler', '.elements div', {togglerEvent: 'mouseover'});
	} else if (CurPage == 'portfolio') {
		var accordion = new Accordion('.toggler', '.elements div');
	}
	
});

window.onresize = function () { CenterCont(); }