<!--
/*
* The JavaScript returned from src="http://www.google.com/afsonline/show_afs_ads.js uses
* the parameter values assigned on this page to populate an array
* of ad objects. Once that array has been populated,
* the JavaScript will call the google_afs_request_done
* function to display the ads.  
*
* The reference to this file MUST be above the reference to
* the page that calls this one.
*/

/*
* This function retrieves the search query from the URL.
*/
function GetParam() {
	var w = document.getElementById("txtWhat");
	var l = document.getElementById("txtWhere");
//	var s = document.getElementById("ddlState");
//	var st = s.options[s.selectedIndex].text;
//	if (st == 'Any State') { st = '' };
	var match = '';
	if (w.value != '') { 
		match = w.value;
//		if ((l.value != '') || (st != '')) { match += '+in'}
		if (l.value != '') { match += '+in+' + l.value}
//		if (st != '') { match += '+' + st }
	}
	return (match) ? decodeURIComponent(match.replace(' ','+')) : null;
}

/*
* This function is required. 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)
{
	/*
	* 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 narrowAds = "";   // narrow ad unit html text

	for(i = 0; i < google_num_ads; i++)
	{
		if (google_ads[i].type=="text/wide")
		{
			// render a wide ad
			wideAds+='<br><br><a style="color:#2E5B84;font-weight:bold;" onmouseover="javascript:window.status=\'' +
					google_ads[i].url + '\';return true;" ' +
					'onmouseout="javascript:window.status=\'\';return true;" ' +
					'href="' + google_ads[i].url + '">' +
					'<span class="adt">' + google_ads[i].line1 + '</span></a><br>' +
					'<span class="adb">' + google_ads[i].line2 + '</span><br>' +
					'<a class="adu" onmouseover="javascript:window.status=\'' +
					google_ads[i].url + '\';return true;" ' +
					'onmouseout="javascript:window.status=\'\';return true;" ' +
					'href="' + google_ads[i].url + '">' +
					'<span>' + google_ads[i].visible_url + '</span></a>';	//<br><br>
		}
		else
		{
			// render a narrow ad
			narrowAds+='<br><br><a style="color:#2E5B84;font-weight:bold;" onmouseover="javascript:window.status=\'' +
					google_ads[i].url + '\';return true;" ' +
					'onmouseout="javascript:window.status=\'\';return true;" ' +
					'href="' + google_ads[i].url + '">' +
					'<span class="adt">' + google_ads[i].line1 + '</span></a><br>' +
					'<span class="adb">' + google_ads[i].line2 + ' ' + google_ads[i].line3 + '</span><br>' +
					'<a class="adu" onmouseover="javascript:window.status=\'' +
					google_ads[i].url + '\';return true;" ' +
					'onmouseout="javascript:window.status=\'\';return true;" ' +
					'href="' + google_ads[i].url + '">' +
					'<span>' + google_ads[i].visible_url + '</span></a>';
		}
	}

	if (narrowAds != "") {
		narrowAds = '<a style="text-decoration:none" ' +
					'href="https://www.google.com/adsense/support/bin/request.py?contact=afs_violation">' +
					'<span class="ad_header"><img height="16" width="78" border="0" src="gfx/abg-en-100c-000000.png" alt="Ads by Google"/></span></a>' + narrowAds;	//<br><br>
	}

	if (wideAds != "") {
		wideAds = '<a style="text-decoration:none" ' +
					'href="https://www.google.com/adsense/support/bin/request.py?contact=afs_violation">' +
					'<span class="ad_header"><img height="16" width="78" border="0" src="gfx/abg-en-100c-000000.png" alt="Ads by Google"/></span></a>' + wideAds;	//<br><br>
	}

	// Write HTML for wide and narrow ads to the proper <div> elements
	var wau = document.getElementById("wide_ad_unit");
	var nau = document.getElementById("narrow_ad_unit");
	if (wau) {wau.innerHTML = wideAds; wau.style.display = ''};
	if (nau) {nau.innerHTML = narrowAds};
	//if (nau) {nau.style.display = ''};
}

google_afs_query = GetParam();
google_afs_ad = 'w0n6'; // specify the number of ads you are requesting
google_afs_client = 'pub-4113849322810730'; // substitute your client ID
google_afs_channel = '7192652462'; // enter your custom channel ID
google_afs_hl = 'en'; // enter your interface language if not English
//google_afs_adtest = 'on'; // DELETE THIS LINE IN PRODUCTION! IT MEANS WE DON'T GET PAID!
// google_afs_ie = 'utf8'; // select input encoding scheme
// google_afs_oe = 'utf8'; // select output encoding scheme
-->
