

var GADS = {
	gScripts: new Array(
		"http://partner.googleadservices.com/gampad/google_service.js",
		"http://community.bonnevillecincinnati.com/Google/Ads/wkrq/a",
		"http://community.bonnevillecincinnati.com/Google/Ads/wkrq/b",
		"http://community.bonnevillecincinnati.com/Google/Ads/wkrq/c"
	),
	gScriptIter: 0,
	
	init: function() {
		document.write("<script type='text/javascript' src='" + this.gScripts[0] + "'><" + "/script>");
		this.loadNext();
	},
	
	loadNext: function() {
		this.gScriptIter++;
		if(this.gScriptIter < this.gScripts.length) {
			document.write("<script type='text/javascript' src='" + this.gScripts[this.gScriptIter] + "'><" + "/script>");
		} else {
			GADslot.init();
		}
	}
}


GADS.init();


var GADslot = {
	skyscraper_id: "wkrq_skyscraper",
	slotname: "wkrq_skyscraper_right_120x600",
	iframe_id: 0,
	ival_id: -1,
	period: 200,
	
	targets: new Array(
		[ "foureg.com", "http://community.bonnevillecincinnati.com/Google/Custom/4eg/wkrq" ]
	),
	
	
	init: function() {
		if(typeof(gadslot_skyscraper) !== "undefined") {
			this.skyscraper_id = gadslot_skyscraper;
		}		
		if(typeof(gadslot_target) !== "undefined") {
			this.slotname = gadslot_target;
		}
		this.iframe_id = "google_ads_iframe_" + this.slotname;
		this.ival_id = setInterval("GADslot.analyze()",this.period);
	},
	
	analyze: function() {
		var iframe = this.find_ifdoc(this.iframe_id);
		if(!iframe) {
			return;
		}
		
		if (typeof(iframe.body.innerHTML) !== "undefined") {
			clearInterval(this.ival_id);
			// determine whether one of our targets is present
			for(var i=0;i<this.targets.length;i++) {
				var t = this.targets[i];
				if(this.check(this.slotname,t[0])) {
					var head = document.getElementsByTagName("head")[0];
					var sc = document.createElement("script");
					sc.type = "text/javascript";
					sc.src = t[1];
					head.appendChild(sc);
					this.ival_id = setInterval("GADslot.load_flyout()",this.period);
				}
			}
		}
	},
	
	load_flyout: function() {
		if(typeof(CIN_Flyout) !== "undefined") {
			clearInterval(this.ival_id);
			CIN_Flyout.init(this.skyscraper_id);
		}
	},
	
	find_ifdoc: function(id) {
		var iframe = document.getElementById(id);
		if(!iframe) {
			return false;
		}
		
		if(iframe.contentDocument)  
		   // Firefox, Opera  
		   iframe.doc = iframe.contentDocument;  
		else if(iframe.contentWindow)  
		   // Internet Explorer  
		   iframe.doc = iframe.contentWindow.document;  
		else if(iframe.document)  
		   // Others?  
		   iframe.doc = iframe.document;
		  
		return iframe.doc;
	},
	
	check: function(slotname,target_url){
	    var tag = this.find_ifdoc(this.iframe_id).body.innerHTML;
	    if (tag.indexOf(target_url) !== -1) {
		   return 1;
	    }
		return 0;
	}
	
}



