WallpaperSetup("Masterdiv");

//===========================================================================================
//    Aller Common Wallpaper v2 - Two column edition
//===========================================================================================

var onResizeCounter = 0;

function WallpaperSetup(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);
            window.onresize=function(){ initializeClickTags(contentDiv);}
        }
    }
}

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=/grafik/common/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=/grafik/common/transparent.gif width=" + AdWidth + " height=" + ContentHeight + " border=0></a>";

    // To be sure the wallpaper gets shown, remove possible wallpaper from main form
    document.forms[0].style.background = "none";

    // Remove existing wallpaper from <HTML> tag, if it can be found with the id "html"
    var myHTML = document.getElementById('html');
    if (myHTML != null)
    {
        myHTML.style.background = "none";
    }
}

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);
		}
	}
}
