if (window.add2tag == null) var add2tag = '';
if (window.soi_adtrace == null) var soi_adtrace = '';
if (window.soi_ad == null) var soi_ad = '';
if (!window.soi_Tagwriter) window.soi_Tagwriter = function() {return '';}

function moveAd(id)
{
	if(isType(id, 'Fallback') == true) return;
	//if(isType('popup1', 'wallpaper') == true) wallpaper = true;
	//else wallpaper = false;

	var source_element = document.getElementById('source_' + id);
	var target_element = document.getElementById('target_' + id);
	
	//wallpaper = true;
	//screenwidth = 1024; //1280

	if(wallpaper == true){
		if(screenwidth <= 1150){
			target_element = document.getElementById('target_' + id + '_wallpaper');
				var em1 = document.getElementById('target_fullbanner2_wallpaper');
				var em2 = document.getElementById('target_skyscraper1_wallpaper');
			
			//alert(em1 + ' -- ' + em2);
			if(em1 && typeof(em1) != 'undefined' && em1 != 'null')
				document.getElementById('target_fullbanner2_wallpaper').style.height = '90px';
			if(em2 && typeof(em2) != 'undefined' && em2 != 'null')
				document.getElementById('target_skyscraper1_wallpaper').style.height = '690px';
			
			
			//alert(document.getElementById('target_skyscraper1_wallpaper').style.height);
			if (id == 'skyscraper1'){
				hideElem('anzeigegif_'+id);
				source_element.style.position = 'relative';
				source_element.style.left = '70px';
				source_element.style.top = '-15px';
				//alert('height of source_skyscraper1: ' + source_element.style.height);
			}else if(id == 'fullbanner2'){
				source_element.style.position = 'relative';
				source_element.style.textAlign = 'right';
				source_element.style.paddingLeft = '51px';
				target_element.style.height = '90px';
			}
		}else if(screenwidth > 1150 && id == 'skyscraper1'){
			hideElem('anzeigegif_'+id);
			target_element = document.getElementById('target_' + id);
			source_element.style.left = '963px';
			source_element.style.top = '-173px';
		}else if(screenwidth > 1150 && id == 'fullbanner2'){
			source_element.style.position = 'relative';
			source_element.style.left = '7px';
			source_element.style.top = '0px'; //-7px
		}
		
	}else{
		var url = top.location.href;
		var regex = /\/videos/;
		if ((id == 'skyscraper1' && screenwidth <= 1150) && !regex.exec(url)){
			target_element = document.getElementById('target_' + id + '_inline');
			source_element.style.position = 'relative';
			source_element.style.left = '0px';
			source_element.style.top = '0px';
			source_element.style.paddingBottom = '15px';
		}
	}
	//if (id == 'rectangle1' && (isType(id, 'PR1') == true || wallpaper == true)) {
	if (id == 'rectangle1' && (isType(id, 'PR1') == true || (wallpaper == true && screenwidth <= 1150))) {
		target_element = document.getElementById('target_' + id + '_inline');
	}else if(id == 'rectangle1'){
		source_element.style.paddingBottom = '15px';
	}
	if (!source_element || !target_element) return;
	var target_parent = target_element.parentNode;
	target_parent.replaceChild(source_element, target_element);
	source_element.style.display = source_element.tagName.toLowerCase() == 'div' ? 'block' : 'inline';
}
function buildWallpaper(id){
	
}
function hasBlockpixel(ad_id) {
	return isType(ad_id, 'Block[_-]?pixel') ? true : false;
}

function isType(ad_id, type, adtrace) {
	
	
	if (!adtrace) adtrace = soi_adtrace;
	if (!adtrace) return false;

	// Existence check.
	if (type == null) type = '';

	var typeTest = new RegExp(ad_id + '.+' + type, 'i');
	var result = typeTest.test(adtrace);

	return result ? true : false;
}


function BacsAdTestShowDiv(name) {
	document.getElementById(name).style.backgroundColor = 'lime';
	document.getElementById(name).style.display = 'block';
	document.getElementById(name).innerHTML = name+':'+document.getElementById(name).innerHTML;		
}


function BacsAdTestShowAllDivs() {
	BacsAdTestShowDiv('source_fullbanner1');
	BacsAdTestShowDiv('source_fullbanner2');
	BacsAdTestShowDiv('source_skyscraper1');
	BacsAdTestShowDiv('source_rectangle1');
	BacsAdTestShowDiv('target_fullbanner2');
	BacsAdTestShowDiv('target_fullbanner2_wallpaper');
	BacsAdTestShowDiv('target_skyscraper1');
	BacsAdTestShowDiv('target_skyscraper1_wallpaper');
	BacsAdTestShowDiv('target_skyscraper1_inline');
	BacsAdTestShowDiv('target_rectangle1');
	BacsAdTestShowDiv('target_fullbanner1');	
}

function BacsAdTestWallpaperStandardSkyBottom() {
	BacsAdTestWallpaperGeneric('bottom', 'standard');
}

function BacsAdTestWallpaperStandardSkyRight() {
	BacsAdTestWallpaperGeneric('right', 'standard');
}

function BacsAdTestWallpaperSmallSkyBottom() {
	BacsAdTestWallpaperGeneric('bottom', 'small');
}

function BacsAdTestWallpaperSmallSkyRight() {
	BacsAdTestWallpaperGeneric('right', 'small');
}

function BacsAdTestWallpaperGeneric(skyPos, screenSize) {

	var source_element = document.getElementById('source_' + id);
	var target_element = document.getElementById('target_' + id);
	
	if (screenSize == 'small') {
		target_element = document.getElementById('target_' + id + '_wallpaper');
		// sky
		hideElem('anzeigegif_skyscraper');
		source_element.style.position = 'relative';
		source_element.style.left = '70px';
		source_element.style.top = '-13px';
		// banner
		source_element.style.position = 'relative';
		source_element.style.textAlign = 'right';
		source_element.style.paddingLeft = '51px';
	} else {
		// sky
		hideElem('anzeigegif_'+id);
		target_element = document.getElementById('target_' + id);
		source_element.style.left = '963px';
		source_element.style.top = '-175px';
		// banner
		source_element.style.position = 'relative';
		source_element.style.left = '7px';
		source_element.style.top = '-7px';
	}

	if (id == 'rectangle1' && (isType(id, 'PR1') == true || wallpaper == true)) {
		target_element = document.getElementById('target_' + id + '_inline');
	}else if(id == 'rectangle1'){
		source_element.style.paddingBottom = '15px';
	}
	if (!source_element || !target_element) return;
	var target_parent = target_element.parentNode;
	target_parent.replaceChild(source_element, target_element);
	source_element.style.display = source_element.tagName.toLowerCase() == 'div' ? 'block' : 'inline';
}

function TVT_VideoAdRequest(video_ad_id, data) {
	// Skript fuer Erzeugung der URL fuer VideoAds, wird aus dem Player heraus verwendet
	
	var BACS_avt_debug = false;

	if (typeof(data) != 'object') data = {};
	var ad_request = '';

	if (typeof(window.soi_VideoAdRequest) == 'function') {
		if (BACS_avt_debug) { alert('TVT_VideoAdRequest: neue Ad-Variante'); }
		var config_data = {};
		if (data.prefetch) config_data.prefetch = 1;

		ad_request = window.soi_VideoAdRequest(video_ad_id, config_data);
	}

	if (BACS_avt_debug) { alert('TVT_VideoAdRequest: ad_request'+ad_request); }
	return ad_request;
}

function trackSoiVideoEnd (smartcount_htmlcode) { // executes Smartcount from SOI-VideoAds
	/* 
	Info:
	Deactivated at the moment. Smartcount must not be executed if video is on autoplay.
	Our videos with ads are all on autoplay at the moment, no Smartcount is needed.
	
	SK, 20090619	
	*/
	
	/*	
	if (smartcount_htmlcode.match(/^http/)) { // new smartcount, only URI
		alert ('NEW!!! '+smartcount_htmlcode);
		void(document.getElementById('ads_soi_dumpdiv').innerHTML += '<img src="'+unescape(smartcount_htmlcode)+'" />');
	} else { // old smartcount, HTML snippet
		alert ('OLD!!! '+smartcount_htmlcode);
		void(document.getElementById('ads_soi_dumpdiv').innerHTML += unescape(smartcount_htmlcode));
	}
	*/
}