
function toggleMenu(id) {

SubMenu = $(id).getElementsBySelector('[class="menuSublevelText"]');
SubMenu = SubMenu[0];
menuText = $(id).getElementsBySelector('[class="menuToplevelText"]');
menuText = menuText[0];



if(Element.visible(SubMenu)) {
	
	Effect.SlideUp(SubMenu, {duration:0.5, queue: {position:'end', scope: 'menumove'}});
	$(menuText).setStyle({color: '#FFFFFF'})
}

else
{
	
	menuChildren = $('menuContainer').childElements();
	
	for (var x = 0; x < menuChildren.length; x++)
   {
   		
		
		if (menuChildren[x].hasClassName('menuItem')) {
			menuChildName = menuChildren[x].identify();
			//alert($(menuChildName).getElementsBySelector('[class="menuSublevelText"]').length);
			//alert(menuChildren[x].identify());
			if (id != menuChildName) { 
				
				otherMenuText = menuChildren[x].getElementsBySelector('[class="menuToplevelText"]')[0];
				$(otherMenuText).writeAttribute('onMouseOver', 'onMenuMouseOver(\'' + menuChildName + '\');');
				$(otherMenuText).writeAttribute('onMouseOut', 'onMenuMouseOut(\'' + menuChildName + '\');');
				$(menuChildName + 'On').writeAttribute('onMouseOver', 'onMenuMouseOver(\'' + menuChildName + '\');');
				$(menuChildName + 'On').writeAttribute('onMouseOut', 'onMenuMouseOut(\'' + menuChildName + '\');');
				$(otherMenuText).setStyle({color: '#FFFFFF'});
				$(menuChildName + 'On').hide();
				$(menuChildName + 'Off').show();
				
				
				
				if (menuChildren[x].getElementsBySelector('[class="menuSublevelText"]').length != 0) {
					otherSubMenu = menuChildren[x].getElementsBySelector('[class="menuSublevelText"]')[0];
					
					
					if (otherSubMenu.visible()) { 
						new Effect.SlideUp(otherSubMenu, {duration:0.5, queue: {position:'end', scope: 'menumove'}});
					}
				} 
			}
			
		}
	}
	
	
	
   
	
	if (SubMenu.innerHTML != "") {
		Effect.SlideDown(SubMenu, {duration:0.5, queue: {position:'end', scope: 'modelmove'}});
		
	
	}
	//alert('running');	
	$(menuText).writeAttribute('onMouseOver', '');
	$(menuText).writeAttribute('onMouseOut', '');
	$(id + 'On').writeAttribute('onMouseOver', '');
	$(id + 'On').writeAttribute('onMouseOut', '');
	$(menuText).setStyle({color: '#00845f'});
	$(id + 'Off').hide();
	$(id + 'On').show();

}
	

}

function onMenu(pageId) {
	$('contentInternal').hide();
	$('popupBox').hide();
	$('loadingBox').show();
	//alert('test');
	
	var pageLookup = new Array();
	pageLookup[3] = "/";
	pageLookup[4] = "/who";
	pageLookup[5] = "/whatdoyouneed";
	pageLookup[10] = "/strategicsupport";
	pageLookup[11] = "/campaigndirection";
	pageLookup[12] = "/copythatsells";
	pageLookup[21] = "/trainingforresults";
	pageLookup[6] = "/clientsprojects";
	pageLookup[13] = "/clients";
	pageLookup[15] = "/projects";
	pageLookup[7] = "/comments";
	pageLookup[8] = "/contactlinda";
	pageLookup[9] = "/tutorials";
	pageLookup[24] = "/tutorials/joysperils";
	pageLookup[18] = "/tutorials/guidingprinciples";
	pageLookup[20] = "/tutorials/greatbrief";
	pageLookup[26] = "/tutorials/kickbuttcopy";
	pageLookup[27] = "/tutorials/friendtest";
	pageLookup[37] = "/articles";
	
	//alert(pageLookup[pageId]);
	
	pageTracker._trackPageview(pageLookup[pageId]);
	var theDate = new Date();
	var url = 'getcontent.php?postid=' + pageId + '&time=' + theDate.getTime();
	//new Ajax.Request(url, {method: 'get', onSuccess: showBox(transport)});
	new Ajax.Request(url, {method: 'get', onSuccess: function(transport) { 
					
	
					$('contentInternal').update(transport.responseText); 
					$('loadingBox').hide();
					$('contentInternal').show();


					
					//new Effect.Appear('contentInternal', {duration: 1});
				

						
			
					// Note update of the page has to occur after the above page open check or navigation bar may move in too far
					
				} });		
	
}

function onPopup(pageId) {
	
	$('popupBox').show();
	$('popupBoxContent').hide();
	//$('popupBoxContent').hide();
	var theDate = new Date();
	var url = 'getcontent.php?postid=' + pageId + '&time=' + theDate.getTime() + '&popup=1';
	//new Ajax.Request(url, {method: 'get', onSuccess: showBox(transport)});
	new Ajax.Request(url, {method: 'get', onSuccess: function(transport) { 
					
	
					$('popupBoxContent').update(transport.responseText); 
					$('popupBoxContent').show();
					
					//new Effect.Appear('contentInternal', {duration: 1});
				

						
			
					// Note update of the page has to occur after the above page open check or navigation bar may move in too far
					
				} });		
	
}

function closePopup()
{
	$('popupBox').hide();
}

function onMenuMouseOver(id) {

	menuText = $(id).getElementsBySelector('[class="menuToplevelText"]')[0];
	$(menuText).setStyle({color: '#00845f'});
				$(id + 'On').show();
				$(id + 'Off').hide();

}

function onMenuMouseOut(id) {

	menuText = $(id).getElementsBySelector('[class="menuToplevelText"]')[0];
	$(menuText).setStyle({color: '#FFFFFF'});
				$(id + 'On').hide();
				$(id + 'Off').show();

}

function fadeWelcome() {
	$('popupBox').hide();
	new Effect.Fade('titleImageLayer', {duration: 4, fps: 80, delay:1});
}

Event.observe(window, 'load', function() {
fadeWelcome();	
});
