// JavaScript Document

myacronyms = new Array ('e_and_is', 'E&IS'
												
												,'about', 'About Us'
												,'antennas', 'Antenna Systems' 
												,'archives_nes', 'Archives NES'
												,'archives_nss', 'Archives NSS'
												,'as_and_t', 'AS&T'
												,'ads', 'ADS'
												,'ale-47','ALE-47'
												,'ast', 'Advanced Systems & Technology'
												,'atsp3', 'Advanced Technology Support Program 3'
												,'bios', 'Biographies'
												,'cdt','CDT'
												, 'cft', 'Integrated C4ISR'
												,'chemsentry','ChemSentry'
												,'cmo', 'Commodity Management Organization'
												,'cms', 'Contract Manufacturing Services'
												,'cnir', 'CNIR'
												,'dataconv','Data Converter Unit'
												,'e-commerceconnections', 'e-Commerce Connections'
												,'eldp', 'Engineering Leadership Development Program'
												,'oldp', 'Operations Leadership Development Program'
												,'eisjobs', 'E&IS Jobs'
												,'eng_career', 'Engineering Career Day'
												,'ep', 'Electronic Warfare'
												,'elec_laser_subsys', 'Electronic & Laser Subsystems'
												,'esps', 'Electronic Systems Product Support'
												,'firstintercomm', 'First InterComm System'
												,'fldp', 'Financial Leadership Development Program'
												,'gstamids','GSTAMIDS'
												,'hazsentry','HazSentry'
												,'hoss','HOSS'
												,'hrldp', 'Human Resources Leadership Development Program'
												,'ids', 'Information Dominance Systems'
												,'ihud','IHUD'
												,'iris', 'Infrared Imaging Systems'
												,'iw', 'Information Warfare'
												,'laserwarning','Laser Warning Systems'
												,'mw_ir', 'Microwave and Infrared Electronics Group'
												,'mongoose','Mongoose'
												,'monohud','MonoHUD'
												,'mots','MOTS'
												,'ns','NS'
  											  ,'nss', 'National Security Solutions'
												,'products', 'Products & Services'
												,'purchaseorder', 'Purchase Order'
												,'radardisp','Radar Display Systems'
												,'sas','SAS'
												,'si', 'Sensor Integration'
												,'ss', 'Sensor Systems'
												,'s2', 'Sensor Systems'
												,'sse', 'Space Systems and Electronics'
												,'supplierlink', 'Supplier Link'
												,'tamis','TAMIS'
                                                ,'tmg','TMG'
												,'wit', 'Women in Technology'
												); 



function breadcrumbs(){
	sURL = new String;
  bits = new Object;
	mytitles = new Object;
  var x = 0;
  var stop = 0;
	var titlecheck = 'no';
  var output = " &nbsp; <img src='/images/house.gif' width='13' height='13'> <a href=\"http://www.baesystems.com/\" class='breadcrumb'>BAE SYSTEMS</a> <img src='/images/house.gif' width='13' height='13'> <a href=\"/index.htm\" class='breadcrumb'>E&amp;IS</a> ";
  sURL = location.href;
  sURL = sURL.slice(8,sURL.length);
  chunkStart = sURL.indexOf("/");
  sURL = sURL.slice(chunkStart+1,sURL.length)
  while(!stop){
    chunkStart = sURL.indexOf("/");
    if (chunkStart != -1){
      bits[x] = sURL.slice(0,chunkStart)
			mytitles[x] = cleanup(bits[x]);
			
      sURL = sURL.slice(chunkStart+1,sURL.length);
    }else{
      stop = 1;
    }
    x++;
  }
  for(var i in bits){
    output += "<img src='/images/arrow.gif' width='13' height='13'> <a href=\"";
		//for(y=1;y<x-i;y++){
    for(y=1;y<x-i;y++){
      output += "../";
    }
    output += bits[i] + "/index.htm\" class='breadcrumb'>" + mytitles[i] + "</a> ";
		var homecheck = mytitles[i] + ' Home';
		titlecheck =((mytitles[i]==document.title)||(homecheck==document.title))?'yes':'no';
		if (i==2){break;}
  }
	if (titlecheck=='no'){
		var mydoctitle=avoidrepeat(output);
		//no longer using document titles at the end of the breadcrumbs trail per web meeting 2/14/06
		//if decide to use them again use the line below instead of the one following it
		//document.write(output + "<img src='/images/arrow.gif' width='13' height='13'> " + mydoctitle);}
		document.write(output);}
	else {document.write(output);}
}

//function to cleanup the titles
function cleanup(myoutput){
	myoutput=unescape(myoutput);
	//if (myoutput=="e and is") myoutput="E&IS";
	var checkspecialcase = false;
	for (var i=0;i<myacronyms.length;i++){
		if (myoutput==myacronyms[i]){
		myoutput=myacronyms[i+1];
		checkspecialcase=true;
		break;}
	}
	if (checkspecialcase==false)
	myoutput = capfirstletter(myoutput);
	var re = /_/g;
	myoutput = myoutput.replace(re, " ");
	return myoutput;
	}




// Capitalize the first letter of each word	
function capfirstletter(thisoutput)
{
	var tempoutput = "";
	var letters=new RegExp("[abcdefghijklmnopqrstuvwxyz]");
	var flag=true;
	for (var i=0;i<thisoutput.length;i++){
		curChar=thisoutput.substr(i,1);
		if(letters.exec(curChar)){
			if(flag){
				curChar=curChar.toUpperCase();
				flag=false;
			}
		}
		else {
			flag=true;
		}
		tempoutput+=curChar;
		
	}
	return tempoutput;
}

//function to avoid repeating the directory name in the page title
function avoidrepeat(theoutput)
{
var fulltitle = document.title;
//find out the directory name of the last breadcrumb
var endsearch = theoutput.lastIndexOf('<');
var startsearch = (theoutput.lastIndexOf('>',endsearch) +1);
var whichdir = theoutput.substring(startsearch, endsearch);

if (fulltitle.indexOf(',')){
	var titledir = fulltitle.substring(0,fulltitle.indexOf(','));
	//check if it matches the first part of the document title and if so,
	//remove the redundant portion of the document title
	if (titledir==whichdir){
	var pagetitle = fulltitle.substring((fulltitle.indexOf(',')+1),fulltitle.length);
	return pagetitle;
	}
	else
	return fulltitle;
	
}
else
return fulltitle;	
}
