﻿//新闻图片切换
var _c = _h = 0;
var num=0;
$(function() {
    num = $("#pic img").length;
    //alert(num);
    $('#play > a').click(function() {
        var i = $(this).attr('title') - 1;
        clearInterval(_h);
        _c = i;
        play();
        change(i);
    })
    $("#pic img").hover(function() { clearInterval(_h) }, function() { play() });
    play();
    $('#play > a').css('background-color', '#037294').css('color','white').eq(0).css('background-color', 'white').css('color','black').blur();
});
function play() {
    _h = setInterval("auto()", 3000);
}
function change(i) {
    $('#play > a').css('background-color', '#037294').css('color','white').eq(i).css('background-color', 'white').css('color','black').blur();
    $("#pic img").hide().eq(i).fadeIn(800);
}
function auto() {
    _c = _c > num-2 ? 0 : _c + 1;
    change(_c);
}

//项目切换
$(function(){
    //准备属性
    $("#project-nav li").each(function(i){
        $(this).attr("index",i);
    });
    $("#project-main > div").each(function(i){
        $(this).attr("index",i);
    });
    
    //绑定mouseover
    $("#project-nav li").bind("mouseover",function(){
        var id=$(this).attr("index");
        $("#project-nav li:not([index='" + id + "'])").removeAttr("current").removeClass().addClass("nav");
        $(this).attr("current",1).addClass("nav-a");
        
        $("#project-main > div:not([index='" + id + "'])").hide();
        $("#project-main > div[index='" + id + "']").show();
    });
    
    //触发
    $("#project-nav li:first").trigger("mouseover");
    
    //载入第一个导航
    $("#menu-top li:first").trigger("mouseover");
});