/* this prevents dom flickering, needs to be outside of dom.ready event: */
document.documentElement.className += 'js_active';
/*end dom flickering =) */


jQuery(window).load(function(){
	var autorotate = jQuery("meta[name=autorotate]").attr('content');
	var autorotate_duration = jQuery("meta[name=autorotate_duration]").attr('content');
	
	/*image slider (alternate)*/
	var $slide_images = jQuery('#cu3er img');	
	if ($slide_images.length > 0 && autorotate != "2")
	{	
		if(autorotate_duration == '') autorotate_duration = 5;
	
		$slide_images.not('.current_img img').css({display:"none"});
		$slide_images.filter('.current_img img').css({visibility:"visible"});
		// set the automatic image rotation, number is time between transitions in miliseconds
		interval = setInterval(function() { k_fader("#cu3er img",'1'); }, (parseInt(autorotate_duration) * 1000)); 	
	}
});


	function k_fader($items_to_fade, $next_or_prev)
{	
	var $items = jQuery($items_to_fade);
	var $currentitem = $items.filter(":visible");
	var $new_item;
	var $selector;
	
	$items.css('visibility','visible');

	if($items.length > 1)
	{
		for(i = 0; i < $items.length; i++)
		{
			if($items[i] == $currentitem[0])
			{	
				$selector = $next_or_prev >= 0 ? i != $items.length-1 ? i+1 : 0 : i == 0 ? $items.length-1 : i-1;
				
				$new_item = jQuery($items[$selector]);
				break;
			}
		}
		
		if( $new_item && $new_item.css("display") == "none" )
			{	
				$currentitem.css({zIndex:2});
				$new_item.css({zIndex:3}).fadeIn(1200, function()
				{
					$currentitem.css({display:"none"});
				});
				
			}
	}
}



