﻿function InitGAFS(afs_query, afs_ad, afs_client, afs_channel, afs_adpage) {
    google_afs_query = afs_query;
    google_afs_ad = afs_ad; // specify the number of ads you are requesting
    google_afs_client = afs_client; // substitute your client ID
    google_afs_channel = afs_channel; // enter your comma-separated channel IDs
    google_afs_hl = "zh-CN"; // enter your interface language if not English
    google_afs_gl = 'cn';
    //google_afs_ie = 'gb2312'; // select input encoding scheme
    //google_afs_oe = 'gb2312'; // select output encoding scheme
    google_afs_adsafe = 'medium'; // specify level for filtering non-family-safe ads
    google_afs_adtest = 'off'; // ** set parameter to off before launch to production
    google_afs_adpage = afs_adpage;
}
function OutputGAFS(){
document.write(unescape("%3Cscript type='text/javascript' language='JavaScript' src='http://www.google.com/afsonline/show_afs_ads.js'%3E%3C/script%3E"));
//document.write(unescape("%3Cscript type='text/javascript' language='JavaScript' src='http://www.google.cn/afsonline/show_afs_ads_cn.js'%3E%3C/script%3E"));
}
function InitGAFC(ad_client, ad_channel, max_num_ads, ad_type, image_size) {
    google_ad_client = ad_client; // 此处填上您的pub-id号码(pub-#)
    google_ad_channel = ad_channel;
    google_ad_output = 'js';
    google_max_num_ads = max_num_ads;
    google_ad_type = ad_type;
    google_image_size = image_size;
    google_feedback = 'on';
}
function OutputGAFC() {
    document.write(unescape("%3Cscript type='text/javascript' language='JavaScript' src='http://pagead2.googlesyndication.com/pagead/show_ads.js'%3E%3C/script%3E"));
}

function ga_160() {
    document.writeln('<script type="text/javascript"><!--');
    document.writeln('google_ad_client = "pub-3388570396365381";');
    document.writeln('/* WWW.ZHIGOU.COM LIST页面 160x600 */');
    document.writeln('google_ad_slot = "0579427308";');
    document.writeln('google_ad_width = 160;');
    document.writeln('google_ad_height = 600;');
    document.writeln('//-->');
    document.writeln('</script>');
    document.writeln('<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">');
    document.writeln('</script>');
}
function ga_728() {
    document.writeln('<script type="text/javascript"><!--');
    document.writeln('google_ad_client = "pub-3388570396365381";');
    document.writeln('/* WWW.ZHIGOU.COM LIST页面 160x600 */');
    document.writeln('google_ad_slot = "3987455344";');
    document.writeln('google_ad_width = 728;');
    document.writeln('google_ad_height = 90;');
    document.writeln('//-->');
    document.writeln('</script>');
    document.writeln('<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">');
    document.writeln('</script>');
}
function ga_200() {
    document.writeln('<script type="text/javascript"><!--');
    document.writeln('google_ad_client = "pub-3388570396365381";');
    document.writeln('/* WWW.ZHIGOU.COM LIST页面 160x600 */');
    document.writeln('google_ad_slot = "9513060022";');
    document.writeln('google_ad_width = 200;');
    document.writeln('google_ad_height = 200;');
    document.writeln('//-->');
    document.writeln('</script>');
    document.writeln('<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">');
    document.writeln('</script>');
}

var g_bGWShow = false;
var g_bGNShow = false;
function google_afs_request_done(google_ads) {
    /*
    * Verify that there are actually ads to display.
    */
    var google_num_ads = google_ads.length;
    //    if (google_num_ads <= 0)
    //        return;

    var wideAds = "";   //wide ad unit html text
    var wideAds2 = "";   //wide ad unit html text
    var narrowAds = "";   //narrow ad unit html text

    var bWideClosed = false;
    var bWideClosed2 = false;
    for (i = 0; i < google_num_ads; i++) {
        if (google_ads[i].type == "text/wide") {
            //** render a wide ad
            if (i < 3) {
                wideAds += '<div class="gaitem gaitemw">';
                wideAds += '<span class="gatitle"><a target="_blank" href="' + google_ads[i].url + '">' + '<b>' + google_ads[i].line1 + '</b></a></span>' +
                '<span class="gatext">' + google_ads[i].line2 + '</span>' +
                '<span class="gasite"><a target="_blank" href="' + google_ads[i].url + '">' + google_ads[i].visible_url + '</a></span>';
                wideAds += '</div>';
            }
            else {
                wideAds2 += '<div class="gaitem gaitemw">';
                wideAds2 += '<span class="gatitle"><a target="_blank" href="' + google_ads[i].url + '">' + '<b>' + google_ads[i].line1 + '</b></a></span>' +
                '<span class="gatext">' + google_ads[i].line2 + '</span>' +
                '<span class="gasite"><a target="_blank" href="' + google_ads[i].url + '">' + google_ads[i].visible_url + '</a></span>';
                wideAds2 += '</div>';
            }
        }
        else {
            //render a narrow ad
            narrowAds += '<div class="gaitem">';
            narrowAds += '<span class="gatitle"><a target="_blank" href="' + google_ads[i].url + '">' +  '<b>' + google_ads[i].line1 + '</b></a></span>' +
            '<span class="gatext">' + google_ads[i].line2 + ' ' + google_ads[i].line3 + '</span>' +
            '<span class="gasite"><a target="_blank" href="' + google_ads[i].url + '">' + google_ads[i].visible_url + '</a></span>';
            narrowAds += '</div>';
        }
    }
    if (narrowAds != "") {
        g_bGNShow = true;
        narrowAds = '<div class="gahead"><a href="https://www.google.com/adsense/support/bin/request.py?contact=afs_violation" target="_blank">Google提供的广告</a></div>' + narrowAds;
    }

    if (wideAds != "") {
        g_bGWShow = true;
        wideAds = '<div class="gahead"><span class="text"><a href="https://www.google.com/adsense/support/bin/request.py?contact=afs_violation" target="_blank">Google提供的广告</a></span></div>' + wideAds;
    }

    if (wideAds2 != "") {
        g_bGWShow = true;
        wideAds2 = '<div class="gahead"><span class="text"><a href="https://www.google.com/adsense/support/bin/request.py?contact=afs_violation" target="_blank">Google提供的广告</a></span></div>' + wideAds2;
    }

    //** Write HTML for wide and narrow ads to the proper <div> elements
    $("#gwcon").html(wideAds);
    $("#gwcon2").html(wideAds2);
    $("#gncon").html(narrowAds);

    if (!g_bGNShow && !g_bGWShow) {
        InitGAFC('pub-3388570396365381', '8215577078', '9', 'text', '728X90');
        OutputGAFC();
    }
}

var gAfcNarrowOnly = false;
function google_ad_request_done(google_ads) {
    /*
    * 该函数是必须的，是用于展示来自JavaScript请求的
    * 广告。您可以修改本段代码以使其符合您网页的
    * 设计和布局的命令
    */
    var gAfcWideA = '';
    var gAfcWideB = '';
    var gAfcNarrow = '';
    var i;
    /*
    * 验证此处真的有广告展示。
    */
    if (google_ads.length == 0) {
        return;
    }
    /*
    * 如果返回的是一个图片或Flash广告，则展示该广告。
    * 否则，建立一个包含所有广告的字符串之后再使用
    * document.write 命令打印该字符串
    */
    if (google_ads[0].type == "text") {
        /*
        * 发布商可以修改文字大小。
        * 使文字占用广告单元的大部分空间。
        */
        if (!gAfcNarrowOnly) {
            for (i = 0; i < google_ads.length && i < 3; ++i) {
                /*优先填充横幅广告位--在第一屏--取3条价格最高的广告单元*/
                gAfcWideA += '<div class="gaitem gaitemw">';
                gAfcWideA += '<span class="gatitle"><a target="_blank" href="' + google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'去' + google_ads[i].visible_url + '\';return true">' + '<b>' + google_ads[i].line1 + '</b></a></span>' +
                '<span class="gatext">' + google_ads[i].line2 + ' ' + google_ads[i].line3 + 
                '<a target="_blank" href="' + google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'去' + google_ads[i].visible_url + '\';return true">' + google_ads[i].visible_url + '</a></span>';
                gAfcWideA += '</div>';               
            }
            for (i = 3; i < google_ads.length; ++i) {
                gAfcNarrow += '<div class="gaitem">';
                gAfcNarrow += '<span class="gatitle"><a target="_blank" href="' + google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'去' + google_ads[i].visible_url + '\';return true">' + '<b>' + google_ads[i].line1 + '</b></a></span>' +
                '<span class="gatext">' + google_ads[i].line2 + ' ' + google_ads[i].line3 + '</span>' +
                '<span class="gasite"><a target="_blank" href="' + google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'去' + google_ads[i].visible_url + '\';return true">' + google_ads[i].visible_url + '</a></span>';
                gAfcNarrow += '</div>';
            }
        }
        else {
            for (i = 0; i < google_ads.length; ++i) {
                gAfcNarrow += '<div class="gaitem">';
                gAfcNarrow += '<span class="gatitle"><a target="_blank" href="' + google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'去' + google_ads[i].visible_url + '\';return true">' + '<b>' + google_ads[i].line1 + '</b></a></span>' +
                '<span class="gatext">' + google_ads[i].line2 + ' ' + google_ads[i].line3 + '</span>' +
                '<span class="gasite"><a target="_blank" href="' + google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'去' + google_ads[i].visible_url + '\';return true">' + google_ads[i].visible_url + '</a></span>';
                gAfcNarrow += '</div>';
            }
        }
    }
    if (!gAfcNarrowOnly) {
        if (gAfcNarrow != "") {
            gAfcNarrow = '<span class="gahead"><a href=\"' + google_info.feedback_url + '\">Google提供的广告</a></span>' + gAfcNarrow;
            $("#gncon").html(gAfcNarrow); $("#gncon").show();
        }
        if (gAfcWideA != "") {
            gAfcWideA = '<span class="gahead"><a href=\"' + google_info.feedback_url + '\">Google提供的广告</a></span>' + gAfcWideA;
            $("#gwcon").html(gAfcWideA); $("#gwcon").show();
        }
    }
    else {
        if (gAfcNarrow != "") {
            gAfcNarrow = '<span class="gahead"><a href=\"' + google_info.feedback_url + '\">Google提供的广告</a></span>' + gAfcNarrow;
            $("#gncon").html(gAfcNarrow); $("#gncon").show();
        }
    }
}