/*
function preload() {
	var d = document;
	if (d.images) {
		if(!d.p) d.p = new Array();
		var i, j = d.p.length, a = preload.arguments;
		for(i = 0; i < a.length; i++) {
			if (a[i].indexOf("#") != 0) {
				d.p[j] = new Image;
				d.p[j++].src = a[i];
			}
		}
	}
}

preload(
	'/images/but-apprentice-hover.png',
	'/images/but-apprentice-inactive.png',
	
	'/images/but-elearning-active.png',
	'/images/but-elearning-hover.png',
	
	'/images/but-permanent-active.png',
	'/images/but-permanent-hover.png',
	
	'/images/but-temp-active.png',
	'/images/but-temp-hover.png',
	
	'/images/but-trainee-active.png',
	'/images/but-trainee-hover.png',
	
	'/images/but-training-active.png',
	'/images/but-training-hover.png',
	
	'/images/but-subscribe-hover.png',
	'/images/but-search-hover.png'
);

*/
	
$(window).load(function() {
	
	/*
	
	function rotate( direction ) {
	
		if( direction == undefined ) {
			direction = 1;
		}
		
		if( news_content.hasClass('active') ) { return false; }
		news_content.addClass('active');
		var id = news_content.find( 'ul' ).first().attr( 'id' );
		for( i = 0; i < items; i++ ) {
			if( $(news_items[i]).attr('id') == do_id ) {
				do_id_now = 'small_news_' + ( i + direction );
				if( i > items-2 ) {
					do_id_now = 'small_news_0';
				}
				if( do_id_now == 'small_news_-1' ) {
					do_id_now = 'small_news_' + (items-1);
				}		
			}
		}
		
		news_content.children('li').fadeOut('normal',function() {
			$(this).remove();
			for( i = 0; i < items; i++ ) {
				if( $(news_items[i]).attr('id') == do_id_now ) {
					var temp = $(news_items[i]).clone();
					temp.css( 'display', 'none' );
					news_content.prepend( temp ).children().fadeIn('normal', function() { 
						news_content.removeClass('active');
					});
					do_id = do_id_now;
				}
			}
		});
		
	}
	
	//
	var news_content = $('#news_content ul');
	var news_items = $('#news_items ul li');
	var items = news_items.length;//count items in list
	var do_id = 'small_news_0';
	var do_id_now = '';
	var direction = 0;
	
	var timeout = null
	
	// 
	news_content.children().remove();
	var temp = $(news_items[0]).clone();
	news_content.prepend( temp ).children().fadeIn();
	
	// when you press the left button
	$('#button_left').click( function() {
		rotate(-1);
		clearTimeout(timeout);
		timeout = setInterval( function() {rotate(1)}, 5000 );
	});
	
	// when you press the right button
	$('#button_right').click( function() {
		rotate(1);
		clearTimeout(timeout);
		timeout = setInterval( function() {rotate(1)}, 5000 );
	});
	
	timeout = setInterval( function() {rotate(1)}, 5000 );
	*/
/*
	$("#news_items").animate({ 
        left: "-=300px",
      }, 2000, );
*/	  
	  $(function(){ $("#news_items").liScroll({travelocity: 0.05}); }); 
	
});











