// ========================================================================================
// Copyright 2002-2008. Inium, Inc. All Rights Reserved.                  +1.312.925.3073 =
// Version 1.1                                                          Released 20030225 =
// version 1.0                                                          released 20021124 =
// ========================================================================================
// This script is Iyah -> Inium You Are Here.  It is a flexible implementation of client- =
// side javascript breadcrumbing without the use of cookies.                              =
//                                                                                        =
// This script is free to use providing this header is not changed in any way and that no =
// changes except those specifically mentioned in the "Permitted Changes" section below   =
// are made:                                                                              =
//                                                                                        =
// Permitted Changes - Total 5 (five). You may change:                                    =
//      (1) var def (Iyahimgpt) of image source in setting the divider.                   =
//      (2) var def (Iyahclass) of class name for formatting Iyah output.                 =
//      (3) var def (Iyahfface) of default font face if not using CSS.                    =
//      (4) var def (Iyahfsize) of default font size if not using CSS.                    =
//      (5) var def (Iyahfwght) of default font weight if not using CSS.                  =
// -------------------------------------------------------------------------------------- =
//      This script carries no warranties, guarantees or assurances of any kind.          =
// -------------------------------------------------------------------------------------- =
// Useful? Tell us: thisscriptrocks@inium.com  	 Not? Tell us: thisscriptsucks@inium.com  =
// ========================================================================================
function Iyah($divider,$new_line) {
// permitted changes below five lines only //
	var Iyahclass = "\" class=\"crumbnav\">";
	var Iyahfface = "";
	var Iyahfsize = "";
	var Iyahfwght = "";
	var Iyahimgpt = "<img src=\"/images/bcarrow.gif\"> ";
// permitted changes above five lines only //
//
// unless both empty, set font string as if FACE and SIZE have a value, otherwise CSTR to "":
	if (Iyahfface != "") { // || (Iyahfsize != "") {
	// Iyahfcstr - FontCombinedString
		var Iyahfcstr = "<font face=\"" + Iyahfface + "\" " + "size=\"" + Iyahfsize + "\">";
		var Iyahfccls = "</font>";
		}else{
		var Iyahfcstr = "";
		var Iyahfccls = "";
	}

	if ($divider == 1) {
		$divider = Iyahimgpt;
 		}else{
		$divider = ">>";
	}
// URL convert to txt str e.g. http://www.inium.com/sfa/js/dev_elements.html
$location = window.location.toString();
//get substr URL after protcol (http://) splits at / e.g. www.inium.com,sfa,js,dev_elements.html 
$subString = $location.substr(7).split("/");
// prints path to the home directory + the $divider e.g.'<a href="/">Home</a>>>'
// uses getLoc() func blw w/ subString.length to determine num dirs up from current home directory is.
document.write("<a href=\"" + getLoc($subString.length - 1) + Iyahclass + Iyahfcstr + "Home" + Iyahfccls +"</a>" + $divider + " ");
//document.write($location.indexOf(document.domain));
//document.write($subString[$subString.length-1].length);
//document.write("<a href=\"" + getLoc($subString.length - 1) + Iyahclass + "Home</a>" + $divider + " ");
// prints remainder of path converting file names first letters to uppercase using getCaps()=====
    $a = ($location.indexOf(document.domain) == -1) ? 1:1;
	if ($subString[$subString.length-1].length == 0) { 
		a=1; 
		} 
//loops thru sub-dirs, adds uppercase letter from makeCaps() and prints as link
//Remove +$home_file to return to default directory listing
    for (i = 1; i < $subString.length - $a; i++) {
        $subString[i] = makeCaps(unescape($subString[i]));
		document.write("<a href=\"" + getLoc($subString.length - i - 2) + "\" class=\"crumbnav\">" + $subString[i] + "</a>" + $divider);
    }
//breaks current file title to second line if $new_line set to 1
if ($new_line == 1) { document.write("<br>"); }
//writes out CSS + document title of current page
document.write(document.title);
}//EoFn Iyah()

//picks up directory names and changes first letter to UPPER except if dir starts with .- or %20.
function makeCaps($a) { 
//$a takes on the value of $subString[i] which is a directory title from the Iyah() function above
//make this a case switch with directories having -_.%20 in the URL
	$sub_dir_name = $a.split("_");
	//loops thru dir names and changes to leading UPPER.
    for (l = 0; l <  $sub_dir_name.length; l++) {
         $sub_dir_name[l] =  $sub_dir_name[l].toUpperCase().slice(0, 1) +  $sub_dir_name[l].slice(1);
    }
    return  $sub_dir_name.join(" ");
}//EoFn makeCaps()

// determins number of levels up required to reach root directory and prints the appropriate number of '../'
function getLoc($num) {
var $path = "";
    if ($num > 0) {
        for ($count = 0; $count < $num; $count++) {
			// for each level specified by $num add a '../'
            $path = $path + "../";
			        }
    }	
return $path; //returns the $path value to the Iyah calling code
}//EoFn getLoc()
