// JavaScript Document

// *************************************************************************************
// Horizontal Links Navigation Javascript
// Usage: In the head of your document put this script. (you knew that, right?)
//        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, I like 'Home.htm'. If you do use index.htm or index.html (or whatever your
//        server automatically dishes up), blank out IndexFile to ''.
//
// Version: 0.92
// Date: 30JAN2003
// Author: Eric Zander (eric_zander@yahoo.com)
//
// NOTE: This script is free... please send me an email letting me know you're using it and what you think.
//
// *************************************************************************************



function HNav() {

var BaseURL1 = "www.royalhomesinc.net/"
var BaseURL2 = "~royalhomes/"
var IndexFile = ""

var DocURLRef = document.URL
var DocURL = DocURLRef
var DocURLSplit = ''

var HomeURL = ''
var TextURL = ''
var LinkURL = ''
var LinkURLSpacer = ''
var HTMLString = ''
var HTMLString1 = ''

// 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.html'
		}
	if (DocURL.search(BaseURL2)!= -1 && BaseURL2 !='') {
		DocURL=DocURL.slice(DocURL.indexOf(BaseURL2) + BaseURL2.length)
		HomeURL = DocURLRef.slice(0, DocURLRef.indexOf(BaseURL2) + BaseURL2.length) + 'index.html'
		}
	}

// 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 (i=0; i<(DocURLSplit.length-1); i++) {
	TextURL = DocURLSplit[i].replace(/_/g, " ")
	
	if(TextURL == "Floor Plans") {	
		LinkURL = LinkURLSpacer + DocURLSplit[i] + '/'+ "floorplansoverview.htm"
		}
	else {
		LinkURL = LinkURLSpacer + DocURLSplit[i] + '/'+ IndexFile
	}
		
	if(i==(DocURLSplit.length-2) || TextURL == "Explore Our Homes"){ // the far right folder is not a link.
		if(TextURL == "Explore Our Homes") {
			HTMLString += TextURL + " > "
			}
		else {
			HTMLString += TextURL
			}
			
		LinkURLSpacer = LinkURLSpacer.slice(0,-3)
	}
	else{ // but every other folder is.		
		HTMLString += '<a href="'+LinkURL+'">'+TextURL+'</a>' + " / "
		LinkURLSpacer = LinkURLSpacer.slice(0,-3)
	}
}

// now add the home link and output it to you HTML document.
if(DocURLSplit.length == 1)
	HTMLString = ":: "+"Home".link(HomeURL)
else
	HTMLString = HTMLString1.concat(":: ","Home".link(HomeURL)," / ", HTMLString, " ")
document.writeln(HTMLString)
}