$(document).ready(function () {
	if (document.getElementById("page")) {
		WallpaperSetup2("page");
	}
	else if (document.getElementById("pageArticle")) {
		WallpaperSetup2("pageArticle");
	}
	else {

	}
});


//===========================================================================================
//    Aller Common Wallpaper v2 - Two column edition
//===========================================================================================

var onResizeCounter = 0;

function WallpaperSetup2(contentDiv) {
	// Get wallpaper setting from 'wallPaperSettings' DIV
	var myWallpaperSettings = document.getElementById('wallpaperSettings');

	if (myWallpaperSettings != null) {
		// Get ad color from wallpaper settings and use if it can be found
		var adColor = myWallpaperSettings.getAttribute('adColor');
		if (adColor != null && adColor != '') {
			document.body.style.backgroundColor = adColor;
		}

		// Get ad color from wallpaper settings and use if it can be found
		var adImage = myWallpaperSettings.getAttribute('adImage');
		if (adImage != null && adImage != '') {
			document.body.style.backgroundImage = 'url(' + adImage + ')';
			document.body.style.backgroundPosition = 'top center';
			document.body.style.backgroundRepeat = 'no-repeat';

			//addLoadEvent(initializeClickTags, contentDiv);
			initializeClickTags(contentDiv);
			window.onresize = function() { initializeClickTags(contentDiv); };
		}

	}
	else {
	}
}

function initializeClickTags(contentDiv) {

	// Get wallpaper setting from 'wallPaperSettings' DIV
	var myWallpaperSettings = document.getElementById('wallpaperSettings');

	//Use defined image as wallpaper
	//WallpaperSetup(contentDiv);

	// Get ad URL from wallpaper settings and use if it can be found
	var adURL = myWallpaperSettings.getAttribute('adURL');
	if (adURL != null && adURL != '') {
		generateClickTags(contentDiv, adURL);
	}
}

function generateClickTags(contentDiv, adURL) {
	// Setup general values
	var myContentDiv = document.getElementById(contentDiv);
	var ContentWidth = myContentDiv.offsetWidth;
	var AdWidth = (document.documentElement.clientWidth - ContentWidth) / 2;
	var RightAdLeft = ContentWidth + AdWidth;
	var ContentHeight = myContentDiv.offsetHeight;

	// Generate left column DIV
	var myLeftDiv = document.getElementById('divAdClickLeft');
	myLeftDiv.style.position = 'absolute';
	myLeftDiv.style.left = '0px';
	myLeftDiv.style.top = '0px';
	myLeftDiv.style.zIndex = '10000';
	myLeftDiv.innerHTML = "<a href=" + adURL + " target=_blank><img src=/images/transparent.gif width=" + AdWidth + " height=" + ContentHeight + " border=0></a>";

	// Generate right column DIV
	var myRightDiv = document.getElementById('divAdClickRight');
	myRightDiv.style.position = 'absolute';
	myRightDiv.style.left = RightAdLeft + 'px';
	myRightDiv.style.top = '0px';
	myRightDiv.style.zIndex = '10000';
	myRightDiv.innerHTML = "<a href=" + adURL + " target=_blank><img src=/images/transparent.gif width=" + AdWidth + " height=" + ContentHeight + " border=0></a>";
}

function addLoadEvent(func, parameter) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = function () {
			func(parameter);
		}
	}
	else {
		window.onload = function () {
			oldonload();
			func(parameter);
		}
	}
}

