//By ilovecolors.com.ar
//www.ilovecolors.com.ar/rotating-jquery-tabs/

//array to store IDs of our tabs
var tabs = [];
//index for array
var ind = 0;
//store setInterval reference
var inter;
// li tausch
var aaa = 0;

//change tab and highlight current tab title
function change(stringref){
	//hide the other tabs
	jQuery('.tab:not(#' + stringref + ')').hide();
	//show proper tab, catch IE6 bug
	if (jQuery.browser.msie && jQuery.browser.version.substr(0,3) == "6.0")
		jQuery('.tab#' + stringref).show();
	else 
		jQuery('.tab#' + stringref).show();
	//clear highlight from previous tab title
	//jQuery('.htabs a:not(#' + stringref + 't)').removeClass('over');
//	jQuery('#' + tabs[0] + 't').removeClass();
//	jQuery('#' + tabs[1] + 't').removeClass();
//	jQuery('#' + tabs[1] + 't').addClass('2');
//	jQuery('#' + tabs[2] + 't').removeClass();
//	jQuery('#' + tabs[3] + 't').removeClass();
//	jQuery('#' + tabs[3] + 't').addClass('4');


	jQuery('#' + tabs[0] + 't').removeClass();
	jQuery('#' + tabs[1] + 't').removeClass();
	jQuery('#' + tabs[2] + 't').removeClass();
	jQuery('#' + tabs[3] + 't').removeClass();
	
	jQuery('#' + tabs[2] + 't').addClass('braun1');
	jQuery('#' + tabs[3] + 't').addClass('braun2');
	jQuery('#' + tabs[0] + 't').addClass('blau1');
	jQuery('#' + tabs[1] + 't').addClass('blau2');

	if (stringref == "x3" || stringref == "x2")
		{
		jQuery('#4erbg').removeClass();	
		jQuery('#4erbg').addClass('bg_blau');
		}
	else
		{
		jQuery('#4erbg').removeClass();	
		jQuery('#4erbg').addClass('bg_braun');
		}
	
	//highlight currenttab title
	//jQuery('.htabs a[href=#' + stringref + ']').addClass('over');
	jQuery('#' + stringref + 't').removeClass();
	jQuery('#' + stringref + 't').addClass('over');
}
function next(){
	//call change to display next tab
	change(tabs[ind++]);
	//if it's the last tab, clear the index
	if(ind >= tabs.length)
		ind = 0;
}

jQuery(document).ready(function(){
	//store all tabs in array
	jQuery(".tab").map(function(){
		tabs[ind++] = jQuery(this).attr("id");
    })
	//set index to next element to fade
	ind = 1;
	//initialize tabs, display the current tab
	jQuery(".tab:not(:first)").hide();
	jQuery(".tab:first").show();
	//highlight the current tab title
	jQuery('#' + tabs[0] + 't').addClass('over');
	//alert ('#' + tabs[0] + 't');
	//alert('#' + tabs[0] + 't');
	//handler for clicking on tabs
/*	jQuery(".htabs li a").click(function(){		
		//if tab is clicked, stop rotating 
		clearInterval(inter);
		//store reference to clicked tab
		stringref = jQuery(this).attr("href").split('#')[1];
		//display referenced tab
		change(stringref);
		return false;
	});*/
	
	jQuery("a#abc1").click(function(){		
		//if tab is clicked, stop rotating 
		clearInterval(inter);
		//store reference to clicked tab
		stringref = jQuery(this).attr("href").split('#')[1];
		//display referenced tab
		change(stringref);
		return false;
	});
	jQuery("a#abc2").click(function(){		
		//if tab is clicked, stop rotating 
		clearInterval(inter);
		//store reference to clicked tab
		stringref = jQuery(this).attr("href").split('#')[1];
		//display referenced tab
		change(stringref);
		return false;
	});
	jQuery("a#abc3").click(function(){		
		//if tab is clicked, stop rotating 
		clearInterval(inter);
		//store reference to clicked tab
		stringref = jQuery(this).attr("href").split('#')[1];
		//display referenced tab
		change(stringref);
		return false;
	});
	jQuery("a#abc4").click(function(){		
		//if tab is clicked, stop rotating 
		clearInterval(inter);
		//store reference to clicked tab
		stringref = jQuery(this).attr("href").split('#')[1];
		//display referenced tab
		change(stringref);
		return false;
	});
	//start rotating tabs
	inter = setInterval("next()", 4500);
});


