function readcookie(n)
{
 a = document.cookie;
 res = '';
 while(a != '')
 {
  while(a.substr(0,1) == ' '){a = a.substr(1,a.length);}
  cookiename = a.substring(0,a.indexOf('='));
  if(a.indexOf(';') != -1)
  {cookiewert = a.substring(a.indexOf('=')+1,a.indexOf(';'));}
  else{cookiewert = a.substr(a.indexOf('=')+1,a.length);}
  if(n == cookiename){res = cookiewert;}
  i = a.indexOf(';')+1;
  if(i == 0){i = a.length}
  a = a.substring(i,a.length);
 }
return(res)
}

function placecookie(Bezeichner,Wert,Dauer)
   {
      jetzt=new Date();
      document.cookie=Bezeichner+"="+Wert+";";
   }


function switcher(element){
	var id = element;
	switch (id) {
		case 'news':
		document.getElementById('sc_switch1').style.backgroundPosition = '0 0';
		document.getElementById('sc_newsbox').style.display = 'block';
		document.getElementById('sc_downloads').style.display = 'none';
		document.getElementById('sc_upcomingwars').style.display = 'none';
		placecookie("switch1",1);
		break;
		case 'downloads':
		document.getElementById('sc_switch1').style.backgroundPosition = '0 -38px';
		document.getElementById('sc_newsbox').style.display = 'none';
		document.getElementById('sc_downloads').style.display = 'block';
		document.getElementById('sc_upcomingwars').style.display = 'none';
		placecookie("switch1",2);
		break;
		case 'upcomingwars':
		document.getElementById('sc_switch1').style.backgroundPosition = '0 -76px';
		document.getElementById('sc_newsbox').style.display = 'none';
		document.getElementById('sc_downloads').style.display = 'none';
		document.getElementById('sc_upcomingwars').style.display = 'block';
		placecookie("switch1",3);
		break;


		// Switcher 2
		case 'poll':
		document.getElementById('sc_switch2').style.backgroundPosition = '0 0';
		document.getElementById('sc_pollbox').style.display = 'block';
		document.getElementById('sc_tsbox').style.display = 'none';
		document.getElementById('sc_topuserbox').style.display = 'none';
		placecookie("switch2",1);
		break;
		case 'ts':
		document.getElementById('sc_switch2').style.backgroundPosition = '0 -39px';
		document.getElementById('sc_pollbox').style.display = 'none';
		document.getElementById('sc_tsbox').style.display = 'block';
		document.getElementById('sc_topuserbox').style.display = 'none';
		placecookie("switch2",2);
		break;
		case 'topuser':
		document.getElementById('sc_switch2').style.backgroundPosition = '0 -78px';
		document.getElementById('sc_pollbox').style.display = 'none';
		document.getElementById('sc_tsbox').style.display = 'none';
		document.getElementById('sc_topuserbox').style.display = 'block';
		placecookie("switch2",3);
		break;
		default:
		// nothing
		break;
	}
}


// Prüft onload die Cookies
// Und führt funktion aus
window.onload = function() {
switchcookie1 = readcookie("switch1")
	if (switchcookie1==1) {
		switcher("news");
	}
	if (switchcookie1==2) {
		switcher("downloads");
	}
	if (switchcookie1==3) {
		switcher("upcomingwars");
	}
switchcookie2 = readcookie("switch2")
	if (switchcookie2==1) {
		switcher("poll");
	}
	if (switchcookie2==2) {
		switcher("ts");
	}
	if (switchcookie2==3) {
		switcher("topuser");
	}

}


$(document).ready(function() {
  	$("#tmslider").easySlider({
		prevText: '<img src="style/base/tm-left.png" width="34" height="19"  alt="" />',
		nextText: '<img src="style/base/tm-right.png" width="34" height="19"  alt="" />',
		orientation: 'horizontal',	
		speed: 200 			
	});
});
// News Vote Funktion
		function hidehover(e){
			var n=1;
			while(n<6) {
				document.getElementById("hover"+ e + n).style.display='none';
				document.getElementById("nohover" + e).style.display='block';
				n++;
			}	
		}
		function showhover(n, e){
			hidehover(e);
			document.getElementById("nohover"+ e).style.display='none';
			document.getElementById("hover"+ e + n).style.display='block';
		}



