var nav = {
// ### WHEN EDITING THIS FILE, THE T1 - T4 DEFINITIONS MUST ABSOLUTELY MATCH ACTUAL HTML ELEMENTS
// ### If you are defining the element id's for a channel and only want Tier 1 and Tier 2 visible, only specify those id's. Tier 3 and Tier 4 would be left blank.
// ### If a Tier is defined and no actual element exists with that ID, the code can keep going and doesn't know to stop.
	
	//Community Home
	'Community':{
		t1:'navCommunity',
		t2:'t2commhome',
		leftbox:'',
		t3:'',
		t4:''
	},

	//Profile
	'Activity':{
		t1:'navCommunity',
		t2:'t2profilehome',
		leftbox:'lbprofile',
		t3:'t3activity',
		t4:''
	},
	
	// Member Not Found
	'Member Not Found':{
		t1:'navCommunity',
		t2:'',
		leftbox:'',
		t3:'',
		t4:''
	},
	
	"Friend's Activity":{
		t1:'navCommunity',
		t2:'',
		leftbox:'lbprofile',
		t3:'t3activity',
		t4:'',
		hide:['t3settings']
	},
	
	'Member Community Join':{
		t1:'navCommunity',
		t2:'t2commhome',
		leftbox:'',
		t3:'',
		t4:''
	},

	'Activities':{
		t1:'navCommunity',
		t2:'t2profilehome',
		leftbox:'lbprofile',
		t3:'t3activity',
		t4:''
	},
	
	"Friend's Activities":{
		t1:'navCommunity',
		t2:'',
		leftbox:'lbprofile',
		t3:'t3activity',
		t4:'',
		hide:['t3settings']
	},
	
	//Bio
	'Bio':{
		t1:'navCommunity',
		t2:'t2profilehome',
		leftbox:'lbprofile',
		t3:'t3bio',
		t4:''
	},
	"Friend's Bio":{
		t1:'navCommunity',
		t2:'',
		leftbox:'lbprofile',
		t3:'t3bio',
		t4:'',
		hide:['t3settings']
	},
	"Private Bio":{
		t1:'navCommunity',
		t2:'',
		leftbox:'lbprofile',
		t3:'t3bio',
		t4:'',
		hide:['t3settings']
	},
	
	//Basic Profile
	'Update Basic Profile':{
		t1:'navCommunity',
		t2:'t2profilehome',
		leftbox:'lbprofile',
		t3:'t3bio',
		t4:''
	},

	//Account Settings
	'Account Settings':{
		t1:'navCommunity',
		t2:'t2profilehome',
		leftbox:'lbprofile',
		t3:'t3settings',
		t4:''
	},
	
	//Newsletter Subscriptions
	'Newsletter Subscriptions':{
		t1:'navCommunity',
		t2:'t2profilehome',
		leftbox:'lbprofile',
		t3:'t3settings',
		t4:'t4subscriptions'
	},
	
	//Military Profile
	'Update Military Profile':{
		t1:'navCommunity',
		t2:'t2profilehome',
		leftbox:'lbprofile',
		t3:'t3bio',
		t4:''
	},
	
	//Work History
	'Work History':{
		t1:'navCommunity',
		t2:'t2profilehome',
		leftbox:'lbprofile',
		t3:'t3bio',
		t4:''
	},
		
	//Profile Photo
	'Upload Profile Photo':{
		t1:'navCommunity',
		t2:'t2profilehome',
		leftbox:'lbprofile',
		t3:'t3bio',
		t4:''
	},
	
	//Installation History
	'Installation History':{
		t1:'navCommunity',
		t2:'t2profilehome',
		leftbox:'lbprofile',
		t3:'t3bio',
		t4:''
	},

	//Education History
	'Education History':{
		t1:'navCommunity',
		t2:'t2profilehome',
		leftbox:'lbprofile',
		t3:'t3bio',
		t4:''
	},

	//Work Profile
	'Work Profile':{
		t1:'navCommunity',
		t2:'t2profilehome',
		leftbox:'lbprofile',
		t3:'t3bio',
		t4:''
	},
	
	//About Me
	'About Me':{
		t1:'navCommunity',
		t2:'t2profilehome',
		leftbox:'lbprofile',
		t3:'t3bio',
		t4:''
	},	
	
	//Messages
	'Inbox':{
		t1:'navCommunity',
		t2:'t2messages',
		leftbox:'lbmessages',
		t3:'t3inbox',
		t4:''
	},
	
		//Compose Messages
		'Compose Message':{
			t1:'navCommunity',
			t2:'t2messages',
			leftbox:'lbmessages',
			t3:'t3compose',
			t4:''
		},
		
		//Read Messages
		'Read Message':{
			t1:'navCommunity',
			t2:'t2messages',
			leftbox:'lbmessages',
			t3:'t3inbox',
			t4:''
		},

		//Sent Messages
		'Sent Messages':{
			t1:'navCommunity',
			t2:'t2messages',
			leftbox:'lbmessages',
			t3:'t3sentmsg',
			t4:''
		},


	//Friends
	'Friends':{
		t1:'navCommunity',
		t2:'t2friends',
		leftbox:'lbfriends',
		t3:'t3viewfriends',
		t4:''
	},
	
	//Friend's Friends page
	'Members':{
		t1:'navCommunity',
		t2:'',
		leftbox:'',
		t3:'',
		t4:''
	},

		//Friends
		'Friend Requests':{
			t1:'navCommunity',
			t2:'t2friends',
			leftbox:'lbfriends',
			t3:'t3friendrequests',
			t4:''
		},
		//Friends
		'Find Friends':{
			t1:'navCommunity',
			t2:'t2friends',
			leftbox:'lbfriends',
			t3:'t3findfriends',
			t4:''
		},	
		//Friends
		'Invite Friends':{
			t1:'navCommunity',
			t2:'t2friends',
			leftbox:'lbfriends',
			t3:'t3invitefriends',
			t4:''
		},
		//Friends
		'Invitations Sent':{
			t1:'navCommunity',
			t2:'t2friends',
			leftbox:'lbfriends',
			t3:'t3invitefriends',
			t4:''
		},
		
	//Groups
	'Groups':{
		t1:'navCommunity',
		t2:'t2groups',
		leftbox:'lbgroups',
		t3:'t3allgroups',
		t4:''
	},
	
	//My Page Manager
	'My Page Manager':{
		t1:'navCommunity',
		t2:'t2groups',
		leftbox:'lbgroups',
		t3:'t3unitpages',
		t4:''
	},

	//Comments
	'Notifications':{
		t1:'navCommunity',
		t2:'t2profilehome',
		leftbox:'lbprofile',
		t3:'t3activity',
		t4:''
	},
	
	//Legacy App Definitions
	'badgebuilder':{
		t1:'navCommunity',
		t2:'t2profilehome',
		leftbox:'lbprofile',
		t3:'t3bio',
		t4:''
	},
	
	'ribbonbuilder':{
		t1:'navCommunity',
		t2:'t2profilehome',
		leftbox:'lbprofile',
		t3:'t3bio',
		t4:''
	},
	
	'campaignbuilder':{
		t1:'navCommunity',
		t2:'t2profilehome',
		leftbox:'lbprofile',
		t3:'t3bio',
		t4:''
	},
	
	'salutes':{
		t1:'navCommunity',
		t2:'t2profilehome',
		leftbox:'lbprofile',
		t3:'t3activity',
		t4:''
	},
	
	'associations':{
		t1:'navCommunity',
		t2:'t2profilehome',
		leftbox:'lbprofile',
		t3:'t3bio',
		t4:''
	},

	"Private":{
		t1:'navCommunity',
		t2:'',
		t3:'',
		t4:'',
		leftbox:''
	},
	
	
	loaded:false,
	timerint:0,
	doload:function(){

		if(nav.loaded == false){
		
			//set window load event to re-trigger loading if it failed the first time
			window.attachEvent ? window.attachEvent("onload", nav.doload) : window.addEventListener("load", nav.doload, false);
	
			navdisplaystart = new Date().getTime();

			nav.timerint = setInterval(function(){

				nav.loaded = true;

				//loop through nav object
				for(i in nav[pageid]){

					//check if tier value is defined & check if element exists
					if(nav[pageid][i] != ''){

						//check if element exists
						if( document.getElementById(nav[pageid][i]) != null ){

							a = document.getElementById( nav[pageid][i] );

							if(i == 't1' || i == 't3' || i == 'leftbox'){
								if(!nav.checkClass(a, 'selected')){ a.className += ' selected'; }
							}
							if(i == 't2' || i == 't4'){
								if(!nav.checkClass(a, 'subselect')){ a.className += ' subselect'; }
							}
							if(i == 'hide'){ //hide elements defined in config
								for(s in nav[pageid][i]){
									a.style.display = 'none';
								}
							}

						}else{
							navdisplayendtime = new Date().getTime();
							if( (navdisplayendtime - navdisplaystart) < 2500){
								nav.loaded = false;
							}else{
								nav.loaded = true;
							}
						}

					}

				}

				if(nav.loaded == true){
					clearInterval(nav.timerint);
				}

			},30); 
			
		}

	},
	
	//check if the given class passed as 'b' exists on the given element passed as 'a'
	checkClass:function(a,b){
		if(a != null && a.attributes['class'] != undefined){//element exists
			arr = a.attributes['class'].nodeValue.split(' '); //build array of class names
			exists = false; //check if target class name exists on element
			for(i in arr){ arr[i] == b ? exists = true:''; }
			if(exists == true){ return true; } else { return false; }
		}else{ return false; }
	}
	
}
nav.doload();




jQuery(document).ready(function(){
	
	//IE6 fixes
	if(jQuery.browser.msie && jQuery.browser.version < 7){
		//hover
		jQuery('.hover').hover( 
			function(){ jQuery(this).addClass('hovering');jQuery(this).hasClass('selected') ? jQuery(this).addClass('selectedhovering'):'';}, 
			function(){ jQuery(this).removeClass('hovering'); jQuery(this).hasClass('selectedhovering')? jQuery(this).removeClass('selectedhovering'):'';
		});

		//:first-child
		jQuery('#nav li:first-child').addClass('firstchild');
	}
	
	
	//handle search bar behavior
	jQuery('#search>li').click(function(){
		jQuery('#search .selected').removeClass('selected');
		jQuery(this).addClass('selected');
	});
	jQuery('.searchkeyword, .searchzip, .searchfirstname, .searchlastname').focus(function(){
		if( jQuery(this).val() == 'First Name' || jQuery(this).val() == 'Last Name' || jQuery(this).val() == 'Keywords' || jQuery(this).val() == 'Zip Code'	){ jQuery(this).val(''); }
	});
	jQuery('.searchkeyword, .searchzip, .searchfirstname, .searchlastname').blur(function(){
		if( jQuery(this).attr('class') === 'searchkeyword' && jQuery(this).val() === '' ){ jQuery(this).val('Keywords'); }
		if( jQuery(this).attr('class') === 'searchzip' && jQuery(this).val() === '' ){ jQuery(this).val('Zip Code'); }
		if( jQuery(this).attr('class') === 'searchfirstname' && jQuery(this).val() === '' ){ jQuery(this).val('First Name'); }
		if( jQuery(this).attr('class') === 'searchlastname' && jQuery(this).val() === '' ){ jQuery(this).val('Last Name'); }
	});
	jQuery('.searchsubmit').click(function(){
		jQuery(this).siblings().each(function(){
			a = {'searchfirstname':'First Name','searchlastname':'Last Name','searchkeyword':'Keywords','searchzip':'Zip Code'};
			if( jQuery(this).attr('class') in a && a[jQuery(this).attr('class')] == jQuery(this).val() ){ jQuery(this).val(''); }
		});
	});
});



