var path = window.location.pathname;
var folderLevel = path.split("/")

function globalNav(){
    var t=this;
    var nav = document.getElementById('nav');
	
	sectionBanner();
	
	if (nav != null){
		var anchs = nav.getElementsByTagName("a");
		var criteria;
		for(i=0;i<anchs.length;i++){
			if (anchs[i].href.indexOf(folderLevel[1]) >= 0){
				//FOLDER LEVEL WHYDEVRY HAS THREE LINKS ASSOCIATED WITH THE FOLDER LEVEL
				//	-WHYDEVRY
				//	-ONLINE OPTIONS
				//	-CAREER SERVICES					
				if (folderLevel[1] == "whydevry"){
					//ONLINE OPTIONS AND CAREER SERVICES ARE PART OF WHYDEVRY
					//THEREFORE WE NEED TO DESTINGUISH BETWEEN THE THREE LINKS
					//AND DECIDE WHICH LINK TO HIGHLIGHT
					if(anchs[i].href.indexOf("online") == -1 && folderLevel[2].indexOf("online") == -1 && anchs[i].href.indexOf("career") == -1 && folderLevel[2].indexOf("career") == -1){
						anchs[i].className='active';//HIGHLIGHT WHYDEVRY
					}
					else if (anchs[i].href.indexOf("online") >= 0 && folderLevel[2].indexOf("online") >= 0){ 
						anchs[i].className='active';//HIGHLIGHT ONLINE
					}else if (anchs[i].href.indexOf("career") >= 0 && folderLevel[2].indexOf("career") >= 0){ 
						anchs[i].className='active';//HIGHLIGHT CAREER SERVICES
					}
				}else {		
					anchs[i].className='active';
				}
			}
		}
	
		if (folderLevel[1] == "programs"){
			setProgramNav();
		}else{
			setSubsection();
		}
	}
}


function setSubsection(){
	var sectNav = document.getElementById('section_nav');
	if (sectNav != null){
		var anchs = sectNav.getElementsByTagName("a");		
		for(var x=0;x<anchs.length;x++){
			if(anchs[x].href.indexOf(path) >= 0){			
				anchs[x].className='active';				
				//ADMISSIONS HAS EXTRA CODE TO COLLAPSE AND EXPAND SECTIONS BY DETERMING
				//WHERE THE USER IS IN THE NAV THE SECTION NEEDS TO BE EXPANDED				
				if (folderLevel[1] == "admissions"){					
					var subLevel = anchs[x].parentNode.parentNode.getAttribute('id');					
					if (subLevel != "" && subLevel != null){						
						if (anchs[x].nextSibling != null && anchs[x].nextSibling.nextSibling != null && anchs[x].nextSibling.nextSibling.getAttribute('id') != null){
							if (anchs[x].nextSibling.nextSibling.getAttribute('id').indexOf('sub') >= 0){							
								SwitchMenu(anchs[x].nextSibling.nextSibling.getAttribute('id'));	
							}
						}
						else{
							SwitchMenu(subLevel);
						}
					}					
				}
				break;	
			}
		}
	}
}

function setProgramNav(){
	var programNav = document.getElementById('colleges_nav'); // Added this line for the quick wins update
	var programAnchs = programNav.getElementsByTagName("a");
	var criteria;
	var programPos;
	var delimitedFolderLevel = "/" + folderLevel[2] + "/"; 
	/*if (programNav != null){
		for(var i=0; i<programAnchs.length; i++){
			if (programAnchs[i].href.indexOf(delimitedFolderLevel) >= 0) {
				if (delimitedFolderLevel == "/technical_management/"){					
					//ABOUT CRIMINAL JUSTICE AND ABOUT HEALTH MANAGEMENT IS LOCATED IN THE TECHNICAL MANAGEMENT FOLDER
					//THEREFORE DESTINGUISHING BETWEEN THE THREE LINKS IS NEEDED TO DECIDE WHICH ONE TO HIGHLIGHT					
					
					if (programAnchs[i].href.indexOf("about-criminal") == -1 && folderLevel[3] != "about-criminal-justice.jsp" && programAnchs[i].href.indexOf("about-health") == -1 && folderLevel[3] != "about-health-information-management.jsp"){
						programAnchs[i].className='active';
						break;
					}else if (programAnchs[i].href.indexOf("about-criminal") >= 0 && folderLevel[3] == "about-criminal-justice.jsp"){
						programAnchs[i].className='active';
						break;
					}else if (programAnchs[i].href.indexOf("about-health") >= 0 && folderLevel[3] == "about-health-information-management.jsp"){
						programAnchs[i].className='active';
						break;
					}
					
				}else {
					programAnchs[i].className='active';
					break;
				}			
			}
		}
	}*/
	
	var tabNav = document.getElementById('tab_nav');
	if (tabNav != null){
		var tabAnchs = tabNav.getElementsByTagName("a");
				
		if (folderLevel[3].indexOf("about") >= 0){
			criteria = "about";	
		}else if (folderLevel[3].indexOf("career") >= 0){
			criteria = "career";
		}else if (folderLevel[3].indexOf("objectives") >= 0){
			criteria = "objectives";
		}else if (folderLevel[3].indexOf("courses") >= 0){
			criteria = "courses";
		}
		
		for(var x=0;x<tabAnchs.length;x++){
			if(tabAnchs[x].href.indexOf(criteria) >= 0){
				tabAnchs[x].className='active';
				break;
			}
		}
	}
}

function sectionBanner() {
	var sectionName = "";
	
	sectionName = folderLevel[1];
	
	if (path.indexOf("online_options") >= 0){
		sectionName = "online";
	}else if(path.indexOf("career-services") >= 0){
		sectionName = "career";
	}else if(path.indexOf("/faculty/") >= 0){
		sectionName = "faculty";
	}
	
	switch(sectionName){
		case "admissions":
			var bannerAdmissionsImages = new Array("/resources/images/bnr_admissions_0.gif", "/resources/images/bnr_admissions_1.gif", "/resources/images/bnr_admissions_2.gif");
			bannerSwap(bannerAdmissionsImages, "bnrStudent");
			break;
		case "programs":
			var bannerProgramsImages = new Array("/resources/images/bnr_programs_0.gif", "/resources/images/bnr_programs_3.gif", "/resources/images/bnr_programs_4.gif");
			bannerSwap(bannerProgramsImages, "bnrStudent");
			break;
		case "tuition":
			var bannerTuitionImages = new Array("/resources/images/bnr_financial_0.gif", "/resources/images/bnr_financial_2.gif");
			bannerSwap(bannerTuitionImages, "bnrStudent");
			break;
		case "locations":
			var bannerLocationsImages = new Array("/resources/images/bnr_locations_0.gif", "/resources/images/bnr_locations_1.gif", "/resources/images/bnr_locations_2.gif", "/resources/images/bnr_locations_3.gif");
			bannerSwap(bannerLocationsImages, "bnrStudent");
			break;
		case "whydevry":
			var bannerWhydevryImages = new Array("/resources/images/bnr_whydevry_0.gif", "/resources/images/bnr_whydevry_1.gif", "/resources/images/bnr_whydevry_2.gif", "/resources/images/bnr_whydevry_3.gif");
			bannerSwap(bannerWhydevryImages, "bnrStudent");
			break;
		case "online":
			var bannerOnlineImages = new Array("/resources/images/bnr_online_0.gif", "/resources/images/bnr_online_2.gif", "/resources/images/bnr_online_3.gif");
			bannerSwap(bannerOnlineImages, "bnrStudent");
			break;
		case "career":
			var bannerCareerImages = new Array("/resources/images/bnr_career_0.gif", "/resources/images/bnr_career_1.gif", "/resources/images/bnr_career_2.gif");
			bannerSwap(bannerCareerImages, "bnrStudent");
			break;
		case "faculty":
			var bannerFacultyImages = new Array("/resources/images/bnr_faculty_0.gif");
			bannerSwap(bannerFacultyImages, "bnrStudent");
			break;			
		//default:
			//var bannerImages = new Array("/resources/images/bnr_home_0.jpg", "/resources/images/bnr_home_1.jpg", "/resources/images/bnr_home_2.jpg", "/resources/images/bnr_home_3.jpg");
			//bannerSwap(bannerImages, "bnrStudent");
	}	
}

function newWin(which){
	nuWin = window.open(which,"definition","WIDTH=680, left=70,menubar=0,resizable=0,scrollbars=1");
	nuWin.focus(which);
}

function newWin1(which, iWidth, iHeight){
	if (!iWidth){
   		iWidth = 700;
	}
	if (!iHeight){
		iHeight = 500;
	}	

   nuWin = window.open(which,"definition"," WIDTH=" + iWidth + ", height=" + iHeight + ", left=50, top=50,menubar=0,resizable=0,scrollbars=1");
   nuWin.focus(which);
}

function newWin0(which, iWidth, iHeight){
	if (!iWidth){
   		iWidth = 700;
	}
	if (!iHeight){
		iHeight = 500;
	}	

   nuWin = window.open(which,"definition"," WIDTH=" + iWidth + ", height=" + iHeight + ", left=50, top=50,,menubar=0,resizable=1,scrollbars=1");   
   nuWin.focus(which);

}

function newWindemo(which, iWidth, iHeight){
	if (!iWidth){
   		iWidth = 980;
	}
	if (!iHeight){
		iHeight = 620;
	}	
   nuWin = window.open(which,"definition"," WIDTH=" + iWidth + ", height=" + iHeight + ", left=50, top=50,,menubar=0,resizable=0,scrollbars=1");
   nuWin.focus(which);
}

function newWin3(which){
   nuWin = window.open(which,"definition", "left=50, top=50,menubar=0,resizable=1,scrollbars=1,status=1,location=0,toolbar=0");
   nuWin.focus(which);
}

function newWinTestimonials(which, iWidth, iHeight){
	if (!iWidth){
   		iWidth = 700;
	}
	if (!iHeight){
		iHeight = 500;
	}	
   nuWin = window.open(which,"definition"," WIDTH=" + iWidth + ", height=" + iHeight + ",left=50,top=50,menubar=0,resizable=0,scrollbars=0");
   nuWin.focus(which);
}