	var TRANSITION_TIME = 700;
	var INTERVAL_TIME = 10000;

	//background color transitions
	var bgcolors = new Array();
	bgcolors[0] = "#F7931E";
	bgcolors[1] = "#3F538E";
	bgcolors[2] = "#ee3e34";
	bgcolors[3] = "#d9e021";

	//background color transitions
	var leadboxes = new Array();
	leadboxes[0] = "#skupna";
	leadboxes[1] = "#druzabna";
	leadboxes[2] = "#optimizacija";
	leadboxes[3] = "#komunikacija";

	
	var leadimgs = new Array();
	leadimgs[0] = "#skupna_img";
	leadimgs[1] = "#druzabna_img";
	leadimgs[2] = "#optimizacija_img";
	leadimgs[3] = "#komunikacija_img";
	

	var i = 0;
	var rotateItems = leadboxes.length;
	var direction = 0;
	var rotateAuto;
	
	//combination of fades on individual elements within each .lead_content box - passes in direction
	function rotatorfade(direction) {
		if(direction == undefined) direction = 0; //for undefined param
		
		/* first fade out showing elements*/
		$(leadboxes[i % rotateItems] + ' h1').fadeOut('500');
		$(leadboxes[i % rotateItems] + ' h2').fadeOut('500', function(){ //chained animation starts here to avoid animation queue conflicts
			$(leadimgs[i % rotateItems]).fadeOut('100', function(){
				$(leadboxes[i % rotateItems]).hide();
				if (direction == -1){
					i = i+rotateItems-1; //skip over next
					//alert(i);
				}
				else i++; // go forwards
				$(leadboxes[i % rotateItems]).show();
				$("#lead_home").animate({ backgroundColor: bgcolors[i % rotateItems] }, 500, function(){ //animate to next color - chains fadeIns
					$(leadimgs[i % rotateItems]).fadeIn('500', function(){
						$(leadboxes[i % rotateItems] + ' h1').fadeIn('500');
						$(leadboxes[i % rotateItems] + ' h2').fadeIn('500');
					});
				});
			});
		});
	}
	
	//ie6 no fade
	function rotatorfadeIE6(direction){
		if(direction == undefined) direction = 0; //for undefined param
		$(leadboxes[i % rotateItems]).hide();
		if (direction == -1){
			i = i+2; //skip over next
		}
		else i++; // go forwards
		$("#lead_home").animate({ backgroundColor: bgcolors[i % rotateItems] }, 500, function(){
			$(leadboxes[i % rotateItems]).show();
			$(leadboxes[i % rotateItems] +' h1').show();
			$(leadboxes[i % rotateItems] +' h2').show();
		});
		
		
	}
	
	function theRotator() { 
		$('#case_rotator .case_study').css({opacity: 0.0}); 
		$('#case_rotator .case_study:first').css({opacity: 1.0}); 
		setInterval ('rotate()',INTERVAL_TIME); 
	} 

	function rotate() { 
		var current = ($('#case_rotator .show')? $('#case_rotator .show') : $('#case_rotator div.case_study:first')); 
		var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('#case_rotator div.case_study:first') :current.next()) : $('#case_rotator div.case_study:first')); 
		next.css({opacity: 0.0}) .addClass('show') .animate({opacity: 1.0}, TRANSITION_TIME); 
		current.animate({opacity: 0.0}, TRANSITION_TIME) .removeClass('show'); 
	} 
	
	/* start up animations */
	$(document).ready(function(){

		var rotateSection = $('#lead_rotator .lead_content');
	
		
	
		theRotator(); //rotate case study
		
		if(!MSIE6){
			$(leadimgs[i % rotateItems]).fadeIn('500', function(){
				$(leadboxes[i % rotateItems] + ' h1').fadeIn('500');
				$(leadboxes[i % rotateItems] + ' h2').fadeIn('500', function(){
					rotateAuto = setInterval ( rotatorfade, 10000 );  //set auto animation
				});
			});
		}
		
		else {
			$(leadboxes[i % rotateItems]).show();
			$(leadboxes[i % rotateItems] +' h1').show();
			$(leadboxes[i % rotateItems] +' h2').show();
		}
		
		/* onclicks for rotate back and forth - .rotate-controls */
		$(".rotate-controls").click(function() {
			clearInterval(rotateAuto);
			if ($(this).attr('id') == 'left-arrow'){ 
				//swap left-right arrows
				if(!MSIE6){
					$('#left-arrow').css("background-image","url(design/images/homeleftarrow.png)");
					$('#right-arrow').css("background-image","url(design/images/homerightarrow_idle.png)");
					rotatorfade(-1);
				}
				else rotatorfadeIE6(-1);
			}
			else { 
				//swap left-right arrows
				if(!MSIE6){
					$('#left-arrow').css("background-image","url(design/images/homeleftarrow_idle.png)");
					$('#right-arrow').css("background-image","url(design/images/homerightarrow.png)");
					rotatorfade(0);
				}
				else rotatorfadeIE6(0);
			}
			return false;
		});
  });

