// JavaScript Document
var main_cur=1;
var hideDelayTimer=null;
var main_page=1;
	
function next_m() {
	clearInterval(hideDelayTimer);
	hideDelayTimer=null;
	var banner=$(".main_news");
	var c=banner.length;
	var next=main_cur+1;
	if(next>c) {
		next=1;
		main_page++;
		if(main_page>3) main_page=1;
		
		next_main_page();		
	}
	
	if(next>1)
	if(main_cur!=next) {
		$(".main_paging:eq("+(next-1)+")").css("background",'url(img/index_news_bg1.jpg)');
		$(".main_paging:eq("+(main_cur-1)+")").css("background",'url(img/index_news_bg.jpg)');
		$(".main_news:eq("+(main_cur-1)+")").css('display','none');
		//$(".main_news:eq("+(next-1)+")").animate({opacity: 0.25, left: '+=50', height: 'toggle'}, 500, function() {});
		$(".main_news:eq("+(next-1)+")").css({'display':'block','opacity':'0'});
		//$(".main_news:eq("+(next-1)+")").fadeIn(500);
		$(".main_news:eq("+(next-1)+")").animate({opacity:1}, 500, function() {});
		
	}
	main_cur=next;	
	if(next>1)	hideDelayTimer = setTimeout(function () {hideDelayTimer = null;	next_m();}, 5000);
}

function next_main_page() {
	$.ajax({
	   type: "POST",
	   url: "ajax/main_news.php",
	   cache: true,
	   data: "page="+main_page,
	   success: function(msg){
		   $('#main_news').html(msg);
		   $(".main_paging").mouseover(function() {
				if (hideDelayTimer) clearTimeout(hideDelayTimer);
				var banner=$(".main_news");
				var c=banner.length;		
				var cur=this.id;
				cur=parseInt(cur.replace("aaa", ""));
				
				if(main_cur!=cur) {
					$(".main_paging:eq("+(cur-1)+")").css("background",'url(img/index_news_bg1.jpg)');
					$(".main_paging:eq("+(main_cur-1)+")").css("background",'url(img/index_news_bg.jpg)');
					$(".main_news:eq("+(main_cur-1)+")").css('display','none');
					$(".main_news:eq("+(cur-1)+")").css({'display':'block','opacity':'0'});
					$(".main_news:eq("+(cur-1)+")").animate({opacity:1}, 10, function() {});
				}
				main_cur=cur;
			}).mouseout(function () {
				if (hideDelayTimer) clearTimeout(hideDelayTimer);
				hideDelayTimer = setTimeout(function () {hideDelayTimer = null;	next_m();}, 5000);
				return false;
			});
			$('.main_news').mouseover(function () {
				if (hideDelayTimer) clearTimeout(hideDelayTimer);
				return false;
			}).mouseout(function () {
				if (hideDelayTimer) clearTimeout(hideDelayTimer);
				hideDelayTimer = setTimeout(function () {hideDelayTimer = null;	next_m();}, 5000);
				return false;
			});
			hideDelayTimer = setTimeout(function () {hideDelayTimer = null;	next_m();}, 5000);
			$(".top_news_small").easyTooltip();
	   }
	});		
}
function next_main_page_prev() {
	clearInterval(hideDelayTimer);
	hideDelayTimer=null;
	main_cur=1;
	main_page--;
	if(main_page<1) main_page=3;
	next_main_page();
}
function next_main_page_next() {
	clearInterval(hideDelayTimer);
	hideDelayTimer=null;
	main_cur=1;
	main_page++;
	if(main_page>3) main_page=1;
	next_main_page();
}


$(document).ready(function() {
	$(".main_paging").mouseover(function() {
		if (hideDelayTimer) clearTimeout(hideDelayTimer);
		var banner=$(".main_news");
		var c=banner.length;		
		var cur=this.id;
		cur=parseInt(cur.replace("aaa", ""));
		
		if(main_cur!=cur) {
			$(".main_paging:eq("+(cur-1)+")").css("background",'url(img/index_news_bg1.jpg)');
			$(".main_paging:eq("+(main_cur-1)+")").css("background",'url(img/index_news_bg.jpg)');
			$(".main_news:eq("+(main_cur-1)+")").css('display','none');
			$(".main_news:eq("+(cur-1)+")").css({'display':'block','opacity':'0'});
			$(".main_news:eq("+(cur-1)+")").animate({opacity:1}, 10, function() {});
		}
		main_cur=cur;
	}).mouseout(function () {
		if (hideDelayTimer) clearTimeout(hideDelayTimer);
		hideDelayTimer = setTimeout(function () {hideDelayTimer = null;	next_m();}, 5000);
		return false;
	});
	
	hideDelayTimer = setTimeout(function () {hideDelayTimer = null;	next_m();}, 5000);
	
	$('.main_news').mouseover(function () {
        if (hideDelayTimer) clearTimeout(hideDelayTimer);
        return false;
    }).mouseout(function () {
        if (hideDelayTimer) clearTimeout(hideDelayTimer);
        hideDelayTimer = setTimeout(function () {hideDelayTimer = null;	next_m();}, 5000);
        return false;
    });	
});
