function google_ad_request_done(google_ads) {
    QLife.GoogleAds.requestDone(google_ads);
}

if (typeof(QLife) == 'undefined') {
    var QLife = {};
}

var google_adnum = 0;

QLife.GoogleAds = {
    /**
     * 広告タイプ - コンテンツ
     */
    ADS_CONTENTS : 1,
    /**
     * 広告タイプ - サイドバー
     */
    ADS_SIDEBAR : 2,
    /**
     * 広告タイプ - 左サイドバー
     */
    ADS_SIDEBAR2 : 3,
    /**
     * 広告タイプ
     */
    adsType : null,
    /**
     * 
     */
    setType : function(adsType) {
        this.adsType = adsType;
    },
    /**
     * 
     */
    requestDone : function(google_ads) {
        if (google_ads.length == 0) {
            return;
        }
        
        var s = '';
        var adsType = google_ads[0].type;
        if (adsType == 'flash') {
        	// Flash広告
        } else if (adsType == 'image') {
        	// 画像広告
            s += '<div class="ad_img"><a style="color: #000; font-weight: bold; text-decoration: none;" ' +
                'href="' + google_info.feedback_url + '">Ads by Google</a><br />';
        	s += '<a href="' + google_ads[0].url + '">' +
        		'<img border="0" src="' + google_ads[0].image_url + '"' +
                ' width="' + google_ads[0].image_width + '" height="' + google_ads[0].image_height + '"></a></div>';
        } else if (adsType == 'html') {
        	// HTML広告
            s += google_ads[0].snippet;
        } else {
        	// テキスト広告
            if (this.adsType == this.ADS_CONTENTS) {
                // コンテンツ内 
                s += '<p class="g_ads_title"><a href="' + google_info.feedback_url + '">Ads by Google</a></p>' +
                    '<dl class="g_ads_texttype">';
            } else if (this.adsType == this.ADS_SIDEBAR) {
                // サイドバー
                s += '<p class="g_ads_title"><a href="' + google_info.feedback_url + '">Ads by Google</a></p>' +
                '<dl class="g_ads_texttype">';
            } else if (this.adsType == this.ADS_SIDEBAR2) {
                // 左サイドバー
                s += '<p class="g_ads_texttype_s"><a href="' + google_info.feedback_url + '">Ads by Google2</a></p>' +
                '<dl class="g_ads_texttype">';
            } else {
                return;
            }
            for (var i = 0 ; i < google_ads.length ; i++) {
                if (this.adsType == this.ADS_CONTENTS) {
                    // コンテンツ内 
                    s += '<dt><a href="' + google_ads[i].url + '">' + google_ads[i].line1 + '</a> ' +
                        '<span><a href="' + google_ads[i].url + '">' + google_ads[i].visible_url + '</a></span></dt>' +
                        '<dd>' + google_ads[i].line2 + google_ads[i].line3 + '</dd>';
                } else if (this.adsType == this.ADS_SIDEBAR) {
                    // サイドバー
                    s += '<dt><a href="' + google_ads[i].url + '">' + google_ads[i].line1 + '</a></dt>' +
                        '<dd>' + google_ads[i].line2 + google_ads[i].line3 + '<span><br />' +
                        '<a href="' + google_ads[i].url + '">' + google_ads[i].visible_url + '</a></span></dd>';
                } else if (this.adsType == this.ADS_SIDEBAR2) {
                    // 左サイドバー
                    s += '<dt><a href="' + google_ads[i].url + '">' + google_ads[i].line1 + '</a></dt>' +
                        '<dd>' + google_ads[i].line2 + google_ads[i].line3 + '<span><br />' +
                        '<a href="' + google_ads[i].url + '">' + google_ads[i].visible_url + '</a></span></dd>';
                }
            }
            s += '</dl>';
        // CPCカウント
//        console.log('channel=' + google_ad_channel + ' bidtype=' + google_ads[0].bidtype);
        if (google_ads[0].bidtype == 'CPC') {
        	google_adnum += google_ads.length;
        }
        }
        document.write(s);
    }
}

