// Some AdNetworks require the backup tag to be external javascript

var match, host;
if (document.location.search.match(/host=([^;&]+)/)){
        match = document.location.search.match(/host=([^;&]+)/);
	host = match[1];
} else if (document.referrer.toString() != ''){
        match = document.referrer.toString().match(/https*:\/\/([^\/]+)/);
	host = match[1];
}

if ( top != self ) {
	// In a frame, need to get to the same domain
	document.location.replace('http://' + host + '/extensions/wikia/AdEngine/Athena.hop.iframe.html?host=' + host);
} else {
	var slotname = Athena.getSlotnameFromDom();
	Athena.debug("Athena.hop being called inside hop.js", 2);

	Athena.debug("Determined slotname to be " + slotname + " inside iframe", 6);
	var thisTag = Athena.getNextTag(slotname);
	Athena.debug("Config for ad being called from inside iframe = " + Athena.print_r(thisTag), 6);
      	document.write("<!-- Writing in hop.js -->");
	try {
      		document.write(thisTag['tag']);
	} catch (e) {
       		Athena.reportError("Error loading ads from hop.js = " + Athena.print_r(e));
	}
      	document.write("<!-- /Writing in hop.js -->");
}
