// Analytics
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-11973806-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
})();


// OTP
DM_tag();

// Insert advertising
var strMPU = "/Ads/MPU.htm";
var strSkyscraper = "/Ads/Skyscraper.htm";
var strSuperBanner = "/Ads/SuperBanner.htm";
var strSuperBannerWithPopup = "/Ads/SuperBannerPop.htm";
var strBanner = "/Ads/Banner.htm";
var strButton = "/Ads/Button.htm";
// Adblock stuff
var strLeaderboardBlocked = "<div style=\"width: 728px; height: 90px; vertical-align: middle; text-align: center; background-color: #FFE; font-size: 16px; font-family: Georgia, 'Times New Roman', Times, serif;\"><p><br/>$1</p><p>$2</p></div>";
var strMPUBlocked = "<div style=\"width: 300px; height: 250px; position: relative; text-align: center; background-color: #FFE; font-size: 16px; font-family: Georgia, 'Times New Roman', Times, serif; padding: 5px;\"><div style=\"position: absolute; top:50%; height: 10em; margin-top: -3em;\">$1<br/><br/>$2</div></div>";
var strSkyscraperBlocked = "<div style=\"width: 120px; height: 600px; position: relative; text-align: center; background-color: #FFE; font-size: 16px; font-family: Georgia, 'Times New Roman', Times, serif; padding: 5px;\"><div style=\"position: absolute; top:50%; height: 10em; margin-top: -7em;\">$1<br/><br/>$2</div></div>";
var strBannerBlocked = "<div style=\"width: 468px; height: 60px; position: relative; text-align: center; background-color: #FFE; font-size: 16px; font-family: Georgia, 'Times New Roman', Times, serif; padding: 5px;\">$1<br/>$2</a></div>";
var strLine1 = "<a href=\"/Adblockers.asp\">Blocking Ads Hurts Our Website :(</a>";
var strLine2 = "Please Consider Disabling Your Ad-Block Software and Help Support this Site's Running Costs!";

if (document.body.__defineGetter__)
{
	if (HTMLElement)
	{
		var element = HTMLElement.prototype;
		if (element.__defineGetter__)
		{
			element.__defineGetter__("outerHTML",
			function ()
			{
				var parent = this.parentNode;
				var el = document.createElement(parent.tagName);
				el.appendChild(this);
				var shtml = el.innerHTML;
				parent.appendChild(this);
				return shtml;
				}
			);
		}
	}
}

function insertAdIntoDiv(strID, strAdScript, strAdBlockHtml)
{
	var objScript;
	
	objScript = document.getElementById(strID);
	if (objScript)
	{
		if (bolAdBlocked && strAdBlockHtml)
		{
			strAdBlockHtml = strAdBlockHtml.replace("$1", strLine1);
			strAdBlockHtml = strAdBlockHtml.replace("$2", strLine2);
			objScript.parentNode.innerHTML = strAdBlockHtml;
		}
		else
		{
			objScript.src = strAdScript;
			tile++;
		}
	}
}

// Show popup if this is IE6
if (typeof document.body.style.maxHeight != "undefined")
	insertAdIntoDiv("adSuperBanner", strSuperBanner, strLeaderboardBlocked);
else
	insertAdIntoDiv("adSuperBanner", strSuperBannerWithPopup);

insertAdIntoDiv("adMPU", strMPU, strMPUBlocked);
insertAdIntoDiv("adSkyscraper", strSkyscraper, strSkyscraperBlocked);
insertAdIntoDiv("adBanner", strBanner, strBannerBlocked, strBannerBlocked);
insertAdIntoDiv("adButton", strButton);

// If browser is widescreen resize some pages
if (document.body.clientWidth > 1085)
{
	var divShrinkable, divSkyscraper1, divSkyscraper2;
	
	divShrinkable = document.getElementById("idShrinkable");
	divSkyscraper1 = document.getElementById("idHiddenSkyscraper");
	divSkyscraper2 = document.getElementById("idHiddenSkyscraper2");
	// Shrink content to make room for skyscraper div
	if (divShrinkable)
		divShrinkable.style.paddingRight = "125px";
		
	// Show skyscraper div
	if (divSkyscraper1)
		divSkyscraper1.style.display = "block";
	if (divSkyscraper2)
		divSkyscraper2.style.display = "block";
	
	// Add skyscraper advert into iframe
	if (divSkyscraper1 || divSkyscraper2)
		insertAdIntoDiv("adHiddenSkyscraper", strSkyscraper);
}
