	/*
       *************** <b>This function is required.</b> *****************

       It processes the google_ads JavaScript object,
       * which contains AFS ads relevant to the user's search query. The name of
       * this function <i>must</i> be <b>google_afs_request_done</b>. If this
       * function is not named correctly, your page will not display AFS ads.

     */

      function google_afs_request_done(google_ads)
      {


          var google_num_ads = google_ads.length;
          /*
		    * Verify that there are actually ads to display.
          */
          if (google_num_ads <= 0)
          {
			  document.getElementById("adSenseDivBottom").style.display = "none";
			  document.getElementById("adSenseDivTop").style.display = "none";
			  return;
          }

          var adsTemp = "";
          var adsTop =  ""
          var adsBottom =  ""
          /*
		    * Getting element where ads need to show. ContainerD showing ads without bullets style/implementation.
		    * Condition for Container D
          */


		  	var adsTempletTop = document.getElementById("wnGoogleSponsoredResultsTop")
		 	var adsTempletBottom = document.getElementById("wnGoogleSponsoredResultsBottom")

		  for(i = 0; i < google_num_ads; i++)
          {
              if (google_ads[i].type=="text/wide")
              {
                  /*
		    	  * Distributing half ads at the top and half at the bottom of the search results
          		*/
                  if(i<(google_num_ads/2) ){
					adsTemp = adsTempletTop;
					document.getElementById("urlLine1Top").innerHTML= google_ads[i].line1;
					document.getElementById("urlLine1Top").setAttribute("href",google_ads[i].url)
					document.getElementById("urlLine1Top").setAttribute("onmouseover","window.status='{"+google_ads[i].url+"}';return true;")
					document.getElementById("urlLine2Top").setAttribute("href",google_ads[i].url)
					document.getElementById("urlLine2Top").setAttribute("onmouseover","window.status='{"+google_ads[i].url+"}';return true;")
					if(document.getElementsByTagName('wn')[0]!=null && document.getElementsByTagName('wn')[0].getAttribute("version")=='Container_D'){
						document.getElementById("urlLine2Top").getElementsByTagName("font")[0].innerHTML= google_ads[i].line2;}
					else
						{document.getElementById("urlLine2Top").innerHTML= google_ads[i].line2;}

					document.getElementById("adURLTop").setAttribute("href",google_ads[i].url)
					document.getElementById("adURLTop").innerHTML = google_ads[i].visible_url
					adsTop = adsTop +adsTemp.innerHTML;


					}
                  /*
		    		* Bottom ads distribution.
          		*/
					else{
					adsTemp = adsTempletBottom;
					document.getElementById("urlLine1Bottom").innerHTML= google_ads[i].line1;
					document.getElementById("urlLine1Bottom").setAttribute("href",google_ads[i].url)
					document.getElementById("urlLine2Bottom").setAttribute("href",google_ads[i].url)
					document.getElementById("urlLine1Bottom").setAttribute("onmouseover","window.status='{"+google_ads[i].url+"}';return true;")
					document.getElementById("urlLine2Bottom").setAttribute("onmouseover","window.status='{"+google_ads[i].url+"}';return true;")
					if(document.getElementsByTagName('wn')[0]!=null && document.getElementsByTagName('wn')[0].getAttribute("version")=='Container_D')
						document.getElementById("urlLine2Bottom").getElementsByTagName("font")[0].innerHTML= google_ads[i].line2;
					else
						document.getElementById("urlLine2Bottom").innerHTML= google_ads[i].line2;
					document.getElementById("adURLBottom").setAttribute("href",google_ads[i].url)
					document.getElementById("adURLBottom").innerHTML = google_ads[i].visible_url
					adsBottom = adsBottom +adsTemp.innerHTML;

					}
              }
          }
			  /*
				* Updating Divs with Ads contents.
			*/

          adsTempletTop.innerHTML = adsTop;
          adsTempletBottom.innerHTML = adsBottom;
        }


	  /*
		* Supportive utiliy functions.
	*/

 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];
      }


  /*
	***** CONFIGURATION SETTINGS *****
			USED by Google Ad Sense.
*/
      google_afs_query = wng_searchResultsInfo.query; //Query from wng_searchResultsInfo object (Formed using XML of the page)
      google_afs_ad = 'w'+wng_searchResultsInfo.adsize; // specify the number of ads you are requesting --ONLY WIDE ADS--
      //google_afs_client = 'googlepsotest-afsjs'; // substitute your client ID
      //google_afs_channel = '1234567890'; // enter your custom channel ID
      google_afs_client = 'pub-2613565434640259'; // substitute your client ID
      google_afs_channel = wng_searchResultsInfo.channel_id; // enter your custom channel ID
      google_afs_hl = 'en'; // enter your interface language if not English
      // google_afs_ie = 'utf8'; // select input encoding scheme
      // google_afs_oe = 'utf8'; // select output encoding scheme

