
/************
* Google AFC
*************/

/*
* Define required globals 
*/

// Content for site targeted ads
var gafcOniAd;
var gafcOasuText = "Advertise through Google AdWords on this Site.";

// Google params
var google_ad_client = 'ca-ottaway-pocono_js';
var google_ad_output = 'js';
var google_ad_type = 'text,image,flash'; 
var google_max_num_ads = '3';
var google_image_size='300x250';
var google_encoding = 'latin1';
var google_language = 'en';
var google_safe = 'high';
var google_adtest = 'off';

// Query string object
var gQs = new Querystring();


if(typeof(gQs.get("ovrAFCType")) != "undefined")
{
	google_ad_type = gQs.get("ovrAFCType");
} 

function google_ad_request_done(google_ads) 
{ 
	if(typeof(google_ads) != "undefined" && google_ads.length > 0)
	{
		gafcOniAd = new Object();
		gafcOniAd.type = google_ads[0].bidtype;
		
		// debug
		if(gQs.get("ovrAFCbidtype"))
		{
			gafcOniAd.type = gQs.get("ovrAFCbidtype");
		} 
			
    if (google_ads[0].type == "flash") 
    {         
    	// we have to remove the .swf extension from the URL for use in theAC_FL_RUNContent method
    	var flashUrlNoExt = google_ad.image_url.replace(/\.swf\?/i,"?");
    	
    	gafcOniAd.content = '<div id="gafcFlashAd"><div class="gafcBranding">Ads By Google</div>' +
    											'<scr' + 'ipt language="JavaScript" type="text/javascript">' +
						  '<!--\n' +
						  'AC_FL_RunContent("codebase","http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"' +
						  ',"id","shv","width","' + google_ad.image_width + '","height","' + google_ad.image_height + '","align","middle","src","' +
						  flashUrlNoExt + '","quality","high","wmode","opaque","scale","name","shv","noscale","movie","' + flashUrlNoExt + '"' + 
						  ',"pluginspage","http://www.macromedia.com/go/getflashplayer")\;' +
						  '\n// -->\n' +
  						'</scr' + 'ipt><div class="gafcSignUp"><a href="https://adwords.google.com/select/OnsiteSignupLandingPage?client=' + google_ad_client + '&referringUrl=http://' + document.location.hostname + '&hl=en">' + gafcOasuText + '</a></div></div>';

    } 
    else if (google_ads[0].type == "image") 
    {
      gafcOniAd.content = '<div id="gafcImgAd"><div class="gafcBranding">Ads By Google</div>' +
      									  '<a href="' + 
      				google_ads[0].url + '" target="_top" title="go to ' + google_ads[0].visible_url +
              '"><img border="0" src="' + google_ads[0].image_url +
              '"width="' + google_ads[0].image_width +
              '"height="' + google_ads[0].image_height + '" id="gafcImg"></a><div class="gafcSignUp"><a href="https://adwords.google.com/select/OnsiteSignupLandingPage?client=' + google_ad_client + '&referringUrl=http://' + document.location.hostname + '&hl=en">' + gafcOasuText + '</a></div></div>';
			
    } 
    else 
    {      
      if (google_ads.length == 1) 
      {
      	var adBeginLink = '<a href="' + google_ads[0].url + '" ' +
                          'onmouseout="window.status=\'\'" ' +
                          'onmouseover="window.status=\'go to ' +
                          google_ads[0].visible_url + '\'">';
      	var adEndLink = "</a>";
        //Adjust text sizes when 1 ad is returned.
				gafcOniAd.content= '<div id="gafcSingleTxtAd"><div class="gafcBranding">Ads By Google</div>'+
													'<div id="gafcTxtAd">' +
                          '<div class="gafcAdLine1">' + adBeginLink +
                          google_ads[0].line1 + adEndLink + '</div>' +
                          '<div class="gafcAdLine2">' + adBeginLink +
                          google_ads[0].line2  + adEndLink +
                          '</div><div class="gafcAdLine3">' + adBeginLink +
                          google_ads[0].line3 + '</div>' +
                          '<div class="gafcAdVisUrl">' + adBeginLink +
                          google_ads[0].visible_url + '</div></a></div><div class="gafcSignUp"><a href="https://adwords.google.com/select/OnsiteSignupLandingPage?client=' + google_ad_client + '&referringUrl=http://' + document.location.hostname + '&hl=en">' + gafcOasuText + '</a></div></div>';
      } 
      else if (google_ads.length > 1) 
      {
        /*
         * For text ads, append each ad to the string.
         */
        gafcOniAd.content = '<div id="gafcMultiTxtAd"><div class="gafcBranding">Ads By Google</div>';
        for(i=0; i < google_ads.length; ++i) 
        {
        	var adBeginLink = '<a href="' + google_ads[i].url + '" ' +
                          'onmouseout="window.status=\'\'" ' +
                          'onmouseover="window.status=\'go to ' +
                          google_ads[i].visible_url + '\'">';
      		var adEndLink = "</a>";
        	gafcOniAd.content += '<div class="gafcTxtAd">' +
                          '<div class="gafcAdLine1">' + adBeginLink +
                          google_ads[i].line1 + adEndLink + '</div>' +
                          '<div class="gafcAdLine2">' + adBeginLink +
                          google_ads[i].line2  + adEndLink +
                          '</div><div class="gafcAdLine3">' + adBeginLink +
                          google_ads[i].line3 + '</div>' +
                          '<div class="gafcAdVisUrl">' + adBeginLink +
                          google_ads[i].visible_url + '</div></a></div>';
        }
        gafcOniAd.content += '<div class="gafcSignUp"><a href="https://adwords.google.com/select/OnsiteSignupLandingPage?client=' + google_ad_client + '&referringUrl=http://' + document.location.hostname + '&hl=en">' + gafcOasuText + '</a></div></div>';
      }
    }
	}
  return;	
}  

function writeCPCAd()
{
	if(gafcOniAd && gafcOniAd.type == "CPC")
	{
		document.write(gafcOniAd.content);
	}
}

function writeCPMAd()
{
	if(gafcOniAd && gafcOniAd.type == "CPM")
	{
		document.write(gafcOniAd.content);
	}
}

function writeAnyAd()
{
	if(gafcOniAd)
	{
		document.write(gafcOniAd.content);
	}
}