var activead;

function hoverBanner(id, nr, fall) {
	if (fall == 'in') {
		resetAll();
		$(id+'1').style.display = 'block';
		$('pfeil_gross_'+nr).style.display = 'block';
	} else if (fall == 'out') {
		if (!($(id+'2').style.display == 'block'))  $('pfeil_gross_'+nr).style.display = 'none';
		$(id+'1').style.display = 'none';															
	}
}

function switchBanner(id, nr) {
	$(id+'2').style.display = 'block';
	$('pfeil_gross_'+nr).style.display = 'block';
	grey();
	activeAd(nr);
	if (id == 'floating') $('floating1').style.display = 'none';
}

function showBox(id) {
	$('box'+id).style.display = 'block';
}

function activeAd(id) {	
	if (id != undefined) {
		activead = id;
	}
	else 	return activead;
}


function grey() {
	var i = 1;
	while (i < 21) {
		$('pfeil_'+i).style.display = 'none';
		$('pfeil_grau_'+i).style.display = 'block';
		i++;
	}
}

var ads = new Array(
	'skyscraper',
	'superbanner',
	'layer',
	'wallpaper',
	'livestream',
	'webcam',
	'webcast',
	'webreporterS',
	'webreporterB',
	'regenradar',
	'containerAnz',
	'containerGs',
	'maus',
	'sticky',
	'footer',
	'floating',
	'sponsoring',
	'roadblock',
	'brackad',
	'intersistial'
);

function resetAll(id) {
	var j = 1;
	var k = 1;
/*	if ((id == 'box17') && ($('box17').style.display == 'block')) { */
	if ((id == 'box21') && ($('box21').style.display == 'block')) {
		resetAll();
		$(id).style.display = 'block';
		return;
	}
	
	for (var i = 1; i <= ads.length; ++i) {
		/*if (i != 18) {*/
		if (i != 21) {
			$('pfeil_grau_'+i).style.display = 'none';
			$('pfeil_gross_'+i).style.display = 'none';
			$('pfeil_'+i).style.display = 'block';			
		/*}*/
		}
	}
	document.getElementById('pfeil_grau_20').style.left = '260px';  // interstitial
	while (j < 3) {
		for (var i = 0; i < ads.length; ++i) {
			$(ads[i]+j).style.display = 'none';		
		}
		j++;
	}
	/* $('box18').style.display = 'none'; */
	while (k < 22) {
		$('box'+k).style.display = 'none';
		k++;
	}
	/* $('box18').style.display = 'none'; */
	uninitMouse();
	if (activeAd() == 22) {
		//console.log(activeAd())
		with(window.document.banderoleAd) {
 			GotoFrame(37);
  		Play();
		}
	}
		
	//activeAd(0);
	if (id == 'switch') return;
}

var id2name = new Array(
	'default',
	'skyscraper',
	'superbanner',
	'layer',
	'wallpaper',
	'livestream',
	'webcam',
	'webcast',
	'webreporterS',
	'webreporterB',
	'regenradar',
	'containerAnz',
	'containerGs',
	'maus',
	'sticky',
	'footer',
	'floating',
	'sponsoring',
	'roadblock',
	'brackad',
	'intersistial'
)
function nextAd() {
	resetAll();
	var area;
	
	if ($('standard').style.display != 'none')  area = 1;
	else if ($('sponsor').style.display != 'none')  area = 2;
	else if ($('sonder').style.display != 'none')  area = 3;
	switch (area) {
		case 1:
			if ((activeAd() != 0) && (activeAd() < 4)) {
				switchBanner(id2name[activeAd()+1], activeAd()+1)
			} else {
				switchBanner('skyscraper', 1)
			} 
			break;
		case 2:
			if ((activeAd() != 0) && (activeAd() > 4) && (activeAd() < 12)) {
				switchBanner(id2name[activeAd()+1], activeAd()+1)
			} else {
				switchBanner('livestream', 5)
			}
			break;
		case 3:
			if ((activeAd() != 0) && (activeAd() > 12) && (activeAd() < 16)) {
				if (activeAd()+1 == 13) {
					initMouse();
				} else if (activeAd()+1 == 14) {
					initSticky();
				}
				switchBanner(id2name[activeAd()+1], activeAd()+1)
			} else if (activeAd()+1 == 17) {
				openPeel();
				activeAd(17); 
			} else if (activeAd()+1 == 18) {
				with(window.document.banderoleAd) {
 			 		GotoFrame(15);
  				Play();
					activeAd(18);
					grey();
				}
			} else {
				switchBanner('maus', 13)
				initMouse();
			}
			break;
		default:
			break;
	}
}

function switch_menu(pos, x) {
	if (x == 'x') {
		resetAll();
		switch_menu(pos);
		return;
	} else {
		$$('div.content').each(function(x) { x.hide(); });
		$$('div.red').each(function(x) { x.removeClassName('red').addClassName('grey'); });
		$$('div.red_end').each(function(x) { x.removeClassName('red_end').addClassName('grey_end'); });
		$(pos).show();
		if (pos == 'service') {			
			$('menu_'+pos+'_l').removeClassName('grey').removeClassName('lgrey').addClassName('red');
			$('menu_'+pos+'_r').removeClassName('grey_end').removeClassName('lgrey_end').addClassName('red_end');
			$('steuerung').style.display = 'none';
		} else {
			$('menu_service_l').removeClassName('red').addClassName('lgrey');
			$('menu_service_r').removeClassName('red_end').addClassName('lgrey_end');
			$('menu_'+pos+'_l').removeClassName('grey').addClassName('red');
			$('menu_'+pos+'_r').removeClassName('grey_end').addClassName('red_end');
			$('steuerung').style.display = 'block';		
		}
	}
}

function runFlash() {
	AC_FL_RunContent(
		'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
		'width', '550',
		'height', '400',
		'src', 'pics/swf/test_transparenz.swf',
		'quality', 'high',
		'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
		'align', 'middle',
		'play', 'true',
		'loop', 'true',
		'scale', 'showall',
		'wmode', 'window',
		'devicefont', 'false',
		'id', 'test_transparenz',
		'bgcolor', '#ffffff',
		'name', 'test_transparenz',
		'menu', 'true',
		'allowFullScreen', 'false',
		'allowScriptAccess','sameDomain',
		'movie', 'test_transparenz',
		'salign', ''
	)
}

