$(document).ready(function () {
    var userAgent = navigator.userAgent.toLowerCase();
    $.browser = {
        version: (userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1],
        safari: /webkit/.test(userAgent),
        opera: /opera/.test(userAgent),
        msie: /msie/.test(userAgent) && !/opera/.test(userAgent),
        mozilla: /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent)
    };
    if ($.browser.msie && $.browser.version == "6.0") {
        $("#new1p").css("margin-left", "5px");
        $("#new5ll>ul>li").css("margin-bottom", "-2px");
    }
    var newl = document.getElementById("new5lp");
    if (newl != null) {
        newl.scrollTop = 0;
    }
    $("#new5ll>ul>li[val='1']").attr("keepalive", "1");
    var MyMar = setInterval(newsMove, 3000);
    $("#new5ll>ul>li").bind({
        mouseover: function () {
            clearInterval(MyMar);
            newsMove(this);
        },
        mouseout: function () {
            MyMar = setInterval(newsMove, 3000);
        }
    });
    $("#new5ll>ul>li>div>div>a").bind({
        hover: function () {
            return false;
        }
    });
    $("#n1page>a").bind({
        mouseover: function () {
            n1NowCount = $(this).attr("val");
            n1switch();
            n1State = false;
        },
        mouseout: function () {
            n1State = true;
        }
    });
    if ($("#acont1") != null && $("#acont1").height() < 562) {
        $("#acont1").height(562);
    }
    var aconimg = $("div#acon1 img");
    var acon = $("div#acon1");
    var aconoffset = acon.offset();
    for (var i = 0; i < aconimg.length; i++) {
        var obj = $(aconimg[i]);
        if (obj.width() + obj.offset().left - aconoffset.left > acon.width()) {
            var scale = obj.width() / obj.height()
            obj.width(acon.width() - obj.offset().left + aconoffset.left);
            obj.height(obj.width() / scale);
        }
    }
    $(".n1pic[val=1]").show();
    $(".nipt[val=1]").show();
    n1Count = $("#n1page>a").length;
    window.setInterval(n1switch, 3000);
});
var n1Count;
var n1NowCount=2;
var n1State=true;
function n1switch(){
	if(n1State){
		if(n1NowCount>n1Count){
			n1NowCount=1;
		}
		$("#n1page>a").removeClass("hover");
		$("#n1page>a[val="+n1NowCount+"]").addClass("hover");
		$(".nipt").hide();
		$(".n1pic").hide();
		$(".nipt[val="+n1NowCount+"]").show();
		$(".n1pic[val="+n1NowCount+"]").show();
		n1NowCount++;
	}
}
var lastVal=2;
function newsMove(obj){
	$("#new5ll>ul>li[keepalive='1']").removeClass("hover");
	$("#new5ll>ul>li[keepalive='1']").attr("keepalive","0");
	if(obj!=null){
		lastVal=parseInt($(obj).attr("val"))
		$(obj).addClass("hover");
		$(obj).attr("keepalive","1");
	}else{
		if(lastVal>10){
			lastVal=1;
		}
		$("#new5ll>ul>li[val='"+lastVal+"']").addClass("hover");
		$("#new5ll>ul>li[val='"+lastVal+"']").attr("keepalive","1");
		lastVal++;
	}
	var newl=document.getElementById("new5lp");
	if(newl!=null){
		var nowscr=newl.scrollTop;
		var val=parseInt($("#new5ll>ul>li[keepalive='1']").attr("val"))
		var disscr=(val-1)*262
		newl.scrollTop=disscr;
	}
}
