/*		Author: 		Dan Kovacevic
		Date: 			2.3.2004
		Email: 			dank49@hotmail.com
		Description: 	These functions are used to add to the web site navigation, validation, breadcrumbs, pagetitles, windows, etc.
							Look for a description of each function, just above the function.
*/							



		/*	Read the page title from the document title and display it.  This is an a method with an intent to increase flexibility to
			displaying the title considering that the */

function title()
{
	if (document.title.length < 5) {
		document.title = "Sears Historical Archives";
		return document.title;
	} 
	return document.title;
}

		/* Breadcrumbs */
		
function relpath( linklength ){
	var cd = "../";
	var dir =[ cd ];
	
	for ( j = 1; j < linklength; j++ ) {
		dir [j] = cd + dir[ j - 1 ];
	}
	return true? dir.reverse() : dir();
}


function breadcrumbs(){

	var link = location.toString();
	var crumb = "";
	
	//link=link.substring( link.indexOf("/") + 1 );
	link=link.substring( link.indexOf("//") + 1 );
	
	link=link.split("/");
	
	var href = relpath( link.length );

	href [link.length] = "";

        var text = "";
        var url = "";

			// form the crumbs
			
	for ( i = 1; i < link.length-1; i++ ) {		
		url = href[ i + 2];
		text = unescape(link[i]);
		if ( i > 1) { 
        	text = text.substring(0, 1).toUpperCase() + text.substring( 1, text.length );
        }
		crumb += ("<a class=crumb href=" + url + '>' + text + "</a>  » ")
	}	
	crumb += "&nbsp;" + document.title;	
	crumb = crumb.replace(eval("/"+location.host+"/"), "Archives Home")

return crumb
}


function moreCrumbs() {

//	path = '';
//	loc = '' + location.href;
//	paths = loc.substring(7).split('/');
//	file = loc.substring(0,6);
//
//	for (i=0, n=paths.length;i<n;i++) {
//		file += "/" + paths[i];
//  		path += '> <a href="' + file + '">' + paths[i] + '<\/a> ';
//	}
//return path.substring(1);
}


function win(inFile) {
	var x = screen.availWidth-720-20;

    popUp = window.open(inFile,'infoWin', 'left='+x+',screenX='+x+',top=10, screenY=10,height=700,width=720,scrollbars=yes,resizable=yes');
    if (popUp.opener == null) popUp.opener = self;
    popUp.focus();
}

function main(url) {
    opener.location.href = url;
    opener.focus();
}

		/*	Open new window size based on parametars passed and focus on that window	*/

function openwindow(htmlfile, x, y)
{
	newwindow = window.open(htmlfile,"commentWindow","width=" + x + ",height=" + y + ",titlebar=0,scrollbars=yes");
	newwindow.focus();
}


		/*	Confirmation request	*/

function confirmation(url) {
  if (confirm("Are you sure you want to proceed?")) {
	 location.href = url;
  } else {return false; }
}