// 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) == 'Mac' && (navigator.appName == "Microsoft Internet Explorer"))
	{
	// do nothing - the default is fine
	}
else
	{
		// load some additional style sheet items
		document.write('<link rel="stylesheet" href="/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,">","",null,null,null,"0");
//}
//Overwrite breadcrumbs function
//removed "" from function call
//to allow for non-.html index pages
function anlBreadCrumbs(baseURL){
	breadCrumbs(baseURL,">");
}

//function simplified by Jonas Downey
//initial improvements: march 14 2008
//revised with absolute linking: sep 11 2008
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='';
	for (i=3;i<(subs.length-1);i++) 
	{
		//build up the path variable for each successive folder
		path=path+'/'+subs[i];
		subs[i]=makeCaps(unescape(subs[i]));
		
		//create absolute links using base path
		document.write('<a href="'+base+path+'">'+subs[i]+'</a>  '+delStr+' ');

		//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)
{
		// Check to see if a restriction is applied to the search
		if(f.q.value == "" || f.q.value == "Search APS ...")
		{
				alert("Please enter your search terms.");
				f.q.focus();
				return false;
		}
		return true;
}
