// Default JavaScript file for the Main ANL website
// 06/14/2004
// Author: Dana M. Stasiak (CIS)
//
// Code for swapping stylesheets
// Load the alternate stylesheet based on platform
var p = navigator.platform;
if(p.substring(0,3) == 'Win')
{
	// load some additional style sheet items
	document.write('<link rel="stylesheet" href="https://www.anl.gov/anl_templates/stylesheets/anl_default.css" type="text/css">');
}
else if (p.substring(0,3) == 'Mac')
{
	if(navigator.appName == "Microsoft Internet Explorer")
	{
		// do nothing - the default is fine
	}
	else
	{
		// load some additional style sheet items
		document.write('<link rel="stylesheet" href="https://www.anl.gov/anl_templates/stylesheets/anl_default.css" type="text/css">');
	}
}
else
{
	// load some additional style sheet items
	document.write('<link rel="stylesheet" href="https://www.anl.gov/anl_templates/stylesheets/anl_default.css" type="text/css">');
}

function anlBreadCrumbs(baseURL){
	breadCrumbs(baseURL,">");
}
//function simplified by Jonas Downey 3/14/08
//wordmap functionality added 6/12/08
function breadCrumbs(base,delStr) {
	//grab current URL
	loc=window.location.toString();
	//split into array
	subs = loc.split("/");
	//print the crumbs
	//note: the first four entries in the subs array are contents pulled from 'http://www.domain.com',
	//so we start with i=3. the last entry is 'filename.html' and should not be printed, 
	//so we opt for subs.length-1.
	var path='';
	var wordmap=new Array();
	wordmap['users']="For Users";
	wordmap['news']="News &amp; Highlights";

	for (i=3;i<(subs.length-1);i++) 
	{
		//build up the path variable for each successive folder
		path=path+'/'+subs[i];
		
		for(var v in wordmap){
			if(subs[i]==v)
				subs[i]=wordmap[v];
		}
		subs[i]=makeCaps(unescape(subs[i]));

		//create absolute links using base path
		document.write('<a href="'+base+path+'">'+subs[i]+'</a>  '+delStr+' ');

		//old relative link option
		//document.write('<a href="'+getLoc(subs.length-i-2)+'">'+subs[i]+'</a>  '+delStr+' ');
	}

}
function makeCaps(a) {
  g=a.split(' ');for (l=0;l<g.length;l++) g[l]=g[l].toUpperCase().slice(0,1)+g[l].slice(1);
  return g.join(" ");
}
function getLoc(c) {
  var d="";if (c>0) for (k=0;k<c;k++) d=d+"../";else d="./"; return d;
}

//
// Search functions
function checkSearchForm(f)
{
	if(f.q.value != "Search Argonne ...")
	{
		return true;
	}
	else
	{
		alert("Please enter a search term.");
		f.q.focus();
	}
	return false;
}