/* name of current page, used to hide button */
/* name should be set on every page */
var sswdPageName = "";

/* works in older pre decodeURI JS version */
function unEsc( filename ){

	var result = "";
   if ( 'function' == typeof window.decodeURI ){
   	result = decodeURI( filename );
   } else {
   	result = unescape( filename );
   }
   return( result );
}

/* return name of current html (or php) page string, without its extension
** Requires that the filename has an extension, name returned goes
** from final / or \ to final . 
*/
function getCurrentPageFilename() {
   var fullname = unEsc( document.location );
   var filename = sliceFileName( fullname );
   //alert( fullname + " :: " + filename );
	return( filename );
}

/* return just the name of the file without its extension
** Requires that the filename has an extension; name returned is string
** between final / or \ to final . 
*/
function sliceFileName( fullname )
{
   var filename = "";
   var dotAt = fullname.lastIndexOf( "." );
   if( dotAt > 0 ){
   	var lastSep = fullname.lastIndexOf( "\\" );		// Try invalid local version first
      if ( lastSep < 0 ) lastSep = fullname.lastIndexOf( "/" );
      if (lastSep >= 0 ){
      
      	filename = fullname.slice( lastSep+1, dotAt );
      }
   }
	return( filename );
}

/* handles case where no filename in location, just the home website */
function indexFileFix( curFile )
{
if( curFile.length == 0 ){
   var fullname = unEsc( document.location );
   fullname = fullname.toLowerCase();

   if( fullname.indexOf( "splendidspider.com" ) >= 0 || fullname.indexOf( "yourfriendpaul.com" ) >= 0 ){
   	curFile = "index" ;
      
   }
}
// alert( "\"" + curFile + "\" Length: " + curFile.length );
return( curFile );
}

/* code for Navbar */

function formatNavBar( )
{
   var curFile = getCurrentPageFilename();
   curFile = indexFileFix( curFile );
   curFile += "Pnav";
   //document.write( "<br />Filename: " + curFile  );
   var barList = document.getElementById( "topNavBar" );
   var buttonList = barList.getElementsByTagName( "li" );
   //alert( "Navbar has " + buttonList.length + " buttons" );
   for( var iCount = 0; iCount < buttonList.length; iCount++ ){
      
      if( buttonList[ iCount ].id == curFile ){
      
      	//alert( curFile );
//         buttonList[ iCount ].style.display = "none";
         
      }
      //else document.write( "<br />no: " + buttonList[ iCount ].id + ", " );
   }
}




function buttonMouseOver( elem ){
	// alert( "over " + elem.id );
   elem.oldColor = elem.style.backgroundColor;
   elem.style.backgroundColor = "#e8e1b8";
}

function buttonMouseOut( elem ){
   elem.style.backgroundColor = elem.oldColor;

}

