$(document).ready(function () {
	Sitebar = new Sitebar();	
	Wallpaper = new Wallpaper();
});	

function Sitebar() {
	this.contentBreite = 980;
	this.topPadding = 0;
	this.obj = false;
	this.c = 0;
	this.init();
}

Sitebar.prototype.init = function() {
	if (document.getElementById("ad-sitebar") != null) {
		this.obj = document.getElementById("ad-sitebar");
		this.refreshSize(true);
		var sky = document.getElementById("ad_skyscraper");
		sky.style.padding = "0px";
		sky.style.background = "none";
		if (this.c == 0) {
			this.refreshSize(false);
			this.c = this.c + 1;
		}
	} else {
		if (this.c < 100) {
			setTimeout("Sitebar.init();", 100);
		}
		this.c = this.c + 1;
	}
}

Sitebar.prototype.viewport = function() {
    var size = { x:0,y:0 };
    if (self.innerHeight) { // IE <= 6 
        size.x = self.innerWidth;
        size.y = self.innerHeight;
    } else {
		if (document.documentElement && document.documentElement.clientHeight) { //IE6 @ Strict 
        size.x = document.documentElement.clientWidth;
        size.y = document.documentElement.clientHeight;
    	} else {
			if (document.body)  {
			size.x = document.body.clientWidth;
			size.y = document.body.clientHeight;
			}
		}
    }
	return size;
}

Sitebar.prototype.refreshSize = function(a) {
	var size = this.viewport();
	//alert(".2.");
	var to = 500;
	//alert(size);
	if (size.x > 0 && size.y > 0) {
		var fcb;
		var fch;
		fcb = size.x - this.contentBreite;
		fch = size.y - this.topPadding;
		this.obj.style.width = fcb+"px";
		this.obj.style.height = fch+"px";
		to = 50;
	}
	if ((a)) {
		setTimeout("Sitebar.refreshSize(true);", to);
	}
}

function Wallpaper() {
	this.c = 0;
	this.obj = false;
	this.init();
}

Wallpaper.prototype.init = function() {
	if (document.getElementById("ad-wallpaper-skyscraper") != null) {
		this.obj = document.getElementById("ad-wallpaper-skyscraper");
		this.setPosition();
	} else {
		if (this.c < 100) {
			setTimeout("Wallpaper.init();", 50);
		}
		this.c = this.c + 1;
	}
}


Wallpaper.prototype.setPosition = function(a) {
	if (document.getElementById('ad_leaderboard') != null) {
		var lPos = $('#ad_leaderboard').position();
		//var lHeight = $('#ad-leaderboard').height();
		var lWidth = $('#ad_leaderboard').width();
		$('#ad-wallpaper-skyscraper').css({top: (lPos.top+10)+'px', left: (lPos.left+lWidth)+'px', display: 'block'});
	}
}
