


jQuery(document).ready(function($) {

jQuery.fn.tqSlideNews = function( options ) {
		var container		= jQuery(this);
		var containerHeight	= 170
		var containerWidth	= 334;
		var newsElList		= jQuery('.news-latest-item',container);
		var tmpHeight		= 0;
		var counter			= 0;

		jQuery('.news-latest-list',container.parent()).append('<div class="news-inline-box inline-box-'+counter+'"/>');

		newsElList.each(function(){

			var newsEl	= jQuery(this);

			tmpHeight	= tmpHeight + newsEl.outerHeight();

			if( tmpHeight < containerHeight ) {
				newsEl.addClass('container-'+counter);
			} else {
				counter++;
				jQuery('.news-latest-list',container.parent()).append('<div class="news-inline-box inline-box-'+counter+'"/>');
				newsEl.addClass('container-'+counter);
				tmpHeight	= newsEl.outerHeight();
			}
			jQuery('.inline-box-'+counter).append(newsEl);
		});

		jQuery('.news-inline-box',container).wrap('<div class="news-inline-box-wrapper"/>');
		jQuery('.news-inline-box',container)
		jQuery('.news-latest-list',container.parent()).append('<br class="styleClear"/>');

		var childs	= jQuery('.news-inline-box-wrapper',container);

		var containerWidth	= childs.length * containerWidth;
		container.css('width',containerWidth);


}



	var currentNews	= 0;
	var containerWidth	= 334;
	jQuery('.arrow-left').hide();
	jQuery('.news-latest-list').each(function(){
		jQuery(this).tqSlideNews();
	});
	var newsLength	= $('.news-latest-list .news-inline-box-wrapper').length-1;


	jQuery('.arrow-left').click(function(){
		if(currentNews == 0){
			return;
		}
		currentNews--;
		jQuery('.news-latest-list').animate({
				'marginLeft' : containerWidth*(-currentNews)
			},function(){
			if(currentNews == 0 ){
				jQuery('.arrow-left').fadeOut();
			} else {
				jQuery('.arrow-left').fadeIn();
			}
			if(currentNews == newsLength ){
				jQuery('.arrow-right').fadeOut();
			} else {
				jQuery('.arrow-right').fadeIn();
			}
		 });
	});

	jQuery('.arrow-right').click(function(){

		if(currentNews == newsLength){
			return;
		}
		currentNews++;
		jQuery('.news-latest-list').animate({
				'marginLeft' : containerWidth*(-currentNews)
			},function(){
				if(currentNews > 0 ){
					jQuery('.arrow-left').fadeIn();
				} else {
					jQuery('.arrow-left').fadeOut();
				}

				if(currentNews == newsLength ){
					jQuery('.arrow-right').fadeOut();
				} else {
					jQuery('.arrow-right').fadeIn();
				}

		 });
	});
});


//-->


