
/* this script determines the following ad promotions:
      I.  P1 (left) 160x100 in house promotions
     II.  P2 (right) 160x100 in house promotions
    III.  328x90 promo (below whopper AD)
     IV.  atomz
*/


// I. P1 (left) spot values
var crafts_P1_link          = "http://familyfun.go.com/arts-and-crafts/season/specialfeature/halloween_ms_pumpkins?int_cmp=BAC-FF_ArtsCrafts-P1",
    crafts_P1_imageSrc      = "http://familyfun.go.com/DailyResources/images/ads/0906_pumpkincarving_160x100.jpg",
    crafts_P1_imageAlt      = "Pumpkin Carving",
    crafts_P1_target        = "_self",
    games_P1_link           = "http://familyfun.go.com/halloween?int_cmp=BAC-FF_Games-P1",
    games_P1_imageSrc       = "http://familyfun.go.com/DailyResources/images/ads/0807_halloween_160x100.jpg",
    games_P1_imageAlt       = "Halloween Main",
    games_P1_target         = "_self",
    parties_P1_link         = "http://familyfun.go.com/utilities/global/feature/fftv-archive-video-player/fftv-archive-video-player.html?dl_section=channel&dl_channel=Halloween&int_cmp=BAC-FF_Parties-P1",
    parties_P1_imageSrc     = "http://familyfun.go.com/DailyResources/images/ads/0907_halloween_gen_160x100.jpg",
    parties_P1_imageAlt     = "Halloween Videos",
    parties_P1_target       = "_self",
    recipes_P1_link         = "http://familyfun.go.com/printables/season/specialfeature/halloween-printables-ms?int_cmp=BAC-FF_Recipes-P1",
    recipes_P1_imageSrc     = "http://familyfun.go.com/DailyResources/images/ads/0906_halloweenprint_160x100.gif",
    recipes_P1_imageAlt     = "Halloween Printables",
    recipes_P1_target       = "_self",
    travel_P1_link          = "http://familyfun.go.com/halloween?int_cmp=BAC-FF_Travel-P1",
    travel_P1_imageSrc      = "http://familyfun.go.com/DailyResources/images/ads/0807_halloween_160x100.jpg",
    travel_P1_imageAlt      = "Halloween Main",
    travel_P1_target        = "_self",
    magazine_P1_link        = "https://register.go.com/family/artsandcrafts/login?int_cmp=BAC-FF_Magazine-P1",
    magazine_P1_imageSrc    = "http://familyfun.go.com/DailyResources/images/ads/1206_craftnews_160x100.jpg",
    magazine_P1_imageAlt    = "Craft Newsletter",
    magazine_P1_target      = "_self",
    printables_P1_link      = "http://familyfun.go.com/printables/season/specialfeature/halloween-printables-ms?int_cmp=BAC-FF_Printables-P1",
    printables_P1_imageSrc  = "http://familyfun.go.com/DailyResources/images/ads/0906_halloweenprint_160x100.gif",
    printables_P1_imageAlt  = "Halloween Printables",
    printables_P1_target    = "_self",
    seasonal_P1_link        = "http://familyfun.go.com/arts-and-crafts/season/specialfeature/halloween_ms_crafts?int_cmp=BAC-FF_HolidaySeasonal-P1",
    seasonal_P1_imageSrc    = "http://familyfun.go.com/DailyResources/images/ads/0906_hauntedcrafts_160x100.jpg",
    seasonal_P1_imageAlt    = "Halloween Crafts",
    seasonal_P1_target      = "_self",
    default_P1_link         = "https://register.go.com/family/artsandcrafts/login?int_cmp=BAC-FF_Default-P1",
    default_P1_imageSrc     = "http://familyfun.go.com/DailyResources/images/ads/1206_craftnews_160x100.jpg",
    default_P1_imageAlt     = "Craft Newsletter",
    default_P1_target       = "_self";
    

// II. P2 (right) spot values
var crafts_P2_link          = "http://familyfun.go.com/halloween?int_cmp=BAC-FF_ArtsCrafts-P2",
    crafts_P2_imageSrc      = "http://familyfun.go.com/DailyResources/images/ads/0807_halloween_160x100.jpg",
    crafts_P2_imageAlt      = "Halloween Main",
    crafts_P2_target        = "_self",
    games_P2_link           = "http://familyfun.go.com/arts-and-crafts/season/specialfeature/halloween_ms_crafts?int_cmp=BAC-FF_Games-P2",
    games_P2_imageSrc       = "http://familyfun.go.com/DailyResources/images/ads/0906_hauntedcrafts_160x100.jpg",
    games_P2_imageAlt       = "Halloween Crafts",
    games_P2_target         = "_self",
    parties_P2_link         = "http://familyfun.go.com/arts-and-crafts/season/specialfeature/halloween_ms_crafts?int_cmp=BAC-FF_Parties-P2",
    parties_P2_imageSrc     = "http://familyfun.go.com/DailyResources/images/ads/0906_hauntedcrafts_160x100.jpg",
    parties_P2_imageAlt     = "Halloween Crafts",
    parties_P2_target       = "_self",
    recipes_P2_link         = "http://familyfun.go.com/arts-and-crafts/season/specialfeature/halloween_ms_pumpkins?int_cmp=BAC-FF_Recipes-P2",
    recipes_P2_imageSrc     = "http://familyfun.go.com/DailyResources/images/ads/0906_pumpkincarving_160x100.jpg",
    recipes_P2_imageAlt     = "Pumpkin Carving",
    recipes_P2_target       = "_self",
    travel_P2_link          = "http://familyfun.go.com/utilities/global/feature/fftv-archive-video-player/fftv-archive-video-player.html?dl_section=channel&dl_channel=Halloween&int_cmp=BAC-FF_Travel-P2",
    travel_P2_imageSrc      = "http://familyfun.go.com/DailyResources/images/ads/0907_halloween_gen_160x100.jpg",
    travel_P2_imageAlt      = "Halloween Videos",
    travel_P2_target        = "_self",
    magazine_P2_link        = "http://familyfun.go.com/cake-recipe-face-off?int_cmp=BAC-FF_Magazine-P2",
    magazine_P2_imageSrc    = "http://familyfun.go.com/DailyResources/images/ads/best-cake160x100.jpg",
    magazine_P2_imageAlt    = "Cake Face-off",
    magazine_P2_target      = "_self",
    printables_P2_link      = "http://familyfun.go.com/arts-and-crafts/season/specialfeature/halloween_ms_pumpkins?int_cmp=BAC-FF_Printables-P2",
    printables_P2_imageSrc  = "http://familyfun.go.com/DailyResources/images/ads/0906_pumpkincarving_160x100.jpg",
    printables_P2_imageAlt  = "Pumpkin Carving",
    printables_P2_target    = "_self",
    seasonal_P2_link        = "http://familyfun.go.com/utilities/global/feature/fftv-archive-video-player/fftv-archive-video-player.html?dl_section=channel&dl_channel=Halloween&int_cmp=BAC-FF_HolidaySeasonal-P2",
    seasonal_P2_imageSrc    = "http://familyfun.go.com/DailyResources/images/ads/0907_halloween_gen_160x100.jpg",
    seasonal_P2_imageAlt    = "Halloween Videos",
    seasonal_P2_target      = "_self",
    default_P2_link         = "http://familyfun.go.com/cake-recipe-face-off?int_cmp=BAC-FF_Default-P2",
    default_P2_imageSrc     = "http://familyfun.go.com/DailyResources/images/ads/best-cake160x100.jpg",
    default_P2_imageAlt     = "Cake Face-off",
    default_P2_target       = "_self";
    /*  Commented it out to replace later
    default_P2_link         = "http://familyfun.go.com/printables/craft-templates/specialfeature/scrapbooking-ideas/scrapbooking-ideas.html?int_cmp=BAC-FF_Default-P2",
    default_P2_imageSrc     = "http://familyfun.go.com/DailyResources/images/ads/0707_scrapbooking_160.jpg",
    default_P2_imageAlt     = "FamilyFun's Scrapbooking Ideas",
    default_P2_target       = "_self";
    */
    


    

// III. 328x90 promo (below whopper AD)
var crafts_328x90_link          = "http://familyfun.go.com/newsletter/?CMP=BAC-33PG05837504",
    crafts_328x90_imageSrc      = "http://familyfun.go.com/DailyResources/images/ads/0608_weekendernewsletter_3_328x90.jpg",
    crafts_328x90_imageAlt      = "Want more FamilyFun? Sign up to get craft ideas, recipes, printables, and more send to your e-mail! Go now!",
    crafts_328x90_target        = "_self",
    parties_328x90_link         = "http://familyfun.go.com/newsletter/?CMP=BAC-33PG05837504",
    parties_328x90_imageSrc     = "http://familyfun.go.com/DailyResources/images/ads/0608_weekendernewsletter_3_328x90.jpg",
    parties_328x90_imageAlt     = "Want more FamilyFun? Sign up to get craft ideas, recipes, printables, and more send to your e-mail! Go now!",
    parties_328x90_target       = "_self",
    recipes_328x90_link         = "http://familyfun.go.com/newsletter/?CMP=BAC-33PG05837504",
    recipes_328x90_imageSrc     = "http://familyfun.go.com/DailyResources/images/ads/0608_weekendernewsletter_3_328x90.jpg",
    recipes_328x90_imageAlt     = "Want more FamilyFun? Sign up to get craft ideas, recipes, printables, and more send to your e-mail! Go now!",
    recipes_328x90_target       = "_self",
    games_328x90_link           = "http://familyfun.go.com/newsletter/?CMP=BAC-33PG05837504",
    games_328x90_imageSrc       = "http://familyfun.go.com/DailyResources/images/ads/0608_weekendernewsletter_3_328x90.jpg",
    games_328x90_imageAlt       = "Want more FamilyFun? Sign up to get craft ideas, recipes, printables, and more send to your e-mail! Go now!",
    games_328x90_target         = "_self",
    travel_328x90_link          = "http://familyfun.go.com/newsletter/?CMP=BAC-33PG05837504",
    travel_328x90_imageSrc      = "http://familyfun.go.com/DailyResources/images/ads/0608_weekendernewsletter_3_328x90.jpg",
    travel_328x90_imageAlt      = "Want more FamilyFun? Sign up to get craft ideas, recipes, printables, and more send to your e-mail! Go now!",
    travel_328x90_target        = "_self",
    printables_328x90_link      = "http://familyfun.go.com/newsletter/?CMP=BAC-33PG05837504",
    printables_328x90_imageSrc  = "http://familyfun.go.com/DailyResources/images/ads/0608_weekendernewsletter_3_328x90.jpg",
    printables_328x90_imageAlt  = "Want more FamilyFun? Sign up to get craft ideas, recipes, printables, and more send to your e-mail! Go now!",
    printables_328x90_target    = "_self";
    
    
   
    
// IV. atomz
var atomz_link = "https://w1.buysub.com/servlet/OrdersGateway?cds_mag_code=FAF&cds_page_id=39095&cds_response_key=I9FWW6",
    atomz_imageSrc = "http://familyfun.go.com/DailyResources/images/ads/0707_10dollar_120x80.gif",
    atomz_imageAlt = "FamilyFun Magazine",
    atomz_target = "_self";



function insertP1_spot( solutionCenter )
{
  if( isSpecialCase( solutionCenter) ) { solutionCenter = "default"; }
  
  var P1_link     = eval( solutionCenter + "_P1_link" ),
      P1_imageSrc = eval( solutionCenter + "_P1_imageSrc" ),
      P1_imageAlt = eval( solutionCenter + "_P1_imageAlt" ),
      P1_target   = eval( solutionCenter + "_P1_target" );
    
  // the use of &lid= in the name attribute of the <a> tag allows for global link tracking (see the "Automatic Text Link and Position Tracking" at http://av.hitbox.com/ActiveViewing/HTMLFiles35/help/tracking_code.htm)
  document.write( '<a href="' + P1_link + '" target="' + P1_target + '" name="&lid=' + P1_imageSrc + '"><img src="' + P1_imageSrc + '" width="160" height="100" alt="' + P1_imageAlt + '" border="0"></a>' );
  trackImpression( P1_link );
}




function insertP2_spot( solutionCenter )
{
  if( isSpecialCase( solutionCenter) ) { solutionCenter = "default"; }
  
  var P2_link     = eval( solutionCenter + "_P2_link" ),
      P2_imageSrc = eval( solutionCenter + "_P2_imageSrc" ),
      P2_imageAlt = eval( solutionCenter + "_P2_imageAlt" ),
      P2_target   = eval( solutionCenter + "_P2_target" );
  
  // the use of &lid= in the name attribute of the <a> tag allows for global link tracking (see the "Automatic Text Link and Position Tracking" at http://av.hitbox.com/ActiveViewing/HTMLFiles35/help/tracking_code.htm)
  document.write( '<a href="' + P2_link + '" target="' + P2_target + '" name="&lid=' + P2_imageSrc + '"><img src="' + P2_imageSrc + '" width="160" height="100" alt="' + P2_imageAlt + '" border="0"></a>' );
  trackImpression( P2_link );  
}




function insert328x90( solutionCenter )
{
  if( isSpecialCase( solutionCenter) || solutionCenter == "magazine" || solutionCenter == "seasonal" ) { return; }
  
  var link     = eval( solutionCenter + "_328x90_link" ),
      imageSrc = eval( solutionCenter + "_328x90_imageSrc" ),
      imageAlt = eval( solutionCenter + "_328x90_imageAlt" ),
      target   = eval( solutionCenter + "_328x90_target" );
  
  document.write( '<a href="' + link + '" target="' + target + '"><img src="' + imageSrc + '" width="328" height="90" alt="' + imageAlt + '" border="0"></a>' );
}



function insertAtomzPromo()
{
  // the use of &lid= in the name attribute of the <a> tag allows for global link tracking (see the "Automatic Text Link and Position Tracking" at http://av.hitbox.com/ActiveViewing/HTMLFiles35/help/tracking_code.htm)
  document.write( '<a href="' + atomz_link + '" target="' + atomz_target + '" name="&lid=' + atomz_imageSrc + '"><img src="' + atomz_imageSrc + '" width="120" height="80" alt="' + atomz_imageAlt + '" border="0"></a>' );
  trackImpression( atomz_link );  
}



function insertFAQSubscription()      // used by the magazine FAQ page - http://familyfun.go.com/utilities/global/feature/familyfunmag_aboutmag/familyfunmag_aboutmag.html
{
  document.write( 'For a subscription for your own family, <a href="https://w1.buysub.com/servlet/OrdersGateway?cds_mag_code=FAF&cds_page_id=39095&cds_response_key=I9FWW3">click here</a>; ' );
  document.write( 'for a gift subscription, <a href="https://w1.buysub.com/servlet/GiftsGateway?cds_mag_code=FAF&cds_page_id=39038&cds_response_key=I9FWW14">click here</a>.' );
}



// used by the familyfun shop (1 of 3) - http://familyfun.go.com/utilities/helper/minisite/familyfun-shop/familyfun-shop.html
function insertShopSubscribeURL_1() { document.write( '<td valign="top" align="left"><a href="https://w1.buysub.com/servlet/OrdersGateway?cds_mag_code=FAF&cds_page_id=39095&cds_response_key=I9FWW4"><img height=176 alt="Order Subscriptions" src="/Resources/Features/utilities/global/order_sub.gif" width="123" border="0"></a></td>' ); }

// used by the familyfun shop (2 of 3)
function insertShopSubscribeURL_2() { document.write( '<a href="https://w1.buysub.com/servlet/OrdersGateway?cds_mag_code=FAF&cds_page_id=39095&cds_response_key=I9FWW4">Subscribe today!</a>' ); }

// used by the familyfun shop (3 of 3)
function insertShopSubscribeURL_3() { document.write( '<a class="shoptextfooter" href="https://w1.buysub.com/servlet/OrdersGateway?cds_mag_code=FAF&cds_page_id=39095&cds_response_key=I9FWW4">Order Subscriptions</a>' ); }


function insertHomeTopRightPromo() 
{ 
  /*document.write( '<a href="http://familyfun.go.com/fun-activities/" name="&lid=homepage_header_link1&amp;lpos=header_link1" onmouseover="buttonOn( \'bullet2\' )" onmouseout="buttonOff( \'bullet2\' )"><img src="http://familyfun.go.com/Resources/familyfun2005/images/home/bullet_green.gif" name="bullet2" border="0">Visit the Smile Center for crafts, recipes, and more fun activities</a><div class="spacer4p"></div>' ); 
  document.write( '<a href="http://familyfun.go.com/newsletter/" name="&lid=homepage_header_link2&amp;lpos=header_link2" onmouseover="buttonOn( \'bullet1\' )" onmouseout="buttonOff( \'bullet1\' )"><img src="http://familyfun.go.com/Resources/familyfun2005/images/home/bullet_green.gif" name="bullet1" border="0">Sign-up for free craft, recipe, and printables newsletters!</a>' ); */
  document.write( '<a href="https://register.go.com/family/login?appRedirect=https://register.go.com/family/update" name="&lid=homepage_header_link1&amp;lpos=header_link1" onmouseover="buttonOn( \'bullet1\' )" onmouseout="buttonOff( \'bullet1\' )"><img src="http://familyfun.go.com/Resources/familyfun2005/images/home/bullet_green.gif" name="bullet1" border="0">Sign-up for free craft, recipe, and printables newsletters!</a><div class="spacer4p"></div>' ); 
  document.write( '<a href="http://familyfun.go.com/recipes/family/tool/RecipeFinder/" name="&lid=homepage_header_link2&amp;lpos=header_link2" onmouseover="buttonOn( \'bullet2\' )" onmouseout="buttonOff( \'bullet2\' )"><img src="http://familyfun.go.com/Resources/familyfun2005/images/home/bullet_green.gif" name="bullet2" border="0">Search our recipe finder for quick meals, cute cakes &amp; more</a>' ); 
}


function insertNonHomeTopRightPromo() 
{ 
  document.write( '<span id="headerLinks"><a href="http://familyfun.go.com/utilities/global/feature/fftv-archive-video-player/fftv-archive-video-player.html?dl_section=channel&dl_channel=FamilyFun%20Minute" name="&lid=subpage_header_link1&amp;lpos=header_link1">FamilyFun Minute: 1 Everyday Item, 3 Quick Crafts</a></span><br>' );   
}


function insertMagazineSCPromo() 
{ 
  document.write( '<div id="headerLeftImages"><img src="http://familyfun.go.com/Resources/magazine/monthly/0508_ff0608_cover.jpg" width="149" height="193" alt="FamilyFun Magazine"><img src="http://familyfun.go.com/Resources/magazine/monthly/0508_ff0608_2links.jpg" width="214" height="193" alt="" usemap="#promos" border="0"></div>' );
  document.write( '<map name="promos">' );
  document.write( '  <area name="flipbook" coords="163,70,195,87" href="http://familyfun.go.com/Resources/familyfun2005/flash/flipbook/200806/flipbook.html?ILC-OA6528550882" target="_blank">' );
  document.write( '  <area name="subscription" coords="163,166,195,183" href="https://w1.buysub.com/servlet/OrdersGateway?cds_mag_code=FAF&cds_page_id=39095&cds_response_key=I9FWW5" target="_self">' );
  document.write( '</map>' );
}


function insertSubscriptionPlug( source )
{
  // possible values for source are "article", "craftFinder", and "recipeFinder"; although the last 2 are not used yet, they are placed just in case 
  
  if( source == "article" ) 
  { 
    document.write( '<br><span id="subscriptionPlug">' );
    document.write( '<a href="https://w1.buysub.com/servlet/OrdersGateway?cds_mag_code=FAF&cds_page_id=39095&cds_response_key=I9FWW7">Get 10 issues</a> of FamilyFun Magazine for only $10!<br>' );
    document.write( '<a href="https://w1.buysub.com/servlet/OrdersGateway?cds_mag_code=FAF&cds_page_id=39095&cds_response_key=I9FWW7 ">Click here</a> to subscribe now! <br>' );
    document.write( '</span>' ); 
  }
  else      // for both craftFinder and recipeFinder
  {
    document.write( '<div id="subscriptionPlug" style="text-align: left !important;">' );
    
    document.write( '  <div style="float: left; display: inline; margin: 5px 10px 0 30px;"><img src="http://familyfun.go.com/Resources/familyfun2005/images/COMMON/bullet_orange_light.jpg"></div>' );
    if( source == "craftFinder" ) document.write( '<div style="float: left;"><a href="https://register.go.com/family/artsandcrafts/login?CMP=ILC-EU6463879086">Sign up</a> for FamilyFun\'s free Arts &amp; Crafts Newsletter</div>' );
    if( source == "recipeFinder" ) document.write( '<div style="float: left;"><a href="https://register.go.com/family/recipes/login?CMP=ILC-RJ7862887756">Sign up</a> for FamilyFun\'s free Recipe Newsletter</div>' );
        
    document.write( '  <br clear="all">' );
    document.write( '  <div class="spacer6p"></div>' );
    document.write( '  <div style="float: left; display: inline; margin: 5px 10px 0 30px;"><img src="http://familyfun.go.com/Resources/familyfun2005/images/COMMON/bullet_orange_light.jpg"></div>' );
    document.write( '  <div style="float: left;">' );
    document.write( '    <a href="https://w1.buysub.com/servlet/OrdersGateway?cds_mag_code=FAF&cds_page_id=39095&cds_response_key=I9FWW7">Get 10 issues</a> of FamilyFun Magazine for only $10!<br>' );
    document.write( '    <a href="https://w1.buysub.com/servlet/OrdersGateway?cds_mag_code=FAF&cds_page_id=39095&cds_response_key=I9FWW7">Click here</a> to subscribe now! <br>' );
    document.write( '  </div>' ); 
    document.write( '</div>' ); 
  }
}


// utility
// **************************************************************************************
function isSpecialCase( solutionCenter )
{
  if( ( solutionCenter != "crafts" ) && 
      ( solutionCenter != "games" ) && 
      ( solutionCenter != "parties" ) && 
      ( solutionCenter != "recipes" ) && 
      ( solutionCenter != "travel" ) && 
      ( solutionCenter != "magazine" ) && 
      ( solutionCenter != "printables" ) &&
      ( solutionCenter != "seasonal" ) ) 
  { return true; }
  else { return false; }
}



function extractCampaignCode( url )
{  
  var campaignCode = "",
      codeStartIndex = url.indexOf( "CMP=" ),
      codeEndIndex;
      
  if( codeStartIndex != -1 )
  {
    codeStartIndex += 4;              // remove the "CMP="
    codeEndIndex = url.indexOf( "&", codeStartIndex );
    if( codeEndIndex == -1 ) codeEndIndex = url.length;
    campaignCode = url.substring( codeStartIndex, codeEndIndex );
  }
  
  return campaignCode;
}



var hitboxAccount = "DM5010114FVA52EN3";

function trackImpression( url )
{
//  var campaignCode = extractCampaignCode( url );
  
//  if( campaignCode != "" ) 
//    document.write( '<img src="http://ai.hitbox.com/ai?hb=' + hitboxAccount + '&ai=' + campaignCode + '" width="1" height="1" border="0">' );
}
