//last update: 9/6/02 -PH
//****************************************************************************/
//   CONFIDENTIAL AND PROPRIETARY PROPERTY OF GENEALOGY.COM (510) 794-6850   */
//                        PO Box 7865, FREMONT, CA 94537                     */
// THIS PROGRAM IS AN UNPUBLISHED WORK FULLY PROTECTED BY THE UNITED STATES  */
// COPYRIGHT LAWS AND IS CONSIDERED A TRADE SECRET BELONGING TO THE COPY-    */
// RIGHT HOLDER.                                                             */
//****************************************************************************/

//--------------------------------------------------------------------
// This code isn't needed for the current adServer functions, but it
// used to be included here so we'll continue including it rather than
// risk  breaking HTML files that rely on its presence w/o checking.
//--------------------------------------------------------------------
if ((typeof GetLogicalCookie) != "function") {
  document.write('<script src=/javascript/cookies.js></sc','ript>')
}
if ((typeof Owns) != "function") {
  document.write('<script src=/javascript/ActiveListCookie.js></sc','ript>')
}

var iAdNumber = 0;

// These need to be global for multiple ads on the same page to work correctly
var RN = new String(Math.random());
var RNS= RN.substring(2,11);

function DisplayAdBanner(strPosition, nWidth, nHeight, strCampaign)
{
   var sPos;
   var regexRight      = /!Right/;

   if      (strPosition == 'top')     { sPos = 'top'; }
   else if (strPosition == 'Top')     { sPos = 'top'; }
   else if (strPosition == 'right')   { sPos = 'right'; }
   else if (strPosition == 'Right')   { sPos = 'right'; }
   else if (strPosition == 'bottom')  { sPos = 'bottom'; }
   else if (strPosition == 'Bottom')  { sPos = 'bottom'; }
   else if (regexRight.exec(strPosition) != null)
   {
      sPos = 'right';
      if (nWidth == 0 && nHeight == 0)
      {
         nWidth = 160;
         nHeight = 600;
      }
   }

   if (sPos == '') { sPos = 'top'; } 

   DisplayAd(sPos, nWidth, nHeight);
}

function DisplaySpot(strPosition, nWidth, nHeight, strCampaign)
{
   var sPos;
   if      (strPosition == 'top')     { sPos = 'top'; }
   else if (strPosition == 'Top')     { sPos = 'top'; }
   else if (strPosition == 'right')   { sPos = 'right'; }
   else if (strPosition == 'Right')   { sPos = 'right'; }
   else if (strPosition == 'bottom')  { sPos = 'bottom'; }
   else if (strPosition == 'Bottom')  { sPos = 'bottom'; }
   else                               { sPos = 'right'; }

   DisplayAd(sPos, nWidth, nHeight);
}

function showAd(adStyle)
{
   switch (adStyle) //currently just banner ads
   { 
      default:  //Serve an Ad Banner
         DisplayAd("top", 468, 60);
         break;
   }
}

function DisplayAd(strPosition, nWidth, nHeight)
{
   iAdNumber += 1;

   //----------------------------------------
   // Clean up size
   //----------------------------------------
   if (nWidth == 180 && nHeight == 0)
   {
      nWidth  = 185;
      nHeight = 75;
   } else if (nWidth == 175 && nHeight == 0)
   {
      nHeight = 233;
   } else if (nWidth == 0 && nHeight == 0 && strPosition == 'right')
   {
      nWidth = 160;
      nHeight = 600;
   }

   var sPrefix = 'tgn';
   var sProperty = 'genealogy.com';

   //----------------------------------------
   // Determine Zone
   //----------------------------------------
   var sPath = location.pathname;
   var sHost = location.host;

   var sZone = 'main';

   var regexGenForum = /genforum/i;
   var regexUHP      = /\/users\//;
   if (regexGenForum.exec(sHost) != null)
   {
      sZone = 'messageboards';
   } else if (regexUHP.exec(sPath) != null)
   {
      sZone = 'userhome';
   } else
   {
      sZone = 'main';
   }

   //----------------------------------------
   // Build DARTSiteZone
   //----------------------------------------
   var sDARTSiteZone = sPrefix + '.' + sProperty + '/' + sZone;

   //----------------------------------------
   // Build Params
   //----------------------------------------

   var sParams = ';tile=' + iAdNumber
               + ';lang=en'
               + ';sz=' + nWidth + 'x' + nHeight
               + ';ord=' + RNS;
   if (strPosition != null)
   {
      sParams = sParams + ';pos=' + strPosition;
   }

   //----------------------------------------
   // Build final URL and request the ad
   //----------------------------------------

   var sURL = 'http://ad.doubleclick.net/adj/' + sDARTSiteZone + sParams + '?';

//   document.write('<pre>' + sURL + '</pre>');
   document.write('<SCR' + 'IPT LANGUAGE="JavaScript1.1" SRC="' + sURL + '"></SCR' + 'IPT>');
}


