var google_ads_disp = 0;
var google_ad_output = 'js';
var google_feedback = 'on';
var google_language='de';

function google_afs_request_done(google_ads) {
        google_afs_gl = 'de';
        google_afs_hl = 'de';
        printResult(google_ads);
}

function google_ad_request_done(google_ads) {printResult(google_ads);}

function printResult(google_ads) {

        /*
        * This function is required and is used to display
        * the ads that are returned from the JavaScript
        * request. You should modify the document.write
        * commands so that the HTML they write out fits
        * with your desired ad layout.
        */
        var wideAds = '';
        var narrowAds = '';
        var i;

        /*
        * Verify that there are actually ads to display.
        */

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

        /*
        * If an image or flash ad is returned, display that ad.
        * Otherwise, build a string containing all of the ads and
        * then use a document.write() command to print that string.
        */
        if (typeof(google_info) == "undefined") {
                feedback_url = 'https://www.google.com/adsense/support/bin/request.py?contact=afs_violation';
        } else {
                feedback_url = google_info.feedback_url;
        }

        if (google_ads[0].type == "flash") {
                narrowAds += '<a href=\"' + feedback_url + '\" style="color: #808080; font-size: 11px; text-align: right; text-decoration: none;">Google Anzeigen</a><br>' +
                                         '<p style="text-align: center; margin: 0 auto;">' +
                '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
                ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="' +
                google_ad.image_width + '" HEIGHT="' +
                google_ad.image_height + '"> <PARAM NAME="movie" VALUE="' +
                google_ad.image_url + '">' +
                '<PARAM NAME="quality" VALUE="high">' +
                '<PARAM NAME="AllowScriptAccess" VALUE="never">' +
                '<EMBED src="' +
                google_ad.image_url + '" WIDTH="' +
                google_ad.image_width + '" HEIGHT="' +
                google_ad.image_height +
                '" TYPE="application/x-shockwave-flash"' +
                ' AllowScriptAccess="never" ' +
                ' PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT></p>';
        } else if (google_ads[0].type == "image") {
                narrowAds += '<a href=\"' + feedback_url + '\" style="color: #808080; font-size: 11px; text-align: right; text-decoration: none;">Google Anzeigen</a><br>' +
                                         '<p style="text-align: center; margin: 0 auto;"><a target="_blank" href="' +
                google_ads[0].url + '" target="_top" title="go to ' +
                google_ads[0].visible_url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
                google_ads[0].visible_url + '\';return true"><img border="0" src="' +
                google_ads[0].image_url + '"width="' +
                google_ads[0].image_width + '"height="' +
                google_ads[0].image_height + '"></a></p>';
        } else if (google_ads[0].type == "html") {
                narrowAds += google_ads[0].snippet;
        } else {
                if (google_ads.length == 1) {
                        if (typeof(google_ads[0].line3) == "undefined") {
                                line3 = '';
                        } else {
                                line3 = google_ads[0].line3;
                        }
                }
                /*
                * Partners should adjust text sizes
                * so ads occupy the majority of ad space.
                */
                feedback = '<a href=\"' + feedback_url + '\" style="color: #808080; font-size: 11px; text-align: right; text-decoration: none;">Google Anzeigen</a><br>';

        ul = '<ul style="float: none; margin-bottom: 20px; list-style-type: none; padding: 0px;text-align:left;">';
        li = '<li onmouseout="this.style.backgroundColor=\'\'" onmouseover="this.style.backgroundColor=\'#eee\'" ' +
                 'style="float: left; padding-bottom: 5px; padding-top: 5px; line-height: 20px; width:100%;"> ';
        testchannel = 0;

        if(typeof(netdoktor_ad_style) != "undefined"){
                switch(netdoktor_ad_style){
                        case 'themenboard_red':
                        case 'themenboard_blue':
                        case 'themenboard_blue_single':
                            ul = '<ul class="ads_themenboard_default_ul">';
                            li = '<li class="ads_themenboard_default_li_row"> ';
                            break;
                        case 'themenboard_round':
                            ul = '<ul class="ads_themenboard_round_ul">';
                            li = '<li class="ads_themenboard_round_li_row"> ';
                            break;
                        default:
                            ul = '<ul class="ads_themenboard_default_ul">';
                            li = '<li class="ads_themenboard_default_li_row"> ';
                            break;
                }
        }
        if (typeof(netdoktor_ad_channels) == "undefined") testchannel = 0;
        else if (netdoktor_ad_channels.indexOf('testchannel_1') != -1) {
            testchannel = 1;
        } else if (netdoktor_ad_channels.indexOf('testchannel_2') != -1) {
            testchannel = 2;
        } else if (netdoktor_ad_channels.indexOf('testchannel_3') != -1) {
            testchannel = 3;
        } else if (netdoktor_ad_channels.indexOf('testchannel_4') != -1) {
            testchannel = 4;
        }

                if (google_ads.length == 1) {
                        if (google_ads[0].type=="text/wide") {
                                wideAds += ul + li + feedback + renderAdRow(google_ads[0], line3, testchannel) + '</li></ul>';
                        } else {
                                narrowAds += ul + li + feedback + renderAdRow(google_ads[0], line3, testchannel) + '</li></ul>';
                        }
                } else if (google_ads.length > 1) {
                        wideAds += feedback + ul;
                        narrowAds += feedback + ul;

                        for(i = 0; i < google_ads.length; ++i) {
                                if (typeof(google_ads[i].line3) == "undefined") {
                                        line3 = '';
                                } else {
                                        line3 = google_ads[i].line3;
                                }

                                if (google_ads[i].type=="text/wide") {
                                        wideAds += li + renderAdRow(google_ads[i], line3, testchannel) + ' </li>';
                                } else {
                                        narrowAds += li + renderAdRow(google_ads[i], line3, testchannel) + ' </li>';
                                }
                        }

                        wideAds += '</ul>';
                        narrowAds += '</ul>';
                }
        }

        if (typeof(google_info) == "undefined") {
            document.getElementById("afs_bottom").innerHTML = wideAds;
            document.getElementById("afs_side").innerHTML = narrowAds;
        } else {
                document.write(narrowAds);
        }

        return;
}

function renderAdRow(google_ad_item, line3, testchannel) {
    /* default */
    $renderedAdRow =
        '<a class="navlink" onmouseout="this.className=\'navlink\'" onmouseover="this.className=\'navlinkover\'" ' +
            'target="_blank" href="' + google_ad_item.url + '" onmouseout="window.status=\'\'" ' +
            'onmouseover="window.status=\'go to ' + google_ad_item.visible_url + '\';return true"> ' + google_ad_item.line1 + '</a>' +
        '<div style="color:#000000; font-size: 13.5px; clear:both; width:100%;">' + google_ad_item.line2 + '&nbsp;' + line3  + '</div>' +
        '<div style="margin-top: -4px; clear:both; width:100%;">' +
        '<a style="color: #808080; text-decoration: none; font-size: 11px;" ' +
           'target="_blank" href="' + google_ad_item.url + '" onmouseout="window.status=\'\'" ' +
           'onmouseover="window.status=\'go to ' + google_ad_item.visible_url + '\';return true">' + google_ad_item.visible_url +
        '</a>' +
        '</div>';

    if (testchannel == 1) {
        $renderedAdRow =
            '<a class="navlink" onmouseout="this.className=\'navlink\'" onmouseover="this.className=\'navlinkover\'" ' +
            'target="_blank" href="' + google_ad_item.url + '" onmouseout="window.status=\'\'" ' +
            'onmouseover="window.status=\'go to ' + google_ad_item.visible_url + '\';return true"> ' + google_ad_item.line1 + '</a>' +
        '<div style="color:#000000; font-size: 13.5px; clear:both; width:100%;">' + google_ad_item.line2 + '&nbsp;' + line3  + '</div>' +
        '<div style="margin-top: -4px; clear:both; width:100%;">' +
        '<a style="color: #808080; text-decoration: none; font-size: 11px;" ' +
           'target="_blank" href="' + google_ad_item.url + '" onmouseout="window.status=\'\'" ' +
           'onmouseover="window.status=\'go to ' + google_ad_item.visible_url + '\';return true">' + google_ad_item.visible_url +
        '</a>' +
        '</div>';
    } else if (testchannel == 2) {
        $renderedAdRow =
        '<a class="navlink" style="text-decoration: none;" onmouseout="this.className=\'navlink\'" onmouseover="this.className=\'navlinkover\'" ' +
            'target="_blank" href="' + google_ad_item.url + '" onmouseout="window.status=\'\'" ' +
            'onmouseover="window.status=\'go to ' + google_ad_item.visible_url + '\';return true"> ' + google_ad_item.line1 + '</a>' +
        '<div style="color:#000000; font-size: 13.5px; clear:both; width:100%;">' + google_ad_item.line2 + '&nbsp;' + line3  + '</div>' +
        '<div style="margin-top: -4px; clear:both; width:100%;">' +
        '<a style="color: #808080; text-decoration: none; font-size: 11px;" ' +
           'target="_blank" href="' + google_ad_item.url + '" onmouseout="window.status=\'\'" ' +
           'onmouseover="window.status=\'go to ' + google_ad_item.visible_url + '\';return true">' + google_ad_item.visible_url +
        '</a>' +
        '</div>';
    } else if (testchannel == 3) {
        $renderedAdRow =
        '<a class="navlink_nounderline" onmouseout="this.className=\'navlink_nounderline\'" onmouseover="this.className=\'navlink\'" ' +
            'target="_blank" href="' + google_ad_item.url + '" onmouseout="window.status=\'\'" ' +
            'onmouseover="window.status=\'go to ' + google_ad_item.visible_url + '\';return true"> ' + google_ad_item.line1 + '</a>' +
        '<div style="color:#000000; font-size: 13.5px; clear:both; width:100%;">' + google_ad_item.line2 + '&nbsp;' + line3  + '</div>' +
        '<div style="margin-top: -4px; clear:both; width:100%;">' +
        '<a style="color: #808080; text-decoration: none; font-size: 11px;" ' +
           'target="_blank" href="' + google_ad_item.url + '" onmouseout="window.status=\'\'" ' +
           'onmouseover="window.status=\'go to ' + google_ad_item.visible_url + '\';return true">' + google_ad_item.visible_url +
        '</a>' +
        '</div>';
    } else if (testchannel == 4) {
        $renderedAdRow =
        '<a class="navlinkgrey" onmouseout="this.className=\'navlinkgrey\'" onmouseover="this.className=\'navlinkover\'" ' +
            'target="_blank" href="' + google_ad_item.url + '" onmouseout="window.status=\'\'" ' +
            'onmouseover="window.status=\'go to ' + google_ad_item.visible_url + '\';return true"> ' + google_ad_item.line1 + '</a>' +
        '<div style="color:#191919; font-size: 13.5px; clear:both; width:100%;">' + google_ad_item.line2 + '&nbsp;' + line3  + '</div>' +
        '<div style="margin-top: -4px; clear:both; width:100%;">' +
        '<a style="color: #999999; text-decoration: none; font-size: 11px;" ' +
           'target="_blank" href="' + google_ad_item.url + '" onmouseout="window.status=\'\'" ' +
           'onmouseover="window.status=\'go to ' + google_ad_item.visible_url + '\';return true">' + google_ad_item.visible_url +
        '</a>' +
        '</div>';
    }

    /* Themenboard Designs */
        if(typeof(netdoktor_ad_style) != "undefined" && netdoktor_ad_style == 'themenboard_default') {

        $renderedAdRow =
            '<a class="ads_themenboard_default_header" ' +
                'target="_blank" href="' + google_ad_item.url + '" onmouseout="window.status=\'\'" ' +
                'onmouseover="window.status=\'go to ' + google_ad_item.visible_url + '\';return true"> ' + google_ad_item.line1 + '</a>' +
            '<div class="ads_themenboard_default_content_string">' + google_ad_item.line2 + '&nbsp;' + line3  + '</div>' +
            '<div class="ads_themenboard_default_url_string">' +
            '<a class="ads_themenboard_default_url_link" target="_blank" href="' + google_ad_item.url + '" onmouseout="window.status=\'\'" ' +
               'onmouseover="window.status=\'go to ' + google_ad_item.visible_url + '\';return true">' + google_ad_item.visible_url +
            '</a>' +
            '</div>';
        }
        if(typeof(netdoktor_ad_style) != "undefined" && netdoktor_ad_style == 'themenboard_red') {

        $renderedAdRow =
            '<a class="ads_themenboard_red_header" ' +
                'target="_blank" href="' + google_ad_item.url + '" onmouseout="window.status=\'\'" ' +
                'onmouseover="window.status=\'go to ' + google_ad_item.visible_url + '\';return true"> ' + google_ad_item.line1 + '</a>' +
            '<div class="ads_themenboard_default_content_string">' + google_ad_item.line2 + '&nbsp;' + line3  + '</div>' +
            '<div class="ads_themenboard_default_url_string">' +
            '<a class="ads_themenboard_default_url_link ads_themenboard_red_link" target="_blank" href="' + google_ad_item.url + '" onmouseout="window.status=\'\'" ' +
               'onmouseover="window.status=\'go to ' + google_ad_item.visible_url + '\';return true">' + google_ad_item.visible_url +
            '</a>' +
            '</div>';
        }
        if(typeof(netdoktor_ad_style) != "undefined" && netdoktor_ad_style == 'themenboard_blue') {

        $renderedAdRow =
            '<a class="ads_themenboard_blue_header" ' +
                'target="_blank" href="' + google_ad_item.url + '" onmouseout="window.status=\'\'" ' +
                'onmouseover="window.status=\'go to ' + google_ad_item.visible_url + '\';return true"> ' + google_ad_item.line1 + '</a>' +
            '<div class="ads_themenboard_default_content_string">' + google_ad_item.line2 + '&nbsp;' + line3  + '</div>' +
            '<div class="ads_themenboard_default_url_string">' +
            '<a class="ads_themenboard_default_url_link ads_themenboard_blue_link" target="_blank" href="' + google_ad_item.url + '" onmouseout="window.status=\'\'" ' +
               'onmouseover="window.status=\'go to ' + google_ad_item.visible_url + '\';return true">' + google_ad_item.visible_url +
            '</a>' +
            '</div>';
        }

        if(typeof(netdoktor_ad_style) != "undefined" && netdoktor_ad_style == 'themenboard_red_single') {

        $renderedAdRow =
            '<a class="ads_themenboard_red_header" ' +
                'target="_blank" href="' + google_ad_item.url + '" onmouseout="window.status=\'\'" ' +
                'onmouseover="window.status=\'go to ' + google_ad_item.visible_url + '\';return true"> ' + google_ad_item.line1 + '</a>' +
            '<div class="ads_themenboard_default_content_string ads_themenboard_red_single_content_string">' + google_ad_item.line2 + '&nbsp;' + line3  + '</div>' +
            '<div class="ads_themenboard_default_url_string ads_themenboard_red_single_url_string">' +
            '<a class="ads_themenboard_default_url_link ads_themenboard_red_single_link" target="_blank" href="' + google_ad_item.url + '" onmouseout="window.status=\'\'" ' +
               'onmouseover="window.status=\'go to ' + google_ad_item.visible_url + '\';return true">' + google_ad_item.visible_url +
            '</a>' +
            '</div>';
        }

        if(typeof(netdoktor_ad_style) != "undefined" && netdoktor_ad_style == 'themenboard_round') {

        $renderedAdRow =
            '<a class="ads_themenboard_round_header" ' +
                'target="_blank" href="' + google_ad_item.url + '" onmouseout="window.status=\'\'" ' +
                'onmouseover="window.status=\'go to ' + google_ad_item.visible_url + '\';return true"> ' + google_ad_item.line1 + '</a>' +
            '<div class="ads_themenboard_round_content_string">' + google_ad_item.line2 + '&nbsp;' + line3  + '</div>' +
            '<div class="ads_themenboard_round_url_string">' +
            '<a class="ads_themenboard_round_url_link" target="_blank" href="' + google_ad_item.url + '" onmouseout="window.status=\'\'" ' +
               'onmouseover="window.status=\'go to ' + google_ad_item.visible_url + '\';return true">' + google_ad_item.visible_url +
            '</a>' +
            '</div>';
        }


    return $renderedAdRow;
}

