var div_global = '';

// Change accordion content und nav style
function change(div, num){
	div_global = div;
	document.getElementById(div+'_'+num).style.display = 'block';
	document.getElementById(div+'_'+num).parentNode.style.display = 'block';
	
	for(var i=1;i<=6;i++){
		if(i!=num && document.getElementById(div+'_'+i)){
			document.getElementById(div+'_'+i).style.display = 'none';
			document.getElementById(div+'_link_'+i).className = 'tog_indi';
			}
		}
	document.getElementById(div+'_link_'+num).className = 'tog_indi_on';
	document.getElementById(div+'_link_'+num).blur();
	}

// RollOver maps
function change_map(area, num){
	document.getElementById(area).src = 'img/mainpage/' + area + '_' + num + '.gif';
	}

// Regions
var regions = new Array();
regions[0] = new Object();
regions[0]['ASOC'] = 'AUS;JPN;KOR;NZL';
regions[0]['CEEU'] = 'AUT;FRA;DEU;CHE';
regions[0]['EAEU'] = 'CZE;HUN;POL;SVK';
regions[0]['NOAM'] = 'CAN;CHL;MEX;USA';
regions[0]['NOEU'] = 'BEL;IRL;LUX;NLD;GBR';
regions[0]['SCAN'] = 'DNK;ISL;FIN;NOR;SWE';
regions[0]['SOEU'] = 'ITA;GRC;PRT;ESP;TUR';

// RollOver results
function roll(ref, more, map){
	dia_S = dia[0]['S_'+ref].split(';');
	dia_M = dia[0]['M_'+ref].split(';');
	countries = regions[0][dia_S[3]].split(';');
	
	if(document.getElementById('lang_EN')) language_score = "score";
	if(document.getElementById('lang_DE')) language_score = "Wert";

	if(document.getElementById('bar_info_S').style.display != 'none'){
		$$("#results_map_si .results_bar").setStyle('background-color', '#d4d4d4');
		if(more){
			for(var i=0;i<countries.length;i++){
				document.getElementById('S_' + countries[i]).style.backgroundColor = '#48b2b2';
				}
			}
		if(map == 'all')
			document.getElementById('bar_info_S').style.marginTop = '-10000px';
		else{
			document.getElementById('bar_info_S').style.display = 'block';
			document.getElementById('bar_info_S').style.marginLeft = ((dia_S[0] * 15) - 15) + 'px';
			document.getElementById('bar_info_S').style.marginTop = -(parseInt(dia_S[2] * 8) + 24) + 'px';
			document.getElementById('S_' + ref).style.backgroundColor = '#1b5492';
			document.getElementById('bar_info_S').innerHTML = '#' + dia_S[0] + ' ' + dia_S[1] + ' | ' + language_score + ' ' + dia_S[2];
			}
		}
	
	if(document.getElementById('bar_info_M').style.display != 'none'){
		$$("#results_map_mi .results_bar").setStyle('background-color', '#d4d4d4');
		if(more){
			for(var i=0;i<countries.length;i++){
				document.getElementById('M_' + countries[i]).style.backgroundColor = '#48b2b2';
				}
			}
		if(map == 'all')
			document.getElementById('bar_info_M').style.marginTop = '-10000px';
		else{
			document.getElementById('bar_info_M').style.display = 'block';
			document.getElementById('bar_info_M').style.marginLeft = ((dia_M[0] * 15) - 15) + 'px';
			document.getElementById('bar_info_M').style.marginTop = -(parseInt(dia_M[2] * 8) + 24) + 'px';
			document.getElementById('M_' + ref).style.backgroundColor = '#1b5492';
			document.getElementById('bar_info_M').innerHTML = '#' + dia_M[0] + ' ' + dia_M[1] + ' | ' + language_score + ' ' + dia_M[2];
			}
		}
	}

// Change Button
function change_show(flag){
	var showAll = document.getElementById('showAll');
	var hideAll = document.getElementById('hideAll');
	if(flag == 2){
		showAll.style.display = 'block';
		hideAll.style.display = 'none';
		}
	else{
		showAll.style.display = 'none';
		hideAll.style.display = 'block';		
		}
	}

// scroller
var timerID = null;
var speed = 10;

function ScrollInit(box){
	mov = document.getElementById(box);
	//scroller = document.getElementById(box + '_up');
	document.getElementById(box + '_up').style.display = 'block';
	movHeight = mov.offsetHeight;
	}

function Scroll(direction, height){
	var top = mov.offsetTop;
	/*
	if(top <= 0)
		scroller.style.display = 'block';
	else
		scroller.style.display = 'none';
	*/
	if(direction == 'down'){
		if((movHeight + top) > height)
			mov.style.top = (top - speed) + "px";
		}
	else{
		if(top < 0)
			mov.style.top = (top + speed) + "px";
		}
	timerID = setTimeout('Scroll("'+direction+'", '+height+')', 30);
	}

function ScrollStop(){
	clearTimeout(timerID);
	}

var accordion;
var accordion2;

function first_accordion(){
	// Accordion initialisieren
	accordion = new Fx.Accordion('.toggler', '.element', {
		opacity: false,
		fixedHeight: 150,
		onActive: function(toggler, element){
			toggler.setStyle('background-color', '#dddddd');
			},
		onBackground: function(toggler, element){
			toggler.setStyle('background-color', '#ffffff');
			if(div_global)
				change(div_global, 1);
			}
		}, $('accordion'));
	
	// Initialize accordion 2
	accordion2 = new Fx.Accordion('.toggler2', '.element2', {
		opacity: false,
		fixedHeight: 250,
		show: 6,
		onActive: function(toggler2, element2){
			toggler2.setStyle('background-color', '#dddddd');
			},
		onBackground: function(toggler2, element2){
			toggler2.setStyle('background-color', '#ffffff');
			}
		}, $('accordion2'));
	}

// Initialize accordion 1
window.addEvent('domready', function(){
	/*
	var mySlide = new Array();
	for(var i=1;i<=3;i++){
		mySlide[i] = new Fx.Slide('acc_box_'+i);
		}
	*/
	// Accordion 1 und 2 initialisieren
	first_accordion();
	
	// Initialize accordion 3
	var accordion3 = new Fx.Accordion('.toggler3', '.element3', {
		opacity: false,
		fixedHeight: 100,
		onActive: function(toggler3, element3){
			toggler3.setStyle('background-color', '#dddddd');
			},
		onBackground: function(toggler3, element3){
			toggler3.setStyle('background-color', '#ffffff');
			}
		}, $('accordion3'));
	
	
	$('showAll').onclick = function(){
		accordion.display('all');
		accordion2.display('all');
		accordion.detach();
		accordion2.detach();
		
		document.getElementById('bar_info_S').style.display = 'block';
		document.getElementById('bar_info_M').style.display = 'block';

		/*
		for(var i=1;i<=3;i++){
			eval('mySlide['+i+']').show();
			}
		*/
		change_show(1); 
		}
	
	$('hideAll').onclick = function(){
		document.getElementById('bar_info_M').style.display = 'none';
		
		first_accordion();
		
		accordion.display(0);
		accordion2.display(6);
		/*
		var mySlide = new Array();
		for(var i=1;i<=3;i++){
			mySlide[i] = new Fx.Slide('acc_box_'+i);
			eval('mySlide['+i+']').slideIn();
			}
		*/
		change_show(2);
		}
	
	$$('h2.toggler').addEvent('click', function(){
		document.getElementById('bar_info_S').style.display = 'none';
		document.getElementById('bar_info_M').style.display = 'none';
		});
	
	$$('h1.toggler.S').addEvent('click', function(){
		window.setTimeout("vis('S')", 300);
		document.getElementById('bar_info_M').style.display = 'none';
		});
	
	$$('h1.toggler.M').addEvent('click', function(){
		window.setTimeout("vis('M')", 300);
		document.getElementById('bar_info_S').style.display = 'none';
		});
	});

function vis(what){
	document.getElementById('bar_info_' + what).style.display = 'block';
	}

var objTimer = null;
var xmlHttp = null;

function change_news(what){
	if(window.ActiveXObject){
		try{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
			}
		catch(e){
			try{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
				}
			catch(e){
				}
			}
		}
	else if(window.XMLHttpRequest){
		try{
			xmlHttp = new XMLHttpRequest();
			}
		catch(e){
			}
		}
	
	if(xmlHttp){

		if(document.getElementById('lang_EN')) language = "en";
		if(document.getElementById('lang_DE')) language = "de";

		xmlHttp.open('GET', 'http://'+window.location.host+'/news/news.php?id='+what+'&lang='+language, true);
        xmlHttp.onreadystatechange = news_data;
        xmlHttp.send(null);
		}
	}

function news_data(){
	if(xmlHttp.readyState == 4){
		news = xmlHttp.responseText;
		if(news != ''){
			ex_news = news.split('#*#');

			document.getElementById('news_date').innerHTML = ex_news[0];
			document.getElementById('news_title').innerHTML = ex_news[1];
			document.getElementById('news_content').innerHTML = ex_news[2];
			if(ex_news[3])
				document.getElementById('news_pict').innerHTML = '<img src="img/' + ex_news[3] + '" alt="" class="news_pict left" />';
			else
				document.getElementById('news_pict').innerHTML = '';
			
			document.getElementById('scroll_cont_up').style.display = 'none';
			document.getElementById('scroll_cont').style.top = 0;
			}
		}
	}
