function createNavButton() {
 var thePageHeader = document.getElementById('pageHeader_top');
 var theButton = document.createElement('div');
 theButton.setAttribute('id', 'navButton');
 theButton.addEventListener('click', toggleNavigation);
 thePageHeader.appendChild(theButton);
 document.getElementById('sidebar').className='hidden';
}

function toggleNavigation() {
	navigationDiv=document.getElementById('sidebar');
	if (navigationDiv.className=='hidden') {
		navigationDiv.className='overlay';
	}
	else {
		navigationDiv.className='hidden';
	}
}

function setHeaderBGColor() {
	var theBody=document.body;
	var bodyBG=document.defaultView.getComputedStyle(theBody,null).getPropertyValue('background-color');
	var theHeader=document.getElementById('pageHeader_top');
	theHeader.style.backgroundColor=bodyBG;
	
	var theContainer=document.getElementById('content');	
	var theFooter=document.getElementById('footer');
	var theMain=document.getElementById('mainContent');
	var theText=document.getElementById('content_text');
	var theWrapper=document.getElementById('container');
	var containerBG=document.defaultView.getComputedStyle(theContainer,null).getPropertyValue('background-color');
	theBody.style.backgroundColor=containerBG;
	theFooter.style.backgroundColor=containerBG;
	theMain.style.backgroundColor=containerBG;
	theText.style.backgroundColor=containerBG;
	theWrapper.style.backgroundColor=containerBG;
}

function showLogo() {
	var theLogoDiv=document.getElementById('phoneLogo');
	var theHeight=document.defaultView.getComputedStyle(theLogoDiv,null).getPropertyValue('height');
	var theLogoIMG=document.getElementById('headerLogo');
	if (theHeight=='0px') {
		theLogoIMG.className='hidden';
	}
	else {
		theLogoIMG.className='show';
	}
}

function hideURLbar(){
	window.scrollTo(0,1);
}

if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
	addLoadEvent(setHeaderBGColor);
	addLoadEvent(createNavButton);
	addLoadEvent(showLogo);
	addLoadEvent(hideURLbar);
	}