// 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(string baseURL)
//
// Last Modified: 08/17/2004
// Modified by: D. M. Stasiak (CIS)
//
// Public function for creating breadcrumbs, all defaults for delimiter and styles
// are set in this function.  End-users only need to specify the base URL for their
// site, without the trailing slash (/)
function anlBreadCrumbs(baseURL){
	breadCrumbs(baseURL,">","index.html",null,null,null,"0");
}

// Breadcrumbs code from KaosWeaver Dreamweaver Extension
// Modified slightly to remove the base breadcrumb 
// and to remove the title from the breadcrumb stream
function breadCrumbs(base,delStr,defp,cStyle,tStyle,dStyle,nl) { // by Paul Davis - http://www.kaosweaver.com
	loc=window.location.toString();
	subs=loc.substr(loc.indexOf(base)+base.length+1).split("/");
	//document.write('<a href="'+getLoc(subs.length-1)+defp+'" class="'+cStyle+'">Argonne Home</a>  '+'<span class="'+dStyle+'">'+delStr+'</span> ');
	a=(loc.indexOf(defp)==-1)?1:2;
	for (i=0;i<(subs.length-a);i++) 
	{
		subs[i]=makeCaps(unescape(subs[i]));
		document.write('<a href="userprogram/docs/px_software.pdf" class="'+cStyle+'">'+subs[i]+'</a>  '+'<span class="'+dStyle+'">'+delStr+'</span> ');
	}
	if (nl==1) document.write("<br>");
	//document.write('<span class="'+tStyle+'">'+document.title+'</span>');
}
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+"../"; return d;
}

//
// Search functions
function checkSearchForm(f)
{
		// Check to see if a restriction is applied to the search
		if(f.q.value == "" || f.q.value == "Search Argonne ...")
		{
				alert("Please enter your search terms.");
				f.q.focus();
				return false;
		}
		return true;
}