jQuery.fn.hHeadline = function(settings) {
		settings = jQuery.extend({
			divImg: null,
			divText: null,
			divPager: null,
			timeOut: 1000
		}, settings);		
		
		var hlIdx = 0;
		var hlPrevIdx = -1;
		var hlIntId;
		
		return this.each(function(){
			hlIntId = setTimeout(function(){
			newHeadline(false);
			},0);
			
			$(".headlinesep_main_pic_pager_inactive").click(function(){
				clearTimeout(hlIntId);
				var hlP = jQuery(this);
				hlIdx = $(hlP).attr('id').substr(26);
				hlIntId = setTimeout(function(){
					newHeadline(true);
				},0);
			});
		});
		
		
		function newHeadline(needStop){
			//szöveg
			$.ajax({
		  	cache:false,
		    async:true,
				url: "ajax_headline.php",
				data: {
					type : 'text',
					idx : hlIdx
				},
				success : function(result){
					$(settings.divText).html(result);
					if(hlPrevIdx > -1){
						$(settings.divPager + hlPrevIdx).removeClass('headlinesep_main_pic_pager_active').addClass('headlinesep_main_pic_pager_inactive');
					}
					$(settings.divPager + hlIdx).removeClass('headlinesep_main_pic_pager_inactive').addClass('headlinesep_main_pic_pager_active');
			
					$(settings.divImg).addClass('ajaxloading');
					//kép
					$.ajax({
				  	cache:false,
				    async:true,
						url: "ajax_headline.php",
						data: {
							type : 'img',
							idx : hlIdx
						},
						success : function(result){
							$(settings.divImg).removeClass('ajaxloading');
							$(settings.divImg).html(result);
						}
					});
					
					hlPrevIdx = hlIdx;
			
					hlIdx = hlIdx + 1;
					if(hlIdx >= 4){
						hlIdx = 0;
					}
					if(!needStop){
	  				hlIntId = setTimeout(function(){
						 	newHeadline(false);
						},settings.timeOut);
					}
				}
			});
		};
};
