function fixColorBar() {
	var newWidth = $(window).width();
	newWidth = (newWidth/2)-11;
	$("#colorBar").width(newWidth);
	
	newWidth = newWidth /2;
	
	$("#qrWrapper").width(newWidth);
}

$(window).resize(function() {
	fixColorBar();
});

$(document).ready(function() {
	
	fixColorBar();
	
	$(".mainBlok.image .image").css("opacity","0.5");
	$(".mainBlok.image").hover(function(){
		$(this).children(".image").css("opacity","1.0");
	},function(){
		$(this).children(".image").css("opacity","0.5");
	})
	
	
	if($("#mediaWrapper").attr("id") && !$("#cycleBlok").attr("id")){
		$("#mediaWrapper").css("border","none");	
	}
	
	
	$(".mainBlok.image h2 a").textShadow();
	/*$(".mainBlok.image h2 a").hover(function(){
		$(this).textShadowRemove();
	},function(){
		$(this).textShadow();
	})
*/
	$("#absoluteWrapper").css("display","block");
	
	$("#grid").css("opacity","0.2");
	
	var config = {    
	     over: makeTall, 
	     timeout: 500,
	     out: makeShort
	};
	
	
	function makeTall(){
		//hide other submenus
		if($(this).children(".submenu").css("display") =="none"){
			$(".submenu").fadeOut();
			//show submenu
			$(this).children(".submenu").fadeIn();
		}	
	}
	
	function makeShort(){	
		$(this).children(".submenu").fadeOut();
		//$(".submenu").fadeOut();		
	}
	
	$(".menuItem").hoverIntent(config );

	
	$("#blokCycle, .cycleImages").cycle({
		fx: 'scrollLeft',
		pager:  '#nav',
		timeout: 6000,
		before: onBeforeSector,
		pagerAnchorBuilder: function(idx, slide) { 
		     // return selector string for existing anchor 
		        return '#nav li:eq(' + idx + ') a'; 
		}
	});
	
	
	function onBeforeSector(){
	     	if($(this).attr("rel")){
	     		nr=$(this).attr("rel");
	     		nr=nr.replace("img_","callback_");
	     		
	     		$(".callbacks").not("#"+nr).fadeOut(500,function(){
	     			
	     		});
	     		
     			$("#"+nr).delay(500).fadeIn();
     			
	     		
	     	}
	}
	
	// Media / people
	$("#mediaCycle").cycle({
		fx: 'fade',
		timeout: 6000	
	});
	
	// Case
	$("#caseCycle").cycle({
		fx: 'scrollLeft',
		timeout: 6000	
		
	});
	
	// Live
	$(".blocksCycleWrapper").cycle({
		fx: 'scrollUp',
		timeout: 5000	
		
	});
	
	$("div#liveBalk").smoothDivScroll({
		autoScroll: "onstart",
		autoScrollingDirection: "endlessloopright",
		autoScrollInterval: 100,
		autoScrollStep: 100
	});
	
	$("a[rel^='prettyPhoto']").prettyPhoto({
	        animation_speed: 'normal',
	        show_title: false,
	        allow_resize: true,
	        theme: 'pp_default',
	        modal: true,
	        hide_flash: true,
	        social_tools : '',
	        gallery_markup: ''
	    });
});
