var direction = 0;
var maxHeight = '478';
var minHeight = '239';
var speed = 50;


function foldTopTen() {
	if(direction!= 0)
		return;
	
    currentHeight = getCurrentTopTenHeight();
    if(currentHeight == maxHeight)
    	direction = speed * -1;
    if(currentHeight == minHeight)
    	direction = speed;
    
    foldTopTenMove();
    return;
    //setTimeout ('alert(direction);', 1000);    
    
    
    return;
    /*topTenList.style.height = x + 'px';*/
      
    var topTenArrow2 = document.getElementById('topTenArrow2');
    topTenArrow2.src = 'images/top_ten_arrow_up2.jpg';
    offen = 1;
    
    var topTenList = document.getElementById('top_ten_content');
    topTenList.style.height = 100 + 'px';
      
    var topTenArrow2 = document.getElementById('topTenArrow2');
    topTenArrow2.src = 'images/top_ten_arrow_down2.jpg';

}

function foldTopTenMove() {
	if(direction == 0)
		return;
	
	var currentHeight = getCurrentTopTenHeight() + direction;
	if(currentHeight > maxHeight)
		currentHeight = maxHeight;
	if(currentHeight < minHeight)
		currentHeight = minHeight;
	
	//Hoehe setzen
	var topTenList = document.getElementById('top_ten_content');
	topTenList.style.height = currentHeight + 'px';
	
	if(currentHeight == minHeight) {
		setNextDirection(+1);
	} else if(currentHeight == maxHeight) {
		setNextDirection(-1);
	} else {
		setTimeout ('foldTopTenMove();', 1);		
	}
}


function getCurrentTopTenHeight() {
	var topTenList = document.getElementById('top_ten_content');
	return parseInt(topTenList.style.height);
}

function setNextDirection(nextDirection) {
	var topTenArrow2 = document.getElementById('topTenArrow2');
	if(nextDirection < 0)
		topTenArrow2.src = 'themes/fp/images/top10_btnLess.jpg';
	if(nextDirection > 0)
		topTenArrow2.src = 'themes/fp/images/top10_btnMore.jpg';
	direction = 0;
}

function einsHochRunter() {
	foldTopTen();	
}


function selectOnChange(select) {
  var wert = select.options[select.options.selectedIndex].value;
  window.document.getElementById("toptenTitle").innerHTML = select.options[select.options.selectedIndex].innerHTML;
  selectPlatformTopTen(wert);
}

function selectPlatformTopTen(selectedPlatform) {
    var platforms = Array();
    
    
          platforms[platforms.length] = 'BLU';
          platforms[platforms.length] = 'DVD';
          platforms[platforms.length] = 'LBU';
          platforms[platforms.length] = 'NDS';
          platforms[platforms.length] = 'PCO';
          platforms[platforms.length] = 'PS2';
          platforms[platforms.length] = 'PS3';
          platforms[platforms.length] = 'PSP';
          platforms[platforms.length] = 'WII';
          platforms[platforms.length] = 'XB3';
        
    
    
    
    var platformTable = false;
    for(var i=0; i< platforms.length; i++) {
      platformTable = document.getElementById('topten_' + platforms[i]);
      if(platforms[i] == selectedPlatform) {
        platformTable.style.display = '';
      } else {
        platformTable.style.display = 'none';
      }
    }
}
