//
// RootsWeb header/footer script version 0.5
// also add an image tag to drop a session cookie named rws
// if it is missing
//
// written 09-16-2005 by rkw
//

document.write('<link rel="SHORTCUT ICON" href="http://images.rootsweb.com/favicon.ico">\n');

function addHeaderTab(text,url,sel,border) {
	document.write('<a href="'+url+'"');
	if (border=="left")
		document.write(' style="border-left: 0"');
	else if (border=="right")
		document.write(' style="border-right: 0"');
	if (text==sel) document.write(' class="active"');
	document.write('>'+text+'</a>');
}

function addArea(parent,coords,url,title) {
	var area=document.createElement('area');
	area.shape='rect';
	area.coords=coords;
	area.href=url;
	area.alt=title;
	area.title=title;
	parent.appendChild(area);
}

function writeLink(text,url,sel,border) {
	document.write('<a href="'+url+'"');
	document.write('>'+text+'</a>');
	if (border!='right') document.write(' | ');
}

function writeHeader(dWidth,selTab) {
	document.write('<center>');
// Modern or not ?
	var isMacIE=((navigator.userAgent.indexOf("IE")>-1) && (navigator.userAgent.indexOf("Mac")>-1));
	if (!isMacIE && document.createElement && document.appendChild) {
		document.write('<div id="header">');
		document.write('<img src="http://images.rootsweb.com/mh/rwtop.gif" width=760 height=70 usemap="#Ancestry" border=0>');
		document.write('<div id="nav">');
		addHeaderTab('Home','http://www.rootsweb.com/',selTab,'left');
		addHeaderTab('Searches','http://searches.rootsweb.com/',selTab,'');
		addHeaderTab('Family Trees','http://worldconnect.rootsweb.com/',selTab,'');
		addHeaderTab('Mailing Lists','http://lists.rootsweb.com/',selTab,'');
		addHeaderTab('Message Boards','http://boards.rootsweb.com/',selTab,'');
		addHeaderTab('Web Sites','http://www.rootsweb.com/~websites/',selTab,'');
		addHeaderTab('Passwords','http://passwordcentral.rootsweb.com/',selTab,'');
		addHeaderTab('Help','http://helpdesk.rootsweb.com/',selTab,'right');
	} else {
		document.write('<div>');
		document.write('<img src="http://images.rootsweb.com/mh/rwtop.gif" width=760 height=70 usemap="#Ancestry" border=0>');
		document.write('<div>');
		writeLink('Home','http://www.rootsweb.com/',selTab,'left');
		writeLink('Searches','http://searches.rootsweb.com/',selTab,'');
		writeLink('Family Trees','http://worldconnect.rootsweb.com/',selTab,'');
		writeLink('Mailing Lists','http://lists.rootsweb.com/',selTab,'');
		writeLink('Message Boards','http://boards.rootsweb.com/',selTab,'');
		writeLink('Web Sites','http://www.rootsweb.com/~websites/',selTab,'');
		writeLink('Passwords','http://passwordcentral.rootsweb.com/',selTab,'');
		writeLink('Help','http://helpdesk.rootsweb.com/',selTab,'right');
	}
	document.write('</div>');
	document.write('<map name="Ancestry">');
	document.write('<area shape="rect" coords="2,0,617,76" href="http://www.rootsweb.com/" alt=" " title=" ">');
	document.write('<area shape="rect" coords="616,1,767,69" href="http://www.ancestry.com/s20515/t6062/rd.ashx" alt="Ancestry - Over 1 Billion Names" title="Ancestry - Over 1 Billion Names">');
	document.write('</map>');
	document.write('</div>');
	document.write('</center>');
	document.write('<br>');
	document.write('<div id=content></div>');
}

function footerAddLink(parent,text,url,addSep) {
	var a=document.createElement('a');
	a.href=url;
	a.appendChild(document.createTextNode(text));
	parent.appendChild(a);
	if (addSep) parent.appendChild(document.createTextNode(' | '));
}

function getCookie(name) {
	var dc=document.cookie;
	var prefix=name+"=";
	var begin=dc.indexOf("; "+prefix);
	if (begin==-1) {
		begin=dc.indexOf(prefix);
		if (begin!=0) return null;
	} else {
		begin+=2;
	}
	var end=document.cookie.indexOf(";",begin);
	if (end==-1) end=dc.length;
	return unescape(dc.substring(begin+prefix.length,end));
}

function writeFooter(hrWidth) {
	var rws=getCookie('rws');
	if (null==hrWidth || hrWidth.length==0) hrWidth='90%';
	if (hrWidth!='0')
		document.write('<hr width="'+hrWidth+'" size="1" noshade align="center">');
	document.write('<center>');
	document.write('<p><font face="Verdana, Arial, Helvetica, sans-serif" size="-2">RootsWeb is funded ');
	document.write('and supported by <a href="http://www.rootsweb.com/rootsweb/support.html">Ancestry.com</a> ');
	document.write('and our loyal RootsWeb community. <a href="http://www.rootsweb.com/rootsweb/support.html">Learn ');
	document.write('more.</a><br><br>');
	document.write('<a href="http://www.rootsweb.com/rootsweb/aboutus.html">About Us</a> | ');
	document.write('<a href="http://helpdesk.rootsweb.com/help.cgi">Contact Us</a> | ');
	document.write('<a href="http://www.rootsweb.com/rootsweb/aup.html">Acceptable Use Policy</a> | ');
	document.write('<a href="http://www.rootsweb.com/rootsweb/privacy.html">PRIVACY STATEMENT</a> | ');
	document.write('<a href="http://www.myfamilyinc.com/about_us/copyright.htm"> Copyright</a><br>');
	document.write('Copyright &copy; 1998-2005, MyFamily.com Inc. and its subsidiaries.</font></p></center>');
	if (null==rws || rws.length==0)
		document.write('<img src="http://resources.rootsweb.com/cgi-bin/session" height=1 width=1>');
}
