
function contact ()
{
   document.write('<form name="cf" action="/cgi-bin/sm" method="post">');
}

function top_header (dir)
{
	document.write (
		"<table class=\"toptable\" align=center cellspacing=0 cellpadding=0 border=0>\n"+
		"<tr>\n"																								  +
		"   <td class=\"toptitle\">\n"																  +
      "      <a href=\"lvb/index.htm\">Latin Vulgate Bible</a>\n"						  +
		"   </td>\n"																						  +
		"   <td class=\"toptableclick\">\n"															  +
		"      <a href=\"index.htm\">Home</a>\n"												     +
		"   </td>\n"																						  +
		"   <td class=\"toptableclick\">"                                               +
		"	    <a href=\"cgi-bin/i\">Index</a>"                                        +
		"   </td>"                                                                      +
		"   <td class=\"toptableclick\">\n"															  +
		"      <a href=\"about.htm\">About</a>\n"												  +
		"   </td>\n"																						  +
		"   <td class=\"toptableclick\">\n"															  +
		"      <a href=\"advertising.htm\">Advertising</a>\n"								  +
		"   </td>\n"																						  +
		"   <td class=\"toptableclick\">\n"															  +
		"      <a href=\"contact.htm\">Contact</a>	\n"										  +
		"   </td>\n"																						  +
		"   <td class=\"toptablefiller\">\n"														  +
		"   </td>\n"																						  +
		"</tr>\n"																							  +
		"</table>\n");
  
	document.write (
		"<table class=\"toptable\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n"+
		"<tr>\n"																														+
		"   <td class=\"titlebox\">\n"																					   +
		"      <a class=\"logo\" href=\"index.htm\">Douay-Rheims Catholic Bible</a>	\n"		         +
		"   </td>\n"																												+
		"   <td class=\"domainbox\">\n"																				      +
		"      <font class=\"domain\">DRBO.ORG</font>\n"											               +
		"   </td>\n"																												+
		"</tr>\n"																													+
		"</table>\n");
			
	document.write (
		"<table class=\"searchtable\" align=\"center\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n"					+
		"<tr>\n"																																				+
		"   <td class=\"searchbox\">\n"																												+
		"      <form class=\"search\" method=\"get\" action=\"cgi-bin/s\" border=\"0\" name=\"sf\">\n"							+
		"      <table width=\"100%%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n"											+
		"      <tr>\n"																																		+
		"         <td class=\"radio\">\n"																											+
		"         <input class=\"query\" type=\"text\" name=\"q\" size=\"70\" maxlength=\"120\" value=\"\"></input> \n"	+
		"         <input type=\"submit\" value=\"Search\" class=\"button\"></input>\n"												+
		"         <input name=\"b\" value=\"drb\" type=\"hidden\"></input>\n"															+
		"         <input type=\"radio\" name=\"t\" value=\"0\" checked>Whole Bible</input>\n"										+
		"         <input type=\"radio\" name=\"t\" value=\"1\">Old Testament</input>\n"												+
		"         <input type=\"radio\" name=\"t\" value=\"2\">New Testament</input>\n"												+
		"         </td>\n"																																+
		"      </tr>\n"																																	+
		"      </table>\n"																																+
		"      </form>\n"																																	+
		"   </td>\n"																																		+
		"</tr>\n"																																			+
		"</table>\n"); 
}

function show_img (url, ni, img_type, w, h, link, before, after)
{
   var str = "";
   var date = new Date();
   var n   = 1 + (date.getDay() % ni);
   document.write (before);
   str += '<td width=8>&nbsp;</td><td colspan=3 valign=top width=252><a class=imglink href="' + link + '" target="_blank">' + 
	       '<img src="' + url + n + img_type + '" width=' + w + ' height=' + h + ' border=0></a></td>\n';
	document.write (str);
   document.write (after);
}

function show_img_alt (url, ni, img_type, w, h, link1, link2, before, after)
{
   var date = new Date();
// var n   = 1 + Math.floor (Math.random() * ni);
   var n   = 1 + (date.getDay() % ni);
   
   var str = "";
   var link = link1;
   if (n == 2) link = link2;
   document.write (before);
   str += '<td width=8>&nbsp;</td><td colspan=3 valign=top width=252><a class=imglink href="' + link + '" target="_blank">' + 
	       '<img src="' + url + n + img_type + '" width=' + w + ' height=' + h + ' border=0></a></td>\n';
	document.write (str);
   document.write (after);
}

function show_imglocal (url, ni, img_type, w, h, link, before, after)
{
   var str = "";
   document.write (before);
   str += '<td width=8>&nbsp;</td><td colspan=3 valign=top align=left width=252><a class=imglink href="' + link + '">' + 
	       '<img src="' + url + ni + img_type + '" width=' + w + ' height=' + h + ' border=0></a></td>\n';
	document.write (str);
   document.write (after);
}

function show_button (url, ni, img_type, w, h, link, before, after)
{
   var date = new Date();
// var n   = 1 + Math.floor (Math.random() * ni);
   var n   = 1 + (date.getDay() % ni);
   var str = "";
   str += before;
   str += '<td width=8>&nbsp;</td><td valign=top width=122>' + '<a class=imglink href="' + link +  '" target="_blank">' + 
	       '<img src="' + url + n + img_type + '" width=' + w + ' height=' + h + ' border=0></a></td>\n';
   str += after;
	document.write (str);
}

function show_buttonlocal (url, ni, img_type, w, h, link, before, after)
{
   var str = before;
   var date = new Date();
   var n   = 1 + (date.getDay() % ni);
   str += '<td width=8>&nbsp;</td><td valign=top width=122>' + '<a class=imglink href="' + link + '">' + 
	       '<img src="' + url + n + img_type + '" width=' + w + ' height=' + h + ' border=0></a></td>\n';
   str += after;
   document.write (str);
}

function switch_func (dir, i)
{
      switch (i)
      {
      case 0:
	      show_img     (dir + "img/Valtorta/250ad",       1, ".jpg", 250, 200, "http://www.valtorta.org/","","");
	      break;
      case 1:
	      show_img_alt (dir + "img/Loreto/Ad",            2, ".jpg", 250, 120, "http://www.loretopubs.org/index.php?target=products&product_id=56",
																	   						      "http://www.loretopubs.org/index.php?target=products&product_id=174","","");
	      break;
      case 2:
	      show_img     (dir + "img/RestoredTraditions/drbo_ad",  2, ".jpg", 250, 120, "http://www.restoredtraditions.com/","","");
	      break;
      case 3:
	      show_img     (dir + "img/Audio/Banner",         1, ".jpg", 250,  90, "http://www.douayrheimsaudiobible.org/","","");
	      break;
      case 4:
	      show_button  (dir + "img/DEEnter/deeadd",       2, ".jpg", 120,  90, "http://www.deenterprisesmn.com/","","");
	      break;
      case 5:
	      show_button  (dir + "img/PrayTheRosary/NewPTR", 1, ".jpg", 120,  90, "http://rosarymakersshop.com/","","");
	      break;
      case 6:
	      show_button  (dir + "img/RosaMM/Logo",          1, ".jpg", 120,  90, "http://www.RosaMysticaMantilla.com/","","");
	      break;
      case 7:
//	      show_button  (dir + "img/MirMedal/GMMAd",       1, ".jpg", 120,  90, "http://www.GoldMiraculousMedal.com/","","");
//	      show_button  (dir + "img/Blanks/Ad120x90_",     1, ".jpg", 120,  90, "http://www.drbo.org/advertising.htm","","");
  	      show_button  (dir + "img/VirgoPotens/Ad",       1, ".jpg", 120,  90, "http://www.virgopotensrosaries.com/","","");
	      break;    
//    case 7:
//	      show_button  (dir + "img/PairLite/Ad",          1, ".jpg", 120,  90, "http://promote.pairlite.com/direct.pl?from=pl300&to=pairlite.com/hosting","","");
//	      break;    
      }
}
			
function side_ads (dir)
{
  		var r, i, n, x;
  		var largeads = 4;
  		var smallads = 4;
  		var totalads = largeads + smallads;
  		
		var ad   = new Array (totalads)
		var used = new Array (totalads)
		
  		for (i = 0; i < totalads; i = i + 1) used[i] = 0; 
		for (i = 0; i < 4; i = i + 1) 
		{
			ad[i]   = i; 
			used[i] = 1;
		}
		for (i = 4; i < totalads; i = i + 1) 
		{
			while (1)
			{
				r = Math.floor (Math.random()*totalads);
				if (used[r] == 0) break;
			}
			ad[i]   = r; 
			used[r] = 1;
			if (r >= largeads) // Get another small ad?
			{
				i = i + 1;
				while (1) // Get another one.
				{
					r = largeads + Math.floor (Math.random()*smallads);
					if (used[r] == 0) break;
				}
				ad[i]   = r; 
				used[r] = 1;
			}
		}
  		
		document.write ('<table cellspacing=0 cellpadding=0 border=0>\n');
		for (i = 0; i < totalads; i = i + 1) 
		{  
		   x = 0;
	      document.write ("<tr>\n");
	      switch_func (dir, ad[i]);
         if (ad[i] >= largeads) 
			{
			   if (x == 0)
			   {
			      x = 1;
				   i = i + 1;
      	      switch_func (dir, ad[i]);
				}
			}        
			document.write ('</tr>\n');
			document.write ('<tr><td height=7  colspan=4></td></tr>\n');
		}
		document.write ('</table>\n');
  		
//  		document.write ('<table align=left cellspacing=0 cellpadding=0 border=0>\n');
//  		document.write ('<tr><td width=5></td></tr>\n');
//  		document.write ('</table>\n');
//  		
//  		document.write ('<table align=right width=250 cellspacing=0 cellpadding=0 border=0>\n');
//  		document.write ('<tr><td>\n');
//              document.write ('<script type="text/javascript"><!--\n' +
//                      'google_ad_client = "ca-pub-5789383264118580";\n' +
//                      '/* side_ad */\n' +
//                      'google_ad_slot = "9722272038";\n' +
//                      'google_ad_width = 250;\n' +
//                      'google_ad_height = 250;\n' +
//                      '//-->\n' +
//                      '</script>\n' +
//                      '<script type="text/javascript"\n' +
//                      'src="http://pagead2.googlesyndication.com/pagead/show_ads.js">\n' +
//                      '</script>\n');
//  		document.write ('</td></tr>\n');
//  	        document.write ('</table>\n');
  	   
//		document.write ('<table align=left cellspacing=0 cellpadding=0 border=0>\n');
//		document.write ('<tr><td>\n');
//	   document.write ('<!-- Place this tag where you want the +1 button to render -->\n');
//      document.write ('<g:plusone></g:plusone>\n');
//  	document.write ('<!-- Place this render call where appropriate -->\n');
//  	document.write ('<script type="text/javascript">\n');
//  	document.write ('(function() {\n');
//  	document.write ("    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;\n");
//  	document.write ("    po.src = 'https://apis.google.com/js/plusone.js';\n");
//  	document.write ("    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);\n");
//  	document.write ('  })();\n');
//  	document.write ('</script>\n');
//  	document.write ('</td></tr>\n');
//  	document.write ('</table>\n');

}

