///////////////////////////////////////////////////////////////////////////////
//////////            START OF NAVIGATION BAR JAVASCRIPT             //////////
///////////////////////////////////////////////////////////////////////////////

// Check browser
browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);
if ( (browserName == "Netscape" && browserVer >= 3) ||
     (browserName == "Microsoft Internet Explorer" && browserVer >= 4) )
   checkbrowser = true;
else
   checkbrowser = false;

// Bools for status of sub menus, so that later function know if
// the desired sub menu is visible.
// These should always be listed as false to start.
news_bool = false;
educ_bool = false;
rese_bool = false;
camp_bool = false;
peop_bool = false;
abou_bool = false;

// Predeclare Images
// Images will only be predeclared in Netscape 3 and above, IE 4 and above.
// The sub-menus and rollovers will not work in other browsers (but should
// not produce javascript errors either).
if (checkbrowser) {

// NEWS images:
news_head    = new Image ();
news_head_on = new Image ();
news_week       = new Image ();
news_week_on    = new Image ();
news_week_red   = new Image ();
news_rele       = new Image ();
news_rele_on    = new Image ();
news_rele_red   = new Image ();
news_cale       = new Image ();
news_cale_on    = new Image ();
news_cale_red   = new Image ();
redline_news    = new Image ();
redline_news_on = new Image ();

	news_head.src       = "/images/navbarimages_8-8/news.gif";
	news_head_on.src    = "/images/navbarimages_8-8/news_red.gif";
	redline_news.src    = "/images/spacer1w.gif";
	redline_news_on.src = "/images/navbarimages_8-8/redline_68h.gif";
	news_week.src       = "/images/spacer1w.gif";
    	news_week_on.src    = "/images/navbarimages_8-8/news_week.gif";
	news_week_red.src   = "/images/navbarimages_8-8/news_week_red.gif";
	news_rele.src       = "/images/spacer1w.gif";
	news_rele_on.src    = "/images/navbarimages_8-8/news_rele.gif";
	news_rele_red.src   = "/images/navbarimages_8-8/news_rele_red.gif";
	news_cale.src       = "/images/spacer1w.gif";
	news_cale_on.src    = "/images/navbarimages_8-8/news_cale.gif";
	news_cale_red.src   = "/images/navbarimages_8-8/news_cale_red.gif";

educ_head    = new Image ();
educ_head_on = new Image ();
educ_admi       = new Image ();
educ_admi_on    = new Image ();
educ_admi_red   = new Image ();
educ_grad       = new Image ();
educ_grad_on    = new Image ();
educ_grad_red   = new Image ();
educ_unde       = new Image ();
educ_unde_on    = new Image ();
educ_unde_red   = new Image ();
educ_cour       = new Image ();
educ_cour_on    = new Image ();
educ_cour_red   = new Image ();
redline_educ    = new Image ();
redline_educ_on = new Image ();

	educ_head.src       = "/images/navbarimages_8-8/educ.gif";
	educ_head_on.src    = "/images/navbarimages_8-8/educ_red.gif";
	redline_educ.src    = "/images/spacer1w.gif";
	redline_educ_on.src = "/images/navbarimages_8-8/redline_68h.gif";
	educ_admi.src       = "/images/spacer1w.gif";
	educ_admi_on.src    = "/images/navbarimages_8-8/educ_admi.gif";
	educ_admi_red.src   = "/images/navbarimages_8-8/educ_admi_red.gif";
	educ_grad.src       = "/images/spacer1w.gif";
	educ_grad_on.src    = "/images/navbarimages_8-8/educ_grad.gif";
	educ_grad_red.src   = "/images/navbarimages_8-8/educ_grad_red.gif";
	educ_unde.src       = "/images/spacer1w.gif";
	educ_unde_on.src    = "/images/navbarimages_8-8/educ_unde.gif";
	educ_unde_red.src   = "/images/navbarimages_8-8/educ_unde_red.gif";
	educ_cour.src       = "/images/spacer1w.gif";
	educ_cour_on.src    = "/images/navbarimages_8-8/educ_cour.gif";
	educ_cour_red.src   = "/images/navbarimages_8-8/educ_cour_red.gif";

rese_head    = new Image ();
rese_head_on = new Image ();
rese_area       = new Image ();
rese_area_on    = new Image ();
rese_area_red   = new Image ();
rese_publ       = new Image ();
rese_publ_on    = new Image ();
rese_publ_red   = new Image ();
rese_spon       = new Image ();
rese_spon_on    = new Image ();
rese_spon_red   = new Image ();
rese_spin       = new Image ();
rese_spin_on    = new Image ();
rese_spin_red   = new Image ();
redline_rese    = new Image ();
redline_rese_on = new Image ();

	rese_head.src       = "/images/navbarimages_8-8/rese.gif";
	rese_head_on.src    = "/images/navbarimages_8-8/rese_red.gif";
	redline_rese.src    = "/images/spacer1w.gif";
	redline_rese_on.src = "/images/navbarimages_8-8/redline_68h.gif";
	rese_area.src       = "/images/spacer1w.gif";
	rese_area_on.src    = "/images/navbarimages_8-8/rese_area.gif";
	rese_area_red.src   = "/images/navbarimages_8-8/rese_area_red.gif";
	rese_publ.src       = "/images/spacer1w.gif";
	rese_publ_on.src    = "/images/navbarimages_8-8/rese_publ.gif";
	rese_publ_red.src   = "/images/navbarimages_8-8/rese_publ_red.gif";
	rese_spon.src       = "/images/spacer1w.gif";
	rese_spon_on.src    = "/images/navbarimages_8-8/rese_spon.gif";
	rese_spon_red.src   = "/images/navbarimages_8-8/rese_spon_red.gif";
	rese_spin.src       = "/images/spacer1w.gif";
	rese_spin_on.src    = "/images/navbarimages_8-8/rese_spin.gif";
	rese_spin_red.src   = "/images/navbarimages_8-8/rese_spin_red.gif";

camp_head    = new Image ();
camp_head_on = new Image ();
camp_visi       = new Image ();
camp_visi_on    = new Image ();
camp_visi_red   = new Image ();
camp_camp       = new Image ();
camp_camp_on    = new Image ();
camp_camp_red   = new Image ();
camp_pitt       = new Image ();
camp_pitt_on    = new Image ();
camp_pitt_red   = new Image ();
camp_faci       = new Image ();
camp_faci_on    = new Image ();
camp_faci_red   = new Image ();
redline_camp    = new Image ();
redline_camp_on = new Image ();

	camp_head.src       = "/images/navbarimages_8-8/camp.gif";
	camp_head_on.src    = "/images/navbarimages_8-8/camp_red.gif";
	redline_camp.src    = "/images/spacer1w.gif";
	redline_camp_on.src = "/images/navbarimages_8-8/redline_68h.gif";
	camp_visi.src       = "/images/spacer1w.gif";
	camp_visi_on.src    = "/images/navbarimages_8-8/camp_visi.gif";
	camp_visi_red.src   = "/images/navbarimages_8-8/camp_visi_red.gif";
	camp_camp.src       = "/images/spacer1w.gif";
	camp_camp_on.src    = "/images/navbarimages_8-8/camp_camp.gif";
	camp_camp_red.src   = "/images/navbarimages_8-8/camp_camp_red.gif";
	camp_pitt.src       = "/images/spacer1w.gif";
	camp_pitt_on.src    = "/images/navbarimages_8-8/camp_pitt.gif";
	camp_pitt_red.src   = "/images/navbarimages_8-8/camp_pitt_red.gif";
	camp_faci.src       = "/images/spacer1w.gif";
	camp_faci_on.src    = "/images/navbarimages_8-8/camp_faci.gif";
	camp_faci_red.src   = "/images/navbarimages_8-8/camp_faci_red.gif";

peop_head    = new Image ();
peop_head_on = new Image ();
peop_dire       = new Image ();
peop_dire_on    = new Image ();
peop_dire_red   = new Image ();
peop_whos       = new Image ();
peop_whos_on    = new Image ();
peop_whos_red   = new Image ();
peop_alum       = new Image ();
peop_alum_on    = new Image ();
peop_alum_red   = new Image ();
peop_achi       = new Image ();
peop_achi_on    = new Image ();
peop_achi_red   = new Image ();
redline_peop    = new Image ();
redline_peop_on = new Image ();

	peop_head.src       = "/images/navbarimages_8-8/peop.gif";
	peop_head_on.src    = "/images/navbarimages_8-8/peop_red.gif";
	redline_peop.src    = "/images/spacer1w.gif";
	redline_peop_on.src = "/images/navbarimages_8-8/redline_68h.gif";
	peop_dire.src       = "/images/spacer1w.gif";
	peop_dire_on.src    = "/images/navbarimages_8-8/peop_dire.gif";
	peop_dire_red.src   = "/images/navbarimages_8-8/peop_dire_red.gif";
	peop_whos.src       = "/images/spacer1w.gif";
	peop_whos_on.src    = "/images/navbarimages_8-8/peop_whos.gif";
	peop_whos_red.src   = "/images/navbarimages_8-8/peop_whos_red.gif";
	peop_alum.src       = "/images/spacer1w.gif";
	peop_alum_on.src    = "/images/navbarimages_8-8/peop_alum.gif";
	peop_alum_red.src   = "/images/navbarimages_8-8/peop_alum_red.gif";
	peop_achi.src       = "/images/spacer1w.gif";
	peop_achi_on.src    = "/images/navbarimages_8-8/peop_achi.gif";
	peop_achi_red.src   = "/images/navbarimages_8-8/peop_achi_red.gif";

abou_head    = new Image ();
abou_head_on = new Image ();
abou_divi       = new Image ();
abou_divi_on    = new Image ();
abou_divi_red   = new Image ();
abou_miss       = new Image ();
abou_miss_on    = new Image ();
abou_miss_red   = new Image ();
abou_stat       = new Image ();
abou_stat_on    = new Image ();
abou_stat_red   = new Image ();
abou_deve       = new Image ();
abou_deve_on    = new Image ();
abou_deve_red   = new Image ();
redline_abou    = new Image ();
redline_abou_on = new Image ();

	abou_head.src       = "/images/navbarimages_8-8/abou.gif";
	abou_head_on.src    = "/images/navbarimages_8-8/abou_red.gif";
	redline_abou.src    = "/images/spacer1w.gif";
	redline_abou_on.src = "/images/navbarimages_8-8/redline_68h.gif";
	abou_divi.src       = "/images/spacer1w.gif";
	abou_divi_on.src    = "/images/navbarimages_8-8/abou_divi.gif";
	abou_divi_red.src   = "/images/navbarimages_8-8/abou_divi_red.gif";
	abou_miss.src       = "/images/spacer1w.gif";
	abou_miss_on.src    = "/images/navbarimages_8-8/abou_miss.gif";
	abou_miss_red.src   = "/images/navbarimages_8-8/abou_miss_red.gif";
	abou_stat.src       = "/images/spacer1w.gif";
	abou_stat_on.src    = "/images/navbarimages_8-8/abou_stat.gif";
	abou_stat_red.src   = "/images/navbarimages_8-8/abou_stat_red.gif";
	abou_deve.src       = "/images/spacer1w.gif";
	abou_deve_on.src    = "/images/navbarimages_8-8/abou_deve.gif";
	abou_deve_red.src   = "/images/navbarimages_8-8/abou_deve_red.gif";

}  // end bracket for preloading images inside the "if (checkbrowser) {" statement

// Function for Rollover
function changeImage(img,act) {
  if (document.images && checkbrowser) {
    if (act) { document [img].src = eval(img+'_on.src'); }
    else { document [img].src = eval(img+'.src'); }
  }
}

function changeMENU(menu)
{
	if (menu=='NEWS')      {news_bool=true;educ_bool=false;rese_bool=false;peop_bool=false;camp_bool=false;abou_bool=false;}
	else if (menu=='EDUC') {news_bool=false;educ_bool=true;rese_bool=false;peop_bool=false;camp_bool=false;abou_bool=false;}
	else if (menu=='RESE') {news_bool=false;educ_bool=false;rese_bool=true;peop_bool=false;camp_bool=false;abou_bool=false;}
	else if (menu=='CAMP') {news_bool=false;educ_bool=false;rese_bool=false;peop_bool=false;camp_bool=true;abou_bool=false;}
	else if (menu=='PEOP') {news_bool=false;educ_bool=false;rese_bool=false;peop_bool=true;camp_bool=false;abou_bool=false;}
	else if (menu=='ABOU') {news_bool=false;educ_bool=false;rese_bool=false;peop_bool=false;camp_bool=false;abou_bool=true;}

	changeImage('redline_news',news_bool);changeImage('news_head',news_bool);                                   changeImage('news_week',news_bool);changeImage('news_rele',news_bool);changeImage('news_cale',news_bool);
	changeImage('redline_educ',educ_bool);changeImage('educ_head',educ_bool);changeImage('educ_admi',educ_bool);changeImage('educ_grad',educ_bool);changeImage('educ_unde',educ_bool);changeImage('educ_cour',educ_bool);
	changeImage('redline_rese',rese_bool);changeImage('rese_head',rese_bool);changeImage('rese_area',rese_bool);changeImage('rese_publ',rese_bool);changeImage('rese_spon',rese_bool);changeImage('rese_spin',rese_bool);
	changeImage('redline_camp',camp_bool);changeImage('camp_head',camp_bool);changeImage('camp_visi',camp_bool);changeImage('camp_camp',camp_bool);changeImage('camp_pitt',camp_bool);changeImage('camp_faci',camp_bool);
	changeImage('redline_peop',peop_bool);changeImage('peop_head',peop_bool);changeImage('peop_dire',peop_bool);changeImage('peop_whos',peop_bool);changeImage('peop_alum',peop_bool);changeImage('peop_achi',peop_bool);
	changeImage('redline_abou',abou_bool);changeImage('abou_head',abou_bool);changeImage('abou_divi',abou_bool);changeImage('abou_miss',abou_bool);changeImage('abou_stat',abou_bool);changeImage('abou_deve',abou_bool);
}

function changeToRed(img, is_on_bool, any_page) {
  if (document.images && checkbrowser && is_on_bool)
    { document [img].src = eval(img+'_red.src'); }
}
function changeToBlack(img, is_on_bool, any_page) {
  if (document.images && checkbrowser && is_on_bool)
    { document [img].src = eval(img+'_on.src'); }
}

function changeURL(subMenu, menuChoice, is_on_bool) {
	//Sub-Menus
	if (subMenu == 'NEWS' && is_on_bool) { //NEWS
		if      (menuChoice == 'week') {window.location.href = "http://dev.web.cs.cmu.edu:6666/news/scstoday/autoscripts/scstoday";}
		else if (menuChoice == 'rele') {window.location.href = "http://dev.web.cs.cmu.edu:6666/news/releases/autoscripts/releases";}
		else if (menuChoice == 'cale') {window.location.href = "http://dev.web.cs.cmu.edu:6666/news/calendar/autoscripts/calendar";}
	} else if (subMenu == 'EDUC' && is_on_bool) { //EDUCATION
		if      (menuChoice == 'admi') {window.location.href = "http://www.cs.cmu.edu/education/admissions/index.html";}
		else if (menuChoice == 'grad') {window.location.href = "http://www.cs.cmu.edu/education/graduate.html";}
		else if (menuChoice == 'unde') {window.location.href = "http://www.cs.cmu.edu/education/undergraduate.html";}
		else if (menuChoice == 'cour') {window.location.href = "http://www.cs.cmu.edu/education/courses.html";}
	} else if (subMenu == 'RESE' && is_on_bool) { //RESEARCH
		if      (menuChoice == 'area') {window.location.href = "http://www.cs.cmu.edu/research/areas.html";}
        	else if (menuChoice == 'publ') {window.location.href = "http://www.cs.cmu.edu/publications/index.html";}
		else if (menuChoice == 'spon') {window.location.href = "http://www.cs.cmu.edu/research/sponsors.html";}
		else if (menuChoice == 'spin') {window.location.href = "http://www.cs.cmu.edu/research/spinoffs.html";}
	} else if (subMenu == 'CAMP' && is_on_bool) { //PUBLICATIONS
		if      (menuChoice == 'visi') {window.location.href = "http://www.cs.cmu.edu/campus/visiting.html";}
		else if (menuChoice == 'camp') {window.location.href = "http://www.cs.cmu.edu/campus/campuslife.html";}
		else if (menuChoice == 'pitt') {window.location.href = "http://www.cs.cmu.edu/campus/pittsburgh.html";}
		else if (menuChoice == 'faci') {window.location.href = "http://www.cs.cmu.edu/campus/facilities.html";}
	} else if (subMenu == 'PEOP' && is_on_bool) { //PEOPLE
		if      (menuChoice == 'dire') {window.location.href = "http://www.cs.cmu.edu/people/directory/";}
        	else if (menuChoice == 'whos') {window.location.href = "http://www.cs.cmu.edu/people/who.html";}
		else if (menuChoice == 'alum') {window.location.href = "http://www.cs.cmu.edu/people/alumni/index.html";}
		else if (menuChoice == 'achi') {window.location.href = "http://www.cs.cmu.edu/people/achievements.html";}
	} else if (subMenu == 'ABOU' && is_on_bool) { //ABOUT SCS
		if      (menuChoice == 'divi') {window.location.href = "http://www.cs.cmu.edu/aboutscs/divisions.html";}
		else if (menuChoice == 'miss') {window.location.href = "http://www.cs.cmu.edu/aboutscs/mission.html";}
		else if (menuChoice == 'stat') {window.location.href = "http://www.cs.cmu.edu/aboutscs/statistics.html";}
		else if (menuChoice == 'deve') {window.location.href = "http://www.cs.cmu.edu/aboutscs/development/index.html";}
	}
}

///////////////////////////////////////////////////////////////////////////////
//////////             END OF NAVIGATION BAR JAVASCRIPT              //////////
///////////////////////////////////////////////////////////////////////////////
