﻿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];
}

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 += '<table border="0" cellpadding="0" cellspacing="0">';
  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>';
  var narrowAds = "";   // narrow ad unit html text
  var narrowInit = "";
  narrowInit = '<table border="0" cellspacing="0" cellpadding="0" width="100%" align="center"><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"><img src="/g/nok.gif" border="0" style="vertical-align:middle"></img>&nbsp;&nbsp;<b><a href="' + google_ads[i].url + '" target="_blank" class="ggafstitle1">' + google_ads[i].line1 + '</a></b></td></tr><tr><td>&nbsp;&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 != "") {
   	document.getElementById("wide_ad_unit").innerHTML = wideInit+wideAds+wideEnd;
}
if (narrowAds != "") {
    document.getElementById("narrow_ad_unit").innerHTML = narrowInit+narrowAds+narrowEnd;
}
}


