// Tab Aktuell Rotation
// $(document).ready(function() {
	
var tabrefresh = 10000; // in ms
var stoptab = 0;
var tabsmax;
var fadeintime = 200;
var fadeouttime = 500;
var tabison = 1;
var moving = false;

function stopptabrotation(){
// if (nohide==false)
if (typeof tabtimer!="undefined")
clearTimeout(tabtimer);
}

function starttabrotation(maxtab,tabnr){
if (maxtab > 1) tabtimer = setTimeout("tabrotate(2,"+maxtab+")",tabrefresh);
}

function tabrotate(tabnr,tabsmax) {

// alert('autotabnr'+autotabnr+' tabison'+tabison)

if (moving) { return; } 
else {
	
tab = tabnr;

document.getElementById( 'tabhead' + tab  ).style.backgroundImage = 'url(/images/tabnews/onleft.gif)';
document.getElementById( 'tabheadr' + tab ).style.backgroundImage = 'url(/images/tabnews/onright.gif)';
document.getElementById( 'tabhead' + tab  ).style.fontWeight = 'bold';
document.getElementById( 'tabhead' + tab  ).style.color = '#fff';

var fademe  = $('#cttabfader'); 
var fademein   = $('#gstab'+tab); 
var fademeout   = $('#gstab'+tabison); 

moving = true;
fademe.css({
			opacity: 0,
			display: 'block'
		}).animate({
			opacity: 1
		}, fadeouttime, function() {
		tabison = tabnr;
		fademein.css('display','block');
		fademeout.css('display','none');
		fademe.css({
					opacity: 1,
					display: 'block'
				}).animate({
					opacity: 0
				}, fadeintime, function() {
				moving = false;
				fademe.css('display','none');
				});
		}); 
	
	for (i=1; i<=tabsmax; i++) { 
		if (i!=tab) 
			{
			document.getElementById( 'tabhead' + i  ).style.backgroundImage = 'url(/images/tabnews/offleft.gif)';
			document.getElementById( 'tabheadr' + i  ).style.backgroundImage = 'url(/images/tabnews/offright.gif)';
			document.getElementById( 'tabhead' + i  ).style.fontWeight = 'normal';
			document.getElementById( 'tabhead' + i  ).style.color = '#000';	
			}
	}


	tab ++;
	if (tab>tabsmax) tab = 1;
	tabtimer = setTimeout("tabrotate("+tab+","+tabsmax+")",tabrefresh );
  }
}

// Switch Tab-Box

function showtab( tab, total ) {

// alert(tabison);
if (moving) { return; } 
else {
				
document.getElementById( 'tabhead' + tab  ).style.backgroundImage = 'url(/images/tabnews/onleft.gif)';
document.getElementById( 'tabheadr' + tab  ).style.backgroundImage = 'url(/images/tabnews/onright.gif)';
document.getElementById( 'tabhead' + tab  ).style.fontWeight = 'bold';
document.getElementById( 'tabhead' + tab  ).style.color = '#fff';	
	
var fademe  = $('#cttabfader'); 
var fademein   = $('#gstab'+tab); 
var fademeout   = $('#gstab'+tabison); 

moving = true;

fademe.css({
			opacity: 0,
			display: 'block'
		}).animate({
			opacity: 1
		}, fadeouttime, function() {
		tabison = tab;
		fademein.css('display','block');
		fademeout.css('display','none');
		fademe.css({
					opacity: 1,
					display: 'block'
				}).animate({
					opacity: 0
				}, fadeintime, function() {
				moving = false;
				fademe.css('display','none');
				});
		}); 
	
	for (i=1; i<=total; i++) { 
		if (i!=tab) 
			{
			document.getElementById( 'tabhead' + i  ).style.backgroundImage = 'url(/images/tabnews/offleft.gif)';
			document.getElementById( 'tabheadr' + i  ).style.backgroundImage = 'url(/images/tabnews/offright.gif)';
			document.getElementById( 'tabhead' + i  ).style.fontWeight = 'normal';
			// document.getElementById( 'gstab' + i ).style.display = 'none';
			document.getElementById( 'tabhead' + i  ).style.color = '#000';	
			
			}
	}
  }
}

// });	

