function GetParam(name) {
    var match = new RegExp(name + "=(.+)[&]", "i").exec(location.search);
    if (match == null) {
        match = new RegExp(name + "=(.+)", "i").exec(location.search);
    }

    if (match == null) {
        return null;
    }

    match = match + "";
    result = match.split(",");
    return result[1];
}

var ggafsforceddiv = '';

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 wideInit = "";
//    //wideInit += '<table border="0" cellpadding="0" cellspacing="0"><tr><td class="ggafscol2" height="3" colspan="3"><img src="/trans.gif" width="100%" height="3" alt="" border="0"></td></tr>'; //<tr><td colspan="3" align=right class="ggafs">Annonces Google</td></tr>';
//    wideInit += '<div class="toolbar">&nbsp;Liens sponsorisés / <a href="http://services.google.com/feedback/online_hws_feedback" target="_blank">Annonces Google</a></div><br /><table border="0" cellpadding="0" cellspacing="0" class="ggafstbl">';
//    var wideEnd = "";
//    //wideEnd += '<tr><td class="ggafscol2" height="3" colspan="3"><img src="/trans.gif" width="100%" height="3" alt="" border="0"></img></td></tr></table>';
//    wideEnd += '</table><hr />';
//    var narrowAds = "";   // narrow ad unit html text
//    var narrowInit = "";
//    narrowInit = '<table border="0" cellspacing="0" cellpadding="0" width="100%" align="center" class="ggafstbl"><tr><td class="ggafscol1" height="3"><img src="/images/titre_trait.gif" width="100%" height="3" alt="" border="0"></img></td></tr>'; //<tr><td class="ggafscol1b" height="3" align="right">Annonces Google</td></tr><tr><td width="100%" class="ggafscol1b" align="center"><table border="0" cellspacing="3" cellpadding="0" width="100%" align="center"><tr><td>';
//    var narrowEnd = "";
//    narrowEnd = '</td></tr></table></td></tr><tr><td class="ggafscol1" height="3"><img src="/trans.gif" width="100%" height="3" alt="" border="0"></img></td></tr></table>';


//    for (i = 0; i < google_num_ads; i++) {
//        if (google_ads[i].type == "text/wide") {
//            wideAds += '<tr><td class="ggafstdt">&nbsp;&nbsp;&nbsp;&nbsp;<b><a href="' + google_ads[i].url + '" target="_blank" class="ggafstitle1">' + google_ads[i].line1 + '</a></b></td></tr><tr><td class="ggafsdesc">&nbsp;&nbsp;' + google_ads[i].line2 + '</td></tr><tr><td class="ggafsurl ggafstdb">&nbsp;&nbsp;&nbsp;&nbsp;' + google_ads[i].visible_url + '</td></tr>';
//        }
//        else {
//            narrowAds += '<div><a href="' + google_ads[i].url + '" target="_blank"><b class="ggafstitle1">' + google_ads[i].line1 + '</b><br>' + google_ads[i].line2 + '<br><span class="ggafsurl">' + google_ads[i].visible_url + '</span></a></div><br>';
//        }
//    }

//    if (wideAds != "") {
//        if (google_num_ads > 0) {
//            if (ggafsforceddiv != '') {
//                document.getElementById(ggafsforceddiv).innerHTML = wideInit + wideAds + wideEnd;
//            } else {
//                document.getElementById("wide_ad_unit").innerHTML = wideInit + wideAds + wideEnd;
//            }
//        }
//    }
//    if (narrowAds != "") {
//        if (google_num_ads > 0) {
//            if (ggafsforceddiv != '') {
//                document.getElementById(ggafsforceddiv).innerHTML = narrowInit + narrowAds + narrowEnd;
//            } else {
//                document.getElementById("narrow_ad_unit").innerHTML = narrowInit + narrowAds + narrowEnd;
//            }
//        }
//    }
    //    ggafsforceddiv = '';
    if (ggafsforceddiv != '') {
        ggafsdoneforceddiv(google_ads);
    } else {
        ggafsdonenormal(google_ads);
    }
}

function ggafsdonenormal(google_ads) {
    var google_num_ads = google_ads.length;

    var wideAds = "";
    var wideInit = "";
    wideInit += '<div class="RSerAFS"><div class="AFSHead">Liens sponsorisés / <a href="http://services.google.com/feedback/online_hws_feedback" target="_blank">Annonces Google</a></div><br /><table border="0" cellpadding="0" cellspacing="0" class="ggafstbl">';
    var wideEnd = "";
    wideEnd += '</table></div>';
    var narrowAds = "";
    var narrowInit = "";
    narrowInit = '<table border="0" cellspacing="0" cellpadding="0" width="100%" align="center" class="ggafstbl"><tr><td class="ggafscol1" height="3"><img src="/images/titre_trait.gif" width="100%" height="3" alt="" border="0"></img></td></tr>'; //<tr><td class="ggafscol1b" height="3" align="right">Annonces Google</td></tr><tr><td width="100%" class="ggafscol1b" align="center"><table border="0" cellspacing="3" cellpadding="0" width="100%" align="center"><tr><td>';
    var narrowEnd = "";
    narrowEnd = '</td></tr></table></td></tr><tr><td class="ggafscol1" height="3"><img src="/trans.gif" width="100%" height="3" alt="" border="0"></img></td></tr></table>';

    for (i = 0; i < google_num_ads; i++) {
        if (google_ads[i].type == "text/wide") {
            wideAds += '<tr><td><span class="ggafstdt"><a href="' + google_ads[i].url + '" target="_blank" class="ggafstitle1">' + google_ads[i].line1 + '</a> <br /> <span class="ggafsdesc">' + google_ads[i].line2 + '</span> <span class="ggafsurl ggafstdb"><a href="' + google_ads[i].url + '" target="_blank" class="ggafsurl ggafstdb">' + google_ads[i].visible_url + '</a></span><br /><br /></td></tr>';
            //wideAds += '<tr><td class="ggafstdt"><b><a href="' + google_ads[i].url + '" target="_blank" class="ggafstitle1">' + google_ads[i].line1 + '</a></b></td></tr><tr><td class="ggafsdesc">' + google_ads[i].line2 + '</td></tr><tr><td class="ggafsurl ggafstdb"><a href="' + google_ads[i].url + '" target="_blank" class="ggafsurl ggafstdb">' + google_ads[i].visible_url + '</a></td></tr>';
        }
        else {
            narrowAds += '<div><a href="' + google_ads[i].url + '" target="_blank"><b class="ggafstitle1">' + google_ads[i].line1 + '</b><br>' + google_ads[i].line2 + '<br><span class="ggafsurl">' + google_ads[i].visible_url + '</span></a></div><br>';
        }
    }

    if (wideAds != "") {
        if (google_num_ads > 0) {
            document.getElementById("wide_ad_unit").innerHTML = wideInit + wideAds + wideEnd;
        }
    }
    if (narrowAds != "") {
        if (google_num_ads > 0) {
            document.getElementById("narrow_ad_unit").innerHTML = narrowInit + narrowAds + narrowEnd;
        }
    }
}
function ggafsdoneforceddiv(google_ads) {
    var google_num_ads = google_ads.length;

    var wideAds = "";
    var wideInit = "";
    wideInit += '<h1><a href="http://services.google.com/feedback/online_hws_feedback" target="_blank">Annonce Google</a></h1><table border="0" cellpadding="0" cellspacing="0" class="ggafstbl">';
    var wideEnd = "";
    wideEnd += '</table>';
    var narrowAds = ""; 
    var narrowInit = "";
    narrowInit = '<table border="0" cellspacing="0" cellpadding="0" width="100%" align="center" class="ggafstbl"><tr><td class="ggafscol1" height="3"><img src="/images/titre_trait.gif" width="100%" height="3" alt="" border="0"></img></td></tr>'; //<tr><td class="ggafscol1b" height="3" align="right">Annonces Google</td></tr><tr><td width="100%" class="ggafscol1b" align="center"><table border="0" cellspacing="3" cellpadding="0" width="100%" align="center"><tr><td>';
    var narrowEnd = "";
    narrowEnd = '</td></tr></table></td></tr><tr><td class="ggafscol1" height="3"><img src="/trans.gif" width="100%" height="3" alt="" border="0"></img></td></tr></table>';


    for (i = 0; i < google_num_ads; i++) {
        if (google_ads[i].type == "text/wide") {
            wideAds += '<tr><td class="ggafstdt"><b><a href="' + google_ads[i].url + '" target="_blank" class="ggafstitle1">' + google_ads[i].line1 + '</a></b></td></tr><tr><td class="ggafsdesc">' + google_ads[i].line2 + '</td></tr><tr><td class="ggafsurl ggafstdb"><a href="' + google_ads[i].url + '" target="_blank" class="ggafsurl ggafstdb">' + google_ads[i].visible_url + '</a></td></tr>';
        }
        else {
            narrowAds += '<div><a href="' + google_ads[i].url + '" target="_blank"><b class="ggafstitle1">' + google_ads[i].line1 + '</b><br>' + google_ads[i].line2 + '<br><span class="ggafsurl">' + google_ads[i].visible_url + '</span></a></div><br>';
        }
    }

    if (wideAds != "") {
        if (google_num_ads > 0) {
            document.getElementById(ggafsforceddiv).innerHTML = wideInit + wideAds + wideEnd;
        }
    }
    if (narrowAds != "") {
        if (google_num_ads > 0) {
            document.getElementById(ggafsforceddiv).innerHTML = narrowInit + narrowAds + narrowEnd;
        }
    }
    ggafsforceddiv = '';
}

