$(document).ready(function(){	
	// test
	
	//alert("kica_ads.js");
	
	var debug = false;
	/**
	if(typeof(adtype) == 'undefined') {
		var adtype = '';
	}
	
	adtype = 'wallpaper';
	*/
	
	// values
	var page_width = 804; // Seitenbreite ohne Werbung
	
	var middle_and_bottom_margin_left = 0;
	
	var banner_horizontal_height = 0;
	var banner_horizontal_margin_top = 0;
	var banner_horizontal_margin_left = 1;
	
	var banner_vertical_width = 0;
	var banner_vertical_margin_top = 0;
	var banner_vertical_margin_left = 10;
	
	// Skyscraper wird nach oben verschoben und dockt von rechts an den Superbanner an
	if(typeof(adtype) != 'undefined' && adtype == 'wallpaper') {
		if($('#banner_horizontal img').width() == 468) {
			//
		}
		else if($('#banner_horizontal img').width() == 728) {
			middle_and_bottom_margin_left = middle_and_bottom_margin_left + 130;
			page_width = page_width + 130;
		}
		else {
			if(debug) alert('#banner_horizontal img width ' + $('#banner_horizontal img').width());
			
			middle_and_bottom_margin_left = middle_and_bottom_margin_left + 130;
			page_width = page_width + 130;
		}
		
		if($('#banner_horizontal img').height() == 60) {
			banner_vertical_margin_top = banner_vertical_margin_top - 60;
		}
		else if($('#banner_horizontal img').height() == 90) {
			banner_vertical_margin_top = banner_vertical_margin_top - 90;
		}
		else if($('#banner_horizontal img').height() == 180) {
			banner_vertical_margin_top = banner_vertical_margin_top - 180;
		}
		else {
			if(debug) alert('#banner_horizontal img height ' + $('#banner_horizontal img').height());
			
			banner_vertical_margin_top = banner_vertical_margin_top - 180;
		}
		
		if($('#banner_vertical img').width() == 120) {
			banner_vertical_width = banner_vertical_width + 120;
			page_width = page_width + 120;
		}
		else if($('#banner_vertical img').width() == 160) {
			banner_vertical_width = banner_vertical_width + 160;
			page_width = page_width + 160;
		}
		else if($('#banner_vertical img').width() == 200) {
			banner_vertical_width = banner_vertical_width + 200;
			page_width = page_width + 200;
		}
		else {
			if(debug) alert('#banner_vertical img width ' + $('#banner_vertical img').width());
			
			banner_vertical_width = banner_vertical_width + 200;
			page_width = page_width + 200;
		}
		
		$('#page').css({
			/**'background-color' : '#0000ff',*/
			'width': page_width
		});
		
		$('#top').css({
			'width': page_width
		});
		
		$('#border_left').css({
			'margin-left': middle_and_bottom_margin_left + 'px'
		});
		
		$('#bottom').css({
			'margin-left': middle_and_bottom_margin_left + 'px'
		});
		
		$('#banner_horizontal').css({
			//
		});
		
		$('#banner_vertical').css({
			'width': banner_vertical_width + 'px',
			'margin-top': banner_vertical_margin_top + 'px',
			'margin-left': banner_vertical_margin_left + 'px'
		});
	}
	
	// Skyscraper dockt von unten an den Superbanner an
	if(typeof(adtype) != 'undefined' && adtype == 'expwallpaper') {
		if($('#banner_horizontal img').width() == 468) {
			banner_horizontal_margin_left = banner_horizontal_margin_left + 290;
		}
		else if($('#banner_horizontal img').width() == 728) {
			banner_horizontal_margin_left = banner_horizontal_margin_left + 30;
		}
		else {
			if(debug) alert('#banner_horizontal img width ' + $('#banner_horizontal img').width());
			
			//banner_horizontal_margin_left = banner_horizontal_margin_left + 30;
			banner_horizontal_margin_left = banner_horizontal_margin_left + 40;
		}
		
		if($('#banner_horizontal img').height() == 60) {
			banner_horizontal_height = banner_horizontal_height + 60;
			banner_horizontal_margin_top = banner_horizontal_margin_top + 30;
		}
		else if($('#banner_horizontal img').height() == 90) {
			banner_horizontal_height = banner_horizontal_height + 90;
		}
		else if($('#banner_horizontal img').height() == 180) {
			banner_horizontal_height = banner_horizontal_height + 180;
		}
		else {
			if(debug) alert('#banner_horizontal img height ' + $('#banner_horizontal img').height());
			
			//banner_horizontal_height = banner_horizontal_height + 180;
			banner_horizontal_height = banner_horizontal_height + 90;
		}
		
		if($('#banner_vertical img').width() == 120) {
			page_width = page_width + 120;
			banner_vertical_width = banner_vertical_width + 120;
		}
		else if($('#banner_vertical img').width() == 160) {
			page_width = page_width + 160;
			banner_vertical_width = banner_vertical_width + 160;
		}
		else if($('#banner_vertical img').width() == 200) {
			page_width = page_width + 200;
			banner_vertical_width = banner_vertical_width + 200;
		}
		else {
			if(debug) alert('#banner_vertical img width ' + $('#banner_vertical img').width());
			 
			page_width = page_width + 200;
			banner_vertical_width = banner_vertical_width + 200;
		}
		
		$('#page').css({
			/**'background-color' : '#ff0000',*/
			'width': page_width + 'px'
		});
		
		$('#top').css({
			'width': page_width + 'px'
		});
		
		$('#banner_horizontal').css({
			'margin-top': banner_horizontal_margin_top + 'px',
			'margin-left': banner_horizontal_margin_left + 'px',
			'height': banner_horizontal_height + 'px'
		});
		
		$('#banner_vertical').css({
			'margin-top': banner_vertical_margin_top + 'px',
			'margin-left': banner_vertical_margin_left + 'px',
			'width': banner_vertical_width + 'px'
		});
	}
	
	if(typeof(bgcolor) != 'undefined' && bgcolor != null) {
		$('body').css({
			'background-color': bgcolor,
			'background-image': 'none'
		});
	}
	
	if(typeof(bgimage) != 'undefined' && bgimage != null) {
		$('body').css({
			'background-image': 'url(' + bgimage + ')',
			'background-repeat': 'no-repeat'
		});
	}
	
	if(typeof(adclick) != 'undefined' && adclick != null) {
		$('body').click(function(e) {
			if(e.target == this) {
				location.href = adclick;
			}
		});
	}
	
});


$(document).ready(function(){	
				
  	//alert('hallo');
  	//document.getElementById("banner_vertical").style.border = "solid blue 1px";

	if(typeof(adtype) != "undefined"){ 

		if (!(adtype=="wallpaper"))
		{
   		//alert('test');		
   		document.getElementById("banner_vertical").style.margin="7px 0px 0px 10px";
		}
		else
		{
		//alert('test');
   		document.getElementById("banner_vertical").style.margin="-90px 0px 0px 10px";
		}
	}
	else
	{
   	//alert('test');		
   	document.getElementById("banner_vertical").style.margin="7px 0px 0px 10px";
	}	
			
});	
