/**
 * @file    Overview    Topic Area specific javascript functions.
 *                  Init Date: Thu, 09 Apr 2009 21:15:40 EST.
 *                  Build Date: Thu, 09 Apr 2009 21:15:40 EST.
 *                  Copyright (C) Discovery.com 2009. All Rights Reserved.
 * @name    carl lewin
 *
 *          $Id: adsense-for-content.js,v 1.2.4.16 2009/11/13 18:28:09 sngai Exp $
 */

/**
 * @var        set by page level variables before file load
 */
var googleAFCContainerId = "google-afc-region-" + googleAFCRegion,
    googleAFCContainerObject = document.getElementById(googleAFCContainerId);


/**
 * @function        function executed by google js file
 * @description        creates html utilizing object properties from google then innerHTMLs string to page level id-ed container
 * @param       {object}         google_ads       object passed to function by google js file
 */
function google_ad_request_done(google_ads) {
        var googleAFCHTML = "",
            i;

        if (0 == google_ads.length ) { return; }

        if ("text" == google_ads[0].type) {
                googleAFCHTML += "<div class=\"" + googleAFCAssetType + googleAFCSubordinate + "\">";

                if ((googleAFCAssetType == "blog") || (googleAFCAssetType == "forum") || (googleAFCAssetType == "tv-schedule") || (-1 != (window.location.hostname).indexOf("news."))) {
                        googleAFCHTML += "<div class=\"afc-headline png\"><a href=\"https://www.google.com/adsense/support/bin/request.py?contact=abg_afc&amp;gl=US&amp;hideleadgen=1\" target=\"_blank\">Ads by Google</a></div>";
                } else {
                        googleAFCHTML += "<div class=\"afc-headline png\"><a href=\"https://www.google.com/adsense/support/bin/request.py?contact=abg_afc&amp;gl=US&amp;hideleadgen=1\" target=\"_blank\"><img src=\"/shared/images/transparent.gif\" alt=\"Ads by Google\" width=\"150\" height=\"31\" /></a></div>";
                }

                googleAFCHTML += "<ul class=\"afc-list clear clearfix\">";
                for (i = 0; i < google_ads.length; i++) {
                        googleAFCHTML += "<li class=\"afc-item\">";
                        googleAFCHTML += "<a href=\"" + google_ads[i].url + "\" class=\"afc-title\" onmouseout=\"window.status=''\;\" onmouseover=\"window.status='go to " + google_ads[i].visible_url + "'\;\">" + google_ads[i].line1 + "</a><br />";
                        googleAFCHTML += "<a href=\"" + google_ads[i].url + "\" class=\"afc-description\" onmouseout=\"window.status=''\;\" onmouseover=\"window.status='go to " + google_ads[i].visible_url + "'\;\">" + google_ads[i].line2 + google_ads[i].line3 + "</a><br />";
                        googleAFCHTML += "<a href=\"" + google_ads[i].url + "\" class=\"afc-url\" onmouseout=\"window.status=''\;\" onmouseover=\"window.status='go to " + google_ads[i].visible_url + "'\;\">" + google_ads[i].visible_url + "</a><br />";
                        googleAFCHTML += "</li>";
                }
                googleAFCHTML += "</ul>";
                googleAFCHTML += "</div>";
                googleAFCContainerObject.innerHTML = googleAFCHTML;
        }
}
