//=======================================================================
// JavaScript FBR footer			 Created: January 18, 2001	by: KJH
// History:
//   01-28-2004  kjh -updated copyright date & fax #
//   02-01-2005  kjh -updated copyright date
//   10-??-2007  kjh -new footer style
//   01-07-2008  kjh -updated copyright date
//   07-31-2009  kjh -Test changes to template structure (better CSS structure)
//   12-03-2009  KJH -updated to new path detection
//
//=======================================================================
//=============================================================================
// Locate root area by direct URL or relative path from file location.
//    if  URL (http://) the root area is the secton after the ://
//    if FILE the root area is found via relative path from designated base
//            base directory (pre-defined)

// Initialize items
var txt="";                              // global text output
var lastMenu="";                         // global menu usage
var cMenu="";                            // global menu usage
var msg="";                              // text for alert messages (debug)

var path="";                             // root area (default- not determined)
var pathIn="http://web.fbrhome.net/";    // DEFAULT internal website path
var dSpos=-1;                            // Starting position (default- not found)
var tStr="";                             // temporary string container
var isGWI=0;                             // page internal or gwi [default=internal]

var aloc=""+document.location;  // get path/filename [document.URL changes the slashes]
var dloc=aloc.toUpperCase();             // convert to uppercase
var dEpos=dloc.lastIndexOf("/");         // get last position of "/"

// Served from GWI or Internal?
var sStr="HTTP://WWW.FBR.ORG";           // LIVE area
var dpos=dloc.indexOf(sStr);             // last character position
if (dpos>=0) {                           // Found it?
	isGWI=1;                              // served from GWI.
	}

// Where is the root area?
var sStr="HTTP://";                             // search string
var dpos=dloc.indexOf(sStr);                    // last character position
if (dpos>=0) {                                  // HTTP web server mode
	tStr=dloc.substring(dpos+sStr.length,dloc.length);  // remove the http://
	dSpos=tStr.indexOf("/");                     // next / 
	if (dSpos<0) { dSpos=tStr.length };          // only root area passed
	dSpos=dpos+sStr.length+dSpos;                // root end position in aloc
	path=aloc.substring(dpos,dSpos);             // get root area substring
	if (path.substring(path.length,path.length) != "/") {
		path=path + "/";                          // must end in '/'
		}
	//alert ("URL path: " + path);
	} 

if (path == "" ) {                              // FILE mode?
	sStr="FBRORG";                               // Live internal area?
	dpos=dloc.indexOf(sStr);
	if (dpos>0) {
		for (i=dpos; i<dEpos; i++) {              // count directories
			if (dloc.charAt(i)=="/") { path=path+"../" };  // create relative path
			} // end of for
		}
	}

msg="aloc: " + aloc + " \ndloc: " + dloc + "\n\n";
msg=msg + "dpos: " + dpos + "   dSpos: " + dSpos + "   dEpos: " + dEpos + " \n";
msg=msg + "sStr: " + sStr + "\ntStr: " + tStr;
msg=msg + "\n\n path: " + path;
msg=msg + "\n\n pathIn: " + pathIn;
//alert(msg);

//------------------------ Functions ----------------------------------------
// Get page date
var PageDateObj=document.getElementsByName("FBRdate");   // get array of elements with specific name
var PageDateItem=PageDateObj[0];                         // there should only be 1 FBRdate
var PageDate="";                                         // default to meta data element
if (PageDateItem != undefined ) {                        // grab passed menu value
	PageDate=PageDateItem.content;
   }
var isNetscape=0;
if (navigator.appName == "Netscape") { isNetscape=1 };

//alert ("isNetscape: " + isNetscape );


//---------------------------------------------------------------------------
//                            Main Footer
//---------------------------------------------------------------------------

txt="</div>";              // MasterContent END
document.write(txt);

txt="<div id='MasterFooter' >";   //  Footer start
document.write(txt);

// Address and hours...
txt="<h1><a href='"+path+"home.html'>Foundation for Blood Research</a></h1>";
txt=txt+"<p>P.O. Box 190, 8 Science Park Road &nbsp; &bull; &nbsp; ";
txt=txt+"Scarborough, ME 04070-0190 &nbsp; &bull; &nbsp; ";
txt=txt+"Phone: (207) 883-4131* &nbsp; &bull; &nbsp; Fax: (207) 885-0807</p>";
txt=txt+"<p>Open 7:30 to 5:00 Monday-Friday, Eastern Time U.S.A.</p>";
document.write(txt);

// Footer links and page date...
txt="<div id='PageDate'>"+PageDate+"</div>";
txt=txt+"<div id='FooterLinks'>";
txt=txt+"<A href='"+path+"disclaimer.html'>Disclaimer</a>";
txt=txt+"<A href='#top'>Return to top</A>";
txt=txt+"<A href='"+path+"contact-form.html'>Contact Us</a>";
txt=txt+"</div>";
document.write(txt);

// Disclaimer...
txt="<div id='Disclaimer'>";
txt=txt+"<p>This information is not intended to be a substitute for";
txt=txt+" professional medical advice. You should not use this information";
txt=txt+" to diagnose or treat a health problem or disease without";
txt=txt+" consulting with a qualified healthcare provider. Please";
txt=txt+" consult your healthcare provider with any questions or";
txt=txt+" concerns you may have regarding your condition.</p>";
txt=txt+"</div>";
document.write(txt);

// Copyright...
txt="<p>*If primary phones are down, we can be reached at (207) 831-5648.</p>";
txt=txt+"<p>&copy; copyright 2010 <a href='"+path+"home.html'>";
txt=txt+"Foundation for Blood Research</a>,";
txt=txt+" an independent not-for-profit organization</p>";
document.write(txt);


txt="</div>";                            //  MasterFooter end
document.write(txt);

txt="</div>";                           // MasterAll close
document.write(txt);


//-- Footer date amd links  Backward compatible only!  --
function FooterDate(ftrDate) {
txt="<table align='center' width='800px'>";
txt=txt+"<tr><td width='344px' align='center' valign='top'>";
txt=txt+"<p align='center' style='font-family: arial; margin-bottom: 0px;";
txt=txt+" margin-top: 0px; font-size: x-small; color: #759f71;'>";
txt=txt+"Footer Date: " + ftrDate + "</p>";
txt=txt+"</td><td width='344px' align='center' valign='top'>";
txt=txt+"<p align='center' style='color: #759f71; font-family: arial; font-size: x-small;";
txt=txt+" margin-bottom: 0px; margin-top: 0px; '>";
txt=txt+"<a style=' color: #759f71' href='"+path+"home.html'>FBR Home</a> | ";
txt=txt+"<a style=' color: #759f71' href='"+path+"sitemap.html'>Site Map</a> | ";
txt=txt+"<a style=' color: #759f71' href='"+path+"search.html'>Search</a></p>";
txt=txt+"</td><td width='114px' align='center' valign='top'>";
txt=txt+"</td></tr></table> <br>&nbsp;"; 
document.write(txt);
}

