// JavaScript Document

function showLeaders() {
	if ($('leadershipsub').getStyle('display')=='none') {
		$('leadershipsub').setStyle({ display: 'block' });
	} else {
		$('leadershipsub').setStyle({ display: 'none' });
	}
}

var logo;
var tagline;
var contact = false;
var contentwrapper = false;
var loaded = false;
function moveLogoInit() {
	logo = $('header').select('img.logo')[0];
	tagline = $('header').select('img.tagline')[0];
	contact = $$('a.contact');
	if (contact.length > 0) {
		contact = contact[contact.length-1];
	}
	var cw = $$('#contentwrapper.withbg');
	if (cw.length > 0) {
		contentwrapper = true;
	}
	loaded = true;
	moveLogo();
}

function moveLogo() {
	if (loaded == false) return;
	var w = window;
	var windowWidth = w.innerWidth || (w.document.documentElement.clientWidth || w.document.body.clientWidth);
	var scrollTop = window.scrollTop || document.documentElement.scrollTop || document.scrollTop || 0
				
	if (windowWidth > 1000) {
		
		var newright = 0 - (windowWidth - 1000) + 35;
		$(logo).setStyle({ right: newright+'px' });
		$(tagline).setStyle({ right: newright+'px' });
		$('headerwrapper').setStyle({ width: '100%' });
		$('contentwrapper').setStyle({ width: '100%' });
				
	} else {
		$(logo).setStyle({ right: '35px' });
		$(tagline).setStyle({ right: '35px' });
		$('headerwrapper').setStyle({ width: '1000px' });
		$('contentwrapper').setStyle({ width: '1000px' });
	
	}

	if (contact != false) {
		if (windowWidth > 1000) {
			var newright = 0 - (windowWidth - 1000) + 36;
			$(contact).setStyle({ right: newright+'px' });
		} else {
			$(contact).setStyle({ right: '36px' });
		}
	}
	
	if (contentwrapper != false) {	
		if (windowWidth > 1000) {
			if ((windowWidth-1000) < 7) {
				$('content').setStyle({ borderRight: '#FFF solid '+(windowWidth-1000)+'px' });	
			} else {
				$('content').setStyle({ borderRight: '#FFF solid 7px' });	
			}
		} else {
				$('content').setStyle({ borderRight: '0px' });	
		}
	}
}

function setFullWidth() {
	
	var w = window;
	var windowWidth = w.innerWidth || (w.document.documentElement.clientWidth || w.document.body.clientWidth);
		
	if (windowWidth > 1000) {
		$$('div.fullwidth').each(function(it) {
			it.setStyle({ width: windowWidth+'px' });
		});
	} else {
		$$('div.fullwidth').each(function(it) {
			it.setStyle({ width: '1000px' });
		});
	}
}

Event.observe(window, 'load', setFullWidth);
Event.observe(window, 'load', moveLogoInit);
Event.observe(window, 'resize', moveLogo);
Event.observe(window, 'resize', setFullWidth);
Event.observe(window, 'scroll', moveLogo);