window.addEvent('domready', function() {
	var status = {
		'true': 'open',
		'false': 'close'
	};
	
	//-vertical

	var servicesSlide = new Fx.Slide('subServices').hide();
	var aboutSlide = new Fx.Slide('subAbout').hide();
	var portfolioSlide = new Fx.Slide('subPortfolio').hide();
	var contactSlide = new Fx.Slide('subContact').hide();
	
	function switchIcon(element){
		
	}
	
	function checkState(element){
		if((aboutSlide.open==true)&&(element!='about')) aboutSlide.slideOut();
		if((servicesSlide.open==true)&&(element!='services')) servicesSlide.slideOut();
		if((portfolioSlide.open==true)&&(element!='portfolio')) portfolioSlide.slideOut();
		if((contactSlide.open==true)&&(element!='contact')) contactSlide.slideOut();
	}

	$('services').addEvent('click', function(e){
		e.stop();
		servicesSlide.toggle();
		checkState('services');
		//alert(servicesSlide.open);
		if(servicesSlide.open==false){
			$('about').className = '';
			$('services').className = 'open';
			$('portfolio').className = '';
			$('contact').className = '';
		} else {
			$('about').className = 'open';
			$('services').className = '';
			$('portfolio').className = 'open';
			$('contact').className = 'open';
		}
	});
	
	$('about').addEvent('click', function(e){
		e.stop();
		aboutSlide.toggle();
		checkState('about');
		//alert(aboutSlide.open);
		if(aboutSlide.open==false){
			$('about').className = 'open';
			$('services').className = '';
			$('portfolio').className = '';
			$('contact').className = '';
		} else {
			$('about').className = '';
			$('services').className = 'open';
			$('portfolio').className = 'open';
			$('contact').className = 'open';
		}
	});
	
	$('portfolio').addEvent('click', function(e){
		e.stop();
		portfolioSlide.toggle();
		checkState('portfolio');
		if(portfolioSlide.open==false){
			$('about').className = '';
			$('services').className = '';
			$('portfolio').className = 'open';
			$('contact').className = '';
		} else {
			$('about').className = 'open';
			$('services').className = 'open';
			$('portfolio').className = '';
			$('contact').className = 'open';
		}
	});
	
	$('contact').addEvent('click', function(e){
		e.stop();
		contactSlide.toggle();
		checkState('contact');
		if(contactSlide.open==false){
			$('about').className = '';
			$('services').className = '';
			$('portfolio').className = '';
			$('contact').className = 'open';
		} else {
			$('about').className = 'open';
			$('services').className = 'open';
			$('portfolio').className = 'open';
			$('contact').className = '';
		}
	});
	
	if($('services').className=='open') servicesSlide.show();
	if($('about').className=='open') aboutSlide.show();
	if($('portfolio').className=='open') portfolioSlide.show();
	if($('contact').className=='open') contactSlide.show();
	
	
});



		function getWindowWidth() {
			var windowWidth = 0;
			if (typeof(window.innerHeight) == 'number') {
				windowWidth = window.innerWidth;
			}
			else {
				if (document.documentElement && document.documentElement.clientWidtht) {
					windowWidth = document.documentElement.clientWidth;
				}
				else {
					if (document.body && document.body.clientWidth) {
						windowWidth = document.body.clientWidth;
					}
				}
			}
			return windowWidth;
		}
		function setFooter() {
			if (document.getElementById) {
				var windowWidth = getWindowWidth();
				if (windowWidth > 0) {
					var wrapperWidth = document.getElementById('wrapper').offsetWidth;
					var navElement = document.getElementById('darkMenu');
					//alert(windowWidth);
					if(windowWidth<950){
						var decalage = 950-windowWidth;
						navElement.style.right = '-'+decalage+'px';
						
					} else {
						navElement.style.right = '0px';
					}
					/*var wrapperHeight = document.getElementById('wrapper').offsetHeight;
					var footerElement = document.getElementById('footer');
					var footerHeight  = footerElement.offsetHeight;
					//window.alert('wrapper: ' + wrapperHeight);
					if (windowHeight - (wrapperHeight + footerHeight) >= 0) {
						footerElement.style.position = 'relative';
						footerElement.style.top = (windowHeight - (25 + wrapperHeight + footerHeight)) + 'px';
					}
					else {
						footerElement.style.position = 'static';
					}
					*/
				}
			}
		}
		window.onload = function() {
			var myNav = navigator.appName;
			if (myNav != 'Microsoft Internet Explorer'){
				setFooter();
			}
			//externalLinks(); 
		}
		window.onresize = function() {
			var myNav = navigator.appName;
			if (myNav != 'Microsoft Internet Explorer'){
				setFooter();
			}
		}
