var day = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var month = new Array("Jan" , "Feb" , "Mar" , "Apr" , "May" , "Jun" , "Jul" , "Aug" , "Sept" , "Oct" , " Nov" , "Dec");
var today = new Date;
var formattedToday = day[today.getDay()] + " " + month[today.getMonth()] + " " + today.getDate() + ", " + today.getFullYear();
var num = Math.ceil(Math.random()*3);

function Include(section,pic){
	this.section = section;
	this.pic = pic;
	this.makeHeader = makeHeader;
	this.makeFooter = makeFooter;
}

function makeHeader(){
	var header = new Array();
	var index = 0;	
	header[index++] = '<a name="top"></a>';
	// Main Header Table
	header[index++] = '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
	header[index++] = '<tr>';
	header[index++] = '<td width="249" background="' + imgdir + 'logobg.gif" valign="top"><img src="' + imgdir + 'logo.gif" width="249" height="101" Alt="Mountain Valley Bank"></td>';
	header[index++] = '<td background="' + imgdir + 'logobg.gif" valign="top" align="right"><img src="' + imgdir + 'trees.gif" width="511" height="101"></td>';
	header[index++] = '</tr>';
	header[index++] = '</table>';
	header[index++] = '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
	header[index++] = '<tr>';
	// Top Navigation Item
	header[index++] = '<td rowspan="2" valign="top" width="1%"><img src="' + imgdir + 'navtop.gif" width="183" height="19"><br><a href="' + sitedir + 'onlinebanking.html" onMouseOver="img_act(\'online\'); window.status=\'Online Banking\'; return true" onMouseOut="img_inact(\'online\'); return true"><img src="' + imgdir + 'nav-online-off.gif" width="183" height="33" alt="Online Banking" name="online" border="0"></a></td>';
	// Date Stamp code goes here
	header[index++] = '<td width="50%" background="' + imgdir + 'onlinebg.gif" valign="middle"> &nbsp;&nbsp;&nbsp; <span class="datestamp">' + formattedToday + '</span></td>';
	header[index++] = '<td width="49%" valign="top" align="right" background="' + imgdir + 'onlinebg.gif">';
	if (!window.securepage)
	{
		header[index++] = '<a href="javascript:openIB(\'\');" onMouseOver="img_act(\'login\'); window.status=\'Click Here for Online Banking\';  return true" onMouseOut="img_inact(\'login\'); return true"><img src="' + imgdir + 'nav-login-off.gif" width="232" height="36" alt="Click Here for Online Banking" border="0" name="login"></a>';
	}
	else
	{
		header[index++] = '&nbsp;';
	}
	header[index++] = '</td>';
	header[index++] = '</tr>';
	header[index++] = '<tr> ';
	header[index++] = '<td width="50%" valign="top"><img src="' + imgdir + 'clearpix.gif" width="1" height="16"></td>';
	header[index++] = '<td width="33%" valign="top"><img src="' + imgdir + 'clearpix.gif" width="1" height="16"></td>';
	header[index++] = '</tr>';
	header[index++] = '</table>';
	header[index++] = '<table width="760" border="0" cellspacing="0" cellpadding="0">';
	header[index++] = '<tr>';
	// Main Navigation
	header[index++] = '<td width="183" valign="top" bgcolor="#004830">';
	header[index++] = '<a href="' + sitedir + 'prodserv.html" onMouseOver="img_act(\'product\'); window.status=\'Products and Services\'; popUp(\'HM_Menu1\',event); return true" onMouseOut="img_inact(\'product\'); popDown(\'HM_Menu1\'); return true;"><img src="' + imgdir + 'nav-product-off.gif" width="183" height="28" name="product" alt="Products and Services" border="0"></a><br>';
	header[index++] = '<a href="' + sitedir + 'branch.html" onMouseOver="img_act(\'branch\'); window.status=\'Branch Hours and Locations\'; return true" onMouseOut="img_inact(\'branch\');"><img src="' + imgdir + 'nav-branch-off.gif" width="183" height="28" name="branch" alt="Branch Hours and Locations" border="0"></a><br>';
	header[index++] = '<a href="' + sitedir + 'atm.html" onMouseOver="img_act(\'atm\'); window.status=\'ATM Locations\'; return true" onMouseOut="img_inact(\'atm\');"><img src="' + imgdir + 'nav-atm-off.gif" width="183" height="28" name="atm" alt="ATM Locations" border="0"></a><br>';
	header[index++] = '<a href="' + sitedir + 'calculators.html" onMouseOver="img_act(\'calculators\'); window.status=\'Calculators\'; popUp(\'HM_Menu2\',event); return true" onMouseOut="img_inact(\'calculators\'); popDown(\'HM_Menu2\'); return true;"><img src="' + imgdir + 'nav-calc-off.gif" width="183" height="28" name="calculators" alt="Calculators" border="0"></a><br>';
	header[index++] = '<a href="' + sitedir + 'community.html" onMouseOver="img_act(\'community\'); window.status=\'Community\'; return true" onMouseOut="img_inact(\'community\'); return true;"><img src="' + imgdir + 'nav-community-off.gif" width="183" height="28" name="community" alt="Community" border="0"></a><br>';
	header[index++] = '<a href="' + sitedir + 'aboutus.html" onMouseOver="img_act(\'about\'); window.status=\'About Us\'; return true" onMouseOut="img_inact(\'about\');"><img src="' + imgdir + 'nav-about-off.gif" width="183" height="28" name="about" alt="About Us" border="0"></a><br>';
	header[index++] = '<a href="' + sitedir + 'stockinfo.html" onMouseOver="img_act(\'stock\'); window.status=\'Stock Info\'; return true" onMouseOut="img_inact(\'stock\'); return true;"><img src="' + imgdir + 'nav-stock-off.gif" width="183" height="29" name="stock" alt="Stock Info" border="0"></a><br>';
	header[index++] = '<a href="' + sitedir + 'applications.html" onMouseOver="img_act(\'applications\'); window.status=\'Applications\'; popUp(\'HM_Menu3\',event); return true" onMouseOut="img_inact(\'applications\'); popDown(\'HM_Menu3\'); return true;"><img src="' + imgdir + 'nav-applications-off.gif" width="183" height="28" name="applications" alt="Applications" border="0"></a><br>';
	header[index++] = '<a href="' + homedir + '" onMouseOver="img_act(\'home\'); window.status=\'Home\'; return true" onMouseOut="img_inact(\'home\');"><img src="' + imgdir + 'nav-home-off.gif" width="183" height="28" name="home" alt="Home" border="0"></a></td>';
	header[index++] = '<td width="577" valign="top" align="center"><table cellpadding="0" width="550" border="0" cellspacing="0"><tr><td valign="top" class="ficontent">';
	if (!window.homepage)
	{
		header[index++] = '<img src="' + imgdir + 'hed-' + this.section + '.gif" border="0" width="543" height="27"><br>';
	}
	if (this.pic)
	{
		header[index++] = '<img src="' + imgdir + this.pic + '.jpg" border="0" width="171" height="236" align="right">';
	}
	document.open("text/html","replace");
	document.writeln(header.join(""));
	document.close();
	return;
}

function makeFooter(){
	var footer = new Array();
	var index = 0;
	footer[index++] = '</td></tr></table></td>';
	footer[index++] = '</tr>';
	footer[index++] = '</table>';
	footer[index++] = '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
	footer[index++] = '<tr>';
	footer[index++] = '<td bgcolor="#FEAA1B">';
	// Footer Table 1
	footer[index++] = '<table width="760" border="0" cellspacing="0" cellpadding="0">';
	footer[index++] = '<tr> ';
	footer[index++] = '<td width="183" bgcolor="#004830"><img src="' + imgdir + 'clearpix.gif" width="183" height="1"></td>';
	footer[index++] = '<td bgcolor="#FEAA1B" width="577"><img src="' + imgdir + 'footer.gif" width="198" height="17"><a href="' + sitedir + 'terms.html"><img src="' + imgdir + 'terms3.gif" width="108" height="17" border="0" alt="Disclosure"></a><a href="' + sitedir + 'privacy.html"><img src="' + imgdir + 'privacy.gif" width="53" height="17" alt="Privacy" border="0"></a><a href="' + sitedir + 'security.html"><img src="' + imgdir + 'security.gif" width="58" height="17" alt="Security" border="0"></a></td>';
	footer[index++] = '</tr>';
	footer[index++] = '</table>';
	footer[index++] = '</td>';
	footer[index++] = '</tr>';
	footer[index++] = '</table>';
	// Footer Table 2
	footer[index++] = '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
	footer[index++] = '<tr>';
	footer[index++] = '<td bgcolor="#004830"> ';
	footer[index++] = '<table width="760" border="0" cellspacing="0" cellpadding="0">';
	footer[index++] = '<tr> ';
	footer[index++] = '<td width="183" bgcolor="#004830" valign="top"><a href="#top"><img src="' + imgdir + 'backtotop.gif" width="183" height="45" alt="Back to Top" border="0"></a></td>';
	footer[index++] = '<td bgcolor="#004830" valign="top" align="center"><img src="' + imgdir + 'address.gif" width="577" height="22" alt="P.O. Box 729 | 810 Rankin Avenue North | Dunlap, TN 37327 | 423.949.2146"><br>';
	footer[index++] = '<a href="#" onclick="extLink(\'http://www.hud.gov/\');"><img src="' + imgdir + 'ehl.gif" width="54" height="55" border="0" alt="Equal Housing Lender"></a>';
	footer[index++] = '<a href="#" onclick="extLink(\'http://www.fdic.gov/\');"><img src="' + imgdir + 'memberfdic.gif" width="73" height="55" border="0" alt="Member FDIC"></a></td>';
	footer[index++] = '</tr>';
	footer[index++] = '</table>';
	footer[index++] = '</td>';
	footer[index++] = '</tr>';
	footer[index++] = '</table>';
	document.open("text/html","replace");
	document.writeln(footer.join(""));
	document.close();
	return;
}