
// ***************************************
// Horizontal Links Navigation Javascript
// Usage: In the head of your document put: <script language="JavaScript" SRC="../ca/JS_HorizontalLinksNav.js"></script>
//        In the body of your document put: <SCRIPT Language="JavaScript">HNav()</script>
//      * Change the BaseURL1 to your base URL.
//      * Though not necessary, if using a betatest site or two hosts or any form of second host,
//        change the BaseURL2 to that URL. BaseURL2 can be left blank.
//      * This script draws on your folder names. Good names = good navigation. Bad names = bad navigation.
//      * In lieu of spaces in folder names, you can use the underscore character.
//      * the var 'IndexFile' is used if you want to use something other than 'index.htm' in your folder
//        structure. For example, 'Home.htm'. If you do use index.htm or index.html (or whatever the
//        server automatically assigns), blank out IndexFile to ''.
// Version: 0.92 30JAN2003
//
// ***************************************


function HNav() {

// Though all variables are here, the only three you'll need to worry about are the first 3,
// HTMLString1, and HTMLString2.
// You can change the look of your navigation text by modifying HTMLString1. HTMLString2 is the character used as a seperator.

var BaseURL1 = "www.rurdev.usda.gov/ca/"
var BaseURL2 = "s89533058.onlinehome.us/ca/"
var IndexFile = "index.htm"

var DocURLRef = document.URL
var DocURL = DocURLRef
var DocURLSplit = ''

var HomeURL = ''
var TextURL = ''
var LinkURL = ''
var LinkURLSpacer = ''
var HTMLString = ''
var HTMLString1 = '<table width="95%" border="0" cellspacing="0" bgcolor="#ffffff" cellpadding="1"><tr><td><table width="100%" border="0" cellspacing="0" bgcolor="#ffffff" cellpadding="2"><tr><td><font size="1" face="Verdana, Arial, Helvetica, sans-serif">  '
var HTMLString2 = ' &gt; '
var HTMLString3 = '</div></td><td align="right"><div align="right"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"></div></td></tr></table></td></tr></table>'

// Check for which URL is used. BaseURL1 is the default.

if (BaseURL1 || BaseURL2 !='') {
	if (DocURL.search(BaseURL1)!= -1){
		DocURL=DocURL.slice(DocURL.indexOf(BaseURL1) + BaseURL1.length)
		HomeURL = DocURLRef.slice(0, DocURLRef.indexOf(BaseURL1) + BaseURL1.length) + 'index.htm'
		}
	if (DocURL.search(BaseURL2)!= -1 && BaseURL2 !='') {
		DocURL=DocURL.slice(DocURL.indexOf(BaseURL2) + BaseURL2.length)
		HomeURL = DocURLRef.slice(0, DocURLRef.indexOf(BaseURL2) + BaseURL2.length) + 'index.htm'
		}
	}



// split you string into an array. Each folder will get it's own array value

DocURLSplit = DocURL.split('/')

// build the relative paths

for (var i=0; i<(DocURLSplit.length-1); i++) {
	LinkURLSpacer+='../'
	}

// build the actual string from right to left (reverse of how you'd read it) using relative links.

for (var i=0; i<(DocURLSplit.length-1); i++) {
	LinkURL = LinkURLSpacer + DocURLSplit[i] + '/'+ IndexFile
	TextURL = DocURLSplit[i].replace(/_/g, " ")

	if(i==(DocURLSplit.length-2)){ // the far right folder is not a link.
	HTMLString += HTMLString2 + TextURL
	LinkURLSpacer = LinkURLSpacer.slice(0,-3)
	}
	else{ // but every other folder is.
	HTMLString += HTMLString2 + '<a href="'+LinkURL+'" class="Fineprint" target="_parent">'+TextURL+'</a>'
	LinkURLSpacer = LinkURLSpacer.slice(0,-3)
	}
	}

// now add the home link and output it to you HTML document.
HTMLString = HTMLString1.concat("Home".link(HomeURL), HTMLString, HTMLString3)
document.writeln(HTMLString)
}