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;
	
	var source_element = document.getElementById('source_' + id);
	var target_element = document.getElementById('target_' + id);
	
	 if (!source_element || !target_element) return;
	 
	 // Remedy for IE bug:
    // Prevent IE duplicate request of script src when moving content of container.
    var embedded_scripts = source_element.getElementsByTagName('script');
    for (var i = 0; i < embedded_scripts.length; i++) {
        if (!embedded_scripts[i].src) continue;
        embedded_scripts[i].removeAttribute('src');
    }
	
	if (id == 'skyscraper1') {
        var url = top.location.href;
        var regex = /\/videos/;
        if (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';
        }
    }
    else if (id == 'fullbanner2') {
        if (window.SoiAd && SoiAd.isWallpaper('fullbanner2')) {
			var skyscraper1_anzeige = document.getElementById('anzeigegif_skyscraper1');
			if (skyscraper1_anzeige) skyscraper1_anzeige.style.display = 'none';
            var fb2 = document.getElementById('source_fullbanner2');
            if (fb2) fb2.style.backgroundImage = 'none';
        }
    }
    else if (id == 'rectangle1') {
    
		source_element.style.padding = '15px 0px';

    }
 
    // Test again
    if (!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 moveAd_bak(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
			source_element.style.backgroundPosition = '195px 15px';
		}
		
	}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;
	
	// Remedy for IE bug:
    // Prevent IE duplicate request of script src when moving content of container.
    var embedded_scripts = source_element.getElementsByTagName('script');
    for (var i = 0; i < embedded_scripts.length; i++) {
        if (!embedded_scripts[i].src) continue;
        embedded_scripts[i].removeAttribute('src');
    }

	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;
	
	// Remedy for IE bug:
    // Prevent IE duplicate request of script src when moving content of container.
    var embedded_scripts = source_element.getElementsByTagName('script');
    for (var i = 0; i < embedded_scripts.length; i++) {
        if (!embedded_scripts[i].src) continue;
        embedded_scripts[i].removeAttribute('src');
    }
	
	var target_parent = target_element.parentNode;
	target_parent.replaceChild(source_element, target_element);
	source_element.style.display = source_element.tagName.toLowerCase() == 'div' ? 'block' : 'inline';
}


/*
### comment from 2011-05-06
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 TVT_VideoAdRequest(video_ad_id, data) {
     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");
         }
         ad_request = window.soi_VideoAdRequest(video_ad_id, 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));
	}
	*/
}
