//array to store IDs of our tabs
var tabs = [];
//index for array
var ind = 0;
//store setInterval reference
var inter;

//change tab and highlight current tab title
function change(stringref){
	
	jQuery('.tab:not(#' + stringref + ')').hide(); //hide the other tabs	
	if (jQuery.browser.msie && jQuery.browser.version.substr(0,3) == "6.0")
		jQuery('.tab#' + stringref).show(); //show proper tab, catch IE6 bug
	else jQuery('.tab#' + stringref).fadeIn();
  
  
	jQuery('.htabs a:not(#' + stringref + 't)').removeClass('active'); //clear highlight from previous tab title	
  jQuery('.htabs a[href=#' + stringref + ']').addClass('active');//highlight currenttab title
}

function next(){
	
	change(tabs[ind++]); //call change to display next tab	
	if(ind >= tabs.length) ind = 0; //if it's the last tab, clear the index
}


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;
	
	promenna = new Date(); // vytvoří proměnnou obsahující aktuální datum
  mesic = promenna.getMonth() + 1;//leden je 0
  denVMesici = promenna.getDate();
  //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('active');
	
  if(mesic == '6' && denVMesici == '12'){
    change('tab2');
  }
  else if(mesic == '6' && denVMesici == '13'){
    change('tab3');
  }
  else {
    change('tab3');
    change('tab1');
  }



	
  //handler for clicking on tabs
	jQuery(".htabs a").click(function(){		
	
		clearInterval(inter); //if tab is clicked, stop rotating 		
		stringref = jQuery(this).attr("href").split('#')[1]; //store reference to clicked tab		
		change(stringref); //display referenced tab
		return false;
	});	
});  
